Fix backend port handling, generation progress sync, and restore img2img UI
This commit is contained in:
1 parent
992a642b40
commit
c78960c6f4
9 files changed
+259
-257
No files matched your search
@@ -1 +1 @@
|
||||
import{i as D,t as i}from"./index-CBtRYlFE.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-DVJy0SBd.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};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{i as D,t as i}from"./index-CL30r104.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};
|
||||
Vendored
-121
@@ -1,121 +0,0 @@
|
||||
(function(){const S=document.createElement("link").relList;if(S&&S.supports&&S.supports("modulepreload"))return;for(const z of document.querySelectorAll('link[rel="modulepreload"]'))r(z);new MutationObserver(z=>{for(const A of z)if(A.type==="childList")for(const L of A.addedNodes)L.tagName==="LINK"&&L.rel==="modulepreload"&&r(L)}).observe(document,{childList:!0,subtree:!0});function N(z){const A={};return z.integrity&&(A.integrity=z.integrity),z.referrerPolicy&&(A.referrerPolicy=z.referrerPolicy),z.crossOrigin==="use-credentials"?A.credentials="include":z.crossOrigin==="anonymous"?A.credentials="omit":A.credentials="same-origin",A}function r(z){if(z.ep)return;z.ep=!0;const A=N(z);fetch(z.href,A)}})();function cm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Os={exports:{}},ei={};var kd;function z0(){if(kd)return ei;kd=1;var f=Symbol.for("react.transitional.element"),S=Symbol.for("react.fragment");function N(r,z,A){var L=null;if(A!==void 0&&(L=""+A),z.key!==void 0&&(L=""+z.key),"key"in z){A={};for(var H in z)H!=="key"&&(A[H]=z[H])}else A=z;return z=A.ref,{$$typeof:f,type:r,key:L,ref:z!==void 0?z:null,props:A}}return ei.Fragment=S,ei.jsx=N,ei.jsxs=N,ei}var Zd;function T0(){return Zd||(Zd=1,Os.exports=z0()),Os.exports}var c=T0(),Us={exports:{}},ie={};var Vd;function M0(){if(Vd)return ie;Vd=1;var f=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),L=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),Z=Symbol.iterator;function ee(d){return d===null||typeof d!="object"?null:(d=Z&&d[Z]||d["@@iterator"],typeof d=="function"?d:null)}var q={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},W=Object.assign,ne={};function F(d,_,w){this.props=d,this.context=_,this.refs=ne,this.updater=w||q}F.prototype.isReactComponent={},F.prototype.setState=function(d,_){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,_,"setState")},F.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function Oe(){}Oe.prototype=F.prototype;function ye(d,_,w){this.props=d,this.context=_,this.refs=ne,this.updater=w||q}var Le=ye.prototype=new Oe;Le.constructor=ye,W(Le,F.prototype),Le.isPureReactComponent=!0;var ke=Array.isArray;function Me(){}var te={H:null,A:null,T:null,S:null},de=Object.prototype.hasOwnProperty;function et(d,_,w){var G=w.ref;return{$$typeof:f,type:d,key:_,ref:G!==void 0?G:null,props:w}}function jt(d,_){return et(d.type,_,d.props)}function pe(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Ke(d){var _={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(w){return _[w]})}var ut=/\/+/g;function Je(d,_){return typeof d=="object"&&d!==null&&d.key!=null?Ke(""+d.key):_.toString(36)}function Ye(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Me,Me):(d.status="pending",d.then(function(_){d.status==="pending"&&(d.status="fulfilled",d.value=_)},function(_){d.status==="pending"&&(d.status="rejected",d.reason=_)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,_,w,G,J){var le=typeof d;(le==="undefined"||le==="boolean")&&(d=null);var re=!1;if(d===null)re=!0;else switch(le){case"bigint":case"string":case"number":re=!0;break;case"object":switch(d.$$typeof){case f:case S:re=!0;break;case E:return re=d._init,x(re(d._payload),_,w,G,J)}}if(re)return J=J(d),re=G===""?"."+Je(d,0):G,ke(J)?(w="",re!=null&&(w=re.replace(ut,"$&/")+"/"),x(J,_,w,"",function(ct){return ct})):J!=null&&(pe(J)&&(J=jt(J,w+(J.key==null||d&&d.key===J.key?"":(""+J.key).replace(ut,"$&/")+"/")+re)),_.push(J)),1;re=0;var Ze=G===""?".":G+":";if(ke(d))for(var Ee=0;Ee<d.length;Ee++)G=d[Ee],le=Ze+Je(G,Ee),re+=x(G,_,w,le,J);else if(Ee=ee(d),typeof Ee=="function")for(d=Ee.call(d),Ee=0;!(G=d.next()).done;)G=G.value,le=Ze+Je(G,Ee++),re+=x(G,_,w,le,J);else if(le==="object"){if(typeof d.then=="function")return x(Ye(d),_,w,G,J);throw _=String(d),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.")}return re}function C(d,_,w){if(d==null)return d;var G=[],J=0;return x(d,G,"","",function(le){return _.call(w,le,J++)}),G}function K(d){if(d._status===-1){var _=d._result;_=_(),_.then(function(w){(d._status===0||d._status===-1)&&(d._status=1,d._result=w)},function(w){(d._status===0||d._status===-1)&&(d._status=2,d._result=w)})Line truncated
|
||||
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||||
`+ht+e+cl}var k=!1;function ce(e,t){if(!e||k)return"";k=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var M=function(){throw Error()};if(Object.defineProperty(M.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(M,[])}catch(b){var v=b}Reflect.construct(e,[],M)}else{try{M.call()}catch(b){v=b}e.call(M.prototype)}}else{try{throw Error()}catch(b){v=b}(M=e())&&typeof M.catch=="function"&&M.catch(function(){})}}catch(b){if(b&&v&&typeof b.stack=="string")return[b.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{k=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ut(l):""}function D(e,t){switch(e.tag){case 26:case 27:case 5:return Ut(e.type);case 16:return Ut("Lazy");case 13:return e.child!==t&&t!==null?Ut("Suspense Fallback"):Ut("Suspense");case 19:return Ut("SuspenseList");case 0:case 15:return ce(e.type,!1);case 11:return ce(e.type.render,!1);case 1:return ce(e.type,!0);case 31:return Ut("Activity");default:return""}}function R(e){try{var t="",l=null;do t+=D(e,l),l=e,e=e.return;while(e);return t}catch(a){return`
|
||||
Error generating stack: `+a.message+`
|
||||
`+a.stack}}var I=Object.prototype.hasOwnProperty,V=f.unstable_scheduleCallback,bt=f.unstable_cancelCallback,ea=f.unstable_shouldYield,It=f.unstable_requestPaint,_e=f.unstable_now,Y=f.unstable_getCurrentPriorityLevel,Ne=f.unstable_ImmediatePriority,Ve=f.unstable_UserBlockingPriority,tt=f.unstable_NormalPriority,zt=f.unstable_LowPriority,ll=f.unstable_IdlePriority,xa=f.log,_a=f.unstable_setDisableYieldValue,Fe=null,ae=null;function se(e){if(typeof xa=="function"&&_a(e),ae&&typeof ae.setStrictMode=="function")try{ae.setStrictMode(Fe,e)}catch{}}var ve=Math.clz32?Math.clz32:He,Ae=Math.log,st=Math.LN2;function He(e){return e>>>=0,e===0?32:31-(Ae(e)/st|0)|0}var rt=256,xt=262144,wt=4194304;function sl(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 ii(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=sl(a):(u&=s,u!==0?n=sl(u):l||(l=s&~e,l!==0&&(n=sl(l))))):(s=a&~i,s!==0?n=sl(s):u!==0?n=sl(u):l||(l=a&~e,l!==0&&(n=sl(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 fn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function rm(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 Vs(){var e=wt;return wt<<=1,(wt&62914560)===0&&(wt=4194304),e}function bu(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function on(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-ve(l),M=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 b=v[j];b!==null&&(b.lane&=-536870913)}l&=~M}a!==0&&Ks(e,a,0),i!==0&&n===0&&e.tag!==0&&(e.suspendedLanes|=i&~(u&~t))}function Ks(e,t,l){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-ve(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|l&261930}function Js(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var a=31-ve(l),n=1<<a;n&t|e[a]&t&&(e[a]|=t),l&=~n}}function $s(e,t){var l=t&-t;return l=(l&42)!==0?1:xu(l),(l&(e.suspendedLanes|t))!==0?0:l}function xu(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 _u(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ws(){var e=C.p;return e!==0?e:(e=window.event,e===void 0?32:Hd(e.type))}function Fs(e,t){var l=C.p;try{return C.p=e,t()}finally{C.p=l}}var El=Math.random().toString(36).slice(2),yt="__reactFiber$"+El,Mt="__reactProps$"+El,ja="__reactContainer$"+El,ju="__reactEvents$"+El,mm="__reactListeners$"+El,hm="__reactHandles$"+El,Is="__reactResources$"+El,rn="__reactMarker$"+El;function zu(e){delete e[yt],delete e[Mt],delete e[ju],delete e[mm],delete e[hm]}function za(e){var t=e[yt];if(t)return t;for(var l=e.parentNode;l;){if(t=l[ja]||l[yt]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=xd(e);e!==null;){if(l=e[yt])return l;e=xd(e)}return t}e=l,l=e.parentNode}return null}function Ta(e){if(e=e[yt]||e[ja]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function dn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ma(e){var t=e[Is];return t||(t=e[Is]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function dt(e){e[rn]=!0}var Ps=new Set,ef={};function ta(e,t){Ea(e,t),Ea(e+"Capture",t)}function Ea(e,t){for(ef[e]=t,e=0;e<t.length;e++)Ps.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(Vh,"")}function rd(e,t){return t=od(t),od(e)===t}function we(e,t,l,a,n,i){switch(l){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Aa(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Aa(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":of(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"&&we(e,t,"name",n.name,n,null),we(e,t,"formEncType",n.formEncType,n,null),we(e,t,"formMethod",n.formMethod,n,null),we(e,t,"formTarget",n.formTarget,n,null)):(we(e,t,"encType",n.encType,n,null),we(e,t,"method",n.method,n,null),we(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=ol);break;case"onScroll":a!=null&&he("scroll",e);break;case"onScrollEnd":a!=null&&he("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":he("beforetoggle",e),he("toggle",e),ui(e,"popover",a);break;case"xlinkActuate":fl(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":fl(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":fl(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":fl(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":fl(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":fl(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":fl(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":fl(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":fl(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=bm.get(l)||l,ui(e,l,a))}}function hs(e,t,l,a,n,i){switch(l){case"style":of(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"?Aa(e,a):(typeof a=="number"||typeof a=="bigint")&&Aa(e,""+a);break;case"onScroll":a!=null&&he("scroll",e);break;case"onScrollEnd":a!=null&&he("scrollend",e);break;case"onClick":a!=null&&(e.onclick=ol);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" />
|
||||
`):q.includes("cat")||q.includes("kitten")||q.includes("feline")?(ne="#4F46E5",F="#7C3AED",ye="Stylized Cat Portrait",Oe=`
|
||||
<!-- 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" />
|
||||
`):q.includes("dog")||q.includes("puppy")||q.includes("canine")?(ne="#D97706",F="#B45309",ye="Friendly Dog Portrait",Oe=`
|
||||
<!-- 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" />
|
||||
`):q.includes("city")||q.includes("cyberpunk")||q.includes("tokyo")||q.includes("neon")?(ne="#111827",F="#311042",ye="Neon Cyberpunk Skyline",Oe=`
|
||||
<!-- 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"/>
|
||||
`):q.includes("car")||q.includes("vehicle")||q.includes("supercar")?(ne="#DC2626",F="#991B1B",ye="Futuristic Concept Car",Oe=`
|
||||
<!-- 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" />
|
||||
`):(ne="#06B6D4",F="#0891B2",ye="Abstract Creative Concept",Oe=`
|
||||
<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 Le=`
|
||||
<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="${ne}" />
|
||||
<stop offset="100%" stop-color="${F}" />
|
||||
</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 -->
|
||||
${Oe}
|
||||
|
||||
<!-- 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">${ye}</text>
|
||||
<text x="60" y="455" fill="#94A3B8" font-family="system-ui, -apple-system, sans-serif" font-size="11">Seed: ${W} • Steps: ${E.steps} • Scale: ${E.cfg_scale}</text>
|
||||
</svg>
|
||||
`,Me=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Le)))}`,te=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:Me,seed:E.seed,duration_sec:te}},Z={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};try{const ee=await fetch(`${y}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:L,body:JSON.stringify(Z)});if(ee.ok){const q=await ee.json(),W=q?.data?.[0]?.b64_json??q?.images?.[0];if(W){const ne=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:`data:image/png;base64,${W}`,seed:q.data?.[0]?.seed??E.seed,duration_sec:ne}}}else{let q=`Generation failed (HTTP ${ee.status})`;try{const W=await ee.json();(W?.detail||W?.error?.message)&&(q=W.detail||W.error.message)}catch{}throw new Error(q)}}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 O()}async function Zy(f,S,N){if(f instanceof File){const H=f;if(!Sa())throw new Error("File import requires the local image generator server.");return await Vy(H,S,N),{response:"Model imported successfully"}}if(Pl()){const{listen:H}=await Dy(async()=>{const{listen:y}=await import("./event-DUWu82QQ.js");return{listen:y}},[]);let B=null;S&&(B=await H("import-progress",y=>{S(y.payload)}));try{return{response:await ba("import_model_file",{sourcePath:f}),unlisten:B}}catch(y){throw B&&B(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const z=40;for(let H=1;H<=z;H++){if(N?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(O=>setTimeout(O,150));const B=H/z*100,y=40+Math.sin(H)*5+Math.random()*2,E=(z-H)*.15;S&&S({filename:r,progress:B,speed_mb_s:y,eta_secs:E,status:"Copying to USB..."})}const A=localStorage.getItem("imported-models"),L=A?JSON.parse(A):[];return L.includes(r)||(L.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(L))),{response:"Model imported successfully"}}function Vy(f,S,N){return new Promise((r,z)=>{const A=new XMLHttpRequest,L=Date.now();let H=!1;A.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),A.setRequestHeader("Content-Type","application/octet-stream");const B=()=>{H=!0,A.abort()};N&&(N.aborted?B():N.addEventListener("abort",B,{once:!0})),A.upload.onprogress=y=>{if(!y.lengthComputable||!S)return;const E=Math.max(.1,(Date.now()-L)/1e3),O=y.loaded/E,Z=Math.max(0,y.total-y.loaded);S({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:O/(1024*1024),eta_secs:Z/Math.max(1,O),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?(S&&S({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):z(new Error(y.error||`Import failed (HTTP ${A.status})`))},A.onerror=()=>z(new Error("Import failed while uploading the file.")),A.onabort=()=>z(new DOMException(H?"Import cancelled by user.":"Import aborted.","AbortError")),A.send(f)})}async function Ky(f){if(Pl())return await ba("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const z=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),A=await z.json();if(!z.ok)throw new Error(A.error||"Failed to delete model file");return A}catch(z){throw console.error("Failed to delete model via local API:",z),z}const N=localStorage.getItem("imported-models");let r=N?JSON.parse(N):[];return r=r.filter(z=>ni(z).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function om(){const S="http://127.0.0.1:8080";try{return(await fetch(`${S}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Jy(f=30){const S=Pl()||Sa()?f:3;for(let N=0;N<S;N++){let r=!1;if(Sa()?r=!!(await va()).ready:r=await om(),r)return!0;await new Promise(z=>setTimeout(z,500))}return!1}async function $y(f){try{return await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f})})).json()}catch(S){return console.error("Failed to start model download:",S),{ok:!1,error:S.message}}}async function Wy(){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 im(){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 Fy(){try{return await(await fetch("/api/generation-progre
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"}),N&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(qs,{size:14})})]})});function Py({prompt:f,setPrompt:S,negativePrompt:N,setNegativePrompt:r,constraints:z,setConstraints:A,activeModel:L,generatedImages:H,setGeneratedImages:B,isGenerating:y,setIsGenerating:E,generationProgress:O,setGenerationProgress:Z,setActiveTab:ee,showAlert:q=async({message:ne})=>window.alert(ne),showConfirm:W=async({message:ne})=>window.confirm(ne)}){const[ne,F]=U.useState(null),[Oe,ye]=U.useState(null),[Le,ke]=U.useState(null),[Me,te]=U.useState(!1),[de,et]=U.useState(0),[jt,pe]=U.useState(0),[Ke,ut]=U.useState(0),[Je,Ye]=U.useState(""),[x,C]=U.useState(!1),[K,ge]=U.useState(!1),[oe,d]=U.useState(!1),[_,w]=U.useState(null),[G,J]=U.useState(null),[le,re]=U.useState(!1),[Ze,Ee]=U.useState([]),ct=U.useRef(null),ot=U.useRef(null),ht=U.useRef(!1),cl=async()=>{if(!f.trim())return;J(null),d(!0),w(null);let Y=!1;try{const ae=await va();if(ae&&ae.settings){const se=ae.settings,ve=se.model?se.model.split(/[\\/]/).pop():null,Ae=L?L.split(/[\\/]/).pop():null;(ve!==Ae||parseInt(se.steps)!==parseInt(z.steps)||Math.abs(parseFloat(se.cfgScale)-parseFloat(z.cfgScale))>.05||se.sampler!==z.sampler||parseInt(se.threads)!==parseInt(z.threads)||!!se.useGpu!=(z.useGpu!==!1)||(se.backendType||(se.useGpu===!1?"cpu":"auto"))!==(z.backendType||(z.useGpu===!1?"cpu":"auto")))&&(Y=!0)}else Y=!0}catch{Y=!0}if(Y)try{console.log("Settings out of sync, restarting backend..."),await Xs(L,z);let ae=!1,se=null;for(let ve=0;ve<240;ve++){const Ae=await va();if(Ae.loading&&w({progress:Ae.loading.progress||0,phase:Ae.loading.phase||"Loading model...",speed:Ae.loading.speed||"",current:Ae.loading.current||0,total:Ae.loading.total||0,backendMode:Ae.loading.backendMode||Ae.settings?.backendMode||"",device:Ae.loading.device||Ae.settings?.backendDevice||""}),Ae.ready){ae=!0;break}if(Ae.error){se=Ae.error;break}if(!Ae.running&&ve>3){se="The backend process terminated immediately on startup.";break}await new Promise(st=>setTimeout(st,500))}if(!ae)throw new Error(se||"Backend server failed to start after applying configuration changes.")}catch(ae){console.error("Failed to restart backend:",ae),J(ae.message||"Failed to sync settings with backend."),d(!1);return}d(!1),w(null),ct.current&&clearInterval(ct.current),E(!0),Z(0),et(0),ut(0),Ye(""),ht.current=!1,C(!1),re(!1),ke(null),F(null);const Ne=(z.width>=1024?140:35)*.04,Ve=z.width>=1024?140:35,tt=(z.backendType||(z.useGpu===!1?"cpu":"auto"))!=="cpu";let zt=tt?Ne:Ve,ll=!1,xa=0,_a=0,Fe=0;pe(Math.round(z.steps*zt)),ct.current=setInterval(async()=>{Fe++,et(Fe);try{const ae=await Fy();if(ae&&ae.active){const se=ae.decoding||!1;re(se);const ve=se?ae.steps||z.steps||20:ae.step||0,Ae=ae.steps||z.steps||20,st=se?"":ae.speed||"";(se||ae.steps>0)&&(ht.current=!0,ut(ve)),Ye(se?"decoding":st);let He=0;se?He=99:Ae>0&&(He=Math.round(ve/Ae*100)),He=Math.min(99,He),se||ae.steps>0?Z(He):Z(xt=>Math.max(xt,He));let rt=0;if(se)rt=3;else{const xt=parseFloat(st);if(!isNaN(xt)&&xt>0){const wt=Math.max(0,Ae-ve);st.includes("it/s")?rt=wt/xt:st.includes("s/it")&&(rt=wt*xt)}else{const wt=tt?Ne:Ve;rt=Math.max(0,(Ae-ve)*wt)}}if(tt&&!ll){const xt=st.includes("it/s")&&numericSpeed<.2,wt=st.includes("s/it")&&numericSpeed>5;(xt||wt)&&(ll=!0,C(!0))}pe(Math.round(rt))}else Z(se=>Math.min(15,se+1)),pe(se=>Math.max(1,se-1))}catch(ae){console.warn("Failed to get generation progress, running simulation fallback:",ae),tt&&!ll&&Fe>z.steps*Ne*1.3&&(ll=!0,C(!0),zt=Ve,xa=Fe,_a=Math.min(95,Math.round(Fe/(z.steps*Ne)*100)));let se=Math.min(z.steps-1,Math.floor(Fe/zt)),ve=z.steps*zt;if(Fe>=ve){const He=Math.ceil(Fe/Math.max(.5,se));zt=Math.max(zt+15,He+15),ve=z.steps*zt,se=Math.min(z.steps-1,Math.floor(Fe/zt))}const Ae=Math.max(1,ve-Fe);pe(Math.round(Ae));let st=0;if(ll){const He=99-_a,rt=ve-xa;if(rt>0){const xt=Math.min(1,(Fe-xa)/rt);if(xt<.85)st=Math.round(_a+xt*He);else{const wt=(Fe-(xa+rt*.85))/(zt*2),sl=1-Math.exp(-wt);st=Math.min(99,Math.round(_a+.85*He+.14*He*sl))}}else st=99}else if(Fe<ve*.85)st=Math.round(Fe/ve*100);else{const He=(Fe-ve*.85)/(zt*2),rt=1-Math.exp(-He);st=Math.min(99,Math.round(85+14*rt))}ht.current||Z(He=>Math.max(He,st))}},1e3);try{ot.current=new AbortController;const ae=await ky(f,N,z,L,null,He=>Z(rt=>Math.max(rt,He)),ot.current.signal);ct.current&&clearInterval(ct.current),Z(100),ut(z.steps),pe(0),Ye("");const se={prompt:f,negativePrompt:N,seed:ae.seed,steps:z.steps,cfgScale:z.cfgScale,width:z.width,height:z.height,sampler:z.sampler,model:L,duration_sec:ae.duration_sec,timestamp:new Date().toLocaleTimeString()};let ve=null,Ae=null;try{if(ve=await Yy(ae.image,se),Ae=ve.url,!Ae)throw new Error("The local server saved the image but did not return a file URL.")}catch(He){throw console.error("Generated image could not be saved:",He),new Error(`Image generated but could not be saved to USB: ${He.Line truncated
|
||||
|
||||
${bt}
|
||||
|
||||
Update the UI status anyway?`,confirmLabel:"Update UI"})&&(S(D),r(!0)):await L({title:"Backend Not Running",message:`C++ backend server is not running on port 8080.
|
||||
|
||||
To run locally, start:
|
||||
|
||||
${bt}
|
||||
|
||||
Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(S(D),r(!1));return}ne(D),Oe({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:D,backendMode:"",backendBinary:"",device:""});try{const V=await Xs(D,z);console.log(V);let bt=!1,ea=null;for(let It=0;It<240;It++){const _e=await va();if(_e.loading&&Oe({progress:_e.loading.progress||0,phase:_e.loading.phase||"Loading model...",speed:_e.loading.speed||"",current:_e.loading.current||0,total:_e.loading.total||0,model:_e.loading.model||D,backendMode:_e.loading.backendMode||_e.settings?.backendMode||"",backendBinary:_e.loading.backendBinary||_e.settings?.backendBinary||"",device:_e.loading.device||_e.settings?.backendDevice||""}),_e.ready){bt=!0;break}if(_e.error){ea=_e.error;break}if(!_e.running&&It>3){ea="The backend process terminated immediately on startup.";break}await new Promise(Y=>setTimeout(Y,500))}if(bt)Oe(It=>({...It||{},progress:100,phase:"Model ready",speed:"",current:It?.current||0,total:It?.total||0,model:D})),S(D),r(!0);else throw new Error(ea||"Model server failed to respond on port 8080.")}catch(V){console.error("Failed to load model:",V),A({title:"Model Load Failed",message:V.message||String(V),danger:!0})}finally{setTimeout(()=>Oe(null),800),ne(null)}},ct=async()=>{const D=Ye;x(null),await ot(),D&&await Ee(D)},ot=async()=>{if(pe)return;Ke(!0),Je({progress:10,phase:"Stopping backend process..."});const D=setInterval(async()=>{try{const R=await va();R.unloading?.active?Je({progress:R.unloading.progress||50,phase:R.unloading.phase||"Unloading model..."}):Je(I=>({progress:Math.min(95,I.progress+10),phase:I.phase||"Unloading model..."}))}catch{}},300);try{await Zs(),Je({progress:100,phase:"Model unloaded"}),S(null),x(null),r(!1)}catch(R){console.error(R),A({title:"Unload Failed",message:R.message||String(R),danger:!0})}finally{clearInterval(D),setTimeout(()=>{Ke(!1),Je({progress:0,phase:""})},500)}},ht=async D=>{if(await L({title:"Delete Model?",message:`Delete "${D}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await Ky(D),await w(),f===D&&await ot()}catch(R){console.error("Failed to delete model:",R),A({title:"Delete Failed",message:R.message||String(R),danger:!0})}},cl=async(D,R)=>{const I=new AbortController;jt(I),Le(0),Me({filename:R,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Zy(D,V=>{Le(Math.round(V.progress)),Me({filename:V.filename,speed:V.speed_mb_s.toFixed(1),eta:Math.round(V.eta_secs),status:V.status})},I.signal),await w()}catch(V){console.error("Import failed:",V),V.name!=="AbortError"&&A({title:"Import Failed",message:V.message||String(V),danger:!0})}finally{Le(null),jt(null)}},Ut=()=>{et&&et.abort()},k=D=>{const R=D.target.files[0];R&&cl(R,R.name),D.target.value=""},ce=!!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."}),(C.backendMode||C.backendDevice||C.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[C.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(Su,{size:14}),c.jsxs("span",{children:["Loaded on ",C.backendMode]})]}),C.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendDevice})}),C.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ot,disabled:pe||W!==null,children:[pe?c.jsx(Il,{className:"progress-spinner",size:16}):c.jsx(li,{size:16}),c.jsx("span",{children:pe?"Unloading":"Unload Server"})]})]})}),pe&&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:ut.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round(ut.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",childr
Line truncated
|
||||
|
||||
Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){pe(!0);try{await By(de.map(D=>D.id)),await le()}catch(D){A({title:"Cleanup Failed",message:D.message||String(D),danger:!0})}finally{pe(!1)}}},[de,le,A,z]);U.useEffect(()=>{async function k(){const ce=await Ly();Ye(ce)}k()},[]),U.useEffect(()=>{q?localStorage.setItem("active-model",q):localStorage.removeItem("active-model")},[q]),U.useEffect(()=>{let k=null;async function ce(){const D=await va();if(!!D.ready){k&&clearInterval(k);const I=localStorage.getItem("active-model");if(I)W(I),F(!0);else{try{if(D&&D.settings&&D.settings.model){const V=D.settings.model.split(/[\\/]/).pop();W(V)}}catch{}F(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const V=localStorage.getItem("active-model");V&&(W(V),F(!1))}}return ce(),k=setInterval(ce,2e3),()=>{k&&clearInterval(k)}},[]),U.useEffect(()=>{async function k(){try{const D=await Hy();w(R=>R.cpu_usage===D.cpu_usage&&R.ram_used_gb===D.ram_used_gb&&R.ram_total_gb===D.ram_total_gb&&R.gpu_name===D.gpu_name&&R.vram_used_gb===D.vram_used_gb&&R.vram_total_gb===D.vram_total_gb?R:D)}catch{}}k();const ce=setInterval(k,1500);return()=>clearInterval(ce)},[]),U.useEffect(()=>{if(q){const k=q.toLowerCase();k.includes("flux")||k.includes("schnell")?J(ce=>({...ce,steps:4,cfgScale:1,width:1024,height:1024})):k.includes("lightning")||k.includes("turbo")?J(ce=>({...ce,steps:4,cfgScale:1.5,width:1024,height:1024})):k.includes("sd15")?J(ce=>({...ce,steps:25,cfgScale:7,width:512,height:512})):k.includes("sd35")?J(ce=>({...ce,steps:20,cfgScale:4.5,width:1024,height:1024})):J(ce=>({...ce,steps:20,cfgScale:7,width:512,height:512}))}},[q]);const Ee=U.useMemo(()=>{switch(B){case"generator":return c.jsx(e1,{prompt:E,setPrompt:O,negativePrompt:Z,setNegativePrompt:ee,constraints:G,setConstraints:J,activeModel:q,generatedImages:Je,setGeneratedImages:Ye,isGenerating:x,setIsGenerating:C,generationProgress:K,setGenerationProgress:ge,setActiveTab:y,showAlert:A,showConfirm:z});case"models":return c.jsx(a1,{activeModel:q,setActiveModel:W,serverRunning:ne,setServerRunning:F,constraints:G,showAlert:A,showConfirm:z});case"constraints":return c.jsx(u1,{constraints:G,setConstraints:J,activeModel:q,specs:oe,backendOptions:Le});default:return null}},[B,E,Z,G,q,Je,x,K,ne,oe,Le,A,z]),ct=U.useMemo(()=>c.jsx(Ty,{activeTab:B,setActiveTab:y,specs:oe}),[B,oe]),ot=U.useCallback(async()=>{if(!(!ne||Oe)){ye(!0);try{await Zs(),F(!1),W(null)}catch(k){console.error("Failed to stop server:",k),A({title:"Stop Server Failed",message:k.message||String(k),danger:!0})}finally{ye(!1)}}},[ne,Oe,A]),ht=[...Me?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...Me?.issues||[]],cl=de.reduce((k,ce)=>k+Number(ce.sizeBytes||0),0),Ut=!!(Me&&(ht.length>0||de.length>0));return c.jsxs("div",{className:"app-container",children:[ct,c.jsxs("div",{className:"main-content",children:[c.jsx(Ey,{telemetry:_,serverRunning:ne,activeModel:q,onStopServer:ot,isStoppingServer:Oe,theme:L,setTheme:H}),Ut&&c.jsxs("div",{className:`m3-card readiness-card ${Me?.stale||ht.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:Me?.stale?"Restart Required":ht.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:Me?.stale?`Running server build: ${Me.build||"unknown"}`:ht.length>0?"Local AI Image Generator found setup items that may need attention.":`${de.length} temporary item${de.length===1?"":"s"} can be cleaned (${ai(cl)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:le,disabled:jt,children:jt?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:re,children:Ke?"Copied":"Copy Diagnostics"}),de.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:Ze,disabled:jt,children:["Clean ",ai(cl)]})]})]}),ht.length>0&&c.jsx("div",{className:"readiness-issues",children:ht.slice(0,4).map(k=>c.jsx("span",{children:k},k))}),de.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:de.slice(0,3).map(k=>c.jsxs("span",{title:k.path,children:[k.name," · ",k.size," · ",k.reason]},k.id))})]}),Ee]}),S&&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:S.title}),c.jsx("p",{className:"app-dialog-message",children:S.message}),c.jsxs("div",{className:"app-dialog-actions",children:[S.type==="confirm"&&c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>r(!1),children:S.cancelLabel}),c.jsx("button",{className:`m3-btn ${S.danger?"m3-btn-error":"m3-btn-filled"}`,onClick:()=>r(!0),children:S.con
Line truncated
|
||||
Vendored
-121
@@ -1,121 +0,0 @@
|
||||
(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 N of _)if(N.type==="childList")for(const G of N.addedNodes)G.tagName==="LINK"&&G.rel==="modulepreload"&&r(G)}).observe(document,{childList:!0,subtree:!0});function E(_){const N={};return _.integrity&&(N.integrity=_.integrity),_.referrerPolicy&&(N.referrerPolicy=_.referrerPolicy),_.crossOrigin==="use-credentials"?N.credentials="include":_.crossOrigin==="anonymous"?N.credentials="omit":N.credentials="same-origin",N}function r(_){if(_.ep)return;_.ep=!0;const N=E(_);fetch(_.href,N)}})();function sm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Us={exports:{}},ei={};var Zd;function E0(){if(Zd)return ei;Zd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function E(r,_,N){var G=null;if(N!==void 0&&(G=""+N),_.key!==void 0&&(G=""+_.key),"key"in _){N={};for(var H in _)H!=="key"&&(N[H]=_[H])}else N=_;return _=N.ref,{$$typeof:f,type:r,key:G,ref:_!==void 0?_:null,props:N}}return ei.Fragment=b,ei.jsx=E,ei.jsxs=E,ei}var Vd;function N0(){return Vd||(Vd=1,Us.exports=E0()),Us.exports}var c=N0(),ws={exports:{}},ie={};var Kd;function A0(){if(Kd)return ie;Kd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),G=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),L=Symbol.iterator;function Z(d){return d===null||typeof d!="object"?null:(d=L&&d[L]||d["@@iterator"],typeof d=="function"?d:null)}var V={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},W=Object.assign,ue={};function F(d,j,w){this.props=d,this.context=j,this.refs=ue,this.updater=w||V}F.prototype.isReactComponent={},F.prototype.setState=function(d,j){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,j,"setState")},F.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function Ce(){}Ce.prototype=F.prototype;function Te(d,j,w){this.props=d,this.context=j,this.refs=ue,this.updater=w||V}var Qe=Te.prototype=new Ce;Qe.constructor=Te,W(Qe,F.prototype),Qe.isPureReactComponent=!0;var Le=Array.isArray;function Me(){}var te={H:null,A:null,T:null,S:null},Se=Object.prototype.hasOwnProperty;function ft(d,j,w){var q=w.ref;return{$$typeof:f,type:d,key:j,ref:q!==void 0?q:null,props:w}}function _t(d,j){return ft(d.type,j,d.props)}function ye(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Ve(d){var j={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(w){return j[w]})}var nt=/\/+/g;function Ke(d,j){return typeof d=="object"&&d!==null&&d.key!=null?Ve(""+d.key):j.toString(36)}function Ye(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Me,Me):(d.status="pending",d.then(function(j){d.status==="pending"&&(d.status="fulfilled",d.value=j)},function(j){d.status==="pending"&&(d.status="rejected",d.reason=j)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,j,w,q,J){var ae=typeof d;(ae==="undefined"||ae==="boolean")&&(d=null);var de=!1;if(d===null)de=!0;else switch(ae){case"bigint":case"string":case"number":de=!0;break;case"object":switch(d.$$typeof){case f:case b:de=!0;break;case A:return de=d._init,x(de(d._payload),j,w,q,J)}}if(de)return J=J(d),de=q===""?"."+Ke(d,0):q,Le(J)?(w="",de!=null&&(w=de.replace(nt,"$&/")+"/"),x(J,j,w,"",function(it){return it})):J!=null&&(ye(J)&&(J=_t(J,w+(J.key==null||d&&d.key===J.key?"":(""+J.key).replace(nt,"$&/")+"/")+de)),j.push(J)),1;de=0;var ke=q===""?".":q+":";if(Le(d))for(var Ee=0;Ee<d.length;Ee++)q=d[Ee],ae=ke+Ke(q,Ee),de+=x(q,j,w,ae,J);else if(Ee=Z(d),typeof Ee=="function")for(d=Ee.call(d),Ee=0;!(q=d.next()).done;)q=q.value,ae=ke+Ke(q,Ee++),de+=x(q,j,w,ae,J);else if(ae==="object"){if(typeof d.then=="function")return x(Ye(d),j,w,q,J);throw j=String(d),Error("Objects are not valid as a React child (found: "+(j==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":j)+"). If you meant to render a collection of children, use an array instead.")}return de}function C(d,j,w){if(d==null)return d;var q=[],J=0;return x(d,q,"","",function(ae){return j.call(w,ae,J++)}),q}function K(d){if(d._status===-1){var j=d._result;j=j(),j.then(function(w){(d._status===0||d._status===-1)&&(d._status=1,d._result=w)},function(w){(d._status===0||d._status===-1)&&(d._status=2,d._result=w)}),dLine truncated
|
||||
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||||
`+ht+e+cl}var k=!1;function se(e,t){if(!e||k)return"";k=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var M=function(){throw Error()};if(Object.defineProperty(M.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(M,[])}catch(S){var v=S}Reflect.construct(e,[],M)}else{try{M.call()}catch(S){v=S}e.call(M.prototype)}}else{try{throw Error()}catch(S){v=S}(M=e())&&typeof M.catch=="function"&&M.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(`
|
||||
`),p=s.split(`
|
||||
`);for(n=a=0;a<o.length&&!o[a].includes("DetermineComponentFrameRoot");)a++;for(;n<p.length&&!p[n].includes("DetermineComponentFrameRoot");)n++;if(a===o.length||n===p.length)for(a=o.length-1,n=p.length-1;1<=a&&0<=n&&o[a]!==p[n];)n--;for(;1<=a&&0<=n;a--,n--)if(o[a]!==p[n]){if(a!==1||n!==1)do if(a--,n--,0>n||o[a]!==p[n]){var z=`
|
||||
`+o[a].replace(" at new "," at ");return e.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",e.displayName)),z}while(1<=a&&0<=n);break}}}finally{k=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ut(l):""}function D(e,t){switch(e.tag){case 26:case 27:case 5:return Ut(e.type);case 16:return Ut("Lazy");case 13:return e.child!==t&&t!==null?Ut("Suspense Fallback"):Ut("Suspense");case 19:return Ut("SuspenseList");case 0:case 15:return se(e.type,!1);case 11:return se(e.type.render,!1);case 1:return se(e.type,!0);case 31:return Ut("Activity");default:return""}}function R(e){try{var t="",l=null;do t+=D(e,l),l=e,e=e.return;while(e);return t}catch(a){return`
|
||||
Error generating stack: `+a.message+`
|
||||
`+a.stack}}var I=Object.prototype.hasOwnProperty,P=f.unstable_scheduleCallback,Tt=f.unstable_cancelCallback,It=f.unstable_shouldYield,sl=f.unstable_requestPaint,ut=f.unstable_now,Y=f.unstable_getCurrentPriorityLevel,le=f.unstable_ImmediatePriority,He=f.unstable_UserBlockingPriority,Pe=f.unstable_NormalPriority,jt=f.unstable_LowPriority,ll=f.unstable_IdlePriority,xa=f.log,_a=f.unstable_setDisableYieldValue,We=null,ne=null;function fe(e){if(typeof xa=="function"&&_a(e),ne&&typeof ne.setStrictMode=="function")try{ne.setStrictMode(We,e)}catch{}}var pe=Math.clz32?Math.clz32:Re,Ne=Math.log,ct=Math.LN2;function Re(e){return e>>>=0,e===0?32:31-(Ne(e)/ct|0)|0}var rt=256,St=262144,wt=4194304;function fl(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 ii(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=fl(a):(u&=s,u!==0?n=fl(u):l||(l=s&~e,l!==0&&(n=fl(l))))):(s=a&~i,s!==0?n=fl(s):u!==0?n=fl(u):l||(l=a&~e,l!==0&&(n=fl(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 fn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function hm(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=wt;return wt<<=1,(wt&62914560)===0&&(wt=4194304),e}function xu(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function on(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ym(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,p=e.hiddenUpdates;for(l=u&~l;0<l;){var z=31-pe(l),M=1<<z;s[z]=0,o[z]=-1;var v=p[z];if(v!==null)for(p[z]=null,z=0;z<v.length;z++){var S=v[z];S!==null&&(S.lane&=-536870913)}l&=~M}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-pe(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-pe(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=C.p;return e!==0?e:(e=window.event,e===void 0?32:Gd(e.type))}function Is(e,t){var l=C.p;try{return C.p=e,t()}finally{C.p=l}}var Al=Math.random().toString(36).slice(2),yt="__reactFiber$"+Al,Mt="__reactProps$"+Al,ja="__reactContainer$"+Al,zu="__reactEvents$"+Al,gm="__reactListeners$"+Al,pm="__reactHandles$"+Al,Ps="__reactResources$"+Al,rn="__reactMarker$"+Al;function Tu(e){delete e[yt],delete e[Mt],delete e[zu],delete e[gm],delete e[pm]}function za(e){var t=e[yt];if(t)return t;for(var l=e.parentNode;l;){if(t=l[ja]||l[yt]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=_d(e);e!==null;){if(l=e[yt])return l;e=_d(e)}return t}e=l,l=e.parentNode}return null}function Ta(e){if(e=e[yt]||e[ja]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function dn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ma(e){var t=e[Ps];return t||(t=e[Ps]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function dt(e){e[rn]=!0}var ef=new Set,tf={};function aa(e,t){Ea(e,t),Ea(e+"Capture",t)}function Ea(e,t){for(tf[e]=t,e=0;e<t.length;e++)ef.add(t[e])}var vm=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\
Line truncated
|
||||
`).replace($h,"")}function dd(e,t){return t=rd(t),rd(e)===t}function Ue(e,t,l,a,n,i){switch(l){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Aa(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Aa(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"&&Ue(e,t,"name",n.name,n,null),Ue(e,t,"formEncType",n.formEncType,n,null),Ue(e,t,"formMethod",n.formMethod,n,null),Ue(e,t,"formTarget",n.formTarget,n,null)):(Ue(e,t,"encType",n.encType,n,null),Ue(e,t,"method",n.method,n,null),Ue(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&&he("scroll",e);break;case"onScrollEnd":a!=null&&he("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":he("beforetoggle",e),he("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=jm.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"?Aa(e,a):(typeof a=="number"||typeof a=="bigint")&&Aa(e,""+a);break;case"onScroll":a!=null&&he("scroll",e);break;case"onScrollEnd":a!=null&&he("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" />
|
||||
`):Z.includes("cat")||Z.includes("kitten")||Z.includes("feline")?(W="#4F46E5",ue="#7C3AED",Ce="Stylized Cat Portrait",F=`
|
||||
<!-- 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" />
|
||||
`):Z.includes("dog")||Z.includes("puppy")||Z.includes("canine")?(W="#D97706",ue="#B45309",Ce="Friendly Dog Portrait",F=`
|
||||
<!-- 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" />
|
||||
`):Z.includes("city")||Z.includes("cyberpunk")||Z.includes("tokyo")||Z.includes("neon")?(W="#111827",ue="#311042",Ce="Neon Cyberpunk Skyline",F=`
|
||||
<!-- 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"/>
|
||||
`):Z.includes("car")||Z.includes("vehicle")||Z.includes("supercar")?(W="#DC2626",ue="#991B1B",Ce="Futuristic Concept Car",F=`
|
||||
<!-- 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" />
|
||||
`):(W="#06B6D4",ue="#0891B2",Ce="Abstract Creative Concept",F=`
|
||||
<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 Te=`
|
||||
<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="${W}" />
|
||||
<stop offset="100%" stop-color="${ue}" />
|
||||
</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 -->
|
||||
${F}
|
||||
|
||||
<!-- 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: ${V} • Steps: ${y.steps} • Scale: ${y.cfg_scale}</text>
|
||||
</svg>
|
||||
`,Le=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Te)))}`,Me=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:Le,seed:y.seed,duration_sec:Me}},O={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};try{const L=await fetch(`${B}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:G,body:JSON.stringify(O)});if(L.ok){const Z=await L.json(),V=Z?.data?.[0]?.b64_json??Z?.images?.[0];if(V){const W=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:`data:image/png;base64,${V}`,seed:Z.data?.[0]?.seed??y.seed,duration_sec:W}}}else{let Z=`Generation failed (HTTP ${L.status})`;try{const V=await L.json();(V?.detail||V?.error?.message)&&(Z=V.detail||V.error.message)}catch{}throw new Error(Z)}}catch(L){if(L.name==="AbortError"||L.message.startsWith("Generation failed"))throw L;console.warn("Could not reach local server. Falling back to simulation mode.",L)}return await A()}async function Vy(f,b,E){if(f instanceof File){const H=f;if(!ta())throw new Error("File import requires the local image generator server.");return await Ky(H,b,E),{response:"Model imported successfully"}}if(la()){const{listen:H}=await Cy(async()=>{const{listen:y}=await import("./event-DtK1umGE.js");return{listen:y}},[]);let B=null;b&&(B=await H("import-progress",y=>{b(y.payload)}));try{return{response:await Sa("import_model_file",{sourcePath:f}),unlisten:B}}catch(y){throw B&&B(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const _=40;for(let H=1;H<=_;H++){if(E?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(O=>setTimeout(O,150));const B=H/_*100,y=40+Math.sin(H)*5+Math.random()*2,A=(_-H)*.15;b&&b({filename:r,progress:B,speed_mb_s:y,eta_secs:A,status:"Copying to USB..."})}const N=localStorage.getItem("imported-models"),G=N?JSON.parse(N):[];return G.includes(r)||(G.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(G))),{response:"Model imported successfully"}}function Ky(f,b,E){return new Promise((r,_)=>{const N=new XMLHttpRequest,G=Date.now();let H=!1;N.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),N.setRequestHeader("Content-Type","application/octet-stream");const B=()=>{H=!0,N.abort()};E&&(E.aborted?B():E.addEventListener("abort",B,{once:!0})),N.upload.onprogress=y=>{if(!y.lengthComputable||!b)return;const A=Math.max(.1,(Date.now()-G)/1e3),O=y.loaded/A,L=Math.max(0,y.total-y.loaded);b({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:O/(1024*1024),eta_secs:L/Math.max(1,O),status:"Copying to models folder..."})},N.onload=()=>{let y={};try{y=JSON.parse(N.responseText||"{}")}catch{}N.status>=200&&N.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 ${N.status})`))},N.onerror=()=>_(new Error("Import failed while uploading the file.")),N.onabort=()=>_(new DOMException(H?"Import cancelled by user.":"Import aborted.","AbortError")),N.send(f)})}async function Jy(f){if(la())return await Sa("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})}),N=await _.json();if(!_.ok)throw new Error(N.error||"Failed to delete model file");return N}catch(_){throw console.error("Failed to delete model via local API:",_),_}const E=localStorage.getItem("imported-models");let r=E?JSON.parse(E):[];return r=r.filter(_=>ni(_).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function mm(){const f=await dm();try{return(await fetch(`${f}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function $y(f=30){const b=la()||ta()?f:3;for(let E=0;E<b;E++){let r=!1;if(ta()?r=!!(await Nl()).ready:r=await mm(),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 Fy(){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 Iy(){try{return await(await fetch("/api/generation-progress")).json()}catch(f){ret
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"}),E&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Ls,{size:14})})]})});function e1({prompt:f,setPrompt:b,negativePrompt:E,setNegativePrompt:r,constraints:_,setConstraints:N,activeModel:G,generatedImages:H,setGeneratedImages:B,isGenerating:y,setIsGenerating:A,generationProgress:O,setGenerationProgress:L,setActiveTab:Z,showAlert:V=async({message:ue})=>window.alert(ue),showConfirm:W=async({message:ue})=>window.confirm(ue)}){const[ue,F]=U.useState(null),[Ce,Te]=U.useState(null),[Qe,Le]=U.useState(null),[Me,te]=U.useState(!1),[Se,ft]=U.useState(0),[_t,ye]=U.useState(0),[Ve,nt]=U.useState(0),[Ke,Ye]=U.useState(""),[x,C]=U.useState(!1),[K,ge]=U.useState(!1),[re,d]=U.useState(!1),[j,w]=U.useState(null),[q,J]=U.useState(null),[ae,de]=U.useState(!1),[ke,Ee]=U.useState([]),it=U.useRef(null),ot=U.useRef(null),ht=U.useRef(!1),cl=async()=>{if(!f.trim())return;J(null),d(!0),w(null);let Y=!1;try{const ne=await Nl();if(ne&&ne.settings){const fe=ne.settings,pe=fe.model?fe.model.split(/[\\/]/).pop():null,Ne=G?G.split(/[\\/]/).pop():null;(pe!==Ne||parseInt(fe.steps)!==parseInt(_.steps)||Math.abs(parseFloat(fe.cfgScale)-parseFloat(_.cfgScale))>.05||fe.sampler!==_.sampler||parseInt(fe.threads)!==parseInt(_.threads)||!!fe.useGpu!=(_.useGpu!==!1)||(fe.backendType||(fe.useGpu===!1?"cpu":"auto"))!==(_.backendType||(_.useGpu===!1?"cpu":"auto")))&&(Y=!0)}else Y=!0}catch{Y=!0}if(Y)try{console.log("Settings out of sync, restarting backend..."),await Qs(G,_);let ne=!1,fe=null;for(let pe=0;pe<240;pe++){const Ne=await Nl();if(Ne.loading&&w({progress:Ne.loading.progress||0,phase:Ne.loading.phase||"Loading model...",speed:Ne.loading.speed||"",current:Ne.loading.current||0,total:Ne.loading.total||0,backendMode:Ne.loading.backendMode||Ne.settings?.backendMode||"",device:Ne.loading.device||Ne.settings?.backendDevice||""}),Ne.ready){ne=!0;break}if(Ne.error){fe=Ne.error;break}if(!Ne.running&&pe>3){fe="The backend process terminated immediately on startup.";break}await new Promise(ct=>setTimeout(ct,500))}if(!ne)throw new Error(fe||"Backend server failed to start after applying configuration changes.")}catch(ne){console.error("Failed to restart backend:",ne),J(ne.message||"Failed to sync settings with backend."),d(!1);return}d(!1),w(null),it.current&&clearInterval(it.current),A(!0),L(0),ft(0),nt(0),Ye(""),ht.current=!1,C(!1),de(!1),Le(null),F(null);const le=(_.width>=1024?140:35)*.04,He=_.width>=1024?140:35,Pe=(_.backendType||(_.useGpu===!1?"cpu":"auto"))!=="cpu";let jt=Pe?le:He,ll=!1,xa=0,_a=0,We=0;ye(Math.round(_.steps*jt)),it.current=setInterval(async()=>{We++,ft(We);try{const ne=await Iy();if(ne&&ne.active){const fe=ne.decoding||!1;de(fe);const pe=fe?ne.steps||_.steps||20:ne.step||0,Ne=ne.steps||_.steps||20,ct=fe?"":ne.speed||"";(fe||ne.steps>0)&&(ht.current=!0,nt(pe)),Ye(fe?"decoding":ct);let Re=0;fe?Re=99:Ne>0&&(Re=Math.round(pe/Ne*100)),Re=Math.min(99,Re),fe||ne.steps>0?L(Re):L(St=>Math.max(St,Re));let rt=0;if(fe)rt=3;else{const St=parseFloat(ct);if(!isNaN(St)&&St>0){const wt=Math.max(0,Ne-pe);ct.includes("it/s")?rt=wt/St:ct.includes("s/it")&&(rt=wt*St)}else{const wt=Pe?le:He;rt=Math.max(0,(Ne-pe)*wt)}}if(Pe&&!ll){const St=ct.includes("it/s")&&numericSpeed<.2,wt=ct.includes("s/it")&&numericSpeed>5;(St||wt)&&(ll=!0,C(!0))}ye(Math.round(rt))}else L(fe=>Math.min(15,fe+1)),ye(fe=>Math.max(1,fe-1))}catch(ne){console.warn("Failed to get generation progress, running simulation fallback:",ne),Pe&&!ll&&We>_.steps*le*1.3&&(ll=!0,C(!0),jt=He,xa=We,_a=Math.min(95,Math.round(We/(_.steps*le)*100)));let fe=Math.min(_.steps-1,Math.floor(We/jt)),pe=_.steps*jt;if(We>=pe){const Re=Math.ceil(We/Math.max(.5,fe));jt=Math.max(jt+15,Re+15),pe=_.steps*jt,fe=Math.min(_.steps-1,Math.floor(We/jt))}const Ne=Math.max(1,pe-We);ye(Math.round(Ne));let ct=0;if(ll){const Re=99-_a,rt=pe-xa;if(rt>0){const St=Math.min(1,(We-xa)/rt);if(St<.85)ct=Math.round(_a+St*Re);else{const wt=(We-(xa+rt*.85))/(jt*2),fl=1-Math.exp(-wt);ct=Math.min(99,Math.round(_a+.85*Re+.14*Re*fl))}}else ct=99}else if(We<pe*.85)ct=Math.round(We/pe*100);else{const Re=(We-pe*.85)/(jt*2),rt=1-Math.exp(-Re);ct=Math.min(99,Math.round(85+14*rt))}ht.current||L(Re=>Math.max(Re,ct))}},1e3);try{ot.current=new AbortController;const ne=await Zy(f,E,_,G,null,Re=>L(rt=>Math.max(rt,Re)),ot.current.signal);it.current&&clearInterval(it.current),L(100),nt(_.steps),ye(0),Ye("");const fe={prompt:f,negativePrompt:E,seed:ne.seed,steps:_.steps,cfgScale:_.cfgScale,width:_.width,height:_.height,sampler:_.sampler,model:G,duration_sec:ne.duration_sec,timestamp:new Date().toLocaleTimeString()};let pe=null,Ne=null;try{if(pe=await Xy(ne.image,fe),Ne=pe.url,!Ne)throw new Error("The local server saved the image but did not return a file URL.")}catch(Re){throw console.error("Generated image could not be saved:",Re),new Error(`Image generated but could not be saved to USB: ${Re.mLine truncated
|
||||
|
||||
${sl}
|
||||
|
||||
Update the UI status anyway?`,confirmLabel:"Update UI"})&&(b(D),r(!0)):await G({title:"Backend Not Running",message:`C++ backend server is not running on port ${Tt}.
|
||||
|
||||
To run locally, start:
|
||||
|
||||
${sl}
|
||||
|
||||
Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(D),r(!1));return}ue(D),Ce({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:D,backendMode:"",backendBinary:"",device:""});try{const It=await Qs(D,_);console.log(It);let sl=!1,ut=null;for(let Y=0;Y<240;Y++){const le=await Nl();if(le.loading&&Ce({progress:le.loading.progress||0,phase:le.loading.phase||"Loading model...",speed:le.loading.speed||"",current:le.loading.current||0,total:le.loading.total||0,model:le.loading.model||D,backendMode:le.loading.backendMode||le.settings?.backendMode||"",backendBinary:le.loading.backendBinary||le.settings?.backendBinary||"",device:le.loading.device||le.settings?.backendDevice||""}),le.ready){sl=!0;break}if(le.error){ut=le.error;break}if(!le.running&&Y>3){ut="The backend process terminated immediately on startup.";break}await new Promise(He=>setTimeout(He,500))}if(sl)Ce(Y=>({...Y||{},progress:100,phase:"Model ready",speed:"",current:Y?.current||0,total:Y?.total||0,model:D})),b(D),r(!0);else throw new Error(ut||`Model server failed to respond on port ${Tt}.`)}catch(It){console.error("Failed to load model:",It),N({title:"Model Load Failed",message:It.message||String(It),danger:!0})}finally{setTimeout(()=>Ce(null),800),ue(null)}},it=async()=>{const D=Ye;x(null),await ot(),D&&await Ee(D)},ot=async()=>{if(ye)return;Ve(!0),Ke({progress:10,phase:"Stopping backend process..."});const D=setInterval(async()=>{try{const R=await Nl();R.unloading?.active?Ke({progress:R.unloading.progress||50,phase:R.unloading.phase||"Unloading model..."}):Ke(I=>({progress:Math.min(95,I.progress+10),phase:I.phase||"Unloading model..."}))}catch{}},300);try{await Vs(),Ke({progress:100,phase:"Model unloaded"}),b(null),x(null),r(!1)}catch(R){console.error(R),N({title:"Unload Failed",message:R.message||String(R),danger:!0})}finally{clearInterval(D),setTimeout(()=>{Ve(!1),Ke({progress:0,phase:""})},500)}},ht=async D=>{if(await G({title:"Delete Model?",message:`Delete "${D}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await Jy(D),await w(),f===D&&await ot()}catch(R){console.error("Failed to delete model:",R),N({title:"Delete Failed",message:R.message||String(R),danger:!0})}},cl=async(D,R)=>{const I=new AbortController;_t(I),Qe(0),Me({filename:R,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Vy(D,P=>{Qe(Math.round(P.progress)),Me({filename:P.filename,speed:P.speed_mb_s.toFixed(1),eta:Math.round(P.eta_secs),status:P.status})},I.signal),await w()}catch(P){console.error("Import failed:",P),P.name!=="AbortError"&&N({title:"Import Failed",message:P.message||String(P),danger:!0})}finally{Qe(null),_t(null)}},Ut=()=>{ft&&ft.abort()},k=D=>{const R=D.target.files[0];R&&cl(R,R.name),D.target.value=""},se=!!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."}),(C.backendMode||C.backendDevice||C.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[C.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(bu,{size:14}),c.jsxs("span",{children:["Loaded on ",C.backendMode]})]}),C.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendDevice})}),C.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ot,disabled:ye||W!==null,children:[ye?c.jsx(ea,{className:"progress-spinner",size:16}):c.jsx(li,{size:16}),c.jsx("span",{children:ye?"Unloading":"Unload Server"})]})]})}),ye&&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:nt.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round(nt.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",child
Line truncated
|
||||
|
||||
Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){ye(!0);try{await Ry(Se.map(D=>D.id)),await ae()}catch(D){N({title:"Cleanup Failed",message:D.message||String(D),danger:!0})}finally{ye(!1)}}},[Se,ae,N,_]);U.useEffect(()=>{async function k(){const se=await Yy();Ye(se)}k()},[]),U.useEffect(()=>{V?localStorage.setItem("active-model",V):localStorage.removeItem("active-model")},[V]),U.useEffect(()=>{let k=null;async function se(){const D=await Nl();if(!!D.ready){k&&clearInterval(k);const I=localStorage.getItem("active-model");if(I)W(I),F(!0);else{try{if(D&&D.settings&&D.settings.model){const P=D.settings.model.split(/[\\/]/).pop();W(P)}}catch{}F(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const P=localStorage.getItem("active-model");P&&(W(P),F(!1))}}return se(),k=setInterval(se,2e3),()=>{k&&clearInterval(k)}},[]),U.useEffect(()=>{async function k(){try{const D=await Gy();w(R=>R.cpu_usage===D.cpu_usage&&R.ram_used_gb===D.ram_used_gb&&R.ram_total_gb===D.ram_total_gb&&R.gpu_name===D.gpu_name&&R.vram_used_gb===D.vram_used_gb&&R.vram_total_gb===D.vram_total_gb?R:D)}catch{}}k();const se=setInterval(k,1500);return()=>clearInterval(se)},[]),U.useEffect(()=>{if(V){const k=V.toLowerCase();k.includes("flux")||k.includes("schnell")?J(se=>({...se,steps:4,cfgScale:1,width:1024,height:1024})):k.includes("lightning")||k.includes("turbo")?J(se=>({...se,steps:4,cfgScale:1.5,width:1024,height:1024})):k.includes("sd15")?J(se=>({...se,steps:25,cfgScale:7,width:512,height:512})):k.includes("sd35")?J(se=>({...se,steps:20,cfgScale:4.5,width:1024,height:1024})):J(se=>({...se,steps:20,cfgScale:7,width:512,height:512}))}},[V]);const Ee=U.useMemo(()=>{switch(B){case"generator":return c.jsx(t1,{prompt:A,setPrompt:O,negativePrompt:L,setNegativePrompt:Z,constraints:q,setConstraints:J,activeModel:V,generatedImages:Ke,setGeneratedImages:Ye,isGenerating:x,setIsGenerating:C,generationProgress:K,setGenerationProgress:ge,setActiveTab:y,showAlert:N,showConfirm:_});case"models":return c.jsx(n1,{activeModel:V,setActiveModel:W,serverRunning:ue,setServerRunning:F,constraints:q,showAlert:N,showConfirm:_});case"constraints":return c.jsx(c1,{constraints:q,setConstraints:J,activeModel:V,specs:re,backendOptions:Qe});default:return null}},[B,A,L,q,V,Ke,x,K,ue,re,Qe,N,_]),it=U.useMemo(()=>c.jsx(My,{activeTab:B,setActiveTab:y,specs:re}),[B,re]),ot=U.useCallback(async()=>{if(!(!ue||Ce)){Te(!0);try{await Vs(),F(!1),W(null)}catch(k){console.error("Failed to stop server:",k),N({title:"Stop Server Failed",message:k.message||String(k),danger:!0})}finally{Te(!1)}}},[ue,Ce,N]),ht=[...Me?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...Me?.issues||[]],cl=Se.reduce((k,se)=>k+Number(se.sizeBytes||0),0),Ut=!!(Me&&(ht.length>0||Se.length>0));return c.jsxs("div",{className:"app-container",children:[it,c.jsxs("div",{className:"main-content",children:[c.jsx(Ny,{telemetry:j,serverRunning:ue,activeModel:V,onStopServer:ot,isStoppingServer:Ce,theme:G,setTheme:H}),Ut&&c.jsxs("div",{className:`m3-card readiness-card ${Me?.stale||ht.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:Me?.stale?"Restart Required":ht.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:Me?.stale?`Running server build: ${Me.build||"unknown"}`:ht.length>0?"Local AI Image Generator found setup items that may need attention.":`${Se.length} temporary item${Se.length===1?"":"s"} can be cleaned (${ai(cl)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:ae,disabled:_t,children:_t?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:de,children:Ve?"Copied":"Copy Diagnostics"}),Se.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ke,disabled:_t,children:["Clean ",ai(cl)]})]})]}),ht.length>0&&c.jsx("div",{className:"readiness-issues",children:ht.slice(0,4).map(k=>c.jsx("span",{children:k},k))}),Se.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:Se.slice(0,3).map(k=>c.jsxs("span",{title:k.path,children:[k.name," · ",k.size," · ",k.reason]},k.id))})]}),Ee]}),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-filled"}`,onClick:()=>r(!0),children:b.conf
Line truncated
|
||||
Vendored
+121
@@ -0,0 +1,121 @@
|
||||
(function(){const b=document.createElement("link").relList;if(b&&b.supports&&b.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))r(x);new MutationObserver(x=>{for(const N of x)if(N.type==="childList")for(const G of N.addedNodes)G.tagName==="LINK"&&G.rel==="modulepreload"&&r(G)}).observe(document,{childList:!0,subtree:!0});function E(x){const N={};return x.integrity&&(N.integrity=x.integrity),x.referrerPolicy&&(N.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?N.credentials="include":x.crossOrigin==="anonymous"?N.credentials="omit":N.credentials="same-origin",N}function r(x){if(x.ep)return;x.ep=!0;const N=E(x);fetch(x.href,N)}})();function fm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Bs={exports:{}},ai={};var Zd;function E0(){if(Zd)return ai;Zd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function E(r,x,N){var G=null;if(N!==void 0&&(G=""+N),x.key!==void 0&&(G=""+x.key),"key"in x){N={};for(var H in x)H!=="key"&&(N[H]=x[H])}else N=x;return x=N.ref,{$$typeof:f,type:r,key:G,ref:x!==void 0?x:null,props:N}}return ai.Fragment=b,ai.jsx=E,ai.jsxs=E,ai}var Kd;function N0(){return Kd||(Kd=1,Bs.exports=E0()),Bs.exports}var c=N0(),Rs={exports:{}},le={};var Jd;function A0(){if(Jd)return le;Jd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),G=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),V=Symbol.iterator;function fe(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(){}},L=Object.assign,te={};function W(d,j,B){this.props=d,this.context=j,this.refs=te,this.updater=B||k}W.prototype.isReactComponent={},W.prototype.setState=function(d,j){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,j,"setState")},W.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function Oe(){}Oe.prototype=W.prototype;function de(d,j,B){this.props=d,this.context=j,this.refs=te,this.updater=B||k}var Ee=de.prototype=new Oe;Ee.constructor=de,L(Ee,W.prototype),Ee.isPureReactComponent=!0;var Xe=Array.isArray;function Ae(){}var P={H:null,A:null,T:null,S:null},ve=Object.prototype.hasOwnProperty;function Ke(d,j,B){var q=B.ref;return{$$typeof:f,type:d,key:j,ref:q!==void 0?q:null,props:B}}function yt(d,j){return Ke(d.type,j,d.props)}function me(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Je(d){var j={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(B){return j[B]})}var st=/\/+/g;function $e(d,j){return typeof d=="object"&&d!==null&&d.key!=null?Je(""+d.key):j.toString(36)}function ke(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Ae,Ae):(d.status="pending",d.then(function(j){d.status==="pending"&&(d.status="fulfilled",d.value=j)},function(j){d.status==="pending"&&(d.status="rejected",d.reason=j)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function _(d,j,B,q,K){var ee=typeof d;(ee==="undefined"||ee==="boolean")&&(d=null);var se=!1;if(d===null)se=!0;else switch(ee){case"bigint":case"string":case"number":se=!0;break;case"object":switch(d.$$typeof){case f:case b:se=!0;break;case A:return se=d._init,_(se(d._payload),j,B,q,K)}}if(se)return K=K(d),se=q===""?"."+$e(d,0):q,Xe(K)?(B="",se!=null&&(B=se.replace(st,"$&/")+"/"),_(K,j,B,"",function(gt){return gt})):K!=null&&(me(K)&&(K=yt(K,B+(K.key==null||d&&d.key===K.key?"":(""+K.key).replace(st,"$&/")+"/")+se)),j.push(K)),1;se=0;var Ze=q===""?".":q+":";if(Xe(d))for(var Ne=0;Ne<d.length;Ne++)q=d[Ne],ee=Ze+$e(q,Ne),se+=_(q,j,B,ee,K);else if(Ne=fe(d),typeof Ne=="function")for(d=Ne.call(d),Ne=0;!(q=d.next()).done;)q=q.value,ee=Ze+$e(q,Ne++),se+=_(q,j,B,ee,K);else if(ee==="object"){if(typeof d.then=="function")return _(ke(d),j,B,q,K);throw j=String(d),Error("Objects are not valid as a React child (found: "+(j==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":j)+"). If you meant to render a collection of children, use an array instead.")}return se}function C(d,j,B){if(d==null)return d;var q=[],K=0;return _(d,q,"","",function(ee){return j.call(B,ee,K++)}),q}function J(d){if(d._status===-1){var j=d._result;j=j(),j.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`
|
||||
`+We+e+Ht}var Z=!1;function ie(e,t){if(!e||Z)return"";Z=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var M=function(){throw Error()};if(Object.defineProperty(M.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(M,[])}catch(S){var v=S}Reflect.construct(e,[],M)}else{try{M.call()}catch(S){v=S}e.call(M.prototype)}}else{try{throw Error()}catch(S){v=S}(M=e())&&typeof M.catch=="function"&&M.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(`
|
||||
`),p=s.split(`
|
||||
`);for(n=a=0;a<o.length&&!o[a].includes("DetermineComponentFrameRoot");)a++;for(;n<p.length&&!p[n].includes("DetermineComponentFrameRoot");)n++;if(a===o.length||n===p.length)for(a=o.length-1,n=p.length-1;1<=a&&0<=n&&o[a]!==p[n];)n--;for(;1<=a&&0<=n;a--,n--)if(o[a]!==p[n]){if(a!==1||n!==1)do if(a--,n--,0>n||o[a]!==p[n]){var z=`
|
||||
`+o[a].replace(" at new "," at ");return e.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",e.displayName)),z}while(1<=a&&0<=n);break}}}finally{Z=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Tt(l):""}function D(e,t){switch(e.tag){case 26:case 27:case 5:return Tt(e.type);case 16:return Tt("Lazy");case 13:return e.child!==t&&t!==null?Tt("Suspense Fallback"):Tt("Suspense");case 19:return Tt("SuspenseList");case 0:case 15:return ie(e.type,!1);case 11:return ie(e.type.render,!1);case 1:return ie(e.type,!0);case 31:return Tt("Activity");default:return""}}function R(e){try{var t="",l=null;do t+=D(e,l),l=e,e=e.return;while(e);return t}catch(a){return`
|
||||
Error generating stack: `+a.message+`
|
||||
`+a.stack}}var F=Object.prototype.hasOwnProperty,ae=f.unstable_scheduleCallback,At=f.unstable_cancelCallback,Gt=f.unstable_shouldYield,dl=f.unstable_requestPaint,Re=f.unstable_now,al=f.unstable_getCurrentPriorityLevel,Fe=f.unstable_ImmediatePriority,za=f.unstable_UserBlockingPriority,Ta=f.unstable_NormalPriority,Y=f.unstable_LowPriority,ye=f.unstable_IdlePriority,He=f.log,pt=f.unstable_setDisableYieldValue,ft=null,tt=null;function qt(e){if(typeof He=="function"&&pt(e),tt&&typeof tt.setStrictMode=="function")try{tt.setStrictMode(ft,e)}catch{}}var rt=Math.clz32?Math.clz32:xe,vt=Math.log,Se=Math.LN2;function xe(e){return e>>>=0,e===0?32:31-(vt(e)/Se|0)|0}var Ge=256,_e=262144,Ie=4194304;function je(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 dt(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=je(a):(u&=s,u!==0?n=je(u):l||(l=s&~e,l!==0&&(n=je(l))))):(s=a&~i,s!==0?n=je(s):u!==0?n=je(u):l||(l=a&~e,l!==0&&(n=je(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 bt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function cl(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 ci(){var e=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),e}function ju(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function mn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ym(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,p=e.hiddenUpdates;for(l=u&~l;0<l;){var z=31-rt(l),M=1<<z;s[z]=0,o[z]=-1;var v=p[z];if(v!==null)for(p[z]=null,z=0;z<v.length;z++){var S=v[z];S!==null&&(S.lane&=-536870913)}l&=~M}a!==0&&$s(e,a,0),i!==0&&n===0&&e.tag!==0&&(e.suspendedLanes|=i&~(u&~t))}function $s(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 Ws(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:zu(l),(l&(e.suspendedLanes|t))!==0?0:l}function zu(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 Tu(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Is(){var e=C.p;return e!==0?e:(e=window.event,e===void 0?32:qd(e.type))}function Ps(e,t){var l=C.p;try{return C.p=e,t()}finally{C.p=l}}var Ol=Math.random().toString(36).slice(2),St="__reactFiber$"+Ol,Dt="__reactProps$"+Ol,Ma="__reactContainer$"+Ol,Mu="__reactEvents$"+Ol,gm="__reactListeners$"+Ol,pm="__reactHandles$"+Ol,ef="__reactResources$"+Ol,hn="__reactMarker$"+Ol;function Eu(e){delete e[St],delete e[Dt],delete e[Mu],delete e[gm],delete e[pm]}function Ea(e){var t=e[St];if(t)return t;for(var l=e.parentNode;l;){if(t=l[Ma]||l[St]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=jd(e);e!==null;){if(l=e[St])return l;e=jd(e)}return t}e=l,l=e.parentNode}return null}function Na(e){if(e=e[St]||e[Ma]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function yn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Aa(e){var t=e[ef];return t||(t=e[ef]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function mt(e){e[hn]=!0}var tf=new Set,lf={};function ua(e,t){Da(e,t),Da(e+"Capture",t)}function Da(e,t){for(lf[e]=t,e=0;e<t.length;e++)tf.add(t[e])}var vm=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F
Line truncated
|
||||
`).replace($h,"")}function md(e,t){return t=dd(t),dd(e)===t}function we(e,t,l,a,n,i){switch(l){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Oa(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Oa(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":df(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"&&we(e,t,"name",n.name,n,null),we(e,t,"formEncType",n.formEncType,n,null),we(e,t,"formMethod",n.formMethod,n,null),we(e,t,"formTarget",n.formTarget,n,null)):(we(e,t,"encType",n.encType,n,null),we(e,t,"method",n.method,n,null),we(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=hl);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":ml(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":ml(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":ml(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":ml(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":ml(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":ml(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":ml(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":ml(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":ml(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=jm.get(l)||l,si(e,l,a))}}function ps(e,t,l,a,n,i){switch(l){case"style":df(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"?Oa(e,a):(typeof a=="number"||typeof a=="bigint")&&Oa(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=hl);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" />
|
||||
`):L.includes("cat")||L.includes("kitten")||L.includes("feline")?(W="#4F46E5",Oe="#7C3AED",Ee="Stylized Cat Portrait",de=`
|
||||
<!-- 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" />
|
||||
`):L.includes("dog")||L.includes("puppy")||L.includes("canine")?(W="#D97706",Oe="#B45309",Ee="Friendly Dog Portrait",de=`
|
||||
<!-- 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" />
|
||||
`):L.includes("city")||L.includes("cyberpunk")||L.includes("tokyo")||L.includes("neon")?(W="#111827",Oe="#311042",Ee="Neon Cyberpunk Skyline",de=`
|
||||
<!-- 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"/>
|
||||
`):L.includes("car")||L.includes("vehicle")||L.includes("supercar")?(W="#DC2626",Oe="#991B1B",Ee="Futuristic Concept Car",de=`
|
||||
<!-- 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" />
|
||||
`):(W="#06B6D4",Oe="#0891B2",Ee="Abstract Creative Concept",de=`
|
||||
<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 Xe=`
|
||||
<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="${W}" />
|
||||
<stop offset="100%" stop-color="${Oe}" />
|
||||
</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 -->
|
||||
${de}
|
||||
|
||||
<!-- 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">${Ee}</text>
|
||||
<text x="60" y="455" fill="#94A3B8" font-family="system-ui, -apple-system, sans-serif" font-size="11">Seed: ${te} • Steps: ${h.steps} • Scale: ${h.cfg_scale}</text>
|
||||
</svg>
|
||||
`,P=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Xe)))}`,ve=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:P,seed:h.seed,duration_sec:ve}},U=!!h.image;let V=`${w}/v1/images/generations`,fe={prompt:h.prompt,negative_prompt:h.negative_prompt||"",n:1,size:`${h.width}x${h.height}`,response_format:"b64_json",steps:h.steps,cfg_scale:h.cfg_scale,seed:h.seed,sample_method:h.sampler};if(U){const k=String(h.image).replace(/^data:[^;]+;base64,/,"");V=`${w}/sdapi/v1/img2img`,fe={init_images:[k],prompt:h.prompt,negative_prompt:h.negative_prompt||"",denoising_strength:h.denoising_strength,steps:h.steps,cfg_scale:h.cfg_scale,seed:h.seed,width:h.width,height:h.height,sampler_name:h.sampler,sample_method:h.sampler,batch_size:1,n_iter:1,send_images:!0,save_images:!1}}try{const k=await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},signal:G,body:JSON.stringify(fe)});if(k.ok){const L=await k.json(),te=L?.data?.[0]?.b64_json??L?.images?.[0];if(te){const W=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:`data:image/png;base64,${te}`,seed:L.data?.[0]?.seed??h.seed,duration_sec:W}}}else{let L=`Generation failed (HTTP ${k.status})`;try{const te=await k.json();(te?.detail||te?.error?.message)&&(L=te.detail||te.error.message)}catch{}throw new Error(L)}}catch(k){if(k.name==="AbortError"||k.message.startsWith("Generation failed"))throw k;console.warn("Could not reach local server. Falling back to simulation mode.",k)}return await A()}async function Jy(f,b,E){if(f instanceof File){const H=f;if(!na())throw new Error("File import requires the local image generator server.");return await $y(H,b,E),{response:"Model imported successfully"}}if(ia()){const{listen:H}=await Uy(async()=>{const{listen:h}=await import("./event-BUMINqWq.js");return{listen:h}},[]);let w=null;b&&(w=await H("import-progress",h=>{b(h.payload)}));try{return{response:await ja("import_model_file",{sourcePath:f}),unlisten:w}}catch(h){throw w&&w(),h}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const x=40;for(let H=1;H<=x;H++){if(E?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(U=>setTimeout(U,150));const w=H/x*100,h=40+Math.sin(H)*5+Math.random()*2,A=(x-H)*.15;b&&b({filename:r,progress:w,speed_mb_s:h,eta_secs:A,status:"Copying to USB..."})}const N=localStorage.getItem("imported-models"),G=N?JSON.parse(N):[];return G.includes(r)||(G.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(G))),{response:"Model imported successfully"}}function $y(f,b,E){return new Promise((r,x)=>{const N=new XMLHttpRequest,G=Date.now();let H=!1;N.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),N.setRequestHeader("Content-Type","application/octet-stream");const w=()=>{H=!0,N.abort()};E&&(E.aborted?w():E.addEventListener("abort",w,{once:!0})),N.upload.onprogress=h=>{if(!h.lengthComputable||!b)return;const A=Math.max(.1,(Date.now()-G)/1e3),U=h.loaded/A,V=Math.max(0,h.total-h.loaded);b({filename:f.name,progress:h.loaded/h.total*100,speed_mb_s:U/(1024*1024),eta_secs:V/Math.max(1,U),status:"Copying to models folder..."})},N.onload=()=>{let h={};try{h=JSON.parse(N.responseText||"{}")}catch{}N.status>=200&&N.status<300&&h.ok!==!1?(b&&b({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(h)):x(new Error(h.error||`Import failed (HTTP ${N.status})`))},N.onerror=()=>x(new Error("Import failed while uploading the file.")),N.onabort=()=>x(new DOMException(H?"Import cancelled by user.":"Import aborted.","AbortError")),N.send(f)})}async function Wy(f){if(ia())return await ja("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const x=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),N=await x.json();if(!x.ok)throw new Error(N.error||"Failed to delete model file");return N}catch(x){throw console.error("Failed to delete model via local API:",x),x}const E=localStorage.getItem("imported-models");let r=E?JSON.parse(E):[];return r=r.filter(x=>ui(x).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function hm(){const f=await mm();try{return(await fetch(`${f}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Fy(f=30){const b=ia()||na()?f:3;for(let E=0;E<b;E++){let r=!1;if(na()?r=!!(await Cl()).ready:r=await hm(),r)return!0;await new Promise(x=>setTimeout(x,500))}return!1}async function Iy(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 Py(){try{return await(await fetch("/api/ca
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"}),E&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Xs,{size:14})})]})});function lg({prompt:f,setPrompt:b,negativePrompt:E,setNegativePrompt:r,constraints:x,setConstraints:N,activeModel:G,generatedImages:H,setGeneratedImages:w,isGenerating:h,setIsGenerating:A,generationProgress:U,setGenerationProgress:V,setActiveTab:fe,showAlert:k=async({message:te})=>window.alert(te),showConfirm:L=async({message:te})=>window.confirm(te)}){const[te,W]=O.useState(null),[Oe,de]=O.useState(null),[Ee,Xe]=O.useState(null),[Ae,P]=O.useState(!1),[ve,Ke]=O.useState(0),[yt,me]=O.useState(0),[Je,st]=O.useState(0),[$e,ke]=O.useState(""),[_,C]=O.useState(!1),[J,he]=O.useState(!1),[ce,d]=O.useState(!1),[j,B]=O.useState(null),[q,K]=O.useState(null),[ee,se]=O.useState(!1),[Ze,Ne]=O.useState([]),[gt,Et]=O.useState(null),We=O.useRef(null),Ht=O.useRef(null),Tt=O.useRef(!1),Z=Y=>{const ye=Y.target.files?.[0];if(Y.target.value="",!ye)return;if(!ye.type.startsWith("image/")){K("Please choose an image file (PNG, JPG, or WEBP).");return}const He=new FileReader;He.onload=()=>Et(He.result),He.onerror=()=>K("Could not read the selected image file."),He.readAsDataURL(ye)},ie=()=>Et(null),D=async()=>{if(!f.trim())return;K(null),d(!0),B(null);let Y=!1;try{const Se=await Cl();if(Se&&Se.settings){const xe=Se.settings,Ge=xe.model?xe.model.split(/[\\/]/).pop():null,_e=G?G.split(/[\\/]/).pop():null;(Ge!==_e||parseInt(xe.steps)!==parseInt(x.steps)||Math.abs(parseFloat(xe.cfgScale)-parseFloat(x.cfgScale))>.05||xe.sampler!==x.sampler||parseInt(xe.threads)!==parseInt(x.threads)||!!xe.useGpu!=(x.useGpu!==!1)||(xe.backendType||(xe.useGpu===!1?"cpu":"auto"))!==(x.backendType||(x.useGpu===!1?"cpu":"auto")))&&(Y=!0)}else Y=!0}catch{Y=!0}if(Y)try{console.log("Settings out of sync, restarting backend..."),await Vs(G,x);let Se=!1,xe=null;for(let Ge=0;Ge<240;Ge++){const _e=await Cl();if(_e.loading&&B({progress:_e.loading.progress||0,phase:_e.loading.phase||"Loading model...",speed:_e.loading.speed||"",current:_e.loading.current||0,total:_e.loading.total||0,backendMode:_e.loading.backendMode||_e.settings?.backendMode||"",device:_e.loading.device||_e.settings?.backendDevice||""}),_e.ready){Se=!0;break}if(_e.error){xe=_e.error;break}if(!_e.running&&Ge>3){xe="The backend process terminated immediately on startup.";break}await new Promise(Ie=>setTimeout(Ie,500))}if(!Se)throw new Error(xe||"Backend server failed to start after applying configuration changes.")}catch(Se){console.error("Failed to restart backend:",Se),K(Se.message||"Failed to sync settings with backend."),d(!1);return}d(!1),B(null),We.current&&clearInterval(We.current),A(!0),V(0),Ke(0),st(0),ke(""),Tt.current=!1,C(!1),se(!1),Xe(null),W(null);const ye=(x.width>=1024?140:35)*.04,He=x.width>=1024?140:35,pt=(x.backendType||(x.useGpu===!1?"cpu":"auto"))!=="cpu";let ft=pt?ye:He,tt=!1,qt=0,rt=0,vt=0;me(Math.round(x.steps*ft)),We.current=setInterval(async()=>{vt++,Ke(vt);try{const Se=await eg();if(Se&&Se.active){const xe=Se.decoding||!1;se(xe);const Ge=xe?Se.steps||x.steps||20:Se.step||0,_e=Se.steps||x.steps||20,Ie=xe?"":Se.speed||"";(xe||Se.steps>0)&&(Tt.current=!0,st(Ge)),ke(xe?"decoding":Ie);let je=0;xe?je=99:_e>0&&(je=Math.round(Ge/_e*100)),je=Math.min(99,je),xe||Se.steps>0?V(je):V(bt=>Math.max(bt,je));let dt=0;if(xe)dt=3;else{const bt=parseFloat(Ie);if(!isNaN(bt)&&bt>0){const cl=Math.max(0,_e-Ge);Ie.includes("it/s")?dt=cl/bt:Ie.includes("s/it")&&(dt=cl*bt)}else{const cl=pt?ye:He;dt=Math.max(0,(_e-Ge)*cl)}}if(pt&&!tt){const bt=Ie.includes("it/s")&&numericSpeed<.2,cl=Ie.includes("s/it")&&numericSpeed>5;(bt||cl)&&(tt=!0,C(!0))}me(Math.round(dt))}else V(xe=>Math.min(15,xe+1)),me(xe=>Math.max(1,xe-1))}catch(Se){console.warn("Failed to get generation progress, running simulation fallback:",Se),pt&&!tt&&vt>x.steps*ye*1.3&&(tt=!0,C(!0),ft=He,qt=vt,rt=Math.min(95,Math.round(vt/(x.steps*ye)*100)));let xe=Math.min(x.steps-1,Math.floor(vt/ft)),Ge=x.steps*ft;if(vt>=Ge){const je=Math.ceil(vt/Math.max(.5,xe));ft=Math.max(ft+15,je+15),Ge=x.steps*ft,xe=Math.min(x.steps-1,Math.floor(vt/ft))}const _e=Math.max(1,Ge-vt);me(Math.round(_e));let Ie=0;if(tt){const je=99-rt,dt=Ge-qt;if(dt>0){const bt=Math.min(1,(vt-qt)/dt);if(bt<.85)Ie=Math.round(rt+bt*je);else{const cl=(vt-(qt+dt*.85))/(ft*2),ci=1-Math.exp(-cl);Ie=Math.min(99,Math.round(rt+.85*je+.14*je*ci))}}else Ie=99}else if(vt<Ge*.85)Ie=Math.round(vt/Ge*100);else{const je=(vt-Ge*.85)/(ft*2),dt=1-Math.exp(-je);Ie=Math.min(99,Math.round(85+14*dt))}Tt.current||V(je=>Math.max(je,Ie))}},1e3);try{Ht.current=new AbortController;const Se=await Ky(f,E,x,G,gt,je=>V(dt=>Math.max(dt,je)),Ht.current.signal);We.current&&clearInterval(We.current),V(100),st(x.steps),me(0),ke("");const xe={prompt:f,negativePrompt:E,seed:Se.seed,steps:x.steps,cfgScale:x.cfgScale,width:x.width,height:x.height,sampler:x.sampler,model:G,mode:gt?"img2img":"txt2Line truncated
|
||||
|
||||
${dl}
|
||||
|
||||
Update the UI status anyway?`,confirmLabel:"Update UI"})&&(b(D),r(!0)):await G({title:"Backend Not Running",message:`C++ backend server is not running on port ${At}.
|
||||
|
||||
To run locally, start:
|
||||
|
||||
${dl}
|
||||
|
||||
Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(D),r(!1));return}te(D),Oe({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:D,backendMode:"",backendBinary:"",device:""});try{const Gt=await Vs(D,x);console.log(Gt);let dl=!1,Re=null;for(let al=0;al<240;al++){const Fe=await Cl();if(Fe.loading&&Oe({progress:Fe.loading.progress||0,phase:Fe.loading.phase||"Loading model...",speed:Fe.loading.speed||"",current:Fe.loading.current||0,total:Fe.loading.total||0,model:Fe.loading.model||D,backendMode:Fe.loading.backendMode||Fe.settings?.backendMode||"",backendBinary:Fe.loading.backendBinary||Fe.settings?.backendBinary||"",device:Fe.loading.device||Fe.settings?.backendDevice||""}),Fe.ready){dl=!0;break}if(Fe.error){Re=Fe.error;break}if(!Fe.running&&al>3){Re="The backend process terminated immediately on startup.";break}await new Promise(za=>setTimeout(za,500))}if(dl)Oe(al=>({...al||{},progress:100,phase:"Model ready",speed:"",current:al?.current||0,total:al?.total||0,model:D})),b(D),r(!0);else throw new Error(Re||`Model server failed to respond on port ${At}.`)}catch(Gt){console.error("Failed to load model:",Gt),N({title:"Model Load Failed",message:Gt.message||String(Gt),danger:!0})}finally{setTimeout(()=>Oe(null),800),te(null)}},gt=async()=>{const D=ke;_(null),await Et(),D&&await Ne(D)},Et=async()=>{if(me)return;Je(!0),$e({progress:10,phase:"Stopping backend process..."});const D=setInterval(async()=>{try{const R=await Cl();R.unloading?.active?$e({progress:R.unloading.progress||50,phase:R.unloading.phase||"Unloading model..."}):$e(F=>({progress:Math.min(95,F.progress+10),phase:F.phase||"Unloading model..."}))}catch{}},300);try{await Js(),$e({progress:100,phase:"Model unloaded"}),b(null),_(null),r(!1)}catch(R){console.error(R),N({title:"Unload Failed",message:R.message||String(R),danger:!0})}finally{clearInterval(D),setTimeout(()=>{Je(!1),$e({progress:0,phase:""})},500)}},We=async D=>{if(await G({title:"Delete Model?",message:`Delete "${D}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await Wy(D),await B(),f===D&&await Et()}catch(R){console.error("Failed to delete model:",R),N({title:"Delete Failed",message:R.message||String(R),danger:!0})}},Ht=async(D,R)=>{const F=new AbortController;yt(F),Ee(0),Ae({filename:R,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Jy(D,ae=>{Ee(Math.round(ae.progress)),Ae({filename:ae.filename,speed:ae.speed_mb_s.toFixed(1),eta:Math.round(ae.eta_secs),status:ae.status})},F.signal),await B()}catch(ae){console.error("Import failed:",ae),ae.name!=="AbortError"&&N({title:"Import Failed",message:ae.message||String(ae),danger:!0})}finally{Ee(null),yt(null)}},Tt=()=>{Ke&&Ke.abort()},Z=D=>{const R=D.target.files[0];R&&Ht(R,R.name),D.target.value=""},ie=!!h;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."}),(C.backendMode||C.backendDevice||C.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[C.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:["Loaded on ",C.backendMode]})]}),C.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendDevice})}),C.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:Et,disabled:me||L!==null,children:[me?c.jsx(aa,{className:"progress-spinner",size:16}):c.jsx(rn,{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:st.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round(st.progress),"%"]})]}),c.jsx("div",{className:"model-
Line truncated
|
||||
|
||||
Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){me(!0);try{await Gy(ve.map(D=>D.id)),await ee()}catch(D){N({title:"Cleanup Failed",message:D.message||String(D),danger:!0})}finally{me(!1)}}},[ve,ee,N,x]);O.useEffect(()=>{async function Z(){const ie=await ky();ke(ie)}Z()},[]),O.useEffect(()=>{k?localStorage.setItem("active-model",k):localStorage.removeItem("active-model")},[k]),O.useEffect(()=>{let Z=null;async function ie(){const D=await Cl();if(!!D.ready){Z&&clearInterval(Z);const F=localStorage.getItem("active-model");if(F)L(F),W(!0);else{try{if(D&&D.settings&&D.settings.model){const ae=D.settings.model.split(/[\\/]/).pop();L(ae)}}catch{}W(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const ae=localStorage.getItem("active-model");ae&&(L(ae),W(!1))}}return ie(),Z=setInterval(ie,2e3),()=>{Z&&clearInterval(Z)}},[]),O.useEffect(()=>{async function Z(){try{const D=await Ly();B(R=>R.cpu_usage===D.cpu_usage&&R.ram_used_gb===D.ram_used_gb&&R.ram_total_gb===D.ram_total_gb&&R.gpu_name===D.gpu_name&&R.vram_used_gb===D.vram_used_gb&&R.vram_total_gb===D.vram_total_gb?R:D)}catch{}}Z();const ie=setInterval(Z,1500);return()=>clearInterval(ie)},[]),O.useEffect(()=>{if(k){const Z=k.toLowerCase();Z.includes("flux")||Z.includes("schnell")?K(ie=>({...ie,steps:4,cfgScale:1,width:1024,height:1024})):Z.includes("lightning")||Z.includes("turbo")?K(ie=>({...ie,steps:4,cfgScale:1.5,width:1024,height:1024})):Z.includes("sd15")?K(ie=>({...ie,steps:25,cfgScale:7,width:512,height:512})):Z.includes("sd35")?K(ie=>({...ie,steps:20,cfgScale:4.5,width:1024,height:1024})):K(ie=>({...ie,steps:20,cfgScale:7,width:512,height:512}))}},[k]);const Ne=O.useMemo(()=>{switch(w){case"generator":return c.jsx(ag,{prompt:A,setPrompt:U,negativePrompt:V,setNegativePrompt:fe,constraints:q,setConstraints:K,activeModel:k,generatedImages:$e,setGeneratedImages:ke,isGenerating:_,setIsGenerating:C,generationProgress:J,setGenerationProgress:he,setActiveTab:h,showAlert:N,showConfirm:x});case"models":return c.jsx(ug,{activeModel:k,setActiveModel:L,serverRunning:te,setServerRunning:W,constraints:q,showAlert:N,showConfirm:x});case"constraints":return c.jsx(fg,{constraints:q,setConstraints:K,activeModel:k,specs:ce,backendOptions:Ee});default:return null}},[w,A,V,q,k,$e,_,J,te,ce,Ee,N,x]),gt=O.useMemo(()=>c.jsx(Ny,{activeTab:w,setActiveTab:h,specs:ce}),[w,ce]),Et=O.useCallback(async()=>{if(!(!te||Oe)){de(!0);try{await Js(),W(!1),L(null)}catch(Z){console.error("Failed to stop server:",Z),N({title:"Stop Server Failed",message:Z.message||String(Z),danger:!0})}finally{de(!1)}}},[te,Oe,N]),We=[...Ae?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...Ae?.issues||[]],Ht=ve.reduce((Z,ie)=>Z+Number(ie.sizeBytes||0),0),Tt=!!(Ae&&(We.length>0||ve.length>0));return c.jsxs("div",{className:"app-container",children:[gt,c.jsxs("div",{className:"main-content",children:[c.jsx(Dy,{telemetry:j,serverRunning:te,activeModel:k,onStopServer:Et,isStoppingServer:Oe,theme:G,setTheme:H}),Tt&&c.jsxs("div",{className:`m3-card readiness-card ${Ae?.stale||We.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:Ae?.stale?"Restart Required":We.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:Ae?.stale?`Running server build: ${Ae.build||"unknown"}`:We.length>0?"Local AI Image Generator found setup items that may need attention.":`${ve.length} temporary item${ve.length===1?"":"s"} can be cleaned (${ii(Ht)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:ee,disabled:yt,children:yt?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:se,children:Je?"Copied":"Copy Diagnostics"}),ve.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:Ze,disabled:yt,children:["Clean ",ii(Ht)]})]})]}),We.length>0&&c.jsx("div",{className:"readiness-issues",children:We.slice(0,4).map(Z=>c.jsx("span",{children:Z},Z))}),ve.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:ve.slice(0,3).map(Z=>c.jsxs("span",{title:Z.path,children:[Z.name," · ",Z.size," · ",Z.reason]},Z.id))})]}),Ne]}),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-filled"}`,onClick:()=>r(!0),children:
Line truncated
|
||||
Vendored
+1
-1
@@ -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-CL30r104.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DVJy0SBd.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DW6G7wc2.css">
|
||||
</head>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { memo, useState, useRef, useCallback } from "react";
|
||||
import { Sparkles, Download, Copy, RefreshCw, Check, Sliders, Trash2 } from "lucide-react";
|
||||
import { Sparkles, Download, Copy, RefreshCw, Check, Sliders, Trash2, ImagePlus } from "lucide-react";
|
||||
import { generateImage, startServer, stopServer, waitForServerReady, getBackendStatus, getGenerationProgress, saveGeneratedOutput, deleteGeneratedOutputs } from "../services/api";
|
||||
|
||||
const GalleryItem = memo(({ img, idx, isSelected, onClick }) => {
|
||||
@@ -55,10 +55,27 @@ function Generator({
|
||||
const [errorMsg, setErrorMsg] = useState(null);
|
||||
const [isDecoding, setIsDecoding] = useState(false);
|
||||
const [selectedGalleryIndexes, setSelectedGalleryIndexes] = useState([]);
|
||||
const [baseImage, setBaseImage] = useState(null);
|
||||
const timerRef = useRef(null);
|
||||
const abortControllerRef = useRef(null);
|
||||
const hasRealGenerationStepRef = useRef(false);
|
||||
|
||||
const handleBaseImageSelect = (e) => {
|
||||
const file = e.target.files?.[0];
|
||||
e.target.value = "";
|
||||
if (!file) return;
|
||||
if (!file.type.startsWith("image/")) {
|
||||
setErrorMsg("Please choose an image file (PNG, JPG, or WEBP).");
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => setBaseImage(reader.result);
|
||||
reader.onerror = () => setErrorMsg("Could not read the selected image file.");
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
|
||||
const handleClearBaseImage = () => setBaseImage(null);
|
||||
|
||||
// Trigger main image generation process
|
||||
const handleGenerate = async () => {
|
||||
if (!prompt.trim()) return;
|
||||
@@ -299,7 +316,7 @@ function Generator({
|
||||
negativePrompt,
|
||||
constraints,
|
||||
activeModel,
|
||||
null,
|
||||
baseImage,
|
||||
(prog) => setGenerationProgress((prev) => Math.max(prev, prog)),
|
||||
abortControllerRef.current.signal
|
||||
);
|
||||
@@ -320,6 +337,8 @@ function Generator({
|
||||
height: constraints.height,
|
||||
sampler: constraints.sampler,
|
||||
model: activeModel,
|
||||
mode: baseImage ? "img2img" : "txt2img",
|
||||
denoisingStrength: baseImage ? constraints.denoisingStrength : null,
|
||||
duration_sec: result.duration_sec,
|
||||
timestamp: new Date().toLocaleTimeString(),
|
||||
};
|
||||
@@ -588,6 +607,62 @@ function Generator({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="m3-text-field">
|
||||
<label className="m3-text-field-label">Base Image (Optional)</label>
|
||||
{baseImage ? (
|
||||
<div style={{ display: "flex", gap: "12px", alignItems: "center", padding: "12px", background: "var(--md-sys-color-surface-variant)", borderRadius: "var(--md-shape-corner-medium)", border: "1px solid var(--md-sys-color-outline-variant)" }}>
|
||||
<img src={baseImage} alt="Base" style={{ width: "64px", height: "64px", objectFit: "cover", borderRadius: "8px", flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontWeight: 600, fontSize: "0.85rem" }}>Base image ready</div>
|
||||
<div style={{ fontSize: "0.75rem", color: "var(--md-sys-color-outline)" }}>
|
||||
The AI will redraw this image guided by your prompt.
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" className="m3-btn m3-btn-error" style={{ height: "34px", flexShrink: 0 }} onClick={handleClearBaseImage} disabled={isGenerating}>
|
||||
<Trash2 size={14} />
|
||||
<span>Remove</span>
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<label className="import-box" style={{ margin: 0, padding: "16px", cursor: isGenerating ? "not-allowed" : "pointer" }}>
|
||||
<input
|
||||
type="file"
|
||||
accept="image/png,image/jpeg,image/webp"
|
||||
style={{ display: "none" }}
|
||||
onChange={handleBaseImageSelect}
|
||||
disabled={isGenerating}
|
||||
/>
|
||||
<ImagePlus className="import-icon" />
|
||||
<span style={{ fontWeight: 600 }}>Upload a base image</span>
|
||||
<span style={{ fontSize: "0.75rem", color: "var(--md-sys-color-outline)", textAlign: "center" }}>
|
||||
Optional. Generate a new image based on one of your own.
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
|
||||
{baseImage && (
|
||||
<div style={{ marginTop: "12px" }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontSize: "0.8rem", marginBottom: "4px" }}>
|
||||
<span>Transformation strength</span>
|
||||
<span>{constraints.denoisingStrength.toFixed(2)}</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min="0.1"
|
||||
max="1"
|
||||
step="0.05"
|
||||
value={constraints.denoisingStrength}
|
||||
onChange={(e) => setConstraints((prev) => ({ ...prev, denoisingStrength: parseFloat(e.target.value) }))}
|
||||
disabled={isGenerating}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
<div style={{ fontSize: "0.72rem", color: "var(--md-sys-color-outline)", marginTop: "2px" }}>
|
||||
Lower = closer to your image; higher = more creative freedom. 0.7 is a good start.
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Configuration Status Chips (Material 3 style) */}
|
||||
<div className="m3-text-field">
|
||||
<label className="m3-text-field-label">Active Image Constraints</label>
|
||||
@@ -618,7 +693,7 @@ function Generator({
|
||||
disabled={isGenerating || !prompt.trim() || !activeModel}
|
||||
>
|
||||
<Sparkles size={18} />
|
||||
<span>{!activeModel ? "Select Model to Generate" : "Generate Local Image"}</span>
|
||||
<span>{!activeModel ? "Select Model to Generate" : baseImage ? "Generate from Base Image" : "Generate Local Image"}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -528,11 +528,11 @@ export async function generateImage(prompt, negativePrompt, constraints, activeM
|
||||
};
|
||||
};
|
||||
|
||||
// stable-diffusion.cpp server only exposes /v1/images/generations (OpenAI-compat)
|
||||
// Steps, cfg_scale, seed, sample_method are passed in the body and read by the server
|
||||
// txt2img uses /v1/images/generations; img2img uses /sdapi/v1/img2img.
|
||||
const isImg2Img = !!payload.image;
|
||||
let endpoint = `${baseUrl}/v1/images/generations`;
|
||||
|
||||
const genBody = {
|
||||
let genBody = {
|
||||
prompt: payload.prompt,
|
||||
negative_prompt: payload.negative_prompt || "",
|
||||
n: 1,
|
||||
@@ -547,13 +547,30 @@ export async function generateImage(prompt, negativePrompt, constraints, activeM
|
||||
|
||||
// img2img extra fields
|
||||
if (isImg2Img) {
|
||||
genBody.init_images = [payload.image];
|
||||
genBody.denoising_strength = payload.denoising_strength || 0.7;
|
||||
const initBase64 = String(payload.image).replace(/^data:[^;]+;base64,/, "");
|
||||
endpoint = `${baseUrl}/sdapi/v1/img2img`;
|
||||
genBody = {
|
||||
init_images: [initBase64],
|
||||
prompt: payload.prompt,
|
||||
negative_prompt: payload.negative_prompt || "",
|
||||
denoising_strength: payload.denoising_strength || 0.7,
|
||||
steps: payload.steps,
|
||||
cfg_scale: payload.cfg_scale,
|
||||
seed: payload.seed,
|
||||
width: payload.width,
|
||||
height: payload.height,
|
||||
sampler_name: payload.sampler || "euler_a",
|
||||
sample_method: payload.sampler || "euler_a",
|
||||
batch_size: 1,
|
||||
n_iter: 1,
|
||||
send_images: true,
|
||||
save_images: false,
|
||||
};
|
||||
}
|
||||
|
||||
// Attempt real HTTP call
|
||||
try {
|
||||
const response = await fetch(`${baseUrl}/v1/images/generations`, {
|
||||
const response = await fetch(endpoint, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
signal: signal,
|
||||
|
||||
Reference in new issue
Block a user