From 290906bb5c362b1db911a1fdf4eb4ce2a35bbb7e Mon Sep 17 00:00:00 2001 From: ai-business-hql Date: Fri, 28 Mar 2025 14:32:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dtext=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{App-BbQ1FUHS.js => App-CQdps0fq.js} | 4 +-- .../ParameterDebugInterface-Bqoj11tr.js | 29 ------------------- .../ParameterDebugInterface-nVAl8IgQ.js | 29 +++++++++++++++++++ dist/copilot_web/input.js | 4 +-- ...t-BvuRnqQY.js => workflowChat-BUxk20Uw.js} | 6 ++-- ui/src/apis/comfyApiCustom.ts | 2 +- .../debug/ParameterDebugInterface.tsx | 7 +++-- 7 files changed, 42 insertions(+), 39 deletions(-) rename dist/copilot_web/{App-BbQ1FUHS.js => App-CQdps0fq.js} (95%) delete mode 100644 dist/copilot_web/ParameterDebugInterface-Bqoj11tr.js create mode 100644 dist/copilot_web/ParameterDebugInterface-nVAl8IgQ.js rename dist/copilot_web/{workflowChat-BvuRnqQY.js => workflowChat-BUxk20Uw.js} (99%) diff --git a/dist/copilot_web/App-BbQ1FUHS.js b/dist/copilot_web/App-CQdps0fq.js similarity index 95% rename from dist/copilot_web/App-BbQ1FUHS.js rename to dist/copilot_web/App-CQdps0fq.js index 32f778c..fa589d7 100644 --- a/dist/copilot_web/App-BbQ1FUHS.js +++ b/dist/copilot_web/App-CQdps0fq.js @@ -1,6 +1,6 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BvuRnqQY.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-B3k4U96-.js","copilot_web/assets/input-CTb3NEJr.css"].map(path => { +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BUxk20Uw.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-B3k4U96-.js","copilot_web/assets/input-CTb3NEJr.css"].map(path => { const apiBase = window.comfyAPI?.api?.api?.api_base; const prefix = apiBase ? `${apiBase.substring(1)}/` : ''; return `${prefix}${path}`; }))))=>i.map(i=>d[i]); -import{_ as E}from"./input.js";import{j as s}from"./vendor-markdown-Dek94WS0.js";import{r as n,R as w}from"./vendor-react-V04_Axys.js";import{C as v}from"./message-components-B3k4U96-.js";const y=9999999,x={EXPLAIN_NODE:"copilot:explain-node"},D="/copilot_web/assets/logo-BTZhX0BN.png";function _(e={}){const[u,l]=n.useState({x:e.initialX??window.innerWidth-160,y:e.initialY??20}),[o,r]=n.useState(!1),[a,m]=n.useState({x:0,y:0}),[d,c]=n.useState(0),[g,b]=n.useState({x:0,y:0}),f=n.useCallback(t=>{if(o){const i=Math.min(Math.max(0,t.clientX-g.x),window.innerWidth-(e.boundaryPadding?.right??100)),p=Math.min(Math.max(0,t.clientY-g.y),window.innerHeight-(e.boundaryPadding?.bottom??40));l({x:i,y:p})}},[o,g,e.boundaryPadding]),h=n.useCallback(t=>{if(o){const i=Math.sqrt(Math.pow(t.clientX-a.x,2)+Math.pow(t.clientY-a.y,2)),p=Date.now()-d;i<5&&p<200&&e.onClick?.()}r(!1)},[o,a,d,e.onClick]);return n.useEffect(()=>(o&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h)}),[o,f,h]),{position:u,isDragging:o,handleMouseDown:t=>{t.preventDefault(),r(!0),c(Date.now()),m({x:t.clientX,y:t.clientY});const i=t.currentTarget.getBoundingClientRect();b({x:t.clientX-i.left,y:t.clientY-i.top})}}}const C=w.lazy(()=>E(()=>import("./workflowChat-BvuRnqQY.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.default})));function M(){const e=n.useRef(null),[u,l]=n.useState(!1),[o,r]=n.useState(!1),{position:a,isDragging:m,handleMouseDown:d}=_({boundaryPadding:{right:100,bottom:40},onClick:()=>l(!0)});return n.useEffect(()=>{const c=()=>{l(!0),r(!0)};return window.addEventListener(x.EXPLAIN_NODE,c),()=>window.removeEventListener(x.EXPLAIN_NODE,c)},[]),a?s.jsx(v,{children:s.jsx("div",{ref:e,children:s.jsxs("div",{className:"fixed",style:{zIndex:y,left:a.x,top:a.y,cursor:m?"grabbing":"grab"},children:[s.jsxs("button",{onMouseDown:d,className:"px-2 py-1 border border-gray-300 rounded-md bg-white text-black hover:bg-blue-300 hover:font-bold transition-colors select-none w-40 flex items-center space-x-1",style:{marginLeft:"-40px"},children:[s.jsx("img",{src:D,alt:"ComfyUI-Copilot Logo",className:"h-8 w-8"}),s.jsx("span",{className:"text-[14px] font-medium text-gray-800",children:"ComfyUI-Copilot"})]}),s.jsx(w.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(C,{onClose:()=>{l(!1),r(!1)},visible:u,triggerUsage:o,onUsageTriggered:()=>r(!1)})})]})})}):null}const I=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{I as A,D as l}; +import{_ as E}from"./input.js";import{j as s}from"./vendor-markdown-Dek94WS0.js";import{r as n,R as w}from"./vendor-react-V04_Axys.js";import{C as v}from"./message-components-B3k4U96-.js";const y=9999999,x={EXPLAIN_NODE:"copilot:explain-node"},D="/copilot_web/assets/logo-BTZhX0BN.png";function _(e={}){const[u,l]=n.useState({x:e.initialX??window.innerWidth-160,y:e.initialY??20}),[o,r]=n.useState(!1),[a,m]=n.useState({x:0,y:0}),[d,c]=n.useState(0),[g,b]=n.useState({x:0,y:0}),f=n.useCallback(t=>{if(o){const i=Math.min(Math.max(0,t.clientX-g.x),window.innerWidth-(e.boundaryPadding?.right??100)),p=Math.min(Math.max(0,t.clientY-g.y),window.innerHeight-(e.boundaryPadding?.bottom??40));l({x:i,y:p})}},[o,g,e.boundaryPadding]),h=n.useCallback(t=>{if(o){const i=Math.sqrt(Math.pow(t.clientX-a.x,2)+Math.pow(t.clientY-a.y,2)),p=Date.now()-d;i<5&&p<200&&e.onClick?.()}r(!1)},[o,a,d,e.onClick]);return n.useEffect(()=>(o&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h)}),[o,f,h]),{position:u,isDragging:o,handleMouseDown:t=>{t.preventDefault(),r(!0),c(Date.now()),m({x:t.clientX,y:t.clientY});const i=t.currentTarget.getBoundingClientRect();b({x:t.clientX-i.left,y:t.clientY-i.top})}}}const C=w.lazy(()=>E(()=>import("./workflowChat-BUxk20Uw.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.default})));function M(){const e=n.useRef(null),[u,l]=n.useState(!1),[o,r]=n.useState(!1),{position:a,isDragging:m,handleMouseDown:d}=_({boundaryPadding:{right:100,bottom:40},onClick:()=>l(!0)});return n.useEffect(()=>{const c=()=>{l(!0),r(!0)};return window.addEventListener(x.EXPLAIN_NODE,c),()=>window.removeEventListener(x.EXPLAIN_NODE,c)},[]),a?s.jsx(v,{children:s.jsx("div",{ref:e,children:s.jsxs("div",{className:"fixed",style:{zIndex:y,left:a.x,top:a.y,cursor:m?"grabbing":"grab"},children:[s.jsxs("button",{onMouseDown:d,className:"px-2 py-1 border border-gray-300 rounded-md bg-white text-black hover:bg-blue-300 hover:font-bold transition-colors select-none w-40 flex items-center space-x-1",style:{marginLeft:"-40px"},children:[s.jsx("img",{src:D,alt:"ComfyUI-Copilot Logo",className:"h-8 w-8"}),s.jsx("span",{className:"text-[14px] font-medium text-gray-800",children:"ComfyUI-Copilot"})]}),s.jsx(w.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(C,{onClose:()=>{l(!1),r(!1)},visible:u,triggerUsage:o,onUsageTriggered:()=>r(!1)})})]})})}):null}const I=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{I as A,D as l}; diff --git a/dist/copilot_web/ParameterDebugInterface-Bqoj11tr.js b/dist/copilot_web/ParameterDebugInterface-Bqoj11tr.js deleted file mode 100644 index 1fc548b..0000000 --- a/dist/copilot_web/ParameterDebugInterface-Bqoj11tr.js +++ /dev/null @@ -1,29 +0,0 @@ -import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as f}from"./vendor-react-V04_Axys.js";import{r as et,g as tt,m as st,i as rt}from"./workflowChat-BvuRnqQY.js";import{a as K,u as nt,W as at}from"./message-components-B3k4U96-.js";import"./input.js";import"./App-BbQ1FUHS.js";function ot(h,p){try{if(!h)return console.error("Invalid prompt_output: ",h),h;for(const i of p){if(!h[i.nodeId]){console.error(`Node with ID ${i.nodeId} not found`);continue}if(!h[i.nodeId].inputs){console.error(`Inputs not found for node with ID ${i.nodeId}`);continue}h[i.nodeId].inputs[i.paramName]=i.paramValue}return h}catch(i){return console.error("Error updating prompt:",i),h}}async function lt(h){const p=await K.graphToPrompt(),i=ot(p.output,h);console.log("queuePrompt updated_prompt:",i);const j={prompt:i,client_id:K.api.clientId,extra_data:{extra_pageinfo:{workflow:p.workflow}}};console.debug("queuePrompt request_body.prompt:",i);const y=await et(j);return console.debug("queuePrompt response:",y),y}function Se(h){const p=document.createElement("canvas"),i=p.getContext("2d");if(p.width=512,p.height=512,i){i.fillStyle="#f8d7da",i.fillRect(0,0,p.width,p.height),i.strokeStyle="#dc3545",i.lineWidth=4,i.strokeRect(10,10,p.width-20,p.height-20),i.fillStyle="#dc3545",i.beginPath(),i.arc(p.width/2,150,50,0,2*Math.PI),i.fill(),i.fillStyle="white",i.font="bold 80px Arial",i.textAlign="center",i.textBaseline="middle",i.fillText("!",p.width/2,150),i.fillStyle="#721c24",i.font="20px Arial",i.textAlign="center",i.textBaseline="middle";const j=p.width-60,y=30,k=h.split(" ");let C="",I=250;for(let L=0;Lj&&L>0?(i.fillText(C,p.width/2,I),C=k[L]+" ",I+=y):C=$}i.fillText(C,p.width/2,I)}return p.toDataURL("image/png")}async function it(h){try{if(!h||h==="")return console.log("No prompt ID provided"),{1:[Se("Fail to generate prompt ID")]};const p=await tt(h);if(!p||!p[h])return console.log("Not finished for prompt ID:",h),{};const i=p[h];if(i.status&&i.status.status_str==="error"){console.error("Error for prompt ID:",h);const y=i.status.messages;if(y&&y.length>0){const k=y[y.length-1];if(k&&k.length>0){const C=k[0];return{1:[Se(C)]}}}}const j={};if(i.outputs)for(const y in i.outputs){const k=i.outputs[y];if(k&&k.images){j[y]=[];for(const C of k.images)if(C&&C.filename&&C.type){const I=`${window.location.origin}/view?filename=${encodeURIComponent(C.filename)}&type=${encodeURIComponent(C.type)}${C.subfolder?"&subfolder="+encodeURIComponent(C.subfolder):""}`;j[y].push(I)}console.log("outputImages for nodeId:",y,j[y])}}return j}catch(p){throw console.error("Error getting output images from prompt:",p),p}}function ct(){const h=Object.values(K.graph._nodes_by_id),p=[],i=[];for(const j of h)j.type==="SaveImage"?p.push(j.id):j.type==="PreviewImage"&&i.push(j.id);if(console.log("saveNodeIds:",p),console.log("previewNodeIds:",i),p.length===0&&i.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");if(p.length===1)return p[0];if(p.length==0&&i.length===1)return i[0];{const j=[...p,...i],y=prompt(`Multiple SaveImage and PreviewImage nodes detected with IDs ${j.join(",")}. Please enter the ID to use as the result`);return console.log("prompt input nodeId:",y),Number(y)}}async function dt(h,p){const i=await it(h);return Object.keys(i).length===0?null:i[p.toString()]&&i[p.toString()].length>0?i[p.toString()][0]:null}const xt=` - @keyframes highlight-pulse { - 0% { - box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); - } - 70% { - box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); - } - 100% { - box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); - } - } - - .highlight-pulse { - animation: highlight-pulse 1.5s infinite; - border: 2px solid #3b82f6; - } - - @keyframes fade-in-out { - 0% { opacity: 0; transform: translateY(-20px); } - 10% { opacity: 1; transform: translateY(0); } - 90% { opacity: 1; transform: translateY(0); } - 100% { opacity: 0; transform: translateY(-20px); } - } - - .animate-fade-in-out { - animation: fade-in-out 3s forwards; - } -`,bt=({selectedNodes:h,visible:p,onClose:i})=>{const[j,y]=f.useState(0),[k,C]=f.useState({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),[I,L]=f.useState(!1),[$,_]=f.useState(!1),[Y,ue]=f.useState(0),[R,Le]=f.useState(12),[W,Me]=f.useState(null),[V,he]=f.useState(()=>Array(12).fill(null).map((t,r)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:r%3===0?5:r%3===1?10:15,sampler_name:"euler",cfg:1}}))),[g,J]=f.useState({}),[D,pe]=f.useState({}),[E,Te]=f.useState({}),[Ie,Q]=f.useState({}),[M,le]=f.useState(1),X=6,[Z,A]=f.useState(null),[$e,ge]=f.useState(!1),[De,fe]=f.useState(!1),[Ee,We]=f.useState(""),[B,z]=f.useState({}),[Ve,ee]=f.useState(!1),[ie,be]=f.useState(""),[ce,de]=f.useState([]),[je,xe]=f.useState(!1),[ye,Ae]=f.useState(""),[ve,Be]=f.useState(""),[we,te]=f.useState(null),[F,se]=f.useState({}),{dispatch:G}=nt(),Oe=async()=>{if(!ie.trim()){te("Please enter some text to generate variations");return}xe(!0),te(null),de([]),se({});try{const t=await at.generateSDPrompts(ie);de(t);const r={};t.forEach((a,o)=>{r[`text${o+1}`]=!1}),se(r)}catch(t){console.error("Error generating text:",t),te("Failed to generate text variations. Please try again.")}finally{xe(!1)}},_e=(t,r,a,o)=>{const s=`${t}_${r}`;z(l=>{const c=[...l[s]||[]];return c[a]=o,{...l,[s]:c}}),P(t,r,B[s]||[])},Re=(t,r)=>{const a=`${t}_${r}`;z(s=>{const l=[...s[a]||[]];return l.push(""),{...s,[a]:l}});const o=[...B[a]||[],""];P(t,r,o)},ze=(t,r,a)=>{const o=`${t}_${r}`;z(l=>{const c=[...l[o]||[]];return c.splice(a,1),{...l,[o]:c}});const s=[...B[o]||[]];s.splice(a,1),P(t,r,s)},Ne=t=>{se(r=>({...r,[t]:!r[t]}))},Fe=()=>{const t=`${ye}_${ve}`,r=Object.entries(F).filter(([o,s])=>s).map(([o])=>{const s=parseInt(o.replace("text",""))-1;return ce[s]});if(r.length===0)return;z(o=>{const s=[...o[t]||[]];return{...o,[t]:[...s,...r]}});const a=[...B[t]||[],...r];P(ye,ve,a),ee(!1)},Ge=(t,r)=>{ee(!0),Ae(t),Be(r),be(""),de([]),se({}),xe(!1),te(null)};f.useEffect(()=>{if(!h||h.length===0)return;const t={...g},r=h.map(o=>o.id.toString());Object.keys(t).forEach(o=>{r.includes(o)||delete t[o]}),h.forEach(o=>{const s=o.id.toString();t[s]||(t[s]={})}),JSON.stringify(t)!==JSON.stringify(g)&&J(t)},[h,g]),f.useEffect(()=>{G({type:"SET_SCREEN_STATE",payload:{currentScreen:j,isProcessing:I,isCompleted:$}})},[j,I,$,G]),f.useEffect(()=>{const t=document.createElement("style");return t.textContent=xt,document.head.appendChild(t),()=>{document.head.removeChild(t)}},[]),f.useEffect(()=>{const t=r=>{if(Object.values(D).some(a=>a)){const a=r.target,o=!!a.closest(".dropdown-menu"),s=!!a.closest("[data-dropdown]");!o&&!s&&pe({})}};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[D]);const He=Math.ceil(R/X),re=(t,r)=>{r&&(r.preventDefault(),r.stopPropagation()),le(Math.max(1,Math.min(t,He)))},ke=t=>{if(t&&(t.preventDefault(),t.stopPropagation()),j===1){const r=me();Le(r.length)}A(null),y(r=>Math.min(r+1,2))},ne=t=>{if(t&&(t.preventDefault(),t.stopPropagation()),A(null),$&&_(!1),j===1){const r=h.map(s=>s.id.toString()),a=Object.keys(g),o={...g};a.forEach(s=>{r.includes(s)||delete o[s]}),J(o)}y(r=>Math.max(r-1,0))},Ue=(t,r)=>{r&&(r.preventDefault(),r.stopPropagation()),C(a=>({...a,[t]:!a[t]}))},ae=(t,r,a,o=0)=>{t=isNaN(t)?0:t,r=isNaN(r)?100:r,a=isNaN(a)||a<=0?1:a,r{const t=[],r={};if(Object.keys(g).forEach(s=>{const l=parseInt(s),c=g[s]||{},n=Object.keys(c).filter(m=>c[m]&&c[m].length>0);if(n.length===0)return;const u=[[]];n.forEach(m=>{const x=c[m],d=[];u.forEach(v=>{x.forEach(S=>{const T=[...v,{nodeId:l,paramName:m,paramValue:String(S)}];d.push(T)})}),u.length=0,u.push(...d)}),r[s]=u}),Object.keys(r).length===0)return t;if(Object.keys(r).length===1){const s=Object.keys(r)[0];return r[s]}const a=Object.keys(r);let o=r[a[0]];for(let s=1;s{l.forEach(u=>{c.push([...n,...u])})}),o=c}return o},qe=(t,r,a)=>{a.preventDefault(),a.stopPropagation();const o=`${t}_${r}`;pe(s=>{if(s[o]&&typeof s[o]=="object"?s[o].isOpen:!!s[o])return{...s,[o]:!1};{let c=0,n=0;if(a.currentTarget){const x=a.currentTarget.getBoundingClientRect();c=x.left,n=x.bottom}else c=a.clientX,n=a.clientY+20;const u=window.innerWidth,m=250;return c+m>u&&(c=u-m-10),c<0&&(c=10),{...s,[o]:{isOpen:!0,x:c,y:n}}}})},P=(t,r,a)=>{J(o=>{const s={...o};return s[t]||(s[t]={}),s[t][r]=a,s})},oe=(t,r,a,o)=>{o&&(o.preventDefault(),o.stopPropagation()),J(s=>{const l={...s};l[t]||(l[t]={}),l[t][r]||(l[t][r]=[]);const c=l[t][r];return c.includes(a)?l[t][r]=c.filter(n=>n!==a):l[t][r]=[...c,a],l})},Ke=(t,r,a)=>{const o=`${t}_${r}`;Te(s=>({...s,[o]:a}))},Ye=(t,r,a)=>{if(!g[t]){P(t,r,a);return}const o=g[t][r]||[];a.length===o.length?P(t,r,[]):P(t,r,[...a])},Je=(t,r)=>{const a={};a.nodeParams={};const o=me();return r{const c=l.nodeId.toString(),n=l.paramName,u=l.paramValue;a.nodeParams[c]||(a.nodeParams[c]={}),a.nodeParams[c][n]=u,a[n]=u}),a},Ce=async t=>{t&&(t.preventDefault(),t.stopPropagation());const r=me(),a=r.length,o=ct();if(a>100){A(`Cannot generate more than 100 images at once (currently: ${a} images)`);return}if(A(null),L(!0),ue(0),console.log("Generated parameter combinations:",r),r.length===0){A("No valid parameter combinations found. Please check your parameter selections."),L(!1);return}const s=[];try{for(const m of r){const x=await lt(m);x.prompt_id?s.push(x.prompt_id):(console.error("Failed to get prompt_id from response:",x),s.push(""))}const l=Array(r.length).fill(null).map((m,x)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:Je(g,x)}));he(l);const c=Date.now(),n=5*60*1e3,u=async()=>{if(Date.now()-c>n){console.log("Timeout reached while waiting for images"),L(!1),_(!0),le(1);return}let m=0;for(let x=0;xn?(L(!1),_(!0),le(1)):setTimeout(u,3e3)};u()}catch(l){console.error("Error generating images:",l),L(!1)}},Qe=(t,r)=>{r&&(r.preventDefault(),r.stopPropagation()),Me(t)},Xe=(t,r)=>{r.preventDefault(),r.stopPropagation(),We(t),fe(!0)},Pe=t=>{t&&(t.preventDefault(),t.stopPropagation()),fe(!1)},Ze=t=>{if(t&&(t.preventDefault(),t.stopPropagation()),W!==null){console.log(`Applied image ${W+1} with parameters:`,V[W].params);const r=V[W].params;r.nodeParams&&(Object.entries(r.nodeParams).forEach(([a,o])=>{const s=K.graph._nodes_by_id[a];!s||!s.widgets||Object.entries(o).forEach(([l,c])=>{for(const n of s.widgets)if(n.name===l){n.value=c;break}})}),K.graph.setDirtyCanvas(!1,!0),ge(!0),setTimeout(()=>{ge(!1)},3e3))}},O=(t,r)=>{if(t&&(t.preventDefault(),t.stopPropagation()),j===1&&r!==void 0){const a=[...h];a.splice(r,1),a.length===0?i&&(G({type:"SET_SCREEN_STATE",payload:null}),i()):G({type:"SET_SELECTED_NODE",payload:a});return}i?(G({type:"SET_SCREEN_STATE",payload:null}),i()):(y(0),_(!1),L(!1),A(null))};if(!p||h.length===0)return e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"max-w-lg p-8 bg-white rounded-lg shadow-sm border border-blue-100 relative",children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("h3",{className:"text-base font-bold text-blue-800 mb-2",children:"GenLab"}),e.jsx("div",{className:"h-1 w-16 bg-blue-500 mx-auto rounded-full mb-4"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"bg-blue-100 p-2 rounded-full text-blue-600",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M5 3a2 2 0 00-2 2v2a2 2 0 002 2h2a2 2 0 002-2V5a2 2 0 00-2-2H5zM5 11a2 2 0 00-2 2v2a2 2 0 002 2h2a2 2 0 002-2v-2a2 2 0 00-2-2H5zM11 5a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V5zM11 13a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-800",children:"Batch Test Parameter Pairs"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Select a node to batch test parameter pairs"})]})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"bg-indigo-100 p-2 rounded-full text-indigo-600",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-800",children:"How To Use"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Click on any node in your workflow to start the parameter testing process"})]})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"No node is currently selected"})})]})]})});if($){const t=(M-1)*X,r=Math.min(t+X,V.length),a=V.slice(t,r),o=Math.ceil(V.length/X);return e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:s=>s.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["All ",V.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),$e&&e.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"py-1",children:e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),De&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50",onClick:Pe,children:e.jsxs("div",{className:"bg-white rounded-lg p-2 max-w-4xl max-h-[90vh] relative",onClick:s=>s.stopPropagation(),children:[e.jsx("button",{className:"absolute top-2 right-2 text-gray-700 hover:text-gray-900 rounded-full hover:bg-gray-200 p-1",onClick:Pe,children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("div",{className:"overflow-auto max-h-[calc(90vh-4rem)]",children:e.jsx("img",{src:Ee,alt:"Enlarged image",className:"max-w-full h-auto"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:a.map((s,l)=>{const c=t+l;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${W===c?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:n=>Qe(c,n),children:[e.jsx("button",{className:"absolute top-2 right-2 bg-white bg-opacity-75 rounded-full p-0.5 text-gray-600 hover:text-gray-900 shadow-sm z-10",onClick:n=>Xe(s.url,n),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}),e.jsx("div",{className:"aspect-square",children:e.jsx("img",{src:s.url,alt:`Generated image ${c+1}`,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-24 overflow-y-auto",children:Object.entries(s.params).filter(([n,u])=>n!=="nodeParams"&&typeof u!="object").map(([n,u])=>e.jsxs("div",{children:[n,": ",String(u)]},n))})]},c)})}),o>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:s=>re(1,s),disabled:M===1,className:`px-2 py-1 rounded ${M===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M15.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M8.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L4.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})]})}),e.jsx("button",{onClick:s=>re(M-1,s),disabled:M===1,className:`px-2 py-1 rounded ${M===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"px-2 py-1 text-xs text-gray-800",children:["Page ",M," of ",o]}),e.jsx("button",{onClick:s=>re(M+1,s),disabled:M===o,className:`px-2 py-1 rounded ${M===o?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})}),e.jsx("button",{onClick:s=>re(o,s),disabled:M===o,className:`px-2 py-1 rounded ${M===o?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M4.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L8.586 10 4.293 14.293a1 1 0 000 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M11.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L15.586 10l-4.293 4.293a1 1 0 000 1.414z",clipRule:"evenodd"})]})})]}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:s=>ne(s),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:s=>Ze(s),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:W===null,children:"Apply Selected"})]})]})})}return I?e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:e.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),e.jsxs("div",{className:"text-xs mb-3",children:["Completed ",Y," of ",R," runs"]}),e.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${Y/R*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",Y," images"]}),e.jsx("button",{onClick:t=>{t.preventDefault(),t.stopPropagation(),st({clear:!0}),rt(),L(!1),y(2)},className:"mt-4 px-3 py-1.5 text-xs bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors",children:"Cancel"})]})}),e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",R," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Z&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:Z})]})}),h.length>0?h.map((t,r)=>{const a=t.type||"Unknown Node",o=t.widgets||[],s=t.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[a," (ID: ",s,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:o.map((l,c)=>{const n=l.name;if(!k[n])return null;const u=g[s]?.[n]||[],m=Array.isArray(u)?`[${u.join(", ")}]`:JSON.stringify(u);return e.jsxs("div",{className:cx.preventDefault()})})]},c)})})]},r)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:t=>ne(t),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:t=>Ce(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Start Generation"})]})]})}):j===0?e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select Parameters for Testing"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Choose the parameters you want to include in your batch test"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.map((t,r)=>{const a=t.title||"Unknown Node",o=t.widgets||[];return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:a}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:o.map((s,l)=>{const c=s.name;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${k[c]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:n=>Ue(c,n),children:k[c]&&e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),e.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:c})]},`widget-${l}`)})})})]},`node-${r}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:t=>ke(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})})]})}):j===1?e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Parameter Options"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Ve&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-lg w-full max-w-2xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:()=>ee(!1),children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:"w-full border border-gray-300 rounded-md p-2 text-sm",rows:3,placeholder:"Enter some text here...",value:ie,onChange:t=>be(t.target.value)}),e.jsx("button",{className:"mt-2 px-4 py-2 bg-blue-100 text-blue-700 rounded-md text-sm flex items-center hover:bg-blue-200 transition-colors",onClick:Oe,disabled:je,children:je?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-blue-700",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):e.jsx(e.Fragment,{children:"Generate"})})]}),we&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-sm",children:we}),ce.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Generated variations (select items to add):"}),e.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:ce.map((t,r)=>e.jsxs("div",{className:"flex items-start border border-gray-200 rounded-md p-2",children:[e.jsx("div",{className:"mr-2 mt-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",id:`text${r+1}`,checked:!!F[`text${r+1}`],onChange:()=>Ne(`text${r+1}`),className:"sr-only"}),e.jsx("div",{className:`h-4 w-4 rounded border ${F[`text${r+1}`]?"bg-blue-600 border-blue-600":"bg-white border-gray-300"} flex items-center justify-center`,onClick:()=>Ne(`text${r+1}`),children:F[`text${r+1}`]&&e.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),e.jsx("label",{htmlFor:`text${r+1}`,className:"text-sm text-gray-700 cursor-pointer flex-1",children:t})]},r))})]})]}),e.jsxs("div",{className:"p-4 border-t flex justify-end",children:[e.jsx("button",{className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-md text-sm mr-2 hover:bg-gray-200 transition-colors",onClick:()=>ee(!1),children:"Cancel"}),e.jsx("button",{className:"px-4 py-2 bg-blue-500 text-white rounded-md text-sm hover:bg-blue-600 transition-colors",onClick:Fe,disabled:Object.values(F).every(t=>!t),children:"Add Selected"})]})]})}),h.length>0?h.map((t,r)=>{const a=t.widgets||{},o=Object.values(a),s=t.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b flex justify-between items-center",children:[e.jsxs("span",{children:[t.type," (ID: ",s,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:l=>O(l,r),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-4 space-y-4",children:o.map((l,c)=>{const n=l.name;if(!k[n])return null;const u=`${s}_${n}`;if(l.type==="customtext"||l.type.toLowerCase().includes("text")){B[u]||(z(x=>({...x,[u]:[""]})),(!g[s]||!g[s][n])&&P(s,n,[""]));const m=B[u]||[""];return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[n,":"]}),e.jsxs("button",{className:"px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs flex items-center hover:bg-blue-200 transition-colors",onClick:()=>Ge(s,n),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})}),"AI Writing"]})]}),e.jsx("div",{className:"space-y-2",children:m.map((x,d)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:"flex-1 border border-gray-300 rounded p-2 text-xs resize-y",rows:2,placeholder:"Enter text...",value:x,onChange:v=>_e(s,n,d,v.target.value)}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>ze(s,n,d),title:"Remove",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},d))}),e.jsxs("button",{className:"mt-2 px-2 py-1 border border-dashed border-gray-300 rounded text-xs text-gray-600 hover:bg-gray-50 flex items-center",onClick:()=>Re(s,n),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},c)}if(l.type==="number"){const m=l.options?.min||0,x=l.options?.max||100,d=(l.options?.step||10)/10,v=l.options?.precision||0,S=ae(m,x,d,v),T=Ie[u]||{min:m.toString(),max:x.toString(),step:d.toString()};return(!g[s]||!g[s][n])&&(P(s,n,S),Q(b=>({...b,[u]:T}))),e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[n,":"]}),e.jsx("div",{className:"w-4"})]}),e.jsxs("div",{className:"flex space-x-2 items-center",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:T.min,onClick:b=>{b.preventDefault(),b.stopPropagation()},onChange:b=>{b.preventDefault(),b.stopPropagation();const w=b.target.value;if(Q(N=>({...N,[u]:{...N[u],min:w}})),w===""||!isNaN(parseFloat(w))){const N=w===""?0:parseFloat(w),H=parseFloat(T.max||x.toString()),U=parseFloat(T.step||d.toString()),q=ae(N,H,U,v);P(s,n,q)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:T.max,onClick:b=>{b.preventDefault(),b.stopPropagation()},onChange:b=>{b.preventDefault(),b.stopPropagation();const w=b.target.value;if(Q(N=>({...N,[u]:{...N[u],max:w}})),w===""||!isNaN(parseFloat(w))){const N=parseFloat(T.min||m.toString()),H=w===""?N:parseFloat(w),U=parseFloat(T.step||d.toString()),q=ae(N,H,U,v);P(s,n,q)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:T.step,onClick:b=>{b.preventDefault(),b.stopPropagation()},onChange:b=>{b.preventDefault(),b.stopPropagation();const w=b.target.value;if(Q(N=>({...N,[u]:{...N[u],step:w}})),w===""||!isNaN(parseFloat(w))&&parseFloat(w)>0){const N=parseFloat(T.min||m.toString()),H=parseFloat(T.max||x.toString()),U=w===""?1:parseFloat(w),q=ae(N,H,U,v);P(s,n,q)}}})]}),e.jsxs("div",{className:"mt-1",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(g[s]?.[n]||S).map((b,w)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:N=>{N.stopPropagation(),oe(s,n,b,N)},children:[e.jsx("span",{children:b}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},w))})]}),e.jsx("div",{className:"mt-1",children:e.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max (max 10 values)"})})]},c)}else if(l.type==="combo"){const m=l.options?.values||[],x=`${s}_${n}`;return(!g[s]||!g[s][n])&&P(s,n,m.slice(0,3)),e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("label",{className:"text-xs font-medium text-gray-700",children:n}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:"appearance-none border border-gray-300 rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700",onClick:d=>{d.preventDefault(),d.stopPropagation(),qe(s,n,d)},"data-dropdown":x,children:[e.jsx("span",{children:(g[s]?.[n]||[]).length>0?`${n}: ${(g[s]?.[n]||[]).length} selected`:`Select ${n}`}),e.jsx("div",{className:"ml-2",children:e.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),D[x]&&e.jsxs("div",{className:"absolute z-[9999] mt-1 w-64 bg-white border border-gray-300 rounded-md shadow-lg dropdown-menu",style:{position:"fixed",top:typeof D[x]=="object"?`${D[x].y}px`:"0px",left:typeof D[x]=="object"?`${D[x].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[e.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:e.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:E[x]||"",onChange:d=>{d.preventDefault(),d.stopPropagation(),Ke(s,n,d.target.value)},onClick:d=>{d.preventDefault(),d.stopPropagation()},autoFocus:!0})}),e.jsxs("div",{className:"px-3 py-1.5 bg-gray-50 border-b cursor-pointer text-xs flex items-center text-gray-700 hover:bg-gray-100",onClick:d=>{d.preventDefault(),d.stopPropagation();const v=m.filter(S=>!E[x]||S.toLowerCase().includes((E[x]||"").toLowerCase()));Ye(s,n,v)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${m.length>0&&(g[s]?.[n]||[]).length===m.length?"bg-blue-500 border-blue-500":(g[s]?.[n]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(g[s]?.[n]||[]).length>0&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"font-medium",children:m.length>0&&(g[s]?.[n]||[]).length===m.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[m.filter(d=>!E[x]||d.toLowerCase().includes((E[x]||"").toLowerCase())).map((d,v)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:S=>{S.preventDefault(),S.stopPropagation(),oe(s,n,d,S)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(g[s]?.[n]||[]).includes(d)?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(g[s]?.[n]||[]).includes(d)&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:d})]},v)),m.filter(d=>!E[x]||d.toLowerCase().includes((E[x]||"").toLowerCase())).length===0&&e.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(g[s]?.[n]||[]).map((d,v)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:d}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:S=>{S.preventDefault(),S.stopPropagation(),oe(s,n,d,S)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},v)),e.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:d=>{d.preventDefault(),d.stopPropagation();const v=`${n}${(g[s]?.[n]||[]).length+1}`;P(s,n,[...g[s]?.[n]||[],v])},children:[e.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("span",{children:"Add"})]})]})]})]},c)}else return(!g[s]||!g[s][n])&&P(s,n,[`${n}1`,`${n}2`,`${n}3`]),e.jsxs("div",{className:"border-b pb-3",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx("label",{className:"text-xs font-medium text-gray-700",children:n})}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(g[s]?.[n]||[]).map((m,x)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:m}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:d=>{d.preventDefault(),d.stopPropagation(),oe(s,n,m,d)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},x)),e.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:m=>{m.preventDefault(),m.stopPropagation();const x=`${n}${(g[s]?.[n]||[]).length+1}`;P(s,n,[...g[s]?.[n]||[],x])},children:[e.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("span",{children:"Add"})]})]})]})]},c)})})]},r)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:t=>ne(t),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:t=>ke(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})}):e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",R," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Z&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:Z})]})}),h.length>0?h.map((t,r)=>{const a=t.type||"Unknown Node",o=t.widgets||[],s=t.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[a," (ID: ",s,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:o.map((l,c)=>{const n=l.name;if(!k[n])return null;const u=g[s]?.[n]||[],m=Array.isArray(u)?`[${u.join(", ")}]`:JSON.stringify(u);return e.jsxs("div",{className:cx.preventDefault()})})]},c)})})]},r)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500 text-xs",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:t=>ne(t),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:t=>Ce(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Start Generation"})]})]})})};export{bt as ParameterDebugInterface}; diff --git a/dist/copilot_web/ParameterDebugInterface-nVAl8IgQ.js b/dist/copilot_web/ParameterDebugInterface-nVAl8IgQ.js new file mode 100644 index 0000000..30bed03 --- /dev/null +++ b/dist/copilot_web/ParameterDebugInterface-nVAl8IgQ.js @@ -0,0 +1,29 @@ +import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as f}from"./vendor-react-V04_Axys.js";import{r as et,g as tt,m as st,i as rt}from"./workflowChat-BUxk20Uw.js";import{a as K,u as nt,W as at}from"./message-components-B3k4U96-.js";import"./input.js";import"./App-CQdps0fq.js";function ot(h,p){try{if(!h)return console.error("Invalid prompt_output: ",h),h;for(const i of p){if(!h[i.nodeId]){console.error(`Node with ID ${i.nodeId} not found`);continue}if(!h[i.nodeId].inputs){console.error(`Inputs not found for node with ID ${i.nodeId}`);continue}h[i.nodeId].inputs[i.paramName]=i.paramValue}return h}catch(i){return console.error("Error updating prompt:",i),h}}async function lt(h){const p=await K.graphToPrompt(),i=ot(p.output,h);console.log("queuePrompt updated_prompt:",i);const j={prompt:i,client_id:K.api.clientId,extra_data:{extra_pageinfo:{workflow:p.workflow}}};console.debug("queuePrompt request_body.prompt:",i);const y=await et(j);return console.debug("queuePrompt response:",y),y}function Se(h){const p=document.createElement("canvas"),i=p.getContext("2d");if(p.width=512,p.height=512,i){i.fillStyle="#f8d7da",i.fillRect(0,0,p.width,p.height),i.strokeStyle="#dc3545",i.lineWidth=4,i.strokeRect(10,10,p.width-20,p.height-20),i.fillStyle="#dc3545",i.beginPath(),i.arc(p.width/2,150,50,0,2*Math.PI),i.fill(),i.fillStyle="white",i.font="bold 80px Arial",i.textAlign="center",i.textBaseline="middle",i.fillText("!",p.width/2,150),i.fillStyle="#721c24",i.font="20px Arial",i.textAlign="center",i.textBaseline="middle";const j=p.width-60,y=30,k=h.split(" ");let C="",I=250;for(let L=0;Lj&&L>0?(i.fillText(C,p.width/2,I),C=k[L]+" ",I+=y):C=$}i.fillText(C,p.width/2,I)}return p.toDataURL("image/png")}async function it(h){try{if(!h||h==="")return console.log("No prompt ID provided"),{1:[Se("Fail to generate prompt ID")]};const p=await tt(h);if(!p||!p[h])return console.log("Not finished for prompt ID:",h),{};const i=p[h];if(i.status&&i.status.status_str==="error"){console.error("Error for prompt ID:",h);const y=i.status.messages;if(y&&y.length>0){const k=y[y.length-1];if(k&&k.length>0){const C=k[0];return{1:[Se(C)]}}}}const j={};if(i.outputs)for(const y in i.outputs){const k=i.outputs[y];if(k&&k.images){j[y]=[];for(const C of k.images)if(C&&C.filename&&C.type){const I=`${window.location.origin}/view?filename=${encodeURIComponent(C.filename)}&type=${encodeURIComponent(C.type)}${C.subfolder?"&subfolder="+encodeURIComponent(C.subfolder):""}`;j[y].push(I)}console.log("outputImages for nodeId:",y,j[y])}}return j}catch(p){throw console.error("Error getting output images from prompt:",p),p}}function ct(){const h=Object.values(K.graph._nodes_by_id),p=[],i=[];for(const j of h)j.type==="SaveImage"?p.push(j.id):j.type==="PreviewImage"&&i.push(j.id);if(console.log("saveNodeIds:",p),console.log("previewNodeIds:",i),p.length===0&&i.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");if(p.length===1)return p[0];if(p.length==0&&i.length===1)return i[0];{const j=[...p,...i],y=prompt(`Multiple SaveImage and PreviewImage nodes detected with IDs ${j.join(",")}. Please enter the ID to use as the result`);return console.log("prompt input nodeId:",y),Number(y)}}async function dt(h,p){const i=await it(h);return Object.keys(i).length===0?null:i[p.toString()]&&i[p.toString()].length>0?i[p.toString()][0]:null}const xt=` + @keyframes highlight-pulse { + 0% { + box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); + } + 70% { + box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); + } + 100% { + box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); + } + } + + .highlight-pulse { + animation: highlight-pulse 1.5s infinite; + border: 2px solid #3b82f6; + } + + @keyframes fade-in-out { + 0% { opacity: 0; transform: translateY(-20px); } + 10% { opacity: 1; transform: translateY(0); } + 90% { opacity: 1; transform: translateY(0); } + 100% { opacity: 0; transform: translateY(-20px); } + } + + .animate-fade-in-out { + animation: fade-in-out 3s forwards; + } +`,bt=({selectedNodes:h,visible:p,onClose:i})=>{const[j,y]=f.useState(0),[k,C]=f.useState({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),[I,L]=f.useState(!1),[$,_]=f.useState(!1),[Y,ue]=f.useState(0),[R,Le]=f.useState(12),[W,Me]=f.useState(null),[V,he]=f.useState(()=>Array(12).fill(null).map((t,r)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:r%3===0?5:r%3===1?10:15,sampler_name:"euler",cfg:1}}))),[g,J]=f.useState({}),[D,pe]=f.useState({}),[E,Te]=f.useState({}),[Ie,Q]=f.useState({}),[M,le]=f.useState(1),X=6,[Z,A]=f.useState(null),[$e,ge]=f.useState(!1),[De,fe]=f.useState(!1),[Ee,We]=f.useState(""),[B,z]=f.useState({}),[Ve,ee]=f.useState(!1),[ie,be]=f.useState(""),[ce,de]=f.useState([]),[je,xe]=f.useState(!1),[ye,Ae]=f.useState(""),[ve,Be]=f.useState(""),[we,te]=f.useState(null),[F,se]=f.useState({}),{dispatch:G}=nt(),Oe=async()=>{if(!ie.trim()){te("Please enter some text to generate variations");return}xe(!0),te(null),de([]),se({});try{const t=await at.generateSDPrompts(ie);de(t);const r={};t.forEach((a,o)=>{r[`text${o+1}`]=!1}),se(r)}catch(t){console.error("Error generating text:",t),te("Failed to generate text variations. Please try again.")}finally{xe(!1)}},_e=(t,r,a,o)=>{const s=`${t}_${r}`;z(c=>{const n=[...c[s]||[]];return n[a]=o,{...c,[s]:n}});const l=[...B[s]||[]];l[a]=o,P(t,r,l)},Re=(t,r)=>{const a=`${t}_${r}`;z(s=>{const l=[...s[a]||[]];return l.push(""),{...s,[a]:l}});const o=[...B[a]||[],""];P(t,r,o)},ze=(t,r,a)=>{const o=`${t}_${r}`;z(l=>{const c=[...l[o]||[]];return c.splice(a,1),{...l,[o]:c}});const s=[...B[o]||[]];s.splice(a,1),P(t,r,s)},Ne=t=>{se(r=>({...r,[t]:!r[t]}))},Fe=()=>{const t=`${ye}_${ve}`,r=Object.entries(F).filter(([o,s])=>s).map(([o])=>{const s=parseInt(o.replace("text",""))-1;return ce[s]});if(r.length===0)return;z(o=>{const s=[...o[t]||[]];return{...o,[t]:[...s,...r]}});const a=[...B[t]||[],...r];P(ye,ve,a),ee(!1)},Ge=(t,r)=>{ee(!0),Ae(t),Be(r),be(""),de([]),se({}),xe(!1),te(null)};f.useEffect(()=>{if(!h||h.length===0)return;const t={...g},r=h.map(o=>o.id.toString());Object.keys(t).forEach(o=>{r.includes(o)||delete t[o]}),h.forEach(o=>{const s=o.id.toString();t[s]||(t[s]={})}),JSON.stringify(t)!==JSON.stringify(g)&&J(t)},[h,g]),f.useEffect(()=>{G({type:"SET_SCREEN_STATE",payload:{currentScreen:j,isProcessing:I,isCompleted:$}})},[j,I,$,G]),f.useEffect(()=>{const t=document.createElement("style");return t.textContent=xt,document.head.appendChild(t),()=>{document.head.removeChild(t)}},[]),f.useEffect(()=>{const t=r=>{if(Object.values(D).some(a=>a)){const a=r.target,o=!!a.closest(".dropdown-menu"),s=!!a.closest("[data-dropdown]");!o&&!s&&pe({})}};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[D]);const He=Math.ceil(R/X),re=(t,r)=>{r&&(r.preventDefault(),r.stopPropagation()),le(Math.max(1,Math.min(t,He)))},ke=t=>{if(t&&(t.preventDefault(),t.stopPropagation()),j===1){const r=me();Le(r.length)}A(null),y(r=>Math.min(r+1,2))},ne=t=>{if(t&&(t.preventDefault(),t.stopPropagation()),A(null),$&&_(!1),j===1){const r=h.map(s=>s.id.toString()),a=Object.keys(g),o={...g};a.forEach(s=>{r.includes(s)||delete o[s]}),J(o)}y(r=>Math.max(r-1,0))},Ue=(t,r)=>{r&&(r.preventDefault(),r.stopPropagation()),C(a=>({...a,[t]:!a[t]}))},ae=(t,r,a,o=0)=>{t=isNaN(t)?0:t,r=isNaN(r)?100:r,a=isNaN(a)||a<=0?1:a,r{const t=[],r={};if(Object.keys(g).forEach(s=>{const l=parseInt(s),c=g[s]||{},n=Object.keys(c).filter(m=>c[m]&&c[m].length>0);if(n.length===0)return;const u=[[]];n.forEach(m=>{const x=c[m],d=[];u.forEach(v=>{x.forEach(S=>{const T=[...v,{nodeId:l,paramName:m,paramValue:String(S)}];d.push(T)})}),u.length=0,u.push(...d)}),r[s]=u}),Object.keys(r).length===0)return t;if(Object.keys(r).length===1){const s=Object.keys(r)[0];return r[s]}const a=Object.keys(r);let o=r[a[0]];for(let s=1;s{l.forEach(u=>{c.push([...n,...u])})}),o=c}return o},qe=(t,r,a)=>{a.preventDefault(),a.stopPropagation();const o=`${t}_${r}`;pe(s=>{if(s[o]&&typeof s[o]=="object"?s[o].isOpen:!!s[o])return{...s,[o]:!1};{let c=0,n=0;if(a.currentTarget){const x=a.currentTarget.getBoundingClientRect();c=x.left,n=x.bottom}else c=a.clientX,n=a.clientY+20;const u=window.innerWidth,m=250;return c+m>u&&(c=u-m-10),c<0&&(c=10),{...s,[o]:{isOpen:!0,x:c,y:n}}}})},P=(t,r,a)=>{J(o=>{const s={...o};return s[t]||(s[t]={}),s[t][r]=a,s})},oe=(t,r,a,o)=>{o&&(o.preventDefault(),o.stopPropagation()),J(s=>{const l={...s};l[t]||(l[t]={}),l[t][r]||(l[t][r]=[]);const c=l[t][r];return c.includes(a)?l[t][r]=c.filter(n=>n!==a):l[t][r]=[...c,a],l})},Ke=(t,r,a)=>{const o=`${t}_${r}`;Te(s=>({...s,[o]:a}))},Ye=(t,r,a)=>{if(!g[t]){P(t,r,a);return}const o=g[t][r]||[];a.length===o.length?P(t,r,[]):P(t,r,[...a])},Je=(t,r)=>{const a={};a.nodeParams={};const o=me();return r{const c=l.nodeId.toString(),n=l.paramName,u=l.paramValue;a.nodeParams[c]||(a.nodeParams[c]={}),a.nodeParams[c][n]=u,a[n]=u}),a},Ce=async t=>{t&&(t.preventDefault(),t.stopPropagation());const r=me(),a=r.length,o=ct();if(a>100){A(`Cannot generate more than 100 images at once (currently: ${a} images)`);return}if(A(null),L(!0),ue(0),console.log("Generated parameter combinations:",r),r.length===0){A("No valid parameter combinations found. Please check your parameter selections."),L(!1);return}const s=[];try{for(const m of r){const x=await lt(m);x.prompt_id?s.push(x.prompt_id):(console.error("Failed to get prompt_id from response:",x),s.push(""))}const l=Array(r.length).fill(null).map((m,x)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:Je(g,x)}));he(l);const c=Date.now(),n=5*60*1e3,u=async()=>{if(Date.now()-c>n){console.log("Timeout reached while waiting for images"),L(!1),_(!0),le(1);return}let m=0;for(let x=0;xn?(L(!1),_(!0),le(1)):setTimeout(u,3e3)};u()}catch(l){console.error("Error generating images:",l),L(!1)}},Qe=(t,r)=>{r&&(r.preventDefault(),r.stopPropagation()),Me(t)},Xe=(t,r)=>{r.preventDefault(),r.stopPropagation(),We(t),fe(!0)},Pe=t=>{t&&(t.preventDefault(),t.stopPropagation()),fe(!1)},Ze=t=>{if(t&&(t.preventDefault(),t.stopPropagation()),W!==null){console.log(`Applied image ${W+1} with parameters:`,V[W].params);const r=V[W].params;r.nodeParams&&(Object.entries(r.nodeParams).forEach(([a,o])=>{const s=K.graph._nodes_by_id[a];!s||!s.widgets||Object.entries(o).forEach(([l,c])=>{for(const n of s.widgets)if(n.name===l){n.value=c;break}})}),K.graph.setDirtyCanvas(!1,!0),ge(!0),setTimeout(()=>{ge(!1)},3e3))}},O=(t,r)=>{if(t&&(t.preventDefault(),t.stopPropagation()),j===1&&r!==void 0){const a=[...h];a.splice(r,1),a.length===0?i&&(G({type:"SET_SCREEN_STATE",payload:null}),i()):G({type:"SET_SELECTED_NODE",payload:a});return}i?(G({type:"SET_SCREEN_STATE",payload:null}),i()):(y(0),_(!1),L(!1),A(null))};if(!p||h.length===0)return e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"max-w-lg p-8 bg-white rounded-lg shadow-sm border border-blue-100 relative",children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("h3",{className:"text-base font-bold text-blue-800 mb-2",children:"GenLab"}),e.jsx("div",{className:"h-1 w-16 bg-blue-500 mx-auto rounded-full mb-4"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"bg-blue-100 p-2 rounded-full text-blue-600",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M5 3a2 2 0 00-2 2v2a2 2 0 002 2h2a2 2 0 002-2V5a2 2 0 00-2-2H5zM5 11a2 2 0 00-2 2v2a2 2 0 002 2h2a2 2 0 002-2v-2a2 2 0 00-2-2H5zM11 5a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V5zM11 13a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-800",children:"Batch Test Parameter Pairs"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Select a node to batch test parameter pairs"})]})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"bg-indigo-100 p-2 rounded-full text-indigo-600",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-800",children:"How To Use"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Click on any node in your workflow to start the parameter testing process"})]})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"No node is currently selected"})})]})]})});if($){const t=(M-1)*X,r=Math.min(t+X,V.length),a=V.slice(t,r),o=Math.ceil(V.length/X);return e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:s=>s.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["All ",V.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),$e&&e.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"py-1",children:e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),De&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50",onClick:Pe,children:e.jsxs("div",{className:"bg-white rounded-lg p-2 max-w-4xl max-h-[90vh] relative",onClick:s=>s.stopPropagation(),children:[e.jsx("button",{className:"absolute top-2 right-2 text-gray-700 hover:text-gray-900 rounded-full hover:bg-gray-200 p-1",onClick:Pe,children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("div",{className:"overflow-auto max-h-[calc(90vh-4rem)]",children:e.jsx("img",{src:Ee,alt:"Enlarged image",className:"max-w-full h-auto"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:a.map((s,l)=>{const c=t+l;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${W===c?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:n=>Qe(c,n),children:[e.jsx("button",{className:"absolute top-2 right-2 bg-white bg-opacity-75 rounded-full p-0.5 text-gray-600 hover:text-gray-900 shadow-sm z-10",onClick:n=>Xe(s.url,n),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}),e.jsx("div",{className:"aspect-square",children:e.jsx("img",{src:s.url,alt:`Generated image ${c+1}`,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-24 overflow-y-auto",children:Object.entries(s.params).filter(([n,u])=>n!=="nodeParams"&&typeof u!="object").map(([n,u])=>e.jsxs("div",{children:[n,": ",String(u)]},n))})]},c)})}),o>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:s=>re(1,s),disabled:M===1,className:`px-2 py-1 rounded ${M===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M15.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M8.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L4.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})]})}),e.jsx("button",{onClick:s=>re(M-1,s),disabled:M===1,className:`px-2 py-1 rounded ${M===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"px-2 py-1 text-xs text-gray-800",children:["Page ",M," of ",o]}),e.jsx("button",{onClick:s=>re(M+1,s),disabled:M===o,className:`px-2 py-1 rounded ${M===o?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})}),e.jsx("button",{onClick:s=>re(o,s),disabled:M===o,className:`px-2 py-1 rounded ${M===o?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M4.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L8.586 10 4.293 14.293a1 1 0 000 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M11.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L15.586 10l-4.293 4.293a1 1 0 000 1.414z",clipRule:"evenodd"})]})})]}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:s=>ne(s),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:s=>Ze(s),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:W===null,children:"Apply Selected"})]})]})})}return I?e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:e.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),e.jsxs("div",{className:"text-xs mb-3",children:["Completed ",Y," of ",R," runs"]}),e.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${Y/R*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",Y," images"]}),e.jsx("button",{onClick:t=>{t.preventDefault(),t.stopPropagation(),st({clear:!0}),rt(),L(!1),y(2)},className:"mt-4 px-3 py-1.5 text-xs bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors",children:"Cancel"})]})}),e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",R," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Z&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:Z})]})}),h.length>0?h.map((t,r)=>{const a=t.type||"Unknown Node",o=t.widgets||[],s=t.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[a," (ID: ",s,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:o.map((l,c)=>{const n=l.name;if(!k[n])return null;const u=g[s]?.[n]||[],m=Array.isArray(u)?`[${u.join(", ")}]`:JSON.stringify(u);return e.jsxs("div",{className:cx.preventDefault()})})]},c)})})]},r)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:t=>ne(t),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:t=>Ce(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Start Generation"})]})]})}):j===0?e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select Parameters for Testing"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Choose the parameters you want to include in your batch test"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.map((t,r)=>{const a=t.title||"Unknown Node",o=t.widgets||[];return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:a}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:o.map((s,l)=>{const c=s.name;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${k[c]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:n=>Ue(c,n),children:k[c]&&e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),e.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:c})]},`widget-${l}`)})})})]},`node-${r}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:t=>ke(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})})]})}):j===1?e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Parameter Options"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Ve&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-lg w-full max-w-2xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:()=>ee(!1),children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:"w-full border border-gray-300 rounded-md p-2 text-sm",rows:3,placeholder:"Enter some text here...",value:ie,onChange:t=>be(t.target.value)}),e.jsx("button",{className:"mt-2 px-4 py-2 bg-blue-100 text-blue-700 rounded-md text-sm flex items-center hover:bg-blue-200 transition-colors",onClick:Oe,disabled:je,children:je?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-blue-700",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):e.jsx(e.Fragment,{children:"Generate"})})]}),we&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-sm",children:we}),ce.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Generated variations (select items to add):"}),e.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:ce.map((t,r)=>e.jsxs("div",{className:"flex items-start border border-gray-200 rounded-md p-2",children:[e.jsx("div",{className:"mr-2 mt-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",id:`text${r+1}`,checked:!!F[`text${r+1}`],onChange:()=>Ne(`text${r+1}`),className:"sr-only"}),e.jsx("div",{className:`h-4 w-4 rounded border ${F[`text${r+1}`]?"bg-blue-600 border-blue-600":"bg-white border-gray-300"} flex items-center justify-center`,onClick:()=>Ne(`text${r+1}`),children:F[`text${r+1}`]&&e.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),e.jsx("label",{htmlFor:`text${r+1}`,className:"text-sm text-gray-700 cursor-pointer flex-1",children:t})]},r))})]})]}),e.jsxs("div",{className:"p-4 border-t flex justify-end",children:[e.jsx("button",{className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-md text-sm mr-2 hover:bg-gray-200 transition-colors",onClick:()=>ee(!1),children:"Cancel"}),e.jsx("button",{className:"px-4 py-2 bg-blue-500 text-white rounded-md text-sm hover:bg-blue-600 transition-colors",onClick:Fe,disabled:Object.values(F).every(t=>!t),children:"Add Selected"})]})]})}),h.length>0?h.map((t,r)=>{const a=t.widgets||{},o=Object.values(a),s=t.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b flex justify-between items-center",children:[e.jsxs("span",{children:[t.type," (ID: ",s,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:l=>O(l,r),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-4 space-y-4",children:o.map((l,c)=>{const n=l.name;if(!k[n])return null;const u=`${s}_${n}`;if(l.type==="customtext"||l.type.toLowerCase().includes("text")){B[u]||(z(x=>({...x,[u]:[""]})),(!g[s]||!g[s][n])&&P(s,n,[""]));const m=B[u]||[""];return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[n,":"]}),e.jsxs("button",{className:"px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs flex items-center hover:bg-blue-200 transition-colors",onClick:()=>Ge(s,n),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})}),"AI Writing"]})]}),e.jsx("div",{className:"space-y-2",children:m.map((x,d)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:"flex-1 border border-gray-300 rounded p-2 text-xs resize-y",rows:2,placeholder:"Enter text...",value:x,onChange:v=>_e(s,n,d,v.target.value)}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>ze(s,n,d),title:"Remove",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},d))}),e.jsxs("button",{className:"mt-2 px-2 py-1 border border-dashed border-gray-300 rounded text-xs text-gray-600 hover:bg-gray-50 flex items-center",onClick:()=>Re(s,n),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},c)}if(l.type==="number"){const m=l.options?.min||0,x=l.options?.max||100,d=(l.options?.step||10)/10,v=l.options?.precision||0,S=ae(m,x,d,v),T=Ie[u]||{min:m.toString(),max:x.toString(),step:d.toString()};return(!g[s]||!g[s][n])&&(P(s,n,S),Q(b=>({...b,[u]:T}))),e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[n,":"]}),e.jsx("div",{className:"w-4"})]}),e.jsxs("div",{className:"flex space-x-2 items-center",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:T.min,onClick:b=>{b.preventDefault(),b.stopPropagation()},onChange:b=>{b.preventDefault(),b.stopPropagation();const w=b.target.value;if(Q(N=>({...N,[u]:{...N[u],min:w}})),w===""||!isNaN(parseFloat(w))){const N=w===""?0:parseFloat(w),H=parseFloat(T.max||x.toString()),U=parseFloat(T.step||d.toString()),q=ae(N,H,U,v);P(s,n,q)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:T.max,onClick:b=>{b.preventDefault(),b.stopPropagation()},onChange:b=>{b.preventDefault(),b.stopPropagation();const w=b.target.value;if(Q(N=>({...N,[u]:{...N[u],max:w}})),w===""||!isNaN(parseFloat(w))){const N=parseFloat(T.min||m.toString()),H=w===""?N:parseFloat(w),U=parseFloat(T.step||d.toString()),q=ae(N,H,U,v);P(s,n,q)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:T.step,onClick:b=>{b.preventDefault(),b.stopPropagation()},onChange:b=>{b.preventDefault(),b.stopPropagation();const w=b.target.value;if(Q(N=>({...N,[u]:{...N[u],step:w}})),w===""||!isNaN(parseFloat(w))&&parseFloat(w)>0){const N=parseFloat(T.min||m.toString()),H=parseFloat(T.max||x.toString()),U=w===""?1:parseFloat(w),q=ae(N,H,U,v);P(s,n,q)}}})]}),e.jsxs("div",{className:"mt-1",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(g[s]?.[n]||S).map((b,w)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:N=>{N.stopPropagation(),oe(s,n,b,N)},children:[e.jsx("span",{children:b}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},w))})]}),e.jsx("div",{className:"mt-1",children:e.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max (max 10 values)"})})]},c)}else if(l.type==="combo"){const m=l.options?.values||[],x=`${s}_${n}`;return(!g[s]||!g[s][n])&&P(s,n,m.slice(0,3)),e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("label",{className:"text-xs font-medium text-gray-700",children:n}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:"appearance-none border border-gray-300 rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700",onClick:d=>{d.preventDefault(),d.stopPropagation(),qe(s,n,d)},"data-dropdown":x,children:[e.jsx("span",{children:(g[s]?.[n]||[]).length>0?`${n}: ${(g[s]?.[n]||[]).length} selected`:`Select ${n}`}),e.jsx("div",{className:"ml-2",children:e.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),D[x]&&e.jsxs("div",{className:"absolute z-[9999] mt-1 w-64 bg-white border border-gray-300 rounded-md shadow-lg dropdown-menu",style:{position:"fixed",top:typeof D[x]=="object"?`${D[x].y}px`:"0px",left:typeof D[x]=="object"?`${D[x].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[e.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:e.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:E[x]||"",onChange:d=>{d.preventDefault(),d.stopPropagation(),Ke(s,n,d.target.value)},onClick:d=>{d.preventDefault(),d.stopPropagation()},autoFocus:!0})}),e.jsxs("div",{className:"px-3 py-1.5 bg-gray-50 border-b cursor-pointer text-xs flex items-center text-gray-700 hover:bg-gray-100",onClick:d=>{d.preventDefault(),d.stopPropagation();const v=m.filter(S=>!E[x]||S.toLowerCase().includes((E[x]||"").toLowerCase()));Ye(s,n,v)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${m.length>0&&(g[s]?.[n]||[]).length===m.length?"bg-blue-500 border-blue-500":(g[s]?.[n]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(g[s]?.[n]||[]).length>0&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"font-medium",children:m.length>0&&(g[s]?.[n]||[]).length===m.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[m.filter(d=>!E[x]||d.toLowerCase().includes((E[x]||"").toLowerCase())).map((d,v)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:S=>{S.preventDefault(),S.stopPropagation(),oe(s,n,d,S)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(g[s]?.[n]||[]).includes(d)?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(g[s]?.[n]||[]).includes(d)&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:d})]},v)),m.filter(d=>!E[x]||d.toLowerCase().includes((E[x]||"").toLowerCase())).length===0&&e.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(g[s]?.[n]||[]).map((d,v)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:d}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:S=>{S.preventDefault(),S.stopPropagation(),oe(s,n,d,S)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},v)),e.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:d=>{d.preventDefault(),d.stopPropagation();const v=`${n}${(g[s]?.[n]||[]).length+1}`;P(s,n,[...g[s]?.[n]||[],v])},children:[e.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("span",{children:"Add"})]})]})]})]},c)}else return(!g[s]||!g[s][n])&&P(s,n,[`${n}1`,`${n}2`,`${n}3`]),e.jsxs("div",{className:"border-b pb-3",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx("label",{className:"text-xs font-medium text-gray-700",children:n})}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(g[s]?.[n]||[]).map((m,x)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:m}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:d=>{d.preventDefault(),d.stopPropagation(),oe(s,n,m,d)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},x)),e.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:m=>{m.preventDefault(),m.stopPropagation();const x=`${n}${(g[s]?.[n]||[]).length+1}`;P(s,n,[...g[s]?.[n]||[],x])},children:[e.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("span",{children:"Add"})]})]})]})]},c)})})]},r)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:t=>ne(t),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:t=>ke(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})}):e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",R," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:O,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Z&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:Z})]})}),h.length>0?h.map((t,r)=>{const a=t.type||"Unknown Node",o=t.widgets||[],s=t.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[a," (ID: ",s,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:o.map((l,c)=>{const n=l.name;if(!k[n])return null;const u=g[s]?.[n]||[],m=Array.isArray(u)?`[${u.join(", ")}]`:JSON.stringify(u);return e.jsxs("div",{className:cx.preventDefault()})})]},c)})})]},r)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500 text-xs",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:t=>ne(t),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:t=>Ce(t),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Start Generation"})]})]})})};export{bt as ParameterDebugInterface}; diff --git a/dist/copilot_web/input.js b/dist/copilot_web/input.js index c3a4af9..e6bd61b 100644 --- a/dist/copilot_web/input.js +++ b/dist/copilot_web/input.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-BbQ1FUHS.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-B3k4U96-.js"])))=>i.map(i=>d[i]); -import{j as u}from"./vendor-markdown-Dek94WS0.js";import{a as v,R as p}from"./vendor-react-V04_Axys.js";import{w}from"./message-components-B3k4U96-.js";const R="modulepreload",b=function(e){return"/"+e},m={},P=function(a,s,S){let d=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(s.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=c?"stylesheet":R,c||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),c)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function l(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&l(t.reason);return a().catch(l)})};var i={},f=v;i.createRoot=f.createRoot,i.hydrateRoot=f.hydrateRoot;const _=p.lazy(()=>P(async()=>{const{default:e}=await import("./App-BbQ1FUHS.js").then(a=>a.A);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>({default:e})));function A(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}A().then(()=>w()).then(()=>{const e=document.createElement("div");e.id="comfyui-copilot-plugin",document.body.append(e),i.createRoot(e).render(u.jsx(p.StrictMode,{children:u.jsx(_,{})}))});export{P as _}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-CQdps0fq.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-B3k4U96-.js"])))=>i.map(i=>d[i]); +import{j as u}from"./vendor-markdown-Dek94WS0.js";import{a as v,R as p}from"./vendor-react-V04_Axys.js";import{w}from"./message-components-B3k4U96-.js";const R="modulepreload",b=function(e){return"/"+e},m={},P=function(a,s,S){let d=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(s.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=c?"stylesheet":R,c||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),c)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function l(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&l(t.reason);return a().catch(l)})};var i={},f=v;i.createRoot=f.createRoot,i.hydrateRoot=f.hydrateRoot;const _=p.lazy(()=>P(async()=>{const{default:e}=await import("./App-CQdps0fq.js").then(a=>a.A);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>({default:e})));function A(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}A().then(()=>w()).then(()=>{const e=document.createElement("div");e.id="comfyui-copilot-plugin",document.body.append(e),i.createRoot(e).render(u.jsx(p.StrictMode,{children:u.jsx(_,{})}))});export{P as _}; diff --git a/dist/copilot_web/workflowChat-BvuRnqQY.js b/dist/copilot_web/workflowChat-BUxk20Uw.js similarity index 99% rename from dist/copilot_web/workflowChat-BvuRnqQY.js rename to dist/copilot_web/workflowChat-BUxk20Uw.js index d569a81..dc1e6d9 100644 --- a/dist/copilot_web/workflowChat-BvuRnqQY.js +++ b/dist/copilot_web/workflowChat-BUxk20Uw.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-DDjIxht6.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-B3k4U96-.js","copilot_web/ParameterDebugInterface-Bqoj11tr.js","copilot_web/input.js","copilot_web/assets/input-CTb3NEJr.css","copilot_web/App-BbQ1FUHS.js"])))=>i.map(i=>d[i]); -import{_ as Dt}from"./input.js";import{j as h,r as xg,b as yg}from"./vendor-markdown-Dek94WS0.js";import{r as I,R as wn,c as Mt}from"./vendor-react-V04_Axys.js";import{f as wg,v as bg,a as sn,B as Sg,U as Ag,A as Ir,b as Eg,g as Ve,c as Pt,u as rs,M as Ig,W as Ot}from"./message-components-B3k4U96-.js";import{l as Cg}from"./App-BbQ1FUHS.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-DDjIxht6.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-B3k4U96-.js","copilot_web/ParameterDebugInterface-nVAl8IgQ.js","copilot_web/input.js","copilot_web/assets/input-CTb3NEJr.css","copilot_web/App-CQdps0fq.js"])))=>i.map(i=>d[i]); +import{_ as Dt}from"./input.js";import{j as h,r as xg,b as yg}from"./vendor-markdown-Dek94WS0.js";import{r as I,R as wn,c as Mt}from"./vendor-react-V04_Axys.js";import{f as wg,v as bg,a as sn,B as Sg,U as Ag,A as Ir,b as Eg,g as Ve,c as Pt,u as rs,M as Ig,W as Ot}from"./message-components-B3k4U96-.js";import{l as Cg}from"./App-CQdps0fq.js";/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. @@ -127,4 +127,4 @@ __p += '`),K&&(v+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+v+`return __p -}`;var k=Mo(function(){return X(u,S+"return "+v).apply(o,a)});if(k.source=v,Hi(k))throw k;return k}function I0(e){return J(e).toLowerCase()}function C0(e){return J(e).toUpperCase()}function N0(e,n,t){if(e=J(e),e&&(t||n===o))return Fs(e);if(!e||!(n=Fe(n)))return e;var r=en(e),i=en(n),u=js(r,i),a=zs(r,i)+1;return Mn(r,u,a).join("")}function L0(e,n,t){if(e=J(e),e&&(t||n===o))return e.slice(0,Ks(e)+1);if(!e||!(n=Fe(n)))return e;var r=en(e),i=zs(r,en(n))+1;return Mn(r,0,i).join("")}function R0(e,n,t){if(e=J(e),e&&(t||n===o))return e.replace(Hr,"");if(!e||!(n=Fe(n)))return e;var r=en(e),i=js(r,en(n));return Mn(r,i).join("")}function T0(e,n){var t=bn,r=Rr;if(ae(n)){var i="separator"in n?n.separator:i;t="length"in n?O(n.length):t,r="omission"in n?Fe(n.omission):r}e=J(e);var u=e.length;if(et(e)){var a=en(e);u=a.length}if(t>=u)return e;var l=t-nt(r);if(l<1)return r;var c=a?Mn(a,0,l).join(""):e.slice(0,l);if(i===o)return c+r;if(a&&(l+=c.length-l),qi(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=li(i.source,J(as.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===o?l:v)}}else if(e.indexOf(Fe(i),l)!=l){var y=c.lastIndexOf(i);y>-1&&(c=c.slice(0,y))}return c+r}function M0(e){return e=J(e),e&&zo.test(e)?e.replace(ss,ul):e}var O0=at(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Xi=Mu("toUpperCase");function To(e,n,t){return e=J(e),n=t?o:n,n===o?nl(e)?ll(e):Ha(e):e.match(n)||[]}var Mo=F(function(e,n){try{return Ue(e,o,n)}catch(t){return Hi(t)?t:new R(t)}}),D0=_n(function(e,n){return He(n,function(t){t=ln(t),gn(e,t,Ki(e[t],e))}),e});function P0(e){var n=e==null?0:e.length,t=C();return e=n?ue(e,function(r){if(typeof r[1]!="function")throw new qe(T);return[t(r[0]),r[1]]}):[],F(function(r){for(var i=-1;++ifn)return[];var t=ke,r=Ie(e,ke);n=C(n),e-=ke;for(var i=ui(r,n);++t0||n<0)?new G(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==o&&(n=O(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(ke)},on(G.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=s[r?"take"+(n=="last"?"Right":""):n],u=r||/^find/.test(n);i&&(s.prototype[n]=function(){var a=this.__wrapped__,l=r?[1]:arguments,c=a instanceof G,p=l[0],_=c||M(a),v=function(z){var K=i.apply(s,In([z],l));return r&&y?K[0]:K};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var y=this.__chain__,S=!!this.__actions__.length,N=u&&!y,k=c&&!S;if(!u&&_){a=k?a:new G(this);var L=e.apply(a,l);return L.__actions__.push({func:mr,args:[v],thisArg:o}),new Ze(L,y)}return N&&k?e.apply(this,l):(L=this.thru(v),N?r?L.value()[0]:L.value():L)})}),He(["pop","push","shift","sort","splice","unshift"],function(e){var n=Kt[e],t=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);s.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var u=this.value();return n.apply(M(u)?u:[],i)}return this[t](function(a){return n.apply(M(a)?a:[],i)})}}),on(G.prototype,function(e,n){var t=s[n];if(t){var r=t.name+"";Q.call(st,r)||(st[r]=[]),st[r].push({name:n,func:t})}}),st[cr(o,le).name]=[{name:"wrapper",func:o}],G.prototype.clone=Tl,G.prototype.reverse=Ml,G.prototype.value=Ol,s.prototype.at=lh,s.prototype.chain=fh,s.prototype.commit=ch,s.prototype.next=hh,s.prototype.plant=gh,s.prototype.reverse=ph,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=_h,s.prototype.first=s.prototype.head,mt&&(s.prototype[mt]=dh),s},tt=fl();kn?((kn.exports=tt)._=tt,Qr._=tt):we._=tt}).call(Mt)})(Nr,Nr.exports);var Lr=Nr.exports;function rp(m=!0){I.useEffect(()=>{if(!m)return;const w=Lr.debounce(o=>{document.documentElement.style.setProperty("--mouse-x",`${o.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${o.clientY}px`)},16);return document.addEventListener("mousemove",w),()=>{w.cancel(),document.removeEventListener("mousemove",w)}},[m])}function ip(m={},w=!0){const[o,D]=I.useState(!1),[W,E]=I.useState({width:window.innerWidth/3,height:window.innerHeight,top:0});I.useCallback(Lr.debounce(q=>{o&&E(x=>{const $=window.innerWidth-q.clientX,U=Math.min(Math.max(m.minWidth||300,$),m.maxWidth||window.innerWidth*.8);return{...x,width:U}})},16),[o,m]);const T=I.useCallback(q=>{E(x=>{const $=x.height-q,U=x.top+q;return{...x,height:Math.min(Math.max(m.minHeight||300,$),m.maxHeight||window.innerHeight),top:Math.max(0,U)}})},[m]);return I.useEffect(()=>{if(!w||!o)return;const q=Lr.debounce($=>{E(U=>{const j=window.innerWidth-$.clientX,re=Math.min(Math.max(m.minWidth||300,j),m.maxWidth||window.innerWidth*.8);return{...U,width:re}})},16),x=()=>D(!1);return document.addEventListener("mousemove",q),document.addEventListener("mouseup",x),()=>{q.cancel(),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",x)}},[o,m,w]),{isResizing:o,setIsResizing:D,dimensions:W,handleHeightResize:T}}function sp(m=!0){const{state:w,dispatch:o}=rs(),{activeTab:D,screenState:W}=w;I.useEffect(()=>{if(!m)return;const E=T=>{const q=D==="parameter-debug",x=!W||W.currentScreen===0;if(q&&x){const $=sn.canvas.selected_nodes;if(Object.keys($??{}).length){const U=Object.values($);o({type:"SET_SELECTED_NODE",payload:U})}else o({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[o,m,D,W])}const up=({message:m,onClose:w})=>m?h.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-amber-100 border-b border-amber-200 px-5 py-2 mt-2 relative shadow-sm",children:[h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"flex-shrink-0 mr-2",children:h.jsx("svg",{className:"w-3.5 h-3.5 text-amber-600",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),h.jsx("div",{className:"text-amber-800 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:h.jsx(Ig,{rehypePlugins:[[xg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[yg],className:"prose !text-[11px] prose-a:text-amber-700 prose-a:underline prose-a:font-medium hover:prose-a:text-amber-800",components:{a:({node:o,...D})=>h.jsx("a",{...D,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:o})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:o}),span:({children:o})=>h.jsx("span",{style:{fontSize:"11px"},children:o}),li:({children:o})=>h.jsx("li",{style:{fontSize:"11px"},children:o}),ul:({children:o})=>h.jsx("ul",{style:{fontSize:"11px"},children:o}),ol:({children:o})=>h.jsx("ol",{style:{fontSize:"11px"},children:o})},children:m})})]}),h.jsx("button",{onClick:w,className:"absolute right-2 top-1/2 -translate-y-1/2 text-amber-500 hover:text-amber-700 transition-colors p-1 rounded-full hover:bg-amber-200/50","aria-label":"Close announcement",children:h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,op=()=>{const{state:m,dispatch:w}=rs(),{selectedNode:o,screenState:D}=m,W=o||[],E=wn.lazy(()=>Dt(()=>import("./ParameterDebugInterface-Bqoj11tr.js"),__vite__mapDeps([4,1,2,3,5,6,7])).then(q=>({default:q.ParameterDebugInterface}))),T=()=>{w({type:"SET_SELECTED_NODE",payload:null}),w({type:"SET_SCREEN_STATE",payload:null})};return h.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:h.jsx(wn.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(E,{selectedNodes:W,visible:!0,onClose:T})})})},ko=({active:m,onClick:w,children:o})=>h.jsx("button",{onClick:w,className:`px-4 py-2 font-medium text-sm transition-colors duration-200 ${m?"text-blue-600 border-b-2 border-blue-600":"text-gray-600 hover:text-blue-500 hover:border-b-2 hover:border-blue-300"}`,children:o});function ap({onClose:m,visible:w=!0,triggerUsage:o=!1,onUsageTriggered:D}){const{state:W,dispatch:E}=rs(),{messages:T,installedNodes:q,loading:x,sessionId:$,selectedNode:U,activeTab:j}=W,re=I.useRef(null),[ie,pe]=I.useState(""),[B,P]=I.useState(""),[le,he]=I.useState(window.innerWidth/3),[oe,Pe]=I.useState(!1),[fe,H]=I.useState([]),[Z,Se]=I.useState("gpt-4o-mini");I.useState(window.innerHeight),I.useState(0);const[_e,bn]=I.useState(""),[Rr,kt]=I.useState(!1);rp(w&&j==="chat"),sp(w);const{isResizing:is,setIsResizing:Wt,dimensions:dt,handleHeightResize:Tr}=ip({minWidth:300,maxWidth:window.innerWidth*.8,minHeight:300,maxHeight:window.innerHeight},w);I.useEffect(()=>{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[T]),I.useEffect(()=>{if(j!=="chat")return;(async()=>{const Y=await tp();console.log("[WorkflowChat] Received installed nodes:",Y.length),E({type:"SET_INSTALLED_NODES",payload:Y})})()},[j]);const $n=async A=>{try{const Y=await Ot.fetchMessages(A);E({type:"SET_MESSAGES",payload:Y})}catch(Y){console.error("Error fetching messages:",Y)}};I.useEffect(()=>{if(j!=="chat")return;let A=localStorage.getItem("sessionId");A?(E({type:"SET_SESSION_ID",payload:A}),$n(A)):(A=Ve(),E({type:"SET_SESSION_ID",payload:A}),localStorage.setItem("sessionId",A))},[j]);const fn=wn.useCallback(A=>{if(!oe)return;const Y=window.innerWidth-A.clientX,ee=Math.min(Math.max(300,Y),window.innerWidth*.8);he(ee)},[oe]),Hn=wn.useMemo(()=>Lr.debounce(fn,16),[fn]);I.useEffect(()=>(oe&&(document.addEventListener("mousemove",Hn),document.addEventListener("mouseup",An)),()=>{document.removeEventListener("mousemove",Hn),document.removeEventListener("mouseup",An),Hn.cancel()}),[oe,Hn]);const qn=A=>{pe(A.target.value)},ke=async()=>{if(E({type:"SET_LOADING",payload:!0}),ie.trim()===""&&!U||!$)return;P(ie);const A=Ve(),Y={id:Ve(),role:"user",content:ie,trace_id:A};E({type:"ADD_MESSAGE",payload:Y}),pe("");try{const ee={type:"model_select",data:[Z]};let Ae=Ve(),un=!0;for await(const Ee of Ot.streamInvokeServer($,ie,fe.map(V=>V.file),null,ee,A)){const V={id:Ae,role:"ai",content:JSON.stringify(Ee),format:Ee.format,finished:Ee.finished,name:"Assistant"};if(un)E({type:"ADD_MESSAGE",payload:V}),un=!1;else{E({type:"UPDATE_MESSAGE",payload:V});const ve=W.messages.map(Ke=>Ke.id===V.id&&!Ke.finished?V:Ke);Zn(ve)}Ee.finished&&E({type:"SET_LOADING",payload:!1})}}catch(ee){console.error("Error sending message:",ee),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Mr=async A=>{if(!$)return;E({type:"SET_LOADING",payload:!0}),P(A);const Y=Ve(),ee={id:Ve(),role:"user",content:A,trace_id:Y};E({type:"ADD_MESSAGE",payload:ee});try{const Ae={type:"model_select",data:[Z]};let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,A,fe.map(ve=>ve.file),null,Ae,Y)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=W.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(Ae){console.error("Error sending message:",Ae),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Or=A=>{A.metaKey&&A.key==="Enter"&&ke()},Dr=()=>{E({type:"CLEAR_MESSAGES"});const A=W.sessionId;A&&localStorage.removeItem(`messages_${A}`),localStorage.removeItem("sessionId");const Y=Ve();E({type:"SET_SESSION_ID",payload:Y}),localStorage.setItem("sessionId",Y)},Sn=A=>{pe(A)},Dn=async(A,Y)=>{if(!$||!U)return;E({type:"SET_LOADING",payload:!0});const ee=Ve(),Ae={id:Ve(),role:"user",content:U.comfyClass||U.type,trace_id:ee};E({type:"ADD_MESSAGE",payload:Ae});try{let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,U.comfyClass||U.type,[],A,Y,ee)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(A&&A!==""&&(ve.metadata={intent:A}),Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=W.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(un){console.error("Error sending message:",un),E({type:"SET_LOADING",payload:!1})}},Zn=A=>{W.sessionId&&localStorage.setItem(`messages_${W.sessionId}`,JSON.stringify(A))},Pn=A=>{console.log("[WorkflowChat] Adding new message:",A);const Y=[...W.messages,A];E({type:"ADD_MESSAGE",payload:A}),Zn(Y)},An=()=>{Pe(!1)},Pr=A=>{const Y=Array.from(A).map(ee=>({id:Math.random().toString(36).substr(2,9),file:ee,preview:URL.createObjectURL(ee)}));H(ee=>[...ee,...Y])},Yn=A=>{H(Y=>Y.filter(Ae=>Ae.id!==A))};wn.useEffect(()=>()=>{fe.forEach(A=>URL.revokeObjectURL(A.preview))},[fe]),I.useEffect(()=>{o&&D&&j==="chat"&&(Dn("node_explain"),D())},[o,j]),I.useEffect(()=>{if(!w||j!=="chat")return;(async()=>{try{const Y=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==Y){const Ae=await Ot.fetchAnnouncement();Ae&&Ae.trim()!==""&&(bn(Ae),kt(!0),localStorage.setItem("announcementLastShownDate",Y))}}catch(Y){console.error("Error fetching announcement:",Y)}})()},[w,j]);const Xn=()=>{kt(!1)},gt=A=>{E({type:"SET_ACTIVE_TAB",payload:A})},We=wn.useMemo(()=>h.jsx(op,{}),[]);return h.jsxs("div",{className:"fixed right-0 shadow-lg bg-white duration-200 ease-out",style:{display:w?"block":"none",width:`${dt.width}px`,height:`${dt.height}px`,top:`${dt.top}px`},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300",onMouseDown:A=>{Wt(!0),A.preventDefault()}}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx(Gg,{onClose:m,onClear:Dr,hasMessages:T.length>0,onHeightResize:Tr,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(ko,{active:j==="chat",onClick:()=>gt("chat"),children:"Chat"}),h.jsx(ko,{active:j==="parameter-debug",onClick:()=>gt("parameter-debug"),children:"GenLab"})]}),Rr&&_e&&j==="chat"&&h.jsx(up,{message:_e,onClose:Xn}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth",style:{display:j==="chat"?"block":"none"},ref:re,children:h.jsx(ep,{messages:T,latestInput:B,onOptionClick:Sn,installedNodes:q,onAddMessage:Pn,loading:x})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:j==="chat"?"block":"none"},children:[U&&h.jsx(qg,{nodeInfo:U,onSendWithIntent:Dn,loading:x,onSendWithContent:Mr}),h.jsx($g,{input:ie,loading:x,onChange:qn,onSend:ke,onKeyPress:Or,onUploadImages:Pr,uploadedImages:fe,onRemoveImage:Yn,selectedModel:Z,onModelChange:Se})]}),h.jsx("div",{className:"flex-1 flex flex-col",style:{display:j==="parameter-debug"?"flex":"none"},children:We})]})]})}const mp=Object.freeze(Object.defineProperty({__proto__:null,default:ap},Symbol.toStringTag,{value:"Module"}));export{vp as g,_p as i,pp as m,gp as r,mp as w}; +}`;var k=Mo(function(){return X(u,S+"return "+v).apply(o,a)});if(k.source=v,Hi(k))throw k;return k}function I0(e){return J(e).toLowerCase()}function C0(e){return J(e).toUpperCase()}function N0(e,n,t){if(e=J(e),e&&(t||n===o))return Fs(e);if(!e||!(n=Fe(n)))return e;var r=en(e),i=en(n),u=js(r,i),a=zs(r,i)+1;return Mn(r,u,a).join("")}function L0(e,n,t){if(e=J(e),e&&(t||n===o))return e.slice(0,Ks(e)+1);if(!e||!(n=Fe(n)))return e;var r=en(e),i=zs(r,en(n))+1;return Mn(r,0,i).join("")}function R0(e,n,t){if(e=J(e),e&&(t||n===o))return e.replace(Hr,"");if(!e||!(n=Fe(n)))return e;var r=en(e),i=js(r,en(n));return Mn(r,i).join("")}function T0(e,n){var t=bn,r=Rr;if(ae(n)){var i="separator"in n?n.separator:i;t="length"in n?O(n.length):t,r="omission"in n?Fe(n.omission):r}e=J(e);var u=e.length;if(et(e)){var a=en(e);u=a.length}if(t>=u)return e;var l=t-nt(r);if(l<1)return r;var c=a?Mn(a,0,l).join(""):e.slice(0,l);if(i===o)return c+r;if(a&&(l+=c.length-l),qi(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=li(i.source,J(as.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===o?l:v)}}else if(e.indexOf(Fe(i),l)!=l){var y=c.lastIndexOf(i);y>-1&&(c=c.slice(0,y))}return c+r}function M0(e){return e=J(e),e&&zo.test(e)?e.replace(ss,ul):e}var O0=at(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Xi=Mu("toUpperCase");function To(e,n,t){return e=J(e),n=t?o:n,n===o?nl(e)?ll(e):Ha(e):e.match(n)||[]}var Mo=F(function(e,n){try{return Ue(e,o,n)}catch(t){return Hi(t)?t:new R(t)}}),D0=_n(function(e,n){return He(n,function(t){t=ln(t),gn(e,t,Ki(e[t],e))}),e});function P0(e){var n=e==null?0:e.length,t=C();return e=n?ue(e,function(r){if(typeof r[1]!="function")throw new qe(T);return[t(r[0]),r[1]]}):[],F(function(r){for(var i=-1;++ifn)return[];var t=ke,r=Ie(e,ke);n=C(n),e-=ke;for(var i=ui(r,n);++t0||n<0)?new G(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==o&&(n=O(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(ke)},on(G.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=s[r?"take"+(n=="last"?"Right":""):n],u=r||/^find/.test(n);i&&(s.prototype[n]=function(){var a=this.__wrapped__,l=r?[1]:arguments,c=a instanceof G,p=l[0],_=c||M(a),v=function(z){var K=i.apply(s,In([z],l));return r&&y?K[0]:K};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var y=this.__chain__,S=!!this.__actions__.length,N=u&&!y,k=c&&!S;if(!u&&_){a=k?a:new G(this);var L=e.apply(a,l);return L.__actions__.push({func:mr,args:[v],thisArg:o}),new Ze(L,y)}return N&&k?e.apply(this,l):(L=this.thru(v),N?r?L.value()[0]:L.value():L)})}),He(["pop","push","shift","sort","splice","unshift"],function(e){var n=Kt[e],t=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);s.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var u=this.value();return n.apply(M(u)?u:[],i)}return this[t](function(a){return n.apply(M(a)?a:[],i)})}}),on(G.prototype,function(e,n){var t=s[n];if(t){var r=t.name+"";Q.call(st,r)||(st[r]=[]),st[r].push({name:n,func:t})}}),st[cr(o,le).name]=[{name:"wrapper",func:o}],G.prototype.clone=Tl,G.prototype.reverse=Ml,G.prototype.value=Ol,s.prototype.at=lh,s.prototype.chain=fh,s.prototype.commit=ch,s.prototype.next=hh,s.prototype.plant=gh,s.prototype.reverse=ph,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=_h,s.prototype.first=s.prototype.head,mt&&(s.prototype[mt]=dh),s},tt=fl();kn?((kn.exports=tt)._=tt,Qr._=tt):we._=tt}).call(Mt)})(Nr,Nr.exports);var Lr=Nr.exports;function rp(m=!0){I.useEffect(()=>{if(!m)return;const w=Lr.debounce(o=>{document.documentElement.style.setProperty("--mouse-x",`${o.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${o.clientY}px`)},16);return document.addEventListener("mousemove",w),()=>{w.cancel(),document.removeEventListener("mousemove",w)}},[m])}function ip(m={},w=!0){const[o,D]=I.useState(!1),[W,E]=I.useState({width:window.innerWidth/3,height:window.innerHeight,top:0});I.useCallback(Lr.debounce(q=>{o&&E(x=>{const $=window.innerWidth-q.clientX,U=Math.min(Math.max(m.minWidth||300,$),m.maxWidth||window.innerWidth*.8);return{...x,width:U}})},16),[o,m]);const T=I.useCallback(q=>{E(x=>{const $=x.height-q,U=x.top+q;return{...x,height:Math.min(Math.max(m.minHeight||300,$),m.maxHeight||window.innerHeight),top:Math.max(0,U)}})},[m]);return I.useEffect(()=>{if(!w||!o)return;const q=Lr.debounce($=>{E(U=>{const j=window.innerWidth-$.clientX,re=Math.min(Math.max(m.minWidth||300,j),m.maxWidth||window.innerWidth*.8);return{...U,width:re}})},16),x=()=>D(!1);return document.addEventListener("mousemove",q),document.addEventListener("mouseup",x),()=>{q.cancel(),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",x)}},[o,m,w]),{isResizing:o,setIsResizing:D,dimensions:W,handleHeightResize:T}}function sp(m=!0){const{state:w,dispatch:o}=rs(),{activeTab:D,screenState:W}=w;I.useEffect(()=>{if(!m)return;const E=T=>{const q=D==="parameter-debug",x=!W||W.currentScreen===0;if(q&&x){const $=sn.canvas.selected_nodes;if(Object.keys($??{}).length){const U=Object.values($);o({type:"SET_SELECTED_NODE",payload:U})}else o({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[o,m,D,W])}const up=({message:m,onClose:w})=>m?h.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-amber-100 border-b border-amber-200 px-5 py-2 mt-2 relative shadow-sm",children:[h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"flex-shrink-0 mr-2",children:h.jsx("svg",{className:"w-3.5 h-3.5 text-amber-600",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),h.jsx("div",{className:"text-amber-800 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:h.jsx(Ig,{rehypePlugins:[[xg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[yg],className:"prose !text-[11px] prose-a:text-amber-700 prose-a:underline prose-a:font-medium hover:prose-a:text-amber-800",components:{a:({node:o,...D})=>h.jsx("a",{...D,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:o})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:o}),span:({children:o})=>h.jsx("span",{style:{fontSize:"11px"},children:o}),li:({children:o})=>h.jsx("li",{style:{fontSize:"11px"},children:o}),ul:({children:o})=>h.jsx("ul",{style:{fontSize:"11px"},children:o}),ol:({children:o})=>h.jsx("ol",{style:{fontSize:"11px"},children:o})},children:m})})]}),h.jsx("button",{onClick:w,className:"absolute right-2 top-1/2 -translate-y-1/2 text-amber-500 hover:text-amber-700 transition-colors p-1 rounded-full hover:bg-amber-200/50","aria-label":"Close announcement",children:h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,op=()=>{const{state:m,dispatch:w}=rs(),{selectedNode:o,screenState:D}=m,W=o||[],E=wn.lazy(()=>Dt(()=>import("./ParameterDebugInterface-nVAl8IgQ.js"),__vite__mapDeps([4,1,2,3,5,6,7])).then(q=>({default:q.ParameterDebugInterface}))),T=()=>{w({type:"SET_SELECTED_NODE",payload:null}),w({type:"SET_SCREEN_STATE",payload:null})};return h.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:h.jsx(wn.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(E,{selectedNodes:W,visible:!0,onClose:T})})})},ko=({active:m,onClick:w,children:o})=>h.jsx("button",{onClick:w,className:`px-4 py-2 font-medium text-sm transition-colors duration-200 ${m?"text-blue-600 border-b-2 border-blue-600":"text-gray-600 hover:text-blue-500 hover:border-b-2 hover:border-blue-300"}`,children:o});function ap({onClose:m,visible:w=!0,triggerUsage:o=!1,onUsageTriggered:D}){const{state:W,dispatch:E}=rs(),{messages:T,installedNodes:q,loading:x,sessionId:$,selectedNode:U,activeTab:j}=W,re=I.useRef(null),[ie,pe]=I.useState(""),[B,P]=I.useState(""),[le,he]=I.useState(window.innerWidth/3),[oe,Pe]=I.useState(!1),[fe,H]=I.useState([]),[Z,Se]=I.useState("gpt-4o-mini");I.useState(window.innerHeight),I.useState(0);const[_e,bn]=I.useState(""),[Rr,kt]=I.useState(!1);rp(w&&j==="chat"),sp(w);const{isResizing:is,setIsResizing:Wt,dimensions:dt,handleHeightResize:Tr}=ip({minWidth:300,maxWidth:window.innerWidth*.8,minHeight:300,maxHeight:window.innerHeight},w);I.useEffect(()=>{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[T]),I.useEffect(()=>{if(j!=="chat")return;(async()=>{const Y=await tp();console.log("[WorkflowChat] Received installed nodes:",Y.length),E({type:"SET_INSTALLED_NODES",payload:Y})})()},[j]);const $n=async A=>{try{const Y=await Ot.fetchMessages(A);E({type:"SET_MESSAGES",payload:Y})}catch(Y){console.error("Error fetching messages:",Y)}};I.useEffect(()=>{if(j!=="chat")return;let A=localStorage.getItem("sessionId");A?(E({type:"SET_SESSION_ID",payload:A}),$n(A)):(A=Ve(),E({type:"SET_SESSION_ID",payload:A}),localStorage.setItem("sessionId",A))},[j]);const fn=wn.useCallback(A=>{if(!oe)return;const Y=window.innerWidth-A.clientX,ee=Math.min(Math.max(300,Y),window.innerWidth*.8);he(ee)},[oe]),Hn=wn.useMemo(()=>Lr.debounce(fn,16),[fn]);I.useEffect(()=>(oe&&(document.addEventListener("mousemove",Hn),document.addEventListener("mouseup",An)),()=>{document.removeEventListener("mousemove",Hn),document.removeEventListener("mouseup",An),Hn.cancel()}),[oe,Hn]);const qn=A=>{pe(A.target.value)},ke=async()=>{if(E({type:"SET_LOADING",payload:!0}),ie.trim()===""&&!U||!$)return;P(ie);const A=Ve(),Y={id:Ve(),role:"user",content:ie,trace_id:A};E({type:"ADD_MESSAGE",payload:Y}),pe("");try{const ee={type:"model_select",data:[Z]};let Ae=Ve(),un=!0;for await(const Ee of Ot.streamInvokeServer($,ie,fe.map(V=>V.file),null,ee,A)){const V={id:Ae,role:"ai",content:JSON.stringify(Ee),format:Ee.format,finished:Ee.finished,name:"Assistant"};if(un)E({type:"ADD_MESSAGE",payload:V}),un=!1;else{E({type:"UPDATE_MESSAGE",payload:V});const ve=W.messages.map(Ke=>Ke.id===V.id&&!Ke.finished?V:Ke);Zn(ve)}Ee.finished&&E({type:"SET_LOADING",payload:!1})}}catch(ee){console.error("Error sending message:",ee),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Mr=async A=>{if(!$)return;E({type:"SET_LOADING",payload:!0}),P(A);const Y=Ve(),ee={id:Ve(),role:"user",content:A,trace_id:Y};E({type:"ADD_MESSAGE",payload:ee});try{const Ae={type:"model_select",data:[Z]};let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,A,fe.map(ve=>ve.file),null,Ae,Y)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=W.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(Ae){console.error("Error sending message:",Ae),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Or=A=>{A.metaKey&&A.key==="Enter"&&ke()},Dr=()=>{E({type:"CLEAR_MESSAGES"});const A=W.sessionId;A&&localStorage.removeItem(`messages_${A}`),localStorage.removeItem("sessionId");const Y=Ve();E({type:"SET_SESSION_ID",payload:Y}),localStorage.setItem("sessionId",Y)},Sn=A=>{pe(A)},Dn=async(A,Y)=>{if(!$||!U)return;E({type:"SET_LOADING",payload:!0});const ee=Ve(),Ae={id:Ve(),role:"user",content:U.comfyClass||U.type,trace_id:ee};E({type:"ADD_MESSAGE",payload:Ae});try{let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,U.comfyClass||U.type,[],A,Y,ee)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(A&&A!==""&&(ve.metadata={intent:A}),Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=W.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(un){console.error("Error sending message:",un),E({type:"SET_LOADING",payload:!1})}},Zn=A=>{W.sessionId&&localStorage.setItem(`messages_${W.sessionId}`,JSON.stringify(A))},Pn=A=>{console.log("[WorkflowChat] Adding new message:",A);const Y=[...W.messages,A];E({type:"ADD_MESSAGE",payload:A}),Zn(Y)},An=()=>{Pe(!1)},Pr=A=>{const Y=Array.from(A).map(ee=>({id:Math.random().toString(36).substr(2,9),file:ee,preview:URL.createObjectURL(ee)}));H(ee=>[...ee,...Y])},Yn=A=>{H(Y=>Y.filter(Ae=>Ae.id!==A))};wn.useEffect(()=>()=>{fe.forEach(A=>URL.revokeObjectURL(A.preview))},[fe]),I.useEffect(()=>{o&&D&&j==="chat"&&(Dn("node_explain"),D())},[o,j]),I.useEffect(()=>{if(!w||j!=="chat")return;(async()=>{try{const Y=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==Y){const Ae=await Ot.fetchAnnouncement();Ae&&Ae.trim()!==""&&(bn(Ae),kt(!0),localStorage.setItem("announcementLastShownDate",Y))}}catch(Y){console.error("Error fetching announcement:",Y)}})()},[w,j]);const Xn=()=>{kt(!1)},gt=A=>{E({type:"SET_ACTIVE_TAB",payload:A})},We=wn.useMemo(()=>h.jsx(op,{}),[]);return h.jsxs("div",{className:"fixed right-0 shadow-lg bg-white duration-200 ease-out",style:{display:w?"block":"none",width:`${dt.width}px`,height:`${dt.height}px`,top:`${dt.top}px`},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300",onMouseDown:A=>{Wt(!0),A.preventDefault()}}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx(Gg,{onClose:m,onClear:Dr,hasMessages:T.length>0,onHeightResize:Tr,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(ko,{active:j==="chat",onClick:()=>gt("chat"),children:"Chat"}),h.jsx(ko,{active:j==="parameter-debug",onClick:()=>gt("parameter-debug"),children:"GenLab"})]}),Rr&&_e&&j==="chat"&&h.jsx(up,{message:_e,onClose:Xn}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth",style:{display:j==="chat"?"block":"none"},ref:re,children:h.jsx(ep,{messages:T,latestInput:B,onOptionClick:Sn,installedNodes:q,onAddMessage:Pn,loading:x})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:j==="chat"?"block":"none"},children:[U&&h.jsx(qg,{nodeInfo:U,onSendWithIntent:Dn,loading:x,onSendWithContent:Mr}),h.jsx($g,{input:ie,loading:x,onChange:qn,onSend:ke,onKeyPress:Or,onUploadImages:Pr,uploadedImages:fe,onRemoveImage:Yn,selectedModel:Z,onModelChange:Se})]}),h.jsx("div",{className:"flex-1 flex flex-col",style:{display:j==="parameter-debug"?"flex":"none"},children:We})]})]})}const mp=Object.freeze(Object.defineProperty({__proto__:null,default:ap},Symbol.toStringTag,{value:"Module"}));export{vp as g,_p as i,pp as m,gp as r,mp as w}; diff --git a/ui/src/apis/comfyApiCustom.ts b/ui/src/apis/comfyApiCustom.ts index efce4bc..409a4a4 100644 --- a/ui/src/apis/comfyApiCustom.ts +++ b/ui/src/apis/comfyApiCustom.ts @@ -2,7 +2,7 @@ * @Author: ai-business-hql ai.bussiness.hql@gmail.com * @Date: 2025-02-17 20:53:45 * @LastEditors: ai-business-hql ai.bussiness.hql@gmail.com - * @LastEditTime: 2025-03-27 21:49:14 + * @LastEditTime: 2025-03-28 14:28:51 * @FilePath: /comfyui_copilot/ui/src/apis/comfyApiCustom.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ diff --git a/ui/src/components/debug/ParameterDebugInterface.tsx b/ui/src/components/debug/ParameterDebugInterface.tsx index a8323d1..14980b4 100644 --- a/ui/src/components/debug/ParameterDebugInterface.tsx +++ b/ui/src/components/debug/ParameterDebugInterface.tsx @@ -164,8 +164,11 @@ export const ParameterDebugInterface: React.FC = ( }; }); - // Also update paramTestValues - updateParamTestValues(nodeId, paramName, textInputs[textKey] || []); + // Also update paramTestValues with the new value directly instead of using textInputs state + // (which hasn't been updated yet) + const currentTexts = [...(textInputs[textKey] || [])]; + currentTexts[index] = value; + updateParamTestValues(nodeId, paramName, currentTexts); }; // Add function to add a new text input