From 426fd308fdf237cb87fbcddd4b72f2626c74ff0b Mon Sep 17 00:00:00 2001 From: ai-business-hql Date: Tue, 13 May 2025 11:28:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{App-CGsjxi5y.js => App-Dp5pJunx.js} | 4 ++-- ... => ParameterDebugInterfaceNew-Bll5geLy.js} | 2 +- dist/copilot_web/WorkflowOption-Bee-YmQA.js | 1 + dist/copilot_web/WorkflowOption-C7lWPQXP.js | 1 - dist/copilot_web/input.js | 4 ++-- ...1VVaz.js => message-components-DHkIj9qD.js} | 2 +- ...at-DAlFyxt6.js => workflowChat-CjDaET6O.js} | 8 ++++---- .../chat/messages/WorkflowOption.tsx | 18 ++++++++++++++---- 8 files changed, 25 insertions(+), 15 deletions(-) rename dist/copilot_web/{App-CGsjxi5y.js => App-Dp5pJunx.js} (82%) rename dist/copilot_web/{ParameterDebugInterfaceNew-12BV9YCy.js => ParameterDebugInterfaceNew-Bll5geLy.js} (99%) create mode 100644 dist/copilot_web/WorkflowOption-Bee-YmQA.js delete mode 100644 dist/copilot_web/WorkflowOption-C7lWPQXP.js rename dist/copilot_web/{message-components-DoI1VVaz.js => message-components-DHkIj9qD.js} (99%) rename dist/copilot_web/{workflowChat-DAlFyxt6.js => workflowChat-CjDaET6O.js} (99%) diff --git a/dist/copilot_web/App-CGsjxi5y.js b/dist/copilot_web/App-Dp5pJunx.js similarity index 82% rename from dist/copilot_web/App-CGsjxi5y.js rename to dist/copilot_web/App-Dp5pJunx.js index 2da0e01..13794ba 100644 --- a/dist/copilot_web/App-CGsjxi5y.js +++ b/dist/copilot_web/App-Dp5pJunx.js @@ -1,6 +1,6 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-DAlFyxt6.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-DoI1VVaz.js","copilot_web/assets/input-0GzdDP_m.css","copilot_web/fonts.css"].map(path => { +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-CjDaET6O.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-DHkIj9qD.js","copilot_web/assets/input-0GzdDP_m.css","copilot_web/fonts.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 a}from"./input.js";import{j as t}from"./vendor-markdown-Dek94WS0.js";import{r,R as i}from"./vendor-react-V04_Axys.js";import{C as n}from"./message-components-DoI1VVaz.js";/* empty css */const o={EXPLAIN_NODE:"copilot:explain-node"},d=i.lazy(()=>a(()=>import("./workflowChat-DAlFyxt6.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function p(){const[e,s]=r.useState(!1);return r.useEffect(()=>{const l=()=>{s(!0)};return window.addEventListener(o.EXPLAIN_NODE,l),()=>window.removeEventListener(o.EXPLAIN_NODE,l)},[]),t.jsx(n,{children:t.jsx("div",{className:"h-full w-full flex flex-col",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:t.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>s(!1)})})})})}export{p as default}; +import{_ as a}from"./input.js";import{j as t}from"./vendor-markdown-Dek94WS0.js";import{r,R as i}from"./vendor-react-V04_Axys.js";import{C as n}from"./message-components-DHkIj9qD.js";/* empty css */const o={EXPLAIN_NODE:"copilot:explain-node"},d=i.lazy(()=>a(()=>import("./workflowChat-CjDaET6O.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function p(){const[e,s]=r.useState(!1);return r.useEffect(()=>{const l=()=>{s(!0)};return window.addEventListener(o.EXPLAIN_NODE,l),()=>window.removeEventListener(o.EXPLAIN_NODE,l)},[]),t.jsx(n,{children:t.jsx("div",{className:"h-full w-full flex flex-col",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:t.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>s(!1)})})})})}export{p as default}; diff --git a/dist/copilot_web/ParameterDebugInterfaceNew-12BV9YCy.js b/dist/copilot_web/ParameterDebugInterfaceNew-Bll5geLy.js similarity index 99% rename from dist/copilot_web/ParameterDebugInterfaceNew-12BV9YCy.js rename to dist/copilot_web/ParameterDebugInterfaceNew-Bll5geLy.js index 50c347f..6060836 100644 --- a/dist/copilot_web/ParameterDebugInterfaceNew-12BV9YCy.js +++ b/dist/copilot_web/ParameterDebugInterfaceNew-Bll5geLy.js @@ -1,4 +1,4 @@ -import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as y}from"./vendor-react-V04_Axys.js";import{r as nt,g as ot,m as at,i as lt}from"./workflowChat-DAlFyxt6.js";import{a as Z,u as De,g as ke,W as ue}from"./message-components-DoI1VVaz.js";import"./input.js";/* empty css */function it(a,n){try{if(!a)return console.error("Invalid prompt_output: ",a),a;for(const r of n){if(!a[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!a[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}a[r.nodeId].inputs[r.paramName]=r.paramValue}return a}catch(r){return console.error("Error updating prompt:",r),a}}async function ct(a){const n=await Z.graphToPrompt(),r=it(n.output,a);console.log("queuePrompt updated_prompt:",r);const u={prompt:r,client_id:Z.api.clientId,extra_data:{extra_pageinfo:{workflow:n.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const p=await nt(u);return console.debug("queuePrompt response:",p),p}function Oe(a){const n=document.createElement("canvas"),r=n.getContext("2d");if(n.width=512,n.height=512,r){r.fillStyle="#f8d7da",r.fillRect(0,0,n.width,n.height),r.strokeStyle="#dc3545",r.lineWidth=4,r.strokeRect(10,10,n.width-20,n.height-20),r.fillStyle="#dc3545",r.beginPath(),r.arc(n.width/2,150,50,0,2*Math.PI),r.fill(),r.fillStyle="white",r.font="bold 80px Arial",r.textAlign="center",r.textBaseline="middle",r.fillText("!",n.width/2,150),r.fillStyle="#721c24",r.font="20px Arial",r.textAlign="center",r.textBaseline="middle";const u=n.width-60,p=30,x=a.split(" ");let d="",h=250;for(let v=0;vu&&v>0?(r.fillText(d,n.width/2,h),d=x[v]+" ",h+=p):d=I}r.fillText(d,n.width/2,h)}return n.toDataURL("image/png")}async function dt(a){try{if(!a||a==="")return console.log("No prompt ID provided"),{1:[Oe("Fail to generate prompt ID")]};const n=await ot(a);if(!n||!n[a])return console.log("Not finished for prompt ID:",a),{};const r=n[a];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",a);const p=r.status.messages;if(p&&p.length>0){const x=p[p.length-1];if(x&&x.length>0){const d=x[0];return{1:[Oe(d)]}}}}const u={};if(r.outputs)for(const p in r.outputs){const x=r.outputs[p];if(x&&x.images){u[p]=[];for(const d of x.images)if(d&&d.filename&&d.type){const h=Z.graph._nodes_by_id[p].imgs[0].currentSrc.split("?")[0];u[p].push(h+"?filename="+encodeURIComponent(d.filename)+"&type="+encodeURIComponent(d.type)+(d.subfolder?"&subfolder="+encodeURIComponent(d.subfolder):""))}console.log("outputImages for nodeId:",p,u[p])}}return u}catch(n){throw console.error("Error getting output images from prompt:",n),n}}function ut(){const a=Object.values(Z.graph._nodes_by_id),n=[],r=[];for(const u of a)u.type==="SaveImage"?n.push(u.id):u.type==="PreviewImage"&&r.push(u.id);if(console.log("saveNodeIds:",n),console.log("previewNodeIds:",r),n.length===0&&r.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return n.length===1?n[0]:n.length==0&&r.length===1?r[0]:null}async function xt(a,n){const r=await dt(a);return Object.keys(r).length===0?null:r[n.toString()]&&r[n.toString()].length>0?r[n.toString()][0]:null}const mt=({selectedNodes:a,handleParamSelect:n,selectedParams:r,handleNext:u,handleClose:p})=>{const d=a.flatMap(h=>(h.widgets||[]).map(v=>v.name)).some(h=>r[h]===!0);return 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:p,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"})})})]}),a.map((h,v)=>{const I=h.title||"Unknown Node",S=h.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:I}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:S.map((k,E)=>{const R=k.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 ${r[R]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:$=>n(R,$),children:r[R]&&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:R})]},`widget-${E}`)})})})]},`node-${v}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:h=>u(h),disabled:!d,className:`px-3 py-1.5 text-xs ${d?"bg-pink-200 text-pink-700 hover:bg-pink-300":"bg-gray-200 text-gray-500 cursor-not-allowed"} rounded-md transition-colors`,children:"Next"})})]})},ht=({selectedNodes:a,paramTestValues:n,selectedParams:r,updateParamTestValues:u,toggleDropdown:p,openDropdowns:x,handleTestValueSelect:d,searchTerms:h,handleSearch:v,handleSelectAll:I,handleNext:S,handlePrevious:k,handleClose:E,inputValues:R,setInputValues:$,textInputs:G,handleTextInputChange:O,handleAddTextInput:T,handleRemoveTextInput:w,openAiWritingModal:W})=>{const D=(c,C,H,Q=0)=>{if(c=isNaN(c)?0:c,C=isNaN(C)?100:C,H=isNaN(H)||H<=0?1:H,C{!a||a.length===0||a.forEach(c=>{const C=c.id.toString(),H=c.widgets||{};Object.values(H).forEach(g=>{const M=g.name;if(!r[M])return;if(!(n[C]?.[M]?.length>0)&&g.type==="number"){const m=g.options?.min||0,z=g.options?.max||100;let L=(g.options?.step||10)/10;L<.1&&(L=.1);const P=g.options?.precision||0,A=D(m,z,L,P);if(A.length>0){u(C,M,A);const F=`${C}_${M}`;$(f=>({...f,[F]:{min:m.toString(),max:z.toString(),step:L.toString()}}))}}if(g.type==="customtext"||g.type.toLowerCase().includes("text")){const m=`${C}_${M}`,z=G[m]||[""];JSON.stringify(z)!==JSON.stringify(n[C]?.[M]||[""])&&u(C,M,z)}})})},[a,r,n,G,u,$,D]),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:E,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"})})})]}),a.length>0?a.map((c,C)=>{const H=c.widgets||{},Q=Object.values(H),g=c.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:[c.type," (ID: ",g,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:M=>E(M,C),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:Q.map((M,Y)=>{const m=M.name;if(!r[m])return null;const z=`${g}_${m}`;if(M.type==="customtext"||M.type.toLowerCase().includes("text")){const L=G[z]||[""];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:[m,":"]}),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:()=>W(g,m),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:L.map((P,A)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:`flex-1 border ${P?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:P,onChange:F=>O(g,m,A,F.target.value),required:!0}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>w(g,m,A),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"})})})]},A))}),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:()=>T(g,m),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"]})]},Y)}if(M.type==="number"){const L=M.options?.min||0,P=M.options?.max||100,A=(M.options?.step||10)/10,F=M.options?.precision||0,f=D(L,P,A,F),q=R[z]||{min:L.toString(),max:P.toString(),step:A.toString()};return 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:[m,":"]}),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:q.min,required:!0,onClick:N=>{N.preventDefault(),N.stopPropagation()},onChange:N=>{N.preventDefault(),N.stopPropagation();const _=N.target.value;if($(V=>({...V,[z]:{...V[z],min:_}})),_===""||!isNaN(parseFloat(_))){const V=_===""?0:parseFloat(_),K=parseFloat(q.max||P.toString()),B=parseFloat(q.step||A.toString()),J=D(V,K,B,F);u(g,m,J)}}}),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:q.max,onClick:N=>{N.preventDefault(),N.stopPropagation()},required:!0,onChange:N=>{N.preventDefault(),N.stopPropagation();const _=N.target.value;if($(V=>({...V,[z]:{...V[z],max:_}})),_===""||!isNaN(parseFloat(_))){const V=parseFloat(q.min||L.toString()),K=_===""?V:parseFloat(_),B=parseFloat(q.step||A.toString()),J=D(V,K,B,F);u(g,m,J)}}}),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:q.step,required:!0,onClick:N=>{N.preventDefault(),N.stopPropagation()},onChange:N=>{N.preventDefault(),N.stopPropagation();const _=N.target.value;if($(V=>({...V,[z]:{...V[z],step:_}})),_===""||!isNaN(parseFloat(_))&&parseFloat(_)>0){const V=parseFloat(q.min||L.toString()),K=parseFloat(q.max||P.toString());let B=_===""?1:parseFloat(_);B<.1&&(B=.1);const J=D(V,K,B,F);u(g,m,J)}}})]}),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:(()=>{const N=n[g]?.[m]||f;if(N.length<=10)return N.map((_,V)=>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:K=>{K.stopPropagation(),d(g,m,_,K)},children:[e.jsx("span",{children:_}),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"})})]},V));{const _=N.slice(0,5),V=N.slice(N.length-5);return e.jsxs(e.Fragment,{children:[_.map((K,B)=>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:J=>{J.stopPropagation(),d(g,m,K,J)},children:[e.jsx("span",{children:K}),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"})})]},`first-${B}`)),e.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),V.map((K,B)=>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:J=>{J.stopPropagation(),d(g,m,K,J)},children:[e.jsx("span",{children:K}),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"})})]},`last-${B}`))]})}})()})]}),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"})})]},Y)}else if(M.type==="combo"){const L=M.options?.values||[],P=`${g}_${m}`,A=f=>typeof f=="string"?f:f&&typeof f=="object"&&"name"in f?f.name:String(f),F=f=>typeof f=="object"&&f!==null&&"name"in f?f.name:f;return 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:m}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:`appearance-none border ${(n[g]?.[m]||[]).length===0?"border-red-500":"border-gray-300"} rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700`,onClick:f=>{f.preventDefault(),f.stopPropagation(),p(g,m,f)},"data-dropdown":P,children:[e.jsx("span",{children:(n[g]?.[m]||[]).length>0?`${m}: ${(n[g]?.[m]||[]).length} selected`:`Select ${m}`}),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"})})})]}),x[P]&&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 x[P]=="object"?`${x[P].y}px`:"0px",left:typeof x[P]=="object"?`${x[P].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:h[P]||"",onChange:f=>{f.preventDefault(),f.stopPropagation(),v(g,m,f.target.value)},onClick:f=>{f.preventDefault(),f.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:f=>{f.preventDefault(),f.stopPropagation();const N=L.filter(_=>!h[P]||A(_).toLowerCase().includes((h[P]||"").toLowerCase())).map(F);I(g,m,N)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${L.length>0&&(n[g]?.[m]||[]).length===L.length?"bg-blue-500 border-blue-500":(n[g]?.[m]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(n[g]?.[m]||[]).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:L.length>0&&(n[g]?.[m]||[]).length===L.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[L.filter(f=>!h[P]||A(f).toLowerCase().includes((h[P]||"").toLowerCase())).map((f,q)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:N=>{N.preventDefault(),N.stopPropagation(),d(g,m,F(f),N)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(n[g]?.[m]||[]).includes(F(f))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(n[g]?.[m]||[]).includes(F(f))&&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:A(f)})]},q)),L.filter(f=>!h[P]||A(f).toLowerCase().includes((h[P]||"").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"}),(n[g]?.[m]||[]).length===0&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(n[g]?.[m]||[]).map((f,q)=>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:f}),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:N=>{N.preventDefault(),N.stopPropagation(),d(g,m,f,N)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},q))})]})]},Y)}else return 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:m})}),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:[(n[g]?.[m]||[]).map((L,P)=>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:L}),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:A=>{A.preventDefault(),A.stopPropagation(),d(g,m,L,A)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},P)),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:L=>{L.preventDefault(),L.stopPropagation();const P=`${m}${(n[g]?.[m]||[]).length+1}`;u(g,m,[...n[g]?.[m]||[],P])},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"})]})]})]})]},Y)})})]},C)}):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:c=>k(c),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:c=>S(c),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},gt=({selectedNodes:a,paramTestValues:n,selectedParams:r,totalCount:u,errorMessage:p,handlePrevious:x,handleStartGeneration:d,handleClose:h})=>{const[v,I]=y.useState([]),[S,k]=y.useState(null),[E,R]=y.useState(!1);De();const $=()=>{const O=Object.values(Z.graph._nodes_by_id),T=[],w=[];for(const D of O)D.type==="SaveImage"?T.push(D.id):D.type==="PreviewImage"&&w.push(D.id);const W=[...T,...w];I(W),W.length===1?k(W[0]):W.length>1&&(R(!0),k(null))};y.useEffect(()=>{$()},[]),y.useEffect(()=>{const O=()=>{if(!Z.canvas.selected_nodes)return;const T=Object.values(Z.canvas.selected_nodes);if(T.length===0)return;const w=T[0];w&&(w.type==="SaveImage"||w.type==="PreviewImage")&&(console.log("Selected image node:",w.id),k(w.id))};return document.addEventListener("click",O),()=>{document.removeEventListener("click",O)}},[]);const G=O=>{if(O&&(O.preventDefault(),O.stopPropagation()),v.length>1&&!S){R(!0);return}d(O,S||void 0)};return 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 ",u," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:h,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&&v.length>1&&e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-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:S===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${v.join(",")}. Please click the node on canvas.`:`Current node ID is ${S}, please click Start Generation again`})]})}),p&&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:p})]})}),a.length>0?a.map((O,T)=>{const w=O.type||"Unknown Node",W=O.widgets||[],D=O.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:[w," (ID: ",D,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:W.map((c,C)=>{const H=c.name;if(!r[H])return null;const Q=n[D]?.[H]||[],g=Array.isArray(Q)?`[${Q.join(", ")}]`:JSON.stringify(Q);return e.jsxs("div",{className:CM.preventDefault()})})]},C)})})]},T)}):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:O=>x(O),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:O=>G(O),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${v.length>1&&!S?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:v.length>1&&!S,children:"Start Generation"})]})]})},pt=({selectedNodes:a,paramTestValues:n,selectedParams:r,totalCount:u,completedCount:p,errorMessage:x,handleClose:d,setIsProcessing:h,setCurrentScreen:v,cleanupPolling:I})=>{const S=k=>{k.preventDefault(),k.stopPropagation(),at({clear:!0}),lt(),I&&I(),h(!1),v(2)};return 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 ",p," of ",u," 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:`${p/u*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",p," images"]}),e.jsx("button",{onClick:S,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 ",u," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:d,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"})})})]}),x&&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:x})]})}),a.length>0?a.map((k,E)=>{const R=k.type||"Unknown Node",$=k.widgets||[],G=k.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:[R," (ID: ",G,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:$.map((O,T)=>{const w=O.name;if(!r[w])return null;const W=n[G]?.[w]||[],D=Array.isArray(W)?`[${W.join(", ")}]`:JSON.stringify(W);return e.jsxs("div",{className:T<$.length-1?"flex justify-between items-center border-b pb-2":"flex justify-between items-center",children:[e.jsx("label",{className:"font-medium text-gray-700",children:w}),e.jsx("div",{className:"flex space-x-2 items-center",children:e.jsx("input",{type:"text",className:"w-64 h-7 border border-gray-300 rounded text-sm px-2 bg-gray-50 cursor-not-allowed text-gray-500",readOnly:!0,disabled:!0,value:D,onClick:c=>c.preventDefault()})})]},T)})})]},E)}):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."})]})},ft=({generatedImages:a,selectedImageIndex:n,handleSelectImage:r,handleApplySelected:u,handlePrevious:p,handleClose:x,currentPage:d,handlePageChange:h,imagesPerPage:v,notificationVisible:I,modalVisible:S,modalImageUrl:k,openImageModal:E,closeImageModal:R})=>{const $=Math.ceil(a.length/v),G=(d-1)*v,O=Math.min(G+v,a.length),T=a.slice(G,O);return 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 ",a.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:x,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"})})})]}),I&&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."})]})}),S&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50",onClick:R,children:e.jsxs("div",{className:"bg-white rounded-lg p-2 max-w-4xl max-h-[90vh] relative",onClick:w=>w.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:R,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:k,alt:"Enlarged image",className:"max-w-full object-contain w-auto h-auto"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:T.map((w,W)=>{const D=G+W;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${n===D?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:c=>r(D,c),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:c=>E(w.url,c),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:w.url,alt:`Generated image ${D+1}`,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(w.params).filter(([c,C])=>c!=="nodeParams"&&typeof C!="object").map(([c,C])=>e.jsxs("div",{children:[c,": ",String(C)]},c))})]},D)})}),$>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:w=>h(1,w),disabled:d===1,className:`px-2 py-1 rounded ${d===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:w=>h(d-1,w),disabled:d===1,className:`px-2 py-1 rounded ${d===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 ",d," of ",$]}),e.jsx("button",{onClick:w=>h(d+1,w),disabled:d===$,className:`px-2 py-1 rounded ${d===$?"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:w=>h($,w),disabled:d===$,className:`px-2 py-1 rounded ${d===$?"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:w=>p(w),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:w=>u(w),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:n===null,children:"Apply Selected"})]})]})},bt=({visible:a,aiWritingModalText:n,setAiWritingModalText:r,aiGeneratedTexts:u,aiSelectedTexts:p,aiWritingLoading:x,aiWritingError:d,handleAiWriting:h,toggleTextSelection:v,addSelectedTexts:I,onClose:S})=>a?e.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:S,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 overflow-y-auto flex-1",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-white +import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as y}from"./vendor-react-V04_Axys.js";import{r as nt,g as ot,m as at,i as lt}from"./workflowChat-CjDaET6O.js";import{a as Z,u as De,g as ke,W as ue}from"./message-components-DHkIj9qD.js";import"./input.js";/* empty css */function it(a,n){try{if(!a)return console.error("Invalid prompt_output: ",a),a;for(const r of n){if(!a[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!a[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}a[r.nodeId].inputs[r.paramName]=r.paramValue}return a}catch(r){return console.error("Error updating prompt:",r),a}}async function ct(a){const n=await Z.graphToPrompt(),r=it(n.output,a);console.log("queuePrompt updated_prompt:",r);const u={prompt:r,client_id:Z.api.clientId,extra_data:{extra_pageinfo:{workflow:n.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const p=await nt(u);return console.debug("queuePrompt response:",p),p}function Oe(a){const n=document.createElement("canvas"),r=n.getContext("2d");if(n.width=512,n.height=512,r){r.fillStyle="#f8d7da",r.fillRect(0,0,n.width,n.height),r.strokeStyle="#dc3545",r.lineWidth=4,r.strokeRect(10,10,n.width-20,n.height-20),r.fillStyle="#dc3545",r.beginPath(),r.arc(n.width/2,150,50,0,2*Math.PI),r.fill(),r.fillStyle="white",r.font="bold 80px Arial",r.textAlign="center",r.textBaseline="middle",r.fillText("!",n.width/2,150),r.fillStyle="#721c24",r.font="20px Arial",r.textAlign="center",r.textBaseline="middle";const u=n.width-60,p=30,x=a.split(" ");let d="",h=250;for(let v=0;vu&&v>0?(r.fillText(d,n.width/2,h),d=x[v]+" ",h+=p):d=I}r.fillText(d,n.width/2,h)}return n.toDataURL("image/png")}async function dt(a){try{if(!a||a==="")return console.log("No prompt ID provided"),{1:[Oe("Fail to generate prompt ID")]};const n=await ot(a);if(!n||!n[a])return console.log("Not finished for prompt ID:",a),{};const r=n[a];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",a);const p=r.status.messages;if(p&&p.length>0){const x=p[p.length-1];if(x&&x.length>0){const d=x[0];return{1:[Oe(d)]}}}}const u={};if(r.outputs)for(const p in r.outputs){const x=r.outputs[p];if(x&&x.images){u[p]=[];for(const d of x.images)if(d&&d.filename&&d.type){const h=Z.graph._nodes_by_id[p].imgs[0].currentSrc.split("?")[0];u[p].push(h+"?filename="+encodeURIComponent(d.filename)+"&type="+encodeURIComponent(d.type)+(d.subfolder?"&subfolder="+encodeURIComponent(d.subfolder):""))}console.log("outputImages for nodeId:",p,u[p])}}return u}catch(n){throw console.error("Error getting output images from prompt:",n),n}}function ut(){const a=Object.values(Z.graph._nodes_by_id),n=[],r=[];for(const u of a)u.type==="SaveImage"?n.push(u.id):u.type==="PreviewImage"&&r.push(u.id);if(console.log("saveNodeIds:",n),console.log("previewNodeIds:",r),n.length===0&&r.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return n.length===1?n[0]:n.length==0&&r.length===1?r[0]:null}async function xt(a,n){const r=await dt(a);return Object.keys(r).length===0?null:r[n.toString()]&&r[n.toString()].length>0?r[n.toString()][0]:null}const mt=({selectedNodes:a,handleParamSelect:n,selectedParams:r,handleNext:u,handleClose:p})=>{const d=a.flatMap(h=>(h.widgets||[]).map(v=>v.name)).some(h=>r[h]===!0);return 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:p,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"})})})]}),a.map((h,v)=>{const I=h.title||"Unknown Node",S=h.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:I}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:S.map((k,E)=>{const R=k.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 ${r[R]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:$=>n(R,$),children:r[R]&&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:R})]},`widget-${E}`)})})})]},`node-${v}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:h=>u(h),disabled:!d,className:`px-3 py-1.5 text-xs ${d?"bg-pink-200 text-pink-700 hover:bg-pink-300":"bg-gray-200 text-gray-500 cursor-not-allowed"} rounded-md transition-colors`,children:"Next"})})]})},ht=({selectedNodes:a,paramTestValues:n,selectedParams:r,updateParamTestValues:u,toggleDropdown:p,openDropdowns:x,handleTestValueSelect:d,searchTerms:h,handleSearch:v,handleSelectAll:I,handleNext:S,handlePrevious:k,handleClose:E,inputValues:R,setInputValues:$,textInputs:G,handleTextInputChange:O,handleAddTextInput:T,handleRemoveTextInput:w,openAiWritingModal:W})=>{const D=(c,C,H,Q=0)=>{if(c=isNaN(c)?0:c,C=isNaN(C)?100:C,H=isNaN(H)||H<=0?1:H,C{!a||a.length===0||a.forEach(c=>{const C=c.id.toString(),H=c.widgets||{};Object.values(H).forEach(g=>{const M=g.name;if(!r[M])return;if(!(n[C]?.[M]?.length>0)&&g.type==="number"){const m=g.options?.min||0,z=g.options?.max||100;let L=(g.options?.step||10)/10;L<.1&&(L=.1);const P=g.options?.precision||0,A=D(m,z,L,P);if(A.length>0){u(C,M,A);const F=`${C}_${M}`;$(f=>({...f,[F]:{min:m.toString(),max:z.toString(),step:L.toString()}}))}}if(g.type==="customtext"||g.type.toLowerCase().includes("text")){const m=`${C}_${M}`,z=G[m]||[""];JSON.stringify(z)!==JSON.stringify(n[C]?.[M]||[""])&&u(C,M,z)}})})},[a,r,n,G,u,$,D]),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:E,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"})})})]}),a.length>0?a.map((c,C)=>{const H=c.widgets||{},Q=Object.values(H),g=c.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:[c.type," (ID: ",g,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:M=>E(M,C),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:Q.map((M,Y)=>{const m=M.name;if(!r[m])return null;const z=`${g}_${m}`;if(M.type==="customtext"||M.type.toLowerCase().includes("text")){const L=G[z]||[""];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:[m,":"]}),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:()=>W(g,m),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:L.map((P,A)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:`flex-1 border ${P?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:P,onChange:F=>O(g,m,A,F.target.value),required:!0}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>w(g,m,A),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"})})})]},A))}),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:()=>T(g,m),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"]})]},Y)}if(M.type==="number"){const L=M.options?.min||0,P=M.options?.max||100,A=(M.options?.step||10)/10,F=M.options?.precision||0,f=D(L,P,A,F),q=R[z]||{min:L.toString(),max:P.toString(),step:A.toString()};return 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:[m,":"]}),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:q.min,required:!0,onClick:N=>{N.preventDefault(),N.stopPropagation()},onChange:N=>{N.preventDefault(),N.stopPropagation();const _=N.target.value;if($(V=>({...V,[z]:{...V[z],min:_}})),_===""||!isNaN(parseFloat(_))){const V=_===""?0:parseFloat(_),K=parseFloat(q.max||P.toString()),B=parseFloat(q.step||A.toString()),J=D(V,K,B,F);u(g,m,J)}}}),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:q.max,onClick:N=>{N.preventDefault(),N.stopPropagation()},required:!0,onChange:N=>{N.preventDefault(),N.stopPropagation();const _=N.target.value;if($(V=>({...V,[z]:{...V[z],max:_}})),_===""||!isNaN(parseFloat(_))){const V=parseFloat(q.min||L.toString()),K=_===""?V:parseFloat(_),B=parseFloat(q.step||A.toString()),J=D(V,K,B,F);u(g,m,J)}}}),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:q.step,required:!0,onClick:N=>{N.preventDefault(),N.stopPropagation()},onChange:N=>{N.preventDefault(),N.stopPropagation();const _=N.target.value;if($(V=>({...V,[z]:{...V[z],step:_}})),_===""||!isNaN(parseFloat(_))&&parseFloat(_)>0){const V=parseFloat(q.min||L.toString()),K=parseFloat(q.max||P.toString());let B=_===""?1:parseFloat(_);B<.1&&(B=.1);const J=D(V,K,B,F);u(g,m,J)}}})]}),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:(()=>{const N=n[g]?.[m]||f;if(N.length<=10)return N.map((_,V)=>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:K=>{K.stopPropagation(),d(g,m,_,K)},children:[e.jsx("span",{children:_}),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"})})]},V));{const _=N.slice(0,5),V=N.slice(N.length-5);return e.jsxs(e.Fragment,{children:[_.map((K,B)=>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:J=>{J.stopPropagation(),d(g,m,K,J)},children:[e.jsx("span",{children:K}),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"})})]},`first-${B}`)),e.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),V.map((K,B)=>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:J=>{J.stopPropagation(),d(g,m,K,J)},children:[e.jsx("span",{children:K}),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"})})]},`last-${B}`))]})}})()})]}),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"})})]},Y)}else if(M.type==="combo"){const L=M.options?.values||[],P=`${g}_${m}`,A=f=>typeof f=="string"?f:f&&typeof f=="object"&&"name"in f?f.name:String(f),F=f=>typeof f=="object"&&f!==null&&"name"in f?f.name:f;return 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:m}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:`appearance-none border ${(n[g]?.[m]||[]).length===0?"border-red-500":"border-gray-300"} rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700`,onClick:f=>{f.preventDefault(),f.stopPropagation(),p(g,m,f)},"data-dropdown":P,children:[e.jsx("span",{children:(n[g]?.[m]||[]).length>0?`${m}: ${(n[g]?.[m]||[]).length} selected`:`Select ${m}`}),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"})})})]}),x[P]&&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 x[P]=="object"?`${x[P].y}px`:"0px",left:typeof x[P]=="object"?`${x[P].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:h[P]||"",onChange:f=>{f.preventDefault(),f.stopPropagation(),v(g,m,f.target.value)},onClick:f=>{f.preventDefault(),f.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:f=>{f.preventDefault(),f.stopPropagation();const N=L.filter(_=>!h[P]||A(_).toLowerCase().includes((h[P]||"").toLowerCase())).map(F);I(g,m,N)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${L.length>0&&(n[g]?.[m]||[]).length===L.length?"bg-blue-500 border-blue-500":(n[g]?.[m]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(n[g]?.[m]||[]).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:L.length>0&&(n[g]?.[m]||[]).length===L.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[L.filter(f=>!h[P]||A(f).toLowerCase().includes((h[P]||"").toLowerCase())).map((f,q)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:N=>{N.preventDefault(),N.stopPropagation(),d(g,m,F(f),N)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(n[g]?.[m]||[]).includes(F(f))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(n[g]?.[m]||[]).includes(F(f))&&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:A(f)})]},q)),L.filter(f=>!h[P]||A(f).toLowerCase().includes((h[P]||"").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"}),(n[g]?.[m]||[]).length===0&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(n[g]?.[m]||[]).map((f,q)=>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:f}),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:N=>{N.preventDefault(),N.stopPropagation(),d(g,m,f,N)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},q))})]})]},Y)}else return 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:m})}),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:[(n[g]?.[m]||[]).map((L,P)=>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:L}),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:A=>{A.preventDefault(),A.stopPropagation(),d(g,m,L,A)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},P)),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:L=>{L.preventDefault(),L.stopPropagation();const P=`${m}${(n[g]?.[m]||[]).length+1}`;u(g,m,[...n[g]?.[m]||[],P])},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"})]})]})]})]},Y)})})]},C)}):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:c=>k(c),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:c=>S(c),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},gt=({selectedNodes:a,paramTestValues:n,selectedParams:r,totalCount:u,errorMessage:p,handlePrevious:x,handleStartGeneration:d,handleClose:h})=>{const[v,I]=y.useState([]),[S,k]=y.useState(null),[E,R]=y.useState(!1);De();const $=()=>{const O=Object.values(Z.graph._nodes_by_id),T=[],w=[];for(const D of O)D.type==="SaveImage"?T.push(D.id):D.type==="PreviewImage"&&w.push(D.id);const W=[...T,...w];I(W),W.length===1?k(W[0]):W.length>1&&(R(!0),k(null))};y.useEffect(()=>{$()},[]),y.useEffect(()=>{const O=()=>{if(!Z.canvas.selected_nodes)return;const T=Object.values(Z.canvas.selected_nodes);if(T.length===0)return;const w=T[0];w&&(w.type==="SaveImage"||w.type==="PreviewImage")&&(console.log("Selected image node:",w.id),k(w.id))};return document.addEventListener("click",O),()=>{document.removeEventListener("click",O)}},[]);const G=O=>{if(O&&(O.preventDefault(),O.stopPropagation()),v.length>1&&!S){R(!0);return}d(O,S||void 0)};return 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 ",u," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:h,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&&v.length>1&&e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-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:S===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${v.join(",")}. Please click the node on canvas.`:`Current node ID is ${S}, please click Start Generation again`})]})}),p&&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:p})]})}),a.length>0?a.map((O,T)=>{const w=O.type||"Unknown Node",W=O.widgets||[],D=O.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:[w," (ID: ",D,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:W.map((c,C)=>{const H=c.name;if(!r[H])return null;const Q=n[D]?.[H]||[],g=Array.isArray(Q)?`[${Q.join(", ")}]`:JSON.stringify(Q);return e.jsxs("div",{className:CM.preventDefault()})})]},C)})})]},T)}):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:O=>x(O),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:O=>G(O),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${v.length>1&&!S?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:v.length>1&&!S,children:"Start Generation"})]})]})},pt=({selectedNodes:a,paramTestValues:n,selectedParams:r,totalCount:u,completedCount:p,errorMessage:x,handleClose:d,setIsProcessing:h,setCurrentScreen:v,cleanupPolling:I})=>{const S=k=>{k.preventDefault(),k.stopPropagation(),at({clear:!0}),lt(),I&&I(),h(!1),v(2)};return 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 ",p," of ",u," 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:`${p/u*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",p," images"]}),e.jsx("button",{onClick:S,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 ",u," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:d,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"})})})]}),x&&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:x})]})}),a.length>0?a.map((k,E)=>{const R=k.type||"Unknown Node",$=k.widgets||[],G=k.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:[R," (ID: ",G,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:$.map((O,T)=>{const w=O.name;if(!r[w])return null;const W=n[G]?.[w]||[],D=Array.isArray(W)?`[${W.join(", ")}]`:JSON.stringify(W);return e.jsxs("div",{className:T<$.length-1?"flex justify-between items-center border-b pb-2":"flex justify-between items-center",children:[e.jsx("label",{className:"font-medium text-gray-700",children:w}),e.jsx("div",{className:"flex space-x-2 items-center",children:e.jsx("input",{type:"text",className:"w-64 h-7 border border-gray-300 rounded text-sm px-2 bg-gray-50 cursor-not-allowed text-gray-500",readOnly:!0,disabled:!0,value:D,onClick:c=>c.preventDefault()})})]},T)})})]},E)}):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."})]})},ft=({generatedImages:a,selectedImageIndex:n,handleSelectImage:r,handleApplySelected:u,handlePrevious:p,handleClose:x,currentPage:d,handlePageChange:h,imagesPerPage:v,notificationVisible:I,modalVisible:S,modalImageUrl:k,openImageModal:E,closeImageModal:R})=>{const $=Math.ceil(a.length/v),G=(d-1)*v,O=Math.min(G+v,a.length),T=a.slice(G,O);return 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 ",a.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:x,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"})})})]}),I&&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."})]})}),S&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50",onClick:R,children:e.jsxs("div",{className:"bg-white rounded-lg p-2 max-w-4xl max-h-[90vh] relative",onClick:w=>w.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:R,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:k,alt:"Enlarged image",className:"max-w-full object-contain w-auto h-auto"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:T.map((w,W)=>{const D=G+W;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${n===D?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:c=>r(D,c),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:c=>E(w.url,c),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:w.url,alt:`Generated image ${D+1}`,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(w.params).filter(([c,C])=>c!=="nodeParams"&&typeof C!="object").map(([c,C])=>e.jsxs("div",{children:[c,": ",String(C)]},c))})]},D)})}),$>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:w=>h(1,w),disabled:d===1,className:`px-2 py-1 rounded ${d===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:w=>h(d-1,w),disabled:d===1,className:`px-2 py-1 rounded ${d===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 ",d," of ",$]}),e.jsx("button",{onClick:w=>h(d+1,w),disabled:d===$,className:`px-2 py-1 rounded ${d===$?"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:w=>h($,w),disabled:d===$,className:`px-2 py-1 rounded ${d===$?"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:w=>p(w),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:w=>u(w),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:n===null,children:"Apply Selected"})]})]})},bt=({visible:a,aiWritingModalText:n,setAiWritingModalText:r,aiGeneratedTexts:u,aiSelectedTexts:p,aiWritingLoading:x,aiWritingError:d,handleAiWriting:h,toggleTextSelection:v,addSelectedTexts:I,onClose:S})=>a?e.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:S,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 overflow-y-auto flex-1",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-white bg-gray-50 dark:bg-gray-700 placeholder-gray-500 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-400 diff --git a/dist/copilot_web/WorkflowOption-Bee-YmQA.js b/dist/copilot_web/WorkflowOption-Bee-YmQA.js new file mode 100644 index 0000000..34bdce0 --- /dev/null +++ b/dist/copilot_web/WorkflowOption-Bee-YmQA.js @@ -0,0 +1 @@ +import{j as t}from"./vendor-markdown-Dek94WS0.js";import{W as p,g as u,a as d}from"./message-components-DHkIj9qD.js";import{r as N}from"./vendor-react-V04_Axys.js";function O({content:v,name:C="Assistant",avatar:_,latestInput:y,installedNodes:k,onAddMessage:g}){const h=JSON.parse(v),w=h.ext?.find(e=>e.type==="workflow")?.data||[],[i,c]=N.useState({}),b=async e=>{if(!e.id){console.error("No workflow id provided");return}const r=String(e.id);if(!i[r]){c(o=>({...o,[r]:!0})),p.trackEvent({event_type:"workflow_accept",message_type:"workflow",message_id:h.message_id,data:{workflow_id:e.id,workflow_name:e.name}});try{const o=await p.getOptimizedWorkflow(e.id,y);if(o.workflow){const a=new Set;if(o.workflow.nodes)for(const s of o.workflow.nodes)a.add(s.type);else for(const s of Object.values(o.workflow))a.add(s.class_type);const n=Array.from(a).filter(s=>!k.includes(s));if(console.log("[WorkflowOption] Missing node types:",n),n.length>0){try{console.log("[WorkflowOption] Fetching info for missing nodes");const s=await p.batchGetNodeInfo(n);console.log("[WorkflowOption] Received node infos:",s);const m={text:"",ext:[{type:"node_install_guide",data:s.map(l=>({name:l.name,repository_url:l.github_url}))}]},f={id:u(),role:"ai",content:JSON.stringify(m),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:o.workflow,optimizedParams:o.optimized_params}};g?.(f)}catch(s){console.error("[WorkflowOption] Error fetching node info:",s),alert("Error checking required nodes. Please try again.")}finally{c(s=>({...s,[r]:!1}))}return}j(o.workflow,o.optimized_params)}}catch(o){console.error("Failed to optimize workflow:",o),alert("Failed to optimize workflow. Please try again.")}finally{c(o=>({...o,[r]:!1}))}}},j=(e,r)=>{e.nodes?d.loadGraphData(e):d.loadApiJson(e);for(const[a,n,s,m,f]of r){const l=d.graph._nodes_by_id[a].widgets;for(const x of l)x.name===m&&(x.value=f)}d.graph.setDirtyCanvas(!1,!0);const o={id:u(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};g?.(o)};return t.jsx("div",{className:"space-y-3",children:w.length>0&&t.jsx("div",{className:"flex flex-col space-y-4",children:w.map((e,r)=>{const o=e.id?String(e.id):"";return t.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&t.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:a=>{const n=a.target;n.onerror=null,n.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),t.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[t.jsx("div",{children:t.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),t.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&t.jsxs("div",{className:"relative group",children:[t.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),t.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:t.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),t.jsx("button",{onClick:()=>b(e),disabled:i[o],className:`px-3 py-1.5 ${i[o]?"bg-gray-400 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600"} text-white rounded-md transition-colors text-xs`,children:i[o]?"Loading...":"Accept"})]})]})]},r)})})})}export{O as WorkflowOption}; diff --git a/dist/copilot_web/WorkflowOption-C7lWPQXP.js b/dist/copilot_web/WorkflowOption-C7lWPQXP.js deleted file mode 100644 index f27e4d0..0000000 --- a/dist/copilot_web/WorkflowOption-C7lWPQXP.js +++ /dev/null @@ -1 +0,0 @@ -import{j as t}from"./vendor-markdown-Dek94WS0.js";import{W as f,g as u,a as p}from"./message-components-DoI1VVaz.js";import{r as N}from"./vendor-react-V04_Axys.js";function z({content:v,name:C="Assistant",avatar:_,latestInput:y,installedNodes:k,onAddMessage:g}){const h=JSON.parse(v),w=h.ext?.find(e=>e.type==="workflow")?.data||[],[i,d]=N.useState({}),b=async e=>{if(!e.id){console.error("No workflow id provided");return}const r=String(e.id);if(!i[r]){d(o=>({...o,[r]:!0})),f.trackEvent({event_type:"workflow_accept",message_type:"workflow",message_id:h.message_id,data:{workflow_id:e.id,workflow_name:e.name}});try{const o=await f.getOptimizedWorkflow(e.id,y);if(o.workflow){const n=new Set;for(const s of o.workflow.nodes)n.add(s.type);const a=Array.from(n).filter(s=>!k.includes(s));if(console.log("[WorkflowOption] Missing node types:",a),a.length>0){try{console.log("[WorkflowOption] Fetching info for missing nodes");const s=await f.batchGetNodeInfo(a);console.log("[WorkflowOption] Received node infos:",s);const c={text:"",ext:[{type:"node_install_guide",data:s.map(l=>({name:l.name,repository_url:l.github_url}))}]},m={id:u(),role:"ai",content:JSON.stringify(c),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:o.workflow,optimizedParams:o.optimized_params}};g?.(m)}catch(s){console.error("[WorkflowOption] Error fetching node info:",s),alert("Error checking required nodes. Please try again.")}finally{d(s=>({...s,[r]:!1}))}return}j(o.workflow,o.optimized_params)}}catch(o){console.error("Failed to optimize workflow:",o),alert("Failed to optimize workflow. Please try again.")}finally{d(o=>({...o,[r]:!1}))}}},j=(e,r)=>{p.loadGraphData(e);for(const[n,a,s,c,m]of r){const l=p.graph._nodes_by_id[n].widgets;for(const x of l)x.name===c&&(x.value=m)}p.graph.setDirtyCanvas(!1,!0);const o={id:u(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};g?.(o)};return t.jsx("div",{className:"space-y-3",children:w.length>0&&t.jsx("div",{className:"flex flex-col space-y-4",children:w.map((e,r)=>{const o=e.id?String(e.id):"";return t.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&t.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:n=>{const a=n.target;a.onerror=null,a.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),t.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[t.jsx("div",{children:t.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),t.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&t.jsxs("div",{className:"relative group",children:[t.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),t.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:t.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),t.jsx("button",{onClick:()=>b(e),disabled:i[o],className:`px-3 py-1.5 ${i[o]?"bg-gray-400 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600"} text-white rounded-md transition-colors text-xs`,children:i[o]?"Loading...":"Accept"})]})]})]},r)})})})}export{z as WorkflowOption}; diff --git a/dist/copilot_web/input.js b/dist/copilot_web/input.js index 2472e29..8acd2f2 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-CGsjxi5y.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-DoI1VVaz.js","copilot_web/fonts.css"])))=>i.map(i=>d[i]); -import{j as s}from"./vendor-markdown-Dek94WS0.js";import{a as w,R as p,r as x}from"./vendor-react-V04_Axys.js";import{w as v,a as g}from"./message-components-DoI1VVaz.js";/* empty css */const R="modulepreload",b=function(e){return"/"+e},m={},C=function(c,a,P){let d=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(a.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const i=o.endsWith(".css"),h=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=i?"stylesheet":R,i||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),i)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function u(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"&&u(t.reason);return c().catch(u)})};var l={},f=w;l.createRoot=f.createRoot,l.hydrateRoot=f.hydrateRoot;const S=p.lazy(()=>C(async()=>{const{default:e}=await import("./App-CGsjxi5y.js");return{default:e}},__vite__mapDeps([0,1,2,3,4])).then(({default:e})=>({default:e})));function j(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}j().then(()=>v()).then(()=>{g.extensionManager.registerSidebarTab({id:"comfyui-copilot",icon:"cc-icon-logo",title:"ComfyUI Copilot",tooltip:"ComfyUI Copilot",type:"custom",render:e=>{const c=document.createElement("div");c.id="comfyui-copilot-plugin",c.className="h-full w-full flex flex-col",e.style.height="100%",e.appendChild(c),l.createRoot(c).render(s.jsx(p.StrictMode,{children:s.jsx(x.Suspense,{fallback:s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:s.jsx(S,{})})}))}})});export{C as _}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-Dp5pJunx.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-DHkIj9qD.js","copilot_web/fonts.css"])))=>i.map(i=>d[i]); +import{j as s}from"./vendor-markdown-Dek94WS0.js";import{a as w,R as p,r as x}from"./vendor-react-V04_Axys.js";import{w as v,a as g}from"./message-components-DHkIj9qD.js";/* empty css */const R="modulepreload",b=function(e){return"/"+e},m={},C=function(c,a,P){let d=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(a.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const i=o.endsWith(".css"),h=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=i?"stylesheet":R,i||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),i)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function u(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"&&u(t.reason);return c().catch(u)})};var l={},f=w;l.createRoot=f.createRoot,l.hydrateRoot=f.hydrateRoot;const S=p.lazy(()=>C(async()=>{const{default:e}=await import("./App-Dp5pJunx.js");return{default:e}},__vite__mapDeps([0,1,2,3,4])).then(({default:e})=>({default:e})));function j(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}j().then(()=>v()).then(()=>{g.extensionManager.registerSidebarTab({id:"comfyui-copilot",icon:"cc-icon-logo",title:"ComfyUI Copilot",tooltip:"ComfyUI Copilot",type:"custom",render:e=>{const c=document.createElement("div");c.id="comfyui-copilot-plugin",c.className="h-full w-full flex flex-col",e.style.height="100%",e.appendChild(c),l.createRoot(c).render(s.jsx(p.StrictMode,{children:s.jsx(x.Suspense,{fallback:s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:s.jsx(S,{})})}))}})});export{C as _}; diff --git a/dist/copilot_web/message-components-DoI1VVaz.js b/dist/copilot_web/message-components-DHkIj9qD.js similarity index 99% rename from dist/copilot_web/message-components-DoI1VVaz.js rename to dist/copilot_web/message-components-DHkIj9qD.js index 1cb2b43..0e21096 100644 --- a/dist/copilot_web/message-components-DoI1VVaz.js +++ b/dist/copilot_web/message-components-DHkIj9qD.js @@ -1,4 +1,4 @@ -import{r as He,R as eI}from"./vendor-react-V04_Axys.js";import{j as S,M as tI,r as rI,a as iI,b as nI,c as aI}from"./vendor-markdown-Dek94WS0.js";let Mt=null;const mp=location.pathname.split("/").slice(0,-1).join("/");let oI=null;async function Mpe(){try{await Promise.all([import(mp+"/scripts/api.js").then(i=>{oI=i?.api}),import(mp+"/scripts/app.js").then(i=>{Mt=i?.app})])}catch(i){console.error("waitForApp error",i)}}const W$={messages:[],selectedNode:null,installedNodes:[],loading:!1,sessionId:null,showChat:!1,activeTab:"chat",screenState:null};function sI(i,r){switch(r.type){case"SET_MESSAGES":return{...i,messages:r.payload};case"ADD_MESSAGE":return{...i,messages:[...i.messages,r.payload]};case"UPDATE_MESSAGE":return{...i,messages:i.messages.map(e=>e.id===r.payload.id&&!e.finished?r.payload:e)};case"SET_SELECTED_NODE":return{...i,selectedNode:r.payload};case"SET_INSTALLED_NODES":return{...i,installedNodes:r.payload};case"SET_LOADING":return{...i,loading:r.payload};case"SET_SESSION_ID":return{...i,sessionId:r.payload};case"SET_SHOW_CHAT":return{...i,showChat:r.payload};case"SET_ACTIVE_TAB":return{...i,activeTab:r.payload};case"SET_SCREEN_STATE":return{...i,screenState:r.payload};case"CLEAR_MESSAGES":return{...i,messages:[]};default:return i}}const U$=He.createContext({state:W$,dispatch:()=>null});function Bpe({children:i}){const[r,e]=He.useReducer(sI,W$);return eI.useEffect(()=>{r.sessionId&&r.messages.length>0&&localStorage.setItem(`messages_${r.sessionId}`,JSON.stringify(r.messages))},[r.messages,r.sessionId]),S.jsx(U$.Provider,{value:{state:r,dispatch:e},children:i})}function uI(){const i=He.useContext(U$);if(!i)throw new Error("useChatContext must be used within a ChatProvider");return i}const Ff={apiBaseUrl:"https://comfyui-copilot-server.onrender.com"};function Sr(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const r=Math.random()*16|0;return(i==="x"?r:r&3|8).toString(16)})}var lI="0123456789abcdefghijklmnopqrstuvwxyz";function Or(i){return lI.charAt(i)}function hI(i,r){return i&r}function ys(i,r){return i|r}function bp(i,r){return i^r}function $p(i,r){return i&~r}function cI(i){if(i==0)return-1;var r=0;return i&65535||(i>>=16,r+=16),i&255||(i>>=8,r+=8),i&15||(i>>=4,r+=4),i&3||(i>>=2,r+=2),i&1||++r,r}function dI(i){for(var r=0;i!=0;)i&=i-1,++r;return r}var Pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K$="=";function Iu(i){var r,e,t="";for(r=0;r+3<=i.length;r+=3)e=parseInt(i.substring(r,r+3),16),t+=Pn.charAt(e>>6)+Pn.charAt(e&63);for(r+1==i.length?(e=parseInt(i.substring(r,r+1),16),t+=Pn.charAt(e<<2)):r+2==i.length&&(e=parseInt(i.substring(r,r+2),16),t+=Pn.charAt(e>>2)+Pn.charAt((e&3)<<4));(t.length&3)>0;)t+=K$;return t}function wp(i){var r="",e,t=0,n=0;for(e=0;e>2),n=a&3,t=1):t==1?(r+=Or(n<<2|a>>4),n=a&15,t=2):t==2?(r+=Or(n),r+=Or(a>>2),n=a&3,t=3):(r+=Or(n<<2|a>>4),r+=Or(a&15),t=0))}return t==1&&(r+=Or(n<<2)),r}var pn,fI={decode:function(i){var r;if(pn===void 0){var e="0123456789ABCDEF",t=` \f +import{r as He,R as eI}from"./vendor-react-V04_Axys.js";import{j as S,M as tI,r as rI,a as iI,b as nI,c as aI}from"./vendor-markdown-Dek94WS0.js";let Mt=null;const mp=location.pathname.split("/").slice(0,-1).join("/");let oI=null;async function Mpe(){try{await Promise.all([import(mp+"/scripts/api.js").then(i=>{oI=i?.api}),import(mp+"/scripts/app.js").then(i=>{Mt=i?.app})])}catch(i){console.error("waitForApp error",i)}}const W$={messages:[],selectedNode:null,installedNodes:[],loading:!1,sessionId:null,showChat:!1,activeTab:"chat",screenState:null};function sI(i,r){switch(r.type){case"SET_MESSAGES":return{...i,messages:r.payload};case"ADD_MESSAGE":return{...i,messages:[...i.messages,r.payload]};case"UPDATE_MESSAGE":return{...i,messages:i.messages.map(e=>e.id===r.payload.id&&!e.finished?r.payload:e)};case"SET_SELECTED_NODE":return{...i,selectedNode:r.payload};case"SET_INSTALLED_NODES":return{...i,installedNodes:r.payload};case"SET_LOADING":return{...i,loading:r.payload};case"SET_SESSION_ID":return{...i,sessionId:r.payload};case"SET_SHOW_CHAT":return{...i,showChat:r.payload};case"SET_ACTIVE_TAB":return{...i,activeTab:r.payload};case"SET_SCREEN_STATE":return{...i,screenState:r.payload};case"CLEAR_MESSAGES":return{...i,messages:[]};default:return i}}const U$=He.createContext({state:W$,dispatch:()=>null});function Bpe({children:i}){const[r,e]=He.useReducer(sI,W$);return eI.useEffect(()=>{r.sessionId&&r.messages.length>0&&localStorage.setItem(`messages_${r.sessionId}`,JSON.stringify(r.messages))},[r.messages,r.sessionId]),S.jsx(U$.Provider,{value:{state:r,dispatch:e},children:i})}function uI(){const i=He.useContext(U$);if(!i)throw new Error("useChatContext must be used within a ChatProvider");return i}const Ff={apiBaseUrl:"https://comfyui-copilot-server-pre.onrender.com"};function Sr(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const r=Math.random()*16|0;return(i==="x"?r:r&3|8).toString(16)})}var lI="0123456789abcdefghijklmnopqrstuvwxyz";function Or(i){return lI.charAt(i)}function hI(i,r){return i&r}function ys(i,r){return i|r}function bp(i,r){return i^r}function $p(i,r){return i&~r}function cI(i){if(i==0)return-1;var r=0;return i&65535||(i>>=16,r+=16),i&255||(i>>=8,r+=8),i&15||(i>>=4,r+=4),i&3||(i>>=2,r+=2),i&1||++r,r}function dI(i){for(var r=0;i!=0;)i&=i-1,++r;return r}var Pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K$="=";function Iu(i){var r,e,t="";for(r=0;r+3<=i.length;r+=3)e=parseInt(i.substring(r,r+3),16),t+=Pn.charAt(e>>6)+Pn.charAt(e&63);for(r+1==i.length?(e=parseInt(i.substring(r,r+1),16),t+=Pn.charAt(e<<2)):r+2==i.length&&(e=parseInt(i.substring(r,r+2),16),t+=Pn.charAt(e>>2)+Pn.charAt((e&3)<<4));(t.length&3)>0;)t+=K$;return t}function wp(i){var r="",e,t=0,n=0;for(e=0;e>2),n=a&3,t=1):t==1?(r+=Or(n<<2|a>>4),n=a&15,t=2):t==2?(r+=Or(n),r+=Or(a>>2),n=a&3,t=3):(r+=Or(n<<2|a>>4),r+=Or(a&15),t=0))}return t==1&&(r+=Or(n<<2)),r}var pn,fI={decode:function(i){var r;if(pn===void 0){var e="0123456789ABCDEF",t=` \f \r  \u2028\u2029`;for(pn={},r=0;r<16;++r)pn[e.charAt(r)]=r;for(e=e.toLowerCase(),r=10;r<16;++r)pn[e.charAt(r)]=r;for(r=0;r=2?(n[n.length]=a,a=0,o=0):a<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},Si,wd={decode:function(i){var r;if(Si===void 0){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=`= \f \r  \u2028\u2029`;for(Si=Object.create(null),r=0;r<64;++r)Si[e.charAt(r)]=r;for(Si["-"]=62,Si._=63,r=0;r=4?(n[n.length]=a>>16,n[n.length]=a>>8&255,n[n.length]=a&255,a=0,o=0):a<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=a>>10;break;case 3:n[n.length]=a>>16,n[n.length]=a>>8&255;break}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(i){var r=wd.re.exec(i);if(r)if(r[1])i=r[1];else if(r[2])i=r[2];else throw new Error("RegExp out of sync");return wd.decode(i)}},gn=1e13,Ua=function(){function i(r){this.buf=[+r||0]}return i.prototype.mulAdd=function(r,e){var t=this.buf,n=t.length,a,o;for(a=0;a0&&(t[a]=e)},i.prototype.sub=function(r){var e=this.buf,t=e.length,n,a;for(n=0;n=0;--n)t+=(gn+e[n]).toString().substring(1);return t},i.prototype.valueOf=function(){for(var r=this.buf,e=0,t=r.length-1;t>=0;--t)e=e*gn+r[t];return e},i.prototype.simplify=function(){var r=this.buf;return r.length==1?r[0]:this},i}(),G$="…",vI=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,pI=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Wn(i,r){return i.length>r&&(i=i.substring(0,r)+G$),i}var nh=function(){function i(r,e){this.hexDigits="0123456789ABCDEF",r instanceof i?(this.enc=r.enc,this.pos=r.pos):(this.enc=r,this.pos=e)}return i.prototype.get=function(r){if(r===void 0&&(r=this.pos++),r>=this.enc.length)throw new Error("Requesting byte offset ".concat(r," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(r):this.enc[r]},i.prototype.hexByte=function(r){return this.hexDigits.charAt(r>>4&15)+this.hexDigits.charAt(r&15)},i.prototype.hexDump=function(r,e,t){for(var n="",a=r;a176)return!1}return!0},i.prototype.parseStringISO=function(r,e){for(var t="",n=r;n191&&a<224?t+=String.fromCharCode((a&31)<<6|this.get(n++)&63):t+=String.fromCharCode((a&15)<<12|(this.get(n++)&63)<<6|this.get(n++)&63)}return t},i.prototype.parseStringBMP=function(r,e){for(var t="",n,a,o=r;o127,a=n?255:0,o,s="";t==a&&++r4){for(s=t,o<<=3;!((+s^a)&128);)s=+s<<1,--o;s="("+o+` bit) diff --git a/dist/copilot_web/workflowChat-DAlFyxt6.js b/dist/copilot_web/workflowChat-CjDaET6O.js similarity index 99% rename from dist/copilot_web/workflowChat-DAlFyxt6.js rename to dist/copilot_web/workflowChat-CjDaET6O.js index a7b9520..7aff850 100644 --- a/dist/copilot_web/workflowChat-DAlFyxt6.js +++ b/dist/copilot_web/workflowChat-CjDaET6O.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-C7lWPQXP.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-DoI1VVaz.js","copilot_web/ParameterDebugInterfaceNew-12BV9YCy.js","copilot_web/input.js","copilot_web/assets/input-0GzdDP_m.css","copilot_web/fonts.css"])))=>i.map(i=>d[i]); -import{_ as Ot}from"./input.js";import{j as h,r as yg,b as wg}from"./vendor-markdown-Dek94WS0.js";import{r as L,R as wn,c as Tt}from"./vendor-react-V04_Axys.js";import{f as bg,v as Sg,a as fn,B as Ag,U as Eg,A as Er,b as Ig,g as en,c as Mt,u as ru,M as Cg,W as Rt}from"./message-components-DoI1VVaz.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-Bee-YmQA.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-DHkIj9qD.js","copilot_web/ParameterDebugInterfaceNew-Bll5geLy.js","copilot_web/input.js","copilot_web/assets/input-0GzdDP_m.css","copilot_web/fonts.css"])))=>i.map(i=>d[i]); +import{_ as Ot}from"./input.js";import{j as h,r as yg,b as wg}from"./vendor-markdown-Dek94WS0.js";import{r as L,R as wn,c as Tt}from"./vendor-react-V04_Axys.js";import{f as bg,v as Sg,a as fn,B as Ag,U as Eg,A as Er,b as Ig,g as en,c as Mt,u as ru,M as Cg,W as Rt}from"./message-components-DHkIj9qD.js";/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. @@ -100,7 +100,7 @@ ${k.join(` hover:bg-gray-50`,children:"Close"})})]})})]})}function qg(m){const b=m[0],a=new Set;function F(M,E){if(!(!M||E>=1)&&M.inputs)for(const B of Object.values(M.inputs)){const te=B.link;if(te&&fn.graph.links[te]){const y=fn.graph.links[te].origin_id,q=fn.graph._nodes_by_id[y];q&&(a.add(q.type),F(q,E+1))}}}return b?(F(b,0),[{type:"upstream_node_types",data:Array.from(a)}]):null}function Zg({nodeInfo:m,onSendWithIntent:b,loading:a,onSendWithContent:F}){return console.log("SelectedNodeInfo nodeInfo:",m[0]),h.jsx("div",{className:"mb-3 p-3 rounded-md bg-gray-50 border border-gray-200",children:h.jsxs("div",{className:"text-sm text-gray-700",children:[h.jsxs("p",{children:["Selected node: ",m[0].type]}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-blue-50 text-blue-700 hover:bg-blue-100`,onClick:()=>F(`Reply in ${navigator.language} language: How does the ${m[0].type} node work? I need its official usage guide.`),disabled:a,children:"Usage"}),h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-green-100 text-green-700 hover:bg-green-200`,onClick:()=>F(`Reply in ${navigator.language} language: Show me the technical specifications for the ${m[0].type} node's inputs and outputs.`),disabled:a,children:"Parameters"}),h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-purple-100 - text-purple-700 hover:bg-purple-200`,onClick:()=>b("downstream_subgraph_search",qg(m)),disabled:a,children:"Downstream Nodes"})]})]})})}function Yg(){return h.jsx(Ag,{name:"Assistant",children:h.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[h.jsxs("div",{className:"flex space-x-1",children:[h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Jg=m=>`https://ui-avatars.com/api/?name=${m||"User"}&background=random`,Xg=L.lazy(()=>Ot(()=>import("./WorkflowOption-C7lWPQXP.js"),__vite__mapDeps([0,1,2,3])).then(m=>({default:m.WorkflowOption}))),Qg=L.lazy(()=>Ot(()=>import("./message-components-DoI1VVaz.js").then(m=>m.N),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeSearch}))),Vg=L.lazy(()=>Ot(()=>import("./message-components-DoI1VVaz.js").then(m=>m.D),__vite__mapDeps([3,2,1])).then(m=>({default:m.DownstreamSubgraphs}))),ep=L.lazy(()=>Ot(()=>import("./message-components-DoI1VVaz.js").then(m=>m.d),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeInstallGuide})));function np({messages:m,latestInput:b,onOptionClick:a,installedNodes:F,onAddMessage:M,loading:E}){const B=wn.useMemo(()=>y=>{if(y.role==="user")return h.jsx(Eg,{content:y.content,trace_id:y.trace_id},y.id);if(y.role==="ai"||y.role==="tool"){const q=Jg(y.role);try{const $=JSON.parse(y.content),P=$.ext?.find(k=>k.type==="workflow"),ve=$.ext?.find(k=>k.type==="node"),re=$.ext?.find(k=>k.type==="downstream_subgraph_search"),ge=$.ext?.find(k=>k.type==="node_install_guide");let T=null;if(P)T=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Xg,{content:y.content,name:y.name,avatar:q,latestInput:b,installedNodes:F,onAddMessage:M})});else if(ve)T=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:y.content,name:y.name,avatar:q,installedNodes:F})});else if(re){const k=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Vg,{content:y.content,name:y.name,avatar:q,onAddMessage:M})});if(y.metadata?.intent==="downstream_subgraph_search")return h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,extComponent:k,metadata:y.metadata},y.id);T=k}else ge&&(T=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(ep,{content:y.content,onLoadSubgraph:()=>{if(y.metadata?.pendingSubgraph){const k=Object.values(fn.canvas.selected_nodes)[0];if(k){const oe=y.metadata.pendingSubgraph,ce=oe.json.nodes,se=oe.json.links,Pe=ce.find(Z=>Z.id===0),le=Pe?.id,H={};le&&(H[le]=k),fn.canvas.emitBeforeChange();try{for(const Z of ce)if(Z.id!==le){const Se=Pe?.pos||[0,0],pe=k._pos||[0,0],bn=[Z.pos[0]+pe[0]-Se[0],Z.pos[1]+pe[1]-Se[1]];H[Z.id]=Ig(Z.type,{pos:bn})}}finally{fn.canvas.emitAfterChange()}for(const Z of se){const Se=H[Z.origin_id],pe=H[Z.target_id];Se&&pe&&Se.connect(Z.origin_slot,pe,Z.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(y.metadata?.pendingWorkflow){const k=y.metadata.pendingWorkflow,oe=y.metadata.optimizedParams;fn.loadGraphData(k);for(const[se,Pe,le,H,Z]of oe){const Se=fn.graph._nodes_by_id[se].widgets;for(const pe of Se)pe.name===H&&(pe.value=Z)}fn.graph.setDirtyCanvas(!1,!0);const ce={id:en(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};M?.(ce)}}})}));return $.text||T?h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,extComponent:T,metadata:y.metadata},y.id):T||h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,metadata:y.metadata},y.id)}catch($){return console.error("[MessageList] Error parsing message content:",$),console.error("解析JSON失败",y.content),h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,metadata:y.metadata},y.id)}}return null},[F,a,M,b]),te=wn.useMemo(()=>m?.map(B),[m,B]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[te,E&&h.jsx(Yg,{})]})}async function tp(){try{return await(await Mt.fetchApi("/object_info",{method:"GET"})).json()}catch(m){throw console.error("Error fetching object info:",m),m}}async function rp(){const m=await tp();return Object.keys(m)}async function dp(m){return await(await Mt.fetchApi("/prompt",{method:"POST",body:JSON.stringify(m)})).json()}async function gp(m){try{const b=await Mt.fetchApi("/queue",{method:"POST",body:JSON.stringify(m)});if(!b.ok)throw new Error(`Failed to manage queue: ${b.status} ${b.statusText}`);return b}catch(b){throw console.error("Error managing queue:",b),b}}async function pp(){try{const m=await Mt.fetchApi("/interrupt",{method:"POST"});if(!m.ok)throw new Error(`Failed to interrupt processing: ${m.status} ${m.statusText}`);return m}catch(m){throw console.error("Error interrupting processing:",m),m}}async function _p(m){try{const b=await Mt.fetchApi(`/history/${m}`,{method:"GET"});if(!b.ok)throw new Error(`Failed to fetch history: ${b.status} ${b.statusText}`);return await b.json()}catch(b){throw console.error("Error fetching history:",b),b}}var Ir={exports:{}};/** + text-purple-700 hover:bg-purple-200`,onClick:()=>b("downstream_subgraph_search",qg(m)),disabled:a,children:"Downstream Nodes"})]})]})})}function Yg(){return h.jsx(Ag,{name:"Assistant",children:h.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[h.jsxs("div",{className:"flex space-x-1",children:[h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Jg=m=>`https://ui-avatars.com/api/?name=${m||"User"}&background=random`,Xg=L.lazy(()=>Ot(()=>import("./WorkflowOption-Bee-YmQA.js"),__vite__mapDeps([0,1,2,3])).then(m=>({default:m.WorkflowOption}))),Qg=L.lazy(()=>Ot(()=>import("./message-components-DHkIj9qD.js").then(m=>m.N),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeSearch}))),Vg=L.lazy(()=>Ot(()=>import("./message-components-DHkIj9qD.js").then(m=>m.D),__vite__mapDeps([3,2,1])).then(m=>({default:m.DownstreamSubgraphs}))),ep=L.lazy(()=>Ot(()=>import("./message-components-DHkIj9qD.js").then(m=>m.d),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeInstallGuide})));function np({messages:m,latestInput:b,onOptionClick:a,installedNodes:F,onAddMessage:M,loading:E}){const B=wn.useMemo(()=>y=>{if(y.role==="user")return h.jsx(Eg,{content:y.content,trace_id:y.trace_id},y.id);if(y.role==="ai"||y.role==="tool"){const q=Jg(y.role);try{const $=JSON.parse(y.content),P=$.ext?.find(k=>k.type==="workflow"),ve=$.ext?.find(k=>k.type==="node"),re=$.ext?.find(k=>k.type==="downstream_subgraph_search"),ge=$.ext?.find(k=>k.type==="node_install_guide");let T=null;if(P)T=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Xg,{content:y.content,name:y.name,avatar:q,latestInput:b,installedNodes:F,onAddMessage:M})});else if(ve)T=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:y.content,name:y.name,avatar:q,installedNodes:F})});else if(re){const k=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Vg,{content:y.content,name:y.name,avatar:q,onAddMessage:M})});if(y.metadata?.intent==="downstream_subgraph_search")return h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,extComponent:k,metadata:y.metadata},y.id);T=k}else ge&&(T=h.jsx(L.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(ep,{content:y.content,onLoadSubgraph:()=>{if(y.metadata?.pendingSubgraph){const k=Object.values(fn.canvas.selected_nodes)[0];if(k){const oe=y.metadata.pendingSubgraph,ce=oe.json.nodes,se=oe.json.links,Pe=ce.find(Z=>Z.id===0),le=Pe?.id,H={};le&&(H[le]=k),fn.canvas.emitBeforeChange();try{for(const Z of ce)if(Z.id!==le){const Se=Pe?.pos||[0,0],pe=k._pos||[0,0],bn=[Z.pos[0]+pe[0]-Se[0],Z.pos[1]+pe[1]-Se[1]];H[Z.id]=Ig(Z.type,{pos:bn})}}finally{fn.canvas.emitAfterChange()}for(const Z of se){const Se=H[Z.origin_id],pe=H[Z.target_id];Se&&pe&&Se.connect(Z.origin_slot,pe,Z.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(y.metadata?.pendingWorkflow){const k=y.metadata.pendingWorkflow,oe=y.metadata.optimizedParams;fn.loadGraphData(k);for(const[se,Pe,le,H,Z]of oe){const Se=fn.graph._nodes_by_id[se].widgets;for(const pe of Se)pe.name===H&&(pe.value=Z)}fn.graph.setDirtyCanvas(!1,!0);const ce={id:en(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};M?.(ce)}}})}));return $.text||T?h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,extComponent:T,metadata:y.metadata},y.id):T||h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,metadata:y.metadata},y.id)}catch($){return console.error("[MessageList] Error parsing message content:",$),console.error("解析JSON失败",y.content),h.jsx(Er,{content:y.content,name:y.name,avatar:q,format:y.format,onOptionClick:a,metadata:y.metadata},y.id)}}return null},[F,a,M,b]),te=wn.useMemo(()=>m?.map(B),[m,B]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[te,E&&h.jsx(Yg,{})]})}async function tp(){try{return await(await Mt.fetchApi("/object_info",{method:"GET"})).json()}catch(m){throw console.error("Error fetching object info:",m),m}}async function rp(){const m=await tp();return Object.keys(m)}async function dp(m){return await(await Mt.fetchApi("/prompt",{method:"POST",body:JSON.stringify(m)})).json()}async function gp(m){try{const b=await Mt.fetchApi("/queue",{method:"POST",body:JSON.stringify(m)});if(!b.ok)throw new Error(`Failed to manage queue: ${b.status} ${b.statusText}`);return b}catch(b){throw console.error("Error managing queue:",b),b}}async function pp(){try{const m=await Mt.fetchApi("/interrupt",{method:"POST"});if(!m.ok)throw new Error(`Failed to interrupt processing: ${m.status} ${m.statusText}`);return m}catch(m){throw console.error("Error interrupting processing:",m),m}}async function _p(m){try{const b=await Mt.fetchApi(`/history/${m}`,{method:"GET"});if(!b.ok)throw new Error(`Failed to fetch history: ${b.status} ${b.statusText}`);return await b.json()}catch(b){throw console.error("Error fetching history:",b),b}}var Ir={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors @@ -126,4 +126,4 @@ __p += '`),z&&(v+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+v+`return __p -}`;var W=Ta(function(){return Y(s,S+"return "+v).apply(a,o)});if(W.source=v,zi(W))throw W;return W}function C0(e){return J(e).toLowerCase()}function N0(e){return J(e).toUpperCase()}function L0(e,n,t){if(e=J(e),e&&(t||n===a))return Uu(e);if(!e||!(n=Fe(n)))return e;var r=tn(e),i=tn(n),s=Fu(r,i),o=ju(r,i)+1;return On(r,s,o).join("")}function T0(e,n,t){if(e=J(e),e&&(t||n===a))return e.slice(0,Ku(e)+1);if(!e||!(n=Fe(n)))return e;var r=tn(e),i=ju(r,tn(n))+1;return On(r,0,i).join("")}function R0(e,n,t){if(e=J(e),e&&(t||n===a))return e.replace(zr,"");if(!e||!(n=Fe(n)))return e;var r=tn(e),i=Fu(r,tn(n));return On(r,i).join("")}function O0(e,n){var t=bn,r=Cr;if(ae(n)){var i="separator"in n?n.separator:i;t="length"in n?D(n.length):t,r="omission"in n?Fe(n.omission):r}e=J(e);var s=e.length;if(Qn(e)){var o=tn(e);s=o.length}if(t>=s)return e;var l=t-Vn(r);if(l<1)return r;var c=o?On(o,0,l).join(""):e.slice(0,l);if(i===a)return c+r;if(o&&(l+=c.length-l),$i(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=ai(i.source,J(au.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===a?l:v)}}else if(e.indexOf(Fe(i),l)!=l){var x=c.lastIndexOf(i);x>-1&&(c=c.slice(0,x))}return c+r}function M0(e){return e=J(e),e&&Ga.test(e)?e.replace(iu,al):e}var D0=st(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Zi=Rs("toUpperCase");function La(e,n,t){return e=J(e),n=t?a:n,n===a?tl(e)?fl(e):qo(e):e.match(n)||[]}var Ta=U(function(e,n){try{return Be(e,a,n)}catch(t){return zi(t)?t:new R(t)}}),P0=_n(function(e,n){return qe(n,function(t){t=ln(t),gn(e,t,Gi(e[t],e))}),e});function k0(e){var n=e==null?0:e.length,t=I();return e=n?ue(e,function(r){if(typeof r[1]!="function")throw new Ze(B);return[t(r[0]),r[1]]}):[],U(function(r){for(var i=-1;++iSn)return[];var t=ze,r=Ee(e,ze);n=I(n),e-=ze;for(var i=ii(r,n);++t0||n<0)?new K(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==a&&(n=D(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},K.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},K.prototype.toArray=function(){return this.take(ze)},an(K.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=u[r?"take"+(n=="last"?"Right":""):n],s=r||/^find/.test(n);i&&(u.prototype[n]=function(){var o=this.__wrapped__,l=r?[1]:arguments,c=o instanceof K,p=l[0],_=c||O(o),v=function(G){var z=i.apply(u,In([G],l));return r&&x?z[0]:z};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var x=this.__chain__,S=!!this.__actions__.length,C=s&&!x,W=c&&!S;if(!s&&_){o=W?o:new K(this);var N=e.apply(o,l);return N.__actions__.push({func:vr,args:[v],thisArg:a}),new Ye(N,x)}return C&&W?e.apply(this,l):(N=this.thru(v),C?r?N.value()[0]:N.value():N)})}),qe(["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);u.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var s=this.value();return n.apply(O(s)?s:[],i)}return this[t](function(o){return n.apply(O(o)?o:[],i)})}}),an(K.prototype,function(e,n){var t=u[n];if(t){var r=t.name+"";X.call(rt,r)||(rt[r]=[]),rt[r].push({name:n,func:t})}}),rt[fr(a,oe).name]=[{name:"wrapper",func:a}],K.prototype.clone=Ol,K.prototype.reverse=Ml,K.prototype.value=Dl,u.prototype.at=fh,u.prototype.chain=ch,u.prototype.commit=hh,u.prototype.next=dh,u.prototype.plant=ph,u.prototype.reverse=_h,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=vh,u.prototype.first=u.prototype.head,_t&&(u.prototype[_t]=gh),u},et=cl();kn?((kn.exports=et)._=et,Jr._=et):we._=et}).call(Tt)})(Ir,Ir.exports);var ka=Ir.exports;function ip(m=!0){L.useEffect(()=>{if(!m)return;const b=ka.debounce(a=>{document.documentElement.style.setProperty("--mouse-x",`${a.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${a.clientY}px`)},16);return document.addEventListener("mousemove",b),()=>{b.cancel(),document.removeEventListener("mousemove",b)}},[m])}function up(m=!0){const{state:b,dispatch:a}=ru(),{activeTab:F,screenState:M}=b;L.useEffect(()=>{if(!m)return;const E=B=>{const te=F==="parameter-debug",y=F==="chat",q=!M||M.currentScreen===0;if(y||q&&te){const $=fn.canvas.selected_nodes;Object.keys($??{}).length?a({type:"SET_SELECTED_NODE",payload:Object.values($)}):a({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[a,m,F,M])}const sp=({message:m,onClose:b})=>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(Cg,{rehypePlugins:[[yg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[wg],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:a,...F})=>h.jsx("a",{...F,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:a})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:a}),span:({children:a})=>h.jsx("span",{style:{fontSize:"11px"},children:a}),li:({children:a})=>h.jsx("li",{style:{fontSize:"11px"},children:a}),ul:({children:a})=>h.jsx("ul",{style:{fontSize:"11px"},children:a}),ol:({children:a})=>h.jsx("ol",{style:{fontSize:"11px"},children:a})},children:m})})]}),h.jsx("button",{onClick:b,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,ap=()=>{const{state:m,dispatch:b}=ru(),{selectedNode:a,screenState:F}=m,M=a||[],E=wn.lazy(()=>Ot(()=>import("./ParameterDebugInterfaceNew-12BV9YCy.js"),__vite__mapDeps([4,1,2,3,5,6,7])).then(te=>({default:te.ParameterDebugInterface}))),B=()=>{b({type:"SET_SELECTED_NODE",payload:null}),b({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};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:M,visible:!0,onClose:B})})})},Da=({active:m,onClick:b,children:a})=>h.jsx("button",{onClick:b,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:a});function op({onClose:m,visible:b=!0,triggerUsage:a=!1,onUsageTriggered:F}){const{state:M,dispatch:E}=ru(),{messages:B,installedNodes:te,loading:y,sessionId:q,selectedNode:$,activeTab:P}=M,ve=L.useRef(null),[re,ge]=L.useState(""),[T,k]=L.useState(""),[oe,ce]=L.useState(window.innerWidth/3),[se,Pe]=L.useState(!1),[le,H]=L.useState([]),[Z,Se]=L.useState("gpt-4o-mini");L.useState(window.innerHeight),L.useState(0);const[pe,bn]=L.useState(""),[Cr,Dt]=L.useState(!1);ip(b&&P==="chat"),up(b),L.useEffect(()=>{ve.current&&(ve.current.scrollTop=ve.current.scrollHeight)},[B]),L.useEffect(()=>{if(P!=="chat")return;(async()=>{const j=await rp();console.log("[WorkflowChat] Received installed nodes:",j.length),E({type:"SET_INSTALLED_NODES",payload:j})})()},[P]);const Nr=async A=>{try{const j=await Rt.fetchMessages(A);E({type:"SET_MESSAGES",payload:j})}catch(j){console.error("Error fetching messages:",j)}};L.useEffect(()=>{if(P!=="chat")return;let A=localStorage.getItem("sessionId");A?(E({type:"SET_SESSION_ID",payload:A}),Nr(A)):(A=en(),E({type:"SET_SESSION_ID",payload:A}),localStorage.setItem("sessionId",A))},[P]),L.useEffect(()=>{const A=localStorage.getItem("activeTab");A&&E({type:"SET_ACTIVE_TAB",payload:A});const j=localStorage.getItem("screenState");j&&E({type:"SET_SCREEN_STATE",payload:JSON.parse(j)})},[]),L.useEffect(()=>{localStorage.setItem("activeTab",P)},[P]),L.useEffect(()=>{M.screenState&&localStorage.setItem("screenState",JSON.stringify(M.screenState))},[M.screenState]);const ct=wn.useCallback(A=>{if(!se)return;const j=window.innerWidth-A.clientX,_e=Math.min(Math.max(300,j),window.innerWidth*.8);ce(_e)},[se]),$n=wn.useMemo(()=>ka.debounce(ct,16),[ct]);L.useEffect(()=>(se&&(document.addEventListener("mousemove",$n),document.addEventListener("mouseup",cn)),()=>{document.removeEventListener("mousemove",$n),document.removeEventListener("mouseup",cn),$n.cancel()}),[se,$n]);const Lr=A=>{ge(A.target.value)},Dn=async()=>{if(E({type:"SET_LOADING",payload:!0}),re.trim()===""&&!$||!q)return;k(re);const A=en(),j={id:en(),role:"user",content:re,trace_id:A};E({type:"ADD_MESSAGE",payload:j}),ge("");try{const _e={type:"model_select",data:[Z]};let V=en(),$e=!0;for await(const ke of Rt.streamInvokeServer(q,re,le.map(ie=>ie.file),null,_e,A)){const ie={id:V,role:"ai",content:JSON.stringify(ke),format:ke.format,finished:ke.finished,name:"Assistant"};if($e)E({type:"ADD_MESSAGE",payload:ie}),$e=!1;else{E({type:"UPDATE_MESSAGE",payload:ie});const Ae=M.messages.map(We=>We.id===ie.id&&!We.finished?ie:We);qn(Ae)}ke.finished&&E({type:"SET_LOADING",payload:!1})}}catch(_e){console.error("Error sending message:",_e),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Sn=async A=>{if(!q)return;E({type:"SET_LOADING",payload:!0}),k(A);const j=en(),_e={id:en(),role:"user",content:A,trace_id:j};E({type:"ADD_MESSAGE",payload:_e});try{const V={type:"model_select",data:[Z]};let $e=en(),ke=!0;for await(const ie of Rt.streamInvokeServer(q,A,le.map(Ae=>Ae.file),null,V,j)){const Ae={id:$e,role:"ai",content:JSON.stringify(ie),format:ie.format,finished:ie.finished,name:"Assistant"};if(ke)E({type:"ADD_MESSAGE",payload:Ae}),ke=!1;else{E({type:"UPDATE_MESSAGE",payload:Ae});const We=M.messages.map(nn=>nn.id===Ae.id&&!nn.finished?Ae:nn);qn(We)}ie.finished&&E({type:"SET_LOADING",payload:!1})}}catch(V){console.error("Error sending message:",V),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Tr=A=>{A.metaKey&&A.key==="Enter"&&Dn()},Hn=()=>{E({type:"CLEAR_MESSAGES"});const A=M.sessionId;A&&localStorage.removeItem(`messages_${A}`),localStorage.removeItem("sessionId");const j=en();E({type:"SET_SESSION_ID",payload:j}),localStorage.setItem("sessionId",j)},ze=A=>{ge(A)},Pt=async(A,j)=>{if(!q||!$)return;E({type:"SET_LOADING",payload:!0});const _e=$[0].comfyClass||$[0].type,V=en(),$e={id:en(),role:"user",content:_e,trace_id:V};E({type:"ADD_MESSAGE",payload:$e});try{let ke=en(),ie=!0;for await(const Ae of Rt.streamInvokeServer(q,_e,[],A,j,V)){const We={id:ke,role:"ai",content:JSON.stringify(Ae),format:Ae.format,finished:Ae.finished,name:"Assistant"};if(A&&A!==""&&(We.metadata={intent:A}),ie)E({type:"ADD_MESSAGE",payload:We}),ie=!1;else{E({type:"UPDATE_MESSAGE",payload:We});const nn=M.messages.map(Ce=>Ce.id===We.id&&!Ce.finished?We:Ce);qn(nn)}Ae.finished&&E({type:"SET_LOADING",payload:!1})}}catch(ke){console.error("Error sending message:",ke),E({type:"SET_LOADING",payload:!1})}},qn=A=>{M.sessionId&&localStorage.setItem(`messages_${M.sessionId}`,JSON.stringify(A))},Rr=A=>{console.log("[WorkflowChat] Adding new message:",A);const j=[...M.messages,A];E({type:"ADD_MESSAGE",payload:A}),qn(j)},cn=()=>{Pe(!1)},Zn=A=>{const j=Array.from(A).map(_e=>({id:Math.random().toString(36).substr(2,9),file:_e,preview:URL.createObjectURL(_e)}));H(_e=>[..._e,...j])},Or=A=>{H(j=>j.filter(V=>V.id!==A))};wn.useEffect(()=>()=>{le.forEach(A=>URL.revokeObjectURL(A.preview))},[le]),L.useEffect(()=>{a&&F&&P==="chat"&&(Pt("node_explain"),F())},[a,P]),L.useEffect(()=>{if(!b||P!=="chat")return;(async()=>{try{const j=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==j){const V=await Rt.fetchAnnouncement();V&&V.trim()!==""&&(bn(V),Dt(!0),localStorage.setItem("announcementLastShownDate",j))}}catch(j){console.error("Error fetching announcement:",j)}})()},[b,P]);const Pn=()=>{Dt(!1)},An=A=>{E({type:"SET_ACTIVE_TAB",payload:A})},Mr=wn.useMemo(()=>h.jsx(ap,{}),[]);return b?h.jsxs("div",{className:"flex flex-col h-full w-full bg-white",style:{display:b?"flex":"none",height:"100%"},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx(zg,{onClose:m,onClear:Hn,hasMessages:B.length>0,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(Da,{active:P==="chat",onClick:()=>An("chat"),children:"Chat"}),h.jsx(Da,{active:P==="parameter-debug",onClick:()=>An("parameter-debug"),children:"GenLab"})]}),Cr&&pe&&P==="chat"&&h.jsx(sp,{message:pe,onClose:Pn}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth h-0",style:{display:P==="chat"?"block":"none"},ref:ve,children:h.jsx(np,{messages:B,latestInput:T,onOptionClick:ze,installedNodes:te,onAddMessage:Rr,loading:y})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:P==="chat"?"block":"none"},children:[$&&h.jsx(Zg,{nodeInfo:$,onSendWithIntent:Pt,loading:y,onSendWithContent:Sn}),h.jsx(Hg,{input:re,loading:y,onChange:Lr,onSend:Dn,onKeyPress:Tr,onUploadImages:Zn,uploadedImages:le,onRemoveImage:Or,selectedModel:Z,onModelChange:Se})]}),h.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:P==="parameter-debug"?"flex":"none"},children:Mr})]})]}):null}const vp=Object.freeze(Object.defineProperty({__proto__:null,default:op},Symbol.toStringTag,{value:"Module"}));export{_p as g,pp as i,gp as m,dp as r,vp as w}; +}`;var W=Ta(function(){return Y(s,S+"return "+v).apply(a,o)});if(W.source=v,zi(W))throw W;return W}function C0(e){return J(e).toLowerCase()}function N0(e){return J(e).toUpperCase()}function L0(e,n,t){if(e=J(e),e&&(t||n===a))return Uu(e);if(!e||!(n=Fe(n)))return e;var r=tn(e),i=tn(n),s=Fu(r,i),o=ju(r,i)+1;return On(r,s,o).join("")}function T0(e,n,t){if(e=J(e),e&&(t||n===a))return e.slice(0,Ku(e)+1);if(!e||!(n=Fe(n)))return e;var r=tn(e),i=ju(r,tn(n))+1;return On(r,0,i).join("")}function R0(e,n,t){if(e=J(e),e&&(t||n===a))return e.replace(zr,"");if(!e||!(n=Fe(n)))return e;var r=tn(e),i=Fu(r,tn(n));return On(r,i).join("")}function O0(e,n){var t=bn,r=Cr;if(ae(n)){var i="separator"in n?n.separator:i;t="length"in n?D(n.length):t,r="omission"in n?Fe(n.omission):r}e=J(e);var s=e.length;if(Qn(e)){var o=tn(e);s=o.length}if(t>=s)return e;var l=t-Vn(r);if(l<1)return r;var c=o?On(o,0,l).join(""):e.slice(0,l);if(i===a)return c+r;if(o&&(l+=c.length-l),$i(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=ai(i.source,J(au.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===a?l:v)}}else if(e.indexOf(Fe(i),l)!=l){var x=c.lastIndexOf(i);x>-1&&(c=c.slice(0,x))}return c+r}function M0(e){return e=J(e),e&&Ga.test(e)?e.replace(iu,al):e}var D0=st(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Zi=Rs("toUpperCase");function La(e,n,t){return e=J(e),n=t?a:n,n===a?tl(e)?fl(e):qo(e):e.match(n)||[]}var Ta=U(function(e,n){try{return Be(e,a,n)}catch(t){return zi(t)?t:new R(t)}}),P0=_n(function(e,n){return qe(n,function(t){t=ln(t),gn(e,t,Gi(e[t],e))}),e});function k0(e){var n=e==null?0:e.length,t=I();return e=n?ue(e,function(r){if(typeof r[1]!="function")throw new Ze(B);return[t(r[0]),r[1]]}):[],U(function(r){for(var i=-1;++iSn)return[];var t=ze,r=Ee(e,ze);n=I(n),e-=ze;for(var i=ii(r,n);++t0||n<0)?new K(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==a&&(n=D(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},K.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},K.prototype.toArray=function(){return this.take(ze)},an(K.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=u[r?"take"+(n=="last"?"Right":""):n],s=r||/^find/.test(n);i&&(u.prototype[n]=function(){var o=this.__wrapped__,l=r?[1]:arguments,c=o instanceof K,p=l[0],_=c||O(o),v=function(G){var z=i.apply(u,In([G],l));return r&&x?z[0]:z};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var x=this.__chain__,S=!!this.__actions__.length,C=s&&!x,W=c&&!S;if(!s&&_){o=W?o:new K(this);var N=e.apply(o,l);return N.__actions__.push({func:vr,args:[v],thisArg:a}),new Ye(N,x)}return C&&W?e.apply(this,l):(N=this.thru(v),C?r?N.value()[0]:N.value():N)})}),qe(["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);u.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var s=this.value();return n.apply(O(s)?s:[],i)}return this[t](function(o){return n.apply(O(o)?o:[],i)})}}),an(K.prototype,function(e,n){var t=u[n];if(t){var r=t.name+"";X.call(rt,r)||(rt[r]=[]),rt[r].push({name:n,func:t})}}),rt[fr(a,oe).name]=[{name:"wrapper",func:a}],K.prototype.clone=Ol,K.prototype.reverse=Ml,K.prototype.value=Dl,u.prototype.at=fh,u.prototype.chain=ch,u.prototype.commit=hh,u.prototype.next=dh,u.prototype.plant=ph,u.prototype.reverse=_h,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=vh,u.prototype.first=u.prototype.head,_t&&(u.prototype[_t]=gh),u},et=cl();kn?((kn.exports=et)._=et,Jr._=et):we._=et}).call(Tt)})(Ir,Ir.exports);var ka=Ir.exports;function ip(m=!0){L.useEffect(()=>{if(!m)return;const b=ka.debounce(a=>{document.documentElement.style.setProperty("--mouse-x",`${a.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${a.clientY}px`)},16);return document.addEventListener("mousemove",b),()=>{b.cancel(),document.removeEventListener("mousemove",b)}},[m])}function up(m=!0){const{state:b,dispatch:a}=ru(),{activeTab:F,screenState:M}=b;L.useEffect(()=>{if(!m)return;const E=B=>{const te=F==="parameter-debug",y=F==="chat",q=!M||M.currentScreen===0;if(y||q&&te){const $=fn.canvas.selected_nodes;Object.keys($??{}).length?a({type:"SET_SELECTED_NODE",payload:Object.values($)}):a({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[a,m,F,M])}const sp=({message:m,onClose:b})=>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(Cg,{rehypePlugins:[[yg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[wg],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:a,...F})=>h.jsx("a",{...F,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:a})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:a}),span:({children:a})=>h.jsx("span",{style:{fontSize:"11px"},children:a}),li:({children:a})=>h.jsx("li",{style:{fontSize:"11px"},children:a}),ul:({children:a})=>h.jsx("ul",{style:{fontSize:"11px"},children:a}),ol:({children:a})=>h.jsx("ol",{style:{fontSize:"11px"},children:a})},children:m})})]}),h.jsx("button",{onClick:b,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,ap=()=>{const{state:m,dispatch:b}=ru(),{selectedNode:a,screenState:F}=m,M=a||[],E=wn.lazy(()=>Ot(()=>import("./ParameterDebugInterfaceNew-Bll5geLy.js"),__vite__mapDeps([4,1,2,3,5,6,7])).then(te=>({default:te.ParameterDebugInterface}))),B=()=>{b({type:"SET_SELECTED_NODE",payload:null}),b({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};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:M,visible:!0,onClose:B})})})},Da=({active:m,onClick:b,children:a})=>h.jsx("button",{onClick:b,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:a});function op({onClose:m,visible:b=!0,triggerUsage:a=!1,onUsageTriggered:F}){const{state:M,dispatch:E}=ru(),{messages:B,installedNodes:te,loading:y,sessionId:q,selectedNode:$,activeTab:P}=M,ve=L.useRef(null),[re,ge]=L.useState(""),[T,k]=L.useState(""),[oe,ce]=L.useState(window.innerWidth/3),[se,Pe]=L.useState(!1),[le,H]=L.useState([]),[Z,Se]=L.useState("gpt-4o-mini");L.useState(window.innerHeight),L.useState(0);const[pe,bn]=L.useState(""),[Cr,Dt]=L.useState(!1);ip(b&&P==="chat"),up(b),L.useEffect(()=>{ve.current&&(ve.current.scrollTop=ve.current.scrollHeight)},[B]),L.useEffect(()=>{if(P!=="chat")return;(async()=>{const j=await rp();console.log("[WorkflowChat] Received installed nodes:",j.length),E({type:"SET_INSTALLED_NODES",payload:j})})()},[P]);const Nr=async A=>{try{const j=await Rt.fetchMessages(A);E({type:"SET_MESSAGES",payload:j})}catch(j){console.error("Error fetching messages:",j)}};L.useEffect(()=>{if(P!=="chat")return;let A=localStorage.getItem("sessionId");A?(E({type:"SET_SESSION_ID",payload:A}),Nr(A)):(A=en(),E({type:"SET_SESSION_ID",payload:A}),localStorage.setItem("sessionId",A))},[P]),L.useEffect(()=>{const A=localStorage.getItem("activeTab");A&&E({type:"SET_ACTIVE_TAB",payload:A});const j=localStorage.getItem("screenState");j&&E({type:"SET_SCREEN_STATE",payload:JSON.parse(j)})},[]),L.useEffect(()=>{localStorage.setItem("activeTab",P)},[P]),L.useEffect(()=>{M.screenState&&localStorage.setItem("screenState",JSON.stringify(M.screenState))},[M.screenState]);const ct=wn.useCallback(A=>{if(!se)return;const j=window.innerWidth-A.clientX,_e=Math.min(Math.max(300,j),window.innerWidth*.8);ce(_e)},[se]),$n=wn.useMemo(()=>ka.debounce(ct,16),[ct]);L.useEffect(()=>(se&&(document.addEventListener("mousemove",$n),document.addEventListener("mouseup",cn)),()=>{document.removeEventListener("mousemove",$n),document.removeEventListener("mouseup",cn),$n.cancel()}),[se,$n]);const Lr=A=>{ge(A.target.value)},Dn=async()=>{if(E({type:"SET_LOADING",payload:!0}),re.trim()===""&&!$||!q)return;k(re);const A=en(),j={id:en(),role:"user",content:re,trace_id:A};E({type:"ADD_MESSAGE",payload:j}),ge("");try{const _e={type:"model_select",data:[Z]};let V=en(),$e=!0;for await(const ke of Rt.streamInvokeServer(q,re,le.map(ie=>ie.file),null,_e,A)){const ie={id:V,role:"ai",content:JSON.stringify(ke),format:ke.format,finished:ke.finished,name:"Assistant"};if($e)E({type:"ADD_MESSAGE",payload:ie}),$e=!1;else{E({type:"UPDATE_MESSAGE",payload:ie});const Ae=M.messages.map(We=>We.id===ie.id&&!We.finished?ie:We);qn(Ae)}ke.finished&&E({type:"SET_LOADING",payload:!1})}}catch(_e){console.error("Error sending message:",_e),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Sn=async A=>{if(!q)return;E({type:"SET_LOADING",payload:!0}),k(A);const j=en(),_e={id:en(),role:"user",content:A,trace_id:j};E({type:"ADD_MESSAGE",payload:_e});try{const V={type:"model_select",data:[Z]};let $e=en(),ke=!0;for await(const ie of Rt.streamInvokeServer(q,A,le.map(Ae=>Ae.file),null,V,j)){const Ae={id:$e,role:"ai",content:JSON.stringify(ie),format:ie.format,finished:ie.finished,name:"Assistant"};if(ke)E({type:"ADD_MESSAGE",payload:Ae}),ke=!1;else{E({type:"UPDATE_MESSAGE",payload:Ae});const We=M.messages.map(nn=>nn.id===Ae.id&&!nn.finished?Ae:nn);qn(We)}ie.finished&&E({type:"SET_LOADING",payload:!1})}}catch(V){console.error("Error sending message:",V),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Tr=A=>{A.metaKey&&A.key==="Enter"&&Dn()},Hn=()=>{E({type:"CLEAR_MESSAGES"});const A=M.sessionId;A&&localStorage.removeItem(`messages_${A}`),localStorage.removeItem("sessionId");const j=en();E({type:"SET_SESSION_ID",payload:j}),localStorage.setItem("sessionId",j)},ze=A=>{ge(A)},Pt=async(A,j)=>{if(!q||!$)return;E({type:"SET_LOADING",payload:!0});const _e=$[0].comfyClass||$[0].type,V=en(),$e={id:en(),role:"user",content:_e,trace_id:V};E({type:"ADD_MESSAGE",payload:$e});try{let ke=en(),ie=!0;for await(const Ae of Rt.streamInvokeServer(q,_e,[],A,j,V)){const We={id:ke,role:"ai",content:JSON.stringify(Ae),format:Ae.format,finished:Ae.finished,name:"Assistant"};if(A&&A!==""&&(We.metadata={intent:A}),ie)E({type:"ADD_MESSAGE",payload:We}),ie=!1;else{E({type:"UPDATE_MESSAGE",payload:We});const nn=M.messages.map(Ce=>Ce.id===We.id&&!Ce.finished?We:Ce);qn(nn)}Ae.finished&&E({type:"SET_LOADING",payload:!1})}}catch(ke){console.error("Error sending message:",ke),E({type:"SET_LOADING",payload:!1})}},qn=A=>{M.sessionId&&localStorage.setItem(`messages_${M.sessionId}`,JSON.stringify(A))},Rr=A=>{console.log("[WorkflowChat] Adding new message:",A);const j=[...M.messages,A];E({type:"ADD_MESSAGE",payload:A}),qn(j)},cn=()=>{Pe(!1)},Zn=A=>{const j=Array.from(A).map(_e=>({id:Math.random().toString(36).substr(2,9),file:_e,preview:URL.createObjectURL(_e)}));H(_e=>[..._e,...j])},Or=A=>{H(j=>j.filter(V=>V.id!==A))};wn.useEffect(()=>()=>{le.forEach(A=>URL.revokeObjectURL(A.preview))},[le]),L.useEffect(()=>{a&&F&&P==="chat"&&(Pt("node_explain"),F())},[a,P]),L.useEffect(()=>{if(!b||P!=="chat")return;(async()=>{try{const j=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==j){const V=await Rt.fetchAnnouncement();V&&V.trim()!==""&&(bn(V),Dt(!0),localStorage.setItem("announcementLastShownDate",j))}}catch(j){console.error("Error fetching announcement:",j)}})()},[b,P]);const Pn=()=>{Dt(!1)},An=A=>{E({type:"SET_ACTIVE_TAB",payload:A})},Mr=wn.useMemo(()=>h.jsx(ap,{}),[]);return b?h.jsxs("div",{className:"flex flex-col h-full w-full bg-white",style:{display:b?"flex":"none",height:"100%"},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx(zg,{onClose:m,onClear:Hn,hasMessages:B.length>0,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(Da,{active:P==="chat",onClick:()=>An("chat"),children:"Chat"}),h.jsx(Da,{active:P==="parameter-debug",onClick:()=>An("parameter-debug"),children:"GenLab"})]}),Cr&&pe&&P==="chat"&&h.jsx(sp,{message:pe,onClose:Pn}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth h-0",style:{display:P==="chat"?"block":"none"},ref:ve,children:h.jsx(np,{messages:B,latestInput:T,onOptionClick:ze,installedNodes:te,onAddMessage:Rr,loading:y})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:P==="chat"?"block":"none"},children:[$&&h.jsx(Zg,{nodeInfo:$,onSendWithIntent:Pt,loading:y,onSendWithContent:Sn}),h.jsx(Hg,{input:re,loading:y,onChange:Lr,onSend:Dn,onKeyPress:Tr,onUploadImages:Zn,uploadedImages:le,onRemoveImage:Or,selectedModel:Z,onModelChange:Se})]}),h.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:P==="parameter-debug"?"flex":"none"},children:Mr})]})]}):null}const vp=Object.freeze(Object.defineProperty({__proto__:null,default:op},Symbol.toStringTag,{value:"Module"}));export{_p as g,pp as i,gp as m,dp as r,vp as w}; diff --git a/ui/src/components/chat/messages/WorkflowOption.tsx b/ui/src/components/chat/messages/WorkflowOption.tsx index f64e0e5..43a9e17 100644 --- a/ui/src/components/chat/messages/WorkflowOption.tsx +++ b/ui/src/components/chat/messages/WorkflowOption.tsx @@ -72,8 +72,14 @@ export function WorkflowOption({ content, name = 'Assistant', avatar, latestInpu if (optimizedResult.workflow) { // 检查是否需要安装节点 const nodeTypes = new Set(); - for (const node of optimizedResult.workflow.nodes) { - nodeTypes.add(node.type); + if(optimizedResult.workflow.nodes) { + for (const node of optimizedResult.workflow.nodes) { + nodeTypes.add(node.type); + } + } else { + for (const node of Object.values(optimizedResult.workflow)) { + nodeTypes.add(node.class_type); + } } const missingNodeTypes = Array.from(nodeTypes).filter( @@ -141,8 +147,12 @@ export function WorkflowOption({ content, name = 'Assistant', avatar, latestInpu }; const loadWorkflow = (workflow: any, optimizedParams: any[]) => { - app.loadGraphData(workflow); - + if(workflow.nodes) { + app.loadGraphData(workflow); + } else { + app.loadApiJson(workflow); + } + // 应用优化后的参数 [节点id,节点名称,参数id,参数名称,参数默认值] for (const [nodeId, nodeName, paramIndex, paramName, value] of optimizedParams) { const widgets = app.graph._nodes_by_id[nodeId].widgets;