@fieldwangai/agentflow 0.1.56 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,11 +113,27 @@ function manifestOwnerUserId(manifest) {
113
113
  return String(manifest?.ownerUserId || manifest?.createdBy || "").trim();
114
114
  }
115
115
 
116
- function canAccessMarketplaceNode(manifest, opts = {}) {
116
+ function isAdminRequest(opts = {}) {
117
+ return Boolean(opts?.isAdmin);
118
+ }
119
+
120
+ function canAccessMarketplaceOwner(ownerUserId, opts = {}) {
117
121
  const requestedUserId = String(opts.userId || "").trim();
118
122
  if (!requestedUserId) return true;
123
+ if (isAdminRequest(opts)) return true;
124
+ return Boolean(ownerUserId) && ownerUserId === requestedUserId;
125
+ }
126
+
127
+ function canManageMarketplaceOwner(ownerUserId, opts = {}) {
128
+ const requestedUserId = String(opts.userId || "").trim();
129
+ if (!requestedUserId) return false;
130
+ if (isAdminRequest(opts)) return true;
131
+ return Boolean(ownerUserId) && ownerUserId === requestedUserId;
132
+ }
133
+
134
+ function canAccessMarketplaceNode(manifest, opts = {}) {
119
135
  if ((manifest?.source || "marketplace") !== "marketplace") return true;
120
- return manifestOwnerUserId(manifest) === requestedUserId;
136
+ return canAccessMarketplaceOwner(manifestOwnerUserId(manifest), opts);
121
137
  }
122
138
 
123
139
  function sortVersionsDesc(versions) {
@@ -422,7 +438,7 @@ export function listMarketplaceFlowSnippets(workspaceRoot, opts = {}) {
422
438
  if (!manifest) continue;
423
439
  const snippet = manifest.snippet && typeof manifest.snippet === "object" ? manifest.snippet : {};
424
440
  const ownerUserId = String(manifest.ownerUserId || manifest.createdBy || "").trim();
425
- if (requestedUserId && ownerUserId !== requestedUserId) continue;
441
+ if (requestedUserId && !canAccessMarketplaceOwner(ownerUserId, opts)) continue;
426
442
  snippets.push({
427
443
  id: manifest.id || entry.name,
428
444
  version: manifest.version || version,
@@ -454,8 +470,7 @@ export function deleteMarketplaceNodePackage(workspaceRoot, id, version, opts =
454
470
  return { ok: false, error: `Marketplace node package not found: ${id}@${version}` };
455
471
  }
456
472
  const manifest = normalizeManifest(readYamlObject(manifestPath), packageDir, "marketplace");
457
- const requestedUserId = String(opts.userId || "").trim();
458
- if (!requestedUserId || !manifest || manifestOwnerUserId(manifest) !== requestedUserId) {
473
+ if (!manifest || !canManageMarketplaceOwner(manifestOwnerUserId(manifest), opts)) {
459
474
  return { ok: false, error: "Marketplace node permission denied" };
460
475
  }
461
476
  const usage = listMarketplaceNodeUsages(workspaceRoot, id, version, opts);
@@ -483,8 +498,7 @@ export function deleteMarketplaceFlowSnippetPackage(workspaceRoot, id, version,
483
498
  }
484
499
  const manifest = readYamlObject(manifestPath) || {};
485
500
  const ownerUserId = String(manifest.ownerUserId || manifest.createdBy || "").trim();
486
- const requestedUserId = String(opts.userId || "").trim();
487
- if (!requestedUserId || ownerUserId !== requestedUserId) {
501
+ if (!canManageMarketplaceOwner(ownerUserId, opts)) {
488
502
  return { ok: false, error: "Flow snippet permission denied" };
489
503
  }
490
504
  fs.rmSync(packageDir, { recursive: true, force: true });
@@ -719,7 +733,7 @@ export function publishNodeFromInstance(workspaceRoot, payload = {}, options = {
719
733
  const existingManifest = readYamlObject(path.join(dest, NODE_MANIFEST));
720
734
  if (existingManifest) {
721
735
  const existingOwner = manifestOwnerUserId(existingManifest);
722
- if (existingOwner !== ownerUserId) return { ok: false, error: "Marketplace node permission denied" };
736
+ if (!canManageMarketplaceOwner(existingOwner, options)) return { ok: false, error: "Marketplace node permission denied" };
723
737
  }
724
738
  const now = new Date().toISOString();
725
739
  fs.mkdirSync(path.dirname(dest), { recursive: true });
@@ -797,7 +811,7 @@ export function publishFlowSnippet(workspaceRoot, payload = {}, opts = {}) {
797
811
  const existingManifest = readYamlObject(path.join(dest, FLOW_SNIPPET_MANIFEST));
798
812
  if (existingManifest) {
799
813
  const existingOwner = String(existingManifest.ownerUserId || existingManifest.createdBy || "").trim();
800
- if (existingOwner !== ownerUserId) return { ok: false, error: "Flow snippet permission denied" };
814
+ if (!canManageMarketplaceOwner(existingOwner, opts)) return { ok: false, error: "Flow snippet permission denied" };
801
815
  }
802
816
  fs.mkdirSync(path.dirname(dest), { recursive: true });
803
817
  fs.rmSync(dest, { recursive: true, force: true });
@@ -3271,7 +3271,7 @@ export function startUiServer({
3271
3271
  }
3272
3272
 
3273
3273
  const authUser = getAuthUserFromRequest(req);
3274
- const userCtx = authUser ? { userId: authUser.userId } : {};
3274
+ const userCtx = authUser ? { userId: authUser.userId, isAdmin: Boolean(authUser.isAdmin) } : {};
3275
3275
  if (req.method === "GET" && url.pathname === "/api/display/share") {
3276
3276
  try {
3277
3277
  const id = String(url.searchParams.get("id") || "").trim();
@@ -125,7 +125,7 @@ script: node -e "console.log('TODO: scripts/x.mjs')"
125
125
 
126
126
  `).trimEnd()}function bx(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function gK(e){const t=String(e||"");let n="",r=0;Ym.lastIndex=0;let s;for(;s=Ym.exec(t);)n+=bx(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${bx(s[0])}</span>`,r=s.index+s[0].length;return n+=bx(t.slice(r)),n||" "}function yK(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+i+a+l)}function ST({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var Vn,or;const{t:f}=Pn(),u=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=dK(e),b=fK(g),v=(e==null?void 0:e.isRunMode)??!1,y=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,w=(e==null?void 0:e.isDim)??!1,j=(e==null?void 0:e.nodeStatus)??null,A=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",$=C.startsWith("provide_"),B=C==="provide_bool",F=C==="provide_str",z=C==="provide_file",L=C==="agent_subAgent",O=L&&!v,W=B?pK(p[0]):!1,M=$?String(((Vn=p[0])==null?void 0:Vn.value)??((or=p[0])==null?void 0:or.default)??(e==null?void 0:e.body)??""):"",T=String((e==null?void 0:e.body)||""),E=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),D=!$&&!O&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",_=ks(e==null?void 0:e.images),R=h.useRef(!1),P=h.useRef(!1),X=h.useRef(null),Z=h.useRef(null),V=h.useRef(null),[ne,ue]=h.useState(M),[pe,ge]=h.useState(T);h.useEffect(()=>{R.current||ue(M)},[n,M]),h.useEffect(()=>{P.current||ge(T)},[n,T]),h.useEffect(()=>{const ye=Z.current;if(!ye)return;const Ie=yK(ye,pe);ye.style.minHeight=`${Ie}px`,ye.style.height="",V.current&&(V.current.style.minHeight=`${Ie}px`,V.current.style.height="")},[pe]),h.useEffect(()=>{const ye=X.current,Ie=e==null?void 0:e.onNodeContentResize;if(!O||!ye||!Ie||typeof ResizeObserver>"u")return;let nt=0;const Ct=()=>{window.cancelAnimationFrame(nt),nt=window.requestAnimationFrame(()=>Ie(n))},ie=new ResizeObserver(Ct);return ie.observe(ye),Ct(),()=>{window.cancelAnimationFrame(nt),ie.disconnect()}},[e==null?void 0:e.onNodeContentResize,O,n]);const ae=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],be=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],Ae=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],we=((e==null?void 0:e.model)??"").trim(),Pe=m==="agent"&&!C.startsWith("tool_nodejs"),Te=new Set(ae.map(Bo)),it=new Set(be.map(Bo)),ct=new Set(Ae.map(Bo)),tt=we?we.startsWith("cursor:")||we.startsWith("opencode:")||we.startsWith("claude-code:")?we:ct.has(we)?`claude-code:${we}`:it.has(we)?`opencode:${we}`:Te.has(we)?`cursor:${we}`:we:"",jt=we&&!tt.startsWith("cursor:")&&!tt.startsWith("opencode:")&&!tt.startsWith("claude-code:")&&!Te.has(we)&&!it.has(we)&&!ct.has(we),Ye=we.startsWith("cursor:")?we.slice(7):we.startsWith("opencode:")?we.slice(9):we.startsWith("claude-code:")?we.slice(12):we,kt=ye=>{if(y)return;const Ie=ye.target.value;d&&d(n,Ie)},nn=ye=>{ye.stopPropagation(),!y&&r&&r(n)},vn=ye=>{ye.stopPropagation(),s&&s()},Mn=ye=>{ye.stopPropagation(),!y&&(i==null||i(n,ye.target.value==="true"?"true":"false"))},Ht=ye=>{if(ye.stopPropagation(),y)return;const Ie=ye.target.value;ue(Ie),R.current||i==null||i(n,Ie)},$n=ye=>{ye.stopPropagation(),R.current=!0},Wn=ye=>{if(ye.stopPropagation(),y)return;R.current=!1;const Ie=ye.currentTarget.value;ue(Ie),i==null||i(n,Ie)},le=()=>{y||i==null||i(n,ne)},de=ye=>{if(ye.stopPropagation(),y)return;const Ie=window.prompt("文件路径",ne);Ie!=null&&(ue(Ie),i==null||i(n,Ie))},He=ye=>{if(ge(ye),a==null||a(n,ye),l){const Ie=GU(_,ye);(Ie.length!==_.length||Ie.some((nt,Ct)=>{var ie;return nt.id!==((ie=_[Ct])==null?void 0:ie.id)}))&&l(n,Ie)}},Ze=ye=>{if(ye.stopPropagation(),y)return;const Ie=ye.target.value;P.current?ge(Ie):He(Ie)},ot=ye=>{ye.stopPropagation(),!y&&(P.current=!0)},Xt=ye=>{if(ye.stopPropagation(),y)return;P.current=!1;const Ie=ye.currentTarget.value;He(Ie)},rn=()=>{y||He(pe)},sn=async ye=>{if(y)return;const Ie=await xT({files:ye,body:pe,images:_});Ie&&(ge(Ie.body),a==null||a(n,Ie.body),l==null||l(n,Ie.images))},An=(ye,Ie)=>{if(ye.stopPropagation(),y)return;const nt=_.filter(ie=>ie.id!==Ie.id),Ct=mK(pe,Ie.label);ge(Ct),a==null||a(n,Ct),l==null||l(n,nt)},Sr=ye=>{if(y)return;const Ie=yT(ye);Ie.length!==0&&(ye.preventDefault(),ye.stopPropagation(),sn(Ie).catch(()=>{}))},Jt=ye=>{if(y)return;const Ie=Gm(ye);Ie.length!==0&&(ye.preventDefault(),ye.stopPropagation(),sn(Ie).catch(()=>{}))},mn=()=>{const ye=Z.current,Ie=V.current;!ye||!Ie||(Ie.scrollTop=ye.scrollTop,Ie.scrollLeft=ye.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(j==="success"?" af-flow-node--done":"")+(j==="failed"?" af-flow-node--failed":"")+(j==="running"&&!k?" af-flow-node--running-disk":"")+(w?" af-flow-node--dim":"")+(O?" af-flow-node--inline-body-editor":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:b}),!v&&Pe&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Or,onMouseDown:Or,onClick:Or,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:tt,onChange:kt,onPointerDown:Or,onMouseDown:Or,onClick:Or,"aria-label":f("flow:node.model"),title:Ye||f("flow:node.defaultModel"),disabled:y,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),jt&&o.jsx("option",{value:we,children:we}),ae.length>0&&o.jsx("optgroup",{label:"Cursor",children:ae.map(ye=>o.jsx("option",{value:`cursor:${Bo(ye)}`,children:Bo(ye)},`c-${ye}`))}),be.length>0&&o.jsx("optgroup",{label:"OpenCode",children:be.map(ye=>o.jsx("option",{value:`opencode:${Bo(ye)}`,children:Bo(ye)},`o-${ye}`))}),Ae.length>0&&o.jsx("optgroup",{label:"Claude Code",children:Ae.map(ye=>o.jsx("option",{value:`claude-code:${Bo(ye)}`,children:Bo(ye)},`cc-${ye}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),j==="running"&&!k&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),j==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:A!=null&&String(A).trim()!==""?A:"--"}),j==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!v&&$&&!B&&!F&&!z&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:vn,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!v&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:y,onClick:nn,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:u.map((ye,Ie)=>{if(ye.showOnNode===!1)return null;const nt=f("flow:node.inputTooltip",{name:ye.name||`#${Ie}`,type:ye.type})+(ye.default!=null&&ye.default!==""?f("flow:node.defaultSuffix",{value:ye.default}):""),Ct=ye.name||`#${Ie+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:nt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Ct,ye.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ps,{type:"target",position:Je.Left,id:`input-${Ie}`,className:"af-flow-node__handle",style:{background:nr(ye.type)},title:nt})]},`in-${Ie}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:E}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,B?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(W?" af-flow-node__bool-select--true":""),value:W?"true":"false",onChange:Mn,onPointerDown:Or,onMouseDown:Or,onClick:Or,"aria-label":"Boolean value",title:W?"true":"false",disabled:y,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):F?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ne,onChange:Ht,onCompositionStart:$n,onCompositionEnd:Wn,onBlur:le,onPointerDown:Or,onMouseDown:Or,onClick:Or,placeholder:"输入文本",rows:2,readOnly:y}):z?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Or,onMouseDown:Or,onClick:Or,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:ne,onChange:Ht,onCompositionStart:$n,onCompositionEnd:Wn,onBlur:le,placeholder:"选择或输入文件路径",title:ne||"选择或输入文件路径",readOnly:y}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:y,onClick:de,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):L&&!v?o.jsxs("div",{ref:X,className:"af-flow-node__prompt-stack nodrag",children:[o.jsx("pre",{ref:V,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:gK(pe)+`
127
127
  `}}),o.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:pe,onChange:Ze,onCompositionStart:ot,onCompositionEnd:Xt,onBlur:rn,onPaste:Sr,onDrop:Jt,onScroll:mn,onDragOver:ye=>{Gm(ye).length>0&&ye.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,L&&_.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:_.map((ye,Ie)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:ye.name,children:[o.jsx("img",{src:ye.dataUrl,alt:""}),o.jsxs("span",{children:["[",ye.label||`image ${Ie+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:nt=>An(nt,ye),onPointerDown:Or,onMouseDown:Or,"aria-label":`删除 ${ye.label||`image ${Ie+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ye.id||Ie))}):null,D?o.jsx("span",{className:"af-flow-node__prompt-preview",title:D,children:D}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((ye,Ie)=>{if(ye.showOnNode===!1)return null;const nt=f("flow:node.outputTooltip",{name:ye.name||`#${Ie}`,type:ye.type})+(ye.default!=null&&ye.default!==""?f("flow:node.defaultSuffix",{value:ye.default}):""),Ct=ye.name||`#${Ie+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:nt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Ct,ye.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ps,{type:"source",position:Je.Right,id:`output-${Ie}`,className:"af-flow-node__handle",style:{background:nr(ye.type)},title:nt})]},`out-${Ie}`)})})]})]})}const pp="flowNode";function NT(e){if(!e||!(e instanceof Element))return!1;if(e.closest('[contenteditable="true"]'))return!0;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function Qm(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function xK(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function wK({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Pn(),a=h.useId(),l=h.useRef(null),[c,d]=h.useState(""),[f,u]=h.useState(!1),[p,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),u(!1);const y=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),b=g===n;async function v(y){if(y.preventDefault(),!(!b||f)){u(!0),m("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await k.json().catch(()=>({}));if(!k.ok){m(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(k){m(String((k==null?void 0:k.message)||k))}finally{u(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:v,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!b})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||f,children:i(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function Ij({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:f}){const{t:u}=Pn(),p=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=m.current)==null?void 0:w.focus()});function k(w){w.key==="Escape"&&f(),w.key==="Enter"&&d()}return window.addEventListener("keydown",k),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",k)}},[e,f,d]),!e)return null;const g=r??u("common:common.confirm","确定"),b=s??u("common:common.cancel","取消"),v=t??u("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&f()},children:o.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:v}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:f,"aria-label":b,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:f,children:b}),a&&c?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function bK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Pn(),l=h.useId(),c=h.useRef(null),[d,f]=h.useState(""),[u,p]=h.useState(!1),[m,g]=h.useState("");if(h.useEffect(()=>{if(!e)return;f(""),g(""),p(!1);const k=requestAnimationFrame(()=>{var w;return(w=c.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(k)},[e,n]),!e)return null;const b=d.trim(),v=b===n;async function y(k){if(k.preventDefault(),!v||u)return;p(!0),g("");let w=null;try{const j=new AbortController;w=setTimeout(()=>j.abort(),15e3);const A=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:b,flowArchived:s}),signal:j.signal}),C=await A.json().catch(()=>({}));if(!A.ok){g(typeof C.error=="string"?C.error:a("project:deleteModal.deleteFailed"));return}try{for(let $=localStorage.length-1;$>=0;$--){const B=localStorage.key($);B&&(B.startsWith(`af:composer-sessions:${n}:${r}`)||B.startsWith(`af:composer-active-session:${n}:${r}`)||B.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(B)}}catch{}await i()}catch(j){if((j==null?void 0:j.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((j==null?void 0:j.message)||j))}finally{w&&clearTimeout(w),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:k=>{k.target===k.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:k=>f(k.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!v})]}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!v||u,children:a(u?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function vK({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Ii({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(vK,{children:t})]},n))})}function jT({open:e,onClose:t}){const{t:n}=Pn(),r=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=xK()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(Ii,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(Ii,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Ii,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(Ii,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(Ii,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(Ii,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(Ii,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(Ii,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(Ii,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(Ii,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(Ii,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function kK(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function CT({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Pn(),[i,a]=h.useState(""),[l,c]=h.useState(0),d=h.useRef(null),f=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var b;return(b=d.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(g)},[e]);const u=h.useMemo(()=>{const g=(r||[]).map(y=>{var k,w,j;return{id:y.id,label:((k=y.data)==null?void 0:k.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),b=i.trim(),v=g.map(y=>({e:y,s:kK(y,b)})).filter(y=>y.s>0);return v.sort((y,k)=>k.s-y.s||y.e.id.localeCompare(k.e.id)),v.slice(0,50).map(y=>y.e)},[r,i]);if(h.useEffect(()=>{l>=u.length&&c(0)},[u.length,l]),h.useEffect(()=>{var b;const g=(b=f.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const b=u[g];b&&(n(b.id),t())},m=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(b=>Math.min(u.length-1,b+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(b=>Math.max(0,b-1));return}g.key==="Enter"&&(g.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:g=>{a(g.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:u.length})]}),u.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:u.map((g,b)=>o.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(b),onMouseDown:v=>{v.preventDefault(),p(b)},children:[o.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&o.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function SK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=Pn(),f=h.useId(),u=h.useRef(null),p=h.useRef(null),[m,g]=h.useState(""),[b,v]=h.useState(""),[y,k]=h.useState(!1),[w,j]=h.useState(!1),[A,C]=h.useState(!1),[$,B]=h.useState(""),[F,z]=h.useState("");if(h.useEffect(()=>{if(!e||!i)return;g(""),v(""),B(""),z(""),k(!0),j(!1),C(!1);const E=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const _=await fetch(`/api/pipeline-file-content?${E}`),R=await _.json();if(!_.ok)throw new Error(R.error||"HTTP "+_.status);g(R.content||""),v(R.content||"")}catch(_){B(_.message||String(_))}finally{k(!1)}})();const D=requestAnimationFrame(()=>{var _;return(_=u.current)==null?void 0:_.focus()});return()=>cancelAnimationFrame(D)},[e,i,n,r,s]),!e)return null;const L=m!==b;async function O(E){if(E.preventDefault(),!w){j(!0),B(""),z("");try{const D=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),_=await fetch(`/api/pipeline-file-save?${D}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),R=await _.json();if(!_.ok)throw new Error(R.error||"HTTP "+_.status);v(m),z(d("flow:fileEdit.saved")),l&&l()}catch(D){B(D.message||String(D))}finally{j(!1)}}}async function W(){if(!(!c||A||!m)){C(!0),B("");try{const E=await c(m);typeof E=="string"&&E&&g(E)}catch(E){B(E.message||String(E))}finally{C(!1)}}}function M(){g(b),B(""),z("")}const T=m.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:E=>{E.target===E.currentTarget&&t()},children:o.jsxs("div",{ref:u,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:E=>E.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:y?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):$&&!m?o.jsx("div",{className:"af-file-edit-error",children:$}):o.jsxs(o.Fragment,{children:[T&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:m,onChange:E=>g(E.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),($||F)&&!y&&o.jsx("div",{className:`af-file-edit-status${F?" af-file-edit-status--success":""}`,children:F||$}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:M,disabled:!L||w||A,children:d("flow:fileEdit.reset")}),c&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:W,disabled:A||w||!m,children:d(A?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:O,disabled:!L||w||A,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const ET=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),NK=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function jK(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function CK(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function Tj(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function _T(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(ET.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function PT(e){return{inputNames:Tj(e==null?void 0:e.inputs),outputNames:Tj(e==null?void 0:e.outputs)}}function EK(e,t,n){const r=PT(t),s=CK(e),i=[];for(const a of s)if(!_T(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function _K(e,t){const n=PT(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],c=_T(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function PK(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function AK(e){return e.map(t=>{const n=PK(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function IK(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of NK)ET.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function TK(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function RK(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),d=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function wh({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:f}=Pn(),u=h.useId(),p=h.useRef(null),m=h.useRef(null),[g,b]=h.useState(0),[v,y]=h.useState(0),[k,w]=h.useState(null),j=h.useMemo(()=>ks(c),[c]),A=h.useMemo(()=>EK(e,a,f),[e,a,f]),C=A.length>0,$=h.useMemo(()=>_K(e,a),[e,a]),B=h.useMemo(()=>AK($),[$]),F=h.useMemo(()=>n?null:jK(e,g),[e,g,n]),z=h.useMemo(()=>{if(!F)return[];const E=IK(a,f);return TK(E,F.query)},[F,a,f]);h.useEffect(()=>{y(E=>{const D=Math.max(0,z.length-1);return Math.min(Math.max(0,E),D)})},[z.length]);const L=h.useCallback(()=>{const E=p.current;if(!E||!F||z.length===0){w(null);return}const D=RK(E,g);if(!D){w(null);return}const _=4,R=44,P=13.5*16,X=Math.min(z.length*R+8,P);let Z=D.bottom+_;Z+X>window.innerHeight-8&&(Z=Math.max(8,D.top-X-_));const V=288;let ne=D.left;ne=Math.max(8,Math.min(ne,window.innerWidth-V-8)),w({top:Z,left:ne})},[F,z.length,g]);h.useLayoutEffect(()=>{if(!F||z.length===0){w(null);return}const E=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(E)},[F,z.length,g,e,L]),h.useEffect(()=>{if(!F||z.length===0)return;const E=()=>L();return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[F,z.length,L]);const O=h.useCallback(E=>{if(!F)return;const{atIndex:D}=F,_=e.slice(0,D)+"${"+E+"}"+e.slice(g);t(_);const R=D+E.length+3;queueMicrotask(()=>{const P=p.current;P&&(P.focus(),P.setSelectionRange(R,R)),b(R)})},[F,e,g,t]),W=h.useCallback(()=>{const E=p.current,D=m.current;!E||!D||(D.scrollTop=E.scrollTop,D.scrollLeft=E.scrollLeft,F&&z.length>0&&queueMicrotask(()=>L()))},[F,z.length,L]),M=h.useCallback(E=>{if(!n&&F&&z.length>0&&(E.key==="ArrowDown"||E.key==="ArrowUp"||E.key==="Enter")){if(E.key==="ArrowDown")E.preventDefault(),y(D=>(D+1)%z.length);else if(E.key==="ArrowUp")E.preventDefault(),y(D=>(D-1+z.length)%z.length);else if(E.key==="Enter"&&!E.shiftKey){E.preventDefault();const D=z[v];D&&O(D.insert)}}},[n,F,z,v,O]),T=h.useCallback(async E=>{if(n||typeof d!="function")return!1;const D=await xT({files:E,body:e,images:j});return D?(t(D.body),d(D.images),queueMicrotask(()=>{const _=p.current;if(!_)return;_.focus();const R=D.body.length;_.setSelectionRange(R,R),b(R)}),!0):!1},[n,j,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((E,D)=>o.jsxs("span",{className:"af-body-image-chip",title:E.name,children:[o.jsx("img",{src:E.dataUrl,alt:""}),o.jsxs("span",{children:["[",E.label||`image ${D+1}`,"]"]})]},E.id||D))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:B+`
128
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?u:void 0,onChange:E=>{t(E.target.value),b(E.target.selectionStart??E.target.value.length)},onSelect:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??0)},onClick:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??0)},onKeyUp:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??D.value.length)},onKeyDown:M,onPaste:E=>{const D=yT(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onDragOver:E=>{Gm(E).length>0&&E.preventDefault()},onDrop:E=>{const D=Gm(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onScroll:W})]}),F&&z.length>0&&k?$r.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:z.map((E,D)=>o.jsx("li",{role:"option","aria-selected":D===v,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(D===v?" af-composer-mention-item--active":""),onMouseDown:_=>_.preventDefault(),onMouseEnter:()=>y(D),onClick:()=>O(E.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${E.insert}}`}),E.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:E.subtitle}):null]})},`${E.section}-${E.insert}`))}),document.body):null,C?o.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:A.map(E=>E.message).join(" · ")}):null]})}const AT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function bh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Rj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Pn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((p,m)=>m!==u)),d=(u,p,m)=>{const g=n.map((b,v)=>{if(v!==u)return b;const y={...b,[p]:m};return p==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((u,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function IT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:f,ioSlots:u}){const{t:p}=Pn(),[m,g]=h.useState(!1),[b,v]=h.useState(!1),[y,k]=h.useState({status:"idle",message:""}),w=h.useCallback(O=>{t(W=>W&&{...W,...O})},[t]),{cursorList:j,opencodeList:A,claudeCodeList:C,currentNotInLists:$}=h.useMemo(()=>{const O=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],M=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],T=new Set([...O,...W,...M].map(bh)),E=((e==null?void 0:e.model)??"").trim(),D=E.startsWith("cursor:")?E.slice(7):E.startsWith("opencode:")?E.slice(9):E.startsWith("claude-code:")?E.slice(12):E,_=E&&!T.has(D)?E:"";return{cursorList:O,opencodeList:W,claudeCodeList:M,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const B=String(e.script??""),F=n==="tool_nodejs"||B.trim()!=="",z=typeof c=="function"&&!i&&(e==null?void 0:e.newId),L=async()=>{if(z){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const O=await c(e,n);k({status:"success",message:O!=null&&O.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:O.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(O){k({status:"error",message:String((O==null?void 0:O.message)||O)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:L,disabled:!z||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:O=>w({newId:O.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:O=>w({label:O.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:nl.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>w({role:O.target.value}),disabled:i,children:nl.map(O=>o.jsx("option",{value:O,children:O},O))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const O=(e.model||"").trim();return O?$||O:""})(),onChange:O=>w({model:O.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),$?o.jsxs("option",{value:$,children:[$,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?o.jsx("optgroup",{label:"Cursor",children:j.map(O=>o.jsx("option",{value:bh(O),children:O},`c-${O}`))}):null,A.length>0?o.jsx("optgroup",{label:"OpenCode",children:A.map(O=>o.jsx("option",{value:bh(O),children:O},`o-${O}`))}):null,C.length>0?o.jsx("optgroup",{label:"Claude Code",children:C.map(O=>o.jsx("option",{value:`claude-code:${bh(O)}`,children:O},`cc-${O}`))}):null]})]}),o.jsx(Rj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>w({inputs:O}),disabled:i,requiredReadonly:!d}),o.jsx(Rj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>w({outputs:O}),disabled:i,requiredReadonly:!d}),F?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>v(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(wh,{value:B,onChange:O=>w({script:O}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(wh,{value:e.body,onChange:O=>w({body:O}),images:e.images,onImagesChange:O=>w({images:O}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:O=>{O.target===O.currentTarget&&v(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>v(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(wh,{value:B,onChange:O=>w({script:O}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:O=>{O.target===O.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(wh,{value:e.body,onChange:O=>w({body:O}),images:e.images,onImagesChange:O=>w({images:O}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function y0(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function LK(e){const t=y0(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function TT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Lj({text:e}){const{t}=Pn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(dp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Oj({o:e}){var r;const{t}=Pn(),n=y0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:TT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(dp,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Mj(e){return LK(e)}function $j(e){var r;if(!e)return null;const t=y0(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?TT(String(n)):String(n)}function Dj({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Fj=2e4,RT="af:run-node-ctx-width";function Jh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Da(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):Da(Jh())}function OK(){try{const e=localStorage.getItem(RT);if(e==null)return Da(Jh());const t=parseInt(e,10);return Number.isFinite(t)?Da(t):Da(Jh())}catch{return Da(Jh())}}async function zj(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function MK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function $K({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Pn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(OK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,p]=h.useState(!0),[m,g]=h.useState(""),[b,v]=h.useState([]),[y,k]=h.useState(null),[w,j]=h.useState(null),A=h.useRef(null),C=h.useRef(null),$=h.useRef(0),B=h.useRef(0);h.useLayoutEffect(()=>{const _=window.matchMedia("(max-width: 960px)"),R=()=>l(_.matches);return _.addEventListener("change",R),()=>_.removeEventListener("change",R)},[]),h.useEffect(()=>{function _(){d(R=>Da(R))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const F=h.useCallback(()=>{d(_=>{const R=Da(_);try{localStorage.setItem(RT,String(R))}catch{}return R})},[]),z=h.useCallback(_=>{if(a||_.button!==0)return;_.preventDefault();const R=_.currentTarget;f.current={active:!0,pointerId:_.pointerId,startX:_.clientX,startW:c},R.setPointerCapture(_.pointerId)},[a,c]),L=h.useCallback(_=>{const R=f.current;if(!R.active||_.pointerId!==R.pointerId)return;const P=R.startX-_.clientX;d(Da(R.startW+P))},[]),O=h.useCallback(_=>{const R=f.current;if(!(!R.active||_.pointerId!==R.pointerId)){R.active=!1;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}F()}},[F]),W=h.useCallback(()=>{const _=f.current;_.active&&(_.active=!1,F())},[F]),M=h.useCallback(_=>{const R=Array.isArray(_)?_:[];v(R),k(P=>P&&R.some(X=>X.execId===P)?P:R.length>0?R[R.length-1].execId:null)},[]),T=h.useCallback(()=>{if(!e||!t)return;const _=++$.current,R=new AbortController,P=window.setTimeout(()=>R.abort(),Fj);(async()=>{try{const X=await zj(t,e,n,R.signal);if(_!==$.current)return;M(Array.isArray(X.rounds)?X.rounds:[])}catch{}finally{window.clearTimeout(P)}})()},[e,t,n,M]);h.useEffect(()=>{if(!e||!t){p(!1),g(""),v([]);return}const _=++B.current;p(!0),g(""),v([]),k(null);const R=new AbortController,P=window.setTimeout(()=>R.abort(),Fj);return(async()=>{try{const X=await zj(t,e,n,R.signal);if(_!==B.current)return;M(Array.isArray(X.rounds)?X.rounds:[])}catch(X){if(_!==B.current)return;const Z=(X==null?void 0:X.name)==="AbortError"?"requestTimeout":X.message||String(X);g(Z)}finally{window.clearTimeout(P),_===B.current&&p(!1)}})(),()=>{R.abort(),B.current++,$.current++}},[e,t,n,M]),h.useEffect(()=>{r&&T()},[r,T]),h.useEffect(()=>{clearInterval(C.current);const _=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(_&&_.status==="running"))&&e&&t&&(C.current=setInterval(()=>T(),2e3)),()=>clearInterval(C.current)},[b,e,t,n,r,T]),h.useEffect(()=>{A.current&&(A.current.scrollTop=0)},[y]);const E=b.find(_=>_.execId===y),D=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:D,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:z,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:MK(i,m)}),!u&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+FK((E==null?void 0:E.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:_=>{const R=_.target.value;k(R==="latest"?"latest":Number(R))},children:[...b].reverse().map(_=>{const R=_.execId==="latest"?i("flow:runContext.latest"):`#${_.execId}`,P=zK(i,_.status),X=_.finishedAt?` · ${DK(_.finishedAt)}`:"";return o.jsx("option",{value:String(_.execId),children:`${R} · ${P}${X}`},_.execId)})})]}),E&&o.jsxs("div",{className:"af-run-ctx-body",ref:A,children:[E.inputs&&E.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),E.inputs.map((_,R)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:_.value})]},`${_.slot}-${R}`))]}),E.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Lj,{text:E.prompt})]}),E.outputs&&E.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),E.outputs.map((_,R)=>{const P=Mj(_),X=$j(_);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),P?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:P}):null,o.jsx(Dj,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Oj,{o:_})]},`${_.slot}-${R}`)})]}),!E.prompt&&(!E.outputs||E.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&E&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:_=>{_.target===_.currentTarget&&j(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&E.prompt!=null&&o.jsx(Lj,{text:E.prompt}),w==="output"&&E.outputs&&E.outputs.map((_,R)=>{const P=Mj(_),X=$j(_);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),P?o.jsx("span",{className:"af-run-ctx-format-badge",children:P}):null,o.jsx(Dj,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Oj,{o:_})]},`${_.slot}-${R}`)})]})]})})]})}function DK(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function FK(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function zK(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function BK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Pn(),[d,f]=h.useState({}),[u,p]=h.useState(null),[m,g]=h.useState({}),[b,v]=h.useState(!0),[y,k]=h.useState(!1),[w,j]=h.useState(""),[A,C]=h.useState(!1),[$,B]=h.useState(null),F=h.useRef(null),z=h.useRef(!0),L=h.useRef({});h.useMemo(()=>{var P,X,Z;const R={};for(const V of r){const ne=(Z=(X=(P=V.data)==null?void 0:P.outputs)==null?void 0:X[0])==null?void 0:Z.default;ne!=null&&ne!==""&&(R[V.id]=String(ne))}return L.current=R,R},[r]);const O=h.useMemo(()=>{var P;const R={};for(const X of i){if(!((P=X.data)!=null&&P.inputs))continue;const Z=X.data.inputs;for(let V=0;V<Z.length;V++){const ne=Z[V];if(!(ne!=null&&ne.name))continue;const ue=s.find(ge=>ge.target===X.id&&ge.targetHandle===`input-${V}`);if(!(ue!=null&&ue.source))continue;r.find(ge=>ge.id===ue.source)&&(R[ue.source]=ne.name)}}return R},[i,s,r]);h.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),h.useEffect(()=>{if(!e){v(!1);return}v(!0);const R=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&R.set("archived","1"),fetch(`/api/flow/run-config?${R.toString()}`).then(P=>{if(!P.ok)throw new Error(`HTTP ${P.status}`);return P.json()}).then(P=>{var Z;if(!z.current)return;f(P.presets||{}),p(P.activePreset||null);const X=P.activePreset&&((Z=P.presets)!=null&&Z[P.activePreset])?P.presets[P.activePreset]:{};g({...L.current,...X}),v(!1)}).catch(()=>{z.current&&(g(L.current),v(!1))})},[e,t,n]),h.useEffect(()=>{var P;if(!a)return;const R={};for(const[X,Z]of Object.entries(m)){const V=O[X];if(!V)continue;const ne=r.find(pe=>pe.id===X);if(!ne)continue;(((P=ne.data)==null?void 0:P.definitionId)||"").startsWith("provide_file")?R[V]={type:"file",path:Z}:R[V]={type:"str",value:Z}}a(R)},[m,O,r,a]);const W=h.useCallback((R,P)=>{g(X=>({...X,[R]:P}))},[]),M=h.useCallback(R=>{R!==u&&(p(R),R&&d[R]?g({...L.current,...d[R]}):g(L.current))},[u,d]),T=h.useCallback(async()=>{if(w.trim()){k(!0);try{const R={...d,[w.trim()]:m},P={flowId:e,flowSource:t,archived:n,presets:R,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)})).ok&&(f(R),p(w.trim()),j(""),C(!1))}finally{k(!1)}}},[e,t,n,d,m,w]),E=h.useCallback(async()=>{if(u){k(!0);try{const R={...d};delete R[u];const P=Object.keys(R)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:R,activePreset:P})})).ok&&(f(R),p(P),P&&R[P]?g({...L.current,...R[P]}):g(L.current))}finally{k(!1)}}},[e,t,n,d,u]),D=h.useCallback(async()=>{if(u){k(!0);try{const R={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:R,activePreset:u})})).ok&&f(R)}finally{k(!1)}}},[e,t,n,d,u,m]),_=Object.keys(d);return _.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:R=>M(R.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),_.map(R=>o.jsx("option",{value:R,children:R},R))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>C(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:D,disabled:y,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:E,disabled:y,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),A&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:w,onChange:R=>j(R.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:T,disabled:y||!w.trim(),children:c(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{C(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(R=>{var ge,ae;const P=((ge=R.data)==null?void 0:ge.definitionId)||"",X=P.startsWith("provide_file"),Z=P==="provide_bool",V=((ae=R.data)==null?void 0:ae.label)||R.id,ne=R.id,ue=m[ne]||"",pe=["true","1","yes","on"].includes(String(ue).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(X?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:X?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>B({instanceId:ne,label:V,content:ue}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ne}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(pe?" af-run-config-bool-toggle--true":""),onClick:()=>W(ne,pe?"false":"true"),"aria-pressed":pe,children:pe?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:be=>W(ne,be.target.value),placeholder:c(X?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ne)})})]}),$&&$r.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:$.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>B(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:F,className:"af-provide-edit-modal__textarea",defaultValue:$.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!$||!F.current||(W($.instanceId,F.current.value),B(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>B(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const LT={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},HK={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function WK(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function VK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function UK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function Bj(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(LT))if(r.includes(e))return n;return"other"}function KK({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=HK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=i[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(u=>{u.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:VK(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function qK({open:e,onClose:t,flowId:n}){var B;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,c]=h.useState(null),[d,f]=h.useState(null),[u,p]=h.useState(!1),[m,g]=h.useState(!0),[b,v]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,k]=h.useState(""),w=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const F=m&&n?`?flowId=${encodeURIComponent(n)}`:"",L=await(await fetch(`/api/composer-logs${F}`)).json();s(Array.isArray(L.sessions)?L.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),A=h.useCallback(async F=>{if(!F){f(null);return}p(!0);try{const L=await(await fetch(`/api/composer-logs/${encodeURIComponent(F)}`)).json();f(L)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return A(l),w.current=setInterval(()=>A(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,A]);const C=h.useMemo(()=>{const F=(d==null?void 0:d.events)||[],z=y.trim().toLowerCase();return F.filter(L=>{const O=Bj(L.tag,L.payload);return!b[O]&&O!=="other"?!1:z?[L.tag,JSON.stringify(L.payload||"")].join(" ").toLowerCase().includes(z):!0})},[d,b,y]),$=h.useMemo(()=>{const F=(d==null?void 0:d.events)||[],z={};for(const L of F){const O=Bj(L.tag,L.payload);z[O]=(z[O]||0)+1}return z},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:F=>g(F.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(F=>{const z=l===F.sessionId;return o.jsxs("div",{onClick:()=>c(F.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:z?"rgba(124,77,255,0.18)":"transparent",borderLeft:z?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:UK(F.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:F.flowId||"(no flow)"}),F.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:F.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[WK(F.size)," · ",F.model||"default"]})]},F.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(LT).map(F=>o.jsxs("button",{type:"button",onClick:()=>v(z=>({...z,[F]:!z[F]})),style:{background:b[F]?"rgba(124,77,255,0.25)":"transparent",color:b[F]?"#e8deff":"#6a6a6a",border:`1px solid ${b[F]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[F," ",$[F]!=null?`(${$[F]})`:""]},F)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:F=>k(F.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&C.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((B=d.events)==null?void 0:B.length)||0," total)"]}),C.map((F,z)=>o.jsx(KK,{event:F,defaultExpanded:F.tag==="error"},`${F.ts}_${z}`))]})]})]})]}):null}const YK="0.1.56";function Hj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function vx(e,t){return t==="running"?Hj(e):e==null||!Number.isFinite(e)||e<=0?"--":Hj(e)}const OT=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function GK(e){var k,w,j,A,C,$,B,F,z,L,O;const{setNodes:t}=ac(),n=Yv(),{modelLists:r,onModelChange:s}=h.useContext(OT),i=h.useRef(null),a=!!((k=e.data)!=null&&k.readOnly),l=(w=e.data)!=null&&w.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((A=e.data)!=null&&A.isRunMode)&&!a,d=h.useCallback(W=>{const M=()=>n(W);window.requestAnimationFrame(M),window.setTimeout(M,80)},[n]),f=h.useCallback((W,M)=>{const T=Xj(M);T&&(t(E=>E.map(D=>{var P,X,Z,V,ne,ue;if(D.id!==W)return D;const _=Number(((X=(P=D.data)==null?void 0:P.displaySize)==null?void 0:X.width)||D.width||((Z=D.measured)==null?void 0:Z.width)||0),R=Number(((ne=(V=D.data)==null?void 0:V.displaySize)==null?void 0:ne.height)||D.height||((ue=D.measured)==null?void 0:ue.height)||0);return Math.abs(_-T.width)<2&&Math.abs(R-T.height)<2?D:{...D,width:T.width,height:T.height,data:{...D.data,displaySize:T}}})),d(W))},[d,t]),u=h.useCallback(W=>{if(a)return;const M=i.current;if(!M)return;const T=M.getBoundingClientRect();f(W,{width:Math.max(T.width,M.scrollWidth),height:Math.max(T.height,M.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var ne,ue,pe,ge,ae,be;if(!c)return;W.preventDefault(),W.stopPropagation();const M=i.current,T=M==null?void 0:M.getBoundingClientRect(),E=Number(((ue=(ne=e.data)==null?void 0:ne.displaySize)==null?void 0:ue.width)||e.width||((pe=e.measured)==null?void 0:pe.width)||(T==null?void 0:T.width)||FT),D=Number(((ae=(ge=e.data)==null?void 0:ge.displaySize)==null?void 0:ae.height)||e.height||((be=e.measured)==null?void 0:be.height)||(T==null?void 0:T.height)||vb),_=W.clientX,R=W.clientY,P=e.id;let X=0;const Z=Ae=>{const we=Xj({width:E+Ae.clientX-_,height:D+Ae.clientY-R});we&&(window.cancelAnimationFrame(X),X=window.requestAnimationFrame(()=>f(P,we)))},V=()=>{window.cancelAnimationFrame(X),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(P)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,($=(C=e.data)==null?void 0:C.displaySize)==null?void 0:$.height,(F=(B=e.data)==null?void 0:B.displaySize)==null?void 0:F.width,e.height,e.id,(z=e.measured)==null?void 0:z.height,(L=e.measured)==null?void 0:L.width,e.width,d,c]),m=h.useCallback(W=>{t(M=>M.filter(T=>T.id!==W))},[t]),g=h.useCallback(()=>{var E,D,_,R,P,X,Z,V;const W=((E=e.data)==null?void 0:E.definitionId)||"",M=((D=e.data)==null?void 0:D.label)||e.id,T=((P=(R=(_=e.data)==null?void 0:_.outputs)==null?void 0:R[0])==null?void 0:P.value)||((V=(Z=(X=e.data)==null?void 0:X.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:M,definitionId:W,content:T},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,M)=>{t(T=>T.map(E=>{var _;if(E.id!==W)return E;const D=Array.isArray((_=E.data)==null?void 0:_.outputs)&&E.data.outputs.length?E.data.outputs.map((R,P)=>P===0?{...R,default:M,value:M}:R):[{type:"bool",name:"value",default:M,value:M}];return{...E,data:{...E.data,body:"",outputs:D}}}))},[t]),v=h.useCallback((W,M)=>{t(T=>T.map(E=>E.id===W?{...E,data:{...E.data,body:M}}:E))},[t]),y=h.useCallback((W,M)=>{t(T=>T.map(E=>E.id===W?{...E,data:{...E.data,images:ks(M)}}:E))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx(ST,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:b,onNodeBodyChange:v,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":((O=e.data)==null?void 0:O.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const XK={[pp]:GK},Hd=["CONTROL","TOOL","PROVIDE","AGENT"],JK=1200,Wj="af-flow-node--sync-flash",Vj="af-flow-edge--sync-flash";function Uj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function Kj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function x0(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function QK(e){const t=x0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function vh(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function MT(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function $T(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function kx(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function qj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function Yj(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function ZK(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function e7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function DT(e,t,n,r,s){const i=QK(e),a={id:t,type:pp,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return Uf(a,r,s)}const FT=320,t7=220,n7=1600,vb=104,r7=900;function Gj(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Xj(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:Gj(t,t7,n7)||FT,height:Gj(n,vb,r7)||vb}}function s7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function Jj(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=Ou(i,e.sourceHandle||"output-0","source"),c=Ou(a,e.targetHandle||"input-0","target");return!l||!c?!1:Lu(l,c)}function i7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:kT(a)}:null}function o7(e,t,n){var a;const r=DT(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Lu(n.slot,c):Lu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function a7(e,t){return t?e.map((n,r)=>{const s=o7(n,e,t);if(!s)return null;const i=x0(n);return{def:n,order:r,category:i,categoryRank:Hd.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:MT(s.hydrated.data||n),description:$T(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const l7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function c7(e){const t=new Set,n=[];let r;const s=new RegExp(l7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function Qj(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function Vo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function kh(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(Vo),d=a.map(Vo);return l.map(Vo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function u7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Sx(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function d7({steps:e}){const{t}=Pn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
128
+ `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?u:void 0,onChange:E=>{t(E.target.value),b(E.target.selectionStart??E.target.value.length)},onSelect:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??0)},onClick:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??0)},onKeyUp:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??D.value.length)},onKeyDown:M,onPaste:E=>{const D=yT(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onDragOver:E=>{Gm(E).length>0&&E.preventDefault()},onDrop:E=>{const D=Gm(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onScroll:W})]}),F&&z.length>0&&k?$r.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:z.map((E,D)=>o.jsx("li",{role:"option","aria-selected":D===v,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(D===v?" af-composer-mention-item--active":""),onMouseDown:_=>_.preventDefault(),onMouseEnter:()=>y(D),onClick:()=>O(E.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${E.insert}}`}),E.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:E.subtitle}):null]})},`${E.section}-${E.insert}`))}),document.body):null,C?o.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:A.map(E=>E.message).join(" · ")}):null]})}const AT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function bh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Rj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Pn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((p,m)=>m!==u)),d=(u,p,m)=>{const g=n.map((b,v)=>{if(v!==u)return b;const y={...b,[p]:m};return p==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((u,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function IT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:f,ioSlots:u}){const{t:p}=Pn(),[m,g]=h.useState(!1),[b,v]=h.useState(!1),[y,k]=h.useState({status:"idle",message:""}),w=h.useCallback(O=>{t(W=>W&&{...W,...O})},[t]),{cursorList:j,opencodeList:A,claudeCodeList:C,currentNotInLists:$}=h.useMemo(()=>{const O=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],M=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],T=new Set([...O,...W,...M].map(bh)),E=((e==null?void 0:e.model)??"").trim(),D=E.startsWith("cursor:")?E.slice(7):E.startsWith("opencode:")?E.slice(9):E.startsWith("claude-code:")?E.slice(12):E,_=E&&!T.has(D)?E:"";return{cursorList:O,opencodeList:W,claudeCodeList:M,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const B=String(e.script??""),F=n==="tool_nodejs"||B.trim()!=="",z=typeof c=="function"&&!i&&(e==null?void 0:e.newId),L=async()=>{if(z){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const O=await c(e,n);k({status:"success",message:O!=null&&O.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:O.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(O){k({status:"error",message:String((O==null?void 0:O.message)||O)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:L,disabled:!z||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:O=>w({newId:O.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:O=>w({label:O.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:nl.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>w({role:O.target.value}),disabled:i,children:nl.map(O=>o.jsx("option",{value:O,children:O},O))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const O=(e.model||"").trim();return O?$||O:""})(),onChange:O=>w({model:O.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),$?o.jsxs("option",{value:$,children:[$,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?o.jsx("optgroup",{label:"Cursor",children:j.map(O=>o.jsx("option",{value:bh(O),children:O},`c-${O}`))}):null,A.length>0?o.jsx("optgroup",{label:"OpenCode",children:A.map(O=>o.jsx("option",{value:bh(O),children:O},`o-${O}`))}):null,C.length>0?o.jsx("optgroup",{label:"Claude Code",children:C.map(O=>o.jsx("option",{value:`claude-code:${bh(O)}`,children:O},`cc-${O}`))}):null]})]}),o.jsx(Rj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>w({inputs:O}),disabled:i,requiredReadonly:!d}),o.jsx(Rj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>w({outputs:O}),disabled:i,requiredReadonly:!d}),F?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>v(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(wh,{value:B,onChange:O=>w({script:O}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(wh,{value:e.body,onChange:O=>w({body:O}),images:e.images,onImagesChange:O=>w({images:O}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:O=>{O.target===O.currentTarget&&v(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>v(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(wh,{value:B,onChange:O=>w({script:O}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:O=>{O.target===O.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(wh,{value:e.body,onChange:O=>w({body:O}),images:e.images,onImagesChange:O=>w({images:O}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function y0(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function LK(e){const t=y0(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function TT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Lj({text:e}){const{t}=Pn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(dp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Oj({o:e}){var r;const{t}=Pn(),n=y0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:TT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(dp,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Mj(e){return LK(e)}function $j(e){var r;if(!e)return null;const t=y0(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?TT(String(n)):String(n)}function Dj({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Fj=2e4,RT="af:run-node-ctx-width";function Jh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Da(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):Da(Jh())}function OK(){try{const e=localStorage.getItem(RT);if(e==null)return Da(Jh());const t=parseInt(e,10);return Number.isFinite(t)?Da(t):Da(Jh())}catch{return Da(Jh())}}async function zj(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function MK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function $K({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Pn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(OK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,p]=h.useState(!0),[m,g]=h.useState(""),[b,v]=h.useState([]),[y,k]=h.useState(null),[w,j]=h.useState(null),A=h.useRef(null),C=h.useRef(null),$=h.useRef(0),B=h.useRef(0);h.useLayoutEffect(()=>{const _=window.matchMedia("(max-width: 960px)"),R=()=>l(_.matches);return _.addEventListener("change",R),()=>_.removeEventListener("change",R)},[]),h.useEffect(()=>{function _(){d(R=>Da(R))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const F=h.useCallback(()=>{d(_=>{const R=Da(_);try{localStorage.setItem(RT,String(R))}catch{}return R})},[]),z=h.useCallback(_=>{if(a||_.button!==0)return;_.preventDefault();const R=_.currentTarget;f.current={active:!0,pointerId:_.pointerId,startX:_.clientX,startW:c},R.setPointerCapture(_.pointerId)},[a,c]),L=h.useCallback(_=>{const R=f.current;if(!R.active||_.pointerId!==R.pointerId)return;const P=R.startX-_.clientX;d(Da(R.startW+P))},[]),O=h.useCallback(_=>{const R=f.current;if(!(!R.active||_.pointerId!==R.pointerId)){R.active=!1;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}F()}},[F]),W=h.useCallback(()=>{const _=f.current;_.active&&(_.active=!1,F())},[F]),M=h.useCallback(_=>{const R=Array.isArray(_)?_:[];v(R),k(P=>P&&R.some(X=>X.execId===P)?P:R.length>0?R[R.length-1].execId:null)},[]),T=h.useCallback(()=>{if(!e||!t)return;const _=++$.current,R=new AbortController,P=window.setTimeout(()=>R.abort(),Fj);(async()=>{try{const X=await zj(t,e,n,R.signal);if(_!==$.current)return;M(Array.isArray(X.rounds)?X.rounds:[])}catch{}finally{window.clearTimeout(P)}})()},[e,t,n,M]);h.useEffect(()=>{if(!e||!t){p(!1),g(""),v([]);return}const _=++B.current;p(!0),g(""),v([]),k(null);const R=new AbortController,P=window.setTimeout(()=>R.abort(),Fj);return(async()=>{try{const X=await zj(t,e,n,R.signal);if(_!==B.current)return;M(Array.isArray(X.rounds)?X.rounds:[])}catch(X){if(_!==B.current)return;const Z=(X==null?void 0:X.name)==="AbortError"?"requestTimeout":X.message||String(X);g(Z)}finally{window.clearTimeout(P),_===B.current&&p(!1)}})(),()=>{R.abort(),B.current++,$.current++}},[e,t,n,M]),h.useEffect(()=>{r&&T()},[r,T]),h.useEffect(()=>{clearInterval(C.current);const _=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(_&&_.status==="running"))&&e&&t&&(C.current=setInterval(()=>T(),2e3)),()=>clearInterval(C.current)},[b,e,t,n,r,T]),h.useEffect(()=>{A.current&&(A.current.scrollTop=0)},[y]);const E=b.find(_=>_.execId===y),D=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:D,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:z,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:MK(i,m)}),!u&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+FK((E==null?void 0:E.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:_=>{const R=_.target.value;k(R==="latest"?"latest":Number(R))},children:[...b].reverse().map(_=>{const R=_.execId==="latest"?i("flow:runContext.latest"):`#${_.execId}`,P=zK(i,_.status),X=_.finishedAt?` · ${DK(_.finishedAt)}`:"";return o.jsx("option",{value:String(_.execId),children:`${R} · ${P}${X}`},_.execId)})})]}),E&&o.jsxs("div",{className:"af-run-ctx-body",ref:A,children:[E.inputs&&E.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),E.inputs.map((_,R)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:_.value})]},`${_.slot}-${R}`))]}),E.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Lj,{text:E.prompt})]}),E.outputs&&E.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),E.outputs.map((_,R)=>{const P=Mj(_),X=$j(_);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),P?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:P}):null,o.jsx(Dj,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Oj,{o:_})]},`${_.slot}-${R}`)})]}),!E.prompt&&(!E.outputs||E.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&E&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:_=>{_.target===_.currentTarget&&j(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&E.prompt!=null&&o.jsx(Lj,{text:E.prompt}),w==="output"&&E.outputs&&E.outputs.map((_,R)=>{const P=Mj(_),X=$j(_);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),P?o.jsx("span",{className:"af-run-ctx-format-badge",children:P}):null,o.jsx(Dj,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Oj,{o:_})]},`${_.slot}-${R}`)})]})]})})]})}function DK(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function FK(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function zK(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function BK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Pn(),[d,f]=h.useState({}),[u,p]=h.useState(null),[m,g]=h.useState({}),[b,v]=h.useState(!0),[y,k]=h.useState(!1),[w,j]=h.useState(""),[A,C]=h.useState(!1),[$,B]=h.useState(null),F=h.useRef(null),z=h.useRef(!0),L=h.useRef({});h.useMemo(()=>{var P,X,Z;const R={};for(const V of r){const ne=(Z=(X=(P=V.data)==null?void 0:P.outputs)==null?void 0:X[0])==null?void 0:Z.default;ne!=null&&ne!==""&&(R[V.id]=String(ne))}return L.current=R,R},[r]);const O=h.useMemo(()=>{var P;const R={};for(const X of i){if(!((P=X.data)!=null&&P.inputs))continue;const Z=X.data.inputs;for(let V=0;V<Z.length;V++){const ne=Z[V];if(!(ne!=null&&ne.name))continue;const ue=s.find(ge=>ge.target===X.id&&ge.targetHandle===`input-${V}`);if(!(ue!=null&&ue.source))continue;r.find(ge=>ge.id===ue.source)&&(R[ue.source]=ne.name)}}return R},[i,s,r]);h.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),h.useEffect(()=>{if(!e){v(!1);return}v(!0);const R=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&R.set("archived","1"),fetch(`/api/flow/run-config?${R.toString()}`).then(P=>{if(!P.ok)throw new Error(`HTTP ${P.status}`);return P.json()}).then(P=>{var Z;if(!z.current)return;f(P.presets||{}),p(P.activePreset||null);const X=P.activePreset&&((Z=P.presets)!=null&&Z[P.activePreset])?P.presets[P.activePreset]:{};g({...L.current,...X}),v(!1)}).catch(()=>{z.current&&(g(L.current),v(!1))})},[e,t,n]),h.useEffect(()=>{var P;if(!a)return;const R={};for(const[X,Z]of Object.entries(m)){const V=O[X];if(!V)continue;const ne=r.find(pe=>pe.id===X);if(!ne)continue;(((P=ne.data)==null?void 0:P.definitionId)||"").startsWith("provide_file")?R[V]={type:"file",path:Z}:R[V]={type:"str",value:Z}}a(R)},[m,O,r,a]);const W=h.useCallback((R,P)=>{g(X=>({...X,[R]:P}))},[]),M=h.useCallback(R=>{R!==u&&(p(R),R&&d[R]?g({...L.current,...d[R]}):g(L.current))},[u,d]),T=h.useCallback(async()=>{if(w.trim()){k(!0);try{const R={...d,[w.trim()]:m},P={flowId:e,flowSource:t,archived:n,presets:R,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)})).ok&&(f(R),p(w.trim()),j(""),C(!1))}finally{k(!1)}}},[e,t,n,d,m,w]),E=h.useCallback(async()=>{if(u){k(!0);try{const R={...d};delete R[u];const P=Object.keys(R)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:R,activePreset:P})})).ok&&(f(R),p(P),P&&R[P]?g({...L.current,...R[P]}):g(L.current))}finally{k(!1)}}},[e,t,n,d,u]),D=h.useCallback(async()=>{if(u){k(!0);try{const R={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:R,activePreset:u})})).ok&&f(R)}finally{k(!1)}}},[e,t,n,d,u,m]),_=Object.keys(d);return _.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:R=>M(R.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),_.map(R=>o.jsx("option",{value:R,children:R},R))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>C(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:D,disabled:y,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:E,disabled:y,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),A&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:w,onChange:R=>j(R.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:T,disabled:y||!w.trim(),children:c(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{C(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(R=>{var ge,ae;const P=((ge=R.data)==null?void 0:ge.definitionId)||"",X=P.startsWith("provide_file"),Z=P==="provide_bool",V=((ae=R.data)==null?void 0:ae.label)||R.id,ne=R.id,ue=m[ne]||"",pe=["true","1","yes","on"].includes(String(ue).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(X?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:X?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>B({instanceId:ne,label:V,content:ue}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ne}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(pe?" af-run-config-bool-toggle--true":""),onClick:()=>W(ne,pe?"false":"true"),"aria-pressed":pe,children:pe?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:be=>W(ne,be.target.value),placeholder:c(X?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ne)})})]}),$&&$r.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:$.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>B(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:F,className:"af-provide-edit-modal__textarea",defaultValue:$.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!$||!F.current||(W($.instanceId,F.current.value),B(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>B(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const LT={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},HK={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function WK(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function VK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function UK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function Bj(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(LT))if(r.includes(e))return n;return"other"}function KK({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=HK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=i[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(u=>{u.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:VK(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function qK({open:e,onClose:t,flowId:n}){var B;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,c]=h.useState(null),[d,f]=h.useState(null),[u,p]=h.useState(!1),[m,g]=h.useState(!0),[b,v]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,k]=h.useState(""),w=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const F=m&&n?`?flowId=${encodeURIComponent(n)}`:"",L=await(await fetch(`/api/composer-logs${F}`)).json();s(Array.isArray(L.sessions)?L.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),A=h.useCallback(async F=>{if(!F){f(null);return}p(!0);try{const L=await(await fetch(`/api/composer-logs/${encodeURIComponent(F)}`)).json();f(L)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return A(l),w.current=setInterval(()=>A(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,A]);const C=h.useMemo(()=>{const F=(d==null?void 0:d.events)||[],z=y.trim().toLowerCase();return F.filter(L=>{const O=Bj(L.tag,L.payload);return!b[O]&&O!=="other"?!1:z?[L.tag,JSON.stringify(L.payload||"")].join(" ").toLowerCase().includes(z):!0})},[d,b,y]),$=h.useMemo(()=>{const F=(d==null?void 0:d.events)||[],z={};for(const L of F){const O=Bj(L.tag,L.payload);z[O]=(z[O]||0)+1}return z},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:F=>g(F.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(F=>{const z=l===F.sessionId;return o.jsxs("div",{onClick:()=>c(F.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:z?"rgba(124,77,255,0.18)":"transparent",borderLeft:z?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:UK(F.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:F.flowId||"(no flow)"}),F.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:F.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[WK(F.size)," · ",F.model||"default"]})]},F.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(LT).map(F=>o.jsxs("button",{type:"button",onClick:()=>v(z=>({...z,[F]:!z[F]})),style:{background:b[F]?"rgba(124,77,255,0.25)":"transparent",color:b[F]?"#e8deff":"#6a6a6a",border:`1px solid ${b[F]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[F," ",$[F]!=null?`(${$[F]})`:""]},F)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:F=>k(F.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&C.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((B=d.events)==null?void 0:B.length)||0," total)"]}),C.map((F,z)=>o.jsx(KK,{event:F,defaultExpanded:F.tag==="error"},`${F.ts}_${z}`))]})]})]})]}):null}const YK="0.1.57";function Hj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function vx(e,t){return t==="running"?Hj(e):e==null||!Number.isFinite(e)||e<=0?"--":Hj(e)}const OT=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function GK(e){var k,w,j,A,C,$,B,F,z,L,O;const{setNodes:t}=ac(),n=Yv(),{modelLists:r,onModelChange:s}=h.useContext(OT),i=h.useRef(null),a=!!((k=e.data)!=null&&k.readOnly),l=(w=e.data)!=null&&w.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((A=e.data)!=null&&A.isRunMode)&&!a,d=h.useCallback(W=>{const M=()=>n(W);window.requestAnimationFrame(M),window.setTimeout(M,80)},[n]),f=h.useCallback((W,M)=>{const T=Xj(M);T&&(t(E=>E.map(D=>{var P,X,Z,V,ne,ue;if(D.id!==W)return D;const _=Number(((X=(P=D.data)==null?void 0:P.displaySize)==null?void 0:X.width)||D.width||((Z=D.measured)==null?void 0:Z.width)||0),R=Number(((ne=(V=D.data)==null?void 0:V.displaySize)==null?void 0:ne.height)||D.height||((ue=D.measured)==null?void 0:ue.height)||0);return Math.abs(_-T.width)<2&&Math.abs(R-T.height)<2?D:{...D,width:T.width,height:T.height,data:{...D.data,displaySize:T}}})),d(W))},[d,t]),u=h.useCallback(W=>{if(a)return;const M=i.current;if(!M)return;const T=M.getBoundingClientRect();f(W,{width:Math.max(T.width,M.scrollWidth),height:Math.max(T.height,M.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var ne,ue,pe,ge,ae,be;if(!c)return;W.preventDefault(),W.stopPropagation();const M=i.current,T=M==null?void 0:M.getBoundingClientRect(),E=Number(((ue=(ne=e.data)==null?void 0:ne.displaySize)==null?void 0:ue.width)||e.width||((pe=e.measured)==null?void 0:pe.width)||(T==null?void 0:T.width)||FT),D=Number(((ae=(ge=e.data)==null?void 0:ge.displaySize)==null?void 0:ae.height)||e.height||((be=e.measured)==null?void 0:be.height)||(T==null?void 0:T.height)||vb),_=W.clientX,R=W.clientY,P=e.id;let X=0;const Z=Ae=>{const we=Xj({width:E+Ae.clientX-_,height:D+Ae.clientY-R});we&&(window.cancelAnimationFrame(X),X=window.requestAnimationFrame(()=>f(P,we)))},V=()=>{window.cancelAnimationFrame(X),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(P)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,($=(C=e.data)==null?void 0:C.displaySize)==null?void 0:$.height,(F=(B=e.data)==null?void 0:B.displaySize)==null?void 0:F.width,e.height,e.id,(z=e.measured)==null?void 0:z.height,(L=e.measured)==null?void 0:L.width,e.width,d,c]),m=h.useCallback(W=>{t(M=>M.filter(T=>T.id!==W))},[t]),g=h.useCallback(()=>{var E,D,_,R,P,X,Z,V;const W=((E=e.data)==null?void 0:E.definitionId)||"",M=((D=e.data)==null?void 0:D.label)||e.id,T=((P=(R=(_=e.data)==null?void 0:_.outputs)==null?void 0:R[0])==null?void 0:P.value)||((V=(Z=(X=e.data)==null?void 0:X.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:M,definitionId:W,content:T},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,M)=>{t(T=>T.map(E=>{var _;if(E.id!==W)return E;const D=Array.isArray((_=E.data)==null?void 0:_.outputs)&&E.data.outputs.length?E.data.outputs.map((R,P)=>P===0?{...R,default:M,value:M}:R):[{type:"bool",name:"value",default:M,value:M}];return{...E,data:{...E.data,body:"",outputs:D}}}))},[t]),v=h.useCallback((W,M)=>{t(T=>T.map(E=>E.id===W?{...E,data:{...E.data,body:M}}:E))},[t]),y=h.useCallback((W,M)=>{t(T=>T.map(E=>E.id===W?{...E,data:{...E.data,images:ks(M)}}:E))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx(ST,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:b,onNodeBodyChange:v,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":((O=e.data)==null?void 0:O.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const XK={[pp]:GK},Hd=["CONTROL","TOOL","PROVIDE","AGENT"],JK=1200,Wj="af-flow-node--sync-flash",Vj="af-flow-edge--sync-flash";function Uj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function Kj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function x0(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function QK(e){const t=x0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function vh(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function MT(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function $T(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function kx(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function qj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function Yj(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function ZK(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function e7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function DT(e,t,n,r,s){const i=QK(e),a={id:t,type:pp,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return Uf(a,r,s)}const FT=320,t7=220,n7=1600,vb=104,r7=900;function Gj(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Xj(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:Gj(t,t7,n7)||FT,height:Gj(n,vb,r7)||vb}}function s7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function Jj(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=Ou(i,e.sourceHandle||"output-0","source"),c=Ou(a,e.targetHandle||"input-0","target");return!l||!c?!1:Lu(l,c)}function i7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:kT(a)}:null}function o7(e,t,n){var a;const r=DT(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Lu(n.slot,c):Lu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function a7(e,t){return t?e.map((n,r)=>{const s=o7(n,e,t);if(!s)return null;const i=x0(n);return{def:n,order:r,category:i,categoryRank:Hd.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:MT(s.hydrated.data||n),description:$T(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const l7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function c7(e){const t=new Set,n=[];let r;const s=new RegExp(l7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function Qj(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function Vo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function kh(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(Vo),d=a.map(Vo);return l.map(Vo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function u7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Sx(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function d7({steps:e}){const{t}=Pn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
129
  `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:u7(s)}):null]}):null})]},n.index)})})}function f7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function p7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
130
  ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function h7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function m7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function Zj({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=Pn(),a=h.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return h.useEffect(()=>{if(!s||!a.current)return;const c=a.current;requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(e1,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(e1,{segments:t,running:n})})]})}function e1({segments:e,running:t=!1}){const{t:n}=Pn(),r=e.filter(u=>u.kind==="assistant").map(u=>u.text).join(""),s=e.filter(u=>u.kind==="result").map(u=>u.text).join(""),i=f7(r,s),a=e.filter(u=>u.kind==="error").map(u=>u.text).join(`
131
131
  `),l=e.filter(u=>u.kind!=="error"),c=i?l.filter(u=>u.kind!=="result"):l,d=p7(c),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((u,p)=>o.jsxs("section",{className:m7(u.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:h7(u.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`${u.kind}-${p}`)),t&&!f?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function g7({fitViewEpoch:e}){const{fitView:t}=ac(),n=h.useRef(t);return n.current=t,h.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function y7({onReady:e}){const t=Yv();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function t1(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function n1(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}const Qh=1500,r1=500,x7=262144,w7=2e3;function Nx(e){return typeof e!="string"?"":e.length<=w7?e:`[log line truncated, ${e.length} chars]`}const b7=Qh;function v7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:Nx(s)}}catch{return{ts:n,type:"info",text:Nx(s)}}return{ts:n,type:"log",text:Nx(`[${r}] ${s}`)}}function s1(e){if(!e)return[];const t=[],n=e.split(`
@@ -140,7 +140,7 @@ ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function h7(e,t){return
140
140
  `);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(i){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
141
141
  `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function lo(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function q7(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>lo(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>lo(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>lo(i[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:lo(s)||`Column ${i+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,i)=>({key:String(i),label:lo(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>lo(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>lo(s[a])):s&&typeof s=="object"?r.map(i=>lo(s[i.key])):r.map((i,a)=>a===0?lo(s):""))}}function Y7(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=q7(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
142
142
  `).split(`
143
- `).filter(l=>l.trim());if(s.length>=2&&Go(s[0]).length>1&&BT(s[1])){const l=Go(s[0]),c=HT(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>Go(d)),error:""}}const i=r.includes(" ")?" ":",",a=K7(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function b0({content:e}){const t=h.useMemo(()=>Y7(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:lo(n[i])},`${s.key}-${i}`))},r))})]})})}function v0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>V7(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),I7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const G7="af:workspace-graph:v2",Fc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],X7=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),J7={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Q7={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},Z7={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},eq=new Set(["png","jpg","jpeg","gif","webp","svg"]),tq=320,VT=180,UT=960,Sb=96,KT=900,Nb="display-ref:",nq="0.1.56";function rq(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Ia(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function Zm(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return eq.has(n)}function eg(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=Ia(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function sq(e,t){const n=String(e||"").trim();if(!n)return"";const r=Ia(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function iq(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function oq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function aq(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function lq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!aq(e)}function cq(e){const t=String(e||"").trim();if(!t)return"";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function c1(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function qT(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function YT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function k0(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function Wd(e){const t=String(k0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function u1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function tg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Vd(e){return tg(e)}function jb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function jx(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function d1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function f1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function p1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=Ou(s.get(n),e.sourceHandle||"output-0","source"),a=Ou(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Lu(i,a))}function uq(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:kT(a)}:null}function dq(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Lu(t.slot,a):Lu(a,t.slot)))continue;const c=Wd(n);return{def:n,order:r,category:c,categoryRank:Fc.indexOf(c),slot:a,slotIndex:i,displayLabel:Vd(n),description:jb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function Ud(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function fq(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function pq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Nh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:pq(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function GT(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function hq(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[GT(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function Cx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=JT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const g=r[m]||{},b=g.definitionId||m,v=t.find(B=>B.id===b),y=k0(v)||b,k=t.find(B=>B.id===y)||v,w=g.marketplaceRef||YT(v),j=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},A=!!Yn(y),C=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,$=mu(C,{display:A});return{id:m,type:pp,position:j,...$?{width:$.width,height:$.height}:{},data:{label:g.label||tg(v)||tg(k)||m,definitionId:y,...w?{marketplaceRef:w}:{},...v!=null&&v.packageId?{marketplacePackageId:v.packageId}:{},...v!=null&&v.version?{marketplaceVersion:v.version}:{},schemaType:qT(y,k||v),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...$?{nodeSize:$}:{},...A&&$?{displaySize:$}:{}}}}).map(m=>Uf(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,g)=>({id:m.id||`we-${m.source}-${m.target}-${g}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:Es.ArrowClosed}}));return{nodes:d,edges:bT(f,d),instances:r}}function h1(e){return`${Nb}${e}`}function Ex(e){const t=String(e||"");return t.startsWith(Nb)?t.slice(Nb.length):t}function XT(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Cb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Yn((p=u==null?void 0:u.data)==null?void 0:p.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const u of r){const p=String(u||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,p)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const p=mu(d[u],{display:!0});p&&(c[u]=p)});const f=XT(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function mq(e,t=[]){return Cb(e,t)}function gq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function yq(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function m1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function mu(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:m1(n,VT,UT)||tq,height:m1(r,Sb,KT)||Sb}}function zc(e){var s,i,a,l,c,d,f,u,p,m,g;const t=!!Yn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:u.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return mu({width:n,height:r},{display:t})}function jh(e,t,n){var l,c;const r=JT(fp(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const f=zc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function JT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Yn(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function Yn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Kl(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Yn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Wu(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function QT(e){const t=Wu(e);if(!t.trim())return"";if(/<base\s+[^>]*target\s*=/i.test(t))return t;const n='<base target="_blank">';return/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function xq(e,t){const n=String(e).trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-").replace(/^-+|-+$/g,"")||"html-render",r=String(t).replace(/^\.+/,"")||"png";return`${n}.${r}`}function wq(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function g1(e,t){const n=URL.createObjectURL(e);try{wq(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function bq(e){const t=Wu(e),n=new DOMParser().parseFromString(t||"<body></body>","text/html"),r=new XMLSerializer,s=Array.from(n.querySelectorAll("style")).map(a=>r.serializeToString(a)).join(`
143
+ `).filter(l=>l.trim());if(s.length>=2&&Go(s[0]).length>1&&BT(s[1])){const l=Go(s[0]),c=HT(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>Go(d)),error:""}}const i=r.includes(" ")?" ":",",a=K7(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function b0({content:e}){const t=h.useMemo(()=>Y7(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:lo(n[i])},`${s.key}-${i}`))},r))})]})})}function v0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>V7(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),I7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const G7="af:workspace-graph:v2",Fc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],X7=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),J7={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Q7={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},Z7={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},eq=new Set(["png","jpg","jpeg","gif","webp","svg"]),tq=320,VT=180,UT=960,Sb=96,KT=900,Nb="display-ref:",nq="0.1.57";function rq(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Ia(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function Zm(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return eq.has(n)}function eg(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=Ia(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function sq(e,t){const n=String(e||"").trim();if(!n)return"";const r=Ia(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function iq(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function oq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function aq(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function lq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!aq(e)}function cq(e){const t=String(e||"").trim();if(!t)return"";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function c1(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function qT(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function YT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function k0(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function Wd(e){const t=String(k0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function u1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function tg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Vd(e){return tg(e)}function jb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function jx(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function d1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function f1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function p1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=Ou(s.get(n),e.sourceHandle||"output-0","source"),a=Ou(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Lu(i,a))}function uq(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:kT(a)}:null}function dq(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Lu(t.slot,a):Lu(a,t.slot)))continue;const c=Wd(n);return{def:n,order:r,category:c,categoryRank:Fc.indexOf(c),slot:a,slotIndex:i,displayLabel:Vd(n),description:jb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function Ud(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function fq(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function pq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Nh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:pq(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function GT(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function hq(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[GT(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function Cx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=JT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const g=r[m]||{},b=g.definitionId||m,v=t.find(B=>B.id===b),y=k0(v)||b,k=t.find(B=>B.id===y)||v,w=g.marketplaceRef||YT(v),j=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},A=!!Yn(y),C=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,$=mu(C,{display:A});return{id:m,type:pp,position:j,...$?{width:$.width,height:$.height}:{},data:{label:g.label||tg(v)||tg(k)||m,definitionId:y,...w?{marketplaceRef:w}:{},...v!=null&&v.packageId?{marketplacePackageId:v.packageId}:{},...v!=null&&v.version?{marketplaceVersion:v.version}:{},schemaType:qT(y,k||v),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...$?{nodeSize:$}:{},...A&&$?{displaySize:$}:{}}}}).map(m=>Uf(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,g)=>({id:m.id||`we-${m.source}-${m.target}-${g}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:Es.ArrowClosed}}));return{nodes:d,edges:bT(f,d),instances:r}}function h1(e){return`${Nb}${e}`}function Ex(e){const t=String(e||"");return t.startsWith(Nb)?t.slice(Nb.length):t}function XT(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Cb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Yn((p=u==null?void 0:u.data)==null?void 0:p.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const u of r){const p=String(u||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,p)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const p=mu(d[u],{display:!0});p&&(c[u]=p)});const f=XT(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function mq(e,t=[]){return Cb(e,t)}function gq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function yq(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function m1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function mu(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:m1(n,VT,UT)||tq,height:m1(r,Sb,KT)||Sb}}function zc(e){var s,i,a,l,c,d,f,u,p,m,g;const t=!!Yn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:u.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return mu({width:n,height:r},{display:t})}function jh(e,t,n){var l,c;const r=JT(fp(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const f=zc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function JT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Yn(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function Yn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Kl(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Yn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Wu(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function QT(e){const t=Wu(e);if(!t.trim())return"";if(/<base\s+[^>]*target\s*=/i.test(t))return t;const n='<base target="_blank">';return/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function xq(e,t){const n=String(e).trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-").replace(/^-+|-+$/g,"")||"html-render",r=String(t).replace(/^\.+/,"")||"png";return`${n}.${r}`}function wq(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function g1(e,t){const n=URL.createObjectURL(e);try{wq(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function bq(e){const t=Wu(e),n=new DOMParser().parseFromString(t||"<body></body>","text/html"),r=new XMLSerializer,s=Array.from(n.querySelectorAll("style")).map(a=>r.serializeToString(a)).join(`
144
144
  `),i=n.body?Array.from(n.body.childNodes).map(a=>r.serializeToString(a)).join(""):t;return`
145
145
  <style>
146
146
  * { box-sizing: border-box; }
@@ -15,7 +15,7 @@
15
15
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
16
16
  rel="stylesheet"
17
17
  />
18
- <script type="module" crossorigin src="/assets/index-BqNnKCQo.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-B5VFaSRf.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/index-BYlDWj_n.css">
20
20
  </head>
21
21
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldwangai/agentflow",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "description": "Orchestration system for long-running complex agent tasks using Cursor, OpenCode, or Claude Code as execution backends",
5
5
  "type": "module",
6
6
  "main": "bin/agentflow.mjs",