@vantaloom/runtime-win32-x64 0.9.5 → 0.9.7
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.
- package/VERSION +1 -1
- package/bin/vantaloom-agent.exe +0 -0
- package/bin/vantaloom-api.exe +0 -0
- package/bin/vantaloom-browser.exe +0 -0
- package/bin/vantaloomctl.exe +0 -0
- package/cli/package.json +1 -1
- package/manifest.json +2 -2
- package/package.json +1 -1
- package/web/404.html +1 -1
- package/web/__next.__PAGE__.txt +2 -2
- package/web/__next._full.txt +2 -2
- package/web/__next._head.txt +1 -1
- package/web/__next._index.txt +1 -1
- package/web/__next._tree.txt +1 -1
- package/web/_next/static/chunks/{f50174c289b30da7.js → ec0feea8a0ea25db.js} +4 -4
- package/web/_not-found/__next._full.txt +1 -1
- package/web/_not-found/__next._head.txt +1 -1
- package/web/_not-found/__next._index.txt +1 -1
- package/web/_not-found/__next._not-found/__PAGE__.txt +1 -1
- package/web/_not-found/__next._not-found.txt +1 -1
- package/web/_not-found/__next._tree.txt +1 -1
- package/web/_not-found.html +1 -1
- package/web/_not-found.txt +1 -1
- package/web/index.html +1 -1
- package/web/index.txt +2 -2
- /package/web/_next/static/{N2mdLcpLUub3OX-ZWWxd2 → haqf286sNmpq_ecaBTBCQ}/_buildManifest.js +0 -0
- /package/web/_next/static/{N2mdLcpLUub3OX-ZWWxd2 → haqf286sNmpq_ecaBTBCQ}/_clientMiddlewareManifest.json +0 -0
- /package/web/_next/static/{N2mdLcpLUub3OX-ZWWxd2 → haqf286sNmpq_ecaBTBCQ}/_ssgManifest.js +0 -0
|
@@ -17,12 +17,12 @@ ${c}
|
|
|
17
17
|
${r} [data-chart=${e}] {
|
|
18
18
|
${n.map(([e,n])=>{let r=n.theme?.[t]??n.color;return r?` --color-${e}: ${r};`:null}).filter(Boolean).join("\n")}
|
|
19
19
|
}
|
|
20
|
-
`).join("\n")}}):null}function Vn({active:e,payload:t,className:n,indicator:r="dot",hideLabel:a=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:s,formatter:c,color:d,nameKey:u,labelKey:f}){let{config:h}=function(){let e=ew.useContext(B9);if(!e)throw Error("useChart must be used within a <ChartContainer />");return e}(),m=ew.useMemo(()=>{if(a||!t?.length)return null;let[e]=t,n=`${f??e?.dataKey??e?.name??"value"}`,r=Vr(h,e,n),i=f||"string"!=typeof o?r?.label:h[o]?.label??o;return l?(0,ey.jsx)("div",{className:(0,eI.cn)("font-medium",s),children:l(i,t)}):i?(0,ey.jsx)("div",{className:(0,eI.cn)("font-medium",s),children:i}):null},[o,l,t,a,s,h,f]);if(!e||!t?.length)return null;let p=1===t.length&&"dot"!==r;return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-popover grid min-w-32 items-start gap-1.5 rounded-[var(--surface-popover-radius)] border px-2.5 py-1.5 text-xs",n),children:[p?null:m,(0,ey.jsx)("div",{className:"grid gap-1.5",children:t.filter(e=>"none"!==e.type).map((e,t)=>{let n=`${u??e.name??e.dataKey??"value"}`,a=Vr(h,e,n),o=d??e.payload?.fill??e.color;return(0,ey.jsx)("div",{className:(0,eI.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&e?.value!==void 0&&e.name?c(e.value,e.name,e,t,e.payload):(0,ey.jsxs)(ey.Fragment,{children:[a?.icon?(0,ey.jsx)(a.icon,{}):!i&&(0,ey.jsx)("div",{className:(0,eI.cn)("shrink-0 rounded-[2px]","dot"===r&&"size-2.5","line"===r&&"w-1","dashed"===r&&"w-0 border-[1.5px] border-dashed bg-transparent",p&&"dashed"===r&&"my-0.5"),style:{backgroundColor:"dashed"===r?"transparent":o,borderColor:o}}),(0,ey.jsxs)("div",{className:(0,eI.cn)("flex flex-1 justify-between leading-none",p?"items-end":"items-center"),children:[(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[p?m:null,(0,ey.jsx)("span",{className:"text-muted-foreground",children:a?.label??e.name})]}),null!=e.value&&(0,ey.jsx)("span",{className:"font-mono font-medium text-foreground tabular-nums",children:"number"==typeof e.value?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function Vr(e,t,n){if("object"!=typeof t||null===t)return;let r="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0,a=n;return n in t&&"string"==typeof t[n]?a=t[n]:r&&n in r&&"string"==typeof r[n]&&(a=r[n]),a in e?e[a]:e[n]}let Va={placeholder:"Ask the agent to inspect, change, or explain this workspace...",mode:"Mode",model:"Model",attach:"Attach context",removeChip:"Remove context",removeAttachment:"Remove attachment",queuedMessage:"Queued message",guideQueuedMessage:"Guide",removeQueuedMessage:"Remove queued message",moreQueuedMessageActions:"More queued message actions",contextUsage:"Context usage",contextUsed:"used",contextTokenSummary:"used {used} / {total}",toolCalls:"Tool calls",userMessages:"User messages",otherContext:"Other context",compressContext:"Compress context",compressPrecise:"Precise",compressExtreme:"Extreme",send:"Run",stop:"Stop"},Vi=[{id:"agent",label:"Agent",description:"Use tools and make changes.",icon:(0,ey.jsx)(bC,{className:"fill-current"})},{id:"planner",label:"Planner",description:"Plan before changing files.",icon:(0,ey.jsx)(jT,{})},{id:"reviewer",label:"Reviewer",description:"Inspect risks and regressions.",icon:(0,ey.jsx)(ub,{})}],Vo=[{id:"acceptEdits",label:"Accept edits",description:"Auto-approve edits, ask for risky commands.",icon:(0,ey.jsx)(mZ,{})},{id:"ask",label:"Ask permissions",description:"Ask before any tool action.",icon:(0,ey.jsx)(jz,{})},{id:"auto",label:"Auto mode",description:"Auto-approve all except dangerous.",icon:(0,ey.jsx)(jR,{})}],Vl=[{id:"gpt-5.5",label:"GPT-5.5",description:"Highest quality coding agent."},{id:"gpt-5.4",label:"GPT-5.4",description:"Balanced everyday work."},{id:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Fast lightweight passes."}];function Vs(e){if(e)return"string"==typeof e.label||"number"==typeof e.label?String(e.label):e.id}function Vc({value:e,defaultValue:t,onValueChange:n,modes:r=Vi,modeId:a,defaultModeId:i,onModeChange:o,permissionModes:l=Vo,permissionModeId:s,defaultPermissionModeId:c,onPermissionModeChange:d,models:u=Vl,modelId:f,defaultModelId:h,onModelChange:m,queuedMessages:p,defaultQueuedMessages:g=[],onQueuedMessagesChange:v,onQueueMessage:x,onRemoveQueuedMessage:y,queueOnTab:b=!0,renderQueuedMessageActions:w,contextUsage:j,chips:k=[],attachments:S=[],onAttachmentsChange:N,actions:C,footer:M,running:E=!1,disabled:O=!1,submitOnEnter:P=!0,promptHistory:A,minRows:I=2,maxRows:z=7,onSubmit:T,onStop:D,onAttach:R,onNudge:_,labels:L,className:$,textareaClassName:F,toolbarClassName:B}){let V,H,U={...Va,...L},W=ew.useRef(null),q=ew.useId(),K=ew.useRef(0),[G,X]=function({value:e,defaultValue:t="",onChange:n}){let[r,a]=ew.useState(t);return[e??r,ew.useCallback(t=>{void 0===e&&a(t),n?.(t)},[n,e])]}({value:e,defaultValue:t,onChange:n}),Y=A??[],[Z,J]=ew.useState(null),Q=ew.useRef(""),ee=ew.useRef(!1);ew.useEffect(()=>{J(null),ee.current=!1},[A]);let et=ew.useCallback(e=>{ee.current=!0,X(e);let t=W.current;t&&requestAnimationFrame(()=>{let e=t.value.length;t.setSelectionRange(e,e)})},[X]),[en,er]=ew.useState(g),[ea,ei]=ew.useState(i??r[0]?.id),[eo,el]=ew.useState(c??l[0]?.id),[es,ec]=ew.useState(h??u[0]?.id),ed=a??ea,eu=s??eo,ef=f??es,eh=r.find(e=>e.id===ed)??r[0],em=l.find(e=>e.id===eu)??l[0],ep=u.find(e=>e.id===ef)??u[0],eg=p??en,ev=(G.trim().length>0||S.length>0)&&!O;function ex(){ev&&(T?.({value:G,modeId:eh?.id,modelId:ep?.id,attachments:S.length>0?S:void 0}),J(null),ee.current=!1,Q.current="",X(""),S.length>0&&N?.([]))}async function eb(e){if(0===e.length||!N)return;let t=[];for(let n of e){let e=`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;if(n.type.startsWith("image/")){let r=await function(e){return new Promise(t=>{let n=new FileReader;n.onload=()=>t("string"==typeof n.result?n.result:""),n.onerror=()=>t(""),n.readAsDataURL(e)})}(n);if(!r)continue;t.push({id:e,kind:"image",name:n.name||"image.png",mimeType:n.type||"image/png",dataUrl:r,size:n.size})}else{let r=await function(e){return new Promise(t=>{let n=new FileReader;n.onload=()=>t("string"==typeof n.result?n.result:""),n.onerror=()=>t(""),n.readAsText(e)})}(n),a=(n.name.split(".").pop()??"").toLowerCase();t.push({id:e,kind:"file",name:n.name||"file.txt",mimeType:n.type||"text/plain",text:r,ext:a,size:n.size})}}t.length>0&&N([...S,...t])}function ej(e){void 0===p&&er(e),v?.(e)}function ek(){let e=G.trim();if(!e||O)return!1;K.current+=1;let t={id:`${q}-queued-${K.current}`,content:e},n=[...eg,t];return ej(n),x?.(t,n),X(""),!0}return ew.useLayoutEffect(()=>{let e=W.current;if(!e)return;e.style.height="0px";let t=Number.parseFloat(getComputedStyle(e).lineHeight),n=Number.isFinite(t)?t*z:160;e.style.height=`${Math.min(e.scrollHeight,n)}px`,e.style.overflowY=e.scrollHeight>n?"auto":"hidden"},[z,G]),(0,ey.jsxs)("div",{"data-slot":"agent-input-composer","data-running":E,className:(0,eI.cn)("relative grid w-full",$),children:[eg.length>0&&(0,ey.jsx)(Vf,{messages:eg,labels:U,renderActions:w,onRemove:function(e){let t=eg.find(t=>t.id===e);if(!t)return;let n=eg.filter(t=>t.id!==e);ej(n),y?.(e,t,n)},onNudge:_,running:E}),(0,ey.jsxs)("div",{"data-slot":"agent-input-composer-surface",className:(0,eI.cn)("vtl-agent-input-composer-surface relative grid w-full gap-2 rounded-lg border border-border p-2 shadow-sm transition-colors"),children:[k.length>0&&(0,ey.jsx)("div",{"data-slot":"agent-input-composer-context",className:"flex min-w-0 flex-wrap items-center gap-1.5",children:k.map(e=>(0,ey.jsx)(Vm,{chip:e,removeLabel:U.removeChip},e.id))}),S.length>0&&(0,ey.jsx)("div",{"data-slot":"agent-input-composer-attachments",className:"flex min-w-0 flex-wrap items-center gap-2",children:S.map(e=>(0,ey.jsx)(Vh,{attachment:e,removeLabel:U.removeAttachment,onRemove:()=>N?.(S.filter(t=>t.id!==e.id))},e.id))}),(0,ey.jsx)("textarea",{ref:W,value:G,disabled:O,rows:I,placeholder:U.placeholder,"data-slot":"agent-input-composer-textarea",className:(0,eI.cn)("min-h-10 w-full resize-none border-0 bg-transparent px-0.5 py-0 text-sm leading-5 text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",F),onChange:e=>{var t;return t=e.currentTarget.value,void(!ee.current&&null!==Z&&J(null),ee.current=!1,X(t))},onPaste:function(e){let t=Array.from(e.clipboardData?.files??[]);0!==t.length&&N&&(e.preventDefault(),eb(t))},onKeyDown:e=>{Y.length>0&&e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&("ArrowUp"===e.key||"ArrowDown"===e.key)&&!e.nativeEvent.isComposing&&function(e){if(0===Y.length)return!1;if("older"===e){if(null===Z){Q.current=G;let e=Y.length-1;return J(e),et(Y[e]??""),!0}if(Z<=0)return!0;let e=Z-1;return J(e),et(Y[e]??""),!0}if(null===Z)return!1;let t=Z+1;return t>=Y.length?(J(null),ee.current=!1,et(Q.current),ee.current=!1):(J(t),et(Y[t]??"")),!0}("ArrowUp"===e.key?"older":"newer")?e.preventDefault():b&&"Tab"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&ek()?e.preventDefault():!P||"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),E?ek():ex())}}),(0,ey.jsxs)("div",{"data-slot":"agent-input-composer-toolbar",className:(0,eI.cn)("grid grid-cols-[minmax(0,1fr)_auto] items-end gap-2",B),children:[(0,ey.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,ey.jsx)(Vp,{label:"Permissions",options:l,value:em?.id,trigger:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"grid size-3.5 place-items-center text-muted-foreground [&_svg]:size-3",children:em?.icon??(0,ey.jsx)(jz,{})}),(0,ey.jsx)("span",{className:"hidden truncate md:inline",children:Vs(em)}),(0,ey.jsx)(vu,{className:"size-3 text-muted-foreground"})]}),triggerClassName:"rounded-md bg-transparent px-1.5 text-muted-foreground hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/70",onSelect:function(e){e.disabled||(void 0===s&&el(e.id),d?.(e.id,e))}}),(0,ey.jsx)(Vp,{label:U.model,options:u,value:ep?.id,trigger:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"grid size-3.5 place-items-center text-muted-foreground [&_svg]:size-3 md:hidden",children:(0,ey.jsx)(jT,{})}),(0,ey.jsx)("span",{className:"hidden truncate md:inline",children:Vs(ep)}),(0,ey.jsx)(vu,{className:"size-3 text-muted-foreground"})]}),triggerClassName:"rounded-md bg-transparent px-1.5 text-muted-foreground hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/70",onSelect:function(e){e.disabled||(void 0===f&&ec(e.id),m?.(e.id,e))}}),R&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-label":U.attach,title:U.attach,onClick:R,disabled:O,children:(0,ey.jsx)(jI,{})}),C]}),(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[j&&(0,ey.jsx)(Vu,{usage:j,labels:U}),(V=G.trim().length>0,H=E&&!V,(0,ey.jsx)(eA.Button,{type:"button",size:"icon-xs",variant:H?"outline":"default","aria-label":H?U.stop:U.send,title:H?U.stop:U.send,disabled:!E&&!ev,className:"rounded-full",onClick:H?D:E?()=>ek():ex,children:H?(0,ey.jsx)(jD,{className:"size-3 fill-current"}):(0,ey.jsx)(jP,{className:"size-3.5"})}))]})]}),M&&(0,ey.jsx)("div",{"data-slot":"agent-input-composer-footer",className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:M})]})]})}function Vd(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${Math.round(e/1e3)}k`:e.toLocaleString()}function Vu({usage:e,labels:t}){let[n,r]=ew.useState(!1),a=Math.max(0,e.used),i=Math.max(0,e.total),o=i>0?Math.min(100,Math.round(a/i*100)):0,l=Math.max(0,e.toolCalls),s=Math.max(0,e.userMessages),c=Math.max(0,e.other??Math.max(0,a-l-s)),d=[{name:"toolCalls",value:l,fill:"var(--color-toolCalls)"},{name:"userMessages",value:s,fill:"var(--color-userMessages)"},{name:"other",value:c,fill:"var(--color-other)"},{name:"unused",value:Math.max(0,i-a),fill:"var(--muted)"}].filter(e=>e.value>0),u=t.contextTokenSummary.replace("{used}",Vd(a)).replace("{total}",Vd(i)),f={toolCalls:{label:t.toolCalls,color:"var(--chart-1)"},userMessages:{label:t.userMessages,color:"var(--chart-3)"},other:{label:t.otherContext,color:"var(--chart-5)"}};return(0,ey.jsxs)(xO,{children:[(0,ey.jsx)(xz,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-label":`${t.contextUsage}: ${o}% ${t.contextUsed}`,title:`${t.contextUsage}: ${o}% ${t.contextUsed}`,children:(0,ey.jsx)("span",{"aria-hidden":"true",className:"grid size-4 place-items-center rounded-full",style:{background:`conic-gradient(var(--foreground) ${3.6*o}deg, var(--border) 0deg)`},children:(0,ey.jsx)("span",{className:"size-3 rounded-full bg-background dark:bg-popover"})})})}),(0,ey.jsxs)(xq,{side:"top",align:"center",sideOffset:8,className:"w-44 gap-2 p-3",children:[(0,ey.jsxs)("div",{className:"grid gap-0.5 text-center",children:[(0,ey.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:e.label??t.contextUsage}),(0,ey.jsxs)("div",{className:"text-sm text-muted-foreground",children:[o,"% ",t.contextUsed]}),(0,ey.jsx)("div",{className:"text-sm font-medium",children:u})]}),(0,ey.jsx)("div",{className:"grid justify-center",children:(0,ey.jsx)(Ve,{config:f,className:"h-20 w-20",initialDimension:{width:80,height:80},onMouseMove:()=>r(!0),onMouseLeave:()=>r(!1),children:(0,ey.jsxs)(Bo,{children:[(0,ey.jsx)(BU,{active:n,content:(0,ey.jsx)(Vn,{hideLabel:!0})}),(0,ey.jsx)(LN,{data:d.length>0?d:[{name:"other",value:1,fill:"var(--muted)"}],dataKey:"value",nameKey:"name",innerRadius:25,outerRadius:35,isAnimationActive:!1,strokeWidth:0})]})})}),e.onCompressPrecise||e.onCompressExtreme?(0,ey.jsxs)("div",{className:"flex w-full overflow-hidden rounded-md border",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"flex-1 rounded-none border-r text-xs font-medium",onClick:e.onCompressPrecise,disabled:e.compressing||!e.onCompressPrecise,children:e.compressing?"…":t.compressPrecise??"精确"}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"flex-1 rounded-none text-xs font-medium",onClick:e.onCompressExtreme,disabled:e.compressing||!e.onCompressExtreme,children:e.compressing?"…":t.compressExtreme??"极致"})]}):(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"w-full",onClick:e.onCompress,disabled:!e.onCompress,children:t.compressContext})]})]})}function Vf({messages:e,labels:t,renderActions:n,onRemove:r,onNudge:a,running:i}){return(0,ey.jsx)("div",{"data-slot":"agent-input-composer-queue",className:"vtl-agent-input-composer-queue z-10 mx-5 mb-[-1px] grid gap-1.5 rounded-t-lg rounded-b-none border border-border p-1.5 shadow-xs",children:e.map((e,o)=>(0,ey.jsxs)("div",{"data-slot":"agent-input-composer-queue-item",className:(0,eI.cn)("group/queue flex min-h-8 min-w-0 items-center gap-2 rounded-md px-2 text-sm transition-colors",e.disabled?"text-muted-foreground opacity-60":"text-foreground hover:bg-muted/60"),children:[(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon??(0,ey.jsx)(jA,{})}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",title:String(e.content),children:e.content}),e.meta&&(0,ey.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-70 transition-opacity group-hover/queue:opacity-100",children:[n?.(e),i&&a&&(0,ey.jsxs)(eA.Button,{type:"button",variant:"ghost",size:"xs",className:"h-6 gap-1 px-1.5 text-muted-foreground","aria-label":`${t.guideQueuedMessage} ${o+1}`,onClick:()=>a(e.id),children:[(0,ey.jsx)(jA,{className:"size-3.5"}),t.guideQueuedMessage]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground","aria-label":`${t.removeQueuedMessage} ${o+1}`,onClick:()=>r(e.id),children:(0,ey.jsx)(yi,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground","aria-label":`${t.moreQueuedMessageActions} ${o+1}`,children:(0,ey.jsx)(lY,{})})]})]},e.id))})}function Vh({attachment:e,removeLabel:t,onRemove:n}){return(0,ey.jsxs)("div",{"data-slot":"agent-input-attachment",className:"group/att relative size-14 shrink-0 overflow-hidden rounded-md border border-border bg-muted/40",title:e.name,children:["image"===e.kind&&e.dataUrl?(0,ey.jsx)("img",{src:e.dataUrl,alt:e.name,className:"size-full object-cover"}):(0,ey.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-1 px-1 text-center",children:[(0,ey.jsx)(uC,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"w-full truncate text-[10px] font-semibold uppercase text-muted-foreground",children:e.ext?`.${e.ext}`:"TXT"})]}),(0,ey.jsx)("button",{type:"button","aria-label":t,title:t,onClick:n,className:"absolute right-0.5 top-0.5 grid size-4 place-items-center rounded-full bg-background/85 text-muted-foreground opacity-0 shadow-sm transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover/att:opacity-100",children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]})}function Vm({chip:e,removeLabel:t}){return(0,ey.jsxs)(Bs,{variant:"secondary","data-tone":e.tone,className:(0,eI.cn)("h-6 max-w-full gap-1 rounded-md border border-border bg-muted/70 px-1.5 text-muted-foreground","success"===e.tone&&"border-primary/25 bg-primary/10 text-foreground","warning"===e.tone&&"border-destructive/25 bg-destructive/10 text-foreground"),children:[e.icon&&(0,ey.jsx)("span",{className:"grid size-3.5 shrink-0 place-items-center [&_svg]:size-3",children:e.icon}),(0,ey.jsx)("span",{className:"truncate",children:e.label}),e.onRemove&&(0,ey.jsx)("button",{type:"button",className:"-mr-0.5 grid size-4 shrink-0 place-items-center rounded-sm text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none","aria-label":`${t} ${e.id}`,onClick:()=>e.onRemove?.(e.id),children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]})}function Vp({label:e,options:t,value:n,trigger:r,triggerClassName:a,onSelect:i}){return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"xs",className:(0,eI.cn)("h-6 max-w-40 gap-1 rounded-md px-1.5 text-xs font-medium",a),children:r})}),(0,ey.jsx)(bZ,{align:"start","aria-label":"string"==typeof e?e:void 0,className:"min-w-40 p-1",children:t.map(e=>(0,ey.jsxs)(bJ,{disabled:e.disabled,className:"h-8 gap-2 px-2 text-sm",onSelect:()=>i(e),children:[(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),(0,ey.jsx)(mZ,{className:(0,eI.cn)("ml-auto size-4 text-foreground",n===e.id?"opacity-100":"opacity-0")})]},e.id))})]})}function Vg(e,t,n,r){return[{id:`${t}-task-${e}`,kind:"user",title:n},...r.map(n=>({...n,id:`${t}-${n.id}-${e}`}))]}function Vv(e){return[{id:`read-materials-${e}`,kind:"read",actionLabel:"读取",title:"AgentWorkspace.tsx, styles.css, i18n.json",files:[{id:`workspace-${e}`,name:"AgentWorkspace.tsx",lines:"1-480"},{id:`styles-${e}`,name:"styles.css",lines:"265-820"},{id:`i18n-${e}`,name:"i18n.json",lines:"245-292"}]},{id:`search-actions-${e}`,kind:"search",actionLabel:"搜索",title:"workspace creation, sidebar tree, streaming output",files:[{id:`workspace-search-${e}`,name:"AgentWorkspace.tsx",lines:"64-190"},{id:`style-search-a-${e}`,name:"styles.css",lines:"540-670"},{id:`style-search-b-${e}`,name:"styles.css",lines:"705-790"}]},{id:`subagents-${e}`,kind:"subagent",actionLabel:"召唤",title:"子代理",subagents:[{id:`reader-${e}`,title:"阅读子代理",activity:"阅读 package.json",toolActivities:["读取 package.json","检查 workspace 脚本","整理依赖信息"],status:"阅读 package.json",detail:"package.json 已读取,正在整理脚本与依赖信息。",isRunning:!0,events:Vg(e,"reader","阅读 package.json",[{id:"read-package",kind:"read",actionLabel:"读取",title:"package.json",files:[{id:"package-json",name:"package.json",lines:"1-96"}]},{id:"reader-note",kind:"done",title:"已读取 package.json。\n\n- 已记录 workspace 脚本\n- 已检查 UI 与 app 包依赖\n- 下一步等待主代理合并上下文"}])},{id:`searcher-${e}`,title:"搜索子代理",activity:"搜索 AgentWorkspace.tsx",toolActivities:["搜索 AgentWorkspace.tsx","筛选面板布局","定位事件流接入"],status:"搜索 AgentWorkspace.tsx",detail:"AgentWorkspace.tsx 命中 3 处候选区域,正在筛选可复用结构。",isRunning:!0,events:Vg(e,"searcher","搜索 AgentWorkspace.tsx",[{id:"search-workspace",kind:"search",actionLabel:"搜索",title:"AgentWorkspace.tsx",files:[{id:"agent-workspace-a",name:"AgentWorkspace.tsx",lines:"64-190"},{id:"agent-workspace-b",name:"AgentWorkspace.tsx",lines:"320-418"}]},{id:"searcher-note",kind:"done",title:"已定位 AgentWorkspace.tsx 的面板布局与事件流接入位置。"}])},{id:`verifier-${e}`,title:"验证子代理",activity:"验证工作流状态",toolActivities:["验证对话流","验证右侧面板","检查子代理切换"],status:"验证工作流状态",detail:"工作流状态正在校验,等待主代理提交最终结果。",isRunning:!0,events:Vg(e,"verifier","验证工作流状态",[{id:"verify-flow",kind:"verify",actionLabel:"验证",title:"对话流、右侧面板、子代理切换"},{id:"verifier-note",kind:"done",title:"验证队列已建立,等待主代理继续写入真实结果。"}])}]},{id:`think-structure-${e}`,kind:"thought",actionLabel:"思考",title:"8s",status:"done"},{id:`plan-${e}`,kind:"done",title:"**收到新的编织请求。**\n\n我会先保留当前工作台样式,只用占位文本演示真实任务流:读取、搜索、思考、编辑和验证都会按顺序进入同一条文字流。\n\n- 左侧织布机由真实创建动作产生\n- 编织物初始保持为空\n- 文件读取项仍然可以展开\n- 点击文件名会继续打开右侧标签页"},{id:`edit-workspace-${e}`,kind:"change",actionLabel:"编辑",title:"AgentWorkspace.tsx",additions:44,deletions:16},{id:`edit-style-${e}`,kind:"change",actionLabel:"编辑",title:"styles.css",additions:36,deletions:12},{id:`verify-flow-${e}`,kind:"verify",actionLabel:"验证",title:"empty sidebar, new loom creation, placeholder workflow"},{id:`done-${e}`,kind:"done",title:"演示工作流已完成。\n\n这只是前端占位演示,后续可以直接把事件流替换成真实 agent runtime。"}]}let Vx=[{id:"user-1",kind:"user",title:"345"},...Vv("1"),{id:"user-2",kind:"user",title:"234"}],Vy=(0,ek.default)("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Vb=(0,ek.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Vw=(0,ek.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),Vj=(0,ek.default)("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);(0,ek.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);let Vk=(0,l2.cva)("vtl-dot-matrix-loader",{variants:{size:{xs:"[--vtl-dot-size:3px] [--vtl-dot-gap:3px]",sm:"[--vtl-dot-size:3.5px] [--vtl-dot-gap:3.5px]",default:"[--vtl-dot-size:4px] [--vtl-dot-gap:4px]",lg:"[--vtl-dot-size:5px] [--vtl-dot-gap:5px]",xl:"[--vtl-dot-size:6px] [--vtl-dot-gap:6px]"},tone:{default:"text-current",muted:"text-muted-foreground",primary:"text-primary",inverse:"text-primary-foreground",destructive:"text-destructive"},variant:{pulse:"vtl-dot-matrix-loader-pulse",wave:"vtl-dot-matrix-loader-wave",orbit:"vtl-dot-matrix-loader-orbit",binary:"vtl-dot-matrix-loader-binary"}},defaultVariants:{size:"default",tone:"default",variant:"pulse"}}),VS={pulse:[0,90,180,270,360,450,540,630,720],wave:[0,80,160,80,160,240,160,240,320],orbit:[0,130,260,910,1040,390,780,650,520],binary:[0,210,420,630,140,350,560,70,280]};function VN({className:e,size:t,tone:n,variant:r,animated:a=!0,speed:i=1,style:o,"aria-label":l="Loading",...s}){let c=Math.round(1120/(Number.isFinite(i)&&i>0?i:1)),d=VS[r??"pulse"];return(0,ey.jsx)("span",{role:"status","aria-label":l,"data-animated":a?"true":"false",className:(0,eI.cn)(Vk({size:t,tone:n,variant:r}),e),style:{"--vtl-dot-duration":`${c}ms`,...o},...s,children:Array.from({length:9},(e,t)=>(0,ey.jsx)("span",{"aria-hidden":"true",className:"vtl-dot-matrix-loader-dot",style:{"--vtl-dot-delay":`${d[t]}ms`}},t))})}let VC=(0,l2.cva)("animate-spin",{variants:{size:{xs:"size-3",sm:"size-3.5",default:"size-4",lg:"size-5",xl:"size-6"},variant:{default:"text-current",muted:"text-muted-foreground",primary:"text-primary"}},defaultVariants:{size:"default",variant:"default"}});function VM({className:e,size:t,variant:n,...r}){return(0,ey.jsx)(eM,{role:"status","aria-label":"Loading",className:(0,eI.cn)(VC({size:t,variant:n}),e),...r})}function VE({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"agent-message-actions",className:(0,eI.cn)("flex items-center gap-1.5 text-muted-foreground",e),...t})}function VO({className:e,...t}){return(0,ey.jsx)(eA.Button,{size:"icon-xs",variant:"ghost",className:e,...t})}function VP({mode:e,label:t,retryAttempt:n,retryMax:r,errorDetail:a,className:i}){let o="retry"===e,l=o?`正在进行重试...(${n??1}/${r??1})`:t??"正在处理中",[s,c]=ew.useState(!1),d=ew.useRef(void 0);ew.useEffect(()=>()=>{void 0!==d.current&&window.clearTimeout(d.current)},[]);let u=ew.useCallback(()=>{let e=(a??"").trim();e&&("u">typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,n)=>{try{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select(),document.execCommand("copy"),document.body.removeChild(n),t()}catch(e){n(e)}})).then(()=>{c(!0),void 0!==d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!1),1800)}).catch(()=>{})},[a]),f=o&&!!(a??"").trim();return(0,ey.jsxs)("div",{"data-slot":"conversation-status-tail","aria-live":"polite",className:(0,eI.cn)("flex items-center gap-2 text-sm leading-6",o?"text-destructive":"text-muted-foreground",i),children:[(0,ey.jsx)(VN,{variant:"wave",tone:o?"destructive":"muted",style:{"--vtl-dot-size":"0.2em","--vtl-dot-gap":"0.2em"},"aria-label":l}),(0,ey.jsx)("span",{children:l}),f?(0,ey.jsxs)("button",{type:"button",onClick:u,title:"复制完整报错信息",className:"cursor-pointer rounded text-destructive/80 underline decoration-dotted underline-offset-2 transition-colors hover:text-destructive",children:["(",s?"已复制":"点击复制报错信息",")"]}):null]})}function VA(e){return e.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?|\x1b\[[?!>]?[\d;]*[a-zA-Z~]|\x9b[?!>]?[\d;]*[a-zA-Z~]|\x1b[()#][A-Z0-9]|\x1b[A-Z=><78]|\r/gi,"").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\x80-\x9f]/g,"")}let VI=[".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"];function Vz(e){let t=(e.split(/[?#]/,1)[0]??e).replace(/[\\/]+$/,"").split(/[\\/]/),n=t[t.length-1];return n&&n.trim()?n.trim():e}function VT({src:e,alt:t}){return(0,ey.jsx)("img",{src:e,alt:t,loading:"lazy",className:"vtl-agent-deliverable-image"})}function VD({label:e,target:t,context:n}){let r=n?.classify?.(t)??"url",a=e.trim()||Vz(t);return(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-deliverable-chip",title:t,onClick:()=>n?.onOpen?.({target:t,kind:r,label:a}),children:[(0,ey.jsx)(uC,{className:"vtl-agent-deliverable-chip-icon"}),(0,ey.jsx)("span",{className:"vtl-agent-deliverable-chip-label",children:a}),(0,ey.jsx)("span",{className:"vtl-agent-deliverable-chip-open",children:"打开"})]})}function VR(e,t,n,r,a){if(!t)return;let i=n+t.length;if(r<=n)return void e.push((0,ey.jsx)("span",{className:"vtl-agent-stream-fade-text",children:t},`${a}-fade-${n}`));if(r>=i)return void e.push(t);let o=r-n;e.push(t.slice(0,o)),e.push((0,ey.jsx)("span",{className:"vtl-agent-stream-fade-text",children:t.slice(o)},`${a}-fade-${n}`))}function V_(e,t){let n="!"===e[t]&&"["===e[t+1],r=t+(n?2:1),a=e.indexOf("]",r);if(-1===a||"("!==e[a+1])return null;let i=e.indexOf(")",a+2);if(-1===i)return null;let o=e.slice(r,a),l=e.slice(a+2,i).trim();return l?{isImage:n,label:o,target:l,end:i+1}:null}function VL(e,t=1/0,n){let r=[],a=0;for(;a<e.length;){if("!"===e[a]&&"["===e[a+1]){let t=V_(e,a);if(t){let e=n?.resolveImageSrc?.(t.target)??t.target;r.push((0,ey.jsx)(VT,{src:e,alt:t.label},`img-${a}`)),a=t.end;continue}}if("["===e[a]){let t=V_(e,a);if(t){if(function(e){let t=(e.split(/[?#]/,1)[0]??e).toLowerCase();return!!t.startsWith("data:image/")||VI.some(e=>t.endsWith(e))}(t.target)){let e=n?.resolveImageSrc?.(t.target)??t.target;r.push((0,ey.jsx)(VT,{src:e,alt:t.label||Vz(t.target)},`img-${a}`))}else n?r.push((0,ey.jsx)(VD,{label:t.label,target:t.target,context:n},`chip-${a}`)):r.push((0,ey.jsx)("a",{href:t.target,target:"_blank",rel:"noreferrer noopener",children:t.label||t.target},`link-${a}`));a=t.end;continue}}if(e.startsWith("**",a)){let i=e.indexOf("**",a+2),o=-1===i?e.slice(a+2):e.slice(a+2,i);o.length>0&&r.push((0,ey.jsx)("strong",{children:VL(o,t-a-2,n)},`strong-${a}`)),a=-1===i?e.length:i+2;continue}if("`"===e[a]){let i=e.indexOf("`",a+1),o=-1===i?e.slice(a+1):e.slice(a+1,i);o.length>0&&r.push((0,ey.jsx)("code",{children:VL(o,t-a-1,n)},`code-${a}`)),a=-1===i?e.length:i+1;continue}let i=[e.indexOf("**",a),e.indexOf("`",a),e.indexOf("[",a),e.indexOf("![",a)].filter(e=>e>=0).sort((e,t)=>e-t)[0]??e.length;if(i===a){VR(r,e[a]??"",a,t,`ch-${a}`),a+=1;continue}VR(r,e.slice(a,i),a,t,`text-${a}`),a=i}return r}function V$(e){return/^\s*[-*]\s+/.test(e)}function VF(e){return/^#{1,6}\s+/.test(e.trim())}function VB(e){return/^\s*([-*_])(?:\s*\1){2,}\s*$/.test(e)}function VV(e){return e.includes("|")&&e.trim().split("|").length>=3}function VH(e){return/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}function VU(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}let VW=new Map;function Vq({content:e,isStreaming:t=!1,deliverable:n}){let r=function(e){let t=VW.get(e);if(t)return VW.delete(e),VW.set(e,t),t;let n=function(e){let t=e.replace(/\r\n/g,"\n").split("\n"),n=[],r=0;for(let e of t)n.push(r),r+=e.length+1;let a=[],i=0;for(;i<t.length;){let e=t[i]??"",r=e.trim(),o=n[i]??0;if(!r){i+=1;continue}if(r.startsWith("```")){let e=[];for(i+=1;i<t.length&&!(t[i]??"").trim().startsWith("```");)e.push(t[i]??""),i+=1;i<t.length&&(i+=1),a.push({kind:"code",text:e.join("\n"),start:o});continue}if(VB(e)){a.push({kind:"hr",start:o}),i+=1;continue}if(VF(e)){let e=/^(#{1,6})\s+(.+)$/.exec(r),t=e?.[1]??"##";a.push({kind:"heading",depth:t.length,text:e?.[2]??r,start:o}),i+=1;continue}if(VV(e)&&i+1<t.length&&VH(t[i+1]??"")){let n=VU(e),r=[];for(i+=2;i<t.length&&VV(t[i]??"");)r.push(VU(t[i]??"")),i+=1;a.push({kind:"table",headers:n,rows:r,start:o});continue}if(V$(e)){let e=[];for(;i<t.length&&V$(t[i]??"");)e.push({text:(t[i]??"").replace(/^\s*[-*]\s+/,""),start:n[i]??0}),i+=1;a.push({kind:"list",items:e,start:o});continue}let l=[];for(;i<t.length;){let e=t[i]??"",n=t[i+1]??"";if(!e.trim()||e.trim().startsWith("```")||VB(e)||VF(e)||V$(e)||VV(e)&&VH(n))break;l.push(e),i+=1}a.push({kind:"paragraph",lines:l,start:o})}return a}(e);if(VW.set(e,n),VW.size>512){let e=VW.keys().next().value;void 0!==e&&VW.delete(e)}return n}(e),a=t?Math.max(0,e.length-14):1/0;return(0,ey.jsx)("div",{className:"vtl-agent-markdown",children:r.map((e,t)=>{let r=a-e.start;return"code"===e.kind?(0,ey.jsx)("pre",{children:e.text},`block-${t}`):"hr"===e.kind?(0,ey.jsx)("hr",{},`block-${t}`):"heading"===e.kind?e.depth<=2?(0,ey.jsx)("h3",{children:VL(e.text,r,n)},`block-${t}`):(0,ey.jsx)("h4",{children:VL(e.text,r,n)},`block-${t}`):"list"===e.kind?(0,ey.jsx)("ul",{children:e.items.map((e,t)=>(0,ey.jsx)("li",{children:VL(e.text,a-e.start,n)},`${e.text}-${t}`))},`block-${t}`):"table"===e.kind?(0,ey.jsx)("div",{className:"vtl-agent-markdown-table",children:(0,ey.jsxs)("table",{children:[(0,ey.jsx)("thead",{children:(0,ey.jsx)("tr",{children:e.headers.map((e,t)=>(0,ey.jsx)("th",{children:VL(e,r,n)},`${e}-${t}`))})}),(0,ey.jsx)("tbody",{children:e.rows.map((t,a)=>(0,ey.jsx)("tr",{children:e.headers.map((e,i)=>(0,ey.jsx)("td",{children:VL(t[i]??"",r,n)},`cell-${a}-${i}`))},`row-${a}`))})]})},`block-${t}`):(0,ey.jsx)("p",{children:VL(e.lines.map(e=>e.trim()).join(" "),r,n)},`block-${t}`)})})}function VK(e){return("assistant"===e.kind||"done"===e.kind)&&"模型没有返回内容。"===e.title.trim()&&!e.detail?.trim()}function VG(e){return("error"!==e.kind||"retried"!==e.status)&&!VK(e)}let VX=new Set(["thought","read","search","tool","plan","plan-task","plan-compact","browser"]),VY=ew.forwardRef(function({events:e,labels:t,running:n=!1,bottomInset:r=16,className:a,contentClassName:i,hasEarlier:o,loadingEarlier:l,onLoadEarlier:s,onOpenFile:c,deliverable:d,onOpenSubagent:u,onOpenPlan:f,onOpenSpec:h,onRecallUserMessage:m,onBranchAssistantMessage:p,onRetry:g,onApprovalDecision:v,onContinue:x,onActiveEventChange:y,onAtBottomChange:b},w){let j=ew.useRef(null),k=ew.useRef(!0),S=ew.useRef(!0),N=ew.useRef(b);N.current=b;let[C,M]=ew.useState(0),[E,O]=ew.useState(0),[P,A]=ew.useState({}),I=ew.useMemo(()=>e.filter(VG),[e]),z=ew.useMemo(()=>n?function(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r){if("user"===r.kind){t=t??r;break}if(void 0===t&&(t=r),"error"===r.kind&&"retried"===r.status)return{mode:"retry",retryAttempt:r.retryAttempt??1,retryMax:r.retryMax??1,errorDetail:(r.detail??r.title??"").trim()};if(("assistant"===r.kind||"done"===r.kind)&&r.isStreaming&&r.title.trim())return null;if(r.isStreaming||"running"===r.status)break}}return{mode:"working",label:function(e){switch(e?.kind){case"thought":return"正在思考中";case"change":return"正在编辑文件";case"subagent":return"正在分发子代理";default:return"正在处理中"}}(t)}}(e):null,[n,e]),T=ew.useMemo(()=>{let e,t=new Set;for(let n of I)"user"===n.kind?(e&&t.add(e),e=void 0):"assistant"!==n.kind&&"done"!==n.kind||VK(n)||(e=n.id);return e&&t.add(e),t},[I]),D=ew.useMemo(()=>(function(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!VX.has(r.kind)){t.push(r),n++;continue}let a=n,i=[];for(;a<e.length&&VX.has(e[a].kind);)i.push(e[a]),a++;a<e.length&&i.length>=2?t.push(function(e){let t=0,n=0,r=0,a=0,i=0;for(let o of e)"thought"===o.kind?a+=1:"read"===o.kind?t+=o.files?.length??1:"search"===o.kind?n+=1:"plan"===o.kind||"plan-task"===o.kind||"plan-compact"===o.kind?i+=1:r+=1;let o=[];a>0&&o.push(`思考 ${a} 次`),t>0&&o.push(`阅读 ${t} 个文件`),n>0&&o.push(`搜索 ${n} 次`),r>0&&o.push(`执行 ${r} 条命令`),i>0&&o.push(`更新计划 ${i} 次`);let l=o.length>0?`已${o.join(",")}`:`已完成 ${e.length} 步操作`;return{id:`toolgroup-${e[0].id}`,kind:"toolgroup",title:l,groupedEvents:e}}(i)):t.push(...i),n=a}return t})(I),[I]);ew.useLayoutEffect(()=>{let e=j.current;if(!e)return;function t(){O(e.clientHeight)}t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let R=ew.useMemo(()=>D.reduce((e,t,n)=>{var r;let a=P[Hv(t,n)]??("toolgroup"===(r=t).kind?30:"user"===r.kind?72:"assistant"===r.kind||"done"===r.kind?Math.max(42,Math.min(260,28+22*Math.ceil((r.title.length+(r.detail?.length??0))/68))):"read"===r.kind||"search"===r.kind||"tool"===r.kind?r.files?.length?28+26*Math.min(r.files.length,5):26:"subagent"===r.kind?r.subagents?.length?6+24*Math.min(r.subagents.length,6):42:"change"===r.kind?Math.max(42,Math.min(180,10+(r.files?.length??1)*43)):"approval"===r.kind?"pending"===r.status?140:72:"limit"===r.kind?80:"error"===r.kind?88:"plan-question"===r.kind||"plan-approval"===r.kind?r.detail?60:30:"plan"===r.kind||"plan-task"===r.kind||"plan-compact"===r.kind||"plan-answer"===r.kind||"plan-decision"===r.kind?28:r.detail?54:26);return e.rows.push({event:t,index:n,offset:e.totalHeight,height:a,autoOpen:("read"===t.kind||"tool"===t.kind)&&!!t.isStreaming||"read"===t.kind&&!D.slice(n+1).some(e=>"read"!==e.kind),showActions:T.has(t.id)}),e.totalHeight+=a,e},{rows:[],totalHeight:0}),[P,D,T]),_=R.rows.filter(e=>e.offset+e.height>=C-360&&e.offset<=C+Math.max(E,520)+360),L=40*!!z,$=R.totalHeight+Math.max(0,r)+L,F=ew.useRef(R.rows);F.current=R.rows,ew.useImperativeHandle(w,()=>({scrollToEvent:e=>{let t=j.current;if(!t)return!1;let n=F.current.find(t=>t.event.id===e);if(!n)return!1;k.current=!1;let r=Math.max(0,n.offset-12);return t.scrollTop=r,M(r),!0},scrollToBottom:()=>{let e=j.current;e&&(k.current=!0,e.scrollTop=e.scrollHeight,M(e.scrollTop),!0!==S.current&&(S.current=!0,N.current?.(!0)))}}),[]);let B=ew.useRef(void 0),V=ew.useCallback(()=>{let e;if(!y)return;let t=j.current;if(!t)return;let n=t.scrollTop+24;for(let t of F.current)if(t.offset<=n)e=t.event.id;else break;!e&&F.current.length>0&&(e=F.current[0].event.id),e!==B.current&&(B.current=e,y(e))},[y]),H=ew.useCallback(()=>{let e=j.current;if(!e)return;let t=e.scrollHeight-e.clientHeight,n=t-e.scrollTop,r=t<=1||n<96;r!==S.current&&(S.current=r,b?.(r))},[b]),U=ew.useRef(void 0),W=ew.useRef(0);ew.useLayoutEffect(()=>{let e=j.current,t=D[0]?.id,n=U.current,r=W.current;if(e&&void 0!==n&&t!==n&&D.some(e=>e.id===n)){let t=R.totalHeight-r;if(t>0){let n=e.scrollTop+t;e.scrollTop=n,M(n)}}U.current=t,W.current=R.totalHeight},[D,R.totalHeight]),ew.useLayoutEffect(()=>{let e=j.current;if(!e||!I.length||!k.current){V(),H();return}e.scrollTop=e.scrollHeight,M(e.scrollTop),V(),H()},[r,I.length,$,E,z,V,H]);let q=ew.useCallback((e,t)=>{A(n=>1>Math.abs((n[e]??0)-t)?n:{...n,[e]:t})},[]);return(0,ey.jsxs)("div",{ref:j,"data-slot":"agent-conversation-flow",className:(0,eI.cn)("min-h-0 flex-1 overflow-auto px-4 pt-4 opacity-100 transition-opacity duration-180 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden select-text [-webkit-touch-callout:default] [-webkit-user-select:text]",a),onScroll:function(){let e=j.current;e&&(k.current=e.scrollHeight-e.scrollTop-e.clientHeight<96,M(e.scrollTop),V(),H())},children:[o?(0,ey.jsx)("div",{className:"mx-auto mb-2 flex w-full max-w-[48rem] justify-center",children:(0,ey.jsx)("button",{type:"button",disabled:l,onClick:()=>s?.(),className:"rounded-full border border-border bg-popover px-3 py-1 text-xs text-muted-foreground shadow-sm transition-colors hover:bg-muted disabled:cursor-default disabled:opacity-60",children:l?"加载中…":"↑ 加载更早的消息"})}):null,(0,ey.jsxs)("div",{className:(0,eI.cn)("relative mx-auto min-h-full w-full max-w-[48rem]",i),style:{height:$},children:[_.map(e=>(0,ey.jsx)(VZ,{event:e.event,rowKey:Hv(e.event,e.index),offset:e.offset,autoOpen:e.autoOpen,showActions:e.showActions,labels:t,deliverable:d,onMeasure:q,onOpenFile:c,onOpenSubagent:u,onOpenPlan:f,onOpenSpec:h,onRecallUserMessage:m,onBranchAssistantMessage:p,onRetry:g,onApprovalDecision:v,onContinue:x},Hv(e.event,e.index))),z?(0,ey.jsx)("div",{className:"absolute inset-x-0 px-1 pt-1",style:{top:R.totalHeight},children:(0,ey.jsx)(VP,{mode:z.mode,label:"working"===z.mode?z.label:void 0,retryAttempt:"retry"===z.mode?z.retryAttempt:void 0,retryMax:"retry"===z.mode?z.retryMax:void 0,errorDetail:"retry"===z.mode?z.errorDetail:void 0})}):null]})]})}),VZ=ew.memo(function({event:e,rowKey:t,offset:n,autoOpen:r,showActions:a,labels:i,deliverable:o,onMeasure:l,onOpenFile:s,onOpenSubagent:c,onOpenPlan:d,onOpenSpec:u,onRecallUserMessage:f,onBranchAssistantMessage:h,onRetry:m,onApprovalDecision:p,onContinue:g}){let v=ew.useRef(null);return ew.useLayoutEffect(()=>{let e=v.current;if(!e)return;function n(){l(t,Math.ceil(e.getBoundingClientRect().height))}n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e.id,l,t]),(0,ey.jsx)("div",{ref:v,"data-index":e.id,className:"absolute inset-x-0 top-0",style:{transform:`translateY(${n}px)`},children:(0,ey.jsx)(V1,{event:e,autoOpen:r,showActions:a,labels:i,deliverable:o,onOpenFile:s,onOpenSubagent:c,onOpenPlan:d,onOpenSpec:u,onRecallUserMessage:f,onBranchAssistantMessage:h,onRetry:m,onContinue:g,onApprovalDecision:p})})});function VJ({attachment:e}){return(0,ey.jsx)("div",{className:"size-14 shrink-0 overflow-hidden rounded-md border border-border bg-muted/40",title:e.name,children:"image"===e.kind&&e.url?(0,ey.jsx)("img",{src:e.url,alt:e.name,className:"size-full object-cover"}):(0,ey.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-1 px-1 text-center",children:[(0,ey.jsx)(uC,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"w-full truncate text-[10px] font-semibold uppercase text-muted-foreground",children:e.ext?`.${e.ext}`:"FILE"})]})})}function VQ({event:e,labels:t,onRecallUserMessage:n}){let[r,a]=ew.useState(!1),[i,o]=ew.useState(!1),l=!e.forkInherited&&!!n;async function s(){try{await navigator.clipboard.writeText(e.title??""),o(!0),window.setTimeout(()=>o(!1),1500)}catch{}}return(0,ey.jsxs)("article",{className:"vtl-agent-event-row group","data-kind":e.kind,children:[e.title?(0,ey.jsx)("div",{className:"vtl-agent-user-message-wrap",children:(0,ey.jsx)("div",{className:"vtl-agent-user-message",children:e.title})}):null,e.attachments&&e.attachments.length>0?(0,ey.jsx)("div",{className:"mt-1.5 flex flex-wrap justify-end gap-2",children:e.attachments.map((e,t)=>(0,ey.jsx)(VJ,{attachment:e},t))}):null,(0,ey.jsx)(VE,{className:(0,eI.cn)("absolute top-1/2 right-2 -translate-y-1/2 transition-opacity","opacity-0 focus-within:opacity-100 group-hover:opacity-100 max-md:opacity-100",r&&"opacity-100"),children:(0,ey.jsxs)(bR,{open:r,onOpenChange:a,children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(VO,{type:"button","aria-label":t?.more??"更多操作",title:t?.more??"更多操作",children:(0,ey.jsx)(lY,{})})}),(0,ey.jsxs)(bZ,{align:"end",sideOffset:6,className:"min-w-44",children:[l?(0,ey.jsxs)(bJ,{onSelect:()=>n?.(e),children:[(0,ey.jsx)(Vj,{}),(0,ey.jsx)("span",{className:"flex-1",children:t?.recall??"回退对话到此处"})]}):null,(0,ey.jsxs)(bJ,{onSelect:e=>{e.preventDefault(),s()},children:[(0,ey.jsx)(lU,{}),(0,ey.jsx)("span",{className:"flex-1",children:i?"已复制":t?.copy??"复制提示词"})]})]})]})})]})}function V0({event:e,labels:t,showActions:n,deliverable:r,onBranchAssistantMessage:a}){let[i,o]=ew.useState(!1),l=e.detail?`${e.title}
|
|
20
|
+
`).join("\n")}}):null}function Vn({active:e,payload:t,className:n,indicator:r="dot",hideLabel:a=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:s,formatter:c,color:d,nameKey:u,labelKey:f}){let{config:h}=function(){let e=ew.useContext(B9);if(!e)throw Error("useChart must be used within a <ChartContainer />");return e}(),m=ew.useMemo(()=>{if(a||!t?.length)return null;let[e]=t,n=`${f??e?.dataKey??e?.name??"value"}`,r=Vr(h,e,n),i=f||"string"!=typeof o?r?.label:h[o]?.label??o;return l?(0,ey.jsx)("div",{className:(0,eI.cn)("font-medium",s),children:l(i,t)}):i?(0,ey.jsx)("div",{className:(0,eI.cn)("font-medium",s),children:i}):null},[o,l,t,a,s,h,f]);if(!e||!t?.length)return null;let p=1===t.length&&"dot"!==r;return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-popover grid min-w-32 items-start gap-1.5 rounded-[var(--surface-popover-radius)] border px-2.5 py-1.5 text-xs",n),children:[p?null:m,(0,ey.jsx)("div",{className:"grid gap-1.5",children:t.filter(e=>"none"!==e.type).map((e,t)=>{let n=`${u??e.name??e.dataKey??"value"}`,a=Vr(h,e,n),o=d??e.payload?.fill??e.color;return(0,ey.jsx)("div",{className:(0,eI.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&e?.value!==void 0&&e.name?c(e.value,e.name,e,t,e.payload):(0,ey.jsxs)(ey.Fragment,{children:[a?.icon?(0,ey.jsx)(a.icon,{}):!i&&(0,ey.jsx)("div",{className:(0,eI.cn)("shrink-0 rounded-[2px]","dot"===r&&"size-2.5","line"===r&&"w-1","dashed"===r&&"w-0 border-[1.5px] border-dashed bg-transparent",p&&"dashed"===r&&"my-0.5"),style:{backgroundColor:"dashed"===r?"transparent":o,borderColor:o}}),(0,ey.jsxs)("div",{className:(0,eI.cn)("flex flex-1 justify-between leading-none",p?"items-end":"items-center"),children:[(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[p?m:null,(0,ey.jsx)("span",{className:"text-muted-foreground",children:a?.label??e.name})]}),null!=e.value&&(0,ey.jsx)("span",{className:"font-mono font-medium text-foreground tabular-nums",children:"number"==typeof e.value?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function Vr(e,t,n){if("object"!=typeof t||null===t)return;let r="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0,a=n;return n in t&&"string"==typeof t[n]?a=t[n]:r&&n in r&&"string"==typeof r[n]&&(a=r[n]),a in e?e[a]:e[n]}let Va={placeholder:"Ask the agent to inspect, change, or explain this workspace...",mode:"Mode",model:"Model",attach:"Attach context",removeChip:"Remove context",removeAttachment:"Remove attachment",queuedMessage:"Queued message",guideQueuedMessage:"Guide",removeQueuedMessage:"Remove queued message",moreQueuedMessageActions:"More queued message actions",contextUsage:"Context usage",contextUsed:"used",contextTokenSummary:"used {used} / {total}",toolCalls:"Tool calls",userMessages:"User messages",otherContext:"Other context",compressContext:"Compress context",compressPrecise:"Precise",compressExtreme:"Extreme",send:"Run",stop:"Stop"},Vi=[{id:"agent",label:"Agent",description:"Use tools and make changes.",icon:(0,ey.jsx)(bC,{className:"fill-current"})},{id:"planner",label:"Planner",description:"Plan before changing files.",icon:(0,ey.jsx)(jT,{})},{id:"reviewer",label:"Reviewer",description:"Inspect risks and regressions.",icon:(0,ey.jsx)(ub,{})}],Vo=[{id:"acceptEdits",label:"Accept edits",description:"Auto-approve edits, ask for risky commands.",icon:(0,ey.jsx)(mZ,{})},{id:"ask",label:"Ask permissions",description:"Ask before any tool action.",icon:(0,ey.jsx)(jz,{})},{id:"auto",label:"Auto mode",description:"Auto-approve all except dangerous.",icon:(0,ey.jsx)(jR,{})}],Vl=[{id:"gpt-5.5",label:"GPT-5.5",description:"Highest quality coding agent."},{id:"gpt-5.4",label:"GPT-5.4",description:"Balanced everyday work."},{id:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Fast lightweight passes."}];function Vs(e){if(e)return"string"==typeof e.label||"number"==typeof e.label?String(e.label):e.id}function Vc({value:e,defaultValue:t,onValueChange:n,modes:r=Vi,modeId:a,defaultModeId:i,onModeChange:o,permissionModes:l=Vo,permissionModeId:s,defaultPermissionModeId:c,onPermissionModeChange:d,models:u=Vl,modelId:f,defaultModelId:h,onModelChange:m,queuedMessages:p,defaultQueuedMessages:g=[],onQueuedMessagesChange:v,onQueueMessage:x,onRemoveQueuedMessage:y,queueOnTab:b=!0,renderQueuedMessageActions:w,contextUsage:j,chips:k=[],attachments:S=[],onAttachmentsChange:N,actions:C,footer:M,running:E=!1,disabled:O=!1,submitOnEnter:P=!0,promptHistory:A,minRows:I=2,maxRows:z=7,onSubmit:T,onStop:D,onAttach:R,onNudge:_,labels:L,className:$,textareaClassName:F,toolbarClassName:B}){let V,H,U={...Va,...L},W=ew.useRef(null),q=ew.useId(),K=ew.useRef(0),[G,X]=function({value:e,defaultValue:t="",onChange:n}){let[r,a]=ew.useState(t);return[e??r,ew.useCallback(t=>{void 0===e&&a(t),n?.(t)},[n,e])]}({value:e,defaultValue:t,onChange:n}),Y=A??[],[Z,J]=ew.useState(null),Q=ew.useRef(""),ee=ew.useRef(!1);ew.useEffect(()=>{J(null),ee.current=!1},[A]);let et=ew.useCallback(e=>{ee.current=!0,X(e);let t=W.current;t&&requestAnimationFrame(()=>{let e=t.value.length;t.setSelectionRange(e,e)})},[X]),[en,er]=ew.useState(g),[ea,ei]=ew.useState(i??r[0]?.id),[eo,el]=ew.useState(c??l[0]?.id),[es,ec]=ew.useState(h??u[0]?.id),ed=a??ea,eu=s??eo,ef=f??es,eh=r.find(e=>e.id===ed)??r[0],em=l.find(e=>e.id===eu)??l[0],ep=u.find(e=>e.id===ef)??u[0],eg=p??en,ev=(G.trim().length>0||S.length>0)&&!O;function ex(){ev&&(T?.({value:G,modeId:eh?.id,modelId:ep?.id,attachments:S.length>0?S:void 0}),J(null),ee.current=!1,Q.current="",X(""),S.length>0&&N?.([]))}async function eb(e){if(0===e.length||!N)return;let t=[];for(let n of e){let e=`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;if(n.type.startsWith("image/")){let r=await function(e){return new Promise(t=>{let n=new FileReader;n.onload=()=>t("string"==typeof n.result?n.result:""),n.onerror=()=>t(""),n.readAsDataURL(e)})}(n);if(!r)continue;t.push({id:e,kind:"image",name:n.name||"image.png",mimeType:n.type||"image/png",dataUrl:r,size:n.size})}else{let r=await function(e){return new Promise(t=>{let n=new FileReader;n.onload=()=>t("string"==typeof n.result?n.result:""),n.onerror=()=>t(""),n.readAsText(e)})}(n),a=(n.name.split(".").pop()??"").toLowerCase();t.push({id:e,kind:"file",name:n.name||"file.txt",mimeType:n.type||"text/plain",text:r,ext:a,size:n.size})}}t.length>0&&N([...S,...t])}function ej(e){void 0===p&&er(e),v?.(e)}function ek(){let e=G.trim();if(!e||O)return!1;K.current+=1;let t={id:`${q}-queued-${K.current}`,content:e},n=[...eg,t];return ej(n),x?.(t,n),X(""),!0}return ew.useLayoutEffect(()=>{let e=W.current;if(!e)return;e.style.height="0px";let t=Number.parseFloat(getComputedStyle(e).lineHeight),n=Number.isFinite(t)?t*z:160;e.style.height=`${Math.min(e.scrollHeight,n)}px`,e.style.overflowY=e.scrollHeight>n?"auto":"hidden"},[z,G]),(0,ey.jsxs)("div",{"data-slot":"agent-input-composer","data-running":E,className:(0,eI.cn)("relative grid w-full",$),children:[eg.length>0&&(0,ey.jsx)(Vf,{messages:eg,labels:U,renderActions:w,onRemove:function(e){let t=eg.find(t=>t.id===e);if(!t)return;let n=eg.filter(t=>t.id!==e);ej(n),y?.(e,t,n)},onNudge:_,running:E}),(0,ey.jsxs)("div",{"data-slot":"agent-input-composer-surface",className:(0,eI.cn)("vtl-agent-input-composer-surface relative grid w-full gap-2 rounded-lg border border-border p-2 shadow-sm transition-colors"),children:[k.length>0&&(0,ey.jsx)("div",{"data-slot":"agent-input-composer-context",className:"flex min-w-0 flex-wrap items-center gap-1.5",children:k.map(e=>(0,ey.jsx)(Vm,{chip:e,removeLabel:U.removeChip},e.id))}),S.length>0&&(0,ey.jsx)("div",{"data-slot":"agent-input-composer-attachments",className:"flex min-w-0 flex-wrap items-center gap-2",children:S.map(e=>(0,ey.jsx)(Vh,{attachment:e,removeLabel:U.removeAttachment,onRemove:()=>N?.(S.filter(t=>t.id!==e.id))},e.id))}),(0,ey.jsx)("textarea",{ref:W,value:G,disabled:O,rows:I,placeholder:U.placeholder,"data-slot":"agent-input-composer-textarea",className:(0,eI.cn)("min-h-10 w-full resize-none border-0 bg-transparent px-0.5 py-0 text-sm leading-5 text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",F),onChange:e=>{var t;return t=e.currentTarget.value,void(!ee.current&&null!==Z&&J(null),ee.current=!1,X(t))},onPaste:function(e){let t=Array.from(e.clipboardData?.files??[]);0!==t.length&&N&&(e.preventDefault(),eb(t))},onKeyDown:e=>{Y.length>0&&e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&("ArrowUp"===e.key||"ArrowDown"===e.key)&&!e.nativeEvent.isComposing&&function(e){if(0===Y.length)return!1;if("older"===e){if(null===Z){Q.current=G;let e=Y.length-1;return J(e),et(Y[e]??""),!0}if(Z<=0)return!0;let e=Z-1;return J(e),et(Y[e]??""),!0}if(null===Z)return!1;let t=Z+1;return t>=Y.length?(J(null),ee.current=!1,et(Q.current),ee.current=!1):(J(t),et(Y[t]??"")),!0}("ArrowUp"===e.key?"older":"newer")?e.preventDefault():b&&"Tab"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&ek()?e.preventDefault():!P||"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),E?ek():ex())}}),(0,ey.jsxs)("div",{"data-slot":"agent-input-composer-toolbar",className:(0,eI.cn)("grid grid-cols-[minmax(0,1fr)_auto] items-end gap-2",B),children:[(0,ey.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,ey.jsx)(Vp,{label:"Permissions",options:l,value:em?.id,trigger:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"grid size-3.5 place-items-center text-muted-foreground [&_svg]:size-3",children:em?.icon??(0,ey.jsx)(jz,{})}),(0,ey.jsx)("span",{className:"hidden truncate md:inline",children:Vs(em)}),(0,ey.jsx)(vu,{className:"size-3 text-muted-foreground"})]}),triggerClassName:"rounded-md bg-transparent px-1.5 text-muted-foreground hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/70",onSelect:function(e){e.disabled||(void 0===s&&el(e.id),d?.(e.id,e))}}),(0,ey.jsx)(Vp,{label:U.model,options:u,value:ep?.id,trigger:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"grid size-3.5 place-items-center text-muted-foreground [&_svg]:size-3 md:hidden",children:(0,ey.jsx)(jT,{})}),(0,ey.jsx)("span",{className:"hidden truncate md:inline",children:Vs(ep)}),(0,ey.jsx)(vu,{className:"size-3 text-muted-foreground"})]}),triggerClassName:"rounded-md bg-transparent px-1.5 text-muted-foreground hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/70",onSelect:function(e){e.disabled||(void 0===f&&ec(e.id),m?.(e.id,e))}}),R&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-label":U.attach,title:U.attach,onClick:R,disabled:O,children:(0,ey.jsx)(jI,{})}),C]}),(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[j&&(0,ey.jsx)(Vu,{usage:j,labels:U}),(V=G.trim().length>0,H=E&&!V,(0,ey.jsx)(eA.Button,{type:"button",size:"icon-xs",variant:H?"outline":"default","aria-label":H?U.stop:U.send,title:H?U.stop:U.send,disabled:!E&&!ev,className:"rounded-full",onClick:H?D:E?()=>ek():ex,children:H?(0,ey.jsx)(jD,{className:"size-3 fill-current"}):(0,ey.jsx)(jP,{className:"size-3.5"})}))]})]}),M&&(0,ey.jsx)("div",{"data-slot":"agent-input-composer-footer",className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:M})]})]})}function Vd(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${Math.round(e/1e3)}k`:e.toLocaleString()}function Vu({usage:e,labels:t}){let[n,r]=ew.useState(!1),a=Math.max(0,e.used),i=Math.max(0,e.total),o=i>0?Math.min(100,Math.round(a/i*100)):0,l=Math.max(0,e.toolCalls),s=Math.max(0,e.userMessages),c=Math.max(0,e.other??Math.max(0,a-l-s)),d=[{name:"toolCalls",value:l,fill:"var(--color-toolCalls)"},{name:"userMessages",value:s,fill:"var(--color-userMessages)"},{name:"other",value:c,fill:"var(--color-other)"},{name:"unused",value:Math.max(0,i-a),fill:"var(--muted)"}].filter(e=>e.value>0),u=t.contextTokenSummary.replace("{used}",Vd(a)).replace("{total}",Vd(i)),f={toolCalls:{label:t.toolCalls,color:"var(--chart-1)"},userMessages:{label:t.userMessages,color:"var(--chart-3)"},other:{label:t.otherContext,color:"var(--chart-5)"}};return(0,ey.jsxs)(xO,{children:[(0,ey.jsx)(xz,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-label":`${t.contextUsage}: ${o}% ${t.contextUsed}`,title:`${t.contextUsage}: ${o}% ${t.contextUsed}`,children:(0,ey.jsx)("span",{"aria-hidden":"true",className:"grid size-4 place-items-center rounded-full",style:{background:`conic-gradient(var(--foreground) ${3.6*o}deg, var(--border) 0deg)`},children:(0,ey.jsx)("span",{className:"size-3 rounded-full bg-background dark:bg-popover"})})})}),(0,ey.jsxs)(xq,{side:"top",align:"center",sideOffset:8,className:"w-44 gap-2 p-3",children:[(0,ey.jsxs)("div",{className:"grid gap-0.5 text-center",children:[(0,ey.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:e.label??t.contextUsage}),(0,ey.jsxs)("div",{className:"text-sm text-muted-foreground",children:[o,"% ",t.contextUsed]}),(0,ey.jsx)("div",{className:"text-sm font-medium",children:u})]}),(0,ey.jsx)("div",{className:"grid justify-center",children:(0,ey.jsx)(Ve,{config:f,className:"h-20 w-20",initialDimension:{width:80,height:80},onMouseMove:()=>r(!0),onMouseLeave:()=>r(!1),children:(0,ey.jsxs)(Bo,{children:[(0,ey.jsx)(BU,{active:n,content:(0,ey.jsx)(Vn,{hideLabel:!0})}),(0,ey.jsx)(LN,{data:d.length>0?d:[{name:"other",value:1,fill:"var(--muted)"}],dataKey:"value",nameKey:"name",innerRadius:25,outerRadius:35,isAnimationActive:!1,strokeWidth:0})]})})}),e.onCompressPrecise||e.onCompressExtreme?(0,ey.jsxs)("div",{className:"flex w-full overflow-hidden rounded-md border",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"flex-1 rounded-none border-r text-xs font-medium",onClick:e.onCompressPrecise,disabled:e.compressing||!e.onCompressPrecise,children:e.compressing?"…":t.compressPrecise??"精确"}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"flex-1 rounded-none text-xs font-medium",onClick:e.onCompressExtreme,disabled:e.compressing||!e.onCompressExtreme,children:e.compressing?"…":t.compressExtreme??"极致"})]}):(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"w-full",onClick:e.onCompress,disabled:!e.onCompress,children:t.compressContext})]})]})}function Vf({messages:e,labels:t,renderActions:n,onRemove:r,onNudge:a,running:i}){return(0,ey.jsx)("div",{"data-slot":"agent-input-composer-queue",className:"vtl-agent-input-composer-queue z-10 mx-5 mb-[-1px] grid gap-1.5 rounded-t-lg rounded-b-none border border-border p-1.5 shadow-xs",children:e.map((e,o)=>(0,ey.jsxs)("div",{"data-slot":"agent-input-composer-queue-item",className:(0,eI.cn)("group/queue flex min-h-8 min-w-0 items-center gap-2 rounded-md px-2 text-sm transition-colors",e.disabled?"text-muted-foreground opacity-60":"text-foreground hover:bg-muted/60"),children:[(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon??(0,ey.jsx)(jA,{})}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",title:String(e.content),children:e.content}),e.meta&&(0,ey.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-70 transition-opacity group-hover/queue:opacity-100",children:[n?.(e),i&&a&&(0,ey.jsxs)(eA.Button,{type:"button",variant:"ghost",size:"xs",className:"h-6 gap-1 px-1.5 text-muted-foreground","aria-label":`${t.guideQueuedMessage} ${o+1}`,onClick:()=>a(e.id),children:[(0,ey.jsx)(jA,{className:"size-3.5"}),t.guideQueuedMessage]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground","aria-label":`${t.removeQueuedMessage} ${o+1}`,onClick:()=>r(e.id),children:(0,ey.jsx)(yi,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground","aria-label":`${t.moreQueuedMessageActions} ${o+1}`,children:(0,ey.jsx)(lY,{})})]})]},e.id))})}function Vh({attachment:e,removeLabel:t,onRemove:n}){return(0,ey.jsxs)("div",{"data-slot":"agent-input-attachment",className:"group/att relative size-14 shrink-0 overflow-hidden rounded-md border border-border bg-muted/40",title:e.name,children:["image"===e.kind&&e.dataUrl?(0,ey.jsx)("img",{src:e.dataUrl,alt:e.name,className:"size-full object-cover"}):(0,ey.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-1 px-1 text-center",children:[(0,ey.jsx)(uC,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"w-full truncate text-[10px] font-semibold uppercase text-muted-foreground",children:e.ext?`.${e.ext}`:"TXT"})]}),(0,ey.jsx)("button",{type:"button","aria-label":t,title:t,onClick:n,className:"absolute right-0.5 top-0.5 grid size-4 place-items-center rounded-full bg-background/85 text-muted-foreground opacity-0 shadow-sm transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover/att:opacity-100",children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]})}function Vm({chip:e,removeLabel:t}){return(0,ey.jsxs)(Bs,{variant:"secondary","data-tone":e.tone,className:(0,eI.cn)("h-6 max-w-full gap-1 rounded-md border border-border bg-muted/70 px-1.5 text-muted-foreground","success"===e.tone&&"border-primary/25 bg-primary/10 text-foreground","warning"===e.tone&&"border-destructive/25 bg-destructive/10 text-foreground"),children:[e.icon&&(0,ey.jsx)("span",{className:"grid size-3.5 shrink-0 place-items-center [&_svg]:size-3",children:e.icon}),(0,ey.jsx)("span",{className:"truncate",children:e.label}),e.onRemove&&(0,ey.jsx)("button",{type:"button",className:"-mr-0.5 grid size-4 shrink-0 place-items-center rounded-sm text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none","aria-label":`${t} ${e.id}`,onClick:()=>e.onRemove?.(e.id),children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]})}function Vp({label:e,options:t,value:n,trigger:r,triggerClassName:a,onSelect:i}){return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"xs",className:(0,eI.cn)("h-6 max-w-40 gap-1 rounded-md px-1.5 text-xs font-medium",a),children:r})}),(0,ey.jsx)(bZ,{align:"start","aria-label":"string"==typeof e?e:void 0,className:"min-w-40 p-1",children:t.map(e=>(0,ey.jsxs)(bJ,{disabled:e.disabled,className:"h-8 gap-2 px-2 text-sm",onSelect:()=>i(e),children:[(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),(0,ey.jsx)(mZ,{className:(0,eI.cn)("ml-auto size-4 text-foreground",n===e.id?"opacity-100":"opacity-0")})]},e.id))})]})}function Vg(e,t,n,r){return[{id:`${t}-task-${e}`,kind:"user",title:n},...r.map(n=>({...n,id:`${t}-${n.id}-${e}`}))]}function Vv(e){return[{id:`read-materials-${e}`,kind:"read",actionLabel:"读取",title:"AgentWorkspace.tsx, styles.css, i18n.json",files:[{id:`workspace-${e}`,name:"AgentWorkspace.tsx",lines:"1-480"},{id:`styles-${e}`,name:"styles.css",lines:"265-820"},{id:`i18n-${e}`,name:"i18n.json",lines:"245-292"}]},{id:`search-actions-${e}`,kind:"search",actionLabel:"搜索",title:"workspace creation, sidebar tree, streaming output",files:[{id:`workspace-search-${e}`,name:"AgentWorkspace.tsx",lines:"64-190"},{id:`style-search-a-${e}`,name:"styles.css",lines:"540-670"},{id:`style-search-b-${e}`,name:"styles.css",lines:"705-790"}]},{id:`subagents-${e}`,kind:"subagent",actionLabel:"召唤",title:"子代理",subagents:[{id:`reader-${e}`,title:"阅读子代理",activity:"阅读 package.json",toolActivities:["读取 package.json","检查 workspace 脚本","整理依赖信息"],status:"阅读 package.json",detail:"package.json 已读取,正在整理脚本与依赖信息。",isRunning:!0,events:Vg(e,"reader","阅读 package.json",[{id:"read-package",kind:"read",actionLabel:"读取",title:"package.json",files:[{id:"package-json",name:"package.json",lines:"1-96"}]},{id:"reader-note",kind:"done",title:"已读取 package.json。\n\n- 已记录 workspace 脚本\n- 已检查 UI 与 app 包依赖\n- 下一步等待主代理合并上下文"}])},{id:`searcher-${e}`,title:"搜索子代理",activity:"搜索 AgentWorkspace.tsx",toolActivities:["搜索 AgentWorkspace.tsx","筛选面板布局","定位事件流接入"],status:"搜索 AgentWorkspace.tsx",detail:"AgentWorkspace.tsx 命中 3 处候选区域,正在筛选可复用结构。",isRunning:!0,events:Vg(e,"searcher","搜索 AgentWorkspace.tsx",[{id:"search-workspace",kind:"search",actionLabel:"搜索",title:"AgentWorkspace.tsx",files:[{id:"agent-workspace-a",name:"AgentWorkspace.tsx",lines:"64-190"},{id:"agent-workspace-b",name:"AgentWorkspace.tsx",lines:"320-418"}]},{id:"searcher-note",kind:"done",title:"已定位 AgentWorkspace.tsx 的面板布局与事件流接入位置。"}])},{id:`verifier-${e}`,title:"验证子代理",activity:"验证工作流状态",toolActivities:["验证对话流","验证右侧面板","检查子代理切换"],status:"验证工作流状态",detail:"工作流状态正在校验,等待主代理提交最终结果。",isRunning:!0,events:Vg(e,"verifier","验证工作流状态",[{id:"verify-flow",kind:"verify",actionLabel:"验证",title:"对话流、右侧面板、子代理切换"},{id:"verifier-note",kind:"done",title:"验证队列已建立,等待主代理继续写入真实结果。"}])}]},{id:`think-structure-${e}`,kind:"thought",actionLabel:"思考",title:"8s",status:"done"},{id:`plan-${e}`,kind:"done",title:"**收到新的编织请求。**\n\n我会先保留当前工作台样式,只用占位文本演示真实任务流:读取、搜索、思考、编辑和验证都会按顺序进入同一条文字流。\n\n- 左侧织布机由真实创建动作产生\n- 编织物初始保持为空\n- 文件读取项仍然可以展开\n- 点击文件名会继续打开右侧标签页"},{id:`edit-workspace-${e}`,kind:"change",actionLabel:"编辑",title:"AgentWorkspace.tsx",additions:44,deletions:16},{id:`edit-style-${e}`,kind:"change",actionLabel:"编辑",title:"styles.css",additions:36,deletions:12},{id:`verify-flow-${e}`,kind:"verify",actionLabel:"验证",title:"empty sidebar, new loom creation, placeholder workflow"},{id:`done-${e}`,kind:"done",title:"演示工作流已完成。\n\n这只是前端占位演示,后续可以直接把事件流替换成真实 agent runtime。"}]}let Vx=[{id:"user-1",kind:"user",title:"345"},...Vv("1"),{id:"user-2",kind:"user",title:"234"}],Vy=(0,ek.default)("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Vb=(0,ek.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Vw=(0,ek.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),Vj=(0,ek.default)("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);(0,ek.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);let Vk=(0,l2.cva)("vtl-dot-matrix-loader",{variants:{size:{xs:"[--vtl-dot-size:3px] [--vtl-dot-gap:3px]",sm:"[--vtl-dot-size:3.5px] [--vtl-dot-gap:3.5px]",default:"[--vtl-dot-size:4px] [--vtl-dot-gap:4px]",lg:"[--vtl-dot-size:5px] [--vtl-dot-gap:5px]",xl:"[--vtl-dot-size:6px] [--vtl-dot-gap:6px]"},tone:{default:"text-current",muted:"text-muted-foreground",primary:"text-primary",inverse:"text-primary-foreground",destructive:"text-destructive"},variant:{pulse:"vtl-dot-matrix-loader-pulse",wave:"vtl-dot-matrix-loader-wave",orbit:"vtl-dot-matrix-loader-orbit",binary:"vtl-dot-matrix-loader-binary"}},defaultVariants:{size:"default",tone:"default",variant:"pulse"}}),VS={pulse:[0,90,180,270,360,450,540,630,720],wave:[0,80,160,80,160,240,160,240,320],orbit:[0,130,260,910,1040,390,780,650,520],binary:[0,210,420,630,140,350,560,70,280]};function VN({className:e,size:t,tone:n,variant:r,animated:a=!0,speed:i=1,style:o,"aria-label":l="Loading",...s}){let c=Math.round(1120/(Number.isFinite(i)&&i>0?i:1)),d=VS[r??"pulse"];return(0,ey.jsx)("span",{role:"status","aria-label":l,"data-animated":a?"true":"false",className:(0,eI.cn)(Vk({size:t,tone:n,variant:r}),e),style:{"--vtl-dot-duration":`${c}ms`,...o},...s,children:Array.from({length:9},(e,t)=>(0,ey.jsx)("span",{"aria-hidden":"true",className:"vtl-dot-matrix-loader-dot",style:{"--vtl-dot-delay":`${d[t]}ms`}},t))})}let VC=(0,l2.cva)("animate-spin",{variants:{size:{xs:"size-3",sm:"size-3.5",default:"size-4",lg:"size-5",xl:"size-6"},variant:{default:"text-current",muted:"text-muted-foreground",primary:"text-primary"}},defaultVariants:{size:"default",variant:"default"}});function VM({className:e,size:t,variant:n,...r}){return(0,ey.jsx)(eM,{role:"status","aria-label":"Loading",className:(0,eI.cn)(VC({size:t,variant:n}),e),...r})}function VE({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"agent-message-actions",className:(0,eI.cn)("flex items-center gap-1.5 text-muted-foreground",e),...t})}function VO({className:e,...t}){return(0,ey.jsx)(eA.Button,{size:"icon-xs",variant:"ghost",className:e,...t})}function VP({mode:e,label:t,retryAttempt:n,retryMax:r,errorDetail:a,className:i}){let o="retry"===e,l=o?`正在进行重试...(${n??1}/${r??1})`:t??"正在处理中",[s,c]=ew.useState(!1),d=ew.useRef(void 0);ew.useEffect(()=>()=>{void 0!==d.current&&window.clearTimeout(d.current)},[]);let u=ew.useCallback(()=>{let e=(a??"").trim();e&&("u">typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,n)=>{try{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select(),document.execCommand("copy"),document.body.removeChild(n),t()}catch(e){n(e)}})).then(()=>{c(!0),void 0!==d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!1),1800)}).catch(()=>{})},[a]),f=o&&!!(a??"").trim();return(0,ey.jsxs)("div",{"data-slot":"conversation-status-tail","aria-live":"polite",className:(0,eI.cn)("flex items-center gap-2 text-sm leading-6",o?"text-destructive":"text-muted-foreground",i),children:[(0,ey.jsx)(VN,{variant:"wave",tone:o?"destructive":"muted",style:{"--vtl-dot-size":"0.2em","--vtl-dot-gap":"0.2em"},"aria-label":l}),(0,ey.jsx)("span",{children:l}),f?(0,ey.jsxs)("button",{type:"button",onClick:u,title:"复制完整报错信息",className:"cursor-pointer rounded text-destructive/80 underline decoration-dotted underline-offset-2 transition-colors hover:text-destructive",children:["(",s?"已复制":"点击复制报错信息",")"]}):null]})}function VA(e){return e.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?|\x1b\[[?!>]?[\d;]*[a-zA-Z~]|\x9b[?!>]?[\d;]*[a-zA-Z~]|\x1b[()#][A-Z0-9]|\x1b[A-Z=><78]|\r/gi,"").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\x80-\x9f]/g,"")}let VI=[".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"];function Vz(e){let t=(e.split(/[?#]/,1)[0]??e).replace(/[\\/]+$/,"").split(/[\\/]/),n=t[t.length-1];return n&&n.trim()?n.trim():e}function VT({src:e,alt:t}){return(0,ey.jsx)("img",{src:e,alt:t,loading:"lazy",className:"vtl-agent-deliverable-image"})}function VD({label:e,target:t,context:n}){let r=n?.classify?.(t)??"url",a=e.trim()||Vz(t);return(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-deliverable-chip",title:t,onClick:()=>n?.onOpen?.({target:t,kind:r,label:a}),children:[(0,ey.jsx)(uC,{className:"vtl-agent-deliverable-chip-icon"}),(0,ey.jsx)("span",{className:"vtl-agent-deliverable-chip-label",children:a}),(0,ey.jsx)("span",{className:"vtl-agent-deliverable-chip-open",children:"打开"})]})}function VR(e,t,n,r,a){if(!t)return;let i=n+t.length;if(r<=n)return void e.push((0,ey.jsx)("span",{className:"vtl-agent-stream-fade-text",children:t},`${a}-fade-${n}`));if(r>=i)return void e.push(t);let o=r-n;e.push(t.slice(0,o)),e.push((0,ey.jsx)("span",{className:"vtl-agent-stream-fade-text",children:t.slice(o)},`${a}-fade-${n}`))}function V_(e,t){let n="!"===e[t]&&"["===e[t+1],r=t+(n?2:1),a=e.indexOf("]",r);if(-1===a||"("!==e[a+1])return null;let i=e.indexOf(")",a+2);if(-1===i)return null;let o=e.slice(r,a),l=e.slice(a+2,i).trim();return l?{isImage:n,label:o,target:l,end:i+1}:null}function VL(e,t=1/0,n){let r=[],a=0;for(;a<e.length;){if("!"===e[a]&&"["===e[a+1]){let t=V_(e,a);if(t){let e=n?.resolveImageSrc?.(t.target)??t.target;r.push((0,ey.jsx)(VT,{src:e,alt:t.label},`img-${a}`)),a=t.end;continue}}if("["===e[a]){let t=V_(e,a);if(t){if(function(e){let t=(e.split(/[?#]/,1)[0]??e).toLowerCase();return!!t.startsWith("data:image/")||VI.some(e=>t.endsWith(e))}(t.target)){let e=n?.resolveImageSrc?.(t.target)??t.target;r.push((0,ey.jsx)(VT,{src:e,alt:t.label||Vz(t.target)},`img-${a}`))}else n?r.push((0,ey.jsx)(VD,{label:t.label,target:t.target,context:n},`chip-${a}`)):r.push((0,ey.jsx)("a",{href:t.target,target:"_blank",rel:"noreferrer noopener",children:t.label||t.target},`link-${a}`));a=t.end;continue}}if(e.startsWith("**",a)){let i=e.indexOf("**",a+2),o=-1===i?e.slice(a+2):e.slice(a+2,i);o.length>0&&r.push((0,ey.jsx)("strong",{children:VL(o,t-a-2,n)},`strong-${a}`)),a=-1===i?e.length:i+2;continue}if("`"===e[a]){let i=e.indexOf("`",a+1),o=-1===i?e.slice(a+1):e.slice(a+1,i);o.length>0&&r.push((0,ey.jsx)("code",{children:VL(o,t-a-1,n)},`code-${a}`)),a=-1===i?e.length:i+1;continue}let i=[e.indexOf("**",a),e.indexOf("`",a),e.indexOf("[",a),e.indexOf("![",a)].filter(e=>e>=0).sort((e,t)=>e-t)[0]??e.length;if(i===a){VR(r,e[a]??"",a,t,`ch-${a}`),a+=1;continue}VR(r,e.slice(a,i),a,t,`text-${a}`),a=i}return r}function V$(e){return/^\s*[-*]\s+/.test(e)}function VF(e){return/^#{1,6}\s+/.test(e.trim())}function VB(e){return/^\s*([-*_])(?:\s*\1){2,}\s*$/.test(e)}function VV(e){return e.includes("|")&&e.trim().split("|").length>=3}function VH(e){return/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}function VU(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}let VW=new Map;function Vq({content:e,isStreaming:t=!1,deliverable:n}){let r=function(e){let t=VW.get(e);if(t)return VW.delete(e),VW.set(e,t),t;let n=function(e){let t=e.replace(/\r\n/g,"\n").split("\n"),n=[],r=0;for(let e of t)n.push(r),r+=e.length+1;let a=[],i=0;for(;i<t.length;){let e=t[i]??"",r=e.trim(),o=n[i]??0;if(!r){i+=1;continue}if(r.startsWith("```")){let e=[];for(i+=1;i<t.length&&!(t[i]??"").trim().startsWith("```");)e.push(t[i]??""),i+=1;i<t.length&&(i+=1),a.push({kind:"code",text:e.join("\n"),start:o});continue}if(VB(e)){a.push({kind:"hr",start:o}),i+=1;continue}if(VF(e)){let e=/^(#{1,6})\s+(.+)$/.exec(r),t=e?.[1]??"##";a.push({kind:"heading",depth:t.length,text:e?.[2]??r,start:o}),i+=1;continue}if(VV(e)&&i+1<t.length&&VH(t[i+1]??"")){let n=VU(e),r=[];for(i+=2;i<t.length&&VV(t[i]??"");)r.push(VU(t[i]??"")),i+=1;a.push({kind:"table",headers:n,rows:r,start:o});continue}if(V$(e)){let e=[];for(;i<t.length&&V$(t[i]??"");)e.push({text:(t[i]??"").replace(/^\s*[-*]\s+/,""),start:n[i]??0}),i+=1;a.push({kind:"list",items:e,start:o});continue}let l=[];for(;i<t.length;){let e=t[i]??"",n=t[i+1]??"";if(!e.trim()||e.trim().startsWith("```")||VB(e)||VF(e)||V$(e)||VV(e)&&VH(n))break;l.push(e),i+=1}a.push({kind:"paragraph",lines:l,start:o})}return a}(e);if(VW.set(e,n),VW.size>512){let e=VW.keys().next().value;void 0!==e&&VW.delete(e)}return n}(e),a=t?Math.max(0,e.length-14):1/0;return(0,ey.jsx)("div",{className:"vtl-agent-markdown",children:r.map((e,t)=>{let r=a-e.start;return"code"===e.kind?(0,ey.jsx)("pre",{children:e.text},`block-${t}`):"hr"===e.kind?(0,ey.jsx)("hr",{},`block-${t}`):"heading"===e.kind?e.depth<=2?(0,ey.jsx)("h3",{children:VL(e.text,r,n)},`block-${t}`):(0,ey.jsx)("h4",{children:VL(e.text,r,n)},`block-${t}`):"list"===e.kind?(0,ey.jsx)("ul",{children:e.items.map((e,t)=>(0,ey.jsx)("li",{children:VL(e.text,a-e.start,n)},`${e.text}-${t}`))},`block-${t}`):"table"===e.kind?(0,ey.jsx)("div",{className:"vtl-agent-markdown-table",children:(0,ey.jsxs)("table",{children:[(0,ey.jsx)("thead",{children:(0,ey.jsx)("tr",{children:e.headers.map((e,t)=>(0,ey.jsx)("th",{children:VL(e,r,n)},`${e}-${t}`))})}),(0,ey.jsx)("tbody",{children:e.rows.map((t,a)=>(0,ey.jsx)("tr",{children:e.headers.map((e,i)=>(0,ey.jsx)("td",{children:VL(t[i]??"",r,n)},`cell-${a}-${i}`))},`row-${a}`))})]})},`block-${t}`):(0,ey.jsx)("p",{children:VL(e.lines.map(e=>e.trim()).join(" "),r,n)},`block-${t}`)})})}function VK(e){return("assistant"===e.kind||"done"===e.kind)&&"模型没有返回内容。"===e.title.trim()&&!e.detail?.trim()}function VG(e){return("error"!==e.kind||"retried"!==e.status)&&!VK(e)}let VX=new Set(["thought","read","search","tool","plan","plan-task","plan-compact","browser"]),VY=ew.forwardRef(function({events:e,labels:t,running:n=!1,bottomInset:r=16,className:a,contentClassName:i,hasEarlier:o,loadingEarlier:l,onLoadEarlier:s,onOpenFile:c,deliverable:d,onOpenSubagent:u,onOpenPlan:f,onOpenSpec:h,onRecallUserMessage:m,onBranchAssistantMessage:p,onRetry:g,onApprovalDecision:v,onContinue:x,onActiveEventChange:y,onAtBottomChange:b},w){let j=ew.useRef(null),k=ew.useRef(!0),S=ew.useRef(!0),N=ew.useRef(b);N.current=b;let[C,M]=ew.useState(0),[E,O]=ew.useState(0),[P,A]=ew.useState({}),I=ew.useMemo(()=>e.filter(VG),[e]),z=ew.useMemo(()=>n?function(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r){if("user"===r.kind){t=t??r;break}if(void 0===t&&(t=r),"error"===r.kind&&"retried"===r.status)return{mode:"retry",retryAttempt:r.retryAttempt??1,retryMax:r.retryMax??1,errorDetail:(r.detail??r.title??"").trim()};if(("assistant"===r.kind||"done"===r.kind)&&r.isStreaming&&r.title.trim())return null;if(r.isStreaming||"running"===r.status)break}}return{mode:"working",label:function(e){switch(e?.kind){case"thought":return"正在思考中";case"change":return"正在编辑文件";case"subagent":return"正在分发子代理";default:return"正在处理中"}}(t)}}(e):null,[n,e]),T=ew.useMemo(()=>{let e,t=new Set;for(let n of I)"user"===n.kind?(e&&t.add(e),e=void 0):"assistant"!==n.kind&&"done"!==n.kind||VK(n)||(e=n.id);return!n&&e&&t.add(e),t},[I,n]),D=ew.useMemo(()=>(function(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!VX.has(r.kind)){t.push(r),n++;continue}let a=n,i=[];for(;a<e.length&&VX.has(e[a].kind);)i.push(e[a]),a++;a<e.length&&i.length>=2?t.push(function(e){let t=0,n=0,r=0,a=0,i=0;for(let o of e)"thought"===o.kind?a+=1:"read"===o.kind?t+=o.files?.length??1:"search"===o.kind?n+=1:"plan"===o.kind||"plan-task"===o.kind||"plan-compact"===o.kind?i+=1:r+=1;let o=[];a>0&&o.push(`思考 ${a} 次`),t>0&&o.push(`阅读 ${t} 个文件`),n>0&&o.push(`搜索 ${n} 次`),r>0&&o.push(`执行 ${r} 条命令`),i>0&&o.push(`更新计划 ${i} 次`);let l=o.length>0?`已${o.join(",")}`:`已完成 ${e.length} 步操作`;return{id:`toolgroup-${e[0].id}`,kind:"toolgroup",title:l,groupedEvents:e}}(i)):t.push(...i),n=a}return t})(I),[I]);ew.useLayoutEffect(()=>{let e=j.current;if(!e)return;function t(){O(e.clientHeight)}t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let R=ew.useMemo(()=>D.reduce((e,t,n)=>{var r;let a=P[Hv(t,n)]??("toolgroup"===(r=t).kind?30:"user"===r.kind?72:"assistant"===r.kind||"done"===r.kind?Math.max(42,Math.min(260,28+22*Math.ceil((r.title.length+(r.detail?.length??0))/68))):"read"===r.kind||"search"===r.kind||"tool"===r.kind?r.files?.length?28+26*Math.min(r.files.length,5):26:"subagent"===r.kind?r.subagents?.length?6+24*Math.min(r.subagents.length,6):42:"change"===r.kind?Math.max(42,Math.min(180,10+(r.files?.length??1)*43)):"approval"===r.kind?"pending"===r.status?140:72:"limit"===r.kind?80:"error"===r.kind?88:"plan-question"===r.kind||"plan-approval"===r.kind?r.detail?60:30:"plan"===r.kind||"plan-task"===r.kind||"plan-compact"===r.kind||"plan-answer"===r.kind||"plan-decision"===r.kind?28:r.detail?54:26);return e.rows.push({event:t,index:n,offset:e.totalHeight,height:a,autoOpen:("read"===t.kind||"tool"===t.kind)&&!!t.isStreaming||"read"===t.kind&&!D.slice(n+1).some(e=>"read"!==e.kind),showActions:T.has(t.id)}),e.totalHeight+=a,e},{rows:[],totalHeight:0}),[P,D,T]),_=R.rows.filter(e=>e.offset+e.height>=C-360&&e.offset<=C+Math.max(E,520)+360),L=40*!!z,$=R.totalHeight+Math.max(0,r)+L,F=ew.useRef(R.rows);F.current=R.rows,ew.useImperativeHandle(w,()=>({scrollToEvent:e=>{let t=j.current;if(!t)return!1;let n=F.current.find(t=>t.event.id===e);if(!n)return!1;k.current=!1;let r=Math.max(0,n.offset-12);return t.scrollTop=r,M(r),!0},scrollToBottom:()=>{let e=j.current;e&&(k.current=!0,e.scrollTop=e.scrollHeight,M(e.scrollTop),!0!==S.current&&(S.current=!0,N.current?.(!0)))}}),[]);let B=ew.useRef(void 0),V=ew.useCallback(()=>{let e;if(!y)return;let t=j.current;if(!t)return;let n=t.scrollTop+24;for(let t of F.current)if(t.offset<=n)e=t.event.id;else break;!e&&F.current.length>0&&(e=F.current[0].event.id),e!==B.current&&(B.current=e,y(e))},[y]),H=ew.useCallback(()=>{let e=j.current;if(!e)return;let t=e.scrollHeight-e.clientHeight,n=t-e.scrollTop,r=t<=1||n<96;r!==S.current&&(S.current=r,b?.(r))},[b]),U=ew.useRef(void 0),W=ew.useRef(0);ew.useLayoutEffect(()=>{let e=j.current,t=D[0]?.id,n=U.current,r=W.current;if(e&&void 0!==n&&t!==n&&D.some(e=>e.id===n)){let t=R.totalHeight-r;if(t>0){let n=e.scrollTop+t;e.scrollTop=n,M(n)}}U.current=t,W.current=R.totalHeight},[D,R.totalHeight]),ew.useLayoutEffect(()=>{let e=j.current;if(!e||!I.length||!k.current){V(),H();return}e.scrollTop=e.scrollHeight,M(e.scrollTop),V(),H()},[r,I.length,$,E,z,V,H]);let q=ew.useCallback((e,t)=>{A(n=>1>Math.abs((n[e]??0)-t)?n:{...n,[e]:t})},[]);return(0,ey.jsxs)("div",{ref:j,"data-slot":"agent-conversation-flow",className:(0,eI.cn)("min-h-0 flex-1 overflow-auto px-4 pt-4 opacity-100 transition-opacity duration-180 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden select-text [-webkit-touch-callout:default] [-webkit-user-select:text]",a),onScroll:function(){let e=j.current;e&&(k.current=e.scrollHeight-e.scrollTop-e.clientHeight<96,M(e.scrollTop),V(),H())},children:[o?(0,ey.jsx)("div",{className:"mx-auto mb-2 flex w-full max-w-[48rem] justify-center",children:(0,ey.jsx)("button",{type:"button",disabled:l,onClick:()=>s?.(),className:"rounded-full border border-border bg-popover px-3 py-1 text-xs text-muted-foreground shadow-sm transition-colors hover:bg-muted disabled:cursor-default disabled:opacity-60",children:l?"加载中…":"↑ 加载更早的消息"})}):null,(0,ey.jsxs)("div",{className:(0,eI.cn)("relative mx-auto min-h-full w-full max-w-[48rem]",i),style:{height:$},children:[_.map(e=>(0,ey.jsx)(VZ,{event:e.event,rowKey:Hv(e.event,e.index),offset:e.offset,autoOpen:e.autoOpen,showActions:e.showActions,labels:t,deliverable:d,onMeasure:q,onOpenFile:c,onOpenSubagent:u,onOpenPlan:f,onOpenSpec:h,onRecallUserMessage:m,onBranchAssistantMessage:p,onRetry:g,onApprovalDecision:v,onContinue:x},Hv(e.event,e.index))),z?(0,ey.jsx)("div",{className:"absolute inset-x-0 px-1 pt-1",style:{top:R.totalHeight},children:(0,ey.jsx)(VP,{mode:z.mode,label:"working"===z.mode?z.label:void 0,retryAttempt:"retry"===z.mode?z.retryAttempt:void 0,retryMax:"retry"===z.mode?z.retryMax:void 0,errorDetail:"retry"===z.mode?z.errorDetail:void 0})}):null]})]})}),VZ=ew.memo(function({event:e,rowKey:t,offset:n,autoOpen:r,showActions:a,labels:i,deliverable:o,onMeasure:l,onOpenFile:s,onOpenSubagent:c,onOpenPlan:d,onOpenSpec:u,onRecallUserMessage:f,onBranchAssistantMessage:h,onRetry:m,onApprovalDecision:p,onContinue:g}){let v=ew.useRef(null);return ew.useLayoutEffect(()=>{let e=v.current;if(!e)return;function n(){l(t,Math.ceil(e.getBoundingClientRect().height))}n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e.id,l,t]),(0,ey.jsx)("div",{ref:v,"data-index":e.id,className:"absolute inset-x-0 top-0",style:{transform:`translateY(${n}px)`},children:(0,ey.jsx)(V1,{event:e,autoOpen:r,showActions:a,labels:i,deliverable:o,onOpenFile:s,onOpenSubagent:c,onOpenPlan:d,onOpenSpec:u,onRecallUserMessage:f,onBranchAssistantMessage:h,onRetry:m,onContinue:g,onApprovalDecision:p})})});function VJ({attachment:e}){return(0,ey.jsx)("div",{className:"size-14 shrink-0 overflow-hidden rounded-md border border-border bg-muted/40",title:e.name,children:"image"===e.kind&&e.url?(0,ey.jsx)("img",{src:e.url,alt:e.name,className:"size-full object-cover"}):(0,ey.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-1 px-1 text-center",children:[(0,ey.jsx)(uC,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"w-full truncate text-[10px] font-semibold uppercase text-muted-foreground",children:e.ext?`.${e.ext}`:"FILE"})]})})}function VQ({event:e,labels:t,onRecallUserMessage:n}){let[r,a]=ew.useState(!1),[i,o]=ew.useState(!1),l=!e.forkInherited&&!!n;async function s(){try{await navigator.clipboard.writeText(e.title??""),o(!0),window.setTimeout(()=>o(!1),1500)}catch{}}return(0,ey.jsxs)("article",{className:"vtl-agent-event-row group","data-kind":e.kind,children:[e.title?(0,ey.jsx)("div",{className:"vtl-agent-user-message-wrap",children:(0,ey.jsx)("div",{className:"vtl-agent-user-message",children:e.title})}):null,e.attachments&&e.attachments.length>0?(0,ey.jsx)("div",{className:"mt-1.5 flex flex-wrap justify-end gap-2",children:e.attachments.map((e,t)=>(0,ey.jsx)(VJ,{attachment:e},t))}):null,(0,ey.jsx)(VE,{className:(0,eI.cn)("absolute top-1/2 right-2 -translate-y-1/2 transition-opacity","opacity-0 focus-within:opacity-100 group-hover:opacity-100 max-md:opacity-100",r&&"opacity-100"),children:(0,ey.jsxs)(bR,{open:r,onOpenChange:a,children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(VO,{type:"button","aria-label":t?.more??"更多操作",title:t?.more??"更多操作",children:(0,ey.jsx)(lY,{})})}),(0,ey.jsxs)(bZ,{align:"end",sideOffset:6,className:"min-w-44",children:[l?(0,ey.jsxs)(bJ,{onSelect:()=>n?.(e),children:[(0,ey.jsx)(Vj,{}),(0,ey.jsx)("span",{className:"flex-1",children:t?.recall??"回退对话到此处"})]}):null,(0,ey.jsxs)(bJ,{onSelect:e=>{e.preventDefault(),s()},children:[(0,ey.jsx)(lU,{}),(0,ey.jsx)("span",{className:"flex-1",children:i?"已复制":t?.copy??"复制提示词"})]})]})]})})]})}function V0({event:e,labels:t,showActions:n,deliverable:r,onBranchAssistantMessage:a}){let[i,o]=ew.useState(!1),l=e.detail?`${e.title}
|
|
21
21
|
|
|
22
|
-
${e.detail}`:e.title;async function s(){try{await navigator.clipboard.writeText(l??""),o(!0),window.setTimeout(()=>o(!1),1500)}catch{}}return(0,ey.jsxs)("article",{className:"vtl-agent-event-row group","data-kind":e.kind,children:[(0,ey.jsx)("div",{"data-streaming":e.isStreaming?"true":"false",children:(0,ey.jsx)(Vq,{content:l,isStreaming:e.isStreaming,deliverable:r})}),e.isStreaming||!n?null:(0,ey.jsxs)(VE,{className:(0,eI.cn)("mt-0.5 gap-0.5 transition-opacity","opacity-0 focus-within:opacity-100 group-hover:opacity-100 max-md:opacity-100"),children:[(0,ey.jsx)(VO,{type:"button","aria-label":t?.copyReply??"复制",title:t?.copyReply??"复制",onClick:()=>void s(),children:i?(0,ey.jsx)(mZ,{}):(0,ey.jsx)(lU,{})}),a?(0,ey.jsx)(VO,{type:"button","aria-label":t?.branch??"从此处分支对话",title:t?.branch??"从此处分支对话",onClick:()=>a?.(e),children:(0,ey.jsx)(Vb,{})}):null]})]})}let V1=ew.memo(function({event:e,autoOpen:t,showActions:n,labels:r,deliverable:a,onOpenFile:i,onOpenSubagent:o,onOpenPlan:l,onOpenSpec:s,onRecallUserMessage:c,onBranchAssistantMessage:d,onRetry:u,onApprovalDecision:f,onContinue:h}){return"approval"===e.kind?(0,ey.jsx)(V4,{event:e,onApprovalDecision:f}):"user"===e.kind?(0,ey.jsx)(VQ,{event:e,labels:r,onRecallUserMessage:c}):"assistant"===e.kind||"done"===e.kind?VK(e)?null:(0,ey.jsx)(V0,{event:e,labels:r,showActions:n,deliverable:a,onBranchAssistantMessage:d}):"toolgroup"===e.kind?(0,ey.jsx)(Hh,{event:e,labels:r,onOpenFile:i,onOpenSubagent:o}):("read"===e.kind||"search"===e.kind||"tool"===e.kind)&&(e.files?.length||e.detail?.trim())?(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsx)(Hm,{event:e,autoOpen:t,children:(0,ey.jsx)(V3,{event:e,onOpenFile:i})})}):"subagent"===e.kind&&e.subagents?.length?(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsx)(Hr,{event:e,onOpenSubagent:o})}):"change"===e.kind?(0,ey.jsx)(Hp,{event:e,onOpenFile:i}):"thought"===e.kind?(0,ey.jsx)(Hf,{event:e,labels:r}):"compression"===e.kind?(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":"compression",children:[(0,ey.jsxs)("div",{className:"vtl-agent-compression-divider",children:[(0,ey.jsx)("div",{className:"vtl-agent-compression-line"}),(0,ey.jsx)("span",{className:"vtl-agent-compression-label",children:e.title}),(0,ey.jsx)("div",{className:"vtl-agent-compression-line"})]}),e.detail&&(0,ey.jsx)("div",{className:"vtl-agent-compression-detail",children:e.detail})]}):"plan-answer"===e.kind||"plan-decision"===e.kind?(0,ey.jsx)(Hc,{event:e}):"plan"===e.kind||"plan-task"===e.kind||"plan-question"===e.kind||"plan-approval"===e.kind||"plan-compact"===e.kind?(0,ey.jsx)(Hs,{event:e,onOpenPlan:l,onOpenSpec:s}):"browser"===e.kind?(0,ey.jsx)(Hd,{event:e}):"limit"===e.kind?(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":"limit",children:(0,ey.jsxs)("div",{className:"vtl-agent-limit-card",children:[(0,ey.jsx)("span",{className:"vtl-agent-limit-title",children:e.title}),e.detail&&(0,ey.jsx)("span",{className:"vtl-agent-limit-detail",children:e.detail}),h&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"outline",className:"vtl-agent-limit-continue",onClick:h,children:[(0,ey.jsx)(Vw,{className:"mr-1.5 size-3"}),e.actionLabel??"继续"]})]})}):"error"===e.kind?(0,ey.jsx)(Hu,{event:e,onRetry:u}):(0,ey.jsx)(Ho,{event:e})}),V2={safe:{text:"安全",className:"vtl-approval-badge-safe"},normal:{text:"常规",className:"vtl-approval-badge-normal"},risky:{text:"风险",className:"vtl-approval-badge-risky"},dangerous:{text:"危险",className:"vtl-approval-badge-dangerous"}},V5={recursive_deletion:"递归删除",force_flag:"强制覆盖",network_access:"网络访问",system_modification:"系统修改",process_management:"进程管理",pipe_to_interpreter:"管道执行",dynamic_execution:"动态执行",git_destructive:"Git 破坏性操作",env_modification:"环境变量修改",registry_modification:"注册表修改",system_destructive:"系统破坏性",parse_error:"解析错误"};function V4({event:e,onApprovalDecision:t}){let n=function(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}(e.meta),r="pending"===e.status,a="done"===e.status,i="failed"===e.status,o=(n?V2[n.classification]:void 0)??{text:"常规",className:"vtl-approval-badge-normal"};return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":"approval",children:(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-approval-card",r&&"vtl-approval-pending",a&&"vtl-approval-approved",i&&"vtl-approval-rejected"),children:[(0,ey.jsxs)("div",{className:"vtl-approval-header",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("vtl-approval-badge",o.className),children:o.text}),(0,ey.jsx)("span",{className:"vtl-approval-label",children:r?"需要确认":a?"已放行":"已拒绝"}),n?.toolName&&(0,ey.jsx)("span",{className:"vtl-approval-tool",children:n.toolName})]}),(0,ey.jsx)("div",{className:"vtl-approval-command",children:(0,ey.jsx)("code",{children:e.title})}),e.detail&&!a&&!i&&(0,ey.jsx)("div",{className:"vtl-approval-reason",children:e.detail}),n?.riskFactors&&n.riskFactors.length>0&&r&&(0,ey.jsx)("div",{className:"vtl-approval-risks",children:n.riskFactors.map(e=>(0,ey.jsx)("span",{className:"vtl-approval-risk-tag",children:V5[e]??e},e))}),(a||i)&&e.detail&&(0,ey.jsx)("div",{className:"vtl-approval-resolved-detail",children:e.detail}),r&&t&&n&&(0,ey.jsxs)("div",{className:"vtl-approval-actions",children:[(0,ey.jsx)("button",{type:"button",className:"vtl-approval-btn vtl-approval-btn-approve",onClick:()=>t(n.approvalId,"approve"),children:"放行"}),(0,ey.jsx)("button",{type:"button",className:"vtl-approval-btn vtl-approval-btn-reject",onClick:()=>t(n.approvalId,"reject"),children:"拒绝"})]})]})})}function V3({event:e,onOpenFile:t}){if(e.shellMeta)return(0,ey.jsx)(V6,{event:e,onOpenFile:t});let n=function(e){var t;let n=e.files?.map((t,n)=>V7(e,t,n))??[],r=e.detail?.trim()&&("read"!==e.kind||e.actionLabel?.trim()==="探索")?VA(e.detail.replace(/\r\n/g,"\n")).trimEnd():"";return r?e.actionLabel?.trim()==="探索"?(t=function(e,t){let n,r,a,i,o=(n=[],r=[],a=[],i=null,t.split("\n").forEach((e,t)=>{let o=e.trim();if(!o)return;if(o.startsWith("hint:"))return void a.push({key:`hint-${t}`,label:o.replace(/^hint:\s*/,""),level:0,kind:"hint"});let l=Math.max(0,Math.floor((e.match(/^ */)?.[0].length??0)/2)),s=/[\\/]$/.test(o),c={key:`detail-${t}-${o}`,label:o.replace(/[\\/]+$/,""),level:l,kind:s?"folder":"file"};if(0===l){i={root:c,children:[]},n.push(i);return}i?i.children.push(c):r.push(c)}),{sections:n,orphans:r,hints:a});if(!o.sections.length&&!o.orphans.length)return[...e,...o.hints];let l=new Set,s=[];return e.forEach(e=>{s.push(e);let t=o.sections.findIndex((t,n)=>!l.has(n)&&V9(t.root.label)===V9(e.label));t>=0&&(l.add(t),s.push(...function(e,t,n){if(!t)return e;let r=[];return e.map(e=>{var a,i;let o,l=Math.max(0,e.level-1);return(r.length=l,r[l]=e.label,"file"!==e.kind)?e:{...e,file:{id:e.key,name:e.label,machineId:n,path:(a=t,i=r.slice(0,l+1),o=a.includes("\\")?"\\":"/",[a.replace(/[\\/]+$/,""),...i.map(e=>e.replace(/^[\\/]+|[\\/]+$/g,""))].filter(Boolean).join(o))}}})}(o.sections[t]?.children??[],e.file?.path,e.file?.machineId)))}),o.sections.forEach((e,t)=>{l.has(t)||s.push(e.root,...e.children)}),s.push(...o.orphans,...o.hints),s}(n,r)).map((e,n)=>{if(e.level<=0)return e;let r=Array.from({length:e.level-1},(e,r)=>He(t,n,r+1));return{...e,branch:{ancestorLines:r,isLast:!He(t,n,e.level)}}}):[...n,...r.split("\n").map((e,t)=>{let n=e.trim();return n?n.startsWith("hint:")?{key:`detail-hint-${t}`,label:n.replace(/^hint:\s*/,""),level:0,kind:"hint"}:{key:`detail-plain-${t}`,label:n,level:Math.max(0,Math.floor((e.match(/^ */)?.[0].length??0)/2)),kind:"plain"}:null}).filter(e=>!!e)]:n}(e);return n.length?(0,ey.jsx)("div",{className:"vtl-agent-tool-result","data-kind":e.actionLabel?.trim()==="探索"?"tree":e.kind,children:n.map(e=>(0,ey.jsx)(V8,{row:e,onOpenFile:t},e.key))}):null}function V6({event:e,onOpenFile:t}){let n=e.shellMeta,r=e.detail?VA(e.detail).trim():void 0,a=e.files?.map((t,n)=>V7(e,t,n))??[],i=ew.useCallback((e,t)=>{t.stopPropagation(),navigator.clipboard?.writeText(e)},[]),o="completed"===n.status||"done"===n.status?"shell-ok":"failed"===n.status||"timeout"===n.status?"shell-err":"shell-run",l=void 0!==n.exitCode&&null!==n.exitCode?0===n.exitCode:void 0;return(0,ey.jsxs)("div",{className:"vtl-agent-tool-result","data-kind":"shell",children:[(0,ey.jsxs)("div",{className:"vtl-shell-status-bar",children:[n.commandId?(0,ey.jsx)("button",{type:"button",className:"vtl-shell-chip",title:`命令 ID: ${n.commandId}
|
|
22
|
+
${e.detail}`:e.title;async function s(){try{await navigator.clipboard.writeText(l??""),o(!0),window.setTimeout(()=>o(!1),1500)}catch{}}return(0,ey.jsxs)("article",{className:"vtl-agent-event-row group","data-kind":e.kind,children:[(0,ey.jsx)("div",{"data-streaming":e.isStreaming?"true":"false",children:(0,ey.jsx)(Vq,{content:l,isStreaming:e.isStreaming,deliverable:r})}),e.isStreaming||!n?null:(0,ey.jsxs)(VE,{className:(0,eI.cn)("mt-0.5 gap-0.5 transition-opacity","opacity-0 focus-within:opacity-100 group-hover:opacity-100 max-md:opacity-100"),children:[(0,ey.jsx)(VO,{type:"button","aria-label":t?.copyReply??"复制",title:t?.copyReply??"复制",onClick:()=>void s(),children:i?(0,ey.jsx)(mZ,{}):(0,ey.jsx)(lU,{})}),a?(0,ey.jsx)(VO,{type:"button","aria-label":t?.branch??"从此处分支对话",title:t?.branch??"从此处分支对话",onClick:()=>a?.(e),children:(0,ey.jsx)(Vb,{})}):null]})]})}let V1=ew.memo(function({event:e,autoOpen:t,showActions:n,labels:r,deliverable:a,onOpenFile:i,onOpenSubagent:o,onOpenPlan:l,onOpenSpec:s,onRecallUserMessage:c,onBranchAssistantMessage:d,onRetry:u,onApprovalDecision:f,onContinue:h}){return"approval"===e.kind?(0,ey.jsx)(V4,{event:e,onApprovalDecision:f}):"user"===e.kind?(0,ey.jsx)(VQ,{event:e,labels:r,onRecallUserMessage:c}):"assistant"===e.kind||"done"===e.kind?VK(e)?null:(0,ey.jsx)(V0,{event:e,labels:r,showActions:n,deliverable:a,onBranchAssistantMessage:d}):"toolgroup"===e.kind?(0,ey.jsx)(Hh,{event:e,labels:r,onOpenFile:i,onOpenSubagent:o}):("read"===e.kind||"search"===e.kind||"tool"===e.kind)&&(e.files?.length||e.detail?.trim())?(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsx)(Hm,{event:e,autoOpen:t,children:(0,ey.jsx)(V3,{event:e,onOpenFile:i})})}):"subagent"===e.kind&&e.subagents?.length?(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsx)(Hr,{event:e,onOpenSubagent:o})}):"change"===e.kind?(0,ey.jsx)(Hp,{event:e,onOpenFile:i}):"thought"===e.kind?(0,ey.jsx)(Hf,{event:e,labels:r}):"compression"===e.kind?(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":"compression",children:[(0,ey.jsxs)("div",{className:"vtl-agent-compression-divider",children:[(0,ey.jsx)("div",{className:"vtl-agent-compression-line"}),(0,ey.jsx)("span",{className:"vtl-agent-compression-label",children:e.title}),(0,ey.jsx)("div",{className:"vtl-agent-compression-line"})]}),e.detail&&(0,ey.jsx)("div",{className:"vtl-agent-compression-detail",children:e.detail})]}):"plan-answer"===e.kind||"plan-decision"===e.kind?(0,ey.jsx)(Hc,{event:e}):"plan"===e.kind||"plan-task"===e.kind||"plan-question"===e.kind||"plan-approval"===e.kind||"plan-compact"===e.kind?(0,ey.jsx)(Hs,{event:e,onOpenPlan:l,onOpenSpec:s}):"browser"===e.kind?(0,ey.jsx)(Hd,{event:e,deliverable:a}):"limit"===e.kind?(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":"limit",children:(0,ey.jsxs)("div",{className:"vtl-agent-limit-card",children:[(0,ey.jsx)("span",{className:"vtl-agent-limit-title",children:e.title}),e.detail&&(0,ey.jsx)("span",{className:"vtl-agent-limit-detail",children:e.detail}),h&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"outline",className:"vtl-agent-limit-continue",onClick:h,children:[(0,ey.jsx)(Vw,{className:"mr-1.5 size-3"}),e.actionLabel??"继续"]})]})}):"error"===e.kind?(0,ey.jsx)(Hu,{event:e,onRetry:u}):(0,ey.jsx)(Ho,{event:e})}),V2={safe:{text:"安全",className:"vtl-approval-badge-safe"},normal:{text:"常规",className:"vtl-approval-badge-normal"},risky:{text:"风险",className:"vtl-approval-badge-risky"},dangerous:{text:"危险",className:"vtl-approval-badge-dangerous"}},V5={recursive_deletion:"递归删除",force_flag:"强制覆盖",network_access:"网络访问",system_modification:"系统修改",process_management:"进程管理",pipe_to_interpreter:"管道执行",dynamic_execution:"动态执行",git_destructive:"Git 破坏性操作",env_modification:"环境变量修改",registry_modification:"注册表修改",system_destructive:"系统破坏性",parse_error:"解析错误"};function V4({event:e,onApprovalDecision:t}){let n=function(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}(e.meta),r="pending"===e.status,a="done"===e.status,i="failed"===e.status,o=(n?V2[n.classification]:void 0)??{text:"常规",className:"vtl-approval-badge-normal"};return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":"approval",children:(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-approval-card",r&&"vtl-approval-pending",a&&"vtl-approval-approved",i&&"vtl-approval-rejected"),children:[(0,ey.jsxs)("div",{className:"vtl-approval-header",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("vtl-approval-badge",o.className),children:o.text}),(0,ey.jsx)("span",{className:"vtl-approval-label",children:r?"需要确认":a?"已放行":"已拒绝"}),n?.toolName&&(0,ey.jsx)("span",{className:"vtl-approval-tool",children:n.toolName})]}),(0,ey.jsx)("div",{className:"vtl-approval-command",children:(0,ey.jsx)("code",{children:e.title})}),e.detail&&!a&&!i&&(0,ey.jsx)("div",{className:"vtl-approval-reason",children:e.detail}),n?.riskFactors&&n.riskFactors.length>0&&r&&(0,ey.jsx)("div",{className:"vtl-approval-risks",children:n.riskFactors.map(e=>(0,ey.jsx)("span",{className:"vtl-approval-risk-tag",children:V5[e]??e},e))}),(a||i)&&e.detail&&(0,ey.jsx)("div",{className:"vtl-approval-resolved-detail",children:e.detail}),r&&t&&n&&(0,ey.jsxs)("div",{className:"vtl-approval-actions",children:[(0,ey.jsx)("button",{type:"button",className:"vtl-approval-btn vtl-approval-btn-approve",onClick:()=>t(n.approvalId,"approve"),children:"放行"}),(0,ey.jsx)("button",{type:"button",className:"vtl-approval-btn vtl-approval-btn-reject",onClick:()=>t(n.approvalId,"reject"),children:"拒绝"})]})]})})}function V3({event:e,onOpenFile:t}){if(e.shellMeta)return(0,ey.jsx)(V6,{event:e,onOpenFile:t});let n=function(e){var t;let n=e.files?.map((t,n)=>V7(e,t,n))??[],r=e.detail?.trim()&&("read"!==e.kind||e.actionLabel?.trim()==="探索")?VA(e.detail.replace(/\r\n/g,"\n")).trimEnd():"";return r?e.actionLabel?.trim()==="探索"?(t=function(e,t){let n,r,a,i,o=(n=[],r=[],a=[],i=null,t.split("\n").forEach((e,t)=>{let o=e.trim();if(!o)return;if(o.startsWith("hint:"))return void a.push({key:`hint-${t}`,label:o.replace(/^hint:\s*/,""),level:0,kind:"hint"});let l=Math.max(0,Math.floor((e.match(/^ */)?.[0].length??0)/2)),s=/[\\/]$/.test(o),c={key:`detail-${t}-${o}`,label:o.replace(/[\\/]+$/,""),level:l,kind:s?"folder":"file"};if(0===l){i={root:c,children:[]},n.push(i);return}i?i.children.push(c):r.push(c)}),{sections:n,orphans:r,hints:a});if(!o.sections.length&&!o.orphans.length)return[...e,...o.hints];let l=new Set,s=[];return e.forEach(e=>{s.push(e);let t=o.sections.findIndex((t,n)=>!l.has(n)&&V9(t.root.label)===V9(e.label));t>=0&&(l.add(t),s.push(...function(e,t,n){if(!t)return e;let r=[];return e.map(e=>{var a,i;let o,l=Math.max(0,e.level-1);return(r.length=l,r[l]=e.label,"file"!==e.kind)?e:{...e,file:{id:e.key,name:e.label,machineId:n,path:(a=t,i=r.slice(0,l+1),o=a.includes("\\")?"\\":"/",[a.replace(/[\\/]+$/,""),...i.map(e=>e.replace(/^[\\/]+|[\\/]+$/g,""))].filter(Boolean).join(o))}}})}(o.sections[t]?.children??[],e.file?.path,e.file?.machineId)))}),o.sections.forEach((e,t)=>{l.has(t)||s.push(e.root,...e.children)}),s.push(...o.orphans,...o.hints),s}(n,r)).map((e,n)=>{if(e.level<=0)return e;let r=Array.from({length:e.level-1},(e,r)=>He(t,n,r+1));return{...e,branch:{ancestorLines:r,isLast:!He(t,n,e.level)}}}):[...n,...r.split("\n").map((e,t)=>{let n=e.trim();return n?n.startsWith("hint:")?{key:`detail-hint-${t}`,label:n.replace(/^hint:\s*/,""),level:0,kind:"hint"}:{key:`detail-plain-${t}`,label:n,level:Math.max(0,Math.floor((e.match(/^ */)?.[0].length??0)/2)),kind:"plain"}:null}).filter(e=>!!e)]:n}(e);return n.length?(0,ey.jsx)("div",{className:"vtl-agent-tool-result","data-kind":e.actionLabel?.trim()==="探索"?"tree":e.kind,children:n.map(e=>(0,ey.jsx)(V8,{row:e,onOpenFile:t},e.key))}):null}function V6({event:e,onOpenFile:t}){let n=e.shellMeta,r=e.detail?VA(e.detail).trim():void 0,a=e.files?.map((t,n)=>V7(e,t,n))??[],i=ew.useCallback((e,t)=>{t.stopPropagation(),navigator.clipboard?.writeText(e)},[]),o="completed"===n.status||"done"===n.status?"shell-ok":"failed"===n.status||"timeout"===n.status?"shell-err":"shell-run",l=void 0!==n.exitCode&&null!==n.exitCode?0===n.exitCode:void 0;return(0,ey.jsxs)("div",{className:"vtl-agent-tool-result","data-kind":"shell",children:[(0,ey.jsxs)("div",{className:"vtl-shell-status-bar",children:[n.commandId?(0,ey.jsx)("button",{type:"button",className:"vtl-shell-chip",title:`命令 ID: ${n.commandId}
|
|
23
23
|
点击复制`,onClick:e=>i(n.commandId,e),children:n.commandId}):null,n.logId?(0,ey.jsx)("button",{type:"button",className:"vtl-shell-chip",title:`日志 ID: ${n.logId}
|
|
24
24
|
点击复制`,onClick:e=>i(n.logId,e),children:n.logId.replace(/^artifacts\//,"")}):null,n.cwd?(0,ey.jsx)("button",{type:"button",className:"vtl-shell-chip vtl-shell-chip-cwd",title:`工作目录: ${n.cwd}
|
|
25
|
-
点击复制`,onClick:e=>i(n.cwd,e),children:n.cwd}):null,(0,ey.jsx)("span",{className:"vtl-shell-spacer"}),n.status?(0,ey.jsx)("span",{className:`vtl-shell-badge ${o}`,children:n.status}):null,void 0!==l?(0,ey.jsxs)("span",{className:`vtl-shell-badge ${l?"shell-ok":"shell-err"}`,children:["exit ",n.exitCode]}):null,n.durationMs?(0,ey.jsx)("span",{className:"vtl-shell-badge shell-time",children:n.durationMs>=1e3?`${(n.durationMs/1e3).toFixed(1)}s`:`${n.durationMs}ms`}):null]}),r?(0,ey.jsx)("pre",{className:"vtl-shell-output",children:r}):null,a.length>0?(0,ey.jsx)("div",{className:"vtl-agent-tool-result","data-kind":"tool",children:a.map(e=>(0,ey.jsx)(V8,{row:e,onOpenFile:t},e.key))}):null]})}function V8({row:e,onOpenFile:t}){let n=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("span",{className:"vtl-agent-tool-row-tree","aria-hidden":"true","data-level":e.level,children:[e.branch?.ancestorLines.map((e,t)=>(0,ey.jsx)("span",{className:"vtl-agent-tool-row-tree-ancestor","data-active":e?"true":void 0},`ancestor-${t}`)),e.level>0?(0,ey.jsx)("span",{className:"vtl-agent-tool-row-tree-elbow","data-last":e.branch?.isLast?"true":void 0}):null,(0,ey.jsx)("span",{className:"vtl-agent-tool-row-icon",children:"folder"===e.kind?"▾":""})]}),(0,ey.jsx)("span",{className:"vtl-agent-tool-row-label",children:e.label}),e.meta?(0,ey.jsx)("em",{children:e.meta}):null]}),r={"--tool-tree-indent":`${13*Math.min(e.level,8)}px`,"--tool-tree-level":Math.min(e.level,8)};return e.file&&"file"===e.kind?(0,ey.jsx)("button",{type:"button",className:"vtl-agent-tool-row","data-kind":e.kind,style:r,onClick:()=>t?.(e.file),children:n}):(0,ey.jsx)("div",{className:"vtl-agent-tool-row","data-kind":e.kind,style:r,children:n})}function V7(e,t,n){let r=e.actionLabel?.trim()==="探索"||t.meta?.toLowerCase().startsWith("depth")||/[\\/]$/.test(t.name)||!!(t.path&&/[\\/]$/.test(t.path)),a=Hg(t.name||t.path||"untitled");return{key:t.id??`file-${n}-${t.path??t.name}`,label:a,level:0,kind:r?"folder":"file",meta:t.lines??t.meta,file:t}}function V9(e){return Hg(e.replace(/[\\/]+$/,"")).toLowerCase()}function He(e,t,n){for(let r=t+1;r<e.length;r+=1){let t=e[r]?.level??0;if(t<n)break;if(t===n)return!0}return!1}let Ht={explore:{label:"探索",color:"text-sky-600 dark:text-sky-400",Icon:Vy},workflow:{label:"工作流",color:"text-violet-600 dark:text-violet-400",Icon:uP},operator:{label:"操作员",color:"text-pink-600 dark:text-pink-400",Icon:uO},custom:{label:"自定义",color:"text-amber-600 dark:text-amber-400",Icon:ub}};function Hn(e){return Ht[e??""]??{label:"子代理",color:"text-muted-foreground",Icon:ub}}function Hr({event:e,onOpenSubagent:t}){return(0,ey.jsx)("div",{className:"grid gap-2",children:e.subagents?.map(n=>(0,ey.jsx)(Ha,{subagent:n,event:e,onOpenSubagent:t},n.id||n.title))})}function Ha({subagent:e,event:t,onOpenSubagent:n}){let[r,a]=ew.useState(!1),i=Hn(e.subagentType),o=e.status??(e.isRunning?"running":"done"),l=!!e.isRunning||"running"===o,s="failed"===o,c=e.name||`${i.label}子代理`,d=(e.result??t.detail??"").trim(),u=i.Icon,f=!!e.inline;return(0,ey.jsxs)("section",{className:(0,eI.cn)("overflow-hidden rounded-lg border bg-card/60",s&&"border-destructive/40"),"data-subagent-card":!0,"data-running":l?"true":void 0,children:[f?(0,ey.jsxs)("div",{className:"flex w-full items-center gap-2.5 px-3 py-2 text-left",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("flex size-6 shrink-0 items-center justify-center rounded-md bg-muted/60",i.color),children:(0,ey.jsx)(u,{className:"size-3.5"})}),(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] font-medium",children:[(0,ey.jsx)("span",{className:"truncate",children:c}),(0,ey.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 py-px text-[10px] font-normal text-muted-foreground",children:i.label})]}),e.title?(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.title}):null]}),(0,ey.jsx)(Hi,{status:o,running:l})]}):(0,ey.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors hover:bg-accent/40",onClick:()=>n?.(e,t),title:"打开子代理对话",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("flex size-6 shrink-0 items-center justify-center rounded-md bg-muted/60",i.color),children:(0,ey.jsx)(u,{className:"size-3.5"})}),(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] font-medium",children:[(0,ey.jsx)("span",{className:"truncate",children:c}),(0,ey.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 py-px text-[10px] font-normal text-muted-foreground",children:i.label})]}),e.title?(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.title}):null]}),(0,ey.jsx)(Hi,{status:o,running:l})]}),d?(0,ey.jsx)("div",{className:"border-t",children:f?(0,ey.jsx)("div",{className:"max-h-72 overflow-auto whitespace-pre-wrap px-3 py-2 text-xs leading-relaxed text-foreground/80",children:d}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-3 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:()=>a(e=>!e),"aria-expanded":r,children:[(0,ey.jsx)(mQ,{className:(0,eI.cn)("size-3 transition-transform",r&&"rotate-90")}),r?"收起结果":"查看结果"]}),r?(0,ey.jsx)("div",{className:"max-h-72 overflow-auto whitespace-pre-wrap px-3 pb-3 text-xs leading-relaxed text-foreground/80",children:d}):null]})}):null]})}function Hi({status:e,running:t}){return t?(0,ey.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"failed"===e?(0,ey.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-destructive",children:[(0,ey.jsx)(hM,{className:"size-3"}),"失败"]}):(0,ey.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-emerald-600 dark:text-emerald-500",children:[(0,ey.jsx)(eO,{className:"size-3"}),"完成"]})}function Ho({event:e}){return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsxs)("p",{className:"vtl-agent-action-line",children:[e.actionLabel?(0,ey.jsx)("strong",{children:e.actionLabel}):null,e.title,e.meta?(0,ey.jsx)("em",{children:e.meta}):null]})})}function Hl(e){return e.replace(/^(?:[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}✅❌✓▶️]+)\s*/u,"").trim()}function Hs({event:e,onOpenPlan:t,onOpenSpec:n}){let r="plan-question"===e.kind||"plan-approval"===e.kind,[a,i]=ew.useState(r),{category:o,action:l}=function(e){let t=Hl(e.title);if("plan-task"===e.kind){let e=t;return t.includes("活动任务")?e="更新活动任务":(t.includes("任务已更新")||"任务已更新"===t)&&(e="更新任务状态"),{category:"任务",action:e}}if("plan-question"===e.kind)return{category:"计划",action:"向用户提问"};if("plan-approval"===e.kind)return{category:"计划",action:"等待批准"};if("plan-compact"===e.kind)return{category:"计划",action:"压缩上下文"};let n=t;return t.includes("编译")?n="编译计划树":t.includes("规范")?n="更新规范":t.includes("计划")&&(n="更新计划"),{category:"计划",action:n}}(e),s=e.specPath?()=>n?.(e.specPath):void 0,c=!s&&("plan"===e.kind||"plan-approval"===e.kind||e.planDocPath)?t:void 0,d=s??c,u=e.applied??[],f=e.questions??[],h=e.detail?.trim()??"",m=!!h||u.length>0||f.length>0||!!d||"number"==typeof e.keepFileRefs;return(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>m&&i(e=>!e),"aria-expanded":a,children:[(0,ey.jsx)("span",{children:o}),l]}),m?(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",a?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsxs)("div",{className:"mt-1 space-y-1.5 border-l border-border/60 pl-2 text-xs text-muted-foreground",children:[f.length>0?(0,ey.jsx)("ul",{className:"space-y-1",children:f.map((t,n)=>(0,ey.jsxs)("li",{children:[(0,ey.jsx)("div",{className:"text-foreground/80",children:t.text}),t.options&&t.options.length>0?(0,ey.jsx)("div",{className:"mt-0.5 flex flex-wrap gap-1",children:t.options.map((t,r)=>(0,ey.jsx)("span",{className:"rounded border border-border/60 px-1.5 py-0.5",children:t},`${e.id}-q-${n}-o-${r}`))}):null]},t.id||`${e.id}-q-${n}`))}):h?(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words",children:h}):null,"number"==typeof e.keepFileRefs?(0,ey.jsx)("p",{children:`保留 ${e.keepFileRefs} 处文件引用`}):null,u.length>0?(0,ey.jsx)("ul",{className:"space-y-0.5",children:u.map((t,n)=>(0,ey.jsxs)("li",{className:"truncate",children:["✓ ",t]},`${e.id}-applied-${n}`))}):null,d?(0,ey.jsx)("button",{type:"button",className:"text-sky-teal hover:underline",onClick:d,children:s?"查看规范":"查看计划"}):null]})})}):null]})}function Hc({event:e}){let t=Hl(e.title);return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsxs)("p",{className:"vtl-agent-action-line",children:[t,e.detail?.trim()?(0,ey.jsx)("em",{children:e.detail.trim()}):null]})})}function Hd({event:e}){let[t,n]=ew.useState(!1),{category:r,action:a}=function(e){let t=Hl(e.title);for(let[e,n]of[[/^(navigate|go_to|goto)\b/i,"导航"],[/^click\b/i,"点击"],[/^(type|input)\b/i,"输入"],[/^scroll\b/i,"滚动"],[/^(key|send_keys)\b/i,"按键"],[/^(back|go_back)\b/i,"返回"],[/^find\b/i,"查找"],[/^extract\b/i,"提取"],[/^screenshot\b/i,"截图"],[/^(switch_tab|switch)\b/i,"切换标签"],[/^close_tab\b/i,"关闭标签"],[/^tabs?\b/i,"标签页"],[/^state\b/i,"读取状态"]])if(e.test(t)){let r=t.replace(e,"").trim();return{category:"浏览",action:r?`${n} ${r}`:n}}return{category:"浏览",action:t}}(e),i=e.detail?.trim()??"",o=!!i;return(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>o&&n(e=>!e),"aria-expanded":t,children:[(0,ey.jsx)("span",{children:r}),a]}),o?(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",t?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsx)("div",{className:"mt-1 space-y-1.5 border-l border-border/60 pl-2 text-xs text-muted-foreground",children:(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words",children:i})})})}):null]})}function Hu({event:e,onRetry:t}){return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsxs)("div",{className:"vtl-agent-error-card",children:[(0,ey.jsxs)("div",{className:"vtl-agent-error-card-body",children:[(0,ey.jsxs)("span",{children:[e.meta?(0,ey.jsx)("strong",{children:e.meta}):null,e.title]}),e.detail?(0,ey.jsx)("p",{children:e.detail}):null]}),e.retryable&&t?(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-error-retry",onClick:()=>t(e),children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]}):null]})})}function Hf({event:e,labels:t}){let[n,r]=ew.useState(!!e.isStreaming),a=!!e.detail?.trim(),i=e.title||t?.thinking||"思考中";return ew.useEffect(()=>{r(!!e.isStreaming)},[e.isStreaming]),(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-thought-line","data-streaming":e.isStreaming?"true":"false","aria-expanded":n,onClick:()=>a&&r(e=>!e),children:[(0,ey.jsx)("span",{children:i}),e.meta?(0,ey.jsx)("em",{children:e.meta}):null]}),a?(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",n?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsx)("div",{className:"vtl-agent-thought-detail",children:(0,ey.jsx)(Vq,{content:e.detail??"",isStreaming:e.isStreaming})})})}):null]})}function Hh({event:e,labels:t,onOpenFile:n,onOpenSubagent:r}){let[a,i]=ew.useState(!1),o=e.groupedEvents??[];return(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":"toolgroup",children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>i(e=>!e),"aria-expanded":a,children:[(0,ey.jsx)("span",{children:a?"收起":"展开"}),e.title]}),(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity] duration-200 ease-out",a?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsx)("div",{className:"mt-1 space-y-0.5 border-l border-border/60 pl-2",children:o.map((e,a)=>(0,ey.jsx)(V1,{event:e,autoOpen:!1,labels:t,onOpenFile:n,onOpenSubagent:r},Hv(e,a)))})})})]})}function Hm({event:e,autoOpen:t,children:n}){let[r,a]=ew.useState(t),i=ew.useRef(null);return ew.useEffect(()=>{a(t)},[t]),ew.useEffect(()=>{if(!r||!t||!i.current)return;let e=i.current.querySelector(".vtl-agent-tool-result");e&&(e.scrollTop=e.scrollHeight)},[t,n,e.detail,e.files?.length,r]),(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>a(e=>!e),"aria-expanded":r,children:[(0,ey.jsx)("span",{children:e.actionLabel?e.actionLabel:null}),e.title]}),(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",r?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{ref:i,className:"min-h-0 overflow-hidden",children:n})})]})}function Hp({event:e,onOpenFile:t}){let n=e.files?.length?e.files:[{id:e.id,name:e.title,diff:e.diff,kind:"diff",mutationId:e.mutationId,additions:e.additions,deletions:e.deletions}];return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsx)("div",{className:"vtl-agent-change-stack",children:n.map((r,a)=>{let i=r.additions??(1===n.length?e.additions:void 0),o=r.deletions??(1===n.length?e.deletions:void 0),l=!!(r.diff??e.diff);return(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-change-row","data-streaming":e.isStreaming?"true":void 0,disabled:!l,onClick:()=>{l&&t?.({...r,diff:r.diff??e.diff,kind:r.kind??"diff",mutationId:r.mutationId??e.mutationId})},children:[(0,ey.jsxs)("span",{children:[e.actionLabel?(0,ey.jsx)("strong",{children:e.actionLabel}):null,Hg(r.name||r.path||e.title)]}),"number"==typeof i||"number"==typeof o?(0,ey.jsxs)("em",{children:["number"==typeof i?(0,ey.jsxs)("b",{"data-kind":"add",children:["+",i]}):null,"number"==typeof o?(0,ey.jsxs)("b",{"data-kind":"delete",children:["-",o]}):null]}):e.meta?(0,ey.jsx)("em",{children:e.meta}):null]},r.id??`${e.id}-${r.path??r.name}-${a}`)})})})}function Hg(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Hv(e,t){return e.id||`index-${t}`}let Hx="max-w-[42.5rem]",Hy={recall:"回退对话到此处",branch:"从此处分支对话",copy:"复制提示词",copyReply:"复制",more:"更多操作",expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"},Hb=ew.forwardRef(function(e,t){return(0,ey.jsx)(Hw,{...e,handleRef:t})});function Hw({handleRef:e,className:t,composerClassName:n,flowContentClassName:r,initialEvents:a,events:i,hasEarlier:o,loadingEarlier:l,onLoadEarlier:s,models:c,modelId:d,permissionModeId:u,running:f,disabled:h,onEventsChange:m,onModelChange:p,onPermissionModeChange:g,onSubmit:v,attachments:x,onAttachmentsChange:y,onStop:b,onOpenFile:w,deliverable:j,onOpenSubagent:k,onOpenPlan:S,onOpenSpec:N,planPromptBar:C,onRetry:M,onApprovalDecision:E,onContinue:O,onRecallUserMessage:P,onBranchAssistantMessage:A,onActiveEventChange:I,composerValue:z,onComposerValueChange:T,promptHistory:D,queuedMessages:R,onQueuedMessagesChange:_,onNudge:L,contextUsage:$}){let F=i??a??Vx,[B,V]=ew.useState(F),H=ew.useRef(0),U=ew.useRef(F),W=ew.useRef([]),q=ew.useRef(null),K=ew.useRef(null),G=ew.useRef(null),X=ew.useRef([]),[Y,Z]=ew.useState(168),[J,Q]=ew.useState(!0),ee=ew.useId().replace(/[^a-zA-Z0-9_-]/g,""),et=i??B,en=ew.useCallback(e=>{k?.(e)},[k]);function er(e){let t=e(U.current);U.current=t,void 0===i&&V(t),m?.(t)}function ea(e,t){let n=window.setTimeout(t,e);W.current.push(n)}return ew.useImperativeHandle(e,()=>({scrollToEvent:e=>{let t=K.current;if(!t||!e)return;let n=t.querySelector('[data-slot="agent-conversation-flow"]');if(!n)return;X.current.forEach(e=>window.clearTimeout(e)),X.current=[];let r=`[data-index="${(window.CSS?.escape??function(e){return e.replace(/["\\]/g,"\\$&")})(e)}"]`,a=["rounded-lg","ring-2","ring-primary/60","ring-offset-2","ring-offset-background","transition-shadow","duration-300"],i=e=>{e.scrollIntoView({behavior:"smooth",block:"start"}),e.classList.add(...a);let t=window.setTimeout(()=>{e.classList.remove(...a)},1600);X.current.push(t)},o=n.querySelector(r);if(o)return void i(o);G.current?.scrollToEvent(e);let l=0,s=()=>{let e=n.querySelector(r);if(e)return void i(e);if((l+=1)<8){let e=window.setTimeout(s,60);X.current.push(e)}},c=window.setTimeout(s,60);X.current.push(c)}}),[]),ew.useEffect(()=>()=>{X.current.forEach(e=>window.clearTimeout(e)),X.current=[]},[]),ew.useLayoutEffect(()=>{let e=q.current;if(!e)return;function t(){Z(Math.ceil(e.getBoundingClientRect().height))}t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),ew.useEffect(()=>{U.current=et},[et]),ew.useEffect(()=>()=>{W.current.forEach(e=>window.clearTimeout(e)),W.current=[]},[]),(0,ey.jsxs)("section",{ref:K,className:(0,eI.cn)("vtl-agent-conversation-panel relative flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-transparent",t),children:[(0,ey.jsx)(VY,{ref:G,events:et,running:f,hasEarlier:o,loadingEarlier:l,onLoadEarlier:s,bottomInset:Y+16,contentClassName:(0,eI.cn)(Hx,n,r),onOpenFile:w,deliverable:j,onOpenSubagent:en,onOpenPlan:S,onOpenSpec:N,onRetry:M,onApprovalDecision:E,onContinue:O,onRecallUserMessage:P,onBranchAssistantMessage:A,onActiveEventChange:I,onAtBottomChange:Q,labels:Hy}),(0,ey.jsx)("button",{type:"button","aria-label":"滚动到底部",onClick:()=>G.current?.scrollToBottom(),style:{bottom:Y+12},className:(0,eI.cn)("pointer-events-auto absolute left-1/2 z-30 -translate-x-1/2 flex size-9 items-center justify-center rounded-full border bg-popover text-popover-foreground shadow-md transition-opacity hover:bg-muted",J&&"pointer-events-none opacity-0"),children:(0,ey.jsx)(jO,{className:"size-4"})}),(0,ey.jsx)("div",{ref:q,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center px-4 pb-4",children:(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-agent-composer-dock pointer-events-auto relative w-full",Hx,n),children:[C,(0,ey.jsx)(Vc,{className:"relative z-10 w-full",submitOnEnter:!0,value:z,onValueChange:T,promptHistory:D,running:f,disabled:h,minRows:1,maxRows:8,permissionModeId:u,onPermissionModeChange:e=>g?.(e),models:c,modelId:d,onModelChange:e=>p?.(e),queuedMessages:R,onQueuedMessagesChange:_,onNudge:L,attachments:x,onAttachmentsChange:y,contextUsage:$,labels:{placeholder:"请问",mode:"模式",model:"模型",attach:"添加上下文",removeChip:"移除上下文",removeAttachment:"移除附件",queuedMessage:"待发送消息",guideQueuedMessage:"引导",removeQueuedMessage:"移除待发送消息",moreQueuedMessageActions:"更多待发送消息操作",contextUsage:"上下文用量",contextUsed:"已用",contextTokenSummary:"已用 {used} / {total}",toolCalls:"输入 token",userMessages:"输出 token",otherContext:"已完成轮次",compressContext:"压缩上下文",compressPrecise:"精确",compressExtreme:"极致",send:"发送",stop:"停止"},onSubmit:function(e){let t,n,r=e.value.trim(),a=(e.attachments?.length??0)>0;if(!r&&!a)return;if(v)return void v({value:r,modeId:"agent",modelId:e.modelId??d,attachments:e.attachments});H.current+=1;let i=`${ee}-${H.current}`,o=`user-${i}`;er(e=>[...e,{id:o,kind:"user",title:r}]),t=Vv(i),n=180,t.forEach(e=>{if("done"===e.kind){var t,r,a;let i,o,l=e.title;ea(n,()=>{er(t=>[...t,{...e,title:"",isStreaming:!0,status:"running"}])}),t=e.id,r=l,a=n+120,i=Math.max(4,Math.ceil(r.length/36)),o=0,ea(a,function e(){o=Math.min(r.length,o+i),er(e=>e.map(e=>e.id===t?{...e,title:r.slice(0,o),isStreaming:o<r.length,status:o<r.length?"running":"done"}:e)),o<r.length&&ea(42,e)}),n+=Math.min(2200,Math.max(900,18*l.length))+260;return}ea(n,()=>{er(t=>[...t,e])}),n+="thought"===e.kind?520:300})},onStop:b})]})})]})}function Hj({ownerMachineId:e,title:t,resolvedLocation:n,className:r}){let a=function(e){let{machines:t}=vj();return ew.useMemo(()=>{if(sC(e))return"本机";let n=t.find(t=>t.id===e);return n?n.isLocal?"本机":n.name:e??"本机"},[t,e])}(e),i=n??a,o=t.trim()||"新 Agent 对话";return(0,ey.jsxs)("div",{className:(0,eI.cn)("flex h-9 shrink-0 items-center gap-1.5 border-b px-3 text-sm",r),children:[(0,ey.jsx)(eP,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,ey.jsx)("span",{className:"shrink-0 truncate text-muted-foreground",title:i,children:i}),(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":"true",children:"/"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",title:o,children:o})]})}function Hk({rounds:e,onJumpToRound:t,activeRunId:n,className:r}){let[a,i]=ew.useState(!1),o=ew.useRef(null),[l,s]=ew.useState(304);if(ew.useEffect(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&i(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]),ew.useLayoutEffect(()=>{if(!a)return;let e=()=>{let e=o.current;if(!e)return;let t=e.getBoundingClientRect().left;s(Math.max(120,Math.min(304,window.innerWidth-t-16)))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]),!e.length)return null;let c=e.length>24?e.slice(e.length-24):e;return(0,ey.jsxs)("div",{ref:o,className:(0,eI.cn)("relative",r),children:[(0,ey.jsx)("button",{type:"button","aria-label":"轮次时间轴",title:`轮次时间轴 \xb7 共 ${e.length} 轮`,onClick:()=>i(e=>!e),className:(0,eI.cn)("group flex flex-col items-start gap-[7px] rounded-md px-1.5 py-2 outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted/50",a&&"invisible"),children:c.map(e=>{let t=!!n&&e.runId===n;return(0,ey.jsx)("span",{"aria-hidden":"true",className:(0,eI.cn)("h-[3px] rounded-full transition-all duration-200",t?"w-5 bg-foreground/85":"w-2.5 bg-muted-foreground/30 group-hover:bg-muted-foreground/55")},e.runId)})}),a?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),(0,ey.jsx)("div",{style:{width:l},className:"absolute left-0 top-0 z-50 max-h-[20rem] overflow-y-auto overflow-x-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md vtl-scrollbar-hidden",children:(0,ey.jsx)("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-px",children:e.map(e=>{let r=!!n&&e.runId===n;return(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full min-w-0 items-center gap-2 rounded px-2 py-1 text-left transition-colors",r?"bg-muted":"hover:bg-muted/70"),onClick:()=>{t(e),i(!1)},children:[(0,ey.jsx)("span",{"aria-hidden":"true",className:(0,eI.cn)("h-[2.5px] shrink-0 rounded-full transition-all",r?"w-3.5 bg-foreground/85":"w-2.5 bg-muted-foreground/40")}),(0,ey.jsx)("span",{className:(0,eI.cn)("min-w-0 flex-1 truncate text-[13px] leading-snug",r?"font-medium text-foreground":"text-foreground/90"),children:e.title?.trim()||e.summary?.trim()||"未命名轮次"})]},e.runId)})})})]}):null]})}let HS=(0,ek.default)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),HN=(0,ek.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),HC={title:"Explorer",search:"Search files...",newFile:"New file",newFolder:"New folder",refresh:"Refresh",collapseAll:"Collapse all",rename:"Rename",delete:"Delete",copyPath:"Copy path",open:"Open",empty:"No files yet.",noResults:"No matching files.",loading:"Loading..."};function HM(e){return"folder"===e.kind||!!e.children||!!e.hasChildren}function HE(e){return`${e.name} ${e.path}`.toLowerCase()}function HO(e,t){if(e&&t)return HP(e.children,t)}function HP(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?HP(n.children,t):void 0;if(e)return e}}function HA(e,t){return e?t.map(t=>HP(e.children,t)).filter(e=>!!e):[]}function HI(e,t){let n=e.includes("\\")?"\\":"/";return e.endsWith("\\")||e.endsWith("/")?`${e}${t}`:`${e}${n}${t}`}function Hz(e,t,n){return e.map(e=>e.id===t?n(e):e.children?{...e,children:Hz(e.children,t,n)}:e)}function HT(e,t){return e.filter(e=>!t.has(e.id)).map(e=>({...e,children:e.children?HT(e.children,t):void 0}))}function HD(e,t){return e.some(e=>e.id===t||!!(e.children&&HD(e.children,t)))}function HR(e,t){let n=HI(t,e.name);return{...e,path:n,children:e.children?.map(e=>HR(e,n))}}function H_(e,t,n){let[r,a]=ew.useState(t??n);return[e??r,a]}function HL({roots:e,defaultRoots:t,activeRootId:n,defaultActiveRootId:r,activeNodeId:a,defaultActiveNodeId:i,selectedIds:o,defaultSelectedIds:l,expandedIds:s,defaultExpandedIds:c,searchValue:d,defaultSearchValue:u,loadingIds:f,labels:h,allowMultiSelect:m=!0,allowCreateFile:p=!0,allowCreateFolder:g=!0,allowRename:v=!0,allowDelete:x=!0,allowDragAndDrop:y=!0,allowBoxSelect:b=!0,openFilesOnSingleClick:w=!0,showSearch:j=!0,showToolbar:k=!0,compact:S=!1,onActiveRootChange:N,onActiveNodeChange:C,onSelectionChange:M,onExpandedChange:E,onSearchValueChange:O,onOpenNode:P,onLoadChildren:A,onCreateNode:I,onRenameNode:z,onDeleteNodes:T,onMoveNodes:D,onCopyPath:R,onRefresh:_,className:L,sidebarClassName:$,style:F}){let B={...HC,...h},V=ew.useRef(null),H=ew.useRef(void 0),U=ew.useRef([]),[W,q]=ew.useState(()=>(t??[]).map(e=>({...e,children:function e(t){return t.map(t=>({...t,children:t.children?e(t.children):void 0}))}(e.children)}))),K=e??W,G=K[0]?.id,[X,Y]=ew.useState(r??G),Z=n??X??G,J=K.find(e=>e.id===Z)??K[0],[Q,ee]=ew.useState(i),et=a??Q,[en,er]=H_(o,l,i?[i]:[]),[ea,ei]=H_(s,c,G?[G]:[]),[eo,el]=ew.useState(u??""),es=d??eo,[ec,ed]=ew.useState(),[eu,ef]=ew.useState(""),[eh,em]=ew.useState([]),[ep,eg]=ew.useState(),[ev,ex]=ew.useState(),eb=ew.useRef(0),ej=ew.useMemo(()=>new Set(f),[f]),ek=ew.useMemo(()=>new Set(ea),[ea]),eS=ew.useMemo(()=>new Set(en),[en]),eN=HO(J,et),eC=es.trim().length>0;function eM(t){e||q(e=>t(e))}function eE(e){void 0===s&&ei(e),E?.(e)}function eO(e){void 0===o&&er(e),M?.({root:J,node:e.at(-1)?HO(J,e.at(-1)):void 0,nodes:HA(J,e)})}function eP(e){void 0===a&&ee(e?.id),C?.(e)}async function ez(e){if(HM(e)&&J){if(ek.has(e.id))return void eE(ea.filter(t=>t!==e.id));if(A&&e.hasChildren&&!e.children){let t=await A(e,J);eM(n=>n.map(n=>n.id===J.id?{...n,children:Hz(n.children,e.id,e=>({...e,children:t}))}:n))}eE([...ea,e.id])}}function eT(e){var t;t=e.id,void 0===n&&Y(t),N?.(t),ek.has(e.id)?eE(ea.filter(t=>t!==e.id)):eE([...ea,e.id])}function eD(e,t){if(e.disabled)return;let n=m&&(t?.metaKey||t?.ctrlKey)?eS.has(e.id)?en.filter(t=>t!==e.id):[...en,e.id]:[e.id];eP(e),eO(n)}function eR(e){J&&!e.disabled&&P?.(e,J)}function e_(e){if(!J)return;let t=eN&&HM(eN)?eN:J,n="folder"===e?"untitled-folder":"untitled.ts";eb.current+=1;let r={id:`created-${eb.current}`,name:n,path:HI(t.path,n),kind:"folder"===e?"folder":"code",children:"folder"===e?[]:void 0};I?.(t,e,n),eM(e=>e.map(e=>{var n,a;return e.id!==J.id?e:"children"in t&&"platform"in t?{...e,children:[r,...e.children]}:{...e,children:(n=e.children,a=t.id,Hz(n,a,e=>({...e,children:[r,...e.children??[]],hasChildren:!0})))}})),eE([...new Set([...ea,t.id])]),eP(r),eO([r.id]),ed(r.id),ef(r.name)}function eL(e){!v||e.disabled||e.readonly||(ed(e.id),ef(e.name))}function e$(e){let t=eu.trim();ed(void 0),t&&t!==e.name&&(z?.(e,t),eM(n=>n.map(n=>n.id===J?.id?{...n,children:Hz(n.children,e.id,e=>{let n,r,a;return{...e,name:t,path:HI((r=(n=e.path.replace(/[\\/]+$/,"")).includes("\\")?"\\":"/",(a=n.lastIndexOf(r))<=0?n:n.slice(0,a)),t)}})}:n)))}function eF(e,t){if(!J||!y||e.disabled||ev)return void t.preventDefault();let n=eS.has(e.id)?en:[e.id];eS.has(e.id)||(eO([e.id]),eP(e)),em(n),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",n.join(","))}function eB(e,t){if(!y||0===eh.length)return;t.preventDefault(),t.dataTransfer.dropEffect="move";let n=t.currentTarget.getBoundingClientRect(),r=(t.clientY-n.top)/n.height,a=r<.3?"before":r>.7?"after":HM(e)?"inside":"after";eg({targetId:e.id,position:a})}function eV(e,t){t.preventDefault(),ep?.targetId===e.id&&function(e,t){let n;if(!J||0===eh.length||!y)return;let r=(n=new Set(eh),HA(J,eh).filter(e=>!Array.from(n).some(t=>{var n,r;let a;return t!==e.id&&(n=J.children,r=e.id,a=HP(n,t),!!(a?.children&&HD(a.children,r)))})));if(0===r.length||r.some(t=>t.id===e.id||!!(t.children&&HD(t.children,e.id))))return;let a=new Set(r.map(e=>e.id)),i="inside"!==t||HM(e)?t:"after";D?.({root:J,nodes:r,target:e,position:i}),eM(t=>t.map(t=>{if(t.id!==J.id)return t;let n=function e(t,n,r,a,i){let o=!1,l=[];for(let s of t){if(s.id===n){if("before"===r){l.push(...a.map(e=>HR(e,i))),l.push(s),o=!0;continue}if("after"===r){l.push(s),l.push(...a.map(e=>HR(e,i))),o=!0;continue}if("inside"===r){l.push({...s,children:[...a.map(e=>HR(e,s.path)),...s.children??[]],hasChildren:!0}),o=!0;continue}}if(s.children){let t=e(s.children,n,r,a,s.path);l.push({...s,children:t.nodes}),o=o||t.inserted}else l.push(s)}return{nodes:l,inserted:o}}(HT(t.children,a),e.id,i,r,t.path);return{...t,children:n.inserted?n.nodes:t.children}})),"inside"===i&&eE([...new Set([...ea,e.id])]),eO(r.map(e=>e.id)),eP(r[0])}(e,ep.position),eg(void 0),em([])}function eH(e){let t=V.current;if(!t||!J)return;let n=Math.min(e.startX,e.currentX),r=Math.max(e.startX,e.currentX),a=Math.min(e.startY,e.currentY),i=Math.max(e.startY,e.currentY),o=Array.from(t.querySelectorAll("[data-file-tree-node-id]")).filter(e=>{let t=e.getBoundingClientRect();return t.left<r&&t.right>n&&t.top<i&&t.bottom>a}).map(e=>e.dataset.fileTreeNodeId).filter(e=>!!e);if(o.length>0){eO(Array.from(new Set([...U.current,...o])));let e=HO(J,o.at(-1));e&&eP(e)}}return ew.useEffect(()=>{n||X||!G||Y(G)},[n,G,X]),(0,ey.jsxs)("div",{ref:V,"data-slot":"file-tree-panel",className:(0,eI.cn)("vtl-surface-panel relative flex min-h-[28rem] w-full max-w-sm flex-col overflow-hidden rounded-[var(--surface-panel-radius)] border",L),style:F,onPointerDown:function(e){let t=e.target;if(!b||!m||!e.ctrlKey||0!==e.button||t.closest("input, textarea, [data-file-tree-ignore-box]"))return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect();H.current=e.pointerId,U.current=en,e.currentTarget.setPointerCapture(e.pointerId),ex({startX:e.clientX,startY:e.clientY,currentX:e.clientX,currentY:e.clientY,panelLeft:n.left,panelTop:n.top})},onPointerMove:function(e){if(!ev||H.current!==e.pointerId)return;e.preventDefault();let t={...ev,currentX:e.clientX,currentY:e.clientY};ex(t),eH(t)},onPointerUp:function(e){ev&&H.current===e.pointerId&&(eH(ev),ex(void 0),U.current=[],H.current=void 0)},onPointerCancel:()=>{ex(void 0),U.current=[],H.current=void 0},children:[k&&(0,ey.jsxs)("div",{"data-file-tree-ignore-box":!0,className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[(0,ey.jsx)("div",{className:"mr-auto min-w-0 truncate px-1 text-sm font-medium",children:B.title}),p&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.newFile,onClick:()=>e_("file"),children:(0,ey.jsx)(lJ,{})}),g&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.newFolder,onClick:()=>e_("folder"),children:(0,ey.jsx)(x9,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.refresh,onClick:()=>J&&_?.(J),children:(0,ey.jsx)(ya,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.collapseAll,onClick:function(){eE(J?[J.id]:[])},children:(0,ey.jsx)(fg.XIcon,{})})]}),j&&(0,ey.jsx)("div",{"data-file-tree-ignore-box":!0,className:"shrink-0 border-b p-2",children:(0,ey.jsxs)(b6,{className:"h-7 rounded-md",children:[(0,ey.jsx)(b7,{align:"inline-start",className:"pl-2",children:(0,ey.jsx)(vk,{className:"size-3.5"})}),(0,ey.jsx)(b9,{value:es,onChange:e=>{var t;return t=e.target.value,void(void 0===d&&el(t),O?.(t))},placeholder:B.search,className:"h-7 text-xs"})]})}),(0,ey.jsx)(wz,{className:(0,eI.cn)("min-h-0 flex-1",$),"data-slot":"file-tree-panel-scroll",children:(0,ey.jsxs)("div",{className:(0,eI.cn)("py-1",S&&"py-0.5"),children:[0===K.length&&(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:B.empty}),K.map(e=>(0,ey.jsx)(H$,{root:e,activeRoot:J,labels:B,expandedSet:ek,selectedSet:eS,activeNodeId:et,searchValue:es,loadingSet:ej,compact:S,renamingId:ec,renamingName:eu,allowRename:v,allowDelete:x,allowDragAndDrop:y,openFilesOnSingleClick:w,draggingIds:eh,dropTarget:ep,hasSearch:eC,onRootToggle:eT,onNodeToggle:e=>void ez(e),onNodeSelect:eD,onNodeOpen:eR,onStartRename:eL,onRenamingNameChange:ef,onCommitRename:e$,onCancelRename:()=>ed(void 0),onDelete:e=>(function(e){if(!x||0===e.length||!J)return;T?.(e);let t=new Set(e.map(e=>e.id));eM(e=>e.map(e=>e.id===J.id?{...e,children:HT(e.children,t)}:e)),eO(en.filter(e=>!t.has(e))),et&&t.has(et)&&eP(void 0)})(function(e){if(eS.has(e.id)){let t=HA(J,en);return t.length>0?t:[e]}return[e]}(e)),onCopyPath:e=>R?.(e),onDragStart:eF,onDragOver:eB,onDragEnd:()=>{em([]),eg(void 0)},onDrop:eV},e.id))]})}),ev&&(0,ey.jsx)(HH,{box:ev})]})}function H$({root:e,activeRoot:t,labels:n,expandedSet:r,selectedSet:a,activeNodeId:i,searchValue:o,loadingSet:l,compact:s,renamingId:c,renamingName:d,allowRename:u,allowDelete:f,allowDragAndDrop:h,openFilesOnSingleClick:m,draggingIds:p,dropTarget:g,hasSearch:v,onRootToggle:x,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A}){let I=r.has(e.id),z=o.trim().toLowerCase(),T=v?e.children.filter(e=>Hq(e,z)):e.children;return(0,ey.jsxs)("section",{"data-slot":"file-tree-root",className:"min-w-0",children:[(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("group flex h-7 w-full items-center gap-1 px-2 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",t?.id===e.id&&"text-foreground"),onClick:()=>x(e),children:[(0,ey.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center",children:I?(0,ey.jsx)(vu,{className:"size-3.5"}):(0,ey.jsx)(mQ,{className:"size-3.5"})}),(0,ey.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center [&_svg]:size-3.5",children:e.icon??(0,ey.jsx)(uM,{})}),(0,ey.jsx)("span",{className:"truncate uppercase tracking-wide",children:e.name})]}),(I||v)&&(0,ey.jsxs)("div",{children:[l.has(e.id)&&(0,ey.jsx)("div",{className:"px-8 py-2 text-xs text-muted-foreground",children:n.loading}),!l.has(e.id)&&0===T.length&&(0,ey.jsx)("div",{className:"px-8 py-2 text-xs text-muted-foreground",children:v?n.noResults:n.empty}),T.map(t=>(0,ey.jsx)(HF,{node:t,root:e,depth:0,labels:n,expandedSet:r,selectedSet:a,activeNodeId:i,searchValue:z,loadingSet:l,compact:s,renamingId:c,renamingName:d,allowRename:u,allowDelete:f,allowDragAndDrop:h,openFilesOnSingleClick:m,draggingIds:p,dropTarget:g,hasSearch:v,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A},t.id))]})]})}function HF({node:e,root:t,depth:n,labels:r,expandedSet:a,selectedSet:i,activeNodeId:o,searchValue:l,loadingSet:s,compact:c,renamingId:d,renamingName:u,allowRename:f,allowDelete:h,allowDragAndDrop:m,openFilesOnSingleClick:p,draggingIds:g,dropTarget:v,hasSearch:x,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A}){let I=HM(e),z=a.has(e.id),T=i.has(e.id),D=o===e.id,R=d===e.id,_=s.has(e.id),L=g.includes(e.id),$=v?.targetId===e.id&&"inside"!==v.position,F=v?.targetId===e.id&&"inside"===v.position,B=e.children??[],V=x?B.filter(e=>Hq(e,l)):B,H=!x||HE(e).includes(l),U=(z||x)&&V.length>0,W=8+14*n;if(x&&!H&&0===V.length)return null;let q=(0,ey.jsxs)("div",{"data-slot":"file-tree-row","data-file-tree-node-id":e.id,"data-active":D?"true":void 0,"data-selected":T?"true":void 0,draggable:m&&!R&&!e.disabled,className:(0,eI.cn)("group/tree-row relative flex w-full items-center gap-1 pr-1 text-left text-xs transition-colors",c?"h-6":"h-7",T||D?"bg-muted text-foreground":"text-foreground hover:bg-muted/60",F&&"bg-primary/10 ring-1 ring-inset ring-primary/35",L&&"opacity-45",e.disabled&&"pointer-events-none opacity-50"),style:{paddingLeft:W},onDragStart:t=>E(e,t),onDragOver:t=>O(e,t),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.dataset.dragLeave="true")},onDragEnd:P,onDrop:t=>A(e,t),onDoubleClick:()=>w(e),onKeyDown:t=>{"Enter"===t.key&&w(e),"F2"===t.key&&(t.preventDefault(),j(e)),("Delete"===t.key||"Backspace"===t.key)&&(t.preventDefault(),C(e)),"ArrowRight"===t.key&&I&&!z&&(t.preventDefault(),y(e)),"ArrowLeft"===t.key&&I&&z&&(t.preventDefault(),y(e))},children:[(0,ey.jsx)(HB,{depth:n}),$&&(0,ey.jsx)(HV,{position:v.position,depth:n}),e.recentlyModified&&(0,ey.jsx)("span",{className:"absolute top-1/2 left-1 h-1.5 w-1.5 -translate-y-1/2 rounded-full bg-primary"}),(0,ey.jsx)("button",{type:"button",tabIndex:-1,className:"flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted-foreground/10 hover:text-foreground",onClick:t=>{t.stopPropagation(),y(e)},"aria-label":z?"Collapse":"Expand",children:I?z?(0,ey.jsx)(vu,{className:"size-3.5"}):(0,ey.jsx)(mQ,{className:"size-3.5"}):null}),(0,ey.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",onClick:t=>{b(e,t),!I||t.metaKey||t.ctrlKey?!I&&p&&w(e):y(e)},children:[(0,ey.jsx)(HW,{node:e,open:z}),R?(0,ey.jsx)("input",{value:u,onChange:e=>k(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),S(e)),"Escape"===t.key&&(t.preventDefault(),N())},onBlur:()=>S(e),autoFocus:!0,className:"h-5 min-w-0 flex-1 rounded-sm border border-ring bg-background px-1 text-xs outline-none"}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name}),e.badge&&(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.badge}),e.meta&&(0,ey.jsx)("span",{className:"hidden shrink-0 text-muted-foreground group-hover/tree-row:inline sm:inline",children:e.meta})]})]}),!R&&(0,ey.jsx)(HU,{node:e,root:t,labels:r,allowRename:f,allowDelete:h,onOpen:w,onRename:j,onDelete:C,onCopyPath:M}),_&&(0,ey.jsx)("span",{className:"absolute inset-y-0 right-8 flex items-center text-[10px] text-muted-foreground",children:r.loading})]});return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)(bv,{children:[(0,ey.jsx)(by,{asChild:!0,children:q}),(0,ey.jsxs)(bM,{className:"w-40",children:[(0,ey.jsxs)(bE,{onSelect:()=>w(e),children:[(0,ey.jsx)(x3,{}),r.open]}),(0,ey.jsxs)(bE,{onSelect:()=>M(e),children:[(0,ey.jsx)(lU,{}),r.copyPath]}),f&&!e.readonly&&(0,ey.jsxs)(bE,{onSelect:()=>j(e),children:[(0,ey.jsx)(HN,{}),r.rename]}),h&&!e.readonly&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(bO,{}),(0,ey.jsxs)(bE,{variant:"destructive",onSelect:()=>C(e),children:[(0,ey.jsx)(yi,{}),r.delete]})]})]})]}),z&&I&&_&&(0,ey.jsx)("div",{className:"py-1 text-xs text-muted-foreground",style:{paddingLeft:W+40},children:r.loading}),U&&V.map(e=>(0,ey.jsx)(HF,{node:e,root:t,depth:n+1,labels:r,expandedSet:a,selectedSet:i,activeNodeId:o,searchValue:l,loadingSet:s,compact:c,renamingId:d,renamingName:u,allowRename:f,allowDelete:h,allowDragAndDrop:m,openFilesOnSingleClick:p,draggingIds:g,dropTarget:v,hasSearch:x,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A},e.id))]})}function HB({depth:e}){return e<=0?null:(0,ey.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0",children:Array.from({length:e}).map((e,t)=>(0,ey.jsx)("span",{className:"absolute inset-y-0 w-px bg-border/80 dark:bg-border/70",style:{left:17+14*t}},t))})}function HV({position:e,depth:t}){return(0,ey.jsxs)("span",{"aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute right-2 z-10 flex h-3 items-center text-primary","before"===e?"top-[-6px]":"bottom-[-6px]"),style:{left:28+14*t},children:[(0,ey.jsx)("span",{className:"text-[10px] leading-none",children:">"}),(0,ey.jsx)("span",{className:"mx-0.5 h-px flex-1 bg-primary"}),(0,ey.jsx)("span",{className:"text-[10px] leading-none",children:"<"})]})}function HH({box:e}){let t=Math.min(e.startX,e.currentX)-e.panelLeft,n=Math.min(e.startY,e.currentY)-e.panelTop,r=Math.abs(e.currentX-e.startX),a=Math.abs(e.currentY-e.startY);return(0,ey.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute z-50 rounded-sm border border-primary bg-primary/10 shadow-sm",style:{left:t,top:n,width:r,height:a}})}function HU({node:e,labels:t,allowRename:n,allowDelete:r,onOpen:a,onRename:i,onDelete:o,onCopyPath:l}){return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button","data-file-tree-ignore-box":!0,variant:"ghost",size:"icon-xs",className:"size-6 opacity-0 group-hover/tree-row:opacity-100 data-[state=open]:opacity-100",onClick:e=>e.stopPropagation(),"aria-label":"More actions",children:(0,ey.jsx)(lY,{})})}),(0,ey.jsxs)(bZ,{align:"end",className:"w-40",children:[(0,ey.jsxs)(bJ,{onSelect:()=>a(e),children:[(0,ey.jsx)(x3,{}),t.open]}),(0,ey.jsxs)(bJ,{onSelect:()=>l(e),children:[(0,ey.jsx)(lU,{}),t.copyPath]}),n&&!e.readonly&&(0,ey.jsxs)(bJ,{onSelect:()=>i(e),children:[(0,ey.jsx)(HN,{}),t.rename]}),r&&!e.readonly&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{variant:"destructive",onSelect:()=>o(e),children:[(0,ey.jsx)(yi,{}),t.delete]})]})]})]})}function HW({node:e,open:t}){let n=e.icon??function(e,t){if(HM(e))return t?(0,ey.jsx)(uM,{}):(0,ey.jsx)(x7,{});let n=e.name.toLowerCase();return"image"===e.kind||/\.(png|jpg|jpeg|gif|webp|svg|avif)$/.test(n)?(0,ey.jsx)(x6,{}):"archive"===e.kind||/\.(zip|rar|7z|tar|gz)$/.test(n)?(0,ey.jsx)(x2,{}):"code"===e.kind||/\.(ts|tsx|js|jsx|json|css|scss|html|py|rs|go|mdx)$/.test(n)?(0,ey.jsx)(uk,{}):"text"===e.kind||/\.(md|txt|log|yaml|yml)$/.test(n)?(0,ey.jsx)(uC,{}):(0,ey.jsx)(x3,{})}(e,t);return(0,ey.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-3.5",children:n})}function Hq(e,t){return!!(!t||HE(e).includes(t))||!!e.children?.some(e=>Hq(e,t))}function HK(e){let t=e.trim(),n=/^vantaloom:\/\/([^/]+)\/(.+)$/i.exec(t);return n?{machineId:n[1]||"local",path:decodeURIComponent(n[2]||"").replace(/\//g,"/")}:{machineId:"local",path:t}}function HG(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function HX(e){let t=e.map(HK).filter(e=>e.path);return await Promise.all(t.map(async(e,t)=>{let n,r,a=await uK(e.machineId,e.path);return{id:`agent-root-${e.machineId}-${t}-${a.path}`,machineId:e.machineId,name:(n=a.path.replace(/[\\/]+$/,""),r=/([^\\/]+)$/.exec(n),r?.[1]??(n||"workspace")),path:a.path,platform:a.machine.platform,children:HG(a.items)}}))}async function HY(e,t){let n=t.machineId||"local";return HG((await uK(n,e.path)).items)}function HZ({folders:e,className:t,onOpenFile:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(!1),[l,s]=ew.useState(0),c=e.join("\0"),d=ew.useCallback(async()=>{o(!0);try{a(await HX(e)),s(e=>e+1)}catch{a([]),s(e=>e+1)}finally{o(!1)}},[e]);return ew.useEffect(()=>{d()},[c,d]),ew.useEffect(()=>{function e(){d()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[d]),(0,ey.jsx)(HL,{className:t,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:r,defaultExpandedIds:r.map(e=>e.id),loadingIds:i?r.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:0===e.length?"未配置可访问文件夹":"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:HY,onOpenNode:(e,t)=>{"folder"!==e.kind&&n?.({machineId:t.machineId||"local",path:e.path})},onRefresh:()=>{d()}},l)}function HJ({open:e,folders:t,onOpenChange:n,onSelectFile:r}){return(0,ey.jsx)(dC,{open:e,onOpenChange:n,children:(0,ey.jsxs)(fx,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fb,{className:"sr-only",children:"选择文件"}),(0,ey.jsx)(fw,{className:"sr-only",children:"从当前 Agent 可访问的文件夹中选择文件。"}),(0,ey.jsx)(HZ,{folders:t,className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{r(e),n(!1)}})]})})}function HQ({className:e,onChooseFile:t}){return(0,ey.jsx)("div",{className:(0,eI.cn)("grid size-full place-items-center rounded-[inherit] bg-background p-6",e),children:(0,ey.jsxs)("div",{className:"grid justify-items-center gap-3 text-center",children:[(0,ey.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-muted/35 text-muted-foreground",children:(0,ey.jsx)(uM,{className:"size-4"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"outline",onClick:t,children:[(0,ey.jsx)(HS,{className:"size-4"}),"选择文件"]})]})})}let H0=(0,ek.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function H1({conversationId:e,ownerMachineId:t,planState:n,onOpenPlan:r,onFocusComposer:a,onResolved:i}){let o=n?.questions?.find(e=>!e.answered&&!e.answer),l=n?.approvals?.find(e=>!e.decision),[s,c]=ew.useState(),[d,u]=ew.useState(!1),[f,h]=ew.useState(!1),[m,p]=ew.useState(""),g=o?.id??l?.id;if(ew.useEffect(()=>{g&&g!==s&&(h(!1),p(""))},[g,s]),!e||!g||g===s)return null;async function v(n){if(e&&o&&!d){u(!0);try{await sL(e,o.id,n,t),c(o.id),i?.()}catch{}finally{u(!1)}}}async function x(n,r){if(e&&l&&!d){u(!0);try{await s$(e,l.id,n,r,t),c(l.id),i?.()}catch{}finally{u(!1)}}}return(0,ey.jsx)("div",{"data-slot":"agent-plan-prompt-bar",className:"vtl-agent-plan-prompt-bar z-10 mx-5 mb-[-1px] grid gap-2 rounded-t-lg rounded-b-none border border-border bg-card p-2.5 shadow-xs",children:o?(0,ey.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(H0,{className:"mt-0.5 size-4 shrink-0 text-vivid-violet"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:o.text})]}),o.options&&o.options.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-1.5 pl-6",children:o.options.map((e,t)=>(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",disabled:d,className:"h-7",onClick:()=>void v(e),children:e},`${o.id}-opt-${t}`))}):null,(0,ey.jsxs)("div",{className:"flex items-center gap-2 pl-6 text-xs text-muted-foreground",children:[d?(0,ey.jsx)(eM,{className:"size-3.5 animate-spin"}):null,(0,ey.jsx)("button",{type:"button",className:"underline-offset-2 hover:text-foreground hover:underline",onClick:()=>a?.(),children:"在下方输入框自由作答"})]})]}):l?(0,ey.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(uj,{className:"mt-0.5 size-4 shrink-0 text-sky-teal"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:l.summary||"等待计划批准"})]}),f?(0,ey.jsxs)("div",{className:"flex flex-col gap-2 pl-6",children:[(0,ey.jsx)("textarea",{value:m,autoFocus:!0,rows:2,placeholder:"说明需要修改的地方…",className:(0,eI.cn)("w-full resize-none rounded-md border border-border bg-background px-2 py-1.5 text-sm","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"),onChange:e=>p(e.target.value)}),(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"default",disabled:d||!m.trim(),className:"h-7",onClick:()=>void x("rejected",m.trim()),children:[d?(0,ey.jsx)(eM,{className:"size-3.5 animate-spin"}):null,"提交修改意见"]}),(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7",onClick:()=>h(!1),children:"取消"})]})]}):(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",className:"h-7",onClick:()=>r?.(),children:"查看计划"}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"default",disabled:d,className:"h-7",onClick:()=>void x("approved"),children:[d?(0,ey.jsx)(eM,{className:"size-3.5 animate-spin"}):(0,ey.jsx)(mZ,{className:"size-3.5"}),"批准"]}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"ghost",disabled:d,className:"h-7",onClick:()=>h(!0),children:[(0,ey.jsx)(HN,{className:"size-3.5"}),"提出修改"]})]})]}):null})}let H2={expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"};function H5({icon:e,title:t,role:n,running:r,status:a,active:i,onClick:o,events:l}){let s=ew.useMemo(()=>(function(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.kind==="user")return e.slice(t);return e})(l),[l]);return(0,ey.jsxs)("button",{type:"button",onClick:o,className:(0,eI.cn)("relative flex h-48 w-full shrink-0 flex-col overflow-hidden rounded-xl border bg-card text-left shadow-md transition-all","hover:-translate-y-0.5 hover:shadow-lg",i?"border-primary/70 ring-2 ring-primary/40":r?"border-green-500/50":"border-border/70"),children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2 border-b bg-muted/50 px-2.5 py-1.5",children:[(0,ey.jsx)("span",{className:"shrink-0",children:e}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium",children:[t,(0,ey.jsxs)("span",{className:"ml-1 text-[10px] font-normal text-muted-foreground",children:["· ",n]})]}),(0,ey.jsxs)("span",{className:(0,eI.cn)("flex shrink-0 items-center gap-0.5 rounded px-1.5 py-px text-[9.5px]",r?"bg-green-500/15 text-green-600 dark:text-green-400":"failed"===a?"bg-hot-pink/15 text-hot-pink":"bg-muted text-muted-foreground"),children:[r?(0,ey.jsx)(eM,{className:"size-2.5 animate-spin"}):null,r?"运行中":"failed"===a?"失败":"paused"===a?"已暂停":"已完成"]})]}),(0,ey.jsxs)("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[s.length>0?(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0",children:(0,ey.jsx)(VY,{events:s,bottomInset:8,contentClassName:"max-w-none px-3",labels:H2})}):(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-[11px] text-muted-foreground/50",children:"暂无内容"}),(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-background to-transparent"})]})]})}function H4({subagent:e,ownerMachineId:t,active:n,onClick:r}){let[a,i]=ew.useState([]);ew.useEffect(()=>{let n,r=!1,a=async()=>{try{let o=await sA(e.id,t);if(r)return;i(o.events);let l="working"===o.conversation.status||!!o.conversation.running;n=window.setTimeout(a,l?1500:6e3)}catch{if(r)return;n=window.setTimeout(a,4e3)}};return a(),()=>{r=!0,n&&window.clearTimeout(n)}},[e.id,t]);let o=Hn(e.type),l=o.Icon;return(0,ey.jsx)(H5,{icon:(0,ey.jsx)(l,{className:(0,eI.cn)("size-4",o.color)}),title:e.name||`${o.label}子代理`,role:o.label,running:e.running,status:e.status,active:n,onClick:r,events:a})}function H3({conversationTitle:e,rootEvents:t,rootOwnerMachineId:n,running:r,subagentTree:a,baselineSubagentIds:i,activeSubagentPath:o,onSelectMain:l,onSelectSubagent:s}){let c=ew.useMemo(()=>(function e(t,n=[]){for(let r of t)n.push({id:r.id,name:r.subagentName,type:r.subagentType,status:r.status,running:r.running,ownerMachineId:r.ownerMachineId,createdAt:r.createdAt}),e(r.children??[],n);return n})(a).filter(e=>!i.has(e.id)).sort((e,t)=>(e.createdAt??"").localeCompare(t.createdAt??"")),[a,i]),d=o[o.length-1]?.id,u=0===o.length;return(0,ey.jsx)("div",{className:"h-full min-h-0 overflow-y-auto px-4 py-4 vtl-scrollbar-hidden",children:(0,ey.jsxs)("div",{className:"ml-auto flex w-full max-w-[20rem] flex-col gap-4",children:[(0,ey.jsx)(H5,{icon:(0,ey.jsx)(ub,{className:"size-4 text-sky-500"}),title:"主 Agent",role:e||"主对话",running:r,status:r?"working":"idle",active:u,onClick:l,events:t}),c.map(e=>(0,ey.jsx)(H4,{subagent:e,ownerMachineId:n,active:e.id===d,onClick:()=>s({id:e.id,ownerMachineId:e.ownerMachineId??n,name:e.name,subagentType:e.type})},e.id))]})})}function H6(e){return`vtl:composer-draft:${e}`}function H8(e){if(!e)return"";try{return window.localStorage.getItem(H6(e))??""}catch{return""}}function H7(e){return`vtl:agent:prompt-history:${e}`}function H9(e){if(!e)return[];try{let t=window.localStorage.getItem(H7(e));if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];return n.filter(e=>"string"==typeof e)}catch{return[]}}function Ue(e){return`vtl:agent-read-pos:${e}`}let Ut=(0,ek.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),Un=(0,ek.default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]),Ur=(0,ek.default)("file-type-corner",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"15usau"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M3 16v-1.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5V16",key:"s1gz5"}],["path",{d:"M6 22h2",key:"194x9m"}],["path",{d:"M7 14v8",key:"11ixej"}]]),Ua=(0,ek.default)("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Ui=(0,ek.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),Uo=(0,ek.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),Ul=(0,ek.default)("panel-bottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]),Us=(0,ek.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);function Uc(e,t){return"function"==typeof e?e(t):e}function Ud(e,t){return n=>{t.setState(t=>({...t,[e]:Uc(n,t[e])}))}}function Uu(e){return e instanceof Function}function Uf(e,t,n){let r,a=[];return i=>{let o,l;n.key&&n.debug&&(o=Date.now());let s=e(i);if(!(s.length!==a.length||s.some((e,t)=>a[t]!==e)))return r;if(a=s,n.key&&n.debug&&(l=Date.now()),r=t(...s),null==n||null==n.onChange||n.onChange(r),n.key&&n.debug&&null!=n&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-l)*100)/100,r=t/16,a=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${a(t,5)} /${a(e,5)} ms`,`
|
|
25
|
+
点击复制`,onClick:e=>i(n.cwd,e),children:n.cwd}):null,(0,ey.jsx)("span",{className:"vtl-shell-spacer"}),n.status?(0,ey.jsx)("span",{className:`vtl-shell-badge ${o}`,children:n.status}):null,void 0!==l?(0,ey.jsxs)("span",{className:`vtl-shell-badge ${l?"shell-ok":"shell-err"}`,children:["exit ",n.exitCode]}):null,n.durationMs?(0,ey.jsx)("span",{className:"vtl-shell-badge shell-time",children:n.durationMs>=1e3?`${(n.durationMs/1e3).toFixed(1)}s`:`${n.durationMs}ms`}):null]}),r?(0,ey.jsx)("pre",{className:"vtl-shell-output",children:r}):null,a.length>0?(0,ey.jsx)("div",{className:"vtl-agent-tool-result","data-kind":"tool",children:a.map(e=>(0,ey.jsx)(V8,{row:e,onOpenFile:t},e.key))}):null]})}function V8({row:e,onOpenFile:t}){let n=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("span",{className:"vtl-agent-tool-row-tree","aria-hidden":"true","data-level":e.level,children:[e.branch?.ancestorLines.map((e,t)=>(0,ey.jsx)("span",{className:"vtl-agent-tool-row-tree-ancestor","data-active":e?"true":void 0},`ancestor-${t}`)),e.level>0?(0,ey.jsx)("span",{className:"vtl-agent-tool-row-tree-elbow","data-last":e.branch?.isLast?"true":void 0}):null,(0,ey.jsx)("span",{className:"vtl-agent-tool-row-icon",children:"folder"===e.kind?"▾":""})]}),(0,ey.jsx)("span",{className:"vtl-agent-tool-row-label",children:e.label}),e.meta?(0,ey.jsx)("em",{children:e.meta}):null]}),r={"--tool-tree-indent":`${13*Math.min(e.level,8)}px`,"--tool-tree-level":Math.min(e.level,8)};return e.file&&"file"===e.kind?(0,ey.jsx)("button",{type:"button",className:"vtl-agent-tool-row","data-kind":e.kind,style:r,onClick:()=>t?.(e.file),children:n}):(0,ey.jsx)("div",{className:"vtl-agent-tool-row","data-kind":e.kind,style:r,children:n})}function V7(e,t,n){let r=e.actionLabel?.trim()==="探索"||t.meta?.toLowerCase().startsWith("depth")||/[\\/]$/.test(t.name)||!!(t.path&&/[\\/]$/.test(t.path)),a=Hg(t.name||t.path||"untitled");return{key:t.id??`file-${n}-${t.path??t.name}`,label:a,level:0,kind:r?"folder":"file",meta:t.lines??t.meta,file:t}}function V9(e){return Hg(e.replace(/[\\/]+$/,"")).toLowerCase()}function He(e,t,n){for(let r=t+1;r<e.length;r+=1){let t=e[r]?.level??0;if(t<n)break;if(t===n)return!0}return!1}let Ht={explore:{label:"探索",color:"text-sky-600 dark:text-sky-400",Icon:Vy},workflow:{label:"工作流",color:"text-violet-600 dark:text-violet-400",Icon:uP},operator:{label:"操作员",color:"text-pink-600 dark:text-pink-400",Icon:uO},custom:{label:"自定义",color:"text-amber-600 dark:text-amber-400",Icon:ub}};function Hn(e){return Ht[e??""]??{label:"子代理",color:"text-muted-foreground",Icon:ub}}function Hr({event:e,onOpenSubagent:t}){return(0,ey.jsx)("div",{className:"grid gap-2",children:e.subagents?.map(n=>(0,ey.jsx)(Ha,{subagent:n,event:e,onOpenSubagent:t},n.id||n.title))})}function Ha({subagent:e,event:t,onOpenSubagent:n}){let[r,a]=ew.useState(!1),i=Hn(e.subagentType),o=e.status??(e.isRunning?"running":"done"),l=!!e.isRunning||"running"===o,s="failed"===o,c=e.name||`${i.label}子代理`,d=(e.result??t.detail??"").trim(),u=i.Icon,f=!!e.inline;return(0,ey.jsxs)("section",{className:(0,eI.cn)("overflow-hidden rounded-lg border bg-card/60",s&&"border-destructive/40"),"data-subagent-card":!0,"data-running":l?"true":void 0,children:[f?(0,ey.jsxs)("div",{className:"flex w-full items-center gap-2.5 px-3 py-2 text-left",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("flex size-6 shrink-0 items-center justify-center rounded-md bg-muted/60",i.color),children:(0,ey.jsx)(u,{className:"size-3.5"})}),(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] font-medium",children:[(0,ey.jsx)("span",{className:"truncate",children:c}),(0,ey.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 py-px text-[10px] font-normal text-muted-foreground",children:i.label})]}),e.title?(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.title}):null]}),(0,ey.jsx)(Hi,{status:o,running:l})]}):(0,ey.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors hover:bg-accent/40",onClick:()=>n?.(e,t),title:"打开子代理对话",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("flex size-6 shrink-0 items-center justify-center rounded-md bg-muted/60",i.color),children:(0,ey.jsx)(u,{className:"size-3.5"})}),(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] font-medium",children:[(0,ey.jsx)("span",{className:"truncate",children:c}),(0,ey.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 py-px text-[10px] font-normal text-muted-foreground",children:i.label})]}),e.title?(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.title}):null]}),(0,ey.jsx)(Hi,{status:o,running:l})]}),d?(0,ey.jsx)("div",{className:"border-t",children:f?(0,ey.jsx)("div",{className:"max-h-72 overflow-auto whitespace-pre-wrap px-3 py-2 text-xs leading-relaxed text-foreground/80",children:d}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-3 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:()=>a(e=>!e),"aria-expanded":r,children:[(0,ey.jsx)(mQ,{className:(0,eI.cn)("size-3 transition-transform",r&&"rotate-90")}),r?"收起结果":"查看结果"]}),r?(0,ey.jsx)("div",{className:"max-h-72 overflow-auto whitespace-pre-wrap px-3 pb-3 text-xs leading-relaxed text-foreground/80",children:d}):null]})}):null]})}function Hi({status:e,running:t}){return t?(0,ey.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"failed"===e?(0,ey.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-destructive",children:[(0,ey.jsx)(hM,{className:"size-3"}),"失败"]}):(0,ey.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-emerald-600 dark:text-emerald-500",children:[(0,ey.jsx)(eO,{className:"size-3"}),"完成"]})}function Ho({event:e}){return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsxs)("p",{className:"vtl-agent-action-line",children:[e.actionLabel?(0,ey.jsx)("strong",{children:e.actionLabel}):null,e.title,e.meta?(0,ey.jsx)("em",{children:e.meta}):null]})})}function Hl(e){return e.replace(/^(?:[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}✅❌✓▶️]+)\s*/u,"").trim()}function Hs({event:e,onOpenPlan:t,onOpenSpec:n}){let r="plan-question"===e.kind||"plan-approval"===e.kind,[a,i]=ew.useState(r),{category:o,action:l}=function(e){let t=Hl(e.title);if("plan-task"===e.kind){let e=t;return t.includes("活动任务")?e="更新活动任务":(t.includes("任务已更新")||"任务已更新"===t)&&(e="更新任务状态"),{category:"任务",action:e}}if("plan-question"===e.kind)return{category:"计划",action:"向用户提问"};if("plan-approval"===e.kind)return{category:"计划",action:"等待批准"};if("plan-compact"===e.kind)return{category:"计划",action:"压缩上下文"};let n=t;return t.includes("编译")?n="编译计划树":t.includes("规范")?n="更新规范":t.includes("计划")&&(n="更新计划"),{category:"计划",action:n}}(e),s=e.specPath?()=>n?.(e.specPath):void 0,c=!s&&("plan"===e.kind||"plan-approval"===e.kind||e.planDocPath)?t:void 0,d=s??c,u=e.applied??[],f=e.questions??[],h=e.detail?.trim()??"",m=!!h||u.length>0||f.length>0||!!d||"number"==typeof e.keepFileRefs;return(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>m&&i(e=>!e),"aria-expanded":a,children:[(0,ey.jsx)("span",{children:o}),l]}),m?(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",a?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsxs)("div",{className:"mt-1 space-y-1.5 border-l border-border/60 pl-2 text-xs text-muted-foreground",children:[f.length>0?(0,ey.jsx)("ul",{className:"space-y-1",children:f.map((t,n)=>(0,ey.jsxs)("li",{children:[(0,ey.jsx)("div",{className:"text-foreground/80",children:t.text}),t.options&&t.options.length>0?(0,ey.jsx)("div",{className:"mt-0.5 flex flex-wrap gap-1",children:t.options.map((t,r)=>(0,ey.jsx)("span",{className:"rounded border border-border/60 px-1.5 py-0.5",children:t},`${e.id}-q-${n}-o-${r}`))}):null]},t.id||`${e.id}-q-${n}`))}):h?(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words",children:h}):null,"number"==typeof e.keepFileRefs?(0,ey.jsx)("p",{children:`保留 ${e.keepFileRefs} 处文件引用`}):null,u.length>0?(0,ey.jsx)("ul",{className:"space-y-0.5",children:u.map((t,n)=>(0,ey.jsxs)("li",{className:"truncate",children:["✓ ",t]},`${e.id}-applied-${n}`))}):null,d?(0,ey.jsx)("button",{type:"button",className:"text-sky-teal hover:underline",onClick:d,children:s?"查看规范":"查看计划"}):null]})})}):null]})}function Hc({event:e}){let t=Hl(e.title);return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsxs)("p",{className:"vtl-agent-action-line",children:[t,e.detail?.trim()?(0,ey.jsx)("em",{children:e.detail.trim()}):null]})})}function Hd({event:e,deliverable:t}){let[n,r]=ew.useState(!1),{category:a,action:i}=function(e){let t=Hl(e.title);for(let[e,n]of[[/^(navigate|go_to|goto)\b/i,"导航"],[/^click\b/i,"点击"],[/^(type|input)\b/i,"输入"],[/^scroll\b/i,"滚动"],[/^(key|send_keys)\b/i,"按键"],[/^(back|go_back)\b/i,"返回"],[/^find\b/i,"查找"],[/^extract\b/i,"提取"],[/^screenshot\b/i,"截图"],[/^(switch_tab|switch)\b/i,"切换标签"],[/^close_tab\b/i,"关闭标签"],[/^tabs?\b/i,"标签页"],[/^state\b/i,"读取状态"]])if(e.test(t)){let r=t.replace(e,"").trim();return{category:"浏览",action:r?`${n} ${r}`:n}}return{category:"浏览",action:t}}(e),o=e.detail?.trim()??"",l=!!o,s=e.screenshotPath?.trim(),c=s?t?.resolveImageSrc?.(s)??s:"";return(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>l&&r(e=>!e),"aria-expanded":n,children:[(0,ey.jsx)("span",{children:a}),i]}),l?(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",n?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsx)("div",{className:"mt-1 space-y-1.5 border-l border-border/60 pl-2 text-xs text-muted-foreground",children:(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words",children:o})})})}):null,c?(0,ey.jsx)("div",{className:"mt-1.5",children:(0,ey.jsx)(VT,{src:c,alt:"浏览器截图"})}):null]})}function Hu({event:e,onRetry:t}){return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsxs)("div",{className:"vtl-agent-error-card",children:[(0,ey.jsxs)("div",{className:"vtl-agent-error-card-body",children:[(0,ey.jsxs)("span",{children:[e.meta?(0,ey.jsx)("strong",{children:e.meta}):null,e.title]}),e.detail?(0,ey.jsx)("p",{children:e.detail}):null]}),e.retryable&&t?(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-error-retry",onClick:()=>t(e),children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]}):null]})})}function Hf({event:e,labels:t}){let[n,r]=ew.useState(!!e.isStreaming),a=!!e.detail?.trim(),i=e.title||t?.thinking||"思考中";return ew.useEffect(()=>{r(!!e.isStreaming)},[e.isStreaming]),(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-thought-line","data-streaming":e.isStreaming?"true":"false","aria-expanded":n,onClick:()=>a&&r(e=>!e),children:[(0,ey.jsx)("span",{children:i}),e.meta?(0,ey.jsx)("em",{children:e.meta}):null]}),a?(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",n?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsx)("div",{className:"vtl-agent-thought-detail",children:(0,ey.jsx)(Vq,{content:e.detail??"",isStreaming:e.isStreaming})})})}):null]})}function Hh({event:e,labels:t,onOpenFile:n,onOpenSubagent:r}){let[a,i]=ew.useState(!1),o=e.groupedEvents??[];return(0,ey.jsxs)("article",{className:"vtl-agent-event-row","data-kind":"toolgroup",children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>i(e=>!e),"aria-expanded":a,children:[(0,ey.jsx)("span",{children:a?"收起":"展开"}),e.title]}),(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity] duration-200 ease-out",a?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{className:"min-h-0 overflow-hidden",children:(0,ey.jsx)("div",{className:"mt-1 space-y-0.5 border-l border-border/60 pl-2",children:o.map((e,a)=>(0,ey.jsx)(V1,{event:e,autoOpen:!1,labels:t,onOpenFile:n,onOpenSubagent:r},Hv(e,a)))})})})]})}function Hm({event:e,autoOpen:t,children:n}){let[r,a]=ew.useState(t),i=ew.useRef(null);return ew.useEffect(()=>{a(t)},[t]),ew.useEffect(()=>{if(!r||!t||!i.current)return;let e=i.current.querySelector(".vtl-agent-tool-result");e&&(e.scrollTop=e.scrollHeight)},[t,n,e.detail,e.files?.length,r]),(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-event-read-line",onClick:()=>a(e=>!e),"aria-expanded":r,children:[(0,ey.jsx)("span",{children:e.actionLabel?e.actionLabel:null}),e.title]}),(0,ey.jsx)("div",{className:(0,eI.cn)("grid overflow-hidden transition-[grid-template-rows,opacity,transform] duration-200 ease-out",r?"translate-y-0 grid-rows-[1fr] opacity-100":"-translate-y-1 grid-rows-[0fr] opacity-0"),children:(0,ey.jsx)("div",{ref:i,className:"min-h-0 overflow-hidden",children:n})})]})}function Hp({event:e,onOpenFile:t}){let n=e.files?.length?e.files:[{id:e.id,name:e.title,diff:e.diff,kind:"diff",mutationId:e.mutationId,additions:e.additions,deletions:e.deletions}];return(0,ey.jsx)("article",{className:"vtl-agent-event-row","data-kind":e.kind,children:(0,ey.jsx)("div",{className:"vtl-agent-change-stack",children:n.map((r,a)=>{let i=r.additions??(1===n.length?e.additions:void 0),o=r.deletions??(1===n.length?e.deletions:void 0),l=!!(r.diff??e.diff);return(0,ey.jsxs)("button",{type:"button",className:"vtl-agent-change-row","data-streaming":e.isStreaming?"true":void 0,disabled:!l,onClick:()=>{l&&t?.({...r,diff:r.diff??e.diff,kind:r.kind??"diff",mutationId:r.mutationId??e.mutationId})},children:[(0,ey.jsxs)("span",{children:[e.actionLabel?(0,ey.jsx)("strong",{children:e.actionLabel}):null,Hg(r.name||r.path||e.title)]}),"number"==typeof i||"number"==typeof o?(0,ey.jsxs)("em",{children:["number"==typeof i?(0,ey.jsxs)("b",{"data-kind":"add",children:["+",i]}):null,"number"==typeof o?(0,ey.jsxs)("b",{"data-kind":"delete",children:["-",o]}):null]}):e.meta?(0,ey.jsx)("em",{children:e.meta}):null]},r.id??`${e.id}-${r.path??r.name}-${a}`)})})})}function Hg(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Hv(e,t){return e.id||`index-${t}`}let Hx="max-w-[42.5rem]",Hy={recall:"回退对话到此处",branch:"从此处分支对话",copy:"复制提示词",copyReply:"复制",more:"更多操作",expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"},Hb=ew.forwardRef(function(e,t){return(0,ey.jsx)(Hw,{...e,handleRef:t})});function Hw({handleRef:e,className:t,composerClassName:n,flowContentClassName:r,initialEvents:a,events:i,hasEarlier:o,loadingEarlier:l,onLoadEarlier:s,models:c,modelId:d,permissionModeId:u,running:f,disabled:h,onEventsChange:m,onModelChange:p,onPermissionModeChange:g,onSubmit:v,attachments:x,onAttachmentsChange:y,onStop:b,onOpenFile:w,deliverable:j,onOpenSubagent:k,onOpenPlan:S,onOpenSpec:N,planPromptBar:C,onRetry:M,onApprovalDecision:E,onContinue:O,onRecallUserMessage:P,onBranchAssistantMessage:A,onActiveEventChange:I,composerValue:z,onComposerValueChange:T,promptHistory:D,queuedMessages:R,onQueuedMessagesChange:_,onNudge:L,contextUsage:$}){let F=i??a??Vx,[B,V]=ew.useState(F),H=ew.useRef(0),U=ew.useRef(F),W=ew.useRef([]),q=ew.useRef(null),K=ew.useRef(null),G=ew.useRef(null),X=ew.useRef([]),[Y,Z]=ew.useState(168),[J,Q]=ew.useState(!0),ee=ew.useId().replace(/[^a-zA-Z0-9_-]/g,""),et=i??B,en=ew.useCallback(e=>{k?.(e)},[k]);function er(e){let t=e(U.current);U.current=t,void 0===i&&V(t),m?.(t)}function ea(e,t){let n=window.setTimeout(t,e);W.current.push(n)}return ew.useImperativeHandle(e,()=>({scrollToEvent:e=>{let t=K.current;if(!t||!e)return;let n=t.querySelector('[data-slot="agent-conversation-flow"]');if(!n)return;X.current.forEach(e=>window.clearTimeout(e)),X.current=[];let r=`[data-index="${(window.CSS?.escape??function(e){return e.replace(/["\\]/g,"\\$&")})(e)}"]`,a=["rounded-lg","ring-2","ring-primary/60","ring-offset-2","ring-offset-background","transition-shadow","duration-300"],i=e=>{e.scrollIntoView({behavior:"smooth",block:"start"}),e.classList.add(...a);let t=window.setTimeout(()=>{e.classList.remove(...a)},1600);X.current.push(t)},o=n.querySelector(r);if(o)return void i(o);G.current?.scrollToEvent(e);let l=0,s=()=>{let e=n.querySelector(r);if(e)return void i(e);if((l+=1)<8){let e=window.setTimeout(s,60);X.current.push(e)}},c=window.setTimeout(s,60);X.current.push(c)}}),[]),ew.useEffect(()=>()=>{X.current.forEach(e=>window.clearTimeout(e)),X.current=[]},[]),ew.useLayoutEffect(()=>{let e=q.current;if(!e)return;function t(){Z(Math.ceil(e.getBoundingClientRect().height))}t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),ew.useEffect(()=>{U.current=et},[et]),ew.useEffect(()=>()=>{W.current.forEach(e=>window.clearTimeout(e)),W.current=[]},[]),(0,ey.jsxs)("section",{ref:K,className:(0,eI.cn)("vtl-agent-conversation-panel relative flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-transparent",t),children:[(0,ey.jsx)(VY,{ref:G,events:et,running:f,hasEarlier:o,loadingEarlier:l,onLoadEarlier:s,bottomInset:Y+16,contentClassName:(0,eI.cn)(Hx,n,r),onOpenFile:w,deliverable:j,onOpenSubagent:en,onOpenPlan:S,onOpenSpec:N,onRetry:M,onApprovalDecision:E,onContinue:O,onRecallUserMessage:P,onBranchAssistantMessage:A,onActiveEventChange:I,onAtBottomChange:Q,labels:Hy}),(0,ey.jsx)("button",{type:"button","aria-label":"滚动到底部",onClick:()=>G.current?.scrollToBottom(),style:{bottom:Y+12},className:(0,eI.cn)("pointer-events-auto absolute left-1/2 z-30 -translate-x-1/2 flex size-9 items-center justify-center rounded-full border bg-popover text-popover-foreground shadow-md transition-opacity hover:bg-muted",J&&"pointer-events-none opacity-0"),children:(0,ey.jsx)(jO,{className:"size-4"})}),(0,ey.jsx)("div",{ref:q,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center px-4 pb-4",children:(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-agent-composer-dock pointer-events-auto relative w-full",Hx,n),children:[C,(0,ey.jsx)(Vc,{className:"relative z-10 w-full",submitOnEnter:!0,value:z,onValueChange:T,promptHistory:D,running:f,disabled:h,minRows:1,maxRows:8,permissionModeId:u,onPermissionModeChange:e=>g?.(e),models:c,modelId:d,onModelChange:e=>p?.(e),queuedMessages:R,onQueuedMessagesChange:_,onNudge:L,attachments:x,onAttachmentsChange:y,contextUsage:$,labels:{placeholder:"请问",mode:"模式",model:"模型",attach:"添加上下文",removeChip:"移除上下文",removeAttachment:"移除附件",queuedMessage:"待发送消息",guideQueuedMessage:"引导",removeQueuedMessage:"移除待发送消息",moreQueuedMessageActions:"更多待发送消息操作",contextUsage:"上下文用量",contextUsed:"已用",contextTokenSummary:"已用 {used} / {total}",toolCalls:"输入 token",userMessages:"输出 token",otherContext:"已完成轮次",compressContext:"压缩上下文",compressPrecise:"精确",compressExtreme:"极致",send:"发送",stop:"停止"},onSubmit:function(e){let t,n,r=e.value.trim(),a=(e.attachments?.length??0)>0;if(!r&&!a)return;if(v)return void v({value:r,modeId:"agent",modelId:e.modelId??d,attachments:e.attachments});H.current+=1;let i=`${ee}-${H.current}`,o=`user-${i}`;er(e=>[...e,{id:o,kind:"user",title:r}]),t=Vv(i),n=180,t.forEach(e=>{if("done"===e.kind){var t,r,a;let i,o,l=e.title;ea(n,()=>{er(t=>[...t,{...e,title:"",isStreaming:!0,status:"running"}])}),t=e.id,r=l,a=n+120,i=Math.max(4,Math.ceil(r.length/36)),o=0,ea(a,function e(){o=Math.min(r.length,o+i),er(e=>e.map(e=>e.id===t?{...e,title:r.slice(0,o),isStreaming:o<r.length,status:o<r.length?"running":"done"}:e)),o<r.length&&ea(42,e)}),n+=Math.min(2200,Math.max(900,18*l.length))+260;return}ea(n,()=>{er(t=>[...t,e])}),n+="thought"===e.kind?520:300})},onStop:b})]})})]})}function Hj({ownerMachineId:e,title:t,resolvedLocation:n,className:r}){let a=function(e){let{machines:t}=vj();return ew.useMemo(()=>{if(sC(e))return"本机";let n=t.find(t=>t.id===e);return n?n.isLocal?"本机":n.name:e??"本机"},[t,e])}(e),i=n??a,o=t.trim()||"新 Agent 对话";return(0,ey.jsxs)("div",{className:(0,eI.cn)("flex h-9 shrink-0 items-center gap-1.5 border-b px-3 text-sm",r),children:[(0,ey.jsx)(eP,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,ey.jsx)("span",{className:"shrink-0 truncate text-muted-foreground",title:i,children:i}),(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":"true",children:"/"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",title:o,children:o})]})}function Hk({rounds:e,onJumpToRound:t,activeRunId:n,className:r}){let[a,i]=ew.useState(!1),o=ew.useRef(null),[l,s]=ew.useState(304);if(ew.useEffect(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&i(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]),ew.useLayoutEffect(()=>{if(!a)return;let e=()=>{let e=o.current;if(!e)return;let t=e.getBoundingClientRect().left;s(Math.max(120,Math.min(304,window.innerWidth-t-16)))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]),!e.length)return null;let c=e.length>24?e.slice(e.length-24):e;return(0,ey.jsxs)("div",{ref:o,className:(0,eI.cn)("relative",r),children:[(0,ey.jsx)("button",{type:"button","aria-label":"轮次时间轴",title:`轮次时间轴 \xb7 共 ${e.length} 轮`,onClick:()=>i(e=>!e),className:(0,eI.cn)("group flex flex-col items-start gap-[7px] rounded-md px-1.5 py-2 outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted/50",a&&"invisible"),children:c.map(e=>{let t=!!n&&e.runId===n;return(0,ey.jsx)("span",{"aria-hidden":"true",className:(0,eI.cn)("h-[3px] rounded-full transition-all duration-200",t?"w-5 bg-foreground/85":"w-2.5 bg-muted-foreground/30 group-hover:bg-muted-foreground/55")},e.runId)})}),a?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),(0,ey.jsx)("div",{style:{width:l},className:"absolute left-0 top-0 z-50 max-h-[20rem] overflow-y-auto overflow-x-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md vtl-scrollbar-hidden",children:(0,ey.jsx)("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-px",children:e.map(e=>{let r=!!n&&e.runId===n;return(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full min-w-0 items-center gap-2 rounded px-2 py-1 text-left transition-colors",r?"bg-muted":"hover:bg-muted/70"),onClick:()=>{t(e),i(!1)},children:[(0,ey.jsx)("span",{"aria-hidden":"true",className:(0,eI.cn)("h-[2.5px] shrink-0 rounded-full transition-all",r?"w-3.5 bg-foreground/85":"w-2.5 bg-muted-foreground/40")}),(0,ey.jsx)("span",{className:(0,eI.cn)("min-w-0 flex-1 truncate text-[13px] leading-snug",r?"font-medium text-foreground":"text-foreground/90"),children:e.title?.trim()||e.summary?.trim()||"未命名轮次"})]},e.runId)})})})]}):null]})}let HS=(0,ek.default)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),HN=(0,ek.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),HC={title:"Explorer",search:"Search files...",newFile:"New file",newFolder:"New folder",refresh:"Refresh",collapseAll:"Collapse all",rename:"Rename",delete:"Delete",copyPath:"Copy path",open:"Open",empty:"No files yet.",noResults:"No matching files.",loading:"Loading..."};function HM(e){return"folder"===e.kind||!!e.children||!!e.hasChildren}function HE(e){return`${e.name} ${e.path}`.toLowerCase()}function HO(e,t){if(e&&t)return HP(e.children,t)}function HP(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?HP(n.children,t):void 0;if(e)return e}}function HA(e,t){return e?t.map(t=>HP(e.children,t)).filter(e=>!!e):[]}function HI(e,t){let n=e.includes("\\")?"\\":"/";return e.endsWith("\\")||e.endsWith("/")?`${e}${t}`:`${e}${n}${t}`}function Hz(e,t,n){return e.map(e=>e.id===t?n(e):e.children?{...e,children:Hz(e.children,t,n)}:e)}function HT(e,t){return e.filter(e=>!t.has(e.id)).map(e=>({...e,children:e.children?HT(e.children,t):void 0}))}function HD(e,t){return e.some(e=>e.id===t||!!(e.children&&HD(e.children,t)))}function HR(e,t){let n=HI(t,e.name);return{...e,path:n,children:e.children?.map(e=>HR(e,n))}}function H_(e,t,n){let[r,a]=ew.useState(t??n);return[e??r,a]}function HL({roots:e,defaultRoots:t,activeRootId:n,defaultActiveRootId:r,activeNodeId:a,defaultActiveNodeId:i,selectedIds:o,defaultSelectedIds:l,expandedIds:s,defaultExpandedIds:c,searchValue:d,defaultSearchValue:u,loadingIds:f,labels:h,allowMultiSelect:m=!0,allowCreateFile:p=!0,allowCreateFolder:g=!0,allowRename:v=!0,allowDelete:x=!0,allowDragAndDrop:y=!0,allowBoxSelect:b=!0,openFilesOnSingleClick:w=!0,showSearch:j=!0,showToolbar:k=!0,compact:S=!1,onActiveRootChange:N,onActiveNodeChange:C,onSelectionChange:M,onExpandedChange:E,onSearchValueChange:O,onOpenNode:P,onLoadChildren:A,onCreateNode:I,onRenameNode:z,onDeleteNodes:T,onMoveNodes:D,onCopyPath:R,onRefresh:_,className:L,sidebarClassName:$,style:F}){let B={...HC,...h},V=ew.useRef(null),H=ew.useRef(void 0),U=ew.useRef([]),[W,q]=ew.useState(()=>(t??[]).map(e=>({...e,children:function e(t){return t.map(t=>({...t,children:t.children?e(t.children):void 0}))}(e.children)}))),K=e??W,G=K[0]?.id,[X,Y]=ew.useState(r??G),Z=n??X??G,J=K.find(e=>e.id===Z)??K[0],[Q,ee]=ew.useState(i),et=a??Q,[en,er]=H_(o,l,i?[i]:[]),[ea,ei]=H_(s,c,G?[G]:[]),[eo,el]=ew.useState(u??""),es=d??eo,[ec,ed]=ew.useState(),[eu,ef]=ew.useState(""),[eh,em]=ew.useState([]),[ep,eg]=ew.useState(),[ev,ex]=ew.useState(),eb=ew.useRef(0),ej=ew.useMemo(()=>new Set(f),[f]),ek=ew.useMemo(()=>new Set(ea),[ea]),eS=ew.useMemo(()=>new Set(en),[en]),eN=HO(J,et),eC=es.trim().length>0;function eM(t){e||q(e=>t(e))}function eE(e){void 0===s&&ei(e),E?.(e)}function eO(e){void 0===o&&er(e),M?.({root:J,node:e.at(-1)?HO(J,e.at(-1)):void 0,nodes:HA(J,e)})}function eP(e){void 0===a&&ee(e?.id),C?.(e)}async function ez(e){if(HM(e)&&J){if(ek.has(e.id))return void eE(ea.filter(t=>t!==e.id));if(A&&e.hasChildren&&!e.children){let t=await A(e,J);eM(n=>n.map(n=>n.id===J.id?{...n,children:Hz(n.children,e.id,e=>({...e,children:t}))}:n))}eE([...ea,e.id])}}function eT(e){var t;t=e.id,void 0===n&&Y(t),N?.(t),ek.has(e.id)?eE(ea.filter(t=>t!==e.id)):eE([...ea,e.id])}function eD(e,t){if(e.disabled)return;let n=m&&(t?.metaKey||t?.ctrlKey)?eS.has(e.id)?en.filter(t=>t!==e.id):[...en,e.id]:[e.id];eP(e),eO(n)}function eR(e){J&&!e.disabled&&P?.(e,J)}function e_(e){if(!J)return;let t=eN&&HM(eN)?eN:J,n="folder"===e?"untitled-folder":"untitled.ts";eb.current+=1;let r={id:`created-${eb.current}`,name:n,path:HI(t.path,n),kind:"folder"===e?"folder":"code",children:"folder"===e?[]:void 0};I?.(t,e,n),eM(e=>e.map(e=>{var n,a;return e.id!==J.id?e:"children"in t&&"platform"in t?{...e,children:[r,...e.children]}:{...e,children:(n=e.children,a=t.id,Hz(n,a,e=>({...e,children:[r,...e.children??[]],hasChildren:!0})))}})),eE([...new Set([...ea,t.id])]),eP(r),eO([r.id]),ed(r.id),ef(r.name)}function eL(e){!v||e.disabled||e.readonly||(ed(e.id),ef(e.name))}function e$(e){let t=eu.trim();ed(void 0),t&&t!==e.name&&(z?.(e,t),eM(n=>n.map(n=>n.id===J?.id?{...n,children:Hz(n.children,e.id,e=>{let n,r,a;return{...e,name:t,path:HI((r=(n=e.path.replace(/[\\/]+$/,"")).includes("\\")?"\\":"/",(a=n.lastIndexOf(r))<=0?n:n.slice(0,a)),t)}})}:n)))}function eF(e,t){if(!J||!y||e.disabled||ev)return void t.preventDefault();let n=eS.has(e.id)?en:[e.id];eS.has(e.id)||(eO([e.id]),eP(e)),em(n),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",n.join(","))}function eB(e,t){if(!y||0===eh.length)return;t.preventDefault(),t.dataTransfer.dropEffect="move";let n=t.currentTarget.getBoundingClientRect(),r=(t.clientY-n.top)/n.height,a=r<.3?"before":r>.7?"after":HM(e)?"inside":"after";eg({targetId:e.id,position:a})}function eV(e,t){t.preventDefault(),ep?.targetId===e.id&&function(e,t){let n;if(!J||0===eh.length||!y)return;let r=(n=new Set(eh),HA(J,eh).filter(e=>!Array.from(n).some(t=>{var n,r;let a;return t!==e.id&&(n=J.children,r=e.id,a=HP(n,t),!!(a?.children&&HD(a.children,r)))})));if(0===r.length||r.some(t=>t.id===e.id||!!(t.children&&HD(t.children,e.id))))return;let a=new Set(r.map(e=>e.id)),i="inside"!==t||HM(e)?t:"after";D?.({root:J,nodes:r,target:e,position:i}),eM(t=>t.map(t=>{if(t.id!==J.id)return t;let n=function e(t,n,r,a,i){let o=!1,l=[];for(let s of t){if(s.id===n){if("before"===r){l.push(...a.map(e=>HR(e,i))),l.push(s),o=!0;continue}if("after"===r){l.push(s),l.push(...a.map(e=>HR(e,i))),o=!0;continue}if("inside"===r){l.push({...s,children:[...a.map(e=>HR(e,s.path)),...s.children??[]],hasChildren:!0}),o=!0;continue}}if(s.children){let t=e(s.children,n,r,a,s.path);l.push({...s,children:t.nodes}),o=o||t.inserted}else l.push(s)}return{nodes:l,inserted:o}}(HT(t.children,a),e.id,i,r,t.path);return{...t,children:n.inserted?n.nodes:t.children}})),"inside"===i&&eE([...new Set([...ea,e.id])]),eO(r.map(e=>e.id)),eP(r[0])}(e,ep.position),eg(void 0),em([])}function eH(e){let t=V.current;if(!t||!J)return;let n=Math.min(e.startX,e.currentX),r=Math.max(e.startX,e.currentX),a=Math.min(e.startY,e.currentY),i=Math.max(e.startY,e.currentY),o=Array.from(t.querySelectorAll("[data-file-tree-node-id]")).filter(e=>{let t=e.getBoundingClientRect();return t.left<r&&t.right>n&&t.top<i&&t.bottom>a}).map(e=>e.dataset.fileTreeNodeId).filter(e=>!!e);if(o.length>0){eO(Array.from(new Set([...U.current,...o])));let e=HO(J,o.at(-1));e&&eP(e)}}return ew.useEffect(()=>{n||X||!G||Y(G)},[n,G,X]),(0,ey.jsxs)("div",{ref:V,"data-slot":"file-tree-panel",className:(0,eI.cn)("vtl-surface-panel relative flex min-h-[28rem] w-full max-w-sm flex-col overflow-hidden rounded-[var(--surface-panel-radius)] border",L),style:F,onPointerDown:function(e){let t=e.target;if(!b||!m||!e.ctrlKey||0!==e.button||t.closest("input, textarea, [data-file-tree-ignore-box]"))return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect();H.current=e.pointerId,U.current=en,e.currentTarget.setPointerCapture(e.pointerId),ex({startX:e.clientX,startY:e.clientY,currentX:e.clientX,currentY:e.clientY,panelLeft:n.left,panelTop:n.top})},onPointerMove:function(e){if(!ev||H.current!==e.pointerId)return;e.preventDefault();let t={...ev,currentX:e.clientX,currentY:e.clientY};ex(t),eH(t)},onPointerUp:function(e){ev&&H.current===e.pointerId&&(eH(ev),ex(void 0),U.current=[],H.current=void 0)},onPointerCancel:()=>{ex(void 0),U.current=[],H.current=void 0},children:[k&&(0,ey.jsxs)("div",{"data-file-tree-ignore-box":!0,className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[(0,ey.jsx)("div",{className:"mr-auto min-w-0 truncate px-1 text-sm font-medium",children:B.title}),p&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.newFile,onClick:()=>e_("file"),children:(0,ey.jsx)(lJ,{})}),g&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.newFolder,onClick:()=>e_("folder"),children:(0,ey.jsx)(x9,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.refresh,onClick:()=>J&&_?.(J),children:(0,ey.jsx)(ya,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":B.collapseAll,onClick:function(){eE(J?[J.id]:[])},children:(0,ey.jsx)(fg.XIcon,{})})]}),j&&(0,ey.jsx)("div",{"data-file-tree-ignore-box":!0,className:"shrink-0 border-b p-2",children:(0,ey.jsxs)(b6,{className:"h-7 rounded-md",children:[(0,ey.jsx)(b7,{align:"inline-start",className:"pl-2",children:(0,ey.jsx)(vk,{className:"size-3.5"})}),(0,ey.jsx)(b9,{value:es,onChange:e=>{var t;return t=e.target.value,void(void 0===d&&el(t),O?.(t))},placeholder:B.search,className:"h-7 text-xs"})]})}),(0,ey.jsx)(wz,{className:(0,eI.cn)("min-h-0 flex-1",$),"data-slot":"file-tree-panel-scroll",children:(0,ey.jsxs)("div",{className:(0,eI.cn)("py-1",S&&"py-0.5"),children:[0===K.length&&(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:B.empty}),K.map(e=>(0,ey.jsx)(H$,{root:e,activeRoot:J,labels:B,expandedSet:ek,selectedSet:eS,activeNodeId:et,searchValue:es,loadingSet:ej,compact:S,renamingId:ec,renamingName:eu,allowRename:v,allowDelete:x,allowDragAndDrop:y,openFilesOnSingleClick:w,draggingIds:eh,dropTarget:ep,hasSearch:eC,onRootToggle:eT,onNodeToggle:e=>void ez(e),onNodeSelect:eD,onNodeOpen:eR,onStartRename:eL,onRenamingNameChange:ef,onCommitRename:e$,onCancelRename:()=>ed(void 0),onDelete:e=>(function(e){if(!x||0===e.length||!J)return;T?.(e);let t=new Set(e.map(e=>e.id));eM(e=>e.map(e=>e.id===J.id?{...e,children:HT(e.children,t)}:e)),eO(en.filter(e=>!t.has(e))),et&&t.has(et)&&eP(void 0)})(function(e){if(eS.has(e.id)){let t=HA(J,en);return t.length>0?t:[e]}return[e]}(e)),onCopyPath:e=>R?.(e),onDragStart:eF,onDragOver:eB,onDragEnd:()=>{em([]),eg(void 0)},onDrop:eV},e.id))]})}),ev&&(0,ey.jsx)(HH,{box:ev})]})}function H$({root:e,activeRoot:t,labels:n,expandedSet:r,selectedSet:a,activeNodeId:i,searchValue:o,loadingSet:l,compact:s,renamingId:c,renamingName:d,allowRename:u,allowDelete:f,allowDragAndDrop:h,openFilesOnSingleClick:m,draggingIds:p,dropTarget:g,hasSearch:v,onRootToggle:x,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A}){let I=r.has(e.id),z=o.trim().toLowerCase(),T=v?e.children.filter(e=>Hq(e,z)):e.children;return(0,ey.jsxs)("section",{"data-slot":"file-tree-root",className:"min-w-0",children:[(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("group flex h-7 w-full items-center gap-1 px-2 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",t?.id===e.id&&"text-foreground"),onClick:()=>x(e),children:[(0,ey.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center",children:I?(0,ey.jsx)(vu,{className:"size-3.5"}):(0,ey.jsx)(mQ,{className:"size-3.5"})}),(0,ey.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center [&_svg]:size-3.5",children:e.icon??(0,ey.jsx)(uM,{})}),(0,ey.jsx)("span",{className:"truncate uppercase tracking-wide",children:e.name})]}),(I||v)&&(0,ey.jsxs)("div",{children:[l.has(e.id)&&(0,ey.jsx)("div",{className:"px-8 py-2 text-xs text-muted-foreground",children:n.loading}),!l.has(e.id)&&0===T.length&&(0,ey.jsx)("div",{className:"px-8 py-2 text-xs text-muted-foreground",children:v?n.noResults:n.empty}),T.map(t=>(0,ey.jsx)(HF,{node:t,root:e,depth:0,labels:n,expandedSet:r,selectedSet:a,activeNodeId:i,searchValue:z,loadingSet:l,compact:s,renamingId:c,renamingName:d,allowRename:u,allowDelete:f,allowDragAndDrop:h,openFilesOnSingleClick:m,draggingIds:p,dropTarget:g,hasSearch:v,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A},t.id))]})]})}function HF({node:e,root:t,depth:n,labels:r,expandedSet:a,selectedSet:i,activeNodeId:o,searchValue:l,loadingSet:s,compact:c,renamingId:d,renamingName:u,allowRename:f,allowDelete:h,allowDragAndDrop:m,openFilesOnSingleClick:p,draggingIds:g,dropTarget:v,hasSearch:x,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A}){let I=HM(e),z=a.has(e.id),T=i.has(e.id),D=o===e.id,R=d===e.id,_=s.has(e.id),L=g.includes(e.id),$=v?.targetId===e.id&&"inside"!==v.position,F=v?.targetId===e.id&&"inside"===v.position,B=e.children??[],V=x?B.filter(e=>Hq(e,l)):B,H=!x||HE(e).includes(l),U=(z||x)&&V.length>0,W=8+14*n;if(x&&!H&&0===V.length)return null;let q=(0,ey.jsxs)("div",{"data-slot":"file-tree-row","data-file-tree-node-id":e.id,"data-active":D?"true":void 0,"data-selected":T?"true":void 0,draggable:m&&!R&&!e.disabled,className:(0,eI.cn)("group/tree-row relative flex w-full items-center gap-1 pr-1 text-left text-xs transition-colors",c?"h-6":"h-7",T||D?"bg-muted text-foreground":"text-foreground hover:bg-muted/60",F&&"bg-primary/10 ring-1 ring-inset ring-primary/35",L&&"opacity-45",e.disabled&&"pointer-events-none opacity-50"),style:{paddingLeft:W},onDragStart:t=>E(e,t),onDragOver:t=>O(e,t),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.dataset.dragLeave="true")},onDragEnd:P,onDrop:t=>A(e,t),onDoubleClick:()=>w(e),onKeyDown:t=>{"Enter"===t.key&&w(e),"F2"===t.key&&(t.preventDefault(),j(e)),("Delete"===t.key||"Backspace"===t.key)&&(t.preventDefault(),C(e)),"ArrowRight"===t.key&&I&&!z&&(t.preventDefault(),y(e)),"ArrowLeft"===t.key&&I&&z&&(t.preventDefault(),y(e))},children:[(0,ey.jsx)(HB,{depth:n}),$&&(0,ey.jsx)(HV,{position:v.position,depth:n}),e.recentlyModified&&(0,ey.jsx)("span",{className:"absolute top-1/2 left-1 h-1.5 w-1.5 -translate-y-1/2 rounded-full bg-primary"}),(0,ey.jsx)("button",{type:"button",tabIndex:-1,className:"flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted-foreground/10 hover:text-foreground",onClick:t=>{t.stopPropagation(),y(e)},"aria-label":z?"Collapse":"Expand",children:I?z?(0,ey.jsx)(vu,{className:"size-3.5"}):(0,ey.jsx)(mQ,{className:"size-3.5"}):null}),(0,ey.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",onClick:t=>{b(e,t),!I||t.metaKey||t.ctrlKey?!I&&p&&w(e):y(e)},children:[(0,ey.jsx)(HW,{node:e,open:z}),R?(0,ey.jsx)("input",{value:u,onChange:e=>k(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),S(e)),"Escape"===t.key&&(t.preventDefault(),N())},onBlur:()=>S(e),autoFocus:!0,className:"h-5 min-w-0 flex-1 rounded-sm border border-ring bg-background px-1 text-xs outline-none"}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name}),e.badge&&(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.badge}),e.meta&&(0,ey.jsx)("span",{className:"hidden shrink-0 text-muted-foreground group-hover/tree-row:inline sm:inline",children:e.meta})]})]}),!R&&(0,ey.jsx)(HU,{node:e,root:t,labels:r,allowRename:f,allowDelete:h,onOpen:w,onRename:j,onDelete:C,onCopyPath:M}),_&&(0,ey.jsx)("span",{className:"absolute inset-y-0 right-8 flex items-center text-[10px] text-muted-foreground",children:r.loading})]});return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)(bv,{children:[(0,ey.jsx)(by,{asChild:!0,children:q}),(0,ey.jsxs)(bM,{className:"w-40",children:[(0,ey.jsxs)(bE,{onSelect:()=>w(e),children:[(0,ey.jsx)(x3,{}),r.open]}),(0,ey.jsxs)(bE,{onSelect:()=>M(e),children:[(0,ey.jsx)(lU,{}),r.copyPath]}),f&&!e.readonly&&(0,ey.jsxs)(bE,{onSelect:()=>j(e),children:[(0,ey.jsx)(HN,{}),r.rename]}),h&&!e.readonly&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(bO,{}),(0,ey.jsxs)(bE,{variant:"destructive",onSelect:()=>C(e),children:[(0,ey.jsx)(yi,{}),r.delete]})]})]})]}),z&&I&&_&&(0,ey.jsx)("div",{className:"py-1 text-xs text-muted-foreground",style:{paddingLeft:W+40},children:r.loading}),U&&V.map(e=>(0,ey.jsx)(HF,{node:e,root:t,depth:n+1,labels:r,expandedSet:a,selectedSet:i,activeNodeId:o,searchValue:l,loadingSet:s,compact:c,renamingId:d,renamingName:u,allowRename:f,allowDelete:h,allowDragAndDrop:m,openFilesOnSingleClick:p,draggingIds:g,dropTarget:v,hasSearch:x,onNodeToggle:y,onNodeSelect:b,onNodeOpen:w,onStartRename:j,onRenamingNameChange:k,onCommitRename:S,onCancelRename:N,onDelete:C,onCopyPath:M,onDragStart:E,onDragOver:O,onDragEnd:P,onDrop:A},e.id))]})}function HB({depth:e}){return e<=0?null:(0,ey.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0",children:Array.from({length:e}).map((e,t)=>(0,ey.jsx)("span",{className:"absolute inset-y-0 w-px bg-border/80 dark:bg-border/70",style:{left:17+14*t}},t))})}function HV({position:e,depth:t}){return(0,ey.jsxs)("span",{"aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute right-2 z-10 flex h-3 items-center text-primary","before"===e?"top-[-6px]":"bottom-[-6px]"),style:{left:28+14*t},children:[(0,ey.jsx)("span",{className:"text-[10px] leading-none",children:">"}),(0,ey.jsx)("span",{className:"mx-0.5 h-px flex-1 bg-primary"}),(0,ey.jsx)("span",{className:"text-[10px] leading-none",children:"<"})]})}function HH({box:e}){let t=Math.min(e.startX,e.currentX)-e.panelLeft,n=Math.min(e.startY,e.currentY)-e.panelTop,r=Math.abs(e.currentX-e.startX),a=Math.abs(e.currentY-e.startY);return(0,ey.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute z-50 rounded-sm border border-primary bg-primary/10 shadow-sm",style:{left:t,top:n,width:r,height:a}})}function HU({node:e,labels:t,allowRename:n,allowDelete:r,onOpen:a,onRename:i,onDelete:o,onCopyPath:l}){return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button","data-file-tree-ignore-box":!0,variant:"ghost",size:"icon-xs",className:"size-6 opacity-0 group-hover/tree-row:opacity-100 data-[state=open]:opacity-100",onClick:e=>e.stopPropagation(),"aria-label":"More actions",children:(0,ey.jsx)(lY,{})})}),(0,ey.jsxs)(bZ,{align:"end",className:"w-40",children:[(0,ey.jsxs)(bJ,{onSelect:()=>a(e),children:[(0,ey.jsx)(x3,{}),t.open]}),(0,ey.jsxs)(bJ,{onSelect:()=>l(e),children:[(0,ey.jsx)(lU,{}),t.copyPath]}),n&&!e.readonly&&(0,ey.jsxs)(bJ,{onSelect:()=>i(e),children:[(0,ey.jsx)(HN,{}),t.rename]}),r&&!e.readonly&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{variant:"destructive",onSelect:()=>o(e),children:[(0,ey.jsx)(yi,{}),t.delete]})]})]})]})}function HW({node:e,open:t}){let n=e.icon??function(e,t){if(HM(e))return t?(0,ey.jsx)(uM,{}):(0,ey.jsx)(x7,{});let n=e.name.toLowerCase();return"image"===e.kind||/\.(png|jpg|jpeg|gif|webp|svg|avif)$/.test(n)?(0,ey.jsx)(x6,{}):"archive"===e.kind||/\.(zip|rar|7z|tar|gz)$/.test(n)?(0,ey.jsx)(x2,{}):"code"===e.kind||/\.(ts|tsx|js|jsx|json|css|scss|html|py|rs|go|mdx)$/.test(n)?(0,ey.jsx)(uk,{}):"text"===e.kind||/\.(md|txt|log|yaml|yml)$/.test(n)?(0,ey.jsx)(uC,{}):(0,ey.jsx)(x3,{})}(e,t);return(0,ey.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-3.5",children:n})}function Hq(e,t){return!!(!t||HE(e).includes(t))||!!e.children?.some(e=>Hq(e,t))}function HK(e){let t=e.trim(),n=/^vantaloom:\/\/([^/]+)\/(.+)$/i.exec(t);return n?{machineId:n[1]||"local",path:decodeURIComponent(n[2]||"").replace(/\//g,"/")}:{machineId:"local",path:t}}function HG(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function HX(e){let t=e.map(HK).filter(e=>e.path);return await Promise.all(t.map(async(e,t)=>{let n,r,a=await uK(e.machineId,e.path);return{id:`agent-root-${e.machineId}-${t}-${a.path}`,machineId:e.machineId,name:(n=a.path.replace(/[\\/]+$/,""),r=/([^\\/]+)$/.exec(n),r?.[1]??(n||"workspace")),path:a.path,platform:a.machine.platform,children:HG(a.items)}}))}async function HY(e,t){let n=t.machineId||"local";return HG((await uK(n,e.path)).items)}function HZ({folders:e,className:t,onOpenFile:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(!1),[l,s]=ew.useState(0),c=e.join("\0"),d=ew.useCallback(async()=>{o(!0);try{a(await HX(e)),s(e=>e+1)}catch{a([]),s(e=>e+1)}finally{o(!1)}},[e]);return ew.useEffect(()=>{d()},[c,d]),ew.useEffect(()=>{function e(){d()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[d]),(0,ey.jsx)(HL,{className:t,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:r,defaultExpandedIds:r.map(e=>e.id),loadingIds:i?r.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:0===e.length?"未配置可访问文件夹":"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:HY,onOpenNode:(e,t)=>{"folder"!==e.kind&&n?.({machineId:t.machineId||"local",path:e.path})},onRefresh:()=>{d()}},l)}function HJ({open:e,folders:t,onOpenChange:n,onSelectFile:r}){return(0,ey.jsx)(dC,{open:e,onOpenChange:n,children:(0,ey.jsxs)(fx,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fb,{className:"sr-only",children:"选择文件"}),(0,ey.jsx)(fw,{className:"sr-only",children:"从当前 Agent 可访问的文件夹中选择文件。"}),(0,ey.jsx)(HZ,{folders:t,className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{r(e),n(!1)}})]})})}function HQ({className:e,onChooseFile:t}){return(0,ey.jsx)("div",{className:(0,eI.cn)("grid size-full place-items-center rounded-[inherit] bg-background p-6",e),children:(0,ey.jsxs)("div",{className:"grid justify-items-center gap-3 text-center",children:[(0,ey.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-muted/35 text-muted-foreground",children:(0,ey.jsx)(uM,{className:"size-4"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"outline",onClick:t,children:[(0,ey.jsx)(HS,{className:"size-4"}),"选择文件"]})]})})}let H0=(0,ek.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function H1({conversationId:e,ownerMachineId:t,planState:n,onOpenPlan:r,onFocusComposer:a,onResolved:i}){let o=n?.questions?.find(e=>!e.answered&&!e.answer),l=n?.approvals?.find(e=>!e.decision),[s,c]=ew.useState(),[d,u]=ew.useState(!1),[f,h]=ew.useState(!1),[m,p]=ew.useState(""),g=o?.id??l?.id;if(ew.useEffect(()=>{g&&g!==s&&(h(!1),p(""))},[g,s]),!e||!g||g===s)return null;async function v(n){if(e&&o&&!d){u(!0);try{await sL(e,o.id,n,t),c(o.id),i?.()}catch{}finally{u(!1)}}}async function x(n,r){if(e&&l&&!d){u(!0);try{await s$(e,l.id,n,r,t),c(l.id),i?.()}catch{}finally{u(!1)}}}return(0,ey.jsx)("div",{"data-slot":"agent-plan-prompt-bar",className:"vtl-agent-plan-prompt-bar z-10 mx-5 mb-[-1px] grid gap-2 rounded-t-lg rounded-b-none border border-border bg-card p-2.5 shadow-xs",children:o?(0,ey.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(H0,{className:"mt-0.5 size-4 shrink-0 text-vivid-violet"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:o.text})]}),o.options&&o.options.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-1.5 pl-6",children:o.options.map((e,t)=>(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",disabled:d,className:"h-7",onClick:()=>void v(e),children:e},`${o.id}-opt-${t}`))}):null,(0,ey.jsxs)("div",{className:"flex items-center gap-2 pl-6 text-xs text-muted-foreground",children:[d?(0,ey.jsx)(eM,{className:"size-3.5 animate-spin"}):null,(0,ey.jsx)("button",{type:"button",className:"underline-offset-2 hover:text-foreground hover:underline",onClick:()=>a?.(),children:"在下方输入框自由作答"})]})]}):l?(0,ey.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(uj,{className:"mt-0.5 size-4 shrink-0 text-sky-teal"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:l.summary||"等待计划批准"})]}),f?(0,ey.jsxs)("div",{className:"flex flex-col gap-2 pl-6",children:[(0,ey.jsx)("textarea",{value:m,autoFocus:!0,rows:2,placeholder:"说明需要修改的地方…",className:(0,eI.cn)("w-full resize-none rounded-md border border-border bg-background px-2 py-1.5 text-sm","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"),onChange:e=>p(e.target.value)}),(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"default",disabled:d||!m.trim(),className:"h-7",onClick:()=>void x("rejected",m.trim()),children:[d?(0,ey.jsx)(eM,{className:"size-3.5 animate-spin"}):null,"提交修改意见"]}),(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7",onClick:()=>h(!1),children:"取消"})]})]}):(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",className:"h-7",onClick:()=>r?.(),children:"查看计划"}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"default",disabled:d,className:"h-7",onClick:()=>void x("approved"),children:[d?(0,ey.jsx)(eM,{className:"size-3.5 animate-spin"}):(0,ey.jsx)(mZ,{className:"size-3.5"}),"批准"]}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",variant:"ghost",disabled:d,className:"h-7",onClick:()=>h(!0),children:[(0,ey.jsx)(HN,{className:"size-3.5"}),"提出修改"]})]})]}):null})}let H2={expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"};function H5({icon:e,title:t,role:n,running:r,status:a,active:i,onClick:o,events:l}){let s=ew.useMemo(()=>(function(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.kind==="user")return e.slice(t);return e})(l),[l]);return(0,ey.jsxs)("button",{type:"button",onClick:o,className:(0,eI.cn)("relative flex h-48 w-full shrink-0 flex-col overflow-hidden rounded-xl border bg-card text-left shadow-md transition-all","hover:-translate-y-0.5 hover:shadow-lg",i?"border-primary/70 ring-2 ring-primary/40":r?"border-green-500/50":"border-border/70"),children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2 border-b bg-muted/50 px-2.5 py-1.5",children:[(0,ey.jsx)("span",{className:"shrink-0",children:e}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium",children:[t,(0,ey.jsxs)("span",{className:"ml-1 text-[10px] font-normal text-muted-foreground",children:["· ",n]})]}),(0,ey.jsxs)("span",{className:(0,eI.cn)("flex shrink-0 items-center gap-0.5 rounded px-1.5 py-px text-[9.5px]",r?"bg-green-500/15 text-green-600 dark:text-green-400":"failed"===a?"bg-hot-pink/15 text-hot-pink":"bg-muted text-muted-foreground"),children:[r?(0,ey.jsx)(eM,{className:"size-2.5 animate-spin"}):null,r?"运行中":"failed"===a?"失败":"paused"===a?"已暂停":"已完成"]})]}),(0,ey.jsxs)("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[s.length>0?(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0",children:(0,ey.jsx)(VY,{events:s,bottomInset:8,contentClassName:"max-w-none px-3",labels:H2})}):(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-[11px] text-muted-foreground/50",children:"暂无内容"}),(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-background to-transparent"})]})]})}function H4({subagent:e,ownerMachineId:t,active:n,onClick:r}){let[a,i]=ew.useState([]);ew.useEffect(()=>{let n,r=!1,a=async()=>{try{let o=await sA(e.id,t);if(r)return;i(o.events);let l="working"===o.conversation.status||!!o.conversation.running;n=window.setTimeout(a,l?1500:6e3)}catch{if(r)return;n=window.setTimeout(a,4e3)}};return a(),()=>{r=!0,n&&window.clearTimeout(n)}},[e.id,t]);let o=Hn(e.type),l=o.Icon;return(0,ey.jsx)(H5,{icon:(0,ey.jsx)(l,{className:(0,eI.cn)("size-4",o.color)}),title:e.name||`${o.label}子代理`,role:o.label,running:e.running,status:e.status,active:n,onClick:r,events:a})}function H3({conversationTitle:e,rootEvents:t,rootOwnerMachineId:n,running:r,subagentTree:a,baselineSubagentIds:i,activeSubagentPath:o,onSelectMain:l,onSelectSubagent:s}){let c=ew.useMemo(()=>(function e(t,n=[]){for(let r of t)n.push({id:r.id,name:r.subagentName,type:r.subagentType,status:r.status,running:r.running,ownerMachineId:r.ownerMachineId,createdAt:r.createdAt}),e(r.children??[],n);return n})(a).filter(e=>!i.has(e.id)).sort((e,t)=>(e.createdAt??"").localeCompare(t.createdAt??"")),[a,i]),d=o[o.length-1]?.id,u=0===o.length;return(0,ey.jsx)("div",{className:"h-full min-h-0 overflow-y-auto px-4 py-4 vtl-scrollbar-hidden",children:(0,ey.jsxs)("div",{className:"ml-auto flex w-full max-w-[20rem] flex-col gap-4",children:[(0,ey.jsx)(H5,{icon:(0,ey.jsx)(ub,{className:"size-4 text-sky-500"}),title:"主 Agent",role:e||"主对话",running:r,status:r?"working":"idle",active:u,onClick:l,events:t}),c.map(e=>(0,ey.jsx)(H4,{subagent:e,ownerMachineId:n,active:e.id===d,onClick:()=>s({id:e.id,ownerMachineId:e.ownerMachineId??n,name:e.name,subagentType:e.type})},e.id))]})})}function H6(e){return`vtl:composer-draft:${e}`}function H8(e){if(!e)return"";try{return window.localStorage.getItem(H6(e))??""}catch{return""}}function H7(e){return`vtl:agent:prompt-history:${e}`}function H9(e){if(!e)return[];try{let t=window.localStorage.getItem(H7(e));if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];return n.filter(e=>"string"==typeof e)}catch{return[]}}function Ue(e){return`vtl:agent-read-pos:${e}`}let Ut=(0,ek.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),Un=(0,ek.default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]),Ur=(0,ek.default)("file-type-corner",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"15usau"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M3 16v-1.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5V16",key:"s1gz5"}],["path",{d:"M6 22h2",key:"194x9m"}],["path",{d:"M7 14v8",key:"11ixej"}]]),Ua=(0,ek.default)("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Ui=(0,ek.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),Uo=(0,ek.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),Ul=(0,ek.default)("panel-bottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]),Us=(0,ek.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);function Uc(e,t){return"function"==typeof e?e(t):e}function Ud(e,t){return n=>{t.setState(t=>({...t,[e]:Uc(n,t[e])}))}}function Uu(e){return e instanceof Function}function Uf(e,t,n){let r,a=[];return i=>{let o,l;n.key&&n.debug&&(o=Date.now());let s=e(i);if(!(s.length!==a.length||s.some((e,t)=>a[t]!==e)))return r;if(a=s,n.key&&n.debug&&(l=Date.now()),r=t(...s),null==n||null==n.onChange||n.onChange(r),n.key&&n.debug&&null!=n&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-l)*100)/100,r=t/16,a=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${a(t,5)} /${a(e,5)} ms`,`
|
|
26
26
|
font-size: .6rem;
|
|
27
27
|
font-weight: bold;
|
|
28
28
|
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,null==n?void 0:n.key)}return r}}function Uh(e,t,n,r){return{debug:()=>{var n;return null!=(n=null==e?void 0:e.debugAll)?n:e[t]},key:!1,onChange:r}}let Um="debugHeaders";function Up(e,t,n){var r;let a={id:null!=(r=n.id)?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(a),e},getContext:()=>({table:e,header:a,column:t})};return e._features.forEach(t=>{null==t.createHeader||t.createHeader(a,e)}),a}function Ug(e,t,n,r){var a,i;let o=0,l=function(e,t){void 0===t&&(t=1),o=Math.max(o,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;null!=(n=e.columns)&&n.length&&l(e.columns,t+1)},0)};l(e);let s=[],c=(e,t)=>{let a={depth:t,id:[r,`${t}`].filter(Boolean).join("_"),headers:[]},i=[];e.forEach(e=>{let o,l=[...i].reverse()[0],s=e.column.depth===a.depth,c=!1;if(s&&e.column.parent?o=e.column.parent:(o=e.column,c=!0),l&&(null==l?void 0:l.column)===o)l.subHeaders.push(e);else{let a=Up(n,o,{id:[r,t,o.id,null==e?void 0:e.id].filter(Boolean).join("_"),isPlaceholder:c,placeholderId:c?`${i.filter(e=>e.column===o).length}`:void 0,depth:t,index:i.length});a.subHeaders.push(e),i.push(a)}a.headers.push(e),e.headerGroup=a}),s.push(a),t>0&&c(i,t-1)};c(t.map((e,t)=>Up(n,e,{depth:o,index:t})),o-1),s.reverse();let d=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];return e.subHeaders&&e.subHeaders.length?(r=[],d(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:a}=e;t+=n,r.push(a)})):t=1,n+=Math.min(...r),e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return d(null!=(a=null==(i=s[0])?void 0:i.headers)?a:[]),s}let Uv=(e,t,n,r,a,i,o)=>{let l={id:t,index:r,original:n,depth:a,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(l._valuesCache.hasOwnProperty(t))return l._valuesCache[t];let n=e.getColumn(t);if(null!=n&&n.accessorFn)return l._valuesCache[t]=n.accessorFn(l.original,r),l._valuesCache[t]},getUniqueValues:t=>{if(l._uniqueValuesCache.hasOwnProperty(t))return l._uniqueValuesCache[t];let n=e.getColumn(t);if(null!=n&&n.accessorFn)return n.columnDef.getUniqueValues?l._uniqueValuesCache[t]=n.columnDef.getUniqueValues(l.original,r):l._uniqueValuesCache[t]=[l.getValue(t)],l._uniqueValuesCache[t]},renderValue:t=>{var n;return null!=(n=l.getValue(t))?n:e.options.renderFallbackValue},subRows:null!=i?i:[],getLeafRows:()=>{var e,t;let n,r;return e=l.subRows,t=e=>e.subRows,n=[],(r=e=>{e.forEach(e=>{n.push(e);let a=t(e);null!=a&&a.length&&r(a)})})(e),n},getParentRow:()=>l.parentId?e.getRow(l.parentId,!0):void 0,getParentRows:()=>{let e=[],t=l;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:Uf(()=>[e.getAllLeafColumns()],t=>t.map(t=>{var n;let r;return n=t.id,r={id:`${l.id}_${t.id}`,row:l,column:t,getValue:()=>l.getValue(n),renderValue:()=>{var t;return null!=(t=r.getValue())?t:e.options.renderFallbackValue},getContext:Uf(()=>[e,t,l,r],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),Uh(e.options,"debugCells","cell.getContext"))},e._features.forEach(n=>{null==n.createCell||n.createCell(r,t,l,e)},{}),r}),Uh(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:Uf(()=>[l.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),Uh(e.options,"debugRows","getAllCellsByColumnId"))};for(let t=0;t<e._features.length;t++){let n=e._features[t];null==n||null==n.createRow||n.createRow(l,e)}return l},Ux=(e,t,n)=>{var r,a;let i=null==n||null==(r=n.toString())?void 0:r.toLowerCase();return!!(null==(a=e.getValue(t))||null==(a=a.toString())||null==(a=a.toLowerCase())?void 0:a.includes(i))};Ux.autoRemove=e=>UE(e);let Uy=(e,t,n)=>{var r;return!!(null==(r=e.getValue(t))||null==(r=r.toString())?void 0:r.includes(n))};Uy.autoRemove=e=>UE(e);let Ub=(e,t,n)=>{var r;return(null==(r=e.getValue(t))||null==(r=r.toString())?void 0:r.toLowerCase())===(null==n?void 0:n.toLowerCase())};Ub.autoRemove=e=>UE(e);let Uw=(e,t,n)=>{var r;return null==(r=e.getValue(t))?void 0:r.includes(n)};Uw.autoRemove=e=>UE(e);let Uj=(e,t,n)=>!n.some(n=>{var r;return!(null!=(r=e.getValue(t))&&r.includes(n))});Uj.autoRemove=e=>UE(e)||!(null!=e&&e.length);let Uk=(e,t,n)=>n.some(n=>{var r;return null==(r=e.getValue(t))?void 0:r.includes(n)});Uk.autoRemove=e=>UE(e)||!(null!=e&&e.length);let US=(e,t,n)=>e.getValue(t)===n;US.autoRemove=e=>UE(e);let UN=(e,t,n)=>e.getValue(t)==n;UN.autoRemove=e=>UE(e);let UC=(e,t,n)=>{let[r,a]=n,i=e.getValue(t);return i>=r&&i<=a};UC.resolveFilterValue=e=>{let[t,n]=e,r="number"!=typeof t?parseFloat(t):t,a="number"!=typeof n?parseFloat(n):n,i=null===t||Number.isNaN(r)?-1/0:r,o=null===n||Number.isNaN(a)?1/0:a;if(i>o){let e=i;i=o,o=e}return[i,o]},UC.autoRemove=e=>UE(e)||UE(e[0])&&UE(e[1]);let UM={includesString:Ux,includesStringSensitive:Uy,equalsString:Ub,arrIncludes:Uw,arrIncludesAll:Uj,arrIncludesSome:Uk,equals:US,weakEquals:UN,inNumberRange:UC};function UE(e){return null==e||""===e}function UO(e,t,n){return!!e&&!!e.autoRemove&&e.autoRemove(t,n)||void 0===t||"string"==typeof t&&!t}let UP={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+("number"==typeof r?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);null!=n&&(r>n||void 0===r&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);null!=n&&(r<n||void 0===r&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,a;return n.forEach(t=>{let n=t.getValue(e);null!=n&&(void 0===r?n>=n&&(r=a=n):(r>n&&(r=n),a<n&&(a=n)))}),[r,a]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let a=t.getValue(e);null!=a&&(a*=1)>=a&&(++n,r+=a)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!(Array.isArray(n)&&n.every(e=>"number"==typeof e)))return;if(1===n.length)return n[0];let r=Math.floor(n.length/2),a=n.sort((e,t)=>e-t);return n.length%2!=0?a[r]:(a[r-1]+a[r])/2},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},UA=()=>({left:[],right:[]}),UI={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},Uz=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),UT=null;function UD(e){return"touchstart"===e.type}function UR(e,t){return t?"center"===t?e.getCenterVisibleLeafColumns():"left"===t?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}let U_=()=>({pageIndex:0,pageSize:10}),UL=()=>({top:[],bottom:[]}),U$=(e,t,n,r,a)=>{var i;let o=a.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&null!=(i=o.subRows)&&i.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>U$(e,t.id,n,r,a))};function UF(e,t){let n=e.getState().rowSelection,r=[],a={},i=function(e,t){return e.map(e=>{var t;let o=UB(e,n);if(o&&(r.push(e),a[e.id]=e),null!=(t=e.subRows)&&t.length&&(e={...e,subRows:i(e.subRows)}),o)return e}).filter(Boolean)};return{rows:i(t.rows),flatRows:r,rowsById:a}}function UB(e,t){var n;return null!=(n=t[e.id])&&n}function UV(e,t,n){var r;if(!(null!=(r=e.subRows)&&r.length))return!1;let a=!0,i=!1;return e.subRows.forEach(e=>{if((!i||a)&&(e.getCanSelect()&&(UB(e,t)?i=!0:a=!1),e.subRows&&e.subRows.length)){let n=UV(e,t);"all"===n?i=!0:("some"===n&&(i=!0),a=!1)}}),a?"all":!!i&&"some"}let UH=/([0-9]+)/gm;function UU(e,t){return e===t?0:e>t?1:-1}function UW(e){return"number"==typeof e?isNaN(e)||e===1/0||e===-1/0?"":String(e):"string"==typeof e?e:""}function Uq(e,t){let n=e.split(UH).filter(Boolean),r=t.split(UH).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),a=parseInt(e,10),i=parseInt(t,10),o=[a,i].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return -1;continue}if(isNaN(o[1]))return isNaN(a)?-1:1;if(a>i)return 1;if(i>a)return -1}return n.length-r.length}let UK={alphanumeric:(e,t,n)=>Uq(UW(e.getValue(n)).toLowerCase(),UW(t.getValue(n)).toLowerCase()),alphanumericCaseSensitive:(e,t,n)=>Uq(UW(e.getValue(n)),UW(t.getValue(n))),text:(e,t,n)=>UU(UW(e.getValue(n)).toLowerCase(),UW(t.getValue(n)).toLowerCase()),textCaseSensitive:(e,t,n)=>UU(UW(e.getValue(n)),UW(t.getValue(n))),datetime:(e,t,n)=>{let r=e.getValue(n),a=t.getValue(n);return r>a?1:r<a?-1:0},basic:(e,t,n)=>UU(e.getValue(n),t.getValue(n))},UG=[{createTable:e=>{e.getHeaderGroups=Uf(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,a)=>{var i,o;let l=null!=(i=null==r?void 0:r.map(e=>n.find(t=>t.id===e)).filter(Boolean))?i:[],s=null!=(o=null==a?void 0:a.map(e=>n.find(t=>t.id===e)).filter(Boolean))?o:[];return Ug(t,[...l,...n.filter(e=>!(null!=r&&r.includes(e.id))&&!(null!=a&&a.includes(e.id))),...s],e)},Uh(e.options,Um,"getHeaderGroups")),e.getCenterHeaderGroups=Uf(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,a)=>Ug(t,n=n.filter(e=>!(null!=r&&r.includes(e.id))&&!(null!=a&&a.includes(e.id))),e,"center"),Uh(e.options,Um,"getCenterHeaderGroups")),e.getLeftHeaderGroups=Uf(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var a;return Ug(t,null!=(a=null==r?void 0:r.map(e=>n.find(t=>t.id===e)).filter(Boolean))?a:[],e,"left")},Uh(e.options,Um,"getLeftHeaderGroups")),e.getRightHeaderGroups=Uf(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var a;return Ug(t,null!=(a=null==r?void 0:r.map(e=>n.find(t=>t.id===e)).filter(Boolean))?a:[],e,"right")},Uh(e.options,Um,"getRightHeaderGroups")),e.getFooterGroups=Uf(()=>[e.getHeaderGroups()],e=>[...e].reverse(),Uh(e.options,Um,"getFooterGroups")),e.getLeftFooterGroups=Uf(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),Uh(e.options,Um,"getLeftFooterGroups")),e.getCenterFooterGroups=Uf(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),Uh(e.options,Um,"getCenterFooterGroups")),e.getRightFooterGroups=Uf(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),Uh(e.options,Um,"getRightFooterGroups")),e.getFlatHeaders=Uf(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),Uh(e.options,Um,"getFlatHeaders")),e.getLeftFlatHeaders=Uf(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),Uh(e.options,Um,"getLeftFlatHeaders")),e.getCenterFlatHeaders=Uf(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),Uh(e.options,Um,"getCenterFlatHeaders")),e.getRightFlatHeaders=Uf(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),Uh(e.options,Um,"getRightFlatHeaders")),e.getCenterLeafHeaders=Uf(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!(null!=(t=e.subHeaders)&&t.length)}),Uh(e.options,Um,"getCenterLeafHeaders")),e.getLeftLeafHeaders=Uf(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!(null!=(t=e.subHeaders)&&t.length)}),Uh(e.options,Um,"getLeftLeafHeaders")),e.getRightLeafHeaders=Uf(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!(null!=(t=e.subHeaders)&&t.length)}),Uh(e.options,Um,"getRightLeafHeaders")),e.getLeafHeaders=Uf(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>{var r,a,i,o,l,s;return[...null!=(r=null==(a=e[0])?void 0:a.headers)?r:[],...null!=(i=null==(o=t[0])?void 0:o.headers)?i:[],...null!=(l=null==(s=n[0])?void 0:s.headers)?l:[]].map(e=>e.getLeafHeaders()).flat()},Uh(e.options,Um,"getLeafHeaders"))}},{getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Ud("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:null!=n?n:!e.getIsVisible()}))},e.getIsVisible=()=>{var n,r;let a=e.columns;return null==(n=a.length?a.some(e=>e.getIsVisible()):null==(r=t.getState().columnVisibility)?void 0:r[e.id])||n},e.getCanHide=()=>{var n,r;return(null==(n=e.columnDef.enableHiding)||n)&&(null==(r=t.options.enableHiding)||r)},e.getToggleVisibilityHandler=()=>t=>{null==e.toggleVisibility||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=Uf(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),Uh(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=Uf(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],Uh(t.options,"debugRows","getVisibleCells"))},createTable:e=>{let t=(t,n)=>Uf(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join("_")],e=>e.filter(e=>null==e.getIsVisible?void 0:e.getIsVisible()),Uh(e.options,"debugColumns",t));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>null==e.options.onColumnVisibilityChange?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{var n;e.setColumnVisibility(t?{}:null!=(n=e.initialState.columnVisibility)?n:{})},e.toggleAllColumnsVisible=t=>{var n;t=null!=(n=t)?n:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(null!=n.getCanHide&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(null!=e.getIsVisible&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>null==e.getIsVisible?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{var n;e.toggleAllColumnsVisible(null==(n=t.target)?void 0:n.checked)}}},{getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Ud("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=Uf(e=>[UR(t,e)],t=>t.findIndex(t=>t.id===e.id),Uh(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var r;return(null==(r=UR(t,n)[0])?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;let a=UR(t,n);return(null==(r=a[a.length-1])?void 0:r.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>null==e.options.onColumnOrderChange?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:null!=(n=e.initialState.columnOrder)?n:[])},e._getOrderColumnsFn=Uf(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let a=[];if(null!=e&&e.length){let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&a.push(n.splice(r,1)[0])}a=[...a,...n]}else a=r;var i=a;if(!(null!=t&&t.length)||!n)return i;let o=i.filter(e=>!t.includes(e.id));return"remove"===n?o:[...t.map(e=>i.find(t=>t.id===e)).filter(Boolean),...o]},Uh(e.options,"debugTable","_getOrderColumnsFn"))}},{getInitialState:e=>({columnPinning:UA(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Ud("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>{var t,a,i,o,l,s;return"right"===n?{left:(null!=(i=null==e?void 0:e.left)?i:[]).filter(e=>!(null!=r&&r.includes(e))),right:[...(null!=(o=null==e?void 0:e.right)?o:[]).filter(e=>!(null!=r&&r.includes(e))),...r]}:"left"===n?{left:[...(null!=(l=null==e?void 0:e.left)?l:[]).filter(e=>!(null!=r&&r.includes(e))),...r],right:(null!=(s=null==e?void 0:e.right)?s:[]).filter(e=>!(null!=r&&r.includes(e)))}:{left:(null!=(t=null==e?void 0:e.left)?t:[]).filter(e=>!(null!=r&&r.includes(e))),right:(null!=(a=null==e?void 0:e.right)?a:[]).filter(e=>!(null!=r&&r.includes(e)))}})},e.getCanPin=()=>e.getLeafColumns().some(e=>{var n,r,a;return(null==(n=e.columnDef.enablePinning)||n)&&(null==(r=null!=(a=t.options.enableColumnPinning)?a:t.options.enablePinning)||r)}),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:a}=t.getState().columnPinning,i=n.some(e=>null==r?void 0:r.includes(e)),o=n.some(e=>null==a?void 0:a.includes(e));return i?"left":!!o&&"right"},e.getPinnedIndex=()=>{var n,r;let a=e.getIsPinned();return a?null!=(n=null==(r=t.getState().columnPinning)||null==(r=r[a])?void 0:r.indexOf(e.id))?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=Uf(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...null!=t?t:[],...null!=n?n:[]];return e.filter(e=>!r.includes(e.column.id))},Uh(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=Uf(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:"left"})),Uh(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=Uf(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:"right"})),Uh(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>null==e.options.onColumnPinningChange?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,r;return e.setColumnPinning(t?UA():null!=(n=null==(r=e.initialState)?void 0:r.columnPinning)?n:UA())},e.getIsSomeColumnsPinned=t=>{var n,r,a;let i=e.getState().columnPinning;return t?!!(null==(n=i[t])?void 0:n.length):!!((null==(r=i.left)?void 0:r.length)||(null==(a=i.right)?void 0:a.length))},e.getLeftLeafColumns=Uf(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),Uh(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=Uf(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),Uh(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=Uf(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...null!=t?t:[],...null!=n?n:[]];return e.filter(e=>!r.includes(e.id))},Uh(e.options,"debugColumns","getCenterLeafColumns"))}},{createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},{getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:Ud("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0],r=null==n?void 0:n.getValue(e.id);return"string"==typeof r?UM.includesString:"number"==typeof r?UM.inNumberRange:"boolean"==typeof r||null!==r&&"object"==typeof r?UM.equals:Array.isArray(r)?UM.arrIncludes:UM.weakEquals},e.getFilterFn=()=>{var n,r;return Uu(e.columnDef.filterFn)?e.columnDef.filterFn:"auto"===e.columnDef.filterFn?e.getAutoFilterFn():null!=(n=null==(r=t.options.filterFns)?void 0:r[e.columnDef.filterFn])?n:UM[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,r,a;return(null==(n=e.columnDef.enableColumnFilter)||n)&&(null==(r=t.options.enableColumnFilters)||r)&&(null==(a=t.options.enableFilters)||a)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return null==(n=t.getState().columnFilters)||null==(n=n.find(t=>t.id===e.id))?void 0:n.value},e.getFilterIndex=()=>{var n,r;return null!=(n=null==(r=t.getState().columnFilters)?void 0:r.findIndex(t=>t.id===e.id))?n:-1},e.setFilterValue=n=>{t.setColumnFilters(t=>{var r,a;let i=e.getFilterFn(),o=null==t?void 0:t.find(t=>t.id===e.id),l=Uc(n,o?o.value:void 0);if(UO(i,l,e))return null!=(r=null==t?void 0:t.filter(t=>t.id!==e.id))?r:[];let s={id:e.id,value:l};return o?null!=(a=null==t?void 0:t.map(t=>t.id===e.id?s:t))?a:[]:null!=t&&t.length?[...t,s]:[s]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();null==e.options.onColumnFiltersChange||e.options.onColumnFiltersChange(e=>{var r;return null==(r=Uc(t,e))?void 0:r.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&UO(t.getFilterFn(),e.value,t))&&!0})})},e.resetColumnFilters=t=>{var n,r;e.setColumnFilters(t?[]:null!=(n=null==(r=e.initialState)?void 0:r.columnFilters)?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel)?e.getPreFilteredRowModel():e._getFilteredRowModel()}},{createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},{getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:Ud("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;let r=null==(n=e.getCoreRowModel().flatRows[0])||null==(n=n._getAllCellsByColumnId()[t.id])?void 0:n.getValue();return"string"==typeof r||"number"==typeof r}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,r,a,i;return(null==(n=e.columnDef.enableGlobalFilter)||n)&&(null==(r=t.options.enableGlobalFilter)||r)&&(null==(a=t.options.enableFilters)||a)&&(null==(i=null==t.options.getColumnCanGlobalFilter?void 0:t.options.getColumnCanGlobalFilter(e))||i)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>UM.includesString,e.getGlobalFilterFn=()=>{var t,n;let{globalFilterFn:r}=e.options;return Uu(r)?r:"auto"===r?e.getGlobalAutoFilterFn():null!=(t=null==(n=e.options.filterFns)?void 0:n[r])?t:UM[r]},e.setGlobalFilter=t=>{null==e.options.onGlobalFilterChange||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Ud("sorting",e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=null==t?void 0:t.getValue(e.id);if("[object Date]"===Object.prototype.toString.call(n))return UK.datetime;if("string"==typeof n&&(r=!0,n.split(UH).length>1))return UK.alphanumeric}return r?UK.text:UK.basic},e.getAutoSortDir=()=>{let n=t.getFilteredRowModel().flatRows[0];return"string"==typeof(null==n?void 0:n.getValue(e.id))?"asc":"desc"},e.getSortingFn=()=>{var n,r;if(!e)throw Error();return Uu(e.columnDef.sortingFn)?e.columnDef.sortingFn:"auto"===e.columnDef.sortingFn?e.getAutoSortingFn():null!=(n=null==(r=t.options.sortingFns)?void 0:r[e.columnDef.sortingFn])?n:UK[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let a=e.getNextSortingOrder(),i=null!=n;t.setSorting(o=>{let l,s=null==o?void 0:o.find(t=>t.id===e.id),c=null==o?void 0:o.findIndex(t=>t.id===e.id),d=[],u=i?n:"desc"===a;if("toggle"!=(l=null!=o&&o.length&&e.getCanMultiSort()&&r?s?"toggle":"add":null!=o&&o.length&&c!==o.length-1?"replace":s?"toggle":"replace")||i||a||(l="remove"),"add"===l){var f;(d=[...o,{id:e.id,desc:u}]).splice(0,d.length-(null!=(f=t.options.maxMultiSortColCount)?f:Number.MAX_SAFE_INTEGER))}else d="toggle"===l?o.map(t=>t.id===e.id?{...t,desc:u}:t):"remove"===l?o.filter(t=>t.id!==e.id):[{id:e.id,desc:u}];return d})},e.getFirstSortDir=()=>{var n,r;return(null!=(n=null!=(r=e.columnDef.sortDescFirst)?r:t.options.sortDescFirst)?n:"desc"===e.getAutoSortDir())?"desc":"asc"},e.getNextSortingOrder=n=>{var r,a;let i=e.getFirstSortDir(),o=e.getIsSorted();return o?(o===i||null!=(r=t.options.enableSortingRemoval)&&!r||!!n&&null!=(a=t.options.enableMultiRemove)&&!a)&&("desc"===o?"asc":"desc"):i},e.getCanSort=()=>{var n,r;return(null==(n=e.columnDef.enableSorting)||n)&&(null==(r=t.options.enableSorting)||r)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,r;return null!=(n=null!=(r=e.columnDef.enableMultiSort)?r:t.options.enableMultiSort)?n:!!e.accessorFn},e.getIsSorted=()=>{var n;let r=null==(n=t.getState().sorting)?void 0:n.find(t=>t.id===e.id);return!!r&&(r.desc?"desc":"asc")},e.getSortIndex=()=>{var n,r;return null!=(n=null==(r=t.getState().sorting)?void 0:r.findIndex(t=>t.id===e.id))?n:-1},e.clearSorting=()=>{t.setSorting(t=>null!=t&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(null==r.persist||r.persist(),null==e.toggleSorting||e.toggleSorting(void 0,!!e.getCanMultiSort()&&(null==t.options.isMultiSortEvent?void 0:t.options.isMultiSortEvent(r))))}}},createTable:e=>{e.setSorting=t=>null==e.options.onSortingChange?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,r;e.setSorting(t?[]:null!=(n=null==(r=e.initialState)?void 0:r.sorting)?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel)?e.getPreSortedRowModel():e._getSortedRowModel()}},{getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return null!=(t=null==(n=e.getValue())||null==n.toString?void 0:n.toString())?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Ud("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>null!=t&&t.includes(e.id)?t.filter(t=>t!==e.id):[...null!=t?t:[],e.id])},e.getCanGroup=()=>{var n,r;return(null==(n=e.columnDef.enableGrouping)||n)&&(null==(r=t.options.enableGrouping)||r)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return null==(n=t.getState().grouping)?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return null==(n=t.getState().grouping)?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0],r=null==n?void 0:n.getValue(e.id);return"number"==typeof r?UP.sum:"[object Date]"===Object.prototype.toString.call(r)?UP.extent:void 0},e.getAggregationFn=()=>{var n,r;if(!e)throw Error();return Uu(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:"auto"===e.columnDef.aggregationFn?e.getAutoAggregationFn():null!=(n=null==(r=t.options.aggregationFns)?void 0:r[e.columnDef.aggregationFn])?n:UP[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>null==e.options.onGroupingChange?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,r;e.setGrouping(t?[]:null!=(n=null==(r=e.initialState)?void 0:r.grouping)?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel)?e.getPreGroupedRowModel():e._getGroupedRowModel()},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return null!=r&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!(null!=(t=n.subRows)&&t.length)}}},{getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Ud("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var r,a;if(!t)return void e._queue(()=>{t=!0});if(null!=(r=null!=(a=e.options.autoResetAll)?a:e.options.autoResetExpanded)?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>null==e.options.onExpandedChange?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{(null!=t?t:!e.getIsAllRowsExpanded())?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{var n,r;e.setExpanded(t?{}:null!=(n=null==(r=e.initialState)?void 0:r.expanded)?n:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{null==t.persist||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return!0===t||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return"boolean"==typeof t?!0===t:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(!0===e.getState().expanded?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(".");t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel)?e.getPreExpandedRowModel():e._getExpandedRowModel()},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{var a;let i=!0===r||!!(null!=r&&r[e.id]),o={};if(!0===r?Object.keys(t.getRowModel().rowsById).forEach(e=>{o[e]=!0}):o=r,n=null!=(a=n)?a:!i,!i&&n)return{...o,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=o;return n}return r})},e.getIsExpanded=()=>{var n;let r=t.getState().expanded;return!!(null!=(n=null==t.options.getIsRowExpanded?void 0:t.options.getIsRowExpanded(e))?n:!0===r||(null==r?void 0:r[e.id]))},e.getCanExpand=()=>{var n,r,a;return null!=(n=null==t.options.getRowCanExpand?void 0:t.options.getRowCanExpand(e))?n:(null==(r=t.options.enableExpanding)||r)&&!!(null!=(a=e.subRows)&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)n=(r=t.getRow(r.parentId,!0)).getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},{getInitialState:e=>({...e,pagination:{...U_(),...null==e?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:Ud("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var r,a;if(!t)return void e._queue(()=>{t=!0});if(null!=(r=null!=(a=e.options.autoResetAll)?a:e.options.autoResetPageIndex)?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>null==e.options.onPaginationChange?void 0:e.options.onPaginationChange(e=>Uc(t,e)),e.resetPagination=t=>{var n;e.setPagination(t?U_():null!=(n=e.initialState.pagination)?n:U_())},e.setPageIndex=t=>{e.setPagination(n=>{let r=Uc(t,n.pageIndex);return r=Math.max(0,Math.min(r,void 0===e.options.pageCount||-1===e.options.pageCount?Number.MAX_SAFE_INTEGER:e.options.pageCount-1)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n,r;e.setPageIndex(t?0:null!=(n=null==(r=e.initialState)||null==(r=r.pagination)?void 0:r.pageIndex)?n:0)},e.resetPageSize=t=>{var n,r;e.setPageSize(t?10:null!=(n=null==(r=e.initialState)||null==(r=r.pagination)?void 0:r.pageSize)?n:10)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,Uc(t,e.pageSize)),r=Math.floor(e.pageSize*e.pageIndex/n);return{...e,pageIndex:r,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{var r;let a=Uc(t,null!=(r=e.options.pageCount)?r:-1);return"number"==typeof a&&(a=Math.max(-1,a)),{...n,pageCount:a}}),e.getPageOptions=Uf(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},Uh(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return -1===n||0!==n&&t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel)?e.getPrePaginationRowModel():e._getPaginationRowModel(),e.getPageCount=()=>{var t;return null!=(t=e.options.pageCount)?t:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var t;return null!=(t=e.options.rowCount)?t:e.getPrePaginationRowModel().rows.length}}},{getInitialState:e=>({rowPinning:UL(),...e}),getDefaultOptions:e=>({onRowPinningChange:Ud("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,r,a)=>{let i=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=new Set([...a?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],e.id,...i]);t.setRowPinning(e=>{var t,r,a,i,l,s;return"bottom"===n?{top:(null!=(a=null==e?void 0:e.top)?a:[]).filter(e=>!(null!=o&&o.has(e))),bottom:[...(null!=(i=null==e?void 0:e.bottom)?i:[]).filter(e=>!(null!=o&&o.has(e))),...Array.from(o)]}:"top"===n?{top:[...(null!=(l=null==e?void 0:e.top)?l:[]).filter(e=>!(null!=o&&o.has(e))),...Array.from(o)],bottom:(null!=(s=null==e?void 0:e.bottom)?s:[]).filter(e=>!(null!=o&&o.has(e)))}:{top:(null!=(t=null==e?void 0:e.top)?t:[]).filter(e=>!(null!=o&&o.has(e))),bottom:(null!=(r=null==e?void 0:e.bottom)?r:[]).filter(e=>!(null!=o&&o.has(e)))}})},e.getCanPin=()=>{var n;let{enableRowPinning:r,enablePinning:a}=t.options;return"function"==typeof r?r(e):null==(n=null!=r?r:a)||n},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:a}=t.getState().rowPinning,i=n.some(e=>null==r?void 0:r.includes(e)),o=n.some(e=>null==a?void 0:a.includes(e));return i?"top":!!o&&"bottom"},e.getPinnedIndex=()=>{var n,r;let a=e.getIsPinned();if(!a)return -1;let i=null==(n="top"===a?t.getTopRows():t.getBottomRows())?void 0:n.map(e=>{let{id:t}=e;return t});return null!=(r=null==i?void 0:i.indexOf(e.id))?r:-1}},createTable:e=>{e.setRowPinning=t=>null==e.options.onRowPinningChange?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,r;return e.setRowPinning(t?UL():null!=(n=null==(r=e.initialState)?void 0:r.rowPinning)?n:UL())},e.getIsSomeRowsPinned=t=>{var n,r,a;let i=e.getState().rowPinning;return t?!!(null==(n=i[t])?void 0:n.length):!!((null==(r=i.top)?void 0:r.length)||(null==(a=i.bottom)?void 0:a.length))},e._getPinnedRows=(t,n,r)=>{var a;return(null==(a=e.options.keepPinnedRows)||a?(null!=n?n:[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(null!=n?n:[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r}))},e.getTopRows=Uf(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),Uh(e.options,"debugRows","getTopRows")),e.getBottomRows=Uf(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),Uh(e.options,"debugRows","getBottomRows")),e.getCenterRows=Uf(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...null!=t?t:[],...null!=n?n:[]]);return e.filter(e=>!r.has(e.id))},Uh(e.options,"debugRows","getCenterRows"))}},{getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Ud("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>null==e.options.onRowSelectionChange?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:null!=(n=e.initialState.rowSelection)?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=void 0!==t?t:!e.getIsAllRowsSelected();let r={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):a.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=void 0!==t?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(t=>{U$(a,t.id,r,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=Uf(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?UF(e,n):{rows:[],flatRows:[],rowsById:{}},Uh(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=Uf(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?UF(e,n):{rows:[],flatRows:[],rowsById:{}},Uh(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=Uf(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?UF(e,n):{rows:[],flatRows:[],rowsById:{}},Uh(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{var t;let n=Object.keys(null!=(t=e.getState().rowSelection)?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return!e.getIsAllPageRowsSelected()&&t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let a=e.getIsSelected();t.setRowSelection(i=>{var o;if(n=void 0!==n?n:!a,e.getCanSelect()&&a===n)return i;let l={...i};return U$(l,e.id,n,null==(o=null==r?void 0:r.selectChildren)||o,t),l})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return UB(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return"some"===UV(e,n)},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return"all"===UV(e,n)},e.getCanSelect=()=>{var n;return"function"==typeof t.options.enableRowSelection?t.options.enableRowSelection(e):null==(n=t.options.enableRowSelection)||n},e.getCanSelectSubRows=()=>{var n;return"function"==typeof t.options.enableSubRowSelection?t.options.enableSubRowSelection(e):null==(n=t.options.enableSubRowSelection)||n},e.getCanMultiSelect=()=>{var n;return"function"==typeof t.options.enableMultiRowSelection?t.options.enableMultiRowSelection(e):null==(n=t.options.enableMultiRowSelection)||n},e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{var r;t&&e.toggleSelected(null==(r=n.target)?void 0:r.checked)}}}},{getDefaultColumnDef:()=>UI,getInitialState:e=>({columnSizing:{},columnSizingInfo:Uz(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:Ud("columnSizing",e),onColumnSizingInfoChange:Ud("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,r,a;let i=t.getState().columnSizing[e.id];return Math.min(Math.max(null!=(n=e.columnDef.minSize)?n:UI.minSize,null!=(r=null!=i?i:e.columnDef.size)?r:UI.size),null!=(a=e.columnDef.maxSize)?a:UI.maxSize)},e.getStart=Uf(e=>[e,UR(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),Uh(t.options,"debugColumns","getStart")),e.getAfter=Uf(e=>[e,UR(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),Uh(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>{var n,r;return(null==(n=e.columnDef.enableResizing)||n)&&(null==(r=t.options.enableColumnResizing)||r)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{if(e.subHeaders.length)e.subHeaders.forEach(n);else{var r;t+=null!=(r=e.column.getSize())?r:0}};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),a=null==r?void 0:r.getCanResize();return i=>{if(!r||!a||(null==i.persist||i.persist(),UD(i)&&i.touches&&i.touches.length>1))return;let o=e.getSize(),l=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],s=UD(i)?Math.round(i.touches[0].clientX):i.clientX,c={},d=(e,n)=>{"number"==typeof n&&(t.setColumnSizingInfo(e=>{var r,a;let i="rtl"===t.options.columnResizeDirection?-1:1,o=(n-(null!=(r=null==e?void 0:e.startOffset)?r:0))*i,l=Math.max(o/(null!=(a=null==e?void 0:e.startSize)?a:0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;c[t]=Math.round(100*Math.max(n+n*l,0))/100}),{...e,deltaOffset:o,deltaPercentage:l}}),("onChange"===t.options.columnResizeMode||"end"===e)&&t.setColumnSizing(e=>({...e,...c})))},u=e=>{d("end",e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=n||("u">typeof document?document:null),h={moveHandler:e=>d("move",e.clientX),upHandler:e=>{null==f||f.removeEventListener("mousemove",h.moveHandler),null==f||f.removeEventListener("mouseup",h.upHandler),u(e.clientX)}},m={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d("move",e.touches[0].clientX),!1),upHandler:e=>{var t;null==f||f.removeEventListener("touchmove",m.moveHandler),null==f||f.removeEventListener("touchend",m.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),u(null==(t=e.touches[0])?void 0:t.clientX)}},p=!!function(){if("boolean"==typeof UT)return UT;let e=!1;try{let t=()=>{};window.addEventListener("test",t,{get passive(){return e=!0,!1}}),window.removeEventListener("test",t)}catch(t){e=!1}return UT=e}()&&{passive:!1};UD(i)?(null==f||f.addEventListener("touchmove",m.moveHandler,p),null==f||f.addEventListener("touchend",m.upHandler,p)):(null==f||f.addEventListener("mousemove",h.moveHandler,p),null==f||f.addEventListener("mouseup",h.upHandler,p)),t.setColumnSizingInfo(e=>({...e,startOffset:s,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>null==e.options.onColumnSizingChange?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>null==e.options.onColumnSizingInfoChange?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:null!=(n=e.initialState.columnSizing)?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?Uz():null!=(n=e.initialState.columnSizingInfo)?n:Uz())},e.getTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0},e.getLeftTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getLeftHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0},e.getCenterTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getCenterHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0},e.getRightTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getRightHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0}}}];function UX(e,t){var n,r,a;let i;return e?"function"==typeof(r=n=e)&&(i=Object.getPrototypeOf(r)).prototype&&i.prototype.isReactComponent||"function"==typeof n||"object"==typeof(a=n)&&"symbol"==typeof a.$$typeof&&["react.memo","react.forward_ref"].includes(a.$$typeof.description)?ew.createElement(e,t):e:null}function UY(e,t,n){let r,a=n.initialDeps??[],i=!0;function o(){let o=e();return(o.length!==a.length||o.some((e,t)=>a[t]!==e))&&(a=o,r=t(...o),(null==n?void 0:n.onChange)&&!(i&&n.skipInitialOnChange)&&n.onChange(r),i=!1),r}return o.updateDeps=e=>{a=e},o}function UZ(e,t){if(void 0!==e)return e;throw Error(`Unexpected undefined${t?`: ${t}`:""}`)}let UJ=()=>{if(void 0!==i)return i;if("u"<typeof navigator)return i=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return i=!0;let e=navigator.maxTouchPoints;return i="MacIntel"===navigator.platform&&void 0!==e&&e>0},UQ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},U0=e=>e,U1=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},U2=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let a=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(a(UQ(n)),!r.ResizeObserver)return()=>{};let i=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(null==e?void 0:e.borderBoxSize){let t=e.borderBoxSize[0];if(t)return void a({width:t.inlineSize,height:t.blockSize})}a(UQ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},U5={passive:!0},U4="u"<typeof window||"onscrollend"in window,U3=(e,t)=>((e,t,n)=>{var r,a;let i,o=e.scrollElement;if(!o)return;let l=e.targetWindow;if(!l)return;let s=e.options.useScrollendEvent&&U4,c=0,d=s?null:(r=()=>t(c,!1),a=e.options.isScrollingResetDelay,function(...e){l.clearTimeout(i),i=l.setTimeout(()=>r.apply(this,e),a)}),u=e=>()=>{c=n(o),null==d||d(),t(c,e)},f=u(!0),h=u(!1);return o.addEventListener("scroll",f,U5),s&&o.addEventListener("scrollend",h,U5),()=>{o.removeEventListener("scroll",f),s&&o.removeEventListener("scrollend",h)}})(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),U6=(e,t,n)=>{if(null==t?void 0:t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},U8=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;null==(i=null==(a=r.scrollElement)?void 0:a.scrollTo)||i.call(a,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})};class U7{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,t,n;return(null==(n=null==(t=null==(e=this.targetWindow)?void 0:e.performance)?void 0:t.now)?void 0:n.call(t))??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){for(let[e,n]of(this.observer.unobserve(t),this.elementsCache))if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var n;null==(n=t())||n.disconnect(),e=null},observe:e=>{var n;return null==(n=t())?void 0:n.observe(e,{box:"border-box"})},unobserve:e=>{var n;return null==(n=t())?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:U0,rangeExtractor:U1,onChange:()=>{},measureElement:U6,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate"};for(let n in e){let r=e[n];void 0!==r&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;null==(n=(t=this.options).onChange)||n.call(t,this,e)},this.maybeNotify=UY(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();if(this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{null!==this._intendedScrollOffset&&1.5>Math.abs(e-this._intendedScrollOffset)&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,UJ()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener("touchstart",t,U5),e.addEventListener("touchend",n,U5),this.unsubs.push(()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchend",n),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let a=t-1;a>=0;a--){let t=e[a];if(n.has(t.lane))continue;let i=r.get(t.lane);if(null==i||t.end>i.end?r.set(t.lane,t):t.end<i.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=UY(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,a,i,o)=>(void 0!==this.prevLanes&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:a,lanes:i,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=UY(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:a,lanes:i,laneAssignmentMode:o},l)=>{let s=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),1===i){var d;let a,i=this.options.gap,o=2*e,l=this._flatMeasurements;if(!l||l.length<o){let e=new Float64Array(o);l&&c>0&&e.set(l.subarray(0,2*c)),l=e,this._flatMeasurements=l}if(0===c)a=t+n;else{let e=c-1;a=l[2*e]+l[2*e+1]+i}for(let t=c;t<e;t++){let e=r(t),n=s.get(e),o="number"==typeof n?n:this.options.estimateSize(t);l[2*t]=a,l[2*t+1]=o,a+=o+i}let u=(d=l,new Proxy(Array(e),{get(t,n,a){if("string"==typeof n){let a=n.charCodeAt(0);if(a>=48&&a<=57){let a=+n;if(Number.isInteger(a)&&a>=0&&a<e){let e=t[a];if(!e){let n=d[2*a];e=t[a]={index:a,key:r(a),start:n,size:d[2*a+1],end:n+d[2*a+1],lane:0}}return e}}if("length"===n)return e}return Reflect.get(t,n,a)}}));return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,c),f=Array(i).fill(void 0);for(let e=0;e<c;e++){let t=u[e];t&&(f[t.lane]=e)}for(let a=c;a<e;a++){let e,i,l=r(a),c=this.laneAssignments.get(a),d="estimate"===o||s.has(l);if(void 0!==c&&this.options.lanes>1){let r=f[e=c],a=void 0!==r?u[r]:void 0;i=a?a.end+this.options.gap:t+n}else{let r=1===this.options.lanes?u[a-1]:this.getFurthestMeasurement(u,a);i=r?r.end+this.options.gap:t+n,e=r?r.lane:a%this.options.lanes,this.options.lanes>1&&d&&this.laneAssignments.set(a,e)}let h=s.get(l),m="number"==typeof h?h:this.options.estimateSize(a),p=i+m;u[a]={index:a,start:i,size:m,end:p,key:l,lane:e},f[e]=a}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=UY(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?function({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:a}){let i=e.length-1,o=a?e=>a[2*e]:t=>e[t].start,l=a?e=>a[2*e]+a[2*e+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:i};let s=U9(0,i,o,n),c=s;if(1===r)for(;c<i&&l(c)<n+t;)c++;else if(r>1){let a=Array(r).fill(0);for(;c<i&&a.some(e=>e<n+t);){let t=e[c];a[t.lane]=t.end,c++}let o=Array(r).fill(n+t);for(;s>=0&&o.some(e=>e>=n);){let t=e[s];o[t.lane]=t.start,s--}s=Math.max(0,s-s%r),c=Math.min(i,c+(r-1-c%r))}return{startIndex:s,endIndex:c}}({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:1===r&&null!=this._flatMeasurements?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=UY(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,a)=>null===r||null===a?[]:e({startIndex:r,endIndex:a,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;let n=this.scrollState.index??(null==(t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:t.index);if(void 0!==n&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,n-t),a=Math.min(this.options.count-1,n+t);return e>=r&&e<=a}return!0},this.measureElement=e=>{if(!e)return void this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;let r,a,i;if(e<0||e>=this.options.count)return;let o=this._flatMeasurements;if(1===this.options.lanes&&null!==o)i=this.options.getItemKey(e),a=o[2*e],r=o[2*e+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,a=t.start,r=t.size}let l=t-(this.itemSizeCache.get(i)??r);0!==l&&((null==(n=this.scrollState)?void 0:n.behavior)!=="smooth"&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:a,size:r,end:a+r,lane:0},l,this):a<this.getScrollOffset()+this.scrollAdjustments&&"backward"!==this.scrollDirection)&&(UJ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=l:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0})),(null===this.pendingMin||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=UY(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,a=e.length;r<a;r++){let a=t[e[r]];n.push(a)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(0===t.length)return;let n=this._flatMeasurements,r=1===this.options.lanes&&null!=n,a=U9(0,t.length-1,r?e=>n[2*e]:e=>UZ(t[e]).start,e);return UZ(t[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),a=this.getScrollOffset();return"auto"===t&&(t=e>=a+r?"end":"start"),"center"===t?e+=(n-r)/2:"end"===t&&(e-=r),Math.max(Math.min(this.getMaxScrollOffset(),e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),a=this.measurementsCache[e];if(!a)return;if("auto"===t)if(a.end>=r+n-this.options.scrollPaddingEnd)t="end";else{if(!(a.start<=r+this.options.scrollPaddingStart))return[r,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let i="end"===t?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,t,a.size),t]},this.scrollToOffset=(e,{align:t="start",behavior:n="auto"}={})=>{let r=this.getOffsetForAlignment(e,t),a=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t="auto",behavior:n="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[a,i]=r,o=this.now();this.scrollState={index:e,align:i,behavior:n,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t="auto"}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t,n=this.getMeasurements();if(0===n.length)t=this.options.paddingStart;else if(1===this.options.lanes){let r=n.length-1,a=this._flatMeasurements;t=null!=a?a[2*r]+a[2*r+1]:(null==(e=n[r])?void 0:e.end)??0}else{let e=Array(this.options.lanes).fill(null),r=n.length-1;for(;r>=0&&e.some(e=>null===e);){let t=n[r];null===e[t.lane]&&(e[t.lane]=t.end),r--}t=Math.max(...e.filter(e=>null!==e))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(0===this.itemSizeCache.size)return e;for(let t of this.getMeasurements())t&&this.itemSizeCache.has(t.key)&&e.push({index:t.index,key:t.key,start:t.start,size:t.size,end:t.end,lane:t.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&1.01>Math.abs(t-this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r="smooth"===this.scrollState.behavior&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:r?"smooth":"auto"})}this.scheduleScrollReconcile()}}let U9=(e,t,n,r)=>{for(;e<=t;){let a=(e+t)/2|0,i=n(a);if(i<r)e=a+1;else{if(!(i>r))return a;t=a-1}}return e>0?e-1:0},We="u">typeof document?ew.useLayoutEffect:ew.useEffect,Wt=(0,ek.default)("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),Wn={pathSeparator:"/",searchPlaceholder:"Filter rows...",rows:e=>`${e.toLocaleString()} rows`,columns:e=>`${e.toLocaleString()} columns`,selected:e=>`${e.toLocaleString()} selected`,copied:"Copied",copyCell:"Copy cell",noRows:"No rows match this view.",selectAllRows:"Select all visible rows",selectRow:e=>`Select row ${e+1}`,resizeColumn:"Resize column",sortAsc:"Sort ascending",sortDesc:"Sort descending",sortClear:"Clear sorting"};function Wr(e,t){return"function"==typeof e?e(t):e}function Wa(e){return null==e?"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):e instanceof Date?e.toISOString():JSON.stringify(e)}function Wi(e){return"number"==typeof e?e:"boolean"==typeof e?+!!e:Wa(e).toLowerCase()}function Wo({file:e={name:"data-table.csv",type:"records"},rows:t,data:n,columns:r,source:a,rowId:i,sorting:o,defaultSorting:l=[],onSortingChange:s,globalFilter:c,defaultGlobalFilter:d="",onGlobalFilterChange:u,rowSelection:f,defaultRowSelection:h={},onRowSelectionChange:m,columnSizing:p,defaultColumnSizing:g={},onColumnSizingChange:v,onCellCopy:x,showHeader:y=!0,showToolbar:b=!0,rowHeight:w=32,overscan:j=14,labels:k,className:S,headerClassName:N,toolbarClassName:C,gridClassName:M,...E}){let O=ew.useMemo(()=>({...Wn,...k}),[k]),P=ew.useMemo(()=>{var e,t;let n;return(e=a)?"csv"===e.type?function(e,t=","){let n=function(e,t=","){let n=[],r="",a=[],i=!1;for(let o=0;o<e.length;o+=1){let l=e[o],s=e[o+1];if('"'===l){i&&'"'===s?(r+='"',o+=1):i=!i;continue}if(!i&&l===t){a.push(r),r="";continue}if(!i&&("\n"===l||"\r"===l)){"\r"===l&&"\n"===s&&(o+=1),a.push(r),n.push(a),a=[],r="";continue}r+=l}return a.push(r),a.some(e=>e.length>0)&&n.push(a),n}(e.trim(),t),r=n[0]?.map((e,t)=>e.trim()||`Column ${t+1}`)??[];return{rows:n.slice(1).map(e=>{let t={};return r.forEach((n,r)=>{t[n]=e[r]??""}),t}),columns:r.map(e=>({id:e,header:e,accessorKey:e,minWidth:96,width:Math.max(120,Math.min(260,12*e.length+80))}))}}(e.content,e.delimiter):Array.isArray(n="string"==typeof(t=e.content)?JSON.parse(t):t)?{rows:n,columns:void 0}:n&&"object"==typeof n?{rows:n.rows??n.data??[n],columns:n.columns}:{rows:[{value:n}],columns:void 0}:{rows:void 0,columns:void 0}},[a]),A=ew.useMemo(()=>n??t??P.rows??[],[n,t,P.rows]),I=ew.useMemo(()=>r??P.columns??function(e){let t=new Set;for(let n of e.slice(0,50))Object.keys(n).forEach(e=>t.add(e));return Array.from(t).map(e=>({id:e,header:e,accessorKey:e,minWidth:96,width:Math.max(120,Math.min(280,12*e.length+88))}))}(A),[r,P.columns,A]),[z,T]=ew.useState(l),[D,R]=ew.useState(d),[_,L]=ew.useState(h),[$,F]=ew.useState(g),[B,V]=ew.useState(void 0),[H,U]=ew.useState(void 0),W=ew.useRef(null),q=o??z,K=c??D,G=f??_,X=p??$,Y=function(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=ew.useState(()=>({current:function(e){var t,n;let r=[...UG,...null!=(t=e._features)?t:[]],a={_features:r},i=a._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultOptions?void 0:t.getDefaultOptions(a)),{}),o={...null!=(n=e.initialState)?n:{}};a._features.forEach(e=>{var t;o=null!=(t=null==e.getInitialState?void 0:e.getInitialState(o))?t:o});let l=[],s=!1,c={_features:r,options:{...i,...e},initialState:o,_queue:e=>{l.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;l.length;)l.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{a.setState(a.initialState)},setOptions:e=>{var t;t=Uc(e,a.options),a.options=a.options.mergeOptions?a.options.mergeOptions(i,t):{...i,...t}},getState:()=>a.options.state,setState:e=>{null==a.options.onStateChange||a.options.onStateChange(e)},_getRowId:(e,t,n)=>{var r;return null!=(r=null==a.options.getRowId?void 0:a.options.getRowId(e,t,n))?r:`${n?[n.id,t].join("."):t}`},getCoreRowModel:()=>(a._getCoreRowModel||(a._getCoreRowModel=a.options.getCoreRowModel(a)),a._getCoreRowModel()),getRowModel:()=>a.getPaginationRowModel(),getRow:(e,t)=>{let n=(t?a.getPrePaginationRowModel():a.getRowModel()).rowsById[e];if(!n&&!(n=a.getCoreRowModel().rowsById[e]))throw Error();return n},_getDefaultColumnDef:Uf(()=>[a.options.defaultColumn],e=>{var t;return e=null!=(t=e)?t:{},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t,n;return null!=(t=null==(n=e.renderValue())||null==n.toString?void 0:n.toString())?t:null},...a._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultColumnDef?void 0:t.getDefaultColumnDef()),{}),...e}},Uh(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>a.options.columns,getAllColumns:Uf(()=>[a._getColumnDefs()],e=>{let t=function(e,n,r){return void 0===r&&(r=0),e.map(e=>{let i=function(e,t,n,r){var a,i;let o,l={...e._getDefaultColumnDef(),...t},s=l.accessorKey,c=null!=(a=null!=(i=l.id)?i:s?"function"==typeof String.prototype.replaceAll?s.replaceAll(".","_"):s.replace(/\./g,"_"):void 0)?a:"string"==typeof l.header?l.header:void 0;if(l.accessorFn?o=l.accessorFn:s&&(o=s.includes(".")?e=>{let t=e;for(let e of s.split(".")){var n;t=null==(n=t)?void 0:n[e]}return t}:e=>e[l.accessorKey]),!c)throw Error();let d={id:`${String(c)}`,accessorFn:o,parent:r,depth:n,columnDef:l,columns:[],getFlatColumns:Uf(()=>[!0],()=>{var e;return[d,...null==(e=d.columns)?void 0:e.flatMap(e=>e.getFlatColumns())]},Uh(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:Uf(()=>[e._getOrderColumnsFn()],e=>{var t;return null!=(t=d.columns)&&t.length?e(d.columns.flatMap(e=>e.getLeafColumns())):[d]},Uh(e.options,"debugColumns","column.getLeafColumns"))};for(let t of e._features)null==t.createColumn||t.createColumn(d,e);return d}(a,e,r,n);return i.columns=e.columns?t(e.columns,i,r+1):[],i})};return t(e)},Uh(e,"debugColumns","getAllColumns")),getAllFlatColumns:Uf(()=>[a.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),Uh(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:Uf(()=>[a.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),Uh(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:Uf(()=>[a.getAllColumns(),a._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),Uh(e,"debugColumns","getAllLeafColumns")),getColumn:e=>a._getAllFlatColumnsById()[e]};Object.assign(a,c);for(let e=0;e<a._features.length;e++){let t=a._features[e];null==t||null==t.createTable||t.createTable(a)}return a}(t)})),[r,a]=ew.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{a(t),null==e.onStateChange||e.onStateChange(t)}})),n.current}({data:A,columns:ew.useMemo(()=>I.map(e=>({id:e.id,accessorFn:(t,n)=>e.accessorFn?e.accessorFn(t,n):e.accessorKey?t[e.accessorKey]:void 0,header:()=>e.header,cell:t=>e.cell?e.cell({row:t.row.original,rowIndex:t.row.index,value:t.getValue(),column:e}):Wa(t.getValue()),sortingFn:(e,t,n)=>{let r=Wi(e.getValue(n)),a=Wi(t.getValue(n));return"number"==typeof r&&"number"==typeof a?r-a:String(r).localeCompare(String(a),void 0,{numeric:!0})},enableSorting:e.enableSorting??!0,enableGlobalFilter:e.enableFiltering??!0,size:e.width??168,minSize:e.minWidth??80,maxSize:e.maxWidth??640,meta:{align:e.align,className:e.className,headerClassName:e.headerClassName,copyValue:e.copyValue,sourceColumn:e}})),[I]),state:{sorting:q,globalFilter:K,rowSelection:G,columnSizing:X},defaultColumn:{minSize:80,size:168,maxSize:640},columnResizeMode:"onChange",enableRowSelection:!0,getRowId:"function"==typeof i?(e,t)=>i(e,t):i?(e,t)=>Wa(e[i])||String(t):void 0,onSortingChange:e=>{let t=Wr(e,q);void 0===o&&T(t),s?.(t)},onGlobalFilterChange:e=>{let t=Wr(e,K);void 0===c&&R(t),u?.(t)},onRowSelectionChange:e=>{let t=Wr(e,G);void 0===f&&L(t),m?.(t)},onColumnSizingChange:e=>{let t=Wr(e,X);void 0===p&&F(t),v?.(t)},globalFilterFn:(e,t,n)=>{let r=String(n??"").trim().toLowerCase();return!r||Wa(e.getValue(t)).toLowerCase().includes(r)},getCoreRowModel:e=>Uf(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,a,i){void 0===a&&(a=0);let o=[];for(let s=0;s<t.length;s++){let c=Uv(e,e._getRowId(t[s],s,i),t[s],s,a,void 0,null==i?void 0:i.id);if(n.flatRows.push(c),n.rowsById[c.id]=c,o.push(c),e.options.getSubRows){var l;c.originalSubRows=e.options.getSubRows(t[s],s),null!=(l=c.originalSubRows)&&l.length&&(c.subRows=r(c.originalSubRows,a+1,c))}}return o};return n.rows=r(t),n},Uh(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>Uf(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{var a,i,o,l,s,c,d,u,f,h;let m,p,g,v,x,y,b,w,j,k;if(!t.rows.length||!(null!=n&&n.length)&&!r){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}let S=[],N=[];(null!=n?n:[]).forEach(t=>{var n;let r=e.getColumn(t.id);if(!r)return;let a=r.getFilterFn();a&&S.push({id:t.id,filterFn:a,resolvedValue:null!=(n=null==a.resolveFilterValue?void 0:a.resolveFilterValue(t.value))?n:t.value})});let C=(null!=n?n:[]).map(e=>e.id),M=e.getGlobalFilterFn(),E=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());r&&M&&E.length&&(C.push("__global__"),E.forEach(e=>{var t;N.push({id:e.id,filterFn:M,resolvedValue:null!=(t=null==M.resolveFilterValue?void 0:M.resolveFilterValue(r))?t:r})}));for(let e=0;e<t.flatRows.length;e++){let n=t.flatRows[e];if(n.columnFilters={},S.length)for(let e=0;e<S.length;e++){let t=(m=S[e]).id;n.columnFilters[t]=m.filterFn(n,t,m.resolvedValue,e=>{n.columnFiltersMeta[t]=e})}if(N.length){for(let e=0;e<N.length;e++){let t=(p=N[e]).id;if(p.filterFn(n,t,p.resolvedValue,e=>{n.columnFiltersMeta[t]=e})){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return a=t.rows,i=e=>{for(let t=0;t<C.length;t++)if(!1===e.columnFilters[C[t]])return!1;return!0},e.options.filterFromLeafRows?(o=a,l=i,g=[],v={},x=null!=(c=(s=e).options.maxLeafRowFilterDepth)?c:100,{rows:(y=function(e,t){void 0===t&&(t=0);let n=[];for(let a=0;a<e.length;a++){var r;let i=e[a],o=Uv(s,i.id,i.original,i.index,i.depth,void 0,i.parentId);if(o.columnFilters=i.columnFilters,null!=(r=i.subRows)&&r.length&&t<x){if(o.subRows=y(i.subRows,t+1),l(i=o)&&!o.subRows.length||l(i)||o.subRows.length){n.push(i),v[i.id]=i,g.push(i);continue}}else l(i=o)&&(n.push(i),v[i.id]=i,g.push(i))}return n})(o),flatRows:g,rowsById:v}):(d=a,u=i,b=[],w={},j=null!=(h=(f=e).options.maxLeafRowFilterDepth)?h:100,{rows:(k=function(e,t){void 0===t&&(t=0);let n=[];for(let a=0;a<e.length;a++){let i=e[a];if(u(i)){var r;if(null!=(r=i.subRows)&&r.length&&t<j){let e=Uv(f,i.id,i.original,i.index,i.depth,void 0,i.parentId);e.subRows=k(i.subRows,t+1),i=e}n.push(i),b.push(i),w[i.id]=i}}return n})(d),flatRows:b,rowsById:w})},Uh(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),getSortedRowModel:e=>Uf(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(null!=t&&t.length))return n;let r=e.getState().sorting,a=[],i=r.filter(t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()}),o={};i.forEach(t=>{let n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});let l=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let r=0;r<i.length;r+=1){var n;let a=i[r],l=o[a.id],s=l.sortUndefined,c=null!=(n=null==a?void 0:a.desc)&&n,d=0;if(s){let n=e.getValue(a.id),r=t.getValue(a.id),i=void 0===n,o=void 0===r;if(i||o){if("first"===s)return i?-1:1;if("last"===s)return i?1:-1;d=i&&o?0:i?s:-s}}if(0===d&&(d=l.sortingFn(e,t,a.id)),0!==d)return c&&(d*=-1),l.invertSorting&&(d*=-1),d}return e.index-t.index}),t.forEach(e=>{var t;a.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=l(e.subRows))}),t};return{rows:l(n.rows),flatRows:a,rowsById:n.rowsById}},Uh(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}),Z=Y.getRowModel().rows,J=function({useFlushSync:e=!0,...t}){let n=ew.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,a)=>{var i;e&&a?(0,iy.flushSync)(n):n(),null==(i=t.onChange)||i.call(t,r,a)}},[a]=ew.useState(()=>new U7(r));return a.setOptions(r),We(()=>a._didMount(),[]),We(()=>a._willUpdate()),a}({observeElementRect:U2,observeElementOffset:U3,scrollToFn:U8,...{count:Z.length,getScrollElement:()=>W.current,estimateSize:()=>w,overscan:j,scrollMargin:w}}),Q=Y.getVisibleLeafColumns(),ee=Q.reduce((e,t)=>e+t.getSize(),40),et=`40px ${Q.map(e=>`${e.getSize()}px`).join(" ")}`,en=(e?.path??e?.name??"data-table").split(/[\\/]+/).filter(Boolean),er=Y.getSelectedRowModel().rows.length;async function ea(e,t){let n=I.find(e=>e.id===t);if(!n)return;let r=e.getValue(t),a=n.copyValue?n.copyValue({row:e.original,rowIndex:e.index,value:r,column:n}):Wa(r);await Wl(a)&&(U({rowId:e.id,columnId:t}),x?.({row:e.original,rowIndex:e.index,columnId:t,value:r,text:a}),window.setTimeout(()=>{U(n=>n?.rowId===e.id&&n.columnId===t?void 0:n)},1200))}return(0,ey.jsxs)("div",{"data-slot":"data-table-tab-viewer",className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 w-full min-w-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",y&&b?"grid-rows-[auto_auto_minmax(0,1fr)]":y||b?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",S),...E,children:[y&&(0,ey.jsxs)("div",{"data-slot":"data-table-tab-viewer-header",className:(0,eI.cn)("flex min-h-9 min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",N),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,ey.jsx)(uN,{className:"size-3.5"})}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:en.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[t>0&&(0,ey.jsx)("span",{className:"text-muted-foreground",children:O.pathSeparator}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",t<en.length-1?"text-muted-foreground":"text-foreground"),children:e})]},`${e}-${t}`))}),(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground ui-text-kbd",children:e.type??"records"})]}),b&&(0,ey.jsxs)("div",{"data-slot":"data-table-tab-viewer-toolbar",className:(0,eI.cn)("flex min-h-10 min-w-0 items-center gap-2 border-b px-3 py-1.5",C),children:[(0,ey.jsxs)("div",{className:"relative min-w-36 flex-1 sm:max-w-80",children:[(0,ey.jsx)(vk,{className:"pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,ey.jsx)(ez,{value:K,onChange:e=>Y.setGlobalFilter(e.target.value),placeholder:O.searchPlaceholder,className:"h-7 rounded-md border-border bg-background pl-8 ui-text-control"})]}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-muted-foreground ui-text-kbd",children:[(0,ey.jsx)("span",{children:O.rows(Z.length)}),(0,ey.jsx)("span",{className:"h-3 w-px bg-border"}),(0,ey.jsx)("span",{children:O.columns(I.length)}),er>0&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{className:"h-3 w-px bg-border"}),(0,ey.jsx)("span",{className:"text-foreground",children:O.selected(er)})]})]})]}),(0,ey.jsx)("div",{ref:W,"data-slot":"data-table-tab-viewer-grid",className:(0,eI.cn)("min-h-0 min-w-0 overflow-auto bg-background","[scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]","[&::-webkit-scrollbar]:size-2.5 [&::-webkit-scrollbar-corner]:bg-transparent [&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-[3px] [&::-webkit-scrollbar-thumb]:border-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:bg-clip-content",M),children:(0,ey.jsxs)("div",{className:"relative min-h-full",style:{width:ee,minWidth:"100%"},children:[(0,ey.jsxs)("div",{"data-slot":"data-table-tab-viewer-head",className:"sticky top-0 z-20 grid min-w-full border-b bg-muted/70 backdrop-blur",style:{gridTemplateColumns:et,width:ee,minWidth:"100%"},children:[(0,ey.jsx)("div",{className:"grid h-8 place-items-center border-r",children:(0,ey.jsx)(v$,{checked:!!Y.getIsAllRowsSelected()||!!Y.getIsSomeRowsSelected()&&"indeterminate",onCheckedChange:e=>Y.toggleAllRowsSelected(!0===e),"aria-label":O.selectAllRows})}),Y.getFlatHeaders().map(e=>{let t=e.column.columnDef.meta,n=e.column.getIsSorted();return(0,ey.jsxs)("div",{className:(0,eI.cn)("group/header relative flex h-8 min-w-0 items-center border-r text-muted-foreground",t?.align==="right"&&"justify-end",t?.align==="center"&&"justify-center",t?.headerClassName),children:[(0,ey.jsxs)("button",{type:"button",disabled:!e.column.getCanSort(),"aria-label":`${Wa(t?.sourceColumn.header??e.id)}: ${"asc"===n?O.sortDesc:"desc"===n?O.sortClear:O.sortAsc}`,onClick:e.column.getToggleSortingHandler(),className:(0,eI.cn)("flex h-full min-w-0 flex-1 items-center gap-1.5 px-2 text-left ui-text-kbd",e.column.getCanSort()&&"text-foreground hover:bg-muted"),children:[(0,ey.jsx)("span",{className:"truncate",children:UX(e.column.columnDef.header,e.getContext())}),"asc"===n?(0,ey.jsx)(jP,{className:"size-3 shrink-0"}):"desc"===n?(0,ey.jsx)(jO,{className:"size-3 shrink-0"}):e.column.getCanSort()?(0,ey.jsx)(Wt,{className:"size-3 shrink-0 opacity-45"}):null]}),e.column.getCanResize()&&(0,ey.jsx)("button",{type:"button","aria-label":O.resizeColumn,onDoubleClick:()=>e.column.resetSize(),onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:(0,eI.cn)("absolute top-0 right-0 h-full w-2 translate-x-1/2 cursor-col-resize touch-none","after:absolute after:top-1 after:right-1/2 after:bottom-1 after:w-px after:bg-border","hover:after:bg-foreground",e.column.getIsResizing()&&"after:bg-foreground")})]},e.id)})]}),0===Z.length?(0,ey.jsx)("div",{className:"grid min-h-44 place-items-center text-muted-foreground ui-text-body",children:O.noRows}):(0,ey.jsx)("div",{"data-slot":"data-table-tab-viewer-rows",className:"relative",style:{height:J.getTotalSize()},children:J.getVirtualItems().map(e=>{let t=Z[e.index];return t?(0,ey.jsxs)("div",{"data-slot":"data-table-tab-viewer-row","data-state":t.getIsSelected()?"selected":void 0,className:(0,eI.cn)("absolute left-0 grid min-w-full border-b transition-colors","hover:bg-muted/40 data-[state=selected]:bg-muted/65"),style:{gridTemplateColumns:et,width:ee,minWidth:"100%",height:e.size,transform:`translateY(${e.start-J.options.scrollMargin}px)`},children:[(0,ey.jsx)("div",{className:"grid place-items-center border-r",children:(0,ey.jsx)(v$,{checked:t.getIsSelected(),onCheckedChange:e=>t.toggleSelected(!0===e),"aria-label":O.selectRow(t.index)})}),t.getVisibleCells().map(e=>{let n=e.column.columnDef.meta,r=B?.rowId===t.id&&B.columnId===e.column.id,a=H?.rowId===t.id&&H.columnId===e.column.id;return(0,ey.jsxs)("button",{type:"button","data-slot":"data-table-tab-viewer-cell","data-active":r?"":void 0,onClick:()=>V({rowId:t.id,columnId:e.column.id}),onDoubleClick:()=>ea(t,e.column.id),className:(0,eI.cn)("group/cell relative flex min-w-0 items-center border-r px-2 text-left ui-text-code","focus-visible:z-10 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none","data-active:bg-selection/10",n?.align==="right"&&"justify-end text-right",n?.align==="center"&&"justify-center text-center",n?.className),style:{height:w},children:[(0,ey.jsx)("span",{className:"min-w-0 truncate",children:UX(e.column.columnDef.cell,e.getContext())}),(0,ey.jsx)("span",{className:(0,eI.cn)("absolute top-1/2 right-1 grid size-5 -translate-y-1/2 place-items-center rounded-full border bg-background/95 text-muted-foreground opacity-0 shadow-xs transition-opacity","group-hover/cell:opacity-100",r&&"opacity-100"),title:O.copyCell,onClick:n=>{n.stopPropagation(),ea(t,e.column.id)},children:a?(0,ey.jsx)(mZ,{className:"size-3"}):(0,ey.jsx)(lU,{className:"size-3"})})]},e.id)})]},t.id):null})})]})})]})}async function Wl(e){try{return await navigator.clipboard?.writeText(e),!0}catch{var t=e;try{let e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",document.body.appendChild(e),e.select();let n=document.execCommand("copy");return document.body.removeChild(e),n}catch{return!1}}}let Ws=(0,ek.default)("rows-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]),Wc={pathSeparator:"/",additions:"additions",deletions:"deletions",actions:"Diff view options",unified:"Unified diff",split:"Split diff",foldedLines:e=>`${e} folded lines`,expandDown:"Expand next lines",expandUp:"Expand previous lines",expandAll:"Expand folded lines",empty:"No diff content."};function Wd(e){return void 0===e?"":String(e)}function Wu({line:e,language:t}){let n=ew.useMemo(()=>(function(e,t){if(!e)return[{text:" ",type:"plain"}];let n=RegExp(`("(?:(?:\\\\.)|[^"\\\\])*"|'(?:(?:\\\\.)|[^'\\\\])*'|\\\`(?:(?:\\\\.)|[^\\\`\\\\])*\\\`|//.*|${"css"===t?"\\b(?:align-items|background|border|className|color|display|font|gap|grid|height|justify-content|margin|padding|position|width)\\b":"\\b(?:as|async|await|const|export|false|from|function|if|import|in|let|new|null|return|string|true|type|undefined)\\b"}|\\b\\d+(?:\\.\\d+)?\\b|[{}()[\\].,;:<>/=+\\-*])`,"g"),r=[],a=0;for(let t of e.matchAll(n)){let n=t[0],i=t.index??0;i>a&&r.push({text:e.slice(a,i),type:"plain"}),n.startsWith("//")?r.push({text:n,type:"comment"}):/^["'`]/.test(n)?r.push({text:n,type:"string"}):/^\d/.test(n)?r.push({text:n,type:"number"}):/^[{}()[\].,;:<>/=+\-*]$/.test(n)?r.push({text:n,type:"punctuation"}):r.push({text:n,type:"keyword"}),a=i+n.length}return a<e.length&&r.push({text:e.slice(a),type:"plain"}),r})(e,t),[t,e]);return(0,ey.jsx)(ey.Fragment,{children:n.map((e,t)=>(0,ey.jsx)("span",{className:(0,eI.cn)("comment"===e.type&&"text-[var(--vtl-diff-comment)] italic","keyword"===e.type&&"text-[var(--vtl-diff-keyword)]","string"===e.type&&"text-[var(--vtl-diff-string)]","number"===e.type&&"text-[var(--vtl-diff-number)]","punctuation"===e.type&&"text-[var(--vtl-diff-punctuation)]"),children:e.text},`${e.text}-${t}`))})}function Wf({row:e,language:t,side:n,blankType:r}){if(!e)return(0,ey.jsxs)("div",{className:(0,eI.cn)("relative grid grid-cols-[2.5rem_minmax(0,1fr)] items-stretch overflow-hidden bg-[var(--vtl-diff-empty-bg)]","old"===n&&"border-r",r&&"bg-[image:var(--vtl-diff-empty-hatch)]"),children:[r&&(0,ey.jsx)("span",{className:(0,eI.cn)("absolute inset-y-0 left-0 w-1","insert"===r&&"bg-[var(--vtl-diff-insert-fg)]","delete"===r&&"bg-[var(--vtl-diff-delete-fg)]")}),(0,ey.jsx)("span",{}),(0,ey.jsx)("span",{})]});let a="old"===n?"insert"===e.type?void 0:e.oldLineNumber:"delete"===e.type?void 0:e.newLineNumber;return(0,ey.jsxs)("div",{className:(0,eI.cn)("relative grid grid-cols-[2.5rem_minmax(0,1fr)] items-stretch overflow-hidden","old"===n&&"border-r","insert"===e.type&&"bg-[var(--vtl-diff-insert-bg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-bg)]"),children:["context"!==e.type&&(0,ey.jsx)("span",{className:(0,eI.cn)("absolute inset-y-0 left-0 w-1","insert"===e.type&&"bg-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-fg)]")}),(0,ey.jsx)("span",{className:(0,eI.cn)("select-none bg-inherit px-2 text-right text-[var(--vtl-diff-gutter-fg)]","insert"===e.type&&"text-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"text-[var(--vtl-diff-delete-fg)]"),children:Wd(a)}),(0,ey.jsx)("span",{className:"overflow-hidden px-3 text-[var(--vtl-diff-code-fg)]",children:(0,ey.jsx)("span",{className:"inline-block whitespace-pre will-change-transform",style:{transform:"translateX(calc(var(--vtl-diff-scroll-left,0px) * -1))"},children:(0,ey.jsx)(Wu,{line:e.content,language:t})})})]})}function Wh({row:e,language:t,style:n,viewportWidth:r}){return(0,ey.jsx)("div",{"data-slot":"diff-tab-viewer-line","data-type":e.type,className:(0,eI.cn)("absolute w-full min-w-full ui-text-code","insert"===e.type&&"bg-[var(--vtl-diff-insert-bg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-bg)]"),style:n,children:(0,ey.jsxs)("div",{className:"sticky left-0 grid h-full grid-cols-[2.5rem_minmax(0,1fr)] items-stretch",style:{width:r},children:["context"!==e.type&&(0,ey.jsx)("span",{className:(0,eI.cn)("absolute inset-y-0 left-0 w-1","insert"===e.type&&"bg-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-fg)]")}),(0,ey.jsx)("span",{className:(0,eI.cn)("select-none bg-inherit px-2 text-right text-[var(--vtl-diff-gutter-fg)]","insert"===e.type&&"text-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"text-[var(--vtl-diff-delete-fg)]"),children:Wd(e.newLineNumber)}),(0,ey.jsx)("span",{className:"overflow-hidden px-3 text-[var(--vtl-diff-code-fg)]",children:(0,ey.jsx)("span",{className:"inline-block whitespace-pre will-change-transform",style:{transform:"translateX(calc(var(--vtl-diff-scroll-left,0px) * -1))"},children:(0,ey.jsx)(Wu,{line:e.content,language:t})})})]})})}function Wm({row:e,language:t,style:n,viewportWidth:r}){return(0,ey.jsx)("div",{"data-slot":"diff-tab-viewer-split-line",className:"absolute w-full min-w-full ui-text-code",style:n,children:(0,ey.jsxs)("div",{className:"sticky left-0 grid h-full grid-cols-[minmax(0,1fr)_minmax(0,1fr)] items-stretch",style:{width:r},children:[(0,ey.jsx)(Wf,{row:e.oldLine,language:t,side:"old",blankType:e.oldBlankType}),(0,ey.jsx)(Wf,{row:e.newLine,language:t,side:"new",blankType:e.newBlankType})]})})}function Wp({row:e,labels:t,style:n,viewportWidth:r,onExpand:a}){let i="fold-count"===e.kind,o=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("span",{}),i?(0,ey.jsx)("div",{className:"flex h-full min-w-0 items-center justify-start px-3 text-muted-foreground",children:(0,ey.jsx)("span",{children:t.foldedLines(e.hiddenCount)})}):(0,ey.jsx)("button",{type:"button",className:"group flex h-full min-w-0 items-center gap-2 px-3 text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:bg-muted/70","aria-label":"down"===e.direction?t.expandDown:t.expandUp,onClick:()=>a(e.direction),children:(0,ey.jsxs)(ey.Fragment,{children:["down"===e.direction?(0,ey.jsx)(vu,{className:"size-3.5 shrink-0"}):(0,ey.jsx)(vf,{className:"size-3.5 shrink-0"}),(0,ey.jsx)("span",{className:"h-px min-w-8 flex-1 bg-border transition-colors group-hover:bg-foreground/35"})]})})]});return void 0!==r?(0,ey.jsx)("div",{"data-slot":`diff-tab-viewer-${e.kind}`,className:"absolute w-full min-w-full bg-muted/25 ui-text-code",style:n,children:(0,ey.jsx)("div",{className:"sticky left-0 grid h-full grid-cols-[2.5rem_minmax(0,1fr)] items-stretch",style:{width:r},children:o})}):(0,ey.jsx)("div",{"data-slot":`diff-tab-viewer-${e.kind}`,className:"absolute grid w-full min-w-full grid-cols-[2.5rem_minmax(0,1fr)] items-stretch bg-muted/25 ui-text-code",style:n,children:o})}function Wg({open:e,labels:t,currentView:n,onOpenChange:r,onToggleView:a}){let i="unified"===n?t.split:t.unified;return(0,ey.jsx)("div",{"data-slot":"diff-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),a()},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out active:translate-y-0",e?"pointer-events-auto -translate-y-[42px] opacity-100":"pointer-events-none translate-y-1 opacity-0"),children:"unified"===n?(0,ey.jsx)(Ut,{className:"size-4"}):(0,ey.jsx)(Ws,{className:"size-4"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function Wv({file:e,lines:t,diff:n,showHeader:r=!0,contextBefore:a=4,contextAfter:i=4,minFoldLines:o=18,expandStep:l=50,rowHeight:s=22,view:c,defaultView:d="unified",onViewChange:u,labels:f,className:h,headerClassName:m,viewerClassName:p,style:g,...v}){let x,y=ew.useMemo(()=>({...Wc,...f}),[f]),b=ew.useMemo(()=>t??(n?function(e){let t=[],n=0,r=0,a=!1;for(let i of e.split("\n")){let e=/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/.exec(i);if(e){n=Number(e[1]),r=Number(e[2]),a=!0;continue}if(!a||i.startsWith("\\ No newline"))continue;let o=i[0],l=i.slice(1);if("+"===o){t.push({type:"insert",content:l,newLineNumber:r}),r+=1;continue}if("-"===o){t.push({type:"delete",content:l,oldLineNumber:n,newLineNumber:r}),n+=1;continue}t.push({type:"context",content:" "===o?l:i,oldLineNumber:n,newLineNumber:r}),n+=1,r+=1}return t}(n):[]),[n,t]),[w,j]=ew.useState({}),[k,S]=ew.useState(0),[N,C]=ew.useState(d),[M,E]=ew.useState(!1),O=ew.useRef(null),[P,A]=function(){let e=ew.useRef(null),[t,n]=ew.useState({height:0,width:0});return ew.useEffect(()=>{let t=e.current;if(!t)return;function r(){n({height:t.getBoundingClientRect().height,width:t.clientWidth})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}(),I=(x=/\.([^.\\/]+)$/.exec(e.name||e.path||""),(e.language??x?.[1]??"text").toLowerCase()),z=c??N,T=ew.useMemo(()=>b.reduce((e,t)=>({additions:e.additions+ +("insert"===t.type),deletions:e.deletions+ +("delete"===t.type),maxLineLength:Math.max(e.maxLineLength,t.content.length)}),{additions:0,deletions:0,maxLineLength:0}),[b]),D=ew.useMemo(()=>(function({rows:e,folds:t,contextBefore:n,contextAfter:r,minFoldLines:a}){let i=[],o=0;function l(e,t){i.push({kind:"line",id:`line-${t}-${e.type}`,line:e})}for(;o<e.length;){let s=e[o];if(s?.type!=="context"){s&&l(s,o),o+=1;continue}let c=o;for(;o<e.length&&e[o]?.type==="context";)o+=1;let d=o,u=d-c;if(u<=n+r+a){for(let t=c;t<d;t+=1)l(e[t],t);continue}let f=`${c}-${d}`,h=t[f]??{revealTop:0,revealBottom:0},m=Math.min(n+h.revealTop,u),p=Math.min(r+h.revealBottom,u-m),g=c+m,v=d-p,x=v-g;if(x<=0){for(let t=c;t<d;t+=1)l(e[t],t);continue}for(let t=c;t<g;t+=1)l(e[t],t);i.push({kind:"fold-action",id:`fold-${f}-down-${x}`,foldId:f,direction:"down",hiddenCount:x}),i.push({kind:"fold-count",id:`fold-${f}-count-${x}`,foldId:f,hiddenCount:x}),i.push({kind:"fold-action",id:`fold-${f}-up-${x}`,foldId:f,direction:"up",hiddenCount:x});for(let t=v;t<d;t+=1)l(e[t],t)}return i})({rows:b,folds:w,contextBefore:a,contextAfter:i,minFoldLines:o}),[i,a,w,o,b]),R=ew.useMemo(()=>(function(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!r)break;if("line"!==r.kind){t.push(r),n+=1;continue}if("context"===r.line.type){t.push({kind:"split-line",id:`split-${r.id}`,oldLine:r.line,newLine:r.line}),n+=1;continue}let a=[];for(;e[n]?.kind==="line";){let t=e[n];if("context"===t.line.type)break;a.push(t.line),n+=1}let i=a.filter(e=>"delete"===e.type),o=a.filter(e=>"insert"===e.type),l=Math.max(i.length,o.length);for(let e=0;e<l;e+=1){let n=i[e],r=o[e];t.push({kind:"split-line",id:`split-change-${t.length}-${n?.oldLineNumber??"empty"}-${r?.newLineNumber??"empty"}`,oldLine:n,newLine:r,oldBlankType:n?void 0:"insert",newBlankType:r?void 0:"delete"})}}return t})(D),[D]),_="split"===z?R:D,L=(e.path??e.name).split(/[\\/]+/).filter(Boolean),$=_.length*s,F=Math.max(0,Math.floor(k/s)-12),B=Math.min(_.length,Math.ceil((k+A.height)/s)+12),V=_.slice(F,B),H=Math.max(A.width,1),U=9.6*T.maxLineLength+168,W=Math.max(760,U),q=Math.max(A.width,1),K=Math.max(q,q/2+U),G=`${e.path??e.name}-${n??""}-${t?.length??0}`;return ew.useEffect(()=>{j({}),S(0),E(!1)},[G]),ew.useEffect(()=>{if(M)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&O.current?.contains(t)||E(!1)}},[M]),(0,ey.jsxs)("div",{ref:O,"data-slot":"diff-tab-viewer","data-view":z,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 w-full min-w-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",r?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",h),style:g,...v,children:[r&&(0,ey.jsxs)("div",{"data-slot":"diff-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",m),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,ey.jsx)(Un,{className:"size-3.5"})}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:L.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[t>0&&(0,ey.jsx)("span",{className:"text-muted-foreground",children:y.pathSeparator}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",t===L.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,ey.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[(0,ey.jsxs)(Bs,{variant:"outline",className:"text-[var(--vtl-diff-insert-fg)]",children:["+",T.additions," ",y.additions]}),(0,ey.jsxs)(Bs,{variant:"outline",className:"text-[var(--vtl-diff-delete-fg)]",children:["-",T.deletions," ",y.deletions]})]})]}),0===b.length?(0,ey.jsx)("div",{className:"grid min-h-0 place-items-center p-6 text-muted-foreground ui-text-body",children:y.empty}):(0,ey.jsx)("div",{ref:P,"data-slot":"diff-tab-viewer-body",className:(0,eI.cn)("min-h-0 min-w-0 overflow-auto bg-background font-mono","[scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]","[&::-webkit-scrollbar]:size-2.5 [&::-webkit-scrollbar-corner]:bg-transparent [&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-[3px] [&::-webkit-scrollbar-thumb]:border-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:bg-clip-content",p),style:{"--vtl-diff-scroll-left":"0px"},onScroll:e=>{S(e.currentTarget.scrollTop),e.currentTarget.style.setProperty("--vtl-diff-scroll-left",`${e.currentTarget.scrollLeft}px`)},children:(0,ey.jsx)("div",{"data-slot":"diff-tab-viewer-scroll-width",className:"relative min-h-full",style:{height:$,width:"split"===z?K:W,minWidth:"100%"},children:V.map((e,t)=>{let n=F+t,r={height:s,lineHeight:`${s}px`,transform:`translateY(${n*s}px)`};return"line"===e.kind?(0,ey.jsx)(Wh,{row:e.line,language:I,style:r,viewportWidth:H},e.id):"split-line"===e.kind?(0,ey.jsx)(Wm,{row:e,language:I,style:r,viewportWidth:q},e.id):(0,ey.jsx)(Wp,{row:e,labels:y,style:r,viewportWidth:"split"===z?q:void 0,onExpand:t=>{var n;return n=e.foldId,void j(e=>{let r=e[n]??{revealTop:0,revealBottom:0};return"all"===t?{...e,[n]:{revealTop:Number.MAX_SAFE_INTEGER,revealBottom:0}}:{...e,[n]:{revealTop:"down"===t?r.revealTop+l:r.revealTop,revealBottom:"up"===t?r.revealBottom+l:r.revealBottom}}})}},e.id)})})}),(0,ey.jsx)(Wg,{open:M,labels:y,currentView:z,onOpenChange:E,onToggleView:function(){var e;e="unified"===z?"split":"unified",void 0===c&&C(e),u?.(e)}})]})}var Wx=e.i(32800);function Wy(e){return new Wx.LanguageSupport(Wx.StreamLanguage.define(e))}function Wb(t){return e.A(22206).then(e=>e.sql({dialect:e[t]}))}let Ww=[Wx.LanguageDescription.of({name:"C",extensions:["c","h","ino"],load:()=>e.A(92137).then(e=>e.cpp())}),Wx.LanguageDescription.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>e.A(92137).then(e=>e.cpp())}),Wx.LanguageDescription.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Wb("Cassandra")}),Wx.LanguageDescription.of({name:"CSS",extensions:["css"],load:()=>e.A(79258).then(e=>e.css())}),Wx.LanguageDescription.of({name:"Go",extensions:["go"],load:()=>e.A(44771).then(e=>e.go())}),Wx.LanguageDescription.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>e.A(82412).then(e=>e.html())}),Wx.LanguageDescription.of({name:"Java",extensions:["java"],load:()=>e.A(35733).then(e=>e.java())}),Wx.LanguageDescription.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>e.A(56714).then(e=>e.javascript())}),Wx.LanguageDescription.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>e.A(68909).then(e=>e.jinja())}),Wx.LanguageDescription.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>e.A(42017).then(e=>e.json())}),Wx.LanguageDescription.of({name:"JSX",extensions:["jsx"],load:()=>e.A(56714).then(e=>e.javascript({jsx:!0}))}),Wx.LanguageDescription.of({name:"LESS",extensions:["less"],load:()=>e.A(23404).then(e=>e.less())}),Wx.LanguageDescription.of({name:"Liquid",extensions:["liquid"],load:()=>e.A(20628).then(e=>e.liquid())}),Wx.LanguageDescription.of({name:"MariaDB SQL",load:()=>Wb("MariaSQL")}),Wx.LanguageDescription.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>e.A(80207).then(e=>e.markdown())}),Wx.LanguageDescription.of({name:"MS SQL",load:()=>Wb("MSSQL")}),Wx.LanguageDescription.of({name:"MySQL",load:()=>Wb("MySQL")}),Wx.LanguageDescription.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>e.A(50333).then(e=>e.php())}),Wx.LanguageDescription.of({name:"PLSQL",extensions:["pls"],load:()=>Wb("PLSQL")}),Wx.LanguageDescription.of({name:"PostgreSQL",load:()=>Wb("PostgreSQL")}),Wx.LanguageDescription.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>e.A(43848).then(e=>e.python())}),Wx.LanguageDescription.of({name:"Rust",extensions:["rs"],load:()=>e.A(22094).then(e=>e.rust())}),Wx.LanguageDescription.of({name:"Sass",extensions:["sass"],load:()=>e.A(62363).then(e=>e.sass({indented:!0}))}),Wx.LanguageDescription.of({name:"SCSS",extensions:["scss"],load:()=>e.A(62363).then(e=>e.sass())}),Wx.LanguageDescription.of({name:"SQL",extensions:["sql"],load:()=>Wb("StandardSQL")}),Wx.LanguageDescription.of({name:"SQLite",load:()=>Wb("SQLite")}),Wx.LanguageDescription.of({name:"TSX",extensions:["tsx"],load:()=>e.A(56714).then(e=>e.javascript({jsx:!0,typescript:!0}))}),Wx.LanguageDescription.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>e.A(56714).then(e=>e.javascript({typescript:!0}))}),Wx.LanguageDescription.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>e.A(11043).then(e=>e.wast())}),Wx.LanguageDescription.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>e.A(25290).then(e=>e.xml())}),Wx.LanguageDescription.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>e.A(66027).then(e=>e.yaml())}),Wx.LanguageDescription.of({name:"APL",extensions:["dyalog","apl"],load:()=>e.A(66919).then(e=>Wy(e.apl))}),Wx.LanguageDescription.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>e.A(96245).then(e=>Wy(e.asciiArmor))}),Wx.LanguageDescription.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>e.A(95592).then(e=>Wy(e.asn1({})))}),Wx.LanguageDescription.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>e.A(38120).then(e=>Wy(e.asterisk))}),Wx.LanguageDescription.of({name:"Brainfuck",extensions:["b","bf"],load:()=>e.A(33855).then(e=>Wy(e.brainfuck))}),Wx.LanguageDescription.of({name:"Cobol",extensions:["cob","cpy"],load:()=>e.A(37413).then(e=>Wy(e.cobol))}),Wx.LanguageDescription.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>e.A(38138).then(e=>Wy(e.csharp))}),Wx.LanguageDescription.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>e.A(32566).then(e=>Wy(e.clojure))}),Wx.LanguageDescription.of({name:"ClojureScript",extensions:["cljs"],load:()=>e.A(32566).then(e=>Wy(e.clojure))}),Wx.LanguageDescription.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>e.A(48876).then(e=>Wy(e.gss))}),Wx.LanguageDescription.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>e.A(44086).then(e=>Wy(e.cmake))}),Wx.LanguageDescription.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>e.A(11973).then(e=>Wy(e.coffeeScript))}),Wx.LanguageDescription.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>e.A(16995).then(e=>Wy(e.commonLisp))}),Wx.LanguageDescription.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>e.A(45748).then(e=>Wy(e.cypher))}),Wx.LanguageDescription.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>e.A(64832).then(e=>Wy(e.cython))}),Wx.LanguageDescription.of({name:"Crystal",extensions:["cr"],load:()=>e.A(55133).then(e=>Wy(e.crystal))}),Wx.LanguageDescription.of({name:"D",extensions:["d"],load:()=>e.A(24299).then(e=>Wy(e.d))}),Wx.LanguageDescription.of({name:"Dart",extensions:["dart"],load:()=>e.A(38138).then(e=>Wy(e.dart))}),Wx.LanguageDescription.of({name:"diff",extensions:["diff","patch"],load:()=>e.A(85978).then(e=>Wy(e.diff))}),Wx.LanguageDescription.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>e.A(89654).then(e=>Wy(e.dockerFile))}),Wx.LanguageDescription.of({name:"DTD",extensions:["dtd"],load:()=>e.A(77925).then(e=>Wy(e.dtd))}),Wx.LanguageDescription.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>e.A(27553).then(e=>Wy(e.dylan))}),Wx.LanguageDescription.of({name:"EBNF",load:()=>e.A(6232).then(e=>Wy(e.ebnf))}),Wx.LanguageDescription.of({name:"ECL",extensions:["ecl"],load:()=>e.A(11956).then(e=>Wy(e.ecl))}),Wx.LanguageDescription.of({name:"edn",extensions:["edn"],load:()=>e.A(32566).then(e=>Wy(e.clojure))}),Wx.LanguageDescription.of({name:"Eiffel",extensions:["e"],load:()=>e.A(25267).then(e=>Wy(e.eiffel))}),Wx.LanguageDescription.of({name:"Elm",extensions:["elm"],load:()=>e.A(6956).then(e=>Wy(e.elm))}),Wx.LanguageDescription.of({name:"Erlang",extensions:["erl"],load:()=>e.A(2095).then(e=>Wy(e.erlang))}),Wx.LanguageDescription.of({name:"Esper",load:()=>e.A(45412).then(e=>Wy(e.esper))}),Wx.LanguageDescription.of({name:"Factor",extensions:["factor"],load:()=>e.A(2075).then(e=>Wy(e.factor))}),Wx.LanguageDescription.of({name:"FCL",load:()=>e.A(68091).then(e=>Wy(e.fcl))}),Wx.LanguageDescription.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>e.A(54669).then(e=>Wy(e.forth))}),Wx.LanguageDescription.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>e.A(76946).then(e=>Wy(e.fortran))}),Wx.LanguageDescription.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>e.A(36855).then(e=>Wy(e.fSharp))}),Wx.LanguageDescription.of({name:"Gas",extensions:["s"],load:()=>e.A(40367).then(e=>Wy(e.gas))}),Wx.LanguageDescription.of({name:"Gherkin",extensions:["feature"],load:()=>e.A(23161).then(e=>Wy(e.gherkin))}),Wx.LanguageDescription.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>e.A(97713).then(e=>Wy(e.groovy))}),Wx.LanguageDescription.of({name:"Haskell",extensions:["hs"],load:()=>e.A(56334).then(e=>Wy(e.haskell))}),Wx.LanguageDescription.of({name:"Haxe",extensions:["hx"],load:()=>e.A(70963).then(e=>Wy(e.haxe))}),Wx.LanguageDescription.of({name:"HXML",extensions:["hxml"],load:()=>e.A(70963).then(e=>Wy(e.hxml))}),Wx.LanguageDescription.of({name:"HTTP",load:()=>e.A(35064).then(e=>Wy(e.http))}),Wx.LanguageDescription.of({name:"IDL",extensions:["pro"],load:()=>e.A(89381).then(e=>Wy(e.idl))}),Wx.LanguageDescription.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>e.A(59695).then(e=>Wy(e.jsonld))}),Wx.LanguageDescription.of({name:"Julia",extensions:["jl"],load:()=>e.A(64014).then(e=>Wy(e.julia))}),Wx.LanguageDescription.of({name:"Kotlin",extensions:["kt","kts"],load:()=>e.A(38138).then(e=>Wy(e.kotlin))}),Wx.LanguageDescription.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>e.A(42765).then(e=>Wy(e.liveScript))}),Wx.LanguageDescription.of({name:"Lua",extensions:["lua"],load:()=>e.A(97328).then(e=>Wy(e.lua))}),Wx.LanguageDescription.of({name:"mIRC",extensions:["mrc"],load:()=>e.A(34747).then(e=>Wy(e.mirc))}),Wx.LanguageDescription.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>e.A(15637).then(e=>Wy(e.mathematica))}),Wx.LanguageDescription.of({name:"Modelica",extensions:["mo"],load:()=>e.A(4877).then(e=>Wy(e.modelica))}),Wx.LanguageDescription.of({name:"MUMPS",extensions:["mps"],load:()=>e.A(51221).then(e=>Wy(e.mumps))}),Wx.LanguageDescription.of({name:"Mbox",extensions:["mbox"],load:()=>e.A(64186).then(e=>Wy(e.mbox))}),Wx.LanguageDescription.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>e.A(84274).then(e=>Wy(e.nginx))}),Wx.LanguageDescription.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>e.A(51971).then(e=>Wy(e.nsis))}),Wx.LanguageDescription.of({name:"NTriples",extensions:["nt","nq"],load:()=>e.A(42967).then(e=>Wy(e.ntriples))}),Wx.LanguageDescription.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>e.A(38138).then(e=>Wy(e.objectiveC))}),Wx.LanguageDescription.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>e.A(38138).then(e=>Wy(e.objectiveCpp))}),Wx.LanguageDescription.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>e.A(36855).then(e=>Wy(e.oCaml))}),Wx.LanguageDescription.of({name:"Octave",extensions:["m"],load:()=>e.A(22492).then(e=>Wy(e.octave))}),Wx.LanguageDescription.of({name:"Oz",extensions:["oz"],load:()=>e.A(73945).then(e=>Wy(e.oz))}),Wx.LanguageDescription.of({name:"Pascal",extensions:["p","pas"],load:()=>e.A(2372).then(e=>Wy(e.pascal))}),Wx.LanguageDescription.of({name:"Perl",extensions:["pl","pm"],load:()=>e.A(44660).then(e=>Wy(e.perl))}),Wx.LanguageDescription.of({name:"Pig",extensions:["pig"],load:()=>e.A(28734).then(e=>Wy(e.pig))}),Wx.LanguageDescription.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>e.A(36584).then(e=>Wy(e.powerShell))}),Wx.LanguageDescription.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>e.A(97145).then(e=>Wy(e.properties))}),Wx.LanguageDescription.of({name:"ProtoBuf",extensions:["proto"],load:()=>e.A(86304).then(e=>Wy(e.protobuf))}),Wx.LanguageDescription.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>e.A(86501).then(e=>Wy(e.pug))}),Wx.LanguageDescription.of({name:"Puppet",extensions:["pp"],load:()=>e.A(16397).then(e=>Wy(e.puppet))}),Wx.LanguageDescription.of({name:"Q",extensions:["q"],load:()=>e.A(71617).then(e=>Wy(e.q))}),Wx.LanguageDescription.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>e.A(62905).then(e=>Wy(e.r))}),Wx.LanguageDescription.of({name:"RPM Changes",load:()=>e.A(31053).then(e=>Wy(e.rpmChanges))}),Wx.LanguageDescription.of({name:"RPM Spec",extensions:["spec"],load:()=>e.A(31053).then(e=>Wy(e.rpmSpec))}),Wx.LanguageDescription.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>e.A(84403).then(e=>Wy(e.ruby))}),Wx.LanguageDescription.of({name:"SAS",extensions:["sas"],load:()=>e.A(57388).then(e=>Wy(e.sas))}),Wx.LanguageDescription.of({name:"Scala",extensions:["scala"],load:()=>e.A(38138).then(e=>Wy(e.scala))}),Wx.LanguageDescription.of({name:"Scheme",extensions:["scm","ss"],load:()=>e.A(94780).then(e=>Wy(e.scheme))}),Wx.LanguageDescription.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>e.A(8240).then(e=>Wy(e.shell))}),Wx.LanguageDescription.of({name:"Sieve",extensions:["siv","sieve"],load:()=>e.A(46740).then(e=>Wy(e.sieve))}),Wx.LanguageDescription.of({name:"Smalltalk",extensions:["st"],load:()=>e.A(48213).then(e=>Wy(e.smalltalk))}),Wx.LanguageDescription.of({name:"Solr",load:()=>e.A(47982).then(e=>Wy(e.solr))}),Wx.LanguageDescription.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>e.A(36855).then(e=>Wy(e.sml))}),Wx.LanguageDescription.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>e.A(85501).then(e=>Wy(e.sparql))}),Wx.LanguageDescription.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>e.A(44878).then(e=>Wy(e.spreadsheet))}),Wx.LanguageDescription.of({name:"Squirrel",extensions:["nut"],load:()=>e.A(38138).then(e=>Wy(e.squirrel))}),Wx.LanguageDescription.of({name:"Stylus",extensions:["styl"],load:()=>e.A(76475).then(e=>Wy(e.stylus))}),Wx.LanguageDescription.of({name:"Swift",extensions:["swift"],load:()=>e.A(8835).then(e=>Wy(e.swift))}),Wx.LanguageDescription.of({name:"sTeX",load:()=>e.A(42690).then(e=>Wy(e.stex))}),Wx.LanguageDescription.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>e.A(42690).then(e=>Wy(e.stex))}),Wx.LanguageDescription.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>e.A(78077).then(e=>Wy(e.verilog))}),Wx.LanguageDescription.of({name:"Tcl",extensions:["tcl"],load:()=>e.A(139).then(e=>Wy(e.tcl))}),Wx.LanguageDescription.of({name:"Textile",extensions:["textile"],load:()=>e.A(75208).then(e=>Wy(e.textile))}),Wx.LanguageDescription.of({name:"TiddlyWiki",load:()=>e.A(44524).then(e=>Wy(e.tiddlyWiki))}),Wx.LanguageDescription.of({name:"Tiki wiki",load:()=>e.A(38168).then(e=>Wy(e.tiki))}),Wx.LanguageDescription.of({name:"TOML",extensions:["toml"],load:()=>e.A(40346).then(e=>Wy(e.toml))}),Wx.LanguageDescription.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>e.A(13368).then(e=>Wy(e.troff))}),Wx.LanguageDescription.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>e.A(49796).then(e=>Wy(e.ttcn))}),Wx.LanguageDescription.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>e.A(80429).then(e=>Wy(e.ttcnCfg))}),Wx.LanguageDescription.of({name:"Turtle",extensions:["ttl"],load:()=>e.A(98657).then(e=>Wy(e.turtle))}),Wx.LanguageDescription.of({name:"Web IDL",extensions:["webidl"],load:()=>e.A(86672).then(e=>Wy(e.webIDL))}),Wx.LanguageDescription.of({name:"VB.NET",extensions:["vb"],load:()=>e.A(39480).then(e=>Wy(e.vb))}),Wx.LanguageDescription.of({name:"VBScript",extensions:["vbs"],load:()=>e.A(77625).then(e=>Wy(e.vbScript))}),Wx.LanguageDescription.of({name:"Velocity",extensions:["vtl"],load:()=>e.A(42762).then(e=>Wy(e.velocity))}),Wx.LanguageDescription.of({name:"Verilog",extensions:["v"],load:()=>e.A(78077).then(e=>Wy(e.verilog))}),Wx.LanguageDescription.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>e.A(24973).then(e=>Wy(e.vhdl))}),Wx.LanguageDescription.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>e.A(50321).then(e=>Wy(e.xQuery))}),Wx.LanguageDescription.of({name:"Yacas",extensions:["ys"],load:()=>e.A(79514).then(e=>Wy(e.yacas))}),Wx.LanguageDescription.of({name:"Z80",extensions:["z80"],load:()=>e.A(91533).then(e=>Wy(e.z80))}),Wx.LanguageDescription.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>e.A(20878).then(e=>Wy(e.mscgen))}),Wx.LanguageDescription.of({name:"Xù",extensions:["xu"],load:()=>e.A(20878).then(e=>Wy(e.xu))}),Wx.LanguageDescription.of({name:"MsGenny",extensions:["msgenny"],load:()=>e.A(20878).then(e=>Wy(e.msgenny))}),Wx.LanguageDescription.of({name:"Vue",extensions:["vue"],load:()=>e.A(99646).then(e=>e.vue())}),Wx.LanguageDescription.of({name:"Angular Template",load:()=>e.A(29423).then(e=>e.angular())})];var Wj=e.i(68113),Wk=e.i(2262),WS=e.i(17300);function WN(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let a=e(t,n);return!!a&&(r(n.update(a)),!0)}}let WC=WN(function(e,t,n=t.selection.ranges){let r=[],a=-1;t:for(let{from:e,to:i}of n){let n=r.length,o=1e9,l;for(let n=e;n<=i;){let s=t.doc.lineAt(n);if(void 0==l&&!(l=WO(t,s.from).line))continue t;if(s.from>a&&(e==i||i>s.from)){a=s.from;let e=/^\s*/.exec(s.text)[0].length,t=e==s.length,n=s.text.slice(e,e+l.length)==l?e:-1;e<s.text.length&&e<o&&(o=e),r.push({line:s,comment:n,token:l,indent:e,empty:t,single:!1})}n=s.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:a,empty:i,single:o}of r)(o||!i)&&e.push({from:t.from+a,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:a}of r)if(n>=0){let r=t.from+n,i=r+a.length;" "==t.text[i-t.from]&&i++,e.push({from:r,to:i})}return{changes:e}}return null},0),WM=WN(WP,0),WE=WN((e,t)=>WP(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),a=n.to<=r.to?r:e.doc.lineAt(n.to);a.from>r.from&&a.from==n.to&&(a=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let i=t.length-1;i>=0&&t[i].to>r.from?t[i].to=a.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:a.to})}return t}(t)),0);function WO(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function WP(e,t,n=t.selection.ranges){let r=n.map(e=>WO(t,e.from).block);if(!r.every(e=>e))return null;let a=n.map((e,n)=>(function(e,{open:t,close:n},r,a){let i,o,l=e.sliceDoc(r-50,r),s=e.sliceDoc(a,a+50),c=/\s*$/.exec(l)[0].length,d=/^\s*/.exec(s)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&s.slice(d,d+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:a+d,margin:d&&1}};a-r<=100?i=o=e.sliceDoc(r,a):(i=e.sliceDoc(r,r+50),o=e.sliceDoc(a-50,a));let f=/^\s*/.exec(i)[0].length,h=/\s*$/.exec(o)[0].length,m=o.length-h-n.length;return i.slice(f,f+t.length)==t&&o.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(i.charAt(f+t.length))},close:{pos:a-h-n.length,margin:+!!/\s/.test(o.charAt(m-1))}}:null})(t,r[n],e.from,e.to));if(2!=e&&!a.every(e=>e))return{changes:t.changes(n.map((e,t)=>a[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&a.some(e=>e)){let e=[];for(let t=0,n;t<a.length;t++)if(n=a[t]){let a=r[t],{open:i,close:o}=n;e.push({from:i.pos-a.open.length,to:i.pos+i.margin},{from:o.pos-o.margin,to:o.pos+a.close.length})}return{changes:e}}return null}let WA=Wj.Annotation.define(),WI=Wj.Annotation.define(),Wz=Wj.Facet.define(),WT=Wj.Facet.define({combine:e=>(0,Wj.combineConfig)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),WD=Wj.StateField.define({create:()=>WG.empty,update(e,t){let n=t.state.facet(WT),r=t.annotation(WA);if(r){let a=WB.fromTransaction(t,r.selection),i=r.side,o=0==i?e.undone:e.done;return o=a?WV(o,o.length,n.minDepth,a):WW(o,t.startState.selection),new WG(0==i?r.rest:o,0==i?o:r.rest)}let a=t.annotation(WI);if(("full"==a||"before"==a)&&(e=e.isolate()),!1===t.annotation(Wj.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let i=WB.fromTransaction(t),o=t.annotation(Wj.Transaction.time),l=t.annotation(Wj.Transaction.userEvent);return i?e=e.addChanges(i,o,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,n.newGroupDelay)),("full"==a||"after"==a)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new WG(e.done.map(WB.fromJSON),e.undone.map(WB.fromJSON))});function WR(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let a=n.field(WD,!1);if(!a)return!1;let i=a.pop(e,n,t);return!!i&&(r(i),!0)}}let W_=WR(0,!1),WL=WR(1,!1),W$=WR(0,!0),WF=WR(1,!0);class WB{constructor(e,t,n,r,a){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=a}setSelAfter(e){return new WB(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new WB(e.changes&&Wj.ChangeSet.fromJSON(e.changes),[],e.mapped&&Wj.ChangeDesc.fromJSON(e.mapped),e.startSelection&&Wj.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(Wj.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=WU;for(let t of e.startState.facet(Wz)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new WB(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,WU)}static selection(e){return new WB(void 0,WU,void 0,void 0,e)}}function WV(e,t,n,r){let a=e.slice(t+1>n+20?t-n-1:0,t);return a.push(r),a}function WH(e,t){return e.length?t.length?e.concat(t):e:t}let WU=[];function WW(e,t){if(!e.length)return[WB.selection([t])];{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),WV(e,e.length-1,1e9,n.setSelAfter(r)))}}function Wq(e,t){if(!e.length)return e;let n=e.length,r=WU;for(;n;){let a=function(e,t,n){let r=WH(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):WU,n);if(!e.changes)return WB.selection(r);let a=e.changes.map(t),i=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(i):i;return new WB(a,Wj.StateEffect.mapEffects(e.effects,t),o,e.startSelection.map(i),r)}(e[n-1],t,r);if(a.changes&&!a.changes.empty||a.effects.length){let t=e.slice(0,n);return t[n-1]=a,t}t=a.mapped,n--,r=a.selectionsAfter}return r.length?[WB.selection(r)]:WU}let WK=/^(input\.type|delete)($|\.)/;class WG{constructor(e,t,n=0,r){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new WG(this.done,this.undone):this}addChanges(e,t,n,r,a){var i,o;let l,s,c=this.done,d=c[c.length-1];return new WG(c=d&&d.changes&&!d.changes.empty&&e.changes&&(!n||WK.test(n))&&(!d.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(a,(i=d.changes,o=e.changes,l=[],s=!1,i.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,n,r)=>{for(let e=0;e<l.length;){let t=l[e++],a=l[e++];r>=t&&n<=a&&(s=!0)}}),s))||"input.type.compose"==n)?WV(c,c.length-1,r.minDepth,new WB(e.changes.compose(d.changes),WH(Wj.StateEffect.mapEffects(e.effects,d.changes),d.effects),d.mapped,d.startSelection,WU)):WV(c,c.length,r.minDepth,e),WU,t,n)}addSelection(e,t,n,r){var a;let i=this.done.length?this.done[this.done.length-1].selectionsAfter:WU;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(a=i[i.length-1],a.ranges.length==e.ranges.length&&0===a.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new WG(WW(this.done,e),this.undone,t,n)}addMapping(e){return new WG(Wq(this.done,e),Wq(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let a=r[r.length-1],i=a.selectionsAfter[0]||(a.startSelection?a.startSelection.map(a.changes.invertedDesc,1):t.selection);if(n&&a.selectionsAfter.length){let n,o;return t.update({selection:a.selectionsAfter[a.selectionsAfter.length-1],annotations:WA.of({side:e,rest:(n=r[r.length-1],(o=r.slice())[r.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:i}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!a.changes)return null;let n=1==r.length?WU:r.slice(0,r.length-1);return a.mapped&&(n=Wq(n,a.mapped)),t.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:WA.of({side:e,rest:n,selection:i}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}WG.empty=new WG(WU,WU);function WX(e,t){return Wj.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function WY(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function WZ({state:e,dispatch:t},n){let r=WX(e.selection,n);return!r.eq(e.selection,!0)&&(t(WY(e,r)),!0)}function WJ(e,t){return Wj.EditorSelection.cursor(t?e.to:e.from)}function WQ(e,t){return WZ(e,n=>n.empty?e.moveByChar(n,t):WJ(n,t))}function W0(e){return e.textDirectionAt(e.state.selection.main.head)==Wk.Direction.LTR}let W1=e=>WQ(e,!W0(e)),W2=e=>WQ(e,W0(e));function W5(e,t){return WZ(e,n=>n.empty?e.moveByGroup(n,t):WJ(n,t))}function W4(e,t,n){let r,a,i=(0,Wx.syntaxTree)(e).resolveInner(t.head),o=n?WS.NodeProp.closedBy:WS.NodeProp.openedBy;for(let r=t.head;;){let t=n?i.childAfter(r):i.childBefore(r);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?r=n?t.to:t.from:i=t}return a=i.type.prop(o)&&(r=n?(0,Wx.matchBrackets)(e,i.from,1):(0,Wx.matchBrackets)(e,i.to,-1))&&r.matched?n?r.end.to:r.end.from:n?i.to:i.from,Wj.EditorSelection.cursor(a,n?-1:1)}function W3(e,t){return WZ(e,n=>{if(!n.empty)return WJ(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}"u">typeof Intl&&Intl.Segmenter;let W6=e=>W3(e,!1),W8=e=>W3(e,!0);function W7(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,a;if(t){for(let t of e.state.facet(Wk.EditorView.scrollMargins)){let a=t(e);(null==a?void 0:a.top)&&(n=Math.max(null==a?void 0:a.top,n)),(null==a?void 0:a.bottom)&&(r=Math.max(null==a?void 0:a.bottom,r))}a=e.scrollDOM.clientHeight-n-r}else a=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,a-5)}}function W9(e,t){let n,r=W7(e),{state:a}=e,i=WX(a.selection,n=>n.empty?e.moveVertically(n,t,r.height):WJ(n,t));if(i.eq(a.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(a.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+r.marginTop,s=o.bottom-r.marginBottom;t&&t.top>l&&t.bottom<s&&(n=Wk.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch(WY(a,i),{effects:n}),!0}let qe=e=>W9(e,!1),qt=e=>W9(e,!0);function qn(e,t,n){let r=e.lineBlockAt(t.head),a=e.moveToLineBoundary(t,n);if(a.head==t.head&&a.head!=(n?r.to:r.from)&&(a=e.moveToLineBoundary(t,n,!1)),!n&&a.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(a=Wj.EditorSelection.cursor(r.from+n))}return a}function qr(e,t){let n=WX(e.state.selection,e=>{let n=t(e);return Wj.EditorSelection.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return!n.eq(e.state.selection)&&(e.dispatch(WY(e.state,n)),!0)}function qa(e,t){return qr(e,n=>e.moveByChar(n,t))}let qi=e=>qa(e,!W0(e)),qo=e=>qa(e,W0(e));function ql(e,t){return qr(e,n=>e.moveByGroup(n,t))}function qs(e,t){return qr(e,n=>e.moveVertically(n,t))}let qc=e=>qs(e,!1),qd=e=>qs(e,!0);function qu(e,t){return qr(e,n=>e.moveVertically(n,t,W7(e).height))}let qf=e=>qu(e,!1),qh=e=>qu(e,!0),qm=({state:e,dispatch:t})=>(t(WY(e,{anchor:0})),!0),qp=({state:e,dispatch:t})=>(t(WY(e,{anchor:e.doc.length})),!0),qg=({state:e,dispatch:t})=>(t(WY(e,{anchor:e.selection.main.anchor,head:0})),!0),qv=({state:e,dispatch:t})=>(t(WY(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function qx(e,t){let{state:n}=e,r=n.selection,a=n.selection.ranges.slice();for(let r of n.selection.ranges){let i=n.doc.lineAt(r.head);if(t?i.to<e.state.doc.length:i.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<i.from||r.head>i.to){a.some(e=>e.head==r.head)||a.push(r);break}if(r.head==n.head)break;n=r}}return a.length!=r.ranges.length&&(e.dispatch(WY(n,Wj.EditorSelection.create(a,a.length-1))),!0)}function qy(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,a=r.changeByRange(r=>{let{from:a,to:i}=r;if(a==i){let o=t(r);o<a?(n="delete.backward",o=qb(e,o,!1)):o>a&&(n="delete.forward",o=qb(e,o,!0)),a=Math.min(a,o),i=Math.max(i,o)}else a=qb(e,a,!1),i=qb(e,i,!0);return a==i?{range:r}:{changes:{from:a,to:i},range:Wj.EditorSelection.cursor(a,a<r.head?-1:1)}});return!a.changes.empty&&(e.dispatch(r.update(a,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Wk.EditorView.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function qb(e,t,n){if(e instanceof Wk.EditorView)for(let r of e.state.facet(Wk.EditorView.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}let qw=(e,t,n)=>qy(e,r=>{let a=r.from,{state:i}=e,o=i.doc.lineAt(a),l,s;if(n&&!t&&a>o.from&&a<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,a-o.from))){if(" "==l[l.length-1])return a-1;let e=(0,Wj.countColumn)(l,i.tabSize)%(0,Wx.getIndentUnit)(i)||(0,Wx.getIndentUnit)(i);for(let t=0;t<e&&" "==l[l.length-1-t];t++)a--;s=a}else(s=(0,Wj.findClusterBreak)(o.text,a-o.from,t,t)+o.from)==a&&o.number!=(t?i.doc.lines:1)?s+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(s-o.from,a-o.from))&&(s=(0,Wj.findClusterBreak)(o.text,s-o.from,!1,!1)+o.from);return s}),qj=e=>qw(e,!1,!0),qk=e=>qw(e,!0,!1),qS=(e,t)=>qy(e,n=>{let r=n.head,{state:a}=e,i=a.doc.lineAt(r),o=a.charCategorizer(r);for(let e=null;;){if(r==(t?i.to:i.from)){r==n.head&&i.number!=(t?a.doc.lines:1)&&(r+=t?1:-1);break}let l=(0,Wj.findClusterBreak)(i.text,r-i.from,t)+i.from,s=i.text.slice(Math.min(r,l)-i.from,Math.max(r,l)-i.from),c=o(s);if(null!=e&&c!=e)break;(" "!=s||r!=n.head)&&(e=c),r=l}return r}),qN=e=>qS(e,!1);function qC(e){let t=[],n=-1;for(let r of e.selection.ranges){let a=e.doc.lineAt(r.from),i=e.doc.lineAt(r.to);if(r.empty||r.to!=i.from||(i=e.doc.lineAt(r.to-1)),n>=a.number){let e=t[t.length-1];e.to=i.to,e.ranges.push(r)}else t.push({from:a.from,to:i.to,ranges:[r]});n=i.number+1}return t}function qM(e,t,n){if(e.readOnly)return!1;let r=[],a=[];for(let t of qC(e)){if(n?t.to==e.doc.length:0==t.from)continue;let i=e.doc.lineAt(n?t.to+1:t.from-1),o=i.length+1;if(n)for(let n of(r.push({from:t.to,to:i.to},{from:t.from,insert:i.text+e.lineBreak}),t.ranges))a.push(Wj.EditorSelection.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)));else for(let n of(r.push({from:i.from,to:t.from},{from:t.to,insert:e.lineBreak+i.text}),t.ranges))a.push(Wj.EditorSelection.range(n.anchor-o,n.head-o))}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:Wj.EditorSelection.create(a,e.selection.mainIndex),userEvent:"move.line"})),!0)}function qE(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of qC(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let a=e.changes(r);return t(e.update({changes:a,selection:e.selection.map(a,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}let qO=qA(!1),qP=qA(!0);function qA(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:a}=n,i=t.doc.lineAt(r),o=!e&&r==a&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=(0,Wx.syntaxTree)(e).resolveInner(t),r=n.childBefore(t),a=n.childAfter(t),i;return r&&a&&r.to<=t&&a.from>=t&&(i=r.type.prop(WS.NodeProp.closedBy))&&i.indexOf(a.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(a.from).from&&!/\S/.test(e.sliceDoc(r.to,a.from))?{from:r.to,to:a.from}:null}(t,r);e&&(r=a=(a<=i.to?i:t.doc.lineAt(a)).to);let l=new Wx.IndentContext(t,{simulateBreak:r,simulateDoubleBreak:!!o}),s=(0,Wx.getIndentation)(l,r);for(null==s&&(s=(0,Wj.countColumn)(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));a<i.to&&/\s/.test(i.text[a-i.from]);)a++;o?{from:r,to:a}=o:r>i.from&&r<i.from+100&&!/\S/.test(i.text.slice(0,r))&&(r=i.from);let c=["",(0,Wx.indentString)(t,s)];return o&&c.push((0,Wx.indentString)(t,l.lineIndent(i.from,-1))),{changes:{from:r,to:a,insert:Wj.Text.of(c)},range:Wj.EditorSelection.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function qI(e,t){let n=-1;return e.changeByRange(r=>{let a=[];for(let i=r.from;i<=r.to;){let o=e.doc.lineAt(i);o.number>n&&(r.empty||r.to>o.from)&&(t(o,a,r),n=o.number),i=o.to+1}let i=e.changes(a);return{changes:a,range:Wj.EditorSelection.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}let qz=[{key:"Ctrl-b",run:W1,shift:qi,preventDefault:!0},{key:"Ctrl-f",run:W2,shift:qo},{key:"Ctrl-p",run:W6,shift:qc},{key:"Ctrl-n",run:W8,shift:qd},{key:"Ctrl-a",run:e=>WZ(e,t=>Wj.EditorSelection.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>qr(e,t=>Wj.EditorSelection.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>WZ(e,t=>Wj.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>qr(e,t=>Wj.EditorSelection.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:qk},{key:"Ctrl-h",run:qj},{key:"Ctrl-k",run:e=>qy(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:qN},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Wj.Text.of(["",""])},range:Wj.EditorSelection.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),a=n==r.from?n-1:(0,Wj.findClusterBreak)(r.text,n-r.from,!1)+r.from,i=n==r.to?n+1:(0,Wj.findClusterBreak)(r.text,n-r.from,!0)+r.from;return{changes:{from:a,to:i,insert:e.doc.slice(n,i).append(e.doc.slice(a,n))},range:Wj.EditorSelection.cursor(i)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:qt}],qT=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>WZ(e,t=>W4(e.state,t,!W0(e))),shift:e=>qr(e,t=>W4(e.state,t,!W0(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>WZ(e,t=>W4(e.state,t,W0(e))),shift:e=>qr(e,t=>W4(e.state,t,W0(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>qM(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>qE(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>qM(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>qE(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>qx(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>qx(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Wj.EditorSelection.create([n.main]):n.main.empty||(r=Wj.EditorSelection.create([Wj.EditorSelection.cursor(n.main.head)])),!!r&&(t(WY(e,r)),!0)}},{key:"Mod-Enter",run:qP},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=qC(e).map(({from:t,to:n})=>Wj.EditorSelection.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Wj.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=WX(e.selection,t=>{let n=(0,Wx.syntaxTree)(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Wj.EditorSelection.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(WY(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(qI(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let a=(0,Wj.countColumn)(r,e.tabSize),i=0,o=(0,Wx.indentString)(e,Math.max(0,a-(0,Wx.getIndentUnit)(e)));for(;i<r.length&&i<o.length&&r.charCodeAt(i)==o.charCodeAt(i);)i++;n.push({from:t.from+i,to:t.from+r.length,insert:o.slice(i)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(qI(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Wx.indentUnit)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Wx.IndentContext(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),a=qI(e,(t,a,i)=>{let o=(0,Wx.getIndentation)(r,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let l=/^\s*/.exec(t.text)[0],s=(0,Wx.indentString)(e,o);(l!=s||i.from<t.from+l.length)&&(n[t.from]=o,a.push({from:t.from,to:t.from+l.length,insert:s}))});return a.changes.empty||t(e.update(a,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(qC(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=WX(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),a=e.coordsAtPos(t.head,t.assoc||1);a&&(n=r.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>{let n,r;return n=!1,r=WX(e.selection,t=>{let r=(0,Wx.matchBrackets)(e,t.head,-1)||(0,Wx.matchBrackets)(e,t.head,1)||t.head>0&&(0,Wx.matchBrackets)(e,t.head-1,1)||t.head<e.doc.length&&(0,Wx.matchBrackets)(e,t.head+1,-1);if(!r||!r.end)return t;n=!0;let a=r.start.from==t.head?r.end.to:r.end.from;return Wj.EditorSelection.cursor(a)}),!!n&&(t(WY(e,r)),!0)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=WO(e.state,n.from);return r.line?WC(e):!!r.block&&WE(e)}},{key:"Alt-A",run:WM},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:W1,shift:qi,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>W5(e,!W0(e)),shift:e=>ql(e,!W0(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>WZ(e,t=>qn(e,t,!W0(e))),shift:e=>qr(e,t=>qn(e,t,!W0(e))),preventDefault:!0},{key:"ArrowRight",run:W2,shift:qo,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>W5(e,W0(e)),shift:e=>ql(e,W0(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>WZ(e,t=>qn(e,t,W0(e))),shift:e=>qr(e,t=>qn(e,t,W0(e))),preventDefault:!0},{key:"ArrowUp",run:W6,shift:qc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:qm,shift:qg},{mac:"Ctrl-ArrowUp",run:qe,shift:qf},{key:"ArrowDown",run:W8,shift:qd,preventDefault:!0},{mac:"Cmd-ArrowDown",run:qp,shift:qv},{mac:"Ctrl-ArrowDown",run:qt,shift:qh},{key:"PageUp",run:qe,shift:qf},{key:"PageDown",run:qt,shift:qh},{key:"Home",run:e=>WZ(e,t=>qn(e,t,!1)),shift:e=>qr(e,t=>qn(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:qm,shift:qg},{key:"End",run:e=>WZ(e,t=>qn(e,t,!0)),shift:e=>qr(e,t=>qn(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:qp,shift:qv},{key:"Enter",run:qO,shift:qO},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:qj,shift:qj,preventDefault:!0},{key:"Delete",run:qk,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:qN,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>qS(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>qy(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>qy(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(qz.map(e=>({mac:e.key,run:e.run,shift:e.shift}))));var qD=e.i(41016);let qR="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class q_{constructor(e,t,n=0,r=e.length,a,i){this.test=i,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=a?e=>a(qR(e)):qR,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return(0,Wj.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,Wj.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,Wj.codePointSize)(e);let r=this.normalize(t);if(r.length)for(let e=0,a=n,i=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,a,i,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;i&&e<t.length&&t.charCodeAt(e)==n?a++:i=!1}}}match(e,t,n,r,a){let i=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?i={from:n.from,to:r,precise:a&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:r,precise:n&&a}:this.matches.push({from:t,index:1,precise:n})),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"u">typeof Symbol&&(q_.prototype[Symbol.iterator]=function(){return this});let qL={from:-1,to:-1,match:/.*/.exec(""),precise:!0},q$="gm"+(null==/x/.unicode?"":"u");class qF{constructor(e,t,n,r=0,a=e.length){if(this.text=e,this.to=a,this.curLine="",this.done=!1,this.value=qL,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new qH(e,t,n,r,a);this.re=new RegExp(t,q$+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let i=e.lineAt(r);this.curLineStart=i.from,this.matchPos=qU(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=qU(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}let qB=new WeakMap;class qV{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=qB.get(e);if(!r||r.from>=n||r.to<=t){let r=new qV(t,e.sliceString(t,n));return qB.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:a,from:i}=r;return i>t&&(a=e.sliceString(t,i)+a,i=t),r.to<n&&(a+=e.sliceString(r.to,n)),qB.set(e,new qV(i,a)),new qV(t,a.slice(t-i,n-i))}}class qH{constructor(e,t,n,r,a){this.text=e,this.to=a,this.done=!1,this.value=qL,this.matchPos=qU(e,r),this.re=new RegExp(t,q$+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=qV.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=qU(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=qV.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function qU(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}"u">typeof Symbol&&(qF.prototype[Symbol.iterator]=qH.prototype[Symbol.iterator]=function(){return this});let qW={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},qq=Wj.Facet.define({combine:e=>(0,Wj.combineConfig)(e,qW,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),qK=Wk.Decoration.mark({class:"cm-selectionMatch"}),qG=Wk.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function qX(e,t,n,r){return(0==n||e(t.sliceDoc(n-1,n))!=Wj.CharCategory.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=Wj.CharCategory.Word)}let qY=Wk.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(qq),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Wk.Decoration.none;let a=r.main,i,o=null;if(a.empty){if(!t.highlightWordAroundCursor)return Wk.Decoration.none;let e=n.wordAt(a.head);if(!e)return Wk.Decoration.none;o=n.charCategorizer(a.head),i=n.sliceDoc(e.from,e.to)}else{let e=a.to-a.from;if(e<t.minSelectionLength||e>200)return Wk.Decoration.none;if(t.wholeWords){var l,s,c;if(i=n.sliceDoc(a.from,a.to),!(qX(o=n.charCategorizer(a.head),n,a.from,a.to)&&(l=o,s=a.from,c=a.to,l(n.sliceDoc(s,s+1))==Wj.CharCategory.Word&&l(n.sliceDoc(c-1,c))==Wj.CharCategory.Word)))return Wk.Decoration.none}else if(!(i=n.sliceDoc(a.from,a.to)))return Wk.Decoration.none}let d=[];for(let r of e.visibleRanges){let e=new q_(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!o||qX(o,n,r,i))&&(a.empty&&r<=a.from&&i>=a.to?d.push(qG.range(r,i)):(r>=a.to||i<=a.from)&&d.push(qK.range(r,i)),d.length>t.maxMatches))return Wk.Decoration.none}}return Wk.Decoration.set(d)}},{decorations:e=>e.decorations}),qZ=Wk.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),qJ=Wj.Facet.define({combine:e=>(0,Wj.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Kv(e),scrollToMatch:e=>Wk.EditorView.scrollIntoView(e)})});class qQ{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,q$),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new q6(this):new q2(this)}getCursor(e,t=0,n){let r=e.doc?e:Wj.EditorState.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?q5(this,r,t,n):q1(this,r,t,n)}}class q0{constructor(e){this.spec=e}}function q1(e,t,n,r){var a,i,o,l;let s;return e.wholeWord&&(o=t.doc,l=t.charCategorizer(t.selection.main.head),s=(e,t,n,r)=>((r>e||r+n.length<t)&&(r=Math.max(0,e-2),n=o.sliceString(r,Math.min(o.length,t+2))),(l(q4(n,e-r))!=Wj.CharCategory.Word||l(q3(n,e-r))!=Wj.CharCategory.Word)&&(l(q3(n,t-r))!=Wj.CharCategory.Word||l(q4(n,t-r))!=Wj.CharCategory.Word))),e.test&&(a=e.test,i=s,s=(e,n,r,o)=>(!i||!!i(e,n,r,o))&&a(e>=o&&n<=o+r.length?r.slice(e-o,n-o):t.doc.sliceString(e,n),t,e,n)),new q_(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),s)}class q2 extends q0{constructor(e){super(e)}nextMatch(e,t,n){let r=q1(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q1(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),a=q1(this.spec,e,n,r),i=null;for(;!a.nextOverlapping().done;)i=a.value;if(i)return i;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q1(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let a=q1(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)r(a.value.from,a.value.to)}}function q5(e,t,n,r){var a,i,o;let l;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),l=(e,t,n)=>!n[0].length||(o(q4(n.input,n.index))!=Wj.CharCategory.Word||o(q3(n.input,n.index))!=Wj.CharCategory.Word)&&(o(q3(n.input,n.index+n[0].length))!=Wj.CharCategory.Word||o(q4(n.input,n.index+n[0].length))!=Wj.CharCategory.Word)),e.test&&(a=e.test,i=l,l=(e,n,r)=>(!i||i(e,n,r))&&a(r[0],t,e,n)),new qF(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:l},n,r)}function q4(e,t){return e.slice((0,Wj.findClusterBreak)(e,t,!1),t)}function q3(e,t){return e.slice(t,(0,Wj.findClusterBreak)(e,t))}class q6 extends q0{nextMatch(e,t,n){let r=q5(this.spec,e,n,e.doc.length).next();return r.done&&(r=q5(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let a=Math.max(t,n-1e4*r),i=q5(this.spec,e,a,n),o=null;for(;!i.next().done;)o=i.value;if(o&&(a==t||o.from>a+10))return o;if(a==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=q5(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let a=q5(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)r(a.value.from,a.value.to)}}let q8=Wj.StateEffect.define(),q7=Wj.StateEffect.define(),q9=Wj.StateField.define({create:e=>new Ke(Ku(e).create(),null),update(e,t){for(let n of t.effects)n.is(q8)?e=new Ke(n.value.create(),e.panel):n.is(q7)&&(e=new Ke(e.query,n.value?Kd:null));return e},provide:e=>Wk.showPanel.from(e,e=>e.panel)});class Ke{constructor(e,t){this.query=e,this.panel=t}}let Kt=Wk.Decoration.mark({class:"cm-searchMatch"}),Kn=Wk.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Kr=Wk.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(q9))}update(e){let t=e.state.field(q9);(t!=e.startState.field(q9)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Wk.Decoration.none;let{view:n}=this,r=new Wj.RangeSetBuilder;for(let t=0,a=n.visibleRanges,i=a.length;t<i;t++){let{from:o,to:l}=a[t];for(;t<i-1&&l>a[t+1].from-500;)l=a[++t].to;e.highlight(n.state,o,l,(e,t)=>{let a=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,a?Kn:Kt)})}return r.finish()}},{decorations:e=>e.decorations});function Ka(e){return t=>{let n=t.state.field(q9,!1);return n&&n.query.spec.valid?e(t,n):Km(t)}}let Ki=Ka((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let a=Wj.EditorSelection.single(r.from,r.to),i=e.state.facet(qJ);return e.dispatch({selection:a,effects:[Kb(e,r),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),Kh(e),!0}),Ko=Ka((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,a=t.prevMatch(n,r,r);if(!a)return!1;let i=Wj.EditorSelection.single(a.from,a.to),o=e.state.facet(qJ);return e.dispatch({selection:i,effects:[Kb(e,a),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),Kh(e),!0}),Kl=Ka((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!!n&&!!n.length&&(e.dispatch({selection:Wj.EditorSelection.create(n.map(e=>Wj.EditorSelection.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),Ks=Ka((e,{query:t})=>{let{state:n}=e,{from:r,to:a}=n.selection.main;if(n.readOnly)return!1;let i=t.nextMatch(n,r,r);if(!i)return!1;let o=i,l=[],s,c,d=[];o.precise?o.from==r&&o.to==a&&(c=n.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),d.push(Wk.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):o=t.nextMatch(n,o.from,o.to);let u=e.state.changes(l);return o&&(s=Wj.EditorSelection.single(o.from,o.to).map(u),d.push(Kb(e,o)),d.push(n.facet(qJ).scrollToMatch(s.main,e))),e.dispatch({changes:u,selection:s,effects:d,userEvent:"input.replace"}),!0}),Kc=Ka((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:a,precise:i}=r;i&&n.push({from:e,to:a,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Wk.EditorView.announce.of(r),userEvent:"input.replace.all"}),!0});function Kd(e){return e.state.facet(qJ).createPanel(e)}function Ku(e,t){var n,r,a,i,o;let l=e.selection.main,s=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!s)return t;let c=e.facet(qJ);return new qQ({search:(null!=(n=null==t?void 0:t.literal)?n:c.literal)?s:s.replace(/\n/g,"\\n"),caseSensitive:null!=(r=null==t?void 0:t.caseSensitive)?r:c.caseSensitive,literal:null!=(a=null==t?void 0:t.literal)?a:c.literal,regexp:null!=(i=null==t?void 0:t.regexp)?i:c.regexp,wholeWord:null!=(o=null==t?void 0:t.wholeWord)?o:c.wholeWord})}function Kf(e){let t=(0,Wk.getPanel)(e,Kd);return t&&t.dom.querySelector("[main-field]")}function Kh(e){let t=Kf(e);t&&t==e.root.activeElement&&t.select()}let Km=e=>{let t=e.state.field(q9,!1);if(t&&t.panel){let n=Kf(e);if(n&&n!=e.root.activeElement){let r=Ku(e.state,t.query.spec);r.valid&&e.dispatch({effects:q8.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[q7.of(!0),t?q8.of(Ku(e.state,t.query.spec)):Wj.StateEffect.appendConfig.of(Kj)]});return!0},Kp=e=>{let t=e.state.field(q9,!1);if(!t||!t.panel)return!1;let n=(0,Wk.getPanel)(e,Kd);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:q7.of(!1)}),!0},Kg=[{key:"Mod-f",run:Km,scope:"editor search-panel"},{key:"F3",run:Ki,shift:Ko,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Ki,shift:Ko,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Kp,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:a}=n.main,i=[],o=0;for(let t=new q_(e.doc,e.sliceDoc(r,a));!t.next().done;){if(i.length>1e3)return!1;t.value.from==r&&(o=i.length),i.push(Wj.EditorSelection.range(t.value.from,t.value.to))}return t(e.update({selection:Wj.EditorSelection.create(i,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:a}=(0,Wk.showDialog)(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return a.then(n=>{let a=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!a)return void e.dispatch({effects:r});let i=t.doc.lineAt(t.selection.main.head),[,o,l,s,c]=a,d=s?+s.slice(1):0,u=l?+l:i.number;if(l&&c){let e=u/100;o&&(e=e*("-"==o?-1:1)+i.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else l&&o&&(u=u*("-"==o?-1:1)+i.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),h=Wj.EditorSelection.cursor(f.from+Math.max(0,Math.min(d,f.length)));e.dispatch({effects:[r,Wk.EditorView.scrollIntoView(h.from,{y:"center"})],selection:h})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=Wj.EditorSelection.create(n.ranges.map(t=>e.wordAt(t.head)||Wj.EditorSelection.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let a=function(e,t){let{main:n,ranges:r}=e.selection,a=e.wordAt(n.head),i=a&&a.from==n.from&&a.to==n.to;for(let n=!1,a=new q_(e.doc,t,r[r.length-1].to);;)if(a.next(),a.done){if(n)return null;a=new q_(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==a.value.from))continue;if(i){let t=e.wordAt(a.value.from);if(!t||t.from!=a.value.from||t.to!=a.value.to)continue}return a.value}}(e,r);return!!a&&(t(e.update({selection:e.selection.addRange(Wj.EditorSelection.range(a.from,a.to),!1),effects:Wk.EditorView.scrollIntoView(a.to)})),!0)},preventDefault:!0}];class Kv{constructor(e){this.view=e;let t=this.query=e.state.field(q9).query.spec;function n(e,t,n){return(0,qD.default)("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=(0,qD.default)("input",{value:t.search,placeholder:Kx(e,"Find"),"aria-label":Kx(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,qD.default)("input",{value:t.replace,placeholder:Kx(e,"Replace"),"aria-label":Kx(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,qD.default)("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=(0,qD.default)("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=(0,qD.default)("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=(0,qD.default)("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>Ki(e),[Kx(e,"next")]),n("prev",()=>Ko(e),[Kx(e,"previous")]),n("select",()=>Kl(e),[Kx(e,"all")]),(0,qD.default)("label",null,[this.caseField,Kx(e,"match case")]),(0,qD.default)("label",null,[this.reField,Kx(e,"regexp")]),(0,qD.default)("label",null,[this.wordField,Kx(e,"by word")]),...e.state.readOnly?[]:[(0,qD.default)("br"),this.replaceField,n("replace",()=>Ks(e),[Kx(e,"replace")]),n("replaceAll",()=>Kc(e),[Kx(e,"replace all")])],(0,qD.default)("button",{name:"close",onclick:()=>Kp(e),"aria-label":Kx(e,"close"),type:"button"},["×"])])}commit(){let e=new qQ({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:q8.of(e)}))}keydown(e){(0,Wk.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ko:Ki)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Ks(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(q8)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(qJ).top}}function Kx(e,t){return e.state.phrase(t)}let Ky=/[\s\.,:;?!]/;function Kb(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),a=e.state.doc.lineAt(n).to,i=Math.max(r.from,t-30),o=Math.min(a,n+30),l=e.state.sliceDoc(i,o);if(i!=r.from){for(let e=0;e<30;e++)if(!Ky.test(l[e+1])&&Ky.test(l[e])){l=l.slice(e);break}}if(o!=a){for(let e=l.length-1;e>l.length-30;e--)if(!Ky.test(l[e-1])&&Ky.test(l[e])){l=l.slice(0,e);break}}return Wk.EditorView.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}let Kw=Wk.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Kj=[q9,Wj.Prec.low(Kr),Kw];var Kk=e.i(62291),KS=Wk;class KN{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class KC{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(K_).markerFilter;r&&(e=r(e,n));let a=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),i=new Wj.RangeSetBuilder,o=[],l=0,s=n.doc.iter(),c=0,d=n.doc.length;for(let e=0;;){let t,n,r=e==a.length?null:a[e];if(!r&&!o.length)break;if(o.length)t=l,n=o.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if((t=r.from)>d)break;n=r.to,o.push(r),e++}for(;e<a.length;){let r=a[e];if(r.from==t&&(r.to>r.from||r.to==t))o.push(r),e++,n=Math.min(r.to,n);else{n=Math.min(r.from,n);break}}n=Math.min(n,d);let u=!1;if(o.some(e=>e.from==t&&(e.to==n||n==d))&&!(u=t==n)&&n-t<10){let e=t-(c+s.value.length);e>0&&(s.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!s.lineBreak&&c+s.value.length>e)break;e=c+s.value.length,c+=s.value.length,s.next()}}let f=Kq(o);if(u)i.add(t,t,KS.Decoration.widget({widget:new KB(f),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");i.add(t,n,KS.Decoration.mark({class:"cm-lintRange cm-lintRange-"+f+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>n)}))}if((l=n)==d)break;for(let e=0;e<o.length;e++)o[e].to<=l&&o.splice(e--,1)}let u=i.finish();return new KC(u,t,KM(u))}}function KM(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:a})=>{if(!(t&&0>a.diagnostics.indexOf(t)))if(r){if(0>a.diagnostics.indexOf(r.diagnostic))return!1;r=new KN(r.from,n,r.diagnostic)}else r=new KN(e,n,t||a.diagnostics[0])}),r}function KE(e,t){let n=t.pos,r=t.end||n,a=e.state.facet(K_).hideOn(e,n,r);if(null!=a)return a;let i=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(KO))||e.changes.touchesRange(i.from,Math.max(i.to,r)))}let KO=Wj.StateEffect.define(),KP=Wj.StateEffect.define(),KA=Wj.StateEffect.define(),KI=Wj.StateField.define({create:()=>new KC(KS.Decoration.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,a=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=KM(n,e.selected.diagnostic,a)||KM(n,null,a)}!n.size&&a&&t.state.facet(K_).autoPanel&&(a=null),e=new KC(n,a,r)}for(let n of t.effects)if(n.is(KO)){let r=t.state.facet(K_).autoPanel?n.value.length?KH.open:null:e.panel;e=KC.init(n.value,r,t.state)}else n.is(KP)?e=new KC(e.diagnostics,n.value?KH.open:null,e.selected):n.is(KA)&&(e=new KC(e.diagnostics,e.panel,n.value));return e},provide:e=>[KS.showPanel.from(e,e=>e.panel),KS.EditorView.decorations.from(e,e=>e.diagnostics)]}),Kz=KS.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function KT(e,t){return(0,qD.default)("ul",{class:"cm-tooltip-lint"},t.map(t=>KF(e,t,!1)))}let KD=e=>{let t=e.state.field(KI,!1);return!!t&&!!t.panel&&(e.dispatch({effects:KP.of(!1)}),!0)},KR=[{key:"Mod-Shift-m",run:e=>{var t,n;let r=e.state.field(KI,!1);r&&r.panel||e.dispatch({effects:(t=e.state,n=[KP.of(!0)],t.field(KI,!1)?n:n.concat(Wj.StateEffect.appendConfig.of(KY)))});let a=(0,KS.getPanel)(e,KH.open);return a&&a.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(KI,!1);if(!t)return!1;let n=e.state.selection.main,r=KM(t.diagnostics,null,n.to+1);return(!!r||!!(r=KM(t.diagnostics,null,0))&&(r.from!=n.from||r.to!=n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),(0,KS.activateHover)(e,r.from,1,{tooltip:KX,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],K_=Wj.Facet.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...(0,Wj.combineConfig)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:KL,tooltipFilter:KL,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,a)=>e(n,r,a)||t(n,r,a):e:t,autoPanel:(e,t)=>e||t})})});function KL(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function K$(e){let t=[];if(e)n:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue n}}t.push("")}return t}function KF(e,t,n){var r;let a=n?K$(t.actions):[];return(0,qD.default)("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},(0,qD.default)("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null==(r=t.actions)?void 0:r.map((n,r)=>{let i=!1,o=r=>{if(r.preventDefault(),i)return;i=!0;let a=KM(e.state.field(KI).diagnostics,t);a&&n.apply(e,a.from,a.to)},{name:l}=n,s=a[r]?l.indexOf(a[r]):-1,c=s<0?l:[l.slice(0,s),(0,qD.default)("u",l.slice(s,s+1)),l.slice(s+1)],d=n.markClass?" "+n.markClass:"";return(0,qD.default)("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:o,onmousedown:o,"aria-label":` Action: ${l}${s<0?"":` (access key "${a[r]})"`}.`},c)}),t.source&&(0,qD.default)("div",{class:"cm-diagnosticSource"},t.source))}class KB extends KS.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return(0,qD.default)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class KV{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=KF(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class KH{constructor(e){this.view=e,this.items=[];let t=t=>{if(!t.ctrlKey&&!t.altKey&&!t.metaKey){if(27==t.keyCode)KD(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],r=K$(n.actions);for(let a=0;a<r.length;a++)if(r[a].toUpperCase().charCodeAt(0)==t.keyCode){let t=KM(this.view.state.field(KI).diagnostics,n);t&&n.actions[a].apply(e,t.from,t.to)}}t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=(0,qD.default)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=(0,qD.default)("div",{class:"cm-panel-lint"},this.list,(0,qD.default)("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>KD(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(KI).selected;if(!e)return -1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return -1}update(){let{diagnostics:e,selected:t}=this.view.state.field(KI),n=0,r=!1,a=null,i=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:l})=>{for(let e of l.diagnostics){if(i.has(e))continue;i.add(e);let o=-1,l;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(l=new KV(this.view,e),this.items.splice(n,0,l),r=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),a=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new KV(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=KM(this.view.state.field(KI).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:KA.of(t)})}static open(e){return new KH(e)}}function KU(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}let KW=KS.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:KU("#f11")},".cm-lintRange-warning":{backgroundImage:KU("orange")},".cm-lintRange-info":{backgroundImage:KU("#999")},".cm-lintRange-hint":{backgroundImage:KU("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Kq(e){let t="hint",n=1;for(let a of e){var r;let e="error"==(r=a.severity)?4:"warning"==r?3:"info"==r?2:1;e>n&&(n=e,t=a.severity)}return t}KS.GutterMarker;let KK=Wj.StateEffect.define(),KG=Wj.StateField.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=KE(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(KK)?t.value:e,e)),provide:e=>KS.showTooltip.from(e)}),KX=(0,KS.hoverTooltip)(function(e,t,n){let{diagnostics:r}=e.state.field(KI),a,i=-1,o=-1;r.between(t-(n<0),t+ +(n>0),(e,r,{spec:l})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return a=l.diagnostics,i=e,o=r,!1});let l=e.state.facet(K_).tooltipFilter;return(a&&l&&(a=l(a,e.state)),a)?{pos:i,end:o,above:e.state.doc.lineAt(i).to<o,create:()=>({dom:KT(e,a)})}:null},{hideOn:KE}),KY=[KI,KS.EditorView.decorations.compute([KI],e=>{let{selected:t,panel:n}=e.field(KI);return t&&n&&t.from!=t.to?KS.Decoration.set([Kz.range(t.from,t.to)]):KS.Decoration.none}),KX,KW],KZ=Wj.Facet.define({combine:e=>(0,Wj.combineConfig)(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}),KJ=[(0,Wk.lineNumbers)(),(0,Wk.highlightActiveLineGutter)(),(0,Wk.highlightSpecialChars)(),function(e={}){return[WD,WT.of(e),Wk.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?W_:"historyRedo"==e.inputType?WL:null;return!!n&&(e.preventDefault(),n(t))}})]}(),(0,Wx.foldGutter)(),(0,Wk.drawSelection)(),(0,Wk.dropCursor)(),Wj.EditorState.allowMultipleSelections.of(!0),(0,Wx.indentOnInput)(),(0,Wx.syntaxHighlighting)(Wx.defaultHighlightStyle,{fallback:!0}),(0,Wx.bracketMatching)(),(0,Kk.closeBrackets)(),(0,Kk.autocompletion)(),(0,Wk.rectangularSelection)(),(0,Wk.crosshairCursor)(),(0,Wk.highlightActiveLine)(),[qZ,qY],Wk.keymap.of([...Kk.closeBracketsKeymap,...qT,...Kg,{key:"Mod-z",run:W_,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:WL,preventDefault:!0},{linux:"Ctrl-Shift-z",run:WL,preventDefault:!0},{key:"Mod-u",run:W$,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:WF,preventDefault:!0},...Wx.foldKeymap,...Kk.completionKeymap,...KR])];var KQ=e.i(99242);let K0=(0,ek.default)("binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]),K1=(0,ek.default)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),K2=(0,ek.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),K5=(0,ek.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),K4=(0,ek.default)("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),K3=(0,ek.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),K6={review:"Review",edit:"Edit",view:"View",code:"Code",preview:"Preview",hex:"Hex",actions:"File view options",save:"Save",saving:"Saving",binaryTitle:"Binary content is not rendered",binaryDescription:"This file is binary or too large to decode safely. Render it only when you explicitly need to inspect the raw bytes.",renderAnyway:"Render anyway",unsupportedPreview:"No preview renderer is available for this file.",noContent:"No file content.",pathSeparator:"/",history:"History"};function K8(e){let t=e.name||e.path||"",n=/\.([^.\\/]+)$/.exec(t);return n?.[1]?.toLowerCase()}function K7(e){if(e.kind)return e.kind;let t=e.mimeType?.toLowerCase()??"",n=K8(e);return t.startsWith("image/")?"svg"===n?"svg":"image":t.startsWith("video/")?"video":t.includes("html")?"html":t.includes("markdown")?"markdown":t.includes("json")?"code":t.startsWith("text/")?"text":"svg"===n?"svg":"html"===n||"htm"===n?"html":"md"===n||"mdx"===n?"markdown":["png","jpg","jpeg","gif","webp","avif"].includes(n??"")?"image":["mp4","webm","mov","m4v","ogg"].includes(n??"")?"video":["zip","tar","gz","7z","rar","exe","dll","bin","wasm","pdf","psd"].includes(n??"")?"binary":"code"}async function K9(e){let t=function(e){for(let t of[(e.language??K8(e)??"text").toLowerCase(),e.mimeType?.toLowerCase()]){if(!t)continue;let e=Wx.LanguageDescription.matchLanguageName(Ww,t,!0);if(e)return e}for(let t of[e.name,e.path]){if(!t)continue;let e=Wx.LanguageDescription.matchFilename(Ww,t);if(e)return e}}(e);if(!t)return[];try{return await t.load()}catch{return[]}}function Ge(e){if(e&&!(e<=0))return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Gt(e){let t=K7(e);return"binary"===t?["hex"]:"image"===t||"video"===t?["preview"]:["html","markdown","richtext","svg"].includes(t)?["code","preview"]:["code"]}let Gn=Wx.HighlightStyle.define([{tag:KQ.tags.comment,color:"var(--vtl-cm-comment)",fontStyle:"italic"},{tag:[KQ.tags.keyword,KQ.tags.modifier,KQ.tags.operatorKeyword],color:"var(--vtl-cm-keyword)"},{tag:[KQ.tags.atom,KQ.tags.bool,KQ.tags.null],color:"var(--vtl-cm-constant)"},{tag:[KQ.tags.number,KQ.tags.integer,KQ.tags.float],color:"var(--vtl-cm-number)"},{tag:[KQ.tags.string,KQ.tags.special(KQ.tags.string),KQ.tags.regexp],color:"var(--vtl-cm-string)"},{tag:[KQ.tags.variableName,KQ.tags.self,KQ.tags.propertyName],color:"var(--vtl-cm-variable)"},{tag:[KQ.tags.definition(KQ.tags.variableName),KQ.tags.function(KQ.tags.variableName)],color:"var(--vtl-cm-function)"},{tag:[KQ.tags.className,KQ.tags.typeName,KQ.tags.namespace],color:"var(--vtl-cm-type)"},{tag:[KQ.tags.tagName,KQ.tags.heading],color:"var(--vtl-cm-tag)"},{tag:KQ.tags.attributeName,color:"var(--vtl-cm-attribute)"},{tag:[KQ.tags.attributeValue,KQ.tags.link],color:"var(--vtl-cm-string)"},{tag:[KQ.tags.punctuation,KQ.tags.separator,KQ.tags.bracket],color:"var(--vtl-cm-punctuation)"},{tag:[KQ.tags.invalid],color:"var(--vtl-cm-invalid)"}]),Gr=Wk.EditorView.theme({"&":{height:"100%",backgroundColor:"var(--vtl-cm-background)",color:"var(--vtl-cm-foreground)",fontSize:"var(--font-size-code)",lineHeight:"var(--vtl-cm-line-height)"},".cm-scroller":{fontFamily:"var(--font-family-mono)",height:"100%",overflow:"auto",scrollbarColor:"var(--border) transparent",scrollbarWidth:"thin"},".cm-scroller::-webkit-scrollbar":{width:"10px",height:"10px"},".cm-scroller::-webkit-scrollbar-track, .cm-scroller::-webkit-scrollbar-corner":{background:"transparent"},".cm-scroller::-webkit-scrollbar-thumb":{backgroundColor:"var(--border)",border:"3px solid transparent",borderRadius:"9999px",backgroundClip:"content-box"},".cm-content":{minHeight:"100%",caretColor:"var(--vtl-cm-foreground)",padding:"0 0"},".cm-gutters":{backgroundColor:"var(--vtl-cm-background)",color:"var(--vtl-cm-gutter-foreground)",borderRightColor:"transparent",left:"0",position:"sticky",zIndex:"2"},".cm-gutter":{minWidth:"2.5rem"},".cm-gutters .cm-foldGutter":{display:"none !important"},".cm-lineNumbers .cm-gutterElement":{minWidth:"2.5rem",padding:"0 0.5rem 0 0",textAlign:"right",lineHeight:"var(--vtl-cm-line-height)"},".cm-activeLine":{backgroundColor:"var(--vtl-cm-active-line)"},".cm-activeLineGutter":{backgroundColor:"var(--vtl-cm-background)",color:"var(--vtl-cm-foreground)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--vtl-cm-selection) !important"},".cm-line ::selection, .cm-content ::selection, ::selection":{backgroundColor:"var(--vtl-cm-selection) !important",color:"var(--vtl-cm-selection-text) !important"},"&.cm-focused":{outline:"none"},".cm-cursor":{borderLeftColor:"var(--vtl-cm-foreground)"},".cm-line":{caretColor:"var(--vtl-cm-foreground)",lineHeight:"var(--vtl-cm-line-height)",minHeight:"var(--vtl-cm-line-height)",padding:"0 0.75rem"}});function Ga({value:e,file:t,readOnly:n,onValueChange:r,wrapLines:a,className:i}){let o=ew.useRef(null),l=ew.useRef(null),s=ew.useRef(e),c=ew.useRef(r);return ew.useEffect(()=>{c.current=r},[r]),ew.useEffect(()=>{s.current=e;let t=l.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e]),ew.useEffect(()=>{let e=o.current;if(!e)return;let r=!1,i=new Wj.Compartment,d=new Wk.EditorView({parent:e,state:Wj.EditorState.create({doc:s.current,extensions:[KJ,Gr,Wj.EditorState.readOnly.of(n),Wk.EditorView.editable.of(!n),a?Wk.EditorView.lineWrapping:[],i.of([]),Wj.Prec.high((0,Wx.syntaxHighlighting)(Gn)),Wk.EditorView.updateListener.of(e=>{if(!e.docChanged)return;let t=e.state.doc.toString();s.current=t,c.current?.(t)})]})});return l.current=d,K9(t).then(e=>{r||l.current!==d||d.dispatch({effects:i.reconfigure(e)})}),()=>{r=!0,d.destroy(),l.current=null}},[t.kind,t.language,t.mimeType,t.name,t.path,t.readOnly,n,a]),(0,ey.jsx)("div",{"data-slot":"file-tab-code-editor",className:(0,eI.cn)("size-full overflow-hidden bg-background",i),ref:o})}function Gi({value:e}){let t=e.split(/\n{2,}/);return(0,ey.jsx)("div",{className:"mx-auto grid w-full max-w-3xl gap-3 p-6",children:t.map((e,t)=>{let n=e.trim();return n?n.startsWith("### ")?(0,ey.jsx)("h3",{className:"ui-text-body font-semibold text-foreground",children:n.replace(/^###\s+/,"")},t):n.startsWith("## ")?(0,ey.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:n.replace(/^##\s+/,"")},t):n.startsWith("# ")?(0,ey.jsx)("h1",{className:"text-xl font-semibold text-foreground",children:n.replace(/^#\s+/,"")},t):n.startsWith(">")?(0,ey.jsx)("blockquote",{className:"ui-text-body border-l-2 pl-3 text-muted-foreground",children:n.replace(/^>\s?/gm,"")},t):/^[-*]\s+/m.test(n)?(0,ey.jsx)("ul",{className:"ui-text-body grid list-disc gap-1 pl-5",children:n.split("\n").map(e=>(0,ey.jsx)("li",{children:e.replace(/^[-*]\s+/,"")},e))},t):n.startsWith("```")?(0,ey.jsx)("pre",{className:"overflow-auto rounded-lg border bg-code p-3 ui-text-code text-code-foreground",children:n.replace(/^```\w*\n?/,"").replace(/```$/,"")},t):(0,ey.jsx)("p",{className:"ui-text-body text-muted-foreground",children:n},t):null})})}function Go({title:e,value:t,className:n}){let r=function(){let[e,t]=ew.useState("light");return ew.useEffect(()=>{function e(){let e=document.documentElement.classList.contains("dark"),n=document.documentElement.classList.contains("light");e||n?t(e?"dark":"light"):t(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}e();let n=new MutationObserver(e),r=window.matchMedia("(prefers-color-scheme: dark)");return n.observe(document.documentElement,{attributeFilter:["class"],attributes:!0}),r.addEventListener("change",e),()=>{n.disconnect(),r.removeEventListener("change",e)}},[]),e}(),a=ew.useMemo(()=>{let e,n;return e="dark"===r?"rgba(255, 255, 255, 0.16)":"#d8dee9",n=`<style data-vantaloom-scrollbar>
|
|
@@ -49,4 +49,4 @@ ${e.detail}`:e.title;async function s(){try{await navigator.clipboard.writeText(
|
|
|
49
49
|
border-radius: 9999px;
|
|
50
50
|
background-clip: content-box;
|
|
51
51
|
}
|
|
52
|
-
</style>`,/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${n}</head>`):`${n}${t}`},[r,t]);return(0,ey.jsx)("iframe",{title:e,sandbox:"allow-scripts",srcDoc:a,className:(0,eI.cn)("size-full border-0 bg-background",n)})}function Gl({file:e,value:t,labels:n}){let r=ew.useMemo(()=>{let n=e.bytes??(t?new TextEncoder().encode(t):[]),r=Math.min(n.length,4096),a=[];for(let e=0;e<r;e+=16){let t=Array.from({length:Math.min(16,r-e)},(t,r)=>n[e+r]??0);a.push({offset:e.toString(16).padStart(8,"0"),hex:t.map(e=>e.toString(16).padStart(2,"0")).join(" "),ascii:t.map(e=>e>=32&&e<=126?String.fromCharCode(e):".").join("")})}return a},[e.bytes,t]);return 0===r.length?(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:n.noContent}):(0,ey.jsx)("div",{className:"size-full overflow-auto bg-background p-3 ui-text-code",children:(0,ey.jsx)("div",{className:"grid min-w-max grid-cols-[5.5rem_30rem_1fr] gap-x-4",children:r.map(e=>(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.offset}),(0,ey.jsx)("span",{className:"font-mono text-foreground",children:e.hex}),(0,ey.jsx)("span",{className:"font-mono text-muted-foreground",children:e.ascii})]},e.offset))})})}function Gs({file:e,labels:t,onApprove:n}){return(0,ey.jsx)("div",{className:"grid size-full place-items-center bg-muted/20 p-6",children:(0,ey.jsxs)("div",{className:"grid max-w-md justify-items-center gap-3 text-center",children:[(0,ey.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-background text-muted-foreground",children:(0,ey.jsx)(K0,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("h3",{className:"ui-text-body font-medium text-foreground",children:t.binaryTitle}),(0,ey.jsx)("p",{className:"ui-text-body text-muted-foreground",children:t.binaryDescription})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[Ge(e.size)&&(0,ey.jsx)(Bs,{variant:"outline",children:Ge(e.size)}),(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",onClick:n,children:t.renderAnyway})]})]})})}function Gc({labels:e}){return(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:e.unsupportedPreview})}function Gd({file:e,value:t,labels:n,renderPreview:r,className:a}){let i=K7(e),o=e.src?e.src:t&&"svg"===K7(e)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:void 0,l=r?.(e,t);return void 0!==l?(0,ey.jsx)("div",{"data-slot":"file-tab-custom-preview",className:(0,eI.cn)("size-full",a),children:l}):"html"===i||"richtext"===i?(0,ey.jsx)(Go,{title:e.name,value:e.previewContent??t,className:a}):"markdown"===i?(0,ey.jsx)("div",{"data-slot":"file-tab-markdown-preview",className:(0,eI.cn)("size-full overflow-auto bg-background",a),children:(0,ey.jsx)(Gi,{value:t})}):"svg"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-svg-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-lg border bg-background p-4"})}):"image"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-image-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-md"})}):"video"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-video-preview",className:(0,eI.cn)("grid size-full place-items-center bg-muted/20 p-6",a),children:(0,ey.jsx)("video",{src:o,controls:!0,preload:"none",className:"max-h-full max-w-full rounded-md border bg-background"})}):(0,ey.jsx)(Gc,{labels:n})}function Gu({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:h,onHistory:m}){let p=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,ey.jsx)(Us,{className:"size-4"}):(0,ey.jsx)(uk,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,ey.jsx)(K1,{className:"size-4"}):(0,ey.jsx)(eS,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:h,disabled:a||!i,icon:(0,ey.jsx)(K3,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:m,icon:(0,ey.jsx)(K2,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===p.length?null:(0,ey.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[p.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function Gf({file:e,value:t,defaultValue:n,onValueChange:r,mode:a,defaultMode:i="review",onModeChange:o,view:l,defaultView:s="code",onViewChange:c,modified:d=!1,onSave:u,onSaveError:f,largeBinaryThreshold:h=2097152,showHeader:m=!0,wrapLines:p=!1,renderPreview:g,onHistory:v,labels:x,className:y,editorClassName:b,previewClassName:w,headerClassName:j,...k}){var S;let N,C,M=ew.useMemo(()=>({...K6,...x}),[x]),[E,O]=ew.useState(n??e.content??""),[P,A]=ew.useState(i),[I,z]=ew.useState(s),[T,D]=ew.useState(!1),[R,_]=ew.useState(!1),[L,$]=ew.useState(!1),F=ew.useRef(null),B=t??E,V=a??P,H=(S=l??I,(N=Gt(e)).includes(S)?S:N[0]),U=K7(e),W=Gt(e).length>1,q=!e.readOnly&&["text","code","html","markdown","richtext","svg"].includes(K7(e)),K=!!u&&q&&"code"===H&&(d||L),G="review"===V||!0===e.readOnly,X="binary"===(C=K7(e))||"image"!==C&&"video"!==C&&!!(e.size&&e.size>h&&!e.content),Y=(e.path??e.name).split(/[\\/]+/).filter(Boolean),Z=Ge(e.size??B.length);async function J(){if(u&&!L){$(!0);try{await u(B),_(!1)}catch(e){f?.(e)}finally{$(!1)}}}return ew.useEffect(()=>{void 0===t&&O(n??e.content??""),D(!1),_(!1)},[n,e,t]),ew.useEffect(()=>{if(R)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&F.current?.contains(t)||_(!1)}},[R]),(0,ey.jsxs)("div",{ref:F,"data-slot":"file-tab-viewer","data-mode":V,"data-view":H,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",m?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",y),...k,children:[m&&(0,ey.jsxs)("div",{"data-slot":"file-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",j),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:"image"===U?(0,ey.jsx)(K5,{className:"size-3.5"}):"video"===U?(0,ey.jsx)(K4,{className:"size-3.5"}):"binary"===U?(0,ey.jsx)(K0,{className:"size-3.5"}):(0,ey.jsx)(x3,{className:"size-3.5"})}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:Y.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[t>0&&(0,ey.jsx)("span",{className:"text-muted-foreground",children:M.pathSeparator}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",t===Y.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,ey.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[Z&&(0,ey.jsx)(Bs,{variant:"outline",children:Z}),q&&"code"===H&&(G?(0,ey.jsxs)(Bs,{variant:"secondary",children:[(0,ey.jsx)(lK,{className:"size-3"}),M.review]}):(0,ey.jsxs)(Bs,{variant:"outline",children:[(0,ey.jsx)(K1,{className:"size-3"}),M.edit]}))]})]}),(0,ey.jsx)("div",{"data-slot":"file-tab-viewer-body",className:"min-h-0 overflow-hidden",children:X&&!T?(0,ey.jsx)(Gs,{file:e,labels:M,onApprove:()=>D(!0)}):"preview"===H?(0,ey.jsx)(Gd,{file:e,value:B,labels:M,renderPreview:g,className:w}):"hex"===H?(0,ey.jsx)(Gl,{file:e,value:B,labels:M}):(0,ey.jsx)(Ga,{file:e,value:B,readOnly:G,onValueChange:function(e){void 0===t&&O(e),r?.(e)},wrapLines:p,className:b})}),(0,ey.jsx)(Gu,{open:R,labels:M,currentView:H,currentMode:V,saving:L,modified:d,canSwitchView:W,canSwitchMode:q&&"code"===H,canSave:K,canOpenHistory:!!(v&&e.path),onOpenChange:_,onToggleView:function(){var e;e="code"===H?"preview":"code",void 0===l&&z(e),c?.(e)},onToggleMode:function(){var e;e="review"===V?"edit":"review",void 0===a&&A(e),o?.(e)},onSave:J,onHistory:()=>{_(!1),v?.(e)}})]})}function Gh(e,t){return e[Math.max(0,t-1)]?.id??e[0]?.id}function Gm(e){return"string"==typeof e||"number"==typeof e?String(e):void 0}function Gp(e,t,n){let r=[...e],a=r[t],i=r[n];return a&&i&&(r[t]=i,r[n]=a),r}function Gg({tabs:e,defaultTabs:t=[],activeTabId:n,defaultActiveTabId:r,onActiveTabChange:a,onTabsChange:i,onCreateTab:o,onCloseTab:l,onTabReorder:s,onTabDetach:c,onExternalTabDrop:d,createActions:u=[],tabActions:f=[],reorderable:h=!0,detachable:m=!1,externalDropTypes:p=[],createLabel:g="New tab",moreLabel:v="More tab actions",closeLabel:x="Close tab",scrollLeftLabel:y="Scroll tabs left",scrollRightLabel:b="Scroll tabs right",tabListLabel:w="Open tabs",emptyContent:j,renderContent:k,showContent:S=!0,className:N,tabListClassName:C,contentClassName:M}){let[E,O]=ew.useState(t),P=ew.useRef(null),A=ew.useRef(null),[I,z]=ew.useState(),[T,D]=ew.useState(void 0),R=ew.useRef(void 0),[_,L]=ew.useState(void 0),[$,F]=ew.useState(!1),B=ew.useRef(void 0),V=ew.useRef(void 0),H=ew.useRef(!1),[U,W]=ew.useState(!1),[q,K]=ew.useState(!1),[G,X]=ew.useState(),Y=e??E,Z=Y.find(e=>!e.disabled),[J,Q]=ew.useState(r??Z?.id),ee=n??J,et=Y.find(e=>e.id===ee&&!e.disabled)??Z;ew.useEffect(()=>{!et&&Z&&void 0===n&&Q(Z.id)},[et,n,Z]);let en=ew.useCallback(t=>{void 0===e&&O(t),i?.(t)},[i,e]),er=ew.useCallback(e=>{R.current=e,D(e)},[]),ea=ew.useCallback(()=>{let e=A.current,t=new Map;if(!e)return t;for(let n of e.querySelectorAll("[data-tab-id]")){let e=n.getBoundingClientRect(),r=n.dataset.tabId;r&&t.set(r,{left:e.left,top:e.top})}return t},[]),ei=ew.useCallback((e,t=!0)=>{t&&(V.current=ea()),B.current=e,L(e)},[ea]),eo=ew.useCallback(()=>{let e=A.current;if(!e){W(!1),K(!1);return}let t=e.scrollWidth-e.clientWidth;W(e.scrollLeft>1),K(e.scrollLeft<t-1)},[]);function el(e){let t=A.current;if(!t)return;let n=Math.max(.7*t.clientWidth,160);t.scrollLeft+="left"===e?-n:n,window.requestAnimationFrame(eo)}ew.useEffect(()=>{F(!0)},[]),ew.useEffect(()=>{eo();let e=A.current;if(!e)return;let t=new ResizeObserver(eo);return t.observe(e),window.addEventListener("resize",eo),()=>{t.disconnect(),window.removeEventListener("resize",eo)}},[Y.length,eo]),ew.useLayoutEffect(()=>{let e=V.current,t=A.current;if(e&&t)for(let n of(V.current=void 0,t.querySelectorAll("[data-tab-id]"))){let t=n.dataset.tabId;if(!t)continue;let r=e.get(t);if(!r)continue;let a=n.getBoundingClientRect(),i=r.left-a.left,o=r.top-a.top;1>Math.abs(i)&&1>Math.abs(o)||n.animate([{transform:`translate(${i}px, ${o}px)`},{transform:"translate(0, 0)"}],{duration:150,easing:"cubic-bezier(0.2, 0, 0, 1)"})}},[_]);let es=ew.useCallback(e=>{let t=A.current;if(t)return Array.from(t.querySelectorAll("[data-tab-id]")).find(t=>t.dataset.tabId===e)},[]),ec=ew.useCallback((e,t)=>{let n=B.current??Y,r=n.findIndex(t=>t.id===e.tabId);if(-1===r)return;let a=t-e.offsetX,i=a+e.width,o=t>=e.currentX,l=n[r+1],s=n[r-1];if(o&&l&&!l.disabled){let e=es(l.id),t=e?.getBoundingClientRect();t&&i>=t.left+.7*t.width&&ei(Gp(n,r,r+1));return}if(!o&&s&&!s.disabled){let e=es(s.id),t=e?.getBoundingClientRect();t&&a<=t.right-.7*t.width&&ei(Gp(n,r,r-1))}},[es,Y,ei]);function ed(e){if(!d||0===p.length)return!1;let t=Array.from(e.dataTransfer.types);return p.some(e=>t.includes(e))}function eu(e){let t=A.current;if(!t)return{index:Y.length,left:0};let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll("[data-tab-id]"));if(0===r.length)return{index:0,left:t.scrollLeft+8};for(let[a,i]of r.entries()){let r=i.getBoundingClientRect();if(e.clientX<r.left+r.width/2)return{index:a,left:r.left-n.left+t.scrollLeft}}let a=r[r.length-1].getBoundingClientRect();return{index:r.length,left:a.right-n.left+t.scrollLeft}}ew.useEffect(()=>{if(T)return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t,{once:!0}),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)};function e(e){let t=R.current;if(!t)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,a=t.dragging||Math.abs(n)>4||Math.abs(r)>4;a&&(e.preventDefault(),ec(t,e.clientX)),er({...t,currentX:e.clientX,currentY:e.clientY,dragging:a})}function t(e){let t=R.current;if(t?.dragging){e.preventDefault(),H.current=!0;let r=Y.find(e=>e.id===t.tabId),i=P.current?.getBoundingClientRect(),o=!!i&&(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom);if(m&&c&&r&&o&&function(e,t){if(e.pinned)return!1;let r=Y.findIndex(t=>t.id===e.id);if(c?.(e,{tabs:Y,clientX:t.clientX,clientY:t.clientY,nativeEvent:t})===!1)return!1;let i=Y.filter(t=>t.id!==e.id);if(en(i),e.id===ee){let e=Gh(i,r);void 0===n&&Q(e),e&&a?.(e)}return!0}(r,e)){z(void 0),er(void 0),ei(void 0,!1);return}let l=B.current;l&&!(l.length===Y.length&&l.every((e,t)=>e.id===Y[t]?.id))&&(en(l),s?.(l))}z(void 0),er(void 0),ei(void 0,!1)}});let ef=et&&(k?.(et)??et.content??(0,ey.jsx)("div",{className:"grid min-h-44 place-items-center bg-muted/30 p-6 text-center text-muted-foreground",children:et.title})),eh=T?.dragging&&_?_:Y,em=T?.dragging?Y.find(e=>e.id===T.tabId):void 0,ep=T?.dragging&&em&&$?(0,iy.createPortal)((0,ey.jsxs)("div",{"data-slot":"multi-tab-drag-preview","aria-hidden":"true",className:"pointer-events-none fixed z-[100] flex h-9 min-w-0 items-center gap-1 rounded-t-lg border border-border bg-background px-2.5 text-foreground shadow-lg",style:{left:T.currentX-T.offsetX,top:T.top,width:T.width},children:[em.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:em.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:em.title}),em.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),document.body):null;return(0,ey.jsxs)("div",{ref:P,"data-slot":"multi-tab-system",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--surface-panel-radius)] border",N),children:[(0,ey.jsxs)("div",{className:"relative flex min-w-0 shrink-0 items-end gap-1 border-b bg-muted/35 px-1.5 pt-1.5",children:[U&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y,onClick:()=>el("left"),className:"mb-1 shrink-0",children:(0,ey.jsx)(mJ,{})}),(0,ey.jsxs)("div",{ref:A,role:"tablist","aria-label":w,"data-slot":"multi-tab-list",className:(0,eI.cn)("relative flex min-w-0 flex-1 items-end overflow-x-auto [scrollbar-width:none] data-[overflow=both]:[mask-image:linear-gradient(90deg,transparent,black_24px,black_calc(100%-24px),transparent)] data-[overflow=left]:[mask-image:linear-gradient(90deg,transparent,black_24px)] data-[overflow=right]:[mask-image:linear-gradient(90deg,black_calc(100%-24px),transparent)] [&::-webkit-scrollbar]:hidden",C),"data-overflow":U&&q?"both":U?"left":q?"right":void 0,onScroll:eo,onDragOver:function(e){ed(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",X(eu(e)))},onDragLeave:function(e){if(!ed(e))return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||X(void 0)},onDrop:function(e){if(!ed(e))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=eu(e);X(void 0),d?.({tabs:Y,insertIndex:t.index,nativeEvent:e})},children:[eh.map((e,t)=>{let r=e.id===et?.id,i=eh[t+1],o=T?.dragging&&I===e.id,s=!r&&!o&&void 0!==i&&i.id!==et?.id&&i.id!==I;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsxs)("div",{onPointerDown:t=>(function(e,t){if(!h||e.disabled||0!==t.button)return;let n=t.currentTarget.getBoundingClientRect();z(e.id),ei(Y,!1),er({tabId:e.id,startX:t.clientX,startY:t.clientY,offsetX:t.clientX-n.left,top:n.top,width:n.width,currentX:t.clientX,currentY:t.clientY,dragging:!1})})(e,t),"data-slot":"multi-tab","data-tab-id":e.id,"data-state":r?"active":"inactive","data-dragging":I===e.id?"true":void 0,"data-modified":e.modified?"true":void 0,className:(0,eI.cn)("group/tab relative flex h-9 min-w-0 max-w-52 shrink-0 items-center gap-1 rounded-t-lg border border-b-0 px-2.5 transition-[border-color,background-color,color,box-shadow,outline-color] duration-150 ease-out",h&&!e.disabled&&"cursor-grab active:cursor-grabbing",r?"border-border bg-background text-foreground shadow-[0_-1px_0_var(--background)_inset]":"border-transparent bg-transparent text-muted-foreground hover:bg-background/70 hover:text-foreground",o&&"border-dashed border-border bg-muted/45 text-transparent shadow-none outline outline-1 outline-ring/30 [&_*]:opacity-0",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsx)("button",{type:"button",role:"tab","aria-label":Gm(e.title),"aria-selected":r,disabled:e.disabled,onClick:t=>{var r;let i;if(H.current){H.current=!1,t.preventDefault();return}r=e.id,(i=Y.find(e=>e.id===r))&&!i.disabled&&(void 0===n&&Q(r),a?.(r))},className:"absolute inset-0 rounded-t-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}),(0,ey.jsxs)("div",{"aria-hidden":"true",className:"pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-1.5",children:[e.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:e.title}),e.meta&&(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.meta}),e.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),!e.pinned&&(0,ey.jsx)("button",{type:"button",draggable:!1,onPointerDown:e=>e.stopPropagation(),"aria-label":e.closeLabel??(Gm(e.title)?`${x}: ${Gm(e.title)}`:x),onClick:()=>(function(e){if(e.pinned)return;let t=Y.findIndex(t=>t.id===e.id),r=Y.filter(t=>t.id!==e.id);if(en(r),l?.(e),e.id===ee){let e=Gh(r,t);void 0===n&&Q(e),e&&a?.(e)}})(e),className:(0,eI.cn)("relative z-20 grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none group-hover/tab:opacity-100",r&&"opacity-100"),children:(0,ey.jsx)(fg.XIcon,{className:"size-3.5"})})]}),s&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"mb-2 h-4 w-px shrink-0 bg-border/80"})]},e.id)}),G?(0,ey.jsxs)("span",{"data-slot":"multi-tab-external-insert","aria-hidden":"true",className:"pointer-events-none absolute top-2 bottom-1 z-30 flex w-0 -translate-x-1/2 items-center justify-center",style:{left:G.left},children:[(0,ey.jsx)("span",{className:"h-full w-px rounded-full bg-foreground/80"}),(0,ey.jsx)("span",{className:"absolute top-0 size-1.5 rounded-full bg-foreground"})]}):null]}),(0,ey.jsxs)("div",{className:"mb-1 flex shrink-0 items-center gap-1",children:[q&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":b,onClick:()=>el("right"),children:(0,ey.jsx)(mQ,{})}),u.length>0?(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,children:(0,ey.jsx)(lJ,{})})}),(0,ey.jsx)(bZ,{align:"end",className:"w-52",children:u.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(b2,{children:e.shortcut})]})]},t))})]}):(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,onClick:function(){let e=o?.();e&&(en([...Y,e]),e.disabled||(void 0===n&&Q(e.id),a?.(e.id)))},children:(0,ey.jsx)(lJ,{})}),f.length>0&&(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":v,children:(0,ey.jsx)(lY,{})})}),(0,ey.jsx)(bZ,{align:"end",className:"w-52",children:f.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(b2,{children:e.shortcut})]})]},t))})]})]})]}),ep,S&&(0,ey.jsx)("div",{"data-slot":"multi-tab-content",className:(0,eI.cn)("min-h-0 overflow-hidden",M),children:ef??j??(0,ey.jsx)("div",{"aria-hidden":"true",className:"min-h-44 rounded-lg border border-dashed bg-muted/30"})})]})}let Gv=(0,ek.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function Gx({status:e}){return"done"===e?(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}):"in_progress"===e?(0,ey.jsx)(Vw,{className:"size-3.5 shrink-0 text-amber-500"}):"blocked"===e||"skipped"===e?(0,ey.jsx)(Gv,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(bC,{className:"size-3.5 shrink-0 text-muted-foreground/50"})}function Gy({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,ey.jsxs)("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}let Gb={main:"主",subagent:"子"};function Gw({node:e,depth:t,activeId:n}){let r=function e(t){if(!t.children||0===t.children.length)return"task"!==t.kind&&"subplan"!==t.kind?{done:0,total:0}:{done:+("done"===t.status),total:1};let n=0,r=0;for(let a of t.children){let t=e(a);n+=t.done,r+=t.total}return{done:n,total:r}}(e),a="phase"===e.kind,i=e.orchestration,o=void 0!==n&&e.id===n;return(0,ey.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,ey.jsxs)("div",{className:(0,eI.cn)("flex items-center gap-2 rounded-md px-1.5 py-1",o&&"bg-sky-teal/10 ring-1 ring-sky-teal/30"),style:{marginLeft:12*t},children:[(0,ey.jsx)(Gx,{status:e.status}),(0,ey.jsx)("span",{className:(0,eI.cn)("min-w-0 flex-1 truncate text-[13px]","done"===e.status&&"text-muted-foreground line-through",o&&"font-medium text-foreground"),title:e.detail||e.title,children:e.title}),a&&i?(0,ey.jsxs)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:[Gb[i.executor]??i.executor,i.subagentType?`:${i.subagentType}`:""]}):null,a&&r.total>0?(0,ey.jsx)(Gy,{done:r.done,total:r.total}):null]}),e.children?.map(e=>(0,ey.jsx)(Gw,{node:e,depth:t+1,activeId:n},e.id))]})}function Gj({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState("");ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{let a=await sD(e,t);n&&(r(a.planState),void 0!==a.planDoc&&i(a.planDoc))};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let o=n?.activePath?.length?n.activePath[n.activePath.length-1]:void 0;return(0,ey.jsx)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:(0,ey.jsxs)(md,{defaultValue:"doc",className:"flex min-h-0 flex-1 flex-col gap-0",children:[(0,ey.jsx)("div",{className:"shrink-0 border-b px-2 py-1.5",children:(0,ey.jsxs)(my,{children:[(0,ey.jsx)(mb,{value:"doc",children:"计划文档"}),(0,ey.jsx)(mb,{value:"tree",children:"执行树"})]})}),(0,ey.jsx)(mw,{value:"doc",className:"min-h-0 flex-1",children:(0,ey.jsx)(wz,{className:"h-full",children:(0,ey.jsx)("div",{className:"px-4 py-3 text-sm",children:a.trim()?(0,ey.jsx)(Vq,{content:a}):(0,ey.jsx)("p",{className:"text-muted-foreground/70",children:"尚无可读计划文档。"})})})}),(0,ey.jsx)(mw,{value:"tree",className:"min-h-0 flex-1",children:(0,ey.jsx)(wz,{className:"h-full",children:(0,ey.jsx)("div",{className:"px-2 py-2",children:n?.tree?(0,ey.jsx)(Gw,{node:n.tree,depth:0,activeId:o}):(0,ey.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"计划尚未编译成执行树。"})})})})]})})}function Gk({conversationId:e,ownerMachineId:t,initialPath:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(n),[l,s]=ew.useState("");return ew.useEffect(()=>{if(!e)return;let n=!0,r=async()=>{let r=await s_(e,t);if(!n)return;let i=r.filter(e=>e.startsWith("plan/specs/"));a(i),o(e=>e??i[0])};r();let i=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(i)}},[e,t]),ew.useEffect(()=>{if(!e||!i)return void s("");let n=!0,r=async()=>{try{let r=await sR(e,i,t);n&&s(r.content)}catch{n&&s("")}};r();let a=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(a)}},[e,t,i]),(0,ey.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,ey.jsx)("div",{className:"flex shrink-0 flex-wrap gap-1 border-b px-2 py-1.5",children:0===r.length?(0,ey.jsx)("span",{className:"px-1 py-1 text-xs text-muted-foreground/70",children:"尚无规范文档"}):r.map(e=>(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors",e===i?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60"),onClick:()=>o(e),children:[(0,ey.jsx)(uC,{className:"size-3.5"}),e.split("/").pop()??e]},e))}),(0,ey.jsx)(wz,{className:"min-h-0 flex-1",children:(0,ey.jsx)("div",{className:"px-4 py-3 text-sm",children:l.trim()?(0,ey.jsx)(Vq,{content:l}):(0,ey.jsx)("p",{className:"text-muted-foreground/70",children:i?"(空文档)":"选择左上方的规范文档查看。"})})})]})}let GS=(0,ek.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),GN=(0,ek.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),GC=(0,ek.default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]),GM=(0,ek.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),GE=(0,ek.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function GO(e,t){return e?eD(`/v1/remote/${e}${t}`):eD(t)}async function GP(e,t){let{signal:n,timeoutMs:r=8e3}=t??{},a=new AbortController,i=r>0?setTimeout(()=>a.abort(),r):void 0;n&&n.addEventListener("abort",()=>a.abort(),{once:!0});try{let t=await fetch(GO(e,"/v1/extensions"),{cache:"no-store",signal:a.signal});if(!t.ok)throw Error(`Extensions API error: ${t.status}`);return await t.json()}finally{i&&clearTimeout(i)}}async function GA(e,t,n){let r=await fetch(GO(e,t),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:void 0===n?void 0:JSON.stringify(n)});if(!r.ok)throw Error(`Extensions API error: ${r.status}`);let a=await r.text();return a?JSON.parse(a):{}}async function GI(e,t){return GA(e,"/v1/extensions/browser/install",{variant:t})}async function Gz(e,t){return GA(e,"/v1/extensions/browser/update",t?{variant:t}:{})}async function GT(e){return GA(e,"/v1/extensions/browser/uninstall")}async function GD(e,t){return GA(e,"/v1/extensions/browser/enable",{enabled:t})}let GR={drafting:"撰写计划",awaiting_approval:"等待批准",executing:"执行中",compacting:"压缩上下文",done:"已完成"};function G_(e){if(!e.children||0===e.children.length)return"task"!==e.kind&&"subplan"!==e.kind?{done:0,total:0}:{done:+("done"===e.status),total:1};let t=0,n=0;for(let r of e.children){let e=G_(r);t+=e.done,n+=e.total}return{done:t,total:n}}function GL(e,t){if(e){if(e.id===t)return e;for(let n of e.children??[]){let e=GL(n,t);if(e)return e}}}function G$({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,ey.jsxs)("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}function GF({state:e}){let{phase:t,task:n}=function(e){let t,n=e.activePath??[];if(!e.tree||0===n.length)return{};for(let r of n){let n=GL(e.tree,r);n&&"phase"===n.kind&&(t=n)}let r=n[n.length-1];return{phase:t,task:r?GL(e.tree,r):void 0}}(e),r=e.tree?G_(e.tree):{done:0,total:0},a=t?G_(t):void 0,i=r.total>0?Math.round(r.done/r.total*100):0,o=n?.status==="in_progress";return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(GB,{icon:(0,ey.jsx)(GC,{}),label:"任务进度"}),(0,ey.jsxs)("div",{className:"flex flex-col gap-2 px-3 pb-2 text-[13px]",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:"当前阶段"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:t?.title??GR[e.phase]??e.phase??"—"})]}),a&&a.total>0?(0,ey.jsx)(G$,{done:a.done,total:a.total}):null,n?(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[o?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):"done"===n.status?(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}):null,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:n.detail||n.title,children:n.title})]}):null,(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:"总体进度"}),(0,ey.jsxs)("span",{className:"ml-auto font-medium tabular-nums",children:[i,"%"]})]}),(0,ey.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${i}%`}})})]}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"})]})}function GB({icon:e,label:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pt-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 [&_svg]:size-3.5",children:[e,(0,ey.jsx)("span",{children:t})]})}function GV(){let[e,t]=ew.useState("loading"),[n,r]=ew.useState(!1),a=ew.useCallback(async e=>{try{let n=(await GP(void 0,{signal:e,timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);n&&n.installed?n.running?t("running"):t(e=>"starting"===e?"starting":"stopped"):t("missing")}catch{t("missing")}},[]);ew.useEffect(()=>{let e=!0,t=new AbortController,n=()=>{e&&a(t.signal)};n();let r=window.setInterval(n,1e4);return()=>{e=!1,t.abort(),window.clearInterval(r)}},[a]);let i=ew.useCallback(async()=>{if(!n){r(!0),t("starting");try{await GD(void 0,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await GP(void 0,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)return void t("running")}catch{}}}catch{}finally{r(!1),await a()}}},[n,a]);return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(Ui,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"浏览器"}),"running"===e?(0,ey.jsx)(GH,{online:!0}):"starting"===e?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):(0,ey.jsx)(GH,{online:!1}),(0,ey.jsx)("span",{className:"truncate font-medium",children:"running"===e?"运行中":"starting"===e?"启动中":"stopped"===e?"已停止":"missing"===e?"未安装":"—"}),(0,ey.jsx)("span",{className:"ml-auto shrink-0",children:"stopped"===e?(0,ey.jsxs)("button",{type:"button",onClick:()=>void i(),className:"inline-flex items-center gap-1 rounded-md border border-border/70 px-1.5 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted",children:[(0,ey.jsx)(Vw,{className:"size-3"}),"启动"]}):"running"===e?(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground/70",title:"在画布的「浏览器」节点中实时查看 Agent 的浏览器操作",children:"画布查看"}):null})]})}function GH({online:e}){return(0,ey.jsx)("span",{"aria-hidden":!0,className:(0,eI.cn)("inline-block size-2 shrink-0 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/40")})}function GU({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState([]),[o,l]=ew.useState([]),{machines:s}=vj();ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{try{let[a,o,s]=await Promise.all([sA(e,t),sz(e,t).catch(()=>[]),sT(e,t).catch(()=>[])]);if(!n)return;r(a),i(o),l(s)}catch{}};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let c=ew.useMemo(()=>new Map(s.map(e=>[e.id,e])),[s]),d=e=>"local"===e||c.get(e)?.status==="online",u=e=>"local"===e?c.get("local")?.name??"本地":c.get(e)?.name??e,f=t??n?.conversation.ownerMachineId??"local",h=(n?.conversation.settings?.hosts??[]).filter(Boolean),m=n?.conversation.runUsage,p=n?.conversation.status==="working",g=(m?.cachedInputTokens??0)+(m?.cacheCreationInputTokens??0),{additions:v,deletions:x}=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=0,r=0;for(let a=Math.max(0,t);a<e.length;a+=1){let t=e[a],i=t?.additions??t?.meta?.additions,o=t?.deletions??t?.meta?.deletions;"number"==typeof i&&(n+=i),"number"==typeof o&&(r+=o)}return{additions:n,deletions:r}}(n?.events??[]),y=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=new Set;for(let r=Math.max(0,t);r<e.length;r+=1){let t=e[r];if(t?.kind==="subagent"&&Array.isArray(t.subagents))for(let e of t.subagents)e?.id&&n.add(e.id)}return n}(n?.events??[]),b=function e(t,n=0,r=[]){for(let a of t)r.push({node:a,depth:n}),a.children&&a.children.length>0&&e(a.children,n+1,r);return r}(a.filter(e=>y.has(e.id))),w=n?.conversation.planState;return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-auto rounded-[inherit] bg-background text-sm",children:[(0,ey.jsx)(GB,{icon:(0,ey.jsx)(uy,{}),label:"环境信息"}),(0,ey.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 pb-2 text-[13px]",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2 text-foreground/90",children:[(0,ey.jsx)(eP,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"运行于"}),(0,ey.jsx)(GH,{online:d(f)}),(0,ey.jsx)("span",{className:"truncate font-medium",children:u(f)})]}),(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(GE,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:"可访问"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-wrap gap-x-3 gap-y-1",children:0===h.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"—"}):h.map(e=>(0,ey.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(GH,{online:d(e)}),(0,ey.jsx)("span",{className:"truncate",children:u(e)})]},e))})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(GN,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"本轮变更"}),(0,ey.jsxs)("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:["+",v]}),(0,ey.jsxs)("span",{className:"font-medium text-rose-600 dark:text-rose-400",children:["-",x]}),(0,ey.jsx)("span",{className:"text-muted-foreground/60",children:"行"})]}),(0,ey.jsx)(GV,{})]}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),w?(0,ey.jsx)(GF,{state:w}):null,(0,ey.jsx)(GB,{icon:(0,ey.jsx)(ub,{}),label:"子智能体"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===b.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮未释放子智能体"}):b.map(({node:e,depth:t})=>{let n="failed"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",style:{paddingLeft:12*t},children:[e.running?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(fg.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||e.title||e.subagentType||"子智能体"}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(GB,{icon:(0,ey.jsx)(uO,{}),label:"后台任务"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===o.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮无后台任务"}):o.map(e=>{let t="failed"===e.status||"timeout"===e.status,n="unknown"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[e.running?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(hM,{className:"size-3.5 shrink-0 text-amber-500"}):t?(0,ey.jsx)(fg.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate font-mono text-[12px]",title:e.command,children:e.command||"(命令)"}),e.orphaned?(0,ey.jsx)("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"该后台进程脱离了本轮但仍在运行",children:"脱离"}):null,(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"状态未知":t?"timeout"===e.status?"超时":"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(GB,{icon:(0,ey.jsx)(GS,{}),label:p?"本轮消耗":"消耗额度"}),(0,ey.jsx)("div",{className:"grid grid-cols-3 gap-2 px-3 pb-3",children:[{label:"输入",value:m?.inputTokens},{label:"输出",value:m?.outputTokens},{label:"缓存",value:g}].map(e=>{let t;return(0,ey.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-2 py-1.5",children:[(0,ey.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e.label}),(0,ey.jsx)("div",{className:"font-mono text-sm font-medium tabular-nums",children:m?(t=e.value??0)>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t):"—"})]},e.label)})})]})}let GW="application/vnd.vantaloom.canvas-node",Gq="application/vnd.vantaloom.canvas-tab",GK="application/vnd.vantaloom.dashboard-widget",GG="application/vnd.vantaloom.workspace-card";var GX=e.i(78737);let GY=(0,ek.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),GZ=(0,ek.default)("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),GJ=(0,ek.default)("tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]),GQ=[{id:"phone",label:"Phone",width:390,userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"tablet",label:"Tablet",width:820,userAgent:"Mozilla/5.0 (iPad; CPU OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"desktop",label:"Desktop",width:1200,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"}],G0=[{id:"adaptive",label:"自适应",adaptive:!0},{id:"16:9",label:"16:9",value:16/9},{id:"4:3",label:"4:3",value:4/3},{id:"3:2",label:"3:2",value:1.5},{id:"1:1",label:"1:1",value:1},{id:"9:16",label:"9:16",value:9/16}],G1={urlLabel:"URL",urlPlaceholder:"https://example.com",navigate:"Navigate",actions:"Browser view options",devices:"User agent",ratios:"Viewport ratio",back:"Back",forward:"Forward",reload:"Reload preview",previewTitle:"Browser preview"};function G2(e,t,n){return e.find(e=>e.id===t)??n}function G5({id:e}){return"phone"===e?(0,ey.jsx)(GZ,{className:"size-4"}):"tablet"===e?(0,ey.jsx)(GJ,{className:"size-4"}):(0,ey.jsx)(eP,{className:"size-4"})}function G4({url:e,defaultUrl:t="https://vantaloom.local/workspace",onUrlChange:n,onNavigate:r,onBack:a,onForward:i,device:o,defaultDevice:l="desktop",onDeviceChange:s,ratio:c,defaultRatio:d="adaptive",onRatioChange:u,devices:f=GQ,ratios:h=G0,srcDoc:m,renderPreview:p,showHeader:g=!0,labels:v,className:x,headerClassName:y,previewClassName:b,...w}){let j=ew.useMemo(()=>({...G1,...v}),[v]),[k,S]=ew.useState(t),[N,C]=ew.useState(e??t),[M,E]=ew.useState(()=>[e??t]),[O,P]=ew.useState(0),[A,I]=ew.useState(l),[z,T]=ew.useState(d),[D,R]=ew.useState(!1),[_,L]=ew.useState(0),$=ew.useRef(null),F=ew.useId(),[B,V]=function(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useEffect(()=>{let t=e.current;if(!t)return;function r(e){t&&n(e??{width:t.clientWidth,height:t.clientHeight})}r();let a=new ResizeObserver(e=>{let t=e[0];t?r({width:t.contentRect.width,height:t.contentRect.height}):r()});return a.observe(t),()=>a.disconnect()},[]),[e,t]}(),H=e??k,U=G2(f,o??A,f[0]??GQ[0]),W=G2(h,c??z,h[0]??G0[0]),q=V.width>0&&V.height>0,K=W.adaptive||"adaptive"===W.id,G=W.value??16/9,X=K&&V.width||U.width,Y=K?V.height||U.width/G:X/G,Z=(q?V.width/V.height:1)<=G,J=Math.max(1,Math.round(q?K||Z?V.width:V.height*G:X)),Q=Math.max(1,Math.round(q?K?V.height:Z?V.width/G:V.height:Y)),ee=J/X,et=ew.useMemo(()=>({url:H,device:U,ratio:W,viewport:{width:J,height:Q,scale:ee}}),[U,W,H,ee,Q,J]);function en(t,a={history:"push"}){void 0===e&&S(t),"none"!==a.history&&E(e=>{let n=e.slice(0,O+1);return n[n.length-1]===t?n:(P(n.length),[...n,t])}),n?.(t),r?.(t)}return ew.useEffect(()=>{C(e??k)},[k,e]),ew.useEffect(()=>{if(D)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&$.current?.contains(t)||R(!1)}},[D]),(0,ey.jsxs)("div",{ref:$,"data-slot":"browser-tab-viewer","data-device":U.id,"data-ratio":W.id,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",g?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",x),...w,children:[g&&(0,ey.jsxs)("div",{"data-slot":"browser-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",y),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,ey.jsx)(GY,{className:"size-3.5"})}),(0,ey.jsxs)("form",{onSubmit:function(e){let t;e.preventDefault();let n=(t=N.trim())?/^[a-z][a-z\d+\-.]*:\/\//i.test(t)?t:/^(localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:\/|$)/i.test(t)?`http://${t}`:`https://${t}`:"";C(n),en(n)},className:"min-w-0 flex-1",children:[(0,ey.jsx)("label",{className:"sr-only",htmlFor:F,children:j.urlLabel}),(0,ey.jsx)(ez,{id:F,value:N,onChange:e=>C(e.target.value),placeholder:j.urlPlaceholder,className:"h-5 rounded-md border bg-background px-2 shadow-none ui-text-kbd",spellCheck:!1})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.back,disabled:O<=0,onClick:function(){if(O<=0)return;let e=O-1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),a?.(t))},className:"size-5 rounded-md",children:(0,ey.jsx)(GX.ArrowLeftIcon,{className:"size-3.5"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.forward,disabled:O>=M.length-1,onClick:function(){if(O>=M.length-1)return;let e=O+1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),i?.(t))},className:"size-5 rounded-md",children:(0,ey.jsx)(ej.ArrowRightIcon,{className:"size-3.5"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.reload,onClick:()=>L(e=>e+1),className:"size-5 rounded-md",children:(0,ey.jsx)(ya,{className:"size-3.5"})})]}),(0,ey.jsx)("div",{ref:B,"data-slot":"browser-tab-viewer-stage",className:(0,eI.cn)("grid min-h-0 place-items-center overflow-hidden bg-muted/20",b),children:(0,ey.jsx)("div",{"data-slot":"browser-tab-viewer-viewport",className:"overflow-hidden rounded-lg border bg-background shadow-sm",style:{width:J,height:Q},children:p?p(et):(0,ey.jsx)("iframe",{title:j.previewTitle,src:m?void 0:H,srcDoc:m,sandbox:"allow-forms allow-modals allow-popups allow-same-origin allow-scripts",className:"size-full border-0 bg-background"},`${_}-${H}-${U.id}-${W.id}`)})}),(0,ey.jsxs)("div",{"data-slot":"browser-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:[(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-popover absolute right-0 bottom-10 grid w-56 gap-3 rounded-[var(--surface-popover-radius)] border p-3 transition-[opacity,transform] duration-150",D?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.devices}),(0,ey.jsx)("div",{className:"flex gap-1.5",children:f.map(e=>(0,ey.jsx)(eA.Button,{type:"button",variant:U.id===e.id?"default":"outline",size:"icon-sm","aria-label":e.label,title:e.label,className:"rounded-full",onClick:()=>{let t;return t=G2(f,e.id,U),void(void 0===o&&I(t.id),s?.(t.id,t))},children:(0,ey.jsx)(G5,{id:e.id})},e.id))})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.ratios}),(0,ey.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,ey.jsx)(eA.Button,{type:"button",variant:W.id===e.id?"default":"outline",size:"xs",className:"h-7 rounded-full px-2.5 ui-text-kbd",onClick:()=>{let t;return t=G2(h,e.id,W),void(void 0===c&&T(t.id),u?.(t.id,t))},children:e.label},e.id))})]})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":j.actions,"aria-expanded":D,onClick:()=>R(e=>!e),className:"rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",D&&"rotate-90")})})]})]})}let G3=(0,ek.default)("monitor-off",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),G6=(0,ek.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);function G8({frame:e,connection:t,takeover:n,onTakeoverChange:r,onInput:a,onReconnect:i,machines:o,selectedMachineId:l,onSelectMachine:s,onStartBrowser:c,starting:d,className:u}){let f=ew.useRef(null),h=ew.useRef(null),m=ew.useRef(0),p=ew.useRef(!1),[g,v]=ew.useState(!1);function x(t){let n=f.current;if(!n)return null;let r=n.getBoundingClientRect();if(0===r.width||0===r.height)return null;let a=(e?.width||n.width)/r.width,i=(e?.height||n.height)/r.height;return{x:Math.round((t.clientX-r.left)*a),y:Math.round((t.clientY-r.top)*i)}}function y(e,t){n&&a&&(e.preventDefault(),a({kind:"key",type:t,key:e.key}),"keyDown"===t&&1===e.key.length&&a({kind:"key",type:"char",key:e.key,text:e.key}))}ew.useEffect(()=>{let t=f.current;if(!t||!e?.b64)return;let n=new Image;return h.current=n,n.onload=()=>{if(h.current!==n)return;let r=e.width||n.naturalWidth,a=e.height||n.naturalHeight;t.width!==r&&(t.width=r),t.height!==a&&(t.height=a);let i=t.getContext("2d");i&&i.drawImage(n,0,0,t.width,t.height)},n.src=`data:image/jpeg;base64,${e.b64}`,()=>{n.onload=null,h.current===n&&(h.current=null)}},[e]);let b="streaming"===t||!!e;return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-panel relative flex size-full min-h-0 flex-col overflow-hidden",u),"data-slot":"live-browser-view",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd shrink-0",children:"浏览器"}),(0,ey.jsx)("div",{className:"min-w-0 flex-1",children:o.length>0?(0,ey.jsx)("select",{value:l??"",onChange:e=>s?.(e.target.value),className:"h-6 w-full max-w-[16rem] truncate rounded-md border bg-background px-2 ui-text-kbd",children:o.map(e=>(0,ey.jsxs)("option",{value:e.id,disabled:!e.running,children:[e.label,e.running?"":"(未运行)"]},e.id))}):(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"无可用浏览器"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"xs",variant:n?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":n,onClick:()=>r(!n),disabled:"streaming"!==t,title:n?"切换到观看模式":"接管:在画面里直接操作",children:[n?(0,ey.jsx)(lq,{className:"size-3.5"}):(0,ey.jsx)(lZ,{className:"size-3.5"}),n?"接管中":"观看"]}),"error"===t&&i?(0,ey.jsx)(eA.Button,{type:"button",size:"icon-xs",variant:"ghost",className:"size-6 rounded-md","aria-label":"重新连接",onClick:i,children:(0,ey.jsx)(G6,{className:"size-3.5"})}):null]}),(0,ey.jsxs)("div",{className:"relative grid min-h-0 flex-1 place-items-center overflow-hidden bg-black/85",children:[b?(0,ey.jsx)("canvas",{ref:f,tabIndex:n?0:-1,onPointerDown:function(e){if(!n||!a)return;let t=x(e);t&&(p.current=!0,e.currentTarget.setPointerCapture(e.pointerId),f.current?.focus(),a({kind:"mouse",type:"mousePressed",button:"left",...t}))},onPointerUp:function(e){if(!n||!a)return;let t=x(e);p.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}t&&a({kind:"mouse",type:"mouseReleased",button:"left",...t})},onPointerMove:function(e){if(!n||!a)return;let t=performance.now();if(t-m.current<33)return;m.current=t;let r=x(e);r&&a({kind:"mouse",type:"mouseMoved",button:p.current?"left":"none",...r})},onKeyDown:e=>y(e,"keyDown"),onKeyUp:e=>y(e,"keyUp"),onFocus:()=>v(!0),onBlur:()=>v(!1),className:(0,eI.cn)("max-h-full max-w-full object-contain outline-none",n?"cursor-crosshair":"cursor-default")}):(0,ey.jsx)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:"connecting"===t?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"size-5 animate-spin"}),(0,ey.jsx)("span",{children:"正在连接浏览器…"})]}):"error"===t?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G3,{className:"size-5"}),(0,ey.jsx)("span",{children:"连接浏览器失败"}),i?(0,ey.jsx)(eA.Button,{type:"button",size:"xs",variant:"outline",onClick:i,children:"重试"}):null]}):d?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"size-5 animate-spin"}),(0,ey.jsx)("span",{children:"正在启动浏览器…"})]}):0===o.length?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G3,{className:"size-5"}),(0,ey.jsx)("span",{children:"未安装浏览器"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground/70",children:"请在「官方扩展」页面安装 Vantaloom 浏览器"})]}):c?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G3,{className:"size-5"}),(0,ey.jsx)("span",{children:"浏览器已停止"}),(0,ey.jsxs)(eA.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:c,children:[(0,ey.jsx)(Vw,{className:"size-3.5"}),"启动浏览器"]})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G3,{className:"size-5"}),(0,ey.jsx)("span",{children:"浏览器未运行"})]})}),n&&b?(0,ey.jsxs)("div",{className:"pointer-events-none absolute inset-0",children:[(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-0 rounded-sm ring-2 ring-inset transition-colors",g?"ring-hot-pink":"ring-hot-pink/50")}),(0,ey.jsxs)("span",{className:"absolute left-2 top-2 rounded bg-hot-pink/90 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["接管中",g?"":"(点击画面以捕获键盘)"]})]}):null]})]})}function G7(e,t){return e?eD(`/v1/remote/${e}/browser${t}`):eD(`/v1/browser${t}`)}async function G9(e,t){try{await fetch(G7(e,"/input"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function Xe({active:e=!0,className:t}){let[n,r]=ew.useState(0),a=function(e,t){let{machines:n}=vj(),[r,a]=ew.useState([]);return ew.useEffect(()=>{if(!e)return;let t=!1;async function r(e,t,n){try{let r=(await GP(t,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(!r||!r.installed)return null;return{id:e,machineId:t,label:n,installed:r.installed,running:r.running}}catch{return null}}async function i(){let e=[{id:"",machineId:void 0,label:"本机"}];for(let t of n)t.isLocal||"online"===t.status&&e.push({id:t.id,machineId:t.id,label:t.name||t.id});let i=await Promise.all(e.map(e=>r(e.id,e.machineId,e.label)));t||a(i.filter(e=>null!==e))}i();let o=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(o)}},[e,n,t]),r}(e,n),[i,o]=ew.useState(""),[l,s]=ew.useState(!1),[c,d]=ew.useState(!1);ew.useEffect(()=>{0===a.length||a.some(e=>e.id===i)||o((a.find(e=>e.running)??a[0]).id)},[a,i]);let u=a.find(e=>e.id===i),f=!!u?.running;ew.useEffect(()=>{!f&&l&&s(!1)},[f,l]);let{frame:h,connection:m,reconnect:p}=function(e){let{machineId:t,enabled:n}=e,[r,a]=ew.useState(null),[i,o]=ew.useState("idle"),[l,s]=ew.useState(0),c=ew.useCallback(()=>{s(e=>e+1)},[]);return ew.useEffect(()=>{let e;if(!n){o("idle"),a(null);return}let r=!1,i=new AbortController;async function l(){o("connecting");try{let e=await fetch(G7(t,"/screencast"),{cache:"no-store",headers:{Accept:"text/event-stream"},signal:i.signal});if(r)return;if(404===e.status||409===e.status){o("no-browser"),s();return}if(!e.ok||!e.body){o("error"),s();return}let n=e.body.getReader(),l=new TextDecoder,c="";for(o("streaming");;){let{value:e,done:t}=await n.read();if(r||t)break;let i=(c+=l.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==i;){let e=c.slice(0,i);c=c.slice(i+2),function(e){let t=e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trimStart());if(0===t.length)return;let n=t.join("\n");if(n&&"[DONE]"!==n)try{let e=JSON.parse(n);"frame"===e.type&&e.b64&&a({b64:e.b64,width:e.meta?.width??0,height:e.meta?.height??0})}catch{}}(e),i=c.indexOf("\n\n")}}r||(o("connecting"),s())}catch{if(r||i.signal.aborted)return;o("error"),s()}}function s(){r||(e=setTimeout(()=>{r||l()},1500))}return l(),()=>{r=!0,i.abort(),e&&clearTimeout(e)}},[t,n,l]),{frame:r,connection:i,reconnect:c}}({machineId:u?.machineId,enabled:e&&f}),g=a.map(e=>({id:e.id,machineId:e.machineId,label:e.label,running:e.running})),v=ew.useCallback(e=>{G9(u?.machineId,e)},[u?.machineId]),x=ew.useCallback(async()=>{if(!c){d(!0);try{await GD(u?.machineId,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await GP(u?.machineId,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)break}catch{}}}catch{}finally{d(!1),r(e=>e+1)}}},[u,c]);return(0,ey.jsx)(G8,{className:t,frame:h,connection:f?m:"no-browser",takeover:l,onTakeoverChange:s,onInput:v,onReconnect:p,machines:g,selectedMachineId:i,onSelectMachine:o,onStartBrowser:u&&!f?()=>void x():void 0,starting:c})}function Xt({defaultUrl:e,className:t}){let{machines:n}=vj(),[r,a]=ew.useState(!1);return(ew.useEffect(()=>{let e=!1;async function t(){let t=[void 0];for(let e of n)e.isLocal||"online"===e.status&&t.push(e.id);let r=await Promise.all(t.map(async e=>{try{let t=await GP(e,{timeoutMs:6e3});return!!t.extensions.find(e=>"browser"===e.id)?.running}catch{return!1}}));e||a(r.some(Boolean))}t();let r=window.setInterval(t,12e3);return()=>{e=!0,window.clearInterval(r)}},[n]),r)?(0,ey.jsx)(Xe,{active:!0,className:t}):(0,ey.jsx)(G4,{className:t,defaultUrl:e})}let Xn=[{policyNumber:3,name:"Allow HTTP Traffic",sourceZone:"Trust",sourceIPs:["192.168.1.0/24","10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["192.168.2.0/24"],tags:["Web Access","Internal"],action:"allow",description:"Permits HTTP traffic from internal network"},{policyNumber:5,name:"Block Suspicious IPs",sourceZone:"Untrust",sourceIPs:["203.0.113.0/24","198.51.100.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Security"],action:"deny",description:"Blocks known malicious IP ranges"},{policyNumber:9,name:"SSH Access Control",sourceZone:"Trust",sourceIPs:["172.16.0.0/12"],destinationZone:"Trust",destinationIPs:["10.50.0.0/16"],tags:["Admin Access","VPN"],action:"allow",description:"Restricted SSH access for admin network"},{policyNumber:12,name:"Database Port Protection",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["10.100.0.0/24"],tags:["Blocking","Database"],action:"deny",description:"Blocks external access to database ports"},{policyNumber:15,name:"API Gateway Access",sourceZone:"Trust",sourceIPs:["192.168.100.0/24","192.168.101.0/24"],destinationZone:"Trust",destinationIPs:["10.200.0.5"],tags:["API","VDI Env"],action:"allow",description:"Allows traffic to API gateway from specific subnets"},{policyNumber:18,name:"Drop Legacy SMB",sourceZone:"Trust",sourceIPs:["Any"],destinationZone:"Trust",destinationIPs:["10.20.0.0/16"],tags:["Legacy","Internal"],action:"drop",description:"Drops SMBv1 probes across workstation networks"},{policyNumber:22,name:"Agent Runtime Mesh",sourceZone:"Trust",sourceIPs:["10.10.4.0/24"],destinationZone:"Trust",destinationIPs:["10.10.8.0/24","10.10.12.0/24"],tags:["Agent","Runtime"],action:"allow",description:"Allows managed agent runtime channels between worker pools"},{policyNumber:27,name:"Block Public Admin Ports",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Admin Access"],action:"deny",description:"Denies public access to SSH, RDP, and database admin ports"},{policyNumber:31,name:"Build Cache Access",sourceZone:"Trust",sourceIPs:["10.30.0.0/16"],destinationZone:"Trust",destinationIPs:["10.60.12.20"],tags:["Build","Internal"],action:"allow",description:"Allows build workers to reach shared cache storage"},{policyNumber:36,name:"Relay Egress",sourceZone:"Trust",sourceIPs:["10.40.0.0/16"],destinationZone:"Untrust",destinationIPs:["198.18.0.0/15"],tags:["Relay","Agent"],action:"allow",description:"Permits relay service egress to managed edge addresses"},{policyNumber:41,name:"Quarantine Subnet",sourceZone:"Quarantine",sourceIPs:["10.250.0.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Security","Blocking"],action:"deny",description:"Blocks quarantined hosts from internal services"},{policyNumber:48,name:"Observability Intake",sourceZone:"Trust",sourceIPs:["10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["10.80.4.10"],tags:["Telemetry","Internal"],action:"allow",description:"Allows metrics and logs to the observability intake"}],Xr=Array.from(new Set(Xn.flatMap(e=>e.tags))).sort(),Xa=[["10.10.4.0/24","Agent workers","Trust","18"],["10.20.0.0/16","Workstations","Trust","41"],["10.250.0.0/24","Quarantine","Quarantine","03"],["198.18.0.0/15","Relay edge","Untrust","12"]],Xi=[["Database Port Protection","2026-06-12","Security"],["Relay Egress","2026-06-28","Network"],["Build Cache Access","2026-07-04","Build"],["Observability Intake","2026-07-18","Ops"]];function Xo({className:e,...t}){return(0,ey.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,eI.cn)("mx-auto flex w-full justify-center",e),...t})}function Xl({className:e,...t}){return(0,ey.jsx)("ul",{"data-slot":"pagination-content",className:(0,eI.cn)("flex flex-row items-center gap-1",e),...t})}function Xs({...e}){return(0,ey.jsx)("li",{"data-slot":"pagination-item",...e})}function Xc({className:e,isActive:t,size:n="icon",...r}){return(0,ey.jsx)("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:(0,eI.cn)((0,eA.buttonVariants)({variant:t?"outline":"ghost",size:n}),e),...r})}function Xd({className:e,previousLabel:t="Previous",...n}){return(0,ey.jsxs)(Xc,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pl-2",e),...n,children:[(0,ey.jsx)(mJ,{}),(0,ey.jsx)("span",{className:"hidden sm:block",children:t})]})}function Xu({className:e,nextLabel:t="Next",...n}){return(0,ey.jsxs)(Xc,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pr-2",e),...n,children:[(0,ey.jsx)("span",{className:"hidden sm:block",children:t}),(0,ey.jsx)(mQ,{})]})}function Xf({className:e,moreLabel:t="More pages",...n}){return(0,ey.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,eI.cn)("flex size-8 items-center justify-center",e),...n,children:[(0,ey.jsx)(lY,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:t})]})}function Xh({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Xm(){let[e,t]=ew.useState(""),[n,r]=ew.useState("all"),[a,i]=ew.useState({allow:!1,drop:!1,deny:!1}),[o,l]=ew.useState(1),s=ew.useMemo(()=>["allow","drop","deny"].filter(e=>a[e]),[a]),c=ew.useMemo(()=>[{id:"policyNumber",header:"策略 #",accessorKey:"policyNumber",align:"right",width:84},{id:"name",header:"名称",accessorKey:"name",width:180,className:"font-medium"},{id:"sourceZone",header:"源区域",accessorKey:"sourceZone",width:112,cell:({row:e})=>(0,ey.jsx)(Xv,{zone:e.sourceZone})},{id:"sourceIPs",header:"源 IP",accessorKey:"sourceIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Xg,{items:e.sourceIPs,variant:"outline"}),copyValue:({row:e})=>e.sourceIPs.join(", ")},{id:"destinationZone",header:"目标区域",accessorKey:"destinationZone",width:112,cell:({row:e})=>(0,ey.jsx)(Xv,{zone:e.destinationZone})},{id:"destinationIPs",header:"目标 IP",accessorKey:"destinationIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Xg,{items:e.destinationIPs,variant:"outline"}),copyValue:({row:e})=>e.destinationIPs.join(", ")},{id:"tags",header:"标签",accessorKey:"tags",width:220,cell:({row:e})=>(0,ey.jsx)(Xg,{items:e.tags,variant:"secondary"}),copyValue:({row:e})=>e.tags.join(", ")},{id:"action",header:"动作",accessorKey:"action",width:96,cell:({row:e})=>(0,ey.jsx)(Xx,{action:e.action})}],[]),d=ew.useMemo(()=>{let t=e.trim().toLowerCase();return Xn.filter(e=>{let r=0===t.length||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.sourceIPs.some(e=>e.toLowerCase().includes(t))||e.destinationIPs.some(e=>e.toLowerCase().includes(t)),i="all"===n||e.tags.includes(n),o=!(a.allow||a.drop||a.deny)||a.allow&&"allow"===e.action||a.drop&&"drop"===e.action||a.deny&&"deny"===e.action;return r&&i&&o})},[a,e,n]),u=Math.max(1,Math.ceil(d.length/8)),f=Math.min(o,u),h=d.slice((f-1)*8,8*f);return ew.useEffect(()=>{l(1)},[a,e,n]),(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsxs)("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-3",children:[(0,ey.jsx)(Xh,{title:"防火墙策略"}),(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"新增策略"]})]}),(0,ey.jsxs)("div",{className:"mb-3 grid shrink-0 grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(12rem,1fr)_10rem_auto]",children:[(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"搜索"}),(0,ey.jsxs)("span",{className:"relative",children:[(0,ey.jsx)(vk,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,ey.jsx)(ez,{value:e,onChange:e=>t(e.target.value),placeholder:"搜索策略...",className:"pl-8"})]})]}),(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"标签"}),(0,ey.jsxs)(gT,{value:n,onValueChange:r,children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:"全部标签"})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"all",children:"全部标签"}),Xr.map(e=>(0,ey.jsx)(vv,{value:e,children:e},e))]})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"动作"}),(0,ey.jsxs)(mB,{type:"multiple",variant:"outline",value:s,onValueChange:function(e){e.includes("clear")?(t(""),r("all"),i({allow:!1,drop:!1,deny:!1}),l(1)):i({allow:e.includes("allow"),drop:e.includes("drop"),deny:e.includes("deny")})},children:[(0,ey.jsx)(mV,{value:"allow",children:"允许"}),(0,ey.jsx)(mV,{value:"drop",children:"丢弃"}),(0,ey.jsx)(mV,{value:"deny",children:"拒绝"}),(0,ey.jsx)(mV,{value:"clear",children:"全部"})]})]})]}),(0,ey.jsx)(Wo,{rows:h,columns:c,rowId:"policyNumber",showHeader:!1,showToolbar:!1,rowHeight:40,className:"min-h-0 flex-1 rounded-lg shadow-none",labels:{noRows:"没有匹配的策略。",selectAllRows:"选择当前页策略",selectRow:e=>`选择第 ${e+1} 条策略`,resizeColumn:"调整列宽",sortAsc:"升序",sortDesc:"降序",sortClear:"取消排序",copyCell:"复制单元格",copied:"已复制"}}),(0,ey.jsx)(Xp,{page:f,totalPages:u,onPageChange:function(e){l(Math.min(u,Math.max(1,e)))}})]})}function Xp({page:e,totalPages:t,onPageChange:n}){let r=ew.useMemo(()=>t<=3?Array.from({length:t},(e,t)=>t+1):e<=2?[1,2,3]:e>=t-1?[t-2,t-1,t]:[e-1,e,e+1],[e,t]),a=r[0]??1,i=r[r.length-1]??t;function o(e,t){e.preventDefault(),n(t)}return(0,ey.jsx)(Xo,{className:"mt-3 shrink-0",children:(0,ey.jsxs)(Xl,{className:"gap-1 sm:gap-2",children:[(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xd,{href:"#",previousLabel:"上一页","aria-disabled":1===e,className:(0,eI.cn)(1===e&&"pointer-events-none opacity-40"),onClick:t=>o(t,e-1)})}),a>1?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xc,{href:"#",size:"icon",onClick:e=>o(e,1),children:"1"})}),a>2?(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xf,{moreLabel:"更多页"})}):null]}):null,r.map(t=>(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xc,{href:"#",size:"icon",isActive:e===t,onClick:e=>o(e,t),children:t})},t)),i<t?(0,ey.jsxs)(ey.Fragment,{children:[i<t-1?(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xf,{moreLabel:"更多页"})}):null,(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xc,{href:"#",size:"icon",onClick:e=>o(e,t),children:t})})]}):null,(0,ey.jsx)(Xs,{children:(0,ey.jsx)(Xu,{href:"#",nextLabel:"下一页","aria-disabled":e===t,className:(0,eI.cn)(e===t&&"pointer-events-none opacity-40"),onClick:t=>o(t,e+1)})})]})})}function Xg({items:e,variant:t}){return(0,ey.jsx)("div",{className:"flex min-w-48 flex-wrap gap-1",children:e.map(e=>(0,ey.jsx)(Bs,{variant:t,children:e},e))})}function Xv({zone:e}){return(0,ey.jsx)(Bs,{variant:"Trust"===e?"secondary":"outline",children:e})}function Xx({action:e}){return(0,ey.jsx)(Bs,{variant:"allow"===e?"default":"destructive",children:{allow:"允许",drop:"丢弃",deny:"拒绝"}[e]})}function Xy({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,ey.jsx)("table",{"data-slot":"table",className:(0,eI.cn)("w-full caption-bottom text-sm",e),...t})})}function Xb({className:e,...t}){return(0,ey.jsx)("thead",{"data-slot":"table-header",className:(0,eI.cn)("[&_tr]:border-b",e),...t})}function Xw({className:e,...t}){return(0,ey.jsx)("tbody",{"data-slot":"table-body",className:(0,eI.cn)("[&_tr:last-child]:border-0",e),...t})}function Xj({className:e,...t}){return(0,ey.jsx)("tr",{"data-slot":"table-row",className:(0,eI.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function Xk({className:e,...t}){return(0,ey.jsx)("th",{"data-slot":"table-head",className:(0,eI.cn)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function XS({className:e,...t}){return(0,ey.jsx)("td",{"data-slot":"table-cell",className:(0,eI.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function XN({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function XC({title:e,headers:t,rows:n}){return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsx)(XN,{title:e}),(0,ey.jsx)("div",{className:"mt-3 min-h-0 flex-1 overflow-auto",children:(0,ey.jsxs)(Xy,{children:[(0,ey.jsx)(Xb,{children:(0,ey.jsx)(Xj,{children:t.map(e=>(0,ey.jsx)(Xk,{children:e},e))})}),(0,ey.jsx)(Xw,{children:n.map(e=>(0,ey.jsx)(Xj,{children:e.map((e,t)=>(0,ey.jsx)(XS,{className:0===t?"font-medium":"text-muted-foreground",children:e},`${e}-${t}`))},e.join("-")))})]})})]})}function XM(){return(0,ey.jsxs)("div",{className:"grid h-full min-h-0 content-start gap-3 p-3",children:[(0,ey.jsx)(XN,{title:"策略申请"}),(0,ey.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,ey.jsx)(ez,{placeholder:"策略名称"}),(0,ey.jsx)(ez,{placeholder:"负责人"}),(0,ey.jsx)(ez,{placeholder:"源 CIDR"}),(0,ey.jsx)(ez,{placeholder:"目标 CIDR"})]}),(0,ey.jsx)("textarea",{placeholder:"用途",className:"min-h-32 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"提交申请"]})})]})}function XE(){return(0,ey.jsxs)(md,{defaultValue:"policies",className:"vtl-firewall-workspace flex h-full min-h-0 flex-col",children:[(0,ey.jsx)("div",{className:"shrink-0 overflow-x-auto px-3 pt-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsxs)(my,{className:"h-8 w-max min-w-full",children:[(0,ey.jsx)(mb,{value:"policies",children:"防火墙策略"}),(0,ey.jsx)(mb,{value:"ip-addresses",children:"IP 地址"}),(0,ey.jsx)(mb,{value:"renewals",children:"续期"}),(0,ey.jsx)(mb,{value:"policy-request",children:"策略申请"}),(0,ey.jsx)(mb,{value:"user-settings",children:"用户设置"})]})}),(0,ey.jsx)(mw,{value:"policies",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(Xm,{})}),(0,ey.jsx)(mw,{value:"ip-addresses",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XC,{title:"IP 地址",headers:["地址","名称","区域","策略"],rows:Xa})}),(0,ey.jsx)(mw,{value:"renewals",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XC,{title:"续期",headers:["策略","续期时间","负责人"],rows:Xi})}),(0,ey.jsx)(mw,{value:"policy-request",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XM,{})}),(0,ey.jsx)(mw,{value:"user-settings",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XC,{title:"用户设置",headers:["设置","值"],rows:[["默认区域","Trust"],["审核提醒","14 天"],["申请审批","安全负责人"],["策略导出","已开启"]]})})]})}function XO(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function XP(e,t){let n=t.machineId||"local";return XO((await uK(n,e.path)).items)}function XA({className:e,onOpenFile:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(!1),[o,l]=ew.useState(0),s=ew.useCallback(async()=>{i(!0);try{let e=await uq();r(e.roots.map(e=>({id:e.id,machineId:e.machineId,name:e.name,path:e.path,platform:e.platform,children:XO(e.children)}))),l(e=>e+1)}catch{r([]),l(e=>e+1)}finally{i(!1)}},[]);return ew.useEffect(()=>{s()},[s]),ew.useEffect(()=>{function e(){s()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[s]),(0,ey.jsx)(HL,{className:e,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:n,defaultExpandedIds:n.map(e=>e.id),loadingIds:a?n.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:XP,onOpenNode:(e,n)=>{"folder"!==e.kind&&t?.({machineId:n.machineId||"local",path:e.path})},onRefresh:()=>{s()}},o)}function XI({open:e,onOpenChange:t,onSelectFile:n}){return(0,ey.jsx)(dC,{open:e,onOpenChange:t,children:(0,ey.jsxs)(fx,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fb,{className:"sr-only",children:"选择文件"}),(0,ey.jsx)(fw,{className:"sr-only",children:"选择本机可访问文件。"}),(0,ey.jsx)(XA,{className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{n(e),t(!1)}})]})})}function Xz(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useLayoutEffect(()=>{let t=e.current;if(!t)return;function r(){let e=t.getBoundingClientRect();n({width:e.width,height:e.height})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}let XT=(0,ek.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);function XD({open:e,placement:t="viewport",movePermissionGranted:n,onOpenChange:r,onAdd:a,onMovePermissionGrantedChange:i}){let o=[{key:"move-permission",label:n?"取消放行权限":"放行权限",icon:n?(0,ey.jsx)(jz,{className:"size-4"}):(0,ey.jsx)(XT,{className:"size-4"}),pressed:n,onClick:()=>i(!n)},{key:"add",label:"新建文件窗口",icon:(0,ey.jsx)(lJ,{className:"size-4"}),pressed:void 0,onClick:a}];return(0,ey.jsx)("div",{className:(0,eI.cn)("right-5 z-50","viewport"===t?"fixed bottom-5 max-md:bottom-20":"absolute bottom-5"),children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,title:t.label,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.pressed&&"border-foreground bg-foreground text-background hover:bg-foreground/90 hover:text-background"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":"文件窗口操作","aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let XR=[];function X_(e,t){return`${e} / ${t.replace(/\\/g," / ").replace(/\//g," / ")}`}function XL(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?XL(n.children,t):void 0;if(e)return e}}function X$(e,t){return e.replace(/\\/g,"/").toLowerCase()===t.replace(/\\/g,"/").toLowerCase()}function XF(e,t){let n=e.replace(/\\/g,"/").replace(/\/+/g,"/");return"windows"===t?n.toLowerCase():n}function XB(e){return e.map(e=>({...e,children:e.children?XB(e.children):void 0}))}let XV=(0,ek.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]),XH=(0,ek.default)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),XU=(0,ek.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),XW={title:"Clipboard",empty:"No clips",dragHandle:"Drag clip"};function Xq({items:e,expanded:t,defaultExpanded:n=!1,expansionDirection:r="down-left",title:a,labels:i,maxCollapsedItems:o=10,maxExpandedHeight:l=360,acceptExternalDrops:s=!1,removeOnExternalDrop:c=!1,className:d,onExpandedChange:u,onItemDragStart:f,onItemDragEnd:h,onItemDuplicate:m,onItemsRemove:p,onItemsReorder:g,onExternalDrop:v,onMouseEnter:x,onMouseLeave:y,...b}){let w={...XW,...i},[j,k]=ew.useState(n),[S,N]=ew.useState(),[C,M]=ew.useState(),[E,O]=ew.useState(n),[P,A]=ew.useState(),[I,z]=ew.useState({canScrollDown:!1,canScrollUp:!1}),[T,D]=ew.useState(!1),[R,_]=ew.useState(!1),L=ew.useRef(0),$=ew.useRef(void 0),F=ew.useRef(!1),B=ew.useRef(null),V=ew.useRef(null),H=void 0!==t,U=(H?t:j)||void 0!==S,W=Math.min(o,10),q=U?e:e.slice(0,W),K=E?C:void 0,G=44*q.length+18,X=Math.min(G,l),Y=U&&G>X,Z=0===e.length?"h-24":U?`${X}px`:"h-28",J=U&&Y?14:0;ew.useEffect(()=>{if(!U){O(!1),z({canScrollDown:!1,canScrollUp:!1});return}O(!1),window.requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=0)}),z({canScrollUp:!1,canScrollDown:G>X});let e=window.setTimeout(()=>{O(!0)},260);return()=>window.clearTimeout(e)},[G,X,U]),ew.useEffect(()=>()=>{void 0!==$.current&&window.clearTimeout($.current)},[]);let Q=ew.useCallback(e=>{H||k(e),u?.(e)},[H,u]);function ee(e,t=0){let n=e.currentTarget.getBoundingClientRect();return e.clientX>=n.left-t&&e.clientX<=n.right+t&&e.clientY>=n.top-t&&e.clientY<=n.bottom+t}function et(e){if(!U||!V.current)return 0;let t=Array.from(V.current.querySelectorAll('[data-slot="clipboard-stack-card"]'));if(0===t.length)return 0;for(let[n,r]of t.entries()){let t=r.getBoundingClientRect();if(e.clientY<t.top+t.height/2)return n}return t.length}function en(e){return void 0!==S||Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.clip-id")}return ew.useEffect(()=>{if(0===e.length||U)return;let t=window.requestAnimationFrame(()=>{B.current?.matches(":hover")&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))});return()=>window.cancelAnimationFrame(t)},[e.length,Q,U]),ew.useEffect(()=>{if(!U||!Y||!K||!V.current)return;let e=q.findIndex(e=>e.id===K);if(e<0)return;let t=V.current,n=44*e-8,r=44*e+(q[e]?.expandedHeight??220)+12,a=t.scrollTop,i=a+t.clientHeight;n<a?t.scrollTo({top:Math.max(0,n),behavior:"smooth"}):r>i&&t.scrollTo({top:r-t.clientHeight,behavior:"smooth"})},[K,Y,q,U]),(0,ey.jsxs)("div",{ref:B,"data-slot":"clipboard-stack","data-expanded":U,"data-closing":T,"data-external-dragging":R,"data-expansion-direction":r,className:(0,eI.cn)("group/clipboard relative w-80 max-w-full overflow-visible py-2",d),onMouseEnter:function(e){x?.(e),ee(e)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))},onMouseMove:function(e){if(!U){ee(e,12)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0));return}!U||S||ee(e,12)||(M(void 0),A(void 0),Q(!1),D(!0),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onMouseLeave:function(e){y?.(e),S||(M(void 0),A(void 0),D(!0),Q(!1),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onDragEnter:function(e){!s||en(e)||(L.current+=1,_(!0),D(!1))},onDragLeave:function(e){!s||en(e)||(L.current=Math.max(0,L.current-1),0===L.current&&(_(!1),A(void 0)))},onDragOver:function(e){!s||en(e)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",_(!0),U?A(et(e)):A(0))},onDrop:function(t){if(!s||en(t))return;t.preventDefault(),t.stopPropagation();let n=P??et(t);L.current=0,_(!1),A(void 0),v?.({insertIndex:n,items:e,nativeEvent:t})},...b,children:[(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-header",className:(0,eI.cn)("mb-2 flex h-8 items-center gap-2 px-1 text-sm font-medium text-foreground transition-[opacity,transform] duration-200","down-left"===r&&"justify-end",U?"opacity-100":"translate-y-1 opacity-0"),children:[(0,ey.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:(0,ey.jsx)(XU,{className:"size-3.5"})}),(0,ey.jsx)("span",{children:a??w.title}),(0,ey.jsx)("span",{className:"ml-auto tabular-nums text-muted-foreground",children:e.length})]}),(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-list",className:(0,eI.cn)("relative transition-[height] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]"),style:{height:Z},children:[e.length>0&&"down-left"===r?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-pivot","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute top-3 right-[34px] z-50 size-2.5 rounded-full bg-foreground shadow-sm transition-[opacity,transform] duration-200 dark:bg-background",U?"scale-75 opacity-0":"opacity-100")}):null,s&&R?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-external-ghost","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute right-0 z-[70] h-14 w-[88%] rounded-xl border bg-background shadow-md shadow-black/10","clipboard-stack-external-ghost"),children:[(0,ey.jsx)("span",{className:"absolute top-3 right-[34px] size-2 rounded-full bg-foreground dark:bg-background"}),(0,ey.jsx)("span",{className:"absolute top-4 left-3 h-2 w-24 rounded-full bg-foreground/18"}),(0,ey.jsx)("span",{className:"absolute top-8 left-3 h-1.5 w-14 rounded-full bg-foreground/10"})]}):null,0===e.length?(0,ey.jsx)("div",{className:"flex h-24 items-center justify-center rounded-xl border border-dashed bg-muted/35 text-sm text-muted-foreground",children:w.empty}):(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-frame",className:"relative h-full",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-scroll",ref:V,className:(0,eI.cn)("relative h-full overflow-x-visible",U&&Y?"clipboard-stack-scrollbar-hidden overflow-y-auto pt-2 pr-1 pb-3":"overflow-visible"),onScroll:e=>{let t=e.currentTarget;z({canScrollUp:t.scrollTop>1,canScrollDown:t.scrollTop+t.clientHeight<t.scrollHeight-1})},onDragOver:function(e){U&&S&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move")},onDrop:function(t){if(!U||!S||void 0===P)return;t.preventDefault(),t.stopPropagation(),F.current=!0;let n=e.findIndex(e=>e.id===S),r=e[n];if(n<0||!r)return;let a=e.filter(e=>e.id!==S),i=Math.max(0,Math.min(P>n?P-1:P,a.length));a.splice(i,0,r),A(void 0),M(void 0),i!==n&&g?.(a,{item:r,fromIndex:n,toIndex:i,items:a})},children:(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-content",className:"relative",style:{width:U&&Y?`calc(100% - ${J}px)`:void 0,marginLeft:U&&Y?`${J}px`:void 0,height:U&&Y?G+28:U?G:"100%"},children:[void 0!==P?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-insert-line","aria-hidden":"true",className:"pointer-events-none absolute right-0 left-0 z-[80] flex items-center",style:{top:44*P-2},children:[(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"}),(0,ey.jsx)("span",{className:"mx-1 size-1.5 rounded-full bg-foreground"}),(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"})]}):null,q.map((t,n)=>(0,ey.jsx)(XK,{item:t,index:n,count:q.length,expanded:U,active:U&&t.id===K,top:U?44*n:void 0,expansionDirection:r,labels:w,onHover:()=>M(t.id),onDuplicate:()=>{let n=e.findIndex(e=>e.id===t.id);n<0||m?.(e,{item:t,index:n,items:e})},onDragOver:e=>{if(U&&S&&S!==t.id){let t=e.currentTarget.getBoundingClientRect();A(e.clientY<t.top+t.height/2?n:n+1)}},onDragStart:e=>{N(e.item.id),M(void 0),F.current=!1,f?.(e)},onDragEnd:t=>{let n=t.nativeEvent.dataTransfer.dropEffect,r=t.item.id,a=e.findIndex(e=>e.id===r),i=c&&!F.current&&"none"!==n&&a>=0;if(N(void 0),A(void 0),M(void 0),F.current?F.current=!1:Q(!1),i){let n=e.filter(e=>e.id!==r);p?.(n,{item:t.item,index:a,items:n})}h?.(t)}},t.id))]})}),Y&&I.canScrollUp?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-top","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-8 bg-gradient-to-b from-background to-transparent"}):null,Y&&I.canScrollDown?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-bottom","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-[90] h-8 bg-gradient-to-t from-background to-transparent"}):null]})]})]})}function XK({item:e,index:t,count:n,expanded:r,active:a,top:i,expansionDirection:o,labels:l,onHover:s,onDuplicate:c,onDragOver:d,onDragStart:u,onDragEnd:f}){let h=Math.min(t,9),m="down-left"===o?-(4.5*h):[-4,2,-1,4][h]??0,p=r?a?n+20:n-t:n+t;return(0,ey.jsx)("article",{"data-slot":"clipboard-stack-card",draggable:!e.disabled,"aria-disabled":e.disabled,className:(0,eI.cn)("absolute right-0 min-h-16 w-full cursor-grab select-none rounded-xl border bg-background p-2.5 text-foreground shadow-sm shadow-black/5 outline-none transition-[top,transform,opacity,box-shadow,border-color] duration-300 ease-[cubic-bezier(.2,.8,.2,1)] active:cursor-grabbing","hover:border-foreground/35 hover:shadow-md hover:shadow-black/10 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40",r&&"min-h-0 overflow-hidden py-2 transition-[top,transform,max-height,opacity,box-shadow,border-color] duration-300",r&&!a&&"max-h-11",e.disabled&&"cursor-not-allowed opacity-50"),style:{top:r?i??44*t:"down-left"===o?0:9*h,zIndex:p,maxHeight:r&&a?e.expandedHeight??220:void 0,transformOrigin:"down-left"===o?"calc(100% - 34px) 14px":"100% 0",transform:r?a?"translate3d(-10px, -6px, 0) rotate(0deg)":"translate3d(0, 0, 0) rotate(0deg)":`translate3d(${"down-left"===o?0:4*h}px, 0, 0) rotate(${m}deg)`},tabIndex:e.disabled?-1:0,onMouseDown:function(t){1!==t.button||e.disabled||t.preventDefault()},onMouseEnter:s,onFocus:s,onAuxClick:function(t){1!==t.button||e.disabled||(t.preventDefault(),c?.())},onDragOver:d,onDragStart:function(t){for(let[n,r]of(t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",e.title),t.dataTransfer.setData("application/vnd.vantaloom.clip-id",e.id),Object.entries(e.dragData??{})))t.dataTransfer.setData(n,r);u?.({item:e,nativeEvent:t})},onDragEnd:function(t){f?.({item:e,nativeEvent:t})},children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-card-media",className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:e.icon??(0,ey.jsx)(XU,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.meta}):null]}),e.description?(0,ey.jsx)("p",{className:(0,eI.cn)("mt-0.5 text-xs leading-5 text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-40 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.description}):null,e.content?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-2 text-xs text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-80 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.content}):null]}),(0,ey.jsx)("span",{"aria-label":l.dragHandle,className:"mt-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground",children:(0,ey.jsx)(fj,{className:"size-3.5"})})]})})}function XG({transfers:e}){let t=e.slice(0,10);if(0===t.length)return null;let n=t.map(e=>{var t,n,r;let a,i,o;return{id:e.id,title:(a="copy"===(t=e).mode?"复制":"移动",i=t.sources.length,o=t.sources[0],`${a} ${i>1?`${i} 项`:XY(o?.path??"")}`),description:(n=e).message?n.message:`${n.sources[0]?.machineId??"local"} -> ${n.target.machineId}`,meta:function(e){switch(e.status){case"completed":return"完成";case"failed":return"失败";case"queued":return"排队";default:return`${Math.round(e.progress?.percent??0)}%`}}(e),icon:"completed"===(r=e).status?(0,ey.jsx)(eO,{className:"size-4"}):"failed"===r.status?(0,ey.jsx)(XH,{className:"size-4"}):"running"===r.status?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):"copy"===r.mode?(0,ey.jsx)(lU,{className:"size-4"}):(0,ey.jsx)(XV,{className:"size-4"}),expandedHeight:132,content:(0,ey.jsx)(XX,{transfer:e})}});return(0,ey.jsx)("div",{className:"pointer-events-auto fixed top-4 right-4 z-50 w-80 max-w-[calc(100vw-2rem)] max-md:left-4 max-md:right-auto max-md:w-auto max-md:max-w-[16rem]",children:(0,ey.jsx)(Xq,{items:n,title:"传输",labels:{empty:"暂无传输",dragHandle:"传输任务"},expansionDirection:"down-left",maxExpandedHeight:420})})}function XX({transfer:e}){let t=Math.max(0,Math.min(100,e.progress?.percent??0));return(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-border",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width] duration-300",style:{width:`${t}%`}})}),(0,ey.jsxs)("div",{className:"grid gap-1 tabular-nums",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate",children:XY(e.target.path)}),(0,ey.jsxs)("span",{children:[Math.round(t),"%"]})]}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"truncate",children:[XZ(e.progress.bytesDone)," /"," ",XZ(e.progress.bytesTotal)]}),(0,ey.jsxs)("span",{children:[e.progress.entriesDone,"/",e.progress.entriesTotal]})]}),e.progress.currentPath?(0,ey.jsx)("div",{className:"truncate text-muted-foreground",children:XY(e.progress.currentPath)}):null]})]})}function XY(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}function XZ(e){if(!e)return"0 B";let t=["B","KB","MB","GB","TB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||0===r?Math.round(n):n.toFixed(1)} ${t[r]}`}let XJ=(0,ek.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function XQ({windowLayout:e,roots:t,active:n,zIndex:r,boardSize:a,onActivate:i,onClose:o,onMinimize:l,onWindowChange:s,onNavigate:c,onRootsChange:d,onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onMoveItems:m}){return(0,ey.jsxs)("section",{className:(0,eI.cn)("absolute overflow-hidden rounded-xl border bg-card shadow-lg transition-[box-shadow,border-color] duration-150","vtl-file-manager-window",n&&"border-foreground shadow-xl"),style:{left:e.x,top:e.y,width:e.w,height:e.h,zIndex:r},onPointerDown:i,children:[(0,ey.jsxs)("div",{className:"grid h-9 cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b bg-muted/35 px-2 active:cursor-grabbing",onPointerDown:function(t){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function a(t){let a=Math.max(0,e.x+t.clientX-n),i=Math.max(0,e.y+t.clientY-r);s({...e,x:a,y:i})}window.addEventListener("pointermove",a),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",e)})},children:[(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"关闭窗口",onPointerDown:e=>e.stopPropagation(),onClick:o,children:(0,ey.jsx)(fg.XIcon,{})}),(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"缩小到剪切板",onPointerDown:e=>e.stopPropagation(),onClick:l,children:(0,ey.jsx)(XJ,{})})]}),(0,ey.jsx)("div",{className:"truncate text-center ui-text-control",children:e.title}),(0,ey.jsx)("div",{className:"w-14"})]}),(0,ey.jsx)(wK,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,draggableItems:!0,onNavigate:c,onRootsChange:e=>d(e),onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>m({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"vtl-file-window-explorer min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0",style:{height:"calc(100% - 2.25rem)",minHeight:0}}),(0,ey.jsx)("button",{type:"button","aria-label":"调整窗口大小",className:"absolute right-0 bottom-0 size-5 cursor-nwse-resize rounded-tl-md border-t border-l bg-background/80",onPointerDown:function(t){t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function o(t){let i=Math.max(420,Math.min(Math.max(420,a.width-e.x),e.w+t.clientX-n)),o=Math.max(320,e.h+t.clientY-r);s({...e,w:i,h:o})}window.addEventListener("pointermove",o),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",e)})}})]})}function X0({clipboardItems:e=[],onClipboardItemsChange:t,className:n,minBoardHeight:r=520,actionsPlacement:a="container"}){let[i,o]=Xz(),[l,s]=ew.useState([]),[c,d]=ew.useState(XR),[u,f]=ew.useState(XR[0]?.id),[h,m]=ew.useState([]),[p,g]=ew.useState(!1),[v,x]=ew.useState(!1),[y,b]=ew.useState(),w=ew.useRef(XR.length),j=ew.useRef(!1),k=ew.useRef(new Set),S=ew.useCallback(async(e,t,n)=>{let r=await uK(e,n);s(n=>{var a;return a={...r,root:{...r.root,id:t,machineId:e}},n.map(e=>e.id!==a.root.id?e:X$(e.path,a.path)?{...e,children:XB(a.items)}:{...e,children:function(e,t,n,r,a){let i=function(e,t,n){let r=XF(e,n),a=XF(t,n);if(r===a)return[];let i=r.endsWith("/")?r:`${r}/`;return a.startsWith(i)?a.slice(i.length).split("/").filter(Boolean):[]}(t,n,r);if(0===i.length)return XB(a);let o="windows"===r?"\\":"/";return function e(t,n,r){let l=i[r];if(!l)return XB(a);let s=n===o?`${o}${l}`:`${n.replace(/[\\/]+$/,"")}${o}${l}`,c=t.findIndex(e=>X$(e.path,s)),d=t[c],u={...d??{id:`synthetic-${s}`,name:l,kind:"folder",path:s,children:[]},kind:"folder",children:e(d?.children??[],s,r+1)};if(c<0)return[...t,u];let f=[...t];return f[c]=u,f}(e,t,0)}(e.children,e.path,a.path,e.platform,a.items)})})},[]),N=ew.useCallback(async()=>{let e=X5((await u0()).transfers);return m(e),e},[]),C=ew.useCallback(e=>{m(t=>X5([e,...t.filter(t=>t.id!==e.id)]))},[]),M=ew.useCallback(e=>{uQ({mode:"move",sources:e.sources.map(e=>({machineId:e.machineId,path:e.path})),target:{machineId:e.target.machineId,path:e.target.path}}).then(C).catch(()=>{})},[C]),E=ew.useCallback(()=>{for(let e of c)S(e.machineId,e.rootId,e.path)},[S,c]);function O(e,t){d(n=>n.map(n=>n.id===e?t(n):n))}function P(e){let t=l[0];if(!t&&!e?.rootId)return;w.current+=1;let n=`files-window-${w.current}`,r=i.current?.getBoundingClientRect(),a=r?.width??o.width,s=r?.height??o.height,c=e?.w??680,u=e?.h??460,h=Math.max(0,(a-c)/2),m=Math.max(0,(s-u)/2),p={id:n,title:e?.title??X_(t?.name??"local",t?.path??""),machineId:e?.machineId??t?.machineId??"local",rootId:e?.rootId??t?.id??"local",path:e?.path??t?.path??"",x:e?.x??h+12*w.current,y:e?.y??m+12*w.current,w:c,h:u};d(e=>[...e,p]),f(n),S(p.machineId,p.rootId,p.path)}ew.useEffect(()=>{let e=!0;return(async function(){let t=await uq();if(e&&(s(t.roots),!j.current&&t.roots[0])){j.current=!0;let e=function(e,t=0){return{id:`files-${e.id.replace(/[^a-z0-9_-]/gi,"-")}-${t}`,title:X_(e.name,e.path),machineId:e.machineId,rootId:e.id,path:e.path,x:28+24*t,y:28+24*t,w:720,h:480}}(t.roots[0]);d([e]),f(e.id),S(e.machineId,e.rootId,e.path)}})().catch(()=>{}),N().catch(()=>{}),()=>{e=!1}},[S,N]),ew.useEffect(()=>{if(!h.some(e=>"pending"===e.status||"running"===e.status||"queued"===e.status))return;let e=window.setInterval(async()=>{let e=(await N().catch(()=>h)).filter(e=>"completed"===e.status&&!k.current.has(e.id));if(e.length>0){for(let t of e)k.current.add(t.id);E()}},1e3);return()=>window.clearInterval(e)},[E,N,h]);let A=sb(),I=c.find(e=>e.id===u);function z(e){return{onNavigate:({rootId:t,path:n})=>{let r=l.find(e=>e.id===t),a=r?.machineId??e.machineId;O(e.id,e=>({...e,machineId:a,rootId:t,path:n,title:X_(r?.name??a,n)})),S(a,t,n)},onRootsChange:s,onCreateFolder:(t,n)=>{uY({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onRenameItem:(t,n)=>{uZ({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onDeleteItems:t=>{uJ({machineId:e.machineId,paths:t.map(e=>e.path)}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=XL(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}}}return A?(0,ey.jsxs)("div",{className:(0,eI.cn)("flex h-full min-h-0 w-full flex-col",n),children:[c.length>1?(0,ey.jsx)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:c.map(e=>(0,ey.jsx)("button",{type:"button",className:(0,eI.cn)("shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",e.id===u?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),onClick:()=>f(e.id),children:e.title},e.id))}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:I?(0,ey.jsx)(X1,{windowLayout:I,roots:l,...z(I)}):(0,ey.jsx)("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"暂无打开的文件窗口"})}),(0,ey.jsx)(XG,{transfers:h}),(0,ey.jsx)(XD,{open:p,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(X2,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]}):(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative h-full min-h-0 w-full overflow-hidden rounded-[inherit]",n),onDragOver:e=>{Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.file-window")&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.file-window");if(t)try{let n=JSON.parse(t),r=i.current?.getBoundingClientRect();e.preventDefault(),e.stopPropagation(),P({...n,x:r?e.clientX-r.left-160:n.x,y:r?e.clientY-r.top-24:n.y})}catch{return}},children:[(0,ey.jsx)("div",{className:"relative h-full min-h-0",style:{minHeight:Math.max(r,o.height-48)},children:c.map((n,r)=>(0,ey.jsx)(XQ,{windowLayout:n,roots:l,active:u===n.id,zIndex:20+r+20*(u===n.id),boardSize:o,onActivate:()=>f(n.id),onClose:()=>d(e=>e.filter(e=>e.id!==n.id)),onMinimize:()=>{t?.([{id:`clip-${n.id}`,title:n.title,description:"文件管理窗口",meta:`${Math.round(n.w)}x${Math.round(n.h)}`,payloads:{"application/vnd.vantaloom.file-window":{...n}},dragData:{"application/vnd.vantaloom.clip-kind":"file-window","application/vnd.vantaloom.file-window":JSON.stringify(n)}},...e.filter(e=>e.id!==`clip-${n.id}`)]),d(e=>e.filter(e=>e.id!==n.id))},onWindowChange:e=>O(n.id,()=>e),...z(n),onNavigate:({rootId:e,path:t})=>{let r=l.find(t=>t.id===e),a=r?.machineId??n.machineId;O(n.id,n=>({...n,machineId:a,rootId:e,path:t,title:X_(r?.name??a,t)})),S(a,e,t)},onRootsChange:s,onCreateFolder:(e,t)=>{uY({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onRenameItem:(e,t)=>{uZ({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onDeleteItems:e=>{uJ({machineId:n.machineId,paths:e.map(e=>e.path)}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=XL(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}},n.id))}),(0,ey.jsx)(XG,{transfers:h}),(0,ey.jsx)(XD,{open:p,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(X2,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]})}function X1({windowLayout:e,roots:t,onNavigate:n,onRootsChange:r,onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onMoveItems:l}){return(0,ey.jsx)(wK,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,onNavigate:n,onRootsChange:e=>r(e),onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>l({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"h-full min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0"})}function X2({move:e,onCancel:t,onConfirm:n}){var r;let a=e?.sources??[],i=Math.max(0,a.length-4);return(0,ey.jsx)(d4,{open:void 0!==e,onOpenChange:e=>{e||t()},children:(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:"确认移动"}),(0,ey.jsx)(ug,{children:e?`将 ${1===(r=a).length?r[0]?X4(r[0]):"0 项":`${r.length} 项`} 移动到 ${X4(e.target)}`:""})]}),e?(0,ey.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-muted/20 p-3 ui-text-body",children:[(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"移动内容"}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[a.slice(0,4).map(e=>(0,ey.jsx)("span",{className:"truncate",children:X4(e)},`${e.machineId}:${e.path}`)),i>0?(0,ey.jsxs)("span",{className:"text-muted-foreground",children:["另有 ",i," 项"]}):null]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"目标位置"}),(0,ey.jsx)("span",{className:"truncate",children:X4(e.target)})]})]}):null,(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{children:"取消"}),(0,ey.jsx)(uv,{onClick:()=>{e&&n(e)},children:"确认移动"})]})]})})}function X5(e){return e.slice(0,10)}function X4(e){let t=e.path.replace(/\\/g,"/");return`${e.machineId} / ${e.name||t}`}function X3({className:e}){return(0,ey.jsx)(X0,{className:(0,eI.cn)("h-full min-h-0 w-full rounded-[inherit] border-0 shadow-none",e),minBoardHeight:360,actionsPlacement:"container"})}var X6=ew;function X8(){return(X8=Object.assign.bind()).apply(null,arguments)}var X7=e=>{var{cx:t,cy:n,r,className:a}=e,i=(0,jL.clsx)("recharts-dot",a);return kp(t)&&kp(n)&&kp(r)?ew.createElement("circle",X8({},IF(e),zu(e),{className:i,cx:t,cy:n,r:r})):null},X9=["points"];function Ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ye(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yn(){return(Yn=Object.assign.bind()).apply(null,arguments)}function Yr(e){var{option:t,dotProps:n,className:r}=e;if((0,ew.isValidElement)(t))return(0,ew.cloneElement)(t,n);if("function"==typeof t)return t(n);var a=(0,jL.clsx)(r,"boolean"!=typeof t?t.className:""),i=null!=n?n:{},{points:o}=i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(i,X9);return ew.createElement(X7,Yn({},l,{className:a}))}function Ya(e){var{points:t,dot:n,className:r,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:s,zIndex:c=CX.scatter}=e;if(null==t||!n&&1!==t.length)return null;var d=z9(n),u=null==n?null:(0,ew.isValidElement)(n)?IV(n.props):"object"!=typeof n||Array.isArray(n)?null:IV(n),f=t.map((e,r)=>{var l,s,c=Yt(Yt(Yt({r:3},o),u),{},{index:r,cx:null!=(l=e.x)?l:void 0,cy:null!=(s=e.y)?s:void 0,dataKey:i,value:e.value,payload:e.payload,points:t});return ew.createElement(Yr,{key:"dot-".concat(r),option:n,dotProps:c,className:a})}),h={};return l&&null!=s&&(h.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(s,")")),ew.createElement(_V,{zIndex:c},ew.createElement(IW,Yn({className:r},h),f))}function Yi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yi(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Yl=e=>{var t,{point:n,childIndex:r,mainColor:a,activeDot:i,dataKey:o,clipPath:l}=e;if(!1===i||null==n.x||null==n.y)return null;var s=Yo(Yo(Yo({},{index:r,dataKey:o,cx:n.x,cy:n.y,r:4,fill:null!=a?a:"none",strokeWidth:2,stroke:"#fff",payload:n.payload,value:n.value}),IB(i)),zu(i));return t=(0,ew.isValidElement)(i)?(0,ew.cloneElement)(i,s):"function"==typeof i?i(s):ew.createElement(X7,s),ew.createElement(IW,{className:"recharts-active-dot",clipPath:l},t)};function Ys(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:a,clipPath:i,zIndex:o=CX.activeDot}=e,l=Se(R7),s=Se(_l);if(null==t||null==s)return null;var c=t.find(e=>s.includes(e.payload));return null==c?null:ew.createElement(_V,{zIndex:o},ew.createElement(Yl,{point:c,childIndex:Number(l),mainColor:n,dataKey:a,activeDot:r,clipPath:i}))}function Yc(e,t){var n,r,a=Se(t=>P_(t,e)),i=Se(e=>PF(e,t)),o=null!=(n=null==a?void 0:a.allowDataOverflow)?n:PD.allowDataOverflow,l=null!=(r=null==i?void 0:i.allowDataOverflow)?r:PL.allowDataOverflow;return{needClip:o||l,needClipX:o,needClipY:l}}function Yd(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,a=Se(F2),{needClipX:i,needClipY:o,needClip:l}=Yc(t,n);if(!l||!a)return null;var{x:s,y:c,width:d,height:u}=a;return ew.createElement("clipPath",{id:"clipPath-".concat(r)},ew.createElement("rect",{x:i?s:s-d/2,y:o?c:c-u/2,width:i?d:2*d,height:o?u:2*u}))}function Yu(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.xAxisId)?n:0}function Yf(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.yAxisId)?n:0}var Yh=(e,t,n)=>Iu(e,"xAxis",Yu(e,t),n),Ym=(e,t,n)=>Id(e,"xAxis",Yu(e,t),n),Yp=(e,t,n)=>Iu(e,"yAxis",Yf(e,t),n),Yg=(e,t,n)=>Id(e,"yAxis",Yf(e,t),n),Yv=j2([Cb,Yh,Yp,Ym,Yg],(e,t,n,r,a)=>kI(e,"xAxis")?kB(t,r,!1):kB(n,a,!1)),Yx=j2([PK,(e,t)=>t],(e,t)=>e.filter(e=>"area"===e.type).find(e=>e.id===t)),Yy=e=>kI(Cb(e),"xAxis")?"yAxis":"xAxis",Yb=j2([Yx,(e,t,n)=>As(e,Yy(e),"yAxis"===Yy(e)?Yf(e,t):Yu(e,t),n)],(e,t)=>{if(null!=e&&null!=t){var n,{stackId:r}=e,a=Mi(e);if(null!=r&&null!=a){var i=null==(n=t[r])?void 0:n.stackedData,o=null==i?void 0:i.find(e=>e.key===a);if(null!=o)return o.map(e=>[e[0],e[1]])}}}),Yw=j2([Cb,Yh,Yp,Ym,Yg,Yb,j8,Yv,Yx,e=>e.rootProps.baseValue],(e,t,n,r,a,i,o,l,s,c)=>{var d,{chartData:u,dataStartIndex:f,dataEndIndex:h}=o;if(null!=s&&("horizontal"===e||"vertical"===e)&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=l){var{data:m}=s;if(null!=(d=m&&m.length>0?m:null==u?void 0:u.slice(f,h+1)))return function(e){var t,{areaSettings:{connectNulls:n,baseValue:r,dataKey:a},stackedData:i,layout:o,chartBaseValue:l,xAxis:s,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:h,bandSize:m}=e,p=i&&i.length,g=((e,t,n,r,a)=>{var i=null!=n?n:t;if(kp(i))return i;var o="horizontal"===e?a:r,l=o.scale.domain();if("number"===o.type){var s=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return"dataMin"===i?c:"dataMax"===i||s<0?s:Math.max(Math.min(l[0],l[1]),0)}return"dataMin"===i?l[0]:"dataMax"===i?l[1]:l[0]})(o,l,r,s,c),v="horizontal"===o,x=!1,y=d.map((e,t)=>{if(p)d=i[u+t];else{var r,o,l,d,y,b=kA(e,a);Array.isArray(b)?(d=b,x=!0):d=[g,b]}var w=null!=(r=null==(o=d)?void 0:o[1])?r:null,j=null==w||p&&!n&&null==kA(e,a);return v?{x:k_({axis:s,ticks:f,bandSize:m,entry:e,index:t}),y:j?null:null!=(y=c.scale.map(w))?y:null,value:d,payload:e}:{x:j?null:null!=(l=s.scale.map(w))?l:null,y:k_({axis:c,ticks:h,bandSize:m,entry:e,index:t}),value:d,payload:e}});return t=p||x?y.map(e=>{var t,n,r=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:null!=r&&null!=e.y&&null!=(n=c.scale.map(r))?n:null,payload:e.payload}:{x:null!=r&&null!=(t=s.scale.map(r))?t:null,y:e.y,payload:e.payload}}):v?c.scale.map(g):s.scale.map(g),{points:y,baseLine:null!=t?t:0,isRange:x}}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataStartIndex:f,areaSettings:s,stackedData:i,displayedData:d,chartBaseValue:c,bandSize:l})}});function Yj(e){var t=IB(e);if(null!=t){var{r:n,strokeWidth:r}=t,a=Number(n),i=Number(r);return(Number.isNaN(a)||a<0)&&(a=3),(Number.isNaN(i)||i<0)&&(i=2),{r:a,strokeWidth:i}}return{r:3,strokeWidth:2}}var Yk=["id"],YS=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function YN(){return(YN=Object.assign.bind()).apply(null,arguments)}function YC(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function YM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YE(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YM(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YM(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YO(e,t){return e&&"none"!==e?e:t}var YP=X6.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kN,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kH(o,t),hide:l,type:c,color:YO(r,i),unit:s,graphicalItemId:d}};return X6.createElement(Ra,{tooltipEntrySettings:u})});function YA(e){var{clipPathId:t,points:n,props:r}=e,{needClip:a,dot:i,dataKey:o}=r,l=IF(r);return X6.createElement(Ya,{points:n,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function YI(e){var{showLabels:t,children:n,points:r}=e,a=r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return YE(YE({},r),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:r,fill:void 0})});return X6.createElement(Ln,{value:t?a:void 0},n)}function Yz(e){var{points:t,baseLine:n,needClip:r,clipPathId:a,props:i}=e,{layout:o,type:l,stroke:s,connectNulls:c,isRange:d}=i,{id:u}=i,f=YC(i,Yk),h=IF(f),m=IV(f);return X6.createElement(X6.Fragment,null,(null==t?void 0:t.length)>1&&X6.createElement(IW,{clipPath:r?"url(#clipPath-".concat(a,")"):void 0},X6.createElement(zw,YN({},m,{id:u,points:t,connectNulls:c,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),"none"!==s&&X6.createElement(zw,YN({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:t})),"none"!==s&&d&&Array.isArray(n)&&X6.createElement(zw,YN({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:n}))),X6.createElement(YA,{points:t,props:f,clipPathId:a}))}function YT(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.y,s=null==(n=i[i.length-1])?void 0:n.y;if(!kM(l)||!kM(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.x||0));return(kp(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.x||0),d)),kp(d))?X6.createElement("rect",{x:0,y:l<s?l:l-c,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(c)}):null}function YD(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.x,s=null==(n=i[i.length-1])?void 0:n.x;if(!kM(l)||!kM(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.y||0));return(kp(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.y||0),d)),kp(d))?X6.createElement("rect",{x:l<s?l:l-c,y:0,width:c,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function YR(e){var{alpha:t,layout:n,points:r,baseLine:a,strokeWidth:i}=e;return"vertical"===n?X6.createElement(YT,{alpha:t,points:r,baseLine:a,strokeWidth:i}):X6.createElement(YD,{alpha:t,points:r,baseLine:a,strokeWidth:i})}function Y_(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i}=e,{points:o,baseLine:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,onAnimationStart:f,onAnimationEnd:h}=r,m=Tk((0,X6.useMemo)(()=>({points:o,baseLine:l}),[o,l]),"recharts-area-"),p=Cw(),[g,v]=(0,X6.useState)(!1),x=(0,X6.useCallback)(()=>{"function"==typeof h&&h(),v(!1)},[h]),y=(0,X6.useCallback)(()=>{"function"==typeof f&&f(),v(!0)},[f]);if(null==p)return null;var b=a.current,w=i.current;return X6.createElement(YI,{showLabels:!g,points:o},r.children,X6.createElement(Tj,{animationId:m,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:x,onAnimationStart:y,key:m},e=>{if(b){var c,d=b.length/o.length,u=1===e?o:o.map((t,n)=>{var r=Math.floor(n*d);if(b[r]){var a=b[r];return YE(YE({},t),{},{x:kw(a.x,t.x,e),y:kw(a.y,t.y,e)})}return t});if(kp(l))c=kw(w,l,e);else c=null==l||kh(l)?kw(w,0,e):l.map((t,n)=>{var r=Math.floor(n*d);if(Array.isArray(w)&&w[r]){var a=w[r];return YE(YE({},t),{},{x:kw(a.x,t.x,e),y:kw(a.y,t.y,e)})}return t});return e>0&&(a.current=u,i.current=c),X6.createElement(Yz,{points:u,baseLine:c,needClip:t,clipPathId:n,props:r})}return e>0&&(a.current=o,i.current=l),X6.createElement(IW,null,s&&X6.createElement("defs",null,X6.createElement("clipPath",{id:"animationClipPath-".concat(n)},X6.createElement(YR,{alpha:e,points:o,baseLine:l,layout:p,strokeWidth:r.strokeWidth}))),X6.createElement(IW,{clipPath:"url(#animationClipPath-".concat(n,")")},X6.createElement(Yz,{points:o,baseLine:l,needClip:t,clipPathId:n,props:r})))}),X6.createElement(Lo,{label:r.label}))}function YL(e){var{needClip:t,clipPathId:n,props:r}=e,a=(0,X6.useRef)(null),i=(0,X6.useRef)();return X6.createElement(Y_,{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i})}class Y$ extends X6.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:a,left:i,needClip:o,xAxisId:l,yAxisId:s,width:c,height:d,id:u,baseLine:f,zIndex:h}=this.props;if(e)return null;var m=(0,jL.clsx)("recharts-area",r),{r:p,strokeWidth:g}=Yj(t),v=z9(t),x=2*p+g,y=o?"url(#clipPath-".concat(v?"":"dots-").concat(u,")"):void 0;return X6.createElement(_V,{zIndex:h},X6.createElement(IW,{className:m},o&&X6.createElement("defs",null,X6.createElement(Yd,{clipPathId:u,xAxisId:l,yAxisId:s}),!v&&X6.createElement("clipPath",{id:"clipPath-dots-".concat(u)},X6.createElement("rect",{x:i-x/2,y:a-x/2,width:c+x,height:d+x}))),X6.createElement(YL,{needClip:o,clipPathId:u,props:this.props})),X6.createElement(Ys,{points:n,mainColor:YO(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}),this.props.isRange&&Array.isArray(f)&&X6.createElement(Ys,{points:f,mainColor:YO(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}))}}var YF={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:CX.area};function YB(e){var t,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,connectNulls:o,dot:l,fill:s,fillOpacity:c,hide:d,isAnimationActive:u,legendType:f,stroke:h,xAxisId:m,yAxisId:p}=e,g=YC(e,YS),v=Se(Cb),x=Se(CF),{needClip:y}=Yc(m,p),b=N3(),{points:w,isRange:j,baseLine:k}=null!=(t=Se(t=>Yw(t,e.id,b)))?t:{},S=Se(F2);if("horizontal"!==v&&"vertical"!==v||null==S||"AreaChart"!==x&&"ComposedChart"!==x)return null;var{height:N,width:C,x:M,y:E}=S;return w&&w.length?X6.createElement(Y$,YN({},g,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:s,fillOpacity:c,height:N,hide:d,layout:v,isAnimationActive:u,isRange:j,legendType:f,needClip:y,points:w,stroke:h,width:C,left:M,top:E,xAxisId:m,yAxisId:p})):null}var YV=X6.memo(function(e){var t=zB(e,YF),n=N3();return X6.createElement(_y,{id:t.id,type:"area"},e=>X6.createElement(X6.Fragment,null,X6.createElement(_p,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,fill:a,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:YO(r,a),value:kH(n,t),payload:e}]})(t)}),X6.createElement(YP,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),X6.createElement(_E,{type:"area",id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:kR(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),X6.createElement(YB,YN({},t,{id:e}))))},Fb);function YH(){return(YH=Object.assign.bind()).apply(null,arguments)}function YU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}YV.displayName="Area";var YW=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YU(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Fs),Yq=(0,ew.forwardRef)(function(e,t){var n,r=zB(e.categoricalChartProps,YW),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:s}=e;return ew.createElement(Fv,{preloadedState:{options:{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0}},reduxStoreName:null!=(n=s.id)?n:a},ew.createElement(Fx,{chartData:s.data}),ew.createElement(Fw,{layout:r.layout,margin:r.margin}),ew.createElement(Fk,{throttleDelay:r.throttleDelay,throttledEvents:r.throttledEvents}),ew.createElement(Fj,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),ew.createElement(F6,YH({},r,{ref:t})))}),YK=["axis"],YG=(0,ew.forwardRef)((e,t)=>ew.createElement(Yq,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:YK,tooltipPayloadSearcher:LC,categoricalChartProps:e,ref:t})),YX=function(e){var{width:t,height:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(r%180+180)%180*Math.PI/180,i=Math.atan(n/t);return Math.abs(a>i&&a<Math.PI-i?n/Math.sin(a):t/Math.cos(a))};function YY(e,t){if(t<1)return[];if(1===t)return e;for(var n=[],r=0;r<e.length;r+=t){var a=e[r];void 0!==a&&n.push(a)}return n}function YZ(e,t,n,r,a){if(e*t<e*r||e*t>e*a)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-a)<=0}function YJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YJ(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Y0(e,t,n){var r,{tick:a,ticks:i,viewBox:o,minTickGap:l,orientation:s,interval:c,tickFormatter:d,unit:u,angle:f}=e;if(!i||!i.length||!a)return[];if(kp(c)||zj.isSsr)return null!=(r=YY(i,(kp(c)?c:0)+1))?r:[];var h="top"===s||"bottom"===s?"width":"height",m=u&&"width"===h?zO(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},p=(e,r)=>{var a,i="function"==typeof d?d(e.value,r):e.value;return"width"===h?(a=zO(i,{fontSize:t,letterSpacing:n}),YX({width:a.width+m.width,height:a.height+m.height},f)):zO(i,{fontSize:t,letterSpacing:n})[h]},g=i[0],v=i[1],x=i.length>=2&&null!=g&&null!=v?kf(v.coordinate-g.coordinate):1,y=function(e,t,n){var r="width"===n,{x:a,y:i,width:o,height:l}=e;return 1===t?{start:r?a:i,end:r?a+o:i+l}:{start:r?a+o:i+l,end:r?a:i}}(o,x,h);return"equidistantPreserveStart"===c?function(e,t,n,r,a){for(var i,o=(r||[]).slice(),{start:l,end:s}=t,c=0,d=1,u=l;d<=o.length;)if(i=function(){var t,i=null==r?void 0:r[c];if(void 0===i)return{v:YY(r,d)};var o=c,f=()=>(void 0===t&&(t=n(i,o)),t),h=i.coordinate,m=0===c||YZ(e,h,f,u,s);m||(c=0,u=l,d+=1),m&&(u=h+e*(f()/2+a),c+=d)}())return i.v;return[]}(x,y,p,i,l):"equidistantPreserveEnd"===c?function(e,t,n,r,a){var i=(r||[]).slice().length;if(0===i)return[];for(var{start:o,end:l}=t,s=1;s<=i;s++){for(var c,d=(i-1)%s,u=o,f=!0,h=d;h<i&&(0===(c=function(){var t,i=r[h];if(null==i)return 0;var o=h,s=()=>(void 0===t&&(t=n(i,o)),t),c=i.coordinate,m=h===d||YZ(e,c,s,u,l);if(!m)return f=!1,1;m&&(u=c+e*(s()/2+a))}())||1!==c);h+=s);if(f){for(var m=[],p=d;p<i;p+=s){var g=r[p];null!=g&&m.push(g)}return m}}return[]}(x,y,p,i,l):("preserveStart"===c||"preserveStartEnd"===c?function(e,t,n,r,a,i){var o=(r||[]).slice(),l=o.length,{start:s,end:c}=t;if(i){var d=r[l-1];if(null!=d){var u=n(d,l-1),f=e*(d.coordinate+e*u/2-c);o[l-1]=d=YQ(YQ({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate}),null!=d.tickCoord&&YZ(e,d.tickCoord,()=>u,s,c)&&(c=d.tickCoord-e*(u/2+a),o[l-1]=YQ(YQ({},d),{},{isShow:!0}))}}for(var h=i?l-1:l,m=function(t){var r,i=o[t];if(null==i)return 1;var l=i,d=()=>(void 0===r&&(r=n(i,t)),r);if(0===t){var u=e*(l.coordinate-e*d()/2-s);o[t]=l=YQ(YQ({},l),{},{tickCoord:u<0?l.coordinate-u*e:l.coordinate})}else o[t]=l=YQ(YQ({},l),{},{tickCoord:l.coordinate});null!=l.tickCoord&&YZ(e,l.tickCoord,d,s,c)&&(s=l.tickCoord+e*(d()/2+a),o[t]=YQ(YQ({},l),{},{isShow:!0}))},p=0;p<h;p++)if(m(p))continue;return o}(x,y,p,i,l,"preserveStartEnd"===c):function(e,t,n,r,a){for(var i=(r||[]).slice(),o=i.length,{start:l}=t,{end:s}=t,c=function(t){var r,c=i[t];if(null==c)return 1;var d=c,u=()=>(void 0===r&&(r=n(c,t)),r);if(t===o-1){var f=e*(d.coordinate+e*u()/2-s);i[t]=d=YQ(YQ({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate})}else i[t]=d=YQ(YQ({},d),{},{tickCoord:d.coordinate});null!=d.tickCoord&&YZ(e,d.tickCoord,u,l,s)&&(s=d.tickCoord-e*(u()/2+a),i[t]=YQ(YQ({},d),{},{isShow:!0}))},d=o-1;d>=0;d--)if(c(d))continue;return i}(x,y,p,i,l)).filter(e=>e.isShow)}var Y1=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function Y2(){return(Y2=Object.assign.bind()).apply(null,arguments)}function Y5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y4(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y5(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y5(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Y3={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:CX.axis};function Y6(e){var{x:t,y:n,width:r,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:s}=e;if(!l)return null;var c=Y4(Y4(Y4({},s),IF(l)),{},{fill:"none"});if("top"===i||"bottom"===i){var d=+("top"===i&&!o||"bottom"===i&&o);c=Y4(Y4({},c),{},{x1:t,y1:n+d*a,x2:t+r,y2:n+d*a})}else{var u=+("left"===i&&!o||"right"===i&&o);c=Y4(Y4({},c),{},{x1:t+u*r,y1:n,x2:t+u*r,y2:n+a})}return ew.createElement("line",Y2({},c,{className:(0,jL.clsx)("recharts-cartesian-axis-line",(0,j_.default)(l,"className"))}))}function Y8(e){var t,{option:n,tickProps:r,value:a}=e,i=(0,jL.clsx)(r.className,"recharts-cartesian-axis-tick-value");if(ew.isValidElement(n))t=ew.cloneElement(n,Y4(Y4({},r),{},{className:i}));else if("function"==typeof n)t=n(Y4(Y4({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";"boolean"!=typeof n&&(o=(0,jL.clsx)(o,Ll(n))),t=ew.createElement(z1,Y2({},r,{className:o}),a)}return t}function Y7(e){var{ticks:t,axisType:n,axisId:r}=e,a=k6();return(0,ew.useEffect)(()=>null==r||null==n?kN:(a(Fh({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{a(Fm({axisId:r,axisType:n}))}),[a,t,r,n]),null}var Y9=(0,ew.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:s,tickTextProps:c,orientation:d,mirror:u,x:f,y:h,width:m,height:p,tickSize:g,tickMargin:v,fontSize:x,letterSpacing:y,getTicksConfig:b,events:w,axisType:j,axisId:k}=e,S=Y0(Y4(Y4({},b),{},{ticks:n}),x,y),N=IF(b),C=IB(r),M=zG(N.textAnchor)?N.textAnchor:function(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}(d,u),E=function(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}(d,u),O={};"object"==typeof a&&(O=a);var P=Y4(Y4({},N),{},{fill:"none"},O),A=S.map(e=>Y4({entry:e},function(e,t,n,r,a,i,o,l,s){var c,d,u,f,h,m,p=l?-1:1,g=e.tickSize||o,v=kp(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":c=d=e.coordinate,m=(u=(f=n+!l*a)-p*g)-p*s,h=v;break;case"left":u=f=e.coordinate,h=(c=(d=t+!l*r)-p*g)-p*s,m=v;break;case"right":u=f=e.coordinate,h=(c=(d=t+l*r)+p*g)+p*s,m=v;break;default:c=d=e.coordinate,m=(u=(f=n+l*a)+p*g)+p*s,h=v}return{line:{x1:c,y1:u,x2:d,y2:f},tick:{x:h,y:m}}}(e,f,h,m,p,d,g,u,v))),I=A.map(e=>{var{entry:t,line:n}=e;return ew.createElement(IW,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(t.value,"-").concat(t.coordinate,"-").concat(t.tickCoord)},a&&ew.createElement("line",Y2({},P,n,{className:(0,jL.clsx)("recharts-cartesian-axis-tick-line",(0,j_.default)(a,"className"))})))}),z=A.map((e,t)=>{var n,a,{entry:d,tick:u}=e,f=Y4(Y4(Y4(Y4({verticalAnchor:E},N),{},{textAnchor:M,stroke:"none",fill:i},u),{},{index:t,payload:d,visibleTicksCount:S.length,tickFormatter:o,padding:s},c),{},{angle:null!=(n=null!=(a=null==c?void 0:c.angle)?a:N.angle)?n:0}),h=Y4(Y4({},f),C);return ew.createElement(IW,Y2({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(d.value,"-").concat(d.coordinate,"-").concat(d.tickCoord)},zf(w,d,t)),r&&ew.createElement(Y8,{option:r,tickProps:h,value:"".concat("function"==typeof o?o(d.value,t):d.value).concat(l||"")}))});return ew.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ew.createElement(Y7,{ticks:S,axisId:k,axisType:j}),z.length>0&&ew.createElement(_V,{zIndex:CX.label},ew.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:t},z)),I.length>0&&ew.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},I))}),Ze=(0,ew.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:a,className:i,hide:o,ticks:l,axisType:s,axisId:c}=e,d=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,Y1),[u,f]=(0,ew.useState)(""),[h,m]=(0,ew.useState)(""),p=(0,ew.useRef)(null);(0,ew.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>{var t;return(e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var l=n?n.getBoundingClientRect().width:0;return Math.round(o+(a+i)+l+(n?r:0))}return 0})({ticks:p.current,label:null==(t=e.labelRef)?void 0:t.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=(0,ew.useCallback)(e=>{if(e){var t=e.getElementsByClassName("recharts-cartesian-axis-tick-value");p.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),a=r.fontSize,i=r.letterSpacing;(a!==u||i!==h)&&(f(a),m(i))}}},[u,h]);return o||null!=r&&r<=0||null!=a&&a<=0?null:ew.createElement(_V,{zIndex:e.zIndex},ew.createElement(IW,{className:(0,jL.clsx)("recharts-cartesian-axis",i)},ew.createElement(Y6,{x:e.x,y:e.y,width:r,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:IF(e)}),ew.createElement(Y9,{ref:g,axisType:s,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),ew.createElement(_J,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},ew.createElement(_3,{label:e.label,labelRef:e.labelRef}),e.children)))}),Zt=ew.forwardRef((e,t)=>{var n=zB(e,Y3);return ew.createElement(Ze,Y2({},n,{ref:t}))});Zt.displayName="CartesianAxis";var Zn=["x1","y1","x2","y2","key"],Zr=["offset"],Za=["xAxisId","yAxisId"],Zi=["xAxisId","yAxisId"];function Zo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zo(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zo(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zs(){return(Zs=Object.assign.bind()).apply(null,arguments)}function Zc(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Zd=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:a,width:i,height:o,ry:l}=e;return ew.createElement("rect",{x:r,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Zu(e){var{option:t,lineItemProps:n}=e;if(ew.isValidElement(t))r=ew.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,a,{x1:i,y1:o,x2:l,y2:s,key:c}=n,d=null!=(a=IF(Zc(n,Zn)))?a:{},{offset:u}=d,f=Zc(d,Zr);r=ew.createElement("line",Zs({},f,{x1:i,y1:o,x2:l,y2:s,fill:"none",key:c}))}return r}function Zf(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Zc(e,Za),s=a.map((e,a)=>{var i=Zl(Zl({},l),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(a),index:a});return ew.createElement(Zu,{key:"line-".concat(a),option:r,lineItemProps:i})});return ew.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Zh(e){var{y:t,height:n,vertical:r=!0,verticalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Zc(e,Zi),s=a.map((e,a)=>{var i=Zl(Zl({},l),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(a),index:a});return ew.createElement(Zu,{option:r,lineItemProps:i,key:"line-".concat(a)})});return ew.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Zm(e){var{horizontalFill:t,fillOpacity:n,x:r,y:a,width:i,height:o,horizontalPoints:l,horizontal:s=!0}=e;if(!s||!t||!t.length||null==l)return null;var c=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,l)=>{var s=c[l+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=l%t.length;return ew.createElement("rect",{key:"react-".concat(l),y:e,x:r,height:d,width:i,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Zp(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:a,y:i,width:o,height:l,verticalPoints:s}=e;if(!t||!n||!n.length)return null;var c=s.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,t)=>{var s=c[t+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=t%n.length;return ew.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:d,height:l,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Zg=(e,t)=>{var{xAxis:n,width:r,height:a,offset:i}=e;return kz(Y0(Zl(Zl(Zl({},Y3),n),{},{ticks:kT(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.left,i.left+i.width,t)},Zv=(e,t)=>{var{yAxis:n,width:r,height:a,offset:i}=e;return kz(Y0(Zl(Zl(Zl({},Y3),n),{},{ticks:kT(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.top,i.top+i.height,t)},Zx={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:CX.grid};function Zy(e){var t=Se(kU),n=Se(kW),r=Cy(),a=Zl(Zl({},zB(e,Zx)),{},{x:kp(e.x)?e.x:r.left,y:kp(e.y)?e.y:r.top,width:kp(e.width)?e.width:r.width,height:kp(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:o,x:l,y:s,width:c,height:d,syncWithTicks:u,horizontalValues:f,verticalValues:h}=a,m=N3(),p=Se(e=>Is(e,"xAxis",i,m)),g=Se(e=>Is(e,"yAxis",o,m));if(!kE(c)||!kE(d)||!kp(l)||!kp(s))return null;var v=a.verticalCoordinatesGenerator||Zg,x=a.horizontalCoordinatesGenerator||Zv,{horizontalPoints:y,verticalPoints:b}=a;if((!y||!y.length)&&"function"==typeof x){var w=f&&f.length,j=x({yAxis:g?Zl(Zl({},g),{},{ticks:w?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!w||u);N9(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(y=j)}if((!b||!b.length)&&"function"==typeof v){var k=h&&h.length,S=v({xAxis:p?Zl(Zl({},p),{},{ticks:k?h:p.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!k||u);N9(Array.isArray(S),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof S,"]")),Array.isArray(S)&&(b=S)}return ew.createElement(_V,{zIndex:a.zIndex},ew.createElement("g",{className:"recharts-cartesian-grid"},ew.createElement(Zd,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),ew.createElement(Zm,Zs({},a,{horizontalPoints:y})),ew.createElement(Zp,Zs({},a,{verticalPoints:b})),ew.createElement(Zf,Zs({},a,{offset:r,horizontalPoints:y,xAxis:p,yAxis:g})),ew.createElement(Zh,Zs({},a,{offset:r,verticalPoints:b,xAxis:p,yAxis:g}))))}Zy.displayName="CartesianGrid";var Zb=["domain","range"],Zw=["domain","range"];function Zj(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Zk(e,t){return e===t||!!(Array.isArray(e)&&2===e.length&&Array.isArray(t))&&2===t.length&&e[0]===t[0]&&e[1]===t[1]}function ZS(e,t){if(e===t)return!0;var{domain:n,range:r}=e,a=Zj(e,Zb),{domain:i,range:o}=t,l=Zj(t,Zw);return!!Zk(n,i)&&!!Zk(r,o)&&Fb(a,l)}var ZN=["type"],ZC=["dangerouslySetInnerHTML","ticks","scale"],ZM=["id","scale"];function ZE(){return(ZE=Object.assign.bind()).apply(null,arguments)}function ZO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ZP(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ZO(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZO(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZA(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function ZI(e){var t=k6(),n=(0,ew.useRef)(null),r=Cw(),{type:a}=e,i=ZA(e,ZN),o=CQ(r,"xAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return ZP(ZP({},i),{},{type:o})},[i,o]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t($d(l)):n.current!==l&&t($u({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t($f(n.current)),n.current=null)},[t]),null}var Zz=e=>{var{xAxisId:t,className:n}=e,r=Se(k2),a=N3(),i="xAxis",o=Se(e=>Ic(e,i,t,a)),l=Se(e=>A9(e,t)),s=Se(e=>In(e,t)),c=Se(e=>PR(e,t));if(null==l||null==s||null==c)return null;var{dangerouslySetInnerHTML:d,ticks:u,scale:f}=e,h=ZA(e,ZC),{id:m,scale:p}=c,g=ZA(c,ZM);return ew.createElement(Zt,ZE({},h,g,{x:s.x,y:s.y,width:l.width,height:l.height,className:(0,jL.clsx)("recharts-".concat(i," ").concat(i),n),viewBox:r,ticks:o,axisType:i,axisId:t}))},ZT={allowDataOverflow:PD.allowDataOverflow,allowDecimals:PD.allowDecimals,allowDuplicatedCategory:PD.allowDuplicatedCategory,angle:PD.angle,axisLine:Y3.axisLine,height:PD.height,hide:!1,includeHidden:PD.includeHidden,interval:PD.interval,label:!1,minTickGap:PD.minTickGap,mirror:PD.mirror,orientation:PD.orientation,padding:PD.padding,reversed:PD.reversed,scale:PD.scale,tick:PD.tick,tickCount:PD.tickCount,tickLine:Y3.tickLine,tickSize:Y3.tickSize,type:PD.type,niceTicks:PD.niceTicks,xAxisId:0},ZD=ew.memo(e=>{var t=zB(e,ZT);return ew.createElement(ew.Fragment,null,ew.createElement(ZI,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),ew.createElement(Zz,t))},ZS);ZD.displayName="XAxis";var ZR=["type"],Z_=["dangerouslySetInnerHTML","ticks","scale"],ZL=["id","scale"];function Z$(){return(Z$=Object.assign.bind()).apply(null,arguments)}function ZF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ZB(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ZF(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZF(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZV(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function ZH(e){var t=k6(),n=(0,ew.useRef)(null),r=Cw(),{type:a}=e,i=ZV(e,ZR),o=CQ(r,"yAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return ZB(ZB({},i),{},{type:o})},[o,i]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t($h(l)):n.current!==l&&t($m({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t($p(n.current)),n.current=null)},[t]),null}function ZU(e){var{yAxisId:t,className:n,width:r,label:a}=e,i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=Se(k2),s=N3(),c=k6(),d="yAxis",u=Se(e=>Ia(e,t)),f=Se(e=>Ir(e,t)),h=Se(e=>Ic(e,d,t,s)),m=Se(e=>P$(e,t));if((0,ew.useLayoutEffect)(()=>{if(!("auto"!==r||!u||_1(a)||(0,ew.isValidElement)(a))&&null!=m){var e=i.current;if(e){var n=e.getCalculatedWidth();Math.round(u.width)!==Math.round(n)&&c($y({id:t,width:n}))}}},[h,u,c,a,t,r,m]),null==u||null==f||null==m)return null;var{dangerouslySetInnerHTML:p,ticks:g,scale:v}=e,x=ZV(e,Z_),{id:y,scale:b}=m,w=ZV(m,ZL);return ew.createElement(Zt,Z$({},x,w,{ref:i,labelRef:o,x:f.x,y:f.y,tickTextProps:"auto"===r?{width:void 0}:{width:r},width:u.width,height:u.height,className:(0,jL.clsx)("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:h,axisType:d,axisId:t}))}var ZW={allowDataOverflow:PL.allowDataOverflow,allowDecimals:PL.allowDecimals,allowDuplicatedCategory:PL.allowDuplicatedCategory,angle:PL.angle,axisLine:Y3.axisLine,hide:!1,includeHidden:PL.includeHidden,interval:PL.interval,label:!1,minTickGap:PL.minTickGap,mirror:PL.mirror,orientation:PL.orientation,padding:PL.padding,reversed:PL.reversed,scale:PL.scale,tick:PL.tick,tickCount:PL.tickCount,tickLine:Y3.tickLine,tickSize:Y3.tickSize,type:PL.type,niceTicks:PL.niceTicks,width:PL.width,yAxisId:0},Zq=ew.memo(e=>{var t=zB(e,ZW);return ew.createElement(ew.Fragment,null,ew.createElement(ZH,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),ew.createElement(ZU,t))},ZS);function ZK({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),o=e.find(e=>e.id===a)??e[0],[l,s]=ew.useState({});if(!o)return null;let c=l[o.id]??o.selectedMetricId??o.metrics[0]?.id,d=o.metrics.find(e=>e.id===c)??o.metrics[0];return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-performance-monitor",n),...r,children:[(0,ey.jsx)(md,{value:o.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(my,{className:"h-8",children:e.map(e=>(0,ey.jsx)(mb,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid min-h-0 flex-1 grid-cols-[14rem_minmax(0,1fr)] border-t",children:[(0,ey.jsx)("div",{className:"min-h-0 overflow-auto border-r p-2",children:o.metrics.map(e=>(0,ey.jsxs)("button",{type:"button",onClick:()=>s(t=>({...t,[o.id]:e.id})),className:(0,eI.cn)("grid w-full grid-cols-[3.75rem_minmax(0,1fr)] gap-3 px-2 py-2 text-left transition-colors",e.id===c&&"bg-muted"),children:[(0,ey.jsx)(ZQ,{data:e.data,color:e.color}),(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsx)("span",{className:"block truncate text-base leading-tight",children:e.label}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.value}),e.detail?(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.detail}):null]})]},e.id))}),(0,ey.jsxs)("div",{className:"min-h-0 overflow-auto p-5",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-5",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h2",{className:"text-4xl leading-none font-semibold tracking-normal",children:d?.title}),d?.subtitle?(0,ey.jsx)("p",{className:"mt-1 text-base text-muted-foreground",children:d.subtitle}):null]}),(0,ey.jsx)("div",{className:"text-right text-sm text-muted-foreground",children:d?.detail})]}),d?(0,ey.jsx)(ZG,{metric:d}):null]})]})]})}function ZG({metric:e}){return"cpu"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZX,{panel:{id:"cpu",title:"% 利用率",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(ZY,{}),(0,ey.jsx)(ZJ,{details:e.details,columns:4})]}):"memory"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZX,{panel:{id:"memory",title:"内存使用量",value:e.detail,data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(ZY,{}),(0,ey.jsx)(ZZ,{segments:e.composition}),(0,ey.jsx)(ZJ,{details:e.details,columns:3})]}):"disk"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZX,{panel:{id:"disk-active",title:"活动时间",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(ZY,{}),(0,ey.jsx)(ZX,{panel:{id:"disk-rate",title:"磁盘传输速率",value:"500 KB/秒",data:e.panels?.[0]?.data??e.data,span:"full"},size:"short"}),(0,ey.jsx)(ZY,{}),(0,ey.jsx)(ZJ,{details:e.details,columns:4})]}):"network"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZX,{panel:{id:"network",title:"吞吐量",value:"100 Kbps",data:e.data,span:"full",color:"danger"},size:"tall"}),(0,ey.jsx)(ZY,{}),(0,ey.jsx)(ZJ,{details:e.details,columns:2})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:(e.panels??[]).map(e=>(0,ey.jsx)(ZX,{panel:e},e.id))}),(0,ey.jsx)(ZJ,{details:e.details,columns:3})]})}function ZX({panel:e,size:t="normal"}){let n={short:"h-[4rem]",normal:"full"===e.span?"h-20":"h-24",large:"h-[17.5rem]",tall:"h-[21.5rem]"}[t];return(0,ey.jsxs)("div",{className:(0,eI.cn)("mt-5","full"===e.span&&"col-span-2"),children:[(0,ey.jsxs)("div",{className:"mb-1 flex items-center justify-between text-sm",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.title}),e.value?(0,ey.jsx)("span",{className:"text-muted-foreground tabular-nums",children:e.value}):null]}),(0,ey.jsx)(Z0,{data:e.data,color:e.color,className:(0,eI.cn)("w-full",n)})]})}function ZY(){return(0,ey.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{children:"60 秒"}),(0,ey.jsx)("span",{children:"0"})]})}function ZZ({segments:e}){let t=e&&e.length>0?e:[{label:"used",value:64},{label:"available",value:36}];return(0,ey.jsxs)("div",{className:"mt-5",children:[(0,ey.jsx)("div",{className:"mb-1 text-sm text-muted-foreground",children:"内存组合"}),(0,ey.jsx)("div",{className:"flex h-[3.25rem] w-full overflow-hidden border border-primary/75 bg-background",children:t.map((e,n)=>(0,ey.jsx)("div",{className:(0,eI.cn)("h-full border-r border-primary/75 last:border-r-0",0===n?"bg-primary/20":n===t.length-1?"bg-background":"bg-primary/8"),style:{width:`${Math.max(0,e.value)}%`}},`${e.label}-${n}`))})]})}function ZJ({details:e,columns:t}){return e?.length?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-5 grid gap-x-10 gap-y-4",2===t&&"grid-cols-2",3===t&&"grid-cols-3",4===t&&"grid-cols-4"),children:e.map(([e,t])=>(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("div",{className:"truncate text-2xl leading-tight tabular-nums",children:t})]},e))}):null}function ZQ({data:e,color:t}){return(0,ey.jsx)(Z0,{data:e,color:t,className:"h-10 w-full",strokeWidth:1.4,compact:!0})}function Z0({data:e,color:t="default",className:n,strokeWidth:r=1.6,compact:a=!1}){let i=ew.useMemo(()=>(e.length>1?e:[0,0]).map((e,t)=>({index:t,value:Math.max(0,Math.min(100,e))})),[e]),o=ew.useMemo(()=>({value:{label:"Value",color:"danger"===t?"var(--destructive)":"var(--foreground)"}}),[t]);return(0,ey.jsx)(Ve,{config:o,className:(0,eI.cn)("aspect-auto border bg-background text-muted-foreground",n),initialDimension:{width:a?96:640,height:a?40:220},children:(0,ey.jsxs)(YG,{data:i,margin:{top:a?2:6,right:0,bottom:0,left:0},children:[a?null:(0,ey.jsx)(Zy,{strokeDasharray:"0",stroke:"var(--border)",strokeOpacity:.7}),(0,ey.jsx)(ZD,{dataKey:"index",hide:!0,domain:["dataMin","dataMax"]}),(0,ey.jsx)(Zq,{hide:!0,domain:[0,100]}),a?null:(0,ey.jsx)(BU,{cursor:!1,content:(0,ey.jsx)(Vn,{hideLabel:!0,indicator:"line"})}),(0,ey.jsx)(YV,{dataKey:"value",type:"monotone",fill:"var(--color-value)",fillOpacity:"danger"===t?.16:.12,stroke:"var(--color-value)",strokeWidth:r,isAnimationActive:!1,dot:!1,activeDot:!1})]})})}Zq.displayName="YAxis";let Z1=(0,ek.default)("badge-alert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Z2=(0,ek.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),Z5={name:"名称",cpu:"CPU",memoryMb:"内存",diskMbps:"磁盘",networkMbps:"网络"};function Z4({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),[o,l]=ew.useState("cpu"),[s,c]=ew.useState("desc"),[d,u]=ew.useState({}),f=e.find(e=>e.id===a)??e[0],h=ew.useMemo(()=>{if(!f)return[];let e=[...function(e){let t=new Map,n=new Map;for(let t of e)void 0!==t.pid&&n.set(t.pid,t);for(let a of e){var r;let e=function e(t,n,r=new Set){void 0!==t.pid&&r.add(t.pid);let a=void 0!==t.parentPid?n.get(t.parentPid):void 0;return!a||void 0===a.pid||r.has(a.pid)||["bash","containerd","dockerd","explorer","init","kernel_task","launchd","services","sh","smss","svchost","system","systemd","wininit","winlogon","zsh"].includes(Je(a))?t:e(a,n,r)}(a,n),i=Je(e),o=t.get(i)??{kind:"group",id:i,name:(r=e,r.appName?.trim()||r.name.trim().replace(/\.(exe|com)$/i,"")||r.id),children:[],status:[],cpu:0,memoryMb:0,diskMbps:0,networkMbps:0};o.children.push(a),o.cpu+=a.cpu,o.memoryMb+=a.memoryMb,o.diskMbps+=a.diskMbps,o.networkMbps+=a.networkMbps,o.status=function(e,t){let n=new Set(e??[]);for(let e of t??[])n.add(e);return Array.from(n)}(o.status,a.status),t.set(i,o)}return Array.from(t.values()).map(e=>({...e,cpu:Jn(Math.min(100,e.cpu)),memoryMb:Jn(e.memoryMb),diskMbps:Jn(e.diskMbps),networkMbps:Jn(e.networkMbps)}))}(f.processes)].sort((e,t)=>Jt(e,t,o,s)),t=[];for(let n of e){if(n.children.length<=1){let e=n.children[0];e&&t.push(Z9(e,0));continue}if(t.push(n),d[n.id])for(let e of[...n.children].sort((e,t)=>Jt(e,t,o,s)))t.push(Z9(e,1))}return t},[f,d,s,o]),m=ew.useMemo(()=>h.map(e=>({memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps})),[h]);function p(e){e===o?c(e=>"asc"===e?"desc":"asc"):(l(e),c("name"===e?"asc":"desc"))}return f?(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-process-monitor",n),...r,children:[(0,ey.jsx)(md,{value:f.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(my,{className:"h-8",children:e.map(e=>(0,ey.jsx)(mb,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid h-14 shrink-0 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] border-y text-sm",children:[(0,ey.jsxs)("button",{type:"button",onClick:()=>p("name"),className:"flex items-end px-3 pb-2 text-left text-muted-foreground",children:["名称",(0,ey.jsx)(Z3,{active:"name"===o,direction:s})]}),(0,ey.jsx)("div",{className:"flex items-end px-3 pb-2 text-muted-foreground",children:"状态"}),["cpu","memoryMb","diskMbps","networkMbps"].map(e=>{var t,n;return(0,ey.jsxs)("button",{type:"button",onClick:()=>p(e),className:"grid content-end border-l px-3 pb-2 text-right",children:[(0,ey.jsx)("span",{className:"text-lg leading-none text-foreground",children:(t=f.totals,"cpu"===(n=e)?`${Math.round(t.cpu)}%`:"memoryMb"===n?`${Math.round(t.memory)}%`:"diskMbps"===n?`${Math.round(t.disk)}%`:"networkMbps"===n?`${Math.round(t.network)}%`:"")}),(0,ey.jsxs)("span",{className:"mt-1 text-xs text-muted-foreground",children:[Z5[e],(0,ey.jsx)(Z3,{active:o===e,direction:s,className:"ml-1 inline-flex"})]})]},e)})]}),(0,ey.jsx)("div",{className:"vtl-scrollbar-hidden min-h-0 flex-1 overflow-auto",children:h.map(e=>{var t;return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-9 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] items-center text-sm","group"===e.kind&&"bg-muted/35"),children:[(0,ey.jsx)(Z6,{row:e,expanded:"group"===e.kind&&!!d[e.id],onToggle:()=>{"group"===e.kind&&u(t=>({...t,[e.id]:!t[e.id]}))}}),(0,ey.jsx)(Z8,{platform:f.platform,status:e.status}),(0,ey.jsx)(Z7,{value:e.cpu,max:100,label:`${e.cpu.toFixed(1)}%`}),(0,ey.jsx)(Z7,{value:e.memoryMb,max:Jr(m,"memoryMb"),label:(t=e.memoryMb)>=1024?`${Ja(t/1024)} GB`:`${Ja(t)} MB`}),(0,ey.jsx)(Z7,{value:e.diskMbps,max:Math.max(1,Jr(m,"diskMbps")),label:`${Ja(e.diskMbps)} MB/秒`}),(0,ey.jsx)(Z7,{value:e.networkMbps,max:Math.max(1,Jr(m,"networkMbps")),label:`${Ja(e.networkMbps)} Mbps`})]},`${e.kind}-${e.id}`)})})]}):null}function Z3({active:e,direction:t,className:n}){return e?(0,ey.jsx)("asc"===t?jP:jO,{className:(0,eI.cn)("ml-1 size-3",n)}):null}function Z6({row:e,expanded:t,onToggle:n}){if("group"===e.kind){let r=t?vu:mQ;return(0,ey.jsxs)("button",{type:"button","aria-expanded":t,onClick:n,className:"flex h-full min-w-0 items-center gap-2 px-3 text-left outline-none transition-colors hover:bg-muted/55 focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"size-2 rounded-sm bg-foreground/65"}),(0,ey.jsxs)("span",{className:"min-w-0 truncate font-medium",children:[e.name," (",e.children.length,")"]})]})}return(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3",style:{paddingLeft:e.depth>0?34:void 0},children:[e.depth>0?(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/70"}):(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-foreground/65"}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",0===e.depth&&"font-medium"),children:e.name}),e.process.pid?(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.process.pid}):null]})}function Z8({platform:e,status:t}){return t?.length?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 text-muted-foreground",children:[t.includes("suspended")?(0,ey.jsx)(Z2,{"aria-label":"linux"===e?"挂起进程":"挂起",className:"size-4"}):null,t.includes("auto-restart")?(0,ey.jsx)(lQ,{"aria-label":"linux"===e?"自动重启进程":"自动重启",className:"size-4"}):null,t.includes("running")?(0,ey.jsx)(Z1,{"aria-label":"运行",className:"size-4 text-primary"}):null]}):(0,ey.jsx)("div",{className:"px-3"})}function Z7({value:e,max:t,label:n}){let r=Math.min(1,Math.max(0,e/Math.max(1,t))),a=r>.78,i=a?`color-mix(in oklch, var(--destructive) ${Math.round(18+42*r)}%, var(--background))`:`color-mix(in oklch, var(--foreground) ${Math.round(5+20*r)}%, var(--background))`;return(0,ey.jsx)("div",{className:"vtl-process-heat-cell h-full border-l px-3 text-right tabular-nums","data-hot":a?"":void 0,style:{background:i},children:(0,ey.jsx)("span",{className:(0,eI.cn)("leading-9",a&&"text-destructive"),children:n})})}function Z9(e,t){return{kind:"process",id:e.id,process:e,depth:t,name:e.appName&&0===t?e.appName:e.name,status:e.status,cpu:e.cpu,memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps}}function Je(e){return e.appId?.trim().toLowerCase()||e.appName?.trim().toLowerCase()||e.name.trim().toLowerCase().replace(/\.(exe|com)$/i,"")||e.id}function Jt(e,t,n,r){let a="asc"===r?1:-1;return"name"===n?e.name.localeCompare(t.name)*a:(e[n]-t[n])*a}function Jn(e){return Math.round(10*e)/10}function Jr(e,t){return e.reduce((e,n)=>Math.max(e,n[t]),0)}function Ja(e){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:+(e<10)}).format(e)}function Ji({className:e}){let t=Jl("/api/local/machines/processes"),n=Js("/machines/processes"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(Z4,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Jo({className:e}){let t=Jl("/api/local/machines/performance"),n=Js("/machines/performance"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(ZK,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Jl(e){let[t,n]=ew.useState([]);return ew.useEffect(()=>{let t=!0,r=!1;async function a(){if(!r){r=!0;try{let r=await fetch(eD(e),{cache:"no-store"});if(!r.ok)return;let a=await r.json();t&&n(a.machines)}catch{t&&n([])}finally{r=!1}}}a();let i=window.setInterval(a,2e3);return()=>{t=!1,window.clearInterval(i)}},[e]),t}function Js(e){let{machines:t}=vj(),[n,r]=ew.useState([]),a=ew.useMemo(()=>t.filter(e=>!e.isLocal&&"online"===e.status).map(e=>e.id),[t]);return ew.useEffect(()=>{if(0===a.length)return void r([]);let t=!0,n=!1;async function i(){if(!n){n=!0;try{let n=await Promise.all(a.map(async t=>{try{return(await sj(t,e)).machines??[]}catch{return[]}}));t&&r(n.flat())}finally{n=!1}}}i();let o=window.setInterval(i,5e3);return()=>{t=!1,window.clearInterval(o)}},[a,e]),n}let Jc=(0,ek.default)("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Jd=(0,ek.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),Ju={loading:"Starting terminal...",newTerminal:"New terminal",closeTerminal:e=>`Close ${e}`,terminalList:"Terminal sessions",status:{idle:"Idle",running:"Running",success:"Succeeded",error:"Failed"}},Jf=[{id:"powershell",title:"PowerShell",shell:"PowerShell",cwd:"D:\\Projects\\Vantaloom-ui",status:"idle",initialOutput:"PowerShell 7.6.1\r\nPS D:\\Projects\\Vantaloom-ui> "}];function Jh(e,t,n){return e.getPropertyValue(t).trim()||n}function Jm(e,t=!1){let n=getComputedStyle(e),r=Jh(n,"--foreground","#18181b"),a=Jh(n,"--terminal-background",Jh(n,"--background","#ffffff")),i="transparent"===a?Jh(n,"--background","#ffffff"):a,o=Jh(n,"--muted-foreground","#71717a"),l=Jh(n,"--border","#e4e4e7"),s=Jh(n,"--selection","#18181b");return{background:a,foreground:r,cursor:t?"transparent":r,cursorAccent:t?"transparent":i,selectionBackground:`color-mix(in oklch, ${s} 18%, transparent)`,selectionForeground:Jh(n,"--selection-foreground","#ffffff"),scrollbarSliderBackground:`color-mix(in oklch, ${l} 78%, transparent)`,scrollbarSliderHoverBackground:l,black:r,red:Jh(n,"--terminal-red","#bf616a"),green:Jh(n,"--terminal-green","#5e8c61"),yellow:Jh(n,"--terminal-yellow","#b06f3c"),blue:Jh(n,"--terminal-blue","#5e81ac"),magenta:Jh(n,"--terminal-magenta","#b48ead"),cyan:Jh(n,"--terminal-cyan","#4c8da8"),white:a,brightBlack:o,brightRed:Jh(n,"--terminal-bright-red","#d06f79"),brightGreen:Jh(n,"--terminal-bright-green","#6b9a70"),brightYellow:Jh(n,"--terminal-bright-yellow","#c2824b"),brightBlue:Jh(n,"--terminal-bright-blue","#6f91ba"),brightMagenta:Jh(n,"--terminal-bright-magenta","#c19ac0"),brightCyan:Jh(n,"--terminal-bright-cyan","#5aa0b8"),brightWhite:r}}function Jp(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function Jg({initialOutput:t,data:n,dataKey:r,options:a,readOnly:i=!1,autoFocus:o=!1,localEcho:l=!1,onData:s,onResize:c,onReady:d,labels:u,className:f,terminalClassName:h,...m}){let p=ew.useMemo(()=>({loading:Ju.loading,...u}),[u]),g=ew.useRef(null),v=ew.useRef(null),x=ew.useRef(void 0),y=ew.useRef(s),b=ew.useRef(c),w=ew.useRef(d),j=ew.useRef(a),k=ew.useRef(i),S=ew.useRef(l),N=ew.useRef(!1),C=ew.useRef(void 0),M=ew.useRef(!1),[E,O]=ew.useState(!1);return ew.useEffect(()=>{y.current=s,b.current=c,w.current=d,j.current=a,k.current=i,S.current=l},[l,s,d,c,a,i]),ew.useEffect(()=>{let n,r=!1,a=[];!async function(){var i;let l,s,c,d,u;if(!g.current||M.current)return;M.current=!0;let[{Terminal:f},{FitAddon:h},{SearchAddon:m},{WebLinksAddon:p}]=await Promise.all([e.A(93626),e.A(16118),e.A(24306),e.A(46866)]);if(r||!g.current)return;let C=new f({convertEol:!1,cursorBlink:!0,cursorStyle:"block",drawBoldTextInBrightColors:!1,fontFamily:(l=getComputedStyle(i=g.current),u=(c=Jh(l,"--font-family-mono",s='"Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", monospace'),d=getComputedStyle(i),c.replace(/var\((--[a-zA-Z0-9-_]+)(?:,[^)]+)?\)/g,(e,t)=>d.getPropertyValue(t).trim()||"")).trim(),`"Cascadia Mono", "Cascadia Code", Consolas, ${u||s}`),fontSize:13,letterSpacing:0,lineHeight:1.25,macOptionIsMeta:!0,minimumContrastRatio:4.5,scrollback:5e3,theme:Jm(g.current),...j.current,allowTransparency:!0}),E=new h,P=new m,A=new p;function I(){try{E.fit(),b.current?.({cols:C.cols,rows:C.rows})}catch{}}for(let e of(C.loadAddon(E),C.loadAddon(P),C.loadAddon(A),C.open(g.current),v.current=C,x.current=E,O(!0),requestAnimationFrame(I),(n=new ResizeObserver(I)).observe(g.current),a.push(C.onData(e=>{k.current||(S.current&&("\r"===e?C.write("\r\n"):""===e?C.write("\b \b"):C.write(e)),y.current?.(e))})),Jp(t)))C.write(e);w.current?.({terminal:C,fitAddon:E,searchAddon:P,webLinksAddon:A,fit:I,focus:()=>C.focus(),clear:()=>C.clear(),setCursorSuppressed:function(e){let t=g.current;t&&(N.current=e,t.toggleAttribute("data-vtl-terminal-cursor-suppressed",e),C.options.theme=Jm(t,e))},write:(e,t)=>C.write(e,t),writeln:e=>C.writeln(e)}),o&&C.focus()}();let i=new MutationObserver(()=>{let e=v.current,t=g.current;e&&t&&(e.options.theme=Jm(t,N.current))});return i.observe(document.documentElement,{attributeFilter:["class","style"],attributes:!0}),()=>{for(let e of(r=!0,i.disconnect(),n?.disconnect(),a))e.dispose();v.current?.dispose(),v.current=null,x.current=void 0,N.current=!1,M.current=!1,O(!1)}},[o,t]),ew.useEffect(()=>{let e=v.current;if(e&&C.current!==r)for(let t of(C.current=r,Jp(n)))e.write(t)},[n,r]),(0,ey.jsxs)("div",{"data-slot":"terminal-tab-surface",className:(0,eI.cn)("relative size-full min-h-0 overflow-hidden bg-background text-foreground",f),...m,children:[(0,ey.jsx)("div",{ref:g,className:(0,eI.cn)("vtl-terminal-xterm size-full overflow-hidden p-1.5 font-mono","[&_.xterm]:h-full [&_.xterm]:p-0 [&_.xterm-viewport]:!bg-transparent","[&_.xterm-screen]:!bg-transparent [&_.xterm-helper-textarea]:!outline-none","[&[data-vtl-terminal-cursor-suppressed]_.xterm-cursor]:!opacity-0","[&_.xterm-viewport::-webkit-scrollbar]:w-2.5 [&_.xterm-viewport::-webkit-scrollbar-track]:bg-transparent","[&_.xterm-viewport::-webkit-scrollbar-thumb]:rounded-full [&_.xterm-viewport::-webkit-scrollbar-thumb]:border-[3px]","[&_.xterm-viewport::-webkit-scrollbar-thumb]:border-transparent [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-border [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-clip-content",h)}),!E&&(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-muted-foreground ui-text-code",children:p.loading})]})}function Jv({status:e="idle"}){return"running"===e?(0,ey.jsx)(Jc,{className:"size-3.5 text-foreground"}):"success"===e?(0,ey.jsx)(eO,{className:"size-3.5 text-foreground"}):"error"===e?(0,ey.jsx)(eE,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(bC,{className:"size-3.5 text-muted-foreground"})}function Jx({session:e}){return e.aiControlled?(0,ey.jsx)(Jd,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(Jv,{status:e.status})}function Jy({sessions:e,defaultSessions:t=Jf,activeSessionId:n,defaultActiveSessionId:r,onActiveSessionChange:a,onSessionsChange:i,onCreateSession:o,onCloseSession:l,onSessionData:s,onSessionResize:c,onSessionReady:d,showTabs:u=!0,allowCreateSession:f=!0,readOnly:h=!1,localEcho:m=!1,terminalOptions:p,labels:g,className:v,tabListClassName:x,terminalClassName:y,...b}){let w=ew.useMemo(()=>({...Ju,...g,status:{...Ju.status,...g?.status}}),[g]),[j,k]=ew.useState(t),S=e??j,N=S[0],[C,M]=ew.useState(r??N?.id),E=n??(S.some(e=>e.id===C)?C:N?.id),O=S.find(e=>e.id===E)??N;function P(t){void 0===e&&k(t),i?.(t)}function A(e){e.disabled||(void 0===n&&M(e.id),a?.(e.id,e))}return(0,ey.jsxs)("div",{"data-slot":"terminal-tab-group",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",u?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",v),...b,children:[u&&(0,ey.jsxs)("div",{"data-slot":"terminal-tab-list",role:"tablist","aria-label":w.terminalList,className:(0,eI.cn)("flex min-w-0 items-center gap-1 border-b bg-muted/35 px-2 py-1.5",x),children:[(0,ey.jsx)(uO,{className:"ml-1 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsxs)("div",{className:(0,eI.cn)("group flex h-7 min-w-0 shrink-0 items-center rounded-md border border-transparent ui-text-control","transition-colors hover:bg-background/80",t?"bg-background text-foreground shadow-xs":"text-muted-foreground",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsxs)("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`terminal-panel-${e.id}`,disabled:e.disabled,onClick:()=>A(e),className:"flex h-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(Jx,{session:e}),(0,ey.jsx)("span",{className:"max-w-36 truncate",children:e.title}),e.shell&&(0,ey.jsx)("span",{className:"hidden text-muted-foreground ui-text-kbd sm:inline",children:e.shell})]}),e.closable&&(0,ey.jsx)("button",{type:"button","aria-label":w.closeTerminal(e.title),onClick:t=>{t.stopPropagation();l?.(e.id,e);let n=S.filter(t=>t.id!==e.id);if(P(n),e.id===E){let e=n.at(-1);e&&A(e)}},className:"mr-1 grid size-4 place-items-center rounded-sm text-muted-foreground opacity-0 outline-none transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/20 group-hover:opacity-100",children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]},e.id)})}),f&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":w.newTerminal,onClick:function(){let e=o?.()??{id:`terminal-${Date.now()}`,title:`Terminal ${S.length+1}`,status:"idle",initialOutput:"",closable:!0};P([...S,e]),A(e)},className:"size-7 shrink-0",children:(0,ey.jsx)(lJ,{className:"size-3.5"})})]}),(0,ey.jsx)("div",{"data-slot":"terminal-tab-panels",className:"relative min-h-0 overflow-hidden",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsx)(Jb,{session:e,selected:t,terminalOptions:p,readOnly:h,localEcho:m,onSessionData:s,onSessionResize:c,onSessionReady:d,labels:w,terminalClassName:y},e.id)})})]})}function Jb({session:e,selected:t,terminalOptions:n,readOnly:r,localEcho:a,onSessionData:i,onSessionResize:o,onSessionReady:l,labels:s,terminalClassName:c}){let d=ew.useRef(null),u=ew.useRef(t);return ew.useEffect(()=>{if(t&&!u.current&&d.current){let e=d.current;requestAnimationFrame(()=>{e&&(e.fit(),e.terminal.refresh(0,e.terminal.rows-1),e.terminal.focus())})}u.current=t},[t]),(0,ey.jsx)("div",{id:`terminal-panel-${e.id}`,role:"tabpanel","aria-hidden":!t,"data-active":t,className:"absolute inset-0 min-h-0",style:{display:t?"block":"none"},children:(0,ey.jsx)(Jg,{initialOutput:e.initialOutput,options:{...n,...e.options},readOnly:r||e.disabled,localEcho:a,autoFocus:t,onData:t=>i?.(e.id,t),onResize:t=>o?.(e.id,t),onReady:t=>{d.current=t,l?.(e.id,t)},labels:s,terminalClassName:c})})}function Jw({className:e,scopeId:t,state:n,onStateChange:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState([]),[s,c]=ew.useState(),[d,u]=ew.useState("local"),[f,h]=ew.useState(),[m,p]=ew.useState(!1),[g,v]=ew.useState(!1),x=ew.useRef(new Map),y=ew.useRef(new Map),b=ew.useRef(new Map),w=ew.useRef(new Map),j=ew.useRef(new Map),k=ew.useRef(new Map),S=ew.useRef(new Map),N=ew.useRef(new Map),C=ew.useRef(!1),M=ew.useRef(n?.autoStart===!1),E=ew.useRef(n),O=ew.useRef(r),P=Array.isArray(n?.sessionIds)?n.sessionIds.join("\0"):"__all__",A=t?.trim()||void 0,I=A??"__unscoped__";ew.useEffect(()=>{E.current=n},[n]),ew.useEffect(()=>{O.current=r},[r]);let z=a.find(e=>e.id===d)??a[0],T=z?.shells?.find(e=>e.id===f)??z?.shells?.[0],D=ew.useMemo(()=>o.map(e=>e.id),[o]),R=ew.useMemo(()=>o.filter(e=>e.aiControlled).map(e=>e.id),[o]),_=D.join("\0"),L=R.join("\0"),$=ew.useCallback((e,t)=>{let n=y.current.get(e);if(t){let t=j.current.get(e);void 0!==t&&(window.clearTimeout(t),j.current.delete(e))}n?.setCursorSuppressed(t)},[]),F=ew.useCallback(e=>{let t=j.current.get(e);void 0!==t&&window.clearTimeout(t);let n=window.setTimeout(()=>{j.current.delete(e),$(e,!1)},90);j.current.set(e,n)},[$]),B=ew.useCallback(e=>{let t=w.current.get(e),n=y.current.get(e);if(!t||!n||t.writing)return;if(!t.buffer){w.current.delete(e),F(e);return}void 0!==t.drainTimer&&(window.clearTimeout(t.drainTimer),t.drainTimer=void 0);let r=t.buffer.slice(0,65536);t.buffer=t.buffer.slice(r.length),t.writing=!0,$(e,!0);try{n.write(r,()=>{(t.writing=!1,y.current.has(e))?t.buffer?t.drainTimer=window.setTimeout(()=>B(e),0):(w.current.delete(e),F(e)):w.current.delete(e)})}catch{t.writing=!1,w.current.delete(e),F(e)}},[F,$]),V=ew.useCallback((e,t)=>{if(!t)return;if(!y.current.get(e))return void b.current.set(e,`${b.current.get(e)??""}${t}`);let n=w.current.get(e);(n||(n={buffer:"",writing:!1},w.current.set(e,n)),n.buffer+=t,$(e,!0),n.buffer.length>=65536)?B(e):n.writing||void 0!==n.drainTimer||(n.drainTimer=window.setTimeout(()=>B(e),8))},[B,$]),H=ew.useCallback((e,t)=>{(k.current.set(e,t.sequence),"output"===t.type&&t.data)?V(e,t.data):"status"===t.type&&t.status&&l(n=>n.map(n=>n.id===e?{...n,status:t.status??n.status,updatedAt:t.createdAt}:n))},[V]),U=ew.useCallback(e=>{if(x.current.has(e))return;let t=new EventSource(function(e,t=0){let n=new URLSearchParams;t>0&&n.set("after",String(t));let r=n.toString();return eD(`/api/local/terminals/sessions/${encodeURIComponent(e)}/events${r?`?${r}`:""}`)}(e,k.current.get(e)??0));t.onmessage=t=>{try{H(e,JSON.parse(t.data))}catch{return}},x.current.set(e,t)},[H]),W=ew.useCallback(async()=>{if(z&&!m){M.current=!1,p(!0);try{let e=await fu({machineId:z.id,scopeId:A,shell:T?.id,cwd:z.defaultCwd,cols:100,rows:30});l(t=>t.some(t=>t.id===e.id)?t:[...t,e]),c(e.id),U(e.id)}catch{return}finally{p(!1)}}},[m,U,z,T,A]);function q(e){let t=S.current.get(e);return t||(t={buffer:"",inFlight:!1},S.current.set(e,t)),t}return ew.useEffect(()=>{let e=!0;return v(!1),async function(){try{let t=E.current,n=t?.sessionIds,r=Array.isArray(n)?new Set(n):void 0,[a,o]=await Promise.all([fc(),fd(A)]);if(!e)return;let s=r?o.sessions.filter(e=>r.has(e.id)):o.sessions;C.current=!1,M.current=t?.autoStart===!1,i(a.machines),l(s),c(e=>{let n=t?.activeSessionId??e;return n&&s.some(e=>e.id===n)?n:s[0]?.id});let d=a.machines[0];if(d){let e=a.machines.find(e=>e.id===t?.selectedMachineId)??d;u(e.id),h(n=>t?.selectedShellId&&e.shells?.some(e=>e.id===t.selectedShellId)?t.selectedShellId:n&&e.shells?.some(e=>e.id===n)?n:e.shells?.[0]?.id)}}finally{e&&v(!0)}}(),()=>{e=!1}},[P,A,I]),ew.useEffect(()=>{g&&O.current?.({sessionIds:D,activeSessionId:s,selectedMachineId:d,selectedShellId:f,autoStart:!M.current,aiControlledSessionIds:R})},[s,R,L,g,d,f,D,_]),ew.useEffect(()=>{let e=new Set(D);for(let e of o)U(e.id);for(let[t,n]of x.current)e.has(t)||(n.close(),x.current.delete(t))},[U,D,o]),ew.useEffect(()=>{!g||C.current||M.current||o.length>0||0===a.length||(C.current=!0,W())},[W,g,a.length,o.length]),ew.useEffect(()=>()=>{for(let e of x.current.values())e.close();for(let e of S.current.values())void 0!==e.timer&&window.clearTimeout(e.timer);for(let e of w.current.values())void 0!==e.drainTimer&&window.clearTimeout(e.drainTimer);for(let[e,t]of j.current)window.clearTimeout(t),$(e,!1);S.current.clear(),w.current.clear(),j.current.clear()},[$]),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid h-full min-h-0 w-full grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit] border bg-card",e),children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 border-b bg-muted/35 px-2 py-1.5",children:[(0,ey.jsxs)(gT,{value:z?.id,onValueChange:e=>{u(e);let t=a.find(t=>t.id===e);h(t?.shells?.[0]?.id)},children:[(0,ey.jsxs)(vh,{size:"sm",className:"max-w-44",children:[(0,ey.jsx)(yt,{className:"size-3.5"}),(0,ey.jsx)(gL,{placeholder:"机器"})]}),(0,ey.jsx)(vg,{align:"start",children:a.filter(e=>"online"===e.status).map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsxs)(gT,{value:T?.id,onValueChange:h,children:[(0,ey.jsx)(vh,{size:"sm",className:"max-w-44",children:(0,ey.jsx)(gL,{placeholder:"Shell"})}),(0,ey.jsx)(vg,{align:"start",children:z?.shells?.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"新建终端",disabled:!z||m,onClick:()=>void W(),className:"ml-auto",children:(0,ey.jsx)(lJ,{className:"size-4"})})]}),(0,ey.jsx)(Jy,{sessions:o.map(Jj),activeSessionId:s,allowCreateSession:!1,localEcho:!1,labels:{loading:"启动终端...",terminalList:"终端会话",closeTerminal:e=>`关闭 ${e}`},onActiveSessionChange:e=>c(e),onCloseSession:e=>{let t,n,r;return x.current.get(e)?.close(),x.current.delete(e),y.current.delete(e),b.current.delete(e),t=w.current.get(e),t?.drainTimer!==void 0&&window.clearTimeout(t.drainTimer),w.current.delete(e),k.current.delete(e),void 0!==(n=j.current.get(e))&&(window.clearTimeout(n),j.current.delete(e)),r=S.current.get(e),void(r?.timer!==void 0&&window.clearTimeout(r.timer),S.current.delete(e),N.current.delete(e),l(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&(M.current=!0),c(t=>t&&t!==e&&n.some(e=>e.id===t)?t:n[0]?.id),n}),ff(e).catch(()=>{}))},onSessionData:function(e,t){let n=q(e);n.buffer+=t,function e(t){let n=q(t);n.inFlight||void 0!==n.timer||(n.timer=window.setTimeout(()=>{n.timer=void 0,function(t){let n=S.current.get(t);if(!n||n.inFlight)return;let r=n.buffer;if(n.buffer="",!r){void 0===n.timer&&S.current.delete(t);return}n.inFlight=!0,fh(t,r).catch(()=>{}).finally(()=>{let n=S.current.get(t);n&&(n.inFlight=!1,n.buffer?e(t):void 0===n.timer&&S.current.delete(t))})}(t)},6))}(e)},onSessionResize:function(e,t){let n=`${t.cols}x${t.rows}`;N.current.get(e)!==n&&(N.current.set(e,n),fm(e,t).then(e=>{l(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}).catch(()=>{}))},onSessionReady:function(e,t){y.current.set(e,t);let n=b.current.get(e);n&&(b.current.delete(e),V(e,n))},className:"min-h-0 rounded-none border-0"})]})}function Jj(e){return{id:e.id,title:e.title,shell:e.ordinal?`T${e.ordinal}`:"",cwd:e.cwd,status:function(e){switch(e){case"running":return"running";case"exited":case"closed":return"success";case"failed":return"error";default:return"idle"}}(e.status),closable:!0,initialOutput:"",aiControlled:e.aiControlled,controller:e.controller}}function Jk(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e.kind){case"file-tab-viewer":{let r=uH("file-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HQ,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(Gf,{className:`${n} border-0`,file:a??r.file,value:e.defaultValue??r.defaultValue??"",defaultValue:e.defaultValue??r.defaultValue,view:e.defaultView,mode:e.defaultMode,modified:e.modified,onValueChange:n=>t.onTabChange?.({...e,defaultValue:n,modified:!0}),onViewChange:n=>t.onTabChange?.({...e,defaultView:n}),onModeChange:n=>t.onTabChange?.({...e,defaultMode:n}),onSave:t.onSaveFileTab?n=>t.onSaveFileTab?.(e,n):void 0,onHistory:()=>t.onOpenFileHistory?.(e),labels:{review:"审阅",edit:"编辑",view:"视图",code:"代码",preview:"预览",hex:"十六进制",actions:"文件菜单",save:"保存",saving:"保存中",history:"历史版本"}})}case"browser-tab-viewer":return(0,ey.jsx)(Xt,{className:`${n} border-0`,defaultUrl:e.defaultUrl??uH("browser-tab-viewer").defaultUrl});case"diff-tab-viewer":{let t=uH("diff-tab-viewer");return(0,ey.jsx)(Wv,{className:`${n} border-0`,file:e.file??t.file,diff:e.diff??t.diff??""})}case"data-table-tab-viewer":{let r=uH("data-table-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HQ,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(Wo,{className:`${n} border-0`,file:{name:a?.name??r.file?.name??"data",path:a?.path??r.file?.path,type:JS(e)},source:void 0!==e.defaultValue?{type:JS(e),content:e.defaultValue}:void 0,data:e.tableData??r.tableData??[]})}case"terminal-tab-group":return(0,ey.jsx)(Jw,{className:`${n} border-0`,scopeId:t.terminalScopeId,state:e.terminal??t.terminalState,onStateChange:t.onTerminalStateChange})}}function JS(e){return`${e.file?.mimeType??""} ${e.file?.path??e.file?.name??""}`.toLowerCase().includes("json")?"json":"csv"}function JN(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e){case"multi-tab-system":{let e=t.nodeId,r=void 0!==t.tabs?t.tabs:[];return(0,ey.jsx)(Gg,{className:n,contentClassName:"min-h-0",tabs:r.map(n=>({id:n.id,title:n.title,meta:n.meta,modified:n.modified,icon:uV(n.kind),content:Jk(n,{terminalScopeId:e?`${t.terminalScopeId??`canvas:node:${e}`}:tab:${n.id}`:t.terminalScopeId,terminalState:n.terminal,onTerminalStateChange:r=>e?t.onTabChange?.(e,{...n,terminal:r}):void 0,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length}),onTabChange:n=>{e&&t.onTabChange?.(e,n)},onSaveFileTab:(n,r)=>e?t.onSaveFileTab?.(e,n,r):void 0,onOpenFileHistory:n=>e?t.onOpenFileHistory?.(e,n):void 0})})),activeTabId:t.activeTabId,detachable:!0,externalDropTypes:[Gq],createLabel:"打开文件",emptyContent:(0,ey.jsx)(HQ,{onChooseFile:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})}),onCreateTab:()=>{t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})},onActiveTabChange:n=>{e&&t.onActiveTabChange?.(e,n)},onTabsChange:n=>{if(!e)return;let a=n.map(e=>r.find(t=>t.id===e.id)).filter(e=>!!e);t.onTabsChange?.(e,a)},onTabDetach:(n,a)=>{if(!e)return!1;let i=r.find(e=>e.id===n.id);return!!i&&t.onTabDetach?.(e,i,{clientX:a.clientX,clientY:a.clientY})},onExternalTabDrop:({insertIndex:n,nativeEvent:r})=>{e&&t.onExternalTabDrop?.(e,n,r)}})}case"file-tree-panel":if(t.workspaceFolders)return(0,ey.jsx)(HZ,{folders:t.workspaceFolders,className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});return(0,ey.jsx)(XA,{className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});case"process-management":return(0,ey.jsx)(Ji,{className:`${n} rounded-[inherit] border-0`});case"machine-performance":return(0,ey.jsx)(Jo,{className:`${n} rounded-[inherit] border-0`});case"firewall-policy-workspace":return(0,ey.jsx)("div",{className:`${n} bg-card`,children:(0,ey.jsx)(XE,{})});case"machine-file-management":return(0,ey.jsx)(X3,{className:`${n} bg-card`});case"agent-conversation-panel":return(0,ey.jsx)(Hb,{className:`${n} vtl-canvas-agent-conversation-node`,composerClassName:"max-w-[42rem]"});case"status-monitor":return(0,ey.jsx)(GU,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"plan-doc-viewer":return(0,ey.jsx)(Gj,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"spec-doc-viewer":return(0,ey.jsx)(Gk,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"file-tab-viewer":case"browser-tab-viewer":case"diff-tab-viewer":case"data-table-tab-viewer":case"terminal-tab-group":return Jk(t.tab??uH(e,`${e}-tab`),{terminalState:t.terminalState,terminalScopeId:t.terminalScopeId,onTerminalStateChange:t.onTerminalStateChange,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:t.nodeId}),onTabChange:e=>{t.nodeId&&t.onTabChange?.(t.nodeId,e)},onSaveFileTab:(e,n)=>t.nodeId?t.onSaveFileTab?.(t.nodeId,e,n):void 0,onOpenFileHistory:e=>t.nodeId?t.onOpenFileHistory?.(t.nodeId,e):void 0})}}function JC({kind:e,...t}){return JN(e,t)}let JM="application/vnd.vantaloom.agent-pane-shredder",JE="application/vnd.vantaloom.agent-pane-cutter";function JO(e,t){return(e?.activeSessionId??"")===(t.activeSessionId??"")&&(e?.selectedMachineId??"")===(t.selectedMachineId??"")&&(e?.selectedShellId??"")===(t.selectedShellId??"")&&(e?.autoStart??!0)===(t.autoStart??!0)&&(e?.sessionIds??[]).join("\0")===t.sessionIds.join("\0")&&(e?.aiControlledSessionIds??[]).join("\0")===(t.aiControlledSessionIds??[]).join("\0")}let JP=[{id:"quad",label:"四分",slots:4,icon:(0,ey.jsx)(ye,{})},{id:"vertical-split",label:"上下二分",slots:2,icon:(0,ey.jsx)(Us,{})},{id:"horizontal-split",label:"左右二分",slots:2,icon:(0,ey.jsx)(Ut,{})},{id:"left-two-right-one",label:"左二右一",slots:3,icon:(0,ey.jsx)(s8,{})},{id:"left-one-right-two",label:"左一右二",slots:3,icon:(0,ey.jsx)(s9,{})},{id:"top-two-bottom-one",label:"上二下一",slots:3,icon:(0,ey.jsx)(Us,{})},{id:"top-one-bottom-two",label:"上一下二",slots:3,icon:(0,ey.jsx)(Ul,{})},{id:"single",label:"整窗口",slots:1,icon:(0,ey.jsx)(Uo,{})}];function JA(e,t,n=[50,50]){let r=e?.[t],a=r?.[0],i=r?.[1];return["number"==typeof a&&a>0?a:n[0],"number"==typeof i&&i>0?i:n[1]]}function JI(e,t){return{[e[0]]:t[0],[e[1]]:t[1]}}function Jz(e,t){return[e[t[0]]??50,e[t[1]]??50]}function JT({mode:e,sizes:t,onSizeGroupChange:n,children:r}){if("single"===e)return(0,ey.jsx)("div",{className:"size-full min-h-0",children:r[0]});if("horizontal-split"===e){let e=JA(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JI(a,e),onLayoutChanged:e=>n?.("outer",Jz(e,a)),children:[(0,ey.jsx)(hk,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("vertical-split"===e){let e=JA(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(a,e),onLayoutChanged:e=>n?.("outer",Jz(e,a)),children:[(0,ey.jsx)(hk,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("left-two-right-one"===e){let e=JA(t,"outer",[58,42]),a=JA(t,"left"),i=["left","right"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JI(i,e),onLayoutChanged:e=>n?.("outer",Jz(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(o,a),onLayoutChanged:e=>n?.("left",Jz(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:20,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:20,children:r[1]})]})}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("left-one-right-two"===e){let e=JA(t,"outer",[42,58]),a=JA(t,"right"),i=["left","right"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JI(i,e),onLayoutChanged:e=>n?.("outer",Jz(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(o,a),onLayoutChanged:e=>n?.("right",Jz(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:20,children:r[1]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:20,children:r[2]})]})})]})}if("top-two-bottom-one"===e){let e=JA(t,"outer",[58,42]),a=JA(t,"top"),i=["top","bottom"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(i,e),onLayoutChanged:e=>n?.("outer",Jz(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JI(o,a),onLayoutChanged:e=>n?.("top",Jz(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:24,children:r[1]})]})}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("top-one-bottom-two"===e){let e=JA(t,"outer",[42,58]),a=JA(t,"bottom"),i=["top","bottom"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(i,e),onLayoutChanged:e=>n?.("outer",Jz(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JI(o,a),onLayoutChanged:e=>n?.("bottom",Jz(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:24,children:r[1]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:24,children:r[2]})]})})]})}let a=JA(t,"outer"),i=JA(t,"left"),o=JA(t,"right"),l=["left","right"],s=["pane-0","pane-2"],c=["pane-1","pane-3"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JI(l,a),onLayoutChanged:e=>n?.("outer",Jz(e,l)),children:[(0,ey.jsx)(hk,{id:l[0],defaultSize:a[0],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(s,i),onLayoutChanged:e=>n?.("left",Jz(e,s)),children:[(0,ey.jsx)(hk,{id:s[0],defaultSize:i[0],minSize:20,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:s[1],defaultSize:i[1],minSize:20,children:r[2]})]})}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:l[1],defaultSize:a[1],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JI(c,o),onLayoutChanged:e=>n?.("right",Jz(e,c)),children:[(0,ey.jsx)(hk,{id:c[0],defaultSize:o[0],minSize:20,children:r[1]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:c[1],defaultSize:o[1],minSize:20,children:r[3]})]})})]})}function JD({conversationId:e,ownerMachineId:t,index:n,content:r,clipboardItems:a,clipboardDraggingId:i,onAdd:o,onPanelDrop:l,onContentChange:s,onClear:c,onCut:d,workspaceFolders:u,onRequestFileTab:f,onOpenWorkspaceFile:h,onSaveFileTab:m,onOpenFileHistory:p}){let[g,v]=ew.useState();return(0,ey.jsx)("div",{"data-agent-pane":n,className:(0,eI.cn)("relative size-full min-h-0 min-w-0 overflow-hidden",r?.kind!=="subagent-conversation-panel"&&"bg-background","vtl-agent-workspace-pane",r?.kind==="subagent-conversation-panel"&&"vtl-agent-workspace-conversation-pane bg-transparent","panel"===g&&"ring-2 ring-foreground/60 ring-inset","shredder"===g&&"ring-2 ring-destructive/70 ring-inset","cutter"===g&&"ring-2 ring-amber-500/70 ring-inset"),onDragOver:e=>{let t=Array.from(e.dataTransfer.types);if(t.includes(JE)){e.preventDefault(),e.dataTransfer.dropEffect="move",v("cutter");return}if(t.includes(JM)){e.preventDefault(),e.dataTransfer.dropEffect="move",v("shredder");return}t.includes(jM)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",v("panel"))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},onDrop:e=>{if(Array.from(e.dataTransfer.types).includes(JE)){e.preventDefault(),e.stopPropagation(),v(void 0),d(n);return}if(Array.from(e.dataTransfer.types).includes(JM)){e.preventDefault(),e.stopPropagation(),v(void 0),c(n);return}let t=function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),n=a.find(e=>e.id===t),r=n?n.payloads?.[jM]:void 0;if(n&&r)return{item:n,content:r.content};let i=e.dataTransfer.getData(jM);if(i)try{let e=JSON.parse(i);return n&&e.content?{item:n,content:e.content}:void 0}catch{return}}(e);t&&(e.preventDefault(),e.stopPropagation(),v(void 0),l(n,t.item,t.content))},children:r?(0,ey.jsx)("div",{className:(0,eI.cn)("size-full min-h-0 min-w-0 overflow-hidden rounded-none","vtl-agent-pane-content","subagent-conversation-panel"===r.kind&&"vtl-agent-pane-conversation-content",i&&"pointer-events-none"),children:jC(r)?JN(r.kind,{tab:r.tab,conversationId:e,ownerMachineId:t,terminalScopeId:e?`agent:${e}:pane:${r.id}`:void 0,terminalState:r.terminal,onTerminalStateChange:e=>{JO(r.terminal,e)||s(n,{...r,terminal:e})},workspaceFolders:u,nodeId:r.id,tabs:r.tabs,activeTabId:r.activeTabId,onRequestFileTab:({insertIndex:e})=>f?.(n,e),onOpenWorkspaceFile:h,onTabsChange:(e,t)=>{s(n,{...r,tabs:t,activeTabId:t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id})},onTabChange:(e,t)=>{"multi-tab-system"===r.kind?s(n,{...r,tabs:(r.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}):s(n,{...r,title:t.title,tab:t})},onSaveFileTab:(e,t,r)=>m?.(n,t,r),onOpenFileHistory:(e,t)=>p?.(n,t),onActiveTabChange:(e,t)=>{s(n,{...r,activeTabId:t})}}):(0,ey.jsx)(Hb,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:r.events},r.id)},r.id):(0,ey.jsx)("div",{className:"vtl-agent-pane-empty grid size-full place-items-center p-4",children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-background/90",onClick:o,"data-tour":"pane-add",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加"]})})})}function JR({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xg,{open:e,onOpenChange:t,title:"添加工作区组件",description:"选择一个组件填入当前窗口。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xp,{loop:!0,children:[(0,ey.jsx)(xv,{placeholder:"搜索组件..."}),(0,ey.jsxs)(xx,{children:[(0,ey.jsx)(xy,{children:"没有匹配组件。"}),(0,ey.jsx)(xb,{heading:"可放入窗口",children:jk.map(e=>(0,ey.jsxs)(xw,{"data-tour":`pane-template-${e.id}`,value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e.id),children:[(0,ey.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsx)(xj,{children:"添加"})]},e.id))})]})]})})}function J_({content:e,index:t,conversationId:n,ownerMachineId:r,workspaceFolders:a,onContentChange:i,onOpenWorkspaceFile:o,onSaveFileTab:l,onOpenFileHistory:s,onRequestFileTab:c}){return jC(e)?JN(e.kind,{tab:e.tab,conversationId:n,ownerMachineId:r,terminalScopeId:n?`agent:${n}:pane:${e.id}`:void 0,terminalState:e.terminal,onTerminalStateChange:n=>{JO(e.terminal,n)||i(t,{...e,terminal:n})},workspaceFolders:a,nodeId:e.id,tabs:e.tabs,activeTabId:e.activeTabId,onRequestFileTab:({insertIndex:e})=>c?.(t,e),onOpenWorkspaceFile:o,onTabsChange:(n,r)=>{i(t,{...e,tabs:r,activeTabId:r.some(t=>t.id===e.activeTabId)?e.activeTabId:r[0]?.id})},onTabChange:(n,r)=>{"multi-tab-system"===e.kind?i(t,{...e,tabs:(e.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):i(t,{...e,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>l?.(t,n,r),onOpenFileHistory:(e,n)=>s?.(t,n),onActiveTabChange:(n,r)=>{i(t,{...e,activeTabId:r})}}):(0,ey.jsx)(Hb,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:e.events},e.id)}let JL=[{kind:"status-monitor",label:"状态监控",icon:(0,ey.jsx)(uy,{})},{kind:"plan-doc-viewer",label:"计划文档",icon:(0,ey.jsx)(uj,{})},{kind:"spec-doc-viewer",label:"规范文档",icon:(0,ey.jsx)(Ur,{})},{kind:"browser-tab-viewer",label:"预览窗口",icon:(0,ey.jsx)(Ui,{})},{kind:"diff-tab-viewer",label:"Diff 栏",icon:(0,ey.jsx)(Un,{})},{kind:"terminal-tab-group",label:"终端窗口",icon:(0,ey.jsx)(uO,{})},{kind:"file-tree-panel",label:"文件树",icon:(0,ey.jsx)(Ua,{})},{kind:"file-tab-viewer",label:"文件窗口",icon:(0,ey.jsx)(uC,{})}];function J$(e,t,n){return Math.min(n,Math.max(t,e))}function JF({onAddCard:e,align:t="end"}){return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加窗口",(0,ey.jsx)(vu,{className:"size-3.5 text-muted-foreground"})]})}),(0,ey.jsx)(bZ,{align:t,sideOffset:6,className:"min-w-40",children:JL.map(t=>(0,ey.jsxs)(bJ,{onSelect:()=>e(t.kind),children:[t.icon,(0,ey.jsx)("span",{className:"flex-1",children:t.label})]},t.kind))})]})}function JB({conversationId:e,ownerMachineId:t,panes:n,agentSide:r,columns:a,heights:i,onColumnsChange:o,onHeightsChange:l,onAddCard:s,onContentChange:c,onClear:d,workspaceFolders:u,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:m,onRequestFileTab:p}){let g=n.map((e,t)=>({content:e,index:t})).filter(e=>!!e.content),v=new Map(g.map(e=>[e.content.id,e])),x=g.map(e=>e.content.id).join("|"),y="left"===r,b=ew.useRef(0);0===b.current&&a.length>0&&(b.current=a.reduce((e,t)=>{let n=/^col-(\d+)/.exec(t.key);return n?Math.max(e,Number(n[1])):e},0));let w=ew.useCallback(()=>`col-${b.current+=1}`,[]),j=e=>o("function"==typeof e?e(a):e),k=e=>l("function"==typeof e?e(i):e),[S,N]=ew.useState(null),[C,M]=ew.useState(null),[E,O]=ew.useState(null),P=ew.useRef(null),A=ew.useRef(null),I=ew.useRef(null),z=ew.useRef(null);ew.useEffect(()=>{let e={};j(t=>{let n=new Set(g.map(e=>e.content.id)),r=t.map(e=>({...e,cardIds:e.cardIds.filter(e=>n.has(e))})).filter(e=>e.cardIds.length>0),a=new Set(r.flatMap(e=>e.cardIds)),o=g.map(e=>e.content.id).filter(e=>!a.has(e));if(o.length>0){r=r.map(e=>({...e,cardIds:[...e.cardIds]}));let t=P.current?.clientHeight??0,n=t=>t.cardIds.reduce((t,n,r)=>t+(e[n]??i[n]??320)+12*(r>0),0);for(let a of o){let i=!1;if(t>0)for(let o of r){let r=12*(o.cardIds.length>0),l=t-n(o)-r;if(l>=320){o.cardIds.push(a),i=!0;break}if(l>=140){o.cardIds.push(a),e[a]=Math.floor(l),i=!0;break}}i||(0===r.length||t>0?r.push({key:w(),width:360,cardIds:[a]}):r[0].cardIds.push(a))}}return!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],a=t[n];if(!r||!a||r.key!==a.key||r.width!==a.width||r.cardIds.length!==a.cardIds.length)return!1;for(let e=0;e<r.cardIds.length;e+=1)if(r.cardIds[e]!==a.cardIds[e])return!1}return!0}(t,r)?r:t}),Object.keys(e).length>0&&k(t=>({...t,...e}))},[x,w]);let T=e=>i[e]??320;ew.useEffect(()=>{if(!S)return;let e=e=>{A.current?function(e,t){let n=P.current,r=A.current;if(!n||!r)return;let a=Array.from(n.querySelectorAll("[data-card-id]")),i=null,o=null,l=1/0;for(let n of a){let a=n.dataset.cardId;if(!a||a===r)continue;let s=n.getBoundingClientRect(),c=Math.max(s.left-e,0,e-s.right),d=Math.max(s.top-t,0,t-s.bottom),u=c*c+d*d;u<l&&(l=u,i=a,o=s)}if(!i||!o){I.current=null,O(null);return}let s=e-o.left,c=o.right-e,d=t-o.top,u=o.bottom-t,f=Math.min(s,c,d,u),h=f===d?"top":f===u?"bottom":f===s?"left":"right";I.current={id:i,edge:h};let m=n.getBoundingClientRect();O(function(e,t){switch(t){case"top":return{left:e.left,top:e.top-6-2,width:e.width,height:4};case"bottom":return{left:e.left,top:e.top+e.height+6-2,width:e.width,height:4};case"left":return{left:e.left-6-2,top:e.top,width:4,height:e.height};case"right":return{left:e.left+e.width+6-2,top:e.top,width:4,height:e.height}}}({left:o.left-m.left,top:o.top-m.top,width:o.width,height:o.height},h))}(e.clientX,e.clientY):z.current&&function(e,t){let n=z.current;if(!n)return;if("width"===n.kind){let t=J$(n.startWidth+(e-n.startX)*n.factor,240,760);j(e=>e.map(e=>e.key===n.columnKey?{...e,width:t}:e));return}if("growHeight"===n.kind){let e=Math.max(140,n.h0+(t-n.startY));k(t=>({...t,[n.cardId]:e}));return}let r=n.hA+n.hB,a=J$(n.hA+(t-n.startY),140,r-140);k(e=>({...e,[n.aboveId]:a,[n.belowId]:r-a}))}(e.clientX,e.clientY)},t=()=>(function(){let e=A.current;if(e){var t,n;let r=I.current;A.current=null,I.current=null,M(null),O(null),N(null),r&&(t=r.id,n=r.edge,e&&e!==t&&j(r=>{let a=r.map(e=>({...e,cardIds:[...e.cardIds]}));for(let t of a){let n=t.cardIds.indexOf(e);n>=0&&t.cardIds.splice(n,1)}let i=-1,o=-1;a.forEach((e,n)=>{let r=e.cardIds.indexOf(t);r>=0&&(i=n,o=r)});let l=a[i];if(!l)return r;if("top"===n||"bottom"===n)l.cardIds.splice("top"===n?o:o+1,0,e);else{let t=(y?"right"===n:"left"===n)?i:i+1;a.splice(t,0,{key:w(),width:a[i]?.width??360,cardIds:[e]})}return a.filter(e=>e.cardIds.length>0)}));return}z.current&&(z.current=null,N(null))})();return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[S]);let D=a.map((e,t)=>({column:e,realIndex:t}));y&&D.reverse();let R=(0,ey.jsx)("div",{className:(0,eI.cn)("flex shrink-0 px-3 py-2",y?"justify-end":"justify-start"),children:(0,ey.jsx)(JF,{onAddCard:s,align:y?"end":"start"})});return 0===g.length?null:(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col",children:[R,(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",children:(0,ey.jsxs)("div",{ref:P,className:"relative flex min-h-full items-start gap-3",children:[D.map(({column:n})=>{let r=[],i=0;for(let e=0;e<n.cardIds.length;e+=1)i+=T(n.cardIds[e]),e<n.cardIds.length-1&&(r.push(i+6),i+=12);let o=i,l=n.cardIds[n.cardIds.length-1],s=1===n.cardIds.length&&v.get(n.cardIds[0])?.content.kind==="status-monitor";return(0,ey.jsxs)("div",{className:(0,eI.cn)("relative flex shrink-0 flex-col gap-3",s&&"h-full"),style:{width:n.width},children:[n.cardIds.map(n=>{let r=v.get(n);if(!r)return null;let{content:a,index:i}=r;return(0,ey.jsxs)("div",{"data-card-id":a.id,style:s?void 0:{height:T(a.id)},className:(0,eI.cn)("group/card relative flex w-full flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm",s?"min-h-0 flex-1":"shrink-0",C===a.id?"opacity-40":"opacity-100"),children:[(0,ey.jsxs)("div",{onPointerDown:e=>{var t;return t=a.id,void(0===e.button&&(e.preventDefault(),e.stopPropagation(),A.current=t,I.current=null,M(t),O(null),N("drag")))},className:"flex shrink-0 cursor-grab touch-none select-none items-center justify-between gap-2 border-b border-border/60 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,ey.jsx)(fj,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.title})]}),(0,ey.jsx)("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:()=>d(i),"aria-label":"关闭窗口",title:"关闭窗口",className:"grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:(0,ey.jsx)(fg.XIcon,{})})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,ey.jsx)(J_,{content:a,index:i,conversationId:e,ownerMachineId:t,workspaceFolders:u,onContentChange:c,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:m,onRequestFileTab:p})})]},a.id)}),n.cardIds.slice(0,-1).map((e,t)=>(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:r=>{var a;return a=n.cardIds[t+1],void(0===r.button&&(r.preventDefault(),r.stopPropagation(),z.current={kind:"height",aboveId:e,belowId:a,startY:r.clientY,hA:T(e),hB:T(a)},N("resize")))},style:{top:r[t]??0},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})},`hbar-${e}`)),l&&!s?(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),z.current={kind:"growHeight",cardId:l,startY:e.clientY,h0:T(l)},N("resize"))},style:{top:o+6},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})}):null,(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>(function(e,t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation();let n=a.find(t=>t.key===e)?.width??360;z.current={kind:"width",columnKey:e,startX:t.clientX,startWidth:n,factor:y?-1:1},N("resize")})(n.key,e),style:y?{left:-6}:{right:-6},className:(0,eI.cn)("group/wbar absolute inset-y-0 z-10 flex w-3 cursor-ew-resize items-center justify-center",y?"-translate-x-1/2":"translate-x-1/2"),children:(0,ey.jsx)("span",{className:"h-12 w-1 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/wbar:opacity-100"})})]},n.key)}),E?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute z-40 rounded-full bg-muted-foreground/70",style:{left:E.left,top:E.top,width:E.width,height:E.height}}):null]})}),S?(0,ey.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 z-50",style:{cursor:"drag"===S?"grabbing":z.current?.kind==="width"?"ew-resize":"ns-resize"}}):null]})}let JV="vtl:workspace-layout-mode",JH="vtl:workspace-agent-side",JU="vtl:workspace-layout-changed",JW={mode:"pane",agentSide:"left"};function Jq(){let e=JW.mode,t=JW.agentSide;try{let n=window.localStorage.getItem(JV);("pane"===n||"card"===n||"control-room"===n)&&(e=n);let r=window.localStorage.getItem(JH);("left"===r||"right"===r)&&(t=r)}catch{}return{mode:e,agentSide:t}}function JK(e){try{e.mode&&window.localStorage.setItem(JV,e.mode),e.agentSide&&window.localStorage.setItem(JH,e.agentSide)}catch{}window.dispatchEvent(new CustomEvent(JU))}function JG({stack:e,rootTitle:t,rootOwnerMachineId:n,onNavigateRoot:r,onNavigateIndex:a,onOpenSubagent:i}){let o=e[e.length-1],[l,s]=ew.useState(null);if(ew.useEffect(()=>{let e;if(!o)return;let t=!1;async function r(){try{let a=await sA(o.id,n);if(t)return;s(a);let i="working"===a.conversation.status||!!a.conversation.running;e=window.setTimeout(r,i?900:5e3)}catch{if(t)return;e=window.setTimeout(r,3e3)}}return s(null),r(),()=>{t=!0,e&&window.clearTimeout(e)}},[o,n]),!o)return null;let c=l?.conversation.status??"working",d="working"===c||!!l?.conversation.running;return(0,ey.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-background",children:[(0,ey.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,ey.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:r,children:t||"主对话"}),e.map((t,n)=>{let r=Hn(t.subagentType),i=n===e.length-1,o=r.Icon;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(mQ,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 transition-colors hover:bg-accent/50",i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>a(n),children:[(0,ey.jsx)(o,{className:(0,eI.cn)("size-3",r.color)}),(0,ey.jsx)("span",{className:"max-w-[10rem] truncate",children:t.name||`${r.label}子代理`})]})]},t.id)}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 pl-2",children:d?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"paused"===c?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,ey.jsx)(hM,{className:"size-3"}),"已暂停"]}):(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-500",children:[(0,ey.jsx)(eO,{className:"size-3"}),"完成"]})})]}),(0,ey.jsx)("div",{className:"relative min-h-0 flex-1",children:l?(0,ey.jsx)(VY,{events:l.events,bottomInset:16,contentClassName:"max-w-[42.5rem]",onOpenSubagent:e=>i(e),labels:{recall:"召回",branch:"分支",expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"}}):(0,ey.jsxs)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"mr-2 size-4 animate-spin"}),"正在打开子代理对话…"]})})]})}let JX=[],JY="vantaloom:file-system-changed";function JZ(e,t){let n;if(0===t.length)return e;let r=new Map;for(let t=0;t<e.length;t+=1){let n=e[t]?.id;n&&r.set(n,t)}for(let a of t){let t=a?.id,i=t?r.get(t):void 0;if(void 0!==i){if(e[i]===a)continue;n||(n=e.slice()),n[i]=a}else n||(n=e.slice()),t&&r.set(t,n.length),n.push(a)}return n??e}function JJ(e,t){if(0===e.length)return t;let n=new Set;for(let e of t)e?.id&&n.add(e.id);let r=e.filter(e=>e?.id&&!n.has(e.id));return 0===r.length?t:[...r,...t]}function JQ(e){var t;let n=(t=e?.layoutMode,JP.some(e=>e.id===t)?t:"quad"),r="right"===e?.agentPosition?"right":"left",a=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return{};let t=e.shell&&"object"==typeof e.shell&&!Array.isArray(e.shell)?e.shell:void 0,n={};for(let e of["agent","panes"]){let r=t?.[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(n[e]=r)}return{...Object.keys(n).length?{shell:n}:{},outer:J0(e.outer),left:J0(e.left),right:J0(e.right),top:J0(e.top),bottom:J0(e.bottom)}}(e?.sizes),i=Array.from({length:Math.max(4,JP.find(e=>e.id===n)?.slots??4)},()=>void 0);for(let[t,n]of(e?.panes??[]).entries()){let e=Number.isInteger(n.slot)?n.slot:t;e<0||e>=i.length||(i[e]=function(e,t){var n,r;let a=e.paneId||`${e.kind}-${t+1}`,i=!(n=e.props)||"object"!=typeof n||Array.isArray(n)?{}:n;if("subagent-conversation-panel"===e.kind)return{id:a,kind:"subagent-conversation-panel",title:J2(i.title)??"Subagent",subagentId:J2(i.subagentId)??a,events:Array.isArray(i.events)?i.events:[]};if(!jS(e.kind))return;let o=i.tab&&"object"==typeof i.tab?i.tab:void 0,l=Array.isArray(i.tabs)?i.tabs.filter(e=>uB(e?.kind)):void 0,s=jS(e.kind);return{id:a,kind:e.kind,title:J2(i.title)??o?.title??s?.title??"组件",tab:o,tabs:l,activeTabId:J2(i.activeTabId),terminal:"terminal-tab-group"===e.kind?!(r=i.terminal)||"object"!=typeof r||Array.isArray(r)?{sessionIds:[]}:{sessionIds:Array.isArray(r.sessionIds)?r.sessionIds.filter(e=>"string"==typeof e):[],activeSessionId:J2(r.activeSessionId),selectedMachineId:J2(r.selectedMachineId),selectedShellId:J2(r.selectedShellId),autoStart:"boolean"==typeof r.autoStart?r.autoStart:void 0,aiControlledSessionIds:Array.isArray(r.aiControlledSessionIds)?r.aiControlledSessionIds.filter(e=>"string"==typeof e):void 0}:void 0}}(n,t))}return{layoutMode:n,agentPosition:r,layoutSizes:a,panes:i,cardColumns:Array.isArray(e?.cardLayout?.columns)?e.cardLayout.columns.filter(e=>e&&"string"==typeof e.key&&Array.isArray(e.cardIds)).map(e=>({key:e.key,width:"number"==typeof e.width&&e.width>0?e.width:360,cardIds:e.cardIds.filter(e=>"string"==typeof e)})):[],cardHeights:e?.cardLayout?.heights&&"object"==typeof e.cardLayout.heights?e.cardLayout.heights:{}}}function J0(e){if(!Array.isArray(e))return;let t=e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0);return t.length?t:void 0}function J1(e){return e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0)}function J2(e){return"string"==typeof e&&e.trim()?e:void 0}function J5(e){let t=e?.id.match(/-(\d+)$/);return t?Number(t[1]):0}function J4(e){return e.reduce((e,t)=>Math.max(e,J5(t)),0)}function J3({conversation:e,clipboardItems:t,clipboardDraggingId:n,onClipboardItemsChange:r,onClipboardDraggingChange:a,onOverlayOpenChange:i,onConversationCreated:o,onCancelDraft:l,subagentStack:s=[],onSubagentStackChange:c,subagentTree:d=[],mobileView:u="conversation",onMobilePaneCountChange:f}){let h=sb(),m=ew.useRef(null),p=ew.useRef(void 0),g=JQ(e?.panes),[v,x]=ew.useState(g.layoutMode),[y,b]=ew.useState(g.agentPosition),w=function(){let[e,t]=ew.useState(JW);return ew.useEffect(()=>{t(Jq());let e=()=>t(Jq());return window.addEventListener(JU,e),window.addEventListener("storage",e),()=>{window.removeEventListener(JU,e),window.removeEventListener("storage",e)}},[]),e}(),j="card"===w.mode,[k,S]=ew.useState(!1),[N,C]=ew.useState(!1);ew.useEffect(()=>{try{C("1"===window.localStorage.getItem("vtl:agent-panes-collapsed"))}catch{}},[]);let M=ew.useCallback(()=>{C(e=>{let t=!e;try{window.localStorage.setItem("vtl:agent-panes-collapsed",t?"1":"0")}catch{}return t})},[]),[E,O]=ew.useState(g.layoutSizes),[P,A]=ew.useState(()=>g.panes),[I,z]=ew.useState(()=>g.cardColumns),[T,D]=ew.useState(()=>g.cardHeights),[R,_]=ew.useState(()=>e?.events??[]),[L,$]=ew.useState(()=>e?.eventsStart??0),[F,B]=ew.useState(()=>e?.eventsTotal??e?.events?.length??0),[V,H]=ew.useState(!1),U=L>0,[W,q]=ew.useState(null),[K,G]=ew.useState(new Set),[X,Y]=ew.useState(void 0),[Z,J]=ew.useState(()=>H8(e?.conversation.id)),Q=ew.useCallback(t=>{J(t),function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(H6(e));window.localStorage.setItem(H6(e),t.slice(0,1e5))}catch{}}(e?.conversation.id,t)},[e?.conversation.id]),[ee,et]=ew.useState(()=>H9(e?.conversation.id)),[en,er]=ew.useState([]),[ea,ei]=ew.useState(void 0),[eo,el]=ew.useState(!1),[es,ec]=ew.useState(!1),[ed,eu]=ew.useState(""),[ef,eh]=ew.useState(e?.conversation.status==="working"),[em,ep]=ew.useState(e?.conversation.status??"idle"),[eg,ev]=ew.useState(e?.conversation.settings?.permissionMode??"acceptEdits"),[ex,eb]=ew.useState([]),[ej,ek]=ew.useState(e?.conversation.tokens??0),[eS,eN]=ew.useState(e?.conversation.runUsage),[eC,eM]=ew.useState(e?.conversation.contextTokens??0),[eE,eO]=ew.useState(!1),eP=ew.useRef(em),[ez,eT]=ew.useState(),[e_,eL]=ew.useState(),[e$,eF]=ew.useState(),eB=ew.useRef(J4(g.panes)),eV=ew.useRef(0),eH=ew.useRef(""),eU=JP.find(e=>e.id===v)?.slots??4,eW=e?.conversation.settings.folders??JX,{models:eq}=vq(),eK=ew.useMemo(()=>{let t=e?.conversation.settings.mainModels??[];return t.length?eq.filter(e=>t.includes(e.value)).map(e=>({id:e.value,label:e.label})):[]},[eq,e?.conversation.settings.mainModels]),eG=ja(e?.conversation.settings.engine),eX=ew.useMemo(()=>{if(eG){let t,n=e?.conversation.settings.ccModel;return[{id:n&&""!==n?n:"__cc_model__",label:(t=n&&""!==n?n:jn,jr.find(e=>e.value===t)?.label??n??""),disabled:!0}]}return eK},[eG,e?.conversation.settings.ccModel,eK]),eY=!eG&&0===eK.length,[eZ,eJ]=ew.useState(!1),eQ=ef||"working"===em||eZ,e0=ew.useCallback(async t=>{if(!e||eE)return;let n=e.conversation.id,r=e.conversation.ownerMachineId;if(eG){if(eQ)return void await s2(n,"请执行 /compact 压缩上下文。",r);eh(!0),ep("working");try{let e=await sG(n,{message:"/compact",modelRef:"",mode:"agent"},r);ep(e.conversation.status)}catch(e){eh(!1),ep("idle"),h$.error(e instanceof Error?e.message:"压缩请求失败")}return}if(eQ)return void await s2(n,"precise"===t?"请在完成当前小任务后进行精确压缩(去除冗余文件读取和旧工具输出)。":"请在完成当前小任务后进行极致压缩(AI摘要),以便继续工作。",r);eO(!0);try{await s5(n,t,void 0,r);let e=await sA(n,r);e&&(_(e.events),$(e.eventsStart??0),B(e.eventsTotal??e.events.length),ek(e.conversation.tokens??0),eN(e.conversation.runUsage),eM(e.conversation.contextTokens??0))}catch{}finally{eO(!1)}},[e,eE,eQ,eG]),e1=ew.useMemo(()=>{if(!e)return;let t=eq.find(e=>e.value===ed),n=t?.contextLength||200,r=e.conversation.contextTokens??0,a=r>0?r:eC,i=a>0?a:ej;return{used:i,total:1e3*n,toolCalls:i,userMessages:0,other:void 0,onCompressPrecise:()=>e0("precise"),onCompressExtreme:()=>e0("extreme"),compressing:eE}},[e,eq,ed,ej,eC,e0,eE]),e2=ew.useMemo(()=>{let t=e?.conversation.rounds;if(t?.length)return t;let n=[];for(let e of R){if("user"!==e.kind)continue;let t=n.length,r=(e.title??"").replace(/\s+/g," ").trim(),a=(r?r.slice(0,28):"")||`第 ${t+1} 轮`;n.push({runId:e.id,index:t,anchorEventId:e.id,title:a,summary:a,createdAt:""})}return n},[e?.conversation.rounds,R]),e5=ew.useCallback(async t=>{let n=e?.conversation.id,r=t.anchorEventId??R.find(e=>e.id.startsWith(`${t.runId}-`))?.id??R.find(e=>e.id===t.runId)?.id;if(r){if(R.some(e=>e.id===r))return void m.current?.scrollToEvent(r);if(n&&L>0)try{let t=await sI(n,{fromEventId:r,end:L},e?.conversation.ownerMachineId);t.events.length>0&&(_(e=>JJ(t.events,e)),$(t.start),t.total>0&&B(t.total))}catch{}window.setTimeout(()=>{m.current?.scrollToEvent(r)},60)}},[e?.conversation.id,e?.conversation.ownerMachineId,R,L]),e4=ew.useCallback(t=>{let n;if(t&&function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(Ue(e));window.localStorage.setItem(Ue(e),t)}catch{}}(e?.conversation.id,t),!t)return void Y(void 0);let r=R.findIndex(e=>e.id===t);if(r>=0)for(let e of e2){let t=e.anchorEventId??e.runId,a=R.findIndex(e=>e.id===t);a>=0&&a<=r&&(n=e.runId)}n||(n=e2.find(e=>t===e.runId||t.startsWith(`${e.runId}-`))?.runId),Y(n)},[e?.conversation.id,R,e2]),e3=ew.useCallback(async e=>{if("file-tab-viewer"!==e.kind||e.modified||e.file?.readOnly)return e;try{var t,n;let r=await u9(e);return(t=e,n=r,t.defaultValue!==n.defaultValue||t.title!==n.title||t.file?.size!==n.file?.size||t.file?.mimeType!==n.file?.mimeType||t.file?.previewContent!==n.file?.previewContent||t.file?.src!==n.file?.src||t.file?.truncated!==n.file?.truncated)?r:e}catch{return e}},[]),e6=ew.useCallback(async e=>{if(!e||!jC(e))return e;if("multi-tab-system"===e.kind){var t,n;let r=e.tabs??[],a=await Promise.all(r.map(e3));return(t=r,n=a,t.length!==n.length||t.some((e,t)=>e!==n[t]))?{...e,tabs:a}:e}if("file-tab-viewer"===e.kind&&e.tab){let t=await e3(e.tab);return t!==e.tab?{...e,title:t.title,tab:t}:e}return e},[e3]),e8=ew.useCallback(async()=>{var e,t;let n=await Promise.all(P.map(async e=>e6(e)));e=P,t=n,(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&A(n)},[P,e6]);ew.useEffect(()=>{i?.(void 0!==ez||void 0!==e_||void 0!==e$)},[e_,e$,i,ez]);let e7=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.events??[];if(e7.current!==t){e7.current=t,_(n),$(e?.eventsStart??0),B(e?.eventsTotal??n.length);return}_(e=>JZ(e,n))},[e?.conversation.id,e?.events]);let e9=ew.useCallback(async()=>{let t=e?.conversation.id;if(t&&!(L<=0)&&!V){H(!0);try{let n=await sI(t,{end:L,limit:200},e?.conversation.ownerMachineId);n.events.length>0&&_(e=>JJ(n.events,e)),$(e=>n.events.length>0?n.start:Math.max(0,e-200)),n.total>0&&B(n.total)}finally{H(!1)}}},[e?.conversation.id,e?.conversation.ownerMachineId,L,V]);function te(e){if(!e.length)return;let t=e.map(jE);r(e=>[...t,...e.filter(e=>!t.some(t=>t.id===e.id))])}function tt(e,t,n){if(!e||!jC(e))return e;if("multi-tab-system"===e.kind){var r;let a,i;return{...e,tabs:(r=e.tabs??[],a=r.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}return"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e}function tn(e,t){return e&&jC(e)?"multi-tab-system"===e.kind?{...e,tabs:(e.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}:"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e:e}function tr(e){A(t=>{let n=t.findIndex(e=>void 0===e);return n>=0?t.map((t,r)=>r===n?e:t):[...t,e]})}function ta(e){eB.current+=1;let t=jN(e,`${e}-${eB.current}`);if("browser-tab-viewer"===e&&t.tab){let e=t.tab;eR().then(n=>{tr(n.length>0?{...t,tab:{...e,defaultUrl:n[0]}}:t)});return}tr(t)}ew.useEffect(()=>{let t=e?.conversation.id;if(!t||0===R.length||p.current===t)return;p.current=t;let n=function(e){if(e)try{return window.localStorage.getItem(Ue(e))??void 0}catch{return}}(t),r=R[R.length-1]?.id;if(!n||n===r||!R.some(e=>e.id===n))return;let a=window.setTimeout(()=>{m.current?.scrollToEvent(n)},80);return()=>window.clearTimeout(a)},[e?.conversation.id,R.length]),ew.useEffect(()=>{J(H8(e?.conversation.id)),et(H9(e?.conversation.id)),er([]),ei(void 0),G(new Set)},[e?.conversation.id]),ew.useEffect(()=>{eh(e?.conversation.status==="working"),ep(e?.conversation.status??"idle")},[e?.conversation.id,e?.conversation.status]),ew.useEffect(()=>{ek(e?.conversation.tokens??0),eN(e?.conversation.runUsage),eM(e?.conversation.contextTokens??0)},[e?.conversation.id,e?.conversation.tokens,e?.conversation.runUsage,e?.conversation.contextTokens]),ew.useEffect(()=>{ev(e?.conversation.settings?.permissionMode??"acceptEdits")},[e?.conversation.id,e?.conversation.settings?.permissionMode]),ew.useEffect(()=>{let e=eK[0]?.id??"";eu(t=>eK.some(e=>e.id===t)?t:e)},[eK]),ew.useEffect(()=>{let t=JQ(e?.panes);x(t.layoutMode),b(t.agentPosition),O(t.layoutSizes),A(t.panes),z(t.cardColumns),D(t.cardHeights),eB.current=J4(t.panes)},[e?.conversation.id,e?.panes]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n)return;let a=!1,i=e=>{_(t=>JZ(t,e.events)),ep(e.conversation.status),ek(e.conversation.tokens??0),eN(e.conversation.runUsage)},o=e=>{void 0===t&&(t=window.setInterval(async()=>{try{let e=await sA(n,r);if(a)return;i(e),eh("working"===e.conversation.status)}catch{return}},e))};if(r&&"local"!==r)return o(600),()=>{a=!0,void 0!==t&&window.clearInterval(t)};let l=e?.conversation.lastSeq??0,s=new EventSource(eD(`/api/local/agent/conversations/${encodeURIComponent(n)}/events/stream?after=${l}`));return s.addEventListener("detail",e=>{try{let t=s4(JSON.parse(e.data));i(t),eh("working"===t.conversation.status)}catch{return}}),s.onerror=()=>{s.close(),o(350)},()=>{a=!0,s.close(),void 0!==t&&window.clearInterval(t)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{if(!e?.conversation.id)return;let t=window.setInterval(()=>{e8()},3e3);return()=>window.clearInterval(t)},[e?.conversation.id,e8]),ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t)return;let r=!1;sV(t,n);let a=window.setInterval(()=>{r||sV(t,n)},3e4);return()=>{r=!0,window.clearInterval(a),sH(t,n)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{let e=R.filter(e=>"change"===e.kind).map(e=>`${e.id}:${e.status??""}:${e.isStreaming?"1":"0"}`).join("|");e&&e!==eH.current&&(eH.current=e,window.dispatchEvent(new CustomEvent(JY)),e8())},[R,e8]),ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return;let n=window.setTimeout(()=>{var n;let r;sK(t,(n={columns:I,heights:T},r=[],P.forEach((e,t)=>{if(e){if(jC(e))return void r.push({paneId:e.id,slot:t,kind:e.kind,machineId:e.terminal?.selectedMachineId,resourceId:e.terminal?.activeSessionId,props:{title:e.title,tab:e.tab,tabs:e.tabs,activeTabId:e.activeTabId,terminal:e.terminal}});r.push({paneId:e.id,slot:t,kind:e.kind,props:{title:e.title,subagentId:e.subagentId,events:e.events}})}}),{layoutMode:v,agentPosition:y,sizes:E,cardLayout:n,panes:r}),e?.conversation.ownerMachineId)},300);return()=>window.clearTimeout(n)},[y,I,T,e?.conversation.id,v,E,P]);let ti=ew.useCallback(e=>{A(t=>{let n=t.findIndex(e=>e?.kind==="browser-tab-viewer");if(n>=0){let r=t[n];return r&&jC(r)&&r.tab&&(!r.tab.defaultUrl||r.tab.defaultUrl.startsWith("https://vantaloom.local"))?t.map((t,a)=>a===n&&r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:t):t}eB.current+=1;let r=jN("browser-tab-viewer",`browser-tab-viewer-${eB.current}`),a=void 0!==r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:r,i=t.findIndex(e=>void 0===e);return i>=0?t.map((e,t)=>t===i?a:e):j?[...t,a]:t})},[j]),to=ew.useRef(!1);function tl(e){A(t=>{if(t.findIndex(t=>t?.kind===e)>=0)return t;eB.current+=1;let n=jN(e,`${e}-${eB.current}`),r=t.findIndex(e=>void 0===e);return r>=0?t.map((e,t)=>t===r?n:e):j?[...t,n]:t})}ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t||n&&"local"!==n)return;to.current=!1;let r=!1,a=async()=>{if(!r&&!to.current)try{let e=(await eR())[0];if(r||to.current||!e)return;to.current=!0,ti(e)}catch{}};a();let i=window.setInterval(a,3e3);return()=>{r=!0,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId,ti]);let ts=ew.useCallback(()=>{tl("plan-doc-viewer")},[j]),tc=ew.useCallback(()=>{tl("spec-doc-viewer")},[j]);ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return void q(null);let n=e?.conversation.ownerMachineId,r=!0,a=async()=>{let e=await sD(t,n);r&&q(e.planState)};a();let i=window.setInterval(a,1500);return()=>{r=!1,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId]);let tf=e?.conversation.planState??W,th=ew.useRef(void 0);function tm(e,t){A(n=>{let r=n.findIndex(t=>t?.kind===e);if(r>=0)return n.map((n,a)=>a===r&&n?{id:n.id,kind:e,title:t.title,tab:t}:n);eB.current+=1;let a={id:`${e}-${eB.current}`,kind:e,title:t.title,tab:t},i=n.findIndex(e=>void 0===e);return i>=0?n.map((e,t)=>t===i?a:e):[...n,a]})}async function tp(e,t,n){try{let r=await u8(e);if(j)return void tm("file-tab-viewer",r);A(e=>e.map((e,a)=>a===t?tt(e,r,n):e))}catch{h$.error("文件预览打开失败")}}function tg(e){if(j)return void tp(e,-1);let t=P.slice(0,eU).findIndex(e=>e?.kind==="multi-tab-system");t<0?h$.warning("请先放入一个多标签页组件"):tp(e,t)}function tv(e){let t=e.path?.trim()||e.name.trim();("diff"===e.kind||"diff"===e.meta)&&e.diff?function(e){let t=e.path?.trim()||e.name.trim(),n={id:function(e,t){let n=0x811c9dc5;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e}-${(n>>>0).toString(36)}`}("diff",`${e.mutationId??""}|${e.machineId??"local"}|${t}|${e.diff??""}`),kind:"diff-tab-viewer",title:`Diff ${e.name}`,file:{name:e.name,path:t,machineId:e.machineId??"local",kind:"code"},diff:e.diff};if(j)return tm("diff-tab-viewer",n);let r=P.slice(0,eU).findIndex(e=>e?.kind==="multi-tab-system");r<0?h$.warning("请先放入一个多标签页组件"):A(e=>e.map((e,t)=>t===r?tt(e,n):e))}(e):!t||e.meta?.toLowerCase().startsWith("depth")||tg({machineId:e.machineId??"local",path:t})}ew.useEffect(()=>{let e=tf?.approvals?.find(e=>!e.decision);e&&th.current!==e.id&&(th.current=e.id,ts())},[tf,ts]);let tx=e?.conversation.ownerMachineId??"local",ty=ew.useMemo(()=>{let e=e=>/^https?:\/\//i.test(e)||e.startsWith("data:"),t=async e=>{let{target:t,kind:n,label:r}=e;try{if("url"===n)return void window.open(t,"_blank","noopener,noreferrer");if("local-file"===n){let e=await fetch(eD(`/v1/files/reveal?path=${encodeURIComponent(t)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}return}let e=await uG(tx,t);if("utf-8"===e.encoding&&"folder"!==e.kind&&!e.truncated)return void tg({machineId:tx,path:t});let a=eD(`/v1/remote/${encodeURIComponent(tx)}/files/raw?path=${encodeURIComponent(t)}`);await mq({url:a,label:r}),h$.success(`已开始下载「${r}」,可在 系统设置 → 下载 查看进度`)}catch(e){h$.error(`打开交付物失败:${e instanceof Error?e.message:String(e)}`)}};return{resolveImageSrc:t=>{if(e(t))return t;let n=`path=${encodeURIComponent(t)}`;return"local"===tx?eD(`/v1/files/raw?${n}`):eD(`/v1/remote/${encodeURIComponent(tx)}/files/raw?${n}`)},classify:t=>e(t)?"url":"local"===tx?"local-file":"remote-file",onOpen:e=>void t(e)}},[tx]);async function tb(e,t,n){let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw h$.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uX({machineId:a,path:r,content:n}),o={...await u7(i,{id:t.id,title:t.title,defaultView:t.defaultView,defaultMode:t.defaultMode}),modified:!1};A(t=>t.map((t,n)=>n===e?tn(t,o):t)),window.dispatchEvent(new CustomEvent(JY)),h$.success("文件已保存")}catch(e){throw h$.error("文件保存失败"),e}}async function tw(t){let n=e?.conversation.id,r=e$?.tab.file?.path,a=e$?.tab.file?.machineId??"local";if(e$&&n&&r)try{let i=await sQ(n,{machineId:a,path:r,mutationId:t.mutationId,state:t.state},e?.conversation.ownerMachineId),o=await u7(i,{id:e$.tab.id,title:`${i.name} @ ${J8(t.mutationId)} ${"before"===t.state?"before":"after"}`,readOnly:!0,defaultView:e$.tab.defaultView,defaultMode:"review"});A(e=>e.map((e,t)=>t===e$.paneIndex?tn(e,o):e)),eF(void 0)}catch{h$.error("历史版本打开失败")}}function tj(e,t,n){let i=P[e];eB.current=Math.max(eB.current,J5(n)),A(t=>t.map((t,r)=>r===e?n:t)),r(e=>{let n=e.filter(e=>e.id!==t.id);if(!i)return n;let r=jE(i);return[r,...n.filter(e=>e.id!==r.id)]}),a?.(void 0)}function tk(e,t){A(n=>n.map((n,r)=>r===e?t:n))}function tS(t){return{id:t.id,ownerMachineId:t.ownerMachineId??e?.conversation.ownerMachineId,name:t.name,subagentType:t.subagentType}}function tN(e){var t=P[e];if(t&&jC(t)&&"terminal-tab-group"===t.kind)for(let e of t.terminal?.sessionIds??[])ff(e).catch(()=>{});A(t=>t.map((t,n)=>n===e?void 0:t))}function tC(e){let t=P[e];t&&te([t]),A(t=>t.map((t,n)=>n===e?void 0:t))}async function tM(t,n="chat",r=[]){let a=e?.conversation.id,i=eG?"":ed||eK[0]?.id||"";if(!a||(t.trim()&&et(function(e,t){let n=t.trim();if(!n)return H9(e);let r=n.slice(0,1e5),a=H9(e);if(a[a.length-1]===r)return a;let i=[...a,r].slice(-100);if(e&&1)try{window.localStorage.setItem(H7(e),JSON.stringify(i))}catch{}return i}(a,t)),ef||"working"===em))return;if(!eG&&!i)return void h$.error("请先在代理模型配置里选择模型");G(function e(t,n=new Set){for(let r of t)n.add(r.id),e(r.children??[],n);return n}(d));let o=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?""!==e.data:(e.text??"")!=="");eh(!0),ep("working");try{let r=await sG(a,{message:t,modelRef:i,mode:n,attachments:o.length>0?o:void 0},e?.conversation.ownerMachineId);ep(r.conversation.status)}catch(e){eh(!1),ep("idle"),h$.error(e instanceof Error?e.message:"对话请求失败")}}async function tE(t){let n=e?.conversation.id,r="string"==typeof t.modelRef?t.modelRef.trim():"",a=eG?"":r||ed||eK[0]?.id||"",i="agent"===t.mode?"agent":"chat";if(n){if(!eG&&!a)return void h$.error("请先在代理模型配置里选择模型");eh(!0),ep("working"),_(e=>e.map(e=>e.id===t.id?{...e,status:"retried"}:e));try{let r=await sX(n,{modelRef:a,mode:i,retryEventId:t.id},e?.conversation.ownerMachineId);ep(r.conversation.status)}catch(e){_(e=>e.map(e=>e.id===t.id?t:e)),eh(!1),ep("idle"),h$.error(e instanceof Error?e.message:"对话重试失败")}}}function tO(e){eQ?h$.error("对话正在运行,请先停止后再回退"):ei(e)}async function tP(){let t=e?.conversation.id;if(!ea||!t)return void ei(void 0);el(!0);try{let n=await sY(t,ea.id,e?.conversation.ownerMachineId);_(n.detail.events),$(0),B(n.detail.events.length),ep(n.detail.conversation.status),eh(!1),Q(n.prompt),c?.([]);let r=[];n.revertedFiles>0&&r.push(`恢复 ${n.revertedFiles} 个文件`),n.deletedFiles>0&&r.push(`删除 ${n.deletedFiles} 个新增文件`),n.archivedSubagents>0&&r.push(`归档 ${n.archivedSubagents} 个子代理`),h$.success(r.length?`已回退:${r.join(",")}`:"已回退到此处"),n.skippedRemote&&n.skippedRemote.length>0&&h$.warning(`${n.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){h$.error(e instanceof Error?e.message:"回退失败")}finally{el(!1),ei(void 0)}}async function tA(t){let n=e?.conversation.id;if(n&&!es){ec(!0);try{let r=await sZ(n,t.id,e?.conversation.ownerMachineId);o?.(r),h$.success("已创建分支对话")}catch(e){h$.error(e instanceof Error?e.message:"创建分支失败")}finally{ec(!1)}}}async function tI(t){let n=e?.conversation.id;if(n)try{let r=e?.conversation.settings??{};await sW(n,{settings:{...r,...t}},e?.conversation.ownerMachineId)}catch(e){h$.error(e instanceof Error?e.message:"设置更新失败")}}async function tz(t,n){let r=e?.conversation.id;if(r)try{await s0(r,t,n,void 0,e?.conversation.ownerMachineId)}catch(e){h$.error(e instanceof Error?e.message:"审批操作失败")}}async function tT(){let t=e?.conversation.id;if(t){eJ(!0);try{await s1(t,e?.conversation.ownerMachineId)}catch{}}}function tD(){tM("继续","agent")}async function tR(t){let n=e?.conversation.id;if(!n)return;let r=ex.find(e=>e.id===t);if(!r)return;let a="string"==typeof r.content?r.content:String(r.content??"");if(a.trim()){eb(e=>e.filter(e=>e.id!==t));try{await s2(n,a.trim(),e?.conversation.ownerMachineId)}catch{}}}ew.useEffect(()=>{"idle"===em&&eZ&&eJ(!1)},[em,eZ]),ew.useEffect(()=>{let e=eP.current;if(eP.current=em,"working"===e&&"idle"===em&&ex.length>0){let e=ex[0];if(e){eb(ex.slice(1));let t="string"==typeof e.content?e.content:String(e.content??"");t.trim()&&tM(t.trim(),"agent")}}},[em]);let t_=Array.from({length:eU},(r,a)=>(0,ey.jsx)(JD,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,index:a,content:P[a],clipboardItems:t,clipboardDraggingId:n,onAdd:()=>eT(a),onPanelDrop:tj,onContentChange:tk,onClear:tN,onCut:tC,workspaceFolders:eW,onRequestFileTab:(e,t)=>eL({paneIndex:e,insertIndex:t}),onOpenWorkspaceFile:tg,onSaveFileTab:tb,onOpenFileHistory:(e,t)=>eF({paneIndex:e,tab:t})},a)),tL=P.slice(0,eU).some(e=>e?.kind==="subagent-conversation-panel"),t$=E.shell?.agent??42,tF=E.shell?.panes??58,tB=w.agentSide,tV="control-room"===w.mode||k,tH=(0,ey.jsxs)(mB,{type:"single",value:tV?"hidden":tB,variant:"outline",size:"sm","data-tour":"control-room-toggle","aria-label":"Agent 面板位置",onValueChange:e=>{"left"===e||"right"===e?(S(!1),b(e),JK({mode:j?"card":"pane",agentSide:e})):"hidden"===e&&(S(!0),JK({mode:"control-room"}))},children:[(0,ey.jsx)(mV,{value:"left","aria-label":"Agent 在左",title:"Agent 在左",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s8,{})}),(0,ey.jsx)(mV,{value:"hidden","aria-label":"隐藏面板,居中对话",title:"隐藏面板,居中对话",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(ct,{})}),(0,ey.jsx)(mV,{value:"right","aria-label":"Agent 在右",title:"Agent 在右",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s9,{})})]}),tU=(0,ey.jsxs)("div",{className:"relative flex size-full min-h-0 min-w-0 flex-col",children:[e?(0,ey.jsx)(Hj,{ownerMachineId:e.conversation.ownerMachineId,title:e.conversation.title,className:"pr-12"}):null,e?(0,ey.jsx)("div",{className:"pointer-events-none absolute left-1 top-9 z-30 flex justify-start pt-1.5",children:(0,ey.jsx)("div",{className:"pointer-events-auto",children:(0,ey.jsx)(Hk,{rounds:e2,onJumpToRound:e5,activeRunId:X})})}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1 pl-10",children:(0,ey.jsx)(Hb,{ref:m,events:e?R:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e9:void 0,models:e?eX:void 0,modelId:eG?eX[0]?.id:ed,permissionModeId:eg,onPermissionModeChange:t=>{ev(t),e?.conversation.id&&tI({permissionMode:t})},running:eQ,disabled:!!e&&eY,onModelChange:eu,onSubmit:e?e=>{tM(e.value,"agent",e.attachments??[])}:void 0,onStop:tT,onOpenFile:tv,deliverable:ty,onOpenSubagent:function(e){e.id&&c?.([tS(e)])},onOpenPlan:ts,onOpenSpec:()=>tc(),planPromptBar:e?(0,ey.jsx)(H1,{conversationId:e.conversation.id,ownerMachineId:e.conversation.ownerMachineId,planState:tf,onOpenPlan:ts,onFocusComposer:()=>{document.querySelector('[data-slot="agent-input-composer"] textarea')?.focus()},onResolved:()=>{let t=e?.conversation.id;t&&sD(t,e?.conversation.ownerMachineId).then(e=>q(e.planState))}}):void 0,onRetry:tE,onApprovalDecision:tz,onContinue:tD,onRecallUserMessage:tO,onBranchAssistantMessage:tA,onActiveEventChange:e4,composerValue:Z,onComposerValueChange:Q,promptHistory:ee,attachments:en,onAttachmentsChange:er,queuedMessages:ex,onQueuedMessagesChange:eb,onNudge:tR,contextUsage:e1})}),s.length>0&&e?(0,ey.jsx)(JG,{stack:s,rootTitle:e.conversation.title,rootOwnerMachineId:e.conversation.ownerMachineId,onNavigateRoot:()=>c?.([]),onNavigateIndex:e=>c?.(s.slice(0,e+1)),onOpenSubagent:function(e){e.id&&c?.([...s,tS(e)])}}):null]}),tW=(0,ey.jsx)(hk,{id:"agent",defaultSize:t$,minSize:28,children:tU},"agent-conversation"),tq=(0,ey.jsx)(hk,{id:"panes",defaultSize:tF,minSize:32,children:(0,ey.jsxs)("section",{className:"vtl-agent-workspace-panel flex size-full min-h-0 min-w-0 flex-col bg-transparent","data-has-conversation-pane":tL?"true":void 0,children:[(0,ey.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-3","data-tour":"pane-toolbar",children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)(md,{value:v,onValueChange:e=>{let t,n;return t=JP.find(t=>t.id===e)?.slots??4,void((n=P.slice(t).filter(e=>!!e)).length&&te(n),A(Array.from({length:Math.max(4,t)},(e,n)=>n<t?P[n]:void 0)),x(e))},children:(0,ey.jsx)(my,{children:JP.map(e=>(0,ey.jsx)(mb,{value:e.id,"aria-label":e.label,title:e.label,className:"h-7 w-10 px-0 [&_svg]:size-4",children:e.icon},e.id))})}),tH,(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"剪切窗口内容",title:"拖拽到窗口以剪切到剪切板",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(JE,"cut")},children:(0,ey.jsx)(l0,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"粉碎窗口内容",title:"拖拽到窗口以清空",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(JM,"clear")},children:(0,ey.jsx)(cn,{})})]})}),(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:(0,ey.jsx)(JT,{mode:v,sizes:E,onSizeGroupChange:function(e,t){let n=J1(t);O(t=>{var r;return(r=t[e],(r?.length??0)===(n?.length??0)&&(r??[]).every((e,t)=>.01>Math.abs(e-(n?.[t]??0))))?t:{...t,[e]:n}})},children:t_},`${e?.conversation.id??"empty"}-${v}`)})]})},"agent-panes"),tK=(0,ey.jsx)(JB,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,panes:P,agentSide:tB,columns:I,heights:T,onColumnsChange:z,onHeightsChange:D,onAddCard:ta,onContentChange:tk,onClear:tN,workspaceFolders:eW,onOpenWorkspaceFile:tg,onSaveFileTab:tb,onOpenFileHistory:(e,t)=>eF({paneIndex:e,tab:t}),onRequestFileTab:(e,t)=>eL({paneIndex:e,insertIndex:t})}),tG=(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-y-0 z-30 flex w-9 items-center","left"===tB?"right-0 justify-end pr-1":"left-0 justify-start pl-1"),children:(0,ey.jsx)("button",{type:"button",onClick:M,"aria-label":N?"展开工作区":"收起工作区",title:N?"展开工作区":"收起工作区",className:"grid size-7 place-items-center rounded-md border bg-background/85 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/panes:opacity-100 [&_svg]:size-4",children:"left"===tB?N?(0,ey.jsx)(ce,{}):(0,ey.jsx)(s7,{}):N?(0,ey.jsx)(tu,{}):(0,ey.jsx)(td,{})})}),tX=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(JR,{open:void 0!==ez,onOpenChange:e=>{e||eT(void 0)},onAdd:function(e){if(void 0===ez)return;eB.current+=1;let t=jN(e,`${e}-${eB.current}`),n=P[ez];n&&te([n]),A(e=>e.map((e,n)=>n===ez?t:e)),eT(void 0)}}),(0,ey.jsx)(HJ,{open:void 0!==e_,folders:eW,onOpenChange:e=>{e||eL(void 0)},onSelectFile:e=>{e_&&tp(e,e_.paneIndex,e_.insertIndex),eL(void 0)}}),(0,ey.jsx)(J6,{open:void 0!==e$,conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,tab:e$?.tab,onOpenChange:e=>{e||eF(void 0)},onSelectVersion:e=>{tw(e)}}),(0,ey.jsx)(d4,{open:void 0!==ea,onOpenChange:e=>{e||eo||ei(void 0)},children:(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:"回退对话到此处?"}),(0,ey.jsx)(ug,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{disabled:eo,children:"取消"}),(0,ey.jsx)(uv,{variant:"destructive",disabled:eo,onClick:e=>{e.preventDefault(),tP()},children:eo?"回退中…":"确认回退"})]})]})})]});return e?h?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(jw,{view:u,onPaneCountChange:f,conversationPanel:(0,ey.jsx)(Hb,{flowContentClassName:"pl-10",events:e?R:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e9:void 0,models:e?eX:void 0,modelId:eG?eX[0]?.id:ed,permissionModeId:eg,onPermissionModeChange:t=>{ev(t),e?.conversation.id&&tI({permissionMode:t})},running:eQ,disabled:!!e&&eY,onModelChange:eu,onSubmit:e?e=>{tM(e.value,"agent",e.attachments??[])}:void 0,onStop:tT,onOpenFile:tv,deliverable:ty,onOpenSubagent:function(e){var t;let n=P.slice(0,eU),r=n.findIndex(e=>!e),a=n.findIndex(e=>e?.kind==="subagent-conversation-panel"),i=r>=0?r:a;if(i<0)return void h$.warning("请释放一个窗口再选中浏览");eV.current+=1;let o={id:t=`subagent-${e.id}-${eV.current}`,kind:"subagent-conversation-panel",title:e.title,subagentId:e.id,events:e.events?.length?e.events:[{id:`${t}-status`,kind:"done",title:e.detail??e.status??e.activity??e.title}]};A(e=>e.map((e,t)=>t===i?o:e))},onRetry:tE,onApprovalDecision:tz,onContinue:tD,onRecallUserMessage:tO,onBranchAssistantMessage:tA,onActiveEventChange:e4,composerValue:Z,onComposerValueChange:Q,promptHistory:ee,attachments:en,onAttachmentsChange:er,queuedMessages:ex,onQueuedMessagesChange:eb,onNudge:tR,contextUsage:e1}),paneElements:t_,panes:P,activeSlotCount:eU,onOpenPalette:eT,timeline:(0,ey.jsx)(Hk,{rounds:e2,onJumpToRound:e5,activeRunId:X})}),tX,(0,ey.jsx)(hW,{position:"top-center"})]}):(0,ey.jsxs)("div",{className:"vtl-app-background vtl-agent-conversation-workspace relative h-full min-h-0",children:[tV?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hj,{direction:"horizontal",children:tq})}),(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 basis-[58%] shrink-0 flex-col",children:[(0,ey.jsx)(hj,{direction:"horizontal",children:tW}),(0,ey.jsx)("div",{className:"absolute right-3 top-1.5 z-20",children:tH})]}),(0,ey.jsx)("div",{className:"relative min-h-0 min-w-0 flex-1",children:(0,ey.jsx)(H3,{conversationTitle:e.conversation.title,rootEvents:R,rootOwnerMachineId:e.conversation.ownerMachineId,running:eQ,subagentTree:d,baselineSubagentIds:K,activeSubagentPath:s,onSelectMain:()=>c?.([]),onSelectSubagent:e=>c?.([e])})})]}):j&&!P.some(Boolean)?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tU}),(0,ey.jsx)("div",{className:(0,eI.cn)("absolute top-2 z-20","left"===tB?"right-3":"left-3"),children:(0,ey.jsx)(JF,{onAddCard:ta,align:"left"===tB?"end":"start"})})]}):j?(0,ey.jsx)("div",{className:"flex h-full min-h-0 overflow-x-auto",children:"left"===tB?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tU}),(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tK})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tK}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tU})]})}):N?(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hj,{direction:"horizontal",children:tq})}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tU}),tG]}):(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:{agent:t$,panes:tF},onLayoutChanged:e=>{let t=e.agent??t$,n=e.panes??tF;!function(e){let t=J1(e),n=t[0],r=t[1];if(void 0===n||void 0===r)return;let a="left"===y?{agent:n,panes:r}:{agent:r,panes:n};O(e=>{let t=e.shell?.agent,n=e.shell?.panes;return .01>Math.abs((t??0)-a.agent)&&.01>Math.abs((n??0)-a.panes)?e:{...e,shell:{...e.shell,...a}}})}("left"===tB?[t,n]:[n,t])},children:["left"===tB?tW:tq,(0,ey.jsx)(hS,{withHandle:!0}),"left"===tB?tq:tW]},`${e?.conversation.id??"empty"}-${tB}`),tG]}),tX,(0,ey.jsx)(hW,{position:"top-right"})]}):(0,ey.jsx)(jg,{onCreated:e=>o?.(e),onCancel:l})}function J6({open:e,conversationId:t,ownerMachineId:n,tab:r,onOpenChange:a,onSelectVersion:i}){let[o,l]=ew.useState([]),[s,c]=ew.useState(!1),d=r?.file?.path,u=r?.file?.machineId??"local";return ew.useEffect(()=>{if(!e||!t||!d)return void l([]);let r=!1;return c(!0),sJ(t,{machineId:u,path:d},n).then(e=>{r||l(e.versions)}).catch(()=>{r||l([])}).finally(()=>{r||c(!1)}),()=>{r=!0}},[t,n,u,e,d]),(0,ey.jsx)(dC,{open:e,onOpenChange:a,children:(0,ey.jsxs)(fx,{className:"max-w-xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fb,{className:"sr-only",children:"历史版本"}),(0,ey.jsx)(fw,{className:"sr-only",children:"浏览当前文件在此 Agent 会话中的修改历史。"}),(0,ey.jsxs)("div",{className:"border-b px-4 py-3",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:r?.file?.name??r?.title??"文件"}),d?(0,ey.jsxs)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:[u,":",d]}):null]}),(0,ey.jsx)("div",{className:"max-h-[28rem] overflow-auto p-2",children:s?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"正在读取历史版本"}):0===o.length?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"还没有记录到这个文件的修改历史"}):(0,ey.jsx)("div",{className:"grid gap-1",children:o.map(e=>{var t;let n;return(0,ey.jsxs)("button",{type:"button",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted/70",onClick:()=>i(e),children:[(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsxs)("span",{className:"block truncate text-sm font-medium",children:[J8(e.mutationId)," ·"," ","before"===e.state?"修改前":"修改后"]}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:Number.isFinite(n=Date.parse(t=e.createdAt))?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(n):t})]}),(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,ey.jsxs)("b",{className:"font-medium text-emerald-600",children:["+",e.additions??0]}),(0,ey.jsxs)("b",{className:"font-medium text-rose-600",children:["-",e.deletions??0]})]})]},e.id)})})})]})})}function J8(e){return e.replace(/^mut-/,"").slice(0,16)}let J7=(0,l2.cva)("vtl-surface-card relative w-full rounded-[var(--surface-card-radius)] border px-4 py-3 text-sm [&>svg]:absolute [&>svg]:top-3.5 [&>svg]:left-4 [&>svg~*]:pl-7",{variants:{variant:{default:"border-border",muted:"border-border bg-muted/40",destructive:"border-destructive/35 bg-destructive/10 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function J9({className:e,variant:t,...n}){return(0,ey.jsx)("div",{role:"alert","data-slot":"alert",className:(0,eI.cn)(J7({variant:t}),e),...n})}function Qe({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-title",className:(0,eI.cn)("mb-1 leading-none font-medium",e),...t})}function Qt({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-description",className:(0,eI.cn)("text-muted-foreground [&_p]:leading-relaxed",e),...t})}function Qn({conversationId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState({}),[i,o]=ew.useState(!0),[l,s]=ew.useState(null),[c,d]=ew.useState(""),u=ew.useCallback(async()=>{let t=(await ji(e)).folders??[];n(t),a(Object.fromEntries(t.map(e=>[e.path,e.vantaloom])))},[e]);async function f(t){if(!l){s(t),d("");try{await jo(t,r[t]??"",e),await u()}catch(e){d(e instanceof Error?e.message:"保存失败")}finally{s(null)}}}return(ew.useEffect(()=>{(async()=>{o(!0);try{await u()}catch(e){d(e instanceof Error?e.message:"加载失败")}finally{o(!1)}})()},[u]),i)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取该对话的项目文档"}):(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"这里管理本对话工作区文件夹里的系统提示词。会自动读取各文件夹的 agent.md / claude.md 等文档;你可以选一份作为模板,或自行编写,保存后写入该文件夹的 vantaloom.md,并作为带标记的系统提示词长期注入本对话上下文。 若未设置且未检测到任何文档,则使用全局“兜底系统提示词”。"})]}),c?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"错误"}),(0,ey.jsx)(Qt,{children:c})]}):null,0===t.length?(0,ey.jsx)("p",{className:"rounded-md border border-dashed px-3 py-4 text-xs text-muted-foreground",children:"本对话还没有工作区文件夹。先在“工作区文件夹”里添加一个本机文件夹,这里就会列出它的文档。"}):t.map(e=>{let t=e.docs??[];return(0,ey.jsxs)("div",{className:"grid gap-2 rounded-md border bg-card p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",title:e.path,children:e.path}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(e.path),disabled:l===e.path,children:[(0,ey.jsx)(K3,{className:"size-4"}),l===e.path?"保存中":"保存到 vantaloom.md"]})]}),t.length>0?(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"用作模板:"}),t.map(t=>(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>a(n=>({...n,[e.path]:t.content})),children:t.name},t.name))]}):(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到 agent.md / claude.md,可直接编写。"}),(0,ey.jsx)(b3,{value:r[e.path]??"",onChange:t=>a(n=>({...n,[e.path]:t.currentTarget.value})),placeholder:"该项目的系统提示词 / 规范,将写入 vantaloom.md",rows:8,className:"resize-y font-mono text-xs"})]},e.path)})]})}let Qr=[{id:"models",label:"模型"},{id:"tools",label:"工具权限"},{id:"commands",label:"禁止命令"},{id:"folders",label:"工作区文件夹"},{id:"system-prompt",label:"系统提示词"},{id:"hosts",label:"可访问主机"}];function Qa({conversation:e,mainModels:t,ccModel:n="",sessionSettings:r,onMainModelsChange:a,onCcModelChange:i,onSessionSettingsChange:o,onClose:l,onEnterConversation:s}){let[c,d]=ew.useState("models"),u=ja(e.settings.engine);return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:l,className:"shrink-0",children:(0,ey.jsx)(fg.XIcon,{className:"size-5"})}),(0,ey.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:()=>s?.(e),children:[(0,ey.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,ey.jsx)("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b px-3 py-2 vtl-scrollbar-hidden",children:Qr.filter(e=>"system-prompt"!==e.id||!u).map(e=>(0,ey.jsx)("button",{type:"button",onClick:()=>d(e.id),className:(0,eI.cn)("shrink-0 rounded-lg px-3 py-1.5 text-[13px] transition-colors",c===e.id?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:e.label},e.id))}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4 pb-[max(1.25rem,env(safe-area-inset-bottom))]",children:(0,ey.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:["models"===c?(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"运行引擎"}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:function(e){switch(e){case"claude-code":return"Claude Code";case"reclaude":return"reclaude";default:return"Vantaloom"}}(e.settings.engine)})]}),u?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("label",{htmlFor:"conversation-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,ey.jsxs)(gT,{value:""===n?jn:n,onValueChange:e=>i?.(e===jn?"":e),children:[(0,ey.jsx)(vh,{id:"conversation-cc-model",className:"w-full",children:(0,ey.jsx)(gL,{placeholder:"选择 Claude Code 模型"})}),(0,ey.jsx)(vg,{children:jr.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,ey.jsx)(vK,{conversation:e,mainModels:t,onMainModelsChange:a})]}):null,"tools"===c?(0,ey.jsx)(w5,{value:r.allowedTools,onChange:e=>o({...r,allowedTools:e,deniedTools:[]})}):null,"commands"===c?(0,ey.jsx)(w4,{value:r.blockedCommands,onChange:e=>o({...r,blockedCommands:e})}):null,"folders"===c?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)(w3,{title:"可访问的工作区文件夹",value:r.folders,onValueChange:e=>o({...r,folders:u?e.slice(-1):e})}),u?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}):null,"system-prompt"!==c||u?null:(0,ey.jsx)(Qn,{conversationId:e.id}),"hosts"===c?(0,ey.jsx)(jt,{value:r.hosts,onValueChange:e=>o({...r,hosts:e}),disabled:u,hint:u?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0}):null]})})]})}function Qi({conversationId:e,ownerMachineId:t,open:n,onOpenChange:r,onEnterConversation:a}){let[i,o]=ew.useState(),[l,s]=ew.useState([]),[c,d]=ew.useState(""),[u,f]=ew.useState({folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:[]});async function h(e){if(!i)return;let n=e.session??u,r=e.mainModels??l,a=e.ccModel??c,s={subagents:i.settings.subagents??[],mainModels:r,folders:n.folders,blockedCommands:n.blockedCommands,allowedTools:n.allowedTools,deniedTools:n.deniedTools,plugins:n.plugins,hosts:n.hosts,permissionMode:n.permissionMode??i.settings.permissionMode,engine:i.settings.engine,ccModel:i.settings.engine?a:void 0};try{let e=await sW(i.id,{settings:s},t);o(e.conversation)}catch{}}function m(){o(void 0),r(!1)}return(ew.useEffect(()=>{if(!n||!e)return;let r=!0;return async function(){try{let n=await sA(e,t);if(!r)return;let a=n.conversation;o(a),s(a.settings.mainModels),d(a.settings.ccModel??""),f({folders:a.settings.folders,blockedCommands:a.settings.blockedCommands,allowedTools:a.settings.allowedTools,deniedTools:a.settings.deniedTools,plugins:a.settings.plugins,hosts:a.settings.hosts})}catch{}}(),()=>{r=!1}},[e,n,t]),n&&i)?(0,ey.jsx)(Qa,{conversation:i,mainModels:l,ccModel:c,sessionSettings:u,onMainModelsChange:e=>{s(e),h({mainModels:e})},onCcModelChange:e=>{d(e),h({ccModel:e})},onSessionSettingsChange:e=>{f(e),h({session:e})},onClose:m,onEnterConversation:e=>{m(),a?.(e.id,t)}}):null}let Qo="local";async function Ql(e){return((await Qp(e,"")).canvases??[]).map(t=>Qm(t,e))}async function Qs(e,t){return Qh(await Qp(t,`/${encodeURIComponent(e)}`),t)}async function Qc(e,t){return Qh(await Qp(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(uU),edges:e.edges.map(uW)})}),t)}async function Qd(e,t,n){return Qh(await Qp(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(uU),edges:t.edges.map(uW),nodeIds:t.nodeIds})}),n)}async function Qu(e,t){return Qh(await Qp(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}async function Qf(){let e={[Qo]:"本机"},t=[],n=[];try{n=await Ql(void 0)}catch{n=[]}let r=[];try{let{machines:e}=await sw();r=(e??[]).filter(e=>!e.isLocal&&"online"===e.status).map(e=>({id:e.id,name:e.name}))}catch{r=[]}let a=await Promise.all(r.map(async n=>{e[n.id]=n.name;try{return await Ql(n.id)}catch{return t.push(n.id),[]}})),i=new Map;for(let e of[...n,...a.flat()]){let t=i.get(e.id);(!t||e.updatedAt>t.updatedAt)&&i.set(e.id,e)}let o=Array.from(i.values());return o.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),{canvases:o,machineNames:e,unreachable:t}}function Qh(e,t){return{canvas:Qm(e.canvas,t),nodes:e.nodes??[],edges:e.edges??[]}}function Qm(e,t){let n=t&&t!==Qo?t:e.ownerMachineId??"local";return{id:e.id,title:e.title||"新画布",ownerMachineId:n,nodeCount:e.nodeCount??0,running:e.running??!1,createdAt:e.createdAt,updatedAt:e.updatedAt,lastOpenedAt:e.lastOpenedAt}}async function Qp(e,t,n,r){let a=await fetch(eD(!e||e===Qo?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let Qg=(0,ek.default)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Qv=(0,ek.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),Qx=(0,ek.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Qy=(0,ek.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),Qb=(0,ek.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Qw=(0,ek.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),Qj={done:"Done",current:"Current",queued:"Queued",blocked:"Blocked"};function Qk(e,t,n){return Math.min(Math.max(e,t),n)}function QS({items:e,currentId:t,labels:n,scrollCurrentIntoView:r=!0,className:a,viewportClassName:i,itemClassName:o,extendLineToViewport:l=!1,...s}){let c={...Qj,...n},d=ew.useRef(null),u=ew.useRef(null),f=ew.useRef(null),h=ew.useRef(0),m=ew.useRef(void 0),[p,g]=ew.useState(0),v=t??e.find(e=>"current"===e.status)?.id,x=ew.useCallback(()=>{void 0!==m.current&&(cancelAnimationFrame(m.current),m.current=void 0)},[]),y=ew.useCallback((e,t=340)=>{let n=d.current,r=u.current;if(!n||!r)return;x();let a=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,o=Qk(e,0,a),l=performance.now();h.current=o;let s=e=>{let r=Qk((e-l)/t,0,1);if(n.scrollTop=i+(o-i)*(1-Math.pow(1-r,3)),r<1){m.current=requestAnimationFrame(s);return}n.scrollTop=o,m.current=void 0};m.current=requestAnimationFrame(s)},[x]),b=ew.useCallback(e=>{let t=d.current,n=u.current;if(!t||!n)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;e.preventDefault();let a=void 0===m.current?t.scrollTop:h.current,i=1===e.deltaMode?32*e.deltaY:2===e.deltaMode?e.deltaY*e.currentTarget.clientHeight:e.deltaY,o=Math.sign(i);if(0===o)return;let l=Array.from(n.querySelectorAll("[data-slot='roadmap-item']")).map(e=>e.offsetTop),s=Qk(Math.ceil(Math.abs(i)/160),1,3),c=a;for(let e=0;e<s;e+=1)c=function(e,t,n,r){if(0===e.length)return t;if(n>0)return e.find(e=>e>t+1)??r;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0!==r&&r<t-1)return r}return 0}(l,c,o,r);y(c)},[y]);return ew.useLayoutEffect(()=>{if(!r)return;let e=d.current,t=u.current,n=f.current;if(!e||!t||!n)return void g(0);let a=n.offsetTop,i=t.scrollHeight-p,o=Math.max(0,e.clientHeight-(i-a));g(e=>Math.abs(e-o)>.5?o:e),requestAnimationFrame(()=>{e.scrollTop=a,h.current=a})},[p,e,v,r]),ew.useEffect(()=>x,[x]),(0,ey.jsx)("div",{"data-slot":"roadmap",className:(0,eI.cn)("min-w-0 text-foreground",a),...s,children:(0,ey.jsx)("div",{"data-slot":"roadmap-viewport",ref:d,onWheel:b,className:(0,eI.cn)("max-h-72 overflow-y-auto overscroll-contain pr-2",i),children:(0,ey.jsxs)("div",{ref:u,className:(0,eI.cn)("relative",l&&"min-h-full"),children:[(0,ey.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 bottom-0 left-[0.3125rem] w-px bg-border"}),e.map(e=>{let t=e.id===v?"current":e.status??"queued";return(0,ey.jsxs)("div",{ref:"current"===t?f:void 0,"data-slot":"roadmap-item","data-status":t,"aria-label":c[t],className:(0,eI.cn)("relative grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-2 py-2.5",o),children:[(0,ey.jsx)("span",{"aria-hidden":"true","data-slot":"roadmap-marker",className:(0,eI.cn)("relative z-10 mt-1 size-2.5 rounded-full border bg-background","done"===t&&"border-muted-foreground bg-muted-foreground","current"===t&&"border-primary bg-primary","queued"===t&&"border-border","blocked"===t&&"border-destructive bg-destructive")}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{"data-slot":"roadmap-title",className:(0,eI.cn)("text-sm leading-5","queued"===t&&"text-muted-foreground","blocked"===t&&"text-destructive"),children:e.title}),e.description?(0,ey.jsx)("div",{"data-slot":"roadmap-description",className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description}):null]}),e.meta?(0,ey.jsx)("div",{"data-slot":"roadmap-meta",className:"pt-0.5 text-right ui-text-kbd text-muted-foreground",children:e.meta}):null]},e.id)}),p>0?(0,ey.jsx)("div",{"aria-hidden":"true","data-slot":"roadmap-bottom-spacer",style:{height:p}}):null]})})})}let QN="/themes/jelly/bg1.png",QC="/themes/jelly/bg2.png",QM="/themes/jelly/bg3.png",QE="/themes/jelly/bg4.png";function QO({image:e,position:t="center",opacity:n=.72,blur:r="10px"}){return{"--vtl-jelly-card-image":`url("${e}")`,"--vtl-jelly-card-position":t,"--vtl-jelly-card-opacity":String(n),"--vtl-jelly-card-blur":r}}function QP({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}let QA={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题"},QI={search:"搜索控制台...",dashboard:"仪表盘",canvas:"画布",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近画布",canvasNew:"新建画布",canvasAll:"浏览所有画布",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"};QA.local,QA.direct,QA.online,QA.p2p,QA.online,QA.direct,QA.sleeping,QA.cpu,QA.memory,QA.activeRuns;function Qz(e){return e.reduce((e,t)=>Math.max(e,t.y+t.h),0)}function QT({children:e}){return(0,ey.jsx)("section",{className:"vtl-app-background flex h-full min-h-0 flex-col pb-14 md:pb-0 text-foreground",children:(0,ey.jsx)(wz,{className:"min-h-0 flex-1",children:e})})}function QD(e){return Math.max(0,...e.map(e=>e.y+e.h))}function QR(e,t,n){return t.some(t=>t.id!==n&&e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}function Q_(e){let t=Math.max(2,Math.min(12,e.w)),n=Math.max(1,e.h),r=Math.max(0,Math.min(12-t,e.x)),a=Math.max(0,e.y);return{...e,x:r,y:a,w:t,h:n}}function QL(e,t,n,r,a){for(let i=0;i<QD(e)+8;i+=1)for(let o=0;o<=12-r;o+=1){let l={id:t,kind:n,x:o,y:i,w:r,h:a};if(!QR(l,e))return l}return{id:t,kind:n,x:0,y:QD(e)+2,w:r,h:a}}function Q$(e){return{...e.defaultConfig}}function QF(e){return e.payloads?.[GG]}function QB({open:e,definitions:t,title:n="添加卡片",description:r="搜索并选择要添加到当前页面的卡片。",groupTitle:a="可添加卡片",onOpenChange:i,onAdd:o}){return(0,ey.jsx)(xg,{open:e,onOpenChange:i,title:n,description:r,className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xp,{loop:!0,children:[(0,ey.jsx)(xv,{placeholder:"搜索可添加卡片..."}),(0,ey.jsxs)(xx,{className:"max-h-[420px]",children:[(0,ey.jsx)(xy,{children:"没有找到可添加的卡片。"}),(0,ey.jsx)(xb,{heading:a,children:t.map(e=>(0,ey.jsxs)(xw,{value:`${e.title} ${e.description}`,keywords:[e.id,e.defaultConfig.dataSource,e.defaultConfig.title],onSelect:()=>o(e.id),className:"min-h-14 items-start py-2",children:[(0,ey.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate font-medium",children:e.title}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xj,{children:[e.defaultSize.w,"x",e.defaultSize.h]})]},e.id))})]})]})})}function QV({open:e,dragMode:t,label:n="页面卡片操作",onOpenChange:r,onAdd:a,onDragModeChange:i}){let o=[{key:"add",label:"添加卡片",icon:(0,ey.jsx)(lJ,{className:"size-4"}),onClick:a,pressed:!1},{key:"drag",label:"拖拽排版",icon:(0,ey.jsx)(lq,{className:"size-4"}),onClick:()=>i(!t),pressed:t}];return(0,ey.jsx)("div",{className:"fixed right-5 bottom-5 z-30",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",t.pressed&&"border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":n,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let QH=(0,ek.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function QU({layout:e,layouts:t,cellSize:n,cellHeight:r,dragMode:a,selected:i,resizing:o,onSelect:l,onMove:s,onCut:c,onCopy:d,onSettingsOpen:u,onResizeStart:f,onResizeEnd:h,children:m}){let[p,g]=ew.useState(!1),v=r??n,x=e.x*(n+12),y=e.y*(v+12),b=e.w*n+(e.w-1)*12,w=e.h*v+(e.h-1)*12;return(0,ey.jsxs)("div",{"data-editable-card":e.id,className:(0,eI.cn)("absolute rounded-lg p-1 transition-[left,top,width,height,box-shadow] duration-200 ease-out",a&&"cursor-grab active:cursor-grabbing",p&&"duration-150",i&&!o&&"z-20 shadow-sm",o&&"z-30 transition-none"),style:{left:x,top:y,width:b,height:w},onPointerDown:function(r){if(!a||o)return;let i=r.target;if(i instanceof HTMLElement&&i.closest("[data-editable-card-action]"))return;r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),l();let c=r.clientX,d=r.clientY;function u(r){let a=Q_({...e,x:e.x+Math.round((r.clientX-c)/(n+12)),y:e.y+Math.round((r.clientY-d)/(n+12))});QR(a,t,e.id)||s(a)}g(!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",e),g(!1)})},onClick:()=>{a&&l()},children:[(0,ey.jsx)("div",{className:(0,eI.cn)("size-full",a&&"pointer-events-none"),children:m}),i&&a&&!o?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-1 rounded-lg border-2 border-foreground"}):null,i&&a&&!o?(0,ey.jsx)(QW,{onSettingsOpen:u,onCut:c,onCopy:d,onResizeStart:f}):null,o?(0,ey.jsx)(Qq,{layout:e,layouts:t,cellSize:n,onResize:s,onResizeEnd:h}):null]})}function QW({onSettingsOpen:e,onCut:t,onCopy:n,onResizeStart:r}){return(0,ey.jsx)(l4,{"data-editable-card-action":!0,placement:"inline",size:"sm","aria-label":"卡片操作",className:"!absolute top-full left-1/2 z-40 mt-2 -translate-x-1/2 rounded-lg bg-popover/95 p-1 shadow-md",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,ey.jsxs)(l3,{children:[(0,ey.jsx)(l6,{type:"button","aria-label":"调整大小",onClick:r,children:(0,ey.jsx)(lX,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"卡片设置",onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(QH,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"复制",onClick:n,children:(0,ey.jsx)(lU,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"剪切",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),t()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(l0,{className:"size-4"})})]})})}function Qq({layout:e,layouts:t,cellSize:n,onResize:r,onResizeEnd:a}){return(0,ey.jsx)("div",{"data-editable-card-action":!0,className:"pointer-events-none absolute inset-1 z-40 border-2 border-foreground",children:[{id:"top-left",className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize"},{id:"top",className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize"},{id:"top-right",className:"top-0 right-0 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize"},{id:"right",className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2 cursor-ew-resize"},{id:"bottom-right",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2 cursor-nwse-resize"},{id:"bottom",className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 cursor-ns-resize"},{id:"bottom-left",className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize"},{id:"left",className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize"}].map(i=>(0,ey.jsx)("button",{type:"button","aria-label":`调整 ${i.id}`,className:(0,eI.cn)("pointer-events-auto absolute size-2.5 border border-foreground bg-background shadow-sm",i.className),onPointerDown:o=>(function(i,o){i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);let l=i.clientX,s=i.clientY;function c(a){let i=Math.round((a.clientX-l)/(n+12)),c=Math.round((a.clientY-s)/(n+12)),d={...e};o.includes("right")&&(d.w=e.w+i),o.includes("bottom")&&(d.h=e.h+c),o.includes("left")&&(d.x=e.x+i,d.w=e.w-i),o.includes("top")&&(d.y=e.y+c,d.h=e.h-c),QR(d=Q_(d),t,e.id)||r(d)}window.addEventListener("pointermove",c),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",e),a()})})(o,i.id)},i.id))})}function QK({className:e,...t}){return(0,ey.jsx)(dT,{"data-slot":"sheet-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function QG({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,ey.jsxs)(dI,{children:[(0,ey.jsx)(QK,{}),(0,ey.jsxs)(dL,{"data-slot":"sheet-content","data-side":n,className:(0,eI.cn)("vtl-surface-modal fixed z-50 flex flex-col gap-4 border transition ease-in-out outline-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-300","right"===n&&"inset-y-0 right-0 h-full w-3/4 border-r-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm","left"===n&&"inset-y-0 left-0 h-full w-3/4 border-l-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm","top"===n&&"inset-x-0 top-0 h-auto border-t-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top","bottom"===n&&"inset-x-0 bottom-0 h-auto border-b-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),...a,children:[t,r&&(0,ey.jsxs)(dK,{className:"absolute top-3 right-3 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none",children:[(0,ey.jsx)(fg.XIcon,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function QX({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"sheet-header",className:(0,eI.cn)("grid gap-1.5 p-4 text-left",e),...t})}function QY({className:e,...t}){return(0,ey.jsx)(dH,{"data-slot":"sheet-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function QZ({className:e,...t}){return(0,ey.jsx)(dW,{"data-slot":"sheet-description",className:(0,eI.cn)("text-sm text-muted-foreground",e),...t})}function QJ({open:e,layout:t,definition:n,config:r,cellSize:a,onOpenChange:i,onConfigChange:o}){let l=t&&a>0?t.w*a+(t.w-1)*12:320,s=t&&a>0?t.h*a+(t.h-1)*12:180;return(0,ey.jsx)(dC,{open:e,onOpenChange:i,children:(0,ey.jsx)(QG,{side:"right",className:"w-screen gap-0 border-0 bg-transparent p-0 shadow-none sm:max-w-none",children:t&&n&&r?(0,ey.jsxs)("div",{className:"grid h-full min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_24rem]",children:[(0,ey.jsx)(QQ,{width:l,height:s,className:"hidden lg:grid",children:n.render(r)}),(0,ey.jsxs)("div",{className:"animate-in slide-in-from-right-4 flex h-full w-full flex-col border-y-0 border-r-0 bg-background text-foreground shadow-lg duration-300",children:[(0,ey.jsxs)(QX,{className:"border-b",children:[(0,ey.jsx)(QY,{children:"卡片设置"}),(0,ey.jsxs)(QZ,{children:[n.title," · ",t.w,"x",t.h]})]}),(0,ey.jsxs)("div",{className:"grid flex-1 content-start gap-4 overflow-y-auto p-4",children:[(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"显示标题"}),(0,ey.jsx)(ez,{value:r.title,onChange:e=>o({title:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"数据来源"}),(0,ey.jsx)(ez,{value:r.dataSource,onChange:e=>o({dataSource:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"刷新间隔"}),(0,ey.jsx)(ez,{value:r.refreshRate,onChange:e=>o({refreshRate:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"备注"}),(0,ey.jsx)("textarea",{value:r.note,rows:4,className:"min-h-24 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 ui-text-control transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",onChange:e=>o({note:e.currentTarget.value})})]}),(0,ey.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3",children:[(0,ey.jsx)("div",{className:"ui-text-control font-medium",children:"当前绑定"}),(0,ey.jsxs)("div",{className:"mt-2 grid gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["类型:",n.id]}),(0,ey.jsxs)("span",{children:["来源:",r.dataSource]}),(0,ey.jsxs)("span",{children:["刷新:",r.refreshRate]})]})]})]})]})]}):null})})}function QQ({width:e,height:t,className:n,children:r}){let[a,i]=Xz(),o=i.width>0&&i.height>0?Math.min(1,(i.width-32)/e,(i.height-32)/t):1;return(0,ey.jsx)("div",{ref:a,className:(0,eI.cn)("min-h-0 min-w-0 place-items-center overflow-hidden p-4",n),children:(0,ey.jsx)("div",{className:"animate-in fade-in-0 zoom-in-95 origin-center rounded-lg duration-300",style:{width:e,height:t,transform:`scale(${Math.max(.1,o)})`},children:r})})}function Q0({boardId:e,definitions:t,initialLayouts:n,clipboardItems:r=[],minRows:a=9,className:i,actionLabel:o,paletteGroupTitle:l,onClipboardItemsChange:s,onOverlayOpenChange:c}){var d;let[u,f]=ew.useState(!1),[h,m]=ew.useState(!1),[p,g]=ew.useState(!1),[v,x]=ew.useState(()=>n),[y,b]=ew.useState({}),[w,j]=ew.useState(),[k,S]=ew.useState(),[N,C]=ew.useState(),M=ew.useRef(0),E=ew.useRef(0),[O,P]=Xz(),A=P.width>0?(d=P.width)<480?2:d<768?4:12:12,I=function(e,t){if(t>=12)return e;let n=[...e].sort((e,t)=>e.y!==t.y?e.y-t.y:e.x-t.x),r=[];for(let e of n){let n=Math.max(2,Math.min(t,Math.round(e.w*t/12))),a=e.h,i=!1;for(let o=0;o<Qz(r)+8&&!i;o+=1)for(let l=0;l<=t-n&&!i;l+=1){let t={...e,x:l,y:o,w:n,h:a};!function(e,t){return t.some(t=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}(t,r)&&(r.push(t),i=!0)}i||r.push({...e,x:0,y:Qz(r),w:n,h:a})}return r}(v,A),z=P.width>0?(P.width-12*(A-1))/A:96,T=A<12?72:z,D=Math.max(a,QD(I)+2),R=D*T+(D-1)*12,_=ew.useMemo(()=>new Map(t.map(e=>[e.id,e])),[t]);function L(e){let t=_.get(e.kind);return y[e.id]??(t?Q$(t):void 0)}function $(e){x(t=>{let n=Q_(e);return QR(n,t,n.id)?t:t.map(e=>e.id===n.id?n:e)})}function F(e){let t=_.get(e);if(!t)return;E.current+=1;let n=`${e}-added-${E.current}`,r=QL(v,n,e,t.defaultSize.w,t.defaultSize.h);x(e=>[...e,r]),b(e=>({...e,[n]:Q$(t)})),j(n),S(void 0),m(!1)}function B(e,t){let n=v.find(t=>t.id===e),r=n?_.get(n.kind):void 0;n&&r&&b(n=>({...n,[e]:{...n[e]??Q$(r),...t}}))}ew.useEffect(()=>{c?.(h||!!N)},[h,c,N]),ew.useEffect(()=>()=>c?.(!1),[c]),ew.useEffect(()=>{p||(j(void 0),S(void 0))},[p]),ew.useEffect(()=>{if(k)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof HTMLElement&&t.closest("[data-editable-card-action]")||(j(k),S(void 0))}},[k]);let V=A<12,H=N?v.find(e=>e.id===N):void 0,U=H?_.get(H.kind):void 0,W=H?L(H):void 0;if(V){let n=[...I].sort((e,t)=>e.y-t.y||e.x-t.x),r=Object.fromEntries(v.map(e=>[e.id,e.w]));return(0,ey.jsxs)(QT,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("mx-auto max-w-7xl p-3",i),children:(0,ey.jsx)("div",{className:"grid grid-cols-2 gap-3",children:n.map(e=>{let t=_.get(e.kind);if(!t)return null;let n=L(e);if(!n)return null;let a=(r[e.id]??e.w)>6;return(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-0 overflow-hidden rounded-lg",a&&"col-span-2"),style:{minHeight:a?200:120},children:t.render(n)},e.id)})})}),(0,ey.jsx)(QV,{open:u,dragMode:!1,label:o,onOpenChange:f,onAdd:()=>{f(!1),m(!0)},onDragModeChange:g}),(0,ey.jsx)(QB,{open:h,definitions:t,groupTitle:l,onOpenChange:m,onAdd:F}),(0,ey.jsx)(QJ,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}return(0,ey.jsxs)(QT,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("relative mx-auto max-w-7xl p-4 lg:p-6",p&&"select-none",i),style:{minHeight:R+48},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(GG)&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let n=r.find(e=>e.id===t),a=n&&QF(n);if(!n||!a||!_.has(a.kind))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let i=O.current,o=i?.getBoundingClientRect();!function(e,t){let n=QF(e);if(!n||!_.has(n.kind))return;E.current+=1;let r=`${n.kind}-clip-${E.current}`,a=Q_({id:r,kind:n.kind,x:t?.x??0,y:t?.y??QD(v),w:n.w,h:n.h}),i=t&&!QR(a,v)?a:QL(v,r,n.kind,n.w,n.h);x(e=>[...e,i]),b(e=>({...e,[r]:{...n.config}})),j(r),S(void 0)}(n,{x:o&&z>0?Math.round((e.clientX-o.left-24)/(z+12)):0,y:o&&z>0?Math.round((e.clientY-o.top-24)/(z+12)):QD(v)})},onPointerDown:e=>{e.target===e.currentTarget&&(j(void 0),p||S(void 0))},children:(0,ey.jsx)("div",{className:"relative",style:{height:R},children:I.map(t=>{let n=_.get(t.kind);if(!n)return null;let r=L(t);return r?(0,ey.jsx)(QU,{layout:t,layouts:I,cellSize:z,cellHeight:T,dragMode:p,selected:w===t.id,resizing:k===t.id,onSelect:()=>{p&&j(t.id)},onMove:$,onCut:()=>(function(t){let n=v.find(e=>e.id===t),r=n?_.get(n.kind):void 0,a=n?L(n):void 0;if(!n||!r||!a)return;let i=function({boardId:e,layout:t,definition:n,config:r}){let a={boardId:e,kind:t.kind,w:t.w,h:t.h,config:{...r}};return{id:`clip-${e}-${t.id}`,title:r.title||n.title,description:n.description,meta:`${t.w}x${t.h}`,icon:n.icon,dragData:{"application/vnd.vantaloom.clip-kind":"workspace-card","application/vnd.vantaloom.workspace-card-board":e,"application/vnd.vantaloom.workspace-card-kind":t.kind,"application/vnd.vantaloom.workspace-card-width":String(t.w),"application/vnd.vantaloom.workspace-card-height":String(t.h),"application/vnd.vantaloom.workspace-card-config":JSON.stringify(r),[GG]:JSON.stringify(a)},payloads:{[GG]:a}}}({boardId:e,layout:n,definition:r,config:a});s?.(e=>[i,...e.filter(e=>e.id!==i.id)]),x(e=>e.filter(e=>e.id!==t)),b(e=>{let n={...e};return delete n[t],n}),j(void 0),S(void 0),C(e=>e===t?void 0:e)})(t.id),onCopy:()=>(function(e){let t=v.find(t=>t.id===e),n=t?_.get(t.kind):void 0;if(!t||!n)return;M.current+=1;let r=`${e}-copy-${M.current}`,a=QL(v,r,t.kind,t.w,t.h);x(e=>[...e,a]),b(t=>({...t,[r]:t[e]??Q$(n)})),j(r)})(t.id),onSettingsOpen:()=>C(t.id),onResizeStart:()=>{j(void 0),S(t.id)},onResizeEnd:()=>{j(t.id),S(void 0)},children:n.render(r)},t.id):null})})}),(0,ey.jsx)(QV,{open:u,dragMode:p,label:o,onOpenChange:f,onAdd:()=>{f(!1),m(!0)},onDragModeChange:g}),(0,ey.jsx)(QB,{open:h,definitions:t,groupTitle:l,onOpenChange:m,onAdd:F}),(0,ey.jsx)(QJ,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}function Q1({parts:e}){return(0,ey.jsx)(ey.Fragment,{children:e.map((e,t)=>(0,ey.jsx)("span",{className:e.small?"text-[0.55em]":void 0,children:e.text},`${e.text}-${t}`))})}function Q2({value:e,minSize:t=24,maxSize:n=180,className:r,...a}){let i=ew.useRef(null),o=ew.useRef(null),[l,s]=ew.useState(t),c=function(e){let t=e.trim();if(/^[$¥€]\s*\d/.test(t))return[{text:t.replace(/^[$¥€]\s*/,""),small:!1},{text:t[0]??"",small:!0}];let n=t.match(/^(.+?)\s*\/\s*(.+)$/);if(n)return[{text:n[1]??"",small:!1},{text:"/",small:!0},{text:n[2]??"",small:!1}];let r=t.match(/^(.+?)([%a-zA-Z$¥€]+)$/);return r?[{text:r[1]??t,small:!1},{text:r[2]??"",small:!0}]:[{text:t,small:!1}]}(e);return ew.useLayoutEffect(()=>{let e=i.current,r=o.current;if(!e||!r)return;function a(e,r){let a=e.clientWidth,i=e.clientHeight;if(a<=0||i<=0)return;let o=t,l=n,c=t;for(;o<=l;){let e=Math.floor((o+l)/2);r.style.fontSize=`${e}px`,r.getBoundingClientRect().width<=a&&r.getBoundingClientRect().height<=i?(c=e,o=e+1):l=e-1}s(c)}a(e,r);let l=new ResizeObserver(()=>a(e,r));return l.observe(e),()=>l.disconnect()},[n,t,e]),(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative min-h-0 min-w-0 overflow-hidden",r),...a,children:[(0,ey.jsx)("span",{ref:o,"aria-hidden":"true",className:"pointer-events-none invisible absolute right-0 bottom-0 flex items-baseline whitespace-nowrap font-semibold leading-none tracking-normal",children:(0,ey.jsx)(Q1,{parts:c})}),(0,ey.jsx)("span",{className:"absolute right-0 bottom-0 flex max-w-full items-baseline whitespace-nowrap font-semibold leading-none tracking-normal text-foreground",style:{fontSize:l},children:(0,ey.jsx)(Q1,{parts:c})})]})}function Q5(e){return/^\d+$/.test(e)&&1===e.length?`0${e}`:/^\d+(?:\.\d+)?%$/.test(e)?`${Number.parseFloat(e).toFixed(1)}%`:e}function Q4({label:e,value:t,minSize:n=42,maxSize:r=180,valueClassName:a="absolute right-0 bottom-0 h-2/3 w-full"}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)(Q2,{value:Q5(t),minSize:n,maxSize:r,className:a})]})}function Q3(e){return Math.max(0,Math.min(100,Math.round(e)))}function Q6({className:e,value:t=0,...n}){let r=Q3(t);return(0,ey.jsx)("div",{"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:(0,eI.cn)("relative h-1.5 w-full overflow-hidden rounded-full bg-muted",e),...n,children:(0,ey.jsx)("div",{"data-slot":"progress-indicator",className:"h-full rounded-full bg-primary transition-all",style:{width:`${r}%`}})})}function Q8({className:e,value:t=0,label:n,showValue:r=!0,...a}){let i=Q3(t),o=2*Math.PI*39;return(0,ey.jsxs)("div",{"data-slot":"progress-ring","aria-label":n?`${n} ${i}%`:`${i}%`,role:"img",className:(0,eI.cn)("relative grid size-24 place-items-center",e),...a,children:[(0,ey.jsxs)("svg",{"aria-hidden":"true","data-slot":"progress-ring-svg",viewBox:"0 0 100 100",className:"absolute inset-0 size-full overflow-visible",children:[(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--muted)",strokeWidth:12}),i>0&&(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--primary)",strokeDasharray:o,strokeDashoffset:o-i/100*o,strokeLinecap:"round",strokeWidth:12,className:"origin-center -rotate-90 transition-all"})]}),(0,ey.jsx)("div",{"data-slot":"progress-ring-center",className:"relative z-10 grid size-16 place-items-center rounded-full bg-card",children:r&&(0,ey.jsxs)("span",{className:"ui-text-control font-medium tabular-nums",children:[i,"%"]})})]})}(0,ek.default)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);let Q7=(0,ek.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function Q9({canvases:e,mode:t="active",scrollable:n=!1,onSelect:r}){let a=ew.useMemo(()=>e.map(e=>{var n;return{id:e.id,status:"live"===(n=e).status?"current":"review"===n.status?"blocked":"done",title:(0,ey.jsx)(eee,{canvas:e,mode:t,onClick:()=>r(e)})}}),[e,t,r]);return(0,ey.jsx)(QS,{items:a,scrollCurrentIntoView:!1,className:(0,eI.cn)("mt-2",n&&"min-h-0 flex-1"),viewportClassName:(0,eI.cn)("max-h-none pr-0",n?"h-full overflow-y-auto":"overflow-visible"),itemClassName:"py-2"})}function eee({canvas:e,onClick:t,mode:n}){return(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("grid w-full items-center gap-4 rounded-lg px-2 py-0 text-left transition-colors hover:bg-muted/50","active"===n?"grid-cols-[minmax(0,1fr)_8rem_1.75rem]":"grid-cols-[minmax(0,1fr)_7rem_7rem_8rem]"),onClick:t,children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:"active"===n?e.purpose:`${e.nodes} nodes`})]}),"active"===n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Q6,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("span",{"aria-label":e.progress>=100?"Canvas complete":"Canvas incomplete",className:(0,eI.cn)("size-2.5 rounded-full",e.progress>=100?"bg-primary":"bg-border")})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eet,{icon:(0,ey.jsx)(Vb,{}),value:`${e.snapshots}`}),(0,ey.jsx)(eet,{icon:(0,ey.jsx)(Q7,{}),value:e.runtime}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:e.lastOpened})]})]})}function eet({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}let een=(0,ek.default)("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),eer=(0,ek.default)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);(0,ek.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var eea=ew;function eei(){return(eei=Object.assign.bind()).apply(null,arguments)}function eeo(e){return ew.createElement(Dc,eei({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var eel=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(n,r)=>{if(kp(e))return e;var a=kp(n)||null==n;return a?e(n,r):(a||function(e,t){if(!e)throw Error("Invariant failed")}(!1,"minPointSize callback function received a value with type of ".concat(typeof n,". Currently only numbers or null/undefined are supported.")),t)}},ees=["children"],eec=(0,ew.createContext)({data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function eed(e){var{children:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,ees);return ew.createElement(eec.Provider,{value:n},t)}var eeu=(e,t,n)=>{var r=null!=n?n:e;if(null!=r)return ky(r,t,0)};function eef(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eeh(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eef(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eef(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var eem=j2([PK,(e,t)=>t],(e,t)=>e.filter(e=>"bar"===e.type).find(e=>e.id===t)),eep=j2([eem],e=>null==e?void 0:e.maxBarSize),eeg=j2([Cb,PK,Yu,Yf,(e,t,n)=>n],(e,t,n,r,a)=>t.filter(t=>"horizontal"===e?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===a).filter(e=>!1===e.hide).filter(e=>"bar"===e.type)),eev=j2([eeg,e=>e.rootProps.barSize,(e,t)=>{var n=Cb(e),r=Yu(e,t),a=Yf(e,t);if(null!=r&&null!=a)return"horizontal"===n?Ii(e,"xAxis",r):Ii(e,"yAxis",a)}],(e,t,n)=>{var r=e.filter(Ml),a=e.filter(e=>null==e.stackId);return[...Object.entries(r.reduce((e,t)=>{var n=e[t.stackId];return null==n&&(n=[]),n.push(t),e[t.stackId]=n,e},{})).map(e=>{var r,[a,i]=e;return{stackId:a,dataKeys:i.map(e=>e.dataKey),barSize:eeu(t,n,null==(r=i[0])?void 0:r.barSize)}}),...a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>null!=e),barSize:eeu(t,n,e.barSize)}))]}),eex=(e,t,n)=>{var r,a,i=Cb(e),o=Yu(e,t),l=Yf(e,t);if(null!=o&&null!=l)return"horizontal"===i?(r=Iu(e,"xAxis",o,n),a=Id(e,"xAxis",o,n)):(r=Iu(e,"yAxis",l,n),a=Id(e,"yAxis",l,n)),kB(r,a)},eey=j2([eev,CR,e=>e.rootProps.barGap,C_,(e,t,n)=>{var r,a,i,o,l=eem(e,t);if(null==l)return 0;var s=Yu(e,t),c=Yf(e,t);if(null==s||null==c)return 0;var d=Cb(e),u=CR(e),{maxBarSize:f}=l;return"horizontal"===d?(i=Iu(e,"xAxis",s,n),o=Id(e,"xAxis",s,n)):(i=Iu(e,"yAxis",c,n),o=Id(e,"yAxis",c,n)),null!=(r=null!=(a=kB(i,o,!0))?a:null==f?u:f)?r:0},eex,eep],(e,t,n,r,a,i,o)=>{var l=function(e,t,n,r,a){var i,o,l=r.length;if(!(l<1)){var s=ky(e,n,0,!0),c=[];if(kM(null==(i=r[0])?void 0:i.barSize)){var d=!1,u=n/l,f=r.reduce((e,t)=>e+(t.barSize||0),0);(f+=(l-1)*s)>=n&&(f-=(l-1)*s,s=0),f>=n&&u>0&&(d=!0,u*=.9,f=l*u);var h={offset:((n-f)/2|0)-s,size:0};o=r.reduce((e,t)=>{var n,r={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:h.offset+h.size+s,size:d?u:null!=(n=t.barSize)?n:0}},a=[...e,r];return h=r.position,a},c)}else{var m=ky(t,n,0,!0);n-2*m-(l-1)*s<=0&&(s=0);var p=(n-2*m-(l-1)*s)/l;p>1&&(p>>=0);var g=kM(a)?Math.min(p,a):p;o=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:m+(p+s)*n+(p-g)/2,size:g}}],c)}return o}}(n,r,a!==i?a:i,e,null==o?t:o);return a!==i&&null!=l&&(l=l.map(e=>eeh(eeh({},e),{},{position:eeh(eeh({},e.position),{},{offset:e.position.offset-a/2})}))),l}),eeb=j2([eey,eem],(e,t)=>{if(null!=e&&null!=t){var n=e.find(e=>e.stackId===t.stackId&&null!=t.dataKey&&e.dataKeys.includes(t.dataKey));if(null!=n)return n.position}}),eew=j2([(e,t,n)=>{var r=Cb(e),a=Yu(e,t),i=Yf(e,t);if(null!=a&&null!=i)return"horizontal"===r?As(e,"yAxis",i,n):As(e,"xAxis",a,n)},eem],(e,t)=>{var n=Mi(t);if(!e||null==n||null==t)return;var{stackId:r}=t;if(null!=r){var a=e[r];if(a){var{stackedData:i}=a;if(i)return i.find(e=>e.key===n)}}}),eej=j2([k0,k2,(e,t,n)=>{var r=Yu(e,t);if(null!=r)return Iu(e,"xAxis",r,n)},(e,t,n)=>{var r=Yf(e,t);if(null!=r)return Iu(e,"yAxis",r,n)},(e,t,n)=>{var r=Yu(e,t);if(null!=r)return Id(e,"xAxis",r,n)},(e,t,n)=>{var r=Yf(e,t);if(null!=r)return Id(e,"yAxis",r,n)},eeb,Cb,j8,eex,eew,eem,(e,t,n,r)=>r],(e,t,n,r,a,i,o,l,s,c,d,u,f)=>{var h,{chartData:m,dataStartIndex:p,dataEndIndex:g}=s;if(null!=u&&null!=o&&null!=t&&("horizontal"===l||"vertical"===l)&&null!=n&&null!=r&&null!=a&&null!=i&&null!=c){var{data:v}=u;if(null!=(h=null!=v&&v.length>0?v:null==m?void 0:m.slice(p,g+1)))return function(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:a},pos:i,bandSize:o,xAxis:l,yAxis:s,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:f,offset:h,cells:m,parentViewBox:p,dataStartIndex:g}=e,v="horizontal"===t?s:l,x=u?v.scale.domain():null,y=(e=>{var{numericAxis:t}=e,n=t.scale.domain();if("number"===t.type){var r=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return r<=0&&a>=0?0:a<0?a:r}return n[0]})({numericAxis:v}),b=v.scale.map(y);return f.map((e,f)=>{if(u){var v=u[f+g];if(null==v)return null;j=((e,t)=>{if(!t||2!==t.length||!kp(t[0])||!kp(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!kp(e[0])||e[0]<n)&&(a[0]=n),(!kp(e[1])||e[1]>r)&&(a[1]=r),a[0]>r&&(a[0]=r),a[1]<n&&(a[1]=n),a})(v,x)}else Array.isArray(j=kA(e,n))||(j=[y,j]);var w=eel(r,0)(j[1],f);if("horizontal"===t){var j,k,S,N,C,M,E,O=s.scale.map(j[0]),P=s.scale.map(j[1]);if(null==O||null==P)return null;k=kL({axis:l,ticks:c,bandSize:o,offset:i.offset,entry:e,index:f}),S=null!=(E=null!=P?P:O)?E:void 0,N=i.size;var A=O-P;if(C=kh(A)?0:A,M={x:k,y:h.top,width:N,height:h.height},Math.abs(w)>0&&Math.abs(C)<Math.abs(w)){var I=kf(C||w)*(Math.abs(w)-Math.abs(C));S-=I,C+=I}}else{var z=l.scale.map(j[0]),T=l.scale.map(j[1]);if(null==z||null==T)return null;if(k=z,S=kL({axis:s,ticks:d,bandSize:o,offset:i.offset,entry:e,index:f}),N=T-z,C=i.size,M={x:h.left,y:S,width:h.width,height:C},Math.abs(w)>0&&Math.abs(N)<Math.abs(w)){var D=kf(N||w)*(Math.abs(w)-Math.abs(N));N+=D}}return null!=k&&null!=S&&null!=N&&null!=C&&(a||0!==N&&0!==C)?ee$(ee$({},e),{},{stackedBarStart:b,x:k,y:S,width:N,height:C,value:u?j:j[1],payload:e,background:M,tooltipPosition:{x:k+N/2,y:S+C/2},parentViewBox:p,originalDataIndex:f},m&&m[f]&&m[f].props):null}).filter(Boolean)}({layout:l,barSettings:u,pos:o,parentViewBox:t,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,stackedData:d,displayedData:h,offset:e,cells:f,dataStartIndex:p})}}),eek=(e,t)=>t,eeS=(e,t,n)=>n,eeN=j2([eek,PK,eeS],(e,t,n)=>t.filter(e=>"bar"===e.type).filter(t=>t.stackId===e).filter(e=>e.isPanorama===n).filter(e=>!e.hide)),eeC=j2([eeN],e=>e.map(e=>e.id)),eeM=j2([e=>e,eek,eeS],(e,t,n)=>{var r=eeC(e,t,n),a=[];return r.forEach(t=>{var r=eej(e,t,n,void 0);null==r||r.forEach(e=>{var t=e.originalDataIndex;a[t]=((e,t)=>{if(!e)return t;if(!t)return e;var n=Math.min(e.x,e.x+e.width,t.x,t.x+t.width),r=Math.min(e.y,e.y+e.height,t.y,t.y+t.height);return{x:n,y:r,width:Math.max(e.x,e.x+e.width,t.x,t.x+t.width)-n,height:Math.max(e.y,e.y+e.height,t.y,t.y+t.height)-r}})(a[t],e)})}),a}),eeE=["index"];function eeO(){return(eeO=Object.assign.bind()).apply(null,arguments)}var eeP=(0,ew.createContext)(void 0),eeA=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),eeI=e=>{var{index:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,eeE),r=(e=>{var t=(0,ew.useContext)(eeP);if(null!=t){var{stackId:n}=t;return"url(#".concat(eeA(n,e),")")}})(t);return ew.createElement(IW,eeO({className:"recharts-bar-stack-layer",clipPath:r},n))},eez=["onMouseEnter","onMouseLeave","onClick"],eeT=["value","background","tooltipPosition"],eeD=["id"],eeR=["onMouseEnter","onClick","onMouseLeave"];function ee_(){return(ee_=Object.assign.bind()).apply(null,arguments)}function eeL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ee$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eeL(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eeL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eeF(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var eeB=eea.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:a,name:i,hide:o,unit:l,tooltipType:s,id:c}=e,d={dataDefinedOnItem:void 0,getPosition:kN,settings:{stroke:n,strokeWidth:r,fill:a,dataKey:t,nameKey:void 0,name:kH(i,t),hide:o,type:s,color:a,unit:l,graphicalItemId:c}};return eea.createElement(Ra,{tooltipEntrySettings:d})});function eeV(e){var t,n=Se(R7),{data:r,dataKey:a,background:i,allOtherBarProps:o}=e,{onMouseEnter:l,onMouseLeave:s,onClick:c}=o,d=eeF(o,eez),u=Rt(l,a,o.id),f=Rn(s),h=Rr(c,a,o.id);if(!i||null==r)return null;var m=IB(i);return eea.createElement(_V,{zIndex:(t=CX.barBackground,i&&"object"==typeof i&&"zIndex"in i&&"number"==typeof i.zIndex&&kM(i.zIndex)?i.zIndex:t)},r.map((e,t)=>{var{value:r,background:o,tooltipPosition:l}=e,s=eeF(e,eeT);if(!o)return null;var c=u(e,t),p=f(e,t),g=h(e,t),v=ee$(ee$(ee$(ee$(ee$({option:i,isActive:String(t)===n},s),{},{fill:"#eee"},o),m),zf(d,e,t)),{},{onMouseEnter:c,onMouseLeave:p,onClick:g,dataKey:a,index:t,className:"recharts-bar-background-rectangle"});return eea.createElement(eeo,ee_({key:"background-bar-".concat(t)},v))}))}function eeH(e){var{showLabels:t,children:n,rects:r}=e,a=null==r?void 0:r.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return ee$(ee$({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return eea.createElement(Ln,{value:t?a:void 0},n)}function eeU(e){var t,{shape:n,activeBar:r,baseProps:a,entry:i,index:o,dataKey:l}=e,s=Se(R7),c=Se(_e),d=r&&String(i.originalDataIndex)===s&&(null==c||l===c),[u,f]=(0,eea.useState)(!1),[h,m]=(0,eea.useState)(!1);(0,eea.useEffect)(()=>{var e;return d?(f(!0),e=requestAnimationFrame(()=>{m(!0)})):m(!1),()=>{cancelAnimationFrame(e)}},[d]);var p=(0,eea.useCallback)(()=>{d||f(!1)},[d]),g=d&&h,v=d||u;t=d?!0===r?n:r:n;var x=eea.createElement(eeo,ee_({},a,{name:String(a.name)},i,{isActive:g,option:t,index:o,dataKey:l,onTransitionEnd:p}));return v?eea.createElement(_V,{zIndex:CX.activeBar},eea.createElement(eeI,{index:i.originalDataIndex},x)):x}function eeW(e){var{shape:t,baseProps:n,entry:r,index:a,dataKey:i}=e;return eea.createElement(eeo,ee_({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:a,dataKey:i}))}function eeq(e){var t,{data:n,props:r}=e,a=null!=(t=IF(r))?t:{},{id:i}=a,o=eeF(a,eeD),{shape:l,dataKey:s,activeBar:c}=r,{onMouseEnter:d,onClick:u,onMouseLeave:f}=r,h=eeF(r,eeR),m=Rt(d,s,i),p=Rn(f),g=Rr(u,s,i);return n?eea.createElement(eea.Fragment,null,n.map((e,t)=>eea.createElement(eeI,ee_({index:e.originalDataIndex,key:"rectangle-".concat(null==e?void 0:e.x,"-").concat(null==e?void 0:e.y,"-").concat(null==e?void 0:e.value,"-").concat(t),className:"recharts-bar-rectangle"},zf(h,e,t),{onMouseEnter:m(e,t),onMouseLeave:p(e,t),onClick:g(e,t)}),c?eea.createElement(eeU,{shape:l,activeBar:c,baseProps:o,entry:e,index:t,dataKey:s}):eea.createElement(eeW,{shape:l,baseProps:o,entry:e,index:t,dataKey:s})))):null}function eeK(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:s,onAnimationEnd:c,onAnimationStart:d}=t,u=n.current,f=Tk(t,"recharts-bar-"),[h,m]=(0,eea.useState)(!1),p=(0,eea.useCallback)(()=>{"function"==typeof c&&c(),m(!1)},[c]),g=(0,eea.useCallback)(()=>{"function"==typeof d&&d(),m(!0)},[d]);return eea.createElement(eeH,{showLabels:!h,rects:r},eea.createElement(Tj,{animationId:f,begin:o,duration:l,isActive:i,easing:s,onAnimationEnd:p,onAnimationStart:g,key:f},e=>{var i=1===e?r:null==r?void 0:r.map((t,n)=>{var r=u&&u[n];if(r)return ee$(ee$({},t),{},{x:kw(r.x,t.x,e),y:kw(r.y,t.y,e),width:kw(r.width,t.width,e),height:kw(r.height,t.height,e)});if("horizontal"===a){var i=kw(0,t.height,e),o=kw(t.stackedBarStart,t.y,e);return ee$(ee$({},t),{},{y:o,height:i})}var l=kw(0,t.width,e),s=kw(t.stackedBarStart,t.x,e);return ee$(ee$({},t),{},{width:l,x:s})});return(e>0&&(n.current=null!=i?i:null),null==i)?null:eea.createElement(IW,null,eea.createElement(eeq,{props:t,data:i}))}),eea.createElement(Lo,{label:t.label}),t.children)}function eeG(e){var t=(0,eea.useRef)(null);return eea.createElement(eeK,{previousRectanglesRef:t,props:e})}var eeX=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:kA(e,t)}};class eeY extends eea.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:a,yAxisId:i,needClip:o,background:l,id:s}=this.props;if(e||null==t)return null;var c=(0,jL.clsx)("recharts-bar",r);return eea.createElement(IW,{className:c,id:s},o&&eea.createElement("defs",null,eea.createElement(Yd,{clipPathId:s,xAxisId:a,yAxisId:i})),eea.createElement(IW,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(s,")"):void 0},eea.createElement(eeV,{data:t,dataKey:n,background:l,allOtherBarProps:this.props}),eea.createElement(eeG,this.props)))}}var eeZ={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,xAxisId:0,yAxisId:0,zIndex:CX.bar};function eeJ(e){var t,{xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u}=e,{needClip:f}=Yc(n,r),h=Se(Cb),m=N3(),p=z7(e.children,z2),g=Se(t=>eej(t,e.id,m,p));if("vertical"!==h&&"horizontal"!==h)return null;var v=null==g?void 0:g[0];return t=null==v||null==v.height||null==v.width?0:"vertical"===h?v.height/2:v.width/2,eea.createElement(eed,{xAxisId:n,yAxisId:r,data:g,dataPointFormatter:eeX,errorBarOffset:t},eea.createElement(eeY,ee_({},e,{layout:h,needClip:f,data:g,xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u})))}eea.memo(function(e){var t,n,r=zB(e,eeZ),a=(t=r.stackId,null!=(n=(0,ew.useContext)(eeP))?n.stackId:null!=t?kR(t):void 0),i=N3();return eea.createElement(_y,{id:r.id,type:"bar"},e=>eea.createElement(eea.Fragment,null,eea.createElement(_p,{legendPayload:(e=>{var{dataKey:t,name:n,fill:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kH(n,t),payload:e}]})(r)}),eea.createElement(eeB,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:e}),eea.createElement(_E,{type:"bar",id:e,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:i,hasCustomShape:null!=r.shape}),eea.createElement(_V,{zIndex:r.zIndex},eea.createElement(eeJ,ee_({},r,{id:e})))))},Fb).displayName="Bar";let eeQ=(0,ek.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);function ee0({className:e,orientation:t="horizontal",...n}){return(0,ey.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,eI.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}function ee1({label:e,description:t,value:n}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:t})]}),(0,ey.jsx)(Q2,{value:Q5(n),minSize:48,maxSize:220,className:"absolute right-0 bottom-0 h-2/3 w-full"})]})}(0,ek.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var ee2=ew,ee5=(e,t,n,r)=>Iu(e,"xAxis",t,r),ee4=(e,t,n,r)=>Id(e,"xAxis",t,r),ee3=(e,t,n,r)=>Iu(e,"yAxis",n,r),ee6=(e,t,n,r)=>Id(e,"yAxis",n,r),ee8=j2([Cb,ee5,ee3,ee4,ee6],(e,t,n,r,a)=>kI(e,"xAxis")?kB(t,r,!1):kB(n,a,!1));function ee7(e){return"line"===e.type}var ee9=j2([PK,(e,t,n,r,a)=>a],(e,t)=>e.filter(ee7).find(e=>e.id===t)),ete=j2([Cb,ee5,ee3,ee4,ee6,ee9,ee8,j6],(e,t,n,r,a,i,o,l)=>{var s,{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(null!=i&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=o&&("horizontal"===e||"vertical"===e)){var{dataKey:f,data:h}=i;if(null!=(s=null!=h&&h.length>0?h:null==c?void 0:c.slice(d,u+1)))return function(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:s}=e;return s.map((e,s)=>{var c=kA(e,o);if("horizontal"===t){var d=k_({axis:n,ticks:a,bandSize:l,entry:e,index:s}),u=null==c?null:r.scale.map(c);return{x:d,y:null!=u?u:null,value:c,payload:e}}var f=null==c?null:n.scale.map(c),h=k_({axis:r,ticks:i,bandSize:l,entry:e,index:s});return null==f||null==h?null:{x:f,y:h,value:c,payload:e}}).filter(Boolean)}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataKey:f,bandSize:o,displayedData:s})}}),ett=["id"],etn=["type","layout","connectNulls","needClip","shape"],etr=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function eta(){return(eta=Object.assign.bind()).apply(null,arguments)}function eti(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eto(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eti(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eti(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function etl(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var ets=ee2.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kN,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kH(o,t),hide:l,type:c,color:r,unit:s,graphicalItemId:d}};return ee2.createElement(Ra,{tooltipEntrySettings:u})}),etc=(e,t)=>"".concat(t,"px ").concat(e,"px");function etd(e){var{clipPathId:t,points:n,props:r}=e,{dot:a,dataKey:i,needClip:o}=r,{id:l}=r,s=IF(etl(r,ett));return ee2.createElement(Ya,{points:n,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:s,needClip:o,clipPathId:t})}function etu(e){var{showLabels:t,children:n,points:r}=e,a=(0,ee2.useMemo)(()=>null==r?void 0:r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return eto(eto({},r),{},{value:e.value,payload:e.payload,viewBox:r,parentViewBox:void 0,fill:void 0})}),[r]);return ee2.createElement(Ln,{value:t?a:void 0},n)}function etf(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:s,needClip:c,shape:d}=i,u=eto(eto({},IV(etl(i,etn))),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:l,connectNulls:s,strokeDasharray:null!=a?a:i.strokeDasharray});return ee2.createElement(ee2.Fragment,null,(null==r?void 0:r.length)>1&&ee2.createElement(Dc,eta({shapeType:"curve",option:d},u,{pathRef:n})),ee2.createElement(etd,{points:r,clipPathId:t,props:i}))}function eth(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,animateNewValues:f,width:h,height:m,onAnimationEnd:p,onAnimationStart:g}=n,v=a.current,x=Tk(o,"recharts-line-"),y=(0,ee2.useRef)(x),[b,w]=(0,ee2.useState)(!1),j=(0,ee2.useCallback)(()=>{"function"==typeof p&&p(),w(!1)},[p]),k=(0,ee2.useCallback)(()=>{"function"==typeof g&&g(),w(!0)},[g]),S=function(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch(e){return 0}}(r.current),N=(0,ee2.useRef)(0);y.current!==x&&(N.current=i.current,y.current=x);var C=N.current;return ee2.createElement(etu,{points:o,showLabels:!b},n.children,ee2.createElement(Tj,{animationId:x,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:j,onAnimationStart:k,key:x},e=>{var c,d=Math.min(kw(C,S+C,e),S);if(c=s?l?((e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return etc(t,e);for(var a=Math.floor(e/r),i=e%r,o=[],l=0,s=0;l<n.length;s+=null!=(c=n[l])?c:0,++l){var c,d=n[l];if(null!=d&&s+d>i){o=[...n.slice(0,l),i-s];break}}var u=o.length%2==0?[0,t]:[t];return[...function(e,t){for(var n=e.length%2!=0?[...e,0]:e,r=[],a=0;a<t;++a)r.push(...n);return r}(n,a),...o,...u].map(e=>"".concat(e,"px")).join(", ")})(d,S,"".concat(l).split(/[,\s]+/gim).map(e=>parseFloat(e))):etc(S,d):null==l?void 0:String(l),e>0&&S>0&&(a.current=o,i.current=Math.max(i.current,d)),v){var u=v.length/o.length,p=1===e?o:o.map((t,n)=>{var r=Math.floor(n*u);if(v[r]){var a=v[r];return eto(eto({},t),{},{x:kw(a.x,t.x,e),y:kw(a.y,t.y,e)})}return f?eto(eto({},t),{},{x:kw(2*h,t.x,e),y:kw(m/2,t.y,e)}):eto(eto({},t),{},{x:t.x,y:t.y})});return a.current=p,ee2.createElement(etf,{props:n,points:p,clipPathId:t,pathRef:r,strokeDasharray:c})}return ee2.createElement(etf,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:c})}),ee2.createElement(Lo,{label:n.label}))}function etm(e){var{clipPathId:t,props:n}=e,r=(0,ee2.useRef)(null),a=(0,ee2.useRef)(0),i=(0,ee2.useRef)(null);return ee2.createElement(eth,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:a,pathRef:i})}var etp=(e,t)=>{var n,r;return{x:null!=(n=e.x)?n:void 0,y:null!=(r=e.y)?r:void 0,value:e.value,errorVal:kA(e.payload,t)}};class etg extends ee2.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:a,yAxisId:i,top:o,left:l,width:s,height:c,id:d,needClip:u,zIndex:f}=this.props;if(e)return null;var h=(0,jL.clsx)("recharts-line",r),{r:m,strokeWidth:p}=Yj(t),g=z9(t),v=2*m+p,x=u?"url(#clipPath-".concat(g?"":"dots-").concat(d,")"):void 0;return ee2.createElement(_V,{zIndex:f},ee2.createElement(IW,{className:h},u&&ee2.createElement("defs",null,ee2.createElement(Yd,{clipPathId:d,xAxisId:a,yAxisId:i}),!g&&ee2.createElement("clipPath",{id:"clipPath-dots-".concat(d)},ee2.createElement("rect",{x:l-v/2,y:o-v/2,width:s+v,height:c+v}))),ee2.createElement(eed,{xAxisId:a,yAxisId:i,data:n,dataPointFormatter:etp,errorBarOffset:0},ee2.createElement(etm,{props:this.props,clipPathId:d}))),ee2.createElement(Ys,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}}var etv={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:CX.line,type:"linear"};function etx(e){var t=zB(e,etv),{activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:s,hide:c,isAnimationActive:d,label:u,legendType:f,xAxisId:h,yAxisId:m,id:p}=t,g=etl(t,etr),{needClip:v}=Yc(h,m),x=Se(F2),y=Se(Cb),b=N3(),w=Se(e=>ete(e,h,m,b,p));if("horizontal"!==y&&"vertical"!==y||null==w||null==x)return null;var{height:j,width:k,x:S,y:N}=x;return ee2.createElement(etg,eta({},g,{id:p,connectNulls:l,dot:s,activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:d,hide:c,label:u,legendType:f,xAxisId:h,yAxisId:m,points:w,layout:y,height:j,width:k,left:S,top:N,needClip:v}))}var ety=ee2.memo(function(e){var t=zB(e,etv),n=N3();return ee2.createElement(_y,{id:t.id,type:"line"},e=>ee2.createElement(ee2.Fragment,null,ee2.createElement(_p,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kH(n,t),payload:e}]})(t)}),ee2.createElement(ets,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),ee2.createElement(_E,{type:"line",id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),ee2.createElement(etx,eta({},t,{id:e}))))},Fb);ety.displayName="Line";var etb=["axis"],etw=(0,ew.forwardRef)((e,t)=>ew.createElement(Yq,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:etb,tooltipPayloadSearcher:LC,categoricalChartProps:e,ref:t}));let etj={online:"bg-foreground",warning:"bg-muted-foreground",offline:"bg-destructive"},etk={direct:"stroke-foreground",p2p:"stroke-foreground",relay:"stroke-muted-foreground",down:"stroke-destructive"},etS={topologyNode:function({data:e}){return(0,ey.jsxs)("div",{className:"vtl-surface-card min-w-36 rounded-[var(--surface-card-radius)] border px-3 py-2",children:[(0,ey.jsx)(ox,{type:"target",position:R.Top,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:R.Bottom,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"target",position:R.Left,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:R.Right,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("size-2.5 shrink-0 rounded-full",etj[e.state])}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:e.label})]}),e.meta?(0,ey.jsx)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:e.meta}):null]})}},etN={topologyEdge:function({id:e,sourceX:t,sourceY:n,targetX:r,targetY:a,sourcePosition:i,targetPosition:o,data:l}){let[s]=aE({sourcePosition:i,sourceX:t,sourceY:n,targetPosition:o,targetX:r,targetY:a}),{x:c,y:d}=function(e){if("u"<typeof document)return{x:0,y:0};let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",e);let n=t.getTotalLength(),r=t.getPointAtLength(n/2);return{x:r.x,y:r.y}}(s),u=l?.kind??"direct";return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(oL,{id:e,path:s,className:(0,eI.cn)("fill-none",etk[u],"p2p"===u&&"stroke-dasharray-[8_6]","relay"===u&&"stroke-dasharray-[12_8]"),style:{strokeWidth:"down"===u?3:2.4,strokeLinecap:"round",strokeLinejoin:"round"}}),(l?.label||l?.meta)&&(0,ey.jsx)("foreignObject",{x:c-48,y:d-20,width:96,height:40,className:"overflow-visible",requiredExtensions:"http://www.w3.org/1999/xhtml",children:(0,ey.jsxs)("div",{className:"pointer-events-none grid h-10 w-24 content-center rounded-md border bg-background/95 px-2 py-1 text-center shadow-sm",children:[l.label?(0,ey.jsx)("div",{className:"truncate text-xs font-medium leading-4",children:l.label}):null,l.meta?(0,ey.jsx)("div",{className:"truncate ui-text-kbd text-muted-foreground",children:l.meta}):null]})})]})}};function etC({nodes:e,links:t,className:n,...r}){let a=ew.useMemo(()=>e.map(e=>({id:e.id,data:{label:e.label,meta:e.meta,state:e.state??"online"},position:{x:e.x/100*1e3,y:e.y/100*560},type:"topologyNode"})),[e]),i=ew.useMemo(()=>t.map(e=>({id:e.id,data:{kind:e.kind??"direct",label:e.label,meta:e.meta},source:e.from,target:e.to,type:"topologyEdge"})),[t]);return(0,ey.jsx)("div",{"data-slot":"topology-map",className:(0,eI.cn)("h-full min-h-0 overflow-hidden rounded-xl bg-muted/25",n),...r,children:(0,ey.jsx)(lh,{children:(0,ey.jsx)(lg,{nodes:a,edges:i,nodeTypes:etS,edgeTypes:etN,fitView:!0,fitViewOptions:{maxZoom:1.15,minZoom:.45,padding:.22},minZoom:.35,maxZoom:1.5,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!1,zoomOnScroll:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},className:"topology-flow text-foreground",children:(0,ey.jsx)(lS,{gap:28,size:1,color:"var(--border)",className:"opacity-80"})})})})}function etM({nodes:e,links:t}){return(0,ey.jsx)(etC,{nodes:e,links:t})}function etE({title:e,count:t}){return(0,ey.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between",children:[(0,ey.jsx)("h2",{className:"text-sm font-semibold tracking-normal",children:e}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:t})]})}function etO({items:e}){return(0,ey.jsx)("div",{className:"mt-2 grid",children:e.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("px-2 py-2",t>0&&"border-t"),children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-1 truncate ui-text-kbd text-muted-foreground","warning"===e.tone&&"text-destructive"),children:e.meta})]},e.id))})}function etP({items:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r])=>({id:`${e}-${n}`,status:"完成"===r?"done":"运行中"===r?"current":"失败"===r?"blocked":"queued",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_8rem_minmax(0,1fr)_4rem] items-center gap-3",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:t}),(0,ey.jsx)("span",{className:"truncate",children:n}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:r})]})})),[e]);return(0,ey.jsx)(QS,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function etA({items:e}){let t=ew.useMemo(()=>e.map(e=>{var t;return{id:e.id,status:"running"===(t=e.state)?"current":"blocked"===t||"failed"===t?"blocked":"queued",title:(0,ey.jsx)(etI,{item:e})}}),[e]);return(0,ey.jsx)(QS,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function etI({item:e}){return(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_7.5rem_5rem] items-center gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.machine," · ",e.agent," · ",e.started]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(Q6,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("div",{className:"ui-text-kbd text-muted-foreground",children:e.runtime})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(Q6,{value:e.load,className:"h-1.5"}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:"load"})]})]})}function etz({workers:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(etT,{worker:e,divided:t>0},e.id))})}function etT({worker:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-24 grid-cols-[minmax(0,1fr)_2.5rem_auto] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-lg font-semibold tracking-normal",children:e.machine}),(0,ey.jsx)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:e.role})]}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.active,"/",e.capacity]}),(0,ey.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,ey.jsx)(etD,{label:"CPU",value:e.cpu}),(0,ey.jsx)(etD,{label:"MEM",value:e.memory})]})]})}function etD({label:e,value:t}){return(0,ey.jsxs)("div",{className:"grid justify-items-center gap-1",children:[(0,ey.jsx)(Q8,{value:t,label:e,className:"size-16 [&_[data-slot=progress-ring-center]]:size-10 [&_[data-slot=progress-ring-center]]:bg-background [&_[data-slot=progress-ring-center]_span]:text-xs"}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e})]})}function etR({events:e}){let t=ew.useMemo(()=>e.map(([e,t],n)=>({id:`${e}-${t}`,status:0===n?"current":"done",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate",children:t})]})})),[e]);return(0,ey.jsx)(QS,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function et_({machines:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(etL,{machine:e,divided:t>0},e.id))})}function etL({machine:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-20 grid-cols-[minmax(0,1fr)_minmax(0,1.45fr)] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(etF,{status:e.status}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.os," · ",e.link," · heartbeat ",e.heartbeat]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 sm:grid-cols-4",children:[(0,ey.jsx)(et$,{icon:(0,ey.jsx)(uS,{}),label:"CPU",value:e.cpu}),(0,ey.jsx)(et$,{icon:(0,ey.jsx)(een,{}),label:"MEM",value:e.memory}),(0,ey.jsx)(et$,{icon:(0,ey.jsx)(uN,{}),label:"DISK",value:e.disk}),(0,ey.jsx)(et$,{icon:(0,ey.jsx)(eer,{}),label:"NET",value:e.network})]})]})}function et$({icon:e,label:t,value:n}){return(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsxs)("div",{className:"flex justify-between gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1 [&_svg]:size-3",children:[e,t]}),(0,ey.jsxs)("span",{children:[n,"%"]})]}),(0,ey.jsx)(Q6,{value:n,className:"h-1.5"})]})}function etF({status:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-2 rounded-full bg-border","online"===e&&"bg-primary")})}function etB({links:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r,a])=>({id:`${e}-${t}`,status:"Relay fallback"===n?"blocked":"current",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_5rem_4rem_3.5rem] items-center gap-3",children:[(0,ey.jsxs)("span",{className:"truncate",children:[e," / ",t]}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:r}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:a})]})})),[e]);return(0,ey.jsx)(QS,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function etV({config:e,data:t}){return(0,ey.jsx)(Ve,{config:e,className:"mt-2 min-h-0 flex-1",children:(0,ey.jsxs)(YG,{data:t,margin:{left:8,right:8},children:[(0,ey.jsx)(Zy,{vertical:!1}),(0,ey.jsx)(ZD,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8}),(0,ey.jsx)(BU,{content:(0,ey.jsx)(Vn,{indicator:"line"})}),(0,ey.jsx)(YV,{dataKey:"cpu",type:"monotone",fill:"var(--color-cpu)",fillOpacity:.11,stroke:"var(--color-cpu)",strokeWidth:2}),(0,ey.jsx)(YV,{dataKey:"memory",type:"monotone",fill:"var(--color-memory)",fillOpacity:.1,stroke:"var(--color-memory)",strokeWidth:2}),(0,ey.jsx)(YV,{dataKey:"network",type:"monotone",fill:"var(--color-network)",fillOpacity:.08,stroke:"var(--color-network)",strokeWidth:2})]})})}function etH({services:e}){let[t,n]=Xz(),r=Math.max(1,Math.floor((Math.max(0,n.width-192-64-32)+5)/12)),a=Math.max(48,n.height>0?Math.floor((n.height-0*Math.max(0,e.length-1))/e.length):48),i=Math.max(28,a-22);return(0,ey.jsx)("div",{ref:t,className:"mt-2 min-h-0 flex-1",children:e.map((e,t)=>(0,ey.jsx)(etU,{service:e,divided:t>0,rowHeight:a,sampleCount:r,sampleHeight:i},e.id))})}function etU({service:e,divided:t,rowHeight:n,sampleCount:r,sampleHeight:a}){let i=ew.useMemo(()=>{var t,n;return t=e.samples,n=r,t.length>=n?t.slice(t.length-n):Array.from({length:n},(e,n)=>{let r=n%t.length;return t[r]??0})},[r,e.samples]);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid grid-cols-[12rem_minmax(0,1fr)_4rem] items-center gap-4 px-2",t&&"border-t"),style:{height:n},children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-0.5 truncate ui-text-kbd text-muted-foreground","告警"===e.state&&"text-destructive"),children:e.state})]}),(0,ey.jsx)("div",{"aria-label":`${e.name} 30 minute stability samples`,className:"flex min-w-0 items-center overflow-hidden",style:{gap:5},children:i.map((t,n)=>{var r;return(0,ey.jsx)("span",{className:(0,eI.cn)("shrink-0 rounded-[2px]",(r=t)<60?"bg-destructive":r<72?"bg-destructive/55":r<84?"bg-primary/35":r<92?"bg-primary/60":"bg-primary"),style:{width:7,height:a},title:`${t}%`},`${e.id}-${n}`)})}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.samples.at(-1),"%"]})]})}let etW=[{id:"canvas-vantaloom-base",title:"Vantaloom 基座设计",status:"live",purpose:"承载多标签系统、文件树、终端和 Agent 会话节点。",nodes:18,agents:3,progress:64,health:91,runtime:"3h 12m",tokenUsage:62e4,lastOpened:"刚刚",snapshots:14,unsavedChanges:3,roadmap:[{title:"接入节点模板选择",state:"done"},{title:"处理节点吸附与连线遮挡",state:"done"},{title:"合并多标签页拖拽",state:"running"},{title:"沉淀真实项目模板",state:"queued"}],settings:{nodeTemplates:["多标签页系统","文件管理树","终端标签组","Agent 对话"],defaultLayout:["默认缩放 0.72","节点内容 2x","定位点 24px"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],sharing:["工作组管理员可编辑","成员可审阅","访客不可访问"],autosave:["每 45 秒保存","节点拖拽结束保存","切换工作区保存"],snapshots:["保留最近 30 个","发布前创建检查点"],hosts:["Studio-PC","Linux-runner-02"],plugins:["Browser","Git checkpoint"]}},{id:"canvas-agent-lab",title:"Agent 编排实验",status:"live",purpose:"验证多 Agent 对话、工具窗口和剪切板在画布中的协同。",nodes:11,agents:4,progress:41,health:78,runtime:"1h 36m",tokenUsage:308e3,lastOpened:"8 分钟前",snapshots:9,unsavedChanges:1,roadmap:[{title:"四分工作区布局",state:"done"},{title:"面板替换进剪切板",state:"done"},{title:"会话浏览页",state:"running"},{title:"会话节点化",state:"queued"}],settings:{nodeTemplates:["Agent 对话","数据表标签","浏览器标签"],defaultLayout:["默认双栏","右侧可调整","剪切板常驻"],folders:["D:/Projects/Vantaloom-ui/apps/vantaloom"],sharing:["仅本机管理员可编辑"],autosave:["每 60 秒保存"],snapshots:["保留最近 12 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-release-map",title:"发布路线图",status:"review",purpose:"梳理组件库、主应用和文档的发布前检查。",nodes:9,agents:1,progress:83,health:86,runtime:"42m",tokenUsage:144e3,lastOpened:"今天 15:02",snapshots:7,unsavedChanges:0,roadmap:[{title:"组件清单",state:"done"},{title:"风险列表",state:"done"},{title:"最终检查",state:"running"}],settings:{nodeTemplates:["Diff 标签","数据表标签","文件预览标签"],defaultLayout:["审阅模式默认开启"],folders:["D:/Projects/Vantaloom-ui/docs"],sharing:["工作组可审阅"],autosave:["手动保存"],snapshots:["里程碑保留"],hosts:["Studio-PC"],plugins:[]}},{id:"canvas-browser-matrix",title:"浏览器预览矩阵",status:"idle",purpose:"检查不同 UA、比例和内嵌预览模式的表现。",nodes:6,agents:0,progress:100,health:94,runtime:"28m",tokenUsage:78e3,lastOpened:"昨天 18:44",snapshots:5,unsavedChanges:0,roadmap:[{title:"自适应模式",state:"done"},{title:"长宽比菜单",state:"done"},{title:"导航按钮",state:"done"}],settings:{nodeTemplates:["浏览器标签","多标签页系统"],defaultLayout:["自适应预览"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-ops-topology",title:"工作组拓扑",status:"idle",purpose:"记录机器、服务和工作组连接关系。",nodes:15,agents:0,progress:100,health:89,runtime:"1h 04m",tokenUsage:92e3,lastOpened:"周四 11:30",snapshots:11,unsavedChanges:0,roadmap:[{title:"机器节点整理",state:"done"},{title:"连接策略标注",state:"done"},{title:"访问权限检查",state:"done"}],settings:{nodeTemplates:["数据表标签","浏览器标签","终端标签组"],defaultLayout:["视口吸附开启","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui/ops"],sharing:["管理员可编辑","成员可查看"],autosave:["每 2 分钟保存"],snapshots:["每日保留"],hosts:["Studio-PC","Linux-runner-02","MacBook-build"],plugins:[]}}];function etq(e,t,n,r,a,i,o){return{id:e,title:t,status:"idle",purpose:n,nodes:r,agents:0,progress:100,health:90,runtime:a,tokenUsage:i,lastOpened:o,snapshots:Math.max(3,Math.round(r/2)),unsavedChanges:0,roadmap:[{title:"整理节点结构",state:"done"},{title:"检查连接关系",state:"done"},{title:"保存最终快照",state:"done"}],settings:{nodeTemplates:["多标签页系统","文件预览标签"],defaultLayout:["默认缩放 0.72","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:[]}}}etW.push(etq("canvas-terminal-layout","终端工作台草图","记录终端标签组、日志表和命令区的组合方式。",7,"36m",84e3,"昨天 15:21"),etq("canvas-file-review","文件审阅流程","沉淀文件树、diff 预览和文件标签之间的拖拽关系。",12,"58m",126e3,"周五 20:10"),etq("canvas-settings-ia","设置导航结构","整理设置菜单面板的主菜单、子菜单和搜索入口。",8,"24m",61e3,"周五 16:42"),etq("canvas-auth-access","本机账户接入","记录本机用户、工作组加入和可用机器列表关系。",10,"47m",112e3,"周四 22:05"),etq("canvas-data-ops","运维数据面板","对齐数据表标签、机器状态卡片和运行记录列表。",14,"1h 18m",172e3,"周三 19:48"));let etK=etW.filter(e=>"idle"!==e.status),etG=etW.filter(e=>"idle"===e.status);function etX(e,t,n=""){return{title:e,dataSource:t,refreshRate:"30s",note:n}}function etY(e,t){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5","vtl-jelly-image-card vtl-jelly-image-card-shadowless"),style:QO({image:t,opacity:.88,blur:"0px"}),children:e})}let etZ=[{id:"metric-active",kind:"metric-active",x:0,y:0,w:3,h:3},{id:"metric-nodes",kind:"metric-nodes",x:3,y:0,w:3,h:3},{id:"metric-unsaved",kind:"metric-unsaved",x:6,y:0,w:3,h:3},{id:"metric-snapshots",kind:"metric-snapshots",x:9,y:0,w:3,h:3},{id:"active",kind:"active",x:0,y:3,w:12,h:3},{id:"recent",kind:"recent",x:0,y:6,w:12,h:Math.max(3,Math.ceil(.75*etG.length)+1)}];function etJ({open:e,title:t,description:n,eyebrow:r,panels:a,defaultPanelId:i="overview",onOpenChange:o}){let l=sb(),[s,c]=ew.useState(i),d=a.find(e=>e.id===s)??a[0];return ew.useEffect(()=>{e&&c(i)},[i,e]),(0,ey.jsx)(dC,{open:e,onOpenChange:o,children:(0,ey.jsxs)(fx,{hideClose:!0,className:(0,eI.cn)("gap-0 overflow-hidden p-0",l?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"h-[min(44rem,calc(100svh-2rem))] max-w-5xl"),children:[(0,ey.jsx)(fb,{className:"sr-only",children:t}),(0,ey.jsxs)(fw,{className:"sr-only",children:[r?(0,ey.jsxs)(ey.Fragment,{children:[r,". "]}):null,n??t]}),l?(0,ey.jsxs)("div",{className:"flex h-full flex-col",children:[(0,ey.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-3",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"关闭",onClick:()=>o(!1),children:(0,ey.jsx)(fg.XIcon,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[r?(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:r}):null,(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:t})]})]}),(0,ey.jsx)("nav",{className:"shrink-0 overflow-x-auto border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsx)("div",{className:"flex gap-1.5 px-4 py-2",children:a.map(e=>(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition-colors",d?.id===e.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e.icon}):null,(0,ey.jsx)("span",{children:e.label}),e.badge?(0,ey.jsx)(Bs,{variant:"outline",className:"h-4 px-1 ui-text-kbd",children:e.badge}):null]},e.id))})}),(0,ey.jsx)(wz,{className:"min-h-0 flex-1",children:(0,ey.jsx)("div",{className:"p-4",children:d?.content})})]}):(0,ey.jsxs)("div",{className:"grid size-full min-h-0 grid-cols-[15rem_minmax(0,1fr)]",children:[(0,ey.jsx)("aside",{"data-slot":"resource-management-dialog-sidebar",className:"min-h-0 border-r bg-muted/20",children:(0,ey.jsx)(wz,{className:"h-full",children:(0,ey.jsx)("div",{className:"space-y-1 p-2",children:a.map(e=>(0,ey.jsxs)(eA.Button,{"data-slot":"resource-management-dialog-nav-item",type:"button",variant:"ghost",className:(0,eI.cn)("h-9 w-full justify-start px-2.5 text-left font-medium",d?.id===e.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:e.icon}):null,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.badge?(0,ey.jsx)(Bs,{variant:"outline",className:"h-5 px-1.5 ui-text-kbd",children:e.badge}):null]},e.id))})})}),(0,ey.jsx)(wz,{className:"min-h-0 bg-background",children:(0,ey.jsx)("div",{className:"p-5 pr-9",children:d?.content})})]})]})})}function etQ({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let[r,a]=ew.useState(),i=ew.useMemo(()=>(function({onSelect:e}){return[{id:"metric-active",title:"活跃画布",description:"当前正在编辑的画布数量。",icon:(0,ey.jsx)(uP,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etX("活跃画布","画布列表"),render:e=>etY((0,ey.jsx)(ee1,{label:e.title,description:"当前正在编辑的画布数量",value:String(etK.length)}),QN)},{id:"metric-nodes",title:"运行节点",description:"所有活跃画布内的节点。",icon:(0,ey.jsx)(Vb,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etX("运行节点","画布节点"),render:e=>etY((0,ey.jsx)(ee1,{label:e.title,description:"所有活跃画布内的节点",value:"38"}),QC)},{id:"metric-unsaved",title:"未保存",description:"等待写入的画布变更。",icon:(0,ey.jsx)(jT,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etX("未保存","画布保存状态"),render:e=>etY((0,ey.jsx)(ee1,{label:e.title,description:"等待写入的画布变更",value:"4"}),QM)},{id:"metric-snapshots",title:"快照",description:"可回退的历史存档。",icon:(0,ey.jsx)(K2,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etX("快照","画布快照"),render:e=>etY((0,ey.jsx)(ee1,{label:e.title,description:"可回退的历史存档",value:"46"}),QE)},{id:"active",title:"正在使用的画布",description:"活跃画布 Roadmap。",icon:(0,ey.jsx)(uP,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:etX("正在使用的画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(etE,{title:t.title,count:etK.length}),(0,ey.jsx)(Q9,{canvases:etK,scrollable:!0,onSelect:e})]})},{id:"recent",title:"最近画布",description:"最近打开的画布。",icon:(0,ey.jsx)(m0,{className:"size-4"}),defaultSize:{w:12,h:Math.max(3,Math.ceil(.75*etG.length)+1)},defaultConfig:etX("最近画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col",children:[(0,ey.jsx)(etE,{title:t.title,count:etG.length}),(0,ey.jsx)(Q9,{canvases:etG,mode:"archive",onSelect:e})]})}]})({onSelect:a}),[]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Q0,{boardId:"canvas-library",definitions:i,initialLayouts:etZ,clipboardItems:e,actionLabel:"画布库页面卡片操作",paletteGroupTitle:"画布库页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n}),(0,ey.jsx)(et1,{canvas:r,onOpenChange:e=>{e||a(void 0)}})]})}function et0({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}function et1({canvas:e,onOpenChange:t}){return e?(0,ey.jsx)(etJ,{open:!!e,onOpenChange:t,title:e.title,eyebrow:"画布管理",description:e.purpose,panels:[{id:"overview",label:"首页",icon:(0,ey.jsx)(Vw,{}),content:(0,ey.jsx)(et2,{canvas:e})},{id:"templates",label:"节点模板",icon:(0,ey.jsx)(Qg,{}),badge:e.settings.nodeTemplates.length,content:(0,ey.jsx)(et4,{title:"可用节点模板",items:e.settings.nodeTemplates})},{id:"layout",label:"默认布局",icon:(0,ey.jsx)(Qw,{}),content:(0,ey.jsx)(et4,{title:"默认布局参数",items:e.settings.defaultLayout})},{id:"folders",label:"工作区绑定",icon:(0,ey.jsx)(m0,{}),content:(0,ey.jsx)(et4,{title:"绑定的工作区文件夹",items:e.settings.folders})},{id:"sharing",label:"共享权限",icon:(0,ey.jsx)(Qb,{}),content:(0,ey.jsx)(et4,{title:"共享与权限",items:e.settings.sharing})},{id:"autosave",label:"自动保存",icon:(0,ey.jsx)(K3,{}),content:(0,ey.jsx)(et4,{title:"自动保存策略",items:e.settings.autosave})},{id:"snapshots",label:"快照和版本",icon:(0,ey.jsx)(K2,{}),content:(0,ey.jsx)(et4,{title:"快照和版本策略",items:e.settings.snapshots})},{id:"hosts",label:"可访问主机",icon:(0,ey.jsx)(Qx,{}),content:(0,ey.jsx)(et4,{title:"可访问主机",items:e.settings.hosts})},{id:"plugins",label:"插件",icon:(0,ey.jsx)(Qy,{}),content:(0,ey.jsx)(et4,{title:"画布插件",items:e.settings.plugins,empty:"未加载插件"})}]}):null}function et2({canvas:e}){return(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("button",{type:"button",className:"group relative grid min-h-72 rounded-[2rem] border bg-card p-7 text-left transition-colors hover:bg-muted/35",children:[(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("div",{className:"max-w-2xl",children:[(0,ey.jsx)("h3",{className:"text-3xl font-semibold tracking-normal",children:e.title}),(0,ey.jsx)("p",{className:"mt-4 text-sm leading-6 text-muted-foreground",children:e.purpose})]}),(0,ey.jsxs)("div",{className:"grid max-w-56 gap-2",children:[(0,ey.jsx)(et5,{label:"Nodes",value:`${e.nodes}`}),(0,ey.jsx)(et5,{label:"Agent",value:`${e.agents}`}),(0,ey.jsx)(et5,{label:"Snapshots",value:`${e.snapshots}`})]})]}),(0,ey.jsx)("span",{className:"absolute right-7 bottom-7 text-sm font-medium text-foreground transition-opacity group-hover:opacity-70",children:"进入"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"Roadmap"}),(0,ey.jsx)(et0,{icon:(0,ey.jsx)(Vb,{}),value:e.runtime})]}),(0,ey.jsx)(QS,{items:e.roadmap.map(e=>({id:e.title,title:e.title,status:"running"===e.state?"current":"done"===e.state?"done":"queued"})),viewportClassName:"max-h-64"})]})]})}function et5({label:e,value:t}){return(0,ey.jsxs)("span",{className:"grid min-w-0 gap-0.5 py-0.5",children:[(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold tracking-normal",children:t})]})}function et4({title:e,items:t,empty:n="暂无内容"}){return(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"overflow-hidden rounded-xl border bg-card",children:t.length>0?t.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("flex min-h-10 items-center gap-2 px-3 text-sm",t>0&&"border-t"),children:[(0,ey.jsx)(Qv,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 truncate",children:e})]},e)):(0,ey.jsx)("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:n})})]})}function et3({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xg,{open:e,onOpenChange:t,title:"添加节点",description:"搜索并选择要放入画布的可用节点。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xp,{loop:!0,children:[(0,ey.jsx)(xv,{placeholder:"搜索节点..."}),(0,ey.jsxs)(xx,{children:[(0,ey.jsx)(xy,{children:"没有匹配节点。"}),(0,ey.jsx)(xb,{heading:"可用节点",children:uL.map(e=>(0,ey.jsxs)(xw,{value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e),children:[(0,ey.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xj,{children:[e.size.width,"x",e.size.height]})]},e.id))})]})]})})}function et6({nodes:e,edges:t,selectedNodeId:n,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c}){let d=ew.useRef(null),{addPaletteOpen:u,addTemplateNode:f,handleAddPaletteOpenChange:h,handleCanvasAction:m,handleCanvasDragOver:p,handleCanvasDrop:g,handleNodeCanvasConnect:v,handleNodeCanvasEdgeAction:x,handleNodeCanvasNodeAction:y,filePickerDialog:b,renderedCanvasNodes:w}=function({workspaceRef:e,nodes:t,clipboardItems:n,onNodesSet:r,onEdgesSet:a,onSelectedNodeChange:i,onClipboardItemsChange:o}){let l=ew.useRef(0),s=ew.useRef(0),[c,d]=ew.useState(!1),[u,f]=ew.useState(),[h,m]=ew.useState(),p=ew.useCallback((t,n)=>{let r,a,i,o,l,s,c,d;return r=e.current,a=r?.querySelector(".react-flow__viewport"),i=r?.getBoundingClientRect(),l="none"!==(o=a?getComputedStyle(a).transform:"none")?new DOMMatrixReadOnly(o):void 0,s=l?.a&&Number.isFinite(l.a)?l.a:1,c=l?.e??0,d=l?.f??0,{x:(t-(i?.left??0)-c)/s,y:(n-(i?.top??0)-d)/s}},[e]),g=ew.useCallback((e,t)=>{r(n=>n.map(n=>{let r,a;return n.id===e?(a="string"==typeof(r=n.data??{}).activeTabId&&t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id,{...n,data:{...r,tabs:t,activeTabId:a}}):n}))},[r]),v=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},activeTabId:t}}:n))},[r]),x=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?function(e,t){let n=e.data??{};if("multi-tab-system"===n.kind){let r=Array.isArray(n.tabs)?n.tabs:[];return{...e,data:{...n,tabs:r.map(e=>e.id===t.id?t:e),activeTabId:t.id}}}return uB(n.kind)?{...e,data:{...n,tab:t}}:e}(n,t):n))},[r]),y=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},terminal:t}}:n))},[r]),b=ew.useCallback((e,t)=>{var n;let a=(n=e.kind,uL.find(e=>e.id===n)?.size??uz({width:480,height:320}));s.current+=1;let o=`${e.kind}-detached-${s.current}`;r(n=>[...n,function({tab:e,nodeId:t,center:n,size:r}){return{id:t,type:"blank",position:uR(n,r),data:{contentScale:2,kind:e.kind,tab:{...e,id:`${t}-tab`}},width:r.width,height:r.height,style:uT(r)}}({tab:e,nodeId:o,center:t,size:a})]),i(o)},[r,i]),w=ew.useCallback(async(e,n)=>{try{let a,i=n?.nodeId?t.find(e=>e.id===n.nodeId):void 0,o=i?(i.data??{}).kind:void 0,l="data-table-tab-viewer"===o?await fe(e):await u8(e),s=void 0!==i&&(a=i.data??{},"multi-tab-system"===a.kind||"file-tab-viewer"===a.kind||"data-table-tab-viewer"===a.kind);n?.nodeId&&s&&r(e=>e.map(e=>e.id===n.nodeId?function(e,t,n){let r=e.data??{};if("multi-tab-system"===r.kind){let a,i,o=Array.isArray(r.tabs)?r.tabs:[];return{...e,data:{...r,tabs:(a=o.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}}return"file-tab-viewer"===r.kind||"data-table-tab-viewer"===r.kind&&"data-table-tab-viewer"===t.kind?{...e,data:{...r,tab:t}}:e}(e,l,n.insertIndex):e)),n?.nodeId&&s||b(l,u??{x:496,y:336})}catch{h$.error("文件预览打开失败")}},[b,t,r,u]),j=ew.useCallback(e=>{let n=t.find(e=>"multi-tab-system"===(e.data??{}).kind);w(e,n?{nodeId:n.id}:void 0)},[t,w]),k=ew.useCallback(async(e,t,n)=>{let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw h$.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uX({machineId:a,path:r,content:n}),o={...t,title:i.name,modified:!1,defaultValue:"utf-8"===i.encoding?i.content:n,file:{...t.file,name:i.name,path:i.path,machineId:i.machine.id,mimeType:i.mimeType,kind:t.file?.kind,size:i.size,truncated:i.truncated}};x(e,o),h$.success("文件已保存")}catch(e){throw h$.error("文件保存失败"),e}},[x]),S=ew.useCallback((e,t,n)=>{b(t,p(n.clientX,n.clientY))},[b,p]),N=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),r=n.find(e=>e.id===t),a=r?r.payloads?.[Gq]:void 0;if(a)return a;let i=e.dataTransfer.getData(Gq);if(i)try{return JSON.parse(i)}catch{return}},[n]),C=ew.useCallback((e,t,n)=>{r(r=>r.map(r=>r.id!==e?r:function(e,t,n){let r=e.data??{},a=Array.isArray(r.tabs)?r.tabs:[],i=new Set(a.map(e=>e.id)),o=n.tab.id,l=2;for(;i.has(o);)o=`${n.tab.id}-${l}`,l+=1;let s=[...a];return s.splice(Math.max(0,Math.min(t,s.length)),0,{...n.tab,id:o}),{...e,data:{...r,tabs:s,activeTabId:o}}}(r,t,n)))},[r]),M=ew.useCallback((e,t,n)=>{let r=N(n);r&&C(e,t,r)},[N,C]),E=ew.useCallback(e=>(function(e,t){for(let n of[...e].reverse()){if("multi-tab-system"!==(n.data??{}).kind)continue;let e=function(e){let t="number"==typeof e.width?e.width:"number"==typeof e.style?.width?e.style.width:"string"==typeof e.style?.width?Number.parseFloat(e.style.width):192,n="number"==typeof e.height?e.height:"number"==typeof e.style?.height?e.style.height:"string"==typeof e.style?.height?Number.parseFloat(e.style.height):112;return{width:Number.isFinite(t)?t:192,height:Number.isFinite(n)?n:112}}(n),r=t.x>=n.position.x&&t.x<=n.position.x+e.width,a=t.y>=n.position.y&&t.y<=n.position.y+e.height;if(r&&a)return n}})(t,e),[t]),O=ew.useCallback((t,n,r)=>(function(e,t,n,r){let a=Array.from(e.current?.querySelectorAll(".react-flow__node")??[]).find(e=>e.getAttribute("data-id")===t),i=a?.querySelector('[data-slot="multi-tab-list"]');if(!i)return r;let o=Array.from(i.querySelectorAll("[data-tab-id]"));for(let[e,t]of o.entries()){let r=t.getBoundingClientRect();if(n<r.left+r.width/2)return e}return o.length})(e,t,n,r),[e]),P=function({nodes:e,onTabsChange:t,onActiveTabChange:n,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabChange:i,onSaveFileTab:o,onTerminalStateChange:l,onTabDetach:s,onExternalTabDrop:c}){return ew.useMemo(()=>e.map(e=>{let d=e.data??{},u=(e.data??{}).kind;return u?{...e,data:{...d,content:(0,ey.jsx)(JC,{kind:u,nodeId:e.id,tab:d.tab,tabs:d.tabs,activeTabId:d.activeTabId,terminalScopeId:`canvas:node:${e.id}`,terminalState:d.terminal,onTerminalStateChange:t=>l(e.id,t),onRequestFileTab:r,onOpenWorkspaceFile:a,onTabsChange:t,onTabChange:i,onSaveFileTab:o,onActiveTabChange:n,onTabDetach:s,onExternalTabDrop:c})}}:e}),[e,n,c,a,r,o,i,s,l,t])}({nodes:t,onTabsChange:g,onActiveTabChange:v,onRequestFileTab:m,onOpenWorkspaceFile:j,onTabChange:x,onSaveFileTab:k,onTerminalStateChange:y,onTabDetach:S,onExternalTabDrop:M}),A=ew.useCallback(e=>{s.current+=1;let n=`${e.id}-${t.length+s.current}`;r(t=>[...t,function({template:e,nodeId:t,center:n}){let r={contentScale:2,kind:e.id};return"multi-tab-system"===e.id?r.tabs=[]:uB(e.id)&&(r.tab=uH(e.id,`${t}-tab`)),{id:t,type:"blank",position:uR(n,e.size),data:r,width:e.size.width,height:e.size.height,style:uT(e.size)}}({template:e,nodeId:n,center:u??{x:496,y:336}})]),i(void 0),d(!1),f(void 0)},[t.length,r,i,u]),I=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let a=n.find(e=>e.id===t),o=p(e.clientX,e.clientY),s=N(e),c=s?E(o):void 0;if(s&&c){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=c.data??{},n=Array.isArray(t.tabs)?t.tabs:[],r=O(c.id,e.clientX,n.length);C(c.id,r,s),i(void 0);return}let d=a?a.payloads?.[GW]:void 0;if(!a||!d)return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",l.current+=1;let u=`${d.node.id}-drop-${l.current}`;r(e=>[...e,function({source:e,nodeId:t,center:n}){let r={width:e.width??192,height:e.height??112};return{...e,id:t,position:uR(n,r),style:e.style??uT(r),selected:!1,data:{...e.data??{},resizing:!1}}}({source:d.node,nodeId:u,center:o})]),i(u)},[n,E,N,p,O,C,r,i]),z=ew.useCallback(e=>{Array.from(e.dataTransfer.types).some(e=>[GW,Gq].includes(e))&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[]),T=ew.useCallback((e,{flowPosition:t})=>{"add"===e&&(f(t),d(!0))},[]),D=ew.useCallback(e=>{a(t=>{if(t.find(t=>t.source===e.source&&t.target===e.target))return t;let n=t.find(t=>t.source===e.target&&t.target===e.source);return n?t.map(e=>e.id===n.id?{...e,data:{...e.data??{},bidirectional:!0}}:e):[...t,{id:`edge-${e.source}-${e.target}-${t.length+1}`,type:"connection",source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,data:{anchors:[]}}]})},[a]),R=ew.useCallback((e,t,n)=>{"cut-edge"===e?a(e=>e.filter(e=>e.id!==t)):a(r=>r.map(r=>{if(r.id!==t)return r;let a=[...r.data?.anchors??[]];return"add-anchor"===e&&n.anchor&&a.splice(n.anchorIndex??a.length,0,n.anchor),"move-anchor"===e&&n.anchor&&void 0!==n.anchorIndex&&(a[n.anchorIndex]=n.anchor),"delete-anchor"===e&&void 0!==n.anchorIndex&&a.splice(n.anchorIndex,1),{...r,data:{...r.data??{},anchors:a}}}))},[a]),_=ew.useCallback((e,n,{snappedPosition:l})=>{if("copy"===e)return void r(e=>{let t=e.find(e=>e.id===n);if(!t)return e;let r=`${t.id}-copy-${e.length+1}`;return i(r),[...e,{...t,id:r,position:l,selected:!1,data:{...t.data??{},resizing:!1}}]});if("cut"===e){let e,l,s,c,d,u=t.find(e=>e.id===n);if(!u)return;let f=(s=(l=function(e){let t=e.data??{},n=t.tab;if(n?.id&&uB(n.kind))return n;let r=t.kind;if(uB(r))return uH(r,e.id)}(e=uU(u)))?{tab:l,sourceNodeId:u.id}:void 0,c={[GW]:{node:e}},d={"application/vnd.vantaloom.clip-kind":l?"canvas-tab":"canvas-node",[GW]:u.id},s&&(c[Gq]=s,d[Gq]=JSON.stringify(s)),{id:`clip-${u.id}`,title:l?.title??"画布节点",description:l?"来自画布的独立标签页。":"来自节点画布的空白节点。",meta:`${Math.round(u.width??192)}x${Math.round(u.height??112)}`,icon:l?uV(l.kind):(0,ey.jsx)(uw,{className:"size-4"}),dragData:d,payloads:c});o(e=>[f,...e.filter(e=>e.id!==f.id)]),r(e=>e.filter(e=>e.id!==n)),a(e=>e.filter(e=>e.source!==n&&e.target!==n)),i(void 0)}},[t,o,a,r,i]);return{addPaletteOpen:c,addTemplateNode:A,filePickerDialog:(0,ey.jsx)(XI,{open:void 0!==h,onOpenChange:e=>{e||m(void 0)},onSelectFile:e=>{m(void 0),w(e,h)}}),handleAddPaletteOpenChange:function(e){d(e),e||f(void 0)},handleCanvasAction:T,handleCanvasDragOver:z,handleCanvasDrop:I,handleNodeCanvasConnect:D,handleNodeCanvasEdgeAction:R,handleNodeCanvasNodeAction:_,renderedCanvasNodes:P}}({workspaceRef:d,nodes:e,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c});return(0,ey.jsxs)("div",{ref:d,className:"vtl-app-background vtl-canvas-workspace relative h-full w-full overflow-hidden",onDragOver:p,onDrop:g,children:[(0,ey.jsx)(sy,{"aria-label":"新建画布",className:"h-full min-h-0 rounded-none border-0",viewportClassName:"h-full",nodes:w,edges:t,nodeTypes:uA,edgeTypes:uI,onNodesChange:a,onEdgesChange:i,selectedNodeId:n,onSelectedNodeChange:s,defaultViewport:{x:0,y:0,zoom:.5},labels:{actions:"画布操作",add:"添加节点",select:"普通鼠标",connect:"连接工具",cut:"剪刀工具",drag:"拖拽工具",modeTools:"模式工具",resetZoom:"重置缩放",viewportTools:"视口工具",lockViewport:"锁定视口",visualSnap:"视觉吸附",nodeSnap:"节点吸附",snapTools:"吸附工具",nodeActions:"节点操作",resizeNode:"调整大小",copyNode:"复制节点",cutNode:"剪切节点"},onCanvasAction:m,onNodeCanvasConnect:v,onNodeCanvasEdgeAction:x,onNodeCanvasNodeAction:y}),(0,ey.jsx)(et3,{open:u,onOpenChange:h,onAdd:f}),b,(0,ey.jsx)(hW,{position:"top-right"})]})}vw.length;let et8={delete:"Delete",empty:"Drop here",title:"Trash"};function et7({active:e=!1,items:t=[],labels:n,className:r,onDrop:a,onDelete:i,onItemRestore:o,...l}){let s={...et8,...n},[c,d]=ew.useState(!1),u=ew.useRef(0),f=e||c||t.length>0;return ew.useEffect(()=>{e||(u.current=0,d(!1))},[e]),(0,ey.jsx)("div",{"data-slot":"trash-drop-zone","data-visible":f,"data-drag-inside":c,className:(0,eI.cn)("fixed top-4 left-1/2 z-50 -translate-x-1/2 transition-[opacity,transform] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]",f?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-5 opacity-0",r),onDragEnter:function(e){e.preventDefault(),u.current+=1,d(!0)},onDragLeave:function(){u.current=Math.max(0,u.current-1),0===u.current&&d(!1)},onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",d(!0)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),u.current=0,d(!1);let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id")||e.dataTransfer.getData("text/plain"),n=e.dataTransfer.getData("text/plain")||t||"Dropped item",r=e.dataTransfer.getData("application/vnd.vantaloom.clip-kind");t&&a?.({id:t,title:n,meta:r,nativeEvent:e})},...l,children:(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-12 overflow-hidden rounded-xl border-2 border-background bg-destructive text-destructive-foreground shadow-lg shadow-black/15 transition-[width,min-height,background-color,border-color,padding,box-shadow] duration-300","dark:border-destructive dark:bg-background dark:text-destructive",c||t.length>0?"w-64 border-dashed bg-destructive/12 p-2 text-destructive dark:bg-destructive/8":"flex size-12 items-center justify-center p-0"),children:c||t.length>0?(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-14 items-center justify-center gap-2 rounded-lg border border-dashed border-destructive/55 bg-destructive/8 px-3 text-sm font-medium text-destructive",children:[(0,ey.jsx)(yi,{className:"size-4"}),(0,ey.jsx)("span",{children:s.empty})]}),t.length>0?(0,ey.jsx)("div",{className:"grid max-h-36 gap-1 overflow-y-auto pr-1",children:t.map(e=>(0,ey.jsxs)("div",{className:"flex h-8 items-center gap-2 rounded-md border border-destructive/25 bg-background/80 px-2 text-foreground",children:[(0,ey.jsx)("button",{type:"button","aria-label":`Restore ${e.title}`,className:"flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",onClick:()=>o?.(e),children:(0,ey.jsx)(fg.XIcon,{className:"size-3.5"})}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}):null]},e.id))}):null,t.length>0?(0,ey.jsx)("button",{type:"button",className:"h-8 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 dark:border dark:border-destructive dark:bg-background dark:text-destructive dark:hover:bg-destructive/10",onClick:()=>i?.(t),children:s.delete}):null]}):(0,ey.jsx)(yi,{className:"size-5"})})})}function et9({hidden:e,items:t,trashItems:n,trashClipboardItems:r,draggingId:a,onDraggingChange:i,onItemsChange:o,onTrashItemsChange:l,onTrashClipboardItemsChange:s}){let c=ew.useRef(0),[d,u]=ew.useState(!1);return(ew.useEffect(()=>{u(!0)},[]),d)?(0,iy.createPortal)((0,ey.jsxs)("div",{className:(0,eI.cn)("pointer-events-none fixed inset-0 z-40 overflow-visible transition-opacity duration-200",e&&"opacity-0"),children:[(0,ey.jsx)(et7,{active:!e&&void 0!==a,items:e?[]:n,className:(0,eI.cn)(e&&"pointer-events-none"),labels:{delete:"删除",empty:"拖入暂存"},onDrop:({id:e,title:n,meta:r})=>{let a=t.find(t=>t.id===e);a&&(s(t=>({...t,[e]:a})),l(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:n,meta:r,icon:a.icon}]))},onDelete:e=>{let t=new Set(e.map(e=>e.id));l(e=>e.filter(e=>!t.has(e.id))),s(e=>{let n={...e};for(let e of t)delete n[e];return n})},onItemRestore:e=>{let n=r[e.id];n&&o([n,...t.filter(e=>e.id!==n.id)]),l(t=>t.filter(t=>t.id!==e.id)),s(t=>{let n={...t};return delete n[e.id],n})}}),t.length>0?(0,ey.jsx)("div",{className:(0,eI.cn)("pointer-events-auto absolute top-4 right-4 w-80 max-w-[calc(100vw-2rem)] transition-[opacity,transform] duration-200",e&&"pointer-events-none -translate-y-2 opacity-0"),children:(0,ey.jsx)(Xq,{items:t,title:"剪切板",labels:{empty:"剪切板为空",dragHandle:"拖拽卡片"},expansionDirection:"down-left",removeOnExternalDrop:!0,maxExpandedHeight:420,onItemDuplicate:(e,{item:n,index:r})=>{let a,i,l,s,d;return c.current+=1,a=n.payloads?.[GK],i=n.payloads?{...n.payloads}:void 0,l=n.payloads?.[GG],a&&i&&(i[GK]={...a,config:{...a.config}}),l&&i&&(i[GG]={...l,config:l.config?{...l.config}:l.config}),s={...n,id:`${n.id}-copy-${c.current}`,title:`${n.title} copy`,payloads:i,dragData:{...n.dragData,...a?{"application/vnd.vantaloom.dashboard-widget-config":JSON.stringify(a.config)}:{}}},void((d=[...t]).splice(r+1,0,s),o(d))},onItemsRemove:e=>o(e),onItemsReorder:e=>o(e),onItemDragStart:({item:e})=>i(e.id),onItemDragEnd:()=>i(void 0)})}):null]}),document.body):null}let ene=(0,ek.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),ent=(0,ek.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),enn=(0,ek.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),enr=(0,ek.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),ena=(0,ek.default)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),eni=(0,ek.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),eno=(0,ek.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),enl=(0,ek.default)("users-round",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]),ens=(0,ek.default)("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);var enc="Collapsible",[end,enu]=cr(enc),[enf,enh]=end(enc),enm=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=cu({prop:r,defaultProp:a??!1,onChange:o,caller:enc});return(0,ey.jsx)(enf,{scope:n,disabled:i,contentId:cc(),open:s,onOpenToggle:ew.useCallback(()=>c(e=>!e),[c]),children:(0,ey.jsx)(cp.div,{"data-state":enb(s),"data-disabled":i?"":void 0,...l,ref:t})})});enm.displayName=enc;var enp="CollapsibleTrigger",eng=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=enh(enp,n);return(0,ey.jsx)(cp.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":enb(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:ci(e.onClick,a.onOpenToggle)})});eng.displayName=enp;var env="CollapsibleContent",enx=ew.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=enh(env,e.__scopeCollapsible);return(0,ey.jsx)(cz,{present:n||a.open,children:({present:e})=>(0,ey.jsx)(eny,{...r,ref:t,present:e})})});enx.displayName=env;var eny=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=enh(env,n),[l,s]=ew.useState(r),c=ew.useRef(null),d=(0,ca.useComposedRefs)(t,c),u=ew.useRef(0),f=u.current,h=ew.useRef(0),m=h.current,p=o.open||l,g=ew.useRef(p),v=ew.useRef(void 0);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),co(()=>{let e=c.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,h.current=t.width,g.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),s(r)}},[o.open,r]),(0,ey.jsx)(cp.div,{"data-state":enb(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:p&&a})});function enb(e){return e?"open":"closed"}var enw=e.i(91e3);let enj={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-model-routes":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-system-prompt":"settings","preferences-layout":"settings","network-topology":"settings","check-update":"settings",account:"settings"};function enk({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeCanvasId:a,onItemSelect:i,onOpenConversation:o,onOpenCanvas:l,onOpenConversationSettings:s,onOpenCanvasSettings:c,onConversationDeleted:d,onAccountSettings:u,subagentTree:f,activeSubagentPath:h,onOpenSubagent:m,hideCanvas:p,className:g}){let v=enj[n]??(en_.some(e=>e.items.some(e=>e.id===n))?"settings":p?"agent":"canvas");p&&"canvas"===v&&(v="agent");let[x,y]=ew.useState(v);ew.useEffect(()=>{y(v)},[v]);let b=p?e.filter(e=>"canvas"!==e.id):e,w=t.find(e=>e.id===x);return(0,ey.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,eI.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",g),children:[(0,ey.jsx)("nav",{className:"mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:b.map(e=>{let t=e.id===x;return(0,ey.jsxs)("button",{type:"button",onClick:()=>y(e.id),className:(0,eI.cn)("flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"border border-border/50 bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"truncate",children:e.label})]},e.id)})}),"canvas"===x?(0,ey.jsx)(enS,{activeCanvasId:a,onItemSelect:i,onOpenCanvas:l,onOpenCanvasSettings:c}):"agent"===x?(0,ey.jsx)(enE,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:s,onConversationDeleted:d,subagentTree:f,activeSubagentPath:h,onOpenSubagent:m}):(0,ey.jsx)(enD,{content:w,activeWorkspace:n,onItemSelect:i}),(0,ey.jsx)(enH,{onItemSelect:i,onAccountSettings:u})]})}function enS({activeCanvasId:e,onItemSelect:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let{recents:a,loading:i}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0);return ew.useEffect(()=>{let e=!0;async function n(){try{let{canvases:n}=await Qf();if(!e)return;let r=[...n].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r)}catch{}finally{e&&r(!1)}}n();let a=setInterval(()=>void n(),1e4);return()=>{e=!1,clearInterval(a)}},[]),{recents:e,loading:n}}(),o=a.filter(e=>!0===e.running),l=a.filter(e=>!0!==e.running),s=i&&0===a.length;return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,ey.jsx)(enF,{icon:eni,label:QI.canvasNew,onClick:()=>t({item:{id:"new-canvas"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[o.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(t=>(0,ey.jsx)(enN,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]}):null,(0,ey.jsx)("div",{className:"mb-2 flex items-center justify-between px-3",children:(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"})}),(0,ey.jsx)("div",{className:"space-y-0.5",children:s?(0,ey.jsx)(enB,{}):0===l.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:"暂无画布"}):l.map(t=>(0,ey.jsx)(enN,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]})]})}function enN({canvas:e,active:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let a=!0===e.running;return(0,ey.jsx)(enT,{title:a?`${e.title} \xb7 运行中`:e.title,label:e.title,active:t,running:a,onOpen:()=>n(e.id,e.ownerMachineId),onOpenSettings:r?()=>r(e.id,e.ownerMachineId):void 0})}let enC="__all__",enM={status:"all",location:enC,sort:"recent"};function enE({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let{recents:s,refresh:c,loading:d,machineNames:u}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState({}),o=ew.useRef(!0),l=ew.useCallback(async()=>{try{let{conversations:e,machineNames:n}=await sO();if(!o.current)return;let r=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r),i(n)}catch{}finally{o.current&&r(!1)}},[]);return ew.useEffect(()=>{o.current=!0,l();let e=setInterval(()=>void l(),1e4);return()=>{o.current=!1,clearInterval(e)}},[l]),{recents:e,refresh:()=>void l(),loading:n,machineNames:a}}(),[f,h]=ew.useState(enM),m=ew.useMemo(()=>{let e=new Set;for(let t of s)e.add(t.ownerMachineId||sN);return Array.from(e)},[s]),p=ew.useCallback(e=>sC(e)?"本机":u[e]??e,[u]),g=ew.useMemo(()=>{let e=s.filter(e=>{let t=!0===e.running;return("running"!==f.status||!!t)&&("idle"!==f.status||!t)&&(f.location===enC||(e.ownerMachineId||sN)===f.location)});return"name"===f.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[s,f]),v=g.filter(e=>!0===e.running),x=g.filter(e=>!0!==e.running),y=f.status!==enM.status||f.location!==enM.location||f.sort!==enM.sort,b=d&&0===s.length,w=ew.useCallback(async e=>{try{await sq(e.id,e.ownerMachineId)}catch{}a?.(e.id),c()},[a,c]),j=ew.useCallback(async e=>{try{let t=await sZ(e.id,void 0,e.ownerMachineId);await c(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[c,n]),k=ew.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),S=o?.[o.length-1]?.id,N=t=>{let a=new Map(t.map(e=>[e.id,e])),o=new Map,s=[];for(let e of t){let t=e.forkOriginId;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=(t,a)=>{let s=t.id!==e||(i?.length??0)===0?null:(0,ey.jsx)(enO,{nodes:i??[],depth:0,ancestors:[],activeIds:k,activeLeafId:S,onOpen:l});return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(enz,{conversation:t,depth:a,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onDelete:w,onFork:j}),s?(0,ey.jsx)("div",{style:a>0?{marginLeft:14*a}:void 0,children:s}):null,(o.get(t.id)??[]).map(e=>c(e,a+1))]},t.id)};return s.map(e=>c(e,0))};return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5","data-tour":"new-conversation",children:(0,ey.jsx)(enF,{icon:tc,label:QI.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[v.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:N(v)})]}):null,(0,ey.jsxs)("div",{className:"mb-2 flex items-center justify-between px-3",children:[(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,ey.jsx)(enA,{filter:f,onChange:h,active:y,locations:m,locationLabel:p})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:b?(0,ey.jsx)(enB,{}):0===x.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:y?"没有符合筛选条件的对话":"暂无对话"}):N(x)})]})]})}function enO({nodes:e,depth:t,ancestors:n,activeIds:r,activeLeafId:a,onOpen:i}){let o=e.filter(e=>(function e(t,n){return!!(t.running||n.has(t.id))||(t.children??[]).some(t=>e(t,n))})(e,r));return 0===o.length?null:(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(e=>{let o=Hn(e.subagentType),l=o.Icon,s=[...n,{id:e.id,ownerMachineId:e.ownerMachineId,name:e.subagentName,subagentType:e.subagentType}],c=e.id===a;return(0,ey.jsxs)("div",{children:[(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*t},onClick:()=>i?.(s),title:e.subagentName||o.label,children:[(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,ey.jsx)(l,{className:(0,eI.cn)("size-3.5 shrink-0",o.color)}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||`${o.label}子代理`}),e.running?(0,ey.jsx)(eM,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,ey.jsx)(enO,{nodes:e.children??[],depth:t+1,ancestors:s,activeIds:r,activeLeafId:a,onOpen:i})]},e.id)})})}let enP={all:"全部",running:"运行中",idle:"空闲"};function enA({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=e.location===enC?"全部":a(e.location);return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,eI.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,ey.jsx)(Qw,{className:"size-4"}),n?(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]})}),(0,ey.jsxs)(bZ,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,ey.jsx)(b0,{children:"筛选与排序"}),(0,ey.jsxs)(bY,{children:[(0,ey.jsxs)(b5,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"状态"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:enP[e.status]})]}),(0,ey.jsx)(b4,{children:(0,ey.jsxs)(bU,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,ey.jsx)(bQ,{value:"all",children:"全部"}),(0,ey.jsx)(bQ,{value:"running",children:"运行中"}),(0,ey.jsx)(bQ,{value:"idle",children:"空闲"})]})})]}),(0,ey.jsxs)(bY,{children:[(0,ey.jsxs)(b5,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,ey.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:i})]}),(0,ey.jsx)(b4,{className:"max-h-72 overflow-y-auto",children:(0,ey.jsxs)(bU,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,ey.jsx)(bQ,{value:enC,children:"全部"}),r.map(e=>(0,ey.jsx)(bQ,{value:e,children:(0,ey.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,ey.jsx)(b1,{}),(0,ey.jsx)(b0,{children:"排序"}),(0,ey.jsxs)(bU,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,ey.jsx)(bQ,{value:"recent",children:"最近活动"}),(0,ey.jsx)(bQ,{value:"name",children:"名称"})]}),n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(b1,{}),(0,ey.jsx)(bJ,{onSelect:()=>t(enM),children:(0,ey.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function enI({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,ey.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,eI.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}function enz({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onDelete:i,onFork:o}){let l=!0===e.running,s=e.settings?.engine??"vantaloom",c="vantaloom"!==s?(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,ey.jsx)(enI,{engine:s}),(0,ey.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,ey.jsx)(enT,{title:l?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:c,active:t,running:l,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a?()=>a(e.id,e.ownerMachineId):void 0,onDelete:i?()=>i(e):void 0,onFork:o?()=>o(e):void 0,deleteLabel:"删除会话"})}function enT({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onDelete:s,onFork:c,deleteLabel:d="删除"}){let[u,f]=ew.useState(!1),h=!!(l||s||c),m=i>0,p=(0,ey.jsxs)(ey.Fragment,{children:[l?(0,ey.jsxs)(bE,{onSelect:()=>l(),children:[(0,ey.jsx)(QH,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(bE,{onSelect:()=>c(),children:[(0,ey.jsx)(Vb,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(bE,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(yi,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]}),g=(0,ey.jsxs)("div",{className:(0,eI.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors",r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:m?{marginLeft:14*i}:void 0,children:[(0,ey.jsxs)("button",{type:"button",title:e,onClick:o,className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[m?(0,ey.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500","aria-label":"运行中"}):(0,ey.jsx)(enV,{active:r}),n??(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),h?(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,ey.jsx)(lY,{className:"size-4"})})}),(0,ey.jsxs)(bZ,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,ey.jsxs)(bJ,{onSelect:()=>l(),children:[(0,ey.jsx)(QH,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(bJ,{onSelect:()=>c(),children:[(0,ey.jsx)(Vb,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(bJ,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(yi,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]})]}):null]});return(0,ey.jsxs)(ey.Fragment,{children:[h?(0,ey.jsxs)(bv,{children:[(0,ey.jsx)(by,{asChild:!0,children:g}),(0,ey.jsx)(bM,{className:"min-w-44",children:p})]}):g,s?(0,ey.jsx)(d4,{open:u,onOpenChange:f,children:(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:d}),(0,ey.jsxs)(ug,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{children:"取消"}),(0,ey.jsx)(uv,{variant:"destructive",onClick:()=>s(),children:"删除"})]})]})}):null]})}function enD({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,ey.jsx)(wz,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,ey.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,ey.jsx)(enL,{activeWorkspace:t,onItemSelect:n},e.id):(0,ey.jsx)(enR,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function enR({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,ey.jsx)(enV,{active:!0})]})}let en_=[{id:"model",title:"模型设置",icon:(0,ey.jsx)(uS,{}),items:[{id:"preferences-model-routes",label:"模型路由",icon:(0,ey.jsx)(mY,{})},{id:"preferences-agent-config",label:"代理配置",icon:(0,ey.jsx)(ub,{})},{id:"preferences-subagent-config",label:"子代理配置",icon:(0,ey.jsx)(enl,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,ey.jsx)(uS,{})}]},{id:"prefs",title:"偏好设置",icon:(0,ey.jsx)(QH,{}),items:[{id:"preferences-system-prompt",label:"系统提示词",icon:(0,ey.jsx)(ena,{})},{id:"preferences-layout",label:"布局排版",icon:(0,ey.jsx)(ent,{})},{id:"preferences-official-extensions",label:"官方扩展",icon:(0,ey.jsx)(Ui,{})}]},{id:"system",title:"系统设置",icon:(0,ey.jsx)(GE,{}),items:[{id:"network-topology",label:"组网关系",icon:(0,ey.jsx)(Qx,{})},{id:"system-downloads",label:"下载",icon:(0,ey.jsx)(x1,{})},{id:"check-update",label:"检查更新",icon:(0,ey.jsx)(ya,{})},{id:"account",label:"Hub 账户",icon:(0,ey.jsx)(eC,{})},{id:"balance-usage",label:"余额用量",icon:(0,ey.jsx)(ens,{})},{id:"feedback",label:"问题反馈",icon:(0,ey.jsx)(jb,{})}]}];function enL({activeWorkspace:e,onItemSelect:t}){return(0,ey.jsx)(ey.Fragment,{children:en_.map(n=>(0,ey.jsx)(en$,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t},n.id))})}function en$({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=ew.useState(!0);return(0,ey.jsxs)(enm,{open:o,onOpenChange:l,children:[(0,ey.jsx)(eng,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,ey.jsx)(vu,{className:(0,eI.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,ey.jsx)(enx,{className:"mt-0.5 space-y-0.5",children:n.map(e=>{let t=e.id===r;return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",t?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),t&&(0,ey.jsx)(enV,{active:!0})]},e.id)})})]})}function enF({icon:e,label:t,onClick:n}){return(0,ey.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",children:[(0,ey.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}function enB(){return(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"}),(0,ey.jsx)("span",{children:"加载中…"})]})}function enV({active:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}function enH({onItemSelect:e,onAccountSettings:t}){let{user:n}=tl(),r=n?.name??QA.product,a=(n?.name??"V").slice(0,1).toUpperCase();return(0,ey.jsx)("div",{className:"mt-auto pt-3",children:(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:a}),(0,ey.jsx)("span",{className:"truncate text-sm text-foreground",children:r})]}),(0,ey.jsx)(mQ,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,ey.jsxs)(bZ,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[n?.email&&(0,ey.jsx)(b0,{className:"truncate font-normal text-muted-foreground",children:n.email}),(0,ey.jsxs)(bJ,{onSelect:()=>e({item:{id:"preferences"}}),children:[(0,ey.jsx)(QH,{}),(0,ey.jsx)("span",{className:"flex-1",children:"设置"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"Ctrl,"})]}),(0,ey.jsxs)(bJ,{disabled:!0,children:[(0,ey.jsx)(ene,{}),(0,ey.jsx)("span",{className:"flex-1",children:"语言"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,ey.jsxs)(bJ,{disabled:!0,children:[(0,ey.jsx)(H0,{}),(0,ey.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{onSelect:()=>{t?t():e({item:{id:"account"}})},children:[(0,ey.jsx)(K2,{}),(0,ey.jsx)("span",{className:"flex-1",children:"Hub 账户"})]}),(0,ey.jsx)(enW,{}),n&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(b1,{}),(0,ey.jsx)(enq,{})]})]})]})})}let enU=["light","dark","jelly"];function enW(){let{resolvedTheme:e,setTheme:t}=(0,hE.useTheme)(),[n,r]=ew.useState(enw.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(enw.appearanceThemeStorageKey)??enw.defaultAppearanceTheme;r(e),(0,enw.applyAppearanceTheme)({theme:e})},[]);let a=n===enw.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=enU[(enU.indexOf(a)+1)%enU.length]??"light";function o(e){r(e),window.localStorage.setItem(enw.appearanceThemeStorageKey,e),(0,enw.applyAppearanceTheme)({theme:e})}let l="dark"===a?enr:eno;return(0,ey.jsxs)(bJ,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(enw.jellyAppearanceTheme);return}o(enw.defaultAppearanceTheme),t(i)}()},children:[(0,ey.jsx)(l,{}),(0,ey.jsx)("span",{className:"flex-1",children:QA.theme}),(0,ey.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function enq(){let{logout:e}=tl();return(0,ey.jsxs)(bJ,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,ey.jsx)(enn,{}),(0,ey.jsx)("span",{className:"flex-1",children:"退出登录"})]})}let enK=ew.default.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),enG=()=>{let e=ew.default.useContext(enK);if(!e)throw Error("useDrawerContext must be used within a Drawer.Root");return e};function enX(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function enY(){return enZ(/^iPhone/)||enZ(/^iPad/)||enZ(/^Mac/)&&navigator.maxTouchPoints>1}function enZ(e){return"u">typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if(!e||"u"<typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");let enJ="u">typeof window?ew.useLayoutEffect:ew.useEffect;function enQ(...e){return(...t)=>{for(let n of e)"function"==typeof n&&n(...t)}}let en0="u">typeof document&&window.visualViewport;function en1(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function en2(e){for(en1(e)&&(e=e.parentElement);e&&!en1(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}let en5=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),en4=0;function en3(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function en6(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=en2(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=r-n)}e=t.parentElement}}function en8(e){return e instanceof HTMLInputElement&&!en5.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function en7(...e){return ew.useCallback(function(...e){return t=>e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}(...e),e)}let en9=new WeakMap;function ere(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):(r[t]=e.style[t],e.style[t]=n)}),n||en9.set(e,r)}let ert=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function ern(e,t){if(!e)return null;let n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform,a=r.match(/^matrix3d\((.+)\)$/);return a?parseFloat(a[1].split(", ")[ert(t)?13:12]):(a=r.match(/^matrix\((.+)\)$/))?parseFloat(a[1].split(", ")[ert(t)?5:4]):null}function err(e,t){if(!e)return()=>{};let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}let era=[.32,.72,0,1],eri="vaul-dragging";function ero(e){let t=ew.default.useRef(e);return ew.default.useEffect(()=>{t.current=e}),ew.default.useMemo(()=>(...e)=>null==t.current?void 0:t.current.call(t,...e),[])}function erl({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,a]=function({defaultProp:e,onChange:t}){let n=ew.default.useState(e),[r]=n,a=ew.default.useRef(r),i=ero(t);return ew.default.useEffect(()=>{a.current!==r&&(i(r),a.current=r)},[r,a,i]),n}({defaultProp:t,onChange:n}),i=void 0!==e,o=i?e:r,l=ero(n);return[o,ew.default.useCallback(t=>{if(i){let n="function"==typeof t?t(e):t;n!==e&&l(n)}else a(t)},[i,e,a,l])]}let ers=()=>()=>{},erc=null,erd=ew.default.forwardRef(function({...e},t){let{overlayRef:n,snapPoints:r,onRelease:a,shouldFade:i,isOpen:o,modal:l,shouldAnimate:s}=enG(),c=en7(t,n),d=r&&r.length>0;if(!l)return null;let u=ew.default.useCallback(e=>a(e),[a]);return ew.default.createElement(dT,{onMouseUp:u,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&d?"true":"false","data-vaul-snap-points-overlay":o&&i?"true":"false","data-vaul-animate":(null==s?void 0:s.current)?"true":"false",...e})});erd.displayName="Drawer.Overlay";let eru=ew.default.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},a){let{drawerRef:i,onPress:o,onRelease:l,onDrag:s,keyboardIsOpen:c,snapPointsOffset:d,activeSnapPointIndex:u,modal:f,isOpen:h,direction:m,snapPoints:p,container:g,handleOnly:v,shouldAnimate:x,autoFocus:y}=enG(),[b,w]=ew.default.useState(!1),j=en7(a,i),k=ew.default.useRef(null),S=ew.default.useRef(null),N=ew.default.useRef(!1),C=p&&p.length>0;function M(e){k.current=null,N.current=!1,l(e)}return!function(){let{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:a}=enG(),i=ew.default.useRef(null),o=(0,ew.useMemo)(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}ew.default.useEffect(()=>{if(t&&n){i.current&&clearTimeout(i.current);let t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;!function(...e){}(r&&!a?err(document.body,{background:"black"}):ers,err(t,{transformOrigin:ert(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${era.join(",")})`}));let n=err(t,{borderRadius:"8px",overflow:"hidden",...ert(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{n(),i.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},500)}}},[t,n,o])}(),ew.default.useEffect(()=>{C&&window.requestAnimationFrame(()=>{w(!0)})},[]),ew.default.createElement(dL,{"data-vaul-drawer-direction":m,"data-vaul-drawer":"","data-vaul-delayed-snap-points":b?"true":"false","data-vaul-snap-points":h&&C?"true":"false","data-vaul-custom-container":g?"true":"false","data-vaul-animate":(null==x?void 0:x.current)?"true":"false",...r,ref:j,style:d&&d.length>0?{"--snap-point-height":`${d[null!=u?u:0]}px`,...t}:t,onPointerDown:e=>{v||(null==r.onPointerDown||r.onPointerDown.call(r,e),k.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==n||n(e),y||e.preventDefault()},onPointerDownOutside:t=>{(null==e||e(t),!f||t.defaultPrevented)?t.preventDefault():c.current&&(c.current=!1)},onFocusOutside:e=>{if(!f)return void e.preventDefault()},onPointerMove:e=>{if(S.current=e,v||(null==r.onPointerMove||r.onPointerMove.call(r,e),!k.current))return;let t=e.pageY-k.current.y,n=e.pageX-k.current.x,a="touch"===e.pointerType?10:2;((e,t,n=0)=>{if(N.current)return!0;let r=Math.abs(e.y),a=Math.abs(e.x),i=a>r,o=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*o<0)&&a>=0&&a<=n)return i}else if(!(e.y*o<0)&&r>=0&&r<=n)return!i;return N.current=!0,!0})({x:n,y:t},m,a)?s(e):(Math.abs(n)>a||Math.abs(t)>a)&&(k.current=null)},onPointerUp:e=>{null==r.onPointerUp||r.onPointerUp.call(r,e),k.current=null,N.current=!1,l(e)},onPointerOut:e=>{null==r.onPointerOut||r.onPointerOut.call(r,e),M(S.current)},onContextMenu:e=>{null==r.onContextMenu||r.onContextMenu.call(r,e),S.current&&M(S.current)}})});eru.displayName="Drawer.Content",ew.default.forwardRef(function({preventCycle:e=!1,children:t,...n},r){let{closeDrawer:a,isDragging:i,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:s,dismissible:c,handleOnly:d,isOpen:u,onPress:f,onDrag:h}=enG(),m=ew.default.useRef(null),p=ew.default.useRef(!1);function g(){m.current&&window.clearTimeout(m.current),p.current=!1}return ew.default.createElement("div",{onClick:function(){p.current?g():window.setTimeout(()=>{!function(){if(i||e||p.current)return g();if(g(),!o||0===o.length){c||a();return}if(l===o[o.length-1]&&c)return a();let t=o.findIndex(e=>e===l);-1===t||s(o[t+1])}()},120)},onPointerCancel:g,onPointerDown:e=>{d&&f(e),m.current=window.setTimeout(()=>{p.current=!0},250)},onPointerMove:e=>{d&&h(e)},ref:r,"data-vaul-drawer-visible":u?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},ew.default.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))}).displayName="Drawer.Handle";let erf=function({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:a,snapPoints:i,shouldScaleBackground:l=!1,setBackgroundColorOnScale:s=!0,closeThreshold:c=.25,scrollLockTimeout:d=100,dismissible:u=!0,handleOnly:f=!1,fadeFromIndex:h=i&&i.length-1,activeSnapPoint:m,setActiveSnapPoint:p,fixed:g,modal:v=!0,onClose:x,nested:y,noBodyStyles:b=!1,direction:w="bottom",defaultOpen:j=!1,disablePreventScroll:k=!0,snapToSequentialPoint:S=!1,preventScrollRestoration:N=!1,repositionInputs:C=!0,onAnimationEnd:M,container:E,autoFocus:O=!1}){var P,A;let[I=!1,z]=erl({defaultProp:j,prop:e,onChange:e=>{null==t||t(e),e||y||ed(),setTimeout(()=>{null==M||M(e)},500),e&&!v&&"u">typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[T,D]=ew.default.useState(!1),[R,_]=ew.default.useState(!1),[L,$]=ew.default.useState(!1),F=ew.default.useRef(null),B=ew.default.useRef(null),V=ew.default.useRef(null),H=ew.default.useRef(null),U=ew.default.useRef(null),W=ew.default.useRef(!1),q=ew.default.useRef(null),K=ew.default.useRef(0),G=ew.default.useRef(!1),X=ew.default.useRef(!j),Y=ew.default.useRef(0),Z=ew.default.useRef(null),J=ew.default.useRef((null==(P=Z.current)?void 0:P.getBoundingClientRect().height)||0),Q=ew.default.useRef((null==(A=Z.current)?void 0:A.getBoundingClientRect().width)||0),ee=ew.default.useRef(0),et=ew.default.useCallback(e=>{i&&e===eo.length-1&&(B.current=new Date)},[]),{activeSnapPoint:en,activeSnapPointIndex:er,setActiveSnapPoint:ea,onRelease:ei,snapPointsOffset:eo,onDrag:el,shouldFade:es,getPercentageDragged:ec}=function({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:a,fadeFromIndex:i,onSnapPointChange:o,direction:l="bottom",container:s,snapToSequentialPoint:c}){let[d,u]=erl({prop:e,defaultProp:null==n?void 0:n[0],onChange:t}),[f,h]=ew.default.useState("u">typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);ew.default.useEffect(()=>{function e(){h({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let m=ew.default.useMemo(()=>d===(null==n?void 0:n[n.length-1])||null,[n,d]),p=ew.default.useMemo(()=>{var e;return null!=(e=null==n?void 0:n.findIndex(e=>e===d))?e:null},[n,d]),g=n&&n.length>0&&(i||0===i)&&!Number.isNaN(i)&&n[i]===d||!n,v=ew.default.useMemo(()=>{var e;let t=s?{width:s.getBoundingClientRect().width,height:s.getBoundingClientRect().height}:"u">typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};return null!=(e=null==n?void 0:n.map(e=>{let n="string"==typeof e,r=0;if(n&&(r=parseInt(e,10)),ert(l)){let a=n?r:f?e*t.height:0;return f?"bottom"===l?t.height-a:-t.height+a:a}let a=n?r:f?e*t.width:0;return f?"right"===l?t.width-a:-t.width+a:a}))?e:[]},[n,f,s]),x=ew.default.useMemo(()=>null!==p?null==v?void 0:v[p]:null,[v,p]),y=ew.default.useCallback(e=>{var t;let s=null!=(t=null==v?void 0:v.findIndex(t=>t===e))?t:null;o(s),ere(r.current,{transition:`transform 0.5s cubic-bezier(${era.join(",")})`,transform:ert(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),v&&s!==v.length-1&&void 0!==i&&s!==i&&s<i?ere(a.current,{transition:`opacity 0.5s cubic-bezier(${era.join(",")})`,opacity:"0"}):ere(a.current,{transition:`opacity 0.5s cubic-bezier(${era.join(",")})`,opacity:"1"}),u(null==n?void 0:n[Math.max(s,0)])},[r.current,n,v,i,a,u]);return ew.default.useEffect(()=>{if(d||e){var t;let r=null!=(t=null==n?void 0:n.findIndex(t=>t===e||t===d))?t:-1;v&&-1!==r&&"number"==typeof v[r]&&y(v[r])}},[d,e,n,v,y]),{isLastSnapPoint:m,activeSnapPoint:d,shouldFade:g,getPercentageDragged:function(e,t){if(!n||"number"!=typeof p||!v||void 0===i)return null;let r=p===i-1;if(p>=i&&t)return 0;if(r&&!t)return 1;if(!g&&!r)return null;let a=r?p+1:p-1,o=e/Math.abs(r?v[a]-v[a-1]:v[a+1]-v[a]);return r?1-o:o},setActiveSnapPoint:u,activeSnapPointIndex:p,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:o}){if(void 0===i)return;let s="bottom"===l||"right"===l?(null!=x?x:0)-e:(null!=x?x:0)+e,d=p===i-1,u=0===p,f=e>0;if(d&&ere(a.current,{transition:`opacity 0.5s cubic-bezier(${era.join(",")})`}),!c&&r>2&&!f)return void(o?t():y(v[0]));if(!c&&r>2&&f&&v&&n)return void y(v[n.length-1]);let h=null==v?void 0:v.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-s)<Math.abs(e-s)?t:e),g=ert(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*g){let e=f?1:-1;return e>0&&m&&n?void y(v[n.length-1]):void(u&&e<0&&o&&t(),null===p||y(v[p+e]))}y(h)},onDrag:function({draggedDistance:e}){if(null===x)return;let t="bottom"===l||"right"===l?x-e:x+e;("bottom"===l||"right"===l)&&t<v[v.length-1]||("top"===l||"left"===l)&&t>v[v.length-1]||ere(r.current,{transform:ert(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:v}}({snapPoints:i,activeSnapPointProp:m,setActiveSnapPointProp:p,drawerRef:Z,fadeFromIndex:h,overlayRef:F,onSnapPointChange:et,direction:w,container:E,snapToSequentialPoint:S});!function(e={}){let{isDisabled:t}=e;enJ(()=>{if(!t){var e,n,r;let t,a,i,l,s,c,d;return 1==++en4&&enY()&&(i=0,l=window.pageXOffset,s=window.pageYOffset,c=enQ((e=document.documentElement,n="paddingRight",r=`${window.innerWidth-document.documentElement.clientWidth}px`,t=e.style[n],e.style[n]=r,()=>{e.style[n]=t})),window.scrollTo(0,0),d=enQ(en3(document,"touchstart",e=>{((a=en2(e.target))!==document.documentElement||a!==document.body)&&(i=e.changedTouches[0].pageY)},{passive:!1,capture:!0}),en3(document,"touchmove",e=>{if(!a||a===document.documentElement||a===document.body)return void e.preventDefault();let t=e.changedTouches[0].pageY,n=a.scrollTop,r=a.scrollHeight-a.clientHeight;0!==r&&((n<=0&&t>i||n>=r&&t<i)&&e.preventDefault(),i=t)},{passive:!1,capture:!0}),en3(document,"touchend",e=>{let t=e.target;en8(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},{passive:!1,capture:!0}),en3(document,"focus",e=>{let t=e.target;en8(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",en0&&(en0.height<window.innerHeight?requestAnimationFrame(()=>{en6(t)}):en0.addEventListener("resize",()=>en6(t),{once:!0}))}))},!0),en3(window,"scroll",()=>{window.scrollTo(0,0)})),o=()=>{c(),d(),window.scrollTo(l,s)}),()=>{0==--en4&&(null==o||o())}}},[t])}({isDisabled:!I||R||!v||L||!T||!C||!k});let{restorePositionSetting:ed}=function({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:a,noBodyStyles:i}){let[o,l]=ew.default.useState(()=>"u">typeof window?window.location.href:""),s=ew.default.useRef(0),c=ew.default.useCallback(()=>{if(enX()&&null===erc&&e&&!i){erc={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};let{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-s.current}px`,left:`${-e}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{let e=t-window.innerHeight;e&&s.current>=t&&(document.body.style.top=`${-(s.current+e)}px`)}),300)}},[e]),d=ew.default.useCallback(()=>{if(enX()&&null!==erc&&!i){let e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,erc),window.requestAnimationFrame(()=>{a&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),erc=null}},[o]);return ew.default.useEffect(()=>{function e(){s.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),ew.default.useEffect(()=>{if(t)return()=>{"u"<typeof document||document.querySelector("[data-vaul-drawer]")||d()}},[t,d]),ew.default.useEffect(()=>{!n&&r&&(e?(window.matchMedia("(display-mode: standalone)").matches||c(),t||window.setTimeout(()=>{d()},500)):d())},[e,r,o,t,n,c,d]),{restorePositionSetting:d}}({isOpen:I,modal:v,nested:null!=y&&y,hasBeenOpened:T,preventScrollRestoration:N,noBodyStyles:b});function eu(){return(window.innerWidth-26)/window.innerWidth}function ef(e,t){var n;let r=e,a=null==(n=window.getSelection())?void 0:n.toString(),i=Z.current?ern(Z.current,w):null,o=new Date;if("SELECT"===r.tagName||r.hasAttribute("data-vaul-no-drag")||r.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(B.current&&o.getTime()-B.current.getTime()<500)return!1;if(null!==i&&("bottom"===w?i>0:i<0))return!0;if(a&&a.length>0)return!1;if(U.current&&o.getTime()-U.current.getTime()<d&&0===i||t)return U.current=o,!1;for(;r;){if(r.scrollHeight>r.clientHeight){if(0!==r.scrollTop)return U.current=new Date,!1;if("dialog"===r.getAttribute("role"))break}r=r.parentNode}return!0}function eh(e){R&&Z.current&&(Z.current.classList.remove(eri),W.current=!1,_(!1),H.current=new Date),null==x||x(),e||z(!1),setTimeout(()=>{i&&ea(i[0])},500)}function em(){if(!Z.current)return;let e=document.querySelector("[data-vaul-drawer-wrapper]"),t=ern(Z.current,w);ere(Z.current,{transform:"translate3d(0, 0, 0)",transition:`transform 0.5s cubic-bezier(${era.join(",")})`}),ere(F.current,{transition:`opacity 0.5s cubic-bezier(${era.join(",")})`,opacity:"1"}),l&&t&&t>0&&I&&ere(e,{borderRadius:"8px",overflow:"hidden",...ert(w)?{transform:`scale(${eu()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${eu()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${era.join(",")})`},!0)}return ew.default.useEffect(()=>{window.requestAnimationFrame(()=>{X.current=!0})},[]),ew.default.useEffect(()=>{var e;function t(){if(Z.current&&C&&(en8(document.activeElement)||G.current)){var e;let t=(null==(e=window.visualViewport)?void 0:e.height)||0,n=window.innerHeight,r=n-t,a=Z.current.getBoundingClientRect().height||0;ee.current||(ee.current=a);let o=Z.current.getBoundingClientRect().top;if(Math.abs(Y.current-r)>60&&(G.current=!G.current),i&&i.length>0&&eo&&er&&(r+=eo[er]||0),Y.current=r,a>t||G.current){let e=Z.current.getBoundingClientRect().height,i=e;e>t&&(i=t-(a>.8*n?o:26)),g?Z.current.style.height=`${e-Math.max(r,0)}px`:Z.current.style.height=`${Math.max(i,t-o)}px`}else{let e;e=navigator.userAgent,"u">typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))||(Z.current.style.height=`${ee.current}px`)}i&&i.length>0&&!G.current?Z.current.style.bottom="0px":Z.current.style.bottom=`${Math.max(r,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[er,i,eo]),ew.default.useEffect(()=>(I&&(ere(document.documentElement,{scrollBehavior:"auto"}),B.current=new Date),()=>{!function(e,t){if(!e||!(e instanceof HTMLElement))return;let n=en9.get(e);n&&(e.style[t]=n[t])}(document.documentElement,"scrollBehavior")}),[I]),ew.default.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),ew.default.createElement(dC,{defaultOpen:j,onOpenChange:e=>{(u||e)&&(e?D(!0):eh(!0),z(e))},open:I},ew.default.createElement(enK.Provider,{value:{activeSnapPoint:en,snapPoints:i,setActiveSnapPoint:ea,drawerRef:Z,overlayRef:F,onOpenChange:t,onPress:function(e){var t,n;!u&&!i||(!Z.current||Z.current.contains(e.target))&&(J.current=(null==(t=Z.current)?void 0:t.getBoundingClientRect().height)||0,Q.current=(null==(n=Z.current)?void 0:n.getBoundingClientRect().width)||0,_(!0),V.current=new Date,enY()&&window.addEventListener("touchend",()=>W.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),K.current=ert(w)?e.pageY:e.pageX)},onRelease:function(e){var t,n;if(!R||!Z.current)return;Z.current.classList.remove(eri),W.current=!1,_(!1),H.current=new Date;let r=ern(Z.current,w);if(!e||!ef(e.target,!1)||!r||Number.isNaN(r)||null===V.current)return;let o=H.current.getTime()-V.current.getTime(),l=K.current-(ert(w)?e.pageY:e.pageX),s=Math.abs(l)/o;if(s>.05&&($(!0),setTimeout(()=>{$(!1)},200)),i){ei({draggedDistance:l*("bottom"===w||"right"===w?1:-1),closeDrawer:eh,velocity:s,dismissible:u}),null==a||a(e,!0);return}if("bottom"===w||"right"===w?l>0:l<0){em(),null==a||a(e,!0);return}if(s>.4){eh(),null==a||a(e,!1);return}let d=Math.min(null!=(t=Z.current.getBoundingClientRect().height)?t:0,window.innerHeight),f=Math.min(null!=(n=Z.current.getBoundingClientRect().width)?n:0,window.innerWidth);if(Math.abs(r)>=("left"===w||"right"===w?f:d)*c){eh(),null==a||a(e,!1);return}null==a||a(e,!0),em()},onDrag:function(e){if(Z.current&&R){let t="bottom"===w||"right"===w?1:-1,n=(K.current-(ert(w)?e.pageY:e.pageX))*t,a=n>0,o=i&&!u&&!a;if(o&&0===er)return;let s=Math.abs(n),c=document.querySelector("[data-vaul-drawer-wrapper]"),d=s/("bottom"===w||"top"===w?J.current:Q.current),f=ec(s,a);if(null!==f&&(d=f),o&&d>=1||!W.current&&!ef(e.target,a))return;if(Z.current.classList.add(eri),W.current=!0,ere(Z.current,{transition:"none"}),ere(F.current,{transition:"none"}),i&&el({draggedDistance:n}),a&&!i){let e=Math.min(-(8*(Math.log(n+1)-2)*1),0)*t;ere(Z.current,{transform:ert(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`});return}let m=1-d;if((es||h&&er===h-1)&&(null==r||r(e,d),ere(F.current,{opacity:`${m}`,transition:"none"},!0)),c&&F.current&&l){let e=Math.min(eu()+d*(1-eu()),1),t=8-8*d,n=Math.max(0,14-14*d);ere(c,{borderRadius:`${t}px`,transform:ert(w)?`scale(${e}) translate3d(0, ${n}px, 0)`:`scale(${e}) translate3d(${n}px, 0, 0)`,transition:"none"},!0)}if(!i){let e=s*t;ere(Z.current,{transform:ert(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:X,handleOnly:f,isOpen:I,isDragging:R,shouldFade:es,closeDrawer:eh,onNestedDrag:function(e,t){if(t<0)return;let n=(window.innerWidth-16)/window.innerWidth,r=n+t*(1-n),a=-16+16*t;ere(Z.current,{transform:ert(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){let t=e?(window.innerWidth-16)/window.innerWidth:1,n=e?-16:0;q.current&&window.clearTimeout(q.current),ere(Z.current,{transition:`transform 0.5s cubic-bezier(${era.join(",")})`,transform:ert(w)?`scale(${t}) translate3d(0, ${n}px, 0)`:`scale(${t}) translate3d(${n}px, 0, 0)`}),!e&&Z.current&&(q.current=setTimeout(()=>{let e=ern(Z.current,w);ere(Z.current,{transition:"none",transform:ert(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){let n=ert(w)?window.innerHeight:window.innerWidth,r=t?(n-16)/n:1,a=t?-16:0;t&&ere(Z.current,{transition:`transform 0.5s cubic-bezier(${era.join(",")})`,transform:ert(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`})},keyboardIsOpen:G,modal:v,snapPointsOffset:eo,activeSnapPointIndex:er,direction:w,shouldScaleBackground:l,setBackgroundColorOnScale:s,noBodyStyles:b,container:E,autoFocus:O}},n))},erh=function(e){let t=enG(),{container:n=t.container,...r}=e;return ew.default.createElement(dI,{container:n,...r})};function erm({className:e,...t}){return(0,ey.jsx)(erd,{"data-slot":"drawer-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function erp({className:e,children:t,...n}){return(0,ey.jsxs)(erh,{"data-slot":"drawer-portal",children:[(0,ey.jsx)(erm,{}),(0,ey.jsxs)(eru,{"data-slot":"drawer-content",className:(0,eI.cn)("vtl-surface-modal group/drawer-content fixed z-50 flex h-auto flex-col border outline-none","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-xl data-[vaul-drawer-direction=top]:border-t-0","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:border-b-0","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-r-0 data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-l-0 data-[vaul-drawer-direction=left]:sm:max-w-sm",e),...n,children:[(0,ey.jsx)("div",{className:"mx-auto mt-3 hidden h-1.5 w-16 shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),t]})]})}function erg({className:e,...t}){return(0,ey.jsx)(dH,{"data-slot":"drawer-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function erv({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:a,onOpenConversation:i,onOpenConversationSettings:o,onConversationDeleted:l,onAccountSettings:s,subagentTree:c,activeSubagentPath:d,onOpenSubagent:u,title:f,trailing:h}){let[m,p]=ew.useState(!1),g=ew.useCallback(()=>p(!1),[]),v=ew.useCallback(e=>{g(),a(e)},[g,a]),x=ew.useCallback((e,t)=>{g(),i(e,t)},[g,i]),y=ew.useCallback(e=>{g(),u?.(e)},[g,u]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(erx,{onMenuClick:()=>p(!0),title:f,trailing:h}),(0,ey.jsx)(erf,{open:m,onOpenChange:p,direction:"left",children:(0,ey.jsxs)(erp,{className:"w-[85vw] max-w-xs",children:[(0,ey.jsx)(erg,{className:"sr-only",children:"导航"}),(0,ey.jsx)(enk,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:v,onOpenConversation:x,onOpenCanvas:()=>{},onOpenConversationSettings:(e,t)=>{g(),o?.(e,t)},onConversationDeleted:l,onAccountSettings:()=>{g(),s?.()},subagentTree:c,activeSubagentPath:d,onOpenSubagent:y,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})})]})}function erx({onMenuClick:e,title:t,trailing:n,className:r}){return(0,ey.jsxs)("header",{className:(0,eI.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,ey.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,ey.jsx)(s8,{})}),t?(0,ey.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,ey.jsx)("div",{className:"min-w-0 flex-1"}),(0,ey.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let ery=(0,ek.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),erb=[{id:"canvas",label:QI.canvas,icon:(0,ey.jsx)(uw,{})},{id:"agent",label:"智能体",icon:(0,ey.jsx)(ub,{})},{id:"settings",label:QI.settings,icon:(0,ey.jsx)(QH,{})}],erw=[{id:"canvas",title:QI.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:QI.canvas,items:[{id:"open-recent-canvas",label:QI.canvasRecent,icon:(0,ey.jsx)(uw,{})},{id:"new-canvas",label:QI.canvasNew,icon:(0,ey.jsx)(lJ,{})},{id:"all-canvases",label:QI.canvasAll,icon:(0,ey.jsx)(uN,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:QI.conversationRecent,icon:(0,ey.jsx)(ery,{})},{id:"new-agent-conversation",label:QI.conversationNew,icon:(0,ey.jsx)(ub,{})}]}]},{id:"settings",title:QI.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,ey.jsx)(QH,{})}]}]}],erj=(0,ek.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),erk=(0,ek.default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),erS=(0,ek.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),erN=(0,ek.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function erC(){let{user:e,machine:t,logout:n,unbind:r,refreshUser:a}=tl(),[i,o]=ew.useState(!1),[l,s]=ew.useState(!1),[c,d]=ew.useState(t),[u,f]=ew.useState(!1),[h,m]=ew.useState(""),[p,g]=ew.useState(!1),[v,x]=ew.useState(null);async function y(){o(!0);try{await eJ("online");let e=eW();d(e),await a()}catch{}finally{o(!1)}}async function b(){let e=h.trim();if(!e)return void x("名称不能为空");g(!0),x(null);try{let t=await e0(e);d(e=>e?{...e,name:t}:e),f(!1)}catch(e){x(e instanceof Error?e.message:"重命名失败")}finally{g(!1)}}async function w(){s(!0);try{await r()}catch{s(!1)}}async function j(){await n()}return ew.useEffect(()=>{d(t)},[t]),e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsx)("div",{className:"flex items-center justify-between gap-3","data-tour":"hub-account",children:(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"Vantaloom Hub 账户"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"管理你的 Hub 连接和设备绑定"})]})}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户信息"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"你的 Vantaloom Hub 账户详情。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,ey.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:(0,ey.jsx)("span",{className:"text-base font-semibold text-primary",children:e.name.charAt(0).toUpperCase()})}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]}),(0,ey.jsxs)(Bs,{variant:"outline",className:"shrink-0",children:[(0,ey.jsx)(jz,{className:"mr-1 size-3"}),"已验证"]})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"用户 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(e.createdAt).toLocaleDateString("zh-CN")})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"此设备已自动注册到你的 Hub 账户。"})]}),c?(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:y,disabled:i,children:[i?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(ya,{}),i?"刷新中...":"刷新状态"]}):null]}),c?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[u?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(ez,{value:h,onChange:e=>m(e.target.value),maxLength:64,autoFocus:!0,placeholder:"机器名称",className:"h-8 text-sm",onKeyDown:e=>{"Enter"===e.key&&b(),"Escape"===e.key&&f(!1)}}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>void b(),disabled:p,"aria-label":"保存名称",children:p?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(mZ,{})}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>f(!1),disabled:p,"aria-label":"取消",children:(0,ey.jsx)(fg.XIcon,{})})]}):(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:c.name}),(0,ey.jsx)("button",{type:"button",onClick:function(){m(c?.name??""),x(null),f(!0)},title:"重命名",className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,ey.jsx)(HN,{className:"size-3.5"})})]}),(0,ey.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[c.platform," / ",c.arch]})]}),(0,ey.jsxs)(Bs,{variant:"online"===c.status?"default":"secondary",className:"shrink-0 gap-1",children:["online"===c.status?(0,ey.jsx)(erS,{className:"size-3"}):(0,ey.jsx)(erN,{className:"size-3"}),"online"===c.status?"在线":"离线"]})]}),v?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:v}):null,(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"设备 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[c.id.slice(0,8),"..."]})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接方式"}),(0,ey.jsx)("span",{className:"text-sm",children:c.connectivity||"直连"})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"本机 IP"}),(0,ey.jsx)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:c.localIp})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"最后心跳"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.lastHeartbeat).toLocaleString("zh-CN")})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.createdAt).toLocaleString("zh-CN")})]})]}):(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[(0,ey.jsx)(erN,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsxs)("div",{children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"设备未绑定"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"设备注册异常,请尝试重新登录"})]})]})]}),(0,ey.jsx)(erM,{}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"hub-account-danger",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold text-destructive",children:"危险操作"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"以下操作不可逆,请谨慎执行。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"解除设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"将此设备从你的 Hub 账户中移除,并退出登录。设备数据不会受到影响。"})]}),(0,ey.jsxs)(d4,{children:[(0,ey.jsx)(d3,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{variant:"destructive",size:"sm",className:"shrink-0",children:[(0,ey.jsx)(erk,{}),"解除绑定"]})}),(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:"确认解除设备绑定?"}),(0,ey.jsx)(ug,{children:"此操作将从你的 Hub 账户中移除当前设备,并退出登录。你可以随时重新登录并绑定设备。"})]}),(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{children:"取消"}),(0,ey.jsx)(uv,{onClick:w,disabled:l,className:"bg-destructive text-white hover:bg-destructive/90",children:l?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"处理中..."]}):"确认解除"})]})]})]})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"退出登录"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"退出当前 Hub 账户但保留设备在云端的注册。下次登录时无需重新绑定。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:[(0,ey.jsx)(enn,{}),"退出登录"]})]})]})]})})}):null}function erM(){let[e,t]=ew.useState(""),[n,r]=ew.useState(""),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(null);async function d(){if(c(null),n.length<8)return void c({kind:"err",text:"新密码至少 8 位"});if(n!==a)return void c({kind:"err",text:"两次输入的新密码不一致"});l(!0);try{await e1(e,n),c({kind:"ok",text:"密码已更新"}),t(""),r(""),i("")}catch(e){c({kind:"err",text:e instanceof Error?e.message:"修改失败,请重试"})}finally{l(!1)}}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(erj,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"修改密码"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"更改你的 Vantaloom Hub 登录密码。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(ez,{type:"password",placeholder:"当前密码",autoComplete:"current-password",value:e,onChange:e=>t(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"新密码(至少 8 位)",autoComplete:"new-password",value:n,onChange:e=>r(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"确认新密码",autoComplete:"new-password",value:a,onChange:e=>i(e.target.value)})]}),s?(0,ey.jsx)("p",{className:"ok"===s.kind?"text-xs text-primary":"text-xs text-destructive",children:s.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsx)(eA.Button,{size:"sm",onClick:d,disabled:o||!e||!n,children:o?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"保存中..."]}):"更新密码"})})]})}var erE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,l1.createSlot)(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,ey.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),erO=ew.forwardRef((e,t)=>(0,ey.jsx)(erE.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));function erP({className:e,...t}){return(0,ey.jsx)(erO,{"data-slot":"label",className:(0,eI.cn)("flex w-fit items-center gap-2 text-sm font-medium leading-snug peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]/field:opacity-50",e),...t})}erO.displayName="Label";var erA=["PageUp","PageDown"],erI=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],erz={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},erT="Slider",[erD,erR,er_]=hq(erT),[erL,er$]=cr(erT,[er_]),[erF,erB]=erL(erT),erV=ew.forwardRef((e,t)=>{let{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:s=0,defaultValue:c=[r],value:d,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:h=!1,form:m,...p}=e,g=ew.useRef(new Set),v=ew.useRef(0),x="horizontal"===o,[y=[],b]=cu({prop:d,defaultProp:c,onChange:e=>{let t=[...g.current];t[v.current]?.focus(),u(e)}}),w=ew.useRef(y);function j(e,t,{commit:n}={commit:!1}){let o,l=(String(i).split(".")[1]||"").length,c=m2(Math.round((Math.round((e-r)/i)*i+r)*(o=Math.pow(10,l)))/o,[r,a]);b((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,s*i))return e;{v.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&f(r),t?r:e}})}return(0,ey.jsx)(erF,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:a,valueIndexToChangeRef:v,thumbs:g.current,values:y,orientation:o,form:m,children:(0,ey.jsx)(erD.Provider,{scope:e.__scopeSlider,children:(0,ey.jsx)(erD.Slot,{scope:e.__scopeSlider,children:(0,ey.jsx)(x?erW:erq,{"aria-disabled":l,"data-disabled":l?"":void 0,...p,ref:t,onPointerDown:ci(p.onPointerDown,()=>{l||(w.current=y)}),min:r,max:a,inverted:h,onSlideStart:l?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(y,e);j(e,t)},onSlideMove:l?void 0:function(e){j(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&j(r,0,{commit:!0}),onEndKeyDown:()=>!l&&j(a,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!l){let n=erA.includes(e.key)||e.shiftKey&&erI.includes(e.key),r=v.current;j(y[r]+i*(n?10:1)*t,r,{commit:!0})}}})})})})});erV.displayName=erT;var[erH,erU]=erL(erT,{startEdge:"left",endEdge:"right",size:"width",direction:1}),erW=ew.forwardRef((e,t)=>{let{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:s,onStepKeyDown:c,...d}=e,[u,f]=ew.useState(null),h=(0,ca.useComposedRefs)(t,e=>f(e)),m=ew.useRef(void 0),p=hZ(a),g="ltr"===p,v=g&&!i||!g&&i;function x(e){let t=m.current||u.getBoundingClientRect(),a=er5([0,t.width],v?[n,r]:[r,n]);return m.current=t,a(e-t.left)}return(0,ey.jsx)(erH,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,ey.jsx)(erK,{dir:p,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=x(e.clientX);o?.(t)},onSlideMove:e=>{let t=x(e.clientX);l?.(t)},onSlideEnd:()=>{m.current=void 0,s?.()},onStepKeyDown:e=>{let t=erz[v?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),erq=ew.forwardRef((e,t)=>{let{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:s,...c}=e,d=ew.useRef(null),u=(0,ca.useComposedRefs)(t,d),f=ew.useRef(void 0),h=!a;function m(e){let t=f.current||d.current.getBoundingClientRect(),a=er5([0,t.height],h?[r,n]:[n,r]);return f.current=t,a(e-t.top)}return(0,ey.jsx)(erH,{scope:e.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:(0,ey.jsx)(erK,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=m(e.clientY);i?.(t)},onSlideMove:e=>{let t=m(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=erz[h?"from-bottom":"from-top"].includes(e.key);s?.({event:e,direction:t?-1:1})}})})}),erK=ew.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:s,...c}=e,d=erB(erT,n);return(0,ey.jsx)(cp.span,{...c,ref:t,onKeyDown:ci(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):erA.concat(erI).includes(e.key)&&(s(e),e.preventDefault())}),onPointerDown:ci(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():r(e)}),onPointerMove:ci(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:ci(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),i(e))})})}),erG="SliderTrack",erX=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=erB(erG,n);return(0,ey.jsx)(cp.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});erX.displayName=erG;var erY="SliderRange",erZ=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=erB(erY,n),i=erU(erY,n),o=ew.useRef(null),l=(0,ca.useComposedRefs)(t,o),s=a.values.length,c=a.values.map(e=>er2(e,a.min,a.max)),d=s>1?Math.min(...c):0,u=100-Math.max(...c);return(0,ey.jsx)(cp.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:l,style:{...e.style,[i.startEdge]:d+"%",[i.endEdge]:u+"%"}})});erZ.displayName=erY;var erJ="SliderThumb",erQ=ew.forwardRef((e,t)=>{let n=erR(e.__scopeSlider),[r,a]=ew.useState(null),i=(0,ca.useComposedRefs)(t,e=>a(e)),o=ew.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,ey.jsx)(er0,{...e,ref:i,index:o})}),er0=ew.forwardRef((e,t)=>{var n,r,a,i,o;let l,s,{__scopeSlider:c,index:d,name:u,...f}=e,h=erB(erJ,c),m=erU(erJ,c),[p,g]=ew.useState(null),v=(0,ca.useComposedRefs)(t,e=>g(e)),x=!p||h.form||!!p.closest("form"),y=ge(p),b=h.values[d],w=void 0===b?0:er2(b,h.min,h.max),j=(n=d,(r=h.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=y?.[m.size],S=k?(a=k,i=w,o=m.direction,s=er5([0,50],[0,l=a/2]),(l-s(i)*o)*o):0;return ew.useEffect(()=>{if(p)return h.thumbs.add(p),()=>{h.thumbs.delete(p)}},[p,h.thumbs]),(0,ey.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${w}% + ${S}px)`},children:[(0,ey.jsx)(erD.ItemSlot,{scope:e.__scopeSlider,children:(0,ey.jsx)(cp.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":h.min,"aria-valuenow":b,"aria-valuemax":h.max,"aria-orientation":h.orientation,"data-orientation":h.orientation,"data-disabled":h.disabled?"":void 0,tabIndex:h.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:ci(e.onFocus,()=>{h.valueIndexToChangeRef.current=d})})}),x&&(0,ey.jsx)(er1,{name:u??(h.name?h.name+(h.values.length>1?"[]":""):void 0),form:h.form,value:b},d)]})});erQ.displayName=erJ;var er1=ew.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let a=ew.useRef(null),i=(0,ca.useComposedRefs)(a,r),o=gy(t);return ew.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,ey.jsx)(cp.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});function er2(e,t,n){return m2(100/(n-t)*(e-t),[0,100])}function er5(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function er4(e){return Array.isArray(e)?e:"number"==typeof e?[e]:void 0}function er3({className:e,defaultValue:t,value:n,min:r=0,max:a=100,...i}){let o=ew.useMemo(()=>er4(n)??er4(t)??[r,a],[t,a,r,n]);return(0,ey.jsxs)(erV,{"data-slot":"slider",defaultValue:er4(t),value:er4(n),min:r,max:a,className:(0,eI.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,ey.jsx)(erX,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1",children:(0,ey.jsx)(erZ,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),o.map((e,t)=>(0,ey.jsx)(erQ,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white shadow-sm transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 hover:ring-ring/50 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden active:ring-3 active:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-primary-foreground"},t))]})}er1.displayName="RadioBubbleInput";let er6=[1e4,3e4,12e4,3e5,6e5];function er8(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??0,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[]}}}function er7(e){return(e&&e.length?e:er6).map(e=>Math.round(e/1e3)).join(", ")}function er9(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,h]=ew.useState("");function m(e,n){t(t=>t?{...t,[e]:{...t[e],...n}}:t),u(!0)}async function p(){if(e&&!o){l(!0),c("");try{let n=await js({compression:e.compression,summary:e.summary,approval:e.approval,behavior:e.behavior});t(er8(n)),h(er7(n.behavior?.retryDelaysMs)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return(ew.useEffect(()=>{!async function(){try{let[e,n]=await Promise.all([jl(),vF()]);t(er8(e)),h(er7(e.behavior?.retryDelaysMs)),r(n.models)}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"代理配置"})}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void p(),disabled:o,children:[(0,ey.jsx)(K3,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"错误"}),(0,ey.jsx)(Qt,{children:s})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"自动压缩阈值"}),(0,ey.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.compression.autoThresholdPercent,"%"]})]}),(0,ey.jsx)(er3,{value:[e.compression.autoThresholdPercent],onValueChange:([e])=>m("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"压缩模型"}),(0,ey.jsx)(eae,{models:n,value:e.compression.modelRef,onValueChange:e=>m("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"对话标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,ey.jsx)(xZ,{checked:e.summary.enableTitleSummary,onCheckedChange:e=>m("summary",{enableTitleSummary:e})})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"轮次标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,ey.jsx)(xZ,{checked:e.summary.enableRoundSummary,onCheckedChange:e=>m("summary",{enableRoundSummary:e})})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(eae,{models:n,value:e.summary.modelRef,onValueChange:e=>m("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"最大工具调用次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.maxToolCalls,onChange:e=>m("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次(默认)。"})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"自动重试次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.retryCount,onChange:e=>m("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,ey.jsx)(ez,{value:f,onChange:e=>{let t=e.currentTarget.value;h(t),m("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"审批模型"}),(0,ey.jsx)(eae,{models:n,value:e.approval.modelRef,onValueChange:e=>m("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"审批提示词"}),(0,ey.jsx)(b3,{value:e.approval.prompt,onChange:e=>m("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})]}):(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"读取失败"}),(0,ey.jsx)(Qt,{children:s||"无法加载代理配置"})]})}function eae({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gT,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:r})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.label},e.id))]})]})}let eat=(0,ek.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var ean="Accordion",ear=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[eaa,eai,eao]=hq(ean),[eal,eas]=cr(ean,[eao,enu]),eac=enu(),ead=ew.default.forwardRef((e,t)=>{let{type:n,...r}=e;return(0,ey.jsx)(eaa.Provider,{scope:e.__scopeAccordion,children:"multiple"===n?(0,ey.jsx)(eag,{...r,ref:t}):(0,ey.jsx)(eap,{...r,ref:t})})});ead.displayName=ean;var[eau,eaf]=eal(ean),[eah,eam]=eal(ean,{collapsible:!1}),eap=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},collapsible:i=!1,...o}=e,[l,s]=cu({prop:n,defaultProp:r??"",onChange:a,caller:ean});return(0,ey.jsx)(eau,{scope:e.__scopeAccordion,value:ew.default.useMemo(()=>l?[l]:[],[l]),onItemOpen:s,onItemClose:ew.default.useCallback(()=>i&&s(""),[i,s]),children:(0,ey.jsx)(eah,{scope:e.__scopeAccordion,collapsible:i,children:(0,ey.jsx)(eay,{...o,ref:t})})})}),eag=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,l]=cu({prop:n,defaultProp:r??[],onChange:a,caller:ean}),s=ew.default.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=ew.default.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return(0,ey.jsx)(eau,{scope:e.__scopeAccordion,value:o,onItemOpen:s,onItemClose:c,children:(0,ey.jsx)(eah,{scope:e.__scopeAccordion,collapsible:!0,children:(0,ey.jsx)(eay,{...i,ref:t})})})}),[eav,eax]=eal(ean),eay=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,disabled:r,dir:a,orientation:i="vertical",...o}=e,l=ew.default.useRef(null),s=(0,ca.useComposedRefs)(l,t),c=eai(n),d="ltr"===hZ(a),u=ci(e.onKeyDown,e=>{if(!ear.includes(e.key))return;let t=e.target,n=c().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),a=n.length;if(-1===r)return;e.preventDefault();let o=r,l=a-1,s=()=>{(o=r+1)>l&&(o=0)},u=()=>{(o=r-1)<0&&(o=l)};switch(e.key){case"Home":o=0;break;case"End":o=l;break;case"ArrowRight":"horizontal"===i&&(d?s():u());break;case"ArrowDown":"vertical"===i&&s();break;case"ArrowLeft":"horizontal"===i&&(d?u():s());break;case"ArrowUp":"vertical"===i&&u()}let f=o%a;n[f].ref.current?.focus()});return(0,ey.jsx)(eav,{scope:n,disabled:r,direction:a,orientation:i,children:(0,ey.jsx)(eaa.Slot,{scope:n,children:(0,ey.jsx)(cp.div,{...o,"data-orientation":i,ref:s,onKeyDown:r?void 0:u})})})}),eab="AccordionItem",[eaw,eaj]=eal(eab),eak=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,value:r,...a}=e,i=eax(eab,n),o=eaf(eab,n),l=eac(n),s=cc(),c=r&&o.value.includes(r)||!1,d=i.disabled||e.disabled;return(0,ey.jsx)(eaw,{scope:n,open:c,disabled:d,triggerId:s,children:(0,ey.jsx)(enm,{"data-orientation":i.orientation,"data-state":eaP(c),...l,...a,ref:t,disabled:d,open:c,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})});eak.displayName=eab;var eaS="AccordionHeader",eaN=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=eax(ean,n),i=eaj(eaS,n);return(0,ey.jsx)(cp.h3,{"data-orientation":a.orientation,"data-state":eaP(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});eaN.displayName=eaS;var eaC="AccordionTrigger",eaM=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=eax(ean,n),i=eaj(eaC,n),o=eam(eaC,n),l=eac(n);return(0,ey.jsx)(eaa.ItemSlot,{scope:n,children:(0,ey.jsx)(eng,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...r,ref:t})})});eaM.displayName=eaC;var eaE="AccordionContent",eaO=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=eax(ean,n),i=eaj(eaE,n),o=eac(n);return(0,ey.jsx)(enx,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function eaP(e){return e?"open":"closed"}function eaA({...e}){return(0,ey.jsx)(ead,{"data-slot":"accordion",...e})}function eaI({className:e,...t}){return(0,ey.jsx)(eak,{"data-slot":"accordion-item",className:(0,eI.cn)("border-b last:border-b-0",e),...t})}function eaz({className:e,children:t,...n}){return(0,ey.jsx)(eaN,{className:"flex",children:(0,ey.jsxs)(eaM,{"data-slot":"accordion-trigger",className:(0,eI.cn)("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,(0,ey.jsx)(vu,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200"})]})})}function eaT({className:e,children:t,...n}){return(0,ey.jsx)(eaO,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-out data-[state=open]:animate-in",...n,children:(0,ey.jsx)("div",{className:(0,eI.cn)("pb-4 pt-0 text-muted-foreground",e),children:t})})}eaO.displayName=eaE;let eaD={vantaloom:"Vantaloom","claude-code":"Claude Code",reclaude:"reclaude"};function eaR(e){return{...e.claudeCode??{}}}function ea_(e,t){if(e.reclaudeExecutable)return e;let n=t.find(e=>"reclaude"===e.engine);return n?.available&&n.detail?{...e,reclaudeExecutable:n.detail}:e}function eaL(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(!1),[f,h]=ew.useState(""),[m,p]=ew.useState(!1);async function g(){if(!d){u(!0),h("");try{let e=(await jd()).engines??[];r(e),t(t=>t?ea_(t,e):t)}catch(e){h(e instanceof Error?e.message:"适配器安装失败")}finally{u(!1)}}}function v(e){t(t=>t?{...t,...e}:t),p(!0)}ew.useEffect(()=>{!async function(){try{let[e,n,a]=await Promise.all([jl(),jc(),vF()]),o=n.engines??[];t(ea_(eaR(e),o)),r(o),i(a.models)}catch(e){h(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]);let x=e?.adapterArgs?.[0]??"";async function y(){if(e&&!s){c(!0),h("");try{let n=await js({claudeCode:e});t(eaR(n)),p(!1)}catch(e){h(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}return o?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取引擎配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"CC 引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"配置 Claude Code / reclaude 引擎。展开下方分组按需修改,留空项将自动发现。"})]}),m&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void y(),disabled:s,children:[(0,ey.jsx)(K3,{className:"size-4"}),s?"保存中":"保存"]})]}),f?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"错误"}),(0,ey.jsx)(Qt,{children:f})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"检测到的引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"本机当前可用的 Agent 运行引擎。不可用的引擎会说明原因。"})]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void g(),disabled:d,children:[d?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):(0,ey.jsx)(x1,{className:"size-4"}),d?"安装中…":"下载/安装适配器"]})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"Claude Code / reclaude 需要 ACP 适配器。运行时不再内置它(以减小体积), 点击上方按钮即可在后台静默下载安装;安装后无需手填路径即可使用。"}),(0,ey.jsx)("div",{className:"grid gap-2",children:0===n.length?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到引擎信息。"}):n.map(e=>(0,ey.jsxs)("div",{className:"grid gap-1 rounded-md border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:eaD[e.engine]??e.engine}),(0,ey.jsxs)("span",{className:(0,eI.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium [&_svg]:size-3",e.available?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-destructive/10 text-destructive"),children:[e.available?(0,ey.jsx)(eO,{}):(0,ey.jsx)(eat,{}),e.available?"可用":"不可用"]})]}),e.reason?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.reason}):null,e.detail?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:e.detail}):null]},e.engine))})]}),(0,ey.jsx)("section",{className:"rounded-lg border bg-card px-4",children:(0,ey.jsxs)(eaA,{type:"multiple",className:"w-full",children:[(0,ey.jsxs)(eaI,{value:"adapter",children:[(0,ey.jsx)(eaz,{children:"适配器"}),(0,ey.jsxs)(eaT,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"适配器命令"}),(0,ey.jsx)(ez,{value:e.adapterCommand??"",onChange:e=>v({adapterCommand:e.currentTarget.value}),placeholder:"node"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动使用 node 运行适配器。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"适配器入口 (…/@zed-industries/claude-code-acp/dist/index.js)"}),(0,ey.jsx)(ez,{value:x,onChange:e=>{let t=e.currentTarget.value;v({adapterArgs:t?[t]:[]})},placeholder:"…/@zed-industries/claude-code-acp/dist/index.js"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动发现(随运行时安装或环境变量 VANTALOOM_CC_ADAPTER)。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"Git Bash 路径"}),(0,ey.jsx)(ez,{value:e.gitBashPath??"",onChange:e=>v({gitBashPath:e.currentTarget.value}),placeholder:"C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Windows 专用,留空自动发现。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"reclaude 可执行文件"}),(0,ey.jsx)(ez,{value:e.reclaudeExecutable??"",onChange:e=>v({reclaudeExecutable:e.currentTarget.value}),placeholder:"reclaude"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"reclaude 可执行文件(或 node shim)路径;自动发现到 reclaude 时会自动填入, 会通过内置 shim 启动。留空则自动发现。"})]})]})]}),(0,ey.jsxs)(eaI,{value:"auth",children:[(0,ey.jsx)(eaz,{children:"认证"}),(0,ey.jsxs)(eaT,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"API Key"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.apiKey??"",onChange:e=>v({apiKey:e.currentTarget.value}),placeholder:"claude-code 引擎用;留空可用 claude /login"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用;留空可使用 claude /login 登录。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"OAuth Token"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.oauthToken??"",onChange:e=>v({oauthToken:e.currentTarget.value}),placeholder:"留空使用其它认证方式"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选的 OAuth Token,作为 API Key 之外的认证方式。"})]})]})]}),(0,ey.jsxs)(eaI,{value:"summary",children:[(0,ey.jsx)(eaz,{children:"摘要模型"}),(0,ey.jsx)(eaT,{className:"grid gap-4 text-foreground",children:(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(ea$,{models:a,value:e.summaryModelRef??"",onValueChange:e=>v({summaryModelRef:e}),placeholder:"使用默认"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"CC 会话标题/摘要用的 Vantaloom 模型路由。"})]})})]})]})})]}):(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"读取失败"}),(0,ey.jsx)(Qt,{children:f||"无法加载引擎配置"})]})}function ea$({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gT,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:r})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.label},e.id))]})]})}let eaF=[{id:"card",label:"卡片布局",description:"圆角卡片自由排布,右上角下拉菜单按需添加单窗口。",icon:(0,ey.jsx)(ent,{})},{id:"pane",label:"分屏布局",description:"传统多窗格 + 顶部分屏预设,可拖拽分割线调整。",icon:(0,ey.jsx)(Ut,{})},{id:"control-room",label:"导播台视角",description:"隐藏窗格,右侧以监视器墙并排查看主代理与各子代理。",icon:(0,ey.jsx)(eP,{})}],eaB=[{id:"left",label:"Agent 在左",icon:(0,ey.jsx)(s8,{})},{id:"right",label:"Agent 在右",icon:(0,ey.jsx)(s9,{})}];function eaV(){let[e,t]=ew.useState("pane"),[n,r]=ew.useState("left");return ew.useEffect(()=>{let e=Jq();t(e.mode),r(e.agentSide)},[]),(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"布局排版"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 工作区的窗口布局与 Agent 对话的位置,设置即时应用到所有会话。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"布局模式"}),(0,ey.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",children:eaF.map(n=>{let r=e===n.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var e;t(e=n.id),JK({mode:e})},className:(0,eI.cn)("flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors [&_svg]:size-5",r?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":r,children:[(0,ey.jsx)("span",{className:(0,eI.cn)("grid size-9 place-items-center rounded-md",r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.icon}),(0,ey.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.label}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:n.description})]},n.id)})})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"Agent 对话位置"}),(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:eaB.map(e=>{let t=n===e.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var t;r(t=e.id),JK({agentSide:t})},className:(0,eI.cn)("inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors [&_svg]:size-4",t?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":t,children:[e.icon,e.label]},e.id)})})]})]})}let eaH=[{value:"openai-v1",label:"OpenAI v1"},{value:"anthropic",label:"Anthropic"},{value:"openai-responses",label:"OpenAI Responses"}];function eaU(e){return{id:e.id,providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:"",models:e.models,selectedModelIds:e.selectedModelIds,builtin:e.builtin,loadingModels:!1,saving:!1,error:e.lastError??"",savedKeyAvailable:!0,editing:!1}}function eaW(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState(""),o=ew.useCallback(async()=>{i("");try{let e=await vF();t(e.routes.map(eaU))}catch(e){i(e instanceof Error?e.message:"模型路由读取失败")}finally{r(!1)}},[]);function l(e,n){t(t=>t.map((t,r)=>r===e?n(t):t))}async function s(t){let n=e[t];if(n&&!n.saving){l(t,e=>({...e,saving:!0,error:""}));try{let e=await vV({id:n.id,providerName:n.providerName,protocol:n.protocol,endpointUrl:n.endpointUrl,apiKey:n.apiKey,models:n.models,selectedModelIds:n.selectedModelIds});l(t,()=>eaU(e))}catch(e){l(t,t=>({...t,saving:!1,error:e instanceof Error?e.message:"保存失败"}))}}}async function c(n){let r=e[n];if(r&&!r.saving){if(!r.id)return void t(e=>e.filter((e,t)=>t!==n));l(n,e=>({...e,saving:!0,error:""}));try{await vH(r.id),t(e=>e.filter((e,t)=>t!==n))}catch(e){l(n,t=>({...t,saving:!1,error:e instanceof Error?e.message:"删除失败"}))}}}return ew.useEffect(()=>{o()},[o]),ew.useEffect(()=>{let e=!1,n=window.setInterval(()=>{(async()=>{try{let n=await vF();if(e)return;let r=n.routes.find(e=>e.builtin);t(e=>{let t=e.some(e=>e.builtin);return r?t?e.map(e=>e.builtin?{...e,providerName:r.providerName,models:r.models,selectedModelIds:r.selectedModelIds,error:r.lastError??""}:e):[eaU(r),...e]:t?e.filter(e=>!e.builtin):e})}catch{}})()},3e4);return()=>{e=!0,window.clearInterval(n)}},[]),(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"模型路由"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:function(){t(e=>[{providerName:"",protocol:"openai-v1",endpointUrl:"",apiKey:"",models:[],selectedModelIds:[],loadingModels:!1,saving:!1,error:"",editing:!0},...e])},"data-tour":"add-model-route",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加模型路由"]})]}),a?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"读取失败"}),(0,ey.jsx)(Qt,{children:a})]}):null,n?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型路由"}):0===e.length?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型路由。"}):(0,ey.jsx)("div",{className:"grid gap-3",children:e.map((e,t)=>(0,ey.jsx)(eaq,{draft:e,onDraftChange:e=>l(t,()=>e),onSave:()=>{s(t)},onDelete:()=>{c(t)}},e.id??`draft-${t}`))})]})}function eaq({draft:e,onDraftChange:t,onSave:n,onDelete:r}){let a=ew.useRef(e),i=ew.useRef(t),o=[e.providerName,e.protocol,e.endpointUrl,e.apiKey||(e.savedKeyAvailable?"saved":"")].join("\n"),l=e.providerName.trim()&&e.endpointUrl.trim()&&e.apiKey.trim(),s=e.providerName.trim()&&e.endpointUrl.trim()&&(e.apiKey.trim()||e.savedKeyAvailable)&&e.selectedModelIds.length>0&&!e.saving;function c(n){t({...e,...n})}if(ew.useEffect(()=>{a.current=e,i.current=t},[e,t]),ew.useEffect(()=>{if(!l)return;let e=window.setTimeout(async()=>{let e=a.current;i.current({...e,loadingModels:!0,error:""});try{let t=await vB({providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:e.apiKey}),n=e.selectedModelIds.filter(e=>t.models.some(t=>t.id===e));i.current({...e,models:t.models,selectedModelIds:n,loadingModels:!1,error:""})}catch(t){i.current({...e,loadingModels:!1,error:t instanceof Error?t.message:"模型拉取失败"})}},650);return()=>window.clearTimeout(e)},[l,o]),!e.editing||e.builtin){let t=e.selectedModelIds.map(t=>e.models.find(e=>e.id===t)?.displayName||t).filter(Boolean),n=eaH.find(t=>t.value===e.protocol)?.label??e.protocol;return(0,ey.jsxs)("section",{className:"grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.builtin?(0,ey.jsx)(lK,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.providerName}),e.builtin?(0,ey.jsx)("span",{className:"ui-text-kbd rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:"官渠"}):null,(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n})]}),(0,ey.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(", "):"未选择模型"})]}),e.builtin?null:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>c({editing:!0}),children:[(0,ey.jsx)(HN,{className:"size-4"}),"编辑"]})]})}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-3","data-tour":"model-route-form",children:[(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_11rem]",children:[(0,ey.jsx)(ez,{value:e.providerName,placeholder:"提供商名称",onChange:e=>c({providerName:e.currentTarget.value})}),(0,ey.jsxs)(gT,{value:e.protocol,onValueChange:e=>c({protocol:e}),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{})}),(0,ey.jsx)(vg,{children:eaH.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)]",children:[(0,ey.jsx)(ez,{value:e.endpointUrl,placeholder:"API 端点 URL,例如 https://api.openai.com/v1",onChange:e=>c({endpointUrl:e.currentTarget.value})}),(0,ey.jsx)(ez,{value:e.apiKey,type:"password",placeholder:e.savedKeyAvailable?"已保存,留空沿用":"API Key",onChange:e=>c({apiKey:e.currentTarget.value})})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-6 items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-medium",children:[(0,ey.jsx)(mY,{className:"size-4 text-muted-foreground"}),"可用模型"]}),e.loadingModels?(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"拉取中"}):null]}),e.models.length>0?(0,ey.jsx)("div",{className:"grid max-h-64 gap-1 overflow-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.models.map(t=>{let n=e.selectedModelIds.includes(t.id);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-8 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 text-sm hover:bg-muted/60",n&&"bg-muted/70"),children:[(0,ey.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,ey.jsx)(v$,{checked:n,onCheckedChange:n=>{var r;return r=t.id,void c({selectedModelIds:!0===n?[...e.selectedModelIds,r]:e.selectedModelIds.filter(e=>e!==r)})}}),(0,ey.jsx)("span",{className:"truncate",children:t.displayName||t.id})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(ez,{type:"number",className:"h-6 w-16 px-1.5 text-center text-xs tabular-nums",value:t.contextLength||200,min:1,max:1e4,onChange:n=>{var r,a;return r=t.id,a=Number.parseInt(n.currentTarget.value,10)||0,void c({models:e.models.map(e=>e.id===r?{...e,contextLength:a>0?a:void 0}:e)})}}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"k"})]})]},t.id)})}):(0,ey.jsx)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:"填写端点和密钥后会自动拉取模型。"})]}),e.error?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"模型路由错误"}),(0,ey.jsx)(Qt,{className:"break-words",children:e.error})]}):null,(0,ey.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,ey.jsxs)(eA.Button,{type:"button",variant:"destructive",onClick:r,disabled:e.saving,children:[(0,ey.jsx)(yi,{className:"size-4"}),"删除"]}),(0,ey.jsx)(eA.Button,{type:"button",onClick:n,disabled:!s,children:e.saving?"保存中":"保存"})]})]})}async function eaK(){return eaX("/api/local/subagent-config")}async function eaG(e){return eaX("/api/local/subagent-config",{method:"PUT",body:JSON.stringify(e)})}async function eaX(e,t){let n=await fetch(eD(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"subagent config api failed");return r}function eaY(e){return{explore:{...e.explore},workflow:{...e.workflow},operator:{...e.operator},custom:{...e.custom,models:[...e.custom.models??[]]}}}let eaZ={explore:{title:"探索子代理",icon:(0,ey.jsx)(Vy,{className:"size-4"}),tint:"text-sky-600 dark:text-sky-400",description:"只读的代码库探索/调研专家。彻底阅读、搜索代码库,返回带文件路径+行号引用的完整结论,替主 agent 节省上下文。",tools:"仅阅读(vantaloom_read)"},workflow:{title:"工作流子代理",icon:(0,ey.jsx)(uP,{className:"size-4"}),tint:"text-violet-600 dark:text-violet-400",description:"按 workflow-*.yml 严格执行可重复的多步流程,并把其中确定性的步骤自动固化为脚本、给 yml 添加批注。",tools:"阅读 / 编辑 / 终端(vantaloom_read · vantaloom_edit · vantaloom_shell)"},operator:{title:"操作员子代理",icon:(0,ey.jsx)(uO,{className:"size-4"}),tint:"text-pink-600 dark:text-pink-400",description:"专门驱动交互式终端(未来含浏览器)。执行大量终端操作并把结果回报给主 agent。",tools:"阅读 / 终端(vantaloom_read · vantaloom_shell)"}};function eaJ(){let[e,t]=ew.useState(null),{models:n,loading:r}=vq(),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1);async function f(){if(e&&!o){l(!0),c("");try{let n=await eaG({explore:e.explore,workflow:e.workflow,operator:e.operator,custom:e.custom});t(eaY(n)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await eaK();t(eaY(e))}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取子代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"子代理配置"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"主 agent 可以派发这些子代理来分担任务。每个子代理拥有独立上下文与受限工具集,完成后只把结果汇报给主 agent。"})]}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(),disabled:o,children:[(0,ey.jsx)(K3,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"错误"}),(0,ey.jsx)(Qt,{children:s})]}):null,["explore","workflow","operator"].map(a=>(0,ey.jsx)(eaQ,{tourId:`subagent-${a}`,meta:eaZ[a],value:e[a],models:n,modelsLoading:r,onChange:e=>{t(t=>t?{...t,[a]:{...t[a],...e}}:t),u(!0)}},a)),(0,ey.jsx)(ea0,{value:e.custom,models:n,modelsLoading:r,onChange:function(e){t(t=>t?{...t,custom:{...t.custom,...e}}:t),u(!0)}})]}):(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"读取失败"}),(0,ey.jsx)(Qt,{children:s||"无法加载子代理配置"})]})}function eaQ({meta:e,value:t,models:n,modelsLoading:r,onChange:a,tourId:i}){return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":i,children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:e.tint,children:e.icon}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:e.title})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description}),(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"text-foreground/70",children:"可用工具:"}),e.tools,(0,ey.jsx)("span",{className:"ml-1 text-muted-foreground/70",children:"(固定,不可更改)"})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"使用模型"}),(0,ey.jsx)(ea1,{models:n,value:t.modelRef,onValueChange:e=>a({modelRef:e}),placeholder:r?"读取模型中":"继承上级模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则继承派发它的上级 agent 当前使用的模型。"})]}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"允许上级指定模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,上级 agent 可在派发时动态指定该子代理使用的模型。"})]}),(0,ey.jsx)(xZ,{checked:t.allowCallerModel,onCheckedChange:e=>a({allowCallerModel:e})})]}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"系统提示词"}),t.promptOverride?(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a({promptOverride:""}),children:"恢复默认"}):null]}),(0,ey.jsx)(b3,{value:t.promptOverride,onChange:e=>a({promptOverride:e.currentTarget.value}),placeholder:"留空使用内置默认提示词;在此输入将覆盖默认提示词(环境/工具说明仍会自动附加)。",rows:t.promptOverride?10:3,className:"resize-y text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"覆盖该官方子代理的预设系统提示词。派发时还会自动附加工作区、操作系统与工具使用说明。"})]})]})}function ea0({value:e,models:t,modelsLoading:n,onChange:r}){let a=ew.useCallback(e=>t.find(t=>t.value===e)?.label??e,[t]);return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"subagent-custom",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:(0,ey.jsx)(ub,{className:"size-4"})}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自定义子代理"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 可以自取名字、从下面的模型池中选一个模型来召唤自定义子代理,并可选择是否继承当前对话上下文。自定义子代理拥有完整工具集,还能进一步派发上面三种官方子代理。"}),(0,ey.jsx)(ee0,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erP,{className:"text-sm",children:"可用模型池"}),(0,ey.jsx)(xY,{variant:"list-combobox",value:e.models,onValueChange:e=>r({models:e}),options:t,placeholder:n?"读取模型中":"选择可供自定义子代理使用的模型",searchPlaceholder:"搜索模型...",emptyText:"没有可用模型",renderItem:a}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 召唤自定义子代理时会从这个池中选择一个模型。留空则沿用上级 agent 的模型。"})]})]})}function ea1({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gT,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:r})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))]})]})}function ea2(){let[e,t]=ew.useState(""),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState("");async function d(){if(!a){i(!0),c("");try{await js({systemPrompt:{userPrompt:e}}),l(!1)}catch(e){c(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return(ew.useEffect(()=>{(async()=>{try{let e=await jl();t(e.systemPrompt?.userPrompt??"")}catch(e){c(e instanceof Error?e.message:"加载失败")}finally{r(!1)}})()},[]),n)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取系统提示词配置"}):(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"兜底系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅对 vantaloom 引擎对话生效。当某个对话未检测到任何项目文档(CLAUDE.md / AGENTS.md / vantaloom.md),也没有在该对话的“系统提示词”里单独设置时, 才使用这里的内容作为兜底。各对话独立的系统提示词请到对话设置 → 系统提示词中配置。"})]}),o?(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void d(),disabled:a,children:[(0,ey.jsx)(K3,{className:"size-4"}),a?"保存中":"保存"]}):null]}),s?(0,ey.jsxs)(J9,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qe,{children:"错误"}),(0,ey.jsx)(Qt,{children:s})]}):null,(0,ey.jsx)(b3,{value:e,onChange:e=>{t(e.currentTarget.value),l(!0)},placeholder:"例如:始终用中文回复;提交前先跑测试;优先复用现有代码……",rows:8,className:"resize-y text-sm"})]})}function ea5({section:e}={}){return(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":`preferences-${e??"model-routes"}`,children:"agent-config"===e?(0,ey.jsx)(er9,{}):"subagent-config"===e?(0,ey.jsx)(eaJ,{}):"cc-engine-config"===e?(0,ey.jsx)(eaL,{}):"system-prompt"===e?(0,ey.jsx)(ea2,{}):"layout"===e?(0,ey.jsx)(eaV,{}):(0,ey.jsx)(eaW,{})})})}let ea4=(0,ek.default)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);function ea3(e,t){if(e.isLocal)return eD(t);let n=t.replace(/^\/v1(?=\/)/,"");return eD(`/v1/remote/${e.id}${n}`)}async function ea6(e){try{let t=await fetch(`https://registry.npmjs.org/@vantaloom/runtime-${e}`,{headers:{Accept:"application/vnd.npm.install-v1+json"},cache:"no-store"});if(!t.ok)return;let n=await t.json();return n?.["dist-tags"]?.latest}catch{return}}function ea8(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback((e,n)=>{t(t=>t.map(t=>t.machine.id===e?{...t,...n}:t))},[]),o=ew.useCallback(async()=>{r(!0);let e=[];try{let t=await fetch(eD("/v1/remote/machines"),{cache:"no-store"});e=(await t.json()).machines??[]}catch{e=[]}a.current&&(t(e.map(e=>({machine:e,loading:!0}))),r(!1),await Promise.all(e.map(async e=>{if(!e.isLocal&&"online"!==e.status){a.current&&i(e.id,{loading:!1,error:"离线"});return}try{let t,n=await fetch(ea3(e,"/v1/runtime/info"),{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.text();try{t=JSON.parse(r)}catch{throw Error("该机器运行时过旧,不支持版本检测")}let o=await ea6(t.platform);a.current&&i(e.id,{info:t,latest:o,loading:!1})}catch(t){a.current&&i(e.id,{loading:!1,error:t instanceof Error?t.message:"无法获取版本"})}})))},[i]);async function l(e){if(e.info&&!e.updating){i(e.machine.id,{updating:!0});try{await fetch(ea3(e.machine,"/v1/runtime/update"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:e.latest})})}catch{}window.setTimeout(()=>{a.current&&o()},25e3)}}return ew.useEffect(()=>(a.current=!0,o(),()=>{a.current=!1}),[o]),(0,ey.jsx)("div",{className:"h-full overflow-auto px-6 py-8","data-tour":"check-update",children:(0,ey.jsxs)("div",{className:"mx-auto flex max-w-3xl flex-col gap-5",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h1",{className:"text-xl font-semibold",children:"检查更新"}),(0,ey.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"工作组内各机器的运行时版本与可用更新。点击「立即更新」可让对应机器自动更新(该机器会短暂重启)。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:()=>void o(),disabled:n,children:[(0,ey.jsx)(ya,{className:(0,eI.cn)("size-4",n&&"animate-spin")}),"刷新"]})]}),n&&0===e.length?(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl border bg-card p-8 text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 正在获取机器列表…"]}):0===e.length?(0,ey.jsx)("div",{className:"rounded-xl border bg-card p-8 text-center text-sm text-muted-foreground",children:"暂无可用机器。"}):(0,ey.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{let t=!!e.info&&!!e.latest&&e.latest!==e.info.version;return(0,ey.jsxs)("div",{className:"flex items-center gap-4 rounded-xl border bg-card px-4 py-3",children:[(0,ey.jsx)(eP,{className:"size-5 shrink-0 text-muted-foreground"}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.machine.name}),e.machine.isLocal?(0,ey.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"本机"}):null]}),(0,ey.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.loading?"读取版本中…":e.error?(0,ey.jsx)("span",{className:"text-amber-600",children:e.error}):(0,ey.jsxs)(ey.Fragment,{children:[function(e){switch(e){case"windows":return"Windows";case"darwin":return"macOS";case"linux":return"Linux";case"android":return"Android";default:return e||"未知"}}(e.info?.os??e.machine.platform??"")," · 当前 ",(0,ey.jsx)("span",{className:"font-mono",children:e.info?.version??"?"}),e.latest?(0,ey.jsxs)(ey.Fragment,{children:[" · 最新 ",(0,ey.jsx)("span",{className:"font-mono",children:e.latest})]}):null,e.info?.updatedAt?(0,ey.jsxs)(ey.Fragment,{children:[" · 更新于 ",function(e){if(!e)return"—";let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):"—"}(e.info.updatedAt)]}):null]})})]}),e.loading?(0,ey.jsx)(eM,{className:"size-4 animate-spin text-muted-foreground"}):e.updating?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 更新中…"]}):t?(0,ey.jsxs)(eA.Button,{size:"sm",onClick:()=>void l(e),children:[(0,ey.jsx)(ea4,{className:"size-4"})," 立即更新"]}):e.info?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)(eO,{className:"size-4 text-emerald-500"})," 已是最新"]}):null]},e.machine.id)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"最新版本号来自 npm(@vantaloom/runtime-<平台>)。更新过程中该机器会停止并重启运行时, 若你的手机正连着它会短暂断开,更新完成后重新连接即可。"})]})})}let ea7=(0,ek.default)("gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]),ea9=(0,ek.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),eie=[{value:"24h",label:"近 24 小时"},{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"}];function eit(){let{user:e}=tl(),[t,n]=ew.useState(null),[r,a]=ew.useState(!0),[i,o]=ew.useState(null),[l,s]=ew.useState("7d"),[c,d]=ew.useState("all"),[u,f]=ew.useState([]),[h,m]=ew.useState([]),[p,g]=ew.useState(!0),[v,x]=ew.useState(""),[y,b]=ew.useState(!1),[w,j]=ew.useState(null),k=ew.useCallback(async()=>{a(!0),o(null);try{n(await e6())}catch(e){o(e instanceof Error?e.message:"读取余额失败")}finally{a(!1)}},[]);ew.useEffect(()=>{e&&(k(),e9().then(e=>f(e.models)).catch(()=>f([])))},[e,k]),ew.useEffect(()=>{if(!e)return;let t=!1;return g(!0),e8(l,"all"===c?void 0:c).then(e=>{t||m(e.points)}).catch(()=>{t||m([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e,l,c]);let S=ew.useMemo(()=>h.reduce((e,t)=>(e.costMicro+=t.costMicro,e.requests+=t.requests,e.totalTokens+=t.totalTokens,e),{costMicro:0,requests:0,totalTokens:0}),[h]),N=ew.useMemo(()=>h.map(e=>{var t;let n;return{label:(t=e.time,n=new Date(t),"24h"===l?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})),cost:e.costMicro/1e6,requests:e.requests,tokens:e.totalTokens}}),[h,l]);async function C(){let e=v.trim();if(e){b(!0),j(null);try{let t=await e7(e);j({kind:"ok",text:`兑换成功,到账 ${e4(t.valueMicro)}`}),x(""),n(e=>e?{...e,balanceMicro:t.balanceMicro,balanceUsd:t.balanceMicro/1e6}:e)}catch(e){j({kind:"err",text:e instanceof Error?e.message:"兑换失败,请检查兑换码"})}finally{b(!1)}}}return e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"余额与用量"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"查看官方渠道的账户余额、调用用量,并使用兑换码充值。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ens,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户余额"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void k(),disabled:r,children:[r?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(ya,{}),"刷新"]})]}),i?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:i}):(0,ey.jsx)("p",{className:"text-3xl font-semibold tracking-tight",children:r&&!t?"—":e4(t?.balanceMicro??0,4)})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ea7,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"兑换码充值"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"输入兑换码,金额将立即计入账户余额。"}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ez,{value:v,onChange:e=>x(e.target.value),placeholder:"请输入兑换码",className:"font-mono",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,ey.jsxs)(eA.Button,{className:"shrink-0",onClick:()=>void C(),disabled:y||!v.trim(),children:[y?(0,ey.jsx)(eM,{className:"animate-spin"}):null,"兑换"]})]}),w?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===w.kind?"text-primary":"text-destructive"),children:w.text}):null]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ea9,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"用量趋势"})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsxs)(gT,{value:c,onValueChange:d,children:[(0,ey.jsx)(vh,{size:"sm",className:"w-44",children:(0,ey.jsx)(gL,{placeholder:"全部模型"})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"all",children:"全部模型"}),u.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.displayName||e.id},e.id))]})]}),(0,ey.jsxs)(gT,{value:l,onValueChange:s,children:[(0,ey.jsx)(vh,{size:"sm",className:"w-32",children:(0,ey.jsx)(gL,{})}),(0,ey.jsx)(vg,{children:eie.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]})]})]}),(0,ey.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,ey.jsx)(ein,{label:"花费",value:e4(S.costMicro,4)}),(0,ey.jsx)(ein,{label:"请求数",value:S.requests.toLocaleString("zh-CN")}),(0,ey.jsx)(ein,{label:"Tokens",value:S.totalTokens.toLocaleString("zh-CN")})]}),(0,ey.jsx)("div",{className:"h-56 w-full",children:p&&0===h.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===N.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"所选区间暂无用量记录"}):(0,ey.jsx)(Cp,{width:"100%",height:"100%",children:(0,ey.jsxs)(YG,{data:N,margin:{top:8,right:8,left:0,bottom:0},children:[(0,ey.jsx)("defs",{children:(0,ey.jsxs)("linearGradient",{id:"usageCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ey.jsx)("stop",{offset:"5%",stopColor:"var(--color-primary)",stopOpacity:.35}),(0,ey.jsx)("stop",{offset:"95%",stopColor:"var(--color-primary)",stopOpacity:0})]})}),(0,ey.jsx)(Zy,{strokeDasharray:"3 3",stroke:"var(--color-border)",vertical:!1}),(0,ey.jsx)(ZD,{dataKey:"label",tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1}),(0,ey.jsx)(Zq,{tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1,width:48,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,ey.jsx)(BU,{contentStyle:{borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-popover)",fontSize:12},formatter:e=>[`$${Number(e).toFixed(4)}`,"花费"]}),(0,ey.jsx)(YV,{type:"monotone",dataKey:"cost",stroke:"var(--color-primary)",strokeWidth:2,fill:"url(#usageCost)"})]})})})]})]})}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(ens,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再查看余额与用量。"})]})})}function ein({label:e,value:t}){return(0,ey.jsxs)("div",{className:"rounded-md bg-muted/55 px-3 py-2",children:[(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("p",{className:"mt-0.5 truncate text-sm font-semibold",children:t})]})}let eir=(0,ek.default)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),eia=(0,ek.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),eii=[{value:"bug",label:"功能异常"},{value:"feature",label:"功能建议"},{value:"billing",label:"计费与余额"},{value:"other",label:"其他"}],eio=Object.fromEntries(eii.map(e=>[e.value,e.label])),eil={pending:{label:"待审批",variant:"secondary"},preparing:{label:"准备完成",variant:"outline"},done:{label:"已完成",variant:"default"},noplan:{label:"暂时无计划",variant:"secondary"}};function eis(){let{user:e}=tl(),[t,n]=ew.useState(""),[r,a]=ew.useState("bug"),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState(!1),[u,f]=ew.useState(null),[h,m]=ew.useState(!1),p=ew.useRef(null),[g,v]=ew.useState([]),[x,y]=ew.useState(!0),[b,w]=ew.useState(null),j=ew.useCallback(async()=>{y(!0);try{let e=await tt();v(e.issues)}catch{v([])}finally{y(!1)}},[]);function k(e){let t=Array.from(e).filter(e=>e.type.startsWith("image/"));f(null),s(e=>{let n=[...e];for(let e of t){if(n.length>=10){f({kind:"err",text:`最多上传 10 张图片`});break}if(e.size>8388608){f({kind:"err",text:`「${e.name}」过大(上限 8MB)`});continue}n.push({id:`${e.name}-${e.size}-${n.length}`,file:e,url:URL.createObjectURL(e)})}return n})}async function S(){if(!t.trim())return void f({kind:"err",text:"请填写标题"});d(!0),f(null);try{let{issue:e}=await te({title:t.trim(),type:r,content:i.trim()}),c=!1;for(let t of l)try{await tn(e.id,t.file)}catch{c=!0}f({kind:"ok",text:c?"反馈已提交,但部分图片上传失败,请在下方列表确认":"反馈已提交,感谢您的反馈!"}),n(""),a("bug"),o(""),l.forEach(e=>URL.revokeObjectURL(e.url)),s([]),j()}catch(e){f({kind:"err",text:e instanceof Error?e.message:"提交失败,请重试"})}finally{d(!1)}}return ew.useEffect(()=>{e&&j()},[e,j]),ew.useEffect(()=>()=>{l.forEach(e=>URL.revokeObjectURL(e.url))},[]),e?(0,ey.jsxs)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:[(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"问题反馈"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"提交功能异常、建议或计费问题,我们会在看板中跟进处理。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"标题"}),(0,ey.jsx)(ez,{value:t,onChange:e=>n(e.target.value),maxLength:120,placeholder:"简要描述问题"})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"类型"}),(0,ey.jsxs)(gT,{value:r,onValueChange:a,children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{})}),(0,ey.jsx)(vg,{children:eii.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"详细描述"}),(0,ey.jsx)(b3,{value:i,onChange:e=>o(e.target.value),rows:5,placeholder:"详细描述问题的复现步骤、期望行为等",onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),k(t))}})]}),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid gap-3 rounded-lg border border-dashed p-3 transition-colors",h?"border-primary bg-primary/5":"border-input"),onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:["可拖拽、粘贴或选择图片(最多 ",10," 张,单张 ≤ 8MB)"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>p.current?.click(),children:[(0,ey.jsx)(eir,{}),"添加图片"]}),(0,ey.jsx)("input",{ref:p,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&k(e.target.files),e.target.value=""}})]}),l.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,ey.jsxs)("div",{className:"relative size-16 overflow-hidden rounded-md border",children:[(0,ey.jsx)("img",{src:e.url,alt:e.file.name,className:"size-full object-cover"}),(0,ey.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void s(e=>{let n=e.find(e=>e.id===t);return n&&URL.revokeObjectURL(n.url),e.filter(e=>e.id!==t)})},className:"absolute right-0.5 top-0.5 rounded-full bg-black/55 p-0.5 text-white hover:bg-black/75","aria-label":"移除图片",children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]},e.id))}):null]}),u?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===u.kind?"text-primary":"text-destructive"),children:u.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsxs)(eA.Button,{onClick:()=>void S(),disabled:c||!t.trim(),children:[c?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(eia,{}),"提交反馈"]})})]}),(0,ey.jsxs)("section",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"我的反馈"}),x?(0,ey.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===g.length?(0,ey.jsx)("p",{className:"rounded-lg border bg-card p-6 text-center text-xs text-muted-foreground",children:"你还没有提交过反馈。"}):g.map(e=>{let t=eil[e.status]??{label:e.status,variant:"secondary"};return(0,ey.jsxs)("article",{className:"grid gap-2 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,ey.jsx)(Bs,{variant:"outline",children:eio[e.type]??e.type}),(0,ey.jsx)(Bs,{variant:t.variant,children:t.label})]})]}),e.content?(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:e.content}):null,e.images.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:e.images.map(t=>(0,ey.jsx)("button",{type:"button",className:"size-16 overflow-hidden rounded-md border",onClick:()=>w({issueId:e.id,imageId:t.id}),children:(0,ey.jsx)(eid,{issueId:e.id,imageId:t.id})},t.id))}):null,(0,ey.jsx)("p",{className:"text-[11px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN")})]},e.id)})]})]}),(0,ey.jsx)(dC,{open:null!==b,onOpenChange:e=>{e||w(null)},children:(0,ey.jsx)(fx,{className:"max-w-3xl",children:b?(0,ey.jsx)(eiu,{issueId:b.issueId,imageId:b.imageId,className:"max-h-[75vh] w-full object-contain"}):null})})]}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(jb,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再提交问题反馈。"})]})})}function eic(e,t){let[n,r]=ew.useState(null);return ew.useEffect(()=>{let n=!0,a=null;return tr(e,t).then(e=>{a=e,n?r(e):URL.revokeObjectURL(e)}).catch(()=>{}),()=>{n=!1,a&&URL.revokeObjectURL(a)}},[e,t]),n}function eid({issueId:e,imageId:t}){let n=eic(e,t);return n?(0,ey.jsx)("img",{src:n,alt:"",className:"size-full object-cover"}):(0,ey.jsx)("div",{className:"flex size-full items-center justify-center bg-muted"})}function eiu({issueId:e,imageId:t,className:n}){let r=eic(e,t);return r?(0,ey.jsx)("img",{src:r,alt:"",className:n}):(0,ey.jsx)("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})})}let eif={totals:{machines:0,online:0,runtime:0,tokens:0},machines:[],topology:{nodes:[],links:[]},pathTotals:{direct:0,p2p:0,relay:0,broken:0},latency:[],candidates:[]},eih={metrics:{online:0,health:0,latency:"local",events:0},machines:[],trend:[],networkLinks:[],events:[],serviceHealth:[]};function eim(e,t){let[n,r]=ew.useState(t);return ew.useEffect(()=>{let n=!0,a=!1;async function i(){if(!a){a=!0;try{let t=await fetch(eD(e),{cache:"no-store"});if(!t.ok)return;let a=await t.json();n&&r(a)}catch{n&&r(t)}finally{a=!1}}}i();let o=window.setInterval(i,2e3);return()=>{n=!1,window.clearInterval(o)}},[t,e]),n}function eip(){let e=eim("/api/local/machines/fleet",eif),{nodes:t,links:n}=e.topology;return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"shrink-0 border-b px-6 py-4",children:[(0,ey.jsx)("h2",{className:"text-base font-semibold tracking-normal",children:"组网关系"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"系统中各机器的拓扑关系图(自动生成)。节点为机器,连线表示机器之间的连接方式与实时延迟。"}),(0,ey.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["机器 ",e.totals.online,"/",e.totals.machines," 在线"]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"直连 ",e.pathTotals.direct]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"P2P ",e.pathTotals.p2p]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-muted-foreground"}),"中继 ",e.pathTotals.relay]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-destructive"}),"断开 ",e.pathTotals.broken]})]})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 p-4",children:0===t.length?(0,ey.jsx)("div",{className:"grid h-full place-items-center rounded-lg border border-dashed",children:(0,ey.jsx)("p",{className:"max-w-sm text-center text-sm text-muted-foreground",children:"暂未发现其它机器。登录 Hub 账户并把机器加入同一工作组后,这里会自动绘制组网拓扑。"})}):(0,ey.jsx)("div",{className:"h-full overflow-hidden rounded-lg border bg-card",children:(0,ey.jsx)(etM,{nodes:t,links:n})})}),(0,ey.jsx)("footer",{className:"shrink-0 border-t px-6 py-2",children:(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[(0,ey.jsx)("span",{children:"连接方式:"}),[{kind:"direct",label:"直连",className:"bg-foreground"},{kind:"p2p",label:"P2P",className:"bg-foreground"},{kind:"relay",label:"中继",className:"bg-muted-foreground"},{kind:"down",label:"断开",className:"bg-destructive"}].map(e=>(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:`h-0.5 w-4 rounded ${e.className}`}),e.label]},e.kind))]})})]})}let eig="local",eiv=[{id:"cloakbrowser",label:"CloakBrowser 默认",description:"源码级反爬的真 Chromium,最适合 agent 在真实站点稳定工作。"},{id:"chrome-for-testing",label:"Chrome for Testing",description:"Google 官方纯净自动化 Chromium,更轻量、自动化友好。"}];function eix(){let{machines:e}=vj(),t=ew.useMemo(()=>{let t=[],n=!1;for(let r of e)if(r.isLocal)n=!0,t.unshift({id:eig,name:"本机",online:!0,reachable:!0,isLocal:!0});else{let e="online"===r.status;t.push({id:r.id,name:r.name,online:e,reachable:r.reachable??e,isLocal:!1})}return n||t.unshift({id:eig,name:"本机",online:!0,reachable:!0,isLocal:!0}),t},[e]),[n,r]=ew.useState(eig);return ew.useEffect(()=>{t.some(e=>e.id===n)||r(t[0]?.id??eig)},[t,n]),(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":"preferences-official-extensions",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"官方扩展"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"为指定机器安装并管理官方扩展。扩展与 Agent 运行时同机部署,按机器各自安装。"})]}),(0,ey.jsxs)(md,{value:n,onValueChange:r,className:"grid gap-4",children:[(0,ey.jsx)("div",{className:"overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsx)(my,{className:"h-8 w-max min-w-full",children:t.map(e=>(0,ey.jsxs)(mb,{value:e.id,className:"gap-1.5",children:[(0,ey.jsx)(eP,{className:"size-3.5"}),(0,ey.jsx)("span",{className:"truncate",children:e.name}),(0,ey.jsx)("span",{className:(0,eI.cn)("size-1.5 rounded-full",e.online?"bg-emerald-500":"bg-muted-foreground/40"),"aria-label":e.online?"在线":"离线"})]},e.id))})}),(0,ey.jsx)(eiy,{machine:t.find(e=>e.id===n)??t[0]},n)]})]})})})}function eiy({machine:e}){var t;let n=(t=e?.id??eig)===eig?void 0:t,r=e?.reachable??!0,[a,i]=ew.useState(null),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(0),[f,h]=ew.useState(!1),m=ew.useCallback(()=>u(e=>e+1),[]);ew.useEffect(()=>{if(!r){l(!1),c(!0),i(null);return}let e=!0,t=new AbortController;async function a(){try{let r=await GP(n,{signal:t.signal});if(!e)return;i(r.extensions??[]),c(!1)}catch{if(!e)return;c(!0)}finally{e&&l(!1)}}a();let o=f?window.setInterval(a,3e3):void 0;return()=>{e=!1,t.abort(),o&&window.clearInterval(o)}},[n,r,d,f]);let p=a?.find(e=>"browser"===e.id)??(a?eib:void 0);return o?(0,ey.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,ey.jsx)(VM,{className:"size-4"}),"正在获取扩展状态…"]}):s||!a?(0,ey.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,ey.jsx)("p",{className:"text-sm text-destructive",children:"无法获取扩展状态"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:r?"请确认该机器的运行时已启动,稍后重试。":"该机器当前不可达(离线或无连接路径)。"}),r&&(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:m,children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]})})]}):p?(0,ey.jsx)(eiw,{machineId:n,extension:p,onChanged:m,setPolling:h}):(0,ey.jsx)("div",{className:"rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:"该机器暂无可用的官方扩展。"})}let eib={id:"browser",name:"Vantaloom 浏览器",installed:!1,enabled:!1,running:!1,variant:"cloakbrowser",version:"",available:["cloakbrowser","chrome-for-testing"]};function eiw({machineId:e,extension:t,onChanged:n,setPolling:r}){var a;let[i,o]=ew.useState(null),[l,s]=ew.useState(null),[c,d]=ew.useState(t.variant??"cloakbrowser");ew.useEffect(()=>{t.installed&&t.variant&&d(t.variant)},[t.installed,t.variant]);let u="install"===i;async function f(e,t,a=!1){o(e),s(null),a&&r(!0);try{await t(),n()}catch{s("操作失败,请稍后重试。")}finally{o(null),a&&r(!1)}}async function h(t){o("enable"),s(null),r(!0);try{await GD(e,t),n();let r=Date.now()+3e4;for(;Date.now()<r;){await new Promise(e=>setTimeout(e,1500));try{let n=(await GP(e,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(n&&n.running===t)break}catch{}}n()}catch{s(t?"启动失败,请稍后重试。":"停止失败,请稍后重试。")}finally{o(null),r(!1)}}let m="enable"===i,p=m&&!t.running||t.enabled&&!t.running,g=m&&t.running,v=t.installed?t.running?(0,ey.jsx)(Bs,{variant:"default",children:"运行中"}):p?(0,ey.jsx)(Bs,{variant:"secondary",className:"bg-amber-500/15 text-amber-600 dark:text-amber-400",children:"启动中"}):(0,ey.jsx)(Bs,{variant:"secondary",className:"bg-muted text-muted-foreground",children:"已停止"}):(0,ey.jsx)(Bs,{variant:"outline",children:"未安装"}),x=eiv.filter(e=>!t.available?.length||t.available.includes(e.id));return(0,ey.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-3",children:[(0,ey.jsx)("span",{className:"grid size-10 shrink-0 place-items-center rounded-md bg-primary/10 text-primary [&_svg]:size-5",children:(0,ey.jsx)(Ui,{})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Vantaloom 浏览器"}),v,t.installed&&t.version&&(0,ey.jsxs)("span",{className:"text-xs text-muted-foreground",children:["v",t.version]})]}),(0,ey.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"让 Agent 可操作真实浏览器:网站预览直连真实浏览器,可在指定机器上运行并远程观看 Agent 的操作过程。"})]})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"浏览器内核"}),(0,ey.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:x.map(e=>{let n=c===e.id,r=t.installed;return(0,ey.jsxs)("button",{type:"button",disabled:r||null!==i,onClick:()=>d(e.id),className:(0,eI.cn)("flex flex-col gap-1 rounded-lg border p-3 text-left transition-colors",n?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground",(r||null!==i)&&"opacity-60"),"aria-pressed":n,children:[(0,ey.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.id)})}),t.installed&&(0,ey.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["已安装的内核为 ",(a=t.variant,eiv.find(e=>e.id===a)?.label??a),",如需更换请先卸载。"]})]}),(0,ey.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:t.installed?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)(eA.Button,{size:"sm",disabled:null!==i,onClick:()=>h(!t.running),children:[m?(0,ey.jsx)(VM,{className:"size-3.5"}):t.running?(0,ey.jsx)(jD,{className:"size-3.5"}):(0,ey.jsx)(Vw,{className:"size-3.5"}),g?"停止中…":p?"启动中…":t.running?"停止浏览器":"启动浏览器"]}),(0,ey.jsxs)(eA.Button,{size:"sm",variant:"outline",disabled:null!==i,onClick:()=>f("update",()=>Gz(e),!0),children:["update"===i?(0,ey.jsx)(VM,{className:"size-3.5"}):(0,ey.jsx)(ya,{className:"size-3.5"}),"update"===i?"正在更新…":"更新"]}),(0,ey.jsxs)(eA.Button,{size:"sm",variant:"destructive",disabled:null!==i,onClick:()=>f("uninstall",()=>GT(e)),children:["uninstall"===i?(0,ey.jsx)(VM,{className:"size-3.5"}):(0,ey.jsx)(yi,{className:"size-3.5"}),"卸载"]})]}):(0,ey.jsxs)(eA.Button,{size:"sm",disabled:null!==i,onClick:()=>f("install",()=>GI(e,c),!0),children:[u?(0,ey.jsx)(VM,{className:"size-3.5"}):null,u?"正在安装…":"安装"]})}),t.installed&&(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium text-foreground",children:"在此机器上运行"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后该机器的 Agent 可使用浏览器工具;关闭则停止浏览器与边车进程。"})]}),(0,ey.jsx)(xZ,{checked:t.enabled,disabled:null!==i,onCheckedChange:e=>void h(e),"aria-label":"在此机器上运行浏览器扩展"})]}),l&&(0,ey.jsx)("p",{className:"text-xs text-destructive",children:l})]})}let eij=(0,ek.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);function eik(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${e} B`;let t=["KB","MB","GB","TB"],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n>=100?0:1)} ${t[r]}`}function eiS({status:e}){switch(e){case"active":return(0,ey.jsx)(Bs,{variant:"default",children:"下载中"});case"complete":return(0,ey.jsx)(Bs,{className:"border-transparent bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"已完成"});case"error":return(0,ey.jsx)(Bs,{variant:"destructive",children:"失败"});case"paused":return(0,ey.jsx)(Bs,{variant:"secondary",children:"已暂停"});case"canceled":return(0,ey.jsx)(Bs,{variant:"outline",children:"已取消"});default:return(0,ey.jsx)(Bs,{variant:"outline",children:"等待中"})}}let eiN=["complete","error","canceled"];function eiC({download:e}){let{status:t,percent:n,totalBytes:r}=e,a=Math.max(0,Math.min(100,n));return r<0&&"active"===t?(0,ey.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-y-0 w-1/3 rounded-full bg-primary/70","vtl-download-indeterminate")})}):(0,ey.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:(0,eI.cn)("h-full rounded-full transition-all","error"===t?"bg-destructive":"complete"===t?"bg-emerald-500":"paused"===t?"bg-muted-foreground/60":"bg-primary","active"===t&&"vtl-download-stripes bg-[length:1rem_1rem]"),style:{width:`${a}%`}})})}function eiM({download:e}){var t,n,r;let a,[i,o]=ew.useState(!1),l=ew.useCallback(async e=>{o(!0);try{await e()}catch{}finally{o(!1)}},[]),{status:s}=e,c="active"===s?!Number.isFinite(t=e.speedBps)||t<=0?"":`${eik(t)}/s`:"",d="active"===s?function(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`}(e.etaSeconds):"",u=!(e.totalBytes<0&&"active"===s),f="active"===s,h="paused"===s,m="error"===s||"canceled"===s,p="active"===s||"paused"===s||"waiting"===s,g=eiN.includes(s);return(0,ey.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.label||e.url||e.id}),(0,ey.jsx)(eiS,{status:s}),e.attempt>1&&(0,ey.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["重试 ",e.attempt]})]}),e.dest&&(0,ey.jsx)("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:e.dest})]}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[i&&(0,ey.jsx)(VM,{className:"size-3.5"}),f&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"暂停","aria-label":"暂停",onClick:()=>l(()=>mK(e.id,"pause")),children:(0,ey.jsx)(eij,{className:"size-3.5"})}),h&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"继续","aria-label":"继续",onClick:()=>l(()=>mK(e.id,"resume")),children:(0,ey.jsx)(Vw,{className:"size-3.5"})}),m&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"重试","aria-label":"重试",onClick:()=>l(()=>mK(e.id,"retry")),children:(0,ey.jsx)(ya,{className:"size-3.5"})}),p&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"取消","aria-label":"取消",onClick:()=>l(()=>mK(e.id,"cancel")),children:(0,ey.jsx)(fg.XIcon,{className:"size-3.5"})}),g&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive",disabled:i,title:"移除","aria-label":"移除",onClick:()=>l(()=>mK(e.id,"remove")),children:(0,ey.jsx)(yi,{className:"size-3.5"})})]})]}),(0,ey.jsx)(eiC,{download:e}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[u&&(0,ey.jsxs)("span",{className:"tabular-nums",children:[Math.round(e.percent),"%"]}),(0,ey.jsx)("span",{className:"tabular-nums",children:(n=e.downloadedBytes,r=e.totalBytes,a=eik(n),r<0?a:`${a} / ${eik(r)}`)}),c&&(0,ey.jsx)("span",{className:"tabular-nums",children:c}),d&&(0,ey.jsxs)("span",{className:"tabular-nums",children:["剩余 ",d]}),e.connections>0&&(0,ey.jsxs)("span",{className:"tabular-nums",children:[e.connections," 连接"]})]}),"error"===s&&e.error&&(0,ey.jsx)("p",{className:"text-[11px] text-destructive",children:e.error})]})}function eiE(){let[e,t]=ew.useState([]),[n,r]=ew.useState("loading"),[a,i]=ew.useState(0),o=ew.useCallback(()=>{r("loading"),i(e=>e+1)},[]);return(ew.useEffect(()=>{let e,n=!1,a=new AbortController,i=e=>{n||(t(e),r("ready"))};async function o(){try{let e=await mU({signal:a.signal});if(n)return;t(e.downloads),r("ready")}catch(e){if(n||a.signal.aborted)return;if(e instanceof mH)return void r("unavailable")}try{await mW(i,{signal:a.signal}),n||l()}catch(e){if(n||a.signal.aborted)return;if(e instanceof mH)return void r("unavailable");r(e=>"ready"===e?"ready":"error"),l()}}function l(){n||(e=setTimeout(()=>{n||o()},2e3))}return o(),()=>{n=!0,a.abort(),e&&clearTimeout(e)}},[a]),"loading"===n)?(0,ey.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,ey.jsx)(VM,{className:"size-4"}),"正在获取下载状态…"]}):"unavailable"===n||"error"===n?(0,ey.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,ey.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载状态"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]})})]}):0===e.length?(0,ey.jsx)("div",{className:"rounded-lg border bg-card p-10 text-center text-sm text-muted-foreground",children:"暂无下载任务"}):(0,ey.jsx)("div",{className:"grid gap-2",children:e.map(e=>(0,ey.jsx)(eiM,{download:e},e.id))})}function eiO({label:e,description:t,value:n,min:r,max:a,onChange:i,disabled:o}){return(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-foreground",children:e}),t&&(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t}),(0,ey.jsx)(ez,{type:"number",inputMode:"numeric",min:r,max:a,value:Number.isFinite(n)?n:0,disabled:o,onChange:e=>{let t=Number(e.target.value);if(Number.isNaN(t))return;let n=t;void 0!==r&&(n=Math.max(r,n)),void 0!==a&&(n=Math.min(a,n)),i(n)},className:"max-w-[12rem]"})]})}function eiP(){let[e,t]=ew.useState(null),[n,r]=ew.useState("loading"),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState(null),[d,u]=ew.useState(0),f=ew.useCallback(()=>{r("loading"),u(e=>e+1)},[]);ew.useEffect(()=>{let e=!1,n=new AbortController;return async function(){try{let a=await mG({signal:n.signal});if(e)return;t(a),r("ready")}catch(t){if(e||n.signal.aborted)return;r(t instanceof mH?"unavailable":"error")}}(),()=>{e=!0,n.abort()}},[d]);let h=ew.useCallback((e,n)=>{t(t=>t?{...t,[e]:n}:t),l(!1)},[]),m=ew.useCallback(async()=>{if(e){i(!0),c(null),l(!1);try{let n=await mX(e);t(n),l(!0)}catch{c("保存失败,请稍后重试。")}finally{i(!1)}}},[e]);return"loading"===n?(0,ey.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,ey.jsx)(VM,{className:"size-4"}),"正在加载下载设置…"]}):"unavailable"!==n&&"error"!==n&&e?(0,ey.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-foreground",children:"下载目录"}),(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载文件的默认保存位置。"}),(0,ey.jsx)(ez,{type:"text",value:e.downloadDir,disabled:a,placeholder:"例如 D:\\\\Downloads",onChange:e=>h("downloadDir",e.target.value)})]}),(0,ey.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,ey.jsx)(eiO,{label:"最大同时下载数",description:"同时进行的任务数量上限。",value:e.maxConcurrentDownloads,min:1,max:32,disabled:a,onChange:e=>h("maxConcurrentDownloads",e)}),(0,ey.jsx)(eiO,{label:"单任务最大连接数",description:"单个任务的并发分段连接数(1–16)。",value:e.maxConnectionsPerTask,min:1,max:16,disabled:a,onChange:e=>h("maxConnectionsPerTask",e)}),(0,ey.jsx)(eiO,{label:"失败重试次数",description:"任务失败后的自动重试上限。",value:e.maxRetries,min:0,max:20,disabled:a,onChange:e=>h("maxRetries",e)})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-foreground",children:"代理"}),(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载使用的代理地址,留空则不使用代理。"}),(0,ey.jsx)(ez,{type:"text",value:e.proxy,disabled:a,placeholder:"例如 http://127.0.0.1:7890(留空=不使用)",onChange:e=>h("proxy",e.target.value)})]}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium text-foreground",children:"校验文件哈希"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"下载完成后校验文件哈希以确保完整性。"})]}),(0,ey.jsx)(xZ,{checked:e.verifyChecksums,disabled:a,onCheckedChange:e=>h("verifyChecksums",e),"aria-label":"校验文件哈希"})]}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,ey.jsxs)(eA.Button,{size:"sm",disabled:a,onClick:m,children:[a?(0,ey.jsx)(VM,{className:"size-3.5"}):null,a?"正在保存…":"保存设置"]}),o&&!a&&(0,ey.jsx)("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"已保存"}),s&&(0,ey.jsx)("span",{className:"text-xs text-destructive",children:s})]})]}):(0,ey.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,ey.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载设置"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:f,children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]})})]})}function eiA(){return(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":"system-downloads",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold tracking-normal",children:[(0,ey.jsx)(x1,{className:"size-4"}),"下载"]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"管理本机的下载任务,并配置下载目录、并发与代理等全局选项。"})]}),(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"下载任务"}),(0,ey.jsx)(eiE,{})]}),(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"全局设置"}),(0,ey.jsx)(eiP,{})]})]})})})}let eiI=["light","dark","jelly"],eiz={light:{label:"Light",icon:eno,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:enr,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,ey.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,ey.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,ey.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,ey.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,ey.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,ey.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function eiT(){let{resolvedTheme:e,setTheme:t}=(0,hE.useTheme)(),[n,r]=ew.useState(enw.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(enw.appearanceThemeStorageKey)??enw.defaultAppearanceTheme;r(e),(0,enw.applyAppearanceTheme)({theme:e})},[]);let a=n===enw.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=eiI.indexOf(a),o=eiI[(i+1)%eiI.length]??"light",{icon:l,label:s,className:c}=eiz[a];function d(e){r(e),window.localStorage.setItem(enw.appearanceThemeStorageKey,e),(0,enw.applyAppearanceTheme)({theme:e})}return(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,eI.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${QA.theme}: ${s}`,title:`${QA.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(enw.jellyAppearanceTheme);return}d(enw.defaultAppearanceTheme),t(o)},children:(0,ey.jsx)(l,{})})}let eiD=(0,ek.default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);(0,ek.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),(0,ek.default)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);let eiR=(0,ek.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),ei_=[{id:"run-ui-polish",title:"组件库视觉回归检查",machine:"Studio-PC",agent:"UI Polish",state:"running",started:"14:08",runtime:"22m",progress:68,load:54},{id:"run-runner-build",title:"Linux runner 镜像构建",machine:"Linux-runner-02",agent:"Build Agent",state:"running",started:"14:15",runtime:"15m",progress:41,load:86},{id:"run-access-audit",title:"工作组权限审阅",machine:"Studio-PC",agent:"Access Agent",state:"blocked",started:"14:21",runtime:"9m",progress:37,load:18},{id:"run-docs",title:"发布说明摘要",machine:"MacBook-build",agent:"Docs Agent",state:"queued",started:"等待",runtime:"0m",progress:0,load:0},{id:"run-cache-clean",title:"缓存清理策略验证",machine:"Linux-runner-02",agent:"Ops Sentinel",state:"failed",started:"13:54",runtime:"6m",progress:28,load:12}],eiL=[{id:"worker-studio",machine:"Studio-PC",role:"local coordinator",active:3,capacity:6,cpu:42,memory:68},{id:"worker-runner",machine:"Linux-runner-02",role:"gpu worker",active:4,capacity:5,cpu:76,memory:81},{id:"worker-mac",machine:"MacBook-build",role:"build host",active:0,capacity:3,cpu:8,memory:24}],ei$=[{id:"confirm-shell",title:"Studio-PC 请求执行发布前文件写入",meta:"UI Polish · apply_patch",tone:"normal"},{id:"confirm-service",title:"Linux-runner-02 请求重启 runner 服务",meta:"Ops Sentinel · Restart-Service",tone:"warning"},{id:"confirm-token",title:"工作组 token 加入新机器",meta:"Access Agent · admin required",tone:"normal"}],eiF=[["14:29","Studio-PC","pnpm --filter vantaloom-app lint","完成"],["14:27","Linux-runner-02","docker build agent-runtime","运行中"],["14:22","Studio-PC","apply_patch agent settings","完成"],["14:17","MacBook-build","pnpm typecheck","排队"],["14:03","Linux-runner-02","cache prune dry-run","失败"]],eiB={cpu:{label:"CPU",color:"var(--chart-1)"},memory:{label:"Memory",color:"var(--chart-3)"},network:{label:"Network",color:"var(--chart-5)"}};function eiV(e,t,n=42,r){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5",r&&"vtl-jelly-image-card",r&&r.includes("/bg")&&"vtl-jelly-image-card-shadowless"),style:r?QO({image:r,opacity:.74,blur:"8px"}):void 0,children:(0,ey.jsx)(Q4,{label:e,value:t,minSize:n})})}function eiH(e,t,n=""){return{title:e,dataSource:t,refreshRate:"10s",note:n}}let eiU={metrics:{online:2,health:88.4,latency:"38ms",events:17},machines:[{id:"studio",name:"Studio-PC",os:"Windows",status:"online",link:"direct",heartbeat:"3s",cpu:42,memory:68,disk:71,network:24},{id:"runner",name:"Linux-runner-02",os:"Linux",status:"online",link:"p2p",heartbeat:"5s",cpu:76,memory:81,disk:62,network:43},{id:"mac",name:"MacBook-build",os:"macOS",status:"sleeping",link:"direct",heartbeat:"2m",cpu:8,memory:24,disk:48,network:6}],trend:[{time:"09:00",cpu:36,memory:54,network:24},{time:"10:00",cpu:48,memory:61,network:29},{time:"11:00",cpu:44,memory:58,network:34},{time:"12:00",cpu:63,memory:72,network:41},{time:"13:00",cpu:58,memory:69,network:37},{time:"14:00",cpu:71,memory:76,network:46}],networkLinks:[["Studio-PC","Linux-runner-02","P2P","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","12ms","0.0%"],["Linux-runner-02","MacBook-build","Relay fallback","84ms","1.1%"]],events:[["14:31","Linux-runner-02 心跳延迟升高"],["14:28","Studio-PC 完成 2 个工具调用"],["14:19","MacBook-build 进入睡眠状态"],["14:12","工作组权限策略同步完成"],["14:04","P2P 链路切换到备用路径"]],serviceHealth:[{id:"local-service",name:"Local service",state:"正常",samples:[96,98,97,95,96,94,97,98,96,95,97,96]},{id:"agent-runtime",name:"Agent runtime",state:"正常",samples:[91,93,94,90,88,92,94,93,91,89,92,94]},{id:"p2p-mesh",name:"P2P mesh",state:"波动",samples:[78,82,76,73,68,71,74,79,83,80,77,72]},{id:"plugin-bridge",name:"Plugin bridge",state:"告警",samples:[88,86,84,82,79,74,63,54,48,52,67,76]}]},eiW=[{id:"metric-runs",title:"运行中",description:"当前正在执行的运行数量。",icon:(0,ey.jsx)(uP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("运行中","运行队列"),render:e=>eiV(e.title,"07",44,QN)},{id:"metric-queued",title:"排队",description:"等待调度的任务数量。",icon:(0,ey.jsx)(uy,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("排队","调度器"),render:e=>eiV(e.title,"04",44,QC)},{id:"metric-blocked",title:"待确认",description:"等待人工确认的任务数量。",icon:(0,ey.jsx)(eiR,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("待确认","确认队列"),render:e=>eiV(e.title,"03",44,QM)},{id:"metric-workers",title:"Worker",description:"当前可调度 worker 数量。",icon:(0,ey.jsx)(GE,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("Worker","Agent worker"),render:e=>eiV(e.title,"14",44,QE)},{id:"queue",title:"任务队列",description:"运行队列 Roadmap。",icon:(0,ey.jsx)(GC,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eiH("任务队列","运行队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QP,{title:e.title}),(0,ey.jsx)(etA,{items:ei_})]})},{id:"workers",title:"Agent worker",description:"各 worker 的负载和容量。",icon:(0,ey.jsx)(GE,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eiH("Agent worker","Worker 状态"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QP,{title:e.title}),(0,ey.jsx)(etz,{workers:eiL})]})},{id:"log",title:"最近执行",description:"最近执行记录 Roadmap。",icon:(0,ey.jsx)(Q7,{className:"size-4"}),defaultSize:{w:7,h:4},defaultConfig:eiH("最近执行","执行日志"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QP,{title:e.title}),(0,ey.jsx)(etP,{items:eiF})]})},{id:"confirmations",title:"待确认",description:"等待人工确认的事项。",icon:(0,ey.jsx)(eeQ,{className:"size-4"}),defaultSize:{w:5,h:4},defaultConfig:eiH("待确认","确认队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QP,{title:e.title}),(0,ey.jsx)(etO,{items:ei$})]})}],eiq=[{id:"metric-runs",kind:"metric-runs",x:0,y:0,w:3,h:2},{id:"metric-queued",kind:"metric-queued",x:3,y:0,w:3,h:2},{id:"metric-blocked",kind:"metric-blocked",x:6,y:0,w:3,h:2},{id:"metric-workers",kind:"metric-workers",x:9,y:0,w:3,h:2},{id:"queue",kind:"queue",x:0,y:2,w:7,h:5},{id:"workers",kind:"workers",x:7,y:2,w:5,h:5},{id:"log",kind:"log",x:0,y:7,w:7,h:4},{id:"confirmations",kind:"confirmations",x:7,y:7,w:5,h:4}];function eiK(e=eiU){return[{id:"metric-online",title:"在线机器",description:"当前在线机器数量。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("在线机器","机器心跳"),render:t=>eiV(t.title,String(e.metrics.online),44,QN)},{id:"metric-health",title:"健康度",description:"工作组整体健康度。",icon:(0,ey.jsx)(eO,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("健康度","服务遥测"),render:t=>eiV(t.title,`${e.metrics.health}%`,44,QC)},{id:"metric-latency",title:"平均延迟",description:"机器连接平均延迟。",icon:(0,ey.jsx)(eer,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("平均延迟","网络遥测"),render:t=>eiV(t.title,e.metrics.latency,44,QM)},{id:"metric-events",title:"事件",description:"最近事件数量。",icon:(0,ey.jsx)(eeQ,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiH("事件","事件流"),render:t=>eiV(t.title,String(e.metrics.events),44,QE)},{id:"machines",title:"机器健康矩阵",description:"各机器资源和心跳状态。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eiH("机器健康矩阵","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"vtl-jelly-image-card flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",style:QO({image:"/themes/jelly/card1.png",opacity:.88,blur:"10px"}),children:[(0,ey.jsx)(QP,{title:t.title}),(0,ey.jsx)(et_,{machines:e.machines})]})},{id:"trend",title:"资源趋势",description:"CPU、内存和网络趋势。",icon:(0,ey.jsx)(eiD,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eiH("资源趋势","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QP,{title:t.title}),(0,ey.jsx)(etV,{config:eiB,data:e.trend})]})},{id:"network",title:"网络连接",description:"机器之间连接状态。",icon:(0,ey.jsx)(Qx,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eiH("网络连接","网络遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QP,{title:t.title}),(0,ey.jsx)(etB,{links:e.networkLinks})]})},{id:"events",title:"事件流",description:"最近遥测事件。",icon:(0,ey.jsx)(eeQ,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eiH("事件流","事件流"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QP,{title:t.title}),(0,ey.jsx)(etR,{events:e.events})]})},{id:"services",title:"服务健康",description:"服务 30 分钟粒度健康条。",icon:(0,ey.jsx)(GE,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eiH("服务健康","服务遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QP,{title:t.title}),(0,ey.jsx)(etH,{services:e.serviceHealth})]})}]}eiK();let eiG=[{id:"metric-online",kind:"metric-online",x:0,y:0,w:3,h:2},{id:"metric-health",kind:"metric-health",x:3,y:0,w:3,h:2},{id:"metric-latency",kind:"metric-latency",x:6,y:0,w:3,h:2},{id:"metric-events",kind:"metric-events",x:9,y:0,w:3,h:2},{id:"machines",kind:"machines",x:0,y:2,w:7,h:5},{id:"trend",kind:"trend",x:7,y:2,w:5,h:5},{id:"network",kind:"network",x:0,y:7,w:6,h:4},{id:"events",kind:"events",x:6,y:7,w:6,h:4},{id:"services",kind:"services",x:0,y:11,w:12,h:3}],eiX={totals:{machines:4,online:2,runtime:3,tokens:7},machines:[{id:"studio",name:"Studio-PC",role:"本机",group:"Core",os:"Windows 11",runtime:"0.16.4",state:"online",tags:["admin","shell","files","scheduler"],agent:"6/8",cpu:42,memory:68,version:"Agent runtime 0.16.4",admin:"Allay"},{id:"runner",name:"Linux-runner-02",role:"GPU worker",group:"Compute",os:"Ubuntu 24.04",runtime:"0.16.3",state:"online",tags:["gpu","agent","files"],agent:"4/6",cpu:76,memory:81,version:"Agent runtime 0.16.3",admin:"Ops"},{id:"mac",name:"MacBook-build",role:"构建机",group:"Build",os:"macOS 15.4",runtime:"0.15.9",state:"sleeping",tags:["build","readonly"],agent:"0/3",cpu:8,memory:24,version:"Agent runtime 0.15.9",admin:"Allay"},{id:"observer",name:"Observer-01",role:"只读观测节点",group:"Edge",os:"Debian 13",runtime:"0.16.2",state:"warning",tags:["readonly","audit"],agent:"1/2",cpu:18,memory:36,version:"Agent runtime 0.16.2",admin:"Security"}],topology:{nodes:[{id:"studio",label:"Studio-PC",meta:"本机",x:50,y:18},{id:"runner",label:"Linux-runner-02",meta:"GPU worker",x:22,y:60},{id:"mac",label:"MacBook-build",meta:"构建机",x:76,y:58,state:"warning"},{id:"observer",label:"Observer-01",meta:"只读观测",x:50,y:82,state:"warning"}],links:[{id:"sr",from:"studio",to:"runner",kind:"p2p",label:"P2P",meta:"38ms / 0.3%"},{id:"sm",from:"studio",to:"mac",kind:"direct",label:"Direct",meta:"12ms / 0%"},{id:"ro",from:"runner",to:"observer",kind:"relay",label:"Relay",meta:"84ms / 1.1%"},{id:"mo",from:"mac",to:"observer",kind:"down",label:"Down",meta:"lost"}]},pathTotals:{direct:1,p2p:1,relay:1,broken:1},latency:[{time:"09:00",p2p:42,direct:12,relay:96},{time:"10:00",p2p:39,direct:12,relay:88},{time:"11:00",p2p:44,direct:14,relay:91},{time:"12:00",p2p:38,direct:12,relay:84},{time:"13:00",p2p:36,direct:11,relay:86},{time:"14:00",p2p:41,direct:13,relay:93}],candidates:[["Studio-PC","Linux-runner-02","P2P","symmetric NAT","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","open port 4178","12ms","0.0%"],["Linux-runner-02","Observer-01","Relay","udp blocked","84ms","1.1%"],["MacBook-build","Observer-01","Interrupted","sleep","-","-"]]};function eiY({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){return(0,ey.jsx)(Q0,{boardId:"runtime-operations",definitions:eiW,initialLayouts:eiq,clipboardItems:e,actionLabel:"运行页面卡片操作",paletteGroupTitle:"运行页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eiZ({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let r=eim("/api/local/machines/telemetry",eih),a=ew.useMemo(()=>eiK(r),[r]);return(0,ey.jsx)(Q0,{boardId:"telemetry",definitions:a,initialLayouts:eiG,clipboardItems:e,actionLabel:"遥测页面卡片操作",paletteGroupTitle:"遥测页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eiJ({className:e,title:t="Vantaloom"}){return(0,ey.jsxs)("svg",{viewBox:"180 350 1130 260",fill:"currentColor",role:"img","aria-label":t,className:(0,eI.cn)("[[data-vtl-theme=jelly]_&]:opacity-70",e),children:[(0,ey.jsx)("path",{d:"m658 393 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,ey.jsx)("path",{d:"m1147 452h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,ey.jsx)("path",{d:"m556 449h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,ey.jsx)("path",{d:"m409 450h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,ey.jsx)("path",{d:"m918 450h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,ey.jsx)("path",{d:"m224 442h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,ey.jsx)("path",{d:"m1010 450h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,ey.jsx)("path",{d:"m848 371h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function eiQ(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function ei0(e){return"u"<typeof document?null:document.querySelector(e)}function ei1(){return null!=ei0('[role="menu"]')}function ei2(){return null!=ei0('[data-tour="init-wizard"]')}function ei5(){let e=ei0('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}!function(e=eiX){eiH("机器","机器组"),eiH("在线","机器心跳"),eiH("Runtime","Agent runtime"),eiH("Token","机器注册"),eiH("机器组","机器组"),eiH("拓扑图","网络拓扑"),eiH("直连","网络拓扑"),eiH("P2P","网络拓扑"),eiH("Relay","网络拓扑"),eiH("中断","网络拓扑"),eiH("延迟","网络遥测"),eiH("候选路径","网络候选路径")}(),eiH("日志与审计","审计事件"),eiH("筛选","审计筛选"),eiH("拒绝事件","审计事件"),eiH("事件趋势","审计事件");var ei4=e.i(64990);function ei3(){let e=sb(),[t,n]=ew.useState(!1);ew.useEffect(()=>{try{n("1"===window.localStorage.getItem("vtl:sidebar-collapsed"))}catch{}},[]);let r=ew.useCallback(()=>{n(e=>{let t=!e;try{window.localStorage.setItem("vtl:sidebar-collapsed",t?"1":"0")}catch{}return t})},[]),[a,i]=ew.useState("home"),[o,l]=ew.useState(!1),[s,c]=ew.useState(),[d,u]=ew.useState(),[f,h]=ew.useState([]),[m,p]=ew.useState([]),[g,v]=ew.useState("conversation"),[x,y]=ew.useState(0),b=s?.conversation.id,w=s?.conversation.ownerMachineId;ew.useEffect(()=>{h([]),p([]),v("conversation")},[b]),ew.useEffect(()=>{let e;if(!b||"new-agent-conversation"!==a)return void p([]);let t=!1,n=async()=>{let r=await sz(b,w);t||(p(r),e=window.setTimeout(n,!function e(t){return t.some(t=>t.running||e(t.children??[]))}(r)?6e3:2e3))};return n(),()=>{t=!0,e&&window.clearTimeout(e)}},[b,w,a]);let[j,k]=ew.useState(),[S,N]=ew.useState(!1),[C,M]=ew.useState([]),[E,O]=ew.useState([]),[P,A]=ew.useState({}),[I,z]=ew.useState(),[T,D]=ew.useState(u_),[R,_]=ew.useState([]),[L,$]=ew.useState(),[F,B]=ew.useState(),[V,H]=ew.useState(),U=ew.useRef(!1),W=ew.useCallback(e=>{D(t=>iQ(e,t))},[]),q=ew.useCallback(e=>{_(t=>iQ(e,t))},[]),K=ew.useCallback(async(e,t)=>{let n="u">typeof performance?performance.now():Date.now();console.debug(`[open] click conversation=${e} owner=${t??"local"}`),u({id:e,ownerMachineId:t}),i("new-agent-conversation");let r=()=>Math.round(("u">typeof performance?performance.now():Date.now())-n);try{let n=await sB(e,t);console.debug(`[open] detail loaded in ${r()}ms (id=${e})`),c(n),u(t=>t?.id===e?void 0:t)}catch(n){if(n instanceof sk){let r=n.openedBy?.displayName||"另一台设备";if(window.confirm(`此对话正在「${r}」上打开,无法同时操作。是否强制接管(对方将被踢出)?`)){try{let n=await sB(e,t,{force:!0});c(n)}finally{u(t=>t?.id===e?void 0:t)}return}u(t=>t?.id===e?void 0:t),s||i("home");return}console.warn(`[open] failed after ${r()}ms (id=${e})`,n),u(t=>t?.id===e?void 0:t),s||i("home")}},[s]),G=ew.useCallback(async(e,t)=>{h([]),await K(e,t)},[K]),X=ew.useCallback(()=>{c(void 0),i("new-agent-conversation")},[]),Y=ew.useCallback(async()=>{let e=await sP();e?await K(e.conversation.id,e.conversation.ownerMachineId):X()},[K,X]),Z=ew.useCallback(async()=>{U.current=!0,D(u_),_([]),i("new-canvas");try{let e=await Qc({title:"新画布",nodes:u_,edges:[]});B(e.canvas.id),H("local")}catch{B(void 0),H(void 0),U.current=!1}},[]),J=ew.useCallback(async(e,t)=>{try{await Qu(e,t);let n=await Qs(e,t);U.current=!0,D(n.nodes),_(n.edges),B(n.canvas.id),H(n.canvas.ownerMachineId),i("new-canvas")}catch{}},[]);ew.useEffect(()=>{if(!F)return;if(U.current){U.current=!1;return}let e=window.setTimeout(()=>{Qd(F,{nodes:T,edges:R,nodeIds:T.map(e=>e.id)},V).catch(()=>{})},800);return()=>window.clearTimeout(e)},[T,R,F,V]);let Q=ew.useCallback(({item:t})=>{if(!e||"new-canvas"!==t.id&&"all-canvases"!==t.id&&"open-recent-canvas"!==t.id){if("new-canvas"===t.id)return void Z();if("all-canvases"===t.id)return void i("all-canvases");if("new-agent-conversation"===t.id)return void X();if("open-recent-conversation"===t.id)return void Y();if("runs"===t.id)return void i("runs");if("telemetry"===t.id)return void i("telemetry");("preferences"===t.id||"preferences-model-routes"===t.id||"preferences-agent-config"===t.id||"preferences-subagent-config"===t.id||"preferences-cc-engine-config"===t.id||"preferences-system-prompt"===t.id||"preferences-layout"===t.id||"preferences-official-extensions"===t.id||"network-topology"===t.id||"system-downloads"===t.id||"check-update"===t.id||"account"===t.id||"balance-usage"===t.id||"feedback"===t.id)&&i(t.id)}},[Z,e,Y,X]),{start:ee}=(0,ei4.useTour)(),et=ew.useCallback(()=>{var e;ee((e={select:e=>Q({item:{id:e}}),startNewConversation:X,goHome:()=>{i("home"),c(void 0)}},{id:"product-tour",steps:[{id:"intro",centered:!0,title:"欢迎使用 Vantaloom 👋",body:(0,ey.jsxs)(ey.Fragment,{children:["这是一份手把手向导,会高亮关键位置并在需要时",(0,ey.jsx)("b",{children:"请你亲自操作"}),"(没做完不会出现「下一步」)。 全程界面都可正常点击;随时按 ",(0,ey.jsx)("kbd",{children:"Esc"})," 或右上角 ✕ 退出。"]})},{id:"theme",before:eiQ(()=>e.goHome()),target:()=>ei0('[role="menu"]')??ei0('[data-tour="account-button"]'),gate:ei1,gateHint:"点击用户名按钮展开菜单",padding:6,title:"切换主题",body:(0,ey.jsxs)(ey.Fragment,{children:["点击左下角的 ",(0,ey.jsx)("b",{children:"用户名按钮"})," 打开菜单。展开后,里面的 ",(0,ey.jsx)("b",{children:"外观 / 主题"})," 项每点一次就在"," ",(0,ey.jsx)("b",{children:"浅色 → 深色 → 果冻"})," 之间循环。"]})},{id:"model-routes-add",before:eiQ(()=>e.select("preferences-model-routes")),target:()=>ei0('[data-tour="model-route-form"]')??ei0('[data-tour="add-model-route"]'),gate:()=>null!=ei0('[data-tour="model-route-form"]'),gateHint:"点击「添加模型路由」",title:"配置模型渠道(1/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["进入 ",(0,ey.jsx)("b",{children:"设置 → 模型路由"}),"。请点 ",(0,ey.jsx)("b",{children:"添加模型路由"})," 新增一个第三方渠道(任何 OpenAI / Anthropic 兼容 API 都行)。"]})},{id:"model-routes-fields",before:eiQ(()=>e.select("preferences-model-routes")),target:'[data-tour="model-route-form"]',waitForTarget:2500,title:"配置模型渠道(2/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["表单各项:",(0,ey.jsx)("b",{children:"提供商名称"})," 仅作标识;",(0,ey.jsx)("b",{children:"协议"})," 选 OpenAI / Anthropic 风格;",(0,ey.jsx)("b",{children:"Endpoint URL"})," 填到 ",(0,ey.jsx)("code",{children:"/v1"})," 这一级;",(0,ey.jsx)("b",{children:"API Key"})," 是密钥;",(0,ey.jsx)("b",{children:"可用模型"})," 勾选启用并可设上下文长度。",(0,ey.jsx)("br",{}),"⚠️ 填完",(0,ey.jsx)("b",{children:"务必点「保存」"}),",否则不生效。"]})},{id:"agent-config-compression",before:eiQ(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-compression"]',title:"代理配置 · 压缩上下文",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 代理配置"})," 的第一块:当对话 token 接近模型上下文窗口的设定百分比时,自动用",(0,ey.jsx)("b",{children:"压缩模型"})," 压缩历史。阈值 0% 表示关闭,建议 70%-85%。"]})},{id:"agent-config-summary",before:eiQ(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-summary"]',title:"代理配置 · 对话摘要",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"对话摘要"}),":开启后用",(0,ey.jsx)("b",{children:"摘要模型"}),"自动生成 / 更新对话标题与每轮的轮次标题,方便在侧边栏 与时间轴里快速辨认。"]})},{id:"agent-config-approval",before:eiQ(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-approval"]',title:"代理配置 · 命令审批",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"命令审批"}),":在 Auto 权限模式下,用",(0,ey.jsx)("b",{children:"审批模型"})," + ",(0,ey.jsx)("b",{children:"审批提示词"})," 判断 Agent 发起的命令 是否自动放行。留空则非危险命令全部放行。改完记得 ",(0,ey.jsx)("b",{children:"保存"}),"。"]})},{id:"subagent-explore",before:eiQ(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-explore"]',title:"子代理 · 探索",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 子代理配置"}),"。",(0,ey.jsx)("b",{children:"探索"})," 子代理擅长只读检索代码 / 资料。可单独设它的",(0,ey.jsx)("b",{children:"使用模型"}),"(留空则继承上级)与",(0,ey.jsx)("b",{children:"系统提示词"}),"。"]})},{id:"subagent-workflow",before:eiQ(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-workflow"]',title:"子代理 · 工作流",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"工作流"})," 子代理负责多步骤任务编排,同样可单独配模型与提示词。"]})},{id:"subagent-operator",before:eiQ(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-operator"]',title:"子代理 · 操作",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"操作"})," 子代理执行写文件 / 跑命令等动手类任务,工具集固定。"]})},{id:"subagent-custom",before:eiQ(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-custom"]',title:"子代理 · 自定义",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"自定义子代理"}),":主 Agent 可自取名字、从你设的",(0,ey.jsx)("b",{children:"可用模型池"}),"里挑模型来召唤,拥有完整 工具集,还能再派发上面三种官方子代理。"]})},{id:"check-update",before:eiQ(()=>e.select("check-update")),target:'[data-tour="check-update"]',title:"检查更新",body:(0,ey.jsxs)(ey.Fragment,{children:["这里查看各机器的运行时版本并 ",(0,ey.jsx)("b",{children:"立即更新"}),"。原理:从 npm 拉取最新运行时包、就地替换二进制与 前端,",(0,ey.jsx)("b",{children:"无需重装"}),";P2P mesh 未变时更新还",(0,ey.jsx)("b",{children:"不需要管理员权限"}),"。"]})},{id:"hub-account",before:eiQ(()=>e.select("account")),target:'[data-tour="hub-account"]',title:"Hub 账户",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → Hub 账户"}),"。上方是你的",(0,ey.jsx)("b",{children:"账户信息"}),"与",(0,ey.jsx)("b",{children:"设备绑定"}),"状态——Hub 负责多机互联、组网 下发与云端身份。"]})},{id:"hub-account-danger",before:eiQ(()=>e.select("account")),target:'[data-tour="hub-account-danger"]',title:"Hub 账户 · 危险操作",body:(0,ey.jsxs)(ey.Fragment,{children:["下方的 ",(0,ey.jsx)("b",{children:"危险操作"})," 区可",(0,ey.jsx)("b",{children:"解除设备绑定"}),"或",(0,ey.jsx)("b",{children:"退出登录"}),"。这些操作不可逆,会把本机移出 账户,请谨慎。"]})},{id:"new-conversation",before:eiQ(()=>e.goHome()),target:'[data-tour="home-new-conversation"]',gate:ei2,gateHint:"点击「新建对话」继续",title:"创建新对话",body:(0,ey.jsxs)(ey.Fragment,{children:["回到主页,请点 ",(0,ey.jsx)("b",{children:"新建对话"})," 进入初始化向导(侧边栏顶部也有同样入口)。"]})},{id:"wizard-1",target:'[data-tour="init-wizard"]',placement:"left",padding:4,waitForTarget:5e3,gate:()=>!ei2()||ei5()>=2,gateHint:"配好运行环境后点向导的「下一步」",title:"向导 ① 运行环境与引擎",body:(0,ey.jsxs)(ey.Fragment,{children:["先选在",(0,ey.jsx)("b",{children:"哪台机器"}),"上运行;本机运行时还能选 ",(0,ey.jsx)("b",{children:"运行引擎"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," / ",(0,ey.jsx)("b",{children:"Claude Code"})," / ",(0,ey.jsx)("b",{children:"reclaude"}),"(Claude Code 仅限本机)。 整个向导区域已高亮,配好后点向导自己的 ",(0,ey.jsx)("b",{children:"下一步"}),"。"]})},{id:"wizard-2",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!ei2()||ei5()>=3,gateHint:"选好工作目录后点向导的「下一步」",title:"向导 ② 选择工作目录",body:(0,ey.jsxs)(ey.Fragment,{children:["先给对话",(0,ey.jsx)("b",{children:"起个名字"}),",再选 ",(0,ey.jsx)("b",{children:"工作目录"}),"——这是智能体能读写的根目录 (Claude Code 用单个目录作为工作根目录)。选好后点向导的「下一步」。"]})},{id:"wizard-3",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!ei2()||ei5()>=4,gateHint:"配好模型后点向导的「下一步」",title:"向导 ③ 模型设置",body:(0,ey.jsxs)(ey.Fragment,{children:["选择这段对话使用的",(0,ey.jsx)("b",{children:"模型"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," 用你刚配置的模型路由,",(0,ey.jsx)("b",{children:"Claude Code"})," 则由其自身提供模型。选好后点向导的「下一步」。"]})},{id:"wizard-4",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!ei2(),gateHint:"点向导的「确认开始」创建对话",title:"向导 ④ 确认开始",body:(0,ey.jsxs)(ey.Fragment,{children:["核对无误后,点向导右下角的 ",(0,ey.jsx)("b",{children:"确认开始"})," 创建对话。创建成功后会自动进入对话界面。"]})},{id:"composer-toolbar",target:'[data-slot="agent-input-composer-toolbar"]',waitForTarget:6e3,title:"输入框下方的按钮",body:(0,ey.jsxs)(ey.Fragment,{children:["输入框下面一排:",(0,ey.jsx)("b",{children:"权限模式"}),"(工具调用是否需审批)、",(0,ey.jsx)("b",{children:"模型选择"}),"、右侧 ",(0,ey.jsx)("b",{children:"发送 / 停止"}),"按钮(运行中变停止),以及 ",(0,ey.jsx)("b",{children:"上下文用量"})," 指示。"]})},{id:"queue-stack",target:'[data-slot="agent-input-composer-textarea"]',waitForTarget:3e3,title:"待发送栈(Tab 键)",body:(0,ey.jsxs)(ey.Fragment,{children:["输入内容后按 ",(0,ey.jsx)("kbd",{children:"Tab"})," 可把它压入",(0,ey.jsx)("b",{children:"待发送栈"}),"而不立即发送,便于排队多条指令。栈里每条都能 点击:用 ",(0,ey.jsx)("b",{children:"引导"})," 在合适时机插入对话,或删除。"]})},{id:"pane-toolbar",target:'[data-tour="pane-toolbar"]',waitForTarget:3e3,title:"工作区顶栏",body:(0,ey.jsxs)(ey.Fragment,{children:["右侧工作区最上面一排:左边 ",(0,ey.jsx)("b",{children:"布局标签"})," 切换分屏预设,中间 ",(0,ey.jsx)("b",{children:"位置切换"})," 控制对话面板在左 / 居中 / 在右。"]})},{id:"pane-split",target:'[aria-label="上下二分"]',waitForTarget:4e3,gate:()=>null!=ei0('[aria-label="上下二分"][data-state="active"]'),gateHint:"点「上下二分」分栏",title:"动手 · 上下分栏",body:(0,ey.jsxs)(ey.Fragment,{children:["在布局标签里点 ",(0,ey.jsx)("b",{children:"上下二分"}),"(顶部面板图标),把右侧工作区分成上下两块。"]})},{id:"pane-add-top",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=ei0('[placeholder="搜索组件..."]')||null!=ei0('[data-slot="multi-tab-list"]'),gateHint:"点上面板的「添加」",autoAdvance:!0,title:"动手 · 添加上面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["点",(0,ey.jsx)("b",{children:"上面板"}),"中间的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,打开组件选择面板。"]})},{id:"pane-pick-multitab",target:'[data-tour="pane-template-multi-tab-system"]',waitForTarget:3e3,gate:()=>null!=ei0('[data-slot="multi-tab-list"]'),gateHint:"选择「多标签页系统」",title:"动手 · 选多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["在弹出面板里找到 ",(0,ey.jsx)("b",{children:"多标签页系统"}),"(即多文件标签组件)并点击添加,它会填入上面板。"]})},{id:"multi-tab",target:'[data-slot="multi-tab-list"]',waitForTarget:3e3,title:"多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["顶部是",(0,ey.jsx)("b",{children:"多文件标签条"}),":点 ",(0,ey.jsx)("b",{children:"+"})," 新增标签、点标签切换文件、",(0,ey.jsx)("b",{children:"×"})," 关闭。单文件内还能在",(0,ey.jsx)("b",{children:"查看 / 编辑"})," 与 ",(0,ey.jsx)("b",{children:"代码 / 预览 / 十六进制"})," 间切换,编辑后记得保存。"]})},{id:"pane-add-bottom",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=ei0('[placeholder="搜索组件..."]')||null!=ei0('[data-slot="terminal-tab-group"]'),gateHint:"点下面板的「添加」",autoAdvance:!0,title:"动手 · 添加下面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["现在点",(0,ey.jsx)("b",{children:"下面板"}),"的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,再次打开组件选择面板。"]})},{id:"pane-pick-terminal",target:'[data-tour="pane-template-terminal-tab-group"]',waitForTarget:3e3,gate:()=>null!=ei0('[data-slot="terminal-tab-group"]'),gateHint:"选择「终端标签组」",title:"动手 · 选终端",body:(0,ey.jsxs)(ey.Fragment,{children:["在面板里找到 ",(0,ey.jsx)("b",{children:"终端标签组"})," 并点击添加,它会填入下面板。"]})},{id:"terminal",target:'[data-slot="terminal-tab-group"]',waitForTarget:3e3,title:"终端组件",body:(0,ey.jsxs)(ey.Fragment,{children:["终端支持多会话标签:点 ",(0,ey.jsx)("b",{children:"+"})," 新开会话、点标签切换、",(0,ey.jsx)("b",{children:"×"})," 关闭。直接输入命令即可,输出实时回显,与本机真实 shell 一致。"]})},{id:"pane-cut-clear",target:'[aria-label="剪切窗口内容"]',waitForTarget:3e3,title:"剪切与粉碎",body:(0,ey.jsxs)(ey.Fragment,{children:["顶栏的 ",(0,ey.jsx)("b",{children:"剪切"}),"(剪刀)把窗口内容移动到别处;",(0,ey.jsx)("b",{children:"粉碎"}),"(碎纸机)清空该窗口。均对单个 pane 生效。"]})},{id:"control-room",target:'[data-tour="control-room-toggle"]',waitForTarget:3e3,title:"导播台视角",body:(0,ey.jsxs)(ey.Fragment,{children:["点位置切换中间的 ",(0,ey.jsx)("b",{children:"「隐藏面板」"}),"(矩形图标)进入",(0,ey.jsx)("b",{children:"导播台"}),":对话偏左,右侧悬浮显示主 Agent 与各子 Agent 的实时预览小窗,点小窗即可切换主面板。"]})},{id:"outro",centered:!0,title:"完成 🎉",body:(0,ey.jsxs)(ey.Fragment,{children:["你已走过核心功能。随时可从空白页的 ",(0,ey.jsx)("b",{children:"使用教程"})," 重新打开本向导。开始创造吧!"]})}]}))},[Q,X,ee]),en=ew.useCallback(()=>{i("account")},[]),er=d?.id??s?.conversation.id,ea=!!d&&s?.conversation.id!==d.id;return(0,ey.jsxs)("main",{className:"vtl-app-background relative flex h-svh overflow-hidden text-foreground select-none [-webkit-touch-callout:none]",children:[e?(0,ey.jsx)(erv,{navItems:erb,contents:erw,activeWorkspace:a,activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:m,activeSubagentPath:f,onOpenSubagent:e=>h(e),title:"new-agent-conversation"===a&&s?s.conversation.title?.trim()||"新 Agent 对话":QA.product,trailing:"new-agent-conversation"===a&&s?(0,ey.jsx)(jj,{view:g,onViewChange:v,paneCount:x}):(0,ey.jsx)(eiT,{})}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:(0,eI.cn)("relative hidden h-svh shrink-0 overflow-hidden p-3 transition-[width,padding] duration-300 ease-out md:block",t?"w-0 p-0":"w-[19.5rem]"),children:(0,ey.jsx)(enk,{navItems:erb,contents:erw,activeWorkspace:a,activeConversationId:er,activeCanvasId:F,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenCanvas:(e,t)=>{J(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:m,activeSubagentPath:f,onOpenSubagent:e=>h(e)})}),(0,ey.jsx)("div",{className:(0,eI.cn)("group/sb-handle absolute inset-y-0 z-30 hidden w-8 md:block","transition-[left] duration-300 ease-out",t?"left-0":"left-[18.5rem]"),children:(0,ey.jsx)("button",{type:"button",onClick:r,"aria-label":t?"展开侧边栏":"收起侧边栏",title:t?"展开侧边栏":"收起侧边栏",className:"absolute top-1/2 left-0 flex h-14 w-6 -translate-y-1/2 items-center justify-center rounded-r-md border border-l-0 border-border bg-background/85 text-muted-foreground opacity-0 shadow-md backdrop-blur transition-opacity duration-200 hover:text-foreground focus-visible:opacity-100 group-hover/sb-handle:opacity-100",children:t?(0,ey.jsx)(tu,{className:"size-4"}):(0,ey.jsx)(td,{className:"size-4"})})})]}),(0,ey.jsxs)("section",{className:(0,eI.cn)("relative h-full min-w-0 flex-1 overflow-hidden",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:["runs"===a?(0,ey.jsx)(eiY,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"telemetry"===a?(0,ey.jsx)(eiZ,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"preferences-model-routes"===a?(0,ey.jsx)(ea5,{section:"model-routes"}):"preferences-agent-config"===a?(0,ey.jsx)(ea5,{section:"agent-config"}):"preferences-subagent-config"===a?(0,ey.jsx)(ea5,{section:"subagent-config"}):"preferences-cc-engine-config"===a?(0,ey.jsx)(ea5,{section:"cc-engine-config"}):"preferences-system-prompt"===a?(0,ey.jsx)(ea5,{section:"system-prompt"}):"preferences-layout"===a?(0,ey.jsx)(ea5,{section:"layout"}):"preferences-official-extensions"===a?(0,ey.jsx)(eix,{}):"network-topology"===a?(0,ey.jsx)(eip,{}):"system-downloads"===a?(0,ey.jsx)(eiA,{}):"preferences"===a?(0,ey.jsx)(ea5,{}):"check-update"===a?(0,ey.jsx)(ea8,{}):"balance-usage"===a?(0,ey.jsx)(eit,{}):"feedback"===a?(0,ey.jsx)(eis,{}):"account"===a?(0,ey.jsx)(erC,{}):e||"new-canvas"!==a?e||"all-canvases"!==a?"new-agent-conversation"===a&&ea?(0,ey.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-6 animate-spin"}),(0,ey.jsx)("span",{className:"text-sm",children:"正在打开对话…"})]}):"new-agent-conversation"===a?(0,ey.jsx)(J3,{conversation:s,clipboardItems:C,clipboardDraggingId:I,onClipboardItemsChange:M,onClipboardDraggingChange:z,onOverlayOpenChange:l,onConversationCreated:e=>{c(e)},onCancelDraft:()=>i("home"),subagentStack:f,onSubagentStackChange:h,subagentTree:m,mobileView:g,onMobilePaneCountChange:y}):e?(0,ey.jsx)(ei8,{activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{k(t=>t?.id===e?void 0:t)}}):(0,ey.jsx)(ei6,{onNewConversation:X,onStartTour:et}):(0,ey.jsx)(etQ,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):(0,ey.jsx)(et6,{nodes:T,edges:R,selectedNodeId:L,clipboardItems:C,onNodesChange:W,onEdgesChange:q,onNodesSet:D,onEdgesSet:_,onSelectedNodeChange:$,onClipboardItemsChange:M}),j?(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-0 z-30",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:(0,ey.jsx)(Qi,{conversationId:j.id,ownerMachineId:j.owner,open:!0,onOpenChange:e=>{e||k(void 0)},onEnterConversation:(e,t)=>{G(e,t)}})}):null,(0,ey.jsx)(et9,{hidden:!!j||("new-agent-conversation"===a?o:S),items:C,trashItems:E,draggingId:I,onDraggingChange:z,onItemsChange:M,onTrashItemsChange:O,onTrashClipboardItemsChange:A,trashClipboardItems:P})]})]})}function ei6({onNewConversation:e,onStartTour:t}){return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,ey.jsx)(eiJ,{className:"h-20 w-auto max-w-[78vw] text-foreground"}),(0,ey.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"从左侧选择一个会话,或新建对话"}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,ey.jsxs)(eA.Button,{type:"button",onClick:e,"data-tour":"home-new-conversation",children:[(0,ey.jsx)(tc,{className:"size-4"}),"新建对话"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",onClick:t,children:[(0,ey.jsx)(ts,{className:"size-4"}),"使用教程"]})]})]})}function ei8({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a}){return(0,ey.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:(0,ey.jsx)(enE,{activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a})})}function ei7(){let{ready:e,user:t,logout:n}=tl();return e?t?(0,ey.jsx)(ei3,{}):(0,ey.jsx)(ta,{onComplete:()=>{window.location.reload()}}):(0,ey.jsx)("main",{className:"grid min-h-svh place-items-center bg-background",children:(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,ey.jsx)("div",{className:"size-8 animate-spin rounded-full border-2 border-muted-foreground/20 border-t-primary"}),(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接中..."})]})})}function ei9(){return(0,ey.jsx)(to,{children:(0,ey.jsx)(ei7,{})})}e.s(["default",()=>ei9],66204)}]);
|
|
52
|
+
</style>`,/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${n}</head>`):`${n}${t}`},[r,t]);return(0,ey.jsx)("iframe",{title:e,sandbox:"allow-scripts",srcDoc:a,className:(0,eI.cn)("size-full border-0 bg-background",n)})}function Gl({file:e,value:t,labels:n}){let r=ew.useMemo(()=>{let n=e.bytes??(t?new TextEncoder().encode(t):[]),r=Math.min(n.length,4096),a=[];for(let e=0;e<r;e+=16){let t=Array.from({length:Math.min(16,r-e)},(t,r)=>n[e+r]??0);a.push({offset:e.toString(16).padStart(8,"0"),hex:t.map(e=>e.toString(16).padStart(2,"0")).join(" "),ascii:t.map(e=>e>=32&&e<=126?String.fromCharCode(e):".").join("")})}return a},[e.bytes,t]);return 0===r.length?(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:n.noContent}):(0,ey.jsx)("div",{className:"size-full overflow-auto bg-background p-3 ui-text-code",children:(0,ey.jsx)("div",{className:"grid min-w-max grid-cols-[5.5rem_30rem_1fr] gap-x-4",children:r.map(e=>(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.offset}),(0,ey.jsx)("span",{className:"font-mono text-foreground",children:e.hex}),(0,ey.jsx)("span",{className:"font-mono text-muted-foreground",children:e.ascii})]},e.offset))})})}function Gs({file:e,labels:t,onApprove:n}){return(0,ey.jsx)("div",{className:"grid size-full place-items-center bg-muted/20 p-6",children:(0,ey.jsxs)("div",{className:"grid max-w-md justify-items-center gap-3 text-center",children:[(0,ey.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-background text-muted-foreground",children:(0,ey.jsx)(K0,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("h3",{className:"ui-text-body font-medium text-foreground",children:t.binaryTitle}),(0,ey.jsx)("p",{className:"ui-text-body text-muted-foreground",children:t.binaryDescription})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[Ge(e.size)&&(0,ey.jsx)(Bs,{variant:"outline",children:Ge(e.size)}),(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",onClick:n,children:t.renderAnyway})]})]})})}function Gc({labels:e}){return(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:e.unsupportedPreview})}function Gd({file:e,value:t,labels:n,renderPreview:r,className:a}){let i=K7(e),o=e.src?e.src:t&&"svg"===K7(e)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:void 0,l=r?.(e,t);return void 0!==l?(0,ey.jsx)("div",{"data-slot":"file-tab-custom-preview",className:(0,eI.cn)("size-full",a),children:l}):"html"===i||"richtext"===i?(0,ey.jsx)(Go,{title:e.name,value:e.previewContent??t,className:a}):"markdown"===i?(0,ey.jsx)("div",{"data-slot":"file-tab-markdown-preview",className:(0,eI.cn)("size-full overflow-auto bg-background",a),children:(0,ey.jsx)(Gi,{value:t})}):"svg"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-svg-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-lg border bg-background p-4"})}):"image"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-image-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-md"})}):"video"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-video-preview",className:(0,eI.cn)("grid size-full place-items-center bg-muted/20 p-6",a),children:(0,ey.jsx)("video",{src:o,controls:!0,preload:"none",className:"max-h-full max-w-full rounded-md border bg-background"})}):(0,ey.jsx)(Gc,{labels:n})}function Gu({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:h,onHistory:m}){let p=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,ey.jsx)(Us,{className:"size-4"}):(0,ey.jsx)(uk,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,ey.jsx)(K1,{className:"size-4"}):(0,ey.jsx)(eS,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:h,disabled:a||!i,icon:(0,ey.jsx)(K3,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:m,icon:(0,ey.jsx)(K2,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===p.length?null:(0,ey.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[p.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function Gf({file:e,value:t,defaultValue:n,onValueChange:r,mode:a,defaultMode:i="review",onModeChange:o,view:l,defaultView:s="code",onViewChange:c,modified:d=!1,onSave:u,onSaveError:f,largeBinaryThreshold:h=2097152,showHeader:m=!0,wrapLines:p=!1,renderPreview:g,onHistory:v,labels:x,className:y,editorClassName:b,previewClassName:w,headerClassName:j,...k}){var S;let N,C,M=ew.useMemo(()=>({...K6,...x}),[x]),[E,O]=ew.useState(n??e.content??""),[P,A]=ew.useState(i),[I,z]=ew.useState(s),[T,D]=ew.useState(!1),[R,_]=ew.useState(!1),[L,$]=ew.useState(!1),F=ew.useRef(null),B=t??E,V=a??P,H=(S=l??I,(N=Gt(e)).includes(S)?S:N[0]),U=K7(e),W=Gt(e).length>1,q=!e.readOnly&&["text","code","html","markdown","richtext","svg"].includes(K7(e)),K=!!u&&q&&"code"===H&&(d||L),G="review"===V||!0===e.readOnly,X="binary"===(C=K7(e))||"image"!==C&&"video"!==C&&!!(e.size&&e.size>h&&!e.content),Y=(e.path??e.name).split(/[\\/]+/).filter(Boolean),Z=Ge(e.size??B.length);async function J(){if(u&&!L){$(!0);try{await u(B),_(!1)}catch(e){f?.(e)}finally{$(!1)}}}return ew.useEffect(()=>{void 0===t&&O(n??e.content??""),D(!1),_(!1)},[n,e,t]),ew.useEffect(()=>{if(R)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&F.current?.contains(t)||_(!1)}},[R]),(0,ey.jsxs)("div",{ref:F,"data-slot":"file-tab-viewer","data-mode":V,"data-view":H,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",m?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",y),...k,children:[m&&(0,ey.jsxs)("div",{"data-slot":"file-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",j),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:"image"===U?(0,ey.jsx)(K5,{className:"size-3.5"}):"video"===U?(0,ey.jsx)(K4,{className:"size-3.5"}):"binary"===U?(0,ey.jsx)(K0,{className:"size-3.5"}):(0,ey.jsx)(x3,{className:"size-3.5"})}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:Y.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[t>0&&(0,ey.jsx)("span",{className:"text-muted-foreground",children:M.pathSeparator}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",t===Y.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,ey.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[Z&&(0,ey.jsx)(Bs,{variant:"outline",children:Z}),q&&"code"===H&&(G?(0,ey.jsxs)(Bs,{variant:"secondary",children:[(0,ey.jsx)(lK,{className:"size-3"}),M.review]}):(0,ey.jsxs)(Bs,{variant:"outline",children:[(0,ey.jsx)(K1,{className:"size-3"}),M.edit]}))]})]}),(0,ey.jsx)("div",{"data-slot":"file-tab-viewer-body",className:"min-h-0 overflow-hidden",children:X&&!T?(0,ey.jsx)(Gs,{file:e,labels:M,onApprove:()=>D(!0)}):"preview"===H?(0,ey.jsx)(Gd,{file:e,value:B,labels:M,renderPreview:g,className:w}):"hex"===H?(0,ey.jsx)(Gl,{file:e,value:B,labels:M}):(0,ey.jsx)(Ga,{file:e,value:B,readOnly:G,onValueChange:function(e){void 0===t&&O(e),r?.(e)},wrapLines:p,className:b})}),(0,ey.jsx)(Gu,{open:R,labels:M,currentView:H,currentMode:V,saving:L,modified:d,canSwitchView:W,canSwitchMode:q&&"code"===H,canSave:K,canOpenHistory:!!(v&&e.path),onOpenChange:_,onToggleView:function(){var e;e="code"===H?"preview":"code",void 0===l&&z(e),c?.(e)},onToggleMode:function(){var e;e="review"===V?"edit":"review",void 0===a&&A(e),o?.(e)},onSave:J,onHistory:()=>{_(!1),v?.(e)}})]})}function Gh(e,t){return e[Math.max(0,t-1)]?.id??e[0]?.id}function Gm(e){return"string"==typeof e||"number"==typeof e?String(e):void 0}function Gp(e,t,n){let r=[...e],a=r[t],i=r[n];return a&&i&&(r[t]=i,r[n]=a),r}function Gg({tabs:e,defaultTabs:t=[],activeTabId:n,defaultActiveTabId:r,onActiveTabChange:a,onTabsChange:i,onCreateTab:o,onCloseTab:l,onTabReorder:s,onTabDetach:c,onExternalTabDrop:d,createActions:u=[],tabActions:f=[],reorderable:h=!0,detachable:m=!1,externalDropTypes:p=[],createLabel:g="New tab",moreLabel:v="More tab actions",closeLabel:x="Close tab",scrollLeftLabel:y="Scroll tabs left",scrollRightLabel:b="Scroll tabs right",tabListLabel:w="Open tabs",emptyContent:j,renderContent:k,showContent:S=!0,className:N,tabListClassName:C,contentClassName:M}){let[E,O]=ew.useState(t),P=ew.useRef(null),A=ew.useRef(null),[I,z]=ew.useState(),[T,D]=ew.useState(void 0),R=ew.useRef(void 0),[_,L]=ew.useState(void 0),[$,F]=ew.useState(!1),B=ew.useRef(void 0),V=ew.useRef(void 0),H=ew.useRef(!1),[U,W]=ew.useState(!1),[q,K]=ew.useState(!1),[G,X]=ew.useState(),Y=e??E,Z=Y.find(e=>!e.disabled),[J,Q]=ew.useState(r??Z?.id),ee=n??J,et=Y.find(e=>e.id===ee&&!e.disabled)??Z;ew.useEffect(()=>{!et&&Z&&void 0===n&&Q(Z.id)},[et,n,Z]);let en=ew.useCallback(t=>{void 0===e&&O(t),i?.(t)},[i,e]),er=ew.useCallback(e=>{R.current=e,D(e)},[]),ea=ew.useCallback(()=>{let e=A.current,t=new Map;if(!e)return t;for(let n of e.querySelectorAll("[data-tab-id]")){let e=n.getBoundingClientRect(),r=n.dataset.tabId;r&&t.set(r,{left:e.left,top:e.top})}return t},[]),ei=ew.useCallback((e,t=!0)=>{t&&(V.current=ea()),B.current=e,L(e)},[ea]),eo=ew.useCallback(()=>{let e=A.current;if(!e){W(!1),K(!1);return}let t=e.scrollWidth-e.clientWidth;W(e.scrollLeft>1),K(e.scrollLeft<t-1)},[]);function el(e){let t=A.current;if(!t)return;let n=Math.max(.7*t.clientWidth,160);t.scrollLeft+="left"===e?-n:n,window.requestAnimationFrame(eo)}ew.useEffect(()=>{F(!0)},[]),ew.useEffect(()=>{eo();let e=A.current;if(!e)return;let t=new ResizeObserver(eo);return t.observe(e),window.addEventListener("resize",eo),()=>{t.disconnect(),window.removeEventListener("resize",eo)}},[Y.length,eo]),ew.useLayoutEffect(()=>{let e=V.current,t=A.current;if(e&&t)for(let n of(V.current=void 0,t.querySelectorAll("[data-tab-id]"))){let t=n.dataset.tabId;if(!t)continue;let r=e.get(t);if(!r)continue;let a=n.getBoundingClientRect(),i=r.left-a.left,o=r.top-a.top;1>Math.abs(i)&&1>Math.abs(o)||n.animate([{transform:`translate(${i}px, ${o}px)`},{transform:"translate(0, 0)"}],{duration:150,easing:"cubic-bezier(0.2, 0, 0, 1)"})}},[_]);let es=ew.useCallback(e=>{let t=A.current;if(t)return Array.from(t.querySelectorAll("[data-tab-id]")).find(t=>t.dataset.tabId===e)},[]),ec=ew.useCallback((e,t)=>{let n=B.current??Y,r=n.findIndex(t=>t.id===e.tabId);if(-1===r)return;let a=t-e.offsetX,i=a+e.width,o=t>=e.currentX,l=n[r+1],s=n[r-1];if(o&&l&&!l.disabled){let e=es(l.id),t=e?.getBoundingClientRect();t&&i>=t.left+.7*t.width&&ei(Gp(n,r,r+1));return}if(!o&&s&&!s.disabled){let e=es(s.id),t=e?.getBoundingClientRect();t&&a<=t.right-.7*t.width&&ei(Gp(n,r,r-1))}},[es,Y,ei]);function ed(e){if(!d||0===p.length)return!1;let t=Array.from(e.dataTransfer.types);return p.some(e=>t.includes(e))}function eu(e){let t=A.current;if(!t)return{index:Y.length,left:0};let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll("[data-tab-id]"));if(0===r.length)return{index:0,left:t.scrollLeft+8};for(let[a,i]of r.entries()){let r=i.getBoundingClientRect();if(e.clientX<r.left+r.width/2)return{index:a,left:r.left-n.left+t.scrollLeft}}let a=r[r.length-1].getBoundingClientRect();return{index:r.length,left:a.right-n.left+t.scrollLeft}}ew.useEffect(()=>{if(T)return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t,{once:!0}),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)};function e(e){let t=R.current;if(!t)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,a=t.dragging||Math.abs(n)>4||Math.abs(r)>4;a&&(e.preventDefault(),ec(t,e.clientX)),er({...t,currentX:e.clientX,currentY:e.clientY,dragging:a})}function t(e){let t=R.current;if(t?.dragging){e.preventDefault(),H.current=!0;let r=Y.find(e=>e.id===t.tabId),i=P.current?.getBoundingClientRect(),o=!!i&&(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom);if(m&&c&&r&&o&&function(e,t){if(e.pinned)return!1;let r=Y.findIndex(t=>t.id===e.id);if(c?.(e,{tabs:Y,clientX:t.clientX,clientY:t.clientY,nativeEvent:t})===!1)return!1;let i=Y.filter(t=>t.id!==e.id);if(en(i),e.id===ee){let e=Gh(i,r);void 0===n&&Q(e),e&&a?.(e)}return!0}(r,e)){z(void 0),er(void 0),ei(void 0,!1);return}let l=B.current;l&&!(l.length===Y.length&&l.every((e,t)=>e.id===Y[t]?.id))&&(en(l),s?.(l))}z(void 0),er(void 0),ei(void 0,!1)}});let ef=et&&(k?.(et)??et.content??(0,ey.jsx)("div",{className:"grid min-h-44 place-items-center bg-muted/30 p-6 text-center text-muted-foreground",children:et.title})),eh=T?.dragging&&_?_:Y,em=T?.dragging?Y.find(e=>e.id===T.tabId):void 0,ep=T?.dragging&&em&&$?(0,iy.createPortal)((0,ey.jsxs)("div",{"data-slot":"multi-tab-drag-preview","aria-hidden":"true",className:"pointer-events-none fixed z-[100] flex h-9 min-w-0 items-center gap-1 rounded-t-lg border border-border bg-background px-2.5 text-foreground shadow-lg",style:{left:T.currentX-T.offsetX,top:T.top,width:T.width},children:[em.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:em.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:em.title}),em.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),document.body):null;return(0,ey.jsxs)("div",{ref:P,"data-slot":"multi-tab-system",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--surface-panel-radius)] border",N),children:[(0,ey.jsxs)("div",{className:"relative flex min-w-0 shrink-0 items-end gap-1 border-b bg-muted/35 px-1.5 pt-1.5",children:[U&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y,onClick:()=>el("left"),className:"mb-1 shrink-0",children:(0,ey.jsx)(mJ,{})}),(0,ey.jsxs)("div",{ref:A,role:"tablist","aria-label":w,"data-slot":"multi-tab-list",className:(0,eI.cn)("relative flex min-w-0 flex-1 items-end overflow-x-auto [scrollbar-width:none] data-[overflow=both]:[mask-image:linear-gradient(90deg,transparent,black_24px,black_calc(100%-24px),transparent)] data-[overflow=left]:[mask-image:linear-gradient(90deg,transparent,black_24px)] data-[overflow=right]:[mask-image:linear-gradient(90deg,black_calc(100%-24px),transparent)] [&::-webkit-scrollbar]:hidden",C),"data-overflow":U&&q?"both":U?"left":q?"right":void 0,onScroll:eo,onDragOver:function(e){ed(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",X(eu(e)))},onDragLeave:function(e){if(!ed(e))return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||X(void 0)},onDrop:function(e){if(!ed(e))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=eu(e);X(void 0),d?.({tabs:Y,insertIndex:t.index,nativeEvent:e})},children:[eh.map((e,t)=>{let r=e.id===et?.id,i=eh[t+1],o=T?.dragging&&I===e.id,s=!r&&!o&&void 0!==i&&i.id!==et?.id&&i.id!==I;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsxs)("div",{onPointerDown:t=>(function(e,t){if(!h||e.disabled||0!==t.button)return;let n=t.currentTarget.getBoundingClientRect();z(e.id),ei(Y,!1),er({tabId:e.id,startX:t.clientX,startY:t.clientY,offsetX:t.clientX-n.left,top:n.top,width:n.width,currentX:t.clientX,currentY:t.clientY,dragging:!1})})(e,t),"data-slot":"multi-tab","data-tab-id":e.id,"data-state":r?"active":"inactive","data-dragging":I===e.id?"true":void 0,"data-modified":e.modified?"true":void 0,className:(0,eI.cn)("group/tab relative flex h-9 min-w-0 max-w-52 shrink-0 items-center gap-1 rounded-t-lg border border-b-0 px-2.5 transition-[border-color,background-color,color,box-shadow,outline-color] duration-150 ease-out",h&&!e.disabled&&"cursor-grab active:cursor-grabbing",r?"border-border bg-background text-foreground shadow-[0_-1px_0_var(--background)_inset]":"border-transparent bg-transparent text-muted-foreground hover:bg-background/70 hover:text-foreground",o&&"border-dashed border-border bg-muted/45 text-transparent shadow-none outline outline-1 outline-ring/30 [&_*]:opacity-0",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsx)("button",{type:"button",role:"tab","aria-label":Gm(e.title),"aria-selected":r,disabled:e.disabled,onClick:t=>{var r;let i;if(H.current){H.current=!1,t.preventDefault();return}r=e.id,(i=Y.find(e=>e.id===r))&&!i.disabled&&(void 0===n&&Q(r),a?.(r))},className:"absolute inset-0 rounded-t-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}),(0,ey.jsxs)("div",{"aria-hidden":"true",className:"pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-1.5",children:[e.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:e.title}),e.meta&&(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.meta}),e.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),!e.pinned&&(0,ey.jsx)("button",{type:"button",draggable:!1,onPointerDown:e=>e.stopPropagation(),"aria-label":e.closeLabel??(Gm(e.title)?`${x}: ${Gm(e.title)}`:x),onClick:()=>(function(e){if(e.pinned)return;let t=Y.findIndex(t=>t.id===e.id),r=Y.filter(t=>t.id!==e.id);if(en(r),l?.(e),e.id===ee){let e=Gh(r,t);void 0===n&&Q(e),e&&a?.(e)}})(e),className:(0,eI.cn)("relative z-20 grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none group-hover/tab:opacity-100",r&&"opacity-100"),children:(0,ey.jsx)(fg.XIcon,{className:"size-3.5"})})]}),s&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"mb-2 h-4 w-px shrink-0 bg-border/80"})]},e.id)}),G?(0,ey.jsxs)("span",{"data-slot":"multi-tab-external-insert","aria-hidden":"true",className:"pointer-events-none absolute top-2 bottom-1 z-30 flex w-0 -translate-x-1/2 items-center justify-center",style:{left:G.left},children:[(0,ey.jsx)("span",{className:"h-full w-px rounded-full bg-foreground/80"}),(0,ey.jsx)("span",{className:"absolute top-0 size-1.5 rounded-full bg-foreground"})]}):null]}),(0,ey.jsxs)("div",{className:"mb-1 flex shrink-0 items-center gap-1",children:[q&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":b,onClick:()=>el("right"),children:(0,ey.jsx)(mQ,{})}),u.length>0?(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,children:(0,ey.jsx)(lJ,{})})}),(0,ey.jsx)(bZ,{align:"end",className:"w-52",children:u.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(b2,{children:e.shortcut})]})]},t))})]}):(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,onClick:function(){let e=o?.();e&&(en([...Y,e]),e.disabled||(void 0===n&&Q(e.id),a?.(e.id)))},children:(0,ey.jsx)(lJ,{})}),f.length>0&&(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":v,children:(0,ey.jsx)(lY,{})})}),(0,ey.jsx)(bZ,{align:"end",className:"w-52",children:f.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(b2,{children:e.shortcut})]})]},t))})]})]})]}),ep,S&&(0,ey.jsx)("div",{"data-slot":"multi-tab-content",className:(0,eI.cn)("min-h-0 overflow-hidden",M),children:ef??j??(0,ey.jsx)("div",{"aria-hidden":"true",className:"min-h-44 rounded-lg border border-dashed bg-muted/30"})})]})}let Gv=(0,ek.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function Gx({status:e}){return"done"===e?(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}):"in_progress"===e?(0,ey.jsx)(Vw,{className:"size-3.5 shrink-0 text-amber-500"}):"blocked"===e||"skipped"===e?(0,ey.jsx)(Gv,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(bC,{className:"size-3.5 shrink-0 text-muted-foreground/50"})}function Gy({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,ey.jsxs)("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}let Gb={main:"主",subagent:"子"};function Gw({node:e,depth:t,activeId:n}){let r=function e(t){if(!t.children||0===t.children.length)return"task"!==t.kind&&"subplan"!==t.kind?{done:0,total:0}:{done:+("done"===t.status),total:1};let n=0,r=0;for(let a of t.children){let t=e(a);n+=t.done,r+=t.total}return{done:n,total:r}}(e),a="phase"===e.kind,i=e.orchestration,o=void 0!==n&&e.id===n;return(0,ey.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,ey.jsxs)("div",{className:(0,eI.cn)("flex items-center gap-2 rounded-md px-1.5 py-1",o&&"bg-sky-teal/10 ring-1 ring-sky-teal/30"),style:{marginLeft:12*t},children:[(0,ey.jsx)(Gx,{status:e.status}),(0,ey.jsx)("span",{className:(0,eI.cn)("min-w-0 flex-1 truncate text-[13px]","done"===e.status&&"text-muted-foreground line-through",o&&"font-medium text-foreground"),title:e.detail||e.title,children:e.title}),a&&i?(0,ey.jsxs)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:[Gb[i.executor]??i.executor,i.subagentType?`:${i.subagentType}`:""]}):null,a&&r.total>0?(0,ey.jsx)(Gy,{done:r.done,total:r.total}):null]}),e.children?.map(e=>(0,ey.jsx)(Gw,{node:e,depth:t+1,activeId:n},e.id))]})}function Gj({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState("");ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{let a=await sD(e,t);n&&(r(a.planState),void 0!==a.planDoc&&i(a.planDoc))};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let o=n?.activePath?.length?n.activePath[n.activePath.length-1]:void 0;return(0,ey.jsx)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:(0,ey.jsxs)(md,{defaultValue:"doc",className:"flex min-h-0 flex-1 flex-col gap-0",children:[(0,ey.jsx)("div",{className:"shrink-0 border-b px-2 py-1.5",children:(0,ey.jsxs)(my,{children:[(0,ey.jsx)(mb,{value:"doc",children:"计划文档"}),(0,ey.jsx)(mb,{value:"tree",children:"执行树"})]})}),(0,ey.jsx)(mw,{value:"doc",className:"min-h-0 flex-1",children:(0,ey.jsx)(wz,{className:"h-full",children:(0,ey.jsx)("div",{className:"px-4 py-3 text-sm",children:a.trim()?(0,ey.jsx)(Vq,{content:a}):(0,ey.jsx)("p",{className:"text-muted-foreground/70",children:"尚无可读计划文档。"})})})}),(0,ey.jsx)(mw,{value:"tree",className:"min-h-0 flex-1",children:(0,ey.jsx)(wz,{className:"h-full",children:(0,ey.jsx)("div",{className:"px-2 py-2",children:n?.tree?(0,ey.jsx)(Gw,{node:n.tree,depth:0,activeId:o}):(0,ey.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"计划尚未编译成执行树。"})})})})]})})}function Gk({conversationId:e,ownerMachineId:t,initialPath:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(n),[l,s]=ew.useState("");return ew.useEffect(()=>{if(!e)return;let n=!0,r=async()=>{let r=await s_(e,t);if(!n)return;let i=r.filter(e=>e.startsWith("plan/specs/"));a(i),o(e=>e??i[0])};r();let i=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(i)}},[e,t]),ew.useEffect(()=>{if(!e||!i)return void s("");let n=!0,r=async()=>{try{let r=await sR(e,i,t);n&&s(r.content)}catch{n&&s("")}};r();let a=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(a)}},[e,t,i]),(0,ey.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,ey.jsx)("div",{className:"flex shrink-0 flex-wrap gap-1 border-b px-2 py-1.5",children:0===r.length?(0,ey.jsx)("span",{className:"px-1 py-1 text-xs text-muted-foreground/70",children:"尚无规范文档"}):r.map(e=>(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors",e===i?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60"),onClick:()=>o(e),children:[(0,ey.jsx)(uC,{className:"size-3.5"}),e.split("/").pop()??e]},e))}),(0,ey.jsx)(wz,{className:"min-h-0 flex-1",children:(0,ey.jsx)("div",{className:"px-4 py-3 text-sm",children:l.trim()?(0,ey.jsx)(Vq,{content:l}):(0,ey.jsx)("p",{className:"text-muted-foreground/70",children:i?"(空文档)":"选择左上方的规范文档查看。"})})})]})}let GS=(0,ek.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),GN=(0,ek.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),GC=(0,ek.default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]),GM=(0,ek.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),GE=(0,ek.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function GO(e,t){return e?eD(`/v1/remote/${e}${t}`):eD(t)}async function GP(e,t){let{signal:n,timeoutMs:r=8e3}=t??{},a=new AbortController,i=r>0?setTimeout(()=>a.abort(),r):void 0;n&&n.addEventListener("abort",()=>a.abort(),{once:!0});try{let t=await fetch(GO(e,"/v1/extensions"),{cache:"no-store",signal:a.signal});if(!t.ok)throw Error(`Extensions API error: ${t.status}`);return await t.json()}finally{i&&clearTimeout(i)}}async function GA(e,t,n){let r=await fetch(GO(e,t),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:void 0===n?void 0:JSON.stringify(n)});if(!r.ok)throw Error(`Extensions API error: ${r.status}`);let a=await r.text();return a?JSON.parse(a):{}}async function GI(e,t){return GA(e,"/v1/extensions/browser/install",{variant:t})}async function Gz(e,t){return GA(e,"/v1/extensions/browser/update",t?{variant:t}:{})}async function GT(e){return GA(e,"/v1/extensions/browser/uninstall")}async function GD(e,t){return GA(e,"/v1/extensions/browser/enable",{enabled:t})}async function GR(e,t){let{timeoutMs:n=6e3}=t??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;try{let t=await fetch(GO(e,"/v1/browser/info"),{cache:"no-store",signal:r.signal});if(!t.ok)return null;let n=await t.text(),a=n?JSON.parse(n):{};return{running:!!a.running,monitoring:!!a.monitoring}}catch{return null}finally{a&&clearTimeout(a)}}async function G_(e,t){return{monitoring:!!(await GA(e,"/v1/browser/monitor",{enabled:t})).monitoring}}let GL={drafting:"撰写计划",awaiting_approval:"等待批准",executing:"执行中",compacting:"压缩上下文",done:"已完成"};function G$(e){if(!e.children||0===e.children.length)return"task"!==e.kind&&"subplan"!==e.kind?{done:0,total:0}:{done:+("done"===e.status),total:1};let t=0,n=0;for(let r of e.children){let e=G$(r);t+=e.done,n+=e.total}return{done:t,total:n}}function GF(e,t){if(e){if(e.id===t)return e;for(let n of e.children??[]){let e=GF(n,t);if(e)return e}}}function GB({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,ey.jsxs)("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}function GV({state:e}){let{phase:t,task:n}=function(e){let t,n=e.activePath??[];if(!e.tree||0===n.length)return{};for(let r of n){let n=GF(e.tree,r);n&&"phase"===n.kind&&(t=n)}let r=n[n.length-1];return{phase:t,task:r?GF(e.tree,r):void 0}}(e),r=e.tree?G$(e.tree):{done:0,total:0},a=t?G$(t):void 0,i=r.total>0?Math.round(r.done/r.total*100):0,o=n?.status==="in_progress";return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(GH,{icon:(0,ey.jsx)(GC,{}),label:"任务进度"}),(0,ey.jsxs)("div",{className:"flex flex-col gap-2 px-3 pb-2 text-[13px]",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:"当前阶段"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:t?.title??GL[e.phase]??e.phase??"—"})]}),a&&a.total>0?(0,ey.jsx)(GB,{done:a.done,total:a.total}):null,n?(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[o?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):"done"===n.status?(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}):null,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:n.detail||n.title,children:n.title})]}):null,(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:"总体进度"}),(0,ey.jsxs)("span",{className:"ml-auto font-medium tabular-nums",children:[i,"%"]})]}),(0,ey.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${i}%`}})})]}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"})]})}function GH({icon:e,label:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pt-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 [&_svg]:size-3.5",children:[e,(0,ey.jsx)("span",{children:t})]})}function GU(){let[e,t]=ew.useState("loading"),[n,r]=ew.useState(!1),a=ew.useCallback(async e=>{try{let n=(await GP(void 0,{signal:e,timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);n&&n.installed?n.running?t("running"):t(e=>"starting"===e?"starting":"stopped"):t("missing")}catch{t("missing")}},[]);ew.useEffect(()=>{let e=!0,t=new AbortController,n=()=>{e&&a(t.signal)};n();let r=window.setInterval(n,1e4);return()=>{e=!1,t.abort(),window.clearInterval(r)}},[a]);let i=ew.useCallback(async()=>{if(!n){r(!0),t("starting");try{await GD(void 0,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await GP(void 0,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)return void t("running")}catch{}}}catch{}finally{r(!1),await a()}}},[n,a]);return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(Ui,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"浏览器"}),"running"===e?(0,ey.jsx)(GW,{online:!0}):"starting"===e?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):(0,ey.jsx)(GW,{online:!1}),(0,ey.jsx)("span",{className:"truncate font-medium",children:"running"===e?"运行中":"starting"===e?"启动中":"stopped"===e?"已停止":"missing"===e?"未安装":"—"}),(0,ey.jsx)("span",{className:"ml-auto shrink-0",children:"stopped"===e?(0,ey.jsxs)("button",{type:"button",onClick:()=>void i(),className:"inline-flex items-center gap-1 rounded-md border border-border/70 px-1.5 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted",children:[(0,ey.jsx)(Vw,{className:"size-3"}),"启动"]}):"running"===e?(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground/70",title:"在画布的「浏览器」节点中实时查看 Agent 的浏览器操作",children:"画布查看"}):null})]})}function GW({online:e}){return(0,ey.jsx)("span",{"aria-hidden":!0,className:(0,eI.cn)("inline-block size-2 shrink-0 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/40")})}function Gq({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState([]),[o,l]=ew.useState([]),{machines:s}=vj();ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{try{let[a,o,s]=await Promise.all([sA(e,t),sz(e,t).catch(()=>[]),sT(e,t).catch(()=>[])]);if(!n)return;r(a),i(o),l(s)}catch{}};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let c=ew.useMemo(()=>new Map(s.map(e=>[e.id,e])),[s]),d=e=>"local"===e||c.get(e)?.status==="online",u=e=>"local"===e?c.get("local")?.name??"本地":c.get(e)?.name??e,f=t??n?.conversation.ownerMachineId??"local",h=(n?.conversation.settings?.hosts??[]).filter(Boolean),m=n?.conversation.runUsage,p=n?.conversation.status==="working",g=(m?.cachedInputTokens??0)+(m?.cacheCreationInputTokens??0),{additions:v,deletions:x}=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=0,r=0;for(let a=Math.max(0,t);a<e.length;a+=1){let t=e[a],i=t?.additions??t?.meta?.additions,o=t?.deletions??t?.meta?.deletions;"number"==typeof i&&(n+=i),"number"==typeof o&&(r+=o)}return{additions:n,deletions:r}}(n?.events??[]),y=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=new Set;for(let r=Math.max(0,t);r<e.length;r+=1){let t=e[r];if(t?.kind==="subagent"&&Array.isArray(t.subagents))for(let e of t.subagents)e?.id&&n.add(e.id)}return n}(n?.events??[]),b=function e(t,n=0,r=[]){for(let a of t)r.push({node:a,depth:n}),a.children&&a.children.length>0&&e(a.children,n+1,r);return r}(a.filter(e=>y.has(e.id))),w=n?.conversation.planState;return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-auto rounded-[inherit] bg-background text-sm",children:[(0,ey.jsx)(GH,{icon:(0,ey.jsx)(uy,{}),label:"环境信息"}),(0,ey.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 pb-2 text-[13px]",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2 text-foreground/90",children:[(0,ey.jsx)(eP,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"运行于"}),(0,ey.jsx)(GW,{online:d(f)}),(0,ey.jsx)("span",{className:"truncate font-medium",children:u(f)})]}),(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(GE,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:"可访问"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-wrap gap-x-3 gap-y-1",children:0===h.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"—"}):h.map(e=>(0,ey.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(GW,{online:d(e)}),(0,ey.jsx)("span",{className:"truncate",children:u(e)})]},e))})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(GN,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"本轮变更"}),(0,ey.jsxs)("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:["+",v]}),(0,ey.jsxs)("span",{className:"font-medium text-rose-600 dark:text-rose-400",children:["-",x]}),(0,ey.jsx)("span",{className:"text-muted-foreground/60",children:"行"})]}),(0,ey.jsx)(GU,{})]}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),w?(0,ey.jsx)(GV,{state:w}):null,(0,ey.jsx)(GH,{icon:(0,ey.jsx)(ub,{}),label:"子智能体"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===b.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮未释放子智能体"}):b.map(({node:e,depth:t})=>{let n="failed"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",style:{paddingLeft:12*t},children:[e.running?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(fg.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||e.title||e.subagentType||"子智能体"}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(GH,{icon:(0,ey.jsx)(uO,{}),label:"后台任务"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===o.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮无后台任务"}):o.map(e=>{let t="failed"===e.status||"timeout"===e.status,n="unknown"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[e.running?(0,ey.jsx)(GM,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(hM,{className:"size-3.5 shrink-0 text-amber-500"}):t?(0,ey.jsx)(fg.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(mZ,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate font-mono text-[12px]",title:e.command,children:e.command||"(命令)"}),e.orphaned?(0,ey.jsx)("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"该后台进程脱离了本轮但仍在运行",children:"脱离"}):null,(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"状态未知":t?"timeout"===e.status?"超时":"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(GH,{icon:(0,ey.jsx)(GS,{}),label:p?"本轮消耗":"消耗额度"}),(0,ey.jsx)("div",{className:"grid grid-cols-3 gap-2 px-3 pb-3",children:[{label:"输入",value:m?.inputTokens},{label:"输出",value:m?.outputTokens},{label:"缓存",value:g}].map(e=>{let t;return(0,ey.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-2 py-1.5",children:[(0,ey.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e.label}),(0,ey.jsx)("div",{className:"font-mono text-sm font-medium tabular-nums",children:m?(t=e.value??0)>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t):"—"})]},e.label)})})]})}let GK="application/vnd.vantaloom.canvas-node",GG="application/vnd.vantaloom.canvas-tab",GX="application/vnd.vantaloom.dashboard-widget",GY="application/vnd.vantaloom.workspace-card";var GZ=e.i(78737);let GJ=(0,ek.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),GQ=(0,ek.default)("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),G0=(0,ek.default)("tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]),G1=[{id:"phone",label:"Phone",width:390,userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"tablet",label:"Tablet",width:820,userAgent:"Mozilla/5.0 (iPad; CPU OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"desktop",label:"Desktop",width:1200,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"}],G2=[{id:"adaptive",label:"自适应",adaptive:!0},{id:"16:9",label:"16:9",value:16/9},{id:"4:3",label:"4:3",value:4/3},{id:"3:2",label:"3:2",value:1.5},{id:"1:1",label:"1:1",value:1},{id:"9:16",label:"9:16",value:9/16}],G5={urlLabel:"URL",urlPlaceholder:"https://example.com",navigate:"Navigate",actions:"Browser view options",devices:"User agent",ratios:"Viewport ratio",back:"Back",forward:"Forward",reload:"Reload preview",previewTitle:"Browser preview"};function G4(e,t,n){return e.find(e=>e.id===t)??n}function G3({id:e}){return"phone"===e?(0,ey.jsx)(GQ,{className:"size-4"}):"tablet"===e?(0,ey.jsx)(G0,{className:"size-4"}):(0,ey.jsx)(eP,{className:"size-4"})}function G6({url:e,defaultUrl:t="https://vantaloom.local/workspace",onUrlChange:n,onNavigate:r,onBack:a,onForward:i,device:o,defaultDevice:l="desktop",onDeviceChange:s,ratio:c,defaultRatio:d="adaptive",onRatioChange:u,devices:f=G1,ratios:h=G2,srcDoc:m,renderPreview:p,showHeader:g=!0,labels:v,className:x,headerClassName:y,previewClassName:b,...w}){let j=ew.useMemo(()=>({...G5,...v}),[v]),[k,S]=ew.useState(t),[N,C]=ew.useState(e??t),[M,E]=ew.useState(()=>[e??t]),[O,P]=ew.useState(0),[A,I]=ew.useState(l),[z,T]=ew.useState(d),[D,R]=ew.useState(!1),[_,L]=ew.useState(0),$=ew.useRef(null),F=ew.useId(),[B,V]=function(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useEffect(()=>{let t=e.current;if(!t)return;function r(e){t&&n(e??{width:t.clientWidth,height:t.clientHeight})}r();let a=new ResizeObserver(e=>{let t=e[0];t?r({width:t.contentRect.width,height:t.contentRect.height}):r()});return a.observe(t),()=>a.disconnect()},[]),[e,t]}(),H=e??k,U=G4(f,o??A,f[0]??G1[0]),W=G4(h,c??z,h[0]??G2[0]),q=V.width>0&&V.height>0,K=W.adaptive||"adaptive"===W.id,G=W.value??16/9,X=K&&V.width||U.width,Y=K?V.height||U.width/G:X/G,Z=(q?V.width/V.height:1)<=G,J=Math.max(1,Math.round(q?K||Z?V.width:V.height*G:X)),Q=Math.max(1,Math.round(q?K?V.height:Z?V.width/G:V.height:Y)),ee=J/X,et=ew.useMemo(()=>({url:H,device:U,ratio:W,viewport:{width:J,height:Q,scale:ee}}),[U,W,H,ee,Q,J]);function en(t,a={history:"push"}){void 0===e&&S(t),"none"!==a.history&&E(e=>{let n=e.slice(0,O+1);return n[n.length-1]===t?n:(P(n.length),[...n,t])}),n?.(t),r?.(t)}return ew.useEffect(()=>{C(e??k)},[k,e]),ew.useEffect(()=>{if(D)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&$.current?.contains(t)||R(!1)}},[D]),(0,ey.jsxs)("div",{ref:$,"data-slot":"browser-tab-viewer","data-device":U.id,"data-ratio":W.id,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",g?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",x),...w,children:[g&&(0,ey.jsxs)("div",{"data-slot":"browser-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",y),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,ey.jsx)(GJ,{className:"size-3.5"})}),(0,ey.jsxs)("form",{onSubmit:function(e){let t;e.preventDefault();let n=(t=N.trim())?/^[a-z][a-z\d+\-.]*:\/\//i.test(t)?t:/^(localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:\/|$)/i.test(t)?`http://${t}`:`https://${t}`:"";C(n),en(n)},className:"min-w-0 flex-1",children:[(0,ey.jsx)("label",{className:"sr-only",htmlFor:F,children:j.urlLabel}),(0,ey.jsx)(ez,{id:F,value:N,onChange:e=>C(e.target.value),placeholder:j.urlPlaceholder,className:"h-5 rounded-md border bg-background px-2 shadow-none ui-text-kbd",spellCheck:!1})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.back,disabled:O<=0,onClick:function(){if(O<=0)return;let e=O-1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),a?.(t))},className:"size-5 rounded-md",children:(0,ey.jsx)(GZ.ArrowLeftIcon,{className:"size-3.5"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.forward,disabled:O>=M.length-1,onClick:function(){if(O>=M.length-1)return;let e=O+1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),i?.(t))},className:"size-5 rounded-md",children:(0,ey.jsx)(ej.ArrowRightIcon,{className:"size-3.5"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.reload,onClick:()=>L(e=>e+1),className:"size-5 rounded-md",children:(0,ey.jsx)(ya,{className:"size-3.5"})})]}),(0,ey.jsx)("div",{ref:B,"data-slot":"browser-tab-viewer-stage",className:(0,eI.cn)("grid min-h-0 place-items-center overflow-hidden bg-muted/20",b),children:(0,ey.jsx)("div",{"data-slot":"browser-tab-viewer-viewport",className:"overflow-hidden rounded-lg border bg-background shadow-sm",style:{width:J,height:Q},children:p?p(et):(0,ey.jsx)("iframe",{title:j.previewTitle,src:m?void 0:H,srcDoc:m,sandbox:"allow-forms allow-modals allow-popups allow-same-origin allow-scripts",className:"size-full border-0 bg-background"},`${_}-${H}-${U.id}-${W.id}`)})}),(0,ey.jsxs)("div",{"data-slot":"browser-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:[(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-popover absolute right-0 bottom-10 grid w-56 gap-3 rounded-[var(--surface-popover-radius)] border p-3 transition-[opacity,transform] duration-150",D?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.devices}),(0,ey.jsx)("div",{className:"flex gap-1.5",children:f.map(e=>(0,ey.jsx)(eA.Button,{type:"button",variant:U.id===e.id?"default":"outline",size:"icon-sm","aria-label":e.label,title:e.label,className:"rounded-full",onClick:()=>{let t;return t=G4(f,e.id,U),void(void 0===o&&I(t.id),s?.(t.id,t))},children:(0,ey.jsx)(G3,{id:e.id})},e.id))})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.ratios}),(0,ey.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,ey.jsx)(eA.Button,{type:"button",variant:W.id===e.id?"default":"outline",size:"xs",className:"h-7 rounded-full px-2.5 ui-text-kbd",onClick:()=>{let t;return t=G4(h,e.id,W),void(void 0===c&&T(t.id),u?.(t.id,t))},children:e.label},e.id))})]})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":j.actions,"aria-expanded":D,onClick:()=>R(e=>!e),className:"rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",D&&"rotate-90")})})]})]})}let G8=(0,ek.default)("monitor-off",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),G7=(0,ek.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);function G9({frame:e,cursor:t,connection:n,takeover:r,onTakeoverChange:a,onInput:i,onReconnect:o,machines:l,selectedMachineId:s,onSelectMachine:c,onStartBrowser:d,starting:u,monitoring:f,onMonitoringChange:h,className:m}){let p=ew.useRef(null),g=ew.useRef(null),v=ew.useRef(null),x=ew.useRef(t??null),y=ew.useRef(0),b=ew.useRef(!1),[w,j]=ew.useState(!1),k=ew.useCallback(()=>{let e=p.current,t=v.current;if(!e||!t)return;let n=e.getContext("2d");if(!n)return;n.drawImage(t,0,0,e.width,e.height);let r=x.current;if(!r)return;let a=Math.max(9,e.width/110);n.save(),n.beginPath(),n.arc(r.x,r.y,a,0,2*Math.PI),n.fillStyle="rgba(255,45,85,0.35)",n.fill(),n.lineWidth=Math.max(2,a/4),n.strokeStyle="rgba(255,255,255,0.95)",n.stroke(),n.beginPath(),n.arc(r.x,r.y,Math.max(2.5,.32*a),0,2*Math.PI),n.fillStyle="rgba(255,45,85,0.95)",n.fill(),n.restore()},[]);function S(t){let n=p.current;if(!n)return null;let r=n.getBoundingClientRect();if(0===r.width||0===r.height)return null;let a=(e?.width||n.width)/r.width,i=(e?.height||n.height)/r.height;return{x:Math.round((t.clientX-r.left)*a),y:Math.round((t.clientY-r.top)*i)}}function N(e,t){r&&i&&(e.preventDefault(),i({kind:"key",type:t,key:e.key}),"keyDown"===t&&1===e.key.length&&i({kind:"key",type:"char",key:e.key,text:e.key}))}ew.useEffect(()=>{let t=p.current;if(!t||!e?.b64)return;let n=new Image;return g.current=n,n.onload=()=>{if(g.current!==n)return;let r=e.width||n.naturalWidth,a=e.height||n.naturalHeight;t.width!==r&&(t.width=r),t.height!==a&&(t.height=a),v.current=n,k()},n.src=`data:image/jpeg;base64,${e.b64}`,()=>{n.onload=null,g.current===n&&(g.current=null)}},[e,k]),ew.useEffect(()=>{x.current=t??null,k()},[t,k]);let C="streaming"===n||!!e;return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-panel relative flex size-full min-h-0 flex-col overflow-hidden",m),"data-slot":"live-browser-view",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd shrink-0",children:"浏览器"}),(0,ey.jsx)("div",{className:"min-w-0 flex-1",children:l.length>0?(0,ey.jsx)("select",{value:s??"",onChange:e=>c?.(e.target.value),className:"h-6 w-full max-w-[16rem] truncate rounded-md border bg-background px-2 ui-text-kbd",children:l.map(e=>(0,ey.jsxs)("option",{value:e.id,disabled:!e.running,children:[e.label,e.running?"":"(未运行)"]},e.id))}):(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"无可用浏览器"})}),h?(0,ey.jsxs)(eA.Button,{type:"button",size:"xs",variant:f?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":!!f,onClick:()=>h(!f),title:f?"浏览器监视:开启(有头实时画面,会打开一个真实浏览器窗口)。点击关闭后仅在 agent 每次操作后显示一帧。":"浏览器监视:关闭(仅在 agent 每次操作后显示一帧)。点击开启有头实时画面,会打开一个真实浏览器窗口。",children:[f?(0,ey.jsx)(eP,{className:"size-3.5"}):(0,ey.jsx)(G8,{className:"size-3.5"}),"监视"]}):null,(0,ey.jsxs)(eA.Button,{type:"button",size:"xs",variant:r?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":r,onClick:()=>a(!r),disabled:"streaming"!==n,title:r?"切换到观看模式":"接管:在画面里直接操作",children:[r?(0,ey.jsx)(lq,{className:"size-3.5"}):(0,ey.jsx)(lZ,{className:"size-3.5"}),r?"接管中":"观看"]}),"error"===n&&o?(0,ey.jsx)(eA.Button,{type:"button",size:"icon-xs",variant:"ghost",className:"size-6 rounded-md","aria-label":"重新连接",onClick:o,children:(0,ey.jsx)(G7,{className:"size-3.5"})}):null]}),(0,ey.jsxs)("div",{className:"relative grid min-h-0 flex-1 place-items-center overflow-hidden bg-black/85",children:[C?(0,ey.jsx)("canvas",{ref:p,tabIndex:r?0:-1,onPointerDown:function(e){if(!r||!i)return;let t=S(e);t&&(b.current=!0,e.currentTarget.setPointerCapture(e.pointerId),p.current?.focus(),i({kind:"mouse",type:"mousePressed",button:"left",...t}))},onPointerUp:function(e){if(!r||!i)return;let t=S(e);b.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}t&&i({kind:"mouse",type:"mouseReleased",button:"left",...t})},onPointerMove:function(e){if(!r||!i)return;let t=performance.now();if(t-y.current<33)return;y.current=t;let n=S(e);n&&i({kind:"mouse",type:"mouseMoved",button:b.current?"left":"none",...n})},onKeyDown:e=>N(e,"keyDown"),onKeyUp:e=>N(e,"keyUp"),onFocus:()=>j(!0),onBlur:()=>j(!1),className:(0,eI.cn)("max-h-full max-w-full object-contain outline-none",r?"cursor-crosshair":"cursor-default")}):(0,ey.jsx)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:"connecting"===n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"size-5 animate-spin"}),(0,ey.jsx)("span",{children:"正在连接浏览器…"})]}):"error"===n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G8,{className:"size-5"}),(0,ey.jsx)("span",{children:"连接浏览器失败"}),o?(0,ey.jsx)(eA.Button,{type:"button",size:"xs",variant:"outline",onClick:o,children:"重试"}):null]}):u?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"size-5 animate-spin"}),(0,ey.jsx)("span",{children:"正在启动浏览器…"})]}):0===l.length?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G8,{className:"size-5"}),(0,ey.jsx)("span",{children:"未安装浏览器"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground/70",children:"请在「官方扩展」页面安装 Vantaloom 浏览器"})]}):d?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G8,{className:"size-5"}),(0,ey.jsx)("span",{children:"浏览器已停止"}),(0,ey.jsxs)(eA.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:d,children:[(0,ey.jsx)(Vw,{className:"size-3.5"}),"启动浏览器"]})]}):!f&&h?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G8,{className:"size-5"}),(0,ey.jsx)("span",{children:"等待 agent 操作后显示画面"}),(0,ey.jsxs)(eA.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:()=>h(!0),children:[(0,ey.jsx)(eP,{className:"size-3.5"}),"开启浏览器监视以查看实时画面"]})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(G8,{className:"size-5"}),(0,ey.jsx)("span",{children:"浏览器未运行"})]})}),r&&C?(0,ey.jsxs)("div",{className:"pointer-events-none absolute inset-0",children:[(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-0 rounded-sm ring-2 ring-inset transition-colors",w?"ring-hot-pink":"ring-hot-pink/50")}),(0,ey.jsxs)("span",{className:"absolute left-2 top-2 rounded bg-hot-pink/90 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["接管中",w?"":"(点击画面以捕获键盘)"]})]}):null]})]})}function Xe(e,t){return e?eD(`/v1/remote/${e}/browser${t}`):eD(`/v1/browser${t}`)}async function Xt(e,t){try{await fetch(Xe(e,"/input"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function Xn({active:e=!0,className:t}){let[n,r]=ew.useState(0),a=function(e,t){let{machines:n}=vj(),[r,a]=ew.useState([]);return ew.useEffect(()=>{if(!e)return;let t=!1;async function r(e,t,n){try{let r=(await GP(t,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(!r||!r.installed)return null;return{id:e,machineId:t,label:n,installed:r.installed,running:r.running}}catch{return null}}async function i(){let e=[{id:"",machineId:void 0,label:"本机"}];for(let t of n)t.isLocal||"online"===t.status&&e.push({id:t.id,machineId:t.id,label:t.name||t.id});let i=await Promise.all(e.map(e=>r(e.id,e.machineId,e.label)));t||a(i.filter(e=>null!==e))}i();let o=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(o)}},[e,n,t]),r}(e,n),[i,o]=ew.useState(""),[l,s]=ew.useState(!1),[c,d]=ew.useState(!1),[u,f]=ew.useState(!1);ew.useEffect(()=>{0===a.length||a.some(e=>e.id===i)||o((a.find(e=>e.running)??a[0]).id)},[a,i]);let h=a.find(e=>e.id===i),m=!!h?.running;ew.useEffect(()=>{!m&&l&&s(!1)},[m,l]);let{frame:p,cursor:g,connection:v,reconnect:x}=function(e){let{machineId:t,enabled:n}=e,[r,a]=ew.useState(null),[i,o]=ew.useState(null),[l,s]=ew.useState("idle"),[c,d]=ew.useState(0),u=ew.useCallback(()=>{d(e=>e+1)},[]);return ew.useEffect(()=>{let e;if(!n){s("idle"),a(null),o(null);return}let r=!1,i=new AbortController;async function l(){s("connecting");try{let e=await fetch(Xe(t,"/screencast"),{cache:"no-store",headers:{Accept:"text/event-stream"},signal:i.signal});if(r)return;if(404===e.status||409===e.status){s("no-browser"),c();return}if(!e.ok||!e.body){s("error"),c();return}let n=e.body.getReader(),l=new TextDecoder,d="";for(s("streaming");;){let{value:e,done:t}=await n.read();if(r||t)break;let i=(d+=l.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==i;){let e=d.slice(0,i);d=d.slice(i+2),function(e){let t=e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trimStart());if(0===t.length)return;let n=t.join("\n");if(n&&"[DONE]"!==n)try{let e=JSON.parse(n);"frame"===e.type&&e.b64?a({b64:e.b64,width:e.meta?.width??0,height:e.meta?.height??0}):"cursor"===e.type&&"number"==typeof e.x&&"number"==typeof e.y&&o({x:e.x,y:e.y})}catch{}}(e),i=d.indexOf("\n\n")}}r||(s("connecting"),c())}catch{if(r||i.signal.aborted)return;s("error"),c()}}function c(){r||(e=setTimeout(()=>{r||l()},1500))}return l(),()=>{r=!0,i.abort(),e&&clearTimeout(e)}},[t,n,c]),{frame:r,cursor:i,connection:l,reconnect:u}}({machineId:h?.machineId,enabled:e&&m});ew.useEffect(()=>{if(!e||!m)return void f(!1);let t=!1;return GR(h?.machineId).then(e=>{!t&&e&&f(e.monitoring)}),()=>{t=!0}},[e,m,h?.machineId]);let y=ew.useCallback(e=>{G_(h?.machineId,e).then(e=>{f(e.monitoring),x()}).catch(()=>{})},[h,x]),b=a.map(e=>({id:e.id,machineId:e.machineId,label:e.label,running:e.running})),w=ew.useCallback(e=>{Xt(h?.machineId,e)},[h?.machineId]),j=ew.useCallback(async()=>{if(!c){d(!0);try{await GD(h?.machineId,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await GP(h?.machineId,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)break}catch{}}}catch{}finally{d(!1),r(e=>e+1)}}},[h,c]);return(0,ey.jsx)(G9,{cursor:g,className:t,frame:p,connection:m?v:"no-browser",takeover:l,onTakeoverChange:s,onInput:w,onReconnect:x,machines:b,selectedMachineId:i,onSelectMachine:o,onStartBrowser:h&&!m?()=>void j():void 0,starting:c,monitoring:u,onMonitoringChange:m?y:void 0})}function Xr({defaultUrl:e,className:t}){let{machines:n}=vj(),[r,a]=ew.useState(!1);return(ew.useEffect(()=>{let e=!1;async function t(){let t=[void 0];for(let e of n)e.isLocal||"online"===e.status&&t.push(e.id);let r=await Promise.all(t.map(async e=>{try{let t=await GP(e,{timeoutMs:6e3});return!!t.extensions.find(e=>"browser"===e.id)?.running}catch{return!1}}));e||a(r.some(Boolean))}t();let r=window.setInterval(t,12e3);return()=>{e=!0,window.clearInterval(r)}},[n]),r)?(0,ey.jsx)(Xn,{active:!0,className:t}):(0,ey.jsx)(G6,{className:t,defaultUrl:e})}let Xa=[{policyNumber:3,name:"Allow HTTP Traffic",sourceZone:"Trust",sourceIPs:["192.168.1.0/24","10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["192.168.2.0/24"],tags:["Web Access","Internal"],action:"allow",description:"Permits HTTP traffic from internal network"},{policyNumber:5,name:"Block Suspicious IPs",sourceZone:"Untrust",sourceIPs:["203.0.113.0/24","198.51.100.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Security"],action:"deny",description:"Blocks known malicious IP ranges"},{policyNumber:9,name:"SSH Access Control",sourceZone:"Trust",sourceIPs:["172.16.0.0/12"],destinationZone:"Trust",destinationIPs:["10.50.0.0/16"],tags:["Admin Access","VPN"],action:"allow",description:"Restricted SSH access for admin network"},{policyNumber:12,name:"Database Port Protection",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["10.100.0.0/24"],tags:["Blocking","Database"],action:"deny",description:"Blocks external access to database ports"},{policyNumber:15,name:"API Gateway Access",sourceZone:"Trust",sourceIPs:["192.168.100.0/24","192.168.101.0/24"],destinationZone:"Trust",destinationIPs:["10.200.0.5"],tags:["API","VDI Env"],action:"allow",description:"Allows traffic to API gateway from specific subnets"},{policyNumber:18,name:"Drop Legacy SMB",sourceZone:"Trust",sourceIPs:["Any"],destinationZone:"Trust",destinationIPs:["10.20.0.0/16"],tags:["Legacy","Internal"],action:"drop",description:"Drops SMBv1 probes across workstation networks"},{policyNumber:22,name:"Agent Runtime Mesh",sourceZone:"Trust",sourceIPs:["10.10.4.0/24"],destinationZone:"Trust",destinationIPs:["10.10.8.0/24","10.10.12.0/24"],tags:["Agent","Runtime"],action:"allow",description:"Allows managed agent runtime channels between worker pools"},{policyNumber:27,name:"Block Public Admin Ports",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Admin Access"],action:"deny",description:"Denies public access to SSH, RDP, and database admin ports"},{policyNumber:31,name:"Build Cache Access",sourceZone:"Trust",sourceIPs:["10.30.0.0/16"],destinationZone:"Trust",destinationIPs:["10.60.12.20"],tags:["Build","Internal"],action:"allow",description:"Allows build workers to reach shared cache storage"},{policyNumber:36,name:"Relay Egress",sourceZone:"Trust",sourceIPs:["10.40.0.0/16"],destinationZone:"Untrust",destinationIPs:["198.18.0.0/15"],tags:["Relay","Agent"],action:"allow",description:"Permits relay service egress to managed edge addresses"},{policyNumber:41,name:"Quarantine Subnet",sourceZone:"Quarantine",sourceIPs:["10.250.0.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Security","Blocking"],action:"deny",description:"Blocks quarantined hosts from internal services"},{policyNumber:48,name:"Observability Intake",sourceZone:"Trust",sourceIPs:["10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["10.80.4.10"],tags:["Telemetry","Internal"],action:"allow",description:"Allows metrics and logs to the observability intake"}],Xi=Array.from(new Set(Xa.flatMap(e=>e.tags))).sort(),Xo=[["10.10.4.0/24","Agent workers","Trust","18"],["10.20.0.0/16","Workstations","Trust","41"],["10.250.0.0/24","Quarantine","Quarantine","03"],["198.18.0.0/15","Relay edge","Untrust","12"]],Xl=[["Database Port Protection","2026-06-12","Security"],["Relay Egress","2026-06-28","Network"],["Build Cache Access","2026-07-04","Build"],["Observability Intake","2026-07-18","Ops"]];function Xs({className:e,...t}){return(0,ey.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,eI.cn)("mx-auto flex w-full justify-center",e),...t})}function Xc({className:e,...t}){return(0,ey.jsx)("ul",{"data-slot":"pagination-content",className:(0,eI.cn)("flex flex-row items-center gap-1",e),...t})}function Xd({...e}){return(0,ey.jsx)("li",{"data-slot":"pagination-item",...e})}function Xu({className:e,isActive:t,size:n="icon",...r}){return(0,ey.jsx)("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:(0,eI.cn)((0,eA.buttonVariants)({variant:t?"outline":"ghost",size:n}),e),...r})}function Xf({className:e,previousLabel:t="Previous",...n}){return(0,ey.jsxs)(Xu,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pl-2",e),...n,children:[(0,ey.jsx)(mJ,{}),(0,ey.jsx)("span",{className:"hidden sm:block",children:t})]})}function Xh({className:e,nextLabel:t="Next",...n}){return(0,ey.jsxs)(Xu,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pr-2",e),...n,children:[(0,ey.jsx)("span",{className:"hidden sm:block",children:t}),(0,ey.jsx)(mQ,{})]})}function Xm({className:e,moreLabel:t="More pages",...n}){return(0,ey.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,eI.cn)("flex size-8 items-center justify-center",e),...n,children:[(0,ey.jsx)(lY,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:t})]})}function Xp({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Xg(){let[e,t]=ew.useState(""),[n,r]=ew.useState("all"),[a,i]=ew.useState({allow:!1,drop:!1,deny:!1}),[o,l]=ew.useState(1),s=ew.useMemo(()=>["allow","drop","deny"].filter(e=>a[e]),[a]),c=ew.useMemo(()=>[{id:"policyNumber",header:"策略 #",accessorKey:"policyNumber",align:"right",width:84},{id:"name",header:"名称",accessorKey:"name",width:180,className:"font-medium"},{id:"sourceZone",header:"源区域",accessorKey:"sourceZone",width:112,cell:({row:e})=>(0,ey.jsx)(Xy,{zone:e.sourceZone})},{id:"sourceIPs",header:"源 IP",accessorKey:"sourceIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Xx,{items:e.sourceIPs,variant:"outline"}),copyValue:({row:e})=>e.sourceIPs.join(", ")},{id:"destinationZone",header:"目标区域",accessorKey:"destinationZone",width:112,cell:({row:e})=>(0,ey.jsx)(Xy,{zone:e.destinationZone})},{id:"destinationIPs",header:"目标 IP",accessorKey:"destinationIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Xx,{items:e.destinationIPs,variant:"outline"}),copyValue:({row:e})=>e.destinationIPs.join(", ")},{id:"tags",header:"标签",accessorKey:"tags",width:220,cell:({row:e})=>(0,ey.jsx)(Xx,{items:e.tags,variant:"secondary"}),copyValue:({row:e})=>e.tags.join(", ")},{id:"action",header:"动作",accessorKey:"action",width:96,cell:({row:e})=>(0,ey.jsx)(Xb,{action:e.action})}],[]),d=ew.useMemo(()=>{let t=e.trim().toLowerCase();return Xa.filter(e=>{let r=0===t.length||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.sourceIPs.some(e=>e.toLowerCase().includes(t))||e.destinationIPs.some(e=>e.toLowerCase().includes(t)),i="all"===n||e.tags.includes(n),o=!(a.allow||a.drop||a.deny)||a.allow&&"allow"===e.action||a.drop&&"drop"===e.action||a.deny&&"deny"===e.action;return r&&i&&o})},[a,e,n]),u=Math.max(1,Math.ceil(d.length/8)),f=Math.min(o,u),h=d.slice((f-1)*8,8*f);return ew.useEffect(()=>{l(1)},[a,e,n]),(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsxs)("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-3",children:[(0,ey.jsx)(Xp,{title:"防火墙策略"}),(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"新增策略"]})]}),(0,ey.jsxs)("div",{className:"mb-3 grid shrink-0 grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(12rem,1fr)_10rem_auto]",children:[(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"搜索"}),(0,ey.jsxs)("span",{className:"relative",children:[(0,ey.jsx)(vk,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,ey.jsx)(ez,{value:e,onChange:e=>t(e.target.value),placeholder:"搜索策略...",className:"pl-8"})]})]}),(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"标签"}),(0,ey.jsxs)(gT,{value:n,onValueChange:r,children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:"全部标签"})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"all",children:"全部标签"}),Xi.map(e=>(0,ey.jsx)(vv,{value:e,children:e},e))]})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"动作"}),(0,ey.jsxs)(mB,{type:"multiple",variant:"outline",value:s,onValueChange:function(e){e.includes("clear")?(t(""),r("all"),i({allow:!1,drop:!1,deny:!1}),l(1)):i({allow:e.includes("allow"),drop:e.includes("drop"),deny:e.includes("deny")})},children:[(0,ey.jsx)(mV,{value:"allow",children:"允许"}),(0,ey.jsx)(mV,{value:"drop",children:"丢弃"}),(0,ey.jsx)(mV,{value:"deny",children:"拒绝"}),(0,ey.jsx)(mV,{value:"clear",children:"全部"})]})]})]}),(0,ey.jsx)(Wo,{rows:h,columns:c,rowId:"policyNumber",showHeader:!1,showToolbar:!1,rowHeight:40,className:"min-h-0 flex-1 rounded-lg shadow-none",labels:{noRows:"没有匹配的策略。",selectAllRows:"选择当前页策略",selectRow:e=>`选择第 ${e+1} 条策略`,resizeColumn:"调整列宽",sortAsc:"升序",sortDesc:"降序",sortClear:"取消排序",copyCell:"复制单元格",copied:"已复制"}}),(0,ey.jsx)(Xv,{page:f,totalPages:u,onPageChange:function(e){l(Math.min(u,Math.max(1,e)))}})]})}function Xv({page:e,totalPages:t,onPageChange:n}){let r=ew.useMemo(()=>t<=3?Array.from({length:t},(e,t)=>t+1):e<=2?[1,2,3]:e>=t-1?[t-2,t-1,t]:[e-1,e,e+1],[e,t]),a=r[0]??1,i=r[r.length-1]??t;function o(e,t){e.preventDefault(),n(t)}return(0,ey.jsx)(Xs,{className:"mt-3 shrink-0",children:(0,ey.jsxs)(Xc,{className:"gap-1 sm:gap-2",children:[(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xf,{href:"#",previousLabel:"上一页","aria-disabled":1===e,className:(0,eI.cn)(1===e&&"pointer-events-none opacity-40"),onClick:t=>o(t,e-1)})}),a>1?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xu,{href:"#",size:"icon",onClick:e=>o(e,1),children:"1"})}),a>2?(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xm,{moreLabel:"更多页"})}):null]}):null,r.map(t=>(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xu,{href:"#",size:"icon",isActive:e===t,onClick:e=>o(e,t),children:t})},t)),i<t?(0,ey.jsxs)(ey.Fragment,{children:[i<t-1?(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xm,{moreLabel:"更多页"})}):null,(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xu,{href:"#",size:"icon",onClick:e=>o(e,t),children:t})})]}):null,(0,ey.jsx)(Xd,{children:(0,ey.jsx)(Xh,{href:"#",nextLabel:"下一页","aria-disabled":e===t,className:(0,eI.cn)(e===t&&"pointer-events-none opacity-40"),onClick:t=>o(t,e+1)})})]})})}function Xx({items:e,variant:t}){return(0,ey.jsx)("div",{className:"flex min-w-48 flex-wrap gap-1",children:e.map(e=>(0,ey.jsx)(Bs,{variant:t,children:e},e))})}function Xy({zone:e}){return(0,ey.jsx)(Bs,{variant:"Trust"===e?"secondary":"outline",children:e})}function Xb({action:e}){return(0,ey.jsx)(Bs,{variant:"allow"===e?"default":"destructive",children:{allow:"允许",drop:"丢弃",deny:"拒绝"}[e]})}function Xw({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,ey.jsx)("table",{"data-slot":"table",className:(0,eI.cn)("w-full caption-bottom text-sm",e),...t})})}function Xj({className:e,...t}){return(0,ey.jsx)("thead",{"data-slot":"table-header",className:(0,eI.cn)("[&_tr]:border-b",e),...t})}function Xk({className:e,...t}){return(0,ey.jsx)("tbody",{"data-slot":"table-body",className:(0,eI.cn)("[&_tr:last-child]:border-0",e),...t})}function XS({className:e,...t}){return(0,ey.jsx)("tr",{"data-slot":"table-row",className:(0,eI.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function XN({className:e,...t}){return(0,ey.jsx)("th",{"data-slot":"table-head",className:(0,eI.cn)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function XC({className:e,...t}){return(0,ey.jsx)("td",{"data-slot":"table-cell",className:(0,eI.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function XM({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function XE({title:e,headers:t,rows:n}){return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsx)(XM,{title:e}),(0,ey.jsx)("div",{className:"mt-3 min-h-0 flex-1 overflow-auto",children:(0,ey.jsxs)(Xw,{children:[(0,ey.jsx)(Xj,{children:(0,ey.jsx)(XS,{children:t.map(e=>(0,ey.jsx)(XN,{children:e},e))})}),(0,ey.jsx)(Xk,{children:n.map(e=>(0,ey.jsx)(XS,{children:e.map((e,t)=>(0,ey.jsx)(XC,{className:0===t?"font-medium":"text-muted-foreground",children:e},`${e}-${t}`))},e.join("-")))})]})})]})}function XO(){return(0,ey.jsxs)("div",{className:"grid h-full min-h-0 content-start gap-3 p-3",children:[(0,ey.jsx)(XM,{title:"策略申请"}),(0,ey.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,ey.jsx)(ez,{placeholder:"策略名称"}),(0,ey.jsx)(ez,{placeholder:"负责人"}),(0,ey.jsx)(ez,{placeholder:"源 CIDR"}),(0,ey.jsx)(ez,{placeholder:"目标 CIDR"})]}),(0,ey.jsx)("textarea",{placeholder:"用途",className:"min-h-32 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"提交申请"]})})]})}function XP(){return(0,ey.jsxs)(md,{defaultValue:"policies",className:"vtl-firewall-workspace flex h-full min-h-0 flex-col",children:[(0,ey.jsx)("div",{className:"shrink-0 overflow-x-auto px-3 pt-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsxs)(my,{className:"h-8 w-max min-w-full",children:[(0,ey.jsx)(mb,{value:"policies",children:"防火墙策略"}),(0,ey.jsx)(mb,{value:"ip-addresses",children:"IP 地址"}),(0,ey.jsx)(mb,{value:"renewals",children:"续期"}),(0,ey.jsx)(mb,{value:"policy-request",children:"策略申请"}),(0,ey.jsx)(mb,{value:"user-settings",children:"用户设置"})]})}),(0,ey.jsx)(mw,{value:"policies",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(Xg,{})}),(0,ey.jsx)(mw,{value:"ip-addresses",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XE,{title:"IP 地址",headers:["地址","名称","区域","策略"],rows:Xo})}),(0,ey.jsx)(mw,{value:"renewals",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XE,{title:"续期",headers:["策略","续期时间","负责人"],rows:Xl})}),(0,ey.jsx)(mw,{value:"policy-request",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XO,{})}),(0,ey.jsx)(mw,{value:"user-settings",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(XE,{title:"用户设置",headers:["设置","值"],rows:[["默认区域","Trust"],["审核提醒","14 天"],["申请审批","安全负责人"],["策略导出","已开启"]]})})]})}function XA(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function XI(e,t){let n=t.machineId||"local";return XA((await uK(n,e.path)).items)}function Xz({className:e,onOpenFile:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(!1),[o,l]=ew.useState(0),s=ew.useCallback(async()=>{i(!0);try{let e=await uq();r(e.roots.map(e=>({id:e.id,machineId:e.machineId,name:e.name,path:e.path,platform:e.platform,children:XA(e.children)}))),l(e=>e+1)}catch{r([]),l(e=>e+1)}finally{i(!1)}},[]);return ew.useEffect(()=>{s()},[s]),ew.useEffect(()=>{function e(){s()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[s]),(0,ey.jsx)(HL,{className:e,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:n,defaultExpandedIds:n.map(e=>e.id),loadingIds:a?n.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:XI,onOpenNode:(e,n)=>{"folder"!==e.kind&&t?.({machineId:n.machineId||"local",path:e.path})},onRefresh:()=>{s()}},o)}function XT({open:e,onOpenChange:t,onSelectFile:n}){return(0,ey.jsx)(dC,{open:e,onOpenChange:t,children:(0,ey.jsxs)(fx,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fb,{className:"sr-only",children:"选择文件"}),(0,ey.jsx)(fw,{className:"sr-only",children:"选择本机可访问文件。"}),(0,ey.jsx)(Xz,{className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{n(e),t(!1)}})]})})}function XD(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useLayoutEffect(()=>{let t=e.current;if(!t)return;function r(){let e=t.getBoundingClientRect();n({width:e.width,height:e.height})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}let XR=(0,ek.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);function X_({open:e,placement:t="viewport",movePermissionGranted:n,onOpenChange:r,onAdd:a,onMovePermissionGrantedChange:i}){let o=[{key:"move-permission",label:n?"取消放行权限":"放行权限",icon:n?(0,ey.jsx)(jz,{className:"size-4"}):(0,ey.jsx)(XR,{className:"size-4"}),pressed:n,onClick:()=>i(!n)},{key:"add",label:"新建文件窗口",icon:(0,ey.jsx)(lJ,{className:"size-4"}),pressed:void 0,onClick:a}];return(0,ey.jsx)("div",{className:(0,eI.cn)("right-5 z-50","viewport"===t?"fixed bottom-5 max-md:bottom-20":"absolute bottom-5"),children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,title:t.label,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.pressed&&"border-foreground bg-foreground text-background hover:bg-foreground/90 hover:text-background"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":"文件窗口操作","aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let XL=[];function X$(e,t){return`${e} / ${t.replace(/\\/g," / ").replace(/\//g," / ")}`}function XF(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?XF(n.children,t):void 0;if(e)return e}}function XB(e,t){return e.replace(/\\/g,"/").toLowerCase()===t.replace(/\\/g,"/").toLowerCase()}function XV(e,t){let n=e.replace(/\\/g,"/").replace(/\/+/g,"/");return"windows"===t?n.toLowerCase():n}function XH(e){return e.map(e=>({...e,children:e.children?XH(e.children):void 0}))}let XU=(0,ek.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]),XW=(0,ek.default)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),Xq=(0,ek.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),XK={title:"Clipboard",empty:"No clips",dragHandle:"Drag clip"};function XG({items:e,expanded:t,defaultExpanded:n=!1,expansionDirection:r="down-left",title:a,labels:i,maxCollapsedItems:o=10,maxExpandedHeight:l=360,acceptExternalDrops:s=!1,removeOnExternalDrop:c=!1,className:d,onExpandedChange:u,onItemDragStart:f,onItemDragEnd:h,onItemDuplicate:m,onItemsRemove:p,onItemsReorder:g,onExternalDrop:v,onMouseEnter:x,onMouseLeave:y,...b}){let w={...XK,...i},[j,k]=ew.useState(n),[S,N]=ew.useState(),[C,M]=ew.useState(),[E,O]=ew.useState(n),[P,A]=ew.useState(),[I,z]=ew.useState({canScrollDown:!1,canScrollUp:!1}),[T,D]=ew.useState(!1),[R,_]=ew.useState(!1),L=ew.useRef(0),$=ew.useRef(void 0),F=ew.useRef(!1),B=ew.useRef(null),V=ew.useRef(null),H=void 0!==t,U=(H?t:j)||void 0!==S,W=Math.min(o,10),q=U?e:e.slice(0,W),K=E?C:void 0,G=44*q.length+18,X=Math.min(G,l),Y=U&&G>X,Z=0===e.length?"h-24":U?`${X}px`:"h-28",J=U&&Y?14:0;ew.useEffect(()=>{if(!U){O(!1),z({canScrollDown:!1,canScrollUp:!1});return}O(!1),window.requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=0)}),z({canScrollUp:!1,canScrollDown:G>X});let e=window.setTimeout(()=>{O(!0)},260);return()=>window.clearTimeout(e)},[G,X,U]),ew.useEffect(()=>()=>{void 0!==$.current&&window.clearTimeout($.current)},[]);let Q=ew.useCallback(e=>{H||k(e),u?.(e)},[H,u]);function ee(e,t=0){let n=e.currentTarget.getBoundingClientRect();return e.clientX>=n.left-t&&e.clientX<=n.right+t&&e.clientY>=n.top-t&&e.clientY<=n.bottom+t}function et(e){if(!U||!V.current)return 0;let t=Array.from(V.current.querySelectorAll('[data-slot="clipboard-stack-card"]'));if(0===t.length)return 0;for(let[n,r]of t.entries()){let t=r.getBoundingClientRect();if(e.clientY<t.top+t.height/2)return n}return t.length}function en(e){return void 0!==S||Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.clip-id")}return ew.useEffect(()=>{if(0===e.length||U)return;let t=window.requestAnimationFrame(()=>{B.current?.matches(":hover")&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))});return()=>window.cancelAnimationFrame(t)},[e.length,Q,U]),ew.useEffect(()=>{if(!U||!Y||!K||!V.current)return;let e=q.findIndex(e=>e.id===K);if(e<0)return;let t=V.current,n=44*e-8,r=44*e+(q[e]?.expandedHeight??220)+12,a=t.scrollTop,i=a+t.clientHeight;n<a?t.scrollTo({top:Math.max(0,n),behavior:"smooth"}):r>i&&t.scrollTo({top:r-t.clientHeight,behavior:"smooth"})},[K,Y,q,U]),(0,ey.jsxs)("div",{ref:B,"data-slot":"clipboard-stack","data-expanded":U,"data-closing":T,"data-external-dragging":R,"data-expansion-direction":r,className:(0,eI.cn)("group/clipboard relative w-80 max-w-full overflow-visible py-2",d),onMouseEnter:function(e){x?.(e),ee(e)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))},onMouseMove:function(e){if(!U){ee(e,12)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0));return}!U||S||ee(e,12)||(M(void 0),A(void 0),Q(!1),D(!0),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onMouseLeave:function(e){y?.(e),S||(M(void 0),A(void 0),D(!0),Q(!1),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onDragEnter:function(e){!s||en(e)||(L.current+=1,_(!0),D(!1))},onDragLeave:function(e){!s||en(e)||(L.current=Math.max(0,L.current-1),0===L.current&&(_(!1),A(void 0)))},onDragOver:function(e){!s||en(e)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",_(!0),U?A(et(e)):A(0))},onDrop:function(t){if(!s||en(t))return;t.preventDefault(),t.stopPropagation();let n=P??et(t);L.current=0,_(!1),A(void 0),v?.({insertIndex:n,items:e,nativeEvent:t})},...b,children:[(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-header",className:(0,eI.cn)("mb-2 flex h-8 items-center gap-2 px-1 text-sm font-medium text-foreground transition-[opacity,transform] duration-200","down-left"===r&&"justify-end",U?"opacity-100":"translate-y-1 opacity-0"),children:[(0,ey.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:(0,ey.jsx)(Xq,{className:"size-3.5"})}),(0,ey.jsx)("span",{children:a??w.title}),(0,ey.jsx)("span",{className:"ml-auto tabular-nums text-muted-foreground",children:e.length})]}),(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-list",className:(0,eI.cn)("relative transition-[height] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]"),style:{height:Z},children:[e.length>0&&"down-left"===r?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-pivot","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute top-3 right-[34px] z-50 size-2.5 rounded-full bg-foreground shadow-sm transition-[opacity,transform] duration-200 dark:bg-background",U?"scale-75 opacity-0":"opacity-100")}):null,s&&R?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-external-ghost","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute right-0 z-[70] h-14 w-[88%] rounded-xl border bg-background shadow-md shadow-black/10","clipboard-stack-external-ghost"),children:[(0,ey.jsx)("span",{className:"absolute top-3 right-[34px] size-2 rounded-full bg-foreground dark:bg-background"}),(0,ey.jsx)("span",{className:"absolute top-4 left-3 h-2 w-24 rounded-full bg-foreground/18"}),(0,ey.jsx)("span",{className:"absolute top-8 left-3 h-1.5 w-14 rounded-full bg-foreground/10"})]}):null,0===e.length?(0,ey.jsx)("div",{className:"flex h-24 items-center justify-center rounded-xl border border-dashed bg-muted/35 text-sm text-muted-foreground",children:w.empty}):(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-frame",className:"relative h-full",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-scroll",ref:V,className:(0,eI.cn)("relative h-full overflow-x-visible",U&&Y?"clipboard-stack-scrollbar-hidden overflow-y-auto pt-2 pr-1 pb-3":"overflow-visible"),onScroll:e=>{let t=e.currentTarget;z({canScrollUp:t.scrollTop>1,canScrollDown:t.scrollTop+t.clientHeight<t.scrollHeight-1})},onDragOver:function(e){U&&S&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move")},onDrop:function(t){if(!U||!S||void 0===P)return;t.preventDefault(),t.stopPropagation(),F.current=!0;let n=e.findIndex(e=>e.id===S),r=e[n];if(n<0||!r)return;let a=e.filter(e=>e.id!==S),i=Math.max(0,Math.min(P>n?P-1:P,a.length));a.splice(i,0,r),A(void 0),M(void 0),i!==n&&g?.(a,{item:r,fromIndex:n,toIndex:i,items:a})},children:(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-content",className:"relative",style:{width:U&&Y?`calc(100% - ${J}px)`:void 0,marginLeft:U&&Y?`${J}px`:void 0,height:U&&Y?G+28:U?G:"100%"},children:[void 0!==P?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-insert-line","aria-hidden":"true",className:"pointer-events-none absolute right-0 left-0 z-[80] flex items-center",style:{top:44*P-2},children:[(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"}),(0,ey.jsx)("span",{className:"mx-1 size-1.5 rounded-full bg-foreground"}),(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"})]}):null,q.map((t,n)=>(0,ey.jsx)(XX,{item:t,index:n,count:q.length,expanded:U,active:U&&t.id===K,top:U?44*n:void 0,expansionDirection:r,labels:w,onHover:()=>M(t.id),onDuplicate:()=>{let n=e.findIndex(e=>e.id===t.id);n<0||m?.(e,{item:t,index:n,items:e})},onDragOver:e=>{if(U&&S&&S!==t.id){let t=e.currentTarget.getBoundingClientRect();A(e.clientY<t.top+t.height/2?n:n+1)}},onDragStart:e=>{N(e.item.id),M(void 0),F.current=!1,f?.(e)},onDragEnd:t=>{let n=t.nativeEvent.dataTransfer.dropEffect,r=t.item.id,a=e.findIndex(e=>e.id===r),i=c&&!F.current&&"none"!==n&&a>=0;if(N(void 0),A(void 0),M(void 0),F.current?F.current=!1:Q(!1),i){let n=e.filter(e=>e.id!==r);p?.(n,{item:t.item,index:a,items:n})}h?.(t)}},t.id))]})}),Y&&I.canScrollUp?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-top","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-8 bg-gradient-to-b from-background to-transparent"}):null,Y&&I.canScrollDown?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-bottom","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-[90] h-8 bg-gradient-to-t from-background to-transparent"}):null]})]})]})}function XX({item:e,index:t,count:n,expanded:r,active:a,top:i,expansionDirection:o,labels:l,onHover:s,onDuplicate:c,onDragOver:d,onDragStart:u,onDragEnd:f}){let h=Math.min(t,9),m="down-left"===o?-(4.5*h):[-4,2,-1,4][h]??0,p=r?a?n+20:n-t:n+t;return(0,ey.jsx)("article",{"data-slot":"clipboard-stack-card",draggable:!e.disabled,"aria-disabled":e.disabled,className:(0,eI.cn)("absolute right-0 min-h-16 w-full cursor-grab select-none rounded-xl border bg-background p-2.5 text-foreground shadow-sm shadow-black/5 outline-none transition-[top,transform,opacity,box-shadow,border-color] duration-300 ease-[cubic-bezier(.2,.8,.2,1)] active:cursor-grabbing","hover:border-foreground/35 hover:shadow-md hover:shadow-black/10 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40",r&&"min-h-0 overflow-hidden py-2 transition-[top,transform,max-height,opacity,box-shadow,border-color] duration-300",r&&!a&&"max-h-11",e.disabled&&"cursor-not-allowed opacity-50"),style:{top:r?i??44*t:"down-left"===o?0:9*h,zIndex:p,maxHeight:r&&a?e.expandedHeight??220:void 0,transformOrigin:"down-left"===o?"calc(100% - 34px) 14px":"100% 0",transform:r?a?"translate3d(-10px, -6px, 0) rotate(0deg)":"translate3d(0, 0, 0) rotate(0deg)":`translate3d(${"down-left"===o?0:4*h}px, 0, 0) rotate(${m}deg)`},tabIndex:e.disabled?-1:0,onMouseDown:function(t){1!==t.button||e.disabled||t.preventDefault()},onMouseEnter:s,onFocus:s,onAuxClick:function(t){1!==t.button||e.disabled||(t.preventDefault(),c?.())},onDragOver:d,onDragStart:function(t){for(let[n,r]of(t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",e.title),t.dataTransfer.setData("application/vnd.vantaloom.clip-id",e.id),Object.entries(e.dragData??{})))t.dataTransfer.setData(n,r);u?.({item:e,nativeEvent:t})},onDragEnd:function(t){f?.({item:e,nativeEvent:t})},children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-card-media",className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:e.icon??(0,ey.jsx)(Xq,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.meta}):null]}),e.description?(0,ey.jsx)("p",{className:(0,eI.cn)("mt-0.5 text-xs leading-5 text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-40 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.description}):null,e.content?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-2 text-xs text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-80 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.content}):null]}),(0,ey.jsx)("span",{"aria-label":l.dragHandle,className:"mt-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground",children:(0,ey.jsx)(fj,{className:"size-3.5"})})]})})}function XY({transfers:e}){let t=e.slice(0,10);if(0===t.length)return null;let n=t.map(e=>{var t,n,r;let a,i,o;return{id:e.id,title:(a="copy"===(t=e).mode?"复制":"移动",i=t.sources.length,o=t.sources[0],`${a} ${i>1?`${i} 项`:XJ(o?.path??"")}`),description:(n=e).message?n.message:`${n.sources[0]?.machineId??"local"} -> ${n.target.machineId}`,meta:function(e){switch(e.status){case"completed":return"完成";case"failed":return"失败";case"queued":return"排队";default:return`${Math.round(e.progress?.percent??0)}%`}}(e),icon:"completed"===(r=e).status?(0,ey.jsx)(eO,{className:"size-4"}):"failed"===r.status?(0,ey.jsx)(XW,{className:"size-4"}):"running"===r.status?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):"copy"===r.mode?(0,ey.jsx)(lU,{className:"size-4"}):(0,ey.jsx)(XU,{className:"size-4"}),expandedHeight:132,content:(0,ey.jsx)(XZ,{transfer:e})}});return(0,ey.jsx)("div",{className:"pointer-events-auto fixed top-4 right-4 z-50 w-80 max-w-[calc(100vw-2rem)] max-md:left-4 max-md:right-auto max-md:w-auto max-md:max-w-[16rem]",children:(0,ey.jsx)(XG,{items:n,title:"传输",labels:{empty:"暂无传输",dragHandle:"传输任务"},expansionDirection:"down-left",maxExpandedHeight:420})})}function XZ({transfer:e}){let t=Math.max(0,Math.min(100,e.progress?.percent??0));return(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-border",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width] duration-300",style:{width:`${t}%`}})}),(0,ey.jsxs)("div",{className:"grid gap-1 tabular-nums",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate",children:XJ(e.target.path)}),(0,ey.jsxs)("span",{children:[Math.round(t),"%"]})]}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"truncate",children:[XQ(e.progress.bytesDone)," /"," ",XQ(e.progress.bytesTotal)]}),(0,ey.jsxs)("span",{children:[e.progress.entriesDone,"/",e.progress.entriesTotal]})]}),e.progress.currentPath?(0,ey.jsx)("div",{className:"truncate text-muted-foreground",children:XJ(e.progress.currentPath)}):null]})]})}function XJ(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}function XQ(e){if(!e)return"0 B";let t=["B","KB","MB","GB","TB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||0===r?Math.round(n):n.toFixed(1)} ${t[r]}`}let X0=(0,ek.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function X1({windowLayout:e,roots:t,active:n,zIndex:r,boardSize:a,onActivate:i,onClose:o,onMinimize:l,onWindowChange:s,onNavigate:c,onRootsChange:d,onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onMoveItems:m}){return(0,ey.jsxs)("section",{className:(0,eI.cn)("absolute overflow-hidden rounded-xl border bg-card shadow-lg transition-[box-shadow,border-color] duration-150","vtl-file-manager-window",n&&"border-foreground shadow-xl"),style:{left:e.x,top:e.y,width:e.w,height:e.h,zIndex:r},onPointerDown:i,children:[(0,ey.jsxs)("div",{className:"grid h-9 cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b bg-muted/35 px-2 active:cursor-grabbing",onPointerDown:function(t){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function a(t){let a=Math.max(0,e.x+t.clientX-n),i=Math.max(0,e.y+t.clientY-r);s({...e,x:a,y:i})}window.addEventListener("pointermove",a),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",e)})},children:[(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"关闭窗口",onPointerDown:e=>e.stopPropagation(),onClick:o,children:(0,ey.jsx)(fg.XIcon,{})}),(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"缩小到剪切板",onPointerDown:e=>e.stopPropagation(),onClick:l,children:(0,ey.jsx)(X0,{})})]}),(0,ey.jsx)("div",{className:"truncate text-center ui-text-control",children:e.title}),(0,ey.jsx)("div",{className:"w-14"})]}),(0,ey.jsx)(wK,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,draggableItems:!0,onNavigate:c,onRootsChange:e=>d(e),onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>m({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"vtl-file-window-explorer min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0",style:{height:"calc(100% - 2.25rem)",minHeight:0}}),(0,ey.jsx)("button",{type:"button","aria-label":"调整窗口大小",className:"absolute right-0 bottom-0 size-5 cursor-nwse-resize rounded-tl-md border-t border-l bg-background/80",onPointerDown:function(t){t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function o(t){let i=Math.max(420,Math.min(Math.max(420,a.width-e.x),e.w+t.clientX-n)),o=Math.max(320,e.h+t.clientY-r);s({...e,w:i,h:o})}window.addEventListener("pointermove",o),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",e)})}})]})}function X2({clipboardItems:e=[],onClipboardItemsChange:t,className:n,minBoardHeight:r=520,actionsPlacement:a="container"}){let[i,o]=XD(),[l,s]=ew.useState([]),[c,d]=ew.useState(XL),[u,f]=ew.useState(XL[0]?.id),[h,m]=ew.useState([]),[p,g]=ew.useState(!1),[v,x]=ew.useState(!1),[y,b]=ew.useState(),w=ew.useRef(XL.length),j=ew.useRef(!1),k=ew.useRef(new Set),S=ew.useCallback(async(e,t,n)=>{let r=await uK(e,n);s(n=>{var a;return a={...r,root:{...r.root,id:t,machineId:e}},n.map(e=>e.id!==a.root.id?e:XB(e.path,a.path)?{...e,children:XH(a.items)}:{...e,children:function(e,t,n,r,a){let i=function(e,t,n){let r=XV(e,n),a=XV(t,n);if(r===a)return[];let i=r.endsWith("/")?r:`${r}/`;return a.startsWith(i)?a.slice(i.length).split("/").filter(Boolean):[]}(t,n,r);if(0===i.length)return XH(a);let o="windows"===r?"\\":"/";return function e(t,n,r){let l=i[r];if(!l)return XH(a);let s=n===o?`${o}${l}`:`${n.replace(/[\\/]+$/,"")}${o}${l}`,c=t.findIndex(e=>XB(e.path,s)),d=t[c],u={...d??{id:`synthetic-${s}`,name:l,kind:"folder",path:s,children:[]},kind:"folder",children:e(d?.children??[],s,r+1)};if(c<0)return[...t,u];let f=[...t];return f[c]=u,f}(e,t,0)}(e.children,e.path,a.path,e.platform,a.items)})})},[]),N=ew.useCallback(async()=>{let e=X3((await u0()).transfers);return m(e),e},[]),C=ew.useCallback(e=>{m(t=>X3([e,...t.filter(t=>t.id!==e.id)]))},[]),M=ew.useCallback(e=>{uQ({mode:"move",sources:e.sources.map(e=>({machineId:e.machineId,path:e.path})),target:{machineId:e.target.machineId,path:e.target.path}}).then(C).catch(()=>{})},[C]),E=ew.useCallback(()=>{for(let e of c)S(e.machineId,e.rootId,e.path)},[S,c]);function O(e,t){d(n=>n.map(n=>n.id===e?t(n):n))}function P(e){let t=l[0];if(!t&&!e?.rootId)return;w.current+=1;let n=`files-window-${w.current}`,r=i.current?.getBoundingClientRect(),a=r?.width??o.width,s=r?.height??o.height,c=e?.w??680,u=e?.h??460,h=Math.max(0,(a-c)/2),m=Math.max(0,(s-u)/2),p={id:n,title:e?.title??X$(t?.name??"local",t?.path??""),machineId:e?.machineId??t?.machineId??"local",rootId:e?.rootId??t?.id??"local",path:e?.path??t?.path??"",x:e?.x??h+12*w.current,y:e?.y??m+12*w.current,w:c,h:u};d(e=>[...e,p]),f(n),S(p.machineId,p.rootId,p.path)}ew.useEffect(()=>{let e=!0;return(async function(){let t=await uq();if(e&&(s(t.roots),!j.current&&t.roots[0])){j.current=!0;let e=function(e,t=0){return{id:`files-${e.id.replace(/[^a-z0-9_-]/gi,"-")}-${t}`,title:X$(e.name,e.path),machineId:e.machineId,rootId:e.id,path:e.path,x:28+24*t,y:28+24*t,w:720,h:480}}(t.roots[0]);d([e]),f(e.id),S(e.machineId,e.rootId,e.path)}})().catch(()=>{}),N().catch(()=>{}),()=>{e=!1}},[S,N]),ew.useEffect(()=>{if(!h.some(e=>"pending"===e.status||"running"===e.status||"queued"===e.status))return;let e=window.setInterval(async()=>{let e=(await N().catch(()=>h)).filter(e=>"completed"===e.status&&!k.current.has(e.id));if(e.length>0){for(let t of e)k.current.add(t.id);E()}},1e3);return()=>window.clearInterval(e)},[E,N,h]);let A=sb(),I=c.find(e=>e.id===u);function z(e){return{onNavigate:({rootId:t,path:n})=>{let r=l.find(e=>e.id===t),a=r?.machineId??e.machineId;O(e.id,e=>({...e,machineId:a,rootId:t,path:n,title:X$(r?.name??a,n)})),S(a,t,n)},onRootsChange:s,onCreateFolder:(t,n)=>{uY({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onRenameItem:(t,n)=>{uZ({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onDeleteItems:t=>{uJ({machineId:e.machineId,paths:t.map(e=>e.path)}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=XF(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}}}return A?(0,ey.jsxs)("div",{className:(0,eI.cn)("flex h-full min-h-0 w-full flex-col",n),children:[c.length>1?(0,ey.jsx)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:c.map(e=>(0,ey.jsx)("button",{type:"button",className:(0,eI.cn)("shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",e.id===u?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),onClick:()=>f(e.id),children:e.title},e.id))}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:I?(0,ey.jsx)(X5,{windowLayout:I,roots:l,...z(I)}):(0,ey.jsx)("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"暂无打开的文件窗口"})}),(0,ey.jsx)(XY,{transfers:h}),(0,ey.jsx)(X_,{open:p,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(X4,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]}):(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative h-full min-h-0 w-full overflow-hidden rounded-[inherit]",n),onDragOver:e=>{Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.file-window")&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.file-window");if(t)try{let n=JSON.parse(t),r=i.current?.getBoundingClientRect();e.preventDefault(),e.stopPropagation(),P({...n,x:r?e.clientX-r.left-160:n.x,y:r?e.clientY-r.top-24:n.y})}catch{return}},children:[(0,ey.jsx)("div",{className:"relative h-full min-h-0",style:{minHeight:Math.max(r,o.height-48)},children:c.map((n,r)=>(0,ey.jsx)(X1,{windowLayout:n,roots:l,active:u===n.id,zIndex:20+r+20*(u===n.id),boardSize:o,onActivate:()=>f(n.id),onClose:()=>d(e=>e.filter(e=>e.id!==n.id)),onMinimize:()=>{t?.([{id:`clip-${n.id}`,title:n.title,description:"文件管理窗口",meta:`${Math.round(n.w)}x${Math.round(n.h)}`,payloads:{"application/vnd.vantaloom.file-window":{...n}},dragData:{"application/vnd.vantaloom.clip-kind":"file-window","application/vnd.vantaloom.file-window":JSON.stringify(n)}},...e.filter(e=>e.id!==`clip-${n.id}`)]),d(e=>e.filter(e=>e.id!==n.id))},onWindowChange:e=>O(n.id,()=>e),...z(n),onNavigate:({rootId:e,path:t})=>{let r=l.find(t=>t.id===e),a=r?.machineId??n.machineId;O(n.id,n=>({...n,machineId:a,rootId:e,path:t,title:X$(r?.name??a,t)})),S(a,e,t)},onRootsChange:s,onCreateFolder:(e,t)=>{uY({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onRenameItem:(e,t)=>{uZ({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onDeleteItems:e=>{uJ({machineId:n.machineId,paths:e.map(e=>e.path)}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=XF(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}},n.id))}),(0,ey.jsx)(XY,{transfers:h}),(0,ey.jsx)(X_,{open:p,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(X4,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]})}function X5({windowLayout:e,roots:t,onNavigate:n,onRootsChange:r,onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onMoveItems:l}){return(0,ey.jsx)(wK,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,onNavigate:n,onRootsChange:e=>r(e),onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>l({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"h-full min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0"})}function X4({move:e,onCancel:t,onConfirm:n}){var r;let a=e?.sources??[],i=Math.max(0,a.length-4);return(0,ey.jsx)(d4,{open:void 0!==e,onOpenChange:e=>{e||t()},children:(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:"确认移动"}),(0,ey.jsx)(ug,{children:e?`将 ${1===(r=a).length?r[0]?X6(r[0]):"0 项":`${r.length} 项`} 移动到 ${X6(e.target)}`:""})]}),e?(0,ey.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-muted/20 p-3 ui-text-body",children:[(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"移动内容"}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[a.slice(0,4).map(e=>(0,ey.jsx)("span",{className:"truncate",children:X6(e)},`${e.machineId}:${e.path}`)),i>0?(0,ey.jsxs)("span",{className:"text-muted-foreground",children:["另有 ",i," 项"]}):null]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"目标位置"}),(0,ey.jsx)("span",{className:"truncate",children:X6(e.target)})]})]}):null,(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{children:"取消"}),(0,ey.jsx)(uv,{onClick:()=>{e&&n(e)},children:"确认移动"})]})]})})}function X3(e){return e.slice(0,10)}function X6(e){let t=e.path.replace(/\\/g,"/");return`${e.machineId} / ${e.name||t}`}function X8({className:e}){return(0,ey.jsx)(X2,{className:(0,eI.cn)("h-full min-h-0 w-full rounded-[inherit] border-0 shadow-none",e),minBoardHeight:360,actionsPlacement:"container"})}var X7=ew;function X9(){return(X9=Object.assign.bind()).apply(null,arguments)}var Ye=e=>{var{cx:t,cy:n,r,className:a}=e,i=(0,jL.clsx)("recharts-dot",a);return kp(t)&&kp(n)&&kp(r)?ew.createElement("circle",X9({},IF(e),zu(e),{className:i,cx:t,cy:n,r:r})):null},Yt=["points"];function Yn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yn(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ya(){return(Ya=Object.assign.bind()).apply(null,arguments)}function Yi(e){var{option:t,dotProps:n,className:r}=e;if((0,ew.isValidElement)(t))return(0,ew.cloneElement)(t,n);if("function"==typeof t)return t(n);var a=(0,jL.clsx)(r,"boolean"!=typeof t?t.className:""),i=null!=n?n:{},{points:o}=i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(i,Yt);return ew.createElement(Ye,Ya({},l,{className:a}))}function Yo(e){var{points:t,dot:n,className:r,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:s,zIndex:c=CX.scatter}=e;if(null==t||!n&&1!==t.length)return null;var d=z9(n),u=null==n?null:(0,ew.isValidElement)(n)?IV(n.props):"object"!=typeof n||Array.isArray(n)?null:IV(n),f=t.map((e,r)=>{var l,s,c=Yr(Yr(Yr({r:3},o),u),{},{index:r,cx:null!=(l=e.x)?l:void 0,cy:null!=(s=e.y)?s:void 0,dataKey:i,value:e.value,payload:e.payload,points:t});return ew.createElement(Yi,{key:"dot-".concat(r),option:n,dotProps:c,className:a})}),h={};return l&&null!=s&&(h.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(s,")")),ew.createElement(_V,{zIndex:c},ew.createElement(IW,Ya({className:r},h),f))}function Yl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ys(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yl(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Yc=e=>{var t,{point:n,childIndex:r,mainColor:a,activeDot:i,dataKey:o,clipPath:l}=e;if(!1===i||null==n.x||null==n.y)return null;var s=Ys(Ys(Ys({},{index:r,dataKey:o,cx:n.x,cy:n.y,r:4,fill:null!=a?a:"none",strokeWidth:2,stroke:"#fff",payload:n.payload,value:n.value}),IB(i)),zu(i));return t=(0,ew.isValidElement)(i)?(0,ew.cloneElement)(i,s):"function"==typeof i?i(s):ew.createElement(Ye,s),ew.createElement(IW,{className:"recharts-active-dot",clipPath:l},t)};function Yd(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:a,clipPath:i,zIndex:o=CX.activeDot}=e,l=Se(R7),s=Se(_l);if(null==t||null==s)return null;var c=t.find(e=>s.includes(e.payload));return null==c?null:ew.createElement(_V,{zIndex:o},ew.createElement(Yc,{point:c,childIndex:Number(l),mainColor:n,dataKey:a,activeDot:r,clipPath:i}))}function Yu(e,t){var n,r,a=Se(t=>P_(t,e)),i=Se(e=>PF(e,t)),o=null!=(n=null==a?void 0:a.allowDataOverflow)?n:PD.allowDataOverflow,l=null!=(r=null==i?void 0:i.allowDataOverflow)?r:PL.allowDataOverflow;return{needClip:o||l,needClipX:o,needClipY:l}}function Yf(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,a=Se(F2),{needClipX:i,needClipY:o,needClip:l}=Yu(t,n);if(!l||!a)return null;var{x:s,y:c,width:d,height:u}=a;return ew.createElement("clipPath",{id:"clipPath-".concat(r)},ew.createElement("rect",{x:i?s:s-d/2,y:o?c:c-u/2,width:i?d:2*d,height:o?u:2*u}))}function Yh(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.xAxisId)?n:0}function Ym(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.yAxisId)?n:0}var Yp=(e,t,n)=>Iu(e,"xAxis",Yh(e,t),n),Yg=(e,t,n)=>Id(e,"xAxis",Yh(e,t),n),Yv=(e,t,n)=>Iu(e,"yAxis",Ym(e,t),n),Yx=(e,t,n)=>Id(e,"yAxis",Ym(e,t),n),Yy=j2([Cb,Yp,Yv,Yg,Yx],(e,t,n,r,a)=>kI(e,"xAxis")?kB(t,r,!1):kB(n,a,!1)),Yb=j2([PK,(e,t)=>t],(e,t)=>e.filter(e=>"area"===e.type).find(e=>e.id===t)),Yw=e=>kI(Cb(e),"xAxis")?"yAxis":"xAxis",Yj=j2([Yb,(e,t,n)=>As(e,Yw(e),"yAxis"===Yw(e)?Ym(e,t):Yh(e,t),n)],(e,t)=>{if(null!=e&&null!=t){var n,{stackId:r}=e,a=Mi(e);if(null!=r&&null!=a){var i=null==(n=t[r])?void 0:n.stackedData,o=null==i?void 0:i.find(e=>e.key===a);if(null!=o)return o.map(e=>[e[0],e[1]])}}}),Yk=j2([Cb,Yp,Yv,Yg,Yx,Yj,j8,Yy,Yb,e=>e.rootProps.baseValue],(e,t,n,r,a,i,o,l,s,c)=>{var d,{chartData:u,dataStartIndex:f,dataEndIndex:h}=o;if(null!=s&&("horizontal"===e||"vertical"===e)&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=l){var{data:m}=s;if(null!=(d=m&&m.length>0?m:null==u?void 0:u.slice(f,h+1)))return function(e){var t,{areaSettings:{connectNulls:n,baseValue:r,dataKey:a},stackedData:i,layout:o,chartBaseValue:l,xAxis:s,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:h,bandSize:m}=e,p=i&&i.length,g=((e,t,n,r,a)=>{var i=null!=n?n:t;if(kp(i))return i;var o="horizontal"===e?a:r,l=o.scale.domain();if("number"===o.type){var s=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return"dataMin"===i?c:"dataMax"===i||s<0?s:Math.max(Math.min(l[0],l[1]),0)}return"dataMin"===i?l[0]:"dataMax"===i?l[1]:l[0]})(o,l,r,s,c),v="horizontal"===o,x=!1,y=d.map((e,t)=>{if(p)d=i[u+t];else{var r,o,l,d,y,b=kA(e,a);Array.isArray(b)?(d=b,x=!0):d=[g,b]}var w=null!=(r=null==(o=d)?void 0:o[1])?r:null,j=null==w||p&&!n&&null==kA(e,a);return v?{x:k_({axis:s,ticks:f,bandSize:m,entry:e,index:t}),y:j?null:null!=(y=c.scale.map(w))?y:null,value:d,payload:e}:{x:j?null:null!=(l=s.scale.map(w))?l:null,y:k_({axis:c,ticks:h,bandSize:m,entry:e,index:t}),value:d,payload:e}});return t=p||x?y.map(e=>{var t,n,r=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:null!=r&&null!=e.y&&null!=(n=c.scale.map(r))?n:null,payload:e.payload}:{x:null!=r&&null!=(t=s.scale.map(r))?t:null,y:e.y,payload:e.payload}}):v?c.scale.map(g):s.scale.map(g),{points:y,baseLine:null!=t?t:0,isRange:x}}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataStartIndex:f,areaSettings:s,stackedData:i,displayedData:d,chartBaseValue:c,bandSize:l})}});function YS(e){var t=IB(e);if(null!=t){var{r:n,strokeWidth:r}=t,a=Number(n),i=Number(r);return(Number.isNaN(a)||a<0)&&(a=3),(Number.isNaN(i)||i<0)&&(i=2),{r:a,strokeWidth:i}}return{r:3,strokeWidth:2}}var YN=["id"],YC=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function YM(){return(YM=Object.assign.bind()).apply(null,arguments)}function YE(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function YO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YP(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YO(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YO(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YA(e,t){return e&&"none"!==e?e:t}var YI=X7.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kN,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kH(o,t),hide:l,type:c,color:YA(r,i),unit:s,graphicalItemId:d}};return X7.createElement(Ra,{tooltipEntrySettings:u})});function Yz(e){var{clipPathId:t,points:n,props:r}=e,{needClip:a,dot:i,dataKey:o}=r,l=IF(r);return X7.createElement(Yo,{points:n,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function YT(e){var{showLabels:t,children:n,points:r}=e,a=r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return YP(YP({},r),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:r,fill:void 0})});return X7.createElement(Ln,{value:t?a:void 0},n)}function YD(e){var{points:t,baseLine:n,needClip:r,clipPathId:a,props:i}=e,{layout:o,type:l,stroke:s,connectNulls:c,isRange:d}=i,{id:u}=i,f=YE(i,YN),h=IF(f),m=IV(f);return X7.createElement(X7.Fragment,null,(null==t?void 0:t.length)>1&&X7.createElement(IW,{clipPath:r?"url(#clipPath-".concat(a,")"):void 0},X7.createElement(zw,YM({},m,{id:u,points:t,connectNulls:c,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),"none"!==s&&X7.createElement(zw,YM({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:t})),"none"!==s&&d&&Array.isArray(n)&&X7.createElement(zw,YM({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:n}))),X7.createElement(Yz,{points:t,props:f,clipPathId:a}))}function YR(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.y,s=null==(n=i[i.length-1])?void 0:n.y;if(!kM(l)||!kM(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.x||0));return(kp(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.x||0),d)),kp(d))?X7.createElement("rect",{x:0,y:l<s?l:l-c,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(c)}):null}function Y_(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.x,s=null==(n=i[i.length-1])?void 0:n.x;if(!kM(l)||!kM(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.y||0));return(kp(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.y||0),d)),kp(d))?X7.createElement("rect",{x:l<s?l:l-c,y:0,width:c,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function YL(e){var{alpha:t,layout:n,points:r,baseLine:a,strokeWidth:i}=e;return"vertical"===n?X7.createElement(YR,{alpha:t,points:r,baseLine:a,strokeWidth:i}):X7.createElement(Y_,{alpha:t,points:r,baseLine:a,strokeWidth:i})}function Y$(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i}=e,{points:o,baseLine:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,onAnimationStart:f,onAnimationEnd:h}=r,m=Tk((0,X7.useMemo)(()=>({points:o,baseLine:l}),[o,l]),"recharts-area-"),p=Cw(),[g,v]=(0,X7.useState)(!1),x=(0,X7.useCallback)(()=>{"function"==typeof h&&h(),v(!1)},[h]),y=(0,X7.useCallback)(()=>{"function"==typeof f&&f(),v(!0)},[f]);if(null==p)return null;var b=a.current,w=i.current;return X7.createElement(YT,{showLabels:!g,points:o},r.children,X7.createElement(Tj,{animationId:m,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:x,onAnimationStart:y,key:m},e=>{if(b){var c,d=b.length/o.length,u=1===e?o:o.map((t,n)=>{var r=Math.floor(n*d);if(b[r]){var a=b[r];return YP(YP({},t),{},{x:kw(a.x,t.x,e),y:kw(a.y,t.y,e)})}return t});if(kp(l))c=kw(w,l,e);else c=null==l||kh(l)?kw(w,0,e):l.map((t,n)=>{var r=Math.floor(n*d);if(Array.isArray(w)&&w[r]){var a=w[r];return YP(YP({},t),{},{x:kw(a.x,t.x,e),y:kw(a.y,t.y,e)})}return t});return e>0&&(a.current=u,i.current=c),X7.createElement(YD,{points:u,baseLine:c,needClip:t,clipPathId:n,props:r})}return e>0&&(a.current=o,i.current=l),X7.createElement(IW,null,s&&X7.createElement("defs",null,X7.createElement("clipPath",{id:"animationClipPath-".concat(n)},X7.createElement(YL,{alpha:e,points:o,baseLine:l,layout:p,strokeWidth:r.strokeWidth}))),X7.createElement(IW,{clipPath:"url(#animationClipPath-".concat(n,")")},X7.createElement(YD,{points:o,baseLine:l,needClip:t,clipPathId:n,props:r})))}),X7.createElement(Lo,{label:r.label}))}function YF(e){var{needClip:t,clipPathId:n,props:r}=e,a=(0,X7.useRef)(null),i=(0,X7.useRef)();return X7.createElement(Y$,{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i})}class YB extends X7.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:a,left:i,needClip:o,xAxisId:l,yAxisId:s,width:c,height:d,id:u,baseLine:f,zIndex:h}=this.props;if(e)return null;var m=(0,jL.clsx)("recharts-area",r),{r:p,strokeWidth:g}=YS(t),v=z9(t),x=2*p+g,y=o?"url(#clipPath-".concat(v?"":"dots-").concat(u,")"):void 0;return X7.createElement(_V,{zIndex:h},X7.createElement(IW,{className:m},o&&X7.createElement("defs",null,X7.createElement(Yf,{clipPathId:u,xAxisId:l,yAxisId:s}),!v&&X7.createElement("clipPath",{id:"clipPath-dots-".concat(u)},X7.createElement("rect",{x:i-x/2,y:a-x/2,width:c+x,height:d+x}))),X7.createElement(YF,{needClip:o,clipPathId:u,props:this.props})),X7.createElement(Yd,{points:n,mainColor:YA(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}),this.props.isRange&&Array.isArray(f)&&X7.createElement(Yd,{points:f,mainColor:YA(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}))}}var YV={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:CX.area};function YH(e){var t,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,connectNulls:o,dot:l,fill:s,fillOpacity:c,hide:d,isAnimationActive:u,legendType:f,stroke:h,xAxisId:m,yAxisId:p}=e,g=YE(e,YC),v=Se(Cb),x=Se(CF),{needClip:y}=Yu(m,p),b=N3(),{points:w,isRange:j,baseLine:k}=null!=(t=Se(t=>Yk(t,e.id,b)))?t:{},S=Se(F2);if("horizontal"!==v&&"vertical"!==v||null==S||"AreaChart"!==x&&"ComposedChart"!==x)return null;var{height:N,width:C,x:M,y:E}=S;return w&&w.length?X7.createElement(YB,YM({},g,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:s,fillOpacity:c,height:N,hide:d,layout:v,isAnimationActive:u,isRange:j,legendType:f,needClip:y,points:w,stroke:h,width:C,left:M,top:E,xAxisId:m,yAxisId:p})):null}var YU=X7.memo(function(e){var t=zB(e,YV),n=N3();return X7.createElement(_y,{id:t.id,type:"area"},e=>X7.createElement(X7.Fragment,null,X7.createElement(_p,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,fill:a,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:YA(r,a),value:kH(n,t),payload:e}]})(t)}),X7.createElement(YI,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),X7.createElement(_E,{type:"area",id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:kR(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),X7.createElement(YH,YM({},t,{id:e}))))},Fb);function YW(){return(YW=Object.assign.bind()).apply(null,arguments)}function Yq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}YU.displayName="Area";var YK=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yq(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Fs),YG=(0,ew.forwardRef)(function(e,t){var n,r=zB(e.categoricalChartProps,YK),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:s}=e;return ew.createElement(Fv,{preloadedState:{options:{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0}},reduxStoreName:null!=(n=s.id)?n:a},ew.createElement(Fx,{chartData:s.data}),ew.createElement(Fw,{layout:r.layout,margin:r.margin}),ew.createElement(Fk,{throttleDelay:r.throttleDelay,throttledEvents:r.throttledEvents}),ew.createElement(Fj,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),ew.createElement(F6,YW({},r,{ref:t})))}),YX=["axis"],YY=(0,ew.forwardRef)((e,t)=>ew.createElement(YG,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:YX,tooltipPayloadSearcher:LC,categoricalChartProps:e,ref:t})),YZ=function(e){var{width:t,height:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(r%180+180)%180*Math.PI/180,i=Math.atan(n/t);return Math.abs(a>i&&a<Math.PI-i?n/Math.sin(a):t/Math.cos(a))};function YJ(e,t){if(t<1)return[];if(1===t)return e;for(var n=[],r=0;r<e.length;r+=t){var a=e[r];void 0!==a&&n.push(a)}return n}function YQ(e,t,n,r,a){if(e*t<e*r||e*t>e*a)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-a)<=0}function Y0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y1(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y0(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Y2(e,t,n){var r,{tick:a,ticks:i,viewBox:o,minTickGap:l,orientation:s,interval:c,tickFormatter:d,unit:u,angle:f}=e;if(!i||!i.length||!a)return[];if(kp(c)||zj.isSsr)return null!=(r=YJ(i,(kp(c)?c:0)+1))?r:[];var h="top"===s||"bottom"===s?"width":"height",m=u&&"width"===h?zO(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},p=(e,r)=>{var a,i="function"==typeof d?d(e.value,r):e.value;return"width"===h?(a=zO(i,{fontSize:t,letterSpacing:n}),YZ({width:a.width+m.width,height:a.height+m.height},f)):zO(i,{fontSize:t,letterSpacing:n})[h]},g=i[0],v=i[1],x=i.length>=2&&null!=g&&null!=v?kf(v.coordinate-g.coordinate):1,y=function(e,t,n){var r="width"===n,{x:a,y:i,width:o,height:l}=e;return 1===t?{start:r?a:i,end:r?a+o:i+l}:{start:r?a+o:i+l,end:r?a:i}}(o,x,h);return"equidistantPreserveStart"===c?function(e,t,n,r,a){for(var i,o=(r||[]).slice(),{start:l,end:s}=t,c=0,d=1,u=l;d<=o.length;)if(i=function(){var t,i=null==r?void 0:r[c];if(void 0===i)return{v:YJ(r,d)};var o=c,f=()=>(void 0===t&&(t=n(i,o)),t),h=i.coordinate,m=0===c||YQ(e,h,f,u,s);m||(c=0,u=l,d+=1),m&&(u=h+e*(f()/2+a),c+=d)}())return i.v;return[]}(x,y,p,i,l):"equidistantPreserveEnd"===c?function(e,t,n,r,a){var i=(r||[]).slice().length;if(0===i)return[];for(var{start:o,end:l}=t,s=1;s<=i;s++){for(var c,d=(i-1)%s,u=o,f=!0,h=d;h<i&&(0===(c=function(){var t,i=r[h];if(null==i)return 0;var o=h,s=()=>(void 0===t&&(t=n(i,o)),t),c=i.coordinate,m=h===d||YQ(e,c,s,u,l);if(!m)return f=!1,1;m&&(u=c+e*(s()/2+a))}())||1!==c);h+=s);if(f){for(var m=[],p=d;p<i;p+=s){var g=r[p];null!=g&&m.push(g)}return m}}return[]}(x,y,p,i,l):("preserveStart"===c||"preserveStartEnd"===c?function(e,t,n,r,a,i){var o=(r||[]).slice(),l=o.length,{start:s,end:c}=t;if(i){var d=r[l-1];if(null!=d){var u=n(d,l-1),f=e*(d.coordinate+e*u/2-c);o[l-1]=d=Y1(Y1({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate}),null!=d.tickCoord&&YQ(e,d.tickCoord,()=>u,s,c)&&(c=d.tickCoord-e*(u/2+a),o[l-1]=Y1(Y1({},d),{},{isShow:!0}))}}for(var h=i?l-1:l,m=function(t){var r,i=o[t];if(null==i)return 1;var l=i,d=()=>(void 0===r&&(r=n(i,t)),r);if(0===t){var u=e*(l.coordinate-e*d()/2-s);o[t]=l=Y1(Y1({},l),{},{tickCoord:u<0?l.coordinate-u*e:l.coordinate})}else o[t]=l=Y1(Y1({},l),{},{tickCoord:l.coordinate});null!=l.tickCoord&&YQ(e,l.tickCoord,d,s,c)&&(s=l.tickCoord+e*(d()/2+a),o[t]=Y1(Y1({},l),{},{isShow:!0}))},p=0;p<h;p++)if(m(p))continue;return o}(x,y,p,i,l,"preserveStartEnd"===c):function(e,t,n,r,a){for(var i=(r||[]).slice(),o=i.length,{start:l}=t,{end:s}=t,c=function(t){var r,c=i[t];if(null==c)return 1;var d=c,u=()=>(void 0===r&&(r=n(c,t)),r);if(t===o-1){var f=e*(d.coordinate+e*u()/2-s);i[t]=d=Y1(Y1({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate})}else i[t]=d=Y1(Y1({},d),{},{tickCoord:d.coordinate});null!=d.tickCoord&&YQ(e,d.tickCoord,u,l,s)&&(s=d.tickCoord-e*(u()/2+a),i[t]=Y1(Y1({},d),{},{isShow:!0}))},d=o-1;d>=0;d--)if(c(d))continue;return i}(x,y,p,i,l)).filter(e=>e.isShow)}var Y5=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function Y4(){return(Y4=Object.assign.bind()).apply(null,arguments)}function Y3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y6(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y3(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y3(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Y8={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:CX.axis};function Y7(e){var{x:t,y:n,width:r,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:s}=e;if(!l)return null;var c=Y6(Y6(Y6({},s),IF(l)),{},{fill:"none"});if("top"===i||"bottom"===i){var d=+("top"===i&&!o||"bottom"===i&&o);c=Y6(Y6({},c),{},{x1:t,y1:n+d*a,x2:t+r,y2:n+d*a})}else{var u=+("left"===i&&!o||"right"===i&&o);c=Y6(Y6({},c),{},{x1:t+u*r,y1:n,x2:t+u*r,y2:n+a})}return ew.createElement("line",Y4({},c,{className:(0,jL.clsx)("recharts-cartesian-axis-line",(0,j_.default)(l,"className"))}))}function Y9(e){var t,{option:n,tickProps:r,value:a}=e,i=(0,jL.clsx)(r.className,"recharts-cartesian-axis-tick-value");if(ew.isValidElement(n))t=ew.cloneElement(n,Y6(Y6({},r),{},{className:i}));else if("function"==typeof n)t=n(Y6(Y6({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";"boolean"!=typeof n&&(o=(0,jL.clsx)(o,Ll(n))),t=ew.createElement(z1,Y4({},r,{className:o}),a)}return t}function Ze(e){var{ticks:t,axisType:n,axisId:r}=e,a=k6();return(0,ew.useEffect)(()=>null==r||null==n?kN:(a(Fh({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{a(Fm({axisId:r,axisType:n}))}),[a,t,r,n]),null}var Zt=(0,ew.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:s,tickTextProps:c,orientation:d,mirror:u,x:f,y:h,width:m,height:p,tickSize:g,tickMargin:v,fontSize:x,letterSpacing:y,getTicksConfig:b,events:w,axisType:j,axisId:k}=e,S=Y2(Y6(Y6({},b),{},{ticks:n}),x,y),N=IF(b),C=IB(r),M=zG(N.textAnchor)?N.textAnchor:function(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}(d,u),E=function(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}(d,u),O={};"object"==typeof a&&(O=a);var P=Y6(Y6({},N),{},{fill:"none"},O),A=S.map(e=>Y6({entry:e},function(e,t,n,r,a,i,o,l,s){var c,d,u,f,h,m,p=l?-1:1,g=e.tickSize||o,v=kp(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":c=d=e.coordinate,m=(u=(f=n+!l*a)-p*g)-p*s,h=v;break;case"left":u=f=e.coordinate,h=(c=(d=t+!l*r)-p*g)-p*s,m=v;break;case"right":u=f=e.coordinate,h=(c=(d=t+l*r)+p*g)+p*s,m=v;break;default:c=d=e.coordinate,m=(u=(f=n+l*a)+p*g)+p*s,h=v}return{line:{x1:c,y1:u,x2:d,y2:f},tick:{x:h,y:m}}}(e,f,h,m,p,d,g,u,v))),I=A.map(e=>{var{entry:t,line:n}=e;return ew.createElement(IW,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(t.value,"-").concat(t.coordinate,"-").concat(t.tickCoord)},a&&ew.createElement("line",Y4({},P,n,{className:(0,jL.clsx)("recharts-cartesian-axis-tick-line",(0,j_.default)(a,"className"))})))}),z=A.map((e,t)=>{var n,a,{entry:d,tick:u}=e,f=Y6(Y6(Y6(Y6({verticalAnchor:E},N),{},{textAnchor:M,stroke:"none",fill:i},u),{},{index:t,payload:d,visibleTicksCount:S.length,tickFormatter:o,padding:s},c),{},{angle:null!=(n=null!=(a=null==c?void 0:c.angle)?a:N.angle)?n:0}),h=Y6(Y6({},f),C);return ew.createElement(IW,Y4({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(d.value,"-").concat(d.coordinate,"-").concat(d.tickCoord)},zf(w,d,t)),r&&ew.createElement(Y9,{option:r,tickProps:h,value:"".concat("function"==typeof o?o(d.value,t):d.value).concat(l||"")}))});return ew.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ew.createElement(Ze,{ticks:S,axisId:k,axisType:j}),z.length>0&&ew.createElement(_V,{zIndex:CX.label},ew.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:t},z)),I.length>0&&ew.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},I))}),Zn=(0,ew.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:a,className:i,hide:o,ticks:l,axisType:s,axisId:c}=e,d=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,Y5),[u,f]=(0,ew.useState)(""),[h,m]=(0,ew.useState)(""),p=(0,ew.useRef)(null);(0,ew.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>{var t;return(e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var l=n?n.getBoundingClientRect().width:0;return Math.round(o+(a+i)+l+(n?r:0))}return 0})({ticks:p.current,label:null==(t=e.labelRef)?void 0:t.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=(0,ew.useCallback)(e=>{if(e){var t=e.getElementsByClassName("recharts-cartesian-axis-tick-value");p.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),a=r.fontSize,i=r.letterSpacing;(a!==u||i!==h)&&(f(a),m(i))}}},[u,h]);return o||null!=r&&r<=0||null!=a&&a<=0?null:ew.createElement(_V,{zIndex:e.zIndex},ew.createElement(IW,{className:(0,jL.clsx)("recharts-cartesian-axis",i)},ew.createElement(Y7,{x:e.x,y:e.y,width:r,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:IF(e)}),ew.createElement(Zt,{ref:g,axisType:s,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),ew.createElement(_J,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},ew.createElement(_3,{label:e.label,labelRef:e.labelRef}),e.children)))}),Zr=ew.forwardRef((e,t)=>{var n=zB(e,Y8);return ew.createElement(Zn,Y4({},n,{ref:t}))});Zr.displayName="CartesianAxis";var Za=["x1","y1","x2","y2","key"],Zi=["offset"],Zo=["xAxisId","yAxisId"],Zl=["xAxisId","yAxisId"];function Zs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zs(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zd(){return(Zd=Object.assign.bind()).apply(null,arguments)}function Zu(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Zf=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:a,width:i,height:o,ry:l}=e;return ew.createElement("rect",{x:r,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Zh(e){var{option:t,lineItemProps:n}=e;if(ew.isValidElement(t))r=ew.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,a,{x1:i,y1:o,x2:l,y2:s,key:c}=n,d=null!=(a=IF(Zu(n,Za)))?a:{},{offset:u}=d,f=Zu(d,Zi);r=ew.createElement("line",Zd({},f,{x1:i,y1:o,x2:l,y2:s,fill:"none",key:c}))}return r}function Zm(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Zu(e,Zo),s=a.map((e,a)=>{var i=Zc(Zc({},l),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(a),index:a});return ew.createElement(Zh,{key:"line-".concat(a),option:r,lineItemProps:i})});return ew.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Zp(e){var{y:t,height:n,vertical:r=!0,verticalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Zu(e,Zl),s=a.map((e,a)=>{var i=Zc(Zc({},l),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(a),index:a});return ew.createElement(Zh,{option:r,lineItemProps:i,key:"line-".concat(a)})});return ew.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Zg(e){var{horizontalFill:t,fillOpacity:n,x:r,y:a,width:i,height:o,horizontalPoints:l,horizontal:s=!0}=e;if(!s||!t||!t.length||null==l)return null;var c=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,l)=>{var s=c[l+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=l%t.length;return ew.createElement("rect",{key:"react-".concat(l),y:e,x:r,height:d,width:i,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Zv(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:a,y:i,width:o,height:l,verticalPoints:s}=e;if(!t||!n||!n.length)return null;var c=s.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,t)=>{var s=c[t+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=t%n.length;return ew.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:d,height:l,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Zx=(e,t)=>{var{xAxis:n,width:r,height:a,offset:i}=e;return kz(Y2(Zc(Zc(Zc({},Y8),n),{},{ticks:kT(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.left,i.left+i.width,t)},Zy=(e,t)=>{var{yAxis:n,width:r,height:a,offset:i}=e;return kz(Y2(Zc(Zc(Zc({},Y8),n),{},{ticks:kT(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.top,i.top+i.height,t)},Zb={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:CX.grid};function Zw(e){var t=Se(kU),n=Se(kW),r=Cy(),a=Zc(Zc({},zB(e,Zb)),{},{x:kp(e.x)?e.x:r.left,y:kp(e.y)?e.y:r.top,width:kp(e.width)?e.width:r.width,height:kp(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:o,x:l,y:s,width:c,height:d,syncWithTicks:u,horizontalValues:f,verticalValues:h}=a,m=N3(),p=Se(e=>Is(e,"xAxis",i,m)),g=Se(e=>Is(e,"yAxis",o,m));if(!kE(c)||!kE(d)||!kp(l)||!kp(s))return null;var v=a.verticalCoordinatesGenerator||Zx,x=a.horizontalCoordinatesGenerator||Zy,{horizontalPoints:y,verticalPoints:b}=a;if((!y||!y.length)&&"function"==typeof x){var w=f&&f.length,j=x({yAxis:g?Zc(Zc({},g),{},{ticks:w?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!w||u);N9(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(y=j)}if((!b||!b.length)&&"function"==typeof v){var k=h&&h.length,S=v({xAxis:p?Zc(Zc({},p),{},{ticks:k?h:p.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!k||u);N9(Array.isArray(S),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof S,"]")),Array.isArray(S)&&(b=S)}return ew.createElement(_V,{zIndex:a.zIndex},ew.createElement("g",{className:"recharts-cartesian-grid"},ew.createElement(Zf,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),ew.createElement(Zg,Zd({},a,{horizontalPoints:y})),ew.createElement(Zv,Zd({},a,{verticalPoints:b})),ew.createElement(Zm,Zd({},a,{offset:r,horizontalPoints:y,xAxis:p,yAxis:g})),ew.createElement(Zp,Zd({},a,{offset:r,verticalPoints:b,xAxis:p,yAxis:g}))))}Zw.displayName="CartesianGrid";var Zj=["domain","range"],Zk=["domain","range"];function ZS(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function ZN(e,t){return e===t||!!(Array.isArray(e)&&2===e.length&&Array.isArray(t))&&2===t.length&&e[0]===t[0]&&e[1]===t[1]}function ZC(e,t){if(e===t)return!0;var{domain:n,range:r}=e,a=ZS(e,Zj),{domain:i,range:o}=t,l=ZS(t,Zk);return!!ZN(n,i)&&!!ZN(r,o)&&Fb(a,l)}var ZM=["type"],ZE=["dangerouslySetInnerHTML","ticks","scale"],ZO=["id","scale"];function ZP(){return(ZP=Object.assign.bind()).apply(null,arguments)}function ZA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ZI(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ZA(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zz(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function ZT(e){var t=k6(),n=(0,ew.useRef)(null),r=Cw(),{type:a}=e,i=Zz(e,ZM),o=CQ(r,"xAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return ZI(ZI({},i),{},{type:o})},[i,o]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t($d(l)):n.current!==l&&t($u({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t($f(n.current)),n.current=null)},[t]),null}var ZD=e=>{var{xAxisId:t,className:n}=e,r=Se(k2),a=N3(),i="xAxis",o=Se(e=>Ic(e,i,t,a)),l=Se(e=>A9(e,t)),s=Se(e=>In(e,t)),c=Se(e=>PR(e,t));if(null==l||null==s||null==c)return null;var{dangerouslySetInnerHTML:d,ticks:u,scale:f}=e,h=Zz(e,ZE),{id:m,scale:p}=c,g=Zz(c,ZO);return ew.createElement(Zr,ZP({},h,g,{x:s.x,y:s.y,width:l.width,height:l.height,className:(0,jL.clsx)("recharts-".concat(i," ").concat(i),n),viewBox:r,ticks:o,axisType:i,axisId:t}))},ZR={allowDataOverflow:PD.allowDataOverflow,allowDecimals:PD.allowDecimals,allowDuplicatedCategory:PD.allowDuplicatedCategory,angle:PD.angle,axisLine:Y8.axisLine,height:PD.height,hide:!1,includeHidden:PD.includeHidden,interval:PD.interval,label:!1,minTickGap:PD.minTickGap,mirror:PD.mirror,orientation:PD.orientation,padding:PD.padding,reversed:PD.reversed,scale:PD.scale,tick:PD.tick,tickCount:PD.tickCount,tickLine:Y8.tickLine,tickSize:Y8.tickSize,type:PD.type,niceTicks:PD.niceTicks,xAxisId:0},Z_=ew.memo(e=>{var t=zB(e,ZR);return ew.createElement(ew.Fragment,null,ew.createElement(ZT,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),ew.createElement(ZD,t))},ZC);Z_.displayName="XAxis";var ZL=["type"],Z$=["dangerouslySetInnerHTML","ticks","scale"],ZF=["id","scale"];function ZB(){return(ZB=Object.assign.bind()).apply(null,arguments)}function ZV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ZH(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ZV(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZU(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function ZW(e){var t=k6(),n=(0,ew.useRef)(null),r=Cw(),{type:a}=e,i=ZU(e,ZL),o=CQ(r,"yAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return ZH(ZH({},i),{},{type:o})},[o,i]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t($h(l)):n.current!==l&&t($m({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t($p(n.current)),n.current=null)},[t]),null}function Zq(e){var{yAxisId:t,className:n,width:r,label:a}=e,i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=Se(k2),s=N3(),c=k6(),d="yAxis",u=Se(e=>Ia(e,t)),f=Se(e=>Ir(e,t)),h=Se(e=>Ic(e,d,t,s)),m=Se(e=>P$(e,t));if((0,ew.useLayoutEffect)(()=>{if(!("auto"!==r||!u||_1(a)||(0,ew.isValidElement)(a))&&null!=m){var e=i.current;if(e){var n=e.getCalculatedWidth();Math.round(u.width)!==Math.round(n)&&c($y({id:t,width:n}))}}},[h,u,c,a,t,r,m]),null==u||null==f||null==m)return null;var{dangerouslySetInnerHTML:p,ticks:g,scale:v}=e,x=ZU(e,Z$),{id:y,scale:b}=m,w=ZU(m,ZF);return ew.createElement(Zr,ZB({},x,w,{ref:i,labelRef:o,x:f.x,y:f.y,tickTextProps:"auto"===r?{width:void 0}:{width:r},width:u.width,height:u.height,className:(0,jL.clsx)("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:h,axisType:d,axisId:t}))}var ZK={allowDataOverflow:PL.allowDataOverflow,allowDecimals:PL.allowDecimals,allowDuplicatedCategory:PL.allowDuplicatedCategory,angle:PL.angle,axisLine:Y8.axisLine,hide:!1,includeHidden:PL.includeHidden,interval:PL.interval,label:!1,minTickGap:PL.minTickGap,mirror:PL.mirror,orientation:PL.orientation,padding:PL.padding,reversed:PL.reversed,scale:PL.scale,tick:PL.tick,tickCount:PL.tickCount,tickLine:Y8.tickLine,tickSize:Y8.tickSize,type:PL.type,niceTicks:PL.niceTicks,width:PL.width,yAxisId:0},ZG=ew.memo(e=>{var t=zB(e,ZK);return ew.createElement(ew.Fragment,null,ew.createElement(ZW,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),ew.createElement(Zq,t))},ZC);function ZX({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),o=e.find(e=>e.id===a)??e[0],[l,s]=ew.useState({});if(!o)return null;let c=l[o.id]??o.selectedMetricId??o.metrics[0]?.id,d=o.metrics.find(e=>e.id===c)??o.metrics[0];return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-performance-monitor",n),...r,children:[(0,ey.jsx)(md,{value:o.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(my,{className:"h-8",children:e.map(e=>(0,ey.jsx)(mb,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid min-h-0 flex-1 grid-cols-[14rem_minmax(0,1fr)] border-t",children:[(0,ey.jsx)("div",{className:"min-h-0 overflow-auto border-r p-2",children:o.metrics.map(e=>(0,ey.jsxs)("button",{type:"button",onClick:()=>s(t=>({...t,[o.id]:e.id})),className:(0,eI.cn)("grid w-full grid-cols-[3.75rem_minmax(0,1fr)] gap-3 px-2 py-2 text-left transition-colors",e.id===c&&"bg-muted"),children:[(0,ey.jsx)(Z1,{data:e.data,color:e.color}),(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsx)("span",{className:"block truncate text-base leading-tight",children:e.label}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.value}),e.detail?(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.detail}):null]})]},e.id))}),(0,ey.jsxs)("div",{className:"min-h-0 overflow-auto p-5",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-5",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h2",{className:"text-4xl leading-none font-semibold tracking-normal",children:d?.title}),d?.subtitle?(0,ey.jsx)("p",{className:"mt-1 text-base text-muted-foreground",children:d.subtitle}):null]}),(0,ey.jsx)("div",{className:"text-right text-sm text-muted-foreground",children:d?.detail})]}),d?(0,ey.jsx)(ZY,{metric:d}):null]})]})]})}function ZY({metric:e}){return"cpu"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZZ,{panel:{id:"cpu",title:"% 利用率",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(ZJ,{}),(0,ey.jsx)(Z0,{details:e.details,columns:4})]}):"memory"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZZ,{panel:{id:"memory",title:"内存使用量",value:e.detail,data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(ZJ,{}),(0,ey.jsx)(ZQ,{segments:e.composition}),(0,ey.jsx)(Z0,{details:e.details,columns:3})]}):"disk"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZZ,{panel:{id:"disk-active",title:"活动时间",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(ZJ,{}),(0,ey.jsx)(ZZ,{panel:{id:"disk-rate",title:"磁盘传输速率",value:"500 KB/秒",data:e.panels?.[0]?.data??e.data,span:"full"},size:"short"}),(0,ey.jsx)(ZJ,{}),(0,ey.jsx)(Z0,{details:e.details,columns:4})]}):"network"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZZ,{panel:{id:"network",title:"吞吐量",value:"100 Kbps",data:e.data,span:"full",color:"danger"},size:"tall"}),(0,ey.jsx)(ZJ,{}),(0,ey.jsx)(Z0,{details:e.details,columns:2})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:(e.panels??[]).map(e=>(0,ey.jsx)(ZZ,{panel:e},e.id))}),(0,ey.jsx)(Z0,{details:e.details,columns:3})]})}function ZZ({panel:e,size:t="normal"}){let n={short:"h-[4rem]",normal:"full"===e.span?"h-20":"h-24",large:"h-[17.5rem]",tall:"h-[21.5rem]"}[t];return(0,ey.jsxs)("div",{className:(0,eI.cn)("mt-5","full"===e.span&&"col-span-2"),children:[(0,ey.jsxs)("div",{className:"mb-1 flex items-center justify-between text-sm",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.title}),e.value?(0,ey.jsx)("span",{className:"text-muted-foreground tabular-nums",children:e.value}):null]}),(0,ey.jsx)(Z2,{data:e.data,color:e.color,className:(0,eI.cn)("w-full",n)})]})}function ZJ(){return(0,ey.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{children:"60 秒"}),(0,ey.jsx)("span",{children:"0"})]})}function ZQ({segments:e}){let t=e&&e.length>0?e:[{label:"used",value:64},{label:"available",value:36}];return(0,ey.jsxs)("div",{className:"mt-5",children:[(0,ey.jsx)("div",{className:"mb-1 text-sm text-muted-foreground",children:"内存组合"}),(0,ey.jsx)("div",{className:"flex h-[3.25rem] w-full overflow-hidden border border-primary/75 bg-background",children:t.map((e,n)=>(0,ey.jsx)("div",{className:(0,eI.cn)("h-full border-r border-primary/75 last:border-r-0",0===n?"bg-primary/20":n===t.length-1?"bg-background":"bg-primary/8"),style:{width:`${Math.max(0,e.value)}%`}},`${e.label}-${n}`))})]})}function Z0({details:e,columns:t}){return e?.length?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-5 grid gap-x-10 gap-y-4",2===t&&"grid-cols-2",3===t&&"grid-cols-3",4===t&&"grid-cols-4"),children:e.map(([e,t])=>(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("div",{className:"truncate text-2xl leading-tight tabular-nums",children:t})]},e))}):null}function Z1({data:e,color:t}){return(0,ey.jsx)(Z2,{data:e,color:t,className:"h-10 w-full",strokeWidth:1.4,compact:!0})}function Z2({data:e,color:t="default",className:n,strokeWidth:r=1.6,compact:a=!1}){let i=ew.useMemo(()=>(e.length>1?e:[0,0]).map((e,t)=>({index:t,value:Math.max(0,Math.min(100,e))})),[e]),o=ew.useMemo(()=>({value:{label:"Value",color:"danger"===t?"var(--destructive)":"var(--foreground)"}}),[t]);return(0,ey.jsx)(Ve,{config:o,className:(0,eI.cn)("aspect-auto border bg-background text-muted-foreground",n),initialDimension:{width:a?96:640,height:a?40:220},children:(0,ey.jsxs)(YY,{data:i,margin:{top:a?2:6,right:0,bottom:0,left:0},children:[a?null:(0,ey.jsx)(Zw,{strokeDasharray:"0",stroke:"var(--border)",strokeOpacity:.7}),(0,ey.jsx)(Z_,{dataKey:"index",hide:!0,domain:["dataMin","dataMax"]}),(0,ey.jsx)(ZG,{hide:!0,domain:[0,100]}),a?null:(0,ey.jsx)(BU,{cursor:!1,content:(0,ey.jsx)(Vn,{hideLabel:!0,indicator:"line"})}),(0,ey.jsx)(YU,{dataKey:"value",type:"monotone",fill:"var(--color-value)",fillOpacity:"danger"===t?.16:.12,stroke:"var(--color-value)",strokeWidth:r,isAnimationActive:!1,dot:!1,activeDot:!1})]})})}ZG.displayName="YAxis";let Z5=(0,ek.default)("badge-alert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Z4=(0,ek.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),Z3={name:"名称",cpu:"CPU",memoryMb:"内存",diskMbps:"磁盘",networkMbps:"网络"};function Z6({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),[o,l]=ew.useState("cpu"),[s,c]=ew.useState("desc"),[d,u]=ew.useState({}),f=e.find(e=>e.id===a)??e[0],h=ew.useMemo(()=>{if(!f)return[];let e=[...function(e){let t=new Map,n=new Map;for(let t of e)void 0!==t.pid&&n.set(t.pid,t);for(let a of e){var r;let e=function e(t,n,r=new Set){void 0!==t.pid&&r.add(t.pid);let a=void 0!==t.parentPid?n.get(t.parentPid):void 0;return!a||void 0===a.pid||r.has(a.pid)||["bash","containerd","dockerd","explorer","init","kernel_task","launchd","services","sh","smss","svchost","system","systemd","wininit","winlogon","zsh"].includes(Jn(a))?t:e(a,n,r)}(a,n),i=Jn(e),o=t.get(i)??{kind:"group",id:i,name:(r=e,r.appName?.trim()||r.name.trim().replace(/\.(exe|com)$/i,"")||r.id),children:[],status:[],cpu:0,memoryMb:0,diskMbps:0,networkMbps:0};o.children.push(a),o.cpu+=a.cpu,o.memoryMb+=a.memoryMb,o.diskMbps+=a.diskMbps,o.networkMbps+=a.networkMbps,o.status=function(e,t){let n=new Set(e??[]);for(let e of t??[])n.add(e);return Array.from(n)}(o.status,a.status),t.set(i,o)}return Array.from(t.values()).map(e=>({...e,cpu:Ja(Math.min(100,e.cpu)),memoryMb:Ja(e.memoryMb),diskMbps:Ja(e.diskMbps),networkMbps:Ja(e.networkMbps)}))}(f.processes)].sort((e,t)=>Jr(e,t,o,s)),t=[];for(let n of e){if(n.children.length<=1){let e=n.children[0];e&&t.push(Jt(e,0));continue}if(t.push(n),d[n.id])for(let e of[...n.children].sort((e,t)=>Jr(e,t,o,s)))t.push(Jt(e,1))}return t},[f,d,s,o]),m=ew.useMemo(()=>h.map(e=>({memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps})),[h]);function p(e){e===o?c(e=>"asc"===e?"desc":"asc"):(l(e),c("name"===e?"asc":"desc"))}return f?(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-process-monitor",n),...r,children:[(0,ey.jsx)(md,{value:f.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(my,{className:"h-8",children:e.map(e=>(0,ey.jsx)(mb,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid h-14 shrink-0 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] border-y text-sm",children:[(0,ey.jsxs)("button",{type:"button",onClick:()=>p("name"),className:"flex items-end px-3 pb-2 text-left text-muted-foreground",children:["名称",(0,ey.jsx)(Z8,{active:"name"===o,direction:s})]}),(0,ey.jsx)("div",{className:"flex items-end px-3 pb-2 text-muted-foreground",children:"状态"}),["cpu","memoryMb","diskMbps","networkMbps"].map(e=>{var t,n;return(0,ey.jsxs)("button",{type:"button",onClick:()=>p(e),className:"grid content-end border-l px-3 pb-2 text-right",children:[(0,ey.jsx)("span",{className:"text-lg leading-none text-foreground",children:(t=f.totals,"cpu"===(n=e)?`${Math.round(t.cpu)}%`:"memoryMb"===n?`${Math.round(t.memory)}%`:"diskMbps"===n?`${Math.round(t.disk)}%`:"networkMbps"===n?`${Math.round(t.network)}%`:"")}),(0,ey.jsxs)("span",{className:"mt-1 text-xs text-muted-foreground",children:[Z3[e],(0,ey.jsx)(Z8,{active:o===e,direction:s,className:"ml-1 inline-flex"})]})]},e)})]}),(0,ey.jsx)("div",{className:"vtl-scrollbar-hidden min-h-0 flex-1 overflow-auto",children:h.map(e=>{var t;return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-9 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] items-center text-sm","group"===e.kind&&"bg-muted/35"),children:[(0,ey.jsx)(Z7,{row:e,expanded:"group"===e.kind&&!!d[e.id],onToggle:()=>{"group"===e.kind&&u(t=>({...t,[e.id]:!t[e.id]}))}}),(0,ey.jsx)(Z9,{platform:f.platform,status:e.status}),(0,ey.jsx)(Je,{value:e.cpu,max:100,label:`${e.cpu.toFixed(1)}%`}),(0,ey.jsx)(Je,{value:e.memoryMb,max:Ji(m,"memoryMb"),label:(t=e.memoryMb)>=1024?`${Jo(t/1024)} GB`:`${Jo(t)} MB`}),(0,ey.jsx)(Je,{value:e.diskMbps,max:Math.max(1,Ji(m,"diskMbps")),label:`${Jo(e.diskMbps)} MB/秒`}),(0,ey.jsx)(Je,{value:e.networkMbps,max:Math.max(1,Ji(m,"networkMbps")),label:`${Jo(e.networkMbps)} Mbps`})]},`${e.kind}-${e.id}`)})})]}):null}function Z8({active:e,direction:t,className:n}){return e?(0,ey.jsx)("asc"===t?jP:jO,{className:(0,eI.cn)("ml-1 size-3",n)}):null}function Z7({row:e,expanded:t,onToggle:n}){if("group"===e.kind){let r=t?vu:mQ;return(0,ey.jsxs)("button",{type:"button","aria-expanded":t,onClick:n,className:"flex h-full min-w-0 items-center gap-2 px-3 text-left outline-none transition-colors hover:bg-muted/55 focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"size-2 rounded-sm bg-foreground/65"}),(0,ey.jsxs)("span",{className:"min-w-0 truncate font-medium",children:[e.name," (",e.children.length,")"]})]})}return(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3",style:{paddingLeft:e.depth>0?34:void 0},children:[e.depth>0?(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/70"}):(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-foreground/65"}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",0===e.depth&&"font-medium"),children:e.name}),e.process.pid?(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.process.pid}):null]})}function Z9({platform:e,status:t}){return t?.length?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 text-muted-foreground",children:[t.includes("suspended")?(0,ey.jsx)(Z4,{"aria-label":"linux"===e?"挂起进程":"挂起",className:"size-4"}):null,t.includes("auto-restart")?(0,ey.jsx)(lQ,{"aria-label":"linux"===e?"自动重启进程":"自动重启",className:"size-4"}):null,t.includes("running")?(0,ey.jsx)(Z5,{"aria-label":"运行",className:"size-4 text-primary"}):null]}):(0,ey.jsx)("div",{className:"px-3"})}function Je({value:e,max:t,label:n}){let r=Math.min(1,Math.max(0,e/Math.max(1,t))),a=r>.78,i=a?`color-mix(in oklch, var(--destructive) ${Math.round(18+42*r)}%, var(--background))`:`color-mix(in oklch, var(--foreground) ${Math.round(5+20*r)}%, var(--background))`;return(0,ey.jsx)("div",{className:"vtl-process-heat-cell h-full border-l px-3 text-right tabular-nums","data-hot":a?"":void 0,style:{background:i},children:(0,ey.jsx)("span",{className:(0,eI.cn)("leading-9",a&&"text-destructive"),children:n})})}function Jt(e,t){return{kind:"process",id:e.id,process:e,depth:t,name:e.appName&&0===t?e.appName:e.name,status:e.status,cpu:e.cpu,memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps}}function Jn(e){return e.appId?.trim().toLowerCase()||e.appName?.trim().toLowerCase()||e.name.trim().toLowerCase().replace(/\.(exe|com)$/i,"")||e.id}function Jr(e,t,n,r){let a="asc"===r?1:-1;return"name"===n?e.name.localeCompare(t.name)*a:(e[n]-t[n])*a}function Ja(e){return Math.round(10*e)/10}function Ji(e,t){return e.reduce((e,n)=>Math.max(e,n[t]),0)}function Jo(e){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:+(e<10)}).format(e)}function Jl({className:e}){let t=Jc("/api/local/machines/processes"),n=Jd("/machines/processes"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(Z6,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Js({className:e}){let t=Jc("/api/local/machines/performance"),n=Jd("/machines/performance"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(ZX,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Jc(e){let[t,n]=ew.useState([]);return ew.useEffect(()=>{let t=!0,r=!1;async function a(){if(!r){r=!0;try{let r=await fetch(eD(e),{cache:"no-store"});if(!r.ok)return;let a=await r.json();t&&n(a.machines)}catch{t&&n([])}finally{r=!1}}}a();let i=window.setInterval(a,2e3);return()=>{t=!1,window.clearInterval(i)}},[e]),t}function Jd(e){let{machines:t}=vj(),[n,r]=ew.useState([]),a=ew.useMemo(()=>t.filter(e=>!e.isLocal&&"online"===e.status).map(e=>e.id),[t]);return ew.useEffect(()=>{if(0===a.length)return void r([]);let t=!0,n=!1;async function i(){if(!n){n=!0;try{let n=await Promise.all(a.map(async t=>{try{return(await sj(t,e)).machines??[]}catch{return[]}}));t&&r(n.flat())}finally{n=!1}}}i();let o=window.setInterval(i,5e3);return()=>{t=!1,window.clearInterval(o)}},[a,e]),n}let Ju=(0,ek.default)("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Jf=(0,ek.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),Jh={loading:"Starting terminal...",newTerminal:"New terminal",closeTerminal:e=>`Close ${e}`,terminalList:"Terminal sessions",status:{idle:"Idle",running:"Running",success:"Succeeded",error:"Failed"}},Jm=[{id:"powershell",title:"PowerShell",shell:"PowerShell",cwd:"D:\\Projects\\Vantaloom-ui",status:"idle",initialOutput:"PowerShell 7.6.1\r\nPS D:\\Projects\\Vantaloom-ui> "}];function Jp(e,t,n){return e.getPropertyValue(t).trim()||n}function Jg(e,t=!1){let n=getComputedStyle(e),r=Jp(n,"--foreground","#18181b"),a=Jp(n,"--terminal-background",Jp(n,"--background","#ffffff")),i="transparent"===a?Jp(n,"--background","#ffffff"):a,o=Jp(n,"--muted-foreground","#71717a"),l=Jp(n,"--border","#e4e4e7"),s=Jp(n,"--selection","#18181b");return{background:a,foreground:r,cursor:t?"transparent":r,cursorAccent:t?"transparent":i,selectionBackground:`color-mix(in oklch, ${s} 18%, transparent)`,selectionForeground:Jp(n,"--selection-foreground","#ffffff"),scrollbarSliderBackground:`color-mix(in oklch, ${l} 78%, transparent)`,scrollbarSliderHoverBackground:l,black:r,red:Jp(n,"--terminal-red","#bf616a"),green:Jp(n,"--terminal-green","#5e8c61"),yellow:Jp(n,"--terminal-yellow","#b06f3c"),blue:Jp(n,"--terminal-blue","#5e81ac"),magenta:Jp(n,"--terminal-magenta","#b48ead"),cyan:Jp(n,"--terminal-cyan","#4c8da8"),white:a,brightBlack:o,brightRed:Jp(n,"--terminal-bright-red","#d06f79"),brightGreen:Jp(n,"--terminal-bright-green","#6b9a70"),brightYellow:Jp(n,"--terminal-bright-yellow","#c2824b"),brightBlue:Jp(n,"--terminal-bright-blue","#6f91ba"),brightMagenta:Jp(n,"--terminal-bright-magenta","#c19ac0"),brightCyan:Jp(n,"--terminal-bright-cyan","#5aa0b8"),brightWhite:r}}function Jv(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function Jx({initialOutput:t,data:n,dataKey:r,options:a,readOnly:i=!1,autoFocus:o=!1,localEcho:l=!1,onData:s,onResize:c,onReady:d,labels:u,className:f,terminalClassName:h,...m}){let p=ew.useMemo(()=>({loading:Jh.loading,...u}),[u]),g=ew.useRef(null),v=ew.useRef(null),x=ew.useRef(void 0),y=ew.useRef(s),b=ew.useRef(c),w=ew.useRef(d),j=ew.useRef(a),k=ew.useRef(i),S=ew.useRef(l),N=ew.useRef(!1),C=ew.useRef(void 0),M=ew.useRef(!1),[E,O]=ew.useState(!1);return ew.useEffect(()=>{y.current=s,b.current=c,w.current=d,j.current=a,k.current=i,S.current=l},[l,s,d,c,a,i]),ew.useEffect(()=>{let n,r=!1,a=[];!async function(){var i;let l,s,c,d,u;if(!g.current||M.current)return;M.current=!0;let[{Terminal:f},{FitAddon:h},{SearchAddon:m},{WebLinksAddon:p}]=await Promise.all([e.A(93626),e.A(16118),e.A(24306),e.A(46866)]);if(r||!g.current)return;let C=new f({convertEol:!1,cursorBlink:!0,cursorStyle:"block",drawBoldTextInBrightColors:!1,fontFamily:(l=getComputedStyle(i=g.current),u=(c=Jp(l,"--font-family-mono",s='"Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", monospace'),d=getComputedStyle(i),c.replace(/var\((--[a-zA-Z0-9-_]+)(?:,[^)]+)?\)/g,(e,t)=>d.getPropertyValue(t).trim()||"")).trim(),`"Cascadia Mono", "Cascadia Code", Consolas, ${u||s}`),fontSize:13,letterSpacing:0,lineHeight:1.25,macOptionIsMeta:!0,minimumContrastRatio:4.5,scrollback:5e3,theme:Jg(g.current),...j.current,allowTransparency:!0}),E=new h,P=new m,A=new p;function I(){try{E.fit(),b.current?.({cols:C.cols,rows:C.rows})}catch{}}for(let e of(C.loadAddon(E),C.loadAddon(P),C.loadAddon(A),C.open(g.current),v.current=C,x.current=E,O(!0),requestAnimationFrame(I),(n=new ResizeObserver(I)).observe(g.current),a.push(C.onData(e=>{k.current||(S.current&&("\r"===e?C.write("\r\n"):""===e?C.write("\b \b"):C.write(e)),y.current?.(e))})),Jv(t)))C.write(e);w.current?.({terminal:C,fitAddon:E,searchAddon:P,webLinksAddon:A,fit:I,focus:()=>C.focus(),clear:()=>C.clear(),setCursorSuppressed:function(e){let t=g.current;t&&(N.current=e,t.toggleAttribute("data-vtl-terminal-cursor-suppressed",e),C.options.theme=Jg(t,e))},write:(e,t)=>C.write(e,t),writeln:e=>C.writeln(e)}),o&&C.focus()}();let i=new MutationObserver(()=>{let e=v.current,t=g.current;e&&t&&(e.options.theme=Jg(t,N.current))});return i.observe(document.documentElement,{attributeFilter:["class","style"],attributes:!0}),()=>{for(let e of(r=!0,i.disconnect(),n?.disconnect(),a))e.dispose();v.current?.dispose(),v.current=null,x.current=void 0,N.current=!1,M.current=!1,O(!1)}},[o,t]),ew.useEffect(()=>{let e=v.current;if(e&&C.current!==r)for(let t of(C.current=r,Jv(n)))e.write(t)},[n,r]),(0,ey.jsxs)("div",{"data-slot":"terminal-tab-surface",className:(0,eI.cn)("relative size-full min-h-0 overflow-hidden bg-background text-foreground",f),...m,children:[(0,ey.jsx)("div",{ref:g,className:(0,eI.cn)("vtl-terminal-xterm size-full overflow-hidden p-1.5 font-mono","[&_.xterm]:h-full [&_.xterm]:p-0 [&_.xterm-viewport]:!bg-transparent","[&_.xterm-screen]:!bg-transparent [&_.xterm-helper-textarea]:!outline-none","[&[data-vtl-terminal-cursor-suppressed]_.xterm-cursor]:!opacity-0","[&_.xterm-viewport::-webkit-scrollbar]:w-2.5 [&_.xterm-viewport::-webkit-scrollbar-track]:bg-transparent","[&_.xterm-viewport::-webkit-scrollbar-thumb]:rounded-full [&_.xterm-viewport::-webkit-scrollbar-thumb]:border-[3px]","[&_.xterm-viewport::-webkit-scrollbar-thumb]:border-transparent [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-border [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-clip-content",h)}),!E&&(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-muted-foreground ui-text-code",children:p.loading})]})}function Jy({status:e="idle"}){return"running"===e?(0,ey.jsx)(Ju,{className:"size-3.5 text-foreground"}):"success"===e?(0,ey.jsx)(eO,{className:"size-3.5 text-foreground"}):"error"===e?(0,ey.jsx)(eE,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(bC,{className:"size-3.5 text-muted-foreground"})}function Jb({session:e}){return e.aiControlled?(0,ey.jsx)(Jf,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(Jy,{status:e.status})}function Jw({sessions:e,defaultSessions:t=Jm,activeSessionId:n,defaultActiveSessionId:r,onActiveSessionChange:a,onSessionsChange:i,onCreateSession:o,onCloseSession:l,onSessionData:s,onSessionResize:c,onSessionReady:d,showTabs:u=!0,allowCreateSession:f=!0,readOnly:h=!1,localEcho:m=!1,terminalOptions:p,labels:g,className:v,tabListClassName:x,terminalClassName:y,...b}){let w=ew.useMemo(()=>({...Jh,...g,status:{...Jh.status,...g?.status}}),[g]),[j,k]=ew.useState(t),S=e??j,N=S[0],[C,M]=ew.useState(r??N?.id),E=n??(S.some(e=>e.id===C)?C:N?.id),O=S.find(e=>e.id===E)??N;function P(t){void 0===e&&k(t),i?.(t)}function A(e){e.disabled||(void 0===n&&M(e.id),a?.(e.id,e))}return(0,ey.jsxs)("div",{"data-slot":"terminal-tab-group",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",u?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",v),...b,children:[u&&(0,ey.jsxs)("div",{"data-slot":"terminal-tab-list",role:"tablist","aria-label":w.terminalList,className:(0,eI.cn)("flex min-w-0 items-center gap-1 border-b bg-muted/35 px-2 py-1.5",x),children:[(0,ey.jsx)(uO,{className:"ml-1 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsxs)("div",{className:(0,eI.cn)("group flex h-7 min-w-0 shrink-0 items-center rounded-md border border-transparent ui-text-control","transition-colors hover:bg-background/80",t?"bg-background text-foreground shadow-xs":"text-muted-foreground",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsxs)("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`terminal-panel-${e.id}`,disabled:e.disabled,onClick:()=>A(e),className:"flex h-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(Jb,{session:e}),(0,ey.jsx)("span",{className:"max-w-36 truncate",children:e.title}),e.shell&&(0,ey.jsx)("span",{className:"hidden text-muted-foreground ui-text-kbd sm:inline",children:e.shell})]}),e.closable&&(0,ey.jsx)("button",{type:"button","aria-label":w.closeTerminal(e.title),onClick:t=>{t.stopPropagation();l?.(e.id,e);let n=S.filter(t=>t.id!==e.id);if(P(n),e.id===E){let e=n.at(-1);e&&A(e)}},className:"mr-1 grid size-4 place-items-center rounded-sm text-muted-foreground opacity-0 outline-none transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/20 group-hover:opacity-100",children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]},e.id)})}),f&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":w.newTerminal,onClick:function(){let e=o?.()??{id:`terminal-${Date.now()}`,title:`Terminal ${S.length+1}`,status:"idle",initialOutput:"",closable:!0};P([...S,e]),A(e)},className:"size-7 shrink-0",children:(0,ey.jsx)(lJ,{className:"size-3.5"})})]}),(0,ey.jsx)("div",{"data-slot":"terminal-tab-panels",className:"relative min-h-0 overflow-hidden",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsx)(Jj,{session:e,selected:t,terminalOptions:p,readOnly:h,localEcho:m,onSessionData:s,onSessionResize:c,onSessionReady:d,labels:w,terminalClassName:y},e.id)})})]})}function Jj({session:e,selected:t,terminalOptions:n,readOnly:r,localEcho:a,onSessionData:i,onSessionResize:o,onSessionReady:l,labels:s,terminalClassName:c}){let d=ew.useRef(null),u=ew.useRef(t);return ew.useEffect(()=>{if(t&&!u.current&&d.current){let e=d.current;requestAnimationFrame(()=>{e&&(e.fit(),e.terminal.refresh(0,e.terminal.rows-1),e.terminal.focus())})}u.current=t},[t]),(0,ey.jsx)("div",{id:`terminal-panel-${e.id}`,role:"tabpanel","aria-hidden":!t,"data-active":t,className:"absolute inset-0 min-h-0",style:{display:t?"block":"none"},children:(0,ey.jsx)(Jx,{initialOutput:e.initialOutput,options:{...n,...e.options},readOnly:r||e.disabled,localEcho:a,autoFocus:t,onData:t=>i?.(e.id,t),onResize:t=>o?.(e.id,t),onReady:t=>{d.current=t,l?.(e.id,t)},labels:s,terminalClassName:c})})}function Jk({className:e,scopeId:t,state:n,onStateChange:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState([]),[s,c]=ew.useState(),[d,u]=ew.useState("local"),[f,h]=ew.useState(),[m,p]=ew.useState(!1),[g,v]=ew.useState(!1),x=ew.useRef(new Map),y=ew.useRef(new Map),b=ew.useRef(new Map),w=ew.useRef(new Map),j=ew.useRef(new Map),k=ew.useRef(new Map),S=ew.useRef(new Map),N=ew.useRef(new Map),C=ew.useRef(!1),M=ew.useRef(n?.autoStart===!1),E=ew.useRef(n),O=ew.useRef(r),P=Array.isArray(n?.sessionIds)?n.sessionIds.join("\0"):"__all__",A=t?.trim()||void 0,I=A??"__unscoped__";ew.useEffect(()=>{E.current=n},[n]),ew.useEffect(()=>{O.current=r},[r]);let z=a.find(e=>e.id===d)??a[0],T=z?.shells?.find(e=>e.id===f)??z?.shells?.[0],D=ew.useMemo(()=>o.map(e=>e.id),[o]),R=ew.useMemo(()=>o.filter(e=>e.aiControlled).map(e=>e.id),[o]),_=D.join("\0"),L=R.join("\0"),$=ew.useCallback((e,t)=>{let n=y.current.get(e);if(t){let t=j.current.get(e);void 0!==t&&(window.clearTimeout(t),j.current.delete(e))}n?.setCursorSuppressed(t)},[]),F=ew.useCallback(e=>{let t=j.current.get(e);void 0!==t&&window.clearTimeout(t);let n=window.setTimeout(()=>{j.current.delete(e),$(e,!1)},90);j.current.set(e,n)},[$]),B=ew.useCallback(e=>{let t=w.current.get(e),n=y.current.get(e);if(!t||!n||t.writing)return;if(!t.buffer){w.current.delete(e),F(e);return}void 0!==t.drainTimer&&(window.clearTimeout(t.drainTimer),t.drainTimer=void 0);let r=t.buffer.slice(0,65536);t.buffer=t.buffer.slice(r.length),t.writing=!0,$(e,!0);try{n.write(r,()=>{(t.writing=!1,y.current.has(e))?t.buffer?t.drainTimer=window.setTimeout(()=>B(e),0):(w.current.delete(e),F(e)):w.current.delete(e)})}catch{t.writing=!1,w.current.delete(e),F(e)}},[F,$]),V=ew.useCallback((e,t)=>{if(!t)return;if(!y.current.get(e))return void b.current.set(e,`${b.current.get(e)??""}${t}`);let n=w.current.get(e);(n||(n={buffer:"",writing:!1},w.current.set(e,n)),n.buffer+=t,$(e,!0),n.buffer.length>=65536)?B(e):n.writing||void 0!==n.drainTimer||(n.drainTimer=window.setTimeout(()=>B(e),8))},[B,$]),H=ew.useCallback((e,t)=>{(k.current.set(e,t.sequence),"output"===t.type&&t.data)?V(e,t.data):"status"===t.type&&t.status&&l(n=>n.map(n=>n.id===e?{...n,status:t.status??n.status,updatedAt:t.createdAt}:n))},[V]),U=ew.useCallback(e=>{if(x.current.has(e))return;let t=new EventSource(function(e,t=0){let n=new URLSearchParams;t>0&&n.set("after",String(t));let r=n.toString();return eD(`/api/local/terminals/sessions/${encodeURIComponent(e)}/events${r?`?${r}`:""}`)}(e,k.current.get(e)??0));t.onmessage=t=>{try{H(e,JSON.parse(t.data))}catch{return}},x.current.set(e,t)},[H]),W=ew.useCallback(async()=>{if(z&&!m){M.current=!1,p(!0);try{let e=await fu({machineId:z.id,scopeId:A,shell:T?.id,cwd:z.defaultCwd,cols:100,rows:30});l(t=>t.some(t=>t.id===e.id)?t:[...t,e]),c(e.id),U(e.id)}catch{return}finally{p(!1)}}},[m,U,z,T,A]);function q(e){let t=S.current.get(e);return t||(t={buffer:"",inFlight:!1},S.current.set(e,t)),t}return ew.useEffect(()=>{let e=!0;return v(!1),async function(){try{let t=E.current,n=t?.sessionIds,r=Array.isArray(n)?new Set(n):void 0,[a,o]=await Promise.all([fc(),fd(A)]);if(!e)return;let s=r?o.sessions.filter(e=>r.has(e.id)):o.sessions;C.current=!1,M.current=t?.autoStart===!1,i(a.machines),l(s),c(e=>{let n=t?.activeSessionId??e;return n&&s.some(e=>e.id===n)?n:s[0]?.id});let d=a.machines[0];if(d){let e=a.machines.find(e=>e.id===t?.selectedMachineId)??d;u(e.id),h(n=>t?.selectedShellId&&e.shells?.some(e=>e.id===t.selectedShellId)?t.selectedShellId:n&&e.shells?.some(e=>e.id===n)?n:e.shells?.[0]?.id)}}finally{e&&v(!0)}}(),()=>{e=!1}},[P,A,I]),ew.useEffect(()=>{g&&O.current?.({sessionIds:D,activeSessionId:s,selectedMachineId:d,selectedShellId:f,autoStart:!M.current,aiControlledSessionIds:R})},[s,R,L,g,d,f,D,_]),ew.useEffect(()=>{let e=new Set(D);for(let e of o)U(e.id);for(let[t,n]of x.current)e.has(t)||(n.close(),x.current.delete(t))},[U,D,o]),ew.useEffect(()=>{!g||C.current||M.current||o.length>0||0===a.length||(C.current=!0,W())},[W,g,a.length,o.length]),ew.useEffect(()=>()=>{for(let e of x.current.values())e.close();for(let e of S.current.values())void 0!==e.timer&&window.clearTimeout(e.timer);for(let e of w.current.values())void 0!==e.drainTimer&&window.clearTimeout(e.drainTimer);for(let[e,t]of j.current)window.clearTimeout(t),$(e,!1);S.current.clear(),w.current.clear(),j.current.clear()},[$]),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid h-full min-h-0 w-full grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit] border bg-card",e),children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 border-b bg-muted/35 px-2 py-1.5",children:[(0,ey.jsxs)(gT,{value:z?.id,onValueChange:e=>{u(e);let t=a.find(t=>t.id===e);h(t?.shells?.[0]?.id)},children:[(0,ey.jsxs)(vh,{size:"sm",className:"max-w-44",children:[(0,ey.jsx)(yt,{className:"size-3.5"}),(0,ey.jsx)(gL,{placeholder:"机器"})]}),(0,ey.jsx)(vg,{align:"start",children:a.filter(e=>"online"===e.status).map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsxs)(gT,{value:T?.id,onValueChange:h,children:[(0,ey.jsx)(vh,{size:"sm",className:"max-w-44",children:(0,ey.jsx)(gL,{placeholder:"Shell"})}),(0,ey.jsx)(vg,{align:"start",children:z?.shells?.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"新建终端",disabled:!z||m,onClick:()=>void W(),className:"ml-auto",children:(0,ey.jsx)(lJ,{className:"size-4"})})]}),(0,ey.jsx)(Jw,{sessions:o.map(JS),activeSessionId:s,allowCreateSession:!1,localEcho:!1,labels:{loading:"启动终端...",terminalList:"终端会话",closeTerminal:e=>`关闭 ${e}`},onActiveSessionChange:e=>c(e),onCloseSession:e=>{let t,n,r;return x.current.get(e)?.close(),x.current.delete(e),y.current.delete(e),b.current.delete(e),t=w.current.get(e),t?.drainTimer!==void 0&&window.clearTimeout(t.drainTimer),w.current.delete(e),k.current.delete(e),void 0!==(n=j.current.get(e))&&(window.clearTimeout(n),j.current.delete(e)),r=S.current.get(e),void(r?.timer!==void 0&&window.clearTimeout(r.timer),S.current.delete(e),N.current.delete(e),l(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&(M.current=!0),c(t=>t&&t!==e&&n.some(e=>e.id===t)?t:n[0]?.id),n}),ff(e).catch(()=>{}))},onSessionData:function(e,t){let n=q(e);n.buffer+=t,function e(t){let n=q(t);n.inFlight||void 0!==n.timer||(n.timer=window.setTimeout(()=>{n.timer=void 0,function(t){let n=S.current.get(t);if(!n||n.inFlight)return;let r=n.buffer;if(n.buffer="",!r){void 0===n.timer&&S.current.delete(t);return}n.inFlight=!0,fh(t,r).catch(()=>{}).finally(()=>{let n=S.current.get(t);n&&(n.inFlight=!1,n.buffer?e(t):void 0===n.timer&&S.current.delete(t))})}(t)},6))}(e)},onSessionResize:function(e,t){let n=`${t.cols}x${t.rows}`;N.current.get(e)!==n&&(N.current.set(e,n),fm(e,t).then(e=>{l(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}).catch(()=>{}))},onSessionReady:function(e,t){y.current.set(e,t);let n=b.current.get(e);n&&(b.current.delete(e),V(e,n))},className:"min-h-0 rounded-none border-0"})]})}function JS(e){return{id:e.id,title:e.title,shell:e.ordinal?`T${e.ordinal}`:"",cwd:e.cwd,status:function(e){switch(e){case"running":return"running";case"exited":case"closed":return"success";case"failed":return"error";default:return"idle"}}(e.status),closable:!0,initialOutput:"",aiControlled:e.aiControlled,controller:e.controller}}function JN(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e.kind){case"file-tab-viewer":{let r=uH("file-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HQ,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(Gf,{className:`${n} border-0`,file:a??r.file,value:e.defaultValue??r.defaultValue??"",defaultValue:e.defaultValue??r.defaultValue,view:e.defaultView,mode:e.defaultMode,modified:e.modified,onValueChange:n=>t.onTabChange?.({...e,defaultValue:n,modified:!0}),onViewChange:n=>t.onTabChange?.({...e,defaultView:n}),onModeChange:n=>t.onTabChange?.({...e,defaultMode:n}),onSave:t.onSaveFileTab?n=>t.onSaveFileTab?.(e,n):void 0,onHistory:()=>t.onOpenFileHistory?.(e),labels:{review:"审阅",edit:"编辑",view:"视图",code:"代码",preview:"预览",hex:"十六进制",actions:"文件菜单",save:"保存",saving:"保存中",history:"历史版本"}})}case"browser-tab-viewer":return(0,ey.jsx)(Xr,{className:`${n} border-0`,defaultUrl:e.defaultUrl??uH("browser-tab-viewer").defaultUrl});case"diff-tab-viewer":{let t=uH("diff-tab-viewer");return(0,ey.jsx)(Wv,{className:`${n} border-0`,file:e.file??t.file,diff:e.diff??t.diff??""})}case"data-table-tab-viewer":{let r=uH("data-table-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HQ,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(Wo,{className:`${n} border-0`,file:{name:a?.name??r.file?.name??"data",path:a?.path??r.file?.path,type:JC(e)},source:void 0!==e.defaultValue?{type:JC(e),content:e.defaultValue}:void 0,data:e.tableData??r.tableData??[]})}case"terminal-tab-group":return(0,ey.jsx)(Jk,{className:`${n} border-0`,scopeId:t.terminalScopeId,state:e.terminal??t.terminalState,onStateChange:t.onTerminalStateChange})}}function JC(e){return`${e.file?.mimeType??""} ${e.file?.path??e.file?.name??""}`.toLowerCase().includes("json")?"json":"csv"}function JM(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e){case"multi-tab-system":{let e=t.nodeId,r=void 0!==t.tabs?t.tabs:[];return(0,ey.jsx)(Gg,{className:n,contentClassName:"min-h-0",tabs:r.map(n=>({id:n.id,title:n.title,meta:n.meta,modified:n.modified,icon:uV(n.kind),content:JN(n,{terminalScopeId:e?`${t.terminalScopeId??`canvas:node:${e}`}:tab:${n.id}`:t.terminalScopeId,terminalState:n.terminal,onTerminalStateChange:r=>e?t.onTabChange?.(e,{...n,terminal:r}):void 0,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length}),onTabChange:n=>{e&&t.onTabChange?.(e,n)},onSaveFileTab:(n,r)=>e?t.onSaveFileTab?.(e,n,r):void 0,onOpenFileHistory:n=>e?t.onOpenFileHistory?.(e,n):void 0})})),activeTabId:t.activeTabId,detachable:!0,externalDropTypes:[GG],createLabel:"打开文件",emptyContent:(0,ey.jsx)(HQ,{onChooseFile:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})}),onCreateTab:()=>{t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})},onActiveTabChange:n=>{e&&t.onActiveTabChange?.(e,n)},onTabsChange:n=>{if(!e)return;let a=n.map(e=>r.find(t=>t.id===e.id)).filter(e=>!!e);t.onTabsChange?.(e,a)},onTabDetach:(n,a)=>{if(!e)return!1;let i=r.find(e=>e.id===n.id);return!!i&&t.onTabDetach?.(e,i,{clientX:a.clientX,clientY:a.clientY})},onExternalTabDrop:({insertIndex:n,nativeEvent:r})=>{e&&t.onExternalTabDrop?.(e,n,r)}})}case"file-tree-panel":if(t.workspaceFolders)return(0,ey.jsx)(HZ,{folders:t.workspaceFolders,className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});return(0,ey.jsx)(Xz,{className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});case"process-management":return(0,ey.jsx)(Jl,{className:`${n} rounded-[inherit] border-0`});case"machine-performance":return(0,ey.jsx)(Js,{className:`${n} rounded-[inherit] border-0`});case"firewall-policy-workspace":return(0,ey.jsx)("div",{className:`${n} bg-card`,children:(0,ey.jsx)(XP,{})});case"machine-file-management":return(0,ey.jsx)(X8,{className:`${n} bg-card`});case"agent-conversation-panel":return(0,ey.jsx)(Hb,{className:`${n} vtl-canvas-agent-conversation-node`,composerClassName:"max-w-[42rem]"});case"status-monitor":return(0,ey.jsx)(Gq,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"plan-doc-viewer":return(0,ey.jsx)(Gj,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"spec-doc-viewer":return(0,ey.jsx)(Gk,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"file-tab-viewer":case"browser-tab-viewer":case"diff-tab-viewer":case"data-table-tab-viewer":case"terminal-tab-group":return JN(t.tab??uH(e,`${e}-tab`),{terminalState:t.terminalState,terminalScopeId:t.terminalScopeId,onTerminalStateChange:t.onTerminalStateChange,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:t.nodeId}),onTabChange:e=>{t.nodeId&&t.onTabChange?.(t.nodeId,e)},onSaveFileTab:(e,n)=>t.nodeId?t.onSaveFileTab?.(t.nodeId,e,n):void 0,onOpenFileHistory:e=>t.nodeId?t.onOpenFileHistory?.(t.nodeId,e):void 0})}}function JE({kind:e,...t}){return JM(e,t)}let JO="application/vnd.vantaloom.agent-pane-shredder",JP="application/vnd.vantaloom.agent-pane-cutter";function JA(e,t){return(e?.activeSessionId??"")===(t.activeSessionId??"")&&(e?.selectedMachineId??"")===(t.selectedMachineId??"")&&(e?.selectedShellId??"")===(t.selectedShellId??"")&&(e?.autoStart??!0)===(t.autoStart??!0)&&(e?.sessionIds??[]).join("\0")===t.sessionIds.join("\0")&&(e?.aiControlledSessionIds??[]).join("\0")===(t.aiControlledSessionIds??[]).join("\0")}let JI=[{id:"quad",label:"四分",slots:4,icon:(0,ey.jsx)(ye,{})},{id:"vertical-split",label:"上下二分",slots:2,icon:(0,ey.jsx)(Us,{})},{id:"horizontal-split",label:"左右二分",slots:2,icon:(0,ey.jsx)(Ut,{})},{id:"left-two-right-one",label:"左二右一",slots:3,icon:(0,ey.jsx)(s8,{})},{id:"left-one-right-two",label:"左一右二",slots:3,icon:(0,ey.jsx)(s9,{})},{id:"top-two-bottom-one",label:"上二下一",slots:3,icon:(0,ey.jsx)(Us,{})},{id:"top-one-bottom-two",label:"上一下二",slots:3,icon:(0,ey.jsx)(Ul,{})},{id:"single",label:"整窗口",slots:1,icon:(0,ey.jsx)(Uo,{})}];function Jz(e,t,n=[50,50]){let r=e?.[t],a=r?.[0],i=r?.[1];return["number"==typeof a&&a>0?a:n[0],"number"==typeof i&&i>0?i:n[1]]}function JT(e,t){return{[e[0]]:t[0],[e[1]]:t[1]}}function JD(e,t){return[e[t[0]]??50,e[t[1]]??50]}function JR({mode:e,sizes:t,onSizeGroupChange:n,children:r}){if("single"===e)return(0,ey.jsx)("div",{className:"size-full min-h-0",children:r[0]});if("horizontal-split"===e){let e=Jz(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JT(a,e),onLayoutChanged:e=>n?.("outer",JD(e,a)),children:[(0,ey.jsx)(hk,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("vertical-split"===e){let e=Jz(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(a,e),onLayoutChanged:e=>n?.("outer",JD(e,a)),children:[(0,ey.jsx)(hk,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("left-two-right-one"===e){let e=Jz(t,"outer",[58,42]),a=Jz(t,"left"),i=["left","right"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JT(i,e),onLayoutChanged:e=>n?.("outer",JD(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(o,a),onLayoutChanged:e=>n?.("left",JD(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:20,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:20,children:r[1]})]})}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("left-one-right-two"===e){let e=Jz(t,"outer",[42,58]),a=Jz(t,"right"),i=["left","right"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JT(i,e),onLayoutChanged:e=>n?.("outer",JD(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(o,a),onLayoutChanged:e=>n?.("right",JD(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:20,children:r[1]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:20,children:r[2]})]})})]})}if("top-two-bottom-one"===e){let e=Jz(t,"outer",[58,42]),a=Jz(t,"top"),i=["top","bottom"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(i,e),onLayoutChanged:e=>n?.("outer",JD(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JT(o,a),onLayoutChanged:e=>n?.("top",JD(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:24,children:r[1]})]})}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("top-one-bottom-two"===e){let e=Jz(t,"outer",[42,58]),a=Jz(t,"bottom"),i=["top","bottom"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(i,e),onLayoutChanged:e=>n?.("outer",JD(e,i)),children:[(0,ey.jsx)(hk,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JT(o,a),onLayoutChanged:e=>n?.("bottom",JD(e,o)),children:[(0,ey.jsx)(hk,{id:o[0],defaultSize:a[0],minSize:24,children:r[1]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:o[1],defaultSize:a[1],minSize:24,children:r[2]})]})})]})}let a=Jz(t,"outer"),i=Jz(t,"left"),o=Jz(t,"right"),l=["left","right"],s=["pane-0","pane-2"],c=["pane-1","pane-3"];return(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:JT(l,a),onLayoutChanged:e=>n?.("outer",JD(e,l)),children:[(0,ey.jsx)(hk,{id:l[0],defaultSize:a[0],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(s,i),onLayoutChanged:e=>n?.("left",JD(e,s)),children:[(0,ey.jsx)(hk,{id:s[0],defaultSize:i[0],minSize:20,children:r[0]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:s[1],defaultSize:i[1],minSize:20,children:r[2]})]})}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:l[1],defaultSize:a[1],minSize:24,children:(0,ey.jsxs)(hj,{direction:"vertical",defaultLayout:JT(c,o),onLayoutChanged:e=>n?.("right",JD(e,c)),children:[(0,ey.jsx)(hk,{id:c[0],defaultSize:o[0],minSize:20,children:r[1]}),(0,ey.jsx)(hS,{withHandle:!0}),(0,ey.jsx)(hk,{id:c[1],defaultSize:o[1],minSize:20,children:r[3]})]})})]})}function J_({conversationId:e,ownerMachineId:t,index:n,content:r,clipboardItems:a,clipboardDraggingId:i,onAdd:o,onPanelDrop:l,onContentChange:s,onClear:c,onCut:d,workspaceFolders:u,onRequestFileTab:f,onOpenWorkspaceFile:h,onSaveFileTab:m,onOpenFileHistory:p}){let[g,v]=ew.useState();return(0,ey.jsx)("div",{"data-agent-pane":n,className:(0,eI.cn)("relative size-full min-h-0 min-w-0 overflow-hidden",r?.kind!=="subagent-conversation-panel"&&"bg-background","vtl-agent-workspace-pane",r?.kind==="subagent-conversation-panel"&&"vtl-agent-workspace-conversation-pane bg-transparent","panel"===g&&"ring-2 ring-foreground/60 ring-inset","shredder"===g&&"ring-2 ring-destructive/70 ring-inset","cutter"===g&&"ring-2 ring-amber-500/70 ring-inset"),onDragOver:e=>{let t=Array.from(e.dataTransfer.types);if(t.includes(JP)){e.preventDefault(),e.dataTransfer.dropEffect="move",v("cutter");return}if(t.includes(JO)){e.preventDefault(),e.dataTransfer.dropEffect="move",v("shredder");return}t.includes(jM)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",v("panel"))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},onDrop:e=>{if(Array.from(e.dataTransfer.types).includes(JP)){e.preventDefault(),e.stopPropagation(),v(void 0),d(n);return}if(Array.from(e.dataTransfer.types).includes(JO)){e.preventDefault(),e.stopPropagation(),v(void 0),c(n);return}let t=function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),n=a.find(e=>e.id===t),r=n?n.payloads?.[jM]:void 0;if(n&&r)return{item:n,content:r.content};let i=e.dataTransfer.getData(jM);if(i)try{let e=JSON.parse(i);return n&&e.content?{item:n,content:e.content}:void 0}catch{return}}(e);t&&(e.preventDefault(),e.stopPropagation(),v(void 0),l(n,t.item,t.content))},children:r?(0,ey.jsx)("div",{className:(0,eI.cn)("size-full min-h-0 min-w-0 overflow-hidden rounded-none","vtl-agent-pane-content","subagent-conversation-panel"===r.kind&&"vtl-agent-pane-conversation-content",i&&"pointer-events-none"),children:jC(r)?JM(r.kind,{tab:r.tab,conversationId:e,ownerMachineId:t,terminalScopeId:e?`agent:${e}:pane:${r.id}`:void 0,terminalState:r.terminal,onTerminalStateChange:e=>{JA(r.terminal,e)||s(n,{...r,terminal:e})},workspaceFolders:u,nodeId:r.id,tabs:r.tabs,activeTabId:r.activeTabId,onRequestFileTab:({insertIndex:e})=>f?.(n,e),onOpenWorkspaceFile:h,onTabsChange:(e,t)=>{s(n,{...r,tabs:t,activeTabId:t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id})},onTabChange:(e,t)=>{"multi-tab-system"===r.kind?s(n,{...r,tabs:(r.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}):s(n,{...r,title:t.title,tab:t})},onSaveFileTab:(e,t,r)=>m?.(n,t,r),onOpenFileHistory:(e,t)=>p?.(n,t),onActiveTabChange:(e,t)=>{s(n,{...r,activeTabId:t})}}):(0,ey.jsx)(Hb,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:r.events},r.id)},r.id):(0,ey.jsx)("div",{className:"vtl-agent-pane-empty grid size-full place-items-center p-4",children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-background/90",onClick:o,"data-tour":"pane-add",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加"]})})})}function JL({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xg,{open:e,onOpenChange:t,title:"添加工作区组件",description:"选择一个组件填入当前窗口。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xp,{loop:!0,children:[(0,ey.jsx)(xv,{placeholder:"搜索组件..."}),(0,ey.jsxs)(xx,{children:[(0,ey.jsx)(xy,{children:"没有匹配组件。"}),(0,ey.jsx)(xb,{heading:"可放入窗口",children:jk.map(e=>(0,ey.jsxs)(xw,{"data-tour":`pane-template-${e.id}`,value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e.id),children:[(0,ey.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsx)(xj,{children:"添加"})]},e.id))})]})]})})}function J$({content:e,index:t,conversationId:n,ownerMachineId:r,workspaceFolders:a,onContentChange:i,onOpenWorkspaceFile:o,onSaveFileTab:l,onOpenFileHistory:s,onRequestFileTab:c}){return jC(e)?JM(e.kind,{tab:e.tab,conversationId:n,ownerMachineId:r,terminalScopeId:n?`agent:${n}:pane:${e.id}`:void 0,terminalState:e.terminal,onTerminalStateChange:n=>{JA(e.terminal,n)||i(t,{...e,terminal:n})},workspaceFolders:a,nodeId:e.id,tabs:e.tabs,activeTabId:e.activeTabId,onRequestFileTab:({insertIndex:e})=>c?.(t,e),onOpenWorkspaceFile:o,onTabsChange:(n,r)=>{i(t,{...e,tabs:r,activeTabId:r.some(t=>t.id===e.activeTabId)?e.activeTabId:r[0]?.id})},onTabChange:(n,r)=>{"multi-tab-system"===e.kind?i(t,{...e,tabs:(e.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):i(t,{...e,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>l?.(t,n,r),onOpenFileHistory:(e,n)=>s?.(t,n),onActiveTabChange:(n,r)=>{i(t,{...e,activeTabId:r})}}):(0,ey.jsx)(Hb,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:e.events},e.id)}let JF=[{kind:"status-monitor",label:"状态监控",icon:(0,ey.jsx)(uy,{})},{kind:"plan-doc-viewer",label:"计划文档",icon:(0,ey.jsx)(uj,{})},{kind:"spec-doc-viewer",label:"规范文档",icon:(0,ey.jsx)(Ur,{})},{kind:"browser-tab-viewer",label:"预览窗口",icon:(0,ey.jsx)(Ui,{})},{kind:"diff-tab-viewer",label:"Diff 栏",icon:(0,ey.jsx)(Un,{})},{kind:"terminal-tab-group",label:"终端窗口",icon:(0,ey.jsx)(uO,{})},{kind:"file-tree-panel",label:"文件树",icon:(0,ey.jsx)(Ua,{})},{kind:"file-tab-viewer",label:"文件窗口",icon:(0,ey.jsx)(uC,{})}];function JB(e,t,n){return Math.min(n,Math.max(t,e))}function JV({onAddCard:e,align:t="end"}){return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加窗口",(0,ey.jsx)(vu,{className:"size-3.5 text-muted-foreground"})]})}),(0,ey.jsx)(bZ,{align:t,sideOffset:6,className:"min-w-40",children:JF.map(t=>(0,ey.jsxs)(bJ,{onSelect:()=>e(t.kind),children:[t.icon,(0,ey.jsx)("span",{className:"flex-1",children:t.label})]},t.kind))})]})}function JH({conversationId:e,ownerMachineId:t,panes:n,agentSide:r,columns:a,heights:i,onColumnsChange:o,onHeightsChange:l,onAddCard:s,onContentChange:c,onClear:d,workspaceFolders:u,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:m,onRequestFileTab:p}){let g=n.map((e,t)=>({content:e,index:t})).filter(e=>!!e.content),v=new Map(g.map(e=>[e.content.id,e])),x=g.map(e=>e.content.id).join("|"),y="left"===r,b=ew.useRef(0);0===b.current&&a.length>0&&(b.current=a.reduce((e,t)=>{let n=/^col-(\d+)/.exec(t.key);return n?Math.max(e,Number(n[1])):e},0));let w=ew.useCallback(()=>`col-${b.current+=1}`,[]),j=e=>o("function"==typeof e?e(a):e),k=e=>l("function"==typeof e?e(i):e),[S,N]=ew.useState(null),[C,M]=ew.useState(null),[E,O]=ew.useState(null),P=ew.useRef(null),A=ew.useRef(null),I=ew.useRef(null),z=ew.useRef(null);ew.useEffect(()=>{let e={};j(t=>{let n=new Set(g.map(e=>e.content.id)),r=t.map(e=>({...e,cardIds:e.cardIds.filter(e=>n.has(e))})).filter(e=>e.cardIds.length>0),a=new Set(r.flatMap(e=>e.cardIds)),o=g.map(e=>e.content.id).filter(e=>!a.has(e));if(o.length>0){r=r.map(e=>({...e,cardIds:[...e.cardIds]}));let t=P.current?.clientHeight??0,n=t=>t.cardIds.reduce((t,n,r)=>t+(e[n]??i[n]??320)+12*(r>0),0);for(let a of o){let i=!1;if(t>0)for(let o of r){let r=12*(o.cardIds.length>0),l=t-n(o)-r;if(l>=320){o.cardIds.push(a),i=!0;break}if(l>=140){o.cardIds.push(a),e[a]=Math.floor(l),i=!0;break}}i||(0===r.length||t>0?r.push({key:w(),width:360,cardIds:[a]}):r[0].cardIds.push(a))}}return!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],a=t[n];if(!r||!a||r.key!==a.key||r.width!==a.width||r.cardIds.length!==a.cardIds.length)return!1;for(let e=0;e<r.cardIds.length;e+=1)if(r.cardIds[e]!==a.cardIds[e])return!1}return!0}(t,r)?r:t}),Object.keys(e).length>0&&k(t=>({...t,...e}))},[x,w]);let T=e=>i[e]??320;ew.useEffect(()=>{if(!S)return;let e=e=>{A.current?function(e,t){let n=P.current,r=A.current;if(!n||!r)return;let a=Array.from(n.querySelectorAll("[data-card-id]")),i=null,o=null,l=1/0;for(let n of a){let a=n.dataset.cardId;if(!a||a===r)continue;let s=n.getBoundingClientRect(),c=Math.max(s.left-e,0,e-s.right),d=Math.max(s.top-t,0,t-s.bottom),u=c*c+d*d;u<l&&(l=u,i=a,o=s)}if(!i||!o){I.current=null,O(null);return}let s=e-o.left,c=o.right-e,d=t-o.top,u=o.bottom-t,f=Math.min(s,c,d,u),h=f===d?"top":f===u?"bottom":f===s?"left":"right";I.current={id:i,edge:h};let m=n.getBoundingClientRect();O(function(e,t){switch(t){case"top":return{left:e.left,top:e.top-6-2,width:e.width,height:4};case"bottom":return{left:e.left,top:e.top+e.height+6-2,width:e.width,height:4};case"left":return{left:e.left-6-2,top:e.top,width:4,height:e.height};case"right":return{left:e.left+e.width+6-2,top:e.top,width:4,height:e.height}}}({left:o.left-m.left,top:o.top-m.top,width:o.width,height:o.height},h))}(e.clientX,e.clientY):z.current&&function(e,t){let n=z.current;if(!n)return;if("width"===n.kind){let t=JB(n.startWidth+(e-n.startX)*n.factor,240,760);j(e=>e.map(e=>e.key===n.columnKey?{...e,width:t}:e));return}if("growHeight"===n.kind){let e=Math.max(140,n.h0+(t-n.startY));k(t=>({...t,[n.cardId]:e}));return}let r=n.hA+n.hB,a=JB(n.hA+(t-n.startY),140,r-140);k(e=>({...e,[n.aboveId]:a,[n.belowId]:r-a}))}(e.clientX,e.clientY)},t=()=>(function(){let e=A.current;if(e){var t,n;let r=I.current;A.current=null,I.current=null,M(null),O(null),N(null),r&&(t=r.id,n=r.edge,e&&e!==t&&j(r=>{let a=r.map(e=>({...e,cardIds:[...e.cardIds]}));for(let t of a){let n=t.cardIds.indexOf(e);n>=0&&t.cardIds.splice(n,1)}let i=-1,o=-1;a.forEach((e,n)=>{let r=e.cardIds.indexOf(t);r>=0&&(i=n,o=r)});let l=a[i];if(!l)return r;if("top"===n||"bottom"===n)l.cardIds.splice("top"===n?o:o+1,0,e);else{let t=(y?"right"===n:"left"===n)?i:i+1;a.splice(t,0,{key:w(),width:a[i]?.width??360,cardIds:[e]})}return a.filter(e=>e.cardIds.length>0)}));return}z.current&&(z.current=null,N(null))})();return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[S]);let D=a.map((e,t)=>({column:e,realIndex:t}));y&&D.reverse();let R=(0,ey.jsx)("div",{className:(0,eI.cn)("flex shrink-0 px-3 py-2",y?"justify-end":"justify-start"),children:(0,ey.jsx)(JV,{onAddCard:s,align:y?"end":"start"})});return 0===g.length?null:(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col",children:[R,(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",children:(0,ey.jsxs)("div",{ref:P,className:"relative flex min-h-full items-start gap-3",children:[D.map(({column:n})=>{let r=[],i=0;for(let e=0;e<n.cardIds.length;e+=1)i+=T(n.cardIds[e]),e<n.cardIds.length-1&&(r.push(i+6),i+=12);let o=i,l=n.cardIds[n.cardIds.length-1],s=1===n.cardIds.length&&v.get(n.cardIds[0])?.content.kind==="status-monitor";return(0,ey.jsxs)("div",{className:(0,eI.cn)("relative flex shrink-0 flex-col gap-3",s&&"h-full"),style:{width:n.width},children:[n.cardIds.map(n=>{let r=v.get(n);if(!r)return null;let{content:a,index:i}=r;return(0,ey.jsxs)("div",{"data-card-id":a.id,style:s?void 0:{height:T(a.id)},className:(0,eI.cn)("group/card relative flex w-full flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm",s?"min-h-0 flex-1":"shrink-0",C===a.id?"opacity-40":"opacity-100"),children:[(0,ey.jsxs)("div",{onPointerDown:e=>{var t;return t=a.id,void(0===e.button&&(e.preventDefault(),e.stopPropagation(),A.current=t,I.current=null,M(t),O(null),N("drag")))},className:"flex shrink-0 cursor-grab touch-none select-none items-center justify-between gap-2 border-b border-border/60 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,ey.jsx)(fj,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.title})]}),(0,ey.jsx)("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:()=>d(i),"aria-label":"关闭窗口",title:"关闭窗口",className:"grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:(0,ey.jsx)(fg.XIcon,{})})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,ey.jsx)(J$,{content:a,index:i,conversationId:e,ownerMachineId:t,workspaceFolders:u,onContentChange:c,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:m,onRequestFileTab:p})})]},a.id)}),n.cardIds.slice(0,-1).map((e,t)=>(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:r=>{var a;return a=n.cardIds[t+1],void(0===r.button&&(r.preventDefault(),r.stopPropagation(),z.current={kind:"height",aboveId:e,belowId:a,startY:r.clientY,hA:T(e),hB:T(a)},N("resize")))},style:{top:r[t]??0},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})},`hbar-${e}`)),l&&!s?(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),z.current={kind:"growHeight",cardId:l,startY:e.clientY,h0:T(l)},N("resize"))},style:{top:o+6},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})}):null,(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>(function(e,t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation();let n=a.find(t=>t.key===e)?.width??360;z.current={kind:"width",columnKey:e,startX:t.clientX,startWidth:n,factor:y?-1:1},N("resize")})(n.key,e),style:y?{left:-6}:{right:-6},className:(0,eI.cn)("group/wbar absolute inset-y-0 z-10 flex w-3 cursor-ew-resize items-center justify-center",y?"-translate-x-1/2":"translate-x-1/2"),children:(0,ey.jsx)("span",{className:"h-12 w-1 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/wbar:opacity-100"})})]},n.key)}),E?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute z-40 rounded-full bg-muted-foreground/70",style:{left:E.left,top:E.top,width:E.width,height:E.height}}):null]})}),S?(0,ey.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 z-50",style:{cursor:"drag"===S?"grabbing":z.current?.kind==="width"?"ew-resize":"ns-resize"}}):null]})}let JU="vtl:workspace-layout-mode",JW="vtl:workspace-agent-side",Jq="vtl:workspace-layout-changed",JK={mode:"pane",agentSide:"left"};function JG(){let e=JK.mode,t=JK.agentSide;try{let n=window.localStorage.getItem(JU);("pane"===n||"card"===n||"control-room"===n)&&(e=n);let r=window.localStorage.getItem(JW);("left"===r||"right"===r)&&(t=r)}catch{}return{mode:e,agentSide:t}}function JX(e){try{e.mode&&window.localStorage.setItem(JU,e.mode),e.agentSide&&window.localStorage.setItem(JW,e.agentSide)}catch{}window.dispatchEvent(new CustomEvent(Jq))}function JY({stack:e,rootTitle:t,rootOwnerMachineId:n,onNavigateRoot:r,onNavigateIndex:a,onOpenSubagent:i}){let o=e[e.length-1],[l,s]=ew.useState(null);if(ew.useEffect(()=>{let e;if(!o)return;let t=!1;async function r(){try{let a=await sA(o.id,n);if(t)return;s(a);let i="working"===a.conversation.status||!!a.conversation.running;e=window.setTimeout(r,i?900:5e3)}catch{if(t)return;e=window.setTimeout(r,3e3)}}return s(null),r(),()=>{t=!0,e&&window.clearTimeout(e)}},[o,n]),!o)return null;let c=l?.conversation.status??"working",d="working"===c||!!l?.conversation.running;return(0,ey.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-background",children:[(0,ey.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,ey.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:r,children:t||"主对话"}),e.map((t,n)=>{let r=Hn(t.subagentType),i=n===e.length-1,o=r.Icon;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(mQ,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 transition-colors hover:bg-accent/50",i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>a(n),children:[(0,ey.jsx)(o,{className:(0,eI.cn)("size-3",r.color)}),(0,ey.jsx)("span",{className:"max-w-[10rem] truncate",children:t.name||`${r.label}子代理`})]})]},t.id)}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 pl-2",children:d?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"paused"===c?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,ey.jsx)(hM,{className:"size-3"}),"已暂停"]}):(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-500",children:[(0,ey.jsx)(eO,{className:"size-3"}),"完成"]})})]}),(0,ey.jsx)("div",{className:"relative min-h-0 flex-1",children:l?(0,ey.jsx)(VY,{events:l.events,bottomInset:16,contentClassName:"max-w-[42.5rem]",onOpenSubagent:e=>i(e),labels:{recall:"召回",branch:"分支",expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"}}):(0,ey.jsxs)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"mr-2 size-4 animate-spin"}),"正在打开子代理对话…"]})})]})}let JZ=[],JJ="vantaloom:file-system-changed";function JQ(e,t){let n;if(0===t.length)return e;let r=new Map;for(let t=0;t<e.length;t+=1){let n=e[t]?.id;n&&r.set(n,t)}for(let a of t){let t=a?.id,i=t?r.get(t):void 0;if(void 0!==i){if(e[i]===a)continue;n||(n=e.slice()),n[i]=a}else n||(n=e.slice()),t&&r.set(t,n.length),n.push(a)}return n??e}function J0(e,t){if(0===e.length)return t;let n=new Set;for(let e of t)e?.id&&n.add(e.id);let r=e.filter(e=>e?.id&&!n.has(e.id));return 0===r.length?t:[...r,...t]}function J1(e){var t;let n=(t=e?.layoutMode,JI.some(e=>e.id===t)?t:"quad"),r="right"===e?.agentPosition?"right":"left",a=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return{};let t=e.shell&&"object"==typeof e.shell&&!Array.isArray(e.shell)?e.shell:void 0,n={};for(let e of["agent","panes"]){let r=t?.[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(n[e]=r)}return{...Object.keys(n).length?{shell:n}:{},outer:J2(e.outer),left:J2(e.left),right:J2(e.right),top:J2(e.top),bottom:J2(e.bottom)}}(e?.sizes),i=Array.from({length:Math.max(4,JI.find(e=>e.id===n)?.slots??4)},()=>void 0);for(let[t,n]of(e?.panes??[]).entries()){let e=Number.isInteger(n.slot)?n.slot:t;e<0||e>=i.length||(i[e]=function(e,t){var n,r;let a=e.paneId||`${e.kind}-${t+1}`,i=!(n=e.props)||"object"!=typeof n||Array.isArray(n)?{}:n;if("subagent-conversation-panel"===e.kind)return{id:a,kind:"subagent-conversation-panel",title:J4(i.title)??"Subagent",subagentId:J4(i.subagentId)??a,events:Array.isArray(i.events)?i.events:[]};if(!jS(e.kind))return;let o=i.tab&&"object"==typeof i.tab?i.tab:void 0,l=Array.isArray(i.tabs)?i.tabs.filter(e=>uB(e?.kind)):void 0,s=jS(e.kind);return{id:a,kind:e.kind,title:J4(i.title)??o?.title??s?.title??"组件",tab:o,tabs:l,activeTabId:J4(i.activeTabId),terminal:"terminal-tab-group"===e.kind?!(r=i.terminal)||"object"!=typeof r||Array.isArray(r)?{sessionIds:[]}:{sessionIds:Array.isArray(r.sessionIds)?r.sessionIds.filter(e=>"string"==typeof e):[],activeSessionId:J4(r.activeSessionId),selectedMachineId:J4(r.selectedMachineId),selectedShellId:J4(r.selectedShellId),autoStart:"boolean"==typeof r.autoStart?r.autoStart:void 0,aiControlledSessionIds:Array.isArray(r.aiControlledSessionIds)?r.aiControlledSessionIds.filter(e=>"string"==typeof e):void 0}:void 0}}(n,t))}return{layoutMode:n,agentPosition:r,layoutSizes:a,panes:i,cardColumns:Array.isArray(e?.cardLayout?.columns)?e.cardLayout.columns.filter(e=>e&&"string"==typeof e.key&&Array.isArray(e.cardIds)).map(e=>({key:e.key,width:"number"==typeof e.width&&e.width>0?e.width:360,cardIds:e.cardIds.filter(e=>"string"==typeof e)})):[],cardHeights:e?.cardLayout?.heights&&"object"==typeof e.cardLayout.heights?e.cardLayout.heights:{}}}function J2(e){if(!Array.isArray(e))return;let t=e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0);return t.length?t:void 0}function J5(e){return e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0)}function J4(e){return"string"==typeof e&&e.trim()?e:void 0}function J3(e){let t=e?.id.match(/-(\d+)$/);return t?Number(t[1]):0}function J6(e){return e.reduce((e,t)=>Math.max(e,J3(t)),0)}function J8({conversation:e,clipboardItems:t,clipboardDraggingId:n,onClipboardItemsChange:r,onClipboardDraggingChange:a,onOverlayOpenChange:i,onConversationCreated:o,onCancelDraft:l,subagentStack:s=[],onSubagentStackChange:c,subagentTree:d=[],mobileView:u="conversation",onMobilePaneCountChange:f}){let h=sb(),m=ew.useRef(null),p=ew.useRef(void 0),g=J1(e?.panes),[v,x]=ew.useState(g.layoutMode),[y,b]=ew.useState(g.agentPosition),w=function(){let[e,t]=ew.useState(JK);return ew.useEffect(()=>{t(JG());let e=()=>t(JG());return window.addEventListener(Jq,e),window.addEventListener("storage",e),()=>{window.removeEventListener(Jq,e),window.removeEventListener("storage",e)}},[]),e}(),j="card"===w.mode,[k,S]=ew.useState(!1),[N,C]=ew.useState(!1);ew.useEffect(()=>{try{C("1"===window.localStorage.getItem("vtl:agent-panes-collapsed"))}catch{}},[]);let M=ew.useCallback(()=>{C(e=>{let t=!e;try{window.localStorage.setItem("vtl:agent-panes-collapsed",t?"1":"0")}catch{}return t})},[]),[E,O]=ew.useState(g.layoutSizes),[P,A]=ew.useState(()=>g.panes),[I,z]=ew.useState(()=>g.cardColumns),[T,D]=ew.useState(()=>g.cardHeights),[R,_]=ew.useState(()=>e?.events??[]),[L,$]=ew.useState(()=>e?.eventsStart??0),[F,B]=ew.useState(()=>e?.eventsTotal??e?.events?.length??0),[V,H]=ew.useState(!1),U=L>0,[W,q]=ew.useState(null),[K,G]=ew.useState(new Set),[X,Y]=ew.useState(void 0),[Z,J]=ew.useState(()=>H8(e?.conversation.id)),Q=ew.useCallback(t=>{J(t),function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(H6(e));window.localStorage.setItem(H6(e),t.slice(0,1e5))}catch{}}(e?.conversation.id,t)},[e?.conversation.id]),[ee,et]=ew.useState(()=>H9(e?.conversation.id)),[en,er]=ew.useState([]),[ea,ei]=ew.useState(void 0),[eo,el]=ew.useState(!1),[es,ec]=ew.useState(!1),[ed,eu]=ew.useState(""),[ef,eh]=ew.useState(e?.conversation.status==="working"),[em,ep]=ew.useState(e?.conversation.status??"idle"),[eg,ev]=ew.useState(e?.conversation.settings?.permissionMode??"acceptEdits"),[ex,eb]=ew.useState([]),[ej,ek]=ew.useState(e?.conversation.tokens??0),[eS,eN]=ew.useState(e?.conversation.runUsage),[eC,eM]=ew.useState(e?.conversation.contextTokens??0),[eE,eO]=ew.useState(!1),eP=ew.useRef(em),[ez,eT]=ew.useState(),[e_,eL]=ew.useState(),[e$,eF]=ew.useState(),eB=ew.useRef(J6(g.panes)),eV=ew.useRef(0),eH=ew.useRef(""),eU=JI.find(e=>e.id===v)?.slots??4,eW=e?.conversation.settings.folders??JZ,{models:eq}=vq(),eK=ew.useMemo(()=>{let t=e?.conversation.settings.mainModels??[];return t.length?eq.filter(e=>t.includes(e.value)).map(e=>({id:e.value,label:e.label})):[]},[eq,e?.conversation.settings.mainModels]),eG=ja(e?.conversation.settings.engine),eX=ew.useMemo(()=>{if(eG){let t,n=e?.conversation.settings.ccModel;return[{id:n&&""!==n?n:"__cc_model__",label:(t=n&&""!==n?n:jn,jr.find(e=>e.value===t)?.label??n??""),disabled:!0}]}return eK},[eG,e?.conversation.settings.ccModel,eK]),eY=!eG&&0===eK.length,[eZ,eJ]=ew.useState(!1),eQ=ef||"working"===em||eZ,e0=ew.useCallback(async t=>{if(!e||eE)return;let n=e.conversation.id,r=e.conversation.ownerMachineId;if(eG){if(eQ)return void await s2(n,"请执行 /compact 压缩上下文。",r);eh(!0),ep("working");try{let e=await sG(n,{message:"/compact",modelRef:"",mode:"agent"},r);ep(e.conversation.status)}catch(e){eh(!1),ep("idle"),h$.error(e instanceof Error?e.message:"压缩请求失败")}return}if(eQ)return void await s2(n,"precise"===t?"请在完成当前小任务后进行精确压缩(去除冗余文件读取和旧工具输出)。":"请在完成当前小任务后进行极致压缩(AI摘要),以便继续工作。",r);eO(!0);try{await s5(n,t,void 0,r);let e=await sA(n,r);e&&(_(e.events),$(e.eventsStart??0),B(e.eventsTotal??e.events.length),ek(e.conversation.tokens??0),eN(e.conversation.runUsage),eM(e.conversation.contextTokens??0))}catch{}finally{eO(!1)}},[e,eE,eQ,eG]),e1=ew.useMemo(()=>{if(!e)return;let t=eq.find(e=>e.value===ed),n=t?.contextLength||200,r=e.conversation.contextTokens??0,a=r>0?r:eC,i=a>0?a:ej;return{used:i,total:1e3*n,toolCalls:i,userMessages:0,other:void 0,onCompressPrecise:()=>e0("precise"),onCompressExtreme:()=>e0("extreme"),compressing:eE}},[e,eq,ed,ej,eC,e0,eE]),e2=ew.useMemo(()=>{let t=e?.conversation.rounds;if(t?.length)return t;let n=[];for(let e of R){if("user"!==e.kind)continue;let t=n.length,r=(e.title??"").replace(/\s+/g," ").trim(),a=(r?r.slice(0,28):"")||`第 ${t+1} 轮`;n.push({runId:e.id,index:t,anchorEventId:e.id,title:a,summary:a,createdAt:""})}return n},[e?.conversation.rounds,R]),e5=ew.useCallback(async t=>{let n=e?.conversation.id,r=t.anchorEventId??R.find(e=>e.id.startsWith(`${t.runId}-`))?.id??R.find(e=>e.id===t.runId)?.id;if(r){if(R.some(e=>e.id===r))return void m.current?.scrollToEvent(r);if(n&&L>0)try{let t=await sI(n,{fromEventId:r,end:L},e?.conversation.ownerMachineId);t.events.length>0&&(_(e=>J0(t.events,e)),$(t.start),t.total>0&&B(t.total))}catch{}window.setTimeout(()=>{m.current?.scrollToEvent(r)},60)}},[e?.conversation.id,e?.conversation.ownerMachineId,R,L]),e4=ew.useCallback(t=>{let n;if(t&&function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(Ue(e));window.localStorage.setItem(Ue(e),t)}catch{}}(e?.conversation.id,t),!t)return void Y(void 0);let r=R.findIndex(e=>e.id===t);if(r>=0)for(let e of e2){let t=e.anchorEventId??e.runId,a=R.findIndex(e=>e.id===t);a>=0&&a<=r&&(n=e.runId)}n||(n=e2.find(e=>t===e.runId||t.startsWith(`${e.runId}-`))?.runId),Y(n)},[e?.conversation.id,R,e2]),e3=ew.useCallback(async e=>{if("file-tab-viewer"!==e.kind||e.modified||e.file?.readOnly)return e;try{var t,n;let r=await u9(e);return(t=e,n=r,t.defaultValue!==n.defaultValue||t.title!==n.title||t.file?.size!==n.file?.size||t.file?.mimeType!==n.file?.mimeType||t.file?.previewContent!==n.file?.previewContent||t.file?.src!==n.file?.src||t.file?.truncated!==n.file?.truncated)?r:e}catch{return e}},[]),e6=ew.useCallback(async e=>{if(!e||!jC(e))return e;if("multi-tab-system"===e.kind){var t,n;let r=e.tabs??[],a=await Promise.all(r.map(e3));return(t=r,n=a,t.length!==n.length||t.some((e,t)=>e!==n[t]))?{...e,tabs:a}:e}if("file-tab-viewer"===e.kind&&e.tab){let t=await e3(e.tab);return t!==e.tab?{...e,title:t.title,tab:t}:e}return e},[e3]),e8=ew.useCallback(async()=>{var e,t;let n=await Promise.all(P.map(async e=>e6(e)));e=P,t=n,(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&A(n)},[P,e6]);ew.useEffect(()=>{i?.(void 0!==ez||void 0!==e_||void 0!==e$)},[e_,e$,i,ez]);let e7=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.events??[];if(e7.current!==t){e7.current=t,_(n),$(e?.eventsStart??0),B(e?.eventsTotal??n.length);return}_(e=>JQ(e,n))},[e?.conversation.id,e?.events]);let e9=ew.useCallback(async()=>{let t=e?.conversation.id;if(t&&!(L<=0)&&!V){H(!0);try{let n=await sI(t,{end:L,limit:200},e?.conversation.ownerMachineId);n.events.length>0&&_(e=>J0(n.events,e)),$(e=>n.events.length>0?n.start:Math.max(0,e-200)),n.total>0&&B(n.total)}finally{H(!1)}}},[e?.conversation.id,e?.conversation.ownerMachineId,L,V]);function te(e){if(!e.length)return;let t=e.map(jE);r(e=>[...t,...e.filter(e=>!t.some(t=>t.id===e.id))])}function tt(e,t,n){if(!e||!jC(e))return e;if("multi-tab-system"===e.kind){var r;let a,i;return{...e,tabs:(r=e.tabs??[],a=r.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}return"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e}function tn(e,t){return e&&jC(e)?"multi-tab-system"===e.kind?{...e,tabs:(e.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}:"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e:e}function tr(e){A(t=>{let n=t.findIndex(e=>void 0===e);return n>=0?t.map((t,r)=>r===n?e:t):[...t,e]})}function ta(e){eB.current+=1;let t=jN(e,`${e}-${eB.current}`);if("browser-tab-viewer"===e&&t.tab){let e=t.tab;eR().then(n=>{tr(n.length>0?{...t,tab:{...e,defaultUrl:n[0]}}:t)});return}tr(t)}ew.useEffect(()=>{let t=e?.conversation.id;if(!t||0===R.length||p.current===t)return;p.current=t;let n=function(e){if(e)try{return window.localStorage.getItem(Ue(e))??void 0}catch{return}}(t),r=R[R.length-1]?.id;if(!n||n===r||!R.some(e=>e.id===n))return;let a=window.setTimeout(()=>{m.current?.scrollToEvent(n)},80);return()=>window.clearTimeout(a)},[e?.conversation.id,R.length]),ew.useEffect(()=>{J(H8(e?.conversation.id)),et(H9(e?.conversation.id)),er([]),ei(void 0),G(new Set)},[e?.conversation.id]),ew.useEffect(()=>{eh(e?.conversation.status==="working"),ep(e?.conversation.status??"idle")},[e?.conversation.id,e?.conversation.status]),ew.useEffect(()=>{ek(e?.conversation.tokens??0),eN(e?.conversation.runUsage),eM(e?.conversation.contextTokens??0)},[e?.conversation.id,e?.conversation.tokens,e?.conversation.runUsage,e?.conversation.contextTokens]),ew.useEffect(()=>{ev(e?.conversation.settings?.permissionMode??"acceptEdits")},[e?.conversation.id,e?.conversation.settings?.permissionMode]),ew.useEffect(()=>{let e=eK[0]?.id??"";eu(t=>eK.some(e=>e.id===t)?t:e)},[eK]),ew.useEffect(()=>{let t=J1(e?.panes);x(t.layoutMode),b(t.agentPosition),O(t.layoutSizes),A(t.panes),z(t.cardColumns),D(t.cardHeights),eB.current=J6(t.panes)},[e?.conversation.id,e?.panes]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n)return;let a=!1,i=e=>{_(t=>JQ(t,e.events)),ep(e.conversation.status),ek(e.conversation.tokens??0),eN(e.conversation.runUsage)},o=e=>{void 0===t&&(t=window.setInterval(async()=>{try{let e=await sA(n,r);if(a)return;i(e),eh("working"===e.conversation.status)}catch{return}},e))};if(r&&"local"!==r)return o(600),()=>{a=!0,void 0!==t&&window.clearInterval(t)};let l=e?.conversation.lastSeq??0,s=new EventSource(eD(`/api/local/agent/conversations/${encodeURIComponent(n)}/events/stream?after=${l}`));return s.addEventListener("detail",e=>{try{let t=s4(JSON.parse(e.data));i(t),eh("working"===t.conversation.status)}catch{return}}),s.onerror=()=>{s.close(),o(350)},()=>{a=!0,s.close(),void 0!==t&&window.clearInterval(t)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{if(!e?.conversation.id)return;let t=window.setInterval(()=>{e8()},3e3);return()=>window.clearInterval(t)},[e?.conversation.id,e8]),ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t)return;let r=!1;sV(t,n);let a=window.setInterval(()=>{r||sV(t,n)},3e4);return()=>{r=!0,window.clearInterval(a),sH(t,n)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{let e=R.filter(e=>"change"===e.kind).map(e=>`${e.id}:${e.status??""}:${e.isStreaming?"1":"0"}`).join("|");e&&e!==eH.current&&(eH.current=e,window.dispatchEvent(new CustomEvent(JJ)),e8())},[R,e8]),ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return;let n=window.setTimeout(()=>{var n;let r;sK(t,(n={columns:I,heights:T},r=[],P.forEach((e,t)=>{if(e){if(jC(e))return void r.push({paneId:e.id,slot:t,kind:e.kind,machineId:e.terminal?.selectedMachineId,resourceId:e.terminal?.activeSessionId,props:{title:e.title,tab:e.tab,tabs:e.tabs,activeTabId:e.activeTabId,terminal:e.terminal}});r.push({paneId:e.id,slot:t,kind:e.kind,props:{title:e.title,subagentId:e.subagentId,events:e.events}})}}),{layoutMode:v,agentPosition:y,sizes:E,cardLayout:n,panes:r}),e?.conversation.ownerMachineId)},300);return()=>window.clearTimeout(n)},[y,I,T,e?.conversation.id,v,E,P]);let ti=ew.useCallback(e=>{A(t=>{let n=t.findIndex(e=>e?.kind==="browser-tab-viewer");if(n>=0){let r=t[n];return r&&jC(r)&&r.tab&&(!r.tab.defaultUrl||r.tab.defaultUrl.startsWith("https://vantaloom.local"))?t.map((t,a)=>a===n&&r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:t):t}eB.current+=1;let r=jN("browser-tab-viewer",`browser-tab-viewer-${eB.current}`),a=void 0!==r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:r,i=t.findIndex(e=>void 0===e);return i>=0?t.map((e,t)=>t===i?a:e):j?[...t,a]:t})},[j]),to=ew.useRef(!1);function tl(e){A(t=>{if(t.findIndex(t=>t?.kind===e)>=0)return t;eB.current+=1;let n=jN(e,`${e}-${eB.current}`),r=t.findIndex(e=>void 0===e);return r>=0?t.map((e,t)=>t===r?n:e):j?[...t,n]:t})}ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t||n&&"local"!==n)return;to.current=!1;let r=!1,a=async()=>{if(!r&&!to.current)try{let e=(await eR())[0];if(r||to.current||!e)return;to.current=!0,ti(e)}catch{}};a();let i=window.setInterval(a,3e3);return()=>{r=!0,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId,ti]);let ts=ew.useCallback((e,t)=>{A(n=>{if(n.some(n=>void 0!==n&&jC(n)&&(n.id===t||(n.terminal?.sessionIds??[]).includes(e.id))))return n;let r={...jN("terminal-tab-group",t),terminal:{sessionIds:[e.id],activeSessionId:e.id,autoStart:!1,aiControlledSessionIds:[e.id],selectedMachineId:e.machineId}},a=n.findIndex(e=>void 0===e);return a>=0?n.map((e,t)=>t===a?r:e):j?[...n,r]:n})},[j]),tc=ew.useRef(new Set);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t||n&&"local"!==n)return;tc.current=new Set;let r=`agent:${t}:pane:`,a=!1,i=async()=>{if(!a)try{let{sessions:e}=await fd();if(a)return;for(let t of e){if(!0!==t.aiControlled||"agent"!==t.controller||!t.scopeId||!t.scopeId.startsWith(r)||tc.current.has(t.id))continue;let e=t.scopeId.slice(r.length);e&&(tc.current.add(t.id),ts(t,e))}}catch{}};i();let o=window.setInterval(i,4e3);return()=>{a=!0,window.clearInterval(o)}},[e?.conversation.id,e?.conversation.ownerMachineId,ts]);let tf=ew.useCallback(()=>{tl("plan-doc-viewer")},[j]),th=ew.useCallback(()=>{tl("spec-doc-viewer")},[j]);ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return void q(null);let n=e?.conversation.ownerMachineId,r=!0,a=async()=>{let e=await sD(t,n);r&&q(e.planState)};a();let i=window.setInterval(a,1500);return()=>{r=!1,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId]);let tm=e?.conversation.planState??W,tp=ew.useRef(void 0);function tg(e,t){A(n=>{let r=n.findIndex(t=>t?.kind===e);if(r>=0)return n.map((n,a)=>a===r&&n?{id:n.id,kind:e,title:t.title,tab:t}:n);eB.current+=1;let a={id:`${e}-${eB.current}`,kind:e,title:t.title,tab:t},i=n.findIndex(e=>void 0===e);return i>=0?n.map((e,t)=>t===i?a:e):[...n,a]})}async function tv(e,t,n){try{let r=await u8(e);if(j)return void tg("file-tab-viewer",r);A(e=>e.map((e,a)=>a===t?tt(e,r,n):e))}catch{h$.error("文件预览打开失败")}}function tx(e){if(j)return void tv(e,-1);let t=P.slice(0,eU).findIndex(e=>e?.kind==="multi-tab-system");t<0?h$.warning("请先放入一个多标签页组件"):tv(e,t)}function ty(e){let t=e.path?.trim()||e.name.trim();("diff"===e.kind||"diff"===e.meta)&&e.diff?function(e){let t=e.path?.trim()||e.name.trim(),n={id:function(e,t){let n=0x811c9dc5;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e}-${(n>>>0).toString(36)}`}("diff",`${e.mutationId??""}|${e.machineId??"local"}|${t}|${e.diff??""}`),kind:"diff-tab-viewer",title:`Diff ${e.name}`,file:{name:e.name,path:t,machineId:e.machineId??"local",kind:"code"},diff:e.diff};if(j)return tg("diff-tab-viewer",n);let r=P.slice(0,eU).findIndex(e=>e?.kind==="multi-tab-system");r<0?h$.warning("请先放入一个多标签页组件"):A(e=>e.map((e,t)=>t===r?tt(e,n):e))}(e):!t||e.meta?.toLowerCase().startsWith("depth")||tx({machineId:e.machineId??"local",path:t})}ew.useEffect(()=>{let e=tm?.approvals?.find(e=>!e.decision);e&&tp.current!==e.id&&(tp.current=e.id,tf())},[tm,tf]);let tb=e?.conversation.ownerMachineId??"local",tw=ew.useMemo(()=>{let e=e=>/^https?:\/\//i.test(e)||e.startsWith("data:"),t=async e=>{let{target:t,kind:n,label:r}=e;try{if("url"===n)return void window.open(t,"_blank","noopener,noreferrer");if("local-file"===n){let e=await fetch(eD(`/v1/files/reveal?path=${encodeURIComponent(t)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}return}let e=await uG(tb,t);if("utf-8"===e.encoding&&"folder"!==e.kind&&!e.truncated)return void tx({machineId:tb,path:t});let a=eD(`/v1/remote/${encodeURIComponent(tb)}/files/raw?path=${encodeURIComponent(t)}`);await mq({url:a,label:r}),h$.success(`已开始下载「${r}」,可在 系统设置 → 下载 查看进度`)}catch(e){h$.error(`打开交付物失败:${e instanceof Error?e.message:String(e)}`)}};return{resolveImageSrc:t=>{if(e(t))return t;let n=`path=${encodeURIComponent(t)}`;return"local"===tb?eD(`/v1/files/raw?${n}`):eD(`/v1/remote/${encodeURIComponent(tb)}/files/raw?${n}`)},classify:t=>e(t)?"url":"local"===tb?"local-file":"remote-file",onOpen:e=>void t(e)}},[tb]);async function tj(e,t,n){let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw h$.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uX({machineId:a,path:r,content:n}),o={...await u7(i,{id:t.id,title:t.title,defaultView:t.defaultView,defaultMode:t.defaultMode}),modified:!1};A(t=>t.map((t,n)=>n===e?tn(t,o):t)),window.dispatchEvent(new CustomEvent(JJ)),h$.success("文件已保存")}catch(e){throw h$.error("文件保存失败"),e}}async function tk(t){let n=e?.conversation.id,r=e$?.tab.file?.path,a=e$?.tab.file?.machineId??"local";if(e$&&n&&r)try{let i=await sQ(n,{machineId:a,path:r,mutationId:t.mutationId,state:t.state},e?.conversation.ownerMachineId),o=await u7(i,{id:e$.tab.id,title:`${i.name} @ ${J9(t.mutationId)} ${"before"===t.state?"before":"after"}`,readOnly:!0,defaultView:e$.tab.defaultView,defaultMode:"review"});A(e=>e.map((e,t)=>t===e$.paneIndex?tn(e,o):e)),eF(void 0)}catch{h$.error("历史版本打开失败")}}function tS(e,t,n){let i=P[e];eB.current=Math.max(eB.current,J3(n)),A(t=>t.map((t,r)=>r===e?n:t)),r(e=>{let n=e.filter(e=>e.id!==t.id);if(!i)return n;let r=jE(i);return[r,...n.filter(e=>e.id!==r.id)]}),a?.(void 0)}function tN(e,t){A(n=>n.map((n,r)=>r===e?t:n))}function tC(t){return{id:t.id,ownerMachineId:t.ownerMachineId??e?.conversation.ownerMachineId,name:t.name,subagentType:t.subagentType}}function tM(e){var t=P[e];if(t&&jC(t)&&"terminal-tab-group"===t.kind)for(let e of t.terminal?.sessionIds??[])ff(e).catch(()=>{});A(t=>t.map((t,n)=>n===e?void 0:t))}function tE(e){let t=P[e];t&&te([t]),A(t=>t.map((t,n)=>n===e?void 0:t))}async function tO(t,n="chat",r=[]){let a=e?.conversation.id,i=eG?"":ed||eK[0]?.id||"";if(!a||(t.trim()&&et(function(e,t){let n=t.trim();if(!n)return H9(e);let r=n.slice(0,1e5),a=H9(e);if(a[a.length-1]===r)return a;let i=[...a,r].slice(-100);if(e&&1)try{window.localStorage.setItem(H7(e),JSON.stringify(i))}catch{}return i}(a,t)),ef||"working"===em))return;if(!eG&&!i)return void h$.error("请先在代理模型配置里选择模型");G(function e(t,n=new Set){for(let r of t)n.add(r.id),e(r.children??[],n);return n}(d));let o=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?""!==e.data:(e.text??"")!=="");eh(!0),ep("working");try{let r=await sG(a,{message:t,modelRef:i,mode:n,attachments:o.length>0?o:void 0},e?.conversation.ownerMachineId);ep(r.conversation.status)}catch(e){eh(!1),ep("idle"),h$.error(e instanceof Error?e.message:"对话请求失败")}}async function tP(t){let n=e?.conversation.id,r="string"==typeof t.modelRef?t.modelRef.trim():"",a=eG?"":r||ed||eK[0]?.id||"",i="agent"===t.mode?"agent":"chat";if(n){if(!eG&&!a)return void h$.error("请先在代理模型配置里选择模型");eh(!0),ep("working"),_(e=>e.map(e=>e.id===t.id?{...e,status:"retried"}:e));try{let r=await sX(n,{modelRef:a,mode:i,retryEventId:t.id},e?.conversation.ownerMachineId);ep(r.conversation.status)}catch(e){_(e=>e.map(e=>e.id===t.id?t:e)),eh(!1),ep("idle"),h$.error(e instanceof Error?e.message:"对话重试失败")}}}function tA(e){eQ?h$.error("对话正在运行,请先停止后再回退"):ei(e)}async function tI(){let t=e?.conversation.id;if(!ea||!t)return void ei(void 0);el(!0);try{let n=await sY(t,ea.id,e?.conversation.ownerMachineId);_(n.detail.events),$(0),B(n.detail.events.length),ep(n.detail.conversation.status),eh(!1),Q(n.prompt),c?.([]);let r=[];n.revertedFiles>0&&r.push(`恢复 ${n.revertedFiles} 个文件`),n.deletedFiles>0&&r.push(`删除 ${n.deletedFiles} 个新增文件`),n.archivedSubagents>0&&r.push(`归档 ${n.archivedSubagents} 个子代理`),h$.success(r.length?`已回退:${r.join(",")}`:"已回退到此处"),n.skippedRemote&&n.skippedRemote.length>0&&h$.warning(`${n.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){h$.error(e instanceof Error?e.message:"回退失败")}finally{el(!1),ei(void 0)}}async function tz(t){let n=e?.conversation.id;if(n&&!es){ec(!0);try{let r=await sZ(n,t.id,e?.conversation.ownerMachineId);o?.(r),h$.success("已创建分支对话")}catch(e){h$.error(e instanceof Error?e.message:"创建分支失败")}finally{ec(!1)}}}async function tT(t){let n=e?.conversation.id;if(n)try{let r=e?.conversation.settings??{};await sW(n,{settings:{...r,...t}},e?.conversation.ownerMachineId)}catch(e){h$.error(e instanceof Error?e.message:"设置更新失败")}}async function tD(t,n){let r=e?.conversation.id;if(r)try{await s0(r,t,n,void 0,e?.conversation.ownerMachineId)}catch(e){h$.error(e instanceof Error?e.message:"审批操作失败")}}async function tR(){let t=e?.conversation.id;if(t){eJ(!0);try{await s1(t,e?.conversation.ownerMachineId)}catch{}}}function t_(){tO("继续","agent")}async function tL(t){let n=e?.conversation.id;if(!n)return;let r=ex.find(e=>e.id===t);if(!r)return;let a="string"==typeof r.content?r.content:String(r.content??"");if(a.trim()){eb(e=>e.filter(e=>e.id!==t));try{await s2(n,a.trim(),e?.conversation.ownerMachineId)}catch{}}}ew.useEffect(()=>{"idle"===em&&eZ&&eJ(!1)},[em,eZ]),ew.useEffect(()=>{let e=eP.current;if(eP.current=em,"working"===e&&"idle"===em&&ex.length>0){let e=ex[0];if(e){eb(ex.slice(1));let t="string"==typeof e.content?e.content:String(e.content??"");t.trim()&&tO(t.trim(),"agent")}}},[em]);let t$=Array.from({length:eU},(r,a)=>(0,ey.jsx)(J_,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,index:a,content:P[a],clipboardItems:t,clipboardDraggingId:n,onAdd:()=>eT(a),onPanelDrop:tS,onContentChange:tN,onClear:tM,onCut:tE,workspaceFolders:eW,onRequestFileTab:(e,t)=>eL({paneIndex:e,insertIndex:t}),onOpenWorkspaceFile:tx,onSaveFileTab:tj,onOpenFileHistory:(e,t)=>eF({paneIndex:e,tab:t})},a)),tF=P.slice(0,eU).some(e=>e?.kind==="subagent-conversation-panel"),tB=E.shell?.agent??42,tV=E.shell?.panes??58,tH=w.agentSide,tU="control-room"===w.mode||k,tW=(0,ey.jsxs)(mB,{type:"single",value:tU?"hidden":tH,variant:"outline",size:"sm","data-tour":"control-room-toggle","aria-label":"Agent 面板位置",onValueChange:e=>{"left"===e||"right"===e?(S(!1),b(e),JX({mode:j?"card":"pane",agentSide:e})):"hidden"===e&&(S(!0),JX({mode:"control-room"}))},children:[(0,ey.jsx)(mV,{value:"left","aria-label":"Agent 在左",title:"Agent 在左",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s8,{})}),(0,ey.jsx)(mV,{value:"hidden","aria-label":"隐藏面板,居中对话",title:"隐藏面板,居中对话",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(ct,{})}),(0,ey.jsx)(mV,{value:"right","aria-label":"Agent 在右",title:"Agent 在右",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s9,{})})]}),tq=(0,ey.jsxs)("div",{className:"relative flex size-full min-h-0 min-w-0 flex-col",children:[e?(0,ey.jsx)(Hj,{ownerMachineId:e.conversation.ownerMachineId,title:e.conversation.title,className:"pr-12"}):null,e?(0,ey.jsx)("div",{className:"pointer-events-none absolute left-1 top-9 z-30 flex justify-start pt-1.5",children:(0,ey.jsx)("div",{className:"pointer-events-auto",children:(0,ey.jsx)(Hk,{rounds:e2,onJumpToRound:e5,activeRunId:X})})}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1 pl-10",children:(0,ey.jsx)(Hb,{ref:m,events:e?R:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e9:void 0,models:e?eX:void 0,modelId:eG?eX[0]?.id:ed,permissionModeId:eg,onPermissionModeChange:t=>{ev(t),e?.conversation.id&&tT({permissionMode:t})},running:eQ,disabled:!!e&&eY,onModelChange:eu,onSubmit:e?e=>{tO(e.value,"agent",e.attachments??[])}:void 0,onStop:tR,onOpenFile:ty,deliverable:tw,onOpenSubagent:function(e){e.id&&c?.([tC(e)])},onOpenPlan:tf,onOpenSpec:()=>th(),planPromptBar:e?(0,ey.jsx)(H1,{conversationId:e.conversation.id,ownerMachineId:e.conversation.ownerMachineId,planState:tm,onOpenPlan:tf,onFocusComposer:()=>{document.querySelector('[data-slot="agent-input-composer"] textarea')?.focus()},onResolved:()=>{let t=e?.conversation.id;t&&sD(t,e?.conversation.ownerMachineId).then(e=>q(e.planState))}}):void 0,onRetry:tP,onApprovalDecision:tD,onContinue:t_,onRecallUserMessage:tA,onBranchAssistantMessage:tz,onActiveEventChange:e4,composerValue:Z,onComposerValueChange:Q,promptHistory:ee,attachments:en,onAttachmentsChange:er,queuedMessages:ex,onQueuedMessagesChange:eb,onNudge:tL,contextUsage:e1})}),s.length>0&&e?(0,ey.jsx)(JY,{stack:s,rootTitle:e.conversation.title,rootOwnerMachineId:e.conversation.ownerMachineId,onNavigateRoot:()=>c?.([]),onNavigateIndex:e=>c?.(s.slice(0,e+1)),onOpenSubagent:function(e){e.id&&c?.([...s,tC(e)])}}):null]}),tK=(0,ey.jsx)(hk,{id:"agent",defaultSize:tB,minSize:28,children:tq},"agent-conversation"),tG=(0,ey.jsx)(hk,{id:"panes",defaultSize:tV,minSize:32,children:(0,ey.jsxs)("section",{className:"vtl-agent-workspace-panel flex size-full min-h-0 min-w-0 flex-col bg-transparent","data-has-conversation-pane":tF?"true":void 0,children:[(0,ey.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-3","data-tour":"pane-toolbar",children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)(md,{value:v,onValueChange:e=>{let t,n;return t=JI.find(t=>t.id===e)?.slots??4,void((n=P.slice(t).filter(e=>!!e)).length&&te(n),A(Array.from({length:Math.max(4,t)},(e,n)=>n<t?P[n]:void 0)),x(e))},children:(0,ey.jsx)(my,{children:JI.map(e=>(0,ey.jsx)(mb,{value:e.id,"aria-label":e.label,title:e.label,className:"h-7 w-10 px-0 [&_svg]:size-4",children:e.icon},e.id))})}),tW,(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"剪切窗口内容",title:"拖拽到窗口以剪切到剪切板",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(JP,"cut")},children:(0,ey.jsx)(l0,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"粉碎窗口内容",title:"拖拽到窗口以清空",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(JO,"clear")},children:(0,ey.jsx)(cn,{})})]})}),(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:(0,ey.jsx)(JR,{mode:v,sizes:E,onSizeGroupChange:function(e,t){let n=J5(t);O(t=>{var r;return(r=t[e],(r?.length??0)===(n?.length??0)&&(r??[]).every((e,t)=>.01>Math.abs(e-(n?.[t]??0))))?t:{...t,[e]:n}})},children:t$},`${e?.conversation.id??"empty"}-${v}`)})]})},"agent-panes"),tX=(0,ey.jsx)(JH,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,panes:P,agentSide:tH,columns:I,heights:T,onColumnsChange:z,onHeightsChange:D,onAddCard:ta,onContentChange:tN,onClear:tM,workspaceFolders:eW,onOpenWorkspaceFile:tx,onSaveFileTab:tj,onOpenFileHistory:(e,t)=>eF({paneIndex:e,tab:t}),onRequestFileTab:(e,t)=>eL({paneIndex:e,insertIndex:t})}),tY=(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-y-0 z-30 flex w-9 items-center","left"===tH?"right-0 justify-end pr-1":"left-0 justify-start pl-1"),children:(0,ey.jsx)("button",{type:"button",onClick:M,"aria-label":N?"展开工作区":"收起工作区",title:N?"展开工作区":"收起工作区",className:"grid size-7 place-items-center rounded-md border bg-background/85 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/panes:opacity-100 [&_svg]:size-4",children:"left"===tH?N?(0,ey.jsx)(ce,{}):(0,ey.jsx)(s7,{}):N?(0,ey.jsx)(tu,{}):(0,ey.jsx)(td,{})})}),tZ=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(JL,{open:void 0!==ez,onOpenChange:e=>{e||eT(void 0)},onAdd:function(e){if(void 0===ez)return;eB.current+=1;let t=jN(e,`${e}-${eB.current}`),n=P[ez];n&&te([n]),A(e=>e.map((e,n)=>n===ez?t:e)),eT(void 0)}}),(0,ey.jsx)(HJ,{open:void 0!==e_,folders:eW,onOpenChange:e=>{e||eL(void 0)},onSelectFile:e=>{e_&&tv(e,e_.paneIndex,e_.insertIndex),eL(void 0)}}),(0,ey.jsx)(J7,{open:void 0!==e$,conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,tab:e$?.tab,onOpenChange:e=>{e||eF(void 0)},onSelectVersion:e=>{tk(e)}}),(0,ey.jsx)(d4,{open:void 0!==ea,onOpenChange:e=>{e||eo||ei(void 0)},children:(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:"回退对话到此处?"}),(0,ey.jsx)(ug,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{disabled:eo,children:"取消"}),(0,ey.jsx)(uv,{variant:"destructive",disabled:eo,onClick:e=>{e.preventDefault(),tI()},children:eo?"回退中…":"确认回退"})]})]})})]});return e?h?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(jw,{view:u,onPaneCountChange:f,conversationPanel:(0,ey.jsx)(Hb,{flowContentClassName:"pl-10",events:e?R:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e9:void 0,models:e?eX:void 0,modelId:eG?eX[0]?.id:ed,permissionModeId:eg,onPermissionModeChange:t=>{ev(t),e?.conversation.id&&tT({permissionMode:t})},running:eQ,disabled:!!e&&eY,onModelChange:eu,onSubmit:e?e=>{tO(e.value,"agent",e.attachments??[])}:void 0,onStop:tR,onOpenFile:ty,deliverable:tw,onOpenSubagent:function(e){var t;let n=P.slice(0,eU),r=n.findIndex(e=>!e),a=n.findIndex(e=>e?.kind==="subagent-conversation-panel"),i=r>=0?r:a;if(i<0)return void h$.warning("请释放一个窗口再选中浏览");eV.current+=1;let o={id:t=`subagent-${e.id}-${eV.current}`,kind:"subagent-conversation-panel",title:e.title,subagentId:e.id,events:e.events?.length?e.events:[{id:`${t}-status`,kind:"done",title:e.detail??e.status??e.activity??e.title}]};A(e=>e.map((e,t)=>t===i?o:e))},onRetry:tP,onApprovalDecision:tD,onContinue:t_,onRecallUserMessage:tA,onBranchAssistantMessage:tz,onActiveEventChange:e4,composerValue:Z,onComposerValueChange:Q,promptHistory:ee,attachments:en,onAttachmentsChange:er,queuedMessages:ex,onQueuedMessagesChange:eb,onNudge:tL,contextUsage:e1}),paneElements:t$,panes:P,activeSlotCount:eU,onOpenPalette:eT,timeline:(0,ey.jsx)(Hk,{rounds:e2,onJumpToRound:e5,activeRunId:X})}),tZ,(0,ey.jsx)(hW,{position:"top-center"})]}):(0,ey.jsxs)("div",{className:"vtl-app-background vtl-agent-conversation-workspace relative h-full min-h-0",children:[tU?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hj,{direction:"horizontal",children:tG})}),(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 basis-[58%] shrink-0 flex-col",children:[(0,ey.jsx)(hj,{direction:"horizontal",children:tK}),(0,ey.jsx)("div",{className:"absolute right-3 top-1.5 z-20",children:tW})]}),(0,ey.jsx)("div",{className:"relative min-h-0 min-w-0 flex-1",children:(0,ey.jsx)(H3,{conversationTitle:e.conversation.title,rootEvents:R,rootOwnerMachineId:e.conversation.ownerMachineId,running:eQ,subagentTree:d,baselineSubagentIds:K,activeSubagentPath:s,onSelectMain:()=>c?.([]),onSelectSubagent:e=>c?.([e])})})]}):j&&!P.some(Boolean)?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tq}),(0,ey.jsx)("div",{className:(0,eI.cn)("absolute top-2 z-20","left"===tH?"right-3":"left-3"),children:(0,ey.jsx)(JV,{onAddCard:ta,align:"left"===tH?"end":"start"})})]}):j?(0,ey.jsx)("div",{className:"flex h-full min-h-0 overflow-x-auto",children:"left"===tH?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tq}),(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tX})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tX}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tq})]})}):N?(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hj,{direction:"horizontal",children:tG})}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tq}),tY]}):(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsxs)(hj,{direction:"horizontal",defaultLayout:{agent:tB,panes:tV},onLayoutChanged:e=>{let t=e.agent??tB,n=e.panes??tV;!function(e){let t=J5(e),n=t[0],r=t[1];if(void 0===n||void 0===r)return;let a="left"===y?{agent:n,panes:r}:{agent:r,panes:n};O(e=>{let t=e.shell?.agent,n=e.shell?.panes;return .01>Math.abs((t??0)-a.agent)&&.01>Math.abs((n??0)-a.panes)?e:{...e,shell:{...e.shell,...a}}})}("left"===tH?[t,n]:[n,t])},children:["left"===tH?tK:tG,(0,ey.jsx)(hS,{withHandle:!0}),"left"===tH?tG:tK]},`${e?.conversation.id??"empty"}-${tH}`),tY]}),tZ,(0,ey.jsx)(hW,{position:"top-right"})]}):(0,ey.jsx)(jg,{onCreated:e=>o?.(e),onCancel:l})}function J7({open:e,conversationId:t,ownerMachineId:n,tab:r,onOpenChange:a,onSelectVersion:i}){let[o,l]=ew.useState([]),[s,c]=ew.useState(!1),d=r?.file?.path,u=r?.file?.machineId??"local";return ew.useEffect(()=>{if(!e||!t||!d)return void l([]);let r=!1;return c(!0),sJ(t,{machineId:u,path:d},n).then(e=>{r||l(e.versions)}).catch(()=>{r||l([])}).finally(()=>{r||c(!1)}),()=>{r=!0}},[t,n,u,e,d]),(0,ey.jsx)(dC,{open:e,onOpenChange:a,children:(0,ey.jsxs)(fx,{className:"max-w-xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fb,{className:"sr-only",children:"历史版本"}),(0,ey.jsx)(fw,{className:"sr-only",children:"浏览当前文件在此 Agent 会话中的修改历史。"}),(0,ey.jsxs)("div",{className:"border-b px-4 py-3",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:r?.file?.name??r?.title??"文件"}),d?(0,ey.jsxs)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:[u,":",d]}):null]}),(0,ey.jsx)("div",{className:"max-h-[28rem] overflow-auto p-2",children:s?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"正在读取历史版本"}):0===o.length?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"还没有记录到这个文件的修改历史"}):(0,ey.jsx)("div",{className:"grid gap-1",children:o.map(e=>{var t;let n;return(0,ey.jsxs)("button",{type:"button",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted/70",onClick:()=>i(e),children:[(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsxs)("span",{className:"block truncate text-sm font-medium",children:[J9(e.mutationId)," ·"," ","before"===e.state?"修改前":"修改后"]}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:Number.isFinite(n=Date.parse(t=e.createdAt))?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(n):t})]}),(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,ey.jsxs)("b",{className:"font-medium text-emerald-600",children:["+",e.additions??0]}),(0,ey.jsxs)("b",{className:"font-medium text-rose-600",children:["-",e.deletions??0]})]})]},e.id)})})})]})})}function J9(e){return e.replace(/^mut-/,"").slice(0,16)}let Qe=(0,l2.cva)("vtl-surface-card relative w-full rounded-[var(--surface-card-radius)] border px-4 py-3 text-sm [&>svg]:absolute [&>svg]:top-3.5 [&>svg]:left-4 [&>svg~*]:pl-7",{variants:{variant:{default:"border-border",muted:"border-border bg-muted/40",destructive:"border-destructive/35 bg-destructive/10 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function Qt({className:e,variant:t,...n}){return(0,ey.jsx)("div",{role:"alert","data-slot":"alert",className:(0,eI.cn)(Qe({variant:t}),e),...n})}function Qn({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-title",className:(0,eI.cn)("mb-1 leading-none font-medium",e),...t})}function Qr({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-description",className:(0,eI.cn)("text-muted-foreground [&_p]:leading-relaxed",e),...t})}function Qa({conversationId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState({}),[i,o]=ew.useState(!0),[l,s]=ew.useState(null),[c,d]=ew.useState(""),u=ew.useCallback(async()=>{let t=(await ji(e)).folders??[];n(t),a(Object.fromEntries(t.map(e=>[e.path,e.vantaloom])))},[e]);async function f(t){if(!l){s(t),d("");try{await jo(t,r[t]??"",e),await u()}catch(e){d(e instanceof Error?e.message:"保存失败")}finally{s(null)}}}return(ew.useEffect(()=>{(async()=>{o(!0);try{await u()}catch(e){d(e instanceof Error?e.message:"加载失败")}finally{o(!1)}})()},[u]),i)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取该对话的项目文档"}):(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"这里管理本对话工作区文件夹里的系统提示词。会自动读取各文件夹的 agent.md / claude.md 等文档;你可以选一份作为模板,或自行编写,保存后写入该文件夹的 vantaloom.md,并作为带标记的系统提示词长期注入本对话上下文。 若未设置且未检测到任何文档,则使用全局“兜底系统提示词”。"})]}),c?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"错误"}),(0,ey.jsx)(Qr,{children:c})]}):null,0===t.length?(0,ey.jsx)("p",{className:"rounded-md border border-dashed px-3 py-4 text-xs text-muted-foreground",children:"本对话还没有工作区文件夹。先在“工作区文件夹”里添加一个本机文件夹,这里就会列出它的文档。"}):t.map(e=>{let t=e.docs??[];return(0,ey.jsxs)("div",{className:"grid gap-2 rounded-md border bg-card p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",title:e.path,children:e.path}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(e.path),disabled:l===e.path,children:[(0,ey.jsx)(K3,{className:"size-4"}),l===e.path?"保存中":"保存到 vantaloom.md"]})]}),t.length>0?(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"用作模板:"}),t.map(t=>(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>a(n=>({...n,[e.path]:t.content})),children:t.name},t.name))]}):(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到 agent.md / claude.md,可直接编写。"}),(0,ey.jsx)(b3,{value:r[e.path]??"",onChange:t=>a(n=>({...n,[e.path]:t.currentTarget.value})),placeholder:"该项目的系统提示词 / 规范,将写入 vantaloom.md",rows:8,className:"resize-y font-mono text-xs"})]},e.path)})]})}let Qi=[{id:"models",label:"模型"},{id:"tools",label:"工具权限"},{id:"commands",label:"禁止命令"},{id:"folders",label:"工作区文件夹"},{id:"system-prompt",label:"系统提示词"},{id:"hosts",label:"可访问主机"}];function Qo({conversation:e,mainModels:t,ccModel:n="",sessionSettings:r,onMainModelsChange:a,onCcModelChange:i,onSessionSettingsChange:o,onClose:l,onEnterConversation:s}){let[c,d]=ew.useState("models"),u=ja(e.settings.engine);return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:l,className:"shrink-0",children:(0,ey.jsx)(fg.XIcon,{className:"size-5"})}),(0,ey.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:()=>s?.(e),children:[(0,ey.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,ey.jsx)("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b px-3 py-2 vtl-scrollbar-hidden",children:Qi.filter(e=>"system-prompt"!==e.id||!u).map(e=>(0,ey.jsx)("button",{type:"button",onClick:()=>d(e.id),className:(0,eI.cn)("shrink-0 rounded-lg px-3 py-1.5 text-[13px] transition-colors",c===e.id?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:e.label},e.id))}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4 pb-[max(1.25rem,env(safe-area-inset-bottom))]",children:(0,ey.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:["models"===c?(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"运行引擎"}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:function(e){switch(e){case"claude-code":return"Claude Code";case"reclaude":return"reclaude";default:return"Vantaloom"}}(e.settings.engine)})]}),u?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("label",{htmlFor:"conversation-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,ey.jsxs)(gT,{value:""===n?jn:n,onValueChange:e=>i?.(e===jn?"":e),children:[(0,ey.jsx)(vh,{id:"conversation-cc-model",className:"w-full",children:(0,ey.jsx)(gL,{placeholder:"选择 Claude Code 模型"})}),(0,ey.jsx)(vg,{children:jr.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,ey.jsx)(vK,{conversation:e,mainModels:t,onMainModelsChange:a})]}):null,"tools"===c?(0,ey.jsx)(w5,{value:r.allowedTools,onChange:e=>o({...r,allowedTools:e,deniedTools:[]})}):null,"commands"===c?(0,ey.jsx)(w4,{value:r.blockedCommands,onChange:e=>o({...r,blockedCommands:e})}):null,"folders"===c?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)(w3,{title:"可访问的工作区文件夹",value:r.folders,onValueChange:e=>o({...r,folders:u?e.slice(-1):e})}),u?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}):null,"system-prompt"!==c||u?null:(0,ey.jsx)(Qa,{conversationId:e.id}),"hosts"===c?(0,ey.jsx)(jt,{value:r.hosts,onValueChange:e=>o({...r,hosts:e}),disabled:u,hint:u?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0}):null]})})]})}function Ql({conversationId:e,ownerMachineId:t,open:n,onOpenChange:r,onEnterConversation:a}){let[i,o]=ew.useState(),[l,s]=ew.useState([]),[c,d]=ew.useState(""),[u,f]=ew.useState({folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:[]});async function h(e){if(!i)return;let n=e.session??u,r=e.mainModels??l,a=e.ccModel??c,s={subagents:i.settings.subagents??[],mainModels:r,folders:n.folders,blockedCommands:n.blockedCommands,allowedTools:n.allowedTools,deniedTools:n.deniedTools,plugins:n.plugins,hosts:n.hosts,permissionMode:n.permissionMode??i.settings.permissionMode,engine:i.settings.engine,ccModel:i.settings.engine?a:void 0};try{let e=await sW(i.id,{settings:s},t);o(e.conversation)}catch{}}function m(){o(void 0),r(!1)}return(ew.useEffect(()=>{if(!n||!e)return;let r=!0;return async function(){try{let n=await sA(e,t);if(!r)return;let a=n.conversation;o(a),s(a.settings.mainModels),d(a.settings.ccModel??""),f({folders:a.settings.folders,blockedCommands:a.settings.blockedCommands,allowedTools:a.settings.allowedTools,deniedTools:a.settings.deniedTools,plugins:a.settings.plugins,hosts:a.settings.hosts})}catch{}}(),()=>{r=!1}},[e,n,t]),n&&i)?(0,ey.jsx)(Qo,{conversation:i,mainModels:l,ccModel:c,sessionSettings:u,onMainModelsChange:e=>{s(e),h({mainModels:e})},onCcModelChange:e=>{d(e),h({ccModel:e})},onSessionSettingsChange:e=>{f(e),h({session:e})},onClose:m,onEnterConversation:e=>{m(),a?.(e.id,t)}}):null}let Qs="local";async function Qc(e){return((await Qv(e,"")).canvases??[]).map(t=>Qg(t,e))}async function Qd(e,t){return Qp(await Qv(t,`/${encodeURIComponent(e)}`),t)}async function Qu(e,t){return Qp(await Qv(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(uU),edges:e.edges.map(uW)})}),t)}async function Qf(e,t,n){return Qp(await Qv(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(uU),edges:t.edges.map(uW),nodeIds:t.nodeIds})}),n)}async function Qh(e,t){return Qp(await Qv(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}async function Qm(){let e={[Qs]:"本机"},t=[],n=[];try{n=await Qc(void 0)}catch{n=[]}let r=[];try{let{machines:e}=await sw();r=(e??[]).filter(e=>!e.isLocal&&"online"===e.status).map(e=>({id:e.id,name:e.name}))}catch{r=[]}let a=await Promise.all(r.map(async n=>{e[n.id]=n.name;try{return await Qc(n.id)}catch{return t.push(n.id),[]}})),i=new Map;for(let e of[...n,...a.flat()]){let t=i.get(e.id);(!t||e.updatedAt>t.updatedAt)&&i.set(e.id,e)}let o=Array.from(i.values());return o.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),{canvases:o,machineNames:e,unreachable:t}}function Qp(e,t){return{canvas:Qg(e.canvas,t),nodes:e.nodes??[],edges:e.edges??[]}}function Qg(e,t){let n=t&&t!==Qs?t:e.ownerMachineId??"local";return{id:e.id,title:e.title||"新画布",ownerMachineId:n,nodeCount:e.nodeCount??0,running:e.running??!1,createdAt:e.createdAt,updatedAt:e.updatedAt,lastOpenedAt:e.lastOpenedAt}}async function Qv(e,t,n,r){let a=await fetch(eD(!e||e===Qs?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let Qx=(0,ek.default)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Qy=(0,ek.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),Qb=(0,ek.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Qw=(0,ek.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),Qj=(0,ek.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Qk=(0,ek.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),QS={done:"Done",current:"Current",queued:"Queued",blocked:"Blocked"};function QN(e,t,n){return Math.min(Math.max(e,t),n)}function QC({items:e,currentId:t,labels:n,scrollCurrentIntoView:r=!0,className:a,viewportClassName:i,itemClassName:o,extendLineToViewport:l=!1,...s}){let c={...QS,...n},d=ew.useRef(null),u=ew.useRef(null),f=ew.useRef(null),h=ew.useRef(0),m=ew.useRef(void 0),[p,g]=ew.useState(0),v=t??e.find(e=>"current"===e.status)?.id,x=ew.useCallback(()=>{void 0!==m.current&&(cancelAnimationFrame(m.current),m.current=void 0)},[]),y=ew.useCallback((e,t=340)=>{let n=d.current,r=u.current;if(!n||!r)return;x();let a=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,o=QN(e,0,a),l=performance.now();h.current=o;let s=e=>{let r=QN((e-l)/t,0,1);if(n.scrollTop=i+(o-i)*(1-Math.pow(1-r,3)),r<1){m.current=requestAnimationFrame(s);return}n.scrollTop=o,m.current=void 0};m.current=requestAnimationFrame(s)},[x]),b=ew.useCallback(e=>{let t=d.current,n=u.current;if(!t||!n)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;e.preventDefault();let a=void 0===m.current?t.scrollTop:h.current,i=1===e.deltaMode?32*e.deltaY:2===e.deltaMode?e.deltaY*e.currentTarget.clientHeight:e.deltaY,o=Math.sign(i);if(0===o)return;let l=Array.from(n.querySelectorAll("[data-slot='roadmap-item']")).map(e=>e.offsetTop),s=QN(Math.ceil(Math.abs(i)/160),1,3),c=a;for(let e=0;e<s;e+=1)c=function(e,t,n,r){if(0===e.length)return t;if(n>0)return e.find(e=>e>t+1)??r;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0!==r&&r<t-1)return r}return 0}(l,c,o,r);y(c)},[y]);return ew.useLayoutEffect(()=>{if(!r)return;let e=d.current,t=u.current,n=f.current;if(!e||!t||!n)return void g(0);let a=n.offsetTop,i=t.scrollHeight-p,o=Math.max(0,e.clientHeight-(i-a));g(e=>Math.abs(e-o)>.5?o:e),requestAnimationFrame(()=>{e.scrollTop=a,h.current=a})},[p,e,v,r]),ew.useEffect(()=>x,[x]),(0,ey.jsx)("div",{"data-slot":"roadmap",className:(0,eI.cn)("min-w-0 text-foreground",a),...s,children:(0,ey.jsx)("div",{"data-slot":"roadmap-viewport",ref:d,onWheel:b,className:(0,eI.cn)("max-h-72 overflow-y-auto overscroll-contain pr-2",i),children:(0,ey.jsxs)("div",{ref:u,className:(0,eI.cn)("relative",l&&"min-h-full"),children:[(0,ey.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 bottom-0 left-[0.3125rem] w-px bg-border"}),e.map(e=>{let t=e.id===v?"current":e.status??"queued";return(0,ey.jsxs)("div",{ref:"current"===t?f:void 0,"data-slot":"roadmap-item","data-status":t,"aria-label":c[t],className:(0,eI.cn)("relative grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-2 py-2.5",o),children:[(0,ey.jsx)("span",{"aria-hidden":"true","data-slot":"roadmap-marker",className:(0,eI.cn)("relative z-10 mt-1 size-2.5 rounded-full border bg-background","done"===t&&"border-muted-foreground bg-muted-foreground","current"===t&&"border-primary bg-primary","queued"===t&&"border-border","blocked"===t&&"border-destructive bg-destructive")}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{"data-slot":"roadmap-title",className:(0,eI.cn)("text-sm leading-5","queued"===t&&"text-muted-foreground","blocked"===t&&"text-destructive"),children:e.title}),e.description?(0,ey.jsx)("div",{"data-slot":"roadmap-description",className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description}):null]}),e.meta?(0,ey.jsx)("div",{"data-slot":"roadmap-meta",className:"pt-0.5 text-right ui-text-kbd text-muted-foreground",children:e.meta}):null]},e.id)}),p>0?(0,ey.jsx)("div",{"aria-hidden":"true","data-slot":"roadmap-bottom-spacer",style:{height:p}}):null]})})})}let QM="/themes/jelly/bg1.png",QE="/themes/jelly/bg2.png",QO="/themes/jelly/bg3.png",QP="/themes/jelly/bg4.png";function QA({image:e,position:t="center",opacity:n=.72,blur:r="10px"}){return{"--vtl-jelly-card-image":`url("${e}")`,"--vtl-jelly-card-position":t,"--vtl-jelly-card-opacity":String(n),"--vtl-jelly-card-blur":r}}function QI({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}let Qz={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题"},QT={search:"搜索控制台...",dashboard:"仪表盘",canvas:"画布",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近画布",canvasNew:"新建画布",canvasAll:"浏览所有画布",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"};Qz.local,Qz.direct,Qz.online,Qz.p2p,Qz.online,Qz.direct,Qz.sleeping,Qz.cpu,Qz.memory,Qz.activeRuns;function QD(e){return e.reduce((e,t)=>Math.max(e,t.y+t.h),0)}function QR({children:e}){return(0,ey.jsx)("section",{className:"vtl-app-background flex h-full min-h-0 flex-col pb-14 md:pb-0 text-foreground",children:(0,ey.jsx)(wz,{className:"min-h-0 flex-1",children:e})})}function Q_(e){return Math.max(0,...e.map(e=>e.y+e.h))}function QL(e,t,n){return t.some(t=>t.id!==n&&e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}function Q$(e){let t=Math.max(2,Math.min(12,e.w)),n=Math.max(1,e.h),r=Math.max(0,Math.min(12-t,e.x)),a=Math.max(0,e.y);return{...e,x:r,y:a,w:t,h:n}}function QF(e,t,n,r,a){for(let i=0;i<Q_(e)+8;i+=1)for(let o=0;o<=12-r;o+=1){let l={id:t,kind:n,x:o,y:i,w:r,h:a};if(!QL(l,e))return l}return{id:t,kind:n,x:0,y:Q_(e)+2,w:r,h:a}}function QB(e){return{...e.defaultConfig}}function QV(e){return e.payloads?.[GY]}function QH({open:e,definitions:t,title:n="添加卡片",description:r="搜索并选择要添加到当前页面的卡片。",groupTitle:a="可添加卡片",onOpenChange:i,onAdd:o}){return(0,ey.jsx)(xg,{open:e,onOpenChange:i,title:n,description:r,className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xp,{loop:!0,children:[(0,ey.jsx)(xv,{placeholder:"搜索可添加卡片..."}),(0,ey.jsxs)(xx,{className:"max-h-[420px]",children:[(0,ey.jsx)(xy,{children:"没有找到可添加的卡片。"}),(0,ey.jsx)(xb,{heading:a,children:t.map(e=>(0,ey.jsxs)(xw,{value:`${e.title} ${e.description}`,keywords:[e.id,e.defaultConfig.dataSource,e.defaultConfig.title],onSelect:()=>o(e.id),className:"min-h-14 items-start py-2",children:[(0,ey.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate font-medium",children:e.title}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xj,{children:[e.defaultSize.w,"x",e.defaultSize.h]})]},e.id))})]})]})})}function QU({open:e,dragMode:t,label:n="页面卡片操作",onOpenChange:r,onAdd:a,onDragModeChange:i}){let o=[{key:"add",label:"添加卡片",icon:(0,ey.jsx)(lJ,{className:"size-4"}),onClick:a,pressed:!1},{key:"drag",label:"拖拽排版",icon:(0,ey.jsx)(lq,{className:"size-4"}),onClick:()=>i(!t),pressed:t}];return(0,ey.jsx)("div",{className:"fixed right-5 bottom-5 z-30",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",t.pressed&&"border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":n,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let QW=(0,ek.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function Qq({layout:e,layouts:t,cellSize:n,cellHeight:r,dragMode:a,selected:i,resizing:o,onSelect:l,onMove:s,onCut:c,onCopy:d,onSettingsOpen:u,onResizeStart:f,onResizeEnd:h,children:m}){let[p,g]=ew.useState(!1),v=r??n,x=e.x*(n+12),y=e.y*(v+12),b=e.w*n+(e.w-1)*12,w=e.h*v+(e.h-1)*12;return(0,ey.jsxs)("div",{"data-editable-card":e.id,className:(0,eI.cn)("absolute rounded-lg p-1 transition-[left,top,width,height,box-shadow] duration-200 ease-out",a&&"cursor-grab active:cursor-grabbing",p&&"duration-150",i&&!o&&"z-20 shadow-sm",o&&"z-30 transition-none"),style:{left:x,top:y,width:b,height:w},onPointerDown:function(r){if(!a||o)return;let i=r.target;if(i instanceof HTMLElement&&i.closest("[data-editable-card-action]"))return;r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),l();let c=r.clientX,d=r.clientY;function u(r){let a=Q$({...e,x:e.x+Math.round((r.clientX-c)/(n+12)),y:e.y+Math.round((r.clientY-d)/(n+12))});QL(a,t,e.id)||s(a)}g(!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",e),g(!1)})},onClick:()=>{a&&l()},children:[(0,ey.jsx)("div",{className:(0,eI.cn)("size-full",a&&"pointer-events-none"),children:m}),i&&a&&!o?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-1 rounded-lg border-2 border-foreground"}):null,i&&a&&!o?(0,ey.jsx)(QK,{onSettingsOpen:u,onCut:c,onCopy:d,onResizeStart:f}):null,o?(0,ey.jsx)(QG,{layout:e,layouts:t,cellSize:n,onResize:s,onResizeEnd:h}):null]})}function QK({onSettingsOpen:e,onCut:t,onCopy:n,onResizeStart:r}){return(0,ey.jsx)(l4,{"data-editable-card-action":!0,placement:"inline",size:"sm","aria-label":"卡片操作",className:"!absolute top-full left-1/2 z-40 mt-2 -translate-x-1/2 rounded-lg bg-popover/95 p-1 shadow-md",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,ey.jsxs)(l3,{children:[(0,ey.jsx)(l6,{type:"button","aria-label":"调整大小",onClick:r,children:(0,ey.jsx)(lX,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"卡片设置",onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(QW,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"复制",onClick:n,children:(0,ey.jsx)(lU,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"剪切",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),t()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(l0,{className:"size-4"})})]})})}function QG({layout:e,layouts:t,cellSize:n,onResize:r,onResizeEnd:a}){return(0,ey.jsx)("div",{"data-editable-card-action":!0,className:"pointer-events-none absolute inset-1 z-40 border-2 border-foreground",children:[{id:"top-left",className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize"},{id:"top",className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize"},{id:"top-right",className:"top-0 right-0 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize"},{id:"right",className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2 cursor-ew-resize"},{id:"bottom-right",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2 cursor-nwse-resize"},{id:"bottom",className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 cursor-ns-resize"},{id:"bottom-left",className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize"},{id:"left",className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize"}].map(i=>(0,ey.jsx)("button",{type:"button","aria-label":`调整 ${i.id}`,className:(0,eI.cn)("pointer-events-auto absolute size-2.5 border border-foreground bg-background shadow-sm",i.className),onPointerDown:o=>(function(i,o){i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);let l=i.clientX,s=i.clientY;function c(a){let i=Math.round((a.clientX-l)/(n+12)),c=Math.round((a.clientY-s)/(n+12)),d={...e};o.includes("right")&&(d.w=e.w+i),o.includes("bottom")&&(d.h=e.h+c),o.includes("left")&&(d.x=e.x+i,d.w=e.w-i),o.includes("top")&&(d.y=e.y+c,d.h=e.h-c),QL(d=Q$(d),t,e.id)||r(d)}window.addEventListener("pointermove",c),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",e),a()})})(o,i.id)},i.id))})}function QX({className:e,...t}){return(0,ey.jsx)(dT,{"data-slot":"sheet-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function QY({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,ey.jsxs)(dI,{children:[(0,ey.jsx)(QX,{}),(0,ey.jsxs)(dL,{"data-slot":"sheet-content","data-side":n,className:(0,eI.cn)("vtl-surface-modal fixed z-50 flex flex-col gap-4 border transition ease-in-out outline-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-300","right"===n&&"inset-y-0 right-0 h-full w-3/4 border-r-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm","left"===n&&"inset-y-0 left-0 h-full w-3/4 border-l-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm","top"===n&&"inset-x-0 top-0 h-auto border-t-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top","bottom"===n&&"inset-x-0 bottom-0 h-auto border-b-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),...a,children:[t,r&&(0,ey.jsxs)(dK,{className:"absolute top-3 right-3 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none",children:[(0,ey.jsx)(fg.XIcon,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function QZ({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"sheet-header",className:(0,eI.cn)("grid gap-1.5 p-4 text-left",e),...t})}function QJ({className:e,...t}){return(0,ey.jsx)(dH,{"data-slot":"sheet-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function QQ({className:e,...t}){return(0,ey.jsx)(dW,{"data-slot":"sheet-description",className:(0,eI.cn)("text-sm text-muted-foreground",e),...t})}function Q0({open:e,layout:t,definition:n,config:r,cellSize:a,onOpenChange:i,onConfigChange:o}){let l=t&&a>0?t.w*a+(t.w-1)*12:320,s=t&&a>0?t.h*a+(t.h-1)*12:180;return(0,ey.jsx)(dC,{open:e,onOpenChange:i,children:(0,ey.jsx)(QY,{side:"right",className:"w-screen gap-0 border-0 bg-transparent p-0 shadow-none sm:max-w-none",children:t&&n&&r?(0,ey.jsxs)("div",{className:"grid h-full min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_24rem]",children:[(0,ey.jsx)(Q1,{width:l,height:s,className:"hidden lg:grid",children:n.render(r)}),(0,ey.jsxs)("div",{className:"animate-in slide-in-from-right-4 flex h-full w-full flex-col border-y-0 border-r-0 bg-background text-foreground shadow-lg duration-300",children:[(0,ey.jsxs)(QZ,{className:"border-b",children:[(0,ey.jsx)(QJ,{children:"卡片设置"}),(0,ey.jsxs)(QQ,{children:[n.title," · ",t.w,"x",t.h]})]}),(0,ey.jsxs)("div",{className:"grid flex-1 content-start gap-4 overflow-y-auto p-4",children:[(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"显示标题"}),(0,ey.jsx)(ez,{value:r.title,onChange:e=>o({title:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"数据来源"}),(0,ey.jsx)(ez,{value:r.dataSource,onChange:e=>o({dataSource:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"刷新间隔"}),(0,ey.jsx)(ez,{value:r.refreshRate,onChange:e=>o({refreshRate:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"备注"}),(0,ey.jsx)("textarea",{value:r.note,rows:4,className:"min-h-24 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 ui-text-control transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",onChange:e=>o({note:e.currentTarget.value})})]}),(0,ey.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3",children:[(0,ey.jsx)("div",{className:"ui-text-control font-medium",children:"当前绑定"}),(0,ey.jsxs)("div",{className:"mt-2 grid gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["类型:",n.id]}),(0,ey.jsxs)("span",{children:["来源:",r.dataSource]}),(0,ey.jsxs)("span",{children:["刷新:",r.refreshRate]})]})]})]})]})]}):null})})}function Q1({width:e,height:t,className:n,children:r}){let[a,i]=XD(),o=i.width>0&&i.height>0?Math.min(1,(i.width-32)/e,(i.height-32)/t):1;return(0,ey.jsx)("div",{ref:a,className:(0,eI.cn)("min-h-0 min-w-0 place-items-center overflow-hidden p-4",n),children:(0,ey.jsx)("div",{className:"animate-in fade-in-0 zoom-in-95 origin-center rounded-lg duration-300",style:{width:e,height:t,transform:`scale(${Math.max(.1,o)})`},children:r})})}function Q2({boardId:e,definitions:t,initialLayouts:n,clipboardItems:r=[],minRows:a=9,className:i,actionLabel:o,paletteGroupTitle:l,onClipboardItemsChange:s,onOverlayOpenChange:c}){var d;let[u,f]=ew.useState(!1),[h,m]=ew.useState(!1),[p,g]=ew.useState(!1),[v,x]=ew.useState(()=>n),[y,b]=ew.useState({}),[w,j]=ew.useState(),[k,S]=ew.useState(),[N,C]=ew.useState(),M=ew.useRef(0),E=ew.useRef(0),[O,P]=XD(),A=P.width>0?(d=P.width)<480?2:d<768?4:12:12,I=function(e,t){if(t>=12)return e;let n=[...e].sort((e,t)=>e.y!==t.y?e.y-t.y:e.x-t.x),r=[];for(let e of n){let n=Math.max(2,Math.min(t,Math.round(e.w*t/12))),a=e.h,i=!1;for(let o=0;o<QD(r)+8&&!i;o+=1)for(let l=0;l<=t-n&&!i;l+=1){let t={...e,x:l,y:o,w:n,h:a};!function(e,t){return t.some(t=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}(t,r)&&(r.push(t),i=!0)}i||r.push({...e,x:0,y:QD(r),w:n,h:a})}return r}(v,A),z=P.width>0?(P.width-12*(A-1))/A:96,T=A<12?72:z,D=Math.max(a,Q_(I)+2),R=D*T+(D-1)*12,_=ew.useMemo(()=>new Map(t.map(e=>[e.id,e])),[t]);function L(e){let t=_.get(e.kind);return y[e.id]??(t?QB(t):void 0)}function $(e){x(t=>{let n=Q$(e);return QL(n,t,n.id)?t:t.map(e=>e.id===n.id?n:e)})}function F(e){let t=_.get(e);if(!t)return;E.current+=1;let n=`${e}-added-${E.current}`,r=QF(v,n,e,t.defaultSize.w,t.defaultSize.h);x(e=>[...e,r]),b(e=>({...e,[n]:QB(t)})),j(n),S(void 0),m(!1)}function B(e,t){let n=v.find(t=>t.id===e),r=n?_.get(n.kind):void 0;n&&r&&b(n=>({...n,[e]:{...n[e]??QB(r),...t}}))}ew.useEffect(()=>{c?.(h||!!N)},[h,c,N]),ew.useEffect(()=>()=>c?.(!1),[c]),ew.useEffect(()=>{p||(j(void 0),S(void 0))},[p]),ew.useEffect(()=>{if(k)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof HTMLElement&&t.closest("[data-editable-card-action]")||(j(k),S(void 0))}},[k]);let V=A<12,H=N?v.find(e=>e.id===N):void 0,U=H?_.get(H.kind):void 0,W=H?L(H):void 0;if(V){let n=[...I].sort((e,t)=>e.y-t.y||e.x-t.x),r=Object.fromEntries(v.map(e=>[e.id,e.w]));return(0,ey.jsxs)(QR,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("mx-auto max-w-7xl p-3",i),children:(0,ey.jsx)("div",{className:"grid grid-cols-2 gap-3",children:n.map(e=>{let t=_.get(e.kind);if(!t)return null;let n=L(e);if(!n)return null;let a=(r[e.id]??e.w)>6;return(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-0 overflow-hidden rounded-lg",a&&"col-span-2"),style:{minHeight:a?200:120},children:t.render(n)},e.id)})})}),(0,ey.jsx)(QU,{open:u,dragMode:!1,label:o,onOpenChange:f,onAdd:()=>{f(!1),m(!0)},onDragModeChange:g}),(0,ey.jsx)(QH,{open:h,definitions:t,groupTitle:l,onOpenChange:m,onAdd:F}),(0,ey.jsx)(Q0,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}return(0,ey.jsxs)(QR,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("relative mx-auto max-w-7xl p-4 lg:p-6",p&&"select-none",i),style:{minHeight:R+48},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(GY)&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let n=r.find(e=>e.id===t),a=n&&QV(n);if(!n||!a||!_.has(a.kind))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let i=O.current,o=i?.getBoundingClientRect();!function(e,t){let n=QV(e);if(!n||!_.has(n.kind))return;E.current+=1;let r=`${n.kind}-clip-${E.current}`,a=Q$({id:r,kind:n.kind,x:t?.x??0,y:t?.y??Q_(v),w:n.w,h:n.h}),i=t&&!QL(a,v)?a:QF(v,r,n.kind,n.w,n.h);x(e=>[...e,i]),b(e=>({...e,[r]:{...n.config}})),j(r),S(void 0)}(n,{x:o&&z>0?Math.round((e.clientX-o.left-24)/(z+12)):0,y:o&&z>0?Math.round((e.clientY-o.top-24)/(z+12)):Q_(v)})},onPointerDown:e=>{e.target===e.currentTarget&&(j(void 0),p||S(void 0))},children:(0,ey.jsx)("div",{className:"relative",style:{height:R},children:I.map(t=>{let n=_.get(t.kind);if(!n)return null;let r=L(t);return r?(0,ey.jsx)(Qq,{layout:t,layouts:I,cellSize:z,cellHeight:T,dragMode:p,selected:w===t.id,resizing:k===t.id,onSelect:()=>{p&&j(t.id)},onMove:$,onCut:()=>(function(t){let n=v.find(e=>e.id===t),r=n?_.get(n.kind):void 0,a=n?L(n):void 0;if(!n||!r||!a)return;let i=function({boardId:e,layout:t,definition:n,config:r}){let a={boardId:e,kind:t.kind,w:t.w,h:t.h,config:{...r}};return{id:`clip-${e}-${t.id}`,title:r.title||n.title,description:n.description,meta:`${t.w}x${t.h}`,icon:n.icon,dragData:{"application/vnd.vantaloom.clip-kind":"workspace-card","application/vnd.vantaloom.workspace-card-board":e,"application/vnd.vantaloom.workspace-card-kind":t.kind,"application/vnd.vantaloom.workspace-card-width":String(t.w),"application/vnd.vantaloom.workspace-card-height":String(t.h),"application/vnd.vantaloom.workspace-card-config":JSON.stringify(r),[GY]:JSON.stringify(a)},payloads:{[GY]:a}}}({boardId:e,layout:n,definition:r,config:a});s?.(e=>[i,...e.filter(e=>e.id!==i.id)]),x(e=>e.filter(e=>e.id!==t)),b(e=>{let n={...e};return delete n[t],n}),j(void 0),S(void 0),C(e=>e===t?void 0:e)})(t.id),onCopy:()=>(function(e){let t=v.find(t=>t.id===e),n=t?_.get(t.kind):void 0;if(!t||!n)return;M.current+=1;let r=`${e}-copy-${M.current}`,a=QF(v,r,t.kind,t.w,t.h);x(e=>[...e,a]),b(t=>({...t,[r]:t[e]??QB(n)})),j(r)})(t.id),onSettingsOpen:()=>C(t.id),onResizeStart:()=>{j(void 0),S(t.id)},onResizeEnd:()=>{j(t.id),S(void 0)},children:n.render(r)},t.id):null})})}),(0,ey.jsx)(QU,{open:u,dragMode:p,label:o,onOpenChange:f,onAdd:()=>{f(!1),m(!0)},onDragModeChange:g}),(0,ey.jsx)(QH,{open:h,definitions:t,groupTitle:l,onOpenChange:m,onAdd:F}),(0,ey.jsx)(Q0,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}function Q5({parts:e}){return(0,ey.jsx)(ey.Fragment,{children:e.map((e,t)=>(0,ey.jsx)("span",{className:e.small?"text-[0.55em]":void 0,children:e.text},`${e.text}-${t}`))})}function Q4({value:e,minSize:t=24,maxSize:n=180,className:r,...a}){let i=ew.useRef(null),o=ew.useRef(null),[l,s]=ew.useState(t),c=function(e){let t=e.trim();if(/^[$¥€]\s*\d/.test(t))return[{text:t.replace(/^[$¥€]\s*/,""),small:!1},{text:t[0]??"",small:!0}];let n=t.match(/^(.+?)\s*\/\s*(.+)$/);if(n)return[{text:n[1]??"",small:!1},{text:"/",small:!0},{text:n[2]??"",small:!1}];let r=t.match(/^(.+?)([%a-zA-Z$¥€]+)$/);return r?[{text:r[1]??t,small:!1},{text:r[2]??"",small:!0}]:[{text:t,small:!1}]}(e);return ew.useLayoutEffect(()=>{let e=i.current,r=o.current;if(!e||!r)return;function a(e,r){let a=e.clientWidth,i=e.clientHeight;if(a<=0||i<=0)return;let o=t,l=n,c=t;for(;o<=l;){let e=Math.floor((o+l)/2);r.style.fontSize=`${e}px`,r.getBoundingClientRect().width<=a&&r.getBoundingClientRect().height<=i?(c=e,o=e+1):l=e-1}s(c)}a(e,r);let l=new ResizeObserver(()=>a(e,r));return l.observe(e),()=>l.disconnect()},[n,t,e]),(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative min-h-0 min-w-0 overflow-hidden",r),...a,children:[(0,ey.jsx)("span",{ref:o,"aria-hidden":"true",className:"pointer-events-none invisible absolute right-0 bottom-0 flex items-baseline whitespace-nowrap font-semibold leading-none tracking-normal",children:(0,ey.jsx)(Q5,{parts:c})}),(0,ey.jsx)("span",{className:"absolute right-0 bottom-0 flex max-w-full items-baseline whitespace-nowrap font-semibold leading-none tracking-normal text-foreground",style:{fontSize:l},children:(0,ey.jsx)(Q5,{parts:c})})]})}function Q3(e){return/^\d+$/.test(e)&&1===e.length?`0${e}`:/^\d+(?:\.\d+)?%$/.test(e)?`${Number.parseFloat(e).toFixed(1)}%`:e}function Q6({label:e,value:t,minSize:n=42,maxSize:r=180,valueClassName:a="absolute right-0 bottom-0 h-2/3 w-full"}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)(Q4,{value:Q3(t),minSize:n,maxSize:r,className:a})]})}function Q8(e){return Math.max(0,Math.min(100,Math.round(e)))}function Q7({className:e,value:t=0,...n}){let r=Q8(t);return(0,ey.jsx)("div",{"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:(0,eI.cn)("relative h-1.5 w-full overflow-hidden rounded-full bg-muted",e),...n,children:(0,ey.jsx)("div",{"data-slot":"progress-indicator",className:"h-full rounded-full bg-primary transition-all",style:{width:`${r}%`}})})}function Q9({className:e,value:t=0,label:n,showValue:r=!0,...a}){let i=Q8(t),o=2*Math.PI*39;return(0,ey.jsxs)("div",{"data-slot":"progress-ring","aria-label":n?`${n} ${i}%`:`${i}%`,role:"img",className:(0,eI.cn)("relative grid size-24 place-items-center",e),...a,children:[(0,ey.jsxs)("svg",{"aria-hidden":"true","data-slot":"progress-ring-svg",viewBox:"0 0 100 100",className:"absolute inset-0 size-full overflow-visible",children:[(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--muted)",strokeWidth:12}),i>0&&(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--primary)",strokeDasharray:o,strokeDashoffset:o-i/100*o,strokeLinecap:"round",strokeWidth:12,className:"origin-center -rotate-90 transition-all"})]}),(0,ey.jsx)("div",{"data-slot":"progress-ring-center",className:"relative z-10 grid size-16 place-items-center rounded-full bg-card",children:r&&(0,ey.jsxs)("span",{className:"ui-text-control font-medium tabular-nums",children:[i,"%"]})})]})}(0,ek.default)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);let eee=(0,ek.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function eet({canvases:e,mode:t="active",scrollable:n=!1,onSelect:r}){let a=ew.useMemo(()=>e.map(e=>{var n;return{id:e.id,status:"live"===(n=e).status?"current":"review"===n.status?"blocked":"done",title:(0,ey.jsx)(een,{canvas:e,mode:t,onClick:()=>r(e)})}}),[e,t,r]);return(0,ey.jsx)(QC,{items:a,scrollCurrentIntoView:!1,className:(0,eI.cn)("mt-2",n&&"min-h-0 flex-1"),viewportClassName:(0,eI.cn)("max-h-none pr-0",n?"h-full overflow-y-auto":"overflow-visible"),itemClassName:"py-2"})}function een({canvas:e,onClick:t,mode:n}){return(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("grid w-full items-center gap-4 rounded-lg px-2 py-0 text-left transition-colors hover:bg-muted/50","active"===n?"grid-cols-[minmax(0,1fr)_8rem_1.75rem]":"grid-cols-[minmax(0,1fr)_7rem_7rem_8rem]"),onClick:t,children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:"active"===n?e.purpose:`${e.nodes} nodes`})]}),"active"===n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Q7,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("span",{"aria-label":e.progress>=100?"Canvas complete":"Canvas incomplete",className:(0,eI.cn)("size-2.5 rounded-full",e.progress>=100?"bg-primary":"bg-border")})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eer,{icon:(0,ey.jsx)(Vb,{}),value:`${e.snapshots}`}),(0,ey.jsx)(eer,{icon:(0,ey.jsx)(eee,{}),value:e.runtime}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:e.lastOpened})]})]})}function eer({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}let eea=(0,ek.default)("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),eei=(0,ek.default)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);(0,ek.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var eeo=ew;function eel(){return(eel=Object.assign.bind()).apply(null,arguments)}function ees(e){return ew.createElement(Dc,eel({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var eec=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(n,r)=>{if(kp(e))return e;var a=kp(n)||null==n;return a?e(n,r):(a||function(e,t){if(!e)throw Error("Invariant failed")}(!1,"minPointSize callback function received a value with type of ".concat(typeof n,". Currently only numbers or null/undefined are supported.")),t)}},eed=["children"],eeu=(0,ew.createContext)({data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function eef(e){var{children:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,eed);return ew.createElement(eeu.Provider,{value:n},t)}var eeh=(e,t,n)=>{var r=null!=n?n:e;if(null!=r)return ky(r,t,0)};function eem(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eep(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eem(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eem(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var eeg=j2([PK,(e,t)=>t],(e,t)=>e.filter(e=>"bar"===e.type).find(e=>e.id===t)),eev=j2([eeg],e=>null==e?void 0:e.maxBarSize),eex=j2([Cb,PK,Yh,Ym,(e,t,n)=>n],(e,t,n,r,a)=>t.filter(t=>"horizontal"===e?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===a).filter(e=>!1===e.hide).filter(e=>"bar"===e.type)),eey=j2([eex,e=>e.rootProps.barSize,(e,t)=>{var n=Cb(e),r=Yh(e,t),a=Ym(e,t);if(null!=r&&null!=a)return"horizontal"===n?Ii(e,"xAxis",r):Ii(e,"yAxis",a)}],(e,t,n)=>{var r=e.filter(Ml),a=e.filter(e=>null==e.stackId);return[...Object.entries(r.reduce((e,t)=>{var n=e[t.stackId];return null==n&&(n=[]),n.push(t),e[t.stackId]=n,e},{})).map(e=>{var r,[a,i]=e;return{stackId:a,dataKeys:i.map(e=>e.dataKey),barSize:eeh(t,n,null==(r=i[0])?void 0:r.barSize)}}),...a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>null!=e),barSize:eeh(t,n,e.barSize)}))]}),eeb=(e,t,n)=>{var r,a,i=Cb(e),o=Yh(e,t),l=Ym(e,t);if(null!=o&&null!=l)return"horizontal"===i?(r=Iu(e,"xAxis",o,n),a=Id(e,"xAxis",o,n)):(r=Iu(e,"yAxis",l,n),a=Id(e,"yAxis",l,n)),kB(r,a)},eew=j2([eey,CR,e=>e.rootProps.barGap,C_,(e,t,n)=>{var r,a,i,o,l=eeg(e,t);if(null==l)return 0;var s=Yh(e,t),c=Ym(e,t);if(null==s||null==c)return 0;var d=Cb(e),u=CR(e),{maxBarSize:f}=l;return"horizontal"===d?(i=Iu(e,"xAxis",s,n),o=Id(e,"xAxis",s,n)):(i=Iu(e,"yAxis",c,n),o=Id(e,"yAxis",c,n)),null!=(r=null!=(a=kB(i,o,!0))?a:null==f?u:f)?r:0},eeb,eev],(e,t,n,r,a,i,o)=>{var l=function(e,t,n,r,a){var i,o,l=r.length;if(!(l<1)){var s=ky(e,n,0,!0),c=[];if(kM(null==(i=r[0])?void 0:i.barSize)){var d=!1,u=n/l,f=r.reduce((e,t)=>e+(t.barSize||0),0);(f+=(l-1)*s)>=n&&(f-=(l-1)*s,s=0),f>=n&&u>0&&(d=!0,u*=.9,f=l*u);var h={offset:((n-f)/2|0)-s,size:0};o=r.reduce((e,t)=>{var n,r={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:h.offset+h.size+s,size:d?u:null!=(n=t.barSize)?n:0}},a=[...e,r];return h=r.position,a},c)}else{var m=ky(t,n,0,!0);n-2*m-(l-1)*s<=0&&(s=0);var p=(n-2*m-(l-1)*s)/l;p>1&&(p>>=0);var g=kM(a)?Math.min(p,a):p;o=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:m+(p+s)*n+(p-g)/2,size:g}}],c)}return o}}(n,r,a!==i?a:i,e,null==o?t:o);return a!==i&&null!=l&&(l=l.map(e=>eep(eep({},e),{},{position:eep(eep({},e.position),{},{offset:e.position.offset-a/2})}))),l}),eej=j2([eew,eeg],(e,t)=>{if(null!=e&&null!=t){var n=e.find(e=>e.stackId===t.stackId&&null!=t.dataKey&&e.dataKeys.includes(t.dataKey));if(null!=n)return n.position}}),eek=j2([(e,t,n)=>{var r=Cb(e),a=Yh(e,t),i=Ym(e,t);if(null!=a&&null!=i)return"horizontal"===r?As(e,"yAxis",i,n):As(e,"xAxis",a,n)},eeg],(e,t)=>{var n=Mi(t);if(!e||null==n||null==t)return;var{stackId:r}=t;if(null!=r){var a=e[r];if(a){var{stackedData:i}=a;if(i)return i.find(e=>e.key===n)}}}),eeS=j2([k0,k2,(e,t,n)=>{var r=Yh(e,t);if(null!=r)return Iu(e,"xAxis",r,n)},(e,t,n)=>{var r=Ym(e,t);if(null!=r)return Iu(e,"yAxis",r,n)},(e,t,n)=>{var r=Yh(e,t);if(null!=r)return Id(e,"xAxis",r,n)},(e,t,n)=>{var r=Ym(e,t);if(null!=r)return Id(e,"yAxis",r,n)},eej,Cb,j8,eeb,eek,eeg,(e,t,n,r)=>r],(e,t,n,r,a,i,o,l,s,c,d,u,f)=>{var h,{chartData:m,dataStartIndex:p,dataEndIndex:g}=s;if(null!=u&&null!=o&&null!=t&&("horizontal"===l||"vertical"===l)&&null!=n&&null!=r&&null!=a&&null!=i&&null!=c){var{data:v}=u;if(null!=(h=null!=v&&v.length>0?v:null==m?void 0:m.slice(p,g+1)))return function(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:a},pos:i,bandSize:o,xAxis:l,yAxis:s,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:f,offset:h,cells:m,parentViewBox:p,dataStartIndex:g}=e,v="horizontal"===t?s:l,x=u?v.scale.domain():null,y=(e=>{var{numericAxis:t}=e,n=t.scale.domain();if("number"===t.type){var r=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return r<=0&&a>=0?0:a<0?a:r}return n[0]})({numericAxis:v}),b=v.scale.map(y);return f.map((e,f)=>{if(u){var v=u[f+g];if(null==v)return null;j=((e,t)=>{if(!t||2!==t.length||!kp(t[0])||!kp(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!kp(e[0])||e[0]<n)&&(a[0]=n),(!kp(e[1])||e[1]>r)&&(a[1]=r),a[0]>r&&(a[0]=r),a[1]<n&&(a[1]=n),a})(v,x)}else Array.isArray(j=kA(e,n))||(j=[y,j]);var w=eec(r,0)(j[1],f);if("horizontal"===t){var j,k,S,N,C,M,E,O=s.scale.map(j[0]),P=s.scale.map(j[1]);if(null==O||null==P)return null;k=kL({axis:l,ticks:c,bandSize:o,offset:i.offset,entry:e,index:f}),S=null!=(E=null!=P?P:O)?E:void 0,N=i.size;var A=O-P;if(C=kh(A)?0:A,M={x:k,y:h.top,width:N,height:h.height},Math.abs(w)>0&&Math.abs(C)<Math.abs(w)){var I=kf(C||w)*(Math.abs(w)-Math.abs(C));S-=I,C+=I}}else{var z=l.scale.map(j[0]),T=l.scale.map(j[1]);if(null==z||null==T)return null;if(k=z,S=kL({axis:s,ticks:d,bandSize:o,offset:i.offset,entry:e,index:f}),N=T-z,C=i.size,M={x:h.left,y:S,width:h.width,height:C},Math.abs(w)>0&&Math.abs(N)<Math.abs(w)){var D=kf(N||w)*(Math.abs(w)-Math.abs(N));N+=D}}return null!=k&&null!=S&&null!=N&&null!=C&&(a||0!==N&&0!==C)?eeB(eeB({},e),{},{stackedBarStart:b,x:k,y:S,width:N,height:C,value:u?j:j[1],payload:e,background:M,tooltipPosition:{x:k+N/2,y:S+C/2},parentViewBox:p,originalDataIndex:f},m&&m[f]&&m[f].props):null}).filter(Boolean)}({layout:l,barSettings:u,pos:o,parentViewBox:t,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,stackedData:d,displayedData:h,offset:e,cells:f,dataStartIndex:p})}}),eeN=(e,t)=>t,eeC=(e,t,n)=>n,eeM=j2([eeN,PK,eeC],(e,t,n)=>t.filter(e=>"bar"===e.type).filter(t=>t.stackId===e).filter(e=>e.isPanorama===n).filter(e=>!e.hide)),eeE=j2([eeM],e=>e.map(e=>e.id)),eeO=j2([e=>e,eeN,eeC],(e,t,n)=>{var r=eeE(e,t,n),a=[];return r.forEach(t=>{var r=eeS(e,t,n,void 0);null==r||r.forEach(e=>{var t=e.originalDataIndex;a[t]=((e,t)=>{if(!e)return t;if(!t)return e;var n=Math.min(e.x,e.x+e.width,t.x,t.x+t.width),r=Math.min(e.y,e.y+e.height,t.y,t.y+t.height);return{x:n,y:r,width:Math.max(e.x,e.x+e.width,t.x,t.x+t.width)-n,height:Math.max(e.y,e.y+e.height,t.y,t.y+t.height)-r}})(a[t],e)})}),a}),eeP=["index"];function eeA(){return(eeA=Object.assign.bind()).apply(null,arguments)}var eeI=(0,ew.createContext)(void 0),eez=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),eeT=e=>{var{index:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,eeP),r=(e=>{var t=(0,ew.useContext)(eeI);if(null!=t){var{stackId:n}=t;return"url(#".concat(eez(n,e),")")}})(t);return ew.createElement(IW,eeA({className:"recharts-bar-stack-layer",clipPath:r},n))},eeD=["onMouseEnter","onMouseLeave","onClick"],eeR=["value","background","tooltipPosition"],ee_=["id"],eeL=["onMouseEnter","onClick","onMouseLeave"];function ee$(){return(ee$=Object.assign.bind()).apply(null,arguments)}function eeF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eeB(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eeF(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eeF(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eeV(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var eeH=eeo.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:a,name:i,hide:o,unit:l,tooltipType:s,id:c}=e,d={dataDefinedOnItem:void 0,getPosition:kN,settings:{stroke:n,strokeWidth:r,fill:a,dataKey:t,nameKey:void 0,name:kH(i,t),hide:o,type:s,color:a,unit:l,graphicalItemId:c}};return eeo.createElement(Ra,{tooltipEntrySettings:d})});function eeU(e){var t,n=Se(R7),{data:r,dataKey:a,background:i,allOtherBarProps:o}=e,{onMouseEnter:l,onMouseLeave:s,onClick:c}=o,d=eeV(o,eeD),u=Rt(l,a,o.id),f=Rn(s),h=Rr(c,a,o.id);if(!i||null==r)return null;var m=IB(i);return eeo.createElement(_V,{zIndex:(t=CX.barBackground,i&&"object"==typeof i&&"zIndex"in i&&"number"==typeof i.zIndex&&kM(i.zIndex)?i.zIndex:t)},r.map((e,t)=>{var{value:r,background:o,tooltipPosition:l}=e,s=eeV(e,eeR);if(!o)return null;var c=u(e,t),p=f(e,t),g=h(e,t),v=eeB(eeB(eeB(eeB(eeB({option:i,isActive:String(t)===n},s),{},{fill:"#eee"},o),m),zf(d,e,t)),{},{onMouseEnter:c,onMouseLeave:p,onClick:g,dataKey:a,index:t,className:"recharts-bar-background-rectangle"});return eeo.createElement(ees,ee$({key:"background-bar-".concat(t)},v))}))}function eeW(e){var{showLabels:t,children:n,rects:r}=e,a=null==r?void 0:r.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return eeB(eeB({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return eeo.createElement(Ln,{value:t?a:void 0},n)}function eeq(e){var t,{shape:n,activeBar:r,baseProps:a,entry:i,index:o,dataKey:l}=e,s=Se(R7),c=Se(_e),d=r&&String(i.originalDataIndex)===s&&(null==c||l===c),[u,f]=(0,eeo.useState)(!1),[h,m]=(0,eeo.useState)(!1);(0,eeo.useEffect)(()=>{var e;return d?(f(!0),e=requestAnimationFrame(()=>{m(!0)})):m(!1),()=>{cancelAnimationFrame(e)}},[d]);var p=(0,eeo.useCallback)(()=>{d||f(!1)},[d]),g=d&&h,v=d||u;t=d?!0===r?n:r:n;var x=eeo.createElement(ees,ee$({},a,{name:String(a.name)},i,{isActive:g,option:t,index:o,dataKey:l,onTransitionEnd:p}));return v?eeo.createElement(_V,{zIndex:CX.activeBar},eeo.createElement(eeT,{index:i.originalDataIndex},x)):x}function eeK(e){var{shape:t,baseProps:n,entry:r,index:a,dataKey:i}=e;return eeo.createElement(ees,ee$({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:a,dataKey:i}))}function eeG(e){var t,{data:n,props:r}=e,a=null!=(t=IF(r))?t:{},{id:i}=a,o=eeV(a,ee_),{shape:l,dataKey:s,activeBar:c}=r,{onMouseEnter:d,onClick:u,onMouseLeave:f}=r,h=eeV(r,eeL),m=Rt(d,s,i),p=Rn(f),g=Rr(u,s,i);return n?eeo.createElement(eeo.Fragment,null,n.map((e,t)=>eeo.createElement(eeT,ee$({index:e.originalDataIndex,key:"rectangle-".concat(null==e?void 0:e.x,"-").concat(null==e?void 0:e.y,"-").concat(null==e?void 0:e.value,"-").concat(t),className:"recharts-bar-rectangle"},zf(h,e,t),{onMouseEnter:m(e,t),onMouseLeave:p(e,t),onClick:g(e,t)}),c?eeo.createElement(eeq,{shape:l,activeBar:c,baseProps:o,entry:e,index:t,dataKey:s}):eeo.createElement(eeK,{shape:l,baseProps:o,entry:e,index:t,dataKey:s})))):null}function eeX(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:s,onAnimationEnd:c,onAnimationStart:d}=t,u=n.current,f=Tk(t,"recharts-bar-"),[h,m]=(0,eeo.useState)(!1),p=(0,eeo.useCallback)(()=>{"function"==typeof c&&c(),m(!1)},[c]),g=(0,eeo.useCallback)(()=>{"function"==typeof d&&d(),m(!0)},[d]);return eeo.createElement(eeW,{showLabels:!h,rects:r},eeo.createElement(Tj,{animationId:f,begin:o,duration:l,isActive:i,easing:s,onAnimationEnd:p,onAnimationStart:g,key:f},e=>{var i=1===e?r:null==r?void 0:r.map((t,n)=>{var r=u&&u[n];if(r)return eeB(eeB({},t),{},{x:kw(r.x,t.x,e),y:kw(r.y,t.y,e),width:kw(r.width,t.width,e),height:kw(r.height,t.height,e)});if("horizontal"===a){var i=kw(0,t.height,e),o=kw(t.stackedBarStart,t.y,e);return eeB(eeB({},t),{},{y:o,height:i})}var l=kw(0,t.width,e),s=kw(t.stackedBarStart,t.x,e);return eeB(eeB({},t),{},{width:l,x:s})});return(e>0&&(n.current=null!=i?i:null),null==i)?null:eeo.createElement(IW,null,eeo.createElement(eeG,{props:t,data:i}))}),eeo.createElement(Lo,{label:t.label}),t.children)}function eeY(e){var t=(0,eeo.useRef)(null);return eeo.createElement(eeX,{previousRectanglesRef:t,props:e})}var eeZ=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:kA(e,t)}};class eeJ extends eeo.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:a,yAxisId:i,needClip:o,background:l,id:s}=this.props;if(e||null==t)return null;var c=(0,jL.clsx)("recharts-bar",r);return eeo.createElement(IW,{className:c,id:s},o&&eeo.createElement("defs",null,eeo.createElement(Yf,{clipPathId:s,xAxisId:a,yAxisId:i})),eeo.createElement(IW,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(s,")"):void 0},eeo.createElement(eeU,{data:t,dataKey:n,background:l,allOtherBarProps:this.props}),eeo.createElement(eeY,this.props)))}}var eeQ={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,xAxisId:0,yAxisId:0,zIndex:CX.bar};function ee0(e){var t,{xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u}=e,{needClip:f}=Yu(n,r),h=Se(Cb),m=N3(),p=z7(e.children,z2),g=Se(t=>eeS(t,e.id,m,p));if("vertical"!==h&&"horizontal"!==h)return null;var v=null==g?void 0:g[0];return t=null==v||null==v.height||null==v.width?0:"vertical"===h?v.height/2:v.width/2,eeo.createElement(eef,{xAxisId:n,yAxisId:r,data:g,dataPointFormatter:eeZ,errorBarOffset:t},eeo.createElement(eeJ,ee$({},e,{layout:h,needClip:f,data:g,xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u})))}eeo.memo(function(e){var t,n,r=zB(e,eeQ),a=(t=r.stackId,null!=(n=(0,ew.useContext)(eeI))?n.stackId:null!=t?kR(t):void 0),i=N3();return eeo.createElement(_y,{id:r.id,type:"bar"},e=>eeo.createElement(eeo.Fragment,null,eeo.createElement(_p,{legendPayload:(e=>{var{dataKey:t,name:n,fill:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kH(n,t),payload:e}]})(r)}),eeo.createElement(eeH,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:e}),eeo.createElement(_E,{type:"bar",id:e,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:i,hasCustomShape:null!=r.shape}),eeo.createElement(_V,{zIndex:r.zIndex},eeo.createElement(ee0,ee$({},r,{id:e})))))},Fb).displayName="Bar";let ee1=(0,ek.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);function ee2({className:e,orientation:t="horizontal",...n}){return(0,ey.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,eI.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}function ee5({label:e,description:t,value:n}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:t})]}),(0,ey.jsx)(Q4,{value:Q3(n),minSize:48,maxSize:220,className:"absolute right-0 bottom-0 h-2/3 w-full"})]})}(0,ek.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var ee4=ew,ee3=(e,t,n,r)=>Iu(e,"xAxis",t,r),ee6=(e,t,n,r)=>Id(e,"xAxis",t,r),ee8=(e,t,n,r)=>Iu(e,"yAxis",n,r),ee7=(e,t,n,r)=>Id(e,"yAxis",n,r),ee9=j2([Cb,ee3,ee8,ee6,ee7],(e,t,n,r,a)=>kI(e,"xAxis")?kB(t,r,!1):kB(n,a,!1));function ete(e){return"line"===e.type}var ett=j2([PK,(e,t,n,r,a)=>a],(e,t)=>e.filter(ete).find(e=>e.id===t)),etn=j2([Cb,ee3,ee8,ee6,ee7,ett,ee9,j6],(e,t,n,r,a,i,o,l)=>{var s,{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(null!=i&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=o&&("horizontal"===e||"vertical"===e)){var{dataKey:f,data:h}=i;if(null!=(s=null!=h&&h.length>0?h:null==c?void 0:c.slice(d,u+1)))return function(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:s}=e;return s.map((e,s)=>{var c=kA(e,o);if("horizontal"===t){var d=k_({axis:n,ticks:a,bandSize:l,entry:e,index:s}),u=null==c?null:r.scale.map(c);return{x:d,y:null!=u?u:null,value:c,payload:e}}var f=null==c?null:n.scale.map(c),h=k_({axis:r,ticks:i,bandSize:l,entry:e,index:s});return null==f||null==h?null:{x:f,y:h,value:c,payload:e}}).filter(Boolean)}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataKey:f,bandSize:o,displayedData:s})}}),etr=["id"],eta=["type","layout","connectNulls","needClip","shape"],eti=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function eto(){return(eto=Object.assign.bind()).apply(null,arguments)}function etl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ets(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?etl(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):etl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function etc(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var etd=ee4.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kN,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kH(o,t),hide:l,type:c,color:r,unit:s,graphicalItemId:d}};return ee4.createElement(Ra,{tooltipEntrySettings:u})}),etu=(e,t)=>"".concat(t,"px ").concat(e,"px");function etf(e){var{clipPathId:t,points:n,props:r}=e,{dot:a,dataKey:i,needClip:o}=r,{id:l}=r,s=IF(etc(r,etr));return ee4.createElement(Yo,{points:n,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:s,needClip:o,clipPathId:t})}function eth(e){var{showLabels:t,children:n,points:r}=e,a=(0,ee4.useMemo)(()=>null==r?void 0:r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return ets(ets({},r),{},{value:e.value,payload:e.payload,viewBox:r,parentViewBox:void 0,fill:void 0})}),[r]);return ee4.createElement(Ln,{value:t?a:void 0},n)}function etm(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:s,needClip:c,shape:d}=i,u=ets(ets({},IV(etc(i,eta))),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:l,connectNulls:s,strokeDasharray:null!=a?a:i.strokeDasharray});return ee4.createElement(ee4.Fragment,null,(null==r?void 0:r.length)>1&&ee4.createElement(Dc,eto({shapeType:"curve",option:d},u,{pathRef:n})),ee4.createElement(etf,{points:r,clipPathId:t,props:i}))}function etp(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,animateNewValues:f,width:h,height:m,onAnimationEnd:p,onAnimationStart:g}=n,v=a.current,x=Tk(o,"recharts-line-"),y=(0,ee4.useRef)(x),[b,w]=(0,ee4.useState)(!1),j=(0,ee4.useCallback)(()=>{"function"==typeof p&&p(),w(!1)},[p]),k=(0,ee4.useCallback)(()=>{"function"==typeof g&&g(),w(!0)},[g]),S=function(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch(e){return 0}}(r.current),N=(0,ee4.useRef)(0);y.current!==x&&(N.current=i.current,y.current=x);var C=N.current;return ee4.createElement(eth,{points:o,showLabels:!b},n.children,ee4.createElement(Tj,{animationId:x,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:j,onAnimationStart:k,key:x},e=>{var c,d=Math.min(kw(C,S+C,e),S);if(c=s?l?((e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return etu(t,e);for(var a=Math.floor(e/r),i=e%r,o=[],l=0,s=0;l<n.length;s+=null!=(c=n[l])?c:0,++l){var c,d=n[l];if(null!=d&&s+d>i){o=[...n.slice(0,l),i-s];break}}var u=o.length%2==0?[0,t]:[t];return[...function(e,t){for(var n=e.length%2!=0?[...e,0]:e,r=[],a=0;a<t;++a)r.push(...n);return r}(n,a),...o,...u].map(e=>"".concat(e,"px")).join(", ")})(d,S,"".concat(l).split(/[,\s]+/gim).map(e=>parseFloat(e))):etu(S,d):null==l?void 0:String(l),e>0&&S>0&&(a.current=o,i.current=Math.max(i.current,d)),v){var u=v.length/o.length,p=1===e?o:o.map((t,n)=>{var r=Math.floor(n*u);if(v[r]){var a=v[r];return ets(ets({},t),{},{x:kw(a.x,t.x,e),y:kw(a.y,t.y,e)})}return f?ets(ets({},t),{},{x:kw(2*h,t.x,e),y:kw(m/2,t.y,e)}):ets(ets({},t),{},{x:t.x,y:t.y})});return a.current=p,ee4.createElement(etm,{props:n,points:p,clipPathId:t,pathRef:r,strokeDasharray:c})}return ee4.createElement(etm,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:c})}),ee4.createElement(Lo,{label:n.label}))}function etg(e){var{clipPathId:t,props:n}=e,r=(0,ee4.useRef)(null),a=(0,ee4.useRef)(0),i=(0,ee4.useRef)(null);return ee4.createElement(etp,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:a,pathRef:i})}var etv=(e,t)=>{var n,r;return{x:null!=(n=e.x)?n:void 0,y:null!=(r=e.y)?r:void 0,value:e.value,errorVal:kA(e.payload,t)}};class etx extends ee4.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:a,yAxisId:i,top:o,left:l,width:s,height:c,id:d,needClip:u,zIndex:f}=this.props;if(e)return null;var h=(0,jL.clsx)("recharts-line",r),{r:m,strokeWidth:p}=YS(t),g=z9(t),v=2*m+p,x=u?"url(#clipPath-".concat(g?"":"dots-").concat(d,")"):void 0;return ee4.createElement(_V,{zIndex:f},ee4.createElement(IW,{className:h},u&&ee4.createElement("defs",null,ee4.createElement(Yf,{clipPathId:d,xAxisId:a,yAxisId:i}),!g&&ee4.createElement("clipPath",{id:"clipPath-dots-".concat(d)},ee4.createElement("rect",{x:l-v/2,y:o-v/2,width:s+v,height:c+v}))),ee4.createElement(eef,{xAxisId:a,yAxisId:i,data:n,dataPointFormatter:etv,errorBarOffset:0},ee4.createElement(etg,{props:this.props,clipPathId:d}))),ee4.createElement(Yd,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}}var ety={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:CX.line,type:"linear"};function etb(e){var t=zB(e,ety),{activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:s,hide:c,isAnimationActive:d,label:u,legendType:f,xAxisId:h,yAxisId:m,id:p}=t,g=etc(t,eti),{needClip:v}=Yu(h,m),x=Se(F2),y=Se(Cb),b=N3(),w=Se(e=>etn(e,h,m,b,p));if("horizontal"!==y&&"vertical"!==y||null==w||null==x)return null;var{height:j,width:k,x:S,y:N}=x;return ee4.createElement(etx,eto({},g,{id:p,connectNulls:l,dot:s,activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:d,hide:c,label:u,legendType:f,xAxisId:h,yAxisId:m,points:w,layout:y,height:j,width:k,left:S,top:N,needClip:v}))}var etw=ee4.memo(function(e){var t=zB(e,ety),n=N3();return ee4.createElement(_y,{id:t.id,type:"line"},e=>ee4.createElement(ee4.Fragment,null,ee4.createElement(_p,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kH(n,t),payload:e}]})(t)}),ee4.createElement(etd,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),ee4.createElement(_E,{type:"line",id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),ee4.createElement(etb,eto({},t,{id:e}))))},Fb);etw.displayName="Line";var etj=["axis"],etk=(0,ew.forwardRef)((e,t)=>ew.createElement(YG,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:etj,tooltipPayloadSearcher:LC,categoricalChartProps:e,ref:t}));let etS={online:"bg-foreground",warning:"bg-muted-foreground",offline:"bg-destructive"},etN={direct:"stroke-foreground",p2p:"stroke-foreground",relay:"stroke-muted-foreground",down:"stroke-destructive"},etC={topologyNode:function({data:e}){return(0,ey.jsxs)("div",{className:"vtl-surface-card min-w-36 rounded-[var(--surface-card-radius)] border px-3 py-2",children:[(0,ey.jsx)(ox,{type:"target",position:R.Top,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:R.Bottom,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"target",position:R.Left,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:R.Right,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("size-2.5 shrink-0 rounded-full",etS[e.state])}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:e.label})]}),e.meta?(0,ey.jsx)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:e.meta}):null]})}},etM={topologyEdge:function({id:e,sourceX:t,sourceY:n,targetX:r,targetY:a,sourcePosition:i,targetPosition:o,data:l}){let[s]=aE({sourcePosition:i,sourceX:t,sourceY:n,targetPosition:o,targetX:r,targetY:a}),{x:c,y:d}=function(e){if("u"<typeof document)return{x:0,y:0};let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",e);let n=t.getTotalLength(),r=t.getPointAtLength(n/2);return{x:r.x,y:r.y}}(s),u=l?.kind??"direct";return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(oL,{id:e,path:s,className:(0,eI.cn)("fill-none",etN[u],"p2p"===u&&"stroke-dasharray-[8_6]","relay"===u&&"stroke-dasharray-[12_8]"),style:{strokeWidth:"down"===u?3:2.4,strokeLinecap:"round",strokeLinejoin:"round"}}),(l?.label||l?.meta)&&(0,ey.jsx)("foreignObject",{x:c-48,y:d-20,width:96,height:40,className:"overflow-visible",requiredExtensions:"http://www.w3.org/1999/xhtml",children:(0,ey.jsxs)("div",{className:"pointer-events-none grid h-10 w-24 content-center rounded-md border bg-background/95 px-2 py-1 text-center shadow-sm",children:[l.label?(0,ey.jsx)("div",{className:"truncate text-xs font-medium leading-4",children:l.label}):null,l.meta?(0,ey.jsx)("div",{className:"truncate ui-text-kbd text-muted-foreground",children:l.meta}):null]})})]})}};function etE({nodes:e,links:t,className:n,...r}){let a=ew.useMemo(()=>e.map(e=>({id:e.id,data:{label:e.label,meta:e.meta,state:e.state??"online"},position:{x:e.x/100*1e3,y:e.y/100*560},type:"topologyNode"})),[e]),i=ew.useMemo(()=>t.map(e=>({id:e.id,data:{kind:e.kind??"direct",label:e.label,meta:e.meta},source:e.from,target:e.to,type:"topologyEdge"})),[t]);return(0,ey.jsx)("div",{"data-slot":"topology-map",className:(0,eI.cn)("h-full min-h-0 overflow-hidden rounded-xl bg-muted/25",n),...r,children:(0,ey.jsx)(lh,{children:(0,ey.jsx)(lg,{nodes:a,edges:i,nodeTypes:etC,edgeTypes:etM,fitView:!0,fitViewOptions:{maxZoom:1.15,minZoom:.45,padding:.22},minZoom:.35,maxZoom:1.5,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!1,zoomOnScroll:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},className:"topology-flow text-foreground",children:(0,ey.jsx)(lS,{gap:28,size:1,color:"var(--border)",className:"opacity-80"})})})})}function etO({nodes:e,links:t}){return(0,ey.jsx)(etE,{nodes:e,links:t})}function etP({title:e,count:t}){return(0,ey.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between",children:[(0,ey.jsx)("h2",{className:"text-sm font-semibold tracking-normal",children:e}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:t})]})}function etA({items:e}){return(0,ey.jsx)("div",{className:"mt-2 grid",children:e.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("px-2 py-2",t>0&&"border-t"),children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-1 truncate ui-text-kbd text-muted-foreground","warning"===e.tone&&"text-destructive"),children:e.meta})]},e.id))})}function etI({items:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r])=>({id:`${e}-${n}`,status:"完成"===r?"done":"运行中"===r?"current":"失败"===r?"blocked":"queued",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_8rem_minmax(0,1fr)_4rem] items-center gap-3",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:t}),(0,ey.jsx)("span",{className:"truncate",children:n}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:r})]})})),[e]);return(0,ey.jsx)(QC,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function etz({items:e}){let t=ew.useMemo(()=>e.map(e=>{var t;return{id:e.id,status:"running"===(t=e.state)?"current":"blocked"===t||"failed"===t?"blocked":"queued",title:(0,ey.jsx)(etT,{item:e})}}),[e]);return(0,ey.jsx)(QC,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function etT({item:e}){return(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_7.5rem_5rem] items-center gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.machine," · ",e.agent," · ",e.started]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(Q7,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("div",{className:"ui-text-kbd text-muted-foreground",children:e.runtime})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(Q7,{value:e.load,className:"h-1.5"}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:"load"})]})]})}function etD({workers:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(etR,{worker:e,divided:t>0},e.id))})}function etR({worker:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-24 grid-cols-[minmax(0,1fr)_2.5rem_auto] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-lg font-semibold tracking-normal",children:e.machine}),(0,ey.jsx)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:e.role})]}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.active,"/",e.capacity]}),(0,ey.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,ey.jsx)(et_,{label:"CPU",value:e.cpu}),(0,ey.jsx)(et_,{label:"MEM",value:e.memory})]})]})}function et_({label:e,value:t}){return(0,ey.jsxs)("div",{className:"grid justify-items-center gap-1",children:[(0,ey.jsx)(Q9,{value:t,label:e,className:"size-16 [&_[data-slot=progress-ring-center]]:size-10 [&_[data-slot=progress-ring-center]]:bg-background [&_[data-slot=progress-ring-center]_span]:text-xs"}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e})]})}function etL({events:e}){let t=ew.useMemo(()=>e.map(([e,t],n)=>({id:`${e}-${t}`,status:0===n?"current":"done",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate",children:t})]})})),[e]);return(0,ey.jsx)(QC,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function et$({machines:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(etF,{machine:e,divided:t>0},e.id))})}function etF({machine:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-20 grid-cols-[minmax(0,1fr)_minmax(0,1.45fr)] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(etV,{status:e.status}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.os," · ",e.link," · heartbeat ",e.heartbeat]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 sm:grid-cols-4",children:[(0,ey.jsx)(etB,{icon:(0,ey.jsx)(uS,{}),label:"CPU",value:e.cpu}),(0,ey.jsx)(etB,{icon:(0,ey.jsx)(eea,{}),label:"MEM",value:e.memory}),(0,ey.jsx)(etB,{icon:(0,ey.jsx)(uN,{}),label:"DISK",value:e.disk}),(0,ey.jsx)(etB,{icon:(0,ey.jsx)(eei,{}),label:"NET",value:e.network})]})]})}function etB({icon:e,label:t,value:n}){return(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsxs)("div",{className:"flex justify-between gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1 [&_svg]:size-3",children:[e,t]}),(0,ey.jsxs)("span",{children:[n,"%"]})]}),(0,ey.jsx)(Q7,{value:n,className:"h-1.5"})]})}function etV({status:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-2 rounded-full bg-border","online"===e&&"bg-primary")})}function etH({links:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r,a])=>({id:`${e}-${t}`,status:"Relay fallback"===n?"blocked":"current",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_5rem_4rem_3.5rem] items-center gap-3",children:[(0,ey.jsxs)("span",{className:"truncate",children:[e," / ",t]}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:r}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:a})]})})),[e]);return(0,ey.jsx)(QC,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function etU({config:e,data:t}){return(0,ey.jsx)(Ve,{config:e,className:"mt-2 min-h-0 flex-1",children:(0,ey.jsxs)(YY,{data:t,margin:{left:8,right:8},children:[(0,ey.jsx)(Zw,{vertical:!1}),(0,ey.jsx)(Z_,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8}),(0,ey.jsx)(BU,{content:(0,ey.jsx)(Vn,{indicator:"line"})}),(0,ey.jsx)(YU,{dataKey:"cpu",type:"monotone",fill:"var(--color-cpu)",fillOpacity:.11,stroke:"var(--color-cpu)",strokeWidth:2}),(0,ey.jsx)(YU,{dataKey:"memory",type:"monotone",fill:"var(--color-memory)",fillOpacity:.1,stroke:"var(--color-memory)",strokeWidth:2}),(0,ey.jsx)(YU,{dataKey:"network",type:"monotone",fill:"var(--color-network)",fillOpacity:.08,stroke:"var(--color-network)",strokeWidth:2})]})})}function etW({services:e}){let[t,n]=XD(),r=Math.max(1,Math.floor((Math.max(0,n.width-192-64-32)+5)/12)),a=Math.max(48,n.height>0?Math.floor((n.height-0*Math.max(0,e.length-1))/e.length):48),i=Math.max(28,a-22);return(0,ey.jsx)("div",{ref:t,className:"mt-2 min-h-0 flex-1",children:e.map((e,t)=>(0,ey.jsx)(etq,{service:e,divided:t>0,rowHeight:a,sampleCount:r,sampleHeight:i},e.id))})}function etq({service:e,divided:t,rowHeight:n,sampleCount:r,sampleHeight:a}){let i=ew.useMemo(()=>{var t,n;return t=e.samples,n=r,t.length>=n?t.slice(t.length-n):Array.from({length:n},(e,n)=>{let r=n%t.length;return t[r]??0})},[r,e.samples]);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid grid-cols-[12rem_minmax(0,1fr)_4rem] items-center gap-4 px-2",t&&"border-t"),style:{height:n},children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-0.5 truncate ui-text-kbd text-muted-foreground","告警"===e.state&&"text-destructive"),children:e.state})]}),(0,ey.jsx)("div",{"aria-label":`${e.name} 30 minute stability samples`,className:"flex min-w-0 items-center overflow-hidden",style:{gap:5},children:i.map((t,n)=>{var r;return(0,ey.jsx)("span",{className:(0,eI.cn)("shrink-0 rounded-[2px]",(r=t)<60?"bg-destructive":r<72?"bg-destructive/55":r<84?"bg-primary/35":r<92?"bg-primary/60":"bg-primary"),style:{width:7,height:a},title:`${t}%`},`${e.id}-${n}`)})}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.samples.at(-1),"%"]})]})}let etK=[{id:"canvas-vantaloom-base",title:"Vantaloom 基座设计",status:"live",purpose:"承载多标签系统、文件树、终端和 Agent 会话节点。",nodes:18,agents:3,progress:64,health:91,runtime:"3h 12m",tokenUsage:62e4,lastOpened:"刚刚",snapshots:14,unsavedChanges:3,roadmap:[{title:"接入节点模板选择",state:"done"},{title:"处理节点吸附与连线遮挡",state:"done"},{title:"合并多标签页拖拽",state:"running"},{title:"沉淀真实项目模板",state:"queued"}],settings:{nodeTemplates:["多标签页系统","文件管理树","终端标签组","Agent 对话"],defaultLayout:["默认缩放 0.72","节点内容 2x","定位点 24px"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],sharing:["工作组管理员可编辑","成员可审阅","访客不可访问"],autosave:["每 45 秒保存","节点拖拽结束保存","切换工作区保存"],snapshots:["保留最近 30 个","发布前创建检查点"],hosts:["Studio-PC","Linux-runner-02"],plugins:["Browser","Git checkpoint"]}},{id:"canvas-agent-lab",title:"Agent 编排实验",status:"live",purpose:"验证多 Agent 对话、工具窗口和剪切板在画布中的协同。",nodes:11,agents:4,progress:41,health:78,runtime:"1h 36m",tokenUsage:308e3,lastOpened:"8 分钟前",snapshots:9,unsavedChanges:1,roadmap:[{title:"四分工作区布局",state:"done"},{title:"面板替换进剪切板",state:"done"},{title:"会话浏览页",state:"running"},{title:"会话节点化",state:"queued"}],settings:{nodeTemplates:["Agent 对话","数据表标签","浏览器标签"],defaultLayout:["默认双栏","右侧可调整","剪切板常驻"],folders:["D:/Projects/Vantaloom-ui/apps/vantaloom"],sharing:["仅本机管理员可编辑"],autosave:["每 60 秒保存"],snapshots:["保留最近 12 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-release-map",title:"发布路线图",status:"review",purpose:"梳理组件库、主应用和文档的发布前检查。",nodes:9,agents:1,progress:83,health:86,runtime:"42m",tokenUsage:144e3,lastOpened:"今天 15:02",snapshots:7,unsavedChanges:0,roadmap:[{title:"组件清单",state:"done"},{title:"风险列表",state:"done"},{title:"最终检查",state:"running"}],settings:{nodeTemplates:["Diff 标签","数据表标签","文件预览标签"],defaultLayout:["审阅模式默认开启"],folders:["D:/Projects/Vantaloom-ui/docs"],sharing:["工作组可审阅"],autosave:["手动保存"],snapshots:["里程碑保留"],hosts:["Studio-PC"],plugins:[]}},{id:"canvas-browser-matrix",title:"浏览器预览矩阵",status:"idle",purpose:"检查不同 UA、比例和内嵌预览模式的表现。",nodes:6,agents:0,progress:100,health:94,runtime:"28m",tokenUsage:78e3,lastOpened:"昨天 18:44",snapshots:5,unsavedChanges:0,roadmap:[{title:"自适应模式",state:"done"},{title:"长宽比菜单",state:"done"},{title:"导航按钮",state:"done"}],settings:{nodeTemplates:["浏览器标签","多标签页系统"],defaultLayout:["自适应预览"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-ops-topology",title:"工作组拓扑",status:"idle",purpose:"记录机器、服务和工作组连接关系。",nodes:15,agents:0,progress:100,health:89,runtime:"1h 04m",tokenUsage:92e3,lastOpened:"周四 11:30",snapshots:11,unsavedChanges:0,roadmap:[{title:"机器节点整理",state:"done"},{title:"连接策略标注",state:"done"},{title:"访问权限检查",state:"done"}],settings:{nodeTemplates:["数据表标签","浏览器标签","终端标签组"],defaultLayout:["视口吸附开启","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui/ops"],sharing:["管理员可编辑","成员可查看"],autosave:["每 2 分钟保存"],snapshots:["每日保留"],hosts:["Studio-PC","Linux-runner-02","MacBook-build"],plugins:[]}}];function etG(e,t,n,r,a,i,o){return{id:e,title:t,status:"idle",purpose:n,nodes:r,agents:0,progress:100,health:90,runtime:a,tokenUsage:i,lastOpened:o,snapshots:Math.max(3,Math.round(r/2)),unsavedChanges:0,roadmap:[{title:"整理节点结构",state:"done"},{title:"检查连接关系",state:"done"},{title:"保存最终快照",state:"done"}],settings:{nodeTemplates:["多标签页系统","文件预览标签"],defaultLayout:["默认缩放 0.72","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:[]}}}etK.push(etG("canvas-terminal-layout","终端工作台草图","记录终端标签组、日志表和命令区的组合方式。",7,"36m",84e3,"昨天 15:21"),etG("canvas-file-review","文件审阅流程","沉淀文件树、diff 预览和文件标签之间的拖拽关系。",12,"58m",126e3,"周五 20:10"),etG("canvas-settings-ia","设置导航结构","整理设置菜单面板的主菜单、子菜单和搜索入口。",8,"24m",61e3,"周五 16:42"),etG("canvas-auth-access","本机账户接入","记录本机用户、工作组加入和可用机器列表关系。",10,"47m",112e3,"周四 22:05"),etG("canvas-data-ops","运维数据面板","对齐数据表标签、机器状态卡片和运行记录列表。",14,"1h 18m",172e3,"周三 19:48"));let etX=etK.filter(e=>"idle"!==e.status),etY=etK.filter(e=>"idle"===e.status);function etZ(e,t,n=""){return{title:e,dataSource:t,refreshRate:"30s",note:n}}function etJ(e,t){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5","vtl-jelly-image-card vtl-jelly-image-card-shadowless"),style:QA({image:t,opacity:.88,blur:"0px"}),children:e})}let etQ=[{id:"metric-active",kind:"metric-active",x:0,y:0,w:3,h:3},{id:"metric-nodes",kind:"metric-nodes",x:3,y:0,w:3,h:3},{id:"metric-unsaved",kind:"metric-unsaved",x:6,y:0,w:3,h:3},{id:"metric-snapshots",kind:"metric-snapshots",x:9,y:0,w:3,h:3},{id:"active",kind:"active",x:0,y:3,w:12,h:3},{id:"recent",kind:"recent",x:0,y:6,w:12,h:Math.max(3,Math.ceil(.75*etY.length)+1)}];function et0({open:e,title:t,description:n,eyebrow:r,panels:a,defaultPanelId:i="overview",onOpenChange:o}){let l=sb(),[s,c]=ew.useState(i),d=a.find(e=>e.id===s)??a[0];return ew.useEffect(()=>{e&&c(i)},[i,e]),(0,ey.jsx)(dC,{open:e,onOpenChange:o,children:(0,ey.jsxs)(fx,{hideClose:!0,className:(0,eI.cn)("gap-0 overflow-hidden p-0",l?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"h-[min(44rem,calc(100svh-2rem))] max-w-5xl"),children:[(0,ey.jsx)(fb,{className:"sr-only",children:t}),(0,ey.jsxs)(fw,{className:"sr-only",children:[r?(0,ey.jsxs)(ey.Fragment,{children:[r,". "]}):null,n??t]}),l?(0,ey.jsxs)("div",{className:"flex h-full flex-col",children:[(0,ey.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-3",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"关闭",onClick:()=>o(!1),children:(0,ey.jsx)(fg.XIcon,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[r?(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:r}):null,(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:t})]})]}),(0,ey.jsx)("nav",{className:"shrink-0 overflow-x-auto border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsx)("div",{className:"flex gap-1.5 px-4 py-2",children:a.map(e=>(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition-colors",d?.id===e.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e.icon}):null,(0,ey.jsx)("span",{children:e.label}),e.badge?(0,ey.jsx)(Bs,{variant:"outline",className:"h-4 px-1 ui-text-kbd",children:e.badge}):null]},e.id))})}),(0,ey.jsx)(wz,{className:"min-h-0 flex-1",children:(0,ey.jsx)("div",{className:"p-4",children:d?.content})})]}):(0,ey.jsxs)("div",{className:"grid size-full min-h-0 grid-cols-[15rem_minmax(0,1fr)]",children:[(0,ey.jsx)("aside",{"data-slot":"resource-management-dialog-sidebar",className:"min-h-0 border-r bg-muted/20",children:(0,ey.jsx)(wz,{className:"h-full",children:(0,ey.jsx)("div",{className:"space-y-1 p-2",children:a.map(e=>(0,ey.jsxs)(eA.Button,{"data-slot":"resource-management-dialog-nav-item",type:"button",variant:"ghost",className:(0,eI.cn)("h-9 w-full justify-start px-2.5 text-left font-medium",d?.id===e.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:e.icon}):null,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.badge?(0,ey.jsx)(Bs,{variant:"outline",className:"h-5 px-1.5 ui-text-kbd",children:e.badge}):null]},e.id))})})}),(0,ey.jsx)(wz,{className:"min-h-0 bg-background",children:(0,ey.jsx)("div",{className:"p-5 pr-9",children:d?.content})})]})]})})}function et1({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let[r,a]=ew.useState(),i=ew.useMemo(()=>(function({onSelect:e}){return[{id:"metric-active",title:"活跃画布",description:"当前正在编辑的画布数量。",icon:(0,ey.jsx)(uP,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etZ("活跃画布","画布列表"),render:e=>etJ((0,ey.jsx)(ee5,{label:e.title,description:"当前正在编辑的画布数量",value:String(etX.length)}),QM)},{id:"metric-nodes",title:"运行节点",description:"所有活跃画布内的节点。",icon:(0,ey.jsx)(Vb,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etZ("运行节点","画布节点"),render:e=>etJ((0,ey.jsx)(ee5,{label:e.title,description:"所有活跃画布内的节点",value:"38"}),QE)},{id:"metric-unsaved",title:"未保存",description:"等待写入的画布变更。",icon:(0,ey.jsx)(jT,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etZ("未保存","画布保存状态"),render:e=>etJ((0,ey.jsx)(ee5,{label:e.title,description:"等待写入的画布变更",value:"4"}),QO)},{id:"metric-snapshots",title:"快照",description:"可回退的历史存档。",icon:(0,ey.jsx)(K2,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:etZ("快照","画布快照"),render:e=>etJ((0,ey.jsx)(ee5,{label:e.title,description:"可回退的历史存档",value:"46"}),QP)},{id:"active",title:"正在使用的画布",description:"活跃画布 Roadmap。",icon:(0,ey.jsx)(uP,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:etZ("正在使用的画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(etP,{title:t.title,count:etX.length}),(0,ey.jsx)(eet,{canvases:etX,scrollable:!0,onSelect:e})]})},{id:"recent",title:"最近画布",description:"最近打开的画布。",icon:(0,ey.jsx)(m0,{className:"size-4"}),defaultSize:{w:12,h:Math.max(3,Math.ceil(.75*etY.length)+1)},defaultConfig:etZ("最近画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col",children:[(0,ey.jsx)(etP,{title:t.title,count:etY.length}),(0,ey.jsx)(eet,{canvases:etY,mode:"archive",onSelect:e})]})}]})({onSelect:a}),[]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Q2,{boardId:"canvas-library",definitions:i,initialLayouts:etQ,clipboardItems:e,actionLabel:"画布库页面卡片操作",paletteGroupTitle:"画布库页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n}),(0,ey.jsx)(et5,{canvas:r,onOpenChange:e=>{e||a(void 0)}})]})}function et2({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}function et5({canvas:e,onOpenChange:t}){return e?(0,ey.jsx)(et0,{open:!!e,onOpenChange:t,title:e.title,eyebrow:"画布管理",description:e.purpose,panels:[{id:"overview",label:"首页",icon:(0,ey.jsx)(Vw,{}),content:(0,ey.jsx)(et4,{canvas:e})},{id:"templates",label:"节点模板",icon:(0,ey.jsx)(Qx,{}),badge:e.settings.nodeTemplates.length,content:(0,ey.jsx)(et6,{title:"可用节点模板",items:e.settings.nodeTemplates})},{id:"layout",label:"默认布局",icon:(0,ey.jsx)(Qk,{}),content:(0,ey.jsx)(et6,{title:"默认布局参数",items:e.settings.defaultLayout})},{id:"folders",label:"工作区绑定",icon:(0,ey.jsx)(m0,{}),content:(0,ey.jsx)(et6,{title:"绑定的工作区文件夹",items:e.settings.folders})},{id:"sharing",label:"共享权限",icon:(0,ey.jsx)(Qj,{}),content:(0,ey.jsx)(et6,{title:"共享与权限",items:e.settings.sharing})},{id:"autosave",label:"自动保存",icon:(0,ey.jsx)(K3,{}),content:(0,ey.jsx)(et6,{title:"自动保存策略",items:e.settings.autosave})},{id:"snapshots",label:"快照和版本",icon:(0,ey.jsx)(K2,{}),content:(0,ey.jsx)(et6,{title:"快照和版本策略",items:e.settings.snapshots})},{id:"hosts",label:"可访问主机",icon:(0,ey.jsx)(Qb,{}),content:(0,ey.jsx)(et6,{title:"可访问主机",items:e.settings.hosts})},{id:"plugins",label:"插件",icon:(0,ey.jsx)(Qw,{}),content:(0,ey.jsx)(et6,{title:"画布插件",items:e.settings.plugins,empty:"未加载插件"})}]}):null}function et4({canvas:e}){return(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("button",{type:"button",className:"group relative grid min-h-72 rounded-[2rem] border bg-card p-7 text-left transition-colors hover:bg-muted/35",children:[(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("div",{className:"max-w-2xl",children:[(0,ey.jsx)("h3",{className:"text-3xl font-semibold tracking-normal",children:e.title}),(0,ey.jsx)("p",{className:"mt-4 text-sm leading-6 text-muted-foreground",children:e.purpose})]}),(0,ey.jsxs)("div",{className:"grid max-w-56 gap-2",children:[(0,ey.jsx)(et3,{label:"Nodes",value:`${e.nodes}`}),(0,ey.jsx)(et3,{label:"Agent",value:`${e.agents}`}),(0,ey.jsx)(et3,{label:"Snapshots",value:`${e.snapshots}`})]})]}),(0,ey.jsx)("span",{className:"absolute right-7 bottom-7 text-sm font-medium text-foreground transition-opacity group-hover:opacity-70",children:"进入"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"Roadmap"}),(0,ey.jsx)(et2,{icon:(0,ey.jsx)(Vb,{}),value:e.runtime})]}),(0,ey.jsx)(QC,{items:e.roadmap.map(e=>({id:e.title,title:e.title,status:"running"===e.state?"current":"done"===e.state?"done":"queued"})),viewportClassName:"max-h-64"})]})]})}function et3({label:e,value:t}){return(0,ey.jsxs)("span",{className:"grid min-w-0 gap-0.5 py-0.5",children:[(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold tracking-normal",children:t})]})}function et6({title:e,items:t,empty:n="暂无内容"}){return(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"overflow-hidden rounded-xl border bg-card",children:t.length>0?t.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("flex min-h-10 items-center gap-2 px-3 text-sm",t>0&&"border-t"),children:[(0,ey.jsx)(Qy,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 truncate",children:e})]},e)):(0,ey.jsx)("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:n})})]})}function et8({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xg,{open:e,onOpenChange:t,title:"添加节点",description:"搜索并选择要放入画布的可用节点。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xp,{loop:!0,children:[(0,ey.jsx)(xv,{placeholder:"搜索节点..."}),(0,ey.jsxs)(xx,{children:[(0,ey.jsx)(xy,{children:"没有匹配节点。"}),(0,ey.jsx)(xb,{heading:"可用节点",children:uL.map(e=>(0,ey.jsxs)(xw,{value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e),children:[(0,ey.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xj,{children:[e.size.width,"x",e.size.height]})]},e.id))})]})]})})}function et7({nodes:e,edges:t,selectedNodeId:n,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c}){let d=ew.useRef(null),{addPaletteOpen:u,addTemplateNode:f,handleAddPaletteOpenChange:h,handleCanvasAction:m,handleCanvasDragOver:p,handleCanvasDrop:g,handleNodeCanvasConnect:v,handleNodeCanvasEdgeAction:x,handleNodeCanvasNodeAction:y,filePickerDialog:b,renderedCanvasNodes:w}=function({workspaceRef:e,nodes:t,clipboardItems:n,onNodesSet:r,onEdgesSet:a,onSelectedNodeChange:i,onClipboardItemsChange:o}){let l=ew.useRef(0),s=ew.useRef(0),[c,d]=ew.useState(!1),[u,f]=ew.useState(),[h,m]=ew.useState(),p=ew.useCallback((t,n)=>{let r,a,i,o,l,s,c,d;return r=e.current,a=r?.querySelector(".react-flow__viewport"),i=r?.getBoundingClientRect(),l="none"!==(o=a?getComputedStyle(a).transform:"none")?new DOMMatrixReadOnly(o):void 0,s=l?.a&&Number.isFinite(l.a)?l.a:1,c=l?.e??0,d=l?.f??0,{x:(t-(i?.left??0)-c)/s,y:(n-(i?.top??0)-d)/s}},[e]),g=ew.useCallback((e,t)=>{r(n=>n.map(n=>{let r,a;return n.id===e?(a="string"==typeof(r=n.data??{}).activeTabId&&t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id,{...n,data:{...r,tabs:t,activeTabId:a}}):n}))},[r]),v=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},activeTabId:t}}:n))},[r]),x=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?function(e,t){let n=e.data??{};if("multi-tab-system"===n.kind){let r=Array.isArray(n.tabs)?n.tabs:[];return{...e,data:{...n,tabs:r.map(e=>e.id===t.id?t:e),activeTabId:t.id}}}return uB(n.kind)?{...e,data:{...n,tab:t}}:e}(n,t):n))},[r]),y=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},terminal:t}}:n))},[r]),b=ew.useCallback((e,t)=>{var n;let a=(n=e.kind,uL.find(e=>e.id===n)?.size??uz({width:480,height:320}));s.current+=1;let o=`${e.kind}-detached-${s.current}`;r(n=>[...n,function({tab:e,nodeId:t,center:n,size:r}){return{id:t,type:"blank",position:uR(n,r),data:{contentScale:2,kind:e.kind,tab:{...e,id:`${t}-tab`}},width:r.width,height:r.height,style:uT(r)}}({tab:e,nodeId:o,center:t,size:a})]),i(o)},[r,i]),w=ew.useCallback(async(e,n)=>{try{let a,i=n?.nodeId?t.find(e=>e.id===n.nodeId):void 0,o=i?(i.data??{}).kind:void 0,l="data-table-tab-viewer"===o?await fe(e):await u8(e),s=void 0!==i&&(a=i.data??{},"multi-tab-system"===a.kind||"file-tab-viewer"===a.kind||"data-table-tab-viewer"===a.kind);n?.nodeId&&s&&r(e=>e.map(e=>e.id===n.nodeId?function(e,t,n){let r=e.data??{};if("multi-tab-system"===r.kind){let a,i,o=Array.isArray(r.tabs)?r.tabs:[];return{...e,data:{...r,tabs:(a=o.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}}return"file-tab-viewer"===r.kind||"data-table-tab-viewer"===r.kind&&"data-table-tab-viewer"===t.kind?{...e,data:{...r,tab:t}}:e}(e,l,n.insertIndex):e)),n?.nodeId&&s||b(l,u??{x:496,y:336})}catch{h$.error("文件预览打开失败")}},[b,t,r,u]),j=ew.useCallback(e=>{let n=t.find(e=>"multi-tab-system"===(e.data??{}).kind);w(e,n?{nodeId:n.id}:void 0)},[t,w]),k=ew.useCallback(async(e,t,n)=>{let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw h$.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uX({machineId:a,path:r,content:n}),o={...t,title:i.name,modified:!1,defaultValue:"utf-8"===i.encoding?i.content:n,file:{...t.file,name:i.name,path:i.path,machineId:i.machine.id,mimeType:i.mimeType,kind:t.file?.kind,size:i.size,truncated:i.truncated}};x(e,o),h$.success("文件已保存")}catch(e){throw h$.error("文件保存失败"),e}},[x]),S=ew.useCallback((e,t,n)=>{b(t,p(n.clientX,n.clientY))},[b,p]),N=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),r=n.find(e=>e.id===t),a=r?r.payloads?.[GG]:void 0;if(a)return a;let i=e.dataTransfer.getData(GG);if(i)try{return JSON.parse(i)}catch{return}},[n]),C=ew.useCallback((e,t,n)=>{r(r=>r.map(r=>r.id!==e?r:function(e,t,n){let r=e.data??{},a=Array.isArray(r.tabs)?r.tabs:[],i=new Set(a.map(e=>e.id)),o=n.tab.id,l=2;for(;i.has(o);)o=`${n.tab.id}-${l}`,l+=1;let s=[...a];return s.splice(Math.max(0,Math.min(t,s.length)),0,{...n.tab,id:o}),{...e,data:{...r,tabs:s,activeTabId:o}}}(r,t,n)))},[r]),M=ew.useCallback((e,t,n)=>{let r=N(n);r&&C(e,t,r)},[N,C]),E=ew.useCallback(e=>(function(e,t){for(let n of[...e].reverse()){if("multi-tab-system"!==(n.data??{}).kind)continue;let e=function(e){let t="number"==typeof e.width?e.width:"number"==typeof e.style?.width?e.style.width:"string"==typeof e.style?.width?Number.parseFloat(e.style.width):192,n="number"==typeof e.height?e.height:"number"==typeof e.style?.height?e.style.height:"string"==typeof e.style?.height?Number.parseFloat(e.style.height):112;return{width:Number.isFinite(t)?t:192,height:Number.isFinite(n)?n:112}}(n),r=t.x>=n.position.x&&t.x<=n.position.x+e.width,a=t.y>=n.position.y&&t.y<=n.position.y+e.height;if(r&&a)return n}})(t,e),[t]),O=ew.useCallback((t,n,r)=>(function(e,t,n,r){let a=Array.from(e.current?.querySelectorAll(".react-flow__node")??[]).find(e=>e.getAttribute("data-id")===t),i=a?.querySelector('[data-slot="multi-tab-list"]');if(!i)return r;let o=Array.from(i.querySelectorAll("[data-tab-id]"));for(let[e,t]of o.entries()){let r=t.getBoundingClientRect();if(n<r.left+r.width/2)return e}return o.length})(e,t,n,r),[e]),P=function({nodes:e,onTabsChange:t,onActiveTabChange:n,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabChange:i,onSaveFileTab:o,onTerminalStateChange:l,onTabDetach:s,onExternalTabDrop:c}){return ew.useMemo(()=>e.map(e=>{let d=e.data??{},u=(e.data??{}).kind;return u?{...e,data:{...d,content:(0,ey.jsx)(JE,{kind:u,nodeId:e.id,tab:d.tab,tabs:d.tabs,activeTabId:d.activeTabId,terminalScopeId:`canvas:node:${e.id}`,terminalState:d.terminal,onTerminalStateChange:t=>l(e.id,t),onRequestFileTab:r,onOpenWorkspaceFile:a,onTabsChange:t,onTabChange:i,onSaveFileTab:o,onActiveTabChange:n,onTabDetach:s,onExternalTabDrop:c})}}:e}),[e,n,c,a,r,o,i,s,l,t])}({nodes:t,onTabsChange:g,onActiveTabChange:v,onRequestFileTab:m,onOpenWorkspaceFile:j,onTabChange:x,onSaveFileTab:k,onTerminalStateChange:y,onTabDetach:S,onExternalTabDrop:M}),A=ew.useCallback(e=>{s.current+=1;let n=`${e.id}-${t.length+s.current}`;r(t=>[...t,function({template:e,nodeId:t,center:n}){let r={contentScale:2,kind:e.id};return"multi-tab-system"===e.id?r.tabs=[]:uB(e.id)&&(r.tab=uH(e.id,`${t}-tab`)),{id:t,type:"blank",position:uR(n,e.size),data:r,width:e.size.width,height:e.size.height,style:uT(e.size)}}({template:e,nodeId:n,center:u??{x:496,y:336}})]),i(void 0),d(!1),f(void 0)},[t.length,r,i,u]),I=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let a=n.find(e=>e.id===t),o=p(e.clientX,e.clientY),s=N(e),c=s?E(o):void 0;if(s&&c){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=c.data??{},n=Array.isArray(t.tabs)?t.tabs:[],r=O(c.id,e.clientX,n.length);C(c.id,r,s),i(void 0);return}let d=a?a.payloads?.[GK]:void 0;if(!a||!d)return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",l.current+=1;let u=`${d.node.id}-drop-${l.current}`;r(e=>[...e,function({source:e,nodeId:t,center:n}){let r={width:e.width??192,height:e.height??112};return{...e,id:t,position:uR(n,r),style:e.style??uT(r),selected:!1,data:{...e.data??{},resizing:!1}}}({source:d.node,nodeId:u,center:o})]),i(u)},[n,E,N,p,O,C,r,i]),z=ew.useCallback(e=>{Array.from(e.dataTransfer.types).some(e=>[GK,GG].includes(e))&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[]),T=ew.useCallback((e,{flowPosition:t})=>{"add"===e&&(f(t),d(!0))},[]),D=ew.useCallback(e=>{a(t=>{if(t.find(t=>t.source===e.source&&t.target===e.target))return t;let n=t.find(t=>t.source===e.target&&t.target===e.source);return n?t.map(e=>e.id===n.id?{...e,data:{...e.data??{},bidirectional:!0}}:e):[...t,{id:`edge-${e.source}-${e.target}-${t.length+1}`,type:"connection",source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,data:{anchors:[]}}]})},[a]),R=ew.useCallback((e,t,n)=>{"cut-edge"===e?a(e=>e.filter(e=>e.id!==t)):a(r=>r.map(r=>{if(r.id!==t)return r;let a=[...r.data?.anchors??[]];return"add-anchor"===e&&n.anchor&&a.splice(n.anchorIndex??a.length,0,n.anchor),"move-anchor"===e&&n.anchor&&void 0!==n.anchorIndex&&(a[n.anchorIndex]=n.anchor),"delete-anchor"===e&&void 0!==n.anchorIndex&&a.splice(n.anchorIndex,1),{...r,data:{...r.data??{},anchors:a}}}))},[a]),_=ew.useCallback((e,n,{snappedPosition:l})=>{if("copy"===e)return void r(e=>{let t=e.find(e=>e.id===n);if(!t)return e;let r=`${t.id}-copy-${e.length+1}`;return i(r),[...e,{...t,id:r,position:l,selected:!1,data:{...t.data??{},resizing:!1}}]});if("cut"===e){let e,l,s,c,d,u=t.find(e=>e.id===n);if(!u)return;let f=(s=(l=function(e){let t=e.data??{},n=t.tab;if(n?.id&&uB(n.kind))return n;let r=t.kind;if(uB(r))return uH(r,e.id)}(e=uU(u)))?{tab:l,sourceNodeId:u.id}:void 0,c={[GK]:{node:e}},d={"application/vnd.vantaloom.clip-kind":l?"canvas-tab":"canvas-node",[GK]:u.id},s&&(c[GG]=s,d[GG]=JSON.stringify(s)),{id:`clip-${u.id}`,title:l?.title??"画布节点",description:l?"来自画布的独立标签页。":"来自节点画布的空白节点。",meta:`${Math.round(u.width??192)}x${Math.round(u.height??112)}`,icon:l?uV(l.kind):(0,ey.jsx)(uw,{className:"size-4"}),dragData:d,payloads:c});o(e=>[f,...e.filter(e=>e.id!==f.id)]),r(e=>e.filter(e=>e.id!==n)),a(e=>e.filter(e=>e.source!==n&&e.target!==n)),i(void 0)}},[t,o,a,r,i]);return{addPaletteOpen:c,addTemplateNode:A,filePickerDialog:(0,ey.jsx)(XT,{open:void 0!==h,onOpenChange:e=>{e||m(void 0)},onSelectFile:e=>{m(void 0),w(e,h)}}),handleAddPaletteOpenChange:function(e){d(e),e||f(void 0)},handleCanvasAction:T,handleCanvasDragOver:z,handleCanvasDrop:I,handleNodeCanvasConnect:D,handleNodeCanvasEdgeAction:R,handleNodeCanvasNodeAction:_,renderedCanvasNodes:P}}({workspaceRef:d,nodes:e,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c});return(0,ey.jsxs)("div",{ref:d,className:"vtl-app-background vtl-canvas-workspace relative h-full w-full overflow-hidden",onDragOver:p,onDrop:g,children:[(0,ey.jsx)(sy,{"aria-label":"新建画布",className:"h-full min-h-0 rounded-none border-0",viewportClassName:"h-full",nodes:w,edges:t,nodeTypes:uA,edgeTypes:uI,onNodesChange:a,onEdgesChange:i,selectedNodeId:n,onSelectedNodeChange:s,defaultViewport:{x:0,y:0,zoom:.5},labels:{actions:"画布操作",add:"添加节点",select:"普通鼠标",connect:"连接工具",cut:"剪刀工具",drag:"拖拽工具",modeTools:"模式工具",resetZoom:"重置缩放",viewportTools:"视口工具",lockViewport:"锁定视口",visualSnap:"视觉吸附",nodeSnap:"节点吸附",snapTools:"吸附工具",nodeActions:"节点操作",resizeNode:"调整大小",copyNode:"复制节点",cutNode:"剪切节点"},onCanvasAction:m,onNodeCanvasConnect:v,onNodeCanvasEdgeAction:x,onNodeCanvasNodeAction:y}),(0,ey.jsx)(et8,{open:u,onOpenChange:h,onAdd:f}),b,(0,ey.jsx)(hW,{position:"top-right"})]})}vw.length;let et9={delete:"Delete",empty:"Drop here",title:"Trash"};function ene({active:e=!1,items:t=[],labels:n,className:r,onDrop:a,onDelete:i,onItemRestore:o,...l}){let s={...et9,...n},[c,d]=ew.useState(!1),u=ew.useRef(0),f=e||c||t.length>0;return ew.useEffect(()=>{e||(u.current=0,d(!1))},[e]),(0,ey.jsx)("div",{"data-slot":"trash-drop-zone","data-visible":f,"data-drag-inside":c,className:(0,eI.cn)("fixed top-4 left-1/2 z-50 -translate-x-1/2 transition-[opacity,transform] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]",f?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-5 opacity-0",r),onDragEnter:function(e){e.preventDefault(),u.current+=1,d(!0)},onDragLeave:function(){u.current=Math.max(0,u.current-1),0===u.current&&d(!1)},onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",d(!0)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),u.current=0,d(!1);let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id")||e.dataTransfer.getData("text/plain"),n=e.dataTransfer.getData("text/plain")||t||"Dropped item",r=e.dataTransfer.getData("application/vnd.vantaloom.clip-kind");t&&a?.({id:t,title:n,meta:r,nativeEvent:e})},...l,children:(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-12 overflow-hidden rounded-xl border-2 border-background bg-destructive text-destructive-foreground shadow-lg shadow-black/15 transition-[width,min-height,background-color,border-color,padding,box-shadow] duration-300","dark:border-destructive dark:bg-background dark:text-destructive",c||t.length>0?"w-64 border-dashed bg-destructive/12 p-2 text-destructive dark:bg-destructive/8":"flex size-12 items-center justify-center p-0"),children:c||t.length>0?(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-14 items-center justify-center gap-2 rounded-lg border border-dashed border-destructive/55 bg-destructive/8 px-3 text-sm font-medium text-destructive",children:[(0,ey.jsx)(yi,{className:"size-4"}),(0,ey.jsx)("span",{children:s.empty})]}),t.length>0?(0,ey.jsx)("div",{className:"grid max-h-36 gap-1 overflow-y-auto pr-1",children:t.map(e=>(0,ey.jsxs)("div",{className:"flex h-8 items-center gap-2 rounded-md border border-destructive/25 bg-background/80 px-2 text-foreground",children:[(0,ey.jsx)("button",{type:"button","aria-label":`Restore ${e.title}`,className:"flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",onClick:()=>o?.(e),children:(0,ey.jsx)(fg.XIcon,{className:"size-3.5"})}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}):null]},e.id))}):null,t.length>0?(0,ey.jsx)("button",{type:"button",className:"h-8 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 dark:border dark:border-destructive dark:bg-background dark:text-destructive dark:hover:bg-destructive/10",onClick:()=>i?.(t),children:s.delete}):null]}):(0,ey.jsx)(yi,{className:"size-5"})})})}function ent({hidden:e,items:t,trashItems:n,trashClipboardItems:r,draggingId:a,onDraggingChange:i,onItemsChange:o,onTrashItemsChange:l,onTrashClipboardItemsChange:s}){let c=ew.useRef(0),[d,u]=ew.useState(!1);return(ew.useEffect(()=>{u(!0)},[]),d)?(0,iy.createPortal)((0,ey.jsxs)("div",{className:(0,eI.cn)("pointer-events-none fixed inset-0 z-40 overflow-visible transition-opacity duration-200",e&&"opacity-0"),children:[(0,ey.jsx)(ene,{active:!e&&void 0!==a,items:e?[]:n,className:(0,eI.cn)(e&&"pointer-events-none"),labels:{delete:"删除",empty:"拖入暂存"},onDrop:({id:e,title:n,meta:r})=>{let a=t.find(t=>t.id===e);a&&(s(t=>({...t,[e]:a})),l(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:n,meta:r,icon:a.icon}]))},onDelete:e=>{let t=new Set(e.map(e=>e.id));l(e=>e.filter(e=>!t.has(e.id))),s(e=>{let n={...e};for(let e of t)delete n[e];return n})},onItemRestore:e=>{let n=r[e.id];n&&o([n,...t.filter(e=>e.id!==n.id)]),l(t=>t.filter(t=>t.id!==e.id)),s(t=>{let n={...t};return delete n[e.id],n})}}),t.length>0?(0,ey.jsx)("div",{className:(0,eI.cn)("pointer-events-auto absolute top-4 right-4 w-80 max-w-[calc(100vw-2rem)] transition-[opacity,transform] duration-200",e&&"pointer-events-none -translate-y-2 opacity-0"),children:(0,ey.jsx)(XG,{items:t,title:"剪切板",labels:{empty:"剪切板为空",dragHandle:"拖拽卡片"},expansionDirection:"down-left",removeOnExternalDrop:!0,maxExpandedHeight:420,onItemDuplicate:(e,{item:n,index:r})=>{let a,i,l,s,d;return c.current+=1,a=n.payloads?.[GX],i=n.payloads?{...n.payloads}:void 0,l=n.payloads?.[GY],a&&i&&(i[GX]={...a,config:{...a.config}}),l&&i&&(i[GY]={...l,config:l.config?{...l.config}:l.config}),s={...n,id:`${n.id}-copy-${c.current}`,title:`${n.title} copy`,payloads:i,dragData:{...n.dragData,...a?{"application/vnd.vantaloom.dashboard-widget-config":JSON.stringify(a.config)}:{}}},void((d=[...t]).splice(r+1,0,s),o(d))},onItemsRemove:e=>o(e),onItemsReorder:e=>o(e),onItemDragStart:({item:e})=>i(e.id),onItemDragEnd:()=>i(void 0)})}):null]}),document.body):null}let enn=(0,ek.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),enr=(0,ek.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),ena=(0,ek.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),eni=(0,ek.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),eno=(0,ek.default)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),enl=(0,ek.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),ens=(0,ek.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),enc=(0,ek.default)("users-round",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]),end=(0,ek.default)("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);var enu="Collapsible",[enf,enh]=cr(enu),[enm,enp]=enf(enu),eng=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=cu({prop:r,defaultProp:a??!1,onChange:o,caller:enu});return(0,ey.jsx)(enm,{scope:n,disabled:i,contentId:cc(),open:s,onOpenToggle:ew.useCallback(()=>c(e=>!e),[c]),children:(0,ey.jsx)(cp.div,{"data-state":enj(s),"data-disabled":i?"":void 0,...l,ref:t})})});eng.displayName=enu;var env="CollapsibleTrigger",enx=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=enp(env,n);return(0,ey.jsx)(cp.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":enj(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:ci(e.onClick,a.onOpenToggle)})});enx.displayName=env;var eny="CollapsibleContent",enb=ew.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=enp(eny,e.__scopeCollapsible);return(0,ey.jsx)(cz,{present:n||a.open,children:({present:e})=>(0,ey.jsx)(enw,{...r,ref:t,present:e})})});enb.displayName=eny;var enw=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=enp(eny,n),[l,s]=ew.useState(r),c=ew.useRef(null),d=(0,ca.useComposedRefs)(t,c),u=ew.useRef(0),f=u.current,h=ew.useRef(0),m=h.current,p=o.open||l,g=ew.useRef(p),v=ew.useRef(void 0);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),co(()=>{let e=c.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,h.current=t.width,g.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),s(r)}},[o.open,r]),(0,ey.jsx)(cp.div,{"data-state":enj(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:p&&a})});function enj(e){return e?"open":"closed"}var enk=e.i(91e3);let enS={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-model-routes":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-system-prompt":"settings","preferences-layout":"settings","network-topology":"settings","check-update":"settings",account:"settings"};function enN({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeCanvasId:a,onItemSelect:i,onOpenConversation:o,onOpenCanvas:l,onOpenConversationSettings:s,onOpenCanvasSettings:c,onConversationDeleted:d,onAccountSettings:u,subagentTree:f,activeSubagentPath:h,onOpenSubagent:m,hideCanvas:p,className:g}){let v=enS[n]??(en$.some(e=>e.items.some(e=>e.id===n))?"settings":p?"agent":"canvas");p&&"canvas"===v&&(v="agent");let[x,y]=ew.useState(v);ew.useEffect(()=>{y(v)},[v]);let b=p?e.filter(e=>"canvas"!==e.id):e,w=t.find(e=>e.id===x);return(0,ey.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,eI.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",g),children:[(0,ey.jsx)("nav",{className:"mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:b.map(e=>{let t=e.id===x;return(0,ey.jsxs)("button",{type:"button",onClick:()=>y(e.id),className:(0,eI.cn)("flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"border border-border/50 bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"truncate",children:e.label})]},e.id)})}),"canvas"===x?(0,ey.jsx)(enC,{activeCanvasId:a,onItemSelect:i,onOpenCanvas:l,onOpenCanvasSettings:c}):"agent"===x?(0,ey.jsx)(enP,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:s,onConversationDeleted:d,subagentTree:f,activeSubagentPath:h,onOpenSubagent:m}):(0,ey.jsx)(en_,{content:w,activeWorkspace:n,onItemSelect:i}),(0,ey.jsx)(enW,{onItemSelect:i,onAccountSettings:u})]})}function enC({activeCanvasId:e,onItemSelect:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let{recents:a,loading:i}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0);return ew.useEffect(()=>{let e=!0;async function n(){try{let{canvases:n}=await Qm();if(!e)return;let r=[...n].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r)}catch{}finally{e&&r(!1)}}n();let a=setInterval(()=>void n(),1e4);return()=>{e=!1,clearInterval(a)}},[]),{recents:e,loading:n}}(),o=a.filter(e=>!0===e.running),l=a.filter(e=>!0!==e.running),s=i&&0===a.length;return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,ey.jsx)(enV,{icon:enl,label:QT.canvasNew,onClick:()=>t({item:{id:"new-canvas"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[o.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(t=>(0,ey.jsx)(enM,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]}):null,(0,ey.jsx)("div",{className:"mb-2 flex items-center justify-between px-3",children:(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"})}),(0,ey.jsx)("div",{className:"space-y-0.5",children:s?(0,ey.jsx)(enH,{}):0===l.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:"暂无画布"}):l.map(t=>(0,ey.jsx)(enM,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]})]})}function enM({canvas:e,active:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let a=!0===e.running;return(0,ey.jsx)(enR,{title:a?`${e.title} \xb7 运行中`:e.title,label:e.title,active:t,running:a,onOpen:()=>n(e.id,e.ownerMachineId),onOpenSettings:r?()=>r(e.id,e.ownerMachineId):void 0})}let enE="__all__",enO={status:"all",location:enE,sort:"recent"};function enP({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let{recents:s,refresh:c,loading:d,machineNames:u}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState({}),o=ew.useRef(!0),l=ew.useCallback(async()=>{try{let{conversations:e,machineNames:n}=await sO();if(!o.current)return;let r=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r),i(n)}catch{}finally{o.current&&r(!1)}},[]);return ew.useEffect(()=>{o.current=!0,l();let e=setInterval(()=>void l(),1e4);return()=>{o.current=!1,clearInterval(e)}},[l]),{recents:e,refresh:()=>void l(),loading:n,machineNames:a}}(),[f,h]=ew.useState(enO),m=ew.useMemo(()=>{let e=new Set;for(let t of s)e.add(t.ownerMachineId||sN);return Array.from(e)},[s]),p=ew.useCallback(e=>sC(e)?"本机":u[e]??e,[u]),g=ew.useMemo(()=>{let e=s.filter(e=>{let t=!0===e.running;return("running"!==f.status||!!t)&&("idle"!==f.status||!t)&&(f.location===enE||(e.ownerMachineId||sN)===f.location)});return"name"===f.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[s,f]),v=g.filter(e=>!0===e.running),x=g.filter(e=>!0!==e.running),y=f.status!==enO.status||f.location!==enO.location||f.sort!==enO.sort,b=d&&0===s.length,w=ew.useCallback(async e=>{try{await sq(e.id,e.ownerMachineId)}catch{}a?.(e.id),c()},[a,c]),j=ew.useCallback(async e=>{try{let t=await sZ(e.id,void 0,e.ownerMachineId);await c(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[c,n]),k=ew.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),S=o?.[o.length-1]?.id,N=t=>{let a=new Map(t.map(e=>[e.id,e])),o=new Map,s=[];for(let e of t){let t=e.forkOriginId;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=(t,a)=>{let s=t.id!==e||(i?.length??0)===0?null:(0,ey.jsx)(enA,{nodes:i??[],depth:0,ancestors:[],activeIds:k,activeLeafId:S,onOpen:l});return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(enD,{conversation:t,depth:a,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onDelete:w,onFork:j}),s?(0,ey.jsx)("div",{style:a>0?{marginLeft:14*a}:void 0,children:s}):null,(o.get(t.id)??[]).map(e=>c(e,a+1))]},t.id)};return s.map(e=>c(e,0))};return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5","data-tour":"new-conversation",children:(0,ey.jsx)(enV,{icon:tc,label:QT.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[v.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:N(v)})]}):null,(0,ey.jsxs)("div",{className:"mb-2 flex items-center justify-between px-3",children:[(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,ey.jsx)(enz,{filter:f,onChange:h,active:y,locations:m,locationLabel:p})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:b?(0,ey.jsx)(enH,{}):0===x.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:y?"没有符合筛选条件的对话":"暂无对话"}):N(x)})]})]})}function enA({nodes:e,depth:t,ancestors:n,activeIds:r,activeLeafId:a,onOpen:i}){let o=e.filter(e=>(function e(t,n){return!!(t.running||n.has(t.id))||(t.children??[]).some(t=>e(t,n))})(e,r));return 0===o.length?null:(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(e=>{let o=Hn(e.subagentType),l=o.Icon,s=[...n,{id:e.id,ownerMachineId:e.ownerMachineId,name:e.subagentName,subagentType:e.subagentType}],c=e.id===a;return(0,ey.jsxs)("div",{children:[(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*t},onClick:()=>i?.(s),title:e.subagentName||o.label,children:[(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,ey.jsx)(l,{className:(0,eI.cn)("size-3.5 shrink-0",o.color)}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||`${o.label}子代理`}),e.running?(0,ey.jsx)(eM,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,ey.jsx)(enA,{nodes:e.children??[],depth:t+1,ancestors:s,activeIds:r,activeLeafId:a,onOpen:i})]},e.id)})})}let enI={all:"全部",running:"运行中",idle:"空闲"};function enz({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=e.location===enE?"全部":a(e.location);return(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,eI.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,ey.jsx)(Qk,{className:"size-4"}),n?(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]})}),(0,ey.jsxs)(bZ,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,ey.jsx)(b0,{children:"筛选与排序"}),(0,ey.jsxs)(bY,{children:[(0,ey.jsxs)(b5,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"状态"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:enI[e.status]})]}),(0,ey.jsx)(b4,{children:(0,ey.jsxs)(bU,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,ey.jsx)(bQ,{value:"all",children:"全部"}),(0,ey.jsx)(bQ,{value:"running",children:"运行中"}),(0,ey.jsx)(bQ,{value:"idle",children:"空闲"})]})})]}),(0,ey.jsxs)(bY,{children:[(0,ey.jsxs)(b5,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,ey.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:i})]}),(0,ey.jsx)(b4,{className:"max-h-72 overflow-y-auto",children:(0,ey.jsxs)(bU,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,ey.jsx)(bQ,{value:enE,children:"全部"}),r.map(e=>(0,ey.jsx)(bQ,{value:e,children:(0,ey.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,ey.jsx)(b1,{}),(0,ey.jsx)(b0,{children:"排序"}),(0,ey.jsxs)(bU,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,ey.jsx)(bQ,{value:"recent",children:"最近活动"}),(0,ey.jsx)(bQ,{value:"name",children:"名称"})]}),n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(b1,{}),(0,ey.jsx)(bJ,{onSelect:()=>t(enO),children:(0,ey.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function enT({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,ey.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,eI.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}function enD({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onDelete:i,onFork:o}){let l=!0===e.running,s=e.settings?.engine??"vantaloom",c="vantaloom"!==s?(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,ey.jsx)(enT,{engine:s}),(0,ey.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,ey.jsx)(enR,{title:l?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:c,active:t,running:l,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a?()=>a(e.id,e.ownerMachineId):void 0,onDelete:i?()=>i(e):void 0,onFork:o?()=>o(e):void 0,deleteLabel:"删除会话"})}function enR({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onDelete:s,onFork:c,deleteLabel:d="删除"}){let[u,f]=ew.useState(!1),h=!!(l||s||c),m=i>0,p=(0,ey.jsxs)(ey.Fragment,{children:[l?(0,ey.jsxs)(bE,{onSelect:()=>l(),children:[(0,ey.jsx)(QW,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(bE,{onSelect:()=>c(),children:[(0,ey.jsx)(Vb,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(bE,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(yi,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]}),g=(0,ey.jsxs)("div",{className:(0,eI.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors",r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:m?{marginLeft:14*i}:void 0,children:[(0,ey.jsxs)("button",{type:"button",title:e,onClick:o,className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[m?(0,ey.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500","aria-label":"运行中"}):(0,ey.jsx)(enU,{active:r}),n??(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),h?(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,ey.jsx)(lY,{className:"size-4"})})}),(0,ey.jsxs)(bZ,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,ey.jsxs)(bJ,{onSelect:()=>l(),children:[(0,ey.jsx)(QW,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(bJ,{onSelect:()=>c(),children:[(0,ey.jsx)(Vb,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(bJ,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(yi,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]})]}):null]});return(0,ey.jsxs)(ey.Fragment,{children:[h?(0,ey.jsxs)(bv,{children:[(0,ey.jsx)(by,{asChild:!0,children:g}),(0,ey.jsx)(bM,{className:"min-w-44",children:p})]}):g,s?(0,ey.jsx)(d4,{open:u,onOpenChange:f,children:(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:d}),(0,ey.jsxs)(ug,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{children:"取消"}),(0,ey.jsx)(uv,{variant:"destructive",onClick:()=>s(),children:"删除"})]})]})}):null]})}function en_({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,ey.jsx)(wz,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,ey.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,ey.jsx)(enF,{activeWorkspace:t,onItemSelect:n},e.id):(0,ey.jsx)(enL,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function enL({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,ey.jsx)(enU,{active:!0})]})}let en$=[{id:"model",title:"模型设置",icon:(0,ey.jsx)(uS,{}),items:[{id:"preferences-model-routes",label:"模型路由",icon:(0,ey.jsx)(mY,{})},{id:"preferences-agent-config",label:"代理配置",icon:(0,ey.jsx)(ub,{})},{id:"preferences-subagent-config",label:"子代理配置",icon:(0,ey.jsx)(enc,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,ey.jsx)(uS,{})}]},{id:"prefs",title:"偏好设置",icon:(0,ey.jsx)(QW,{}),items:[{id:"preferences-system-prompt",label:"系统提示词",icon:(0,ey.jsx)(eno,{})},{id:"preferences-layout",label:"布局排版",icon:(0,ey.jsx)(enr,{})},{id:"preferences-official-extensions",label:"官方扩展",icon:(0,ey.jsx)(Ui,{})}]},{id:"system",title:"系统设置",icon:(0,ey.jsx)(GE,{}),items:[{id:"network-topology",label:"组网关系",icon:(0,ey.jsx)(Qb,{})},{id:"system-downloads",label:"下载",icon:(0,ey.jsx)(x1,{})},{id:"check-update",label:"检查更新",icon:(0,ey.jsx)(ya,{})},{id:"account",label:"Hub 账户",icon:(0,ey.jsx)(eC,{})},{id:"balance-usage",label:"余额用量",icon:(0,ey.jsx)(end,{})},{id:"feedback",label:"问题反馈",icon:(0,ey.jsx)(jb,{})}]}];function enF({activeWorkspace:e,onItemSelect:t}){return(0,ey.jsx)(ey.Fragment,{children:en$.map(n=>(0,ey.jsx)(enB,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t},n.id))})}function enB({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=ew.useState(!0);return(0,ey.jsxs)(eng,{open:o,onOpenChange:l,children:[(0,ey.jsx)(enx,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,ey.jsx)(vu,{className:(0,eI.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,ey.jsx)(enb,{className:"mt-0.5 space-y-0.5",children:n.map(e=>{let t=e.id===r;return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",t?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),t&&(0,ey.jsx)(enU,{active:!0})]},e.id)})})]})}function enV({icon:e,label:t,onClick:n}){return(0,ey.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",children:[(0,ey.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}function enH(){return(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"}),(0,ey.jsx)("span",{children:"加载中…"})]})}function enU({active:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}function enW({onItemSelect:e,onAccountSettings:t}){let{user:n}=tl(),r=n?.name??Qz.product,a=(n?.name??"V").slice(0,1).toUpperCase();return(0,ey.jsx)("div",{className:"mt-auto pt-3",children:(0,ey.jsxs)(bR,{children:[(0,ey.jsx)(bL,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:a}),(0,ey.jsx)("span",{className:"truncate text-sm text-foreground",children:r})]}),(0,ey.jsx)(mQ,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,ey.jsxs)(bZ,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[n?.email&&(0,ey.jsx)(b0,{className:"truncate font-normal text-muted-foreground",children:n.email}),(0,ey.jsxs)(bJ,{onSelect:()=>e({item:{id:"preferences"}}),children:[(0,ey.jsx)(QW,{}),(0,ey.jsx)("span",{className:"flex-1",children:"设置"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"Ctrl,"})]}),(0,ey.jsxs)(bJ,{disabled:!0,children:[(0,ey.jsx)(enn,{}),(0,ey.jsx)("span",{className:"flex-1",children:"语言"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,ey.jsxs)(bJ,{disabled:!0,children:[(0,ey.jsx)(H0,{}),(0,ey.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,ey.jsx)(b1,{}),(0,ey.jsxs)(bJ,{onSelect:()=>{t?t():e({item:{id:"account"}})},children:[(0,ey.jsx)(K2,{}),(0,ey.jsx)("span",{className:"flex-1",children:"Hub 账户"})]}),(0,ey.jsx)(enK,{}),n&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(b1,{}),(0,ey.jsx)(enG,{})]})]})]})})}let enq=["light","dark","jelly"];function enK(){let{resolvedTheme:e,setTheme:t}=(0,hE.useTheme)(),[n,r]=ew.useState(enk.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(enk.appearanceThemeStorageKey)??enk.defaultAppearanceTheme;r(e),(0,enk.applyAppearanceTheme)({theme:e})},[]);let a=n===enk.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=enq[(enq.indexOf(a)+1)%enq.length]??"light";function o(e){r(e),window.localStorage.setItem(enk.appearanceThemeStorageKey,e),(0,enk.applyAppearanceTheme)({theme:e})}let l="dark"===a?eni:ens;return(0,ey.jsxs)(bJ,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(enk.jellyAppearanceTheme);return}o(enk.defaultAppearanceTheme),t(i)}()},children:[(0,ey.jsx)(l,{}),(0,ey.jsx)("span",{className:"flex-1",children:Qz.theme}),(0,ey.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function enG(){let{logout:e}=tl();return(0,ey.jsxs)(bJ,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,ey.jsx)(ena,{}),(0,ey.jsx)("span",{className:"flex-1",children:"退出登录"})]})}let enX=ew.default.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),enY=()=>{let e=ew.default.useContext(enX);if(!e)throw Error("useDrawerContext must be used within a Drawer.Root");return e};function enZ(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function enJ(){return enQ(/^iPhone/)||enQ(/^iPad/)||enQ(/^Mac/)&&navigator.maxTouchPoints>1}function enQ(e){return"u">typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if(!e||"u"<typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");let en0="u">typeof window?ew.useLayoutEffect:ew.useEffect;function en1(...e){return(...t)=>{for(let n of e)"function"==typeof n&&n(...t)}}let en2="u">typeof document&&window.visualViewport;function en5(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function en4(e){for(en5(e)&&(e=e.parentElement);e&&!en5(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}let en3=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),en6=0;function en8(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function en7(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=en4(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=r-n)}e=t.parentElement}}function en9(e){return e instanceof HTMLInputElement&&!en3.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function ere(...e){return ew.useCallback(function(...e){return t=>e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}(...e),e)}let ert=new WeakMap;function ern(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):(r[t]=e.style[t],e.style[t]=n)}),n||ert.set(e,r)}let err=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function era(e,t){if(!e)return null;let n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform,a=r.match(/^matrix3d\((.+)\)$/);return a?parseFloat(a[1].split(", ")[err(t)?13:12]):(a=r.match(/^matrix\((.+)\)$/))?parseFloat(a[1].split(", ")[err(t)?5:4]):null}function eri(e,t){if(!e)return()=>{};let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}let ero=[.32,.72,0,1],erl="vaul-dragging";function ers(e){let t=ew.default.useRef(e);return ew.default.useEffect(()=>{t.current=e}),ew.default.useMemo(()=>(...e)=>null==t.current?void 0:t.current.call(t,...e),[])}function erc({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,a]=function({defaultProp:e,onChange:t}){let n=ew.default.useState(e),[r]=n,a=ew.default.useRef(r),i=ers(t);return ew.default.useEffect(()=>{a.current!==r&&(i(r),a.current=r)},[r,a,i]),n}({defaultProp:t,onChange:n}),i=void 0!==e,o=i?e:r,l=ers(n);return[o,ew.default.useCallback(t=>{if(i){let n="function"==typeof t?t(e):t;n!==e&&l(n)}else a(t)},[i,e,a,l])]}let erd=()=>()=>{},eru=null,erf=ew.default.forwardRef(function({...e},t){let{overlayRef:n,snapPoints:r,onRelease:a,shouldFade:i,isOpen:o,modal:l,shouldAnimate:s}=enY(),c=ere(t,n),d=r&&r.length>0;if(!l)return null;let u=ew.default.useCallback(e=>a(e),[a]);return ew.default.createElement(dT,{onMouseUp:u,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&d?"true":"false","data-vaul-snap-points-overlay":o&&i?"true":"false","data-vaul-animate":(null==s?void 0:s.current)?"true":"false",...e})});erf.displayName="Drawer.Overlay";let erh=ew.default.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},a){let{drawerRef:i,onPress:o,onRelease:l,onDrag:s,keyboardIsOpen:c,snapPointsOffset:d,activeSnapPointIndex:u,modal:f,isOpen:h,direction:m,snapPoints:p,container:g,handleOnly:v,shouldAnimate:x,autoFocus:y}=enY(),[b,w]=ew.default.useState(!1),j=ere(a,i),k=ew.default.useRef(null),S=ew.default.useRef(null),N=ew.default.useRef(!1),C=p&&p.length>0;function M(e){k.current=null,N.current=!1,l(e)}return!function(){let{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:a}=enY(),i=ew.default.useRef(null),o=(0,ew.useMemo)(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}ew.default.useEffect(()=>{if(t&&n){i.current&&clearTimeout(i.current);let t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;!function(...e){}(r&&!a?eri(document.body,{background:"black"}):erd,eri(t,{transformOrigin:err(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${ero.join(",")})`}));let n=eri(t,{borderRadius:"8px",overflow:"hidden",...err(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{n(),i.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},500)}}},[t,n,o])}(),ew.default.useEffect(()=>{C&&window.requestAnimationFrame(()=>{w(!0)})},[]),ew.default.createElement(dL,{"data-vaul-drawer-direction":m,"data-vaul-drawer":"","data-vaul-delayed-snap-points":b?"true":"false","data-vaul-snap-points":h&&C?"true":"false","data-vaul-custom-container":g?"true":"false","data-vaul-animate":(null==x?void 0:x.current)?"true":"false",...r,ref:j,style:d&&d.length>0?{"--snap-point-height":`${d[null!=u?u:0]}px`,...t}:t,onPointerDown:e=>{v||(null==r.onPointerDown||r.onPointerDown.call(r,e),k.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==n||n(e),y||e.preventDefault()},onPointerDownOutside:t=>{(null==e||e(t),!f||t.defaultPrevented)?t.preventDefault():c.current&&(c.current=!1)},onFocusOutside:e=>{if(!f)return void e.preventDefault()},onPointerMove:e=>{if(S.current=e,v||(null==r.onPointerMove||r.onPointerMove.call(r,e),!k.current))return;let t=e.pageY-k.current.y,n=e.pageX-k.current.x,a="touch"===e.pointerType?10:2;((e,t,n=0)=>{if(N.current)return!0;let r=Math.abs(e.y),a=Math.abs(e.x),i=a>r,o=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*o<0)&&a>=0&&a<=n)return i}else if(!(e.y*o<0)&&r>=0&&r<=n)return!i;return N.current=!0,!0})({x:n,y:t},m,a)?s(e):(Math.abs(n)>a||Math.abs(t)>a)&&(k.current=null)},onPointerUp:e=>{null==r.onPointerUp||r.onPointerUp.call(r,e),k.current=null,N.current=!1,l(e)},onPointerOut:e=>{null==r.onPointerOut||r.onPointerOut.call(r,e),M(S.current)},onContextMenu:e=>{null==r.onContextMenu||r.onContextMenu.call(r,e),S.current&&M(S.current)}})});erh.displayName="Drawer.Content",ew.default.forwardRef(function({preventCycle:e=!1,children:t,...n},r){let{closeDrawer:a,isDragging:i,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:s,dismissible:c,handleOnly:d,isOpen:u,onPress:f,onDrag:h}=enY(),m=ew.default.useRef(null),p=ew.default.useRef(!1);function g(){m.current&&window.clearTimeout(m.current),p.current=!1}return ew.default.createElement("div",{onClick:function(){p.current?g():window.setTimeout(()=>{!function(){if(i||e||p.current)return g();if(g(),!o||0===o.length){c||a();return}if(l===o[o.length-1]&&c)return a();let t=o.findIndex(e=>e===l);-1===t||s(o[t+1])}()},120)},onPointerCancel:g,onPointerDown:e=>{d&&f(e),m.current=window.setTimeout(()=>{p.current=!0},250)},onPointerMove:e=>{d&&h(e)},ref:r,"data-vaul-drawer-visible":u?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},ew.default.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))}).displayName="Drawer.Handle";let erm=function({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:a,snapPoints:i,shouldScaleBackground:l=!1,setBackgroundColorOnScale:s=!0,closeThreshold:c=.25,scrollLockTimeout:d=100,dismissible:u=!0,handleOnly:f=!1,fadeFromIndex:h=i&&i.length-1,activeSnapPoint:m,setActiveSnapPoint:p,fixed:g,modal:v=!0,onClose:x,nested:y,noBodyStyles:b=!1,direction:w="bottom",defaultOpen:j=!1,disablePreventScroll:k=!0,snapToSequentialPoint:S=!1,preventScrollRestoration:N=!1,repositionInputs:C=!0,onAnimationEnd:M,container:E,autoFocus:O=!1}){var P,A;let[I=!1,z]=erc({defaultProp:j,prop:e,onChange:e=>{null==t||t(e),e||y||ed(),setTimeout(()=>{null==M||M(e)},500),e&&!v&&"u">typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[T,D]=ew.default.useState(!1),[R,_]=ew.default.useState(!1),[L,$]=ew.default.useState(!1),F=ew.default.useRef(null),B=ew.default.useRef(null),V=ew.default.useRef(null),H=ew.default.useRef(null),U=ew.default.useRef(null),W=ew.default.useRef(!1),q=ew.default.useRef(null),K=ew.default.useRef(0),G=ew.default.useRef(!1),X=ew.default.useRef(!j),Y=ew.default.useRef(0),Z=ew.default.useRef(null),J=ew.default.useRef((null==(P=Z.current)?void 0:P.getBoundingClientRect().height)||0),Q=ew.default.useRef((null==(A=Z.current)?void 0:A.getBoundingClientRect().width)||0),ee=ew.default.useRef(0),et=ew.default.useCallback(e=>{i&&e===eo.length-1&&(B.current=new Date)},[]),{activeSnapPoint:en,activeSnapPointIndex:er,setActiveSnapPoint:ea,onRelease:ei,snapPointsOffset:eo,onDrag:el,shouldFade:es,getPercentageDragged:ec}=function({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:a,fadeFromIndex:i,onSnapPointChange:o,direction:l="bottom",container:s,snapToSequentialPoint:c}){let[d,u]=erc({prop:e,defaultProp:null==n?void 0:n[0],onChange:t}),[f,h]=ew.default.useState("u">typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);ew.default.useEffect(()=>{function e(){h({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let m=ew.default.useMemo(()=>d===(null==n?void 0:n[n.length-1])||null,[n,d]),p=ew.default.useMemo(()=>{var e;return null!=(e=null==n?void 0:n.findIndex(e=>e===d))?e:null},[n,d]),g=n&&n.length>0&&(i||0===i)&&!Number.isNaN(i)&&n[i]===d||!n,v=ew.default.useMemo(()=>{var e;let t=s?{width:s.getBoundingClientRect().width,height:s.getBoundingClientRect().height}:"u">typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};return null!=(e=null==n?void 0:n.map(e=>{let n="string"==typeof e,r=0;if(n&&(r=parseInt(e,10)),err(l)){let a=n?r:f?e*t.height:0;return f?"bottom"===l?t.height-a:-t.height+a:a}let a=n?r:f?e*t.width:0;return f?"right"===l?t.width-a:-t.width+a:a}))?e:[]},[n,f,s]),x=ew.default.useMemo(()=>null!==p?null==v?void 0:v[p]:null,[v,p]),y=ew.default.useCallback(e=>{var t;let s=null!=(t=null==v?void 0:v.findIndex(t=>t===e))?t:null;o(s),ern(r.current,{transition:`transform 0.5s cubic-bezier(${ero.join(",")})`,transform:err(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),v&&s!==v.length-1&&void 0!==i&&s!==i&&s<i?ern(a.current,{transition:`opacity 0.5s cubic-bezier(${ero.join(",")})`,opacity:"0"}):ern(a.current,{transition:`opacity 0.5s cubic-bezier(${ero.join(",")})`,opacity:"1"}),u(null==n?void 0:n[Math.max(s,0)])},[r.current,n,v,i,a,u]);return ew.default.useEffect(()=>{if(d||e){var t;let r=null!=(t=null==n?void 0:n.findIndex(t=>t===e||t===d))?t:-1;v&&-1!==r&&"number"==typeof v[r]&&y(v[r])}},[d,e,n,v,y]),{isLastSnapPoint:m,activeSnapPoint:d,shouldFade:g,getPercentageDragged:function(e,t){if(!n||"number"!=typeof p||!v||void 0===i)return null;let r=p===i-1;if(p>=i&&t)return 0;if(r&&!t)return 1;if(!g&&!r)return null;let a=r?p+1:p-1,o=e/Math.abs(r?v[a]-v[a-1]:v[a+1]-v[a]);return r?1-o:o},setActiveSnapPoint:u,activeSnapPointIndex:p,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:o}){if(void 0===i)return;let s="bottom"===l||"right"===l?(null!=x?x:0)-e:(null!=x?x:0)+e,d=p===i-1,u=0===p,f=e>0;if(d&&ern(a.current,{transition:`opacity 0.5s cubic-bezier(${ero.join(",")})`}),!c&&r>2&&!f)return void(o?t():y(v[0]));if(!c&&r>2&&f&&v&&n)return void y(v[n.length-1]);let h=null==v?void 0:v.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-s)<Math.abs(e-s)?t:e),g=err(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*g){let e=f?1:-1;return e>0&&m&&n?void y(v[n.length-1]):void(u&&e<0&&o&&t(),null===p||y(v[p+e]))}y(h)},onDrag:function({draggedDistance:e}){if(null===x)return;let t="bottom"===l||"right"===l?x-e:x+e;("bottom"===l||"right"===l)&&t<v[v.length-1]||("top"===l||"left"===l)&&t>v[v.length-1]||ern(r.current,{transform:err(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:v}}({snapPoints:i,activeSnapPointProp:m,setActiveSnapPointProp:p,drawerRef:Z,fadeFromIndex:h,overlayRef:F,onSnapPointChange:et,direction:w,container:E,snapToSequentialPoint:S});!function(e={}){let{isDisabled:t}=e;en0(()=>{if(!t){var e,n,r;let t,a,i,l,s,c,d;return 1==++en6&&enJ()&&(i=0,l=window.pageXOffset,s=window.pageYOffset,c=en1((e=document.documentElement,n="paddingRight",r=`${window.innerWidth-document.documentElement.clientWidth}px`,t=e.style[n],e.style[n]=r,()=>{e.style[n]=t})),window.scrollTo(0,0),d=en1(en8(document,"touchstart",e=>{((a=en4(e.target))!==document.documentElement||a!==document.body)&&(i=e.changedTouches[0].pageY)},{passive:!1,capture:!0}),en8(document,"touchmove",e=>{if(!a||a===document.documentElement||a===document.body)return void e.preventDefault();let t=e.changedTouches[0].pageY,n=a.scrollTop,r=a.scrollHeight-a.clientHeight;0!==r&&((n<=0&&t>i||n>=r&&t<i)&&e.preventDefault(),i=t)},{passive:!1,capture:!0}),en8(document,"touchend",e=>{let t=e.target;en9(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},{passive:!1,capture:!0}),en8(document,"focus",e=>{let t=e.target;en9(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",en2&&(en2.height<window.innerHeight?requestAnimationFrame(()=>{en7(t)}):en2.addEventListener("resize",()=>en7(t),{once:!0}))}))},!0),en8(window,"scroll",()=>{window.scrollTo(0,0)})),o=()=>{c(),d(),window.scrollTo(l,s)}),()=>{0==--en6&&(null==o||o())}}},[t])}({isDisabled:!I||R||!v||L||!T||!C||!k});let{restorePositionSetting:ed}=function({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:a,noBodyStyles:i}){let[o,l]=ew.default.useState(()=>"u">typeof window?window.location.href:""),s=ew.default.useRef(0),c=ew.default.useCallback(()=>{if(enZ()&&null===eru&&e&&!i){eru={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};let{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-s.current}px`,left:`${-e}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{let e=t-window.innerHeight;e&&s.current>=t&&(document.body.style.top=`${-(s.current+e)}px`)}),300)}},[e]),d=ew.default.useCallback(()=>{if(enZ()&&null!==eru&&!i){let e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,eru),window.requestAnimationFrame(()=>{a&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),eru=null}},[o]);return ew.default.useEffect(()=>{function e(){s.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),ew.default.useEffect(()=>{if(t)return()=>{"u"<typeof document||document.querySelector("[data-vaul-drawer]")||d()}},[t,d]),ew.default.useEffect(()=>{!n&&r&&(e?(window.matchMedia("(display-mode: standalone)").matches||c(),t||window.setTimeout(()=>{d()},500)):d())},[e,r,o,t,n,c,d]),{restorePositionSetting:d}}({isOpen:I,modal:v,nested:null!=y&&y,hasBeenOpened:T,preventScrollRestoration:N,noBodyStyles:b});function eu(){return(window.innerWidth-26)/window.innerWidth}function ef(e,t){var n;let r=e,a=null==(n=window.getSelection())?void 0:n.toString(),i=Z.current?era(Z.current,w):null,o=new Date;if("SELECT"===r.tagName||r.hasAttribute("data-vaul-no-drag")||r.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(B.current&&o.getTime()-B.current.getTime()<500)return!1;if(null!==i&&("bottom"===w?i>0:i<0))return!0;if(a&&a.length>0)return!1;if(U.current&&o.getTime()-U.current.getTime()<d&&0===i||t)return U.current=o,!1;for(;r;){if(r.scrollHeight>r.clientHeight){if(0!==r.scrollTop)return U.current=new Date,!1;if("dialog"===r.getAttribute("role"))break}r=r.parentNode}return!0}function eh(e){R&&Z.current&&(Z.current.classList.remove(erl),W.current=!1,_(!1),H.current=new Date),null==x||x(),e||z(!1),setTimeout(()=>{i&&ea(i[0])},500)}function em(){if(!Z.current)return;let e=document.querySelector("[data-vaul-drawer-wrapper]"),t=era(Z.current,w);ern(Z.current,{transform:"translate3d(0, 0, 0)",transition:`transform 0.5s cubic-bezier(${ero.join(",")})`}),ern(F.current,{transition:`opacity 0.5s cubic-bezier(${ero.join(",")})`,opacity:"1"}),l&&t&&t>0&&I&&ern(e,{borderRadius:"8px",overflow:"hidden",...err(w)?{transform:`scale(${eu()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${eu()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${ero.join(",")})`},!0)}return ew.default.useEffect(()=>{window.requestAnimationFrame(()=>{X.current=!0})},[]),ew.default.useEffect(()=>{var e;function t(){if(Z.current&&C&&(en9(document.activeElement)||G.current)){var e;let t=(null==(e=window.visualViewport)?void 0:e.height)||0,n=window.innerHeight,r=n-t,a=Z.current.getBoundingClientRect().height||0;ee.current||(ee.current=a);let o=Z.current.getBoundingClientRect().top;if(Math.abs(Y.current-r)>60&&(G.current=!G.current),i&&i.length>0&&eo&&er&&(r+=eo[er]||0),Y.current=r,a>t||G.current){let e=Z.current.getBoundingClientRect().height,i=e;e>t&&(i=t-(a>.8*n?o:26)),g?Z.current.style.height=`${e-Math.max(r,0)}px`:Z.current.style.height=`${Math.max(i,t-o)}px`}else{let e;e=navigator.userAgent,"u">typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))||(Z.current.style.height=`${ee.current}px`)}i&&i.length>0&&!G.current?Z.current.style.bottom="0px":Z.current.style.bottom=`${Math.max(r,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[er,i,eo]),ew.default.useEffect(()=>(I&&(ern(document.documentElement,{scrollBehavior:"auto"}),B.current=new Date),()=>{!function(e,t){if(!e||!(e instanceof HTMLElement))return;let n=ert.get(e);n&&(e.style[t]=n[t])}(document.documentElement,"scrollBehavior")}),[I]),ew.default.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),ew.default.createElement(dC,{defaultOpen:j,onOpenChange:e=>{(u||e)&&(e?D(!0):eh(!0),z(e))},open:I},ew.default.createElement(enX.Provider,{value:{activeSnapPoint:en,snapPoints:i,setActiveSnapPoint:ea,drawerRef:Z,overlayRef:F,onOpenChange:t,onPress:function(e){var t,n;!u&&!i||(!Z.current||Z.current.contains(e.target))&&(J.current=(null==(t=Z.current)?void 0:t.getBoundingClientRect().height)||0,Q.current=(null==(n=Z.current)?void 0:n.getBoundingClientRect().width)||0,_(!0),V.current=new Date,enJ()&&window.addEventListener("touchend",()=>W.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),K.current=err(w)?e.pageY:e.pageX)},onRelease:function(e){var t,n;if(!R||!Z.current)return;Z.current.classList.remove(erl),W.current=!1,_(!1),H.current=new Date;let r=era(Z.current,w);if(!e||!ef(e.target,!1)||!r||Number.isNaN(r)||null===V.current)return;let o=H.current.getTime()-V.current.getTime(),l=K.current-(err(w)?e.pageY:e.pageX),s=Math.abs(l)/o;if(s>.05&&($(!0),setTimeout(()=>{$(!1)},200)),i){ei({draggedDistance:l*("bottom"===w||"right"===w?1:-1),closeDrawer:eh,velocity:s,dismissible:u}),null==a||a(e,!0);return}if("bottom"===w||"right"===w?l>0:l<0){em(),null==a||a(e,!0);return}if(s>.4){eh(),null==a||a(e,!1);return}let d=Math.min(null!=(t=Z.current.getBoundingClientRect().height)?t:0,window.innerHeight),f=Math.min(null!=(n=Z.current.getBoundingClientRect().width)?n:0,window.innerWidth);if(Math.abs(r)>=("left"===w||"right"===w?f:d)*c){eh(),null==a||a(e,!1);return}null==a||a(e,!0),em()},onDrag:function(e){if(Z.current&&R){let t="bottom"===w||"right"===w?1:-1,n=(K.current-(err(w)?e.pageY:e.pageX))*t,a=n>0,o=i&&!u&&!a;if(o&&0===er)return;let s=Math.abs(n),c=document.querySelector("[data-vaul-drawer-wrapper]"),d=s/("bottom"===w||"top"===w?J.current:Q.current),f=ec(s,a);if(null!==f&&(d=f),o&&d>=1||!W.current&&!ef(e.target,a))return;if(Z.current.classList.add(erl),W.current=!0,ern(Z.current,{transition:"none"}),ern(F.current,{transition:"none"}),i&&el({draggedDistance:n}),a&&!i){let e=Math.min(-(8*(Math.log(n+1)-2)*1),0)*t;ern(Z.current,{transform:err(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`});return}let m=1-d;if((es||h&&er===h-1)&&(null==r||r(e,d),ern(F.current,{opacity:`${m}`,transition:"none"},!0)),c&&F.current&&l){let e=Math.min(eu()+d*(1-eu()),1),t=8-8*d,n=Math.max(0,14-14*d);ern(c,{borderRadius:`${t}px`,transform:err(w)?`scale(${e}) translate3d(0, ${n}px, 0)`:`scale(${e}) translate3d(${n}px, 0, 0)`,transition:"none"},!0)}if(!i){let e=s*t;ern(Z.current,{transform:err(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:X,handleOnly:f,isOpen:I,isDragging:R,shouldFade:es,closeDrawer:eh,onNestedDrag:function(e,t){if(t<0)return;let n=(window.innerWidth-16)/window.innerWidth,r=n+t*(1-n),a=-16+16*t;ern(Z.current,{transform:err(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){let t=e?(window.innerWidth-16)/window.innerWidth:1,n=e?-16:0;q.current&&window.clearTimeout(q.current),ern(Z.current,{transition:`transform 0.5s cubic-bezier(${ero.join(",")})`,transform:err(w)?`scale(${t}) translate3d(0, ${n}px, 0)`:`scale(${t}) translate3d(${n}px, 0, 0)`}),!e&&Z.current&&(q.current=setTimeout(()=>{let e=era(Z.current,w);ern(Z.current,{transition:"none",transform:err(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){let n=err(w)?window.innerHeight:window.innerWidth,r=t?(n-16)/n:1,a=t?-16:0;t&&ern(Z.current,{transition:`transform 0.5s cubic-bezier(${ero.join(",")})`,transform:err(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`})},keyboardIsOpen:G,modal:v,snapPointsOffset:eo,activeSnapPointIndex:er,direction:w,shouldScaleBackground:l,setBackgroundColorOnScale:s,noBodyStyles:b,container:E,autoFocus:O}},n))},erp=function(e){let t=enY(),{container:n=t.container,...r}=e;return ew.default.createElement(dI,{container:n,...r})};function erg({className:e,...t}){return(0,ey.jsx)(erf,{"data-slot":"drawer-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function erv({className:e,children:t,...n}){return(0,ey.jsxs)(erp,{"data-slot":"drawer-portal",children:[(0,ey.jsx)(erg,{}),(0,ey.jsxs)(erh,{"data-slot":"drawer-content",className:(0,eI.cn)("vtl-surface-modal group/drawer-content fixed z-50 flex h-auto flex-col border outline-none","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-xl data-[vaul-drawer-direction=top]:border-t-0","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:border-b-0","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-r-0 data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-l-0 data-[vaul-drawer-direction=left]:sm:max-w-sm",e),...n,children:[(0,ey.jsx)("div",{className:"mx-auto mt-3 hidden h-1.5 w-16 shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),t]})]})}function erx({className:e,...t}){return(0,ey.jsx)(dH,{"data-slot":"drawer-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function ery({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:a,onOpenConversation:i,onOpenConversationSettings:o,onConversationDeleted:l,onAccountSettings:s,subagentTree:c,activeSubagentPath:d,onOpenSubagent:u,title:f,trailing:h}){let[m,p]=ew.useState(!1),g=ew.useCallback(()=>p(!1),[]),v=ew.useCallback(e=>{g(),a(e)},[g,a]),x=ew.useCallback((e,t)=>{g(),i(e,t)},[g,i]),y=ew.useCallback(e=>{g(),u?.(e)},[g,u]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(erb,{onMenuClick:()=>p(!0),title:f,trailing:h}),(0,ey.jsx)(erm,{open:m,onOpenChange:p,direction:"left",children:(0,ey.jsxs)(erv,{className:"w-[85vw] max-w-xs",children:[(0,ey.jsx)(erx,{className:"sr-only",children:"导航"}),(0,ey.jsx)(enN,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:v,onOpenConversation:x,onOpenCanvas:()=>{},onOpenConversationSettings:(e,t)=>{g(),o?.(e,t)},onConversationDeleted:l,onAccountSettings:()=>{g(),s?.()},subagentTree:c,activeSubagentPath:d,onOpenSubagent:y,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})})]})}function erb({onMenuClick:e,title:t,trailing:n,className:r}){return(0,ey.jsxs)("header",{className:(0,eI.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,ey.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,ey.jsx)(s8,{})}),t?(0,ey.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,ey.jsx)("div",{className:"min-w-0 flex-1"}),(0,ey.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let erw=(0,ek.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),erj=[{id:"canvas",label:QT.canvas,icon:(0,ey.jsx)(uw,{})},{id:"agent",label:"智能体",icon:(0,ey.jsx)(ub,{})},{id:"settings",label:QT.settings,icon:(0,ey.jsx)(QW,{})}],erk=[{id:"canvas",title:QT.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:QT.canvas,items:[{id:"open-recent-canvas",label:QT.canvasRecent,icon:(0,ey.jsx)(uw,{})},{id:"new-canvas",label:QT.canvasNew,icon:(0,ey.jsx)(lJ,{})},{id:"all-canvases",label:QT.canvasAll,icon:(0,ey.jsx)(uN,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:QT.conversationRecent,icon:(0,ey.jsx)(erw,{})},{id:"new-agent-conversation",label:QT.conversationNew,icon:(0,ey.jsx)(ub,{})}]}]},{id:"settings",title:QT.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,ey.jsx)(QW,{})}]}]}],erS=(0,ek.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),erN=(0,ek.default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),erC=(0,ek.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),erM=(0,ek.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function erE(){let{user:e,machine:t,logout:n,unbind:r,refreshUser:a}=tl(),[i,o]=ew.useState(!1),[l,s]=ew.useState(!1),[c,d]=ew.useState(t),[u,f]=ew.useState(!1),[h,m]=ew.useState(""),[p,g]=ew.useState(!1),[v,x]=ew.useState(null);async function y(){o(!0);try{await eJ("online");let e=eW();d(e),await a()}catch{}finally{o(!1)}}async function b(){let e=h.trim();if(!e)return void x("名称不能为空");g(!0),x(null);try{let t=await e0(e);d(e=>e?{...e,name:t}:e),f(!1)}catch(e){x(e instanceof Error?e.message:"重命名失败")}finally{g(!1)}}async function w(){s(!0);try{await r()}catch{s(!1)}}async function j(){await n()}return ew.useEffect(()=>{d(t)},[t]),e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsx)("div",{className:"flex items-center justify-between gap-3","data-tour":"hub-account",children:(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"Vantaloom Hub 账户"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"管理你的 Hub 连接和设备绑定"})]})}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户信息"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"你的 Vantaloom Hub 账户详情。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,ey.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:(0,ey.jsx)("span",{className:"text-base font-semibold text-primary",children:e.name.charAt(0).toUpperCase()})}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]}),(0,ey.jsxs)(Bs,{variant:"outline",className:"shrink-0",children:[(0,ey.jsx)(jz,{className:"mr-1 size-3"}),"已验证"]})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"用户 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(e.createdAt).toLocaleDateString("zh-CN")})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"此设备已自动注册到你的 Hub 账户。"})]}),c?(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:y,disabled:i,children:[i?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(ya,{}),i?"刷新中...":"刷新状态"]}):null]}),c?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[u?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(ez,{value:h,onChange:e=>m(e.target.value),maxLength:64,autoFocus:!0,placeholder:"机器名称",className:"h-8 text-sm",onKeyDown:e=>{"Enter"===e.key&&b(),"Escape"===e.key&&f(!1)}}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>void b(),disabled:p,"aria-label":"保存名称",children:p?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(mZ,{})}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>f(!1),disabled:p,"aria-label":"取消",children:(0,ey.jsx)(fg.XIcon,{})})]}):(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:c.name}),(0,ey.jsx)("button",{type:"button",onClick:function(){m(c?.name??""),x(null),f(!0)},title:"重命名",className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,ey.jsx)(HN,{className:"size-3.5"})})]}),(0,ey.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[c.platform," / ",c.arch]})]}),(0,ey.jsxs)(Bs,{variant:"online"===c.status?"default":"secondary",className:"shrink-0 gap-1",children:["online"===c.status?(0,ey.jsx)(erC,{className:"size-3"}):(0,ey.jsx)(erM,{className:"size-3"}),"online"===c.status?"在线":"离线"]})]}),v?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:v}):null,(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"设备 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[c.id.slice(0,8),"..."]})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接方式"}),(0,ey.jsx)("span",{className:"text-sm",children:c.connectivity||"直连"})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"本机 IP"}),(0,ey.jsx)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:c.localIp})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"最后心跳"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.lastHeartbeat).toLocaleString("zh-CN")})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.createdAt).toLocaleString("zh-CN")})]})]}):(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[(0,ey.jsx)(erM,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsxs)("div",{children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"设备未绑定"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"设备注册异常,请尝试重新登录"})]})]})]}),(0,ey.jsx)(erO,{}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"hub-account-danger",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold text-destructive",children:"危险操作"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"以下操作不可逆,请谨慎执行。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"解除设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"将此设备从你的 Hub 账户中移除,并退出登录。设备数据不会受到影响。"})]}),(0,ey.jsxs)(d4,{children:[(0,ey.jsx)(d3,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{variant:"destructive",size:"sm",className:"shrink-0",children:[(0,ey.jsx)(erN,{}),"解除绑定"]})}),(0,ey.jsxs)(uf,{children:[(0,ey.jsxs)(uh,{children:[(0,ey.jsx)(up,{children:"确认解除设备绑定?"}),(0,ey.jsx)(ug,{children:"此操作将从你的 Hub 账户中移除当前设备,并退出登录。你可以随时重新登录并绑定设备。"})]}),(0,ey.jsxs)(um,{children:[(0,ey.jsx)(ux,{children:"取消"}),(0,ey.jsx)(uv,{onClick:w,disabled:l,className:"bg-destructive text-white hover:bg-destructive/90",children:l?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"处理中..."]}):"确认解除"})]})]})]})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"退出登录"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"退出当前 Hub 账户但保留设备在云端的注册。下次登录时无需重新绑定。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:[(0,ey.jsx)(ena,{}),"退出登录"]})]})]})]})})}):null}function erO(){let[e,t]=ew.useState(""),[n,r]=ew.useState(""),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(null);async function d(){if(c(null),n.length<8)return void c({kind:"err",text:"新密码至少 8 位"});if(n!==a)return void c({kind:"err",text:"两次输入的新密码不一致"});l(!0);try{await e1(e,n),c({kind:"ok",text:"密码已更新"}),t(""),r(""),i("")}catch(e){c({kind:"err",text:e instanceof Error?e.message:"修改失败,请重试"})}finally{l(!1)}}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(erS,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"修改密码"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"更改你的 Vantaloom Hub 登录密码。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(ez,{type:"password",placeholder:"当前密码",autoComplete:"current-password",value:e,onChange:e=>t(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"新密码(至少 8 位)",autoComplete:"new-password",value:n,onChange:e=>r(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"确认新密码",autoComplete:"new-password",value:a,onChange:e=>i(e.target.value)})]}),s?(0,ey.jsx)("p",{className:"ok"===s.kind?"text-xs text-primary":"text-xs text-destructive",children:s.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsx)(eA.Button,{size:"sm",onClick:d,disabled:o||!e||!n,children:o?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"保存中..."]}):"更新密码"})})]})}var erP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,l1.createSlot)(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,ey.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),erA=ew.forwardRef((e,t)=>(0,ey.jsx)(erP.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));function erI({className:e,...t}){return(0,ey.jsx)(erA,{"data-slot":"label",className:(0,eI.cn)("flex w-fit items-center gap-2 text-sm font-medium leading-snug peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]/field:opacity-50",e),...t})}erA.displayName="Label";var erz=["PageUp","PageDown"],erT=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],erD={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},erR="Slider",[er_,erL,er$]=hq(erR),[erF,erB]=cr(erR,[er$]),[erV,erH]=erF(erR),erU=ew.forwardRef((e,t)=>{let{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:s=0,defaultValue:c=[r],value:d,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:h=!1,form:m,...p}=e,g=ew.useRef(new Set),v=ew.useRef(0),x="horizontal"===o,[y=[],b]=cu({prop:d,defaultProp:c,onChange:e=>{let t=[...g.current];t[v.current]?.focus(),u(e)}}),w=ew.useRef(y);function j(e,t,{commit:n}={commit:!1}){let o,l=(String(i).split(".")[1]||"").length,c=m2(Math.round((Math.round((e-r)/i)*i+r)*(o=Math.pow(10,l)))/o,[r,a]);b((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,s*i))return e;{v.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&f(r),t?r:e}})}return(0,ey.jsx)(erV,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:a,valueIndexToChangeRef:v,thumbs:g.current,values:y,orientation:o,form:m,children:(0,ey.jsx)(er_.Provider,{scope:e.__scopeSlider,children:(0,ey.jsx)(er_.Slot,{scope:e.__scopeSlider,children:(0,ey.jsx)(x?erK:erG,{"aria-disabled":l,"data-disabled":l?"":void 0,...p,ref:t,onPointerDown:ci(p.onPointerDown,()=>{l||(w.current=y)}),min:r,max:a,inverted:h,onSlideStart:l?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(y,e);j(e,t)},onSlideMove:l?void 0:function(e){j(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&j(r,0,{commit:!0}),onEndKeyDown:()=>!l&&j(a,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!l){let n=erz.includes(e.key)||e.shiftKey&&erT.includes(e.key),r=v.current;j(y[r]+i*(n?10:1)*t,r,{commit:!0})}}})})})})});erU.displayName=erR;var[erW,erq]=erF(erR,{startEdge:"left",endEdge:"right",size:"width",direction:1}),erK=ew.forwardRef((e,t)=>{let{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:s,onStepKeyDown:c,...d}=e,[u,f]=ew.useState(null),h=(0,ca.useComposedRefs)(t,e=>f(e)),m=ew.useRef(void 0),p=hZ(a),g="ltr"===p,v=g&&!i||!g&&i;function x(e){let t=m.current||u.getBoundingClientRect(),a=er3([0,t.width],v?[n,r]:[r,n]);return m.current=t,a(e-t.left)}return(0,ey.jsx)(erW,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,ey.jsx)(erX,{dir:p,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=x(e.clientX);o?.(t)},onSlideMove:e=>{let t=x(e.clientX);l?.(t)},onSlideEnd:()=>{m.current=void 0,s?.()},onStepKeyDown:e=>{let t=erD[v?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),erG=ew.forwardRef((e,t)=>{let{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:s,...c}=e,d=ew.useRef(null),u=(0,ca.useComposedRefs)(t,d),f=ew.useRef(void 0),h=!a;function m(e){let t=f.current||d.current.getBoundingClientRect(),a=er3([0,t.height],h?[r,n]:[n,r]);return f.current=t,a(e-t.top)}return(0,ey.jsx)(erW,{scope:e.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:(0,ey.jsx)(erX,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=m(e.clientY);i?.(t)},onSlideMove:e=>{let t=m(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=erD[h?"from-bottom":"from-top"].includes(e.key);s?.({event:e,direction:t?-1:1})}})})}),erX=ew.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:s,...c}=e,d=erH(erR,n);return(0,ey.jsx)(cp.span,{...c,ref:t,onKeyDown:ci(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):erz.concat(erT).includes(e.key)&&(s(e),e.preventDefault())}),onPointerDown:ci(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():r(e)}),onPointerMove:ci(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:ci(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),i(e))})})}),erY="SliderTrack",erZ=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=erH(erY,n);return(0,ey.jsx)(cp.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});erZ.displayName=erY;var erJ="SliderRange",erQ=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=erH(erJ,n),i=erq(erJ,n),o=ew.useRef(null),l=(0,ca.useComposedRefs)(t,o),s=a.values.length,c=a.values.map(e=>er4(e,a.min,a.max)),d=s>1?Math.min(...c):0,u=100-Math.max(...c);return(0,ey.jsx)(cp.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:l,style:{...e.style,[i.startEdge]:d+"%",[i.endEdge]:u+"%"}})});erQ.displayName=erJ;var er0="SliderThumb",er1=ew.forwardRef((e,t)=>{let n=erL(e.__scopeSlider),[r,a]=ew.useState(null),i=(0,ca.useComposedRefs)(t,e=>a(e)),o=ew.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,ey.jsx)(er2,{...e,ref:i,index:o})}),er2=ew.forwardRef((e,t)=>{var n,r,a,i,o;let l,s,{__scopeSlider:c,index:d,name:u,...f}=e,h=erH(er0,c),m=erq(er0,c),[p,g]=ew.useState(null),v=(0,ca.useComposedRefs)(t,e=>g(e)),x=!p||h.form||!!p.closest("form"),y=ge(p),b=h.values[d],w=void 0===b?0:er4(b,h.min,h.max),j=(n=d,(r=h.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=y?.[m.size],S=k?(a=k,i=w,o=m.direction,s=er3([0,50],[0,l=a/2]),(l-s(i)*o)*o):0;return ew.useEffect(()=>{if(p)return h.thumbs.add(p),()=>{h.thumbs.delete(p)}},[p,h.thumbs]),(0,ey.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${w}% + ${S}px)`},children:[(0,ey.jsx)(er_.ItemSlot,{scope:e.__scopeSlider,children:(0,ey.jsx)(cp.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":h.min,"aria-valuenow":b,"aria-valuemax":h.max,"aria-orientation":h.orientation,"data-orientation":h.orientation,"data-disabled":h.disabled?"":void 0,tabIndex:h.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:ci(e.onFocus,()=>{h.valueIndexToChangeRef.current=d})})}),x&&(0,ey.jsx)(er5,{name:u??(h.name?h.name+(h.values.length>1?"[]":""):void 0),form:h.form,value:b},d)]})});er1.displayName=er0;var er5=ew.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let a=ew.useRef(null),i=(0,ca.useComposedRefs)(a,r),o=gy(t);return ew.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,ey.jsx)(cp.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});function er4(e,t,n){return m2(100/(n-t)*(e-t),[0,100])}function er3(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function er6(e){return Array.isArray(e)?e:"number"==typeof e?[e]:void 0}function er8({className:e,defaultValue:t,value:n,min:r=0,max:a=100,...i}){let o=ew.useMemo(()=>er6(n)??er6(t)??[r,a],[t,a,r,n]);return(0,ey.jsxs)(erU,{"data-slot":"slider",defaultValue:er6(t),value:er6(n),min:r,max:a,className:(0,eI.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,ey.jsx)(erZ,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1",children:(0,ey.jsx)(erQ,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),o.map((e,t)=>(0,ey.jsx)(er1,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white shadow-sm transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 hover:ring-ring/50 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden active:ring-3 active:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-primary-foreground"},t))]})}er5.displayName="RadioBubbleInput";let er7=[1e4,3e4,12e4,3e5,6e5];function er9(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??0,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[]}}}function eae(e){return(e&&e.length?e:er7).map(e=>Math.round(e/1e3)).join(", ")}function eat(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,h]=ew.useState("");function m(e,n){t(t=>t?{...t,[e]:{...t[e],...n}}:t),u(!0)}async function p(){if(e&&!o){l(!0),c("");try{let n=await js({compression:e.compression,summary:e.summary,approval:e.approval,behavior:e.behavior});t(er9(n)),h(eae(n.behavior?.retryDelaysMs)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return(ew.useEffect(()=>{!async function(){try{let[e,n]=await Promise.all([jl(),vF()]);t(er9(e)),h(eae(e.behavior?.retryDelaysMs)),r(n.models)}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"代理配置"})}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void p(),disabled:o,children:[(0,ey.jsx)(K3,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"错误"}),(0,ey.jsx)(Qr,{children:s})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"自动压缩阈值"}),(0,ey.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.compression.autoThresholdPercent,"%"]})]}),(0,ey.jsx)(er8,{value:[e.compression.autoThresholdPercent],onValueChange:([e])=>m("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"压缩模型"}),(0,ey.jsx)(ean,{models:n,value:e.compression.modelRef,onValueChange:e=>m("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"对话标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,ey.jsx)(xZ,{checked:e.summary.enableTitleSummary,onCheckedChange:e=>m("summary",{enableTitleSummary:e})})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"轮次标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,ey.jsx)(xZ,{checked:e.summary.enableRoundSummary,onCheckedChange:e=>m("summary",{enableRoundSummary:e})})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(ean,{models:n,value:e.summary.modelRef,onValueChange:e=>m("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"最大工具调用次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.maxToolCalls,onChange:e=>m("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次(默认)。"})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"自动重试次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.retryCount,onChange:e=>m("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,ey.jsx)(ez,{value:f,onChange:e=>{let t=e.currentTarget.value;h(t),m("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"审批模型"}),(0,ey.jsx)(ean,{models:n,value:e.approval.modelRef,onValueChange:e=>m("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"审批提示词"}),(0,ey.jsx)(b3,{value:e.approval.prompt,onChange:e=>m("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})]}):(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"读取失败"}),(0,ey.jsx)(Qr,{children:s||"无法加载代理配置"})]})}function ean({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gT,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:r})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.label},e.id))]})]})}let ear=(0,ek.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var eaa="Accordion",eai=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[eao,eal,eas]=hq(eaa),[eac,ead]=cr(eaa,[eas,enh]),eau=enh(),eaf=ew.default.forwardRef((e,t)=>{let{type:n,...r}=e;return(0,ey.jsx)(eao.Provider,{scope:e.__scopeAccordion,children:"multiple"===n?(0,ey.jsx)(eax,{...r,ref:t}):(0,ey.jsx)(eav,{...r,ref:t})})});eaf.displayName=eaa;var[eah,eam]=eac(eaa),[eap,eag]=eac(eaa,{collapsible:!1}),eav=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},collapsible:i=!1,...o}=e,[l,s]=cu({prop:n,defaultProp:r??"",onChange:a,caller:eaa});return(0,ey.jsx)(eah,{scope:e.__scopeAccordion,value:ew.default.useMemo(()=>l?[l]:[],[l]),onItemOpen:s,onItemClose:ew.default.useCallback(()=>i&&s(""),[i,s]),children:(0,ey.jsx)(eap,{scope:e.__scopeAccordion,collapsible:i,children:(0,ey.jsx)(eaw,{...o,ref:t})})})}),eax=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,l]=cu({prop:n,defaultProp:r??[],onChange:a,caller:eaa}),s=ew.default.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=ew.default.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return(0,ey.jsx)(eah,{scope:e.__scopeAccordion,value:o,onItemOpen:s,onItemClose:c,children:(0,ey.jsx)(eap,{scope:e.__scopeAccordion,collapsible:!0,children:(0,ey.jsx)(eaw,{...i,ref:t})})})}),[eay,eab]=eac(eaa),eaw=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,disabled:r,dir:a,orientation:i="vertical",...o}=e,l=ew.default.useRef(null),s=(0,ca.useComposedRefs)(l,t),c=eal(n),d="ltr"===hZ(a),u=ci(e.onKeyDown,e=>{if(!eai.includes(e.key))return;let t=e.target,n=c().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),a=n.length;if(-1===r)return;e.preventDefault();let o=r,l=a-1,s=()=>{(o=r+1)>l&&(o=0)},u=()=>{(o=r-1)<0&&(o=l)};switch(e.key){case"Home":o=0;break;case"End":o=l;break;case"ArrowRight":"horizontal"===i&&(d?s():u());break;case"ArrowDown":"vertical"===i&&s();break;case"ArrowLeft":"horizontal"===i&&(d?u():s());break;case"ArrowUp":"vertical"===i&&u()}let f=o%a;n[f].ref.current?.focus()});return(0,ey.jsx)(eay,{scope:n,disabled:r,direction:a,orientation:i,children:(0,ey.jsx)(eao.Slot,{scope:n,children:(0,ey.jsx)(cp.div,{...o,"data-orientation":i,ref:s,onKeyDown:r?void 0:u})})})}),eaj="AccordionItem",[eak,eaS]=eac(eaj),eaN=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,value:r,...a}=e,i=eab(eaj,n),o=eam(eaj,n),l=eau(n),s=cc(),c=r&&o.value.includes(r)||!1,d=i.disabled||e.disabled;return(0,ey.jsx)(eak,{scope:n,open:c,disabled:d,triggerId:s,children:(0,ey.jsx)(eng,{"data-orientation":i.orientation,"data-state":eaI(c),...l,...a,ref:t,disabled:d,open:c,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})});eaN.displayName=eaj;var eaC="AccordionHeader",eaM=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=eab(eaa,n),i=eaS(eaC,n);return(0,ey.jsx)(cp.h3,{"data-orientation":a.orientation,"data-state":eaI(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});eaM.displayName=eaC;var eaE="AccordionTrigger",eaO=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=eab(eaa,n),i=eaS(eaE,n),o=eag(eaE,n),l=eau(n);return(0,ey.jsx)(eao.ItemSlot,{scope:n,children:(0,ey.jsx)(enx,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...r,ref:t})})});eaO.displayName=eaE;var eaP="AccordionContent",eaA=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=eab(eaa,n),i=eaS(eaP,n),o=eau(n);return(0,ey.jsx)(enb,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function eaI(e){return e?"open":"closed"}function eaz({...e}){return(0,ey.jsx)(eaf,{"data-slot":"accordion",...e})}function eaT({className:e,...t}){return(0,ey.jsx)(eaN,{"data-slot":"accordion-item",className:(0,eI.cn)("border-b last:border-b-0",e),...t})}function eaD({className:e,children:t,...n}){return(0,ey.jsx)(eaM,{className:"flex",children:(0,ey.jsxs)(eaO,{"data-slot":"accordion-trigger",className:(0,eI.cn)("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,(0,ey.jsx)(vu,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200"})]})})}function eaR({className:e,children:t,...n}){return(0,ey.jsx)(eaA,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-out data-[state=open]:animate-in",...n,children:(0,ey.jsx)("div",{className:(0,eI.cn)("pb-4 pt-0 text-muted-foreground",e),children:t})})}eaA.displayName=eaP;let ea_={vantaloom:"Vantaloom","claude-code":"Claude Code",reclaude:"reclaude"};function eaL(e){return{...e.claudeCode??{}}}function ea$(e,t){if(e.reclaudeExecutable)return e;let n=t.find(e=>"reclaude"===e.engine);return n?.available&&n.detail?{...e,reclaudeExecutable:n.detail}:e}function eaF(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(!1),[f,h]=ew.useState(""),[m,p]=ew.useState(!1);async function g(){if(!d){u(!0),h("");try{let e=(await jd()).engines??[];r(e),t(t=>t?ea$(t,e):t)}catch(e){h(e instanceof Error?e.message:"适配器安装失败")}finally{u(!1)}}}function v(e){t(t=>t?{...t,...e}:t),p(!0)}ew.useEffect(()=>{!async function(){try{let[e,n,a]=await Promise.all([jl(),jc(),vF()]),o=n.engines??[];t(ea$(eaL(e),o)),r(o),i(a.models)}catch(e){h(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]);let x=e?.adapterArgs?.[0]??"";async function y(){if(e&&!s){c(!0),h("");try{let n=await js({claudeCode:e});t(eaL(n)),p(!1)}catch(e){h(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}return o?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取引擎配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"CC 引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"配置 Claude Code / reclaude 引擎。展开下方分组按需修改,留空项将自动发现。"})]}),m&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void y(),disabled:s,children:[(0,ey.jsx)(K3,{className:"size-4"}),s?"保存中":"保存"]})]}),f?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"错误"}),(0,ey.jsx)(Qr,{children:f})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"检测到的引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"本机当前可用的 Agent 运行引擎。不可用的引擎会说明原因。"})]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void g(),disabled:d,children:[d?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):(0,ey.jsx)(x1,{className:"size-4"}),d?"安装中…":"下载/安装适配器"]})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"Claude Code / reclaude 需要 ACP 适配器。运行时不再内置它(以减小体积), 点击上方按钮即可在后台静默下载安装;安装后无需手填路径即可使用。"}),(0,ey.jsx)("div",{className:"grid gap-2",children:0===n.length?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到引擎信息。"}):n.map(e=>(0,ey.jsxs)("div",{className:"grid gap-1 rounded-md border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:ea_[e.engine]??e.engine}),(0,ey.jsxs)("span",{className:(0,eI.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium [&_svg]:size-3",e.available?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-destructive/10 text-destructive"),children:[e.available?(0,ey.jsx)(eO,{}):(0,ey.jsx)(ear,{}),e.available?"可用":"不可用"]})]}),e.reason?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.reason}):null,e.detail?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:e.detail}):null]},e.engine))})]}),(0,ey.jsx)("section",{className:"rounded-lg border bg-card px-4",children:(0,ey.jsxs)(eaz,{type:"multiple",className:"w-full",children:[(0,ey.jsxs)(eaT,{value:"adapter",children:[(0,ey.jsx)(eaD,{children:"适配器"}),(0,ey.jsxs)(eaR,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"适配器命令"}),(0,ey.jsx)(ez,{value:e.adapterCommand??"",onChange:e=>v({adapterCommand:e.currentTarget.value}),placeholder:"node"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动使用 node 运行适配器。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"适配器入口 (…/@zed-industries/claude-code-acp/dist/index.js)"}),(0,ey.jsx)(ez,{value:x,onChange:e=>{let t=e.currentTarget.value;v({adapterArgs:t?[t]:[]})},placeholder:"…/@zed-industries/claude-code-acp/dist/index.js"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动发现(随运行时安装或环境变量 VANTALOOM_CC_ADAPTER)。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"Git Bash 路径"}),(0,ey.jsx)(ez,{value:e.gitBashPath??"",onChange:e=>v({gitBashPath:e.currentTarget.value}),placeholder:"C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Windows 专用,留空自动发现。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"reclaude 可执行文件"}),(0,ey.jsx)(ez,{value:e.reclaudeExecutable??"",onChange:e=>v({reclaudeExecutable:e.currentTarget.value}),placeholder:"reclaude"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"reclaude 可执行文件(或 node shim)路径;自动发现到 reclaude 时会自动填入, 会通过内置 shim 启动。留空则自动发现。"})]})]})]}),(0,ey.jsxs)(eaT,{value:"auth",children:[(0,ey.jsx)(eaD,{children:"认证"}),(0,ey.jsxs)(eaR,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"API Key"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.apiKey??"",onChange:e=>v({apiKey:e.currentTarget.value}),placeholder:"claude-code 引擎用;留空可用 claude /login"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用;留空可使用 claude /login 登录。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"OAuth Token"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.oauthToken??"",onChange:e=>v({oauthToken:e.currentTarget.value}),placeholder:"留空使用其它认证方式"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选的 OAuth Token,作为 API Key 之外的认证方式。"})]})]})]}),(0,ey.jsxs)(eaT,{value:"summary",children:[(0,ey.jsx)(eaD,{children:"摘要模型"}),(0,ey.jsx)(eaR,{className:"grid gap-4 text-foreground",children:(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(eaB,{models:a,value:e.summaryModelRef??"",onValueChange:e=>v({summaryModelRef:e}),placeholder:"使用默认"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"CC 会话标题/摘要用的 Vantaloom 模型路由。"})]})})]})]})})]}):(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"读取失败"}),(0,ey.jsx)(Qr,{children:f||"无法加载引擎配置"})]})}function eaB({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gT,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:r})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.label},e.id))]})]})}let eaV=[{id:"card",label:"卡片布局",description:"圆角卡片自由排布,右上角下拉菜单按需添加单窗口。",icon:(0,ey.jsx)(enr,{})},{id:"pane",label:"分屏布局",description:"传统多窗格 + 顶部分屏预设,可拖拽分割线调整。",icon:(0,ey.jsx)(Ut,{})},{id:"control-room",label:"导播台视角",description:"隐藏窗格,右侧以监视器墙并排查看主代理与各子代理。",icon:(0,ey.jsx)(eP,{})}],eaH=[{id:"left",label:"Agent 在左",icon:(0,ey.jsx)(s8,{})},{id:"right",label:"Agent 在右",icon:(0,ey.jsx)(s9,{})}];function eaU(){let[e,t]=ew.useState("pane"),[n,r]=ew.useState("left");return ew.useEffect(()=>{let e=JG();t(e.mode),r(e.agentSide)},[]),(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"布局排版"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 工作区的窗口布局与 Agent 对话的位置,设置即时应用到所有会话。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"布局模式"}),(0,ey.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",children:eaV.map(n=>{let r=e===n.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var e;t(e=n.id),JX({mode:e})},className:(0,eI.cn)("flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors [&_svg]:size-5",r?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":r,children:[(0,ey.jsx)("span",{className:(0,eI.cn)("grid size-9 place-items-center rounded-md",r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.icon}),(0,ey.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.label}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:n.description})]},n.id)})})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"Agent 对话位置"}),(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:eaH.map(e=>{let t=n===e.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var t;r(t=e.id),JX({agentSide:t})},className:(0,eI.cn)("inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors [&_svg]:size-4",t?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":t,children:[e.icon,e.label]},e.id)})})]})]})}let eaW=[{value:"openai-v1",label:"OpenAI v1"},{value:"anthropic",label:"Anthropic"},{value:"openai-responses",label:"OpenAI Responses"}];function eaq(e){return{id:e.id,providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:"",models:e.models,selectedModelIds:e.selectedModelIds,builtin:e.builtin,loadingModels:!1,saving:!1,error:e.lastError??"",savedKeyAvailable:!0,editing:!1}}function eaK(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState(""),o=ew.useCallback(async()=>{i("");try{let e=await vF();t(e.routes.map(eaq))}catch(e){i(e instanceof Error?e.message:"模型路由读取失败")}finally{r(!1)}},[]);function l(e,n){t(t=>t.map((t,r)=>r===e?n(t):t))}async function s(t){let n=e[t];if(n&&!n.saving){l(t,e=>({...e,saving:!0,error:""}));try{let e=await vV({id:n.id,providerName:n.providerName,protocol:n.protocol,endpointUrl:n.endpointUrl,apiKey:n.apiKey,models:n.models,selectedModelIds:n.selectedModelIds});l(t,()=>eaq(e))}catch(e){l(t,t=>({...t,saving:!1,error:e instanceof Error?e.message:"保存失败"}))}}}async function c(n){let r=e[n];if(r&&!r.saving){if(!r.id)return void t(e=>e.filter((e,t)=>t!==n));l(n,e=>({...e,saving:!0,error:""}));try{await vH(r.id),t(e=>e.filter((e,t)=>t!==n))}catch(e){l(n,t=>({...t,saving:!1,error:e instanceof Error?e.message:"删除失败"}))}}}return ew.useEffect(()=>{o()},[o]),ew.useEffect(()=>{let e=!1,n=window.setInterval(()=>{(async()=>{try{let n=await vF();if(e)return;let r=n.routes.find(e=>e.builtin);t(e=>{let t=e.some(e=>e.builtin);return r?t?e.map(e=>e.builtin?{...e,providerName:r.providerName,models:r.models,selectedModelIds:r.selectedModelIds,error:r.lastError??""}:e):[eaq(r),...e]:t?e.filter(e=>!e.builtin):e})}catch{}})()},3e4);return()=>{e=!0,window.clearInterval(n)}},[]),(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"模型路由"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:function(){t(e=>[{providerName:"",protocol:"openai-v1",endpointUrl:"",apiKey:"",models:[],selectedModelIds:[],loadingModels:!1,saving:!1,error:"",editing:!0},...e])},"data-tour":"add-model-route",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加模型路由"]})]}),a?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"读取失败"}),(0,ey.jsx)(Qr,{children:a})]}):null,n?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型路由"}):0===e.length?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型路由。"}):(0,ey.jsx)("div",{className:"grid gap-3",children:e.map((e,t)=>(0,ey.jsx)(eaG,{draft:e,onDraftChange:e=>l(t,()=>e),onSave:()=>{s(t)},onDelete:()=>{c(t)}},e.id??`draft-${t}`))})]})}function eaG({draft:e,onDraftChange:t,onSave:n,onDelete:r}){let a=ew.useRef(e),i=ew.useRef(t),o=[e.providerName,e.protocol,e.endpointUrl,e.apiKey||(e.savedKeyAvailable?"saved":"")].join("\n"),l=e.providerName.trim()&&e.endpointUrl.trim()&&e.apiKey.trim(),s=e.providerName.trim()&&e.endpointUrl.trim()&&(e.apiKey.trim()||e.savedKeyAvailable)&&e.selectedModelIds.length>0&&!e.saving;function c(n){t({...e,...n})}if(ew.useEffect(()=>{a.current=e,i.current=t},[e,t]),ew.useEffect(()=>{if(!l)return;let e=window.setTimeout(async()=>{let e=a.current;i.current({...e,loadingModels:!0,error:""});try{let t=await vB({providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:e.apiKey}),n=e.selectedModelIds.filter(e=>t.models.some(t=>t.id===e));i.current({...e,models:t.models,selectedModelIds:n,loadingModels:!1,error:""})}catch(t){i.current({...e,loadingModels:!1,error:t instanceof Error?t.message:"模型拉取失败"})}},650);return()=>window.clearTimeout(e)},[l,o]),!e.editing||e.builtin){let t=e.selectedModelIds.map(t=>e.models.find(e=>e.id===t)?.displayName||t).filter(Boolean),n=eaW.find(t=>t.value===e.protocol)?.label??e.protocol;return(0,ey.jsxs)("section",{className:"grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.builtin?(0,ey.jsx)(lK,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.providerName}),e.builtin?(0,ey.jsx)("span",{className:"ui-text-kbd rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:"官渠"}):null,(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n})]}),(0,ey.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(", "):"未选择模型"})]}),e.builtin?null:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>c({editing:!0}),children:[(0,ey.jsx)(HN,{className:"size-4"}),"编辑"]})]})}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-3","data-tour":"model-route-form",children:[(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_11rem]",children:[(0,ey.jsx)(ez,{value:e.providerName,placeholder:"提供商名称",onChange:e=>c({providerName:e.currentTarget.value})}),(0,ey.jsxs)(gT,{value:e.protocol,onValueChange:e=>c({protocol:e}),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{})}),(0,ey.jsx)(vg,{children:eaW.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)]",children:[(0,ey.jsx)(ez,{value:e.endpointUrl,placeholder:"API 端点 URL,例如 https://api.openai.com/v1",onChange:e=>c({endpointUrl:e.currentTarget.value})}),(0,ey.jsx)(ez,{value:e.apiKey,type:"password",placeholder:e.savedKeyAvailable?"已保存,留空沿用":"API Key",onChange:e=>c({apiKey:e.currentTarget.value})})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-6 items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-medium",children:[(0,ey.jsx)(mY,{className:"size-4 text-muted-foreground"}),"可用模型"]}),e.loadingModels?(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"拉取中"}):null]}),e.models.length>0?(0,ey.jsx)("div",{className:"grid max-h-64 gap-1 overflow-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.models.map(t=>{let n=e.selectedModelIds.includes(t.id);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-8 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 text-sm hover:bg-muted/60",n&&"bg-muted/70"),children:[(0,ey.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,ey.jsx)(v$,{checked:n,onCheckedChange:n=>{var r;return r=t.id,void c({selectedModelIds:!0===n?[...e.selectedModelIds,r]:e.selectedModelIds.filter(e=>e!==r)})}}),(0,ey.jsx)("span",{className:"truncate",children:t.displayName||t.id})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(ez,{type:"number",className:"h-6 w-16 px-1.5 text-center text-xs tabular-nums",value:t.contextLength||200,min:1,max:1e4,onChange:n=>{var r,a;return r=t.id,a=Number.parseInt(n.currentTarget.value,10)||0,void c({models:e.models.map(e=>e.id===r?{...e,contextLength:a>0?a:void 0}:e)})}}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"k"})]})]},t.id)})}):(0,ey.jsx)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:"填写端点和密钥后会自动拉取模型。"})]}),e.error?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"模型路由错误"}),(0,ey.jsx)(Qr,{className:"break-words",children:e.error})]}):null,(0,ey.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,ey.jsxs)(eA.Button,{type:"button",variant:"destructive",onClick:r,disabled:e.saving,children:[(0,ey.jsx)(yi,{className:"size-4"}),"删除"]}),(0,ey.jsx)(eA.Button,{type:"button",onClick:n,disabled:!s,children:e.saving?"保存中":"保存"})]})]})}async function eaX(){return eaZ("/api/local/subagent-config")}async function eaY(e){return eaZ("/api/local/subagent-config",{method:"PUT",body:JSON.stringify(e)})}async function eaZ(e,t){let n=await fetch(eD(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"subagent config api failed");return r}function eaJ(e){return{explore:{...e.explore},workflow:{...e.workflow},operator:{...e.operator},custom:{...e.custom,models:[...e.custom.models??[]]}}}let eaQ={explore:{title:"探索子代理",icon:(0,ey.jsx)(Vy,{className:"size-4"}),tint:"text-sky-600 dark:text-sky-400",description:"只读的代码库探索/调研专家。彻底阅读、搜索代码库,返回带文件路径+行号引用的完整结论,替主 agent 节省上下文。",tools:"仅阅读(vantaloom_read)"},workflow:{title:"工作流子代理",icon:(0,ey.jsx)(uP,{className:"size-4"}),tint:"text-violet-600 dark:text-violet-400",description:"按 workflow-*.yml 严格执行可重复的多步流程,并把其中确定性的步骤自动固化为脚本、给 yml 添加批注。",tools:"阅读 / 编辑 / 终端(vantaloom_read · vantaloom_edit · vantaloom_shell)"},operator:{title:"操作员子代理",icon:(0,ey.jsx)(uO,{className:"size-4"}),tint:"text-pink-600 dark:text-pink-400",description:"专门驱动交互式终端(未来含浏览器)。执行大量终端操作并把结果回报给主 agent。",tools:"阅读 / 终端(vantaloom_read · vantaloom_shell)"}};function ea0(){let[e,t]=ew.useState(null),{models:n,loading:r}=vq(),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1);async function f(){if(e&&!o){l(!0),c("");try{let n=await eaY({explore:e.explore,workflow:e.workflow,operator:e.operator,custom:e.custom});t(eaJ(n)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await eaX();t(eaJ(e))}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取子代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"子代理配置"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"主 agent 可以派发这些子代理来分担任务。每个子代理拥有独立上下文与受限工具集,完成后只把结果汇报给主 agent。"})]}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(),disabled:o,children:[(0,ey.jsx)(K3,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"错误"}),(0,ey.jsx)(Qr,{children:s})]}):null,["explore","workflow","operator"].map(a=>(0,ey.jsx)(ea1,{tourId:`subagent-${a}`,meta:eaQ[a],value:e[a],models:n,modelsLoading:r,onChange:e=>{t(t=>t?{...t,[a]:{...t[a],...e}}:t),u(!0)}},a)),(0,ey.jsx)(ea2,{value:e.custom,models:n,modelsLoading:r,onChange:function(e){t(t=>t?{...t,custom:{...t.custom,...e}}:t),u(!0)}})]}):(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"读取失败"}),(0,ey.jsx)(Qr,{children:s||"无法加载子代理配置"})]})}function ea1({meta:e,value:t,models:n,modelsLoading:r,onChange:a,tourId:i}){return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":i,children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:e.tint,children:e.icon}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:e.title})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description}),(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"text-foreground/70",children:"可用工具:"}),e.tools,(0,ey.jsx)("span",{className:"ml-1 text-muted-foreground/70",children:"(固定,不可更改)"})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"使用模型"}),(0,ey.jsx)(ea5,{models:n,value:t.modelRef,onValueChange:e=>a({modelRef:e}),placeholder:r?"读取模型中":"继承上级模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则继承派发它的上级 agent 当前使用的模型。"})]}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"允许上级指定模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,上级 agent 可在派发时动态指定该子代理使用的模型。"})]}),(0,ey.jsx)(xZ,{checked:t.allowCallerModel,onCheckedChange:e=>a({allowCallerModel:e})})]}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"系统提示词"}),t.promptOverride?(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a({promptOverride:""}),children:"恢复默认"}):null]}),(0,ey.jsx)(b3,{value:t.promptOverride,onChange:e=>a({promptOverride:e.currentTarget.value}),placeholder:"留空使用内置默认提示词;在此输入将覆盖默认提示词(环境/工具说明仍会自动附加)。",rows:t.promptOverride?10:3,className:"resize-y text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"覆盖该官方子代理的预设系统提示词。派发时还会自动附加工作区、操作系统与工具使用说明。"})]})]})}function ea2({value:e,models:t,modelsLoading:n,onChange:r}){let a=ew.useCallback(e=>t.find(t=>t.value===e)?.label??e,[t]);return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"subagent-custom",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:(0,ey.jsx)(ub,{className:"size-4"})}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自定义子代理"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 可以自取名字、从下面的模型池中选一个模型来召唤自定义子代理,并可选择是否继承当前对话上下文。自定义子代理拥有完整工具集,还能进一步派发上面三种官方子代理。"}),(0,ey.jsx)(ee2,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(erI,{className:"text-sm",children:"可用模型池"}),(0,ey.jsx)(xY,{variant:"list-combobox",value:e.models,onValueChange:e=>r({models:e}),options:t,placeholder:n?"读取模型中":"选择可供自定义子代理使用的模型",searchPlaceholder:"搜索模型...",emptyText:"没有可用模型",renderItem:a}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 召唤自定义子代理时会从这个池中选择一个模型。留空则沿用上级 agent 的模型。"})]})]})}function ea5({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gT,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{placeholder:r})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))]})]})}function ea4(){let[e,t]=ew.useState(""),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState("");async function d(){if(!a){i(!0),c("");try{await js({systemPrompt:{userPrompt:e}}),l(!1)}catch(e){c(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return(ew.useEffect(()=>{(async()=>{try{let e=await jl();t(e.systemPrompt?.userPrompt??"")}catch(e){c(e instanceof Error?e.message:"加载失败")}finally{r(!1)}})()},[]),n)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取系统提示词配置"}):(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"兜底系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅对 vantaloom 引擎对话生效。当某个对话未检测到任何项目文档(CLAUDE.md / AGENTS.md / vantaloom.md),也没有在该对话的“系统提示词”里单独设置时, 才使用这里的内容作为兜底。各对话独立的系统提示词请到对话设置 → 系统提示词中配置。"})]}),o?(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void d(),disabled:a,children:[(0,ey.jsx)(K3,{className:"size-4"}),a?"保存中":"保存"]}):null]}),s?(0,ey.jsxs)(Qt,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Qn,{children:"错误"}),(0,ey.jsx)(Qr,{children:s})]}):null,(0,ey.jsx)(b3,{value:e,onChange:e=>{t(e.currentTarget.value),l(!0)},placeholder:"例如:始终用中文回复;提交前先跑测试;优先复用现有代码……",rows:8,className:"resize-y text-sm"})]})}function ea3({section:e}={}){return(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":`preferences-${e??"model-routes"}`,children:"agent-config"===e?(0,ey.jsx)(eat,{}):"subagent-config"===e?(0,ey.jsx)(ea0,{}):"cc-engine-config"===e?(0,ey.jsx)(eaF,{}):"system-prompt"===e?(0,ey.jsx)(ea4,{}):"layout"===e?(0,ey.jsx)(eaU,{}):(0,ey.jsx)(eaK,{})})})}let ea6=(0,ek.default)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);function ea8(e,t){if(e.isLocal)return eD(t);let n=t.replace(/^\/v1(?=\/)/,"");return eD(`/v1/remote/${e.id}${n}`)}async function ea7(e){try{let t=await fetch(`https://registry.npmjs.org/@vantaloom/runtime-${e}`,{headers:{Accept:"application/vnd.npm.install-v1+json"},cache:"no-store"});if(!t.ok)return;let n=await t.json();return n?.["dist-tags"]?.latest}catch{return}}function ea9(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback((e,n)=>{t(t=>t.map(t=>t.machine.id===e?{...t,...n}:t))},[]),o=ew.useCallback(async()=>{r(!0);let e=[];try{let t=await fetch(eD("/v1/remote/machines"),{cache:"no-store"});e=(await t.json()).machines??[]}catch{e=[]}a.current&&(t(e.map(e=>({machine:e,loading:!0}))),r(!1),await Promise.all(e.map(async e=>{if(!e.isLocal&&"online"!==e.status){a.current&&i(e.id,{loading:!1,error:"离线"});return}try{let t,n=await fetch(ea8(e,"/v1/runtime/info"),{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.text();try{t=JSON.parse(r)}catch{throw Error("该机器运行时过旧,不支持版本检测")}let o=await ea7(t.platform);a.current&&i(e.id,{info:t,latest:o,loading:!1})}catch(t){a.current&&i(e.id,{loading:!1,error:t instanceof Error?t.message:"无法获取版本"})}})))},[i]);async function l(e){if(e.info&&!e.updating){i(e.machine.id,{updating:!0});try{await fetch(ea8(e.machine,"/v1/runtime/update"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:e.latest})})}catch{}window.setTimeout(()=>{a.current&&o()},25e3)}}return ew.useEffect(()=>(a.current=!0,o(),()=>{a.current=!1}),[o]),(0,ey.jsx)("div",{className:"h-full overflow-auto px-6 py-8","data-tour":"check-update",children:(0,ey.jsxs)("div",{className:"mx-auto flex max-w-3xl flex-col gap-5",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h1",{className:"text-xl font-semibold",children:"检查更新"}),(0,ey.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"工作组内各机器的运行时版本与可用更新。点击「立即更新」可让对应机器自动更新(该机器会短暂重启)。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:()=>void o(),disabled:n,children:[(0,ey.jsx)(ya,{className:(0,eI.cn)("size-4",n&&"animate-spin")}),"刷新"]})]}),n&&0===e.length?(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl border bg-card p-8 text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 正在获取机器列表…"]}):0===e.length?(0,ey.jsx)("div",{className:"rounded-xl border bg-card p-8 text-center text-sm text-muted-foreground",children:"暂无可用机器。"}):(0,ey.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{let t=!!e.info&&!!e.latest&&e.latest!==e.info.version;return(0,ey.jsxs)("div",{className:"flex items-center gap-4 rounded-xl border bg-card px-4 py-3",children:[(0,ey.jsx)(eP,{className:"size-5 shrink-0 text-muted-foreground"}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.machine.name}),e.machine.isLocal?(0,ey.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"本机"}):null]}),(0,ey.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.loading?"读取版本中…":e.error?(0,ey.jsx)("span",{className:"text-amber-600",children:e.error}):(0,ey.jsxs)(ey.Fragment,{children:[function(e){switch(e){case"windows":return"Windows";case"darwin":return"macOS";case"linux":return"Linux";case"android":return"Android";default:return e||"未知"}}(e.info?.os??e.machine.platform??"")," · 当前 ",(0,ey.jsx)("span",{className:"font-mono",children:e.info?.version??"?"}),e.latest?(0,ey.jsxs)(ey.Fragment,{children:[" · 最新 ",(0,ey.jsx)("span",{className:"font-mono",children:e.latest})]}):null,e.info?.updatedAt?(0,ey.jsxs)(ey.Fragment,{children:[" · 更新于 ",function(e){if(!e)return"—";let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):"—"}(e.info.updatedAt)]}):null]})})]}),e.loading?(0,ey.jsx)(eM,{className:"size-4 animate-spin text-muted-foreground"}):e.updating?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 更新中…"]}):t?(0,ey.jsxs)(eA.Button,{size:"sm",onClick:()=>void l(e),children:[(0,ey.jsx)(ea6,{className:"size-4"})," 立即更新"]}):e.info?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)(eO,{className:"size-4 text-emerald-500"})," 已是最新"]}):null]},e.machine.id)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"最新版本号来自 npm(@vantaloom/runtime-<平台>)。更新过程中该机器会停止并重启运行时, 若你的手机正连着它会短暂断开,更新完成后重新连接即可。"})]})})}let eie=(0,ek.default)("gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]),eit=(0,ek.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),ein=[{value:"24h",label:"近 24 小时"},{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"}];function eir(){let{user:e}=tl(),[t,n]=ew.useState(null),[r,a]=ew.useState(!0),[i,o]=ew.useState(null),[l,s]=ew.useState("7d"),[c,d]=ew.useState("all"),[u,f]=ew.useState([]),[h,m]=ew.useState([]),[p,g]=ew.useState(!0),[v,x]=ew.useState(""),[y,b]=ew.useState(!1),[w,j]=ew.useState(null),k=ew.useCallback(async()=>{a(!0),o(null);try{n(await e6())}catch(e){o(e instanceof Error?e.message:"读取余额失败")}finally{a(!1)}},[]);ew.useEffect(()=>{e&&(k(),e9().then(e=>f(e.models)).catch(()=>f([])))},[e,k]),ew.useEffect(()=>{if(!e)return;let t=!1;return g(!0),e8(l,"all"===c?void 0:c).then(e=>{t||m(e.points)}).catch(()=>{t||m([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e,l,c]);let S=ew.useMemo(()=>h.reduce((e,t)=>(e.costMicro+=t.costMicro,e.requests+=t.requests,e.totalTokens+=t.totalTokens,e),{costMicro:0,requests:0,totalTokens:0}),[h]),N=ew.useMemo(()=>h.map(e=>{var t;let n;return{label:(t=e.time,n=new Date(t),"24h"===l?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})),cost:e.costMicro/1e6,requests:e.requests,tokens:e.totalTokens}}),[h,l]);async function C(){let e=v.trim();if(e){b(!0),j(null);try{let t=await e7(e);j({kind:"ok",text:`兑换成功,到账 ${e4(t.valueMicro)}`}),x(""),n(e=>e?{...e,balanceMicro:t.balanceMicro,balanceUsd:t.balanceMicro/1e6}:e)}catch(e){j({kind:"err",text:e instanceof Error?e.message:"兑换失败,请检查兑换码"})}finally{b(!1)}}}return e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"余额与用量"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"查看官方渠道的账户余额、调用用量,并使用兑换码充值。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(end,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户余额"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void k(),disabled:r,children:[r?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(ya,{}),"刷新"]})]}),i?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:i}):(0,ey.jsx)("p",{className:"text-3xl font-semibold tracking-tight",children:r&&!t?"—":e4(t?.balanceMicro??0,4)})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(eie,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"兑换码充值"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"输入兑换码,金额将立即计入账户余额。"}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ez,{value:v,onChange:e=>x(e.target.value),placeholder:"请输入兑换码",className:"font-mono",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,ey.jsxs)(eA.Button,{className:"shrink-0",onClick:()=>void C(),disabled:y||!v.trim(),children:[y?(0,ey.jsx)(eM,{className:"animate-spin"}):null,"兑换"]})]}),w?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===w.kind?"text-primary":"text-destructive"),children:w.text}):null]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(eit,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"用量趋势"})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsxs)(gT,{value:c,onValueChange:d,children:[(0,ey.jsx)(vh,{size:"sm",className:"w-44",children:(0,ey.jsx)(gL,{placeholder:"全部模型"})}),(0,ey.jsxs)(vg,{children:[(0,ey.jsx)(vv,{value:"all",children:"全部模型"}),u.map(e=>(0,ey.jsx)(vv,{value:e.id,children:e.displayName||e.id},e.id))]})]}),(0,ey.jsxs)(gT,{value:l,onValueChange:s,children:[(0,ey.jsx)(vh,{size:"sm",className:"w-32",children:(0,ey.jsx)(gL,{})}),(0,ey.jsx)(vg,{children:ein.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]})]})]}),(0,ey.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,ey.jsx)(eia,{label:"花费",value:e4(S.costMicro,4)}),(0,ey.jsx)(eia,{label:"请求数",value:S.requests.toLocaleString("zh-CN")}),(0,ey.jsx)(eia,{label:"Tokens",value:S.totalTokens.toLocaleString("zh-CN")})]}),(0,ey.jsx)("div",{className:"h-56 w-full",children:p&&0===h.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===N.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"所选区间暂无用量记录"}):(0,ey.jsx)(Cp,{width:"100%",height:"100%",children:(0,ey.jsxs)(YY,{data:N,margin:{top:8,right:8,left:0,bottom:0},children:[(0,ey.jsx)("defs",{children:(0,ey.jsxs)("linearGradient",{id:"usageCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ey.jsx)("stop",{offset:"5%",stopColor:"var(--color-primary)",stopOpacity:.35}),(0,ey.jsx)("stop",{offset:"95%",stopColor:"var(--color-primary)",stopOpacity:0})]})}),(0,ey.jsx)(Zw,{strokeDasharray:"3 3",stroke:"var(--color-border)",vertical:!1}),(0,ey.jsx)(Z_,{dataKey:"label",tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1}),(0,ey.jsx)(ZG,{tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1,width:48,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,ey.jsx)(BU,{contentStyle:{borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-popover)",fontSize:12},formatter:e=>[`$${Number(e).toFixed(4)}`,"花费"]}),(0,ey.jsx)(YU,{type:"monotone",dataKey:"cost",stroke:"var(--color-primary)",strokeWidth:2,fill:"url(#usageCost)"})]})})})]})]})}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(end,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再查看余额与用量。"})]})})}function eia({label:e,value:t}){return(0,ey.jsxs)("div",{className:"rounded-md bg-muted/55 px-3 py-2",children:[(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("p",{className:"mt-0.5 truncate text-sm font-semibold",children:t})]})}let eii=(0,ek.default)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),eio=(0,ek.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),eil=[{value:"bug",label:"功能异常"},{value:"feature",label:"功能建议"},{value:"billing",label:"计费与余额"},{value:"other",label:"其他"}],eis=Object.fromEntries(eil.map(e=>[e.value,e.label])),eic={pending:{label:"待审批",variant:"secondary"},preparing:{label:"准备完成",variant:"outline"},done:{label:"已完成",variant:"default"},noplan:{label:"暂时无计划",variant:"secondary"}};function eid(){let{user:e}=tl(),[t,n]=ew.useState(""),[r,a]=ew.useState("bug"),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState(!1),[u,f]=ew.useState(null),[h,m]=ew.useState(!1),p=ew.useRef(null),[g,v]=ew.useState([]),[x,y]=ew.useState(!0),[b,w]=ew.useState(null),j=ew.useCallback(async()=>{y(!0);try{let e=await tt();v(e.issues)}catch{v([])}finally{y(!1)}},[]);function k(e){let t=Array.from(e).filter(e=>e.type.startsWith("image/"));f(null),s(e=>{let n=[...e];for(let e of t){if(n.length>=10){f({kind:"err",text:`最多上传 10 张图片`});break}if(e.size>8388608){f({kind:"err",text:`「${e.name}」过大(上限 8MB)`});continue}n.push({id:`${e.name}-${e.size}-${n.length}`,file:e,url:URL.createObjectURL(e)})}return n})}async function S(){if(!t.trim())return void f({kind:"err",text:"请填写标题"});d(!0),f(null);try{let{issue:e}=await te({title:t.trim(),type:r,content:i.trim()}),c=!1;for(let t of l)try{await tn(e.id,t.file)}catch{c=!0}f({kind:"ok",text:c?"反馈已提交,但部分图片上传失败,请在下方列表确认":"反馈已提交,感谢您的反馈!"}),n(""),a("bug"),o(""),l.forEach(e=>URL.revokeObjectURL(e.url)),s([]),j()}catch(e){f({kind:"err",text:e instanceof Error?e.message:"提交失败,请重试"})}finally{d(!1)}}return ew.useEffect(()=>{e&&j()},[e,j]),ew.useEffect(()=>()=>{l.forEach(e=>URL.revokeObjectURL(e.url))},[]),e?(0,ey.jsxs)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:[(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"问题反馈"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"提交功能异常、建议或计费问题,我们会在看板中跟进处理。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"标题"}),(0,ey.jsx)(ez,{value:t,onChange:e=>n(e.target.value),maxLength:120,placeholder:"简要描述问题"})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"类型"}),(0,ey.jsxs)(gT,{value:r,onValueChange:a,children:[(0,ey.jsx)(vh,{className:"w-full",children:(0,ey.jsx)(gL,{})}),(0,ey.jsx)(vg,{children:eil.map(e=>(0,ey.jsx)(vv,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"详细描述"}),(0,ey.jsx)(b3,{value:i,onChange:e=>o(e.target.value),rows:5,placeholder:"详细描述问题的复现步骤、期望行为等",onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),k(t))}})]}),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid gap-3 rounded-lg border border-dashed p-3 transition-colors",h?"border-primary bg-primary/5":"border-input"),onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:["可拖拽、粘贴或选择图片(最多 ",10," 张,单张 ≤ 8MB)"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>p.current?.click(),children:[(0,ey.jsx)(eii,{}),"添加图片"]}),(0,ey.jsx)("input",{ref:p,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&k(e.target.files),e.target.value=""}})]}),l.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,ey.jsxs)("div",{className:"relative size-16 overflow-hidden rounded-md border",children:[(0,ey.jsx)("img",{src:e.url,alt:e.file.name,className:"size-full object-cover"}),(0,ey.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void s(e=>{let n=e.find(e=>e.id===t);return n&&URL.revokeObjectURL(n.url),e.filter(e=>e.id!==t)})},className:"absolute right-0.5 top-0.5 rounded-full bg-black/55 p-0.5 text-white hover:bg-black/75","aria-label":"移除图片",children:(0,ey.jsx)(fg.XIcon,{className:"size-3"})})]},e.id))}):null]}),u?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===u.kind?"text-primary":"text-destructive"),children:u.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsxs)(eA.Button,{onClick:()=>void S(),disabled:c||!t.trim(),children:[c?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(eio,{}),"提交反馈"]})})]}),(0,ey.jsxs)("section",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"我的反馈"}),x?(0,ey.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===g.length?(0,ey.jsx)("p",{className:"rounded-lg border bg-card p-6 text-center text-xs text-muted-foreground",children:"你还没有提交过反馈。"}):g.map(e=>{let t=eic[e.status]??{label:e.status,variant:"secondary"};return(0,ey.jsxs)("article",{className:"grid gap-2 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,ey.jsx)(Bs,{variant:"outline",children:eis[e.type]??e.type}),(0,ey.jsx)(Bs,{variant:t.variant,children:t.label})]})]}),e.content?(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:e.content}):null,e.images.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:e.images.map(t=>(0,ey.jsx)("button",{type:"button",className:"size-16 overflow-hidden rounded-md border",onClick:()=>w({issueId:e.id,imageId:t.id}),children:(0,ey.jsx)(eif,{issueId:e.id,imageId:t.id})},t.id))}):null,(0,ey.jsx)("p",{className:"text-[11px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN")})]},e.id)})]})]}),(0,ey.jsx)(dC,{open:null!==b,onOpenChange:e=>{e||w(null)},children:(0,ey.jsx)(fx,{className:"max-w-3xl",children:b?(0,ey.jsx)(eih,{issueId:b.issueId,imageId:b.imageId,className:"max-h-[75vh] w-full object-contain"}):null})})]}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(jb,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再提交问题反馈。"})]})})}function eiu(e,t){let[n,r]=ew.useState(null);return ew.useEffect(()=>{let n=!0,a=null;return tr(e,t).then(e=>{a=e,n?r(e):URL.revokeObjectURL(e)}).catch(()=>{}),()=>{n=!1,a&&URL.revokeObjectURL(a)}},[e,t]),n}function eif({issueId:e,imageId:t}){let n=eiu(e,t);return n?(0,ey.jsx)("img",{src:n,alt:"",className:"size-full object-cover"}):(0,ey.jsx)("div",{className:"flex size-full items-center justify-center bg-muted"})}function eih({issueId:e,imageId:t,className:n}){let r=eiu(e,t);return r?(0,ey.jsx)("img",{src:r,alt:"",className:n}):(0,ey.jsx)("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})})}let eim={totals:{machines:0,online:0,runtime:0,tokens:0},machines:[],topology:{nodes:[],links:[]},pathTotals:{direct:0,p2p:0,relay:0,broken:0},latency:[],candidates:[]},eip={metrics:{online:0,health:0,latency:"local",events:0},machines:[],trend:[],networkLinks:[],events:[],serviceHealth:[]};function eig(e,t){let[n,r]=ew.useState(t);return ew.useEffect(()=>{let n=!0,a=!1;async function i(){if(!a){a=!0;try{let t=await fetch(eD(e),{cache:"no-store"});if(!t.ok)return;let a=await t.json();n&&r(a)}catch{n&&r(t)}finally{a=!1}}}i();let o=window.setInterval(i,2e3);return()=>{n=!1,window.clearInterval(o)}},[t,e]),n}function eiv(){let e=eig("/api/local/machines/fleet",eim),{nodes:t,links:n}=e.topology;return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"shrink-0 border-b px-6 py-4",children:[(0,ey.jsx)("h2",{className:"text-base font-semibold tracking-normal",children:"组网关系"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"系统中各机器的拓扑关系图(自动生成)。节点为机器,连线表示机器之间的连接方式与实时延迟。"}),(0,ey.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["机器 ",e.totals.online,"/",e.totals.machines," 在线"]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"直连 ",e.pathTotals.direct]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"P2P ",e.pathTotals.p2p]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-muted-foreground"}),"中继 ",e.pathTotals.relay]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-destructive"}),"断开 ",e.pathTotals.broken]})]})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 p-4",children:0===t.length?(0,ey.jsx)("div",{className:"grid h-full place-items-center rounded-lg border border-dashed",children:(0,ey.jsx)("p",{className:"max-w-sm text-center text-sm text-muted-foreground",children:"暂未发现其它机器。登录 Hub 账户并把机器加入同一工作组后,这里会自动绘制组网拓扑。"})}):(0,ey.jsx)("div",{className:"h-full overflow-hidden rounded-lg border bg-card",children:(0,ey.jsx)(etO,{nodes:t,links:n})})}),(0,ey.jsx)("footer",{className:"shrink-0 border-t px-6 py-2",children:(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[(0,ey.jsx)("span",{children:"连接方式:"}),[{kind:"direct",label:"直连",className:"bg-foreground"},{kind:"p2p",label:"P2P",className:"bg-foreground"},{kind:"relay",label:"中继",className:"bg-muted-foreground"},{kind:"down",label:"断开",className:"bg-destructive"}].map(e=>(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:`h-0.5 w-4 rounded ${e.className}`}),e.label]},e.kind))]})})]})}let eix="local",eiy=[{id:"cloakbrowser",label:"CloakBrowser 默认",description:"源码级反爬的真 Chromium,最适合 agent 在真实站点稳定工作。"},{id:"chrome-for-testing",label:"Chrome for Testing",description:"Google 官方纯净自动化 Chromium,更轻量、自动化友好。"}];function eib(){let{machines:e}=vj(),t=ew.useMemo(()=>{let t=[],n=!1;for(let r of e)if(r.isLocal)n=!0,t.unshift({id:eix,name:"本机",online:!0,reachable:!0,isLocal:!0});else{let e="online"===r.status;t.push({id:r.id,name:r.name,online:e,reachable:r.reachable??e,isLocal:!1})}return n||t.unshift({id:eix,name:"本机",online:!0,reachable:!0,isLocal:!0}),t},[e]),[n,r]=ew.useState(eix);return ew.useEffect(()=>{t.some(e=>e.id===n)||r(t[0]?.id??eix)},[t,n]),(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":"preferences-official-extensions",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"官方扩展"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"为指定机器安装并管理官方扩展。扩展与 Agent 运行时同机部署,按机器各自安装。"})]}),(0,ey.jsxs)(md,{value:n,onValueChange:r,className:"grid gap-4",children:[(0,ey.jsx)("div",{className:"overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsx)(my,{className:"h-8 w-max min-w-full",children:t.map(e=>(0,ey.jsxs)(mb,{value:e.id,className:"gap-1.5",children:[(0,ey.jsx)(eP,{className:"size-3.5"}),(0,ey.jsx)("span",{className:"truncate",children:e.name}),(0,ey.jsx)("span",{className:(0,eI.cn)("size-1.5 rounded-full",e.online?"bg-emerald-500":"bg-muted-foreground/40"),"aria-label":e.online?"在线":"离线"})]},e.id))})}),(0,ey.jsx)(eiw,{machine:t.find(e=>e.id===n)??t[0]},n)]})]})})})}function eiw({machine:e}){var t;let n=(t=e?.id??eix)===eix?void 0:t,r=e?.reachable??!0,[a,i]=ew.useState(null),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(0),[f,h]=ew.useState(!1),m=ew.useCallback(()=>u(e=>e+1),[]);ew.useEffect(()=>{if(!r){l(!1),c(!0),i(null);return}let e=!0,t=new AbortController;async function a(){try{let r=await GP(n,{signal:t.signal});if(!e)return;i(r.extensions??[]),c(!1)}catch{if(!e)return;c(!0)}finally{e&&l(!1)}}a();let o=f?window.setInterval(a,3e3):void 0;return()=>{e=!1,t.abort(),o&&window.clearInterval(o)}},[n,r,d,f]);let p=a?.find(e=>"browser"===e.id)??(a?eij:void 0);return o?(0,ey.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,ey.jsx)(VM,{className:"size-4"}),"正在获取扩展状态…"]}):s||!a?(0,ey.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,ey.jsx)("p",{className:"text-sm text-destructive",children:"无法获取扩展状态"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:r?"请确认该机器的运行时已启动,稍后重试。":"该机器当前不可达(离线或无连接路径)。"}),r&&(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:m,children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]})})]}):p?(0,ey.jsx)(eik,{machineId:n,extension:p,onChanged:m,setPolling:h}):(0,ey.jsx)("div",{className:"rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:"该机器暂无可用的官方扩展。"})}let eij={id:"browser",name:"Vantaloom 浏览器",installed:!1,enabled:!1,running:!1,variant:"cloakbrowser",version:"",available:["cloakbrowser","chrome-for-testing"]};function eik({machineId:e,extension:t,onChanged:n,setPolling:r}){var a;let[i,o]=ew.useState(null),[l,s]=ew.useState(null),[c,d]=ew.useState(t.variant??"cloakbrowser");ew.useEffect(()=>{t.installed&&t.variant&&d(t.variant)},[t.installed,t.variant]);let u="install"===i;async function f(e,t,a=!1){o(e),s(null),a&&r(!0);try{await t(),n()}catch{s("操作失败,请稍后重试。")}finally{o(null),a&&r(!1)}}async function h(t){o("enable"),s(null),r(!0);try{await GD(e,t),n();let r=Date.now()+3e4;for(;Date.now()<r;){await new Promise(e=>setTimeout(e,1500));try{let n=(await GP(e,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(n&&n.running===t)break}catch{}}n()}catch{s(t?"启动失败,请稍后重试。":"停止失败,请稍后重试。")}finally{o(null),r(!1)}}let m="enable"===i,p=m&&!t.running||t.enabled&&!t.running,g=m&&t.running,v=t.installed?t.running?(0,ey.jsx)(Bs,{variant:"default",children:"运行中"}):p?(0,ey.jsx)(Bs,{variant:"secondary",className:"bg-amber-500/15 text-amber-600 dark:text-amber-400",children:"启动中"}):(0,ey.jsx)(Bs,{variant:"secondary",className:"bg-muted text-muted-foreground",children:"已停止"}):(0,ey.jsx)(Bs,{variant:"outline",children:"未安装"}),x=eiy.filter(e=>!t.available?.length||t.available.includes(e.id));return(0,ey.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-3",children:[(0,ey.jsx)("span",{className:"grid size-10 shrink-0 place-items-center rounded-md bg-primary/10 text-primary [&_svg]:size-5",children:(0,ey.jsx)(Ui,{})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Vantaloom 浏览器"}),v,t.installed&&t.version&&(0,ey.jsxs)("span",{className:"text-xs text-muted-foreground",children:["v",t.version]})]}),(0,ey.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"让 Agent 可操作真实浏览器:网站预览直连真实浏览器,可在指定机器上运行并远程观看 Agent 的操作过程。"})]})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"浏览器内核"}),(0,ey.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:x.map(e=>{let n=c===e.id,r=t.installed;return(0,ey.jsxs)("button",{type:"button",disabled:r||null!==i,onClick:()=>d(e.id),className:(0,eI.cn)("flex flex-col gap-1 rounded-lg border p-3 text-left transition-colors",n?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground",(r||null!==i)&&"opacity-60"),"aria-pressed":n,children:[(0,ey.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.id)})}),t.installed&&(0,ey.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["已安装的内核为 ",(a=t.variant,eiy.find(e=>e.id===a)?.label??a),",如需更换请先卸载。"]})]}),(0,ey.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:t.installed?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)(eA.Button,{size:"sm",disabled:null!==i,onClick:()=>h(!t.running),children:[m?(0,ey.jsx)(VM,{className:"size-3.5"}):t.running?(0,ey.jsx)(jD,{className:"size-3.5"}):(0,ey.jsx)(Vw,{className:"size-3.5"}),g?"停止中…":p?"启动中…":t.running?"停止浏览器":"启动浏览器"]}),(0,ey.jsxs)(eA.Button,{size:"sm",variant:"outline",disabled:null!==i,onClick:()=>f("update",()=>Gz(e),!0),children:["update"===i?(0,ey.jsx)(VM,{className:"size-3.5"}):(0,ey.jsx)(ya,{className:"size-3.5"}),"update"===i?"正在更新…":"更新"]}),(0,ey.jsxs)(eA.Button,{size:"sm",variant:"destructive",disabled:null!==i,onClick:()=>f("uninstall",()=>GT(e)),children:["uninstall"===i?(0,ey.jsx)(VM,{className:"size-3.5"}):(0,ey.jsx)(yi,{className:"size-3.5"}),"卸载"]})]}):(0,ey.jsxs)(eA.Button,{size:"sm",disabled:null!==i,onClick:()=>f("install",()=>GI(e,c),!0),children:[u?(0,ey.jsx)(VM,{className:"size-3.5"}):null,u?"正在安装…":"安装"]})}),t.installed&&(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium text-foreground",children:"在此机器上运行"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后该机器的 Agent 可使用浏览器工具;关闭则停止浏览器与边车进程。"})]}),(0,ey.jsx)(xZ,{checked:t.enabled,disabled:null!==i,onCheckedChange:e=>void h(e),"aria-label":"在此机器上运行浏览器扩展"})]}),l&&(0,ey.jsx)("p",{className:"text-xs text-destructive",children:l})]})}let eiS=(0,ek.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);function eiN(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${e} B`;let t=["KB","MB","GB","TB"],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n>=100?0:1)} ${t[r]}`}function eiC({status:e}){switch(e){case"active":return(0,ey.jsx)(Bs,{variant:"default",children:"下载中"});case"complete":return(0,ey.jsx)(Bs,{className:"border-transparent bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"已完成"});case"error":return(0,ey.jsx)(Bs,{variant:"destructive",children:"失败"});case"paused":return(0,ey.jsx)(Bs,{variant:"secondary",children:"已暂停"});case"canceled":return(0,ey.jsx)(Bs,{variant:"outline",children:"已取消"});default:return(0,ey.jsx)(Bs,{variant:"outline",children:"等待中"})}}let eiM=["complete","error","canceled"];function eiE({download:e}){let{status:t,percent:n,totalBytes:r}=e,a=Math.max(0,Math.min(100,n));return r<0&&"active"===t?(0,ey.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-y-0 w-1/3 rounded-full bg-primary/70","vtl-download-indeterminate")})}):(0,ey.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,ey.jsx)("div",{className:(0,eI.cn)("h-full rounded-full transition-all","error"===t?"bg-destructive":"complete"===t?"bg-emerald-500":"paused"===t?"bg-muted-foreground/60":"bg-primary","active"===t&&"vtl-download-stripes bg-[length:1rem_1rem]"),style:{width:`${a}%`}})})}function eiO({download:e}){var t,n,r;let a,[i,o]=ew.useState(!1),l=ew.useCallback(async e=>{o(!0);try{await e()}catch{}finally{o(!1)}},[]),{status:s}=e,c="active"===s?!Number.isFinite(t=e.speedBps)||t<=0?"":`${eiN(t)}/s`:"",d="active"===s?function(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`}(e.etaSeconds):"",u=!(e.totalBytes<0&&"active"===s),f="active"===s,h="paused"===s,m="error"===s||"canceled"===s,p="active"===s||"paused"===s||"waiting"===s,g=eiM.includes(s);return(0,ey.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.label||e.url||e.id}),(0,ey.jsx)(eiC,{status:s}),e.attempt>1&&(0,ey.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["重试 ",e.attempt]})]}),e.dest&&(0,ey.jsx)("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:e.dest})]}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[i&&(0,ey.jsx)(VM,{className:"size-3.5"}),f&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"暂停","aria-label":"暂停",onClick:()=>l(()=>mK(e.id,"pause")),children:(0,ey.jsx)(eiS,{className:"size-3.5"})}),h&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"继续","aria-label":"继续",onClick:()=>l(()=>mK(e.id,"resume")),children:(0,ey.jsx)(Vw,{className:"size-3.5"})}),m&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"重试","aria-label":"重试",onClick:()=>l(()=>mK(e.id,"retry")),children:(0,ey.jsx)(ya,{className:"size-3.5"})}),p&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"取消","aria-label":"取消",onClick:()=>l(()=>mK(e.id,"cancel")),children:(0,ey.jsx)(fg.XIcon,{className:"size-3.5"})}),g&&(0,ey.jsx)(eA.Button,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive",disabled:i,title:"移除","aria-label":"移除",onClick:()=>l(()=>mK(e.id,"remove")),children:(0,ey.jsx)(yi,{className:"size-3.5"})})]})]}),(0,ey.jsx)(eiE,{download:e}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[u&&(0,ey.jsxs)("span",{className:"tabular-nums",children:[Math.round(e.percent),"%"]}),(0,ey.jsx)("span",{className:"tabular-nums",children:(n=e.downloadedBytes,r=e.totalBytes,a=eiN(n),r<0?a:`${a} / ${eiN(r)}`)}),c&&(0,ey.jsx)("span",{className:"tabular-nums",children:c}),d&&(0,ey.jsxs)("span",{className:"tabular-nums",children:["剩余 ",d]}),e.connections>0&&(0,ey.jsxs)("span",{className:"tabular-nums",children:[e.connections," 连接"]})]}),"error"===s&&e.error&&(0,ey.jsx)("p",{className:"text-[11px] text-destructive",children:e.error})]})}function eiP(){let[e,t]=ew.useState([]),[n,r]=ew.useState("loading"),[a,i]=ew.useState(0),o=ew.useCallback(()=>{r("loading"),i(e=>e+1)},[]);return(ew.useEffect(()=>{let e,n=!1,a=new AbortController,i=e=>{n||(t(e),r("ready"))};async function o(){try{let e=await mU({signal:a.signal});if(n)return;t(e.downloads),r("ready")}catch(e){if(n||a.signal.aborted)return;if(e instanceof mH)return void r("unavailable")}try{await mW(i,{signal:a.signal}),n||l()}catch(e){if(n||a.signal.aborted)return;if(e instanceof mH)return void r("unavailable");r(e=>"ready"===e?"ready":"error"),l()}}function l(){n||(e=setTimeout(()=>{n||o()},2e3))}return o(),()=>{n=!0,a.abort(),e&&clearTimeout(e)}},[a]),"loading"===n)?(0,ey.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,ey.jsx)(VM,{className:"size-4"}),"正在获取下载状态…"]}):"unavailable"===n||"error"===n?(0,ey.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,ey.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载状态"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]})})]}):0===e.length?(0,ey.jsx)("div",{className:"rounded-lg border bg-card p-10 text-center text-sm text-muted-foreground",children:"暂无下载任务"}):(0,ey.jsx)("div",{className:"grid gap-2",children:e.map(e=>(0,ey.jsx)(eiO,{download:e},e.id))})}function eiA({label:e,description:t,value:n,min:r,max:a,onChange:i,disabled:o}){return(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-foreground",children:e}),t&&(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t}),(0,ey.jsx)(ez,{type:"number",inputMode:"numeric",min:r,max:a,value:Number.isFinite(n)?n:0,disabled:o,onChange:e=>{let t=Number(e.target.value);if(Number.isNaN(t))return;let n=t;void 0!==r&&(n=Math.max(r,n)),void 0!==a&&(n=Math.min(a,n)),i(n)},className:"max-w-[12rem]"})]})}function eiI(){let[e,t]=ew.useState(null),[n,r]=ew.useState("loading"),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState(null),[d,u]=ew.useState(0),f=ew.useCallback(()=>{r("loading"),u(e=>e+1)},[]);ew.useEffect(()=>{let e=!1,n=new AbortController;return async function(){try{let a=await mG({signal:n.signal});if(e)return;t(a),r("ready")}catch(t){if(e||n.signal.aborted)return;r(t instanceof mH?"unavailable":"error")}}(),()=>{e=!0,n.abort()}},[d]);let h=ew.useCallback((e,n)=>{t(t=>t?{...t,[e]:n}:t),l(!1)},[]),m=ew.useCallback(async()=>{if(e){i(!0),c(null),l(!1);try{let n=await mX(e);t(n),l(!0)}catch{c("保存失败,请稍后重试。")}finally{i(!1)}}},[e]);return"loading"===n?(0,ey.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,ey.jsx)(VM,{className:"size-4"}),"正在加载下载设置…"]}):"unavailable"!==n&&"error"!==n&&e?(0,ey.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-foreground",children:"下载目录"}),(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载文件的默认保存位置。"}),(0,ey.jsx)(ez,{type:"text",value:e.downloadDir,disabled:a,placeholder:"例如 D:\\\\Downloads",onChange:e=>h("downloadDir",e.target.value)})]}),(0,ey.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,ey.jsx)(eiA,{label:"最大同时下载数",description:"同时进行的任务数量上限。",value:e.maxConcurrentDownloads,min:1,max:32,disabled:a,onChange:e=>h("maxConcurrentDownloads",e)}),(0,ey.jsx)(eiA,{label:"单任务最大连接数",description:"单个任务的并发分段连接数(1–16)。",value:e.maxConnectionsPerTask,min:1,max:16,disabled:a,onChange:e=>h("maxConnectionsPerTask",e)}),(0,ey.jsx)(eiA,{label:"失败重试次数",description:"任务失败后的自动重试上限。",value:e.maxRetries,min:0,max:20,disabled:a,onChange:e=>h("maxRetries",e)})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs font-medium text-foreground",children:"代理"}),(0,ey.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载使用的代理地址,留空则不使用代理。"}),(0,ey.jsx)(ez,{type:"text",value:e.proxy,disabled:a,placeholder:"例如 http://127.0.0.1:7890(留空=不使用)",onChange:e=>h("proxy",e.target.value)})]}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium text-foreground",children:"校验文件哈希"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"下载完成后校验文件哈希以确保完整性。"})]}),(0,ey.jsx)(xZ,{checked:e.verifyChecksums,disabled:a,onCheckedChange:e=>h("verifyChecksums",e),"aria-label":"校验文件哈希"})]}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,ey.jsxs)(eA.Button,{size:"sm",disabled:a,onClick:m,children:[a?(0,ey.jsx)(VM,{className:"size-3.5"}):null,a?"正在保存…":"保存设置"]}),o&&!a&&(0,ey.jsx)("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"已保存"}),s&&(0,ey.jsx)("span",{className:"text-xs text-destructive",children:s})]})]}):(0,ey.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,ey.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载设置"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:f,children:[(0,ey.jsx)(ya,{className:"size-3.5"}),"重试"]})})]})}function eiz(){return(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":"system-downloads",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold tracking-normal",children:[(0,ey.jsx)(x1,{className:"size-4"}),"下载"]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"管理本机的下载任务,并配置下载目录、并发与代理等全局选项。"})]}),(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"下载任务"}),(0,ey.jsx)(eiP,{})]}),(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"全局设置"}),(0,ey.jsx)(eiI,{})]})]})})})}let eiT=["light","dark","jelly"],eiD={light:{label:"Light",icon:ens,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:eni,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,ey.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,ey.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,ey.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,ey.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,ey.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,ey.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function eiR(){let{resolvedTheme:e,setTheme:t}=(0,hE.useTheme)(),[n,r]=ew.useState(enk.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(enk.appearanceThemeStorageKey)??enk.defaultAppearanceTheme;r(e),(0,enk.applyAppearanceTheme)({theme:e})},[]);let a=n===enk.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=eiT.indexOf(a),o=eiT[(i+1)%eiT.length]??"light",{icon:l,label:s,className:c}=eiD[a];function d(e){r(e),window.localStorage.setItem(enk.appearanceThemeStorageKey,e),(0,enk.applyAppearanceTheme)({theme:e})}return(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,eI.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${Qz.theme}: ${s}`,title:`${Qz.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(enk.jellyAppearanceTheme);return}d(enk.defaultAppearanceTheme),t(o)},children:(0,ey.jsx)(l,{})})}let ei_=(0,ek.default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);(0,ek.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),(0,ek.default)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);let eiL=(0,ek.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),ei$=[{id:"run-ui-polish",title:"组件库视觉回归检查",machine:"Studio-PC",agent:"UI Polish",state:"running",started:"14:08",runtime:"22m",progress:68,load:54},{id:"run-runner-build",title:"Linux runner 镜像构建",machine:"Linux-runner-02",agent:"Build Agent",state:"running",started:"14:15",runtime:"15m",progress:41,load:86},{id:"run-access-audit",title:"工作组权限审阅",machine:"Studio-PC",agent:"Access Agent",state:"blocked",started:"14:21",runtime:"9m",progress:37,load:18},{id:"run-docs",title:"发布说明摘要",machine:"MacBook-build",agent:"Docs Agent",state:"queued",started:"等待",runtime:"0m",progress:0,load:0},{id:"run-cache-clean",title:"缓存清理策略验证",machine:"Linux-runner-02",agent:"Ops Sentinel",state:"failed",started:"13:54",runtime:"6m",progress:28,load:12}],eiF=[{id:"worker-studio",machine:"Studio-PC",role:"local coordinator",active:3,capacity:6,cpu:42,memory:68},{id:"worker-runner",machine:"Linux-runner-02",role:"gpu worker",active:4,capacity:5,cpu:76,memory:81},{id:"worker-mac",machine:"MacBook-build",role:"build host",active:0,capacity:3,cpu:8,memory:24}],eiB=[{id:"confirm-shell",title:"Studio-PC 请求执行发布前文件写入",meta:"UI Polish · apply_patch",tone:"normal"},{id:"confirm-service",title:"Linux-runner-02 请求重启 runner 服务",meta:"Ops Sentinel · Restart-Service",tone:"warning"},{id:"confirm-token",title:"工作组 token 加入新机器",meta:"Access Agent · admin required",tone:"normal"}],eiV=[["14:29","Studio-PC","pnpm --filter vantaloom-app lint","完成"],["14:27","Linux-runner-02","docker build agent-runtime","运行中"],["14:22","Studio-PC","apply_patch agent settings","完成"],["14:17","MacBook-build","pnpm typecheck","排队"],["14:03","Linux-runner-02","cache prune dry-run","失败"]],eiH={cpu:{label:"CPU",color:"var(--chart-1)"},memory:{label:"Memory",color:"var(--chart-3)"},network:{label:"Network",color:"var(--chart-5)"}};function eiU(e,t,n=42,r){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5",r&&"vtl-jelly-image-card",r&&r.includes("/bg")&&"vtl-jelly-image-card-shadowless"),style:r?QA({image:r,opacity:.74,blur:"8px"}):void 0,children:(0,ey.jsx)(Q6,{label:e,value:t,minSize:n})})}function eiW(e,t,n=""){return{title:e,dataSource:t,refreshRate:"10s",note:n}}let eiq={metrics:{online:2,health:88.4,latency:"38ms",events:17},machines:[{id:"studio",name:"Studio-PC",os:"Windows",status:"online",link:"direct",heartbeat:"3s",cpu:42,memory:68,disk:71,network:24},{id:"runner",name:"Linux-runner-02",os:"Linux",status:"online",link:"p2p",heartbeat:"5s",cpu:76,memory:81,disk:62,network:43},{id:"mac",name:"MacBook-build",os:"macOS",status:"sleeping",link:"direct",heartbeat:"2m",cpu:8,memory:24,disk:48,network:6}],trend:[{time:"09:00",cpu:36,memory:54,network:24},{time:"10:00",cpu:48,memory:61,network:29},{time:"11:00",cpu:44,memory:58,network:34},{time:"12:00",cpu:63,memory:72,network:41},{time:"13:00",cpu:58,memory:69,network:37},{time:"14:00",cpu:71,memory:76,network:46}],networkLinks:[["Studio-PC","Linux-runner-02","P2P","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","12ms","0.0%"],["Linux-runner-02","MacBook-build","Relay fallback","84ms","1.1%"]],events:[["14:31","Linux-runner-02 心跳延迟升高"],["14:28","Studio-PC 完成 2 个工具调用"],["14:19","MacBook-build 进入睡眠状态"],["14:12","工作组权限策略同步完成"],["14:04","P2P 链路切换到备用路径"]],serviceHealth:[{id:"local-service",name:"Local service",state:"正常",samples:[96,98,97,95,96,94,97,98,96,95,97,96]},{id:"agent-runtime",name:"Agent runtime",state:"正常",samples:[91,93,94,90,88,92,94,93,91,89,92,94]},{id:"p2p-mesh",name:"P2P mesh",state:"波动",samples:[78,82,76,73,68,71,74,79,83,80,77,72]},{id:"plugin-bridge",name:"Plugin bridge",state:"告警",samples:[88,86,84,82,79,74,63,54,48,52,67,76]}]},eiK=[{id:"metric-runs",title:"运行中",description:"当前正在执行的运行数量。",icon:(0,ey.jsx)(uP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("运行中","运行队列"),render:e=>eiU(e.title,"07",44,QM)},{id:"metric-queued",title:"排队",description:"等待调度的任务数量。",icon:(0,ey.jsx)(uy,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("排队","调度器"),render:e=>eiU(e.title,"04",44,QE)},{id:"metric-blocked",title:"待确认",description:"等待人工确认的任务数量。",icon:(0,ey.jsx)(eiL,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("待确认","确认队列"),render:e=>eiU(e.title,"03",44,QO)},{id:"metric-workers",title:"Worker",description:"当前可调度 worker 数量。",icon:(0,ey.jsx)(GE,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("Worker","Agent worker"),render:e=>eiU(e.title,"14",44,QP)},{id:"queue",title:"任务队列",description:"运行队列 Roadmap。",icon:(0,ey.jsx)(GC,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eiW("任务队列","运行队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QI,{title:e.title}),(0,ey.jsx)(etz,{items:ei$})]})},{id:"workers",title:"Agent worker",description:"各 worker 的负载和容量。",icon:(0,ey.jsx)(GE,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eiW("Agent worker","Worker 状态"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QI,{title:e.title}),(0,ey.jsx)(etD,{workers:eiF})]})},{id:"log",title:"最近执行",description:"最近执行记录 Roadmap。",icon:(0,ey.jsx)(eee,{className:"size-4"}),defaultSize:{w:7,h:4},defaultConfig:eiW("最近执行","执行日志"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QI,{title:e.title}),(0,ey.jsx)(etI,{items:eiV})]})},{id:"confirmations",title:"待确认",description:"等待人工确认的事项。",icon:(0,ey.jsx)(ee1,{className:"size-4"}),defaultSize:{w:5,h:4},defaultConfig:eiW("待确认","确认队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QI,{title:e.title}),(0,ey.jsx)(etA,{items:eiB})]})}],eiG=[{id:"metric-runs",kind:"metric-runs",x:0,y:0,w:3,h:2},{id:"metric-queued",kind:"metric-queued",x:3,y:0,w:3,h:2},{id:"metric-blocked",kind:"metric-blocked",x:6,y:0,w:3,h:2},{id:"metric-workers",kind:"metric-workers",x:9,y:0,w:3,h:2},{id:"queue",kind:"queue",x:0,y:2,w:7,h:5},{id:"workers",kind:"workers",x:7,y:2,w:5,h:5},{id:"log",kind:"log",x:0,y:7,w:7,h:4},{id:"confirmations",kind:"confirmations",x:7,y:7,w:5,h:4}];function eiX(e=eiq){return[{id:"metric-online",title:"在线机器",description:"当前在线机器数量。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("在线机器","机器心跳"),render:t=>eiU(t.title,String(e.metrics.online),44,QM)},{id:"metric-health",title:"健康度",description:"工作组整体健康度。",icon:(0,ey.jsx)(eO,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("健康度","服务遥测"),render:t=>eiU(t.title,`${e.metrics.health}%`,44,QE)},{id:"metric-latency",title:"平均延迟",description:"机器连接平均延迟。",icon:(0,ey.jsx)(eei,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("平均延迟","网络遥测"),render:t=>eiU(t.title,e.metrics.latency,44,QO)},{id:"metric-events",title:"事件",description:"最近事件数量。",icon:(0,ey.jsx)(ee1,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eiW("事件","事件流"),render:t=>eiU(t.title,String(e.metrics.events),44,QP)},{id:"machines",title:"机器健康矩阵",description:"各机器资源和心跳状态。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eiW("机器健康矩阵","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"vtl-jelly-image-card flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",style:QA({image:"/themes/jelly/card1.png",opacity:.88,blur:"10px"}),children:[(0,ey.jsx)(QI,{title:t.title}),(0,ey.jsx)(et$,{machines:e.machines})]})},{id:"trend",title:"资源趋势",description:"CPU、内存和网络趋势。",icon:(0,ey.jsx)(ei_,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eiW("资源趋势","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QI,{title:t.title}),(0,ey.jsx)(etU,{config:eiH,data:e.trend})]})},{id:"network",title:"网络连接",description:"机器之间连接状态。",icon:(0,ey.jsx)(Qb,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eiW("网络连接","网络遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QI,{title:t.title}),(0,ey.jsx)(etH,{links:e.networkLinks})]})},{id:"events",title:"事件流",description:"最近遥测事件。",icon:(0,ey.jsx)(ee1,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eiW("事件流","事件流"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(QI,{title:t.title}),(0,ey.jsx)(etL,{events:e.events})]})},{id:"services",title:"服务健康",description:"服务 30 分钟粒度健康条。",icon:(0,ey.jsx)(GE,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eiW("服务健康","服务遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(QI,{title:t.title}),(0,ey.jsx)(etW,{services:e.serviceHealth})]})}]}eiX();let eiY=[{id:"metric-online",kind:"metric-online",x:0,y:0,w:3,h:2},{id:"metric-health",kind:"metric-health",x:3,y:0,w:3,h:2},{id:"metric-latency",kind:"metric-latency",x:6,y:0,w:3,h:2},{id:"metric-events",kind:"metric-events",x:9,y:0,w:3,h:2},{id:"machines",kind:"machines",x:0,y:2,w:7,h:5},{id:"trend",kind:"trend",x:7,y:2,w:5,h:5},{id:"network",kind:"network",x:0,y:7,w:6,h:4},{id:"events",kind:"events",x:6,y:7,w:6,h:4},{id:"services",kind:"services",x:0,y:11,w:12,h:3}],eiZ={totals:{machines:4,online:2,runtime:3,tokens:7},machines:[{id:"studio",name:"Studio-PC",role:"本机",group:"Core",os:"Windows 11",runtime:"0.16.4",state:"online",tags:["admin","shell","files","scheduler"],agent:"6/8",cpu:42,memory:68,version:"Agent runtime 0.16.4",admin:"Allay"},{id:"runner",name:"Linux-runner-02",role:"GPU worker",group:"Compute",os:"Ubuntu 24.04",runtime:"0.16.3",state:"online",tags:["gpu","agent","files"],agent:"4/6",cpu:76,memory:81,version:"Agent runtime 0.16.3",admin:"Ops"},{id:"mac",name:"MacBook-build",role:"构建机",group:"Build",os:"macOS 15.4",runtime:"0.15.9",state:"sleeping",tags:["build","readonly"],agent:"0/3",cpu:8,memory:24,version:"Agent runtime 0.15.9",admin:"Allay"},{id:"observer",name:"Observer-01",role:"只读观测节点",group:"Edge",os:"Debian 13",runtime:"0.16.2",state:"warning",tags:["readonly","audit"],agent:"1/2",cpu:18,memory:36,version:"Agent runtime 0.16.2",admin:"Security"}],topology:{nodes:[{id:"studio",label:"Studio-PC",meta:"本机",x:50,y:18},{id:"runner",label:"Linux-runner-02",meta:"GPU worker",x:22,y:60},{id:"mac",label:"MacBook-build",meta:"构建机",x:76,y:58,state:"warning"},{id:"observer",label:"Observer-01",meta:"只读观测",x:50,y:82,state:"warning"}],links:[{id:"sr",from:"studio",to:"runner",kind:"p2p",label:"P2P",meta:"38ms / 0.3%"},{id:"sm",from:"studio",to:"mac",kind:"direct",label:"Direct",meta:"12ms / 0%"},{id:"ro",from:"runner",to:"observer",kind:"relay",label:"Relay",meta:"84ms / 1.1%"},{id:"mo",from:"mac",to:"observer",kind:"down",label:"Down",meta:"lost"}]},pathTotals:{direct:1,p2p:1,relay:1,broken:1},latency:[{time:"09:00",p2p:42,direct:12,relay:96},{time:"10:00",p2p:39,direct:12,relay:88},{time:"11:00",p2p:44,direct:14,relay:91},{time:"12:00",p2p:38,direct:12,relay:84},{time:"13:00",p2p:36,direct:11,relay:86},{time:"14:00",p2p:41,direct:13,relay:93}],candidates:[["Studio-PC","Linux-runner-02","P2P","symmetric NAT","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","open port 4178","12ms","0.0%"],["Linux-runner-02","Observer-01","Relay","udp blocked","84ms","1.1%"],["MacBook-build","Observer-01","Interrupted","sleep","-","-"]]};function eiJ({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){return(0,ey.jsx)(Q2,{boardId:"runtime-operations",definitions:eiK,initialLayouts:eiG,clipboardItems:e,actionLabel:"运行页面卡片操作",paletteGroupTitle:"运行页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eiQ({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let r=eig("/api/local/machines/telemetry",eip),a=ew.useMemo(()=>eiX(r),[r]);return(0,ey.jsx)(Q2,{boardId:"telemetry",definitions:a,initialLayouts:eiY,clipboardItems:e,actionLabel:"遥测页面卡片操作",paletteGroupTitle:"遥测页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function ei0({className:e,title:t="Vantaloom"}){return(0,ey.jsxs)("svg",{viewBox:"180 350 1130 260",fill:"currentColor",role:"img","aria-label":t,className:(0,eI.cn)("[[data-vtl-theme=jelly]_&]:opacity-70",e),children:[(0,ey.jsx)("path",{d:"m658 393 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,ey.jsx)("path",{d:"m1147 452h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,ey.jsx)("path",{d:"m556 449h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,ey.jsx)("path",{d:"m409 450h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,ey.jsx)("path",{d:"m918 450h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,ey.jsx)("path",{d:"m224 442h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,ey.jsx)("path",{d:"m1010 450h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,ey.jsx)("path",{d:"m848 371h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function ei1(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function ei2(e){return"u"<typeof document?null:document.querySelector(e)}function ei5(){return null!=ei2('[role="menu"]')}function ei4(){return null!=ei2('[data-tour="init-wizard"]')}function ei3(){let e=ei2('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}!function(e=eiZ){eiW("机器","机器组"),eiW("在线","机器心跳"),eiW("Runtime","Agent runtime"),eiW("Token","机器注册"),eiW("机器组","机器组"),eiW("拓扑图","网络拓扑"),eiW("直连","网络拓扑"),eiW("P2P","网络拓扑"),eiW("Relay","网络拓扑"),eiW("中断","网络拓扑"),eiW("延迟","网络遥测"),eiW("候选路径","网络候选路径")}(),eiW("日志与审计","审计事件"),eiW("筛选","审计筛选"),eiW("拒绝事件","审计事件"),eiW("事件趋势","审计事件");var ei6=e.i(64990);function ei8(){let e=sb(),[t,n]=ew.useState(!1);ew.useEffect(()=>{try{n("1"===window.localStorage.getItem("vtl:sidebar-collapsed"))}catch{}},[]);let r=ew.useCallback(()=>{n(e=>{let t=!e;try{window.localStorage.setItem("vtl:sidebar-collapsed",t?"1":"0")}catch{}return t})},[]),[a,i]=ew.useState("home"),[o,l]=ew.useState(!1),[s,c]=ew.useState(),[d,u]=ew.useState(),[f,h]=ew.useState([]),[m,p]=ew.useState([]),[g,v]=ew.useState("conversation"),[x,y]=ew.useState(0),b=s?.conversation.id,w=s?.conversation.ownerMachineId;ew.useEffect(()=>{h([]),p([]),v("conversation")},[b]),ew.useEffect(()=>{let e;if(!b||"new-agent-conversation"!==a)return void p([]);let t=!1,n=async()=>{let r=await sz(b,w);t||(p(r),e=window.setTimeout(n,!function e(t){return t.some(t=>t.running||e(t.children??[]))}(r)?6e3:2e3))};return n(),()=>{t=!0,e&&window.clearTimeout(e)}},[b,w,a]);let[j,k]=ew.useState(),[S,N]=ew.useState(!1),[C,M]=ew.useState([]),[E,O]=ew.useState([]),[P,A]=ew.useState({}),[I,z]=ew.useState(),[T,D]=ew.useState(u_),[R,_]=ew.useState([]),[L,$]=ew.useState(),[F,B]=ew.useState(),[V,H]=ew.useState(),U=ew.useRef(!1),W=ew.useCallback(e=>{D(t=>iQ(e,t))},[]),q=ew.useCallback(e=>{_(t=>iQ(e,t))},[]),K=ew.useCallback(async(e,t)=>{let n="u">typeof performance?performance.now():Date.now();console.debug(`[open] click conversation=${e} owner=${t??"local"}`),u({id:e,ownerMachineId:t}),i("new-agent-conversation");let r=()=>Math.round(("u">typeof performance?performance.now():Date.now())-n);try{let n=await sB(e,t);console.debug(`[open] detail loaded in ${r()}ms (id=${e})`),c(n),u(t=>t?.id===e?void 0:t)}catch(n){if(n instanceof sk){let r=n.openedBy?.displayName||"另一台设备";if(window.confirm(`此对话正在「${r}」上打开,无法同时操作。是否强制接管(对方将被踢出)?`)){try{let n=await sB(e,t,{force:!0});c(n)}finally{u(t=>t?.id===e?void 0:t)}return}u(t=>t?.id===e?void 0:t),s||i("home");return}console.warn(`[open] failed after ${r()}ms (id=${e})`,n),u(t=>t?.id===e?void 0:t),s||i("home")}},[s]),G=ew.useCallback(async(e,t)=>{h([]),await K(e,t)},[K]),X=ew.useCallback(()=>{c(void 0),i("new-agent-conversation")},[]),Y=ew.useCallback(async()=>{let e=await sP();e?await K(e.conversation.id,e.conversation.ownerMachineId):X()},[K,X]),Z=ew.useCallback(async()=>{U.current=!0,D(u_),_([]),i("new-canvas");try{let e=await Qu({title:"新画布",nodes:u_,edges:[]});B(e.canvas.id),H("local")}catch{B(void 0),H(void 0),U.current=!1}},[]),J=ew.useCallback(async(e,t)=>{try{await Qh(e,t);let n=await Qd(e,t);U.current=!0,D(n.nodes),_(n.edges),B(n.canvas.id),H(n.canvas.ownerMachineId),i("new-canvas")}catch{}},[]);ew.useEffect(()=>{if(!F)return;if(U.current){U.current=!1;return}let e=window.setTimeout(()=>{Qf(F,{nodes:T,edges:R,nodeIds:T.map(e=>e.id)},V).catch(()=>{})},800);return()=>window.clearTimeout(e)},[T,R,F,V]);let Q=ew.useCallback(({item:t})=>{if(!e||"new-canvas"!==t.id&&"all-canvases"!==t.id&&"open-recent-canvas"!==t.id){if("new-canvas"===t.id)return void Z();if("all-canvases"===t.id)return void i("all-canvases");if("new-agent-conversation"===t.id)return void X();if("open-recent-conversation"===t.id)return void Y();if("runs"===t.id)return void i("runs");if("telemetry"===t.id)return void i("telemetry");("preferences"===t.id||"preferences-model-routes"===t.id||"preferences-agent-config"===t.id||"preferences-subagent-config"===t.id||"preferences-cc-engine-config"===t.id||"preferences-system-prompt"===t.id||"preferences-layout"===t.id||"preferences-official-extensions"===t.id||"network-topology"===t.id||"system-downloads"===t.id||"check-update"===t.id||"account"===t.id||"balance-usage"===t.id||"feedback"===t.id)&&i(t.id)}},[Z,e,Y,X]),{start:ee}=(0,ei6.useTour)(),et=ew.useCallback(()=>{var e;ee((e={select:e=>Q({item:{id:e}}),startNewConversation:X,goHome:()=>{i("home"),c(void 0)}},{id:"product-tour",steps:[{id:"intro",centered:!0,title:"欢迎使用 Vantaloom 👋",body:(0,ey.jsxs)(ey.Fragment,{children:["这是一份手把手向导,会高亮关键位置并在需要时",(0,ey.jsx)("b",{children:"请你亲自操作"}),"(没做完不会出现「下一步」)。 全程界面都可正常点击;随时按 ",(0,ey.jsx)("kbd",{children:"Esc"})," 或右上角 ✕ 退出。"]})},{id:"theme",before:ei1(()=>e.goHome()),target:()=>ei2('[role="menu"]')??ei2('[data-tour="account-button"]'),gate:ei5,gateHint:"点击用户名按钮展开菜单",padding:6,title:"切换主题",body:(0,ey.jsxs)(ey.Fragment,{children:["点击左下角的 ",(0,ey.jsx)("b",{children:"用户名按钮"})," 打开菜单。展开后,里面的 ",(0,ey.jsx)("b",{children:"外观 / 主题"})," 项每点一次就在"," ",(0,ey.jsx)("b",{children:"浅色 → 深色 → 果冻"})," 之间循环。"]})},{id:"model-routes-add",before:ei1(()=>e.select("preferences-model-routes")),target:()=>ei2('[data-tour="model-route-form"]')??ei2('[data-tour="add-model-route"]'),gate:()=>null!=ei2('[data-tour="model-route-form"]'),gateHint:"点击「添加模型路由」",title:"配置模型渠道(1/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["进入 ",(0,ey.jsx)("b",{children:"设置 → 模型路由"}),"。请点 ",(0,ey.jsx)("b",{children:"添加模型路由"})," 新增一个第三方渠道(任何 OpenAI / Anthropic 兼容 API 都行)。"]})},{id:"model-routes-fields",before:ei1(()=>e.select("preferences-model-routes")),target:'[data-tour="model-route-form"]',waitForTarget:2500,title:"配置模型渠道(2/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["表单各项:",(0,ey.jsx)("b",{children:"提供商名称"})," 仅作标识;",(0,ey.jsx)("b",{children:"协议"})," 选 OpenAI / Anthropic 风格;",(0,ey.jsx)("b",{children:"Endpoint URL"})," 填到 ",(0,ey.jsx)("code",{children:"/v1"})," 这一级;",(0,ey.jsx)("b",{children:"API Key"})," 是密钥;",(0,ey.jsx)("b",{children:"可用模型"})," 勾选启用并可设上下文长度。",(0,ey.jsx)("br",{}),"⚠️ 填完",(0,ey.jsx)("b",{children:"务必点「保存」"}),",否则不生效。"]})},{id:"agent-config-compression",before:ei1(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-compression"]',title:"代理配置 · 压缩上下文",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 代理配置"})," 的第一块:当对话 token 接近模型上下文窗口的设定百分比时,自动用",(0,ey.jsx)("b",{children:"压缩模型"})," 压缩历史。阈值 0% 表示关闭,建议 70%-85%。"]})},{id:"agent-config-summary",before:ei1(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-summary"]',title:"代理配置 · 对话摘要",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"对话摘要"}),":开启后用",(0,ey.jsx)("b",{children:"摘要模型"}),"自动生成 / 更新对话标题与每轮的轮次标题,方便在侧边栏 与时间轴里快速辨认。"]})},{id:"agent-config-approval",before:ei1(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-approval"]',title:"代理配置 · 命令审批",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"命令审批"}),":在 Auto 权限模式下,用",(0,ey.jsx)("b",{children:"审批模型"})," + ",(0,ey.jsx)("b",{children:"审批提示词"})," 判断 Agent 发起的命令 是否自动放行。留空则非危险命令全部放行。改完记得 ",(0,ey.jsx)("b",{children:"保存"}),"。"]})},{id:"subagent-explore",before:ei1(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-explore"]',title:"子代理 · 探索",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 子代理配置"}),"。",(0,ey.jsx)("b",{children:"探索"})," 子代理擅长只读检索代码 / 资料。可单独设它的",(0,ey.jsx)("b",{children:"使用模型"}),"(留空则继承上级)与",(0,ey.jsx)("b",{children:"系统提示词"}),"。"]})},{id:"subagent-workflow",before:ei1(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-workflow"]',title:"子代理 · 工作流",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"工作流"})," 子代理负责多步骤任务编排,同样可单独配模型与提示词。"]})},{id:"subagent-operator",before:ei1(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-operator"]',title:"子代理 · 操作",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"操作"})," 子代理执行写文件 / 跑命令等动手类任务,工具集固定。"]})},{id:"subagent-custom",before:ei1(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-custom"]',title:"子代理 · 自定义",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"自定义子代理"}),":主 Agent 可自取名字、从你设的",(0,ey.jsx)("b",{children:"可用模型池"}),"里挑模型来召唤,拥有完整 工具集,还能再派发上面三种官方子代理。"]})},{id:"check-update",before:ei1(()=>e.select("check-update")),target:'[data-tour="check-update"]',title:"检查更新",body:(0,ey.jsxs)(ey.Fragment,{children:["这里查看各机器的运行时版本并 ",(0,ey.jsx)("b",{children:"立即更新"}),"。原理:从 npm 拉取最新运行时包、就地替换二进制与 前端,",(0,ey.jsx)("b",{children:"无需重装"}),";P2P mesh 未变时更新还",(0,ey.jsx)("b",{children:"不需要管理员权限"}),"。"]})},{id:"hub-account",before:ei1(()=>e.select("account")),target:'[data-tour="hub-account"]',title:"Hub 账户",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → Hub 账户"}),"。上方是你的",(0,ey.jsx)("b",{children:"账户信息"}),"与",(0,ey.jsx)("b",{children:"设备绑定"}),"状态——Hub 负责多机互联、组网 下发与云端身份。"]})},{id:"hub-account-danger",before:ei1(()=>e.select("account")),target:'[data-tour="hub-account-danger"]',title:"Hub 账户 · 危险操作",body:(0,ey.jsxs)(ey.Fragment,{children:["下方的 ",(0,ey.jsx)("b",{children:"危险操作"})," 区可",(0,ey.jsx)("b",{children:"解除设备绑定"}),"或",(0,ey.jsx)("b",{children:"退出登录"}),"。这些操作不可逆,会把本机移出 账户,请谨慎。"]})},{id:"new-conversation",before:ei1(()=>e.goHome()),target:'[data-tour="home-new-conversation"]',gate:ei4,gateHint:"点击「新建对话」继续",title:"创建新对话",body:(0,ey.jsxs)(ey.Fragment,{children:["回到主页,请点 ",(0,ey.jsx)("b",{children:"新建对话"})," 进入初始化向导(侧边栏顶部也有同样入口)。"]})},{id:"wizard-1",target:'[data-tour="init-wizard"]',placement:"left",padding:4,waitForTarget:5e3,gate:()=>!ei4()||ei3()>=2,gateHint:"配好运行环境后点向导的「下一步」",title:"向导 ① 运行环境与引擎",body:(0,ey.jsxs)(ey.Fragment,{children:["先选在",(0,ey.jsx)("b",{children:"哪台机器"}),"上运行;本机运行时还能选 ",(0,ey.jsx)("b",{children:"运行引擎"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," / ",(0,ey.jsx)("b",{children:"Claude Code"})," / ",(0,ey.jsx)("b",{children:"reclaude"}),"(Claude Code 仅限本机)。 整个向导区域已高亮,配好后点向导自己的 ",(0,ey.jsx)("b",{children:"下一步"}),"。"]})},{id:"wizard-2",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!ei4()||ei3()>=3,gateHint:"选好工作目录后点向导的「下一步」",title:"向导 ② 选择工作目录",body:(0,ey.jsxs)(ey.Fragment,{children:["先给对话",(0,ey.jsx)("b",{children:"起个名字"}),",再选 ",(0,ey.jsx)("b",{children:"工作目录"}),"——这是智能体能读写的根目录 (Claude Code 用单个目录作为工作根目录)。选好后点向导的「下一步」。"]})},{id:"wizard-3",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!ei4()||ei3()>=4,gateHint:"配好模型后点向导的「下一步」",title:"向导 ③ 模型设置",body:(0,ey.jsxs)(ey.Fragment,{children:["选择这段对话使用的",(0,ey.jsx)("b",{children:"模型"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," 用你刚配置的模型路由,",(0,ey.jsx)("b",{children:"Claude Code"})," 则由其自身提供模型。选好后点向导的「下一步」。"]})},{id:"wizard-4",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!ei4(),gateHint:"点向导的「确认开始」创建对话",title:"向导 ④ 确认开始",body:(0,ey.jsxs)(ey.Fragment,{children:["核对无误后,点向导右下角的 ",(0,ey.jsx)("b",{children:"确认开始"})," 创建对话。创建成功后会自动进入对话界面。"]})},{id:"composer-toolbar",target:'[data-slot="agent-input-composer-toolbar"]',waitForTarget:6e3,title:"输入框下方的按钮",body:(0,ey.jsxs)(ey.Fragment,{children:["输入框下面一排:",(0,ey.jsx)("b",{children:"权限模式"}),"(工具调用是否需审批)、",(0,ey.jsx)("b",{children:"模型选择"}),"、右侧 ",(0,ey.jsx)("b",{children:"发送 / 停止"}),"按钮(运行中变停止),以及 ",(0,ey.jsx)("b",{children:"上下文用量"})," 指示。"]})},{id:"queue-stack",target:'[data-slot="agent-input-composer-textarea"]',waitForTarget:3e3,title:"待发送栈(Tab 键)",body:(0,ey.jsxs)(ey.Fragment,{children:["输入内容后按 ",(0,ey.jsx)("kbd",{children:"Tab"})," 可把它压入",(0,ey.jsx)("b",{children:"待发送栈"}),"而不立即发送,便于排队多条指令。栈里每条都能 点击:用 ",(0,ey.jsx)("b",{children:"引导"})," 在合适时机插入对话,或删除。"]})},{id:"pane-toolbar",target:'[data-tour="pane-toolbar"]',waitForTarget:3e3,title:"工作区顶栏",body:(0,ey.jsxs)(ey.Fragment,{children:["右侧工作区最上面一排:左边 ",(0,ey.jsx)("b",{children:"布局标签"})," 切换分屏预设,中间 ",(0,ey.jsx)("b",{children:"位置切换"})," 控制对话面板在左 / 居中 / 在右。"]})},{id:"pane-split",target:'[aria-label="上下二分"]',waitForTarget:4e3,gate:()=>null!=ei2('[aria-label="上下二分"][data-state="active"]'),gateHint:"点「上下二分」分栏",title:"动手 · 上下分栏",body:(0,ey.jsxs)(ey.Fragment,{children:["在布局标签里点 ",(0,ey.jsx)("b",{children:"上下二分"}),"(顶部面板图标),把右侧工作区分成上下两块。"]})},{id:"pane-add-top",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=ei2('[placeholder="搜索组件..."]')||null!=ei2('[data-slot="multi-tab-list"]'),gateHint:"点上面板的「添加」",autoAdvance:!0,title:"动手 · 添加上面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["点",(0,ey.jsx)("b",{children:"上面板"}),"中间的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,打开组件选择面板。"]})},{id:"pane-pick-multitab",target:'[data-tour="pane-template-multi-tab-system"]',waitForTarget:3e3,gate:()=>null!=ei2('[data-slot="multi-tab-list"]'),gateHint:"选择「多标签页系统」",title:"动手 · 选多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["在弹出面板里找到 ",(0,ey.jsx)("b",{children:"多标签页系统"}),"(即多文件标签组件)并点击添加,它会填入上面板。"]})},{id:"multi-tab",target:'[data-slot="multi-tab-list"]',waitForTarget:3e3,title:"多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["顶部是",(0,ey.jsx)("b",{children:"多文件标签条"}),":点 ",(0,ey.jsx)("b",{children:"+"})," 新增标签、点标签切换文件、",(0,ey.jsx)("b",{children:"×"})," 关闭。单文件内还能在",(0,ey.jsx)("b",{children:"查看 / 编辑"})," 与 ",(0,ey.jsx)("b",{children:"代码 / 预览 / 十六进制"})," 间切换,编辑后记得保存。"]})},{id:"pane-add-bottom",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=ei2('[placeholder="搜索组件..."]')||null!=ei2('[data-slot="terminal-tab-group"]'),gateHint:"点下面板的「添加」",autoAdvance:!0,title:"动手 · 添加下面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["现在点",(0,ey.jsx)("b",{children:"下面板"}),"的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,再次打开组件选择面板。"]})},{id:"pane-pick-terminal",target:'[data-tour="pane-template-terminal-tab-group"]',waitForTarget:3e3,gate:()=>null!=ei2('[data-slot="terminal-tab-group"]'),gateHint:"选择「终端标签组」",title:"动手 · 选终端",body:(0,ey.jsxs)(ey.Fragment,{children:["在面板里找到 ",(0,ey.jsx)("b",{children:"终端标签组"})," 并点击添加,它会填入下面板。"]})},{id:"terminal",target:'[data-slot="terminal-tab-group"]',waitForTarget:3e3,title:"终端组件",body:(0,ey.jsxs)(ey.Fragment,{children:["终端支持多会话标签:点 ",(0,ey.jsx)("b",{children:"+"})," 新开会话、点标签切换、",(0,ey.jsx)("b",{children:"×"})," 关闭。直接输入命令即可,输出实时回显,与本机真实 shell 一致。"]})},{id:"pane-cut-clear",target:'[aria-label="剪切窗口内容"]',waitForTarget:3e3,title:"剪切与粉碎",body:(0,ey.jsxs)(ey.Fragment,{children:["顶栏的 ",(0,ey.jsx)("b",{children:"剪切"}),"(剪刀)把窗口内容移动到别处;",(0,ey.jsx)("b",{children:"粉碎"}),"(碎纸机)清空该窗口。均对单个 pane 生效。"]})},{id:"control-room",target:'[data-tour="control-room-toggle"]',waitForTarget:3e3,title:"导播台视角",body:(0,ey.jsxs)(ey.Fragment,{children:["点位置切换中间的 ",(0,ey.jsx)("b",{children:"「隐藏面板」"}),"(矩形图标)进入",(0,ey.jsx)("b",{children:"导播台"}),":对话偏左,右侧悬浮显示主 Agent 与各子 Agent 的实时预览小窗,点小窗即可切换主面板。"]})},{id:"outro",centered:!0,title:"完成 🎉",body:(0,ey.jsxs)(ey.Fragment,{children:["你已走过核心功能。随时可从空白页的 ",(0,ey.jsx)("b",{children:"使用教程"})," 重新打开本向导。开始创造吧!"]})}]}))},[Q,X,ee]),en=ew.useCallback(()=>{i("account")},[]),er=d?.id??s?.conversation.id,ea=!!d&&s?.conversation.id!==d.id;return(0,ey.jsxs)("main",{className:"vtl-app-background relative flex h-svh overflow-hidden text-foreground select-none [-webkit-touch-callout:none]",children:[e?(0,ey.jsx)(ery,{navItems:erj,contents:erk,activeWorkspace:a,activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:m,activeSubagentPath:f,onOpenSubagent:e=>h(e),title:"new-agent-conversation"===a&&s?s.conversation.title?.trim()||"新 Agent 对话":Qz.product,trailing:"new-agent-conversation"===a&&s?(0,ey.jsx)(jj,{view:g,onViewChange:v,paneCount:x}):(0,ey.jsx)(eiR,{})}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:(0,eI.cn)("relative hidden h-svh shrink-0 overflow-hidden p-3 transition-[width,padding] duration-300 ease-out md:block",t?"w-0 p-0":"w-[19.5rem]"),children:(0,ey.jsx)(enN,{navItems:erj,contents:erk,activeWorkspace:a,activeConversationId:er,activeCanvasId:F,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenCanvas:(e,t)=>{J(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:m,activeSubagentPath:f,onOpenSubagent:e=>h(e)})}),(0,ey.jsx)("div",{className:(0,eI.cn)("group/sb-handle absolute inset-y-0 z-30 hidden w-8 md:block","transition-[left] duration-300 ease-out",t?"left-0":"left-[18.5rem]"),children:(0,ey.jsx)("button",{type:"button",onClick:r,"aria-label":t?"展开侧边栏":"收起侧边栏",title:t?"展开侧边栏":"收起侧边栏",className:"absolute top-1/2 left-0 flex h-14 w-6 -translate-y-1/2 items-center justify-center rounded-r-md border border-l-0 border-border bg-background/85 text-muted-foreground opacity-0 shadow-md backdrop-blur transition-opacity duration-200 hover:text-foreground focus-visible:opacity-100 group-hover/sb-handle:opacity-100",children:t?(0,ey.jsx)(tu,{className:"size-4"}):(0,ey.jsx)(td,{className:"size-4"})})})]}),(0,ey.jsxs)("section",{className:(0,eI.cn)("relative h-full min-w-0 flex-1 overflow-hidden",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:["runs"===a?(0,ey.jsx)(eiJ,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"telemetry"===a?(0,ey.jsx)(eiQ,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"preferences-model-routes"===a?(0,ey.jsx)(ea3,{section:"model-routes"}):"preferences-agent-config"===a?(0,ey.jsx)(ea3,{section:"agent-config"}):"preferences-subagent-config"===a?(0,ey.jsx)(ea3,{section:"subagent-config"}):"preferences-cc-engine-config"===a?(0,ey.jsx)(ea3,{section:"cc-engine-config"}):"preferences-system-prompt"===a?(0,ey.jsx)(ea3,{section:"system-prompt"}):"preferences-layout"===a?(0,ey.jsx)(ea3,{section:"layout"}):"preferences-official-extensions"===a?(0,ey.jsx)(eib,{}):"network-topology"===a?(0,ey.jsx)(eiv,{}):"system-downloads"===a?(0,ey.jsx)(eiz,{}):"preferences"===a?(0,ey.jsx)(ea3,{}):"check-update"===a?(0,ey.jsx)(ea9,{}):"balance-usage"===a?(0,ey.jsx)(eir,{}):"feedback"===a?(0,ey.jsx)(eid,{}):"account"===a?(0,ey.jsx)(erE,{}):e||"new-canvas"!==a?e||"all-canvases"!==a?"new-agent-conversation"===a&&ea?(0,ey.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-6 animate-spin"}),(0,ey.jsx)("span",{className:"text-sm",children:"正在打开对话…"})]}):"new-agent-conversation"===a?(0,ey.jsx)(J8,{conversation:s,clipboardItems:C,clipboardDraggingId:I,onClipboardItemsChange:M,onClipboardDraggingChange:z,onOverlayOpenChange:l,onConversationCreated:e=>{c(e)},onCancelDraft:()=>i("home"),subagentStack:f,onSubagentStackChange:h,subagentTree:m,mobileView:g,onMobilePaneCountChange:y}):e?(0,ey.jsx)(ei9,{activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{k(t=>t?.id===e?void 0:t)}}):(0,ey.jsx)(ei7,{onNewConversation:X,onStartTour:et}):(0,ey.jsx)(et1,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):(0,ey.jsx)(et7,{nodes:T,edges:R,selectedNodeId:L,clipboardItems:C,onNodesChange:W,onEdgesChange:q,onNodesSet:D,onEdgesSet:_,onSelectedNodeChange:$,onClipboardItemsChange:M}),j?(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-0 z-30",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:(0,ey.jsx)(Ql,{conversationId:j.id,ownerMachineId:j.owner,open:!0,onOpenChange:e=>{e||k(void 0)},onEnterConversation:(e,t)=>{G(e,t)}})}):null,(0,ey.jsx)(ent,{hidden:!!j||("new-agent-conversation"===a?o:S),items:C,trashItems:E,draggingId:I,onDraggingChange:z,onItemsChange:M,onTrashItemsChange:O,onTrashClipboardItemsChange:A,trashClipboardItems:P})]})]})}function ei7({onNewConversation:e,onStartTour:t}){return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,ey.jsx)(ei0,{className:"h-20 w-auto max-w-[78vw] text-foreground"}),(0,ey.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"从左侧选择一个会话,或新建对话"}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,ey.jsxs)(eA.Button,{type:"button",onClick:e,"data-tour":"home-new-conversation",children:[(0,ey.jsx)(tc,{className:"size-4"}),"新建对话"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",onClick:t,children:[(0,ey.jsx)(ts,{className:"size-4"}),"使用教程"]})]})]})}function ei9({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a}){return(0,ey.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:(0,ey.jsx)(enP,{activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a})})}function eoe(){let{ready:e,user:t,logout:n}=tl();return e?t?(0,ey.jsx)(ei8,{}):(0,ey.jsx)(ta,{onComplete:()=>{window.location.reload()}}):(0,ey.jsx)("main",{className:"grid min-h-svh place-items-center bg-background",children:(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,ey.jsx)("div",{className:"size-8 animate-spin rounded-full border-2 border-muted-foreground/20 border-t-primary"}),(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接中..."})]})})}function eot(){return(0,ey.jsx)(to,{children:(0,ey.jsx)(eoe,{})})}e.s(["default",()=>eot],66204)}]);
|