diff --git a/dist/copilot_web/App-By_5x9Zk.js b/dist/copilot_web/App-Dk85TURt.js similarity index 91% rename from dist/copilot_web/App-By_5x9Zk.js rename to dist/copilot_web/App-Dk85TURt.js index e90a55c..72a1c9f 100644 --- a/dist/copilot_web/App-By_5x9Zk.js +++ b/dist/copilot_web/App-Dk85TURt.js @@ -1,6 +1,6 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat--6TDkP1M.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-yQk9DI7R.js","copilot_web/assets/input-CeTzrUyG.css"].map(path => { +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BMjjRVAR.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-cb3Dm8vl.js","copilot_web/assets/input-CeTzrUyG.css"].map(path => { const apiBase = window.comfyAPI?.api?.api?.api_base; const prefix = apiBase ? `${apiBase.substring(1)}/` : ''; return `${prefix}${path}`; }))))=>i.map(i=>d[i]); -import{_ as E}from"./input.js";import{j as s}from"./vendor-markdown-Dek94WS0.js";import{r as n,R as w}from"./vendor-react-V04_Axys.js";import{C as v}from"./message-components-yQk9DI7R.js";const y=9999999,x={EXPLAIN_NODE:"copilot:explain-node"},D="/copilot_web/assets/logo-BTZhX0BN.png";function _(e={}){const[u,l]=n.useState({x:e.initialX??window.innerWidth-160,y:e.initialY??20}),[o,r]=n.useState(!1),[a,m]=n.useState({x:0,y:0}),[d,c]=n.useState(0),[g,b]=n.useState({x:0,y:0}),f=n.useCallback(t=>{if(o){const i=Math.min(Math.max(0,t.clientX-g.x),window.innerWidth-(e.boundaryPadding?.right??100)),p=Math.min(Math.max(0,t.clientY-g.y),window.innerHeight-(e.boundaryPadding?.bottom??40));l({x:i,y:p})}},[o,g,e.boundaryPadding]),h=n.useCallback(t=>{if(o){const i=Math.sqrt(Math.pow(t.clientX-a.x,2)+Math.pow(t.clientY-a.y,2)),p=Date.now()-d;i<5&&p<200&&e.onClick?.()}r(!1)},[o,a,d,e.onClick]);return n.useEffect(()=>(o&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h)}),[o,f,h]),{position:u,isDragging:o,handleMouseDown:t=>{t.preventDefault(),r(!0),c(Date.now()),m({x:t.clientX,y:t.clientY});const i=t.currentTarget.getBoundingClientRect();b({x:t.clientX-i.left,y:t.clientY-i.top})}}}const C=w.lazy(()=>E(()=>import("./workflowChat--6TDkP1M.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.default})));function M(){const e=n.useRef(null),[u,l]=n.useState(!1),[o,r]=n.useState(!1),{position:a,isDragging:m,handleMouseDown:d}=_({boundaryPadding:{right:100,bottom:40},onClick:()=>l(!0)});return n.useEffect(()=>{const c=()=>{l(!0),r(!0)};return window.addEventListener(x.EXPLAIN_NODE,c),()=>window.removeEventListener(x.EXPLAIN_NODE,c)},[]),a?s.jsx(v,{children:s.jsx("div",{ref:e,children:s.jsxs("div",{className:"fixed",style:{zIndex:y,left:a.x,top:a.y,cursor:m?"grabbing":"grab"},children:[s.jsxs("button",{onMouseDown:d,className:"px-2 py-1 border border-gray-300 rounded-md bg-white text-black hover:bg-blue-300 hover:font-bold transition-colors select-none w-40 flex items-center space-x-1",style:{marginLeft:"-40px"},children:[s.jsx("img",{src:D,alt:"ComfyUI-Copilot Logo",className:"h-8 w-8"}),s.jsx("span",{className:"text-[14px] font-medium text-gray-800",children:"ComfyUI-Copilot"})]}),s.jsx(w.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(C,{onClose:()=>{l(!1),r(!1)},visible:u,triggerUsage:o,onUsageTriggered:()=>r(!1)})})]})})}):null}const I=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{I as A,D as l}; +import{_ as E}from"./input.js";import{j as s}from"./vendor-markdown-Dek94WS0.js";import{r as n,R as w}from"./vendor-react-V04_Axys.js";import{C as v}from"./message-components-cb3Dm8vl.js";const y=9999999,x={EXPLAIN_NODE:"copilot:explain-node"},D="/copilot_web/assets/logo-BTZhX0BN.png";function _(e={}){const[u,l]=n.useState({x:e.initialX??window.innerWidth-160,y:e.initialY??20}),[o,r]=n.useState(!1),[a,m]=n.useState({x:0,y:0}),[d,c]=n.useState(0),[g,b]=n.useState({x:0,y:0}),f=n.useCallback(t=>{if(o){const i=Math.min(Math.max(0,t.clientX-g.x),window.innerWidth-(e.boundaryPadding?.right??100)),p=Math.min(Math.max(0,t.clientY-g.y),window.innerHeight-(e.boundaryPadding?.bottom??40));l({x:i,y:p})}},[o,g,e.boundaryPadding]),h=n.useCallback(t=>{if(o){const i=Math.sqrt(Math.pow(t.clientX-a.x,2)+Math.pow(t.clientY-a.y,2)),p=Date.now()-d;i<5&&p<200&&e.onClick?.()}r(!1)},[o,a,d,e.onClick]);return n.useEffect(()=>(o&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h)}),[o,f,h]),{position:u,isDragging:o,handleMouseDown:t=>{t.preventDefault(),r(!0),c(Date.now()),m({x:t.clientX,y:t.clientY});const i=t.currentTarget.getBoundingClientRect();b({x:t.clientX-i.left,y:t.clientY-i.top})}}}const C=w.lazy(()=>E(()=>import("./workflowChat-BMjjRVAR.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.default})));function M(){const e=n.useRef(null),[u,l]=n.useState(!1),[o,r]=n.useState(!1),{position:a,isDragging:m,handleMouseDown:d}=_({boundaryPadding:{right:100,bottom:40},onClick:()=>l(!0)});return n.useEffect(()=>{const c=()=>{l(!0),r(!0)};return window.addEventListener(x.EXPLAIN_NODE,c),()=>window.removeEventListener(x.EXPLAIN_NODE,c)},[]),a?s.jsx(v,{children:s.jsx("div",{ref:e,children:s.jsxs("div",{className:"fixed",style:{zIndex:y,left:a.x,top:a.y,cursor:m?"grabbing":"grab"},children:[s.jsxs("button",{onMouseDown:d,className:"px-2 py-1 border border-gray-300 rounded-md bg-white text-black hover:bg-blue-300 hover:font-bold transition-colors select-none w-40 flex items-center space-x-1",style:{marginLeft:"-40px"},children:[s.jsx("img",{src:D,alt:"ComfyUI-Copilot Logo",className:"h-8 w-8"}),s.jsx("span",{className:"text-[14px] font-medium text-gray-800",children:"ComfyUI-Copilot"})]}),s.jsx(w.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(C,{onClose:()=>{l(!1),r(!1)},visible:u,triggerUsage:o,onUsageTriggered:()=>r(!1)})})]})})}):null}const I=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{I as A,D as l}; diff --git a/dist/copilot_web/ParameterDebugInterfaceNew-CuNRLSlD.js b/dist/copilot_web/ParameterDebugInterfaceNew-JzENzeyI.js similarity index 99% rename from dist/copilot_web/ParameterDebugInterfaceNew-CuNRLSlD.js rename to dist/copilot_web/ParameterDebugInterfaceNew-JzENzeyI.js index 32f244a..e62df21 100644 --- a/dist/copilot_web/ParameterDebugInterfaceNew-CuNRLSlD.js +++ b/dist/copilot_web/ParameterDebugInterfaceNew-JzENzeyI.js @@ -1,4 +1,4 @@ -import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as j}from"./vendor-react-V04_Axys.js";import{r as et,g as tt,m as st,i as rt}from"./workflowChat--6TDkP1M.js";import{a as Z,u as Ee,g as Ne,W as xe}from"./message-components-yQk9DI7R.js";import"./input.js";import"./App-By_5x9Zk.js";function nt(l,o){try{if(!l)return console.error("Invalid prompt_output: ",l),l;for(const r of o){if(!l[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!l[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}l[r.nodeId].inputs[r.paramName]=r.paramValue}return l}catch(r){return console.error("Error updating prompt:",r),l}}async function ot(l){const o=await Z.graphToPrompt(),r=nt(o.output,l);console.log("queuePrompt updated_prompt:",r);const u={prompt:r,client_id:Z.api.clientId,extra_data:{extra_pageinfo:{workflow:o.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const f=await et(u);return console.debug("queuePrompt response:",f),f}function _e(l){const o=document.createElement("canvas"),r=o.getContext("2d");if(o.width=512,o.height=512,r){r.fillStyle="#f8d7da",r.fillRect(0,0,o.width,o.height),r.strokeStyle="#dc3545",r.lineWidth=4,r.strokeRect(10,10,o.width-20,o.height-20),r.fillStyle="#dc3545",r.beginPath(),r.arc(o.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("!",o.width/2,150),r.fillStyle="#721c24",r.font="20px Arial",r.textAlign="center",r.textBaseline="middle";const u=o.width-60,f=30,m=l.split(" ");let c="",h=250;for(let w=0;wu&&w>0?(r.fillText(c,o.width/2,h),c=m[w]+" ",h+=f):c=E}r.fillText(c,o.width/2,h)}return o.toDataURL("image/png")}async function at(l){try{if(!l||l==="")return console.log("No prompt ID provided"),{1:[_e("Fail to generate prompt ID")]};const o=await tt(l);if(!o||!o[l])return console.log("Not finished for prompt ID:",l),{};const r=o[l];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",l);const f=r.status.messages;if(f&&f.length>0){const m=f[f.length-1];if(m&&m.length>0){const c=m[0];return{1:[_e(c)]}}}}const u={};if(r.outputs)for(const f in r.outputs){const m=r.outputs[f];if(m&&m.images){u[f]=[];for(const c of m.images)if(c&&c.filename&&c.type){const h=Z.graph._nodes_by_id[f].imgs[0].currentSrc.split("?")[0];u[f].push(h+"?filename="+encodeURIComponent(c.filename)+"&type="+encodeURIComponent(c.type)+(c.subfolder?"&subfolder="+encodeURIComponent(c.subfolder):""))}console.log("outputImages for nodeId:",f,u[f])}}return u}catch(o){throw console.error("Error getting output images from prompt:",o),o}}function lt(){const l=Object.values(Z.graph._nodes_by_id),o=[],r=[];for(const u of l)u.type==="SaveImage"?o.push(u.id):u.type==="PreviewImage"&&r.push(u.id);if(console.log("saveNodeIds:",o),console.log("previewNodeIds:",r),o.length===0&&r.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return o.length===1?o[0]:o.length==0&&r.length===1?r[0]:null}async function it(l,o){const r=await at(l);return Object.keys(r).length===0?null:r[o.toString()]&&r[o.toString()].length>0?r[o.toString()][0]:null}const ct=({selectedNodes:l,handleParamSelect:o,selectedParams:r,handleNext:u,handleClose:f})=>{const c=l.flatMap(h=>(h.widgets||[]).map(w=>w.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:f,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"})})})]}),l.map((h,w)=>{const E=h.title||"Unknown Node",C=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:E}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:C.map((S,_)=>{const F=S.name;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${r[F]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:$=>o(F,$),children:r[F]&&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:F})]},`widget-${_}`)})})})]},`node-${w}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:h=>u(h),disabled:!c,className:`px-3 py-1.5 text-xs ${c?"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"})})]})},dt=({selectedNodes:l,paramTestValues:o,selectedParams:r,updateParamTestValues:u,toggleDropdown:f,openDropdowns:m,handleTestValueSelect:c,searchTerms:h,handleSearch:w,handleSelectAll:E,handleNext:C,handlePrevious:S,handleClose:_,inputValues:F,setInputValues:$,textInputs:H,handleTextInputChange:W,handleAddTextInput:A,handleRemoveTextInput:N,openAiWritingModal:T})=>{const D=(d,k,V,Y=0)=>{if(d=isNaN(d)?0:d,k=isNaN(k)?100:k,V=isNaN(V)||V<=0?1:V,k{!l||l.length===0||l.forEach(d=>{const k=d.id.toString(),V=d.widgets||{};Object.values(V).forEach(p=>{const M=p.name;if(!r[M])return;if(!(o[k]?.[M]?.length>0)&&p.type==="number"){const x=p.options?.min||0,G=p.options?.max||100,I=(p.options?.step||10)/10,L=p.options?.precision||0,O=D(x,G,I,L);if(O.length>0){u(k,M,O);const B=`${k}_${M}`;$(g=>({...g,[B]:{min:x.toString(),max:G.toString(),step:I.toString()}}))}}if(p.type==="customtext"||p.type.toLowerCase().includes("text")){const x=`${k}_${M}`,G=H[x]||[""];JSON.stringify(G)!==JSON.stringify(o[k]?.[M]||[""])&&u(k,M,G)}})})},[l,r,o,H,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:_,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"})})})]}),l.length>0?l.map((d,k)=>{const V=d.widgets||{},Y=Object.values(V),p=d.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:[d.type," (ID: ",p,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:M=>_(M,k),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:Y.map((M,Q)=>{const x=M.name;if(!r[x])return null;const G=`${p}_${x}`;if(M.type==="customtext"||M.type.toLowerCase().includes("text")){const I=H[G]||[""];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:[x,":"]}),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:()=>T(p,x),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:I.map((L,O)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:`flex-1 border ${L?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:L,onChange:B=>W(p,x,O,B.target.value),required:!0}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>N(p,x,O),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"})})})]},O))}),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:()=>A(p,x),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"]})]},Q)}if(M.type==="number"){const I=M.options?.min||0,L=M.options?.max||100,O=(M.options?.step||10)/10,B=M.options?.precision||0,g=D(I,L,O,B),U=F[G]||{min:I.toString(),max:L.toString(),step:O.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:[x,":"]}),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:U.min,required:!0,onClick:v=>{v.preventDefault(),v.stopPropagation()},onChange:v=>{v.preventDefault(),v.stopPropagation();const P=v.target.value;if($(R=>({...R,[G]:{...R[G],min:P}})),P===""||!isNaN(parseFloat(P))){const R=P===""?0:parseFloat(P),q=parseFloat(U.max||L.toString()),K=parseFloat(U.step||O.toString()),J=D(R,q,K,B);u(p,x,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:U.max,onClick:v=>{v.preventDefault(),v.stopPropagation()},required:!0,onChange:v=>{v.preventDefault(),v.stopPropagation();const P=v.target.value;if($(R=>({...R,[G]:{...R[G],max:P}})),P===""||!isNaN(parseFloat(P))){const R=parseFloat(U.min||I.toString()),q=P===""?R:parseFloat(P),K=parseFloat(U.step||O.toString()),J=D(R,q,K,B);u(p,x,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:U.step,required:!0,onClick:v=>{v.preventDefault(),v.stopPropagation()},onChange:v=>{v.preventDefault(),v.stopPropagation();const P=v.target.value;if($(R=>({...R,[G]:{...R[G],step:P}})),P===""||!isNaN(parseFloat(P))&&parseFloat(P)>0){const R=parseFloat(U.min||I.toString()),q=parseFloat(U.max||L.toString()),K=P===""?1:parseFloat(P),J=D(R,q,K,B);u(p,x,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 v=o[p]?.[x]||g;if(v.length<=10)return v.map((P,R)=>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:q=>{q.stopPropagation(),c(p,x,P,q)},children:[e.jsx("span",{children:P}),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"})})]},R));{const P=v.slice(0,5),R=v.slice(v.length-5);return e.jsxs(e.Fragment,{children:[P.map((q,K)=>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(),c(p,x,q,J)},children:[e.jsx("span",{children:q}),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-${K}`)),e.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),R.map((q,K)=>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(),c(p,x,q,J)},children:[e.jsx("span",{children:q}),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-${K}`))]})}})()})]}),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"})})]},Q)}else if(M.type==="combo"){const I=M.options?.values||[],L=`${p}_${x}`,O=g=>typeof g=="string"?g:g&&typeof g=="object"&&"name"in g?g.name:String(g),B=g=>typeof g=="object"&&g!==null&&"name"in g?g.name:g;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:x}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:`appearance-none border ${(o[p]?.[x]||[]).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:g=>{g.preventDefault(),g.stopPropagation(),f(p,x,g)},"data-dropdown":L,children:[e.jsx("span",{children:(o[p]?.[x]||[]).length>0?`${x}: ${(o[p]?.[x]||[]).length} selected`:`Select ${x}`}),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"})})})]}),m[L]&&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 m[L]=="object"?`${m[L].y}px`:"0px",left:typeof m[L]=="object"?`${m[L].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[L]||"",onChange:g=>{g.preventDefault(),g.stopPropagation(),w(p,x,g.target.value)},onClick:g=>{g.preventDefault(),g.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:g=>{g.preventDefault(),g.stopPropagation();const v=I.filter(P=>!h[L]||O(P).toLowerCase().includes((h[L]||"").toLowerCase())).map(B);E(p,x,v)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${I.length>0&&(o[p]?.[x]||[]).length===I.length?"bg-blue-500 border-blue-500":(o[p]?.[x]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(o[p]?.[x]||[]).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:I.length>0&&(o[p]?.[x]||[]).length===I.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[I.filter(g=>!h[L]||O(g).toLowerCase().includes((h[L]||"").toLowerCase())).map((g,U)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:v=>{v.preventDefault(),v.stopPropagation(),c(p,x,B(g),v)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(o[p]?.[x]||[]).includes(B(g))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(o[p]?.[x]||[]).includes(B(g))&&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:O(g)})]},U)),I.filter(g=>!h[L]||O(g).toLowerCase().includes((h[L]||"").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"}),(o[p]?.[x]||[]).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:(o[p]?.[x]||[]).map((g,U)=>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:g}),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:v=>{v.preventDefault(),v.stopPropagation(),c(p,x,g,v)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},U))})]})]},Q)}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:x})}),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:[(o[p]?.[x]||[]).map((I,L)=>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:I}),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:O=>{O.preventDefault(),O.stopPropagation(),c(p,x,I,O)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},L)),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:I=>{I.preventDefault(),I.stopPropagation();const L=`${x}${(o[p]?.[x]||[]).length+1}`;u(p,x,[...o[p]?.[x]||[],L])},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"})]})]})]})]},Q)})})]},k)}):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:d=>S(d),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:d=>C(d),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},xt=({selectedNodes:l,paramTestValues:o,selectedParams:r,totalCount:u,errorMessage:f,handlePrevious:m,handleStartGeneration:c,handleClose:h})=>{const[w,E]=j.useState([]),[C,S]=j.useState(null),[_,F]=j.useState(!1);Ee();const $=()=>{const W=Object.values(Z.graph._nodes_by_id),A=[],N=[];for(const D of W)D.type==="SaveImage"?A.push(D.id):D.type==="PreviewImage"&&N.push(D.id);const T=[...A,...N];E(T),T.length===1?S(T[0]):T.length>1&&(F(!0),S(null))};j.useEffect(()=>{$()},[]),j.useEffect(()=>{const W=()=>{if(!Z.canvas.selected_nodes)return;const A=Object.values(Z.canvas.selected_nodes);if(A.length===0)return;const N=A[0];N&&(N.type==="SaveImage"||N.type==="PreviewImage")&&(console.log("Selected image node:",N.id),S(N.id))};return document.addEventListener("click",W),()=>{document.removeEventListener("click",W)}},[]);const H=W=>{if(W&&(W.preventDefault(),W.stopPropagation()),w.length>1&&!C){F(!0);return}c(W,C||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"})})})]}),_&&w.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:C===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${w.join(",")}. Please click the node on canvas.`:`Current node ID is ${C}, please click Start Generation again`})]})}),f&&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:f})]})}),l.length>0?l.map((W,A)=>{const N=W.type||"Unknown Node",T=W.widgets||[],D=W.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:[N," (ID: ",D,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:T.map((d,k)=>{const V=d.name;if(!r[V])return null;const Y=o[D]?.[V]||[],p=Array.isArray(Y)?`[${Y.join(", ")}]`:JSON.stringify(Y);return e.jsxs("div",{className:kM.preventDefault()})})]},k)})})]},A)}):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:W=>m(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=>H(W),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${w.length>1&&!C?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:w.length>1&&!C,children:"Start Generation"})]})]})},ut=({selectedNodes:l,paramTestValues:o,selectedParams:r,totalCount:u,completedCount:f,errorMessage:m,handleClose:c,setIsProcessing:h,setCurrentScreen:w,cleanupPolling:E})=>{const C=S=>{S.preventDefault(),S.stopPropagation(),st({clear:!0}),rt(),E&&E(),h(!1),w(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 ",f," 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:`${f/u*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",f," images"]}),e.jsx("button",{onClick:C,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:c,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"})})})]}),m&&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:m})]})}),l.length>0?l.map((S,_)=>{const F=S.type||"Unknown Node",$=S.widgets||[],H=S.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:[F," (ID: ",H,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:$.map((W,A)=>{const N=W.name;if(!r[N])return null;const T=o[H]?.[N]||[],D=Array.isArray(T)?`[${T.join(", ")}]`:JSON.stringify(T);return e.jsxs("div",{className:A<$.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:N}),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:d=>d.preventDefault()})})]},A)})})]},_)}):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."})]})},mt=({generatedImages:l,selectedImageIndex:o,handleSelectImage:r,handleApplySelected:u,handlePrevious:f,handleClose:m,currentPage:c,handlePageChange:h,imagesPerPage:w,notificationVisible:E,modalVisible:C,modalImageUrl:S,openImageModal:_,closeImageModal:F})=>{const $=Math.ceil(l.length/w),H=(c-1)*w,W=Math.min(H+w,l.length),A=l.slice(H,W);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 ",l.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:m,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),E&&e.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"py-1",children:e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),C&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50",onClick:F,children:e.jsxs("div",{className:"bg-white rounded-lg p-2 max-w-4xl max-h-[90vh] relative",onClick:N=>N.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:F,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:S,alt:"Enlarged image",className:"max-w-full h-auto"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:A.map((N,T)=>{const D=H+T;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${o===D?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:d=>r(D,d),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:d=>_(N.url,d),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:N.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(N.params).filter(([d,k])=>d!=="nodeParams"&&typeof k!="object").map(([d,k])=>e.jsxs("div",{children:[d,": ",String(k)]},d))})]},D)})}),$>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:N=>h(1,N),disabled:c===1,className:`px-2 py-1 rounded ${c===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:N=>h(c-1,N),disabled:c===1,className:`px-2 py-1 rounded ${c===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 ",c," of ",$]}),e.jsx("button",{onClick:N=>h(c+1,N),disabled:c===$,className:`px-2 py-1 rounded ${c===$?"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:N=>h($,N),disabled:c===$,className:`px-2 py-1 rounded ${c===$?"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:N=>f(N),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:N=>u(N),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:o===null,children:"Apply Selected"})]})]})},ht=({visible:l,aiWritingModalText:o,setAiWritingModalText:r,aiGeneratedTexts:u,aiSelectedTexts:f,aiWritingLoading:m,aiWritingError:c,handleAiWriting:h,toggleTextSelection:w,addSelectedTexts:E,onClose:C})=>l?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:C,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-600 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:"w-full border border-gray-300 rounded-md p-2 text-sm",rows:3,placeholder:"Enter some text here...",value:o,onChange:S=>r(S.target.value)}),e.jsx("button",{className:"mt-2 px-4 py-2 bg-blue-100 text-blue-700 rounded-md text-sm flex items-center hover:bg-blue-200 transition-colors",onClick:h,disabled:m,children:m?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-blue-700",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):e.jsx(e.Fragment,{children:"Generate"})})]}),c&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-sm",children:c}),u.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Generated variations (select items to add):"}),e.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:u.map((S,_)=>e.jsxs("div",{className:"flex items-start border border-gray-200 rounded-md p-2",children:[e.jsx("div",{className:"mr-2 mt-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",id:`text${_+1}`,checked:!!f[`text${_+1}`],onChange:()=>w(`text${_+1}`),className:"sr-only"}),e.jsx("div",{className:`h-4 w-4 rounded border ${f[`text${_+1}`]?"bg-blue-600 border-blue-600":"bg-white border-gray-300"} flex items-center justify-center`,onClick:()=>w(`text${_+1}`),children:f[`text${_+1}`]&&e.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),e.jsx("label",{htmlFor:`text${_+1}`,className:"text-sm text-gray-700 cursor-pointer flex-1",children:S})]},_))})]})]}),e.jsxs("div",{className:"p-4 border-t flex justify-end flex-shrink-0",children:[e.jsx("button",{className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-md text-sm mr-2 hover:bg-gray-200 transition-colors",onClick:C,children:"Cancel"}),e.jsx("button",{className:"px-4 py-2 bg-blue-500 text-white rounded-md text-sm hover:bg-blue-600 transition-colors",onClick:E,disabled:Object.values(f).every(S=>!S),children:"Add Selected"})]})]})}):null,ke=l=>{const o=[],r={};if(Object.keys(l).forEach(m=>{const c=parseInt(m),h=l[m]||{},w=Object.keys(h).filter(C=>h[C]&&h[C].length>0);if(w.length===0)return;const E=[[]];w.forEach(C=>{const S=h[C],_=[];E.forEach(F=>{S.forEach($=>{const H=[...F,{nodeId:c,paramName:C,paramValue:String($)}];_.push(H)})}),E.length=0,E.push(..._)}),r[m]=E}),Object.keys(r).length===0)return o;if(Object.keys(r).length===1){const m=Object.keys(r)[0];return r[m]}const u=Object.keys(r);let f=r[u[0]];for(let m=1;m{c.forEach(E=>{h.push([...w,...E])})}),f=h}return f},pt=(l,o)=>{const r={};r.nodeParams={};const u=ke(l);return o{const c=m.nodeId.toString(),h=m.paramName,w=m.paramValue;r.nodeParams[c]||(r.nodeParams[c]={}),r.nodeParams[c][h]=w,r[h]=w}),r},gt=` +import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as j}from"./vendor-react-V04_Axys.js";import{r as et,g as tt,m as st,i as rt}from"./workflowChat-BMjjRVAR.js";import{a as Z,u as Ee,g as Ne,W as xe}from"./message-components-cb3Dm8vl.js";import"./input.js";import"./App-Dk85TURt.js";function nt(l,o){try{if(!l)return console.error("Invalid prompt_output: ",l),l;for(const r of o){if(!l[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!l[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}l[r.nodeId].inputs[r.paramName]=r.paramValue}return l}catch(r){return console.error("Error updating prompt:",r),l}}async function ot(l){const o=await Z.graphToPrompt(),r=nt(o.output,l);console.log("queuePrompt updated_prompt:",r);const u={prompt:r,client_id:Z.api.clientId,extra_data:{extra_pageinfo:{workflow:o.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const f=await et(u);return console.debug("queuePrompt response:",f),f}function _e(l){const o=document.createElement("canvas"),r=o.getContext("2d");if(o.width=512,o.height=512,r){r.fillStyle="#f8d7da",r.fillRect(0,0,o.width,o.height),r.strokeStyle="#dc3545",r.lineWidth=4,r.strokeRect(10,10,o.width-20,o.height-20),r.fillStyle="#dc3545",r.beginPath(),r.arc(o.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("!",o.width/2,150),r.fillStyle="#721c24",r.font="20px Arial",r.textAlign="center",r.textBaseline="middle";const u=o.width-60,f=30,m=l.split(" ");let c="",h=250;for(let w=0;wu&&w>0?(r.fillText(c,o.width/2,h),c=m[w]+" ",h+=f):c=E}r.fillText(c,o.width/2,h)}return o.toDataURL("image/png")}async function at(l){try{if(!l||l==="")return console.log("No prompt ID provided"),{1:[_e("Fail to generate prompt ID")]};const o=await tt(l);if(!o||!o[l])return console.log("Not finished for prompt ID:",l),{};const r=o[l];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",l);const f=r.status.messages;if(f&&f.length>0){const m=f[f.length-1];if(m&&m.length>0){const c=m[0];return{1:[_e(c)]}}}}const u={};if(r.outputs)for(const f in r.outputs){const m=r.outputs[f];if(m&&m.images){u[f]=[];for(const c of m.images)if(c&&c.filename&&c.type){const h=Z.graph._nodes_by_id[f].imgs[0].currentSrc.split("?")[0];u[f].push(h+"?filename="+encodeURIComponent(c.filename)+"&type="+encodeURIComponent(c.type)+(c.subfolder?"&subfolder="+encodeURIComponent(c.subfolder):""))}console.log("outputImages for nodeId:",f,u[f])}}return u}catch(o){throw console.error("Error getting output images from prompt:",o),o}}function lt(){const l=Object.values(Z.graph._nodes_by_id),o=[],r=[];for(const u of l)u.type==="SaveImage"?o.push(u.id):u.type==="PreviewImage"&&r.push(u.id);if(console.log("saveNodeIds:",o),console.log("previewNodeIds:",r),o.length===0&&r.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return o.length===1?o[0]:o.length==0&&r.length===1?r[0]:null}async function it(l,o){const r=await at(l);return Object.keys(r).length===0?null:r[o.toString()]&&r[o.toString()].length>0?r[o.toString()][0]:null}const ct=({selectedNodes:l,handleParamSelect:o,selectedParams:r,handleNext:u,handleClose:f})=>{const c=l.flatMap(h=>(h.widgets||[]).map(w=>w.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:f,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"})})})]}),l.map((h,w)=>{const E=h.title||"Unknown Node",C=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:E}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:C.map((S,_)=>{const F=S.name;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${r[F]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:$=>o(F,$),children:r[F]&&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:F})]},`widget-${_}`)})})})]},`node-${w}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:h=>u(h),disabled:!c,className:`px-3 py-1.5 text-xs ${c?"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"})})]})},dt=({selectedNodes:l,paramTestValues:o,selectedParams:r,updateParamTestValues:u,toggleDropdown:f,openDropdowns:m,handleTestValueSelect:c,searchTerms:h,handleSearch:w,handleSelectAll:E,handleNext:C,handlePrevious:S,handleClose:_,inputValues:F,setInputValues:$,textInputs:H,handleTextInputChange:W,handleAddTextInput:A,handleRemoveTextInput:N,openAiWritingModal:T})=>{const D=(d,k,V,Y=0)=>{if(d=isNaN(d)?0:d,k=isNaN(k)?100:k,V=isNaN(V)||V<=0?1:V,k{!l||l.length===0||l.forEach(d=>{const k=d.id.toString(),V=d.widgets||{};Object.values(V).forEach(p=>{const M=p.name;if(!r[M])return;if(!(o[k]?.[M]?.length>0)&&p.type==="number"){const x=p.options?.min||0,G=p.options?.max||100,I=(p.options?.step||10)/10,L=p.options?.precision||0,O=D(x,G,I,L);if(O.length>0){u(k,M,O);const B=`${k}_${M}`;$(g=>({...g,[B]:{min:x.toString(),max:G.toString(),step:I.toString()}}))}}if(p.type==="customtext"||p.type.toLowerCase().includes("text")){const x=`${k}_${M}`,G=H[x]||[""];JSON.stringify(G)!==JSON.stringify(o[k]?.[M]||[""])&&u(k,M,G)}})})},[l,r,o,H,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:_,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"})})})]}),l.length>0?l.map((d,k)=>{const V=d.widgets||{},Y=Object.values(V),p=d.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:[d.type," (ID: ",p,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:M=>_(M,k),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:Y.map((M,Q)=>{const x=M.name;if(!r[x])return null;const G=`${p}_${x}`;if(M.type==="customtext"||M.type.toLowerCase().includes("text")){const I=H[G]||[""];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:[x,":"]}),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:()=>T(p,x),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:I.map((L,O)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:`flex-1 border ${L?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:L,onChange:B=>W(p,x,O,B.target.value),required:!0}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>N(p,x,O),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"})})})]},O))}),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:()=>A(p,x),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"]})]},Q)}if(M.type==="number"){const I=M.options?.min||0,L=M.options?.max||100,O=(M.options?.step||10)/10,B=M.options?.precision||0,g=D(I,L,O,B),U=F[G]||{min:I.toString(),max:L.toString(),step:O.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:[x,":"]}),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:U.min,required:!0,onClick:v=>{v.preventDefault(),v.stopPropagation()},onChange:v=>{v.preventDefault(),v.stopPropagation();const P=v.target.value;if($(R=>({...R,[G]:{...R[G],min:P}})),P===""||!isNaN(parseFloat(P))){const R=P===""?0:parseFloat(P),q=parseFloat(U.max||L.toString()),K=parseFloat(U.step||O.toString()),J=D(R,q,K,B);u(p,x,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:U.max,onClick:v=>{v.preventDefault(),v.stopPropagation()},required:!0,onChange:v=>{v.preventDefault(),v.stopPropagation();const P=v.target.value;if($(R=>({...R,[G]:{...R[G],max:P}})),P===""||!isNaN(parseFloat(P))){const R=parseFloat(U.min||I.toString()),q=P===""?R:parseFloat(P),K=parseFloat(U.step||O.toString()),J=D(R,q,K,B);u(p,x,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:U.step,required:!0,onClick:v=>{v.preventDefault(),v.stopPropagation()},onChange:v=>{v.preventDefault(),v.stopPropagation();const P=v.target.value;if($(R=>({...R,[G]:{...R[G],step:P}})),P===""||!isNaN(parseFloat(P))&&parseFloat(P)>0){const R=parseFloat(U.min||I.toString()),q=parseFloat(U.max||L.toString()),K=P===""?1:parseFloat(P),J=D(R,q,K,B);u(p,x,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 v=o[p]?.[x]||g;if(v.length<=10)return v.map((P,R)=>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:q=>{q.stopPropagation(),c(p,x,P,q)},children:[e.jsx("span",{children:P}),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"})})]},R));{const P=v.slice(0,5),R=v.slice(v.length-5);return e.jsxs(e.Fragment,{children:[P.map((q,K)=>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(),c(p,x,q,J)},children:[e.jsx("span",{children:q}),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-${K}`)),e.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),R.map((q,K)=>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(),c(p,x,q,J)},children:[e.jsx("span",{children:q}),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-${K}`))]})}})()})]}),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"})})]},Q)}else if(M.type==="combo"){const I=M.options?.values||[],L=`${p}_${x}`,O=g=>typeof g=="string"?g:g&&typeof g=="object"&&"name"in g?g.name:String(g),B=g=>typeof g=="object"&&g!==null&&"name"in g?g.name:g;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:x}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:`appearance-none border ${(o[p]?.[x]||[]).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:g=>{g.preventDefault(),g.stopPropagation(),f(p,x,g)},"data-dropdown":L,children:[e.jsx("span",{children:(o[p]?.[x]||[]).length>0?`${x}: ${(o[p]?.[x]||[]).length} selected`:`Select ${x}`}),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"})})})]}),m[L]&&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 m[L]=="object"?`${m[L].y}px`:"0px",left:typeof m[L]=="object"?`${m[L].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[L]||"",onChange:g=>{g.preventDefault(),g.stopPropagation(),w(p,x,g.target.value)},onClick:g=>{g.preventDefault(),g.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:g=>{g.preventDefault(),g.stopPropagation();const v=I.filter(P=>!h[L]||O(P).toLowerCase().includes((h[L]||"").toLowerCase())).map(B);E(p,x,v)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${I.length>0&&(o[p]?.[x]||[]).length===I.length?"bg-blue-500 border-blue-500":(o[p]?.[x]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(o[p]?.[x]||[]).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:I.length>0&&(o[p]?.[x]||[]).length===I.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[I.filter(g=>!h[L]||O(g).toLowerCase().includes((h[L]||"").toLowerCase())).map((g,U)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:v=>{v.preventDefault(),v.stopPropagation(),c(p,x,B(g),v)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(o[p]?.[x]||[]).includes(B(g))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(o[p]?.[x]||[]).includes(B(g))&&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:O(g)})]},U)),I.filter(g=>!h[L]||O(g).toLowerCase().includes((h[L]||"").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"}),(o[p]?.[x]||[]).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:(o[p]?.[x]||[]).map((g,U)=>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:g}),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:v=>{v.preventDefault(),v.stopPropagation(),c(p,x,g,v)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},U))})]})]},Q)}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:x})}),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:[(o[p]?.[x]||[]).map((I,L)=>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:I}),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:O=>{O.preventDefault(),O.stopPropagation(),c(p,x,I,O)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},L)),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:I=>{I.preventDefault(),I.stopPropagation();const L=`${x}${(o[p]?.[x]||[]).length+1}`;u(p,x,[...o[p]?.[x]||[],L])},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"})]})]})]})]},Q)})})]},k)}):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:d=>S(d),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:d=>C(d),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},xt=({selectedNodes:l,paramTestValues:o,selectedParams:r,totalCount:u,errorMessage:f,handlePrevious:m,handleStartGeneration:c,handleClose:h})=>{const[w,E]=j.useState([]),[C,S]=j.useState(null),[_,F]=j.useState(!1);Ee();const $=()=>{const W=Object.values(Z.graph._nodes_by_id),A=[],N=[];for(const D of W)D.type==="SaveImage"?A.push(D.id):D.type==="PreviewImage"&&N.push(D.id);const T=[...A,...N];E(T),T.length===1?S(T[0]):T.length>1&&(F(!0),S(null))};j.useEffect(()=>{$()},[]),j.useEffect(()=>{const W=()=>{if(!Z.canvas.selected_nodes)return;const A=Object.values(Z.canvas.selected_nodes);if(A.length===0)return;const N=A[0];N&&(N.type==="SaveImage"||N.type==="PreviewImage")&&(console.log("Selected image node:",N.id),S(N.id))};return document.addEventListener("click",W),()=>{document.removeEventListener("click",W)}},[]);const H=W=>{if(W&&(W.preventDefault(),W.stopPropagation()),w.length>1&&!C){F(!0);return}c(W,C||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"})})})]}),_&&w.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:C===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${w.join(",")}. Please click the node on canvas.`:`Current node ID is ${C}, please click Start Generation again`})]})}),f&&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:f})]})}),l.length>0?l.map((W,A)=>{const N=W.type||"Unknown Node",T=W.widgets||[],D=W.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:[N," (ID: ",D,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:T.map((d,k)=>{const V=d.name;if(!r[V])return null;const Y=o[D]?.[V]||[],p=Array.isArray(Y)?`[${Y.join(", ")}]`:JSON.stringify(Y);return e.jsxs("div",{className:kM.preventDefault()})})]},k)})})]},A)}):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:W=>m(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=>H(W),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${w.length>1&&!C?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:w.length>1&&!C,children:"Start Generation"})]})]})},ut=({selectedNodes:l,paramTestValues:o,selectedParams:r,totalCount:u,completedCount:f,errorMessage:m,handleClose:c,setIsProcessing:h,setCurrentScreen:w,cleanupPolling:E})=>{const C=S=>{S.preventDefault(),S.stopPropagation(),st({clear:!0}),rt(),E&&E(),h(!1),w(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 ",f," 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:`${f/u*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",f," images"]}),e.jsx("button",{onClick:C,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:c,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"})})})]}),m&&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:m})]})}),l.length>0?l.map((S,_)=>{const F=S.type||"Unknown Node",$=S.widgets||[],H=S.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:[F," (ID: ",H,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:$.map((W,A)=>{const N=W.name;if(!r[N])return null;const T=o[H]?.[N]||[],D=Array.isArray(T)?`[${T.join(", ")}]`:JSON.stringify(T);return e.jsxs("div",{className:A<$.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:N}),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:d=>d.preventDefault()})})]},A)})})]},_)}):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."})]})},mt=({generatedImages:l,selectedImageIndex:o,handleSelectImage:r,handleApplySelected:u,handlePrevious:f,handleClose:m,currentPage:c,handlePageChange:h,imagesPerPage:w,notificationVisible:E,modalVisible:C,modalImageUrl:S,openImageModal:_,closeImageModal:F})=>{const $=Math.ceil(l.length/w),H=(c-1)*w,W=Math.min(H+w,l.length),A=l.slice(H,W);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 ",l.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:m,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),E&&e.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"py-1",children:e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),C&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50",onClick:F,children:e.jsxs("div",{className:"bg-white rounded-lg p-2 max-w-4xl max-h-[90vh] relative",onClick:N=>N.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:F,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:S,alt:"Enlarged image",className:"max-w-full h-auto"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:A.map((N,T)=>{const D=H+T;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${o===D?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:d=>r(D,d),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:d=>_(N.url,d),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:N.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(N.params).filter(([d,k])=>d!=="nodeParams"&&typeof k!="object").map(([d,k])=>e.jsxs("div",{children:[d,": ",String(k)]},d))})]},D)})}),$>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:N=>h(1,N),disabled:c===1,className:`px-2 py-1 rounded ${c===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:N=>h(c-1,N),disabled:c===1,className:`px-2 py-1 rounded ${c===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 ",c," of ",$]}),e.jsx("button",{onClick:N=>h(c+1,N),disabled:c===$,className:`px-2 py-1 rounded ${c===$?"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:N=>h($,N),disabled:c===$,className:`px-2 py-1 rounded ${c===$?"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:N=>f(N),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:N=>u(N),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:o===null,children:"Apply Selected"})]})]})},ht=({visible:l,aiWritingModalText:o,setAiWritingModalText:r,aiGeneratedTexts:u,aiSelectedTexts:f,aiWritingLoading:m,aiWritingError:c,handleAiWriting:h,toggleTextSelection:w,addSelectedTexts:E,onClose:C})=>l?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:C,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-600 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:"w-full border border-gray-300 rounded-md p-2 text-sm",rows:3,placeholder:"Enter some text here...",value:o,onChange:S=>r(S.target.value)}),e.jsx("button",{className:"mt-2 px-4 py-2 bg-blue-100 text-blue-700 rounded-md text-sm flex items-center hover:bg-blue-200 transition-colors",onClick:h,disabled:m,children:m?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-blue-700",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):e.jsx(e.Fragment,{children:"Generate"})})]}),c&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-sm",children:c}),u.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Generated variations (select items to add):"}),e.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:u.map((S,_)=>e.jsxs("div",{className:"flex items-start border border-gray-200 rounded-md p-2",children:[e.jsx("div",{className:"mr-2 mt-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",id:`text${_+1}`,checked:!!f[`text${_+1}`],onChange:()=>w(`text${_+1}`),className:"sr-only"}),e.jsx("div",{className:`h-4 w-4 rounded border ${f[`text${_+1}`]?"bg-blue-600 border-blue-600":"bg-white border-gray-300"} flex items-center justify-center`,onClick:()=>w(`text${_+1}`),children:f[`text${_+1}`]&&e.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),e.jsx("label",{htmlFor:`text${_+1}`,className:"text-sm text-gray-700 cursor-pointer flex-1",children:S})]},_))})]})]}),e.jsxs("div",{className:"p-4 border-t flex justify-end flex-shrink-0",children:[e.jsx("button",{className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-md text-sm mr-2 hover:bg-gray-200 transition-colors",onClick:C,children:"Cancel"}),e.jsx("button",{className:"px-4 py-2 bg-blue-500 text-white rounded-md text-sm hover:bg-blue-600 transition-colors",onClick:E,disabled:Object.values(f).every(S=>!S),children:"Add Selected"})]})]})}):null,ke=l=>{const o=[],r={};if(Object.keys(l).forEach(m=>{const c=parseInt(m),h=l[m]||{},w=Object.keys(h).filter(C=>h[C]&&h[C].length>0);if(w.length===0)return;const E=[[]];w.forEach(C=>{const S=h[C],_=[];E.forEach(F=>{S.forEach($=>{const H=[...F,{nodeId:c,paramName:C,paramValue:String($)}];_.push(H)})}),E.length=0,E.push(..._)}),r[m]=E}),Object.keys(r).length===0)return o;if(Object.keys(r).length===1){const m=Object.keys(r)[0];return r[m]}const u=Object.keys(r);let f=r[u[0]];for(let m=1;m{c.forEach(E=>{h.push([...w,...E])})}),f=h}return f},pt=(l,o)=>{const r={};r.nodeParams={};const u=ke(l);return o{const c=m.nodeId.toString(),h=m.paramName,w=m.paramValue;r.nodeParams[c]||(r.nodeParams[c]={}),r.nodeParams[c][h]=w,r[h]=w}),r},gt=` @keyframes highlight-pulse { 0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); diff --git a/dist/copilot_web/WorkflowOption-DPhIatDg.js b/dist/copilot_web/WorkflowOption-C6m4gAXH.js similarity index 98% rename from dist/copilot_web/WorkflowOption-DPhIatDg.js rename to dist/copilot_web/WorkflowOption-C6m4gAXH.js index 75d2569..ff6d8cf 100644 --- a/dist/copilot_web/WorkflowOption-DPhIatDg.js +++ b/dist/copilot_web/WorkflowOption-C6m4gAXH.js @@ -1 +1 @@ -import{j as t}from"./vendor-markdown-Dek94WS0.js";import{W as f,g as u,a as p}from"./message-components-yQk9DI7R.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}; +import{j as t}from"./vendor-markdown-Dek94WS0.js";import{W as f,g as u,a as p}from"./message-components-cb3Dm8vl.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 8c91bbe..8e57933 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-By_5x9Zk.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-yQk9DI7R.js"])))=>i.map(i=>d[i]); -import{j as u}from"./vendor-markdown-Dek94WS0.js";import{a as v,R as p}from"./vendor-react-V04_Axys.js";import{w}from"./message-components-yQk9DI7R.js";const R="modulepreload",b=function(e){return"/"+e},m={},P=function(a,s,S){let d=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(s.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=c?"stylesheet":R,c||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),c)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function l(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&l(t.reason);return a().catch(l)})};var i={},f=v;i.createRoot=f.createRoot,i.hydrateRoot=f.hydrateRoot;const _=p.lazy(()=>P(async()=>{const{default:e}=await import("./App-By_5x9Zk.js").then(a=>a.A);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>({default:e})));function A(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}A().then(()=>w()).then(()=>{const e=document.createElement("div");e.id="comfyui-copilot-plugin",document.body.append(e),i.createRoot(e).render(u.jsx(p.StrictMode,{children:u.jsx(_,{})}))});export{P as _}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-Dk85TURt.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-cb3Dm8vl.js"])))=>i.map(i=>d[i]); +import{j as u}from"./vendor-markdown-Dek94WS0.js";import{a as v,R as p}from"./vendor-react-V04_Axys.js";import{w}from"./message-components-cb3Dm8vl.js";const R="modulepreload",b=function(e){return"/"+e},m={},P=function(a,s,S){let d=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(s.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=c?"stylesheet":R,c||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),c)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function l(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&l(t.reason);return a().catch(l)})};var i={},f=v;i.createRoot=f.createRoot,i.hydrateRoot=f.hydrateRoot;const _=p.lazy(()=>P(async()=>{const{default:e}=await import("./App-Dk85TURt.js").then(a=>a.A);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>({default:e})));function A(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}A().then(()=>w()).then(()=>{const e=document.createElement("div");e.id="comfyui-copilot-plugin",document.body.append(e),i.createRoot(e).render(u.jsx(p.StrictMode,{children:u.jsx(_,{})}))});export{P as _}; diff --git a/dist/copilot_web/message-components-yQk9DI7R.js b/dist/copilot_web/message-components-cb3Dm8vl.js similarity index 99% rename from dist/copilot_web/message-components-yQk9DI7R.js rename to dist/copilot_web/message-components-cb3Dm8vl.js index a130867..1da02a6 100644 --- a/dist/copilot_web/message-components-yQk9DI7R.js +++ b/dist/copilot_web/message-components-cb3Dm8vl.js @@ -145,9 +145,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,o=!1,s;return{s:function(){e=e.call(i)},n:function(){var l=e.next();return a=l.done,l},e:function(l){o=!0,s=l},f:function(){try{!a&&e.return!=null&&e.return()}finally{if(o)throw s}}}}function Ope(i,r){var e;if(i){if(typeof i=="string")return V$(i,r);var t=rt(e=Object.prototype.toString.call(i)).call(e,8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return hn(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return V$(i,r)}}function V$(i,r){(r==null||r>i.length)&&(r=i.length);for(var e=0,t=new Array(r);e0&&this.options.deleteNode!==!1?(u===!0&&this._createSeperator(4),this._createDeleteButton(s)):n===0&&this.options.deleteEdge!==!1&&(u===!0&&this._createSeperator(4),this._createDeleteButton(s))),this._bindElementEvents(this.closeDiv,k(e=this.toggleEditMode).call(e,this)),this._temporaryBindEvent("select",k(t=this.showManipulatorToolbar).call(t,this))}this.body.emitter.emit("_redraw")}},{key:"addNodeMode",value:function(){var e;if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addNode",this.guiEnabled===!0){var t,n=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(n),this._createSeperator(),this._createDescription(n.addDescription||this.options.locales.en.addDescription),this._bindElementEvents(this.closeDiv,k(t=this.toggleEditMode).call(t,this))}this._temporaryBindEvent("click",k(e=this._performAddNode).call(e,this))}},{key:"editNode",value:function(){var e=this;this.editMode!==!0&&this.enableEditMode(),this._clean();var t=this.selectionHandler.getSelectedNodes()[0];if(t!==void 0)if(this.inMode="editNode",typeof this.options.editNode=="function")if(t.isCluster!==!0){var n=pe({},t.options,!1);if(n.x=t.x,n.y=t.y,this.options.editNode.length===2)this.options.editNode(n,function(a){a!=null&&e.inMode==="editNode"&&e.body.data.nodes.getDataSet().update(a),e.showManipulatorToolbar()});else throw new Error("The function for edit does not support two arguments (data, callback)")}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError);else throw new Error("No function has been configured to handle the editing of nodes.");else this.showManipulatorToolbar()}},{key:"addEdgeMode",value:function(){var e,t,n,a,o;if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addEdge",this.guiEnabled===!0){var s,u=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(u),this._createSeperator(),this._createDescription(u.edgeDescription||this.options.locales.en.edgeDescription),this._bindElementEvents(this.closeDiv,k(s=this.toggleEditMode).call(s,this))}this._temporaryBindUI("onTouch",k(e=this._handleConnect).call(e,this)),this._temporaryBindUI("onDragEnd",k(t=this._finishConnect).call(t,this)),this._temporaryBindUI("onDrag",k(n=this._dragControlNode).call(n,this)),this._temporaryBindUI("onRelease",k(a=this._finishConnect).call(a,this)),this._temporaryBindUI("onDragStart",k(o=this._dragStartEdge).call(o,this)),this._temporaryBindUI("onHold",function(){})}},{key:"editEdgeMode",value:function(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="editEdge",de(this.options.editEdge)==="object"&&typeof this.options.editEdge.editWithoutDrag=="function"&&(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0)){var e=this.body.edges[this.edgeBeingEditedId];this._performEditEdge(e.from.id,e.to.id);return}if(this.guiEnabled===!0){var t,n=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(n),this._createSeperator(),this._createDescription(n.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindElementEvents(this.closeDiv,k(t=this.toggleEditMode).call(t,this))}if(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0){var a,o,s,u,l=this.body.edges[this.edgeBeingEditedId],h=this._getNewTargetNode(l.from.x,l.from.y),d=this._getNewTargetNode(l.to.x,l.to.y);this.temporaryIds.nodes.push(h.id),this.temporaryIds.nodes.push(d.id),this.body.nodes[h.id]=h,this.body.nodeIndices.push(h.id),this.body.nodes[d.id]=d,this.body.nodeIndices.push(d.id),this._temporaryBindUI("onTouch",k(a=this._controlNodeTouch).call(a,this)),this._temporaryBindUI("onTap",function(){}),this._temporaryBindUI("onHold",function(){}),this._temporaryBindUI("onDragStart",k(o=this._controlNodeDragStart).call(o,this)),this._temporaryBindUI("onDrag",k(s=this._controlNodeDrag).call(s,this)),this._temporaryBindUI("onDragEnd",k(u=this._controlNodeDragEnd).call(u,this)),this._temporaryBindUI("onMouseMove",function(){}),this._temporaryBindEvent("beforeDrawing",function(c){var f=l.edgeType.findBorderPositions(c);h.selected===!1&&(h.x=f.from.x,h.y=f.from.y),d.selected===!1&&(d.x=f.to.x,d.y=f.to.y)}),this.body.emitter.emit("_redraw")}else this.showManipulatorToolbar()}},{key:"deleteSelected",value:function(){var e=this;this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="delete";var t=this.selectionHandler.getSelectedNodeIds(),n=this.selectionHandler.getSelectedEdgeIds(),a=void 0;if(t.length>0){for(var o=0;o0&&typeof this.options.deleteEdge=="function"&&(a=this.options.deleteEdge);if(typeof a=="function"){var s={nodes:t,edges:n};if(a.length===2)a(s,function(u){u!=null&&e.inMode==="delete"?(e.body.data.edges.getDataSet().remove(u.edges),e.body.data.nodes.getDataSet().remove(u.nodes),e.body.emitter.emit("startSimulation"),e.showManipulatorToolbar()):(e.body.emitter.emit("startSimulation"),e.showManipulatorToolbar())});else throw new Error("The function for delete does not support two arguments (data, callback)")}else this.body.data.edges.getDataSet().remove(n),this.body.data.nodes.getDataSet().remove(t),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}},{key:"_setup",value:function(){this.options.enabled===!0?(this.guiEnabled=!0,this._createWrappers(),this.editMode===!1?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}},{key:"_createWrappers",value:function(){if(this.manipulationDiv===void 0&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",this.editMode===!0?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),this.editModeDiv===void 0&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",this.editMode===!0?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),this.closeDiv===void 0){var e,t;this.closeDiv=document.createElement("button"),this.closeDiv.className="vis-close",this.closeDiv.setAttribute("aria-label",(e=(t=this.options.locales[this.options.locale])===null||t===void 0?void 0:t.close)!==null&&e!==void 0?e:this.options.locales.en.close),this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv)}}},{key:"_getNewTargetNode",value:function(e,t){var n=pe({},this.options.controlNodeStyle);n.id="targetNode"+no(),n.hidden=!1,n.physics=!1,n.x=e,n.y=t;var a=this.body.functions.createNode(n);return a.shape.boundingBox={left:e,right:e,top:t,bottom:t},a}},{key:"_createEditButton",value:function(){var e;this._clean(),this.manipulationDOM={},Yr(this.editModeDiv);var t=this.options.locales[this.options.locale],n=this._createButton("editMode","vis-edit vis-edit-mode",t.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(n),this._bindElementEvents(n,k(e=this.toggleEditMode).call(e,this))}},{key:"_clean",value:function(){this.inMode=!1,this.guiEnabled===!0&&(Yr(this.editModeDiv),Yr(this.manipulationDiv),this._cleanupDOMEventListeners()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}},{key:"_cleanupDOMEventListeners",value:function(){var e,t=Spe(Ar(e=this._domEventListenerCleanupQueue).call(e,0)),n;try{for(t.s();!(n=t.n()).done;){var a=n.value;a()}}catch(o){t.e(o)}finally{t.f()}}},{key:"_removeManipulationDOM",value:function(){this._clean(),Yr(this.manipulationDiv),Yr(this.editModeDiv),Yr(this.closeDiv),this.manipulationDiv&&this.canvas.frame.removeChild(this.manipulationDiv),this.editModeDiv&&this.canvas.frame.removeChild(this.editModeDiv),this.closeDiv&&this.canvas.frame.removeChild(this.closeDiv),this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0}},{key:"_createSeperator",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.manipulationDOM["seperatorLineDiv"+e]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+e].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+e])}},{key:"_createAddNodeButton",value:function(e){var t,n=this._createButton("addNode","vis-add",e.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(n),this._bindElementEvents(n,k(t=this.addNodeMode).call(t,this))}},{key:"_createAddEdgeButton",value:function(e){var t,n=this._createButton("addEdge","vis-connect",e.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(n),this._bindElementEvents(n,k(t=this.addEdgeMode).call(t,this))}},{key:"_createEditNodeButton",value:function(e){var t,n=this._createButton("editNode","vis-edit",e.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(n),this._bindElementEvents(n,k(t=this.editNode).call(t,this))}},{key:"_createEditEdgeButton",value:function(e){var t,n=this._createButton("editEdge","vis-edit",e.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(n),this._bindElementEvents(n,k(t=this.editEdgeMode).call(t,this))}},{key:"_createDeleteButton",value:function(e){var t,n;this.options.rtl?n="vis-delete-rtl":n="vis-delete";var a=this._createButton("delete",n,e.del||this.options.locales.en.del);this.manipulationDiv.appendChild(a),this._bindElementEvents(a,k(t=this.deleteSelected).call(t,this))}},{key:"_createBackButton",value:function(e){var t,n=this._createButton("back","vis-back",e.back||this.options.locales.en.back);this.manipulationDiv.appendChild(n),this._bindElementEvents(n,k(t=this.showManipulatorToolbar).call(t,this))}},{key:"_createButton",value:function(e,t,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"vis-label";return this.manipulationDOM[e+"Div"]=document.createElement("button"),this.manipulationDOM[e+"Div"].className="vis-button "+t,this.manipulationDOM[e+"Label"]=document.createElement("div"),this.manipulationDOM[e+"Label"].className=a,this.manipulationDOM[e+"Label"].innerText=n,this.manipulationDOM[e+"Div"].appendChild(this.manipulationDOM[e+"Label"]),this.manipulationDOM[e+"Div"]}},{key:"_createDescription",value:function(e){this.manipulationDOM.descriptionLabel=document.createElement("div"),this.manipulationDOM.descriptionLabel.className="vis-none",this.manipulationDOM.descriptionLabel.innerText=e,this.manipulationDiv.appendChild(this.manipulationDOM.descriptionLabel)}},{key:"_temporaryBindEvent",value:function(e,t){this.temporaryEventFunctions.push({event:e,boundFunction:t}),this.body.emitter.on(e,t)}},{key:"_temporaryBindUI",value:function(e,t){if(this.body.eventListeners[e]!==void 0)this.temporaryUIFunctions[e]=this.body.eventListeners[e],this.body.eventListeners[e]=t;else throw new Error("This UI function does not exist. Typo? You tried: "+e+" possible are: "+ls(Ee(this.body.eventListeners)))}},{key:"_unbindTemporaryUIs",value:function(){for(var e in this.temporaryUIFunctions)Object.prototype.hasOwnProperty.call(this.temporaryUIFunctions,e)&&(this.body.eventListeners[e]=this.temporaryUIFunctions[e],delete this.temporaryUIFunctions[e]);this.temporaryUIFunctions={}}},{key:"_unbindTemporaryEvents",value:function(){for(var e=0;e=0;u--)if(o[u]!==this.selectedControlNode.id){s=this.body.nodes[o[u]];break}if(s!==void 0&&this.selectedControlNode!==void 0)if(s.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var l=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===l.id?this._performEditEdge(s.id,a.to.id):this._performEditEdge(a.from.id,s.id)}else a.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}}},{key:"_handleConnect",value:function(e){if(new Date().valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(e.center),this.lastTouch.translation=Fe({},this.body.view.translation),this.interactionHandler.drag.pointer=this.lastTouch,this.interactionHandler.drag.translation=this.lastTouch.translation;var t=this.lastTouch,n=this.selectionHandler.getNodeAt(t);if(n!==void 0)if(n.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var a=this._getNewTargetNode(n.x,n.y);this.body.nodes[a.id]=a,this.body.nodeIndices.push(a.id);var o=this.body.functions.createEdge({id:"connectionEdge"+no(),from:n.id,to:a.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[o.id]=o,this.body.edgeIndices.push(o.id),this.temporaryIds.nodes.push(a.id),this.temporaryIds.edges.push(o.id)}this.touchTime=new Date().valueOf()}}},{key:"_dragControlNode",value:function(e){var t=this.body.functions.getPointer(e.center),n=this.selectionHandler._pointerToPositionObject(t),a=void 0;this.temporaryIds.edges[0]!==void 0&&(a=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var o=this.selectionHandler._getAllNodesOverlappingWith(n),s=void 0,u=o.length-1;u>=0;u--){var l;if(ie(l=this.temporaryIds.nodes).call(l,o[u])===-1){s=this.body.nodes[o[u]];break}}if(e.controlEdge={from:a,to:s?s.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",e,t),this.temporaryIds.nodes[0]!==void 0){var h=this.body.nodes[this.temporaryIds.nodes[0]];h.x=this.canvas._XconvertDOMtoCanvas(t.x),h.y=this.canvas._YconvertDOMtoCanvas(t.y),this.body.emitter.emit("_redraw")}else this.interactionHandler.onDrag(e)}},{key:"_finishConnect",value:function(e){var t=this.body.functions.getPointer(e.center),n=this.selectionHandler._pointerToPositionObject(t),a=void 0;this.temporaryIds.edges[0]!==void 0&&(a=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var o=this.selectionHandler._getAllNodesOverlappingWith(n),s=void 0,u=o.length-1;u>=0;u--){var l;if(ie(l=this.temporaryIds.nodes).call(l,o[u])===-1){s=this.body.nodes[o[u]];break}}this._cleanupTemporaryNodesAndEdges(),s!==void 0&&(s.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):this.body.nodes[a]!==void 0&&this.body.nodes[s.id]!==void 0&&this._performAddEdge(a,s.id)),e.controlEdge={from:a,to:s?s.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragEnd",e,t),this.body.emitter.emit("_redraw")}},{key:"_dragStartEdge",value:function(e){var t=this.lastTouch;this.selectionHandler.generateClickEvent("dragStart",e,t,void 0,!0)}},{key:"_performAddNode",value:function(e){var t=this,n={id:no(),x:e.pointer.canvas.x,y:e.pointer.canvas.y,label:"new"};if(typeof this.options.addNode=="function")if(this.options.addNode.length===2)this.options.addNode(n,function(a){a!=null&&t.inMode==="addNode"&&t.body.data.nodes.getDataSet().add(a),t.showManipulatorToolbar()});else throw this.showManipulatorToolbar(),new Error("The function for add does not support two arguments (data,callback)");else this.body.data.nodes.getDataSet().add(n),this.showManipulatorToolbar()}},{key:"_performAddEdge",value:function(e,t){var n=this,a={from:e,to:t};if(typeof this.options.addEdge=="function")if(this.options.addEdge.length===2)this.options.addEdge(a,function(o){o!=null&&n.inMode==="addEdge"&&(n.body.data.edges.getDataSet().add(o),n.selectionHandler.unselectAll(),n.showManipulatorToolbar())});else throw new Error("The function for connect does not support two arguments (data,callback)");else this.body.data.edges.getDataSet().add(a),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},{key:"_performEditEdge",value:function(e,t){var n=this,a={id:this.edgeBeingEditedId,from:e,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},o=this.options.editEdge;if(de(o)==="object"&&(o=o.editWithoutDrag),typeof o=="function")if(o.length===2)o(a,function(s){s==null||n.inMode!=="editEdge"?(n.body.edges[a.id].updateEdgeType(),n.body.emitter.emit("_redraw"),n.showManipulatorToolbar()):(n.body.data.edges.getDataSet().update(s),n.selectionHandler.unselectAll(),n.showManipulatorToolbar())});else throw new Error("The function for edit does not support two arguments (data, callback)");else this.body.data.edges.getDataSet().update(a),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}}]),i}(),D="string",I="boolean",w="number",Ya="array",H="object",ZT="dom",Ipe="any",bd=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],$d={borderWidth:{number:w},borderWidthSelected:{number:w,undefined:"undefined"},brokenImage:{string:D,undefined:"undefined"},chosen:{label:{boolean:I,function:"function"},node:{boolean:I,function:"function"},__type__:{object:H,boolean:I}},color:{border:{string:D},background:{string:D},highlight:{border:{string:D},background:{string:D},__type__:{object:H,string:D}},hover:{border:{string:D},background:{string:D},__type__:{object:H,string:D}},__type__:{object:H,string:D}},opacity:{number:w,undefined:"undefined"},fixed:{x:{boolean:I},y:{boolean:I},__type__:{object:H,boolean:I}},font:{align:{string:D},color:{string:D},size:{number:w},face:{string:D},background:{string:D},strokeWidth:{number:w},strokeColor:{string:D},vadjust:{number:w},multi:{boolean:I,string:D},bold:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},boldital:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},ital:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},mono:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},__type__:{object:H,string:D}},group:{string:D,number:w,undefined:"undefined"},heightConstraint:{minimum:{number:w},valign:{string:D},__type__:{object:H,boolean:I,number:w}},hidden:{boolean:I},icon:{face:{string:D},code:{string:D},size:{number:w},color:{string:D},weight:{string:D,number:w},__type__:{object:H}},id:{string:D,number:w},image:{selected:{string:D,undefined:"undefined"},unselected:{string:D,undefined:"undefined"},__type__:{object:H,string:D}},imagePadding:{top:{number:w},right:{number:w},bottom:{number:w},left:{number:w},__type__:{object:H,number:w}},label:{string:D,undefined:"undefined"},labelHighlightBold:{boolean:I},level:{number:w,undefined:"undefined"},margin:{top:{number:w},right:{number:w},bottom:{number:w},left:{number:w},__type__:{object:H,number:w}},mass:{number:w},physics:{boolean:I},scaling:{min:{number:w},max:{number:w},label:{enabled:{boolean:I},min:{number:w},max:{number:w},maxVisible:{number:w},drawThreshold:{number:w},__type__:{object:H,boolean:I}},customScalingFunction:{function:"function"},__type__:{object:H}},shadow:{enabled:{boolean:I},color:{string:D},size:{number:w},x:{number:w},y:{number:w},__type__:{object:H,boolean:I}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:I,array:Ya},borderRadius:{number:w},interpolation:{boolean:I},useImageSize:{boolean:I},useBorderWithImage:{boolean:I},coordinateOrigin:{string:["center","top-left"]},__type__:{object:H}},size:{number:w},title:{string:D,dom:ZT,undefined:"undefined"},value:{number:w,undefined:"undefined"},widthConstraint:{minimum:{number:w},maximum:{number:w},__type__:{object:H,boolean:I,number:w}},x:{number:w},y:{number:w},__type__:{object:H}},kpe={configure:{enabled:{boolean:I},filter:{boolean:I,string:D,array:Ya,function:"function"},container:{dom:ZT},showButton:{boolean:I},__type__:{object:H,boolean:I,string:D,array:Ya,function:"function"}},edges:{arrows:{to:{enabled:{boolean:I},scaleFactor:{number:w},type:{string:bd},imageHeight:{number:w},imageWidth:{number:w},src:{string:D},__type__:{object:H,boolean:I}},middle:{enabled:{boolean:I},scaleFactor:{number:w},type:{string:bd},imageWidth:{number:w},imageHeight:{number:w},src:{string:D},__type__:{object:H,boolean:I}},from:{enabled:{boolean:I},scaleFactor:{number:w},type:{string:bd},imageWidth:{number:w},imageHeight:{number:w},src:{string:D},__type__:{object:H,boolean:I}},__type__:{string:["from","to","middle"],object:H}},endPointOffset:{from:{number:w},to:{number:w},__type__:{object:H,number:w}},arrowStrikethrough:{boolean:I},background:{enabled:{boolean:I},color:{string:D},size:{number:w},dashes:{boolean:I,array:Ya},__type__:{object:H,boolean:I}},chosen:{label:{boolean:I,function:"function"},edge:{boolean:I,function:"function"},__type__:{object:H,boolean:I}},color:{color:{string:D},highlight:{string:D},hover:{string:D},inherit:{string:["from","to","both"],boolean:I},opacity:{number:w},__type__:{object:H,string:D}},dashes:{boolean:I,array:Ya},font:{color:{string:D},size:{number:w},face:{string:D},background:{string:D},strokeWidth:{number:w},strokeColor:{string:D},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:w},multi:{boolean:I,string:D},bold:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},boldital:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},ital:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},mono:{color:{string:D},size:{number:w},face:{string:D},mod:{string:D},vadjust:{number:w},__type__:{object:H,string:D}},__type__:{object:H,string:D}},hidden:{boolean:I},hoverWidth:{function:"function",number:w},label:{string:D,undefined:"undefined"},labelHighlightBold:{boolean:I},length:{number:w,undefined:"undefined"},physics:{boolean:I},scaling:{min:{number:w},max:{number:w},label:{enabled:{boolean:I},min:{number:w},max:{number:w},maxVisible:{number:w},drawThreshold:{number:w},__type__:{object:H,boolean:I}},customScalingFunction:{function:"function"},__type__:{object:H}},selectionWidth:{function:"function",number:w},selfReferenceSize:{number:w},selfReference:{size:{number:w},angle:{number:w},renderBehindTheNode:{boolean:I},__type__:{object:H}},shadow:{enabled:{boolean:I},color:{string:D},size:{number:w},x:{number:w},y:{number:w},__type__:{object:H,boolean:I}},smooth:{enabled:{boolean:I},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:w},forceDirection:{string:["horizontal","vertical","none"],boolean:I},__type__:{object:H,boolean:I}},title:{string:D,undefined:"undefined"},width:{number:w},widthConstraint:{maximum:{number:w},__type__:{object:H,boolean:I,number:w}},value:{number:w,undefined:"undefined"},__type__:{object:H}},groups:{useDefaultGroups:{boolean:I},__any__:$d,__type__:{object:H}},interaction:{dragNodes:{boolean:I},dragView:{boolean:I},hideEdgesOnDrag:{boolean:I},hideEdgesOnZoom:{boolean:I},hideNodesOnDrag:{boolean:I},hover:{boolean:I},keyboard:{enabled:{boolean:I},speed:{x:{number:w},y:{number:w},zoom:{number:w},__type__:{object:H}},bindToWindow:{boolean:I},autoFocus:{boolean:I},__type__:{object:H,boolean:I}},multiselect:{boolean:I},navigationButtons:{boolean:I},selectable:{boolean:I},selectConnectedEdges:{boolean:I},hoverConnectedEdges:{boolean:I},tooltipDelay:{number:w},zoomView:{boolean:I},zoomSpeed:{number:w},__type__:{object:H}},layout:{randomSeed:{undefined:"undefined",number:w,string:D},improvedLayout:{boolean:I},clusterThreshold:{number:w},hierarchical:{enabled:{boolean:I},levelSeparation:{number:w},nodeSpacing:{number:w},treeSpacing:{number:w},blockShifting:{boolean:I},edgeMinimization:{boolean:I},parentCentralization:{boolean:I},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:H,boolean:I}},__type__:{object:H}},manipulation:{enabled:{boolean:I},initiallyActive:{boolean:I},addNode:{boolean:I,function:"function"},addEdge:{boolean:I,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:H,boolean:I,function:"function"}},deleteNode:{boolean:I,function:"function"},deleteEdge:{boolean:I,function:"function"},controlNodeStyle:$d,__type__:{object:H,boolean:I}},nodes:$d,physics:{enabled:{boolean:I},barnesHut:{theta:{number:w},gravitationalConstant:{number:w},centralGravity:{number:w},springLength:{number:w},springConstant:{number:w},damping:{number:w},avoidOverlap:{number:w},__type__:{object:H}},forceAtlas2Based:{theta:{number:w},gravitationalConstant:{number:w},centralGravity:{number:w},springLength:{number:w},springConstant:{number:w},damping:{number:w},avoidOverlap:{number:w},__type__:{object:H}},repulsion:{centralGravity:{number:w},springLength:{number:w},springConstant:{number:w},nodeDistance:{number:w},damping:{number:w},__type__:{object:H}},hierarchicalRepulsion:{centralGravity:{number:w},springLength:{number:w},springConstant:{number:w},nodeDistance:{number:w},damping:{number:w},avoidOverlap:{number:w},__type__:{object:H}},maxVelocity:{number:w},minVelocity:{number:w},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:I},iterations:{number:w},updateInterval:{number:w},onlyDynamicEdges:{boolean:I},fit:{boolean:I},__type__:{object:H,boolean:I}},timestep:{number:w},adaptiveTimestep:{boolean:I},wind:{x:{number:w},y:{number:w},__type__:{object:H}},__type__:{object:H,boolean:I}},autoResize:{boolean:I},clickToUse:{boolean:I},locale:{string:D},locales:{__any__:{any:Ipe},__type__:{object:H}},height:{string:D},width:{string:D},__type__:{object:H}},QT={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},opacity:[0,0,1,.1],fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown","hexagon"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},endPointOffset:{from:[0,-10,10,1],to:[0,-10,10,1]},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],selfReference:{size:[20,0,200,1],angle:[Math.PI/2,-6*Math.PI,6*Math.PI,Math.PI/8],renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"],shakeTowards:["leaves","roots"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0,autoFocus:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0,zoomSpeed:[1,.1,2,.1]},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{theta:[.5,.1,1,.05],gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{theta:[.5,.1,1,.05],gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01],wind:{x:[0,-10,10,.1],y:[0,-10,10,.1]}}},Ppe=function(r,e,t){var n;return!!(oi(r).call(r,"physics")&&oi(n=QT.physics.solver).call(n,e)&&t.physics.solver!==e&&e!=="wind")},xpe=function(){function i(){N(this,i)}return M(i,[{key:"getDistances",value:function(e,t,n){for(var a={},o=e.edges,s=0;s2&&arguments[2]!==void 0?arguments[2]:!1,a=this.distanceSolver.getDistances(this.body,e,t);this._createL_matrix(a),this._createK_matrix(a),this._createE_matrix();for(var o=.01,s=1,u=0,l=Math.max(1e3,Math.min(10*this.body.nodeIndices.length,6e3)),h=5,d=1e9,c=0,f=0,v=0,p=0,g=0;d>o&&us&&gy.type==="downstream_subgraph_search")?.data||[],f=y=>{const m=y.json.nodes.map($=>({id:$.id,label:$.type,color:{background:"#2B7CE9",border:"#1B5BB1"},font:{size:16,color:"#FFFFFF",face:"arial",bold:!0},margin:12,padding:10,shape:"box",widthConstraint:{minimum:100,maximum:200}})),b=y.json.links.map($=>({from:$.origin_id,to:$.target_id,arrows:{to:{enabled:!0,scaleFactor:1.2}},color:"#FFFFFF",width:2}));return{nodes:m,edges:b}};Ve.useEffect(()=>()=>{d.current&&(d.current.destroy(),d.current=null)},[]);const v=Ve.useCallback((y,m)=>{d.current&&d.current.destroy();const b=f(m),$=new z(y,b,{nodes:{shape:"box",margin:12,padding:10,font:{size:16,color:"#FFFFFF",face:"arial",bold:!0},borderWidth:2,shadow:{enabled:!0,color:"rgba(0,0,0,0.2)",size:5}},edges:{arrows:"to",color:"#FFFFFF",width:2,smooth:{enabled:!0,type:"straightCross"}},physics:{enabled:!0,solver:"hierarchicalRepulsion",hierarchicalRepulsion:{nodeDistance:200,springLength:200}},layout:{hierarchical:{enabled:!0,direction:"UD",sortMethod:"directed",nodeSpacing:200,levelSeparation:150}},interaction:{dragNodes:!1,zoomView:!1,dragView:!1}});d.current=$},[]),p=async y=>{console.log("[DownstreamSubgraphs] Starting checkAndLoadSubgraph with node:",y),Vi.trackEvent({event_type:"subgraph_accept",message_type:"subgraph",message_id:u.message_id,data:{subgraph_name:y.name,subgraph_tags:y.tags}});const m=y.json.nodes,b=Object.values(Mt.canvas.selected_nodes)[0];if(!b){console.warn("[DownstreamSubgraphs] No node selected"),alert("Please select a upstream node first before adding a subgraph.");return}const $=m.map(C=>C.type),S=s;console.log("[DownstreamSubgraphs] Required node types:",$),console.log("[DownstreamSubgraphs] Installed node types:",S);const _=$.filter(C=>!S.includes(C));if(console.log("[DownstreamSubgraphs] Missing node types:",_),_.length>0)try{console.log("[DownstreamSubgraphs] Fetching info for missing nodes");const C=await Vi.batchGetNodeInfo(_);console.log("[DownstreamSubgraphs] Received node infos:",C);const R={text:"",ext:[{type:"node_install_guide",data:C.map(B=>({name:B.name,repository_url:B.github_url}))}]};console.log("[DownstreamSubgraphs] Created message content:",R);const x={id:Sr(),role:"ai",content:JSON.stringify(R),format:"markdown",name:"Assistant",metadata:{pendingSubgraph:y}};console.log("[DownstreamSubgraphs] Created AI message:",x),t?.(x);return}catch(C){console.error("[DownstreamSubgraphs] Error fetching node info:",C),alert("Error checking required nodes. Please try again.");return}console.log("[DownstreamSubgraphs] All required nodes are installed, proceeding to load subgraph"),g(y,b)},g=(y,m)=>{const b=y.json.nodes,$=y.json.links,S=b.find(R=>R.id===0),_=S?.id;console.log("[DownstreamSubgraphs] Entry node ID:",_);const C={};_!==null&&(C[_]=m),Mt.canvas.emitBeforeChange();try{for(const R of b)if(R.id!==_){const x=S?.pos,B=[m._pos[0],m._pos[1]],F=[R.pos[0]+B[0]-x[0],R.pos[1]+B[1]-x[1]];C[R.id]=X$(R.type,{pos:F})}for(const R of $){const x=C[R.origin_id],B=C[R.target_id];x&&B&&x.connect(R.origin_slot,B,R.target_slot)}}finally{Mt.canvas.emitAfterChange()}};return Ve.useEffect(()=>{const y=()=>{const m=Mt.canvas.selected_nodes;if(Object.keys(m??{}).length){const b=Object.values(m)[0];a({type:"SET_SELECTED_NODE",payload:b})}else a({type:"SET_SELECTED_NODE",payload:null})};return document.addEventListener("click",y),()=>{document.removeEventListener("click",y)}},[]),O.jsx("div",{className:"rounded-lg bg-green-50 p-3 text-gray-700 text-xs break-words overflow-visible",children:c.length>0&&O.jsx("div",{className:"space-y-3",children:O.jsx("div",{className:"flex flex-wrap gap-2",children:c.map(y=>O.jsxs("div",{className:"relative group",children:[O.jsx("button",{className:`px-3 py-1.5 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors text-xs`,onClick:()=>p(y),onMouseEnter:()=>h(y.name),onMouseLeave:()=>h(null),children:y.name}),O.jsxs("p",{className:"text-xs ml-3 text-gray-500",children:["[",y.tags.join(", "),"]"]}),l===y.name&&O.jsx("div",{className:`fixed -translate-y-full z-[9999] w-[500px] p-4 bg-gray-800 text-white text-xs - rounded-md shadow-lg mb-2 border border-gray-700`,style:{left:"calc(var(--mouse-x, 0) + 16px)",top:"calc(var(--mouse-y, 0) - 8px)"},children:O.jsx("div",{style:{width:"100%",height:"300px"},ref:m=>{m&&v(m,y)}})})]},y.name))})})})}const Vpe=Object.freeze(Object.defineProperty({__proto__:null,DownstreamSubgraphs:Ape},Symbol.toStringTag,{value:"Module"}));function Dpe({content:i,onLoadSubgraph:r}){const t=JSON.parse(i).ext?.find(n=>n.type==="node_install_guide")?.data||[];return O.jsxs("div",{children:[O.jsx("p",{children:"Before loading the graph to canvas, the following nodes need to be installed. Please visit the corresponding GitHub repositories to install them:"}),O.jsx("div",{className:"grid grid-cols-2 gap-3",children:t.map((n,a)=>O.jsx("div",{className:`w-full p-3 bg-white rounded-lg border border-gray-200 - hover:shadow-sm transition-all duration-200`,children:O.jsxs("div",{className:"flex flex-col",children:[O.jsx("h3",{className:"text-[12px] font-medium text-gray-800 mb-4",children:n.name}),O.jsx("div",{className:"flex justify-end",children:n.repository_url?O.jsxs("a",{href:n.repository_url,target:"_blank",rel:"noopener noreferrer",className:`px-2 py-1 bg-white text-gray-900 rounded-md + rounded-md shadow-lg mb-2 border border-gray-700`,style:{left:"calc(var(--mouse-x, 0) + 16px)",top:"calc(var(--mouse-y, 0) - 8px)"},children:O.jsx("div",{style:{width:"100%",height:"300px"},ref:m=>{m&&v(m,y)}})})]},y.name))})})})}const Vpe=Object.freeze(Object.defineProperty({__proto__:null,DownstreamSubgraphs:Ape},Symbol.toStringTag,{value:"Module"}));function Dpe({content:i,onLoadSubgraph:r}){const n=(JSON.parse(i).ext?.find(a=>a.type==="node_install_guide")?.data||[]).reduce((a,o)=>(a.some(s=>s.name===o.name)||a.push(o),a),[]);return O.jsxs("div",{children:[O.jsx("p",{children:"Before loading the graph to canvas, the following nodes need to be installed. Please visit the corresponding GitHub repositories to install them:"}),O.jsx("div",{className:"grid grid-cols-2 gap-3",children:n.map((a,o)=>O.jsx("div",{className:`w-full p-3 bg-white rounded-lg border border-gray-200 + hover:shadow-sm transition-all duration-200`,children:O.jsxs("div",{className:"flex flex-col",children:[O.jsx("h3",{className:"text-[12px] font-medium text-gray-800 mb-4",children:a.name}),O.jsx("div",{className:"flex justify-end",children:a.repository_url?O.jsxs("a",{href:a.repository_url,target:"_blank",rel:"noopener noreferrer",className:`px-2 py-1 bg-white text-gray-900 rounded-md border border-gray-900 hover:bg-gray-100 - transition-colors text-[10px] flex items-center gap-1`,children:[O.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download"]}):O.jsxs("a",{href:`https://www.google.com/search?q=${encodeURIComponent(n.name+" comfyui custom node")}`,target:"_blank",rel:"noopener noreferrer",className:`px-2 py-1 bg-gray-100 text-gray-500 rounded-md - border border-gray-300 text-[10px] flex items-center gap-1`,children:[O.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 21h7a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v11m0 5l4.879-4.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242z"})}),"Search on Google"]})})]})},a))}),O.jsx("p",{className:"mt-4"}),O.jsx("p",{children:"After installation, please click the continue loading graph button to load the graph to the canvas:"}),O.jsx("div",{className:"mt-4",children:O.jsx("button",{className:`px-3 py-2 bg-blue-500 text-white rounded-md + transition-colors text-[10px] flex items-center gap-1`,children:[O.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download"]}):O.jsxs("a",{href:`https://www.google.com/search?q=${encodeURIComponent(a.name+" comfyui custom node")}`,target:"_blank",rel:"noopener noreferrer",className:`px-2 py-1 bg-gray-100 text-gray-500 rounded-md + border border-gray-300 text-[10px] flex items-center gap-1`,children:[O.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 21h7a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v11m0 5l4.879-4.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242z"})}),"Search on Google"]})})]})},o))}),O.jsx("p",{className:"mt-4"}),O.jsx("p",{children:"After installation, please click the continue loading graph button to load the graph to the canvas:"}),O.jsx("div",{className:"mt-4",children:O.jsx("button",{className:`px-3 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors text-xs block mx-auto`,onClick:r,children:"Loading graph directly"})})]})}const Wpe=Object.freeze(Object.defineProperty({__proto__:null,NodeInstallGuide:Dpe},Symbol.toStringTag,{value:"Module"}));export{zpe as A,Y$ as B,Bpe as C,Vpe as D,BI as M,Hpe as N,Lpe as U,Vi as W,Mt as a,X$ as b,oI as c,Wpe as d,Fpe as f,Sr as g,uI as u,jpe as v,Mpe as w}; diff --git a/dist/copilot_web/workflowChat--6TDkP1M.js b/dist/copilot_web/workflowChat-BMjjRVAR.js similarity index 99% rename from dist/copilot_web/workflowChat--6TDkP1M.js rename to dist/copilot_web/workflowChat-BMjjRVAR.js index 945540d..069ff6d 100644 --- a/dist/copilot_web/workflowChat--6TDkP1M.js +++ b/dist/copilot_web/workflowChat-BMjjRVAR.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-DPhIatDg.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-yQk9DI7R.js","copilot_web/ParameterDebugInterfaceNew-CuNRLSlD.js","copilot_web/input.js","copilot_web/assets/input-CeTzrUyG.css","copilot_web/App-By_5x9Zk.js"])))=>i.map(i=>d[i]); -import{_ as Dt}from"./input.js";import{j as h,r as yg,b as wg}from"./vendor-markdown-Dek94WS0.js";import{r as I,R as wn,c as Mt}from"./vendor-react-V04_Axys.js";import{f as bg,v as Sg,a as sn,B as Ag,U as Eg,A as Ir,b as Ig,g as Ve,c as Pt,u as is,M as Cg,W as Ot}from"./message-components-yQk9DI7R.js";import{l as Ng}from"./App-By_5x9Zk.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-C6m4gAXH.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-cb3Dm8vl.js","copilot_web/ParameterDebugInterfaceNew-JzENzeyI.js","copilot_web/input.js","copilot_web/assets/input-CeTzrUyG.css","copilot_web/App-Dk85TURt.js"])))=>i.map(i=>d[i]); +import{_ as Dt}from"./input.js";import{j as h,r as yg,b as wg}from"./vendor-markdown-Dek94WS0.js";import{r as I,R as wn,c as Mt}from"./vendor-react-V04_Axys.js";import{f as bg,v as Sg,a as sn,B as Ag,U as Eg,A as Ir,b as Ig,g as Ve,c as Pt,u as is,M as Cg,W as Ot}from"./message-components-cb3Dm8vl.js";import{l as Ng}from"./App-Dk85TURt.js";/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. @@ -102,7 +102,7 @@ ${W.join(` hover:bg-gray-50`,children:"Close"})})]})})]})}function qg(){const m=Object.values(sn.canvas.selected_nodes)[0],w=new Set;function o(D,B){if(!(!D||B>=1)&&D.inputs)for(const E of Object.values(D.inputs)){const M=E.link;if(M&&sn.graph.links[M]){const q=sn.graph.links[M].origin_id,x=sn.graph._nodes_by_id[q];x&&(w.add(x.type),o(x,B+1))}}}return m?(o(m,0),[{type:"upstream_node_types",data:Array.from(w)}]):null}function Zg({nodeInfo:m,onSendWithIntent:w,loading:o,onSendWithContent:D}){return 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:()=>D(`Reply in ${navigator.language} language: How does the ${m[0].type} node work? I need its official usage guide.`),disabled:o,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:()=>D(`Reply in ${navigator.language} language: Show me the technical specifications for the ${m[0].type} node's inputs and outputs.`),disabled:o,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:()=>w("downstream_subgraph_search",qg()),disabled:o,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 Xg=m=>`https://ui-avatars.com/api/?name=${m||"User"}&background=random`,Jg=I.lazy(()=>Dt(()=>import("./WorkflowOption-DPhIatDg.js"),__vite__mapDeps([0,1,2,3])).then(m=>({default:m.WorkflowOption}))),Qg=I.lazy(()=>Dt(()=>import("./message-components-yQk9DI7R.js").then(m=>m.N),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeSearch}))),Vg=I.lazy(()=>Dt(()=>import("./message-components-yQk9DI7R.js").then(m=>m.D),__vite__mapDeps([3,2,1])).then(m=>({default:m.DownstreamSubgraphs}))),ep=I.lazy(()=>Dt(()=>import("./message-components-yQk9DI7R.js").then(m=>m.d),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeInstallGuide})));function np({messages:m,latestInput:w,onOptionClick:o,installedNodes:D,onAddMessage:B,loading:E}){const M=wn.useMemo(()=>x=>{if(x.role==="user")return h.jsx(Eg,{content:x.content,trace_id:x.trace_id},x.id);if(x.role==="ai"||x.role==="tool"){const $=Xg(x.role);try{const k=JSON.parse(x.content),F=k.ext?.find(W=>W.type==="workflow"),re=k.ext?.find(W=>W.type==="node"),ie=k.ext?.find(W=>W.type==="downstream_subgraph_search"),pe=k.ext?.find(W=>W.type==="node_install_guide");let R=null;if(F)R=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Jg,{content:x.content,name:x.name,avatar:$,latestInput:w,installedNodes:D,onAddMessage:B})});else if(re)R=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:x.content,name:x.name,avatar:$,installedNodes:D})});else if(ie){const W=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Vg,{content:x.content,name:x.name,avatar:$,onAddMessage:B})});if(x.metadata?.intent==="downstream_subgraph_search")return h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,extComponent:W,metadata:x.metadata},x.id);R=W}else pe&&(R=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(ep,{content:x.content,onLoadSubgraph:()=>{if(x.metadata?.pendingSubgraph){const W=Object.values(sn.canvas.selected_nodes)[0];if(W){const le=x.metadata.pendingSubgraph,he=le.json.nodes,oe=le.json.links,Pe=he.find(Z=>Z.id===0),fe=Pe?.id,H={};fe&&(H[fe]=W),sn.canvas.emitBeforeChange();try{for(const Z of he)if(Z.id!==fe){const Se=Pe?.pos||[0,0],_e=W._pos||[0,0],bn=[Z.pos[0]+_e[0]-Se[0],Z.pos[1]+_e[1]-Se[1]];H[Z.id]=Ig(Z.type,{pos:bn})}}finally{sn.canvas.emitAfterChange()}for(const Z of oe){const Se=H[Z.origin_id],_e=H[Z.target_id];Se&&_e&&Se.connect(Z.origin_slot,_e,Z.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(x.metadata?.pendingWorkflow){const W=x.metadata.pendingWorkflow,le=x.metadata.optimizedParams;sn.loadGraphData(W);for(const[oe,Pe,fe,H,Z]of le){const Se=sn.graph._nodes_by_id[oe].widgets;for(const _e of Se)_e.name===H&&(_e.value=Z)}sn.graph.setDirtyCanvas(!1,!0);const he={id:Ve(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};B?.(he)}}})}));return k.text||R?h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,extComponent:R,metadata:x.metadata},x.id):R||h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}catch(k){return console.error("[MessageList] Error parsing message content:",k),console.error("解析JSON失败",x.content),h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}}return null},[D,o,B,w]),q=wn.useMemo(()=>m?.map(M),[m,M]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[q,E&&h.jsx(Yg,{})]})}async function tp(){try{return await(await Pt.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 pp(m){return await(await Pt.fetchApi("/prompt",{method:"POST",body:JSON.stringify(m)})).json()}async function _p(m){try{const w=await Pt.fetchApi("/queue",{method:"POST",body:JSON.stringify(m)});if(!w.ok)throw new Error(`Failed to manage queue: ${w.status} ${w.statusText}`);return w}catch(w){throw console.error("Error managing queue:",w),w}}async function vp(){try{const m=await Pt.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 mp(m){try{const w=await Pt.fetchApi(`/history/${m}`,{method:"GET"});if(!w.ok)throw new Error(`Failed to fetch history: ${w.status} ${w.statusText}`);return await w.json()}catch(w){throw console.error("Error fetching history:",w),w}}var Nr={exports:{}};/** + text-purple-700 hover:bg-purple-200`,onClick:()=>w("downstream_subgraph_search",qg()),disabled:o,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 Xg=m=>`https://ui-avatars.com/api/?name=${m||"User"}&background=random`,Jg=I.lazy(()=>Dt(()=>import("./WorkflowOption-C6m4gAXH.js"),__vite__mapDeps([0,1,2,3])).then(m=>({default:m.WorkflowOption}))),Qg=I.lazy(()=>Dt(()=>import("./message-components-cb3Dm8vl.js").then(m=>m.N),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeSearch}))),Vg=I.lazy(()=>Dt(()=>import("./message-components-cb3Dm8vl.js").then(m=>m.D),__vite__mapDeps([3,2,1])).then(m=>({default:m.DownstreamSubgraphs}))),ep=I.lazy(()=>Dt(()=>import("./message-components-cb3Dm8vl.js").then(m=>m.d),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeInstallGuide})));function np({messages:m,latestInput:w,onOptionClick:o,installedNodes:D,onAddMessage:B,loading:E}){const M=wn.useMemo(()=>x=>{if(x.role==="user")return h.jsx(Eg,{content:x.content,trace_id:x.trace_id},x.id);if(x.role==="ai"||x.role==="tool"){const $=Xg(x.role);try{const k=JSON.parse(x.content),F=k.ext?.find(W=>W.type==="workflow"),re=k.ext?.find(W=>W.type==="node"),ie=k.ext?.find(W=>W.type==="downstream_subgraph_search"),pe=k.ext?.find(W=>W.type==="node_install_guide");let R=null;if(F)R=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Jg,{content:x.content,name:x.name,avatar:$,latestInput:w,installedNodes:D,onAddMessage:B})});else if(re)R=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:x.content,name:x.name,avatar:$,installedNodes:D})});else if(ie){const W=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Vg,{content:x.content,name:x.name,avatar:$,onAddMessage:B})});if(x.metadata?.intent==="downstream_subgraph_search")return h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,extComponent:W,metadata:x.metadata},x.id);R=W}else pe&&(R=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(ep,{content:x.content,onLoadSubgraph:()=>{if(x.metadata?.pendingSubgraph){const W=Object.values(sn.canvas.selected_nodes)[0];if(W){const le=x.metadata.pendingSubgraph,he=le.json.nodes,oe=le.json.links,Pe=he.find(Z=>Z.id===0),fe=Pe?.id,H={};fe&&(H[fe]=W),sn.canvas.emitBeforeChange();try{for(const Z of he)if(Z.id!==fe){const Se=Pe?.pos||[0,0],_e=W._pos||[0,0],bn=[Z.pos[0]+_e[0]-Se[0],Z.pos[1]+_e[1]-Se[1]];H[Z.id]=Ig(Z.type,{pos:bn})}}finally{sn.canvas.emitAfterChange()}for(const Z of oe){const Se=H[Z.origin_id],_e=H[Z.target_id];Se&&_e&&Se.connect(Z.origin_slot,_e,Z.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(x.metadata?.pendingWorkflow){const W=x.metadata.pendingWorkflow,le=x.metadata.optimizedParams;sn.loadGraphData(W);for(const[oe,Pe,fe,H,Z]of le){const Se=sn.graph._nodes_by_id[oe].widgets;for(const _e of Se)_e.name===H&&(_e.value=Z)}sn.graph.setDirtyCanvas(!1,!0);const he={id:Ve(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};B?.(he)}}})}));return k.text||R?h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,extComponent:R,metadata:x.metadata},x.id):R||h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}catch(k){return console.error("[MessageList] Error parsing message content:",k),console.error("解析JSON失败",x.content),h.jsx(Ir,{content:x.content,name:x.name,avatar:$,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}}return null},[D,o,B,w]),q=wn.useMemo(()=>m?.map(M),[m,M]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[q,E&&h.jsx(Yg,{})]})}async function tp(){try{return await(await Pt.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 pp(m){return await(await Pt.fetchApi("/prompt",{method:"POST",body:JSON.stringify(m)})).json()}async function _p(m){try{const w=await Pt.fetchApi("/queue",{method:"POST",body:JSON.stringify(m)});if(!w.ok)throw new Error(`Failed to manage queue: ${w.status} ${w.statusText}`);return w}catch(w){throw console.error("Error managing queue:",w),w}}async function vp(){try{const m=await Pt.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 mp(m){try{const w=await Pt.fetchApi(`/history/${m}`,{method:"GET"});if(!w.ok)throw new Error(`Failed to fetch history: ${w.status} ${w.statusText}`);return await w.json()}catch(w){throw console.error("Error fetching history:",w),w}}var Nr={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors @@ -128,4 +128,4 @@ __p += '`),K&&(v+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+v+`return __p -}`;var U=Oo(function(){return X(u,S+"return "+v).apply(o,a)});if(U.source=v,Hi(U))throw U;return U}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===o))return js(e);if(!e||!(n=Fe(n)))return e;var r=en(e),i=en(n),u=zs(r,i),a=Gs(r,i)+1;return Mn(r,u,a).join("")}function R0(e,n,t){if(e=J(e),e&&(t||n===o))return e.slice(0,$s(e)+1);if(!e||!(n=Fe(n)))return e;var r=en(e),i=Gs(r,en(n))+1;return Mn(r,0,i).join("")}function T0(e,n,t){if(e=J(e),e&&(t||n===o))return e.replace(Hr,"");if(!e||!(n=Fe(n)))return e;var r=en(e),i=zs(r,en(n));return Mn(r,i).join("")}function M0(e,n){var t=bn,r=Rr;if(ae(n)){var i="separator"in n?n.separator:i;t="length"in n?P(n.length):t,r="omission"in n?Fe(n.omission):r}e=J(e);var u=e.length;if(et(e)){var a=en(e);u=a.length}if(t>=u)return e;var l=t-nt(r);if(l<1)return r;var c=a?Mn(a,0,l).join(""):e.slice(0,l);if(i===o)return c+r;if(a&&(l+=c.length-l),qi(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=li(i.source,J(ls.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===o?l:v)}}else if(e.indexOf(Fe(i),l)!=l){var y=c.lastIndexOf(i);y>-1&&(c=c.slice(0,y))}return c+r}function O0(e){return e=J(e),e&&Go.test(e)?e.replace(us,ol):e}var D0=at(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Xi=Ou("toUpperCase");function Mo(e,n,t){return e=J(e),n=t?o:n,n===o?tl(e)?fl(e):qa(e):e.match(n)||[]}var Oo=j(function(e,n){try{return Ue(e,o,n)}catch(t){return Hi(t)?t:new T(t)}}),P0=_n(function(e,n){return He(n,function(t){t=ln(t),gn(e,t,Ki(e[t],e))}),e});function k0(e){var n=e==null?0:e.length,t=C();return e=n?ue(e,function(r){if(typeof r[1]!="function")throw new qe(M);return[t(r[0]),r[1]]}):[],j(function(r){for(var i=-1;++ifn)return[];var t=ke,r=Ie(e,ke);n=C(n),e-=ke;for(var i=ui(r,n);++t0||n<0)?new G(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==o&&(n=P(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(ke)},on(G.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=s[r?"take"+(n=="last"?"Right":""):n],u=r||/^find/.test(n);i&&(s.prototype[n]=function(){var a=this.__wrapped__,l=r?[1]:arguments,c=a instanceof G,p=l[0],_=c||O(a),v=function(z){var K=i.apply(s,In([z],l));return r&&y?K[0]:K};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var y=this.__chain__,S=!!this.__actions__.length,N=u&&!y,U=c&&!S;if(!u&&_){a=U?a:new G(this);var L=e.apply(a,l);return L.__actions__.push({func:mr,args:[v],thisArg:o}),new Ze(L,y)}return N&&U?e.apply(this,l):(L=this.thru(v),N?r?L.value()[0]:L.value():L)})}),He(["pop","push","shift","sort","splice","unshift"],function(e){var n=Kt[e],t=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);s.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var u=this.value();return n.apply(O(u)?u:[],i)}return this[t](function(a){return n.apply(O(a)?a:[],i)})}}),on(G.prototype,function(e,n){var t=s[n];if(t){var r=t.name+"";Q.call(st,r)||(st[r]=[]),st[r].push({name:n,func:t})}}),st[cr(o,le).name]=[{name:"wrapper",func:o}],G.prototype.clone=Ml,G.prototype.reverse=Ol,G.prototype.value=Dl,s.prototype.at=fh,s.prototype.chain=ch,s.prototype.commit=hh,s.prototype.next=dh,s.prototype.plant=ph,s.prototype.reverse=_h,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=vh,s.prototype.first=s.prototype.head,mt&&(s.prototype[mt]=gh),s},tt=cl();kn?((kn.exports=tt)._=tt,Qr._=tt):we._=tt}).call(Mt)})(Nr,Nr.exports);var Lr=Nr.exports;function ip(m=!0){I.useEffect(()=>{if(!m)return;const w=Lr.debounce(o=>{document.documentElement.style.setProperty("--mouse-x",`${o.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${o.clientY}px`)},16);return document.addEventListener("mousemove",w),()=>{w.cancel(),document.removeEventListener("mousemove",w)}},[m])}function sp(m={},w=!0){const[o,D]=I.useState(!1),[B,E]=I.useState({width:window.innerWidth/3,height:window.innerHeight,top:0});I.useCallback(Lr.debounce(q=>{o&&E(x=>{const $=window.innerWidth-q.clientX,k=Math.min(Math.max(m.minWidth||300,$),m.maxWidth||window.innerWidth*.8);return{...x,width:k}})},16),[o,m]);const M=I.useCallback(q=>{E(x=>{const $=x.height-q,k=x.top+q;return{...x,height:Math.min(Math.max(m.minHeight||300,$),m.maxHeight||window.innerHeight),top:Math.max(0,k)}})},[m]);return I.useEffect(()=>{if(!w||!o)return;const q=Lr.debounce($=>{E(k=>{const F=window.innerWidth-$.clientX,re=Math.min(Math.max(m.minWidth||300,F),m.maxWidth||window.innerWidth*.8);return{...k,width:re}})},16),x=()=>D(!1);return document.addEventListener("mousemove",q),document.addEventListener("mouseup",x),()=>{q.cancel(),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",x)}},[o,m,w]),{isResizing:o,setIsResizing:D,dimensions:B,handleHeightResize:M}}function up(m=!0){const{state:w,dispatch:o}=is(),{activeTab:D,screenState:B}=w;I.useEffect(()=>{if(!m)return;const E=M=>{const q=D==="parameter-debug",x=D==="chat",$=!B||B.currentScreen===0;if(x||$&&q){const k=sn.canvas.selected_nodes;if(Object.keys(k??{}).length){const F=Object.values(k);o({type:"SET_SELECTED_NODE",payload:F})}else o({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[o,m,D,B])}const op=({message:m,onClose:w})=>m?h.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-amber-100 border-b border-amber-200 px-5 py-2 mt-2 relative shadow-sm",children:[h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"flex-shrink-0 mr-2",children:h.jsx("svg",{className:"w-3.5 h-3.5 text-amber-600",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),h.jsx("div",{className:"text-amber-800 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:h.jsx(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:o,...D})=>h.jsx("a",{...D,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:o})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:o}),span:({children:o})=>h.jsx("span",{style:{fontSize:"11px"},children:o}),li:({children:o})=>h.jsx("li",{style:{fontSize:"11px"},children:o}),ul:({children:o})=>h.jsx("ul",{style:{fontSize:"11px"},children:o}),ol:({children:o})=>h.jsx("ol",{style:{fontSize:"11px"},children:o})},children:m})})]}),h.jsx("button",{onClick:w,className:"absolute right-2 top-1/2 -translate-y-1/2 text-amber-500 hover:text-amber-700 transition-colors p-1 rounded-full hover:bg-amber-200/50","aria-label":"Close announcement",children:h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,ap=()=>{const{state:m,dispatch:w}=is(),{selectedNode:o,screenState:D}=m,B=o||[],E=wn.lazy(()=>Dt(()=>import("./ParameterDebugInterfaceNew-CuNRLSlD.js"),__vite__mapDeps([4,1,2,3,5,6,7])).then(q=>({default:q.ParameterDebugInterface}))),M=()=>{w({type:"SET_SELECTED_NODE",payload:null}),w({type:"SET_SCREEN_STATE",payload:null})};return h.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:h.jsx(wn.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(E,{selectedNodes:B,visible:!0,onClose:M})})})},Wo=({active:m,onClick:w,children:o})=>h.jsx("button",{onClick:w,className:`px-4 py-2 font-medium text-sm transition-colors duration-200 ${m?"text-blue-600 border-b-2 border-blue-600":"text-gray-600 hover:text-blue-500 hover:border-b-2 hover:border-blue-300"}`,children:o});function lp({onClose:m,visible:w=!0,triggerUsage:o=!1,onUsageTriggered:D}){const{state:B,dispatch:E}=is(),{messages:M,installedNodes:q,loading:x,sessionId:$,selectedNode:k,activeTab:F}=B,re=I.useRef(null),[ie,pe]=I.useState(""),[R,W]=I.useState(""),[le,he]=I.useState(window.innerWidth/3),[oe,Pe]=I.useState(!1),[fe,H]=I.useState([]),[Z,Se]=I.useState("gpt-4o-mini");I.useState(window.innerHeight),I.useState(0);const[_e,bn]=I.useState(""),[Rr,kt]=I.useState(!1);ip(w&&F==="chat"),up(w);const{isResizing:ss,setIsResizing:Wt,dimensions:dt,handleHeightResize:Tr}=sp({minWidth:300,maxWidth:window.innerWidth*.8,minHeight:300,maxHeight:window.innerHeight},w);I.useEffect(()=>{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[M]),I.useEffect(()=>{if(F!=="chat")return;(async()=>{const Y=await rp();console.log("[WorkflowChat] Received installed nodes:",Y.length),E({type:"SET_INSTALLED_NODES",payload:Y})})()},[F]);const $n=async A=>{try{const Y=await Ot.fetchMessages(A);E({type:"SET_MESSAGES",payload:Y})}catch(Y){console.error("Error fetching messages:",Y)}};I.useEffect(()=>{if(F!=="chat")return;let A=localStorage.getItem("sessionId");A?(E({type:"SET_SESSION_ID",payload:A}),$n(A)):(A=Ve(),E({type:"SET_SESSION_ID",payload:A}),localStorage.setItem("sessionId",A))},[F]);const fn=wn.useCallback(A=>{if(!oe)return;const Y=window.innerWidth-A.clientX,ee=Math.min(Math.max(300,Y),window.innerWidth*.8);he(ee)},[oe]),Hn=wn.useMemo(()=>Lr.debounce(fn,16),[fn]);I.useEffect(()=>(oe&&(document.addEventListener("mousemove",Hn),document.addEventListener("mouseup",An)),()=>{document.removeEventListener("mousemove",Hn),document.removeEventListener("mouseup",An),Hn.cancel()}),[oe,Hn]);const qn=A=>{pe(A.target.value)},ke=async()=>{if(E({type:"SET_LOADING",payload:!0}),ie.trim()===""&&!k||!$)return;W(ie);const A=Ve(),Y={id:Ve(),role:"user",content:ie,trace_id:A};E({type:"ADD_MESSAGE",payload:Y}),pe("");try{const ee={type:"model_select",data:[Z]};let Ae=Ve(),un=!0;for await(const Ee of Ot.streamInvokeServer($,ie,fe.map(V=>V.file),null,ee,A)){const V={id:Ae,role:"ai",content:JSON.stringify(Ee),format:Ee.format,finished:Ee.finished,name:"Assistant"};if(un)E({type:"ADD_MESSAGE",payload:V}),un=!1;else{E({type:"UPDATE_MESSAGE",payload:V});const ve=B.messages.map(Ke=>Ke.id===V.id&&!Ke.finished?V:Ke);Zn(ve)}Ee.finished&&E({type:"SET_LOADING",payload:!1})}}catch(ee){console.error("Error sending message:",ee),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Mr=async A=>{if(!$)return;E({type:"SET_LOADING",payload:!0}),W(A);const Y=Ve(),ee={id:Ve(),role:"user",content:A,trace_id:Y};E({type:"ADD_MESSAGE",payload:ee});try{const Ae={type:"model_select",data:[Z]};let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,A,fe.map(ve=>ve.file),null,Ae,Y)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=B.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(Ae){console.error("Error sending message:",Ae),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Or=A=>{A.metaKey&&A.key==="Enter"&&ke()},Dr=()=>{E({type:"CLEAR_MESSAGES"});const A=B.sessionId;A&&localStorage.removeItem(`messages_${A}`),localStorage.removeItem("sessionId");const Y=Ve();E({type:"SET_SESSION_ID",payload:Y}),localStorage.setItem("sessionId",Y)},Sn=A=>{pe(A)},Dn=async(A,Y)=>{if(!$||!k)return;E({type:"SET_LOADING",payload:!0});const ee=Ve(),Ae={id:Ve(),role:"user",content:k.comfyClass||k.type,trace_id:ee};E({type:"ADD_MESSAGE",payload:Ae});try{let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,k.comfyClass||k.type,[],A,Y,ee)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(A&&A!==""&&(ve.metadata={intent:A}),Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=B.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(un){console.error("Error sending message:",un),E({type:"SET_LOADING",payload:!1})}},Zn=A=>{B.sessionId&&localStorage.setItem(`messages_${B.sessionId}`,JSON.stringify(A))},Pn=A=>{console.log("[WorkflowChat] Adding new message:",A);const Y=[...B.messages,A];E({type:"ADD_MESSAGE",payload:A}),Zn(Y)},An=()=>{Pe(!1)},Pr=A=>{const Y=Array.from(A).map(ee=>({id:Math.random().toString(36).substr(2,9),file:ee,preview:URL.createObjectURL(ee)}));H(ee=>[...ee,...Y])},Yn=A=>{H(Y=>Y.filter(Ae=>Ae.id!==A))};wn.useEffect(()=>()=>{fe.forEach(A=>URL.revokeObjectURL(A.preview))},[fe]),I.useEffect(()=>{o&&D&&F==="chat"&&(Dn("node_explain"),D())},[o,F]),I.useEffect(()=>{if(!w||F!=="chat")return;(async()=>{try{const Y=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==Y){const Ae=await Ot.fetchAnnouncement();Ae&&Ae.trim()!==""&&(bn(Ae),kt(!0),localStorage.setItem("announcementLastShownDate",Y))}}catch(Y){console.error("Error fetching announcement:",Y)}})()},[w,F]);const Xn=()=>{kt(!1)},gt=A=>{E({type:"SET_ACTIVE_TAB",payload:A})},We=wn.useMemo(()=>h.jsx(ap,{}),[]);return h.jsxs("div",{className:"fixed right-0 shadow-lg bg-white duration-200 ease-out",style:{display:w?"block":"none",width:`${dt.width}px`,height:`${dt.height}px`,top:`${dt.top}px`},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300",onMouseDown:A=>{Wt(!0),A.preventDefault()}}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx(Kg,{onClose:m,onClear:Dr,hasMessages:M.length>0,onHeightResize:Tr,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(Wo,{active:F==="chat",onClick:()=>gt("chat"),children:"Chat"}),h.jsx(Wo,{active:F==="parameter-debug",onClick:()=>gt("parameter-debug"),children:"GenLab"})]}),Rr&&_e&&F==="chat"&&h.jsx(op,{message:_e,onClose:Xn}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth",style:{display:F==="chat"?"block":"none"},ref:re,children:h.jsx(np,{messages:M,latestInput:R,onOptionClick:Sn,installedNodes:q,onAddMessage:Pn,loading:x})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:F==="chat"?"block":"none"},children:[k&&h.jsx(Zg,{nodeInfo:k,onSendWithIntent:Dn,loading:x,onSendWithContent:Mr}),h.jsx(Hg,{input:ie,loading:x,onChange:qn,onSend:ke,onKeyPress:Or,onUploadImages:Pr,uploadedImages:fe,onRemoveImage:Yn,selectedModel:Z,onModelChange:Se})]}),h.jsx("div",{className:"flex-1 flex flex-col",style:{display:F==="parameter-debug"?"flex":"none"},children:We})]})]})}const xp=Object.freeze(Object.defineProperty({__proto__:null,default:lp},Symbol.toStringTag,{value:"Module"}));export{mp as g,vp as i,_p as m,pp as r,xp as w}; +}`;var U=Oo(function(){return X(u,S+"return "+v).apply(o,a)});if(U.source=v,Hi(U))throw U;return U}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===o))return js(e);if(!e||!(n=Fe(n)))return e;var r=en(e),i=en(n),u=zs(r,i),a=Gs(r,i)+1;return Mn(r,u,a).join("")}function R0(e,n,t){if(e=J(e),e&&(t||n===o))return e.slice(0,$s(e)+1);if(!e||!(n=Fe(n)))return e;var r=en(e),i=Gs(r,en(n))+1;return Mn(r,0,i).join("")}function T0(e,n,t){if(e=J(e),e&&(t||n===o))return e.replace(Hr,"");if(!e||!(n=Fe(n)))return e;var r=en(e),i=zs(r,en(n));return Mn(r,i).join("")}function M0(e,n){var t=bn,r=Rr;if(ae(n)){var i="separator"in n?n.separator:i;t="length"in n?P(n.length):t,r="omission"in n?Fe(n.omission):r}e=J(e);var u=e.length;if(et(e)){var a=en(e);u=a.length}if(t>=u)return e;var l=t-nt(r);if(l<1)return r;var c=a?Mn(a,0,l).join(""):e.slice(0,l);if(i===o)return c+r;if(a&&(l+=c.length-l),qi(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=li(i.source,J(ls.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===o?l:v)}}else if(e.indexOf(Fe(i),l)!=l){var y=c.lastIndexOf(i);y>-1&&(c=c.slice(0,y))}return c+r}function O0(e){return e=J(e),e&&Go.test(e)?e.replace(us,ol):e}var D0=at(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Xi=Ou("toUpperCase");function Mo(e,n,t){return e=J(e),n=t?o:n,n===o?tl(e)?fl(e):qa(e):e.match(n)||[]}var Oo=j(function(e,n){try{return Ue(e,o,n)}catch(t){return Hi(t)?t:new T(t)}}),P0=_n(function(e,n){return He(n,function(t){t=ln(t),gn(e,t,Ki(e[t],e))}),e});function k0(e){var n=e==null?0:e.length,t=C();return e=n?ue(e,function(r){if(typeof r[1]!="function")throw new qe(M);return[t(r[0]),r[1]]}):[],j(function(r){for(var i=-1;++ifn)return[];var t=ke,r=Ie(e,ke);n=C(n),e-=ke;for(var i=ui(r,n);++t0||n<0)?new G(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==o&&(n=P(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(ke)},on(G.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=s[r?"take"+(n=="last"?"Right":""):n],u=r||/^find/.test(n);i&&(s.prototype[n]=function(){var a=this.__wrapped__,l=r?[1]:arguments,c=a instanceof G,p=l[0],_=c||O(a),v=function(z){var K=i.apply(s,In([z],l));return r&&y?K[0]:K};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var y=this.__chain__,S=!!this.__actions__.length,N=u&&!y,U=c&&!S;if(!u&&_){a=U?a:new G(this);var L=e.apply(a,l);return L.__actions__.push({func:mr,args:[v],thisArg:o}),new Ze(L,y)}return N&&U?e.apply(this,l):(L=this.thru(v),N?r?L.value()[0]:L.value():L)})}),He(["pop","push","shift","sort","splice","unshift"],function(e){var n=Kt[e],t=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);s.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var u=this.value();return n.apply(O(u)?u:[],i)}return this[t](function(a){return n.apply(O(a)?a:[],i)})}}),on(G.prototype,function(e,n){var t=s[n];if(t){var r=t.name+"";Q.call(st,r)||(st[r]=[]),st[r].push({name:n,func:t})}}),st[cr(o,le).name]=[{name:"wrapper",func:o}],G.prototype.clone=Ml,G.prototype.reverse=Ol,G.prototype.value=Dl,s.prototype.at=fh,s.prototype.chain=ch,s.prototype.commit=hh,s.prototype.next=dh,s.prototype.plant=ph,s.prototype.reverse=_h,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=vh,s.prototype.first=s.prototype.head,mt&&(s.prototype[mt]=gh),s},tt=cl();kn?((kn.exports=tt)._=tt,Qr._=tt):we._=tt}).call(Mt)})(Nr,Nr.exports);var Lr=Nr.exports;function ip(m=!0){I.useEffect(()=>{if(!m)return;const w=Lr.debounce(o=>{document.documentElement.style.setProperty("--mouse-x",`${o.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${o.clientY}px`)},16);return document.addEventListener("mousemove",w),()=>{w.cancel(),document.removeEventListener("mousemove",w)}},[m])}function sp(m={},w=!0){const[o,D]=I.useState(!1),[B,E]=I.useState({width:window.innerWidth/3,height:window.innerHeight,top:0});I.useCallback(Lr.debounce(q=>{o&&E(x=>{const $=window.innerWidth-q.clientX,k=Math.min(Math.max(m.minWidth||300,$),m.maxWidth||window.innerWidth*.8);return{...x,width:k}})},16),[o,m]);const M=I.useCallback(q=>{E(x=>{const $=x.height-q,k=x.top+q;return{...x,height:Math.min(Math.max(m.minHeight||300,$),m.maxHeight||window.innerHeight),top:Math.max(0,k)}})},[m]);return I.useEffect(()=>{if(!w||!o)return;const q=Lr.debounce($=>{E(k=>{const F=window.innerWidth-$.clientX,re=Math.min(Math.max(m.minWidth||300,F),m.maxWidth||window.innerWidth*.8);return{...k,width:re}})},16),x=()=>D(!1);return document.addEventListener("mousemove",q),document.addEventListener("mouseup",x),()=>{q.cancel(),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",x)}},[o,m,w]),{isResizing:o,setIsResizing:D,dimensions:B,handleHeightResize:M}}function up(m=!0){const{state:w,dispatch:o}=is(),{activeTab:D,screenState:B}=w;I.useEffect(()=>{if(!m)return;const E=M=>{const q=D==="parameter-debug",x=D==="chat",$=!B||B.currentScreen===0;if(x||$&&q){const k=sn.canvas.selected_nodes;if(Object.keys(k??{}).length){const F=Object.values(k);o({type:"SET_SELECTED_NODE",payload:F})}else o({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[o,m,D,B])}const op=({message:m,onClose:w})=>m?h.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-amber-100 border-b border-amber-200 px-5 py-2 mt-2 relative shadow-sm",children:[h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"flex-shrink-0 mr-2",children:h.jsx("svg",{className:"w-3.5 h-3.5 text-amber-600",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),h.jsx("div",{className:"text-amber-800 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:h.jsx(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:o,...D})=>h.jsx("a",{...D,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:o})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:o}),span:({children:o})=>h.jsx("span",{style:{fontSize:"11px"},children:o}),li:({children:o})=>h.jsx("li",{style:{fontSize:"11px"},children:o}),ul:({children:o})=>h.jsx("ul",{style:{fontSize:"11px"},children:o}),ol:({children:o})=>h.jsx("ol",{style:{fontSize:"11px"},children:o})},children:m})})]}),h.jsx("button",{onClick:w,className:"absolute right-2 top-1/2 -translate-y-1/2 text-amber-500 hover:text-amber-700 transition-colors p-1 rounded-full hover:bg-amber-200/50","aria-label":"Close announcement",children:h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,ap=()=>{const{state:m,dispatch:w}=is(),{selectedNode:o,screenState:D}=m,B=o||[],E=wn.lazy(()=>Dt(()=>import("./ParameterDebugInterfaceNew-JzENzeyI.js"),__vite__mapDeps([4,1,2,3,5,6,7])).then(q=>({default:q.ParameterDebugInterface}))),M=()=>{w({type:"SET_SELECTED_NODE",payload:null}),w({type:"SET_SCREEN_STATE",payload:null})};return h.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:h.jsx(wn.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(E,{selectedNodes:B,visible:!0,onClose:M})})})},Wo=({active:m,onClick:w,children:o})=>h.jsx("button",{onClick:w,className:`px-4 py-2 font-medium text-sm transition-colors duration-200 ${m?"text-blue-600 border-b-2 border-blue-600":"text-gray-600 hover:text-blue-500 hover:border-b-2 hover:border-blue-300"}`,children:o});function lp({onClose:m,visible:w=!0,triggerUsage:o=!1,onUsageTriggered:D}){const{state:B,dispatch:E}=is(),{messages:M,installedNodes:q,loading:x,sessionId:$,selectedNode:k,activeTab:F}=B,re=I.useRef(null),[ie,pe]=I.useState(""),[R,W]=I.useState(""),[le,he]=I.useState(window.innerWidth/3),[oe,Pe]=I.useState(!1),[fe,H]=I.useState([]),[Z,Se]=I.useState("gpt-4o-mini");I.useState(window.innerHeight),I.useState(0);const[_e,bn]=I.useState(""),[Rr,kt]=I.useState(!1);ip(w&&F==="chat"),up(w);const{isResizing:ss,setIsResizing:Wt,dimensions:dt,handleHeightResize:Tr}=sp({minWidth:300,maxWidth:window.innerWidth*.8,minHeight:300,maxHeight:window.innerHeight},w);I.useEffect(()=>{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[M]),I.useEffect(()=>{if(F!=="chat")return;(async()=>{const Y=await rp();console.log("[WorkflowChat] Received installed nodes:",Y.length),E({type:"SET_INSTALLED_NODES",payload:Y})})()},[F]);const $n=async A=>{try{const Y=await Ot.fetchMessages(A);E({type:"SET_MESSAGES",payload:Y})}catch(Y){console.error("Error fetching messages:",Y)}};I.useEffect(()=>{if(F!=="chat")return;let A=localStorage.getItem("sessionId");A?(E({type:"SET_SESSION_ID",payload:A}),$n(A)):(A=Ve(),E({type:"SET_SESSION_ID",payload:A}),localStorage.setItem("sessionId",A))},[F]);const fn=wn.useCallback(A=>{if(!oe)return;const Y=window.innerWidth-A.clientX,ee=Math.min(Math.max(300,Y),window.innerWidth*.8);he(ee)},[oe]),Hn=wn.useMemo(()=>Lr.debounce(fn,16),[fn]);I.useEffect(()=>(oe&&(document.addEventListener("mousemove",Hn),document.addEventListener("mouseup",An)),()=>{document.removeEventListener("mousemove",Hn),document.removeEventListener("mouseup",An),Hn.cancel()}),[oe,Hn]);const qn=A=>{pe(A.target.value)},ke=async()=>{if(E({type:"SET_LOADING",payload:!0}),ie.trim()===""&&!k||!$)return;W(ie);const A=Ve(),Y={id:Ve(),role:"user",content:ie,trace_id:A};E({type:"ADD_MESSAGE",payload:Y}),pe("");try{const ee={type:"model_select",data:[Z]};let Ae=Ve(),un=!0;for await(const Ee of Ot.streamInvokeServer($,ie,fe.map(V=>V.file),null,ee,A)){const V={id:Ae,role:"ai",content:JSON.stringify(Ee),format:Ee.format,finished:Ee.finished,name:"Assistant"};if(un)E({type:"ADD_MESSAGE",payload:V}),un=!1;else{E({type:"UPDATE_MESSAGE",payload:V});const ve=B.messages.map(Ke=>Ke.id===V.id&&!Ke.finished?V:Ke);Zn(ve)}Ee.finished&&E({type:"SET_LOADING",payload:!1})}}catch(ee){console.error("Error sending message:",ee),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Mr=async A=>{if(!$)return;E({type:"SET_LOADING",payload:!0}),W(A);const Y=Ve(),ee={id:Ve(),role:"user",content:A,trace_id:Y};E({type:"ADD_MESSAGE",payload:ee});try{const Ae={type:"model_select",data:[Z]};let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,A,fe.map(ve=>ve.file),null,Ae,Y)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=B.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(Ae){console.error("Error sending message:",Ae),E({type:"SET_LOADING",payload:!1})}finally{H([])}},Or=A=>{A.metaKey&&A.key==="Enter"&&ke()},Dr=()=>{E({type:"CLEAR_MESSAGES"});const A=B.sessionId;A&&localStorage.removeItem(`messages_${A}`),localStorage.removeItem("sessionId");const Y=Ve();E({type:"SET_SESSION_ID",payload:Y}),localStorage.setItem("sessionId",Y)},Sn=A=>{pe(A)},Dn=async(A,Y)=>{if(!$||!k)return;E({type:"SET_LOADING",payload:!0});const ee=Ve(),Ae={id:Ve(),role:"user",content:k.comfyClass||k.type,trace_id:ee};E({type:"ADD_MESSAGE",payload:Ae});try{let un=Ve(),Ee=!0;for await(const V of Ot.streamInvokeServer($,k.comfyClass||k.type,[],A,Y,ee)){const ve={id:un,role:"ai",content:JSON.stringify(V),format:V.format,finished:V.finished,name:"Assistant"};if(A&&A!==""&&(ve.metadata={intent:A}),Ee)E({type:"ADD_MESSAGE",payload:ve}),Ee=!1;else{E({type:"UPDATE_MESSAGE",payload:ve});const Ke=B.messages.map(cn=>cn.id===ve.id&&!cn.finished?ve:cn);Zn(Ke)}V.finished&&E({type:"SET_LOADING",payload:!1})}}catch(un){console.error("Error sending message:",un),E({type:"SET_LOADING",payload:!1})}},Zn=A=>{B.sessionId&&localStorage.setItem(`messages_${B.sessionId}`,JSON.stringify(A))},Pn=A=>{console.log("[WorkflowChat] Adding new message:",A);const Y=[...B.messages,A];E({type:"ADD_MESSAGE",payload:A}),Zn(Y)},An=()=>{Pe(!1)},Pr=A=>{const Y=Array.from(A).map(ee=>({id:Math.random().toString(36).substr(2,9),file:ee,preview:URL.createObjectURL(ee)}));H(ee=>[...ee,...Y])},Yn=A=>{H(Y=>Y.filter(Ae=>Ae.id!==A))};wn.useEffect(()=>()=>{fe.forEach(A=>URL.revokeObjectURL(A.preview))},[fe]),I.useEffect(()=>{o&&D&&F==="chat"&&(Dn("node_explain"),D())},[o,F]),I.useEffect(()=>{if(!w||F!=="chat")return;(async()=>{try{const Y=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==Y){const Ae=await Ot.fetchAnnouncement();Ae&&Ae.trim()!==""&&(bn(Ae),kt(!0),localStorage.setItem("announcementLastShownDate",Y))}}catch(Y){console.error("Error fetching announcement:",Y)}})()},[w,F]);const Xn=()=>{kt(!1)},gt=A=>{E({type:"SET_ACTIVE_TAB",payload:A})},We=wn.useMemo(()=>h.jsx(ap,{}),[]);return h.jsxs("div",{className:"fixed right-0 shadow-lg bg-white duration-200 ease-out",style:{display:w?"block":"none",width:`${dt.width}px`,height:`${dt.height}px`,top:`${dt.top}px`},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300",onMouseDown:A=>{Wt(!0),A.preventDefault()}}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx(Kg,{onClose:m,onClear:Dr,hasMessages:M.length>0,onHeightResize:Tr,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(Wo,{active:F==="chat",onClick:()=>gt("chat"),children:"Chat"}),h.jsx(Wo,{active:F==="parameter-debug",onClick:()=>gt("parameter-debug"),children:"GenLab"})]}),Rr&&_e&&F==="chat"&&h.jsx(op,{message:_e,onClose:Xn}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth",style:{display:F==="chat"?"block":"none"},ref:re,children:h.jsx(np,{messages:M,latestInput:R,onOptionClick:Sn,installedNodes:q,onAddMessage:Pn,loading:x})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:F==="chat"?"block":"none"},children:[k&&h.jsx(Zg,{nodeInfo:k,onSendWithIntent:Dn,loading:x,onSendWithContent:Mr}),h.jsx(Hg,{input:ie,loading:x,onChange:qn,onSend:ke,onKeyPress:Or,onUploadImages:Pr,uploadedImages:fe,onRemoveImage:Yn,selectedModel:Z,onModelChange:Se})]}),h.jsx("div",{className:"flex-1 flex flex-col",style:{display:F==="parameter-debug"?"flex":"none"},children:We})]})]})}const xp=Object.freeze(Object.defineProperty({__proto__:null,default:lp},Symbol.toStringTag,{value:"Module"}));export{mp as g,vp as i,_p as m,pp as r,xp as w}; diff --git a/ui/src/components/chat/messages/NodeInstallGuide.tsx b/ui/src/components/chat/messages/NodeInstallGuide.tsx index cc4467e..03d4dee 100644 --- a/ui/src/components/chat/messages/NodeInstallGuide.tsx +++ b/ui/src/components/chat/messages/NodeInstallGuide.tsx @@ -19,12 +19,19 @@ interface NodeInstallGuideProps { export function NodeInstallGuide({ content, onLoadSubgraph }: NodeInstallGuideProps) { const response = JSON.parse(content); const nodeInfos = response.ext?.find((item: { type: string }) => item.type === 'node_install_guide')?.data || []; + + const uniqueNodeInfos = nodeInfos.reduce((acc: any[], node) => { + if (!acc.some(n => n.name === node.name)) { + acc.push(node); + } + return acc; + }, []); return (

Before loading the graph to canvas, the following nodes need to be installed. Please visit the corresponding GitHub repositories to install them:

- {nodeInfos.map((node: any, index: number) => ( + {uniqueNodeInfos.map((node: any, index: number) => (