implement portable static file server and backend process manager for local AI image generation

This commit is contained in:
techjarves committed 2026-06-04 21:18:13 +05:30
1 parent 86f95f5095
commit 4e16a6288a
7 files changed
+177 -146

No files matched your search

@@ -1 +1 @@
import{i as D,t as i}from"./index-DjStOWCE.js";var _;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WINDOW_SUSPENDED="tauri://suspended",r.WINDOW_RESUMED="tauri://resumed",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(_||(_={}));async function l(r,a){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(r,a),await D("plugin:event|unlisten",{event:r,eventId:a})}async function n(r,a,e){var t;const W=typeof e?.target=="string"?{kind:"AnyLabel",label:e.target}:(t=e?.target)!==null&&t!==void 0?t:{kind:"Any"};return D("plugin:event|listen",{event:r,target:W,handler:i(a)}).then(d=>async()=>l(r,d))}export{_ as TauriEvent,n as listen};
import{i as D,t as i}from"./index-BOI9YDBQ.js";var _;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WINDOW_SUSPENDED="tauri://suspended",r.WINDOW_RESUMED="tauri://resumed",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(_||(_={}));async function l(r,a){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(r,a),await D("plugin:event|unlisten",{event:r,eventId:a})}async function n(r,a,e){var t;const W=typeof e?.target=="string"?{kind:"AnyLabel",label:e.target}:(t=e?.target)!==null&&t!==void 0?t:{kind:"Any"};return D("plugin:event|listen",{event:r,target:W,handler:i(a)}).then(d=>async()=>l(r,d))}export{_ as TauriEvent,n as listen};
+121
View File
@@ -0,0 +1,121 @@
(function(){const b=document.createElement("link").relList;if(b&&b.supports&&b.supports("modulepreload"))return;for(const _ of document.querySelectorAll('link[rel="modulepreload"]'))r(_);new MutationObserver(_=>{for(const D of _)if(D.type==="childList")for(const Y of D.addedNodes)Y.tagName==="LINK"&&Y.rel==="modulepreload"&&r(Y)}).observe(document,{childList:!0,subtree:!0});function A(_){const D={};return _.integrity&&(D.integrity=_.integrity),_.referrerPolicy&&(D.referrerPolicy=_.referrerPolicy),_.crossOrigin==="use-credentials"?D.credentials="include":_.crossOrigin==="anonymous"?D.credentials="omit":D.credentials="same-origin",D}function r(_){if(_.ep)return;_.ep=!0;const D=A(_);fetch(_.href,D)}})();function sm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var ws={exports:{}},ti={};var Vd;function z0(){if(Vd)return ti;Vd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function A(r,_,D){var Y=null;if(D!==void 0&&(Y=""+D),_.key!==void 0&&(Y=""+_.key),"key"in _){D={};for(var G in _)G!=="key"&&(D[G]=_[G])}else D=_;return _=D.ref,{$$typeof:f,type:r,key:Y,ref:_!==void 0?_:null,props:D}}return ti.Fragment=b,ti.jsx=A,ti.jsxs=A,ti}var Zd;function T0(){return Zd||(Zd=1,ws.exports=z0()),ws.exports}var c=T0(),Bs={exports:{}},le={};var Kd;function M0(){if(Kd)return le;Kd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),w=Symbol.for("react.activity"),Z=Symbol.iterator;function ce(d){return d===null||typeof d!="object"?null:(d=Z&&d[Z]||d["@@iterator"],typeof d=="function"?d:null)}var $={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,se={};function F(d,z,B){this.props=d,this.context=z,this.refs=se,this.updater=B||$}F.prototype.isReactComponent={},F.prototype.setState=function(d,z){if(typeof d!="object"&&typeof d!="function"&&d!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,d,z,"setState")},F.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function ae(){}ae.prototype=F.prototype;function ue(d,z,B){this.props=d,this.context=z,this.refs=se,this.updater=B||$}var je=ue.prototype=new ae;je.constructor=ue,k(je,F.prototype),je.isPureReactComponent=!0;var Qe=Array.isArray;function Ve(){}var P={H:null,A:null,T:null,S:null},Te=Object.prototype.hasOwnProperty;function Fe(d,z,B){var H=B.ref;return{$$typeof:f,type:d,key:z,ref:H!==void 0?H:null,props:B}}function we(d,z){return Fe(d.type,z,d.props)}function Me(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Je(d){var z={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(B){return z[B]})}var We=/\/+/g;function nt(d,z){return typeof d=="object"&&d!==null&&d.key!=null?Je(""+d.key):z.toString(36)}function $e(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Ve,Ve):(d.status="pending",d.then(function(z){d.status==="pending"&&(d.status="fulfilled",d.value=z)},function(z){d.status==="pending"&&(d.status="rejected",d.reason=z)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,z,B,H,I){var ee=typeof d;(ee==="undefined"||ee==="boolean")&&(d=null);var te=!1;if(d===null)te=!0;else switch(ee){case"bigint":case"string":case"number":te=!0;break;case"object":switch(d.$$typeof){case f:case b:te=!0;break;case E:return te=d._init,x(te(d._payload),z,B,H,I)}}if(te)return I=I(d),te=H===""?"."+nt(d,0):H,Qe(I)?(B="",te!=null&&(B=te.replace(We,"$&/")+"/"),x(I,z,B,"",function(Ut){return Ut})):I!=null&&(Me(I)&&(I=we(I,B+(I.key==null||d&&d.key===I.key?"":(""+I.key).replace(We,"$&/")+"/")+te)),z.push(I)),1;te=0;var qe=H===""?".":H+":";if(Qe(d))for(var Ee=0;Ee<d.length;Ee++)H=d[Ee],ee=qe+nt(H,Ee),te+=x(H,z,B,ee,I);else if(Ee=ce(d),typeof Ee=="function")for(d=Ee.call(d),Ee=0;!(H=d.next()).done;)H=H.value,ee=qe+nt(H,Ee++),te+=x(H,z,B,ee,I);else if(ee==="object"){if(typeof d.then=="function")return x($e(d),z,B,H,I);throw z=String(d),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return te}function O(d,z,B){if(d==null)return d;var H=[],I=0;return x(d,H,"","",function(ee){return z.call(B,ee,I++)}),H}function K(d){if(d._status===-1){var z=d._result;z=z(),z.then(function(B){(d._status===0||d._status===-1)&&(d._status=1,d._result=B)},function(B){(d._status===0||d._status===-1)&&(d._status=2,d._result=B)}),Line truncated
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
`+ht+e+el}var il=!1;function ol(e,t){if(!e||il)return"";il=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var N=function(){throw Error()};if(Object.defineProperty(N.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(N,[])}catch(S){var v=S}Reflect.construct(e,[],N)}else{try{N.call()}catch(S){v=S}e.call(N.prototype)}}else{try{throw Error()}catch(S){v=S}(N=e())&&typeof N.catch=="function"&&N.catch(function(){})}}catch(S){if(S&&v&&typeof S.stack=="string")return[S.stack,v.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var n=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");n&&n.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var i=a.DetermineComponentFrameRoot(),u=i[0],s=i[1];if(u&&s){var o=u.split(`
`),g=s.split(`
`);for(n=a=0;a<o.length&&!o[a].includes("DetermineComponentFrameRoot");)a++;for(;n<g.length&&!g[n].includes("DetermineComponentFrameRoot");)n++;if(a===o.length||n===g.length)for(a=o.length-1,n=g.length-1;1<=a&&0<=n&&o[a]!==g[n];)n--;for(;1<=a&&0<=n;a--,n--)if(o[a]!==g[n]){if(a!==1||n!==1)do if(a--,n--,0>n||o[a]!==g[n]){var j=`
`+o[a].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),j}while(1<=a&&0<=n);break}}}finally{il=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ie(l):""}function T(e,t){switch(e.tag){case 26:case 27:case 5:return Ie(e.type);case 16:return Ie("Lazy");case 13:return e.child!==t&&t!==null?Ie("Suspense Fallback"):Ie("Suspense");case 19:return Ie("SuspenseList");case 0:case 15:return ol(e.type,!1);case 11:return ol(e.type.render,!1);case 1:return ol(e.type,!0);case 31:return Ie("Activity");default:return""}}function C(e){try{var t="",l=null;do t+=T(e,l),l=e,e=e.return;while(e);return t}catch(a){return`
Error generating stack: `+a.message+`
`+a.stack}}var q=Object.prototype.hasOwnProperty,Q=f.unstable_scheduleCallback,Ze=f.unstable_cancelCallback,zt=f.unstable_shouldYield,wt=f.unstable_requestPaint,ge=f.unstable_now,Bt=f.unstable_getCurrentPriorityLevel,ui=f.unstable_ImmediatePriority,ci=f.unstable_UserBlockingPriority,_a=f.unstable_NormalPriority,_u=f.unstable_LowPriority,L=f.unstable_IdlePriority,be=f.log,Ge=f.unstable_setDisableYieldValue,tt=null,Be=null;function _t(e){if(typeof be=="function"&&Ge(e),Be&&typeof Be.setStrictMode=="function")try{Be.setStrictMode(tt,e)}catch{}}var rt=Math.clz32?Math.clz32:Se,ja=Math.log,yt=Math.LN2;function Se(e){return e>>>=0,e===0?32:31-(ja(e)/yt|0)|0}var me=256,Re=262144,ve=4194304;function Le(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function De(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,i=e.suspendedLanes,u=e.pingedLanes;e=e.warmLanes;var s=a&134217727;return s!==0?(a=s&~i,a!==0?n=Le(a):(u&=s,u!==0?n=Le(u):l||(l=s&~e,l!==0&&(n=Le(l))))):(s=a&~i,s!==0?n=Le(s):u!==0?n=Le(u):l||(l=a&~e,l!==0&&(n=Le(l)))),n===0?0:t!==0&&t!==n&&(t&i)===0&&(i=n&-n,l=t&-t,i>=l||i===32&&(l&4194048)!==0)?t:n}function ft(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Rt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tl(){var e=ve;return ve<<=1,(ve&62914560)===0&&(ve=4194304),e}function on(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function rn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function dm(e,t,l,a,n,i){var u=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var s=e.entanglements,o=e.expirationTimes,g=e.hiddenUpdates;for(l=u&~l;0<l;){var j=31-rt(l),N=1<<j;s[j]=0,o[j]=-1;var v=g[j];if(v!==null)for(g[j]=null,j=0;j<v.length;j++){var S=v[j];S!==null&&(S.lane&=-536870913)}l&=~N}a!==0&&Js(e,a,0),i!==0&&n===0&&e.tag!==0&&(e.suspendedLanes|=i&~(u&~t))}function Js(e,t,l){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-rt(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|l&261930}function $s(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var a=31-rt(l),n=1<<a;n&t|e[a]&t&&(e[a]|=t),l&=~n}}function Fs(e,t){var l=t&-t;return l=(l&42)!==0?1:ju(l),(l&(e.suspendedLanes|t))!==0?0:l}function ju(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function zu(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ws(){var e=O.p;return e!==0?e:(e=window.event,e===void 0?32:Gd(e.type))}function Is(e,t){var l=O.p;try{return O.p=e,t()}finally{O.p=l}}var Dl=Math.random().toString(36).slice(2),pt="__reactFiber$"+Dl,Mt="__reactProps$"+Dl,za="__reactContainer$"+Dl,Tu="__reactEvents$"+Dl,mm="__reactListeners$"+Dl,hm="__reactHandles$"+Dl,Ps="__reactResources$"+Dl,dn="__reactMarker$"+Dl;function Mu(e){delete e[pt],delete e[Mt],delete e[Tu],delete e[mm],delete e[hm]}function Ta(e){var t=e[pt];if(t)return t;for(var l=e.parentNode;l;){if(t=l[za]||l[pt]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=_d(e);e!==null;){if(l=e[pt])return l;e=_d(e)}return t}e=l,l=e.parentNode}return null}function Ma(e){if(e=e[pt]||e[za]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function mn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ea(e){var t=e[Ps];return t||(t=e[Ps]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function dt(e){e[dn]=!0}var ef=new Set,tf={};function la(e,t){Na(e,t),Na(e+"Capture",t)}function Na(e,t){for(tf[e]=t,e=0;e<t.length;e++)ef.add(t[e])}var ym=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\ Line truncated
`).replace(Zh,"")}function dd(e,t){return t=rd(t),rd(e)===t}function Oe(e,t,l,a,n,i){switch(l){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Da(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Da(e,""+a);break;case"className":fi(e,"class",a);break;case"tabIndex":fi(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":fi(e,l,a);break;case"style":rf(e,a,i);break;case"data":if(t!=="object"){fi(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||l!=="href")){e.removeAttribute(l);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(l);break}a=ri(""+a),e.setAttribute(l,a);break;case"action":case"formAction":if(typeof a=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof i=="function"&&(l==="formAction"?(t!=="input"&&Oe(e,t,"name",n.name,n,null),Oe(e,t,"formEncType",n.formEncType,n,null),Oe(e,t,"formMethod",n.formMethod,n,null),Oe(e,t,"formTarget",n.formTarget,n,null)):(Oe(e,t,"encType",n.encType,n,null),Oe(e,t,"method",n.method,n,null),Oe(e,t,"target",n.target,n,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(l);break}a=ri(""+a),e.setAttribute(l,a);break;case"onClick":a!=null&&(e.onclick=dl);break;case"onScroll":a!=null&&re("scroll",e);break;case"onScrollEnd":a!=null&&re("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(l=a.__html,l!=null){if(n.children!=null)throw Error(r(60));e.innerHTML=l}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}l=ri(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,""+a):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":a===!0?e.setAttribute(l,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,a):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(l,a):e.removeAttribute(l);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(l):e.setAttribute(l,a);break;case"popover":re("beforetoggle",e),re("toggle",e),si(e,"popover",a);break;case"xlinkActuate":rl(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":rl(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":rl(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":rl(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":rl(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":rl(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":rl(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":rl(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":rl(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":si(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Sm.get(l)||l,si(e,l,a))}}function ps(e,t,l,a,n,i){switch(l){case"style":rf(e,a,i);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(l=a.__html,l!=null){if(n.children!=null)throw Error(r(60));e.innerHTML=l}}break;case"children":typeof a=="string"?Da(e,a):(typeof a=="number"||typeof a=="bigint")&&Da(e,""+a);break;case"onScroll":a!=null&&re("scroll",e);break;case"onScrollEnd":a!=null&&re("scrollend",e);break;case"onClick":a!=null&&(e.onclick=dl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
<!-- Stars -->
<circle cx="80" cy="100" r="1.5" fill="#ffffff" opacity="0.6"/>
<circle cx="160" cy="60" r="1" fill="#ffffff" opacity="0.5"/>
<circle cx="280" cy="120" r="2" fill="#ffffff" opacity="0.8"/>
<circle cx="360" cy="80" r="1.5" fill="#ffffff" opacity="0.4"/>
<circle cx="440" cy="150" r="1" fill="#ffffff" opacity="0.7"/>
<circle cx="400" cy="280" r="2" fill="#ffffff" opacity="0.9"/>
<circle cx="100" cy="300" r="1.5" fill="#ffffff" opacity="0.5"/>
<!-- Moon -->
<circle cx="256" cy="220" r="90" fill="url(#moonGrad)" />
<circle cx="226" cy="190" r="80" fill="#0F172A" />
`):k.includes("cat")||k.includes("kitten")||k.includes("feline")?(F="#4F46E5",ae="#7C3AED",je="Stylized Cat Portrait",ue=`
<!-- Cat head & ears -->
<polygon points="176,280 146,160 216,210" fill="#312E81" />
<polygon points="336,280 366,160 296,210" fill="#312E81" />
<circle cx="256" cy="270" r="80" fill="#4338CA" />
<!-- Eyes -->
<ellipse cx="226" cy="260" rx="14" ry="8" fill="#10B981" />
<ellipse cx="286" cy="260" rx="14" ry="8" fill="#10B981" />
<circle cx="226" cy="260" r="4" fill="#000" />
<circle cx="286" cy="260" r="4" fill="#000" />
<!-- Nose & Whiskers -->
<polygon points="256,285 248,275 264,275" fill="#F43F5E" />
<line x1="226" y1="290" x2="166" y2="280" stroke="#E2E8F0" stroke-width="2" />
<line x1="226" y1="295" x2="156" y2="295" stroke="#E2E8F0" stroke-width="2" />
<line x1="286" y1="290" x2="346" y2="280" stroke="#E2E8F0" stroke-width="2" />
<line x1="286" y1="295" x2="356" y2="295" stroke="#E2E8F0" stroke-width="2" />
`):k.includes("dog")||k.includes("puppy")||k.includes("canine")?(F="#D97706",ae="#B45309",je="Friendly Dog Portrait",ue=`
<!-- Dog head & floppy ears -->
<ellipse cx="166" cy="260" rx="20" ry="60" fill="#78350F" />
<ellipse cx="346" cy="260" rx="20" ry="60" fill="#78350F" />
<circle cx="256" cy="250" r="70" fill="#92400E" />
<ellipse cx="256" cy="280" rx="40" ry="30" fill="#D97706" />
<!-- Eyes -->
<circle cx="226" cy="230" r="10" fill="#1E293B" />
<circle cx="286" cy="230" r="10" fill="#1E293B" />
<circle cx="222" cy="226" r="3" fill="#ffffff" />
<circle cx="282" cy="226" r="3" fill="#ffffff" />
<!-- Nose -->
<ellipse cx="256" cy="275" rx="16" ry="10" fill="#1E293B" />
`):k.includes("city")||k.includes("cyberpunk")||k.includes("tokyo")||k.includes("neon")?(F="#111827",ae="#311042",je="Neon Cyberpunk Skyline",ue=`
<!-- Skyline -->
<rect x="60" y="160" width="80" height="352" fill="#1F2937" opacity="0.9"/>
<rect x="180" y="100" width="100" height="412" fill="#111827" />
<rect x="320" y="200" width="120" height="312" fill="#1F2937" opacity="0.85"/>
<rect x="100" y="240" width="110" height="272" fill="#374151" opacity="0.6"/>
<!-- Neon details -->
<line x1="230" y1="100" x2="230" y2="40" stroke="#EC4899" stroke-width="3" />
<rect x="200" y="140" width="60" height="15" fill="#10B981" opacity="0.7"/>
<rect x="200" y="170" width="60" height="15" fill="#10B981" opacity="0.7"/>
<rect x="200" y="200" width="60" height="15" fill="#3B82F6" opacity="0.7"/>
<rect x="70" y="200" width="15" height="100" fill="#F59E0B" opacity="0.5"/>
<rect x="340" y="250" width="20" height="150" fill="#EF4444" opacity="0.6"/>
`):k.includes("car")||k.includes("vehicle")||k.includes("supercar")?(F="#DC2626",ae="#991B1B",je="Futuristic Concept Car",ue=`
<!-- Road / Perspective grid -->
<line x1="256" y1="350" x2="0" y2="512" stroke="#4B5563" stroke-width="3" />
<line x1="256" y1="350" x2="512" y2="512" stroke="#4B5563" stroke-width="3" />
<!-- Car body -->
<polygon points="126,380 256,330 386,380 346,440 166,440" fill="#EF4444" />
<polygon points="176,370 256,340 336,370 326,390 186,390" fill="#1E293B" opacity="0.9" />
<!-- Headlights -->
<polygon points="136,410 176,415 166,425 136,420" fill="#FBBF24" />
<polygon points="376,410 336,415 346,425 376,420" fill="#FBBF24" />
<!-- Wheels -->
<ellipse cx="156" cy="440" rx="30" ry="15" fill="#111" />
<ellipse cx="356" cy="440" rx="30" ry="15" fill="#111" />
`):(F="#06B6D4",ae="#0891B2",je="Abstract Creative Concept",ue=`
<path d="M0,256 C150,150 350,350 512,256 L512,512 L0,512 Z" fill="#0891B2" opacity="0.4" />
<path d="M0,350 C200,200 300,450 512,350 L512,512 L0,512 Z" fill="#0E7490" opacity="0.6" />
<circle cx="380" cy="180" r="50" fill="#F59E0B" opacity="0.8" />
`);const Qe=`
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
<defs>
<linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="${F}" />
<stop offset="100%" stop-color="${ae}" />
</linearGradient>
<linearGradient id="moonGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#FEF08A" />
<stop offset="100%" stop-color="#FDE047" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="512" height="512" fill="url(#bgGrad)" />
<!-- Shapes -->
${ue}
<!-- Premium UI Overlay Frame -->
<rect x="20" y="20" width="472" height="472" fill="none" stroke="#ffffff" stroke-width="1.5" opacity="0.15" rx="8"/>
<!-- Prompt & Details text -->
<rect x="40" y="410" width="432" height="62" fill="#0F172A" opacity="0.85" rx="6" />
<text x="60" y="435" fill="#F1F5F9" font-family="system-ui, -apple-system, sans-serif" font-size="13" font-weight="bold">${je}</text>
<text x="60" y="455" fill="#94A3B8" font-family="system-ui, -apple-system, sans-serif" font-size="11">Seed: ${se} • Steps: ${E.steps} • Scale: ${E.cfg_scale}</text>
</svg>
`,P=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Qe)))}`,Te=parseFloat(((Date.now()-G)/1e3).toFixed(1));return{image:P,seed:E.seed,duration_sec:Te}},Z=!!E.image,ce={prompt:E.prompt,negative_prompt:E.negative_prompt||"",n:1,size:`${E.width}x${E.height}`,response_format:"b64_json",steps:E.steps,cfg_scale:E.cfg_scale,seed:E.seed,sample_method:E.sampler};Z&&(ce.init_images=[E.image],ce.denoising_strength=E.denoising_strength);try{const $=await fetch(`${y}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:Y,body:JSON.stringify(ce)});if($.ok){const k=await $.json(),se=k?.data?.[0]?.b64_json??k?.images?.[0];if(se){const F=parseFloat(((Date.now()-G)/1e3).toFixed(1));return{image:`data:image/png;base64,${se}`,seed:k.data?.[0]?.seed??E.seed,duration_sec:F}}}else{let k=`Generation failed (HTTP ${$.status})`;try{const se=await $.json();(se?.detail||se?.error?.message)&&(k=se.detail||se.error.message)}catch{}throw new Error(k)}}catch($){if($.name==="AbortError"||$.message.startsWith("Generation failed"))throw $;console.warn("Could not reach local server. Falling back to simulation mode.",$)}return await w()}async function Ky(f,b,A){if(f instanceof File){const G=f;if(!Sa())throw new Error("File import requires the local image generator server.");return await Jy(G,b,A),{response:"Model imported successfully"}}if(Al()){const{listen:G}=await Oy(async()=>{const{listen:y}=await import("./event-CvjXGmc1.js");return{listen:y}},[]);let R=null;b&&(R=await G("import-progress",y=>{b(y.payload)}));try{return{response:await xa("import_model_file",{sourcePath:f}),unlisten:R}}catch(y){throw R&&R(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const _=40;for(let G=1;G<=_;G++){if(A?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(w=>setTimeout(w,150));const R=G/_*100,y=40+Math.sin(G)*5+Math.random()*2,E=(_-G)*.15;b&&b({filename:r,progress:R,speed_mb_s:y,eta_secs:E,status:"Copying to USB..."})}const D=localStorage.getItem("imported-models"),Y=D?JSON.parse(D):[];return Y.includes(r)||(Y.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(Y))),{response:"Model imported successfully"}}function Jy(f,b,A){return new Promise((r,_)=>{const D=new XMLHttpRequest,Y=Date.now();let G=!1;D.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),D.setRequestHeader("Content-Type","application/octet-stream");const R=()=>{G=!0,D.abort()};A&&(A.aborted?R():A.addEventListener("abort",R,{once:!0})),D.upload.onprogress=y=>{if(!y.lengthComputable||!b)return;const E=Math.max(.1,(Date.now()-Y)/1e3),w=y.loaded/E,Z=Math.max(0,y.total-y.loaded);b({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:w/(1024*1024),eta_secs:Z/Math.max(1,w),status:"Copying to models folder..."})},D.onload=()=>{let y={};try{y=JSON.parse(D.responseText||"{}")}catch{}D.status>=200&&D.status<300&&y.ok!==!1?(b&&b({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):_(new Error(y.error||`Import failed (HTTP ${D.status})`))},D.onerror=()=>_(new Error("Import failed while uploading the file.")),D.onabort=()=>_(new DOMException(G?"Import cancelled by user.":"Import aborted.","AbortError")),D.send(f)})}async function $y(f){if(Al())return await xa("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const _=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),D=await _.json();if(!_.ok)throw new Error(D.error||"Failed to delete model file");return D}catch(_){throw console.error("Failed to delete model via local API:",_),_}const A=localStorage.getItem("imported-models");let r=A?JSON.parse(A):[];return r=r.filter(_=>ii(_).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function rm(){const b="http://127.0.0.1:8080";try{return(await fetch(`${b}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Fy(f=30){const b=Al()||Sa()?f:3;for(let A=0;A<b;A++){let r=!1;if(Sa()?r=!!(await ba()).ready:r=await rm(),r)return!0;await new Promise(_=>setTimeout(_,500))}return!1}async function Wy(f){try{return await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f})})).json()}catch(b){return console.error("Failed to start model download:",b),{ok:!1,error:b.message}}}async function Iy(){try{return await(await fetch("/api/cancel-download",{method:"POST"})).json()}catch(f){return console.error("Failed to cancel model download:",f),{ok:!1,error:f.message}}}async function um(){try{return await(await fetch("/api/download-progress")).json()}catch(f){return console.error("Failed to get download progress:",f),{active:!1,error:f.m Line truncated
Seed: ${f.seed}${f.duration_sec?`
Time: ${f.duration_sec.toFixed(1)}s`:""}`,children:[c.jsx("img",{src:f.url,className:"gallery-thumb",alt:"Thumbnail",loading:"lazy",decoding:"async"}),A&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Ys,{size:14})})]})});function t1({prompt:f,setPrompt:b,negativePrompt:A,setNegativePrompt:r,constraints:_,setConstraints:D,activeModel:Y,generatedImages:G,setGeneratedImages:R,isGenerating:y,setIsGenerating:E,generationProgress:w,setGenerationProgress:Z,setActiveTab:ce,inputImage:$,setInputImage:k,showAlert:se=async({message:ae})=>window.alert(ae),showConfirm:F=async({message:ae})=>window.confirm(ae)}){const[ae,ue]=U.useState(null),[je,Qe]=U.useState(null),[Ve,P]=U.useState(null),[Te,Fe]=U.useState(!1),[we,Me]=U.useState(0),[Je,We]=U.useState(0),[nt,$e]=U.useState(0),[x,O]=U.useState(""),[K,fe]=U.useState(!1),[de,d]=U.useState(!1),[z,B]=U.useState(!1),[H,I]=U.useState(null),[ee,te]=U.useState(null),[qe,Ee]=U.useState(!1),[Ut,xt]=U.useState([]),ht=U.useRef(null),el=U.useRef(null),Ie=U.useRef(null),il=()=>{el.current.click()},ol=L=>{const be=L.target.files[0];if(be){const Ge=new FileReader;Ge.onload=()=>{k(Ge.result)},Ge.readAsDataURL(be)}},T=L=>{L.stopPropagation(),k(null),el.current&&(el.current.value="")},C=async()=>{if(!f.trim())return;te(null),B(!0),I(null);let L=!1;try{const Se=await ba();if(Se&&Se.settings){const me=Se.settings,Re=me.model?me.model.split(/[\\/]/).pop():null,ve=Y?Y.split(/[\\/]/).pop():null;(Re!==ve||parseInt(me.steps)!==parseInt(_.steps)||Math.abs(parseFloat(me.cfgScale)-parseFloat(_.cfgScale))>.05||me.sampler!==_.sampler||parseInt(me.threads)!==parseInt(_.threads)||!!me.useGpu!=(_.useGpu!==!1)||(me.backendType||(me.useGpu===!1?"cpu":"auto"))!==(_.backendType||(_.useGpu===!1?"cpu":"auto")))&&(L=!0)}else L=!0}catch{L=!0}if(L)try{console.log("Settings out of sync, restarting backend..."),await Qs(Y,_);let Se=!1,me=null;for(let Re=0;Re<240;Re++){const ve=await ba();if(ve.loading&&I({progress:ve.loading.progress||0,phase:ve.loading.phase||"Loading model...",speed:ve.loading.speed||"",current:ve.loading.current||0,total:ve.loading.total||0,backendMode:ve.loading.backendMode||ve.settings?.backendMode||"",device:ve.loading.device||ve.settings?.backendDevice||""}),ve.ready){Se=!0;break}if(ve.error){me=ve.error;break}if(!ve.running&&Re>3){me="The backend process terminated immediately on startup.";break}await new Promise(Le=>setTimeout(Le,500))}if(!Se)throw new Error(me||"Backend server failed to start after applying configuration changes.")}catch(Se){console.error("Failed to restart backend:",Se),te(Se.message||"Failed to sync settings with backend."),B(!1);return}B(!1),I(null),ht.current&&clearInterval(ht.current),E(!0),Z(0),Me(0),$e(0),O(""),fe(!1),Ee(!1),P(null),ue(null);const be=(_.width>=1024?140:35)*.04,Ge=_.width>=1024?140:35,tt=(_.backendType||(_.useGpu===!1?"cpu":"auto"))!=="cpu";let Be=tt?be:Ge,_t=!1,rt=0,ja=0,yt=0;We(Math.round(_.steps*Be)),ht.current=setInterval(async()=>{yt++,Me(yt);try{const Se=await Py();if(Se&&Se.active){const me=Se.decoding||!1;Ee(me);const Re=me?Se.steps||_.steps||20:Se.step||0,ve=Se.steps||_.steps||20,Le=me?"":Se.speed||"";$e(Re),O(me?"decoding":Le);let De=0;me?De=99:ve>0&&(De=Math.round(Re/ve*100)),De=Math.min(99,De),Z(Rt=>Math.max(Rt,De));let ft=0;if(me)ft=3;else{const Rt=parseFloat(Le);if(!isNaN(Rt)&&Rt>0){const tl=Math.max(0,ve-Re);Le.includes("it/s")?ft=tl/Rt:Le.includes("s/it")&&(ft=tl*Rt)}else{const tl=tt?be:Ge;ft=Math.max(0,(ve-Re)*tl)}}if(tt&&!_t){const Rt=Le.includes("it/s")&&numericSpeed<.2,tl=Le.includes("s/it")&&numericSpeed>5;(Rt||tl)&&(_t=!0,fe(!0))}We(Math.round(ft))}else Z(me=>Math.min(15,me+1)),We(me=>Math.max(1,me-1))}catch(Se){console.warn("Failed to get generation progress, running simulation fallback:",Se),tt&&!_t&&yt>_.steps*be*1.3&&(_t=!0,fe(!0),Be=Ge,rt=yt,ja=Math.min(95,Math.round(yt/(_.steps*be)*100)));let me=Math.min(_.steps-1,Math.floor(yt/Be)),Re=_.steps*Be;if(yt>=Re){const De=Math.ceil(yt/Math.max(.5,me));Be=Math.max(Be+15,De+15),Re=_.steps*Be,me=Math.min(_.steps-1,Math.floor(yt/Be))}$e(me);const ve=Math.max(1,Re-yt);We(Math.round(ve));let Le=0;if(_t){const De=99-ja,ft=Re-rt;if(ft>0){const Rt=Math.min(1,(yt-rt)/ft);if(Rt<.85)Le=Math.round(ja+Rt*De);else{const tl=(yt-(rt+ft*.85))/(Be*2),on=1-Math.exp(-tl);Le=Math.min(99,Math.round(ja+.85*De+.14*De*on))}}else Le=99}else if(yt<Re*.85)Le=Math.round(yt/Re*100);else{const De=(yt-Re*.85)/(Be*2),ft=1-Math.exp(-De);Le=Math.min(99,Math.round(85+14*ft))}Z(De=>Math.max(De,Le))}},1e3);try{Ie.current=new AbortController;const Se=await Zy(f,A,_,Y,$,De=>Z(ft=>Math.max(ft,De)),Ie.current.signal);ht.current&&clearInterval(ht.current),Z(100),$e(_.steps),We(0),O("");const me={prompt:f,negativePrompt:A,seed:Se.seed,steps:_.steps,cfgScale:_.cfgScale,width:_.width,height:_.height,sampler:_.sampler,model:Y,duration_sec:Se.duration_sec,timestamp:new Date().toLocaleTimeString(),inputImage:!!$};let Re=null,ve=null;try{if(Re=await ky(Se.image,me),ve=Re.url,!ve)throw new Error("The local serverLine truncated
${Ze}
Update the UI status anyway?`,confirmLabel:"Update UI"})&&(b(T),r(!0)):await Y({title:"Backend Not Running",message:`C++ backend server is not running on port 8080.
To run locally, start:
${Ze}
Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(T),r(!1));return}se(T),ae({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:T,backendMode:"",backendBinary:"",device:""});try{const Q=await Qs(T,_);console.log(Q);let Ze=!1,zt=null;for(let wt=0;wt<240;wt++){const ge=await ba();if(ge.loading&&ae({progress:ge.loading.progress||0,phase:ge.loading.phase||"Loading model...",speed:ge.loading.speed||"",current:ge.loading.current||0,total:ge.loading.total||0,model:ge.loading.model||T,backendMode:ge.loading.backendMode||ge.settings?.backendMode||"",backendBinary:ge.loading.backendBinary||ge.settings?.backendBinary||"",device:ge.loading.device||ge.settings?.backendDevice||""}),ge.ready){Ze=!0;break}if(ge.error){zt=ge.error;break}if(!ge.running&&wt>3){zt="The backend process terminated immediately on startup.";break}await new Promise(Bt=>setTimeout(Bt,500))}if(Ze)ae(wt=>({...wt||{},progress:100,phase:"Model ready",speed:"",current:wt?.current||0,total:wt?.total||0,model:T})),b(T),r(!0);else throw new Error(zt||"Model server failed to respond on port 8080.")}catch(Q){console.error("Failed to load model:",Q),D({title:"Model Load Failed",message:Q.message||String(Q),danger:!0})}finally{setTimeout(()=>ae(null),800),se(null)}},Ut=async()=>{const T=$e;x(null),await xt(),T&&await Ee(T)},xt=async()=>{if(Me)return;Je(!0),nt({progress:10,phase:"Stopping backend process..."});const T=setInterval(async()=>{try{const C=await ba();C.unloading?.active?nt({progress:C.unloading.progress||50,phase:C.unloading.phase||"Unloading model..."}):nt(q=>({progress:Math.min(95,q.progress+10),phase:q.phase||"Unloading model..."}))}catch{}},300);try{await Ks(),nt({progress:100,phase:"Model unloaded"}),b(null),x(null),r(!1)}catch(C){console.error(C),D({title:"Unload Failed",message:C.message||String(C),danger:!0})}finally{clearInterval(T),setTimeout(()=>{Je(!1),nt({progress:0,phase:""})},500)}},ht=async T=>{if(await Y({title:"Delete Model?",message:`Delete "${T}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await $y(T),await B(),f===T&&await xt()}catch(C){console.error("Failed to delete model:",C),D({title:"Delete Failed",message:C.message||String(C),danger:!0})}},el=async(T,C)=>{const q=new AbortController;we(q),je(0),Ve({filename:C,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Ky(T,Q=>{je(Math.round(Q.progress)),Ve({filename:Q.filename,speed:Q.speed_mb_s.toFixed(1),eta:Math.round(Q.eta_secs),status:Q.status})},q.signal),await B()}catch(Q){console.error("Import failed:",Q),Q.name!=="AbortError"&&D({title:"Import Failed",message:Q.message||String(Q),danger:!0})}finally{je(null),we(null)}},Ie=()=>{Fe&&Fe.abort()},il=T=>{const C=T.target.files[0];C&&el(C,C.name),T.target.value=""},ol=!!y;return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Model Manager"}),c.jsx("p",{className:"workspace-subtitle",children:"Manage local files and download recommended weights directly to your local models folder."})]}),f&&c.jsx("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-primary)",background:"var(--md-sys-color-primary-container)",color:"var(--md-sys-color-on-primary-container)"},children:c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[c.jsxs("div",{children:[c.jsxs("h4",{style:{fontWeight:700},children:["Active Model: ",f]}),c.jsx("p",{style:{fontSize:"0.85rem",marginTop:"2px",opacity:.9},children:"The local C++ stable-diffusion server is running. Real-time telemetry is displaying performance status in the top bar."}),(O.backendMode||O.backendDevice||O.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[O.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:["Loaded on ",O.backendMode]})]}),O.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendDevice})}),O.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:xt,disabled:Me||k!==null,children:[Me?c.jsx(ta,{className:"progress-spinner",size:16}):c.jsx(ai,{size:16}),c.jsx("span",{children:Me?"Unloading":"Unload Server"})]})]})}),Me&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-error)",marginTop:"16px"},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"8px"},children:"Unloading Model"}),c.jsxs("div",{className:"model-progress-section",style:{margin:"8px 0 0 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsx("span",{children:We.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round(We.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",chi Line truncated
Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){We(!0);try{await Hy(we.map(q=>q.id)),await qe()}catch(q){D({title:"Cleanup Failed",message:q.message||String(q),danger:!0})}finally{We(!1)}}},[we,qe,D,_]);U.useEffect(()=>{async function T(){const C=await Xy();O(C)}T()},[]),U.useEffect(()=>{se?localStorage.setItem("active-model",se):localStorage.removeItem("active-model")},[se]),U.useEffect(()=>{let T=null;async function C(){const q=await ba();if(!!q.ready){T&&clearInterval(T);const Ze=localStorage.getItem("active-model");if(Ze)F(Ze),ue(!0);else{try{if(q&&q.settings&&q.settings.model){const zt=q.settings.model.split(/[\\/]/).pop();F(zt)}}catch{}ue(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const zt=localStorage.getItem("active-model");zt&&(F(zt),ue(!1))}}return C(),T=setInterval(C,2e3),()=>{T&&clearInterval(T)}},[]),U.useEffect(()=>{async function T(){try{const q=await qy();I(Q=>Q.cpu_usage===q.cpu_usage&&Q.ram_used_gb===q.ram_used_gb&&Q.ram_total_gb===q.ram_total_gb&&Q.gpu_name===q.gpu_name&&Q.vram_used_gb===q.vram_used_gb&&Q.vram_total_gb===q.vram_total_gb?Q:q)}catch{}}T();const C=setInterval(T,1500);return()=>clearInterval(C)},[]),U.useEffect(()=>{if(se){const T=se.toLowerCase();T.includes("flux")||T.includes("schnell")?te(C=>({...C,steps:4,cfgScale:1,width:1024,height:1024})):T.includes("lightning")||T.includes("turbo")?te(C=>({...C,steps:4,cfgScale:1.5,width:1024,height:1024})):T.includes("sd15")?te(C=>({...C,steps:25,cfgScale:7,width:512,height:512})):T.includes("sd35")?te(C=>({...C,steps:20,cfgScale:4.5,width:1024,height:1024})):te(C=>({...C,steps:20,cfgScale:7,width:512,height:512}))}},[se]);const xt=U.useMemo(()=>{switch(R){case"generator":return c.jsx(l1,{prompt:E,setPrompt:w,negativePrompt:Z,setNegativePrompt:ce,constraints:ee,setConstraints:te,activeModel:se,generatedImages:x,setGeneratedImages:O,isGenerating:K,setIsGenerating:fe,generationProgress:de,setGenerationProgress:d,setActiveTab:y,inputImage:$,setInputImage:k,showAlert:D,showConfirm:_});case"models":return c.jsx(i1,{activeModel:se,setActiveModel:F,serverRunning:ae,setServerRunning:ue,constraints:ee,showAlert:D,showConfirm:_});case"constraints":return c.jsx(s1,{constraints:ee,setConstraints:te,activeModel:se,specs:z,backendOptions:Ve});default:return null}},[R,E,Z,ee,se,x,K,de,$,ae,z,Ve,D,_]),ht=U.useMemo(()=>c.jsx(Ey,{activeTab:R,setActiveTab:y,specs:z}),[R,z]),el=U.useCallback(async()=>{if(!(!ae||je)){Qe(!0);try{await Ks(),ue(!1),F(null)}catch(T){console.error("Failed to stop server:",T),D({title:"Stop Server Failed",message:T.message||String(T),danger:!0})}finally{Qe(!1)}}},[ae,je,D]),Ie=[...Te?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...Te?.issues||[]],il=we.reduce((T,C)=>T+Number(C.sizeBytes||0),0),ol=!!(Te&&(Ie.length>0||we.length>0));return c.jsxs("div",{className:"app-container",children:[ht,c.jsxs("div",{className:"main-content",children:[c.jsx(Ay,{telemetry:H,serverRunning:ae,activeModel:se,onStopServer:el,isStoppingServer:je,theme:Y,setTheme:G}),ol&&c.jsxs("div",{className:`m3-card readiness-card ${Te?.stale||Ie.length>0?"readiness-card-warning":""}`,children:[c.jsxs("div",{className:"readiness-header",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"m3-card-title",style:{marginBottom:"4px"},children:Te?.stale?"Restart Required":Ie.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:Te?.stale?`Running server build: ${Te.build||"unknown"}`:Ie.length>0?"Local AI Image Generator found setup items that may need attention.":`${we.length} temporary item${we.length===1?"":"s"} can be cleaned (${ni(il)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:qe,disabled:Je,children:Je?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:Ee,children:nt?"Copied":"Copy Diagnostics"}),we.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:Ut,disabled:Je,children:["Clean ",ni(il)]})]})]}),Ie.length>0&&c.jsx("div",{className:"readiness-issues",children:Ie.slice(0,4).map(T=>c.jsx("span",{children:T},T))}),we.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:we.slice(0,3).map(T=>c.jsxs("span",{title:T.path,children:[T.name," · ",T.size," · ",T.reason]},T.id))})]}),xt]}),b&&c.jsx("div",{className:"app-dialog-backdrop",role:"presentation",children:c.jsxs("div",{className:"app-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"app-dialog-title",children:[c.jsx("h3",{id:"app-dialog-title",className:"app-dialog-title",children:b.title}),c.jsx("p",{className:"app-dialog-message",children:b.message}),c.jsxs("div",{className:"app-dialog-actions",children:[b.type==="confirm"&&c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>r(!1),children:b.cancelLabel}),c.jsx("button",{className:`m3-btn ${b.danger?"m3-btn-error":"m3-btn-fLine truncated
-120
View File
@@ -1,120 +0,0 @@
(function(){const b=document.createElement("link").relList;if(b&&b.supports&&b.supports("modulepreload"))return;for(const j of document.querySelectorAll('link[rel="modulepreload"]'))r(j);new MutationObserver(j=>{for(const A of j)if(A.type==="childList")for(const Y of A.addedNodes)Y.tagName==="LINK"&&Y.rel==="modulepreload"&&r(Y)}).observe(document,{childList:!0,subtree:!0});function N(j){const A={};return j.integrity&&(A.integrity=j.integrity),j.referrerPolicy&&(A.referrerPolicy=j.referrerPolicy),j.crossOrigin==="use-credentials"?A.credentials="include":j.crossOrigin==="anonymous"?A.credentials="omit":A.credentials="same-origin",A}function r(j){if(j.ep)return;j.ep=!0;const A=N(j);fetch(j.href,A)}})();function sm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Us={exports:{}},Pn={};var Vd;function z0(){if(Vd)return Pn;Vd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function N(r,j,A){var Y=null;if(A!==void 0&&(Y=""+A),j.key!==void 0&&(Y=""+j.key),"key"in j){A={};for(var G in j)G!=="key"&&(A[G]=j[G])}else A=j;return j=A.ref,{$$typeof:f,type:r,key:Y,ref:j!==void 0?j:null,props:A}}return Pn.Fragment=b,Pn.jsx=N,Pn.jsxs=N,Pn}var Zd;function T0(){return Zd||(Zd=1,Us.exports=z0()),Us.exports}var c=T0(),ws={exports:{}},ae={};var Kd;function M0(){if(Kd)return ae;Kd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),V=Symbol.iterator;function ee(d){return d===null||typeof d!="object"?null:(d=V&&d[V]||d["@@iterator"],typeof d=="function"?d:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F=Object.assign,re={};function I(d,z,B){this.props=d,this.context=z,this.refs=re,this.updater=B||k}I.prototype.isReactComponent={},I.prototype.setState=function(d,z){if(typeof d!="object"&&typeof d!="function"&&d!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,d,z,"setState")},I.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function ne(){}ne.prototype=I.prototype;function ce(d,z,B){this.props=d,this.context=z,this.refs=re,this.updater=B||k}var Ge=ce.prototype=new ne;Ge.constructor=ce,F(Ge,I.prototype),Ge.isPureReactComponent=!0;var Ze=Array.isArray;function Xe(){}var $={H:null,A:null,T:null,S:null},je=Object.prototype.hasOwnProperty;function ot(d,z,B){var H=B.ref;return{$$typeof:f,type:d,key:z,ref:H!==void 0?H:null,props:B}}function qe(d,z){return ot(d.type,z,d.props)}function Me(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Ke(d){var z={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(B){return z[B]})}var $e=/\/+/g;function tt(d,z){return typeof d=="object"&&d!==null&&d.key!=null?Ke(""+d.key):z.toString(36)}function Je(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Xe,Xe):(d.status="pending",d.then(function(z){d.status==="pending"&&(d.status="fulfilled",d.value=z)},function(z){d.status==="pending"&&(d.status="rejected",d.reason=z)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,z,B,H,P){var te=typeof d;(te==="undefined"||te==="boolean")&&(d=null);var le=!1;if(d===null)le=!0;else switch(te){case"bigint":case"string":case"number":le=!0;break;case"object":switch(d.$$typeof){case f:case b:le=!0;break;case D:return le=d._init,x(le(d._payload),z,B,H,P)}}if(le)return P=P(d),le=H===""?"."+tt(d,0):H,Ze(P)?(B="",le!=null&&(B=le.replace($e,"$&/")+"/"),x(P,z,B,"",function(ct){return ct})):P!=null&&(Me(P)&&(P=qe(P,B+(P.key==null||d&&d.key===P.key?"":(""+P.key).replace($e,"$&/")+"/")+le)),z.push(P)),1;le=0;var Ue=H===""?".":H+":";if(Ze(d))for(var ze=0;ze<d.length;ze++)H=d[ze],te=Ue+tt(H,ze),le+=x(H,z,B,te,P);else if(ze=ee(d),typeof ze=="function")for(d=ze.call(d),ze=0;!(H=d.next()).done;)H=H.value,te=Ue+tt(H,ze++),le+=x(H,z,B,te,P);else if(te==="object"){if(typeof d.then=="function")return x(Je(d),z,B,H,P);throw z=String(d),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return le}function O(d,z,B){if(d==null)return d;var H=[],P=0;return x(d,H,"","",function(te){return z.call(B,te,P++)}),H}function K(d){if(d._status===-1){var z=d._result;z=z(),z.then(function(B){(d._status===0||d._status===-1)&&(d._status=1,d._result=B)},function(B){(d._status===0||d._status===-1)&&(d._status=2,d._result=B)}),Line truncated
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
`+wt+e+Al}var al=!1;function sl(e,t){if(!e||al)return"";al=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var E=function(){throw Error()};if(Object.defineProperty(E.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(E,[])}catch(S){var v=S}Reflect.construct(e,[],E)}else{try{E.call()}catch(S){v=S}e.call(E.prototype)}}else{try{throw Error()}catch(S){v=S}(E=e())&&typeof E.catch=="function"&&E.catch(function(){})}}catch(S){if(S&&v&&typeof S.stack=="string")return[S.stack,v.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var n=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");n&&n.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var i=a.DetermineComponentFrameRoot(),u=i[0],s=i[1];if(u&&s){var o=u.split(`
`),g=s.split(`
`);for(n=a=0;a<o.length&&!o[a].includes("DetermineComponentFrameRoot");)a++;for(;n<g.length&&!g[n].includes("DetermineComponentFrameRoot");)n++;if(a===o.length||n===g.length)for(a=o.length-1,n=g.length-1;1<=a&&0<=n&&o[a]!==g[n];)n--;for(;1<=a&&0<=n;a--,n--)if(o[a]!==g[n]){if(a!==1||n!==1)do if(a--,n--,0>n||o[a]!==g[n]){var _=`
`+o[a].replace(" at new "," at ");return e.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",e.displayName)),_}while(1<=a&&0<=n);break}}}finally{al=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?rt(l):""}function T(e,t){switch(e.tag){case 26:case 27:case 5:return rt(e.type);case 16:return rt("Lazy");case 13:return e.child!==t&&t!==null?rt("Suspense Fallback"):rt("Suspense");case 19:return rt("SuspenseList");case 0:case 15:return sl(e.type,!1);case 11:return sl(e.type.render,!1);case 1:return sl(e.type,!0);case 31:return rt("Activity");default:return""}}function C(e){try{var t="",l=null;do t+=T(e,l),l=e,e=e.return;while(e);return t}catch(a){return`
Error generating stack: `+a.message+`
`+a.stack}}var q=Object.prototype.hasOwnProperty,Q=f.unstable_scheduleCallback,He=f.unstable_cancelCallback,zt=f.unstable_shouldYield,st=f.unstable_requestPaint,ge=f.unstable_now,sn=f.unstable_getCurrentPriorityLevel,ni=f.unstable_ImmediatePriority,ii=f.unstable_UserBlockingPriority,L=f.unstable_NormalPriority,ve=f.unstable_LowPriority,we=f.unstable_IdlePriority,pt=f.log,Tt=f.unstable_setDisableYieldValue,Bt=null,dt=null;function Rt(e){if(typeof pt=="function"&&Tt(e),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(Bt,e)}catch{}}var Ee=Math.clz32?Math.clz32:Qe,Te=Math.log,xe=Math.LN2;function Qe(e){return e>>>=0,e===0?32:31-(Te(e)/xe|0)|0}var ye=256,lt=262144,Be=4194304;function We(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function _t(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,i=e.suspendedLanes,u=e.pingedLanes;e=e.warmLanes;var s=a&134217727;return s!==0?(a=s&~i,a!==0?n=We(a):(u&=s,u!==0?n=We(u):l||(l=s&~e,l!==0&&(n=We(l))))):(s=a&~i,s!==0?n=We(s):u!==0?n=We(u):l||(l=a&~e,l!==0&&(n=We(l)))),n===0?0:t!==0&&t!==n&&(t&i)===0&&(i=n&-n,l=t&-t,i>=l||i===32&&(l&4194048)!==0)?t:n}function fl(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Su(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ks(){var e=Be;return Be<<=1,(Be&62914560)===0&&(Be=4194304),e}function xu(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function fn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function dm(e,t,l,a,n,i){var u=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var s=e.entanglements,o=e.expirationTimes,g=e.hiddenUpdates;for(l=u&~l;0<l;){var _=31-Ee(l),E=1<<_;s[_]=0,o[_]=-1;var v=g[_];if(v!==null)for(g[_]=null,_=0;_<v.length;_++){var S=v[_];S!==null&&(S.lane&=-536870913)}l&=~E}a!==0&&Js(e,a,0),i!==0&&n===0&&e.tag!==0&&(e.suspendedLanes|=i&~(u&~t))}function Js(e,t,l){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-Ee(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|l&261930}function $s(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var a=31-Ee(l),n=1<<a;n&t|e[a]&t&&(e[a]|=t),l&=~n}}function Ws(e,t){var l=t&-t;return l=(l&42)!==0?1:_u(l),(l&(e.suspendedLanes|t))!==0?0:l}function _u(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ju(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Fs(){var e=O.p;return e!==0?e:(e=window.event,e===void 0?32:Gd(e.type))}function Is(e,t){var l=O.p;try{return O.p=e,t()}finally{O.p=l}}var Dl=Math.random().toString(36).slice(2),gt="__reactFiber$"+Dl,Et="__reactProps$"+Dl,_a="__reactContainer$"+Dl,zu="__reactEvents$"+Dl,mm="__reactListeners$"+Dl,hm="__reactHandles$"+Dl,Ps="__reactResources$"+Dl,on="__reactMarker$"+Dl;function Tu(e){delete e[gt],delete e[Et],delete e[zu],delete e[mm],delete e[hm]}function ja(e){var t=e[gt];if(t)return t;for(var l=e.parentNode;l;){if(t=l[_a]||l[gt]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=_d(e);e!==null;){if(l=e[gt])return l;e=_d(e)}return t}e=l,l=e.parentNode}return null}function za(e){if(e=e[gt]||e[_a]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function rn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ta(e){var t=e[Ps];return t||(t=e[Ps]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function mt(e){e[on]=!0}var ef=new Set,tf={};function la(e,t){Ma(e,t),Ma(e+"Capture",t)}function Ma(e,t){for(tf[e]=t,e=0;e<t.length;e++)ef.add(t[e])}var ym=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\ Line truncated
`).replace(Zh,"")}function dd(e,t){return t=rd(t),rd(e)===t}function Ce(e,t,l,a,n,i){switch(l){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Na(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Na(e,""+a);break;case"className":ci(e,"class",a);break;case"tabIndex":ci(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ci(e,l,a);break;case"style":rf(e,a,i);break;case"data":if(t!=="object"){ci(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||l!=="href")){e.removeAttribute(l);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(l);break}a=fi(""+a),e.setAttribute(l,a);break;case"action":case"formAction":if(typeof a=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof i=="function"&&(l==="formAction"?(t!=="input"&&Ce(e,t,"name",n.name,n,null),Ce(e,t,"formEncType",n.formEncType,n,null),Ce(e,t,"formMethod",n.formMethod,n,null),Ce(e,t,"formTarget",n.formTarget,n,null)):(Ce(e,t,"encType",n.encType,n,null),Ce(e,t,"method",n.method,n,null),Ce(e,t,"target",n.target,n,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(l);break}a=fi(""+a),e.setAttribute(l,a);break;case"onClick":a!=null&&(e.onclick=rl);break;case"onScroll":a!=null&&oe("scroll",e);break;case"onScrollEnd":a!=null&&oe("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(l=a.__html,l!=null){if(n.children!=null)throw Error(r(60));e.innerHTML=l}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}l=fi(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,""+a):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":a===!0?e.setAttribute(l,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,a):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(l,a):e.removeAttribute(l);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(l):e.setAttribute(l,a);break;case"popover":oe("beforetoggle",e),oe("toggle",e),ui(e,"popover",a);break;case"xlinkActuate":ol(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":ol(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":ol(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":ol(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":ol(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":ol(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":ol(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":ol(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":ol(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":ui(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Sm.get(l)||l,ui(e,l,a))}}function ys(e,t,l,a,n,i){switch(l){case"style":rf(e,a,i);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(l=a.__html,l!=null){if(n.children!=null)throw Error(r(60));e.innerHTML=l}}break;case"children":typeof a=="string"?Na(e,a):(typeof a=="number"||typeof a=="bigint")&&Na(e,""+a);break;case"onScroll":a!=null&&oe("scroll",e);break;case"onScrollEnd":a!=null&&oe("scrollend",e);break;case"onClick":a!=null&&(e.onclick=rl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
<!-- Stars -->
<circle cx="80" cy="100" r="1.5" fill="#ffffff" opacity="0.6"/>
<circle cx="160" cy="60" r="1" fill="#ffffff" opacity="0.5"/>
<circle cx="280" cy="120" r="2" fill="#ffffff" opacity="0.8"/>
<circle cx="360" cy="80" r="1.5" fill="#ffffff" opacity="0.4"/>
<circle cx="440" cy="150" r="1" fill="#ffffff" opacity="0.7"/>
<circle cx="400" cy="280" r="2" fill="#ffffff" opacity="0.9"/>
<circle cx="100" cy="300" r="1.5" fill="#ffffff" opacity="0.5"/>
<!-- Moon -->
<circle cx="256" cy="220" r="90" fill="url(#moonGrad)" />
<circle cx="226" cy="190" r="80" fill="#0F172A" />
`):k.includes("cat")||k.includes("kitten")||k.includes("feline")?(re="#4F46E5",I="#7C3AED",ce="Stylized Cat Portrait",ne=`
<!-- Cat head & ears -->
<polygon points="176,280 146,160 216,210" fill="#312E81" />
<polygon points="336,280 366,160 296,210" fill="#312E81" />
<circle cx="256" cy="270" r="80" fill="#4338CA" />
<!-- Eyes -->
<ellipse cx="226" cy="260" rx="14" ry="8" fill="#10B981" />
<ellipse cx="286" cy="260" rx="14" ry="8" fill="#10B981" />
<circle cx="226" cy="260" r="4" fill="#000" />
<circle cx="286" cy="260" r="4" fill="#000" />
<!-- Nose & Whiskers -->
<polygon points="256,285 248,275 264,275" fill="#F43F5E" />
<line x1="226" y1="290" x2="166" y2="280" stroke="#E2E8F0" stroke-width="2" />
<line x1="226" y1="295" x2="156" y2="295" stroke="#E2E8F0" stroke-width="2" />
<line x1="286" y1="290" x2="346" y2="280" stroke="#E2E8F0" stroke-width="2" />
<line x1="286" y1="295" x2="356" y2="295" stroke="#E2E8F0" stroke-width="2" />
`):k.includes("dog")||k.includes("puppy")||k.includes("canine")?(re="#D97706",I="#B45309",ce="Friendly Dog Portrait",ne=`
<!-- Dog head & floppy ears -->
<ellipse cx="166" cy="260" rx="20" ry="60" fill="#78350F" />
<ellipse cx="346" cy="260" rx="20" ry="60" fill="#78350F" />
<circle cx="256" cy="250" r="70" fill="#92400E" />
<ellipse cx="256" cy="280" rx="40" ry="30" fill="#D97706" />
<!-- Eyes -->
<circle cx="226" cy="230" r="10" fill="#1E293B" />
<circle cx="286" cy="230" r="10" fill="#1E293B" />
<circle cx="222" cy="226" r="3" fill="#ffffff" />
<circle cx="282" cy="226" r="3" fill="#ffffff" />
<!-- Nose -->
<ellipse cx="256" cy="275" rx="16" ry="10" fill="#1E293B" />
`):k.includes("city")||k.includes("cyberpunk")||k.includes("tokyo")||k.includes("neon")?(re="#111827",I="#311042",ce="Neon Cyberpunk Skyline",ne=`
<!-- Skyline -->
<rect x="60" y="160" width="80" height="352" fill="#1F2937" opacity="0.9"/>
<rect x="180" y="100" width="100" height="412" fill="#111827" />
<rect x="320" y="200" width="120" height="312" fill="#1F2937" opacity="0.85"/>
<rect x="100" y="240" width="110" height="272" fill="#374151" opacity="0.6"/>
<!-- Neon details -->
<line x1="230" y1="100" x2="230" y2="40" stroke="#EC4899" stroke-width="3" />
<rect x="200" y="140" width="60" height="15" fill="#10B981" opacity="0.7"/>
<rect x="200" y="170" width="60" height="15" fill="#10B981" opacity="0.7"/>
<rect x="200" y="200" width="60" height="15" fill="#3B82F6" opacity="0.7"/>
<rect x="70" y="200" width="15" height="100" fill="#F59E0B" opacity="0.5"/>
<rect x="340" y="250" width="20" height="150" fill="#EF4444" opacity="0.6"/>
`):k.includes("car")||k.includes("vehicle")||k.includes("supercar")?(re="#DC2626",I="#991B1B",ce="Futuristic Concept Car",ne=`
<!-- Road / Perspective grid -->
<line x1="256" y1="350" x2="0" y2="512" stroke="#4B5563" stroke-width="3" />
<line x1="256" y1="350" x2="512" y2="512" stroke="#4B5563" stroke-width="3" />
<!-- Car body -->
<polygon points="126,380 256,330 386,380 346,440 166,440" fill="#EF4444" />
<polygon points="176,370 256,340 336,370 326,390 186,390" fill="#1E293B" opacity="0.9" />
<!-- Headlights -->
<polygon points="136,410 176,415 166,425 136,420" fill="#FBBF24" />
<polygon points="376,410 336,415 346,425 376,420" fill="#FBBF24" />
<!-- Wheels -->
<ellipse cx="156" cy="440" rx="30" ry="15" fill="#111" />
<ellipse cx="356" cy="440" rx="30" ry="15" fill="#111" />
`):(re="#06B6D4",I="#0891B2",ce="Abstract Creative Concept",ne=`
<path d="M0,256 C150,150 350,350 512,256 L512,512 L0,512 Z" fill="#0891B2" opacity="0.4" />
<path d="M0,350 C200,200 300,450 512,350 L512,512 L0,512 Z" fill="#0E7490" opacity="0.6" />
<circle cx="380" cy="180" r="50" fill="#F59E0B" opacity="0.8" />
`);const Ge=`
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
<defs>
<linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="${re}" />
<stop offset="100%" stop-color="${I}" />
</linearGradient>
<linearGradient id="moonGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#FEF08A" />
<stop offset="100%" stop-color="#FDE047" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="512" height="512" fill="url(#bgGrad)" />
<!-- Shapes -->
${ne}
<!-- Premium UI Overlay Frame -->
<rect x="20" y="20" width="472" height="472" fill="none" stroke="#ffffff" stroke-width="1.5" opacity="0.15" rx="8"/>
<!-- Prompt & Details text -->
<rect x="40" y="410" width="432" height="62" fill="#0F172A" opacity="0.85" rx="6" />
<text x="60" y="435" fill="#F1F5F9" font-family="system-ui, -apple-system, sans-serif" font-size="13" font-weight="bold">${ce}</text>
<text x="60" y="455" fill="#94A3B8" font-family="system-ui, -apple-system, sans-serif" font-size="11">Seed: ${F} • Steps: ${y.steps} • Scale: ${y.cfg_scale}</text>
</svg>
`;return{image:`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Ge)))}`,seed:y.seed,duration_sec:3}},U=!!y.image,V={prompt:y.prompt,negative_prompt:y.negative_prompt||"",n:1,size:`${y.width}x${y.height}`,response_format:"b64_json",steps:y.steps,cfg_scale:y.cfg_scale,seed:y.seed,sample_method:y.sampler};U&&(V.init_images=[y.image],V.denoising_strength=y.denoising_strength);try{const ee=await fetch(`${R}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:Y,body:JSON.stringify(V)});if(ee.ok){const k=await ee.json(),F=k?.data?.[0]?.b64_json??k?.images?.[0];if(F)return{image:`data:image/png;base64,${F}`,seed:k.data?.[0]?.seed??y.seed,duration_sec:4.5}}else{let k=`Generation failed (HTTP ${ee.status})`;try{const F=await ee.json();(F?.detail||F?.error?.message)&&(k=F.detail||F.error.message)}catch{}throw new Error(k)}}catch(ee){if(ee.name==="AbortError"||ee.message.startsWith("Generation failed"))throw ee;console.warn("Could not reach local server. Falling back to simulation mode.",ee)}return await D()}async function Ky(f,b,N){if(f instanceof File){const G=f;if(!Sa())throw new Error("File import requires the local image generator server.");return await Jy(G,b,N),{response:"Model imported successfully"}}if(Nl()){const{listen:G}=await Oy(async()=>{const{listen:y}=await import("./event-DJ2yZWXo.js");return{listen:y}},[]);let R=null;b&&(R=await G("import-progress",y=>{b(y.payload)}));try{return{response:await xa("import_model_file",{sourcePath:f}),unlisten:R}}catch(y){throw R&&R(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const j=40;for(let G=1;G<=j;G++){if(N?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(U=>setTimeout(U,150));const R=G/j*100,y=40+Math.sin(G)*5+Math.random()*2,D=(j-G)*.15;b&&b({filename:r,progress:R,speed_mb_s:y,eta_secs:D,status:"Copying to USB..."})}const A=localStorage.getItem("imported-models"),Y=A?JSON.parse(A):[];return Y.includes(r)||(Y.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(Y))),{response:"Model imported successfully"}}function Jy(f,b,N){return new Promise((r,j)=>{const A=new XMLHttpRequest,Y=Date.now();let G=!1;A.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),A.setRequestHeader("Content-Type","application/octet-stream");const R=()=>{G=!0,A.abort()};N&&(N.aborted?R():N.addEventListener("abort",R,{once:!0})),A.upload.onprogress=y=>{if(!y.lengthComputable||!b)return;const D=Math.max(.1,(Date.now()-Y)/1e3),U=y.loaded/D,V=Math.max(0,y.total-y.loaded);b({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:U/(1024*1024),eta_secs:V/Math.max(1,U),status:"Copying to models folder..."})},A.onload=()=>{let y={};try{y=JSON.parse(A.responseText||"{}")}catch{}A.status>=200&&A.status<300&&y.ok!==!1?(b&&b({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):j(new Error(y.error||`Import failed (HTTP ${A.status})`))},A.onerror=()=>j(new Error("Import failed while uploading the file.")),A.onabort=()=>j(new DOMException(G?"Import cancelled by user.":"Import aborted.","AbortError")),A.send(f)})}async function $y(f){if(Nl())return await xa("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const j=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),A=await j.json();if(!j.ok)throw new Error(A.error||"Failed to delete model file");return A}catch(j){throw console.error("Failed to delete model via local API:",j),j}const N=localStorage.getItem("imported-models");let r=N?JSON.parse(N):[];return r=r.filter(j=>ai(j).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function rm(){const b="http://127.0.0.1:8080";try{return(await fetch(`${b}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Wy(f=30){const b=Nl()||Sa()?f:3;for(let N=0;N<b;N++){let r=!1;if(Sa()?r=!!(await ba()).ready:r=await rm(),r)return!0;await new Promise(j=>setTimeout(j,500))}return!1}async function Fy(f){try{return await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f})})).json()}catch(b){return console.error("Failed to start model download:",b),{ok:!1,error:b.message}}}async function Iy(){try{return await(await fetch("/api/cancel-download",{method:"POST"})).json()}catch(f){return console.error("Failed to cancel model download:",f),{ok:!1,error:f.message}}}async function um(){try{return await(await fetch("/api/download-progress")).json()}catch(f){return console.error("Failed to get download progress:",f),{active:!1,error:f.message}}}async function Py(){try{return await(await fetch("/api/generation-progress")).json()}catch(f){ret Line truncated
Seed: ${f.seed}`,children:[c.jsx("img",{src:f.url,className:"gallery-thumb",alt:"Thumbnail",loading:"lazy",decoding:"async"}),N&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Ls,{size:14})})]})});function t1({prompt:f,setPrompt:b,negativePrompt:N,setNegativePrompt:r,constraints:j,setConstraints:A,activeModel:Y,generatedImages:G,setGeneratedImages:R,isGenerating:y,setIsGenerating:D,generationProgress:U,setGenerationProgress:V,setActiveTab:ee,inputImage:k,setInputImage:F,showAlert:re=async({message:ne})=>window.alert(ne),showConfirm:I=async({message:ne})=>window.confirm(ne)}){const[ne,ce]=w.useState(null),[Ge,Ze]=w.useState(null),[Xe,$]=w.useState(null),[je,ot]=w.useState(!1),[qe,Me]=w.useState(0),[Ke,$e]=w.useState(0),[tt,Je]=w.useState(0),[x,O]=w.useState(""),[K,se]=w.useState(!1),[de,d]=w.useState(!1),[z,B]=w.useState(!1),[H,P]=w.useState(null),[te,le]=w.useState(null),[Ue,ze]=w.useState([]),ct=w.useRef(null),yt=w.useRef(null),wt=w.useRef(null),Al=()=>{yt.current.click()},rt=L=>{const ve=L.target.files[0];if(ve){const we=new FileReader;we.onload=()=>{F(we.result)},we.readAsDataURL(ve)}},al=L=>{L.stopPropagation(),F(null),yt.current&&(yt.current.value="")},sl=async()=>{if(!f.trim())return;le(null),B(!0),P(null);let L=!1;try{const Te=await ba();if(Te&&Te.settings){const xe=Te.settings,Qe=xe.model?xe.model.split(/[\\/]/).pop():null,ye=Y?Y.split(/[\\/]/).pop():null;(Qe!==ye||parseInt(xe.steps)!==parseInt(j.steps)||Math.abs(parseFloat(xe.cfgScale)-parseFloat(j.cfgScale))>.05||xe.sampler!==j.sampler||parseInt(xe.threads)!==parseInt(j.threads)||!!xe.useGpu!=(j.useGpu!==!1)||(xe.backendType||(xe.useGpu===!1?"cpu":"auto"))!==(j.backendType||(j.useGpu===!1?"cpu":"auto")))&&(L=!0)}else L=!0}catch{L=!0}if(L)try{console.log("Settings out of sync, restarting backend..."),await Xs(Y,j);let Te=!1,xe=null;for(let Qe=0;Qe<240;Qe++){const ye=await ba();if(ye.loading&&P({progress:ye.loading.progress||0,phase:ye.loading.phase||"Loading model...",speed:ye.loading.speed||"",current:ye.loading.current||0,total:ye.loading.total||0,backendMode:ye.loading.backendMode||ye.settings?.backendMode||"",device:ye.loading.device||ye.settings?.backendDevice||""}),ye.ready){Te=!0;break}if(ye.error){xe=ye.error;break}if(!ye.running&&Qe>3){xe="The backend process terminated immediately on startup.";break}await new Promise(lt=>setTimeout(lt,500))}if(!Te)throw new Error(xe||"Backend server failed to start after applying configuration changes.")}catch(Te){console.error("Failed to restart backend:",Te),le(Te.message||"Failed to sync settings with backend."),B(!1);return}B(!1),P(null),ct.current&&clearInterval(ct.current),D(!0),V(0),Me(0),Je(0),O(""),se(!1),$(null),ce(null);const ve=(j.width>=1024?140:35)*.04,we=j.width>=1024?140:35,pt=(j.backendType||(j.useGpu===!1?"cpu":"auto"))!=="cpu";let Tt=pt?ve:we,Bt=!1,dt=0,Rt=0,Ee=0;$e(Math.round(j.steps*Tt)),ct.current=setInterval(async()=>{Ee++,Me(Ee);try{const Te=await Py();if(Te&&Te.active){const xe=Te.step||0,Qe=Te.steps||j.steps||20,ye=Te.speed||"";Je(xe),O(ye);let lt=0;Qe>0&&(lt=Math.round(xe/Qe*100)),lt=Math.min(99,lt),V(_t=>Math.max(_t,lt));let Be=0;const We=parseFloat(ye);if(!isNaN(We)&&We>0){const _t=Math.max(0,Qe-xe);ye.includes("it/s")?Be=_t/We:ye.includes("s/it")&&(Be=_t*We)}else{const _t=pt?ve:we;Be=Math.max(0,(Qe-xe)*_t)}if(pt&&!Bt){const _t=ye.includes("it/s")&&We<.2,fl=ye.includes("s/it")&&We>5;(_t||fl)&&(Bt=!0,se(!0))}$e(Math.round(Be))}else V(xe=>Math.min(15,xe+1)),$e(xe=>Math.max(1,xe-1))}catch(Te){console.warn("Failed to get generation progress, running simulation fallback:",Te),pt&&!Bt&&Ee>j.steps*ve*1.3&&(Bt=!0,se(!0),Tt=we,dt=Ee,Rt=Math.min(95,Math.round(Ee/(j.steps*ve)*100)));let xe=Math.min(j.steps-1,Math.floor(Ee/Tt)),Qe=j.steps*Tt;if(Ee>=Qe){const Be=Math.ceil(Ee/Math.max(.5,xe));Tt=Math.max(Tt+15,Be+15),Qe=j.steps*Tt,xe=Math.min(j.steps-1,Math.floor(Ee/Tt))}Je(xe);const ye=Math.max(1,Qe-Ee);$e(Math.round(ye));let lt=0;if(Bt){const Be=99-Rt,We=Qe-dt;if(We>0){const _t=Math.min(1,(Ee-dt)/We);if(_t<.85)lt=Math.round(Rt+_t*Be);else{const fl=(Ee-(dt+We*.85))/(Tt*2),Su=1-Math.exp(-fl);lt=Math.min(99,Math.round(Rt+.85*Be+.14*Be*Su))}}else lt=99}else if(Ee<Qe*.85)lt=Math.round(Ee/Qe*100);else{const Be=(Ee-Qe*.85)/(Tt*2),We=1-Math.exp(-Be);lt=Math.min(99,Math.round(85+14*We))}V(Be=>Math.max(Be,lt))}},1e3);try{wt.current=new AbortController;const Te=await Zy(f,N,j,Y,k,Be=>V(We=>Math.max(We,Be)),wt.current.signal);ct.current&&clearInterval(ct.current),V(100),Je(j.steps),$e(0),O("");const xe={prompt:f,negativePrompt:N,seed:Te.seed,steps:j.steps,cfgScale:j.cfgScale,width:j.width,height:j.height,sampler:j.sampler,model:Y,duration_sec:Te.duration_sec,timestamp:new Date().toLocaleTimeString(),inputImage:!!k};let Qe=null,ye=null;try{if(Qe=await Xy(Te.image,xe),ye=Qe.url,!ye)throw new Error("The local server saved the image but did not return a file URL.")}catch(Be){throw console.error("Generated image could not be saved:",Be),new Error(`Image generated but could not be saved to ULine truncated
${He}
Update the UI status anyway?`,confirmLabel:"Update UI"})&&(b(T),r(!0)):await Y({title:"Backend Not Running",message:`C++ backend server is not running on port 8080.
To run locally, start:
${He}
Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(T),r(!1));return}re(T),ne({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:T,backendMode:"",backendBinary:"",device:""});try{const Q=await Xs(T,j);console.log(Q);let He=!1,zt=null;for(let st=0;st<240;st++){const ge=await ba();if(ge.loading&&ne({progress:ge.loading.progress||0,phase:ge.loading.phase||"Loading model...",speed:ge.loading.speed||"",current:ge.loading.current||0,total:ge.loading.total||0,model:ge.loading.model||T,backendMode:ge.loading.backendMode||ge.settings?.backendMode||"",backendBinary:ge.loading.backendBinary||ge.settings?.backendBinary||"",device:ge.loading.device||ge.settings?.backendDevice||""}),ge.ready){He=!0;break}if(ge.error){zt=ge.error;break}if(!ge.running&&st>3){zt="The backend process terminated immediately on startup.";break}await new Promise(sn=>setTimeout(sn,500))}if(He)ne(st=>({...st||{},progress:100,phase:"Model ready",speed:"",current:st?.current||0,total:st?.total||0,model:T})),b(T),r(!0);else throw new Error(zt||"Model server failed to respond on port 8080.")}catch(Q){console.error("Failed to load model:",Q),A({title:"Model Load Failed",message:Q.message||String(Q),danger:!0})}finally{setTimeout(()=>ne(null),800),re(null)}},ct=async()=>{const T=Je;x(null),await yt(),T&&await ze(T)},yt=async()=>{if(Me)return;Ke(!0),tt({progress:10,phase:"Stopping backend process..."});const T=setInterval(async()=>{try{const C=await ba();C.unloading?.active?tt({progress:C.unloading.progress||50,phase:C.unloading.phase||"Unloading model..."}):tt(q=>({progress:Math.min(95,q.progress+10),phase:q.phase||"Unloading model..."}))}catch{}},300);try{await Zs(),tt({progress:100,phase:"Model unloaded"}),b(null),x(null),r(!1)}catch(C){console.error(C),A({title:"Unload Failed",message:C.message||String(C),danger:!0})}finally{clearInterval(T),setTimeout(()=>{Ke(!1),tt({progress:0,phase:""})},500)}},wt=async T=>{if(await Y({title:"Delete Model?",message:`Delete "${T}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await $y(T),await B(),f===T&&await yt()}catch(C){console.error("Failed to delete model:",C),A({title:"Delete Failed",message:C.message||String(C),danger:!0})}},Al=async(T,C)=>{const q=new AbortController;qe(q),Ge(0),Xe({filename:C,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Ky(T,Q=>{Ge(Math.round(Q.progress)),Xe({filename:Q.filename,speed:Q.speed_mb_s.toFixed(1),eta:Math.round(Q.eta_secs),status:Q.status})},q.signal),await B()}catch(Q){console.error("Import failed:",Q),Q.name!=="AbortError"&&A({title:"Import Failed",message:Q.message||String(Q),danger:!0})}finally{Ge(null),qe(null)}},rt=()=>{ot&&ot.abort()},al=T=>{const C=T.target.files[0];C&&Al(C,C.name),T.target.value=""},sl=!!y;return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Model Manager"}),c.jsx("p",{className:"workspace-subtitle",children:"Manage local files and download recommended weights directly to your local models folder."})]}),f&&c.jsx("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-primary)",background:"var(--md-sys-color-primary-container)",color:"var(--md-sys-color-on-primary-container)"},children:c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[c.jsxs("div",{children:[c.jsxs("h4",{style:{fontWeight:700},children:["Active Model: ",f]}),c.jsx("p",{style:{fontSize:"0.85rem",marginTop:"2px",opacity:.9},children:"The local C++ stable-diffusion server is running. Real-time telemetry is displaying performance status in the top bar."}),(O.backendMode||O.backendDevice||O.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[O.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(bu,{size:14}),c.jsxs("span",{children:["Loaded on ",O.backendMode]})]}),O.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendDevice})}),O.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:yt,disabled:Me||F!==null,children:[Me?c.jsx(ta,{className:"progress-spinner",size:16}):c.jsx(ti,{size:16}),c.jsx("span",{children:Me?"Unloading":"Unload Server"})]})]})}),Me&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-error)",marginTop:"16px"},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"8px"},children:"Unloading Model"}),c.jsxs("div",{className:"model-progress-section",style:{margin:"8px 0 0 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsx("span",{children:$e.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round($e.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",chi Line truncated
Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){$e(!0);try{await Hy(qe.map(q=>q.id)),await Ue()}catch(q){A({title:"Cleanup Failed",message:q.message||String(q),danger:!0})}finally{$e(!1)}}},[qe,Ue,A,j]);w.useEffect(()=>{async function T(){const C=await ky();O(C)}T()},[]),w.useEffect(()=>{re?localStorage.setItem("active-model",re):localStorage.removeItem("active-model")},[re]),w.useEffect(()=>{let T=null;async function C(){const q=await ba();if(!!q.ready){T&&clearInterval(T);const He=localStorage.getItem("active-model");if(He)I(He),ce(!0);else{try{if(q&&q.settings&&q.settings.model){const zt=q.settings.model.split(/[\\/]/).pop();I(zt)}}catch{}ce(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const zt=localStorage.getItem("active-model");zt&&(I(zt),ce(!1))}}return C(),T=setInterval(C,2e3),()=>{T&&clearInterval(T)}},[]),w.useEffect(()=>{async function T(){try{const q=await qy();P(Q=>Q.cpu_usage===q.cpu_usage&&Q.ram_used_gb===q.ram_used_gb&&Q.ram_total_gb===q.ram_total_gb&&Q.gpu_name===q.gpu_name&&Q.vram_used_gb===q.vram_used_gb&&Q.vram_total_gb===q.vram_total_gb?Q:q)}catch{}}T();const C=setInterval(T,1500);return()=>clearInterval(C)},[]),w.useEffect(()=>{if(re){const T=re.toLowerCase();T.includes("flux")||T.includes("schnell")?le(C=>({...C,steps:4,cfgScale:1,width:1024,height:1024})):T.includes("lightning")||T.includes("turbo")?le(C=>({...C,steps:4,cfgScale:1.5,width:1024,height:1024})):T.includes("sd15")?le(C=>({...C,steps:25,cfgScale:7,width:512,height:512})):T.includes("sd35")?le(C=>({...C,steps:20,cfgScale:4.5,width:1024,height:1024})):le(C=>({...C,steps:20,cfgScale:7,width:512,height:512}))}},[re]);const yt=w.useMemo(()=>{switch(R){case"generator":return c.jsx(l1,{prompt:D,setPrompt:U,negativePrompt:V,setNegativePrompt:ee,constraints:te,setConstraints:le,activeModel:re,generatedImages:x,setGeneratedImages:O,isGenerating:K,setIsGenerating:se,generationProgress:de,setGenerationProgress:d,setActiveTab:y,inputImage:k,setInputImage:F,showAlert:A,showConfirm:j});case"models":return c.jsx(i1,{activeModel:re,setActiveModel:I,serverRunning:ne,setServerRunning:ce,constraints:te,showAlert:A,showConfirm:j});case"constraints":return c.jsx(s1,{constraints:te,setConstraints:le,activeModel:re,specs:z,backendOptions:Xe});default:return null}},[R,D,V,te,re,x,K,de,k,ne,z,Xe,A,j]),wt=w.useMemo(()=>c.jsx(Ey,{activeTab:R,setActiveTab:y,specs:z}),[R,z]),Al=w.useCallback(async()=>{if(!(!ne||Ge)){Ze(!0);try{await Zs(),ce(!1),I(null)}catch(T){console.error("Failed to stop server:",T),A({title:"Stop Server Failed",message:T.message||String(T),danger:!0})}finally{Ze(!1)}}},[ne,Ge,A]),rt=[...je?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...je?.issues||[]],al=qe.reduce((T,C)=>T+Number(C.sizeBytes||0),0),sl=!!(je&&(rt.length>0||qe.length>0));return c.jsxs("div",{className:"app-container",children:[wt,c.jsxs("div",{className:"main-content",children:[c.jsx(Ay,{telemetry:H,serverRunning:ne,activeModel:re,onStopServer:Al,isStoppingServer:Ge,theme:Y,setTheme:G}),sl&&c.jsxs("div",{className:`m3-card readiness-card ${je?.stale||rt.length>0?"readiness-card-warning":""}`,children:[c.jsxs("div",{className:"readiness-header",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"m3-card-title",style:{marginBottom:"4px"},children:je?.stale?"Restart Required":rt.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:je?.stale?`Running server build: ${je.build||"unknown"}`:rt.length>0?"Local AI Image Generator found setup items that may need attention.":`${qe.length} temporary item${qe.length===1?"":"s"} can be cleaned (${li(al)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:Ue,disabled:Ke,children:Ke?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:ze,children:tt?"Copied":"Copy Diagnostics"}),qe.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ct,disabled:Ke,children:["Clean ",li(al)]})]})]}),rt.length>0&&c.jsx("div",{className:"readiness-issues",children:rt.slice(0,4).map(T=>c.jsx("span",{children:T},T))}),qe.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:qe.slice(0,3).map(T=>c.jsxs("span",{title:T.path,children:[T.name," · ",T.size," · ",T.reason]},T.id))})]}),yt]}),b&&c.jsx("div",{className:"app-dialog-backdrop",role:"presentation",children:c.jsxs("div",{className:"app-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"app-dialog-title",children:[c.jsx("h3",{id:"app-dialog-title",className:"app-dialog-title",children:b.title}),c.jsx("p",{className:"app-dialog-message",children:b.message}),c.jsxs("div",{className:"app-dialog-actions",children:[b.type==="confirm"&&c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>r(!1),children:b.cancelLabel}),c.jsx("button",{className:`m3-btn ${b.danger?"m3-btn-error":"m3-btn-fLine truncated
+1 -1
View File
@@ -8,7 +8,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<title>Local AI Image Generator</title>
<script type="module" crossorigin src="/assets/index-DjStOWCE.js"></script>
<script type="module" crossorigin src="/assets/index-BOI9YDBQ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BVK0F0Ah.css">
</head>
+36 -19
View File
@@ -10,7 +10,7 @@ const GalleryItem = memo(({ img, idx, isSelected, onClick }) => {
<div
className={`gallery-item ${isSelected ? "selected" : ""}`}
onClick={handleClick}
title={`Prompt: ${img.prompt}\nSeed: ${img.seed}`}
title={`Prompt: ${img.prompt}\nSeed: ${img.seed}${img.duration_sec ? `\nTime: ${img.duration_sec.toFixed(1)}s` : ""}`}
>
<img src={img.url} className="gallery-thumb" alt="Thumbnail" loading="lazy" decoding="async" />
{isSelected && (
@@ -55,6 +55,7 @@ function Generator({
const [isRestartingBackend, setIsRestartingBackend] = useState(false);
const [restartLoadProgress, setRestartLoadProgress] = useState(null);
const [errorMsg, setErrorMsg] = useState(null);
const [isDecoding, setIsDecoding] = useState(false);
const [selectedGalleryIndexes, setSelectedGalleryIndexes] = useState([]);
const timerRef = useRef(null);
const fileInputRef = useRef(null);
@@ -170,6 +171,7 @@ function Generator({
setCurrentStep(0);
setGenerationSpeed("");
setIsCpuFallback(false);
setIsDecoding(false);
setGenDuration(null);
setOutputImage(null);
@@ -194,16 +196,25 @@ function Generator({
try {
const progress = await getGenerationProgress();
if (progress && progress.active) {
const step = progress.step || 0;
const decoding = progress.decoding || false;
setIsDecoding(decoding);
const step = decoding ? (progress.steps || constraints.steps || 20) : (progress.step || 0);
const steps = progress.steps || constraints.steps || 20;
const speed = progress.speed || "";
const speed = decoding ? "" : (progress.speed || "");
setCurrentStep(step);
setGenerationSpeed(speed);
if (!decoding) {
setGenerationSpeed(speed);
} else {
setGenerationSpeed("decoding");
}
// Calculate progress percentage
let progressPercent = 0;
if (steps > 0) {
if (decoding) {
progressPercent = 99;
} else if (steps > 0) {
progressPercent = Math.round((step / steps) * 100);
}
progressPercent = Math.min(99, progressPercent);
@@ -211,17 +222,21 @@ function Generator({
// Calculate remaining time
let remaining = 0;
const numericSpeed = parseFloat(speed);
if (!isNaN(numericSpeed) && numericSpeed > 0) {
const remainingSteps = Math.max(0, steps - step);
if (speed.includes("it/s")) {
remaining = remainingSteps / numericSpeed;
} else if (speed.includes("s/it")) {
remaining = remainingSteps * numericSpeed;
}
if (decoding) {
remaining = 3;
} else {
const activeStepTime = gpuSelected ? baseGpuStepTime : baseCpuStepTime;
remaining = Math.max(0, (steps - step) * activeStepTime);
const numericSpeed = parseFloat(speed);
if (!isNaN(numericSpeed) && numericSpeed > 0) {
const remainingSteps = Math.max(0, steps - step);
if (speed.includes("it/s")) {
remaining = remainingSteps / numericSpeed;
} else if (speed.includes("s/it")) {
remaining = remainingSteps * numericSpeed;
}
} else {
const activeStepTime = gpuSelected ? baseGpuStepTime : baseCpuStepTime;
remaining = Math.max(0, (steps - step) * activeStepTime);
}
}
// Detect CPU fallback / slow generation if GPU was requested but it runs slow
@@ -482,7 +497,7 @@ function Generator({
}));
setOutputImage(item.url);
setOutputSeed(item.seed);
setGenDuration(null);
setGenDuration(item.duration_sec ?? item.durationSec ?? null);
}, [setPrompt, setNegativePrompt, setConstraints]);
const toggleGallerySelection = useCallback((idx, event) => {
@@ -733,7 +748,9 @@ function Generator({
) : (
<>
<div className="progress-spinner"></div>
<div className="progress-text" style={{ fontSize: "1.1rem", fontWeight: 700 }}>Generating Locally...</div>
<div className="progress-text" style={{ fontSize: "1.1rem", fontWeight: 700 }}>
{isDecoding ? "Decoding Latents..." : "Generating Locally..."}
</div>
{isCpuFallback && (
<div style={{ fontSize: "0.8rem", color: "var(--md-sys-color-primary)", fontWeight: 600, background: "var(--md-sys-color-primary-container)", padding: "4px 12px", borderRadius: "12px", margin: "4px 0 8px 0", animation: "pulse 2s infinite" }}>
@@ -744,10 +761,10 @@ function Generator({
{/* Real-time stats display */}
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "16px", width: "80%", margin: "8px 0 0 0", fontSize: "0.85rem", opacity: 0.9 }}>
<div style={{ textAlign: "left" }}>
<strong>Step:</strong> {currentStep} / {constraints.steps} ({constraints.steps - currentStep} left)
<strong>Step:</strong> {currentStep} / {constraints.steps} ({Math.max(0, constraints.steps - currentStep)} left)
</div>
<div style={{ textAlign: "right" }}>
<strong>Elapsed:</strong> {elapsedTime}s{generationSpeed && ` (${generationSpeed})`}
<strong>Elapsed:</strong> {elapsedTime}s{generationSpeed && ` (${generationSpeed === "decoding" ? "decoding" : generationSpeed})`}
</div>
</div>
+5 -2
View File
@@ -318,6 +318,7 @@ export async function listModelsFromDisk() {
// Handles API calls to sd-server or mocks them if server is unreachable
export async function generateImage(prompt, negativePrompt, constraints, activeModelName, inputImageBase64, onProgress, signal) {
console.log("Initiating image generation:", { prompt, negativePrompt, constraints, activeModelName });
const startTime = Date.now();
const port = 8080;
const baseUrl = `http://127.0.0.1:${port}`;
@@ -495,11 +496,12 @@ export async function generateImage(prompt, negativePrompt, constraints, activeM
const base64Svg = btoa(unescape(encodeURIComponent(svgString)));
const mockImageUrl = `data:image/svg+xml;base64,${base64Svg}`;
const durationSec = parseFloat(((Date.now() - startTime) / 1000).toFixed(1));
return {
image: mockImageUrl,
seed: payload.seed,
duration_sec: 3.0,
duration_sec: durationSec,
};
};
@@ -540,10 +542,11 @@ export async function generateImage(prompt, negativePrompt, constraints, activeM
// Response: { data: [{ b64_json: "..." }] }
const imgB64 = data?.data?.[0]?.b64_json ?? data?.images?.[0];
if (imgB64) {
const durationSec = parseFloat(((Date.now() - startTime) / 1000).toFixed(1));
return {
image: `data:image/png;base64,${imgB64}`,
seed: data.data?.[0]?.seed ?? payload.seed,
duration_sec: 4.5,
duration_sec: durationSec,
};
}
} else {
+13 -3
View File
@@ -787,14 +787,21 @@ function startBackend(settings = {}) {
generationState.step = 0;
generationState.steps = 0;
generationState.speed = "";
generationState.decoding = false;
}
if (cleanLine.includes("decoding") && generationState.active) {
generationState.decoding = true;
}
const match = cleanLine.match(/\|\s*[^|]*\s*\|\s*(\d+)\/(\d+)\s*-\s*([\d.]+\s*(?:it\/s|s\/it))/);
if (match) {
generationState.active = true;
generationState.step = parseInt(match[1], 10);
generationState.steps = parseInt(match[2], 10);
generationState.speed = match[3].trim();
if (!generationState.decoding) {
generationState.step = parseInt(match[1], 10);
generationState.steps = parseInt(match[2], 10);
generationState.speed = match[3].trim();
}
}
if (cleanLine.includes("generate_image completed")) {
@@ -802,6 +809,7 @@ function startBackend(settings = {}) {
generationState.step = 0;
generationState.steps = 0;
generationState.speed = "";
generationState.decoding = false;
}
}
});
@@ -841,6 +849,7 @@ function startBackend(settings = {}) {
generationState.step = 0;
generationState.steps = 0;
generationState.speed = "";
generationState.decoding = false;
// Force a VRAM poll to update free memory space
setTimeout(() => pollNvidiaVram(true), 1000);
@@ -866,6 +875,7 @@ let generationState = {
step: 0,
steps: 0,
speed: "",
decoding: false,
};
function startModelDownload(url, overrideFilename = null) {