diff --git a/dist/immac_style_mixer/StyleMixerPanel-C1N_9fxL.js b/dist/immac_style_mixer/StyleMixerPanel-CveihzM7.js similarity index 64% rename from dist/immac_style_mixer/StyleMixerPanel-C1N_9fxL.js rename to dist/immac_style_mixer/StyleMixerPanel-CveihzM7.js index d36ba03..406e298 100644 --- a/dist/immac_style_mixer/StyleMixerPanel-C1N_9fxL.js +++ b/dist/immac_style_mixer/StyleMixerPanel-CveihzM7.js @@ -1,4 +1,4 @@ -import{j as e}from"./main.js";import{r as o,b as me}from"./vendor-DPfS0z4g.js";const oe={styles:[],mixes:[],current_mix_id:null},ae="/immac_style_mixer/api/data";function xe(){const[t,c]=o.useState(oe),[p,d]=o.useState(!0),[h,y]=o.useState(null),[f,D]=o.useState(!1),I=o.useRef(oe),_=o.useRef(null),M=o.useRef(!1);o.useEffect(()=>{fetch(ae).then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}`);return m.json()}).then(m=>{I.current=m,c(m)}).catch(m=>y(String(m))).finally(()=>d(!1))},[]);const z=o.useCallback((m,g)=>{var E,P,B,x,S,O,T,F;const k=I.current,j=typeof m=="function"?m(k):m;I.current=j,c(j);const u=j.mixes.length-k.mixes.length,v=j.styles.length-k.styles.length;if(u<0||v<0){try{(P=(E=window.app)==null?void 0:E.refreshComboInNodes)==null||P.call(E),(x=(B=window.app)==null?void 0:B.toast)==null||x.add({severity:"warn",summary:"Style Mixer",detail:"A mix or style was deleted — node combo lists have been refreshed.",life:4e3})}catch(i){console.warn("[ImmacStyleMixer] refreshComboInNodes/toast failed",i)}D(!1)}else if(u>0||v>0){const i=v>0&&k.styles.length===0,a=u>0&&k.mixes.length===0;if(i||a){try{(O=(S=window.app)==null?void 0:S.refreshComboInNodes)==null||O.call(S),(F=(T=window.app)==null?void 0:T.toast)==null||F.add({severity:"info",summary:"Style Mixer",detail:"First item added — node combo lists refreshed.",life:4e3})}catch(s){console.warn("[ImmacStyleMixer] refreshComboInNodes/toast failed",s)}D(!1)}else g!=null&&g.silent||D(!0)}_.current&&clearTimeout(_.current),M.current=(g==null?void 0:g.silent)??!1,_.current=setTimeout(()=>{fetch(ae,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)}).then(()=>{var i,a,s,N,H;if(!M.current)try{(a=(i=window.app)==null?void 0:i.refreshComboInNodes)==null||a.call(i)}catch{}try{(H=(N=(s=window.app)==null?void 0:s.graph)==null?void 0:N.nodes)==null||H.forEach(r=>{typeof r._immacUpdatePreview=="function"&&r._immacUpdatePreview()})}catch{}}).catch(i=>console.error("[ImmacStyleMixer] Save failed",i))},400)},[]),b=o.useCallback(()=>{var m,g,k,j,u;try{(g=(m=window.app)==null?void 0:m.refreshComboInNodes)==null||g.call(m),(u=(j=(k=window.app)==null?void 0:k.graph)==null?void 0:j.nodes)==null||u.forEach(v=>{typeof v._immacUpdatePreview=="function"&&v._immacUpdatePreview()})}catch(v){console.warn("[ImmacStyleMixer] refreshComboInNodes failed",v)}D(!1)},[]);return{data:t,loading:p,error:h,update:z,pendingRefresh:f,refreshNodes:b}}async function ge(t){const c=new FormData;c.append("image",t),c.append("subfolder","immac_style_mixer/styles"),c.append("type","input");const p=await fetch("/upload/image",{method:"POST",body:c});if(!p.ok)throw new Error(`Upload failed: HTTP ${p.status}`);return(await p.json()).name}function Q(t,c){const p=c?`&t=${c}`:"";return`/view?filename=${encodeURIComponent(t)}&subfolder=immac_style_mixer%2Fstyles&type=input${p}`}async function he(t){const c=new FormData;c.append("image",t),c.append("subfolder","immac_style_mixer/mixes"),c.append("type","input");const p=await fetch("/upload/image",{method:"POST",body:c});if(!p.ok)throw new Error(`Upload failed: HTTP ${p.status}`);return(await p.json()).name}function re(t,c){const p=c?`&t=${c}`:"";return`/view?filename=${encodeURIComponent(t)}&subfolder=immac_style_mixer%2Fmixes&type=input${p}`}function ie({src:t,alt:c,onClose:p}){return o.useEffect(()=>{function d(h){h.key==="Escape"&&p()}return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[p]),me.createPortal(e.jsxs("div",{onClick:p,style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:[e.jsx("img",{src:t,alt:c??"",onClick:d=>d.stopPropagation(),style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:8,boxShadow:"0 8px 40px rgba(0,0,0,0.7)",cursor:"default"}}),e.jsx("button",{onClick:p,title:"Close",style:{position:"fixed",top:16,right:20,background:"none",border:"none",color:"#fff",fontSize:28,cursor:"pointer",lineHeight:1,opacity:.8},children:"✕"})]}),document.body)}function pe({value:t,onChange:c,min:p=0,max:d=1,step:h=.05,pixelsPerStep:y=2,width:f=72,decimals:D=2}){const[I,_]=o.useState(!1),[M,z]=o.useState(""),b=o.useRef(null),m=o.useCallback(()=>{const x=parseFloat(M);isNaN(x)||c(x),_(!1)},[M,c]);o.useEffect(()=>{var x,S;I&&((x=b.current)==null||x.focus(),(S=b.current)==null||S.select())},[I]);const g=o.useRef(!1),k=o.useRef(0),j=o.useRef(0),u=o.useRef(!1),v=o.useCallback(x=>{I||(x.currentTarget.setPointerCapture(x.pointerId),g.current=!0,u.current=!1,k.current=x.clientX,j.current=Math.max(p,Math.min(d,t)))},[I,t,p,d]),E=o.useCallback(x=>{if(!g.current)return;const S=x.clientX-k.current;Math.abs(S)>2&&(u.current=!0);const O=S/y,T=j.current+O*h,F=Math.round(T/h)*h,i=parseFloat(Math.max(p,Math.min(d,F)).toFixed(D));c(i)},[h,y,D,p,d,c]),P=o.useCallback(()=>{g.current&&!u.current&&(z(t.toFixed(D)),_(!0)),g.current=!1},[t,D]),B=Math.max(0,Math.min(1,(t-p)/(d-p)))*100;return I?e.jsx("input",{ref:b,type:"text",inputMode:"decimal",value:M,onChange:x=>z(x.target.value),onBlur:m,onKeyDown:x=>{x.key==="Enter"&&m(),x.key==="Escape"&&_(!1)},style:{width:f,background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-primary-color, #6c6)",borderRadius:4,color:"inherit",padding:"2px 4px",fontSize:12,boxSizing:"border-box",textAlign:"center",outline:"none"}}):e.jsxs("div",{draggable:!1,onDragStart:x=>x.stopPropagation(),style:{position:"relative",width:f,height:20,borderRadius:4,overflow:"hidden",cursor:"ew-resize",userSelect:"none",flexShrink:0,border:"1px solid var(--p-surface-border, #555)",background:"var(--p-surface-ground, #141414)",boxSizing:"border-box"},onPointerDown:v,onPointerMove:E,onPointerUp:P,children:[e.jsx("div",{style:{position:"absolute",inset:0,width:`${B}%`,background:"var(--p-primary-color, #4a7a4a)",opacity:.55,pointerEvents:"none"}}),e.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"var(--p-text-color, #ddd)",pointerEvents:"none",fontVariantNumeric:"tabular-nums"},children:t.toFixed(D)})]})}function ye({mix:t,styles:c,isActive:p,isDirty:d,onActivate:h,onUpdate:y,onDelete:f,onDuplicate:D,onRefreshCache:I}){function _(n){n.target.closest("button, input, select, textarea, a")||h()}const[M,z]=o.useState(!1),[b,m]=o.useState(t.name),[g,k]=o.useState(!1),[j,u]=o.useState(!1),[v,E]=o.useState(!1),[P,B]=o.useState(!1),[x,S]=o.useState(!1),[O,T]=o.useState(!1),F=o.useRef(null);function i(){const n=t.styles.filter(l=>l.enabled).map(l=>{var w;return((w=c.find(R=>R.id===l.style_id))==null?void 0:w.value)??""}).filter(Boolean);n.length!==0&&navigator.clipboard.writeText(n.join(", ")).then(()=>{S(!0),setTimeout(()=>S(!1),1500)})}async function a(n){if(n.type.startsWith("image/")){k(!0);try{const l=await he(n);y({...t,image_filename:l,image_updated_at:Date.now()})}catch(l){console.error("[ImmacStyleMixer] Mix image upload failed",l)}finally{k(!1)}}}function s(){z(!1),b.trim()!==t.name&&y({...t,name:b.trim()||t.name})}function N(n,l){const w=t.styles.map((R,$)=>$===n?{...R,...l}:R);y({...t,styles:w})}function H(n){y({...t,styles:t.styles.filter((l,w)=>w!==n)})}function r(n){t.styles.some(l=>l.style_id===n)||y({...t,styles:[...t.styles,{style_id:n,weight:1,enabled:!0}]})}const C=c.filter(n=>!t.styles.some(l=>l.style_id===n.id));return e.jsxs("div",{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="copy",n.dataTransfer.setData("application/x-immac-mix-name",t.name)},onDragEnd:n=>{var X,Y,K,G,J,q,ne;const l=(X=window.app)==null?void 0:X.canvas;if(!l)return;const w=l.canvas;if(!w)return;const R=w.getBoundingClientRect();if(n.clientXR.right||n.clientYR.bottom)return;const $=l.convertEventToCanvasOffset(n),A=window.LiteGraph,L=A==null?void 0:A.createNode("StyleMixImmacStyleMixer");if(!L)return;L.pos=$,(K=(Y=window.app)==null?void 0:Y.graph)==null||K.add(L);const W=(G=L.widgets)==null?void 0:G.find(fe=>fe.name==="mix");W&&(W.value=t.name,(J=W.callback)==null||J.call(W,t.name,null,null,null,L)),(ne=(q=window.app)==null?void 0:q.graph)==null||ne.setDirtyCanvas(!0,!0)},style:{border:`2px solid ${O?"#88aaff":p?"var(--p-primary-color, #6c6)":"var(--p-surface-border, #444)"}`,borderRadius:8,padding:10,background:O?"rgba(100,130,255,0.07)":"var(--p-surface-section, #1e1e1e)",display:"flex",flexDirection:"column",gap:8,width:"100%",position:"relative",overflow:"hidden",cursor:"grab",transition:"border-color 0.15s, background 0.15s"},onClick:_,onDragOver:n=>{n.dataTransfer.types.includes("application/x-immac-style-id")&&(n.preventDefault(),n.dataTransfer.dropEffect="copy",T(!0))},onDragLeave:n=>{n.currentTarget.contains(n.relatedTarget)||T(!1)},onDrop:n=>{T(!1);const l=n.dataTransfer.getData("application/x-immac-style-id");l&&(n.preventDefault(),n.stopPropagation(),r(l))},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[M?e.jsx("input",{autoFocus:!0,value:b,onChange:n=>m(n.target.value),onBlur:s,onKeyDown:n=>{n.key==="Enter"&&s(),n.key==="Escape"&&z(!1)},style:le}):e.jsx("span",{title:"Double-click to rename",onDoubleClick:()=>{m(t.name),z(!0)},style:{fontWeight:600,flex:1,cursor:"text",fontSize:13},children:t.name}),d&&e.jsx("button",{title:"Pending node-cache changes — click to reload",onClick:n=>{n.stopPropagation(),I()},style:{...U,color:"#f5a623",fontSize:14,animation:"immac-pulse 1.8s ease-in-out infinite"},children:e.jsx("i",{className:"pi pi-exclamation-circle"})}),e.jsx("button",{title:t.favorite?"Remove bookmark":"Bookmark",onClick:()=>y({...t,favorite:!t.favorite}),style:U,children:e.jsx("i",{className:t.favorite?"pi pi-bookmark-fill":"pi pi-bookmark"})}),e.jsx("button",{title:"Duplicate mix",onClick:D,style:{...U,color:"var(--p-text-muted-color, #888)"},children:e.jsx("i",{className:"pi pi-copy"})}),(()=>{const n=t.styles.some(l=>{var w;return l.enabled&&((w=c.find(R=>R.id===l.style_id))==null?void 0:w.value)});return e.jsx("button",{title:n?"Copy combined prompt":"No enabled styles with prompt text",onClick:l=>{l.stopPropagation(),i()},disabled:!n,style:{...U,color:x?"#6c6":"var(--p-text-muted-color, #888)",opacity:n?1:.35},children:e.jsx("i",{className:x?"pi pi-check":"pi pi-clipboard"})})})(),e.jsx("button",{title:"Delete mix",onClick:()=>E(!0),style:{...U,color:"var(--p-text-muted-color, #888)"},children:e.jsx("i",{className:"pi pi-trash"})})]}),v&&e.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(20,20,20,0.92)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,zIndex:10},children:[e.jsx("i",{className:"pi pi-trash",style:{fontSize:22,color:"#e55"}}),e.jsxs("span",{style:{fontSize:13,color:"#ddd",fontWeight:600},children:['Delete "',t.name,'"?']}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>E(!1),style:{...se},children:"Cancel"}),e.jsx("button",{onClick:f,style:{...se,background:"#c33",color:"#fff",borderColor:"#c33"},children:"Delete"})]})]}),e.jsxs("div",{style:{position:"relative",width:"100%",paddingBottom:"100%"},onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1),children:[e.jsx("div",{title:"Click or drop an image to set mix cover",onClick:()=>{var n;return(n=F.current)==null?void 0:n.click()},onDragOver:n=>n.preventDefault(),onDrop:n=>{n.preventDefault();const l=n.dataTransfer.files[0];l&&a(l)},style:{position:"absolute",inset:0,borderRadius:6,border:"1px dashed var(--p-surface-border, #555)",overflow:"hidden",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--p-surface-ground, #141414)",fontSize:11,color:"#888",flexShrink:0},children:g?"Uploading…":t.image_filename?e.jsx("img",{src:re(t.image_filename,t.image_updated_at),alt:t.name,style:{width:"100%",height:"100%",objectFit:"cover",transition:"transform 0.3s ease",transform:P?"scale(1.05)":"scale(1)"}}):"+ cover image"}),!g&&t.image_filename&&P&&e.jsx("button",{title:"View full size",onClick:n=>{n.stopPropagation(),u(!0)},style:be,children:e.jsx("i",{className:"pi pi-search-plus"})})]}),j&&t.image_filename&&e.jsx(ie,{src:re(t.image_filename,t.image_updated_at),alt:t.name,onClose:()=>u(!1)}),e.jsx("input",{ref:F,type:"file",accept:"image/*",style:{display:"none"},onChange:n=>{var w;const l=(w=n.target.files)==null?void 0:w[0];l&&a(l),n.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,maxHeight:240,overflowY:"auto"},children:[t.styles.length===0&&e.jsx("div",{style:{fontSize:11,color:"#666"},children:"No styles added yet."}),t.styles.map((n,l)=>{const w=c.find(R=>R.id===n.style_id);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("button",{title:n.enabled?"Disable":"Enable",onClick:()=>N(l,{enabled:!n.enabled}),style:{...U,fontSize:11,padding:"2px 5px",border:"1px solid var(--p-surface-border, #555)",borderRadius:4,background:n.enabled?"var(--p-primary-color, #557755)":"transparent",color:n.enabled?"#fff":"#888",minWidth:32},children:n.enabled?"ON":"OFF"}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(w==null?void 0:w.name)??n.style_id}),e.jsx(pe,{value:n.weight,onChange:R=>N(l,{weight:R}),min:0,max:1,step:.05,width:64}),e.jsx("button",{title:"Remove from mix",onClick:()=>H(l),style:{...U,color:"#e55",fontSize:13},children:"✕"})]},n.style_id)})]}),e.jsxs("select",{value:"",disabled:C.length===0,onChange:n=>{n.target.value&&r(n.target.value)},style:{...le,cursor:C.length===0?"not-allowed":"pointer",opacity:C.length===0?.45:1},title:C.length===0?"All library styles are already in this mix":"Add a style to this mix",children:[e.jsx("option",{value:"",children:C.length===0?"— all styles already added —":"+ add style…"}),C.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})]})}const se={background:"transparent",border:"1px solid #666",borderRadius:5,color:"#ccc",cursor:"pointer",fontSize:12,padding:"4px 12px"},U={background:"none",border:"none",cursor:"pointer",fontSize:16,padding:"0 2px",color:"inherit",lineHeight:1,flexShrink:0},be={position:"absolute",top:6,left:6,background:"rgba(255,255,255,0.92)",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,padding:"3px 6px",lineHeight:1,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.25)"},le={background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-surface-border, #444)",borderRadius:4,color:"inherit",padding:"2px 4px",fontSize:12,boxSizing:"border-box"};(()=>{if(document.getElementById("immac-pulse-style"))return;const t=document.createElement("style");t.id="immac-pulse-style",t.textContent=`@keyframes immac-pulse { +import{j as e}from"./main.js";import{r as o,b as me}from"./vendor-DPfS0z4g.js";const oe={styles:[],mixes:[],current_mix_id:null},ae="/immac_style_mixer/api/data";function xe(){const[t,c]=o.useState(oe),[p,d]=o.useState(!0),[h,y]=o.useState(null),[f,D]=o.useState(!1),I=o.useRef(oe),_=o.useRef(null),N=o.useRef(!1);o.useEffect(()=>{fetch(ae).then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}`);return m.json()}).then(m=>{I.current=m,c(m)}).catch(m=>y(String(m))).finally(()=>d(!1))},[]);const z=o.useCallback((m,g)=>{var E,P,B,x,S,O,T,F;const k=I.current,j=typeof m=="function"?m(k):m;I.current=j,c(j);const u=j.mixes.length-k.mixes.length,v=j.styles.length-k.styles.length;if(u<0||v<0){try{(P=(E=window.app)==null?void 0:E.refreshComboInNodes)==null||P.call(E),(x=(B=window.app)==null?void 0:B.toast)==null||x.add({severity:"warn",summary:"Style Mixer",detail:"A mix or style was deleted — node combo lists have been refreshed.",life:4e3})}catch(i){console.warn("[ImmacStyleMixer] refreshComboInNodes/toast failed",i)}D(!1)}else if(u>0||v>0){const i=v>0&&k.styles.length===0,a=u>0&&k.mixes.length===0;if(i||a){try{(O=(S=window.app)==null?void 0:S.refreshComboInNodes)==null||O.call(S),(F=(T=window.app)==null?void 0:T.toast)==null||F.add({severity:"info",summary:"Style Mixer",detail:"First item added — node combo lists refreshed.",life:4e3})}catch(s){console.warn("[ImmacStyleMixer] refreshComboInNodes/toast failed",s)}D(!1)}else g!=null&&g.silent||D(!0)}_.current&&clearTimeout(_.current),N.current=(g==null?void 0:g.silent)??!1,_.current=setTimeout(()=>{fetch(ae,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)}).then(()=>{var i,a,s,M,H;if(!N.current)try{(a=(i=window.app)==null?void 0:i.refreshComboInNodes)==null||a.call(i)}catch{}try{(H=(M=(s=window.app)==null?void 0:s.graph)==null?void 0:M.nodes)==null||H.forEach(r=>{typeof r._immacUpdatePreview=="function"&&r._immacUpdatePreview()})}catch{}}).catch(i=>console.error("[ImmacStyleMixer] Save failed",i))},400)},[]),b=o.useCallback(()=>{var m,g,k,j,u;try{(g=(m=window.app)==null?void 0:m.refreshComboInNodes)==null||g.call(m),(u=(j=(k=window.app)==null?void 0:k.graph)==null?void 0:j.nodes)==null||u.forEach(v=>{typeof v._immacUpdatePreview=="function"&&v._immacUpdatePreview()})}catch(v){console.warn("[ImmacStyleMixer] refreshComboInNodes failed",v)}D(!1)},[]);return{data:t,loading:p,error:h,update:z,pendingRefresh:f,refreshNodes:b}}async function ge(t){const c=new FormData;c.append("image",t),c.append("subfolder","immac_style_mixer/styles"),c.append("type","input");const p=await fetch("/upload/image",{method:"POST",body:c});if(!p.ok)throw new Error(`Upload failed: HTTP ${p.status}`);return(await p.json()).name}function Q(t,c){const p=c?`&t=${c}`:"";return`/view?filename=${encodeURIComponent(t)}&subfolder=immac_style_mixer%2Fstyles&type=input${p}`}async function he(t){const c=new FormData;c.append("image",t),c.append("subfolder","immac_style_mixer/mixes"),c.append("type","input");const p=await fetch("/upload/image",{method:"POST",body:c});if(!p.ok)throw new Error(`Upload failed: HTTP ${p.status}`);return(await p.json()).name}function re(t,c){const p=c?`&t=${c}`:"";return`/view?filename=${encodeURIComponent(t)}&subfolder=immac_style_mixer%2Fmixes&type=input${p}`}function ie({src:t,alt:c,onClose:p}){return o.useEffect(()=>{function d(h){h.key==="Escape"&&p()}return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[p]),me.createPortal(e.jsxs("div",{onClick:p,style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:[e.jsx("img",{src:t,alt:c??"",onClick:d=>d.stopPropagation(),style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:8,boxShadow:"0 8px 40px rgba(0,0,0,0.7)",cursor:"default"}}),e.jsx("button",{onClick:p,title:"Close",style:{position:"fixed",top:16,right:20,background:"none",border:"none",color:"#fff",fontSize:28,cursor:"pointer",lineHeight:1,opacity:.8},children:"✕"})]}),document.body)}function pe({value:t,onChange:c,min:p=0,max:d=1,step:h=.05,pixelsPerStep:y=2,width:f=72,decimals:D=2}){const[I,_]=o.useState(!1),[N,z]=o.useState(""),b=o.useRef(null),m=o.useCallback(()=>{const x=parseFloat(N);isNaN(x)||c(x),_(!1)},[N,c]);o.useEffect(()=>{var x,S;I&&((x=b.current)==null||x.focus(),(S=b.current)==null||S.select())},[I]);const g=o.useRef(!1),k=o.useRef(0),j=o.useRef(0),u=o.useRef(!1),v=o.useCallback(x=>{I||(x.currentTarget.setPointerCapture(x.pointerId),g.current=!0,u.current=!1,k.current=x.clientX,j.current=Math.max(p,Math.min(d,t)))},[I,t,p,d]),E=o.useCallback(x=>{if(!g.current)return;const S=x.clientX-k.current;Math.abs(S)>2&&(u.current=!0);const O=S/y,T=j.current+O*h,F=Math.round(T/h)*h,i=parseFloat(Math.max(p,Math.min(d,F)).toFixed(D));c(i)},[h,y,D,p,d,c]),P=o.useCallback(()=>{g.current&&!u.current&&(z(t.toFixed(D)),_(!0)),g.current=!1},[t,D]),B=Math.max(0,Math.min(1,(t-p)/(d-p)))*100;return I?e.jsx("input",{ref:b,type:"text",inputMode:"decimal",value:N,onChange:x=>z(x.target.value),onBlur:m,onKeyDown:x=>{x.key==="Enter"&&m(),x.key==="Escape"&&_(!1)},style:{width:f,background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-primary-color, #6c6)",borderRadius:4,color:"inherit",padding:"2px 4px",fontSize:12,boxSizing:"border-box",textAlign:"center",outline:"none"}}):e.jsxs("div",{draggable:!1,onMouseDown:x=>x.stopPropagation(),onDragStart:x=>x.stopPropagation(),style:{position:"relative",width:f,height:20,borderRadius:4,overflow:"hidden",cursor:"ew-resize",userSelect:"none",flexShrink:0,border:"1px solid var(--p-surface-border, #555)",background:"var(--p-surface-ground, #141414)",boxSizing:"border-box"},onPointerDown:v,onPointerMove:E,onPointerUp:P,children:[e.jsx("div",{style:{position:"absolute",inset:0,width:`${B}%`,background:"var(--p-primary-color, #4a7a4a)",opacity:.55,pointerEvents:"none"}}),e.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"var(--p-text-color, #ddd)",pointerEvents:"none",fontVariantNumeric:"tabular-nums"},children:t.toFixed(D)})]})}function ye({mix:t,styles:c,isActive:p,isDirty:d,onActivate:h,onUpdate:y,onDelete:f,onDuplicate:D,onRefreshCache:I}){function _(n){n.target.closest("button, input, select, textarea, a")||h()}const[N,z]=o.useState(!1),[b,m]=o.useState(t.name),[g,k]=o.useState(!1),[j,u]=o.useState(!1),[v,E]=o.useState(!1),[P,B]=o.useState(!1),[x,S]=o.useState(!1),[O,T]=o.useState(!1),F=o.useRef(null);function i(){const n=t.styles.filter(l=>l.enabled).map(l=>{var w;return((w=c.find(R=>R.id===l.style_id))==null?void 0:w.value)??""}).filter(Boolean);n.length!==0&&navigator.clipboard.writeText(n.join(", ")).then(()=>{S(!0),setTimeout(()=>S(!1),1500)})}async function a(n){if(n.type.startsWith("image/")){k(!0);try{const l=await he(n);y({...t,image_filename:l,image_updated_at:Date.now()})}catch(l){console.error("[ImmacStyleMixer] Mix image upload failed",l)}finally{k(!1)}}}function s(){z(!1),b.trim()!==t.name&&y({...t,name:b.trim()||t.name})}function M(n,l){const w=t.styles.map((R,$)=>$===n?{...R,...l}:R);y({...t,styles:w})}function H(n){y({...t,styles:t.styles.filter((l,w)=>w!==n)})}function r(n){t.styles.some(l=>l.style_id===n)||y({...t,styles:[...t.styles,{style_id:n,weight:1,enabled:!0}]})}const C=c.filter(n=>!t.styles.some(l=>l.style_id===n.id));return e.jsxs("div",{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="copy",n.dataTransfer.setData("application/x-immac-mix-name",t.name)},onDragEnd:n=>{var X,Y,K,G,J,q,ne;const l=(X=window.app)==null?void 0:X.canvas;if(!l)return;const w=l.canvas;if(!w)return;const R=w.getBoundingClientRect();if(n.clientXR.right||n.clientYR.bottom)return;const $=l.convertEventToCanvasOffset(n),A=window.LiteGraph,L=A==null?void 0:A.createNode("StyleMixImmacStyleMixer");if(!L)return;L.pos=$,(K=(Y=window.app)==null?void 0:Y.graph)==null||K.add(L);const W=(G=L.widgets)==null?void 0:G.find(fe=>fe.name==="mix");W&&(W.value=t.name,(J=W.callback)==null||J.call(W,t.name,null,null,null,L)),(ne=(q=window.app)==null?void 0:q.graph)==null||ne.setDirtyCanvas(!0,!0)},style:{border:`2px solid ${O?"#88aaff":p?"var(--p-primary-color, #6c6)":"var(--p-surface-border, #444)"}`,borderRadius:8,padding:10,background:O?"rgba(100,130,255,0.07)":"var(--p-surface-section, #1e1e1e)",display:"flex",flexDirection:"column",gap:8,width:"100%",position:"relative",overflow:"hidden",cursor:"grab",transition:"border-color 0.15s, background 0.15s"},onClick:_,onDragOver:n=>{n.dataTransfer.types.includes("application/x-immac-style-id")&&(n.preventDefault(),n.dataTransfer.dropEffect="copy",T(!0))},onDragLeave:n=>{n.currentTarget.contains(n.relatedTarget)||T(!1)},onDrop:n=>{T(!1);const l=n.dataTransfer.getData("application/x-immac-style-id");l&&(n.preventDefault(),n.stopPropagation(),r(l))},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[N?e.jsx("input",{autoFocus:!0,value:b,onChange:n=>m(n.target.value),onBlur:s,onKeyDown:n=>{n.key==="Enter"&&s(),n.key==="Escape"&&z(!1)},style:le}):e.jsx("span",{title:"Double-click to rename",onDoubleClick:()=>{m(t.name),z(!0)},style:{fontWeight:600,flex:1,cursor:"text",fontSize:13},children:t.name}),d&&e.jsx("button",{title:"Pending node-cache changes — click to reload",onClick:n=>{n.stopPropagation(),I()},style:{...U,color:"#f5a623",fontSize:14,animation:"immac-pulse 1.8s ease-in-out infinite"},children:e.jsx("i",{className:"pi pi-exclamation-circle"})}),e.jsx("button",{title:t.favorite?"Remove bookmark":"Bookmark",onClick:()=>y({...t,favorite:!t.favorite}),style:U,children:e.jsx("i",{className:t.favorite?"pi pi-bookmark-fill":"pi pi-bookmark"})}),e.jsx("button",{title:"Duplicate mix",onClick:D,style:{...U,color:"var(--p-text-muted-color, #888)"},children:e.jsx("i",{className:"pi pi-copy"})}),(()=>{const n=t.styles.some(l=>{var w;return l.enabled&&((w=c.find(R=>R.id===l.style_id))==null?void 0:w.value)});return e.jsx("button",{title:n?"Copy combined prompt":"No enabled styles with prompt text",onClick:l=>{l.stopPropagation(),i()},disabled:!n,style:{...U,color:x?"#6c6":"var(--p-text-muted-color, #888)",opacity:n?1:.35},children:e.jsx("i",{className:x?"pi pi-check":"pi pi-clipboard"})})})(),e.jsx("button",{title:"Delete mix",onClick:()=>E(!0),style:{...U,color:"var(--p-text-muted-color, #888)"},children:e.jsx("i",{className:"pi pi-trash"})})]}),v&&e.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(20,20,20,0.92)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,zIndex:10},children:[e.jsx("i",{className:"pi pi-trash",style:{fontSize:22,color:"#e55"}}),e.jsxs("span",{style:{fontSize:13,color:"#ddd",fontWeight:600},children:['Delete "',t.name,'"?']}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>E(!1),style:{...se},children:"Cancel"}),e.jsx("button",{onClick:f,style:{...se,background:"#c33",color:"#fff",borderColor:"#c33"},children:"Delete"})]})]}),e.jsxs("div",{style:{position:"relative",width:"100%",paddingBottom:"100%"},onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1),children:[e.jsx("div",{title:"Click or drop an image to set mix cover",onClick:()=>{var n;return(n=F.current)==null?void 0:n.click()},onDragOver:n=>n.preventDefault(),onDrop:n=>{n.preventDefault();const l=n.dataTransfer.files[0];l&&a(l)},style:{position:"absolute",inset:0,borderRadius:6,border:"1px dashed var(--p-surface-border, #555)",overflow:"hidden",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--p-surface-ground, #141414)",fontSize:11,color:"#888",flexShrink:0},children:g?"Uploading…":t.image_filename?e.jsx("img",{src:re(t.image_filename,t.image_updated_at),alt:t.name,style:{width:"100%",height:"100%",objectFit:"cover",transition:"transform 0.3s ease",transform:P?"scale(1.05)":"scale(1)"}}):"+ cover image"}),!g&&t.image_filename&&P&&e.jsx("button",{title:"View full size",onClick:n=>{n.stopPropagation(),u(!0)},style:be,children:e.jsx("i",{className:"pi pi-search-plus"})})]}),j&&t.image_filename&&e.jsx(ie,{src:re(t.image_filename,t.image_updated_at),alt:t.name,onClose:()=>u(!1)}),e.jsx("input",{ref:F,type:"file",accept:"image/*",style:{display:"none"},onChange:n=>{var w;const l=(w=n.target.files)==null?void 0:w[0];l&&a(l),n.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,maxHeight:240,overflowY:"auto"},children:[t.styles.length===0&&e.jsx("div",{style:{fontSize:11,color:"#666"},children:"No styles added yet."}),t.styles.map((n,l)=>{const w=c.find(R=>R.id===n.style_id);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("button",{title:n.enabled?"Disable":"Enable",onClick:()=>M(l,{enabled:!n.enabled}),style:{...U,fontSize:11,padding:"2px 5px",border:"1px solid var(--p-surface-border, #555)",borderRadius:4,background:n.enabled?"var(--p-primary-color, #557755)":"transparent",color:n.enabled?"#fff":"#888",minWidth:32},children:n.enabled?"ON":"OFF"}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(w==null?void 0:w.name)??n.style_id}),e.jsx(pe,{value:n.weight,onChange:R=>M(l,{weight:R}),min:0,max:1,step:.05,width:64}),e.jsx("button",{title:"Remove from mix",onClick:()=>H(l),style:{...U,color:"#e55",fontSize:13},children:"✕"})]},n.style_id)})]}),e.jsxs("select",{value:"",disabled:C.length===0,onChange:n=>{n.target.value&&r(n.target.value)},style:{...le,cursor:C.length===0?"not-allowed":"pointer",opacity:C.length===0?.45:1},title:C.length===0?"All library styles are already in this mix":"Add a style to this mix",children:[e.jsx("option",{value:"",children:C.length===0?"— all styles already added —":"+ add style…"}),C.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})]})}const se={background:"transparent",border:"1px solid #666",borderRadius:5,color:"#ccc",cursor:"pointer",fontSize:12,padding:"4px 12px"},U={background:"none",border:"none",cursor:"pointer",fontSize:16,padding:"0 2px",color:"inherit",lineHeight:1,flexShrink:0},be={position:"absolute",top:6,left:6,background:"rgba(255,255,255,0.92)",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,padding:"3px 6px",lineHeight:1,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.25)"},le={background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-surface-border, #444)",borderRadius:4,color:"inherit",padding:"2px 4px",fontSize:12,boxSizing:"border-box"};(()=>{if(document.getElementById("immac-pulse-style"))return;const t=document.createElement("style");t.id="immac-pulse-style",t.textContent=`@keyframes immac-pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.55; transform:scale(1.15); } -}`,document.head.appendChild(t)})();function ve({style:t,onUpdate:c,onDelete:p,inCurrentMix:d,onAddToMix:h,onRemoveFromMix:y,isDirty:f,onRefreshCache:D}){const[I,_]=o.useState(!1),[M,z]=o.useState(!1),[b,m]=o.useState(t.name),[g,k]=o.useState(t.value),[j,u]=o.useState(!1),[v,E]=o.useState(!1),[P,B]=o.useState(!1),[x,S]=o.useState(!1),[O,T]=o.useState(!1),F=o.useRef(null),i=!!(h||y);function a(){t.value&&navigator.clipboard.writeText(t.value).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})}function s(){_(!1),b.trim()!==t.name&&c({...t,name:b.trim()||t.name})}function N(){z(!1),g!==t.value&&c({...t,value:g})}async function H(r){if(r.type.startsWith("image/")){u(!0);try{const C=await ge(r);c({...t,image_filename:C,image_updated_at:Date.now()})}catch(C){console.error("[ImmacStyleMixer] Image upload failed",C)}finally{u(!1)}}}return e.jsxs("div",{draggable:!0,onDragStart:r=>{r.dataTransfer.setData("application/x-immac-style-id",t.id),r.dataTransfer.setData("application/x-immac-style-name",t.name),r.dataTransfer.effectAllowed="copy"},onDragEnd:r=>{var L,W,X,Y,K,G,J;const C=(L=window.app)==null?void 0:L.canvas;if(!C)return;const n=C.canvas;if(!n)return;const l=n.getBoundingClientRect();if(r.clientXl.right||r.clientYl.bottom)return;const w=C.convertEventToCanvasOffset(r),R=window.LiteGraph,$=R==null?void 0:R.createNode("StylePickImmacStyleMixer");if(!$)return;$.pos=w,(X=(W=window.app)==null?void 0:W.graph)==null||X.add($);const A=(Y=$.widgets)==null?void 0:Y.find(q=>q.name==="style");A&&(A.value=t.name,(K=A.callback)==null||K.call(A,t.name,null,null,null,$)),(J=(G=window.app)==null?void 0:G.graph)==null||J.setDirtyCanvas(!0,!0)},style:{border:"1px solid var(--p-surface-border, #444)",borderRadius:8,padding:8,width:"100%",background:"var(--p-surface-section, #1e1e1e)",display:"flex",flexDirection:"column",gap:6,position:"relative",overflow:"hidden",cursor:"grab"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{title:t.favorite?"Remove bookmark":"Bookmark",onClick:()=>c({...t,favorite:!t.favorite}),style:V,children:e.jsx("i",{className:t.favorite?"pi pi-bookmark-fill":"pi pi-bookmark"})}),e.jsxs("div",{style:{display:"flex",gap:2},children:[d?e.jsx("button",{title:"Remove from current mix",onClick:y,style:{...V,color:"#e66"},children:e.jsx("i",{className:"pi pi-minus"})}):e.jsx("button",{title:i?"Add to current mix":"No active mix",onClick:h,disabled:!i,style:{...V,color:"var(--p-text-muted-color, #888)",opacity:i?1:.35},children:e.jsx("i",{className:"pi pi-plus"})}),e.jsx("button",{title:t.value?"Copy prompt text":"No prompt text to copy",onClick:a,disabled:!t.value,style:{...V,color:O?"#6c6":"var(--p-text-muted-color, #888)",opacity:t.value?1:.35},children:e.jsx("i",{className:O?"pi pi-check":"pi pi-clipboard"})}),f&&e.jsx("button",{title:"Node combo lists may be stale — click to refresh",onClick:D,style:{...V,color:"#f5a623",fontSize:14,animation:"immac-pulse 1.8s ease-in-out infinite"},children:e.jsx("i",{className:"pi pi-exclamation-circle"})}),e.jsx("button",{title:"Delete style",onClick:()=>B(!0),style:{...V,color:"var(--p-text-muted-color, #888)"},children:e.jsx("i",{className:"pi pi-trash"})})]})]}),P&&e.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(20,20,20,0.92)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,zIndex:10},children:[e.jsx("i",{className:"pi pi-trash",style:{fontSize:22,color:"#e55"}}),e.jsxs("span",{style:{fontSize:13,color:"#ddd",fontWeight:600},children:['Delete "',t.name,'"?']}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>B(!1),style:{...ce},children:"Cancel"}),e.jsx("button",{onClick:p,style:{...ce,background:"#c33",color:"#fff",borderColor:"#c33"},children:"Delete"})]})]}),e.jsxs("div",{style:{position:"relative",width:"100%",paddingBottom:"100%"},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsx("div",{title:"Click or drop to upload image",onClick:()=>{var r;return(r=F.current)==null?void 0:r.click()},onDragOver:r=>r.preventDefault(),onDrop:r=>{r.preventDefault();const C=r.dataTransfer.files[0];C&&H(C)},style:{position:"absolute",inset:0,borderRadius:6,border:"1px dashed var(--p-surface-border, #555)",overflow:"hidden",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--p-surface-ground, #141414)",fontSize:11,color:"#888"},children:j?"Uploading…":t.image_filename?e.jsx("img",{src:Q(t.image_filename,t.image_updated_at),alt:t.name,style:{width:"100%",height:"100%",objectFit:"cover",transition:"transform 0.3s ease",transform:x?"scale(1.05)":"scale(1)"}}):"+ image"}),!j&&t.image_filename&&x&&e.jsx("button",{title:"View full size",onClick:r=>{r.stopPropagation(),E(!0)},style:ke,children:e.jsx("i",{className:"pi pi-search-plus"})})]}),v&&t.image_filename&&e.jsx(ie,{src:Q(t.image_filename,t.image_updated_at),alt:t.name,onClose:()=>E(!1)}),e.jsx("input",{ref:F,type:"file",accept:"image/*",style:{display:"none"},onChange:r=>{var n;const C=(n=r.target.files)==null?void 0:n[0];C&&H(C),r.target.value=""}}),I?e.jsx("input",{autoFocus:!0,value:b,onChange:r=>m(r.target.value),onBlur:s,onKeyDown:r=>{r.key==="Enter"&&s(),r.key==="Escape"&&_(!1)},style:de}):e.jsx("div",{title:"Click to rename",onDoubleClick:()=>{m(t.name),_(!0)},style:{fontWeight:600,fontSize:13,cursor:"text",wordBreak:"break-word"},children:t.name}),M?e.jsx("textarea",{autoFocus:!0,value:g,onChange:r=>k(r.target.value),onBlur:N,onKeyDown:r=>{r.key==="Escape"&&z(!1)},rows:3,style:{...de,resize:"vertical"}}):e.jsx("div",{title:"Click to edit prompt text",onDoubleClick:()=>{k(t.value),z(!0)},style:{fontSize:11,color:"#aaa",cursor:"text",wordBreak:"break-word",minHeight:32},children:t.value||e.jsx("span",{style:{color:"#555"},children:"double-click to add prompt…"})})]})}const ce={background:"transparent",border:"1px solid #666",borderRadius:5,color:"#ccc",cursor:"pointer",fontSize:12,padding:"4px 12px"},V={background:"none",border:"none",cursor:"pointer",fontSize:16,padding:"0 2px",color:"inherit",lineHeight:1},ke={position:"absolute",top:6,left:6,background:"rgba(255,255,255,0.92)",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,padding:"3px 6px",lineHeight:1,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.25)"},de={width:"100%",boxSizing:"border-box",background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-primary-color, #6c6)",borderRadius:4,color:"inherit",padding:"2px 4px",fontSize:12};function we({styles:t,onUpdate:c,onDelete:p,onAdd:d,currentMixStyleIds:h,onAddToMix:y,onRemoveFromMix:f,isDirty:D,onRefreshCache:I}){const[_,M]=o.useState(""),[z,b]=o.useState(!1);function m(){const u=_.trim();u&&(d(u),M(""),b(!1))}const g=t.filter(u=>u.favorite),k=t.filter(u=>!u.favorite),j=[...g,...k];return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:10},children:[j.map(u=>e.jsx(ve,{style:u,onUpdate:c,onDelete:()=>p(u.id),inCurrentMix:h==null?void 0:h.has(u.id),onAddToMix:y?()=>y(u.id):void 0,onRemoveFromMix:f?()=>f(u.id):void 0,isDirty:D,onRefreshCache:I},u.id)),z?e.jsxs("div",{style:{border:"1px dashed var(--p-primary-color, #6c6)",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8,background:"var(--p-surface-section, #1e1e1e)",flexShrink:0},children:[e.jsx("input",{autoFocus:!0,placeholder:"Style name…",value:_,onChange:u=>M(u.target.value),onKeyDown:u=>{u.key==="Enter"&&m(),u.key==="Escape"&&b(!1)},style:je}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:m,style:ue,children:"Add"}),e.jsx("button",{onClick:()=>{b(!1),M("")},style:{...ue,background:"transparent",color:"#aaa"},children:"Cancel"})]})]}):e.jsx("button",{title:"Add a new style",onClick:()=>b(!0),style:{width:"100%",minHeight:80,border:"1px dashed var(--p-surface-border, #555)",borderRadius:8,background:"transparent",color:"#666",cursor:"pointer",fontSize:24},children:"+"})]})})}const je={width:"100%",boxSizing:"border-box",background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-primary-color, #6c6)",borderRadius:4,color:"inherit",padding:"4px 6px",fontSize:13},ue={flex:1,background:"var(--p-primary-color, #557755)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",padding:"4px 8px",fontSize:12};function Z(){return crypto.randomUUID()}function ee({title:t,children:c,defaultOpen:p=!0,grow:d=!0}){const[h,y]=o.useState(p);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:h&&d?"1 1 0":"0 0 auto",minHeight:0,borderBottom:"1px solid var(--p-surface-border, #333)"},children:[e.jsxs("button",{onClick:()=>y(f=>!f),style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",cursor:"pointer",padding:"8px 0",width:"100%",textAlign:"left",color:"#888",flexShrink:0},children:[e.jsx("i",{className:`pi ${h?"pi-chevron-down":"pi-chevron-right"}`,style:{fontSize:10,flexShrink:0}}),e.jsx("span",{style:{fontWeight:700,fontSize:12,textTransform:"uppercase",letterSpacing:"0.08em"},children:t})]}),h&&e.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:8},children:c})]})}function De(){const{data:t,loading:c,error:p,update:d,pendingRefresh:h,refreshNodes:y}=xe(),f=t.mixes.find(i=>i.id===t.current_mix_id)??null,[D,I]=o.useState(null),[_,M]=o.useState(null),[z,b]=o.useState(!1),m=o.useCallback(i=>{const a={id:Z(),name:i,value:"",favorite:!1,image_filename:null};d(s=>({...s,styles:[...s.styles,a]}))},[d]),g=o.useCallback(i=>{d(a=>({...a,styles:a.styles.map(s=>s.id===i.id?i:s)}))},[d]),k=o.useCallback(i=>{d(a=>({...a,styles:a.styles.filter(s=>s.id!==i),mixes:a.mixes.map(s=>({...s,styles:s.styles.filter(N=>N.style_id!==i)}))}))},[d]),j=o.useCallback(i=>{const a={...i,id:Z(),name:`${i.name} (copy)`,favorite:!1};d(s=>{const N=s.mixes.findIndex(r=>r.id===i.id),H=[...s.mixes];return H.splice(N+1,0,a),{...s,mixes:H}})},[d]),u=o.useCallback(()=>{const i={id:Z(),name:`Mix ${t.mixes.length+1}`,favorite:!1,image_filename:null,styles:[]};d(a=>({...a,mixes:[...a.mixes,i]}))},[t.mixes.length,d]),v=o.useCallback((i,a)=>{d(s=>({...s,mixes:s.mixes.map(N=>N.id===i.id?i:N)}),a)},[d]),E=o.useCallback(i=>{f&&(f.styles.some(a=>a.style_id===i)||v({...f,styles:[...f.styles,{style_id:i,weight:1,enabled:!0}]}))},[f,v]),P=o.useCallback(i=>{f&&v({...f,styles:f.styles.filter(a=>a.style_id!==i)})},[f,v]),B=o.useCallback(i=>{d(a=>({...a,mixes:a.mixes.filter(s=>s.id!==i),current_mix_id:a.current_mix_id===i?null:a.current_mix_id}))},[d]),x=o.useCallback(i=>{d(a=>({...a,current_mix_id:i}))},[d]),S=o.useCallback((i,a,s)=>{f&&v({...f,styles:f.styles.map(N=>N.style_id===i?{...N,...a}:N)},s)},[f,v]);if(c)return e.jsx("div",{style:te,children:"Loading…"});if(p)return e.jsxs("div",{style:{...te,color:"#e55"},children:["Error: ",p]});const O=t.mixes.filter(i=>i.favorite),T=t.mixes.filter(i=>!i.favorite),F=[...O,...T];return e.jsxs("div",{style:te,children:[e.jsx(ee,{title:"Current Mix",grow:!1,children:f?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("div",{style:{fontWeight:600,fontSize:14},children:f.name}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"nowrap",overflowX:"auto",borderRadius:6,border:`1px dashed ${z?"#88aaff":"transparent"}`,background:z?"rgba(100,130,255,0.07)":"transparent",padding:z?4:0,transition:"border-color 0.15s, background 0.15s, padding 0.1s",minHeight:40,paddingBottom:6},onDragOver:i=>{i.dataTransfer.types.includes("application/x-immac-style-id")&&(i.preventDefault(),i.dataTransfer.dropEffect="copy",b(!0))},onDragLeave:i=>{i.currentTarget.contains(i.relatedTarget)||b(!1)},onDrop:i=>{b(!1);const a=i.dataTransfer.getData("application/x-immac-style-id");a&&(i.preventDefault(),E(a))},children:[f.styles.length===0&&!z&&e.jsx("div",{style:{fontSize:12,color:"#666"},children:"No styles in this mix yet."}),f.styles.map(i=>{const a=t.styles.find(s=>s.id===i.style_id);return e.jsxs("div",{onMouseEnter:()=>M(i.style_id),onMouseLeave:()=>M(null),onDoubleClick:()=>S(i.style_id,{enabled:!i.enabled},{silent:!0}),style:{border:`1px solid ${i.enabled?"var(--p-primary-color, #6c6)":"var(--p-surface-border, #444)"}`,borderRadius:6,overflow:"hidden",background:"var(--p-surface-section, #1e1e1e)",opacity:i.enabled?1:.45,fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",width:180,flexShrink:0},children:[e.jsxs("div",{style:{position:"relative",width:"100%",paddingBottom:"100%"},children:[e.jsx("div",{style:{position:"absolute",inset:0,background:"var(--p-surface-ground, #141414)",display:"flex",alignItems:"center",justifyContent:"center"},children:a!=null&&a.image_filename?e.jsx("img",{src:Q(a.image_filename,a.image_updated_at),alt:a.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block",transition:"transform 0.3s ease",transform:_===i.style_id?"scale(1.05)":"scale(1)"}}):e.jsx("i",{className:"pi pi-image",style:{fontSize:20,color:"#555"}})}),(a==null?void 0:a.image_filename)&&_===i.style_id&&e.jsx("button",{title:"View full size",onClick:()=>I(Q(a.image_filename,a.image_updated_at)),style:{position:"absolute",top:6,left:6,background:"rgba(255,255,255,0.92)",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,padding:"3px 6px",lineHeight:1,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.25)"},children:e.jsx("i",{className:"pi pi-search-plus"})})]}),e.jsxs("div",{style:{padding:"4px 6px",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:4},children:[e.jsx("div",{style:{fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:"center",fontSize:12},children:(a==null?void 0:a.name)??"?"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("button",{title:i.enabled?"Disable style":"Enable style",onClick:s=>{s.stopPropagation(),S(i.style_id,{enabled:!i.enabled},{silent:!0})},style:{background:i.enabled?"var(--p-primary-color, #557755)":"transparent",border:"1px solid var(--p-surface-border, #555)",borderRadius:4,color:i.enabled?"#fff":"#888",cursor:"pointer",fontSize:10,padding:"1px 4px",lineHeight:1,flexShrink:0},children:i.enabled?"ON":"OFF"}),e.jsx("div",{style:{flex:1,minWidth:0},onClick:s=>s.stopPropagation(),children:e.jsx(pe,{value:i.weight,onChange:s=>S(i.style_id,{weight:s},{silent:!0}),min:0,max:1,step:.05,width:"100%"})}),e.jsx("button",{title:"Remove from mix",onClick:s=>{s.stopPropagation(),P(i.style_id)},style:{background:"none",border:"none",cursor:"pointer",color:"#e66",fontSize:13,padding:"0 2px",lineHeight:1,flexShrink:0},children:"✕"})]})]})]},i.style_id)})]})]}):e.jsx("div",{style:{fontSize:12,color:"#666"},children:"No mix active — select one from Mixes below."})}),e.jsx(ee,{title:"Mixes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:10,paddingBottom:4},children:[F.map(i=>e.jsx("div",{style:{flex:"0 0 280px"},children:e.jsx(ye,{mix:i,styles:t.styles,isActive:i.id===t.current_mix_id,isDirty:h,onActivate:()=>x(i.id),onUpdate:v,onDelete:()=>B(i.id),onDuplicate:()=>j(i),onRefreshCache:y})},i.id)),e.jsx("button",{title:"Add a new mix",onClick:u,style:{flex:"0 0 120px",minHeight:80,border:"1px dashed var(--p-surface-border, #555)",borderRadius:8,background:"transparent",color:"#666",cursor:"pointer",fontSize:22},children:"+"})]})}),e.jsx(ee,{title:"Styles",children:e.jsx(we,{styles:t.styles,onUpdate:g,onDelete:k,onAdd:m,currentMixStyleIds:f?new Set(f.styles.map(i=>i.style_id)):void 0,onAddToMix:f?E:void 0,onRemoveFromMix:f?P:void 0,isDirty:h,onRefreshCache:y})}),D&&e.jsx(ie,{src:D,onClose:()=>I(null)})]})}const te={position:"absolute",inset:0,padding:"0 12px",display:"flex",flexDirection:"column",overflow:"hidden",color:"var(--p-text-color, #eee)",fontSize:13,boxSizing:"border-box"};export{De as default}; +}`,document.head.appendChild(t)})();function ve({style:t,onUpdate:c,onDelete:p,inCurrentMix:d,onAddToMix:h,onRemoveFromMix:y,isDirty:f,onRefreshCache:D}){const[I,_]=o.useState(!1),[N,z]=o.useState(!1),[b,m]=o.useState(t.name),[g,k]=o.useState(t.value),[j,u]=o.useState(!1),[v,E]=o.useState(!1),[P,B]=o.useState(!1),[x,S]=o.useState(!1),[O,T]=o.useState(!1),F=o.useRef(null),i=!!(h||y);function a(){t.value&&navigator.clipboard.writeText(t.value).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})}function s(){_(!1),b.trim()!==t.name&&c({...t,name:b.trim()||t.name})}function M(){z(!1),g!==t.value&&c({...t,value:g})}async function H(r){if(r.type.startsWith("image/")){u(!0);try{const C=await ge(r);c({...t,image_filename:C,image_updated_at:Date.now()})}catch(C){console.error("[ImmacStyleMixer] Image upload failed",C)}finally{u(!1)}}}return e.jsxs("div",{draggable:!0,onDragStart:r=>{r.dataTransfer.setData("application/x-immac-style-id",t.id),r.dataTransfer.setData("application/x-immac-style-name",t.name),r.dataTransfer.effectAllowed="copy"},onDragEnd:r=>{var L,W,X,Y,K,G,J;const C=(L=window.app)==null?void 0:L.canvas;if(!C)return;const n=C.canvas;if(!n)return;const l=n.getBoundingClientRect();if(r.clientXl.right||r.clientYl.bottom)return;const w=C.convertEventToCanvasOffset(r),R=window.LiteGraph,$=R==null?void 0:R.createNode("StylePickImmacStyleMixer");if(!$)return;$.pos=w,(X=(W=window.app)==null?void 0:W.graph)==null||X.add($);const A=(Y=$.widgets)==null?void 0:Y.find(q=>q.name==="style");A&&(A.value=t.name,(K=A.callback)==null||K.call(A,t.name,null,null,null,$)),(J=(G=window.app)==null?void 0:G.graph)==null||J.setDirtyCanvas(!0,!0)},style:{border:"1px solid var(--p-surface-border, #444)",borderRadius:8,padding:8,width:"100%",background:"var(--p-surface-section, #1e1e1e)",display:"flex",flexDirection:"column",gap:6,position:"relative",overflow:"hidden",cursor:"grab"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{title:t.favorite?"Remove bookmark":"Bookmark",onClick:()=>c({...t,favorite:!t.favorite}),style:V,children:e.jsx("i",{className:t.favorite?"pi pi-bookmark-fill":"pi pi-bookmark"})}),e.jsxs("div",{style:{display:"flex",gap:2},children:[d?e.jsx("button",{title:"Remove from current mix",onClick:y,style:{...V,color:"#e66"},children:e.jsx("i",{className:"pi pi-minus"})}):e.jsx("button",{title:i?"Add to current mix":"No active mix",onClick:h,disabled:!i,style:{...V,color:"var(--p-text-muted-color, #888)",opacity:i?1:.35},children:e.jsx("i",{className:"pi pi-plus"})}),e.jsx("button",{title:t.value?"Copy prompt text":"No prompt text to copy",onClick:a,disabled:!t.value,style:{...V,color:O?"#6c6":"var(--p-text-muted-color, #888)",opacity:t.value?1:.35},children:e.jsx("i",{className:O?"pi pi-check":"pi pi-clipboard"})}),f&&e.jsx("button",{title:"Node combo lists may be stale — click to refresh",onClick:D,style:{...V,color:"#f5a623",fontSize:14,animation:"immac-pulse 1.8s ease-in-out infinite"},children:e.jsx("i",{className:"pi pi-exclamation-circle"})}),e.jsx("button",{title:"Delete style",onClick:()=>B(!0),style:{...V,color:"var(--p-text-muted-color, #888)"},children:e.jsx("i",{className:"pi pi-trash"})})]})]}),P&&e.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(20,20,20,0.92)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,zIndex:10},children:[e.jsx("i",{className:"pi pi-trash",style:{fontSize:22,color:"#e55"}}),e.jsxs("span",{style:{fontSize:13,color:"#ddd",fontWeight:600},children:['Delete "',t.name,'"?']}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>B(!1),style:{...ce},children:"Cancel"}),e.jsx("button",{onClick:p,style:{...ce,background:"#c33",color:"#fff",borderColor:"#c33"},children:"Delete"})]})]}),e.jsxs("div",{style:{position:"relative",width:"100%",paddingBottom:"100%"},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsx("div",{title:"Click or drop to upload image",onClick:()=>{var r;return(r=F.current)==null?void 0:r.click()},onDragOver:r=>r.preventDefault(),onDrop:r=>{r.preventDefault();const C=r.dataTransfer.files[0];C&&H(C)},style:{position:"absolute",inset:0,borderRadius:6,border:"1px dashed var(--p-surface-border, #555)",overflow:"hidden",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--p-surface-ground, #141414)",fontSize:11,color:"#888"},children:j?"Uploading…":t.image_filename?e.jsx("img",{src:Q(t.image_filename,t.image_updated_at),alt:t.name,style:{width:"100%",height:"100%",objectFit:"cover",transition:"transform 0.3s ease",transform:x?"scale(1.05)":"scale(1)"}}):"+ image"}),!j&&t.image_filename&&x&&e.jsx("button",{title:"View full size",onClick:r=>{r.stopPropagation(),E(!0)},style:ke,children:e.jsx("i",{className:"pi pi-search-plus"})})]}),v&&t.image_filename&&e.jsx(ie,{src:Q(t.image_filename,t.image_updated_at),alt:t.name,onClose:()=>E(!1)}),e.jsx("input",{ref:F,type:"file",accept:"image/*",style:{display:"none"},onChange:r=>{var n;const C=(n=r.target.files)==null?void 0:n[0];C&&H(C),r.target.value=""}}),I?e.jsx("input",{autoFocus:!0,value:b,onChange:r=>m(r.target.value),onBlur:s,onKeyDown:r=>{r.key==="Enter"&&s(),r.key==="Escape"&&_(!1)},style:de}):e.jsx("div",{title:"Click to rename",onDoubleClick:()=>{m(t.name),_(!0)},style:{fontWeight:600,fontSize:13,cursor:"text",wordBreak:"break-word"},children:t.name}),N?e.jsx("textarea",{autoFocus:!0,value:g,onChange:r=>k(r.target.value),onBlur:M,onKeyDown:r=>{r.key==="Escape"&&z(!1)},rows:3,style:{...de,resize:"vertical"}}):e.jsx("div",{title:"Click to edit prompt text",onDoubleClick:()=>{k(t.value),z(!0)},style:{fontSize:11,color:"#aaa",cursor:"text",wordBreak:"break-word",minHeight:32},children:t.value||e.jsx("span",{style:{color:"#555"},children:"double-click to add prompt…"})})]})}const ce={background:"transparent",border:"1px solid #666",borderRadius:5,color:"#ccc",cursor:"pointer",fontSize:12,padding:"4px 12px"},V={background:"none",border:"none",cursor:"pointer",fontSize:16,padding:"0 2px",color:"inherit",lineHeight:1},ke={position:"absolute",top:6,left:6,background:"rgba(255,255,255,0.92)",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,padding:"3px 6px",lineHeight:1,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.25)"},de={width:"100%",boxSizing:"border-box",background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-primary-color, #6c6)",borderRadius:4,color:"inherit",padding:"2px 4px",fontSize:12};function we({styles:t,onUpdate:c,onDelete:p,onAdd:d,currentMixStyleIds:h,onAddToMix:y,onRemoveFromMix:f,isDirty:D,onRefreshCache:I}){const[_,N]=o.useState(""),[z,b]=o.useState(!1);function m(){const u=_.trim();u&&(d(u),N(""),b(!1))}const g=t.filter(u=>u.favorite),k=t.filter(u=>!u.favorite),j=[...g,...k];return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:10},children:[j.map(u=>e.jsx(ve,{style:u,onUpdate:c,onDelete:()=>p(u.id),inCurrentMix:h==null?void 0:h.has(u.id),onAddToMix:y?()=>y(u.id):void 0,onRemoveFromMix:f?()=>f(u.id):void 0,isDirty:D,onRefreshCache:I},u.id)),z?e.jsxs("div",{style:{border:"1px dashed var(--p-primary-color, #6c6)",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8,background:"var(--p-surface-section, #1e1e1e)",flexShrink:0},children:[e.jsx("input",{autoFocus:!0,placeholder:"Style name…",value:_,onChange:u=>N(u.target.value),onKeyDown:u=>{u.key==="Enter"&&m(),u.key==="Escape"&&b(!1)},style:je}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:m,style:ue,children:"Add"}),e.jsx("button",{onClick:()=>{b(!1),N("")},style:{...ue,background:"transparent",color:"#aaa"},children:"Cancel"})]})]}):e.jsx("button",{title:"Add a new style",onClick:()=>b(!0),style:{width:"100%",minHeight:80,border:"1px dashed var(--p-surface-border, #555)",borderRadius:8,background:"transparent",color:"#666",cursor:"pointer",fontSize:24},children:"+"})]})})}const je={width:"100%",boxSizing:"border-box",background:"var(--p-surface-ground, #141414)",border:"1px solid var(--p-primary-color, #6c6)",borderRadius:4,color:"inherit",padding:"4px 6px",fontSize:13},ue={flex:1,background:"var(--p-primary-color, #557755)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",padding:"4px 8px",fontSize:12};function Z(){return crypto.randomUUID()}function ee({title:t,children:c,defaultOpen:p=!0,grow:d=!0}){const[h,y]=o.useState(p);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:h&&d?"1 1 0":"0 0 auto",minHeight:0,borderBottom:"1px solid var(--p-surface-border, #333)"},children:[e.jsxs("button",{onClick:()=>y(f=>!f),style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",cursor:"pointer",padding:"8px 0",width:"100%",textAlign:"left",color:"#888",flexShrink:0},children:[e.jsx("i",{className:`pi ${h?"pi-chevron-down":"pi-chevron-right"}`,style:{fontSize:10,flexShrink:0}}),e.jsx("span",{style:{fontWeight:700,fontSize:12,textTransform:"uppercase",letterSpacing:"0.08em"},children:t})]}),h&&e.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:8},children:c})]})}function De(){const{data:t,loading:c,error:p,update:d,pendingRefresh:h,refreshNodes:y}=xe(),f=t.mixes.find(i=>i.id===t.current_mix_id)??null,[D,I]=o.useState(null),[_,N]=o.useState(null),[z,b]=o.useState(!1),m=o.useCallback(i=>{const a={id:Z(),name:i,value:"",favorite:!1,image_filename:null};d(s=>({...s,styles:[...s.styles,a]}))},[d]),g=o.useCallback(i=>{d(a=>({...a,styles:a.styles.map(s=>s.id===i.id?i:s)}))},[d]),k=o.useCallback(i=>{d(a=>({...a,styles:a.styles.filter(s=>s.id!==i),mixes:a.mixes.map(s=>({...s,styles:s.styles.filter(M=>M.style_id!==i)}))}))},[d]),j=o.useCallback(i=>{const a={...i,id:Z(),name:`${i.name} (copy)`,favorite:!1};d(s=>{const M=s.mixes.findIndex(r=>r.id===i.id),H=[...s.mixes];return H.splice(M+1,0,a),{...s,mixes:H}})},[d]),u=o.useCallback(()=>{const i={id:Z(),name:`Mix ${t.mixes.length+1}`,favorite:!1,image_filename:null,styles:[]};d(a=>({...a,mixes:[...a.mixes,i]}))},[t.mixes.length,d]),v=o.useCallback((i,a)=>{d(s=>({...s,mixes:s.mixes.map(M=>M.id===i.id?i:M)}),a)},[d]),E=o.useCallback(i=>{f&&(f.styles.some(a=>a.style_id===i)||v({...f,styles:[...f.styles,{style_id:i,weight:1,enabled:!0}]}))},[f,v]),P=o.useCallback(i=>{f&&v({...f,styles:f.styles.filter(a=>a.style_id!==i)})},[f,v]),B=o.useCallback(i=>{d(a=>({...a,mixes:a.mixes.filter(s=>s.id!==i),current_mix_id:a.current_mix_id===i?null:a.current_mix_id}))},[d]),x=o.useCallback(i=>{d(a=>({...a,current_mix_id:i}))},[d]),S=o.useCallback((i,a,s)=>{f&&v({...f,styles:f.styles.map(M=>M.style_id===i?{...M,...a}:M)},s)},[f,v]);if(c)return e.jsx("div",{style:te,children:"Loading…"});if(p)return e.jsxs("div",{style:{...te,color:"#e55"},children:["Error: ",p]});const O=t.mixes.filter(i=>i.favorite),T=t.mixes.filter(i=>!i.favorite),F=[...O,...T];return e.jsxs("div",{style:te,children:[e.jsx(ee,{title:"Current Mix",grow:!1,children:f?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("div",{style:{fontWeight:600,fontSize:14},children:f.name}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"nowrap",overflowX:"auto",borderRadius:6,border:`1px dashed ${z?"#88aaff":"transparent"}`,background:z?"rgba(100,130,255,0.07)":"transparent",padding:z?4:0,transition:"border-color 0.15s, background 0.15s, padding 0.1s",minHeight:40,paddingBottom:6},onDragOver:i=>{i.dataTransfer.types.includes("application/x-immac-style-id")&&(i.preventDefault(),i.dataTransfer.dropEffect="copy",b(!0))},onDragLeave:i=>{i.currentTarget.contains(i.relatedTarget)||b(!1)},onDrop:i=>{b(!1);const a=i.dataTransfer.getData("application/x-immac-style-id");a&&(i.preventDefault(),E(a))},children:[f.styles.length===0&&!z&&e.jsx("div",{style:{fontSize:12,color:"#666"},children:"No styles in this mix yet."}),f.styles.map(i=>{const a=t.styles.find(s=>s.id===i.style_id);return e.jsxs("div",{onMouseEnter:()=>N(i.style_id),onMouseLeave:()=>N(null),onDoubleClick:()=>S(i.style_id,{enabled:!i.enabled},{silent:!0}),style:{border:`1px solid ${i.enabled?"var(--p-primary-color, #6c6)":"var(--p-surface-border, #444)"}`,borderRadius:6,overflow:"hidden",background:"var(--p-surface-section, #1e1e1e)",opacity:i.enabled?1:.45,fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",width:180,flexShrink:0},children:[e.jsxs("div",{style:{position:"relative",width:"100%",paddingBottom:"100%"},children:[e.jsx("div",{style:{position:"absolute",inset:0,background:"var(--p-surface-ground, #141414)",display:"flex",alignItems:"center",justifyContent:"center"},children:a!=null&&a.image_filename?e.jsx("img",{src:Q(a.image_filename,a.image_updated_at),alt:a.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block",transition:"transform 0.3s ease",transform:_===i.style_id?"scale(1.05)":"scale(1)"}}):e.jsx("i",{className:"pi pi-image",style:{fontSize:20,color:"#555"}})}),(a==null?void 0:a.image_filename)&&_===i.style_id&&e.jsx("button",{title:"View full size",onClick:()=>I(Q(a.image_filename,a.image_updated_at)),style:{position:"absolute",top:6,left:6,background:"rgba(255,255,255,0.92)",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,padding:"3px 6px",lineHeight:1,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.25)"},children:e.jsx("i",{className:"pi pi-search-plus"})})]}),e.jsxs("div",{style:{padding:"4px 6px",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:4},children:[e.jsx("div",{style:{fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:"center",fontSize:12},children:(a==null?void 0:a.name)??"?"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("button",{title:i.enabled?"Disable style":"Enable style",onClick:s=>{s.stopPropagation(),S(i.style_id,{enabled:!i.enabled},{silent:!0})},style:{background:i.enabled?"var(--p-primary-color, #557755)":"transparent",border:"1px solid var(--p-surface-border, #555)",borderRadius:4,color:i.enabled?"#fff":"#888",cursor:"pointer",fontSize:10,padding:"1px 4px",lineHeight:1,flexShrink:0},children:i.enabled?"ON":"OFF"}),e.jsx("div",{style:{flex:1,minWidth:0},onClick:s=>s.stopPropagation(),children:e.jsx(pe,{value:i.weight,onChange:s=>S(i.style_id,{weight:s},{silent:!0}),min:0,max:1,step:.05,width:"100%"})}),e.jsx("button",{title:"Remove from mix",onClick:s=>{s.stopPropagation(),P(i.style_id)},style:{background:"none",border:"none",cursor:"pointer",color:"#e66",fontSize:13,padding:"0 2px",lineHeight:1,flexShrink:0},children:"✕"})]})]})]},i.style_id)})]})]}):e.jsx("div",{style:{fontSize:12,color:"#666"},children:"No mix active — select one from Mixes below."})}),e.jsx(ee,{title:"Mixes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:10,paddingBottom:4},children:[F.map(i=>e.jsx("div",{style:{flex:"0 0 280px"},children:e.jsx(ye,{mix:i,styles:t.styles,isActive:i.id===t.current_mix_id,isDirty:h,onActivate:()=>x(i.id),onUpdate:v,onDelete:()=>B(i.id),onDuplicate:()=>j(i),onRefreshCache:y})},i.id)),e.jsx("button",{title:"Add a new mix",onClick:u,style:{flex:"0 0 120px",minHeight:80,border:"1px dashed var(--p-surface-border, #555)",borderRadius:8,background:"transparent",color:"#666",cursor:"pointer",fontSize:22},children:"+"})]})}),e.jsx(ee,{title:"Styles",children:e.jsx(we,{styles:t.styles,onUpdate:g,onDelete:k,onAdd:m,currentMixStyleIds:f?new Set(f.styles.map(i=>i.style_id)):void 0,onAddToMix:f?E:void 0,onRemoveFromMix:f?P:void 0,isDirty:h,onRefreshCache:y})}),D&&e.jsx(ie,{src:D,onClose:()=>I(null)})]})}const te={position:"absolute",inset:0,padding:"0 12px",display:"flex",flexDirection:"column",overflow:"hidden",color:"var(--p-text-color, #eee)",fontSize:13,boxSizing:"border-box"};export{De as default}; diff --git a/dist/immac_style_mixer/main.js b/dist/immac_style_mixer/main.js index b6067b1..26ee6a1 100644 --- a/dist/immac_style_mixer/main.js +++ b/dist/immac_style_mixer/main.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["immac_style_mixer/StyleMixerPanel-C1N_9fxL.js","immac_style_mixer/vendor-DPfS0z4g.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["immac_style_mixer/StyleMixerPanel-CveihzM7.js","immac_style_mixer/vendor-DPfS0z4g.js"])))=>i.map(i=>d[i]); import{r as T,a as z,R as j}from"./vendor-DPfS0z4g.js";const L="modulepreload",B=function(p){return"/"+p},C={},N=function(m,h,f){let e=Promise.resolve();if(h&&h.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),i=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));e=Promise.allSettled(h.map(t=>{if(t=B(t),t in C)return;C[t]=!0;const r=t.endsWith(".css"),o=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${t}"]${o}`))return;const n=document.createElement("link");if(n.rel=r?"stylesheet":L,r||(n.as="script"),n.crossOrigin="",n.href=t,i&&n.setAttribute("nonce",i),document.head.appendChild(n),r)return new Promise((u,l)=>{n.addEventListener("load",u),n.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${t}`)))})}))}function a(s){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=s,window.dispatchEvent(i),!i.defaultPrevented)throw s}return e.then(s=>{for(const i of s||[])i.status==="rejected"&&a(i.reason);return m().catch(a)})};var M={exports:{}},P={};/** * @license React * react-jsx-runtime.production.min.js @@ -7,4 +7,4 @@ import{r as T,a as z,R as j}from"./vendor-DPfS0z4g.js";const L="modulepreload",B * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var A=T,D=Symbol.for("react.element"),F=Symbol.for("react.fragment"),Z=Object.prototype.hasOwnProperty,J=A.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,W={key:!0,ref:!0,__self:!0,__source:!0};function U(p,m,h){var f,e={},a=null,s=null;h!==void 0&&(a=""+h),m.key!==void 0&&(a=""+m.key),m.ref!==void 0&&(s=m.ref);for(f in m)Z.call(m,f)&&!W.hasOwnProperty(f)&&(e[f]=m[f]);if(p&&p.defaultProps)for(f in m=p.defaultProps,m)e[f]===void 0&&(e[f]=m[f]);return{$$typeof:D,type:p,key:a,ref:s,props:e,_owner:J.current}}P.Fragment=F;P.jsx=U;P.jsxs=U;M.exports=P;var k=M.exports,I={},O=z;I.createRoot=O.createRoot,I.hydrateRoot=O.hydrateRoot;const H=j.lazy(()=>N(()=>import("./StyleMixerPanel-C1N_9fxL.js"),__vite__mapDeps([0,1])));function q(){return new Promise(p=>{function m(){if(window.app){p();return}const h=setInterval(()=>{window.app&&(clearInterval(h),p())},50);setTimeout(()=>{clearInterval(h),console.error("[ImmacStyleMixer] Timeout waiting for ComfyUI app"),p()},5e3)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m):m()})}async function V(){if(await q(),!window.app){console.error("[ImmacStyleMixer] ComfyUI app not available");return}window.app.extensionManager.registerSidebarTab({id:"immac-style-mixer",icon:"pi pi-palette",title:"Style Mixer",tooltip:"Immac Style Mixer",type:"custom",render:e=>{const a=document.createElement("div");a.id="immac-style-mixer-root",a.style.position="absolute",a.style.inset="0",a.style.overflow="hidden",e.style.position="relative",e.style.height="100%",e.appendChild(a),I.createRoot(a).render(k.jsx(j.StrictMode,{children:k.jsx(T.Suspense,{fallback:k.jsx("div",{style:{padding:"1rem"},children:"Loading…"}),children:k.jsx(H,{})})}))}});const p="/immac_style_mixer/api/data";async function m(){const e=await fetch(p);if(!e.ok){alert(`Backup failed: HTTP ${e.status}`);return}const a=await e.json(),s=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(s),t=document.createElement("a");t.href=i,t.download=`style_mixer_backup_${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(i)}function h(){const e=document.createElement("a");e.href="/immac_style_mixer/api/backup.zip",e.download=`style_mixer_backup_${new Date().toISOString().slice(0,10)}.zip`,e.click()}function f(){const e=document.createElement("input");e.type="file",e.accept=".json,.zip,application/json,application/zip",e.onchange=()=>{var i;const a=(i=e.files)==null?void 0:i[0];if(!a)return;if(a.name.endsWith(".zip")||a.type==="application/zip")a.arrayBuffer().then(async t=>{var r,o;try{const n=await fetch("/immac_style_mixer/api/restore.zip",{method:"POST",headers:{"Content-Type":"application/zip"},body:t});if(!n.ok){const l=await n.text();throw new Error(`HTTP ${n.status}: ${l.slice(0,300)}`)}const u=await n.json();try{(o=(r=window.app)==null?void 0:r.toast)==null||o.add({severity:"success",summary:"Style Mixer",detail:`ZIP restored: ${u.styles} styles, ${u.mixes} mixes, ${u.images} images. Reload the Style Mixer panel to see changes.`,life:6e3})}catch{}}catch(n){alert(`Failed to restore ZIP backup: ${n.message}`)}}).catch(t=>alert(`Could not read file: ${t.message}`));else{const t=new FileReader;t.onload=async r=>{var o,n,u;try{const l=JSON.parse((o=r.target)==null?void 0:o.result);if(!Array.isArray(l.styles)||!Array.isArray(l.mixes))throw new Error("Invalid backup: missing styles or mixes arrays.");const S=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!S.ok)throw new Error(`Save failed: HTTP ${S.status}`);try{(u=(n=window.app)==null?void 0:n.toast)==null||u.add({severity:"success",summary:"Style Mixer",detail:`Backup restored: ${l.styles.length} styles, ${l.mixes.length} mixes. Reload the Style Mixer panel to see changes.`,life:6e3})}catch{}}catch(l){alert(`Failed to restore backup: ${l.message}`)}},t.readAsText(a)}},e.click()}window.app.registerExtension({name:"ImmacStyleMixer",settings:[{id:"ImmacStyleMixer.BackupRestore",name:"Style Mixer — Backup & Restore",type:(e,a,s)=>{const i=document.createElement("div");i.style.cssText="display:flex;gap:8px;align-items:center";const t=document.createElement("button");t.textContent="⬇ Download backup (JSON)",t.title="Save all styles and mixes to a JSON file",t.style.cssText="cursor:pointer;padding:4px 10px;border-radius:4px",t.onclick=()=>m().catch(console.error);const r=document.createElement("button");r.textContent="⬇ Download ZIP (with images)",r.title="Save styles, mixes and all images to a ZIP file",r.style.cssText="cursor:pointer;padding:4px 10px;border-radius:4px",r.onclick=()=>h();const o=document.createElement("button");return o.textContent="⬆ Restore (JSON or ZIP)",o.title="Restore from a JSON or ZIP backup — auto-detected",o.style.cssText="cursor:pointer;padding:4px 10px;border-radius:4px",o.onclick=()=>f(),i.appendChild(t),i.appendChild(r),i.appendChild(o),i},defaultValue:null}],nodeCreated(e){var E;if(e.comfyClass!=="StyleMixImmacStyleMixer"&&e.comfyClass!=="StylePickImmacStyleMixer")return;const a=e.comfyClass==="StylePickImmacStyleMixer",s=a?"style":"mix",i=(E=e.widgets)==null?void 0:E.find(y=>y.name===s);if(!i)return;const t=document.createElement("img");t.style.cssText="width:100%;height:100%;display:none;object-fit:contain;border-radius:4px";const r=document.createElement("div");r.style.cssText="padding:4px;box-sizing:border-box",r.appendChild(t),r.style.setProperty("--comfy-widget-min-height","0"),r.style.setProperty("--comfy-widget-height","0"),e.addDOMWidget("immac_preview","div",r,{serialize:!1});function o(y,w){var _,d,R,$;const v=((_=e.size)==null?void 0:_[0])??300,b=w/y,c=Math.round((v-8)*b),g=Math.max(80,Math.min(c,600));r.style.setProperty("--comfy-widget-min-height",String(g)),r.style.setProperty("--comfy-widget-height",String(g));const x=(d=e.computeSize)==null?void 0:d.call(e);x&&e.setSize([Math.max(e.size[0],x[0]),Math.max(e.size[1],x[1])]),($=(R=window.app)==null?void 0:R.graph)==null||$.setDirtyCanvas(!0)}function n(){var y,w;r.style.setProperty("--comfy-widget-min-height","0"),r.style.setProperty("--comfy-widget-height","0"),t.style.display="none",(w=(y=window.app)==null?void 0:y.graph)==null||w.setDirtyCanvas(!0)}function u(y){t.onload=()=>{t.style.display="block",o(t.naturalWidth,t.naturalHeight)},t.onerror=()=>{n()},t.src=y}async function l(y){var w;try{const v=await fetch("/immac_style_mixer/api/data");if(!v.ok)return;const b=await v.json();if(a){const c=(b.styles??[]).find(x=>x.name===y);if(!(c!=null&&c.image_filename)){n();return}const g=c.image_updated_at?`&t=${c.image_updated_at}`:"";u(`/view?filename=${encodeURIComponent(c.image_filename)}&subfolder=immac_style_mixer%2Fstyles&type=input${g}`)}else{const c=(b.mixes??[]).find(x=>x.name===y);let g="";if(c!=null&&c.image_filename){const x=c.image_updated_at?`&t=${c.image_updated_at}`:"";g=`/view?filename=${encodeURIComponent(c.image_filename)}&subfolder=immac_style_mixer%2Fmixes&type=input${x}`}else if((w=c==null?void 0:c.styles)!=null&&w.length){const x=Object.fromEntries((b.styles??[]).map(d=>[d.id,d])),_=c.styles.filter(d=>d.enabled!==!1).map(d=>x[d.style_id]).find(d=>d==null?void 0:d.image_filename);if(_){const d=_.image_updated_at?`&t=${_.image_updated_at}`:"";g=`/view?filename=${encodeURIComponent(_.image_filename)}&subfolder=immac_style_mixer%2Fstyles&type=input${d}`}}if(!g){n();return}u(g)}}catch(v){console.error("[ImmacStyleMixer] Preview update failed",v)}}const S=i.callback;i.callback=function(...y){S==null||S.apply(this,y),l(String(i.value??""))},e._immacUpdatePreview=()=>l(String(i.value??"")),i.value&&l(String(i.value))},loadedGraphNode(e){var r;if(typeof e._immacUpdatePreview!="function")return;const a=e.comfyClass==="StylePickImmacStyleMixer",s=a?"style":"mix",i=(r=e.widgets)==null?void 0:r.find(o=>o.name===s),t=String((i==null?void 0:i.value)??"");t==="(no styles saved)"||t==="(no mixes saved)"?fetch("/immac_style_mixer/api/data").then(o=>o.json()).then(o=>{var u;const n=a?o.styles??[]:o.mixes??[];n.length>0&&i&&(i.value=n[0].name,Array.isArray((u=i.options)==null?void 0:u.values)&&(i.options.values=n.map(l=>l.name))),e._immacUpdatePreview()}).catch(()=>e._immacUpdatePreview()):e._immacUpdatePreview()}})}V().catch(console.error);export{k as j}; + */var A=T,D=Symbol.for("react.element"),F=Symbol.for("react.fragment"),Z=Object.prototype.hasOwnProperty,J=A.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,W={key:!0,ref:!0,__self:!0,__source:!0};function U(p,m,h){var f,e={},a=null,s=null;h!==void 0&&(a=""+h),m.key!==void 0&&(a=""+m.key),m.ref!==void 0&&(s=m.ref);for(f in m)Z.call(m,f)&&!W.hasOwnProperty(f)&&(e[f]=m[f]);if(p&&p.defaultProps)for(f in m=p.defaultProps,m)e[f]===void 0&&(e[f]=m[f]);return{$$typeof:D,type:p,key:a,ref:s,props:e,_owner:J.current}}P.Fragment=F;P.jsx=U;P.jsxs=U;M.exports=P;var k=M.exports,I={},O=z;I.createRoot=O.createRoot,I.hydrateRoot=O.hydrateRoot;const H=j.lazy(()=>N(()=>import("./StyleMixerPanel-CveihzM7.js"),__vite__mapDeps([0,1])));function q(){return new Promise(p=>{function m(){if(window.app){p();return}const h=setInterval(()=>{window.app&&(clearInterval(h),p())},50);setTimeout(()=>{clearInterval(h),console.error("[ImmacStyleMixer] Timeout waiting for ComfyUI app"),p()},5e3)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m):m()})}async function V(){if(await q(),!window.app){console.error("[ImmacStyleMixer] ComfyUI app not available");return}window.app.extensionManager.registerSidebarTab({id:"immac-style-mixer",icon:"pi pi-palette",title:"Style Mixer",tooltip:"Immac Style Mixer",type:"custom",render:e=>{const a=document.createElement("div");a.id="immac-style-mixer-root",a.style.position="absolute",a.style.inset="0",a.style.overflow="hidden",e.style.position="relative",e.style.height="100%",e.appendChild(a),I.createRoot(a).render(k.jsx(j.StrictMode,{children:k.jsx(T.Suspense,{fallback:k.jsx("div",{style:{padding:"1rem"},children:"Loading…"}),children:k.jsx(H,{})})}))}});const p="/immac_style_mixer/api/data";async function m(){const e=await fetch(p);if(!e.ok){alert(`Backup failed: HTTP ${e.status}`);return}const a=await e.json(),s=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(s),t=document.createElement("a");t.href=i,t.download=`style_mixer_backup_${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(i)}function h(){const e=document.createElement("a");e.href="/immac_style_mixer/api/backup.zip",e.download=`style_mixer_backup_${new Date().toISOString().slice(0,10)}.zip`,e.click()}function f(){const e=document.createElement("input");e.type="file",e.accept=".json,.zip,application/json,application/zip",e.onchange=()=>{var i;const a=(i=e.files)==null?void 0:i[0];if(!a)return;if(a.name.endsWith(".zip")||a.type==="application/zip")a.arrayBuffer().then(async t=>{var r,o;try{const n=await fetch("/immac_style_mixer/api/restore.zip",{method:"POST",headers:{"Content-Type":"application/zip"},body:t});if(!n.ok){const l=await n.text();throw new Error(`HTTP ${n.status}: ${l.slice(0,300)}`)}const u=await n.json();try{(o=(r=window.app)==null?void 0:r.toast)==null||o.add({severity:"success",summary:"Style Mixer",detail:`ZIP restored: ${u.styles} styles, ${u.mixes} mixes, ${u.images} images. Reload the Style Mixer panel to see changes.`,life:6e3})}catch{}}catch(n){alert(`Failed to restore ZIP backup: ${n.message}`)}}).catch(t=>alert(`Could not read file: ${t.message}`));else{const t=new FileReader;t.onload=async r=>{var o,n,u;try{const l=JSON.parse((o=r.target)==null?void 0:o.result);if(!Array.isArray(l.styles)||!Array.isArray(l.mixes))throw new Error("Invalid backup: missing styles or mixes arrays.");const S=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!S.ok)throw new Error(`Save failed: HTTP ${S.status}`);try{(u=(n=window.app)==null?void 0:n.toast)==null||u.add({severity:"success",summary:"Style Mixer",detail:`Backup restored: ${l.styles.length} styles, ${l.mixes.length} mixes. Reload the Style Mixer panel to see changes.`,life:6e3})}catch{}}catch(l){alert(`Failed to restore backup: ${l.message}`)}},t.readAsText(a)}},e.click()}window.app.registerExtension({name:"ImmacStyleMixer",settings:[{id:"ImmacStyleMixer.BackupRestore",name:"Style Mixer — Backup & Restore",type:(e,a,s)=>{const i=document.createElement("div");i.style.cssText="display:flex;gap:8px;align-items:center";const t=document.createElement("button");t.textContent="⬇ Download backup (JSON)",t.title="Save all styles and mixes to a JSON file",t.style.cssText="cursor:pointer;padding:4px 10px;border-radius:4px",t.onclick=()=>m().catch(console.error);const r=document.createElement("button");r.textContent="⬇ Download ZIP (with images)",r.title="Save styles, mixes and all images to a ZIP file",r.style.cssText="cursor:pointer;padding:4px 10px;border-radius:4px",r.onclick=()=>h();const o=document.createElement("button");return o.textContent="⬆ Restore (JSON or ZIP)",o.title="Restore from a JSON or ZIP backup — auto-detected",o.style.cssText="cursor:pointer;padding:4px 10px;border-radius:4px",o.onclick=()=>f(),i.appendChild(t),i.appendChild(r),i.appendChild(o),i},defaultValue:null}],nodeCreated(e){var E;if(e.comfyClass!=="StyleMixImmacStyleMixer"&&e.comfyClass!=="StylePickImmacStyleMixer")return;const a=e.comfyClass==="StylePickImmacStyleMixer",s=a?"style":"mix",i=(E=e.widgets)==null?void 0:E.find(y=>y.name===s);if(!i)return;const t=document.createElement("img");t.style.cssText="width:100%;height:100%;display:none;object-fit:contain;border-radius:4px";const r=document.createElement("div");r.style.cssText="padding:4px;box-sizing:border-box",r.appendChild(t),r.style.setProperty("--comfy-widget-min-height","0"),r.style.setProperty("--comfy-widget-height","0"),e.addDOMWidget("immac_preview","div",r,{serialize:!1});function o(y,w){var _,d,R,$;const v=((_=e.size)==null?void 0:_[0])??300,b=w/y,c=Math.round((v-8)*b),g=Math.max(80,Math.min(c,600));r.style.setProperty("--comfy-widget-min-height",String(g)),r.style.setProperty("--comfy-widget-height",String(g));const x=(d=e.computeSize)==null?void 0:d.call(e);x&&e.setSize([Math.max(e.size[0],x[0]),Math.max(e.size[1],x[1])]),($=(R=window.app)==null?void 0:R.graph)==null||$.setDirtyCanvas(!0)}function n(){var y,w;r.style.setProperty("--comfy-widget-min-height","0"),r.style.setProperty("--comfy-widget-height","0"),t.style.display="none",(w=(y=window.app)==null?void 0:y.graph)==null||w.setDirtyCanvas(!0)}function u(y){t.onload=()=>{t.style.display="block",o(t.naturalWidth,t.naturalHeight)},t.onerror=()=>{n()},t.src=y}async function l(y){var w;try{const v=await fetch("/immac_style_mixer/api/data");if(!v.ok)return;const b=await v.json();if(a){const c=(b.styles??[]).find(x=>x.name===y);if(!(c!=null&&c.image_filename)){n();return}const g=c.image_updated_at?`&t=${c.image_updated_at}`:"";u(`/view?filename=${encodeURIComponent(c.image_filename)}&subfolder=immac_style_mixer%2Fstyles&type=input${g}`)}else{const c=(b.mixes??[]).find(x=>x.name===y);let g="";if(c!=null&&c.image_filename){const x=c.image_updated_at?`&t=${c.image_updated_at}`:"";g=`/view?filename=${encodeURIComponent(c.image_filename)}&subfolder=immac_style_mixer%2Fmixes&type=input${x}`}else if((w=c==null?void 0:c.styles)!=null&&w.length){const x=Object.fromEntries((b.styles??[]).map(d=>[d.id,d])),_=c.styles.filter(d=>d.enabled!==!1).map(d=>x[d.style_id]).find(d=>d==null?void 0:d.image_filename);if(_){const d=_.image_updated_at?`&t=${_.image_updated_at}`:"";g=`/view?filename=${encodeURIComponent(_.image_filename)}&subfolder=immac_style_mixer%2Fstyles&type=input${d}`}}if(!g){n();return}u(g)}}catch(v){console.error("[ImmacStyleMixer] Preview update failed",v)}}const S=i.callback;i.callback=function(...y){S==null||S.apply(this,y),l(String(i.value??""))},e._immacUpdatePreview=()=>l(String(i.value??"")),i.value&&l(String(i.value))},loadedGraphNode(e){var r;if(typeof e._immacUpdatePreview!="function")return;const a=e.comfyClass==="StylePickImmacStyleMixer",s=a?"style":"mix",i=(r=e.widgets)==null?void 0:r.find(o=>o.name===s),t=String((i==null?void 0:i.value)??"");t==="(no styles saved)"||t==="(no mixes saved)"?fetch("/immac_style_mixer/api/data").then(o=>o.json()).then(o=>{var u;const n=a?o.styles??[]:o.mixes??[];n.length>0&&i&&(i.value=n[0].name,Array.isArray((u=i.options)==null?void 0:u.values)&&(i.options.values=n.map(l=>l.name))),e._immacUpdatePreview()}).catch(()=>e._immacUpdatePreview()):e._immacUpdatePreview()}})}V().catch(console.error);export{k as j}; diff --git a/ui/src/components/BarInput.tsx b/ui/src/components/BarInput.tsx index 98e41d1..3a35f8e 100644 --- a/ui/src/components/BarInput.tsx +++ b/ui/src/components/BarInput.tsx @@ -130,6 +130,7 @@ export default function BarInput({ return (
e.stopPropagation()} onDragStart={(e) => e.stopPropagation()} style={{ position: 'relative',