@kw-yeh/vibeflow 4.0.4 → 4.0.5

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.
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/5576c1267923e491.css" as="style"/><link rel="stylesheet" href="/_next/static/css/5576c1267923e491.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8aa5df0425f6b7b.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-fde992b12936b886.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/zygbxZW3DHGve5whWS7yR/_buildManifest.js" defer=""></script><script src="/_next/static/zygbxZW3DHGve5whWS7yR/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"zygbxZW3DHGve5whWS7yR","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/5576c1267923e491.css" as="style"/><link rel="stylesheet" href="/_next/static/css/5576c1267923e491.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8aa5df0425f6b7b.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-fde992b12936b886.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/jWK_7LAWT3o0Q0pMgqN9g/_buildManifest.js" defer=""></script><script src="/_next/static/jWK_7LAWT3o0Q0pMgqN9g/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"jWK_7LAWT3o0Q0pMgqN9g","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
package/dist/web/404.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/5576c1267923e491.css" as="style"/><link rel="stylesheet" href="/_next/static/css/5576c1267923e491.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8aa5df0425f6b7b.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-fde992b12936b886.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/zygbxZW3DHGve5whWS7yR/_buildManifest.js" defer=""></script><script src="/_next/static/zygbxZW3DHGve5whWS7yR/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"zygbxZW3DHGve5whWS7yR","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/5576c1267923e491.css" as="style"/><link rel="stylesheet" href="/_next/static/css/5576c1267923e491.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8aa5df0425f6b7b.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-fde992b12936b886.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/jWK_7LAWT3o0Q0pMgqN9g/_buildManifest.js" defer=""></script><script src="/_next/static/jWK_7LAWT3o0Q0pMgqN9g/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"jWK_7LAWT3o0Q0pMgqN9g","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -0,0 +1,11 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9845],{2908:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>sI});var n=s(26514),r=s(75834),a=s(24322),i=s.n(a),l=s(18690),o=s(80527),c=s(67297),d=s(5026),u=s(29334),m=s(71520),x=s(44416),f=s(58629),h=s(17329),p=s(70170),g=s(87854),b=s(78999),j=s(85781),v=s(38031),N=s(74567);let y="text-xs font-semibold uppercase tracking-wider text-muted-foreground";var k=s(4416);let w={default:"text-muted-foreground hover:bg-accent hover:text-foreground",primary:"text-muted-foreground hover:bg-accent hover:text-primary",danger:"text-muted-foreground hover:bg-destructive/15 hover:text-destructive"},C=r.forwardRef(({className:e,children:t,tone:s="default",type:r="button",...a},i)=>(0,n.jsx)("button",{ref:i,type:r,className:(0,k.cn)("inline-flex shrink-0 items-center justify-center rounded-full p-1.5 transition-colors outline-none active:scale-95 motion-reduce:transform-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 disabled:active:scale-100 [&_svg]:pointer-events-none",w[s],e),...a,children:t}));C.displayName="IconButton";let A=["backlog","in_progress","done"],S={backlog:"Backlog",in_progress:"In Progress",done:"Done"},z={backlog:"bg-muted-foreground/60",in_progress:"bg-warning animate-pulse",done:"bg-success"};function E(e){if(e.projectName)return e.projectName;let t=(e.projectPath??"").split(/[/\\]/).filter(Boolean);return t[t.length-1]??"未指定專案"}function I(e,t){let s=(0,r.useRef)(null);return(0,r.useEffect)(()=>{if(!e)return;let n=e=>{s.current?.contains(e.target)||t()},r=e=>{"Escape"===e.key&&t()};return window.addEventListener("mousedown",n),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",r)}},[e,t]),s}let P="flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors motion-reduce:transition-none";function T({task:e,anchor:t,onEdit:s,onDelete:a,onClose:i}){let[l,o]=(0,r.useState)(!1),c=I(!0,i),d=Math.max(8,Math.min(t.right-208,window.innerWidth-208-8)),u=Math.max(8,Math.min(t.top,window.innerHeight-224));return(0,n.jsxs)("div",{ref:c,role:"menu",style:{top:u,left:d},onClick:e=>e.stopPropagation(),className:"fixed z-50 w-52 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:[(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{s(),i()},className:(0,k.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",P,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)(m.A,{className:"size-3.5 shrink-0"}),"編輯任務"]}),l?(0,n.jsxs)("div",{className:"flex items-center gap-1 rounded-sm bg-destructive/10 p-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>o(!1),className:"rounded-sm px-2 py-1 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:()=>{a(),i()},className:"ml-auto rounded-sm px-2 py-1 text-sm font-medium text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"確認刪除"})]}):(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>o(!0),className:(0,k.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",P,"text-destructive hover:bg-destructive/15"),title:`刪除任務「${e.title}」(清理 worktree)`,children:[(0,n.jsx)(x.A,{className:"size-3.5 shrink-0"}),"刪除任務"]})]})}function R({task:e,column:t,subAgentCount:s,selected:a,onSelect:i,onEdit:l,onDelete:o}){let c=(0,r.useRef)(null),[d,u]=(0,r.useState)(null),m=null!==d,x="done"===t;return(0,n.jsxs)("div",{ref:c,role:"button",tabIndex:0,"aria-label":`開啟任務:${e.title}`,onClick:i,onKeyDown:e=>{e.target!==e.currentTarget||("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},className:(0,k.cn)("relative cursor-pointer rounded-md border bg-card p-3 outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",x&&"bg-card/60",a?"border-primary shadow-[0_0_0_2px] shadow-primary/20":"border-border hover:border-input"),children:[(0,n.jsxs)("div",{className:"group/head flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(f.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:E(e)}),x?(0,n.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-xs bg-primary/15 px-1.5 py-0.5 font-medium text-primary",children:[(0,n.jsx)(h.A,{className:"size-2.5"}),"complete"]}):(0,n.jsxs)(n.Fragment,{children:[e.effort&&(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 font-medium",m?"hidden":"group-hover/head:hidden"),children:e.effort}),(0,n.jsx)(C,{"aria-label":`任務選項:${e.title}`,title:"移動、編輯或刪除",onClick:e=>{if(e.stopPropagation(),m)return void u(null);let t=c.current?.getBoundingClientRect();t&&u({top:t.top+32,right:t.right-4})},className:(0,k.cn)("size-5 p-0.5",m?"flex":"hidden group-hover/head:flex"),children:(0,n.jsx)(p.A,{className:"size-3.5"})})]})]}),(0,n.jsx)("div",{className:"mt-2",title:e.title,children:(0,n.jsx)("span",{className:(0,k.cn)("line-clamp-2 text-[15px] font-medium leading-[1.4]",x?"text-muted-foreground":"text-foreground"),children:e.title})}),(0,n.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.branch}),"in_progress"===t&&s>0&&(0,n.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,n.jsx)(b.A,{className:"size-3"}),s]})]}),d&&(0,n.jsx)(T,{task:e,anchor:d,onEdit:l,onDelete:o,onClose:()=>u(null)})]})}function $({projects:e,value:t,onChange:s}){let[a,i]=(0,r.useState)(!1),l=I(a,()=>i(!1));return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("button",{type:"button","aria-haspopup":"menu","aria-expanded":a,onClick:()=>i(e=>!e),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium text-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(f.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),t??"所有專案",(0,n.jsx)(j.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),a&&(0,n.jsx)("div",{ref:l,role:"menu",className:"absolute left-0 top-8 z-20 w-56 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:[null,...e].map(e=>(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{s(e),i(!1)},className:(0,k.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",P,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e??"所有專案"}),e===t&&(0,n.jsx)(v.A,{className:"size-3 shrink-0"})]},e??"__all__"))})]})}function B({board:e,subAgents:t,selectedTaskId:s,onSelectTask:a,onEditTask:i,onDeleteTask:l,onNewTask:o}){let[c,d]=(0,r.useState)(null),u=[...e.backlog,...e.in_progress,...e.done],m=Array.from(new Set(u.map(E))).sort((e,t)=>e.localeCompare(t)),x=c&&m.includes(c)?c:null,f=u.length;return(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,n.jsx)($,{projects:m,value:x,onChange:d}),(0,n.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[f," 個任務 \xb7 ",m.length," 個專案"]})]}),(0,n.jsx)("div",{className:"grid min-h-0 flex-1 grid-cols-3 gap-4 overflow-hidden px-5 pb-4 pt-3",children:A.map(r=>{let c=x?e[r].filter(e=>E(e)===x):e[r];return(0,n.jsxs)("section",{className:"flex min-h-0 flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 px-1",children:[(0,n.jsx)("span",{className:(0,k.cn)("size-1.5 shrink-0 rounded-full",z[r])}),(0,n.jsx)("h2",{className:(0,k.cn)(y,"in_progress"===r&&"text-warning"),children:S[r]}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:c.length})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto rounded-md p-1",children:[c.map(e=>(0,n.jsx)(R,{task:e,column:r,subAgentCount:(t[e.id]??[]).length,selected:e.id===s,onSelect:()=>a(e.id),onEdit:()=>i(e.id),onDelete:()=>l(e.id)},e.id)),"backlog"===r&&(0,n.jsxs)("button",{type:"button",onClick:o,className:"flex w-full items-center justify-center gap-1.5 rounded-md px-3 py-2.5 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(N.A,{className:"size-3.5"}),"新增任務"]}),0===c.length&&"backlog"!==r&&(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/60",children:"尚無任務"})]})]},r)})})]})}var D=s(78141),_=s(26392),M=s(85320),L=s(37055);let F=(0,r.lazy)(()=>Promise.all([s.e(7045),s.e(7915)]).then(s.bind(s,37915)));function G({source:e,compact:t=!1,className:s}){return(0,n.jsx)("div",{className:(0,k.cn)("prose max-w-none break-words rounded-md bg-muted/30 p-3 text-muted-foreground",t?"prose-xs":"prose-sm",s),children:(0,n.jsx)(r.Suspense,{fallback:null,children:(0,n.jsx)(F,{source:e,compact:t})})})}var O=s(72975),H=s(41487);let Y=0,V={micro:.12,standard:.16,spatial:.18},K={enter:[.2,0,0,1],exit:[.4,0,1,1]};function U(e,t,s,n=V[e]){return{duration:t?.01:n,ease:K[s]}}function W({timing:e,enterDuration:t,initialOpacity:s=0,transform:n,reducedMotion:r}){return{hidden:{opacity:s,...r?{}:n??{}},visible:{opacity:1,...r?{}:{...n?.x===void 0?{}:{x:0},...n?.y===void 0?{}:{y:0},...n?.scale===void 0?{}:{scale:1}},transition:U(e,r,"enter",t)}}}function X({timing:e,enterDuration:t,initialOpacity:s,exitTiming:n="micro",exitDuration:r,transform:a,exitTransform:i=a,reducedMotion:l}){return{...W({timing:e,enterDuration:t,initialOpacity:s,transform:a,reducedMotion:l}),exit:{opacity:0,...l?{}:i??{},transition:U(n,l,"exit",r)}}}function q({title:e,children:t,description:s,footer:a,showHeader:i=!1,className:l,contentClassName:o,bodyClassName:u,saving:m=!1,motionVariant:x="dialog",onClose:f}){let h=(0,r.useId)(),p=(0,r.useId)(),g=(0,r.useRef)(null),b=(0,r.useRef)("u">typeof document&&document.activeElement instanceof HTMLElement?document.activeElement:null),j=(0,r.useRef)(f),v=(0,r.useRef)(m),N=(0,H.tF)(),y=(0,c.I)()??!1,w=i||void 0!==s||void 0!==a||void 0!==u,A="drawer"===x,S=X({timing:"micro",enterDuration:.14,reducedMotion:y}),z=X({timing:A?"spatial":"standard",exitTiming:"micro",exitDuration:A?.14:void 0,transform:A?{x:16}:{scale:.98},reducedMotion:y});return(0,r.useEffect)(()=>{j.current=f,v.current=m},[f,m]),(0,r.useEffect)(()=>{let e;return Y+=1,e=!1,()=>{e||(e=!0,Y-=1)}},[]),(0,r.useEffect)(()=>{if(!N)return;g.current?.focus();let e=e=>{if("Escape"!==e.key||v.current)return;let t=document.querySelectorAll('[role="dialog"][aria-modal="true"]');t[t.length-1]===g.current&&j.current()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e),b.current?.focus()}},[N]),(0,n.jsxs)(d.PY1.div,{initial:"hidden",animate:"visible",exit:"exit",inert:!N,"aria-hidden":!N||void 0,"data-dialog-state":N?"present":"exiting",className:(0,k.cn)("fixed inset-0 z-50 flex items-center justify-center p-4",!N&&"pointer-events-none",l),children:[(0,n.jsx)(d.PY1.div,{variants:S,className:"absolute inset-0 bg-background/80",onClick:m||!N?void 0:f}),(0,n.jsx)(d.PY1.div,{variants:z,ref:g,role:N?"dialog":void 0,"aria-modal":N?"true":void 0,"aria-labelledby":N?h:void 0,"aria-describedby":N&&s?p:void 0,tabIndex:-1,className:(0,k.cn)("relative z-10 w-full rounded-lg border bg-card text-card-foreground shadow-lg outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",w&&"flex max-h-[min(90vh,760px)] flex-col overflow-hidden",o),children:w?(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsxs)("div",{className:"flex shrink-0 items-start justify-between gap-4 border-b border-border/70 px-5 py-4",children:[(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("h2",{id:h,className:"truncate text-lg font-semibold tracking-tight",children:e}),s&&(0,n.jsx)("div",{id:p,className:"text-sm leading-5 text-muted-foreground",children:s})]}),(0,n.jsx)(C,{"aria-label":`關閉${e}`,onClick:f,disabled:m,className:"mt-0.5 shrink-0 p-1",children:(0,n.jsx)(O.A,{className:"size-4"})})]}),!i&&(0,n.jsx)("h2",{id:h,className:"sr-only",children:e}),(0,n.jsx)("div",{className:(0,k.cn)("min-h-0 flex-1 overflow-y-auto px-5 py-4",u),children:t}),a&&(0,n.jsx)("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/70 bg-muted/20 px-5 py-3",children:a})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{id:h,className:"sr-only",children:e}),t]})})]})}let J={running:{label:"執行中",icon:D.A,tone:"text-warning",spin:!0},completed:{label:"已完成",icon:_.A,tone:"text-primary"},error:{label:"失敗",icon:u.A,tone:"text-destructive"}};function Q({text:e}){let[t,s]=(0,r.useState)(!1);return(0,n.jsxs)("button",{type:"button",onClick:()=>{"u">typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{s(!0),window.setTimeout(()=>s(!1),1500)})},title:"複製",className:"inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(M.A,{className:"size-3"}),t?"已複製":"複製"]})}function Z({label:e,text:t,defaultOpen:s,markdown:a=!1}){let[i,l]=(0,r.useState)(!!s),o=(0,r.useId)();return(0,n.jsxs)("div",{className:"rounded-md border border-border/40 bg-muted/30",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-2 py-1",children:[(0,n.jsxs)("button",{type:"button","aria-expanded":i,"aria-controls":o,onClick:()=>l(e=>!e),className:"inline-flex items-center gap-1 rounded-sm text-xs font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[i?(0,n.jsx)(j.A,{className:"size-3"}):(0,n.jsx)(L.A,{className:"size-3"}),e]}),i&&(0,n.jsx)(Q,{text:t})]}),i&&(a?(0,n.jsx)("div",{id:o,className:"border-t border-border/40",children:(0,n.jsx)(G,{source:t,compact:!0,className:"max-h-60 overflow-auto bg-transparent px-2.5 py-2 text-foreground/90"})}):(0,n.jsx)("pre",{id:o,className:"max-h-60 overflow-auto whitespace-pre-wrap break-words border-t border-border/40 px-2.5 py-2 text-xs leading-relaxed text-foreground/90",children:t}))]})}function ee({run:e,index:t}){let s=J[e.status],r=s.icon,a=0===t||"running"===e.status;return(0,n.jsxs)("li",{className:"rounded-lg border border-border/40 bg-card p-3 text-card-foreground",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,n.jsx)(r,{className:(0,k.cn)("size-4 shrink-0",s.tone,s.spin&&"animate-spin")}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 truncate text-base font-medium",children:[e.subagentType||"子代理",e.description?(0,n.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground",children:["\xb7 ",e.description]}):null]}),(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 text-xs font-medium",s.tone),children:s.label})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(Z,{label:"Prompt",text:e.prompt,defaultOpen:a}),"running"!==e.status&&null!=e.result&&(0,n.jsx)(Z,{label:"結果",text:e.result,markdown:!0})]})]})}function et({open:e,taskId:t,taskTitle:s,runs:r,onClose:a}){return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(q,{title:"子代理",description:s,onClose:a,showHeader:!0,motionVariant:"drawer",className:"justify-end p-0",contentClassName:"flex h-full max-h-none max-w-md flex-col rounded-none border-l",bodyClassName:"p-4",children:0===r.length?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-center text-base text-muted-foreground",children:"這個任務尚未衍生任何子代理"}):(0,n.jsx)("ul",{className:"space-y-3",children:r.map((e,t)=>(0,n.jsx)(ee,{run:e,index:t},e.id))})},`sub-agent-drawer-${t}`)})}var es=s(54903),en=s(19897),er=s(72752),ea=s(55985),ei=s(98201),el=s(55713),eo=s(41336),ec=s(50405),ed=s(6510),eu=s(1445),em=s(37763),ex=s(15344);let ef=(0,s(24779).F)("inline-flex items-center justify-center gap-2 whitespace-nowrap text-base font-medium transition-colors active:scale-95 motion-reduce:transform-none disabled:pointer-events-none disabled:opacity-50 disabled:active:scale-100 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",{variants:{variant:{default:"rounded-full bg-primary text-primary-foreground hover:bg-primary/90",destructive:"rounded-full bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"rounded-lg border bg-background hover:bg-accent hover:text-accent-foreground",secondary:"rounded-lg bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"rounded-lg hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),eh=r.forwardRef(({className:e,variant:t,size:s,...r},a)=>(0,n.jsx)("button",{ref:a,className:(0,k.cn)(ef({variant:t,size:s,className:e})),...r}));function ep(e){return new Promise((t,s)=>{let n=new FileReader;n.onload=()=>{if("string"!=typeof n.result)return void s(Error(`無法讀取附件:${e.name}`));let r=n.result.indexOf(",");r<0?s(Error(`無法解析附件:${e.name}`)):t({name:e.name,mime:e.type||"application/octet-stream",dataBase64:n.result.slice(r+1)})},n.onerror=()=>s(n.error??Error(`無法讀取附件:${e.name}`)),n.readAsDataURL(e)})}function eg(e){return Promise.all(Array.from(e).map(ep))}function eb(){return window.vibeflow??null}async function ej(){let e=eb();return e?e.getState():null}async function ev(e){let t=eb();t&&await t.setBoard(e)}async function eN(e){let t=eb();return t?t.setSettings(e):null}async function ey(e,t){let s=eb();return s?s.connectAgent(e,t):null}async function ek(e){let t=eb();return t?t.refreshAgentModels(e):null}async function ew(){let e=eb();return e?e.getGithubAuthStatus():null}async function eC(){let e=eb();e&&await e.startGithubAuthLogin()}async function eA(){let e=eb();e&&await e.cancelGithubAuthLogin()}async function eS(){let e=eb();return e?e.logoutGithubAuth():null}function ez(e){return window.prompt(e)?.trim()||null}async function eE(){return eb()?ez("輸入專案資料夾的絕對路徑"):null}async function eI(e){let t=eb();return t?t.getGitInfo(e):null}async function eP(){let e=eb();return e?e.listRecentProjects():[]}async function eT(e){let t=eb();return t?t.initRepository(e):null}async function eR(){let e=eb();return e?e.detectAgents():[]}async function e$(e){let t=eb();return t?t.createTask(e):null}async function eB(e){let t=eb();return t?t.updateTask(e):null}async function eD(e){let t=eb();return t?t.resetTaskRun(e):null}async function e_(e){let t=eb();return t?t.getDiff(e):[]}async function eM(e,t){let s=eb();return s?s.getDiffEntries(e,t):[]}async function eL(e,t){let s=eb();return s?s.getDiffFile(e,t):null}async function eF(e){let t=eb();return t?t.listArtifacts(e):[]}async function eG(e,t){let s=eb();return s?s.readArtifact(e,t):null}async function eO(e){let t=eb();return t?t.openArtifactsDir(e):"bridge unavailable"}async function eH(e){let t=eb();return t?t.getDecisions(e):null}async function eY(e){return eb()?ez("skill"===e?"輸入 skill 目錄的絕對路徑(需含 SKILL.md)":`輸入 ${e} 檔案的絕對路徑`):null}async function eV(){let e=eb();return e?e.listLibrary():[]}async function eK(e,t){let s=eb();return s?s.importLibraryEntry({kind:e,sourcePath:t}):null}async function eU(e,t,s,n){let r=eb();return r?r.createLibraryEntry({kind:e,name:t,content:s,description:n}):null}async function eW(e,t){let s=eb();return s?s.readLibraryEntry({kind:e,name:t}):null}async function eX(e,t,s){let n=eb();return n?n.updateLibraryEntry({kind:e,name:t,content:s}):null}async function eq(e,t,s){let n=eb();return!!n&&n.setLibraryEntryEnabled({kind:e,name:t,enabled:s})}async function eJ(e,t){let s=eb();return!!s&&s.deleteLibraryEntry({kind:e,name:t})}async function eQ(e){let t=eb();t&&await t.openExternal(e)}async function eZ(e){let t=eb();return t?t.cleanupTask(e):null}async function e0(e){let t=eb();return t?t.deleteTask(e):null}async function e1(e){let t=eb();return t?t.attachments.write(e):[]}async function e5(e){let t=eb();return t?t.term.start(e):null}function e2(e,t){eb()?.term.input(e,t)}async function e3(e){await eb()?.term.scrollToBottom(e)}async function e4(e){let t=eb();return!!t&&t.term.sessionExists(e)}eh.displayName="Button";var e6=s(9036),e8=s(7640),e7=s(62607);function e9({taskId:e,sessionKey:t,cwd:a,launchCommand:i,launchNonce:l=0,readOnly:o=!1,onReturnToBacklog:c,onLaunchAgent:d,onInteract:u}){let m=t??e,x=(0,r.useRef)(null),f=(0,r.useRef)(null),h=(0,r.useRef)(0),[p,g]=(0,r.useState)(!1),[b,j]=(0,r.useState)(!1),[v,N]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[C,A]=(0,r.useState)(!1),[S,z]=(0,r.useState)(!1),E=(0,r.useRef)(!1),I=(0,r.useRef)(-1),P=(0,r.useRef)(!1),T=(0,r.useRef)(i),R=(0,r.useRef)(l);T.current=i,R.current=l;let $=(0,r.useRef)(a);$.current=a;let B=(0,r.useRef)(o),D=(0,r.useRef)(u);D.current=u;let _=(0,r.useCallback)(t=>{let s=$.current,n=f.current;s&&(E.current=!1,P.current=!0,e5({taskId:e,sessionKey:m,launch:t,cols:n?.cols,rows:n?.rows}).then(()=>{E.current=!0,f.current?.focus()}))},[e,m]),M=(0,r.useCallback)(()=>{let t=$.current,s=f.current;t&&s&&null!==eb()&&!B.current&&(E.current=!1,P.current=!1,e5({taskId:e,sessionKey:m,cols:s.cols,rows:s.rows}).then(()=>{E.current=!0,s.focus()}))},[e,m]),L=(0,r.useCallback)(async()=>{let e=f.current;if(e&&c&&!B.current){D.current?.(),N(!0);try{if(!await c())return;e.reset(),e.clear(),M(),e.focus()}catch(s){let t=s instanceof Error?s.message:String(s);e.writeln(`\r
2
+ ⚠️ 退回 Backlog 失敗:${t}`)}finally{N(!1)}}},[c,M]),F=(0,r.useCallback)(async()=>{let e=f.current;if(e&&d&&!B.current){D.current?.(),w(!0),e.reset(),e.clear();try{await d(),e.focus()}catch(s){let t=s instanceof Error?s.message:String(s);e.writeln(`\r
3
+ ⚠️ 啟動 Agent 失敗:${t}`)}finally{w(!1)}}},[d]),G=(0,r.useCallback)(()=>{if(!E.current||B.current)return;let e=T.current;if(!e)return;let t=R.current;I.current!==t&&(I.current=t,_(e))},[_]);(0,r.useEffect)(()=>{B.current=o,f.current&&(f.current.options.disableStdin=o)},[o]),(0,r.useEffect)(()=>{let t,n,r,a,i,l,o=!1;return E.current=!1,(async()=>{let{Terminal:c}=await s.e(3779).then(s.bind(s,15167)),{FitAddon:d}=await s.e(5695).then(s.bind(s,95695));if(o||!x.current)return;let u=new c({fontSize:12,fontFamily:'Menlo, Monaco, "Courier New", monospace',cursorBlink:!0,disableStdin:B.current,theme:{background:"#191919",foreground:"#e6e6e6",cursor:"#4c9bf5",cursorAccent:"#191919",selectionBackground:"rgba(76, 155, 245, 0.30)",selectionForeground:"#ededed",black:"#3b3b3b",red:"#f0716a",green:"#4ec98a",yellow:"#e2b341",blue:"#4c9bf5",magenta:"#c58af9",cyan:"#4dd0e1",white:"#c8c8c8",brightBlack:"#6e6e6e",brightRed:"#ff8b84",brightGreen:"#6bdfa3",brightYellow:"#f2c862",brightBlue:"#7db8ff",brightMagenta:"#d7a6ff",brightCyan:"#72e0ee",brightWhite:"#ffffff"}}),h=new d;u.loadAddon(h),u.open(x.current);let p=()=>{h.fit();let e=u.element?.querySelector(".xterm-screen"),t=u.element?.querySelector(".xterm-viewport");if(!e||!t)return;let s=function(e,t,s){if(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(s)||e<=2||t<=0||s<=0||t<=s)return e;let n=Math.ceil((t-s)/(t/e));return Math.max(2,e-n)}(u.cols,e.getBoundingClientRect().width,t.clientWidth);s!==u.cols&&u.resize(s,u.rows)};if(f.current=u,await document.fonts.ready,await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o||f.current!==u)return;p();let g=window.vibeflow;if(!g)return u.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");if(B.current)return u.writeln("ℹ️ 任務已完成 — 終端為唯讀,僅供查閱訊息。");if(!$.current)return u.writeln("⚠️ 尚未設定工作目錄,請先選擇專案或建立任務。");let b=B.current?null:T.current;b&&(I.current=R.current),P.current=!!b;let{scrollback:j}=await g.term.start({taskId:e,sessionKey:m,launch:b??void 0,cols:u.cols,rows:u.rows});j&&u.write(j),t=g.term.onData(({sessionKey:e,data:t})=>{e===m&&u.write(t)}),n=g.term.onExit(({sessionKey:e,exitCode:t,intentional:s})=>{if(e!==m||s)return;let n=P.current;if(P.current=!1,!n){E.current=!1,u.writeln(`\r
4
+ ℹ️ 終端已結束(exit code: ${t})`);return}0===t?u.writeln("\r\n✅ Agent 執行完成。"):u.writeln(`\r
5
+ ⚠️ 連線中斷或異常結束(exit code: ${t})`),u.writeln("\r\nℹ️ 已切回互動終端,可手動輸入命令。"),M()}),u.attachCustomKeyEventHandler(e=>"Enter"!==e.key||!e.shiftKey||!!e.altKey||!!e.ctrlKey||!!e.metaKey||!!e.isComposing||!!B.current||(e.preventDefault(),e.stopPropagation(),"keydown"===e.type&&(D.current?.(),g.term.input(m,"\x1b\r")),!1)),u.onData(e=>{B.current||(D.current?.(),g.term.input(m,e),v())}),u.onScroll(()=>{let e=u.buffer.active;A(e.viewportY<e.baseY)});let v=()=>{clearTimeout(i),i=setTimeout(()=>{g.term.isScrolledBack(m).then(e=>{o||f.current!==u||z(e)})},150)},N=x.current;N?.addEventListener("wheel",v,{capture:!0,passive:!0}),l=()=>N?.removeEventListener("wheel",v,{capture:!0}),r=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{if(!o&&f.current===u)try{let{cols:e,rows:t}=u;if(p(),u.cols===e&&u.rows===t)return;g.term.resize(m,u.cols,u.rows)}catch{}},100)}),x.current&&r.observe(x.current),E.current=!0,G()})(),()=>{o=!0,E.current=!1,t?.(),n?.(),r?.disconnect(),clearTimeout(a),clearTimeout(i),l?.(),eb()?.term.kill(m),f.current?.dispose(),f.current=null}},[e,m,G,M]),(0,r.useEffect)(()=>{G()},[i,l,G]);let O=async t=>{if(!B.current&&E.current&&0!==t.length){D.current?.(),j(!0);try{let s=await eg(t),n=await e1({taskId:e,attachments:s});if(n.length>0){let e=n.map(({path:e})=>`'${e.replace(/'/g,"'\\''")}'`).join(" ");e2(m,`${e} `)}}catch(t){let e=t instanceof Error?t.message:String(t);f.current?.writeln(`\r
6
+ ⚠️ 附加檔案失敗:${e}`)}finally{j(!1)}}},H=async()=>{f.current?.scrollToBottom(),A(!1),await e3(m),z(!1),f.current?.focus()};return(0,n.jsxs)("div",{onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!o&&E.current&&(h.current+=1,g(!0)))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect=o||!E.current?"none":"copy")},onDragLeave:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!o&&E.current&&(h.current=Math.max(0,h.current-1),0===h.current&&g(!1)))},onDrop:e=>{e.preventDefault(),h.current=0,g(!1),!o&&E.current&&O(e.dataTransfer.files)},className:(0,k.cn)("flex min-h-36 w-full flex-1 flex-col overflow-hidden rounded-md border border-border bg-card transition-colors",p&&"border-primary bg-primary/5"),children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-muted/50 px-2 py-1",children:[(0,n.jsx)("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:a??"(no cwd)"}),b?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs text-muted-foreground",children:"附加檔案中…"}):o?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs uppercase tracking-wide text-muted-foreground",children:"唯讀"}):(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[c&&(0,n.jsxs)(eh,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void L(),disabled:!a||v||y,title:"捨棄這次執行的程式碼變更、artifacts 與決策紀錄並退回 Backlog,之後按「開始」才會重新啟動 Agent",children:[(0,n.jsx)(e6.A,{className:(0,k.cn)("size-3",v&&"animate-pulse")}),v?"退回中…":"退回 Backlog"]}),d&&(0,n.jsxs)(eh,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void F(),disabled:!a||y||v,title:"只帶入 Agent 設定與 Artifact 資訊,不傳入任務內容",children:[(0,n.jsx)(e8.A,{className:(0,k.cn)("size-3",y&&"animate-pulse")}),y?"啟動中…":"啟動 Agent"]})]})]}),(0,n.jsxs)("div",{className:"relative min-h-0 w-full flex-1 overflow-hidden bg-background p-1",children:[(0,n.jsx)("div",{ref:x,className:"h-full w-full overflow-hidden"}),(C||S)&&(0,n.jsxs)(eh,{variant:"secondary",size:"sm",className:"absolute bottom-3 right-5 h-7 px-2 text-xs shadow-md",onClick:()=>void H(),children:[(0,n.jsx)(e7.A,{className:"size-3"}),"回到最新"]})]})]})}var te=s(18921),tt=s(79608);let ts={scale:1,x:0,y:0};function tn(e,t,s){return Math.min(s,Math.max(t,e))}function tr({src:e,alt:t,className:s}){let a=(0,r.useRef)(null),i=(0,r.useRef)(null),l=(0,r.useRef)(null),[o,c]=(0,r.useState)(ts),[d,u]=(0,r.useState)(!1),m=(0,r.useCallback)((e,t,s)=>{let n=a.current,r=i.current;if(!n||!r)return{x:e,y:t};let l=Math.max(0,(r.offsetWidth*s-n.clientWidth)/2),o=Math.max(0,(r.offsetHeight*s-n.clientHeight)/2);return{x:tn(e,-l,l),y:tn(t,-o,o)}},[]),x=(0,r.useCallback)((e,t=0,s=0)=>{c(n=>{let r=tn(e(n.scale),1,6);return r===n.scale?n:{scale:r,...m(t-(t-n.x)*r/n.scale,s-(s-n.y)*r/n.scale,r)}})},[m]);(0,r.useEffect)(()=>{c(ts)},[e]),(0,r.useEffect)(()=>{let e=a.current;if(!e)return;let t=t=>{t.preventDefault();let s=e.getBoundingClientRect();x(e=>e*Math.exp(-(.0015*t.deltaY)),t.clientX-s.left-s.width/2,t.clientY-s.top-s.height/2)};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[x]),(0,r.useEffect)(()=>{let e=()=>c(e=>({...e,...m(e.x,e.y,e.scale)}));return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[m]);let f=o.scale>1,h=e=>{l.current?.pointerId===e.pointerId&&(l.current=null,u(!1))};return(0,n.jsxs)("div",{className:(0,k.cn)("space-y-3",s),children:[(0,n.jsx)("div",{ref:a,onPointerDown:e=>{f&&0===e.button&&(e.currentTarget.setPointerCapture(e.pointerId),l.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,originX:o.x,originY:o.y},u(!0))},onPointerMove:e=>{let t=l.current;if(!t||t.pointerId!==e.pointerId)return;let s=t.originX+(e.clientX-t.startX),n=t.originY+(e.clientY-t.startY);c(e=>({...e,...m(s,n,e.scale)}))},onPointerUp:h,onPointerCancel:h,className:(0,k.cn)("flex h-[min(60vh,520px)] touch-none select-none items-center justify-center overflow-hidden rounded-md bg-muted/20",f&&(d?"cursor-grabbing":"cursor-grab")),children:(0,n.jsx)("img",{ref:i,src:e,alt:t,draggable:!1,className:"max-h-full max-w-full object-contain",style:{transform:`translate(${o.x}px, ${o.y}px) scale(${o.scale})`}})}),(0,n.jsxs)("div",{className:"flex items-center gap-3 px-1",children:[(0,n.jsx)(te.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("input",{type:"range",min:1,max:6,step:.05,value:o.scale,onChange:e=>{let t=Number(e.target.value);x(()=>t)},"aria-label":"縮放圖片",className:"h-4 min-w-0 flex-1 cursor-pointer accent-primary outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"}),(0,n.jsx)(tt.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,n.jsx)("p",{className:"px-1 text-xs text-muted-foreground",children:"滑桿或滾輪縮放,放大後可拖曳圖片平移。"})]})}function ta(e,t){return e.path===t.path&&e.status===t.status&&e.additions===t.additions&&e.deletions===t.deletions&&e.revision===t.revision}let ti=(0,r.lazy)(()=>s.e(1201).then(s.bind(s,31201)).then(e=>({default:e.default}))),tl={task:"任務",decisions:"決策",artifacts:"Artifacts",diff:"Git diff"},to=["task","decisions","artifacts","diff"],tc=["task","decisions"],td=["task"],tu={A:"新增",M:"修改",D:"刪除",R:"更名","?":"未追蹤"},tm={image:"截圖",video:"影片",text:"文字",binary:"二進位"},tx="vibeflow:workspace-aside-px",tf="--vf-workspace-aside",th=!1;function tp(){if(th)return;th=!0;let e=Number(window.localStorage.getItem(tx));Number.isFinite(e)&&e>=336&&document.documentElement.style.setProperty(tf,`${e}px`)}function tg(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function tb(e){return("image"===e.kind||"video"===e.kind)&&!e.scratch}function tj({title:e,icon:t,children:s,actions:r,count:a,heading:i}){return(0,n.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col border-b border-border last:border-b-0",children:[(0,n.jsxs)("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[i??(0,n.jsxs)("h2",{className:(0,k.cn)(y,"flex min-w-0 items-center gap-2"),children:[t,(0,n.jsx)("span",{className:"truncate",children:e}),void 0!==a&&a>0&&(0,n.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/80",children:a})]}),r]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:s})]})}let tv={MERGED:"bg-primary/15 text-primary",OPEN:"bg-success/15 text-success",CLOSED:"bg-destructive/15 text-destructive"};function tN({outcome:e}){let[t,s]=(0,r.useState)(!1),{pr:a,commits:i,files:l}=e;return(0,n.jsxs)("div",{className:"space-y-4",children:[a&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,k.cn)(y,"flex items-center gap-1.5"),children:[(0,n.jsx)(es.A,{className:"size-3.5"}),"Pull Request"]}),(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5 text-sm",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 rounded-xs px-1.5 py-0.5 text-xs font-medium",tv[a.state]??"bg-secondary text-secondary-foreground"),children:a.state}),(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words text-foreground",children:a.title})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void eQ(a.url),className:"flex items-center gap-1.5 rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(en.A,{className:"size-3"}),"#",a.number]}),a.body&&(0,n.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:t?"收合說明":"展開說明"})]}),a.body&&t&&(0,n.jsx)(G,{source:a.body,compact:!0,className:"bg-transparent p-0"})]})]}),i.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,k.cn)(y,"flex items-center gap-1.5"),children:[(0,n.jsx)(er.A,{className:"size-3.5"}),"Commits",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:i.length})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:i.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("code",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.sha}),(0,n.jsx)("span",{className:"min-w-0 break-words",children:e.subject})]},e.sha))})]}),l.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,k.cn)(y,"flex items-center gap-1.5"),children:[(0,n.jsx)(ea.A,{className:"size-3.5"}),"變更檔案",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:l.length}),(0,n.jsxs)("span",{className:"ml-auto font-normal tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:l.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]},e.path))}),e.truncated&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["只列出前 ",l.length," 個檔案。"]})]})]})}function ty({task:e,column:t,subAgents:s,onOpenSubAgents:r}){return(0,n.jsxs)("div",{className:"space-y-4 text-base",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:"in_progress"===t?"In Progress":"done"===t?"Done":"Backlog"})}),(0,n.jsx)("h3",{className:"break-words text-lg font-semibold tracking-tight text-foreground",children:e.title})]}),(0,n.jsxs)("div",{className:"space-y-1.5 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:[e.projectName&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(f.A,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:e.projectName})]}),(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(g.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 break-all",children:e.branch})]}),e.baseBranch&&(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(ei.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:["base: ",e.baseBranch]})]})]}),e.description&&(0,n.jsx)(G,{source:e.description}),e.outcome&&(0,n.jsx)(tN,{outcome:e.outcome}),s.length>0&&(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.id),className:"flex w-full items-center justify-between rounded-md border border-border/70 px-2.5 py-2 text-left text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsxs)("span",{children:[s.length," sub-agent runs"]}),(0,n.jsx)("span",{children:"View"})]})]})}function tk({taskId:e,live:t}){let[s,a]=(0,r.useState)(void 0);return((0,r.useEffect)(()=>{let s,n=!0;a(void 0);let r=!1,i=async()=>{if(r&&Y>0){n&&t&&(s=setTimeout(()=>void i(),3e3));return}r=!0;try{let t=await eH(e);n&&a(t)}catch{n&&a(null)}finally{n&&t&&(s=setTimeout(()=>void i(),3e3))}};return i(),()=>{n=!1,s&&clearTimeout(s)}},[e,t]),void 0===s)?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取決策書中…"]}):s?.markdown?.trim()?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(G,{source:s.markdown,className:"bg-transparent p-0"}),s.truncated&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"內容過長,僅顯示前段。"}),null!=s.updatedAt&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:["更新於 ",new Date(s.updatedAt).toLocaleString()]})]}):(0,n.jsxs)("div",{className:"space-y-2 py-10 text-center",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"此任務還沒有記錄任何決策。"}),s?.path&&(0,n.jsxs)("p",{className:"break-all px-4 text-xs text-muted-foreground/70",children:["agent 會寫入 ",s.path]})]})}function tw({taskId:e,artifact:t}){let[s,a]=(0,r.useState)(null),[i,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let s=!0;return a(null),l(!1),eG(e,t.name).then(e=>{s&&a(e?.dataUrl??null)}).catch(()=>{s&&a(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]);let o="video"===t.kind;return!s||i?(0,n.jsx)("div",{className:"flex h-24 items-center justify-center rounded-md border border-border/70 bg-card",children:o?(0,n.jsx)(el.A,{className:"size-5 text-muted-foreground"}):(0,n.jsx)(eo.A,{className:"size-5 text-muted-foreground"})}):o?(0,n.jsxs)("div",{className:"relative h-24 w-full overflow-hidden rounded-md border border-border/70 bg-card",children:[(0,n.jsx)("video",{src:s,muted:!0,playsInline:!0,preload:"metadata",onError:()=>l(!0),className:"h-full w-full object-contain"}),(0,n.jsx)("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,n.jsx)("span",{className:"flex size-7 items-center justify-center rounded-full bg-background/80 ring-1 ring-border/70",children:(0,n.jsx)(ec.A,{className:"size-3.5 fill-current text-foreground"})})})]}):(0,n.jsx)("img",{src:s,alt:t.name,className:"h-24 w-full rounded-md border border-border/70 bg-card object-contain"})}function tC({taskId:e,artifact:t,onClose:s}){var a;let[i,l]=(0,r.useState)(void 0),[o,c]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=!0;return l(void 0),c(!1),eG(e,t.name).then(e=>{s&&l(e)}).catch(()=>{s&&l(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]),(0,n.jsx)(q,{title:t.name,description:`${tm[t.kind]} \xb7 ${tg(t.size)}${t.scratch?" \xb7 工作暫存":""}`,onClose:s,showHeader:!0,contentClassName:"max-w-5xl",bodyClassName:"p-4",children:void 0===i?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取中…"]}):null===i?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案,可能已被刪除。"}):"image"===i.kind&&i.dataUrl?(0,n.jsx)(tr,{src:i.dataUrl,alt:t.name}):"video"===i.kind&&i.dataUrl?o?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"這個影片的編碼無法在 app 內播放。用 Artifacts 分頁的「開啟資料夾」以系統播放器開啟。"}):(0,n.jsx)("video",{src:i.dataUrl,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,onError:()=>c(!0),className:"max-h-[70vh] w-full rounded-md bg-black"}):"binary"===i.kind?(0,n.jsxs)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:["無法內嵌預覽的檔案(",tg(t.size),")。用 Artifacts 分頁的「開啟資料夾」以系統播放器或編輯器開啟。"]}):(0,n.jsxs)(n.Fragment,{children:[(a=t.name,/\.(md|markdown|mdx)$/i.test(a))?(0,n.jsx)(G,{source:i.text??""}):(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded-md bg-muted/30 p-3 font-mono text-xs",children:i.text}),i.truncated&&(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"內容過長,僅顯示開頭 256 KB。"})]})})}function tA({taskId:e,artifacts:t,artifactsDir:s}){let[a,i]=(0,r.useState)(null),[o,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)("idle"),[m,x]=(0,r.useState)(null),f=t.filter(tb),h=t.filter(e=>!tb(e)),p=(0,r.useCallback)(()=>{x(null),eO(e).then(e=>x(e||null)).catch(()=>x("開啟失敗"))},[e]),g=(0,r.useCallback)(()=>{s&&navigator.clipboard.writeText(s).then(()=>{u("copied"),window.setTimeout(()=>u("idle"),1600)}).catch(()=>u("error"))},[s]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-3 space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Artifact 資料夾"}),(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("code",{className:"min-w-0 flex-1 select-all break-all rounded-xs bg-background px-2 py-1.5 font-mono text-xs text-foreground",title:s??"尚無可用路徑",children:s??"尚無可用路徑"}),(0,n.jsxs)(eh,{variant:"outline",size:"sm",onClick:g,disabled:!s,title:"複製 Artifact 資料夾路徑",className:"shrink-0 text-xs",children:["copied"===d?(0,n.jsx)(v.A,{className:"size-3.5"}):(0,n.jsx)(M.A,{className:"size-3.5"}),"copied"===d?"已複製":"error"===d?"複製失敗":"複製路徑"]})]})]}),(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-end gap-2",children:[m&&(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:m,children:m}),(0,n.jsxs)(eh,{variant:"outline",size:"sm",onClick:p,title:s??"任務的 artifacts 目錄",className:"text-xs",children:[(0,n.jsx)(ed.A,{className:"size-3.5"}),"開啟資料夾"]})]}),0===t.length?(0,n.jsxs)("div",{className:"space-y-2 py-8 text-center",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"還沒有暫存產物。"}),(0,n.jsxs)("p",{className:"text-xs leading-5 text-muted-foreground/80",children:["Agent 會把驗證截圖、錄影與報告寫進上方資料夾,工作暫存放其下的 ",(0,n.jsx)("code",{className:"rounded-xs bg-muted/40 px-1 py-0.5 font-mono",children:"scratch/"}),",完成任務時會一併清除。"]})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[f.length>0?(0,n.jsx)("ul",{className:"grid grid-cols-2 gap-2",children:f.map(t=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(t),title:t.name,className:"w-full rounded-md border border-border/70 bg-muted/20 p-2 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(tw,{taskId:e,artifact:t}),(0,n.jsxs)("div",{className:"mt-1.5 flex items-baseline gap-1.5",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.name}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:tg(t.size)})]})]})},t.name))}):(0,n.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"還沒有驗證截圖或錄影。"}),h.length>0&&(0,n.jsxs)("div",{className:"rounded-md border border-border/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>c(e=>!e),"aria-expanded":o,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(L.A,{className:(0,k.cn)("size-3.5 shrink-0 transition-transform motion-reduce:transition-none",o&&"rotate-90")}),"其他 ",h.length," 個檔案(報告、script、log)"]}),o&&(0,n.jsx)("ul",{className:"border-t border-border/70",children:h.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e),title:e.name,className:"flex w-full items-center gap-2 px-2 py-1 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:["image"===e.kind?(0,n.jsx)(eo.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):"video"===e.kind?(0,n.jsx)(el.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,n.jsx)(eu.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:e.name}),(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/80",children:[function(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return"剛剛";if(t<60)return`${t} 分前`;let s=Math.floor(t/60);return s<24?`${s} 小時前`:`${Math.floor(s/24)} 天前`}(e.modifiedAt)," \xb7 ",tg(e.size)]})]})},e.name))})]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(tC,{taskId:e,artifact:a,onClose:()=>i(null)},`artifact-${e}-${a.name}`)})]})}let tS=(0,r.memo)(function({file:e,showHeader:t=!0}){return(0,n.jsxs)("div",{className:(0,k.cn)("overflow-hidden",t&&"rounded-md border border-border/70"),children:[t&&(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/70 bg-muted/30 px-2 py-1.5",children:[(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:tu[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),e.truncated&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:"已截斷"})]}),(0,n.jsx)("div",{className:"min-w-0 max-w-full overflow-x-auto text-xs [&_.diff-content]:whitespace-pre-wrap [&_.diff-content]:break-words [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_table]:min-w-full [&_table]:table-fixed [&_td]:min-w-0 [&_td]:align-top",children:(0,n.jsx)(r.Suspense,{fallback:null,children:(0,n.jsx)(ti,{oldValue:e.oldValue,newValue:e.newValue,splitView:!1,useDarkTheme:!0,compareMethod:"diffLines",renderContent:e=>(0,n.jsx)("span",{className:"block min-w-0 max-w-full whitespace-pre-wrap break-words",children:e}),styles:{variables:{dark:{diffViewerBackground:"var(--card)",diffViewerColor:"var(--card-foreground)",addedBackground:"rgba(78, 201, 138, 0.15)",addedColor:"var(--foreground)",removedBackground:"rgba(229, 72, 77, 0.15)",removedColor:"var(--foreground)",wordAddedBackground:"rgba(78, 201, 138, 0.32)",wordRemovedBackground:"rgba(229, 72, 77, 0.32)",addedGutterBackground:"rgba(78, 201, 138, 0.20)",removedGutterBackground:"rgba(229, 72, 77, 0.20)",gutterBackground:"var(--muted)",gutterBackgroundDark:"var(--muted)",gutterColor:"var(--muted-foreground)",addedGutterColor:"var(--foreground)",removedGutterColor:"var(--foreground)",highlightBackground:"rgba(76, 155, 245, 0.15)",highlightGutterBackground:"rgba(76, 155, 245, 0.20)",codeFoldGutterBackground:"var(--muted)",codeFoldBackground:"var(--secondary)",codeFoldContentColor:"var(--muted-foreground)",emptyLineBackground:"var(--card)"}},diffContainer:{width:"100%",maxWidth:"100%",overflowX:"visible"},line:{width:"100%"},content:{width:"100%",maxWidth:"100%",overflowX:"visible"},contentText:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},lineContent:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},gutter:{maxWidth:"2.5rem",minWidth:"2.5rem",width:"2.5rem",paddingLeft:"0.25rem",paddingRight:"0.25rem",whiteSpace:"nowrap"}}})})})]})});function tz({entry:e,file:t,onClose:s}){return(0,n.jsx)(q,{title:e.path,description:(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:tu[e.status]??e.status}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"font-mono tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),t?.truncated&&(0,n.jsx)("span",{children:"\xb7 已截斷"})]}),onClose:s,showHeader:!0,contentClassName:"max-w-6xl",bodyClassName:"p-4",children:void 0===t?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取內容中…"]}):null===t?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案的內容。"}):(0,n.jsx)(tS,{file:t,showHeader:!1})})}function tE({diff:e}){return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(C,{"aria-label":"重新整理 Git diff",title:"重新整理(含 fetch origin)",className:"p-1",disabled:e.loading,onClick:e.manualRefresh,children:(0,n.jsx)(em.A,{className:(0,k.cn)("size-3.5",e.loading&&"animate-spin")})}),e.entries.length>0&&(0,n.jsx)(C,{"aria-label":"放大檢視 Git diff",title:"放大檢視(全部展開)",className:"p-1",onClick:e.expand,children:(0,n.jsx)(ex.A,{className:"size-3.5"})})]})}function tI({taskId:e,diff:t}){let{entries:s,contents:r,selectedEntry:a,setSelectedPath:i,loading:o,error:c,expanded:d,fullFiles:u,closeExpanded:m}=t;return(0,n.jsxs)(n.Fragment,{children:[o&&0===s.length?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取 diff 中…"]}):c?(0,n.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:c}):0===s.length?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"與基準分支相比沒有變更。"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.path),title:`檢視 ${e.path} 的 diff`,className:"flex w-full items-center gap-2 rounded-md border border-border/70 bg-muted/30 px-2 py-1.5 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:"shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:tu[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),(0,n.jsx)(L.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]})},e.path))}),s.length>=80&&(0,n.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["變更檔案超過 ",80," 個,僅顯示前 ",80," 個。"]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(tz,{entry:a,file:a.path in r?r[a.path]:void 0,onClose:()=>i(null)},`diff-${e}-${a.path}`)}),d&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex bg-background/95 text-foreground",children:(0,n.jsxs)("div",{className:"flex min-h-0 w-full flex-col",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border px-5",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Git diff"}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[s.length," changed ",1===s.length?"file":"files"]})]}),(0,n.jsx)(C,{"aria-label":"關閉 diff 放大檢視",title:"關閉",onClick:m,children:(0,n.jsx)(O.A,{className:"size-4"})})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-6xl space-y-4",children:null===u?(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取全部 diff 內容中…"]}):u.map(e=>(0,n.jsx)(tS,{file:e},e.path))})})]})})]})}function tP({task:e,column:t,subAgents:s,launch:a,onStart:i,onReturnToBacklog:l,onLaunchAgent:o,onComplete:c,onEdit:d,onDelete:u,onOpenSubAgents:f,onInteract:h}){let[p,b]=(0,r.useState)("task"),[j,N]=(0,r.useState)(!1),[y,w]=(0,r.useState)([]),A=(0,r.useId)(),S=`${A}-panel`,z=e=>`${A}-tab-${e}`,E=e.worktreePath??e.projectPath??null,I=function(e,t){let s,n;if(!e||!t)return null;let r=t.replace(/\\/g,"/"),a=(n=(s=e.replace(/\\/g,"/").replace(/\/+$/,"")).lastIndexOf("/"))>=0?s.slice(n+1):s;return`${r}/${a}.artifacts`}(e.worktreePath,e.workspacePath),P=function(e,t){let[s,n]=(0,r.useState)([]),[a,i]=(0,r.useState)({}),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[x,f]=(0,r.useState)(0),[h,p]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),j=(0,r.useRef)(new Map),v=(0,r.useCallback)(e=>{let t=new Set(e.map(e=>e.path));for(let e of j.current.keys())t.has(e)||j.current.delete(e);n(t=>(function(e,t){if(e.length!==t.length)return t;let s=!1,n=t.map((t,n)=>{let r=e[n];return ta(r,t)?r:(s=!0,t)});return s?n:e})(t,e)),i(t=>{let s;return s=new Set(e.map(e=>e.path)),Object.keys(t).every(e=>s.has(e))?t:Object.fromEntries(Object.entries(t).filter(([e])=>s.has(e)))})},[]),N=s.find(e=>e.path===l)??null;(0,r.useEffect)(()=>{if(!N)return;let t=N.path,s=j.current.get(t);if(t in a&&s&&ta(s,N))return;let n=!0;return eL(e,t).then(e=>{n&&(j.current.set(t,N),i(s=>{var n;return(n=s[t])===e||n&&e&&n.path===e.path&&n.status===e.status&&n.additions===e.additions&&n.deletions===e.deletions&&n.oldValue===e.oldValue&&n.newValue===e.newValue&&n.truncated===e.truncated?s:{...s,[t]:e}}))}).catch(()=>{n&&(j.current.set(t,N),i(e=>null===e[t]?e:{...e,[t]:null}))}),()=>{n=!1}},[e,N,a]),(0,r.useEffect)(()=>{let s;if(!t)return;let n=!0,r=!1,a=async t=>{if(r&&Y>0){n&&(s=setTimeout(()=>void a(!1),3e3));return}r=!0;try{let s=await eM(e,{fetch:t});if(!n)return;v(s),m(null)}catch(e){n&&m(e instanceof Error?e.message:String(e))}finally{n&&(d(!1),s=setTimeout(()=>void a(!1),3e3))}};return d(!0),a(!0),()=>{n=!1,s&&clearTimeout(s)}},[e,t,x,v]),(0,r.useEffect)(()=>{l&&!s.some(e=>e.path===l)&&o(null)},[s,l]),(0,r.useEffect)(()=>{if(!h)return;let t=!0;return e_(e).then(e=>{t&&b(e)}).catch(e=>{t&&m(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[h,e]);let y=(0,r.useCallback)(()=>{p(!1),b(null)},[]);return{entries:s,contents:a,selectedEntry:N,setSelectedPath:o,loading:c,error:u,expanded:h,fullFiles:g,expand:(0,r.useCallback)(()=>p(!0),[]),closeExpanded:y,manualRefresh:(0,r.useCallback)(()=>{i({}),j.current.clear(),f(e=>e+1)},[])}}(e.id,"in_progress"===t),T=y.filter(tb).length;(0,r.useEffect)(()=>{let s;if("in_progress"!==t)return void w([]);let n=!0,r=!1,a=async()=>{if(r&&Y>0){n&&(s=setTimeout(()=>void a(),3e3));return}r=!0;try{let t=await eF(e.id);n&&w(t)}catch{}finally{n&&(s=setTimeout(()=>void a(),3e3))}};return a(),()=>{n=!1,s&&clearTimeout(s)}},[e.id,t]),(0,r.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"!==e.key||document.querySelector('[role="dialog"][aria-modal="true"]')||N(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]);let R="backlog"===t,$=a?.launch,B=a?.nonce??0,D="done"===t?tc:"backlog"===t?td:to,_=D.includes(p)?p:D[0],M=(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視",className:"flex min-w-0 rounded-md border border-border/70 p-0.5",children:D.map(e=>{let t="artifacts"===e?T:"diff"===e?P.entries.length:0;return(0,n.jsxs)("button",{type:"button",role:"tab",id:z(e),"aria-selected":_===e,"aria-controls":S,onClick:()=>{h?.(),b(e)},className:(0,k.cn)("shrink-0 rounded-sm px-2 py-0.5 text-xs outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",_===e?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground"),children:[tl[e],t>0&&(0,n.jsx)("span",{className:"ml-1 tabular-nums text-muted-foreground/80",children:t})]},e)})}),L=(0,r.useRef)(null),F=(0,r.useRef)(null),G=(0,r.useRef)(null);(0,r.useLayoutEffect)(tp,[]);let O=(e,t)=>{let s,n=Math.round(Math.max(336,Math.min(e,Math.max(336,(s=L.current?.clientWidth??0)>0?s-320-10:e))));document.documentElement.style.setProperty(tf,`${n}px`),t&&window.localStorage.setItem(tx,String(n))},H=()=>{if(!G.current)return;G.current=null;let e=F.current?.getBoundingClientRect().width??0;e>0&&O(e,!0)},V=e=>{let t=F.current?.getBoundingClientRect().width??0;t<=0||O(t+e,!0)};return(0,n.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(g.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 truncate text-base font-semibold",children:e.title})]})}),R&&(0,n.jsxs)(eh,{size:"sm",variant:"outline",onClick:()=>{h?.(),i(e)},disabled:!E,children:[(0,n.jsx)(ec.A,{className:"size-3.5"}),"開始"]}),"in_progress"===t&&(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(eh,{size:"sm",onClick:()=>{h?.(),c(e)},title:"標記完成後會清理 PTY 與 worktree",children:[(0,n.jsx)(v.A,{className:"size-3.5"}),"完成"]})}),(0,n.jsx)(C,{"aria-label":"編輯任務",title:"編輯任務",onClick:()=>{h?.(),d(e.id)},children:(0,n.jsx)(m.A,{className:"size-4"})}),j?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>N(!1),className:"rounded-md px-1.5 py-1 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:()=>u(e.id),className:"rounded-md px-1.5 py-1 text-sm text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"確認刪除"})]}):(0,n.jsx)(C,{"aria-label":"刪除任務",title:"刪除任務(清理 worktree)",tone:"danger",onClick:()=>N(!0),children:(0,n.jsx)(x.A,{className:"size-4"})})]}),"backlog"===t?(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:(0,n.jsx)(tj,{title:tl.task,children:(0,n.jsx)(ty,{task:e,column:t,subAgents:s,onOpenSubAgents:f})})}):"done"===t?(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:(0,n.jsx)(tj,{heading:M,children:(0,n.jsx)("div",{role:"tabpanel",id:S,"aria-labelledby":z(_),className:"h-full",children:"task"===_?(0,n.jsx)(ty,{task:e,column:t,subAgents:s,onOpenSubAgents:f}):(0,n.jsx)(tk,{taskId:e.id,live:!1})})})}):(0,n.jsxs)("main",{ref:L,className:"grid min-h-0 flex-1 grid-rows-[minmax(18rem,1fr)_minmax(18rem,45%)] overflow-hidden lg:grid-cols-[minmax(20rem,1fr)_auto_minmax(21rem,min(var(--vf-workspace-aside,24rem),100%_-_20.625rem))] lg:grid-rows-1 xl:grid-cols-[minmax(0,1fr)_auto_minmax(21rem,min(var(--vf-workspace-aside,27rem),100%_-_20.625rem))]",children:[(0,n.jsx)("div",{className:"flex min-h-0 min-w-0 flex-col border-b border-border bg-muted/30 p-3 lg:border-b-0",children:(0,n.jsx)(e9,{taskId:e.id,cwd:E,launchCommand:$,launchNonce:B,readOnly:!1,onReturnToBacklog:"in_progress"===t?()=>l(e):void 0,onLaunchAgent:"in_progress"===t?()=>o(e):void 0,onInteract:h})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"調整終端機與側邊面板的寬度",tabIndex:0,onPointerDown:e=>{let t=F.current?.getBoundingClientRect().width??0;t<=0||(G.current={x:e.clientX,width:t},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=G.current;t&&O(t.width-(e.clientX-t.x),!1)},onPointerUp:H,onPointerCancel:H,onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),V(24)):"ArrowRight"===e.key&&(e.preventDefault(),V(-24))},className:"hidden w-2.5 shrink-0 cursor-col-resize items-center justify-center border-x border-border bg-card outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50 lg:flex",children:(0,n.jsx)("span",{className:"h-12 w-0.5 rounded-full bg-input"})}),(0,n.jsx)("aside",{ref:F,className:"flex min-h-0 min-w-0 flex-col bg-card/40",children:(0,n.jsx)(tj,{heading:M,actions:"diff"===_?(0,n.jsx)(tE,{diff:P}):void 0,children:(0,n.jsx)("div",{role:"tabpanel",id:S,"aria-labelledby":z(_),className:"h-full",children:"task"===_?(0,n.jsx)(ty,{task:e,column:t,subAgents:s,onOpenSubAgents:f}):"decisions"===_?(0,n.jsx)(tk,{taskId:e.id,live:!0}):"artifacts"===_?(0,n.jsx)(tA,{taskId:e.id,artifacts:y,artifactsDir:I}):(0,n.jsx)(tI,{taskId:e.id,diff:P})})})})]})]})}var tT=s(93659),tR=s(9523);let t$="w-full rounded-md border bg-background px-3 py-2 text-base outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 transition-shadow motion-reduce:transition-none";var tB=s(81450);let tD=[{value:"low",label:"快速",description:"適合範圍明確、低風險的小任務。"},{value:"medium",label:"標準",description:"兼顧速度與推理深度,適合一般開發任務。"},{value:"high",label:"深入",description:"適合跨檔案、除錯或需要較多判斷的任務。"},{value:"xhigh",label:"極致",description:"適合高複雜度、長鏈推理或高風險變更。"}],t_="medium";function tM({value:e,onChange:t,disabled:s=!1}){let r=Math.max(0,tD.findIndex(t=>t.value===e)),a=tD[r];return(0,n.jsxs)("div",{className:"space-y-2.5 rounded-lg border border-border/50 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-base font-medium",children:[(0,n.jsx)(tB.A,{className:"size-4 text-muted-foreground"}),"任務複雜度"]}),(0,n.jsxs)("span",{className:"rounded-full bg-primary/10 px-2.5 py-1 text-sm font-medium text-primary",children:[a.label," \xb7 ",a.value]})]}),(0,n.jsx)("input",{type:"range",name:"task-effort",min:0,max:tD.length-1,step:1,value:r,disabled:s,"aria-label":"任務複雜度","aria-valuetext":`${a.label} (${a.value})`,onChange:e=>{let s=tD[Number(e.target.value)];s&&t(s.value)},className:"h-2 w-full cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50"}),(0,n.jsx)("div",{className:"grid grid-cols-4 text-center text-xs text-muted-foreground","aria-hidden":"true",children:tD.map(e=>(0,n.jsx)("span",{children:e.label},e.value))}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[a.description," Claude Code 與 Codex 會在啟動此任務時套用;實際可用級距依 model 而定。"]})]})}var tL=s(37614);function tF({value:e,onChange:t,disabled:s=!1}){return(0,n.jsxs)("div",{className:"space-y-2.5 rounded-lg border border-border/50 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-base font-medium",children:[(0,n.jsx)(tL.A,{className:"size-4 text-muted-foreground"}),"Auto Mode"]}),(0,n.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Mode",disabled:s,onClick:()=>t(!e),className:"rounded-full p-1 outline-none transition-opacity motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",children:(0,n.jsx)("span",{className:(0,k.cn)("relative inline-block h-4 w-7 shrink-0 rounded-full transition-colors motion-reduce:transition-none",e?"bg-primary":"bg-border"),children:(0,n.jsx)("span",{className:(0,k.cn)("absolute left-0 top-0.5 size-3 rounded-full bg-foreground ring-1 ring-border transition-transform motion-reduce:transform-none motion-reduce:transition-none",e?"translate-x-3.5":"translate-x-0.5")})})})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:e?"開啟:Agent 會直接修改檔案、執行指令,不會逐次向你確認。":"關閉:Agent 每次要動作前,都會在終端機裡等你允許。"})]})}var tG=s(28333);function tO(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function tH(e,t){return!!(t&&e.find(e=>e.path===t)?.missing)}function tY({projectPath:e,recentProjects:t,disabled:s,onSelect:a,onBrowse:i}){let l=e?tO(e):null,o=t.filter(t=>!(t.missing&&t.name===l&&t.path!==e));e&&!o.some(t=>t.path===e)&&o.unshift({path:e,name:l??e,lastUsedAt:0,missing:!1});let c=new Map;for(let e of o)c.set(e.name,(c.get(e.name)??0)+1);let d=tH(t,e),[m,x]=(0,r.useState)(""),f=()=>{let e=m.trim();e&&(a(e),x(""))};return(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("select",{name:"project-folder","aria-label":"專案資料夾",value:e??"",onChange:e=>e.target.value&&a(e.target.value),disabled:s||0===o.length,className:(0,k.cn)(t$,"min-w-0 flex-1",d&&"border-destructive/60"),children:[(0,n.jsx)("option",{value:"",disabled:!0,children:o.length>0?"選擇使用過的專案…":"尚無使用過的專案,請點右側按鈕選取"}),o.map(e=>{let t,s;return(0,n.jsxs)("option",{value:e.path,title:e.path,children:[e.name,(c.get(e.name)??0)>1?` — ${(s=Math.max((t=e.path.replace(/[\\/]+$/,"")).lastIndexOf("/"),t.lastIndexOf("\\")))>0?t.slice(0,s):t}`:"",e.missing?"(路徑遺失)":""]},e.path)})]}),(0,n.jsx)(C,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",onClick:i,disabled:s,tone:"primary",className:"rounded-md border border-border p-2",children:(0,n.jsx)(ed.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{type:"text",name:"project-path","aria-label":"輸入專案資料夾路徑",placeholder:"或輸入資料夾的絕對路徑,按 Enter 套用",value:m,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),f())},disabled:s,spellCheck:!1,className:(0,k.cn)(t$,"min-w-0 flex-1 font-mono text-sm")}),(0,n.jsx)(C,{"aria-label":"套用輸入的路徑",title:"套用輸入的路徑",onClick:f,disabled:s||""===m.trim(),className:"rounded-md border border-border p-2",children:(0,n.jsx)(tG.A,{className:"size-4"})})]}),e&&!d&&(0,n.jsx)("p",{className:"truncate text-sm text-muted-foreground",title:e,children:e}),d&&(0,n.jsxs)("p",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm",children:[(0,n.jsx)(u.A,{className:"mt-0.5 size-3.5 shrink-0 text-destructive"}),(0,n.jsxs)("span",{children:["找不到 ",(0,n.jsx)("code",{className:"break-all text-foreground",children:e}),",專案可能已被移動或刪除。請點右側資料夾按鈕重新選取,之後選單會改用新的路徑。"]})]})]})}function tV({show:e,enabled:t,id:s,className:r,children:a}){let i=(0,c.I)()??!1;return e?t?(0,n.jsx)(d.PY1.div,{id:s,initial:"hidden",animate:"visible",variants:W({timing:"standard",transform:{y:-4},reducedMotion:i}),className:r,children:a}):(0,n.jsx)("div",{id:s,className:r,children:a}):null}function tK({attachment:e,id:t,creating:s,animated:r,onRemove:a}){let i=(0,H.tF)(),l=(0,c.I)()??!1,o=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tT.A,{className:"size-3.5 shrink-0 text-primary"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",title:e.name,children:e.name}),(0,n.jsx)(C,{"aria-label":`移除附件 ${e.name}`,onClick:()=>a(t),disabled:s,className:"p-1",children:(0,n.jsx)(O.A,{className:"size-3.5"})})]});return r?(0,n.jsx)(d.PY1.li,{initial:"hidden",animate:"visible",exit:"exit",variants:X({timing:"micro",transform:{y:4},reducedMotion:l}),inert:!i,"aria-hidden":!i||void 0,className:(0,k.cn)("flex items-center gap-2 rounded-md border border-border/60 bg-muted/30 px-3 py-2",!i&&"pointer-events-none"),children:o}):(0,n.jsx)("li",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-muted/30 px-3 py-2",children:o})}function tU({title:e,agents:t,detectTimedOut:s,onRetry:r,agentCli:a,onAgentChange:i,model:l,onModelChange:o,agentConnections:c}){let d="claude"===a||"codex"===a?a:null,u=d?c?.[d]?.models??[]:[],m=l&&!u.includes(l)?[l,...u]:u,x=m.length>0;return(0,n.jsxs)("div",{className:"space-y-3 rounded-lg border border-border/50 p-4",children:[(0,n.jsx)("p",{className:"text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:e}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(e8.A,{className:"size-3"}),"Agent CLI"]}),null===t?s?(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"text-sm text-destructive",children:"偵測逾時,請確認 Agent CLI 已安裝。"}),(0,n.jsx)("button",{type:"button",onClick:r,className:"rounded-sm text-sm text-primary underline outline-none hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"重新偵測"})]}):(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),"偵測中…"]}):0===t.length?(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"未偵測到 Agent CLI(claude / codex)。"}):(0,n.jsx)("select",{name:`${e.toLowerCase().replace(/\s+/g,"-")}-agent-cli`,value:a,onChange:e=>i(e.target.value),className:t$,children:t.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Model"}),x?(0,n.jsxs)("select",{name:`${e.toLowerCase().replace(/\s+/g,"-")}-model`,value:l,onChange:e=>o(e.target.value),className:t$,children:[(0,n.jsx)("option",{value:"",children:"使用預設 model"}),m.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):(0,n.jsx)("p",{className:"rounded-md border border-border/50 bg-muted/20 p-2 text-sm text-muted-foreground",children:"尚未連線或無法取得 model list,將使用預設 model。"})]})]})}function tW({creating:e,error:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,initRepository:o,detectAgents:c,agentConnections:d,onSubmit:u,onClose:m,inline:x=!1,initialProjectPath:f,defaultAutoMode:h=!0,workstationPath:p}){let[b,N]=(0,r.useState)(1),[y,w]=(0,r.useState)(""),[A,S]=(0,r.useState)(""),[z,E]=(0,r.useState)(null),[I,P]=(0,r.useState)([]),[T,R]=(0,r.useState)(null),[$,B]=(0,r.useState)(!1),[_,M]=(0,r.useState)(!1),[L,F]=(0,r.useState)(""),[G,H]=(0,r.useState)(""),[Y,V]=(0,r.useState)(null),[K,U]=(0,r.useState)(!1),[W,X]=(0,r.useState)(0),[q,J]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)("claude"),[ee,et]=(0,r.useState)(""),[es,en]=(0,r.useState)(t_),[er,ea]=(0,r.useState)(h),[ei,el]=(0,r.useState)([]),[eo,ec]=(0,r.useState)(null),[ed,eu]=(0,r.useState)(!1),[em,ex]=(0,r.useState)(!1),ef=(0,r.useId)(),ep=(0,r.useRef)(0),eb=(0,r.useRef)(null),ej=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;U(!1),V(null);let t=setTimeout(()=>{e&&U(!0)},6e3);return c().then(s=>{e&&(clearTimeout(t),V(s),!s.some(e=>"claude"===e.id)&&s.length>0&&Z(s[0].id))}),()=>{e=!1,clearTimeout(t)}},[c,W]),(0,r.useEffect)(()=>{2===b&&eb.current?.focus()},[b]),(0,r.useEffect)(()=>{x&&eb.current?.focus()},[]),(0,r.useEffect)(()=>{let e=!0;return a().then(t=>{e&&P(t)}),()=>{e=!1}},[a]);let ev=tH(I,z),eN=async e=>{E(e),R(null),F(""),B(!0);try{let t=await i(e);R(t),F(t?.defaultBase??"")}finally{B(!1)}},ey=async e=>{if(tH(I,e)){E(e),R(null),F("");return}await eN(e)},ek=async()=>{let e=await s();e&&(P(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await eN(e))},ew=async()=>{if(z){M(!0);try{let e=await o(z);R(e),F(e?.defaultBase??"")}finally{M(!1)}}};(0,r.useEffect)(()=>{x&&f&&ey(f)},[]);let eC=T?.isRepo??!1,eA=T?.hasRemote??!1,eS=`${p?.trim()||"~/Desktop"}/${z?tO(z):"<專案名>"}`,ez=!!z&&!ev&&eC&&!$&&!_,eE=y.trim().length>0&&!e&&!em&&(!x||ez),eI=()=>{eE&&z&&u(y.trim(),A.trim(),z,eA&&L||null,G.trim(),Q,ee,es,er,ei.map(({input:e})=>e))},eP=async e=>{ec(null),ex(!0);try{let t=(await eg(e)).map(e=>({id:ep.current++,input:e}));el(e=>[...e,...t])}catch(e){ec(e instanceof Error?e.message:String(e))}finally{ex(!1)}},eT=(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium uppercase tracking-wide text-muted-foreground",children:"專案資料夾"}),(0,n.jsx)(tY,{projectPath:z,recentProjects:I,disabled:e||_||$,onSelect:e=>void ey(e),onBrowse:()=>void ek()})]}),(0,n.jsx)(tV,{show:$||_,enabled:x,children:(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),_?"初始化 Git…":"偵測 Git 狀態中…"]})}),(0,n.jsx)(tV,{show:!!T&&!ev&&!$&&!_&&!eC,enabled:x,children:(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/40 bg-destructive/10 p-3",children:[(0,n.jsxs)("p",{className:"text-base",children:["這個資料夾不是 Git repository。請改選一個 Git 專案,或在這裡初始化:會執行",(0,n.jsx)("code",{className:"text-foreground",children:" git init "}),"並建立一個空的初始 commit。"]}),(0,n.jsx)(eh,{size:"sm",variant:"outline",onClick:()=>void ew(),disabled:e,className:"rounded-full",children:"初始化 Git"})]})}),(0,n.jsx)(tV,{show:eC&&eA,enabled:x,children:(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsx)("select",{name:"base-branch",value:L,onChange:e=>F(e.target.value),className:t$,children:(T?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]})}),(0,n.jsx)(tV,{show:eC&&!eA,enabled:x,children:(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["此 repository 沒有 remote,將以目前分支 (",T?.currentBranch??"HEAD",") 為基準建立本地 worktree。"]})}),(0,n.jsx)(tV,{show:eC,enabled:x,children:(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3"}),"分支名稱 (選填)"]}),(0,n.jsx)("input",{name:"branch",value:G,onChange:e=>H(e.target.value),placeholder:"留空則自動命名,例如 feature/login-fix",className:t$}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:eA?"填寫後會建立同名分支;若 remote 已有這個分支,則直接取回並接續上面的工作。":"填寫後會建立同名分支。"})]})}),(0,n.jsx)(tV,{show:eC,enabled:x,children:(0,n.jsxs)("div",{className:"space-y-1.5 rounded-lg border border-border/50 bg-muted/20 p-4",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium",children:[(0,n.jsx)(tR.A,{className:"size-3.5 text-muted-foreground"}),"建立後會立刻做這些事"]}),(0,n.jsxs)("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:[(0,n.jsxs)("li",{children:["在 ",(0,n.jsx)("code",{className:"text-foreground",children:eS})," ","底下建立這張卡專用的 worktree 與分支,你的專案資料夾本身不會被切換。"]}),eA&&(0,n.jsx)("li",{children:"把新分支 push 到 origin;遠端會多出一條分支,有 CI 的話可能被觸發。"}),(0,n.jsxs)("li",{children:["把被 git 忽略的檔案(例如 ",(0,n.jsx)("code",{className:"text-foreground",children:".env"}),")複製一份進 worktree,相依套件資料夾則在背景複製,好讓新 worktree 能直接跑起來。"]}),(0,n.jsxs)("li",{children:["把 VibeFlow 的執行期檔案寫進"," ",(0,n.jsx)("code",{className:"text-foreground",children:".git/info/exclude"}),",不會動到專案的 .gitignore。"]})]})]})})]}),eR=(0,n.jsxs)("div",{className:"rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button","aria-expanded":q,"aria-controls":ef,onClick:()=>J(e=>!e),className:"flex w-full items-center justify-between px-4 py-3 text-left text-base font-medium transition-colors motion-reduce:transition-none outline-none hover:bg-accent/40 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{children:"Advanced"}),(0,n.jsx)(j.A,{className:(0,k.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",q&&"rotate-180")})]}),(0,n.jsx)(tV,{show:q,enabled:x,id:ef,className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(tU,{title:"Agent",agents:Y,detectTimedOut:K,onRetry:()=>X(e=>e+1),agentCli:Q,onAgentChange:e=>{Z(e),et("")},model:ee,onModelChange:et,agentConnections:d})})]}),e$=(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"附件(選填)"}),(0,n.jsxs)("button",{type:"button",disabled:e||em,onClick:()=>ej.current?.click(),onDragEnter:t=>{t.preventDefault(),e||em||eu(!0)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},onDragLeave:()=>eu(!1),onDrop:t=>{t.preventDefault(),eu(!1),e||em||!(t.dataTransfer.files.length>0)||eP(t.dataTransfer.files)},className:(0,k.cn)("flex w-full flex-col items-center gap-2 rounded-lg border-2 border-dashed border-border py-5 text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:border-primary/50 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",ed&&"border-primary/70 bg-primary/5 text-foreground"),children:[(0,n.jsx)(tT.A,{className:"size-5"}),(0,n.jsx)("span",{className:"text-sm",children:"拖放檔案到這裡,或點擊選擇檔案"})]}),(0,n.jsx)("input",{ref:ej,type:"file",multiple:!0,disabled:e||em,className:"hidden",onChange:e=>{e.target.files&&eP(e.target.files),e.target.value=""}}),em&&(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),"讀取附件中…"]}),(0,n.jsx)("ul",{className:"space-y-1.5",children:(0,n.jsx)(l.N,{initial:!1,children:ei.map(({id:t,input:s})=>(0,n.jsx)(tK,{attachment:s,id:t,creating:e,animated:x,onRemove:e=>el(t=>t.filter(t=>t.id!==e))},t))})}),eo&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:eo})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"新增任務"}),m&&(0,n.jsx)(C,{"aria-label":"關閉新增任務",onClick:m,disabled:e,className:"p-1",children:(0,n.jsx)(O.A,{className:"size-4"})})]}),!x&&(0,n.jsxs)("div",{className:"mb-5 flex items-center gap-2",children:[(0,n.jsx)("div",{className:(0,k.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",1===b?"bg-primary text-primary-foreground":"bg-primary/20 text-primary"),children:b>1?(0,n.jsx)(v.A,{className:"size-3.5",strokeWidth:3}):"1"}),(0,n.jsx)("span",{className:(0,k.cn)("text-base tracking-[-0.224px]",1===b?"font-medium text-foreground":"text-muted-foreground"),children:"專案設定"}),(0,n.jsx)("div",{className:(0,k.cn)("h-0.5 flex-1 transition-colors",b>1?"bg-primary/60":"bg-border")}),(0,n.jsx)("div",{className:(0,k.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",2===b?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"2"}),(0,n.jsx)("span",{className:(0,k.cn)("text-base tracking-[-0.224px]",2===b?"font-medium text-foreground":"text-muted-foreground"),children:"任務內容"})]}),x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"mb-5 block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{ref:eb,name:"task-title",autoComplete:"off",value:y,onChange:e=>w(e.target.value),placeholder:"例如:實作登入頁面",className:(0,k.cn)(t$,"text-lg")})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[(0,n.jsxs)("div",{className:"space-y-4",children:[eT,e$]}),(0,n.jsxs)("div",{className:"flex h-full flex-col gap-4",children:[(0,n.jsxs)("label",{className:"flex min-h-0 flex-1 flex-col gap-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"詳細描述(選填)"}),(0,n.jsx)("textarea",{name:"task-description",autoComplete:"off",value:A,onChange:e=>S(e.target.value),rows:12,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,k.cn)(t$,"mb-2 min-h-64 flex-1 resize-y")})]}),(0,n.jsx)(tM,{value:es,onChange:en,disabled:e}),(0,n.jsx)(tF,{value:er,onChange:ea,disabled:e}),t&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-base",children:t})]})]}),(0,n.jsx)("div",{className:"mt-5",children:eR})]}),!x&&(0,n.jsxs)("div",{children:[1===b&&(0,n.jsx)("div",{className:"space-y-4",children:eT}),2===b&&(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{ref:eb,name:"task-title",autoComplete:"off",value:y,onChange:e=>w(e.target.value),placeholder:"例如:實作登入頁面",className:t$})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"詳細描述(選填)"}),(0,n.jsx)("textarea",{value:A,name:"task-description",autoComplete:"off",onChange:e=>S(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,k.cn)(t$,"resize-y")})]}),(0,n.jsx)(tM,{value:es,onChange:en,disabled:e}),(0,n.jsx)(tF,{value:er,onChange:ea,disabled:e}),e$,eR,t&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-base",children:t})]})]}),x?(0,n.jsxs)("div",{className:"mt-6 space-y-2 pb-10",children:[!ez&&y.trim().length>0&&(0,n.jsx)("p",{className:"text-right text-sm text-muted-foreground",children:"請先在左側選擇專案資料夾"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[m&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:m,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:eI,disabled:!eE,className:(0,k.cn)("rounded-full px-5 active:scale-95 transition-transform motion-reduce:transform-none motion-reduce:transition-none",e&&"opacity-80"),children:[e&&(0,n.jsx)(D.A,{className:"animate-spin"}),e?"建立 Worktree 中…":"建立任務"]})]})]}):1===b?(0,n.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[m&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:m,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsx)(eh,{size:"sm",onClick:()=>N(2),disabled:!ez,className:"rounded-full px-5",children:"下一步 →"})]}):(0,n.jsxs)("div",{className:"mt-5 flex items-center justify-between",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>N(1),disabled:e,className:"rounded-full",children:"← 上一步"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[m&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:m,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:eI,disabled:!eE,className:(0,k.cn)("rounded-full px-5 active:scale-95 transition-transform motion-reduce:transform-none motion-reduce:transition-none",e&&"opacity-80"),children:[e&&(0,n.jsx)(D.A,{className:"animate-spin"}),e?"建立 Worktree 中…":"建立任務"]})]})]})]})}let tX="vibeflow:board-split-px";function tq(){let e=Number(window.localStorage.getItem(tX));return Number.isFinite(e)&&e>=180?e:null}function tJ({active:e,children:t}){let s=(0,o.E)(),a=(0,c.I)()??!1,i=W({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:a});return(0,r.useEffect)(()=>{s.stop(),s.set("hidden"),e&&s.start("visible")},[e,s,a]),(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:s,variants:i,inert:!e,"aria-hidden":!e||void 0,className:(0,k.cn)("h-full",!e&&"hidden pointer-events-none"),children:t})}function tQ({board:e,onBoardChange:t,onEditTask:s,onTaskDone:a,onDeleteTask:i,autoMode:o,workstationPath:m,subAgents:x,selectedTaskId:f,onSelectTask:h,onNewTask:p,tabBar:g,onTaskInteract:b,openTabIds:j,initialProjectPath:v,newTaskNonce:N,creating:y,createError:w,pickFolder:C,loadRecentProjects:A,loadGitInfo:S,initRepository:z,detectAgents:E,agentConnections:I,onCreateTask:P}){let[T,R]=(0,r.useState)(null),$=(0,r.useRef)(null),[D,_]=(0,r.useState)(new Set),[M,L]=(0,r.useState)({}),F=(0,r.useRef)(M);F.current=M;let G=W({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:(0,c.I)()??!1}),O=e=>_(t=>t.has(e)?t:new Set(t).add(e)),[H,Y]=(0,r.useState)(null),[V,K]=(0,r.useState)(null),U=async(e,t={})=>{O(e.id),L(s=>({...s,[e.id]:{launch:t,nonce:(s[e.id]?.nonce??0)+1}}))};(0,r.useEffect)(()=>{if(!f||(O(f),M[f]))return;let t=e.in_progress.find(e=>e.id===f);if(!t||null==t.launchedAt||!t.worktreePath)return;let s=!1;return e4(t.id).then(e=>{s||!e||F.current[t.id]||U(t,{resume:!0})}),()=>{s=!0}},[f]);let X=s=>{let n={...s,launchedAt:Date.now()};t({backlog:e.backlog.filter(e=>e.id!==s.id),in_progress:[n,...e.in_progress],done:e.done}),U(n)},J=e=>new Promise((t,s)=>{K({task:e,settle:n=>{(K(null),n)?Q(e).then(()=>t(!0),s):t(!1)}})}),Q=async e=>{let s=await eD(e.id);if(!s)throw Error("未連線到 VibeFlow core");let n=s.state.board;t({backlog:[s.task,...n.backlog.filter(t=>t.id!==e.id)],in_progress:n.in_progress.filter(t=>t.id!==e.id),done:n.done.filter(t=>t.id!==e.id)})},Z=async e=>{await U(e,{includeTaskPrompt:!1})},ee=e=>Y(e),es=(0,r.useRef)(null),en=(0,r.useRef)(null),[er,ea]=(0,r.useState)(tq);(0,r.useLayoutEffect)(()=>{if(null!==er)return;let e=es.current?.clientHeight??0;e>0&&ea(Math.max(180,e-260))},[er]);let ei=e=>{let t=es.current?.clientHeight??0;return Math.max(180,Math.min(e,Math.max(180,t>0?t-260:e)))},el=()=>{en.current&&null!==er&&(en.current=null,window.localStorage.setItem(tX,String(er)))},eo=e=>{if(null===er)return;let t=ei(er+e);ea(t),window.localStorage.setItem(tX,String(t))},ec=T?Object.values(e).flat().find(e=>e.id===T):null,ed=T?x[T]:void 0,eu=T&&ec?{taskId:T,taskTitle:ec.title,runs:ed??[]}:null;(0,r.useEffect)(()=>{T&&ec&&($.current={taskId:T,taskTitle:ec.title,runs:ed??[]})},[T,ec,ed]);let em=eu??$.current;return(0,n.jsxs)("div",{ref:es,className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsx)("div",{style:null===er?void 0:{height:er},className:(0,k.cn)("min-h-0 overflow-hidden border-b border-border",null===er?"flex-1":"shrink-0"),children:(0,n.jsx)(B,{board:e,subAgents:x,selectedTaskId:f??null,onSelectTask:h,onEditTask:s,onDeleteTask:i,onNewTask:p})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":"調整看板與工作區的高度",tabIndex:0,onPointerDown:e=>{null!==er&&(en.current={y:e.clientY,height:er},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=en.current;t&&ea(ei(t.height+(e.clientY-t.y)))},onPointerUp:el,onPointerCancel:el,onKeyDown:e=>{"ArrowUp"===e.key?(e.preventDefault(),eo(-24)):"ArrowDown"===e.key&&(e.preventDefault(),eo(24))},className:"flex h-2.5 shrink-0 cursor-row-resize items-center justify-center border-y border-border bg-card outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)("span",{className:"h-0.5 w-12 rounded-full bg-input"})}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[g,(0,n.jsx)("main",{className:"min-h-0 flex-1",children:(()=>{let t=[...e.in_progress.map(e=>({task:e,column:"in_progress"})),...e.backlog.map(e=>({task:e,column:"backlog"})),...e.done.map(e=>({task:e,column:"done"}))],r=f?t.find(({task:e})=>e.id===f):null,a=new Set(j),l=new Set;for(let e of D){let s=t.find(({task:t})=>t.id===e);s&&(a.has(e)||"in_progress"===s.column)&&l.add(e)}return r&&l.add(r.task.id),(0,n.jsxs)(n.Fragment,{children:[Array.from(l).map(e=>{let r=t.find(({task:t})=>t.id===e);if(!r)return null;let a=e===f;return(0,n.jsx)(tJ,{active:a,children:(0,n.jsx)(tP,{task:r.task,column:r.column,subAgents:x[r.task.id]??[],launch:M[e],onStart:X,onReturnToBacklog:J,onLaunchAgent:Z,onComplete:ee,onEdit:s,onDelete:i,onOpenSubAgents:R,onInteract:b?()=>b(e):void 0})},e)}),!r&&(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:G,className:"flex h-full overflow-y-auto p-8",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-5xl pb-8",children:(0,n.jsx)(tW,{inline:!0,initialProjectPath:v,creating:y,error:w,pickFolder:C,loadRecentProjects:A,loadGitInfo:S,initRepository:z,detectAgents:E,agentConnections:I,defaultAutoMode:o,workstationPath:m,onSubmit:P},`${v??"new"}:${N}`)})})]})})()})]}),(0,n.jsx)(et,{open:null!==T,taskId:em?.taskId??"",taskTitle:em?.taskTitle??"",runs:em?.runs??[],onClose:()=>R(null)}),(0,n.jsx)(l.N,{children:H&&(0,n.jsx)(q,{title:"完成任務",onClose:()=>Y(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["完成「",H.title,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除這張卡的 worktree(尚未 commit 的變更會一起消失)、本地分支",H.branch?`「${H.branch}」`:"","與 artifacts, 並把專案切回",H.baseBranch?`「${H.baseBranch}」`:"基準分支","後更新。此操作無法復原,請先確認要保留的變更都已經 commit 或 push。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>Y(null),children:"取消"}),(0,n.jsx)(eh,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>{var s;let n;H&&(Y(null),s="done",(n={backlog:e.backlog.filter(e=>e.id!==H.id),in_progress:e.in_progress.filter(e=>e.id!==H.id),done:e.done.filter(e=>e.id!==H.id)})[s]=[H,...n[s]],t(n),a(H.id))},children:"完成並清理"})]})]})},"confirm-done-dialog")}),(0,n.jsx)(l.N,{children:V&&(0,n.jsx)(q,{title:"退回 Backlog",onClose:()=>V.settle(!1),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["把「",V.task.title,"」退回 Backlog?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會停止 Agent,並把 worktree 還原到",V.task.baseBranch?`「${V.task.baseBranch}」`:"基準分支","——這張卡在本地的 commit 與未 commit 變更都會消失,artifacts 與決策紀錄也會一併刪除。遠端分支不會被改動。此操作無法復原。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>V.settle(!1),children:"取消"}),(0,n.jsx)(eh,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>V.settle(!0),children:"清除並退回"})]})]})},"confirm-return-dialog")})]})}var tZ=s(51662);function t0({task:e,detectAgents:t,agentConnections:s,pickFolder:a,loadRecentProjects:i,loadGitInfo:o,saving:c,error:d,defaultAutoMode:u=!0,onSubmit:m,onClose:x}){let[f,h]=(0,r.useState)(""),[p,b]=(0,r.useState)(""),[v,N]=(0,r.useState)("claude"),[y,w]=(0,r.useState)(""),[C,A]=(0,r.useState)(t_),[S,z]=(0,r.useState)(!0),[E,I]=(0,r.useState)(null),[P,T]=(0,r.useState)(""),[R,$]=(0,r.useState)(null),[B,_]=(0,r.useState)(!1),[M,L]=(0,r.useState)(!1),[F,G]=(0,r.useState)([]),[O,H]=(0,r.useState)(null),[Y,V]=(0,r.useState)(!1),[K,U]=(0,r.useState)(0),[W,X]=(0,r.useState)(!0),[J,Q]=(0,r.useState)(!1),Z=(0,r.useRef)(null),ee=e??Z.current;if((0,r.useEffect)(()=>{e&&(Z.current=e)},[e]),(0,r.useEffect)(()=>{e&&(h(e.title),b(e.description??""),N(e.agentCli??"claude"),w(e.model??""),A(e.effort??t_),z(e.autoMode??u),I(e.projectPath??null),T(e.baseBranch??""),$(null),_(!1),L(!1),Q(!1))},[e,u]),(0,r.useEffect)(()=>{if(!e||e.launchedAt)return;let t=!0;return i().then(e=>{t&&G(e)}),()=>{t=!1}},[e,i]),(0,r.useEffect)(()=>{if(!e)return;let s=!0;V(!1),H(null);let n=setTimeout(()=>{s&&V(!0)},6e3);return t().then(e=>{s&&(clearTimeout(n),H(e))}),()=>{s=!1,clearTimeout(n)}},[e,t,K]),!ee)return null;let et=!ee.launchedAt,es=f!==ee.title||p!==(ee.description??"")||v!==(ee.agentCli??"claude")||y!==(ee.model??"")||C!==(ee.effort??t_)||S!==(ee.autoMode??u)||M||P!==(ee.baseBranch??""),en=()=>{c||(es?Q(!0):x())},er=tH(F,E),ea=async(e,t=!1)=>{if(I(e),L(e!==ee.projectPath),$(null),!(!t&&tH(F,e))){_(!0);try{let t=await o(e);$(t),T(t?.defaultBase??"")}finally{_(!1)}}},ei=async()=>{let e=await a();e&&(G(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await ea(e,!0))},el=R?.isRepo??!0,eo=R?.hasRemote??!1,ec=f.trim().length>0&&!c&&!B&&(!M||el&&!er);return(0,n.jsx)(l.N,{children:e&&(0,n.jsxs)(q,{title:"編輯任務",description:"更新任務內容與 agent 設定。",saving:c,onClose:en,showHeader:!0,contentClassName:"max-w-2xl",footer:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:en,disabled:c,children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:()=>{ec&&m({title:f.trim(),description:p.trim(),agentCli:v,model:y,effort:C,autoMode:S,...et&&E?{projectPath:E,baseBranch:P||null}:{}})},disabled:!ec,className:(0,k.cn)(c&&"opacity-80"),children:[c&&(0,n.jsx)(D.A,{className:"animate-spin"}),c?"儲存中…":"儲存變更"]})]})]}),children:[J&&(0,n.jsxs)("div",{className:"mb-4 flex items-center justify-between rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-base",children:[(0,n.jsx)("span",{className:"text-warning",children:"有未儲存的變更,確定要離開?"}),(0,n.jsxs)("div",{className:"flex gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>Q(!1),className:"rounded-md px-2 py-0.5 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"繼續編輯"}),(0,n.jsx)("button",{type:"button",onClick:x,className:"rounded-md px-2 py-0.5 text-sm text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"放棄離開"})]})]}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{autoFocus:!0,name:"edit-task-title",autoComplete:"off",value:f,onChange:e=>h(e.target.value),placeholder:"例如:實作登入頁面",className:t$})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"詳細描述(選填)"}),(0,n.jsx)("textarea",{name:"edit-task-description",autoComplete:"off",value:p,onChange:e=>b(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,k.cn)(t$,"resize-y")})]}),(0,n.jsx)(tM,{value:C,onChange:A,disabled:c}),(0,n.jsx)(tF,{value:S,onChange:z,disabled:c}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium uppercase tracking-wide text-muted-foreground",children:[(0,n.jsx)(ed.A,{className:"size-3"}),"專案資料夾"]}),et?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tY,{projectPath:E,recentProjects:F,disabled:c||B,onSelect:e=>void ea(e),onBrowse:()=>void ei()}),B&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),"偵測 Git 狀態中…"]}),M&&!er&&!B&&!el&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"這個資料夾不是 Git repository,請改選一個 Git 專案。"}),M&&!er&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"更換專案會在新專案重建 worktree(此任務尚未開始,無變更會遺失)。"}),M&&el&&eo&&(0,n.jsxs)("label",{className:"block space-y-1.5 pt-1",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsx)("select",{name:"edit-base-branch",value:P,onChange:e=>T(e.target.value),className:t$,children:(R?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 bg-muted/30 px-3 py-2.5",children:[(0,n.jsx)(tZ.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"flex-1 truncate text-base",title:ee.projectPath,children:ee.projectName??(ee.projectPath?tO(ee.projectPath):"—")}),(0,n.jsx)("span",{className:"shrink-0 text-sm text-muted-foreground",children:"任務已開始,鎖定"})]})]}),(0,n.jsxs)("div",{className:"rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>X(e=>!e),className:"flex w-full items-center justify-between px-4 py-3 text-left text-base font-medium transition-colors outline-none hover:bg-accent/40 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{children:"Advanced"}),(0,n.jsx)(j.A,{className:(0,k.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",W&&"rotate-180")})]}),W&&(0,n.jsx)("div",{className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(tU,{title:"Agent",agents:O,detectTimedOut:Y,onRetry:()=>U(e=>e+1),agentCli:v,onAgentChange:e=>{N(e),w("")},model:y,onModelChange:w,agentConnections:s})})]}),d&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:d})]})]},ee.id)})}var t1=s(1896),t5=s(87617),t2=s(6616),t3=s(37744),t4=s(80802),t6=s(69758),t8=s(21684),t7=s(18319),t9=s(37156);let se=[{id:"skill",label:"Skills",hint:"兩個 agent 都會載入。import 需選擇含 SKILL.md 的目錄。"},{id:"prompt",label:"Prompts",hint:"啟用的內容會併入啟動時的 system prompt,排在 Settings 的 System Prompt 之前。"},{id:"script",label:"Scripts",hint:"路徑與用途會寫進 prompt,由 agent 自行決定要不要執行。"}],st={skill:t8.A,prompt:eu.A,script:t7.A};function ss(e,t){return"skill"!==e?"":`---
7
+ name: ${t}
8
+ description:
9
+ ---
10
+
11
+ `}function sn({onEditingChange:e}){let[t,s]=(0,r.useState)([]),[a,i]=(0,r.useState)(!0),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(null),[u,m]=(0,r.useState)(null),[f,h]=(0,r.useState)(null),p=(0,r.useCallback)(async()=>{s(await eV()),i(!1)},[]);(0,r.useEffect)(()=>{p()},[p]),(0,r.useEffect)(()=>{e?.(null!==f)},[f,e]);let g=async(e,t)=>{o(e),d(null);try{await t(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{o(null)}};return f?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-base font-medium",children:f.entry.name}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"skill"===f.entry.kind?"編輯 SKILL.md。frontmatter 的 name 與 description 兩個 CLI 都會讀。":"編輯檔案內容。"})]}),(0,n.jsx)("textarea",{value:f.content,onChange:e=>h({...f,content:e.target.value}),rows:18,spellCheck:!1,className:(0,k.cn)(t$,"resize-y font-mono text-sm leading-5")}),c&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:c}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(eh,{size:"sm",onClick:()=>void(()=>{if(!f)return;let{entry:e,content:t}=f;return g(`save:${e.key}`,async()=>{await eX(e.kind,e.name,t),h(null)})})(),disabled:null!==l,children:"儲存"})]})]}):(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟用的項目會在每次啟動任務時自動投遞:Claude 以 session-only plugin 載入,Codex 以 VibeFlow 組出的 CODEX_HOME 載入。本機與專案自己的 skill 仍會照常載入,這裡的項目是額外加上去的。"}),c&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:c}),se.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=st[e];return(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:(0,k.cn)(y,"flex items-center gap-2"),children:[(0,n.jsx)(o,{className:"size-3.5"}),s,(0,n.jsx)("span",{className:"tabular-nums text-muted-foreground/70",children:i.length})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(eh,{variant:"ghost",size:"sm",onClick:()=>{g(`import:${e}`,async()=>{let t=await eY(e);t&&await eK(e,t)})},disabled:null!==l,children:[l===`import:${e}`?(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(t9.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(eh,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:ss(e,""),description:""}),disabled:null!==l,children:[(0,n.jsx)(N.A,{className:"size-3.5"}),"新建"]})]})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:r}),u?.kind===e&&(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border/60 p-3",children:[(0,n.jsx)("input",{autoFocus:!0,value:u.name,onChange:t=>{let s=t.target.value;m({...u,name:s,content:u.content===ss(e,u.name)?ss(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,k.cn)(t$,"font-mono text-sm")}),"skill"!==e&&(0,n.jsx)("input",{value:u.description,onChange:e=>m({...u,description:e.target.value}),placeholder:"用途說明(scripts 會寫進 prompt 給 agent 判斷)",className:(0,k.cn)(t$,"text-sm")}),(0,n.jsx)("textarea",{value:u.content,onChange:e=>m({...u,content:e.target.value}),rows:8,spellCheck:!1,placeholder:"skill"===e?"":"內容",className:(0,k.cn)(t$,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(eh,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return g("create",async()=>{await eU(e,t,s,n.trim()||void 0),m(null)})})(),disabled:null!==l||0===u.name.trim().length,children:"建立"})]})]}),a?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"讀取中…"}):0===i.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"尚無項目。"}):(0,n.jsx)("div",{className:"grid gap-2",children:i.map(e=>(0,n.jsxs)("div",{className:"flex items-start gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:t=>void g(`toggle:${e.key}`,()=>eq(e.kind,e.name,t.target.checked)),"aria-label":`啟用 ${e.name}`,className:"mt-1 size-4 shrink-0 rounded-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"truncate font-mono text-sm",children:e.name}),e.description&&(0,n.jsx)("p",{className:"line-clamp-2 text-sm text-muted-foreground",title:e.description,children:e.description}),e.sourcePath&&(0,n.jsxs)("p",{className:"truncate text-xs text-muted-foreground/70",children:["來源:",e.sourcePath]})]}),(0,n.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>{g(`open:${e.key}`,async()=>{h({entry:e,content:await eW(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.sourcePath&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>{g(`reimport:${e.key}`,async()=>{e.sourcePath&&await eK(e.kind,e.sourcePath)})},disabled:null!==l,title:"從來源重新複製一份快照",children:l===`reimport:${e.key}`?(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(em.A,{className:"size-3.5"})}),(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>void g(`delete:${e.key}`,()=>eJ(e.kind,e.name)),disabled:null!==l,title:"從 library 刪除",children:(0,n.jsx)(x.A,{className:"size-3.5 text-destructive"})})]})]},e.key))})]},e)})]})}let sr=[{id:"claude",name:"Claude",platform:"Anthropic Console",keyUrl:"https://platform.claude.com/settings/workspaces/default/keys"},{id:"codex",name:"Codex",platform:"OpenAI Platform",keyUrl:"https://platform.openai.com/api-keys"}];function sa({open:e,systemPrompt:t,workstationPath:s,autoMode:a,agentConnections:i,saving:o,error:c,onSave:d,onConnectAgent:m,onRefreshModels:x,onPickFolder:f,onClose:h}){let[p,g]=(0,r.useState)(""),[b,j]=(0,r.useState)(""),[v,N]=(0,r.useState)(!0),[y,w]=(0,r.useState)(null),[C,A]=(0,r.useState)(""),[S,z]=(0,r.useState)(!1),[E,I]=(0,r.useState)(null),[P,T]=(0,r.useState)(!1),[R,$]=(0,r.useState)(null),[B,M]=(0,r.useState)(!1),[L,F]=(0,r.useState)(null),[G,O]=(0,r.useState)("idle"),[H,Y]=(0,r.useState)(""),[V,K]=(0,r.useState)("https://github.com/login/device"),[U,W]=(0,r.useState)(null),[X,J]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(g(t),j(s),N(a),w(null),M(!1),A(""),z(!1),I(null),T(!1),O("idle"),Y(""),W(null),Z(!1),ew().then(F))},[e,t,s,a]),(0,r.useEffect)(()=>{if(e){var t;let e;return t=e=>{if("starting"===e.type){O("starting"),W(null);return}if("code"===e.type){O("waiting"),Y(e.code),K(e.url),Z(!1),J(!1);return}if("success"===e.type){F(e.status),O("success"),J(!1);return}if("cancelled"===e.type){O("idle"),J(!1);return}O("error"),W(e.error),J(!1)},(e=eb())?e.onGithubAuthEvent(t):()=>{}}},[e]);let[ee,et]=(0,r.useState)(!1),[es,er]=(0,r.useState)(!1),ea=y?i?.[y.id]:void 0,ei=(0,r.useMemo)(()=>sr.reduce((e,t)=>e+(i?.[t.id]?.models??[]).length,0),[i]),el=p.trim(),eo=""===el,ec=!o&&!y&&!B,ed=async()=>{let e=await f();e&&j(e)},eu=async()=>{if(!y||P)return;T(!0),I(null);let e=await m(y.id,C);e?I(e):(A(""),w(null)),T(!1)},ex=async()=>{M(!0),O("starting"),Y(""),W(null),Z(!1),J(!0);try{await eC()}catch(e){O("error"),W(e instanceof Error?e.message:String(e)),J(!1)}},ef=async()=>{("starting"===G||"waiting"===G)&&await eA(),M(!1),O("idle"),J(!1),Y(""),W(null),Z(!1),F(await ew())},ep=async()=>{J(!0),W(null);try{let e=await eS();F(e)}catch(e){W(e instanceof Error?e.message:String(e))}finally{J(!1)}},eg=()=>{B&&("starting"===G||"waiting"===G)&&eA(),h()},ej=async()=>{H&&(await navigator.clipboard.writeText(H),Z(!0),window.setTimeout(()=>Z(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(q,{title:B?"登入 GitHub CLI":y?`連結 ${y.name}`:ee?"Library":"設定",description:B?"使用 GitHub CLI 的網頁授權流程登入 github.com。":y?"綁定個人 API key 以取得可用 model list。":ee?"VibeFlow 自有的 skill / prompt / script,啟動任務時投遞給 Claude 與 Codex。":"調整 system prompt 與 agent 帳號連線。",saving:o||P||X,onClose:eg,showHeader:!0,contentClassName:"max-w-2xl",footer:B?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>void ef(),disabled:X&&"success"!==G,children:"success"===G?"完成":"返回"}),"error"===G&&(0,n.jsx)(eh,{size:"sm",onClick:()=>void ex(),children:"重新登入"})]}):y?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>w(null),disabled:P,children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:eu,disabled:P||0===C.trim().length,className:(0,k.cn)(P&&"opacity-80"),children:[P&&(0,n.jsx)(D.A,{className:"animate-spin"}),P?"驗證中…":"儲存 API key"]})]}):ee?es?null:(0,n.jsxs)(eh,{variant:"ghost",size:"sm",onClick:()=>et(!1),children:[(0,n.jsx)(t1.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:eg,disabled:o,children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:()=>{ec&&d(el,b.trim(),v)},disabled:!ec,className:(0,k.cn)(o&&"opacity-80"),children:[o&&(0,n.jsx)(D.A,{className:"animate-spin"}),o?"儲存中…":"儲存設定"]})]}),children:B?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void ef(),disabled:X&&"success"!==G,className:"inline-flex items-center gap-1.5 rounded-sm text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:[(0,n.jsx)(t1.A,{className:"size-4"}),"返回設定"]}),(0,n.jsx)("div",{className:"rounded-md border border-border/60 p-3",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:["success"===G?(0,n.jsx)(_.A,{className:"mt-0.5 size-5 shrink-0 text-success"}):"error"===G?(0,n.jsx)(u.A,{className:"mt-0.5 size-5 shrink-0 text-destructive"}):(0,n.jsx)(D.A,{className:"mt-0.5 size-5 shrink-0 animate-spin text-muted-foreground"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("p",{className:"text-base font-medium",children:"success"===G?"GitHub CLI 已完成授權":"error"===G?"GitHub CLI 授權失敗":"waiting"===G?"等待 GitHub 授權完成":"正在啟動 GitHub CLI 登入"}),(0,n.jsx)("p",{className:"text-sm leading-5 text-muted-foreground",children:"success"===G?`目前登入帳號:${L?.login??"GitHub"}`:"error"===G?U:"waiting"===G?"請複製授權碼並開啟 GitHub 授權頁,完成後 VibeFlow 會自動更新狀態。":"VibeFlow 正在背景準備 gh auth login。"})]})]})}),("waiting"===G||H)&&(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"授權碼"}),(0,n.jsxs)("div",{className:"flex rounded-md border bg-background focus-within:ring-[3px] focus-within:ring-ring/50",children:[(0,n.jsx)("input",{readOnly:!0,value:H,className:"min-w-0 flex-1 bg-transparent px-3 py-2 font-mono text-base tracking-wider outline-none"}),(0,n.jsxs)("button",{type:"button",onClick:()=>void ej(),className:"flex h-9 items-center gap-1.5 rounded-r-md px-3 text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset disabled:opacity-50",disabled:!H,children:[(0,n.jsx)(t5.A,{className:"size-4"}),Q?"已複製":"複製"]})]})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"登入網址"}),(0,n.jsxs)("div",{className:"flex rounded-md border bg-background focus-within:ring-[3px] focus-within:ring-ring/50",children:[(0,n.jsx)("input",{readOnly:!0,value:V,className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-base outline-none"}),(0,n.jsxs)("button",{type:"button",onClick:()=>void eQ(V),className:"flex h-9 items-center gap-1.5 rounded-r-md px-3 text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset",children:[(0,n.jsx)(en.A,{className:"size-4"}),"開啟"]})]})]})]})]}):y?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>w(null),disabled:P,className:"inline-flex items-center gap-1.5 rounded-sm text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:[(0,n.jsx)(t1.A,{className:"size-4"}),"返回設定"]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["為了使用 AI 功能,請綁定您的個人 API 金鑰。前往 ",y.platform,"後台建立 API 金鑰並手動貼上。這是個本地執行的應用程式,因此不會將您所儲存的資訊上傳到任何地方。"]}),(0,n.jsxs)("button",{type:"button",onClick:()=>void eQ(y.keyUrl),className:"inline-flex items-center gap-1.5 rounded-sm text-base text-primary outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:["前往 ",y.platform,(0,n.jsx)(en.A,{className:"size-3.5"})]})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"API key"}),(0,n.jsxs)("div",{className:"flex rounded-md border bg-background focus-within:ring-[3px] focus-within:ring-ring/50",children:[(0,n.jsx)("input",{name:`${y.id}-api-key`,autoComplete:"off",value:C,onChange:e=>A(e.target.value),type:S?"text":"password",placeholder:ea?.connected?"輸入新的 API key 以更新連線":"貼上 API key",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-base outline-none"}),(0,n.jsx)("button",{type:"button",onClick:()=>z(e=>!e),className:"flex w-9 items-center justify-center rounded-r-md text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset","aria-label":S?"隱藏 API key":"顯示 API key",children:S?(0,n.jsx)(t2.A,{className:"size-4"}):(0,n.jsx)(t3.A,{className:"size-4"})})]})]}),(E||ea?.error)&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:E??ea?.error})]}):ee?(0,n.jsx)(sn,{onEditingChange:er}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(tF,{value:v,onChange:N}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"flex items-center justify-between",children:(0,n.jsxs)("span",{className:"text-base font-medium",children:["工作站資料夾",(0,n.jsx)("span",{className:(0,k.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",""===b.trim()?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:""===b.trim()?"預設(~/Desktop)":"已自訂"})]})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{name:"workstation-path",autoComplete:"off",spellCheck:!1,value:b,placeholder:"~/Desktop",onChange:e=>j(e.target.value),className:(0,k.cn)(t$,"font-mono text-sm")}),(0,n.jsx)(eh,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void ed(),children:"選擇資料夾"})]}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["每個任務的 worktree 與執行期檔案會建立在 ","<工作站>/<專案名>/"," 底下;留空則預設為 ~/Desktop。"]})]}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"flex items-center justify-between",children:(0,n.jsxs)("span",{className:"text-base font-medium",children:["System Prompt",(0,n.jsx)("span",{className:(0,k.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",eo?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:eo?"未設定":"已自訂"})]})}),(0,n.jsx)("textarea",{name:"system-prompt",autoComplete:"off",value:p,onChange:e=>g(e.target.value),rows:10,spellCheck:!1,className:(0,k.cn)(t$,"resize-y font-mono text-sm leading-5")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟動 Agent 時會以此 prompt 作為 system prompt;留空則只帶入任務專屬的 Artifact 設定。"})]}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-base font-medium",children:"Library"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"VibeFlow 自有的 skill / prompt / script。啟用的項目會在啟動任務時自動投遞給 Claude 與 Codex,不必依賴本機的 ~/.claude 或 ~/.codex 佈局。"})]}),(0,n.jsxs)(eh,{variant:"secondary",size:"sm",onClick:()=>et(!0),children:[(0,n.jsx)(t4.A,{className:"size-3.5"}),"管理 Library"]})]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-base font-medium",children:"CLI 與帳號設定"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"設定 Agent CLI 的 API key 以同步 model;設定 GitHub CLI 以支援本機 GitHub 操作。"})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[sr.map(e=>{let t=i?.[e.id],s=t?.connected&&(t.models?.length??0)>0;return(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[s?(0,n.jsx)(_.A,{className:"size-4 shrink-0 text-success"}):t?.error?(0,n.jsx)(u.A,{className:"size-4 shrink-0 text-destructive"}):(0,n.jsx)("span",{className:"size-4 shrink-0 rounded-full border border-muted-foreground/50"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"text-base font-medium",children:e.name}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:s?`${t?.models?.length??0} 個 models 可用`:t?.error??"尚未連線"})]}),s&&x&&(0,n.jsx)(eh,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",disabled:R===e.id,"aria-label":"重新整理 model 列表",onClick:async()=>{$(e.id),await x(e.id),$(null)},children:(0,n.jsx)(em.A,{className:(0,k.cn)("size-4",R===e.id&&"animate-spin")})}),(0,n.jsx)(eh,{type:"button",size:"sm",variant:"outline",onClick:()=>{w(e),A(""),z(!1),I(null)},children:s?"設定":"Connect"})]},e.id)}),(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[L?.authenticated?(0,n.jsx)(_.A,{className:"size-4 shrink-0 text-success"}):L?.error?(0,n.jsx)(u.A,{className:"size-4 shrink-0 text-destructive"}):(0,n.jsx)("span",{className:"size-4 shrink-0 rounded-full border border-muted-foreground/50"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"text-base font-medium",children:"GitHub CLI"}),(0,n.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:L?.authenticated?`${L.login??"GitHub"} 已授權(${L.gitProtocol??"https"})`:L?.installed===!1?"找不到 GitHub CLI(gh)":L?.error?L.error:"尚未授權"})]}),L?.authenticated&&(0,n.jsx)(eh,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:X,onClick:()=>void ex(),children:"切換使用者"}),L?.authenticated&&(0,n.jsxs)(eh,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:X,onClick:()=>void ep(),children:[X?(0,n.jsx)(D.A,{className:"size-4 animate-spin"}):(0,n.jsx)(t6.A,{className:"size-4"}),"登出"]}),!L?.authenticated&&(0,n.jsx)(eh,{type:"button",size:"sm",variant:"outline",disabled:L?.installed===!1||X,onClick:()=>void ex(),children:X?"啟動中…":"登入"})]})]}),U&&!B&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:U}),ei>0&&(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["目前共有 ",ei," 個已同步 model 可供 task 選擇。"]})]}),c&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:c})]})},"settings-dialog")})}var si=s(93202),sl=s(51256),so=s(27955),sc=s(26814),sd=s(6684),su=s(76750),sm=s(80136);function sx(e){return e.projectName||function(e){if(!e)return"";let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}(e.projectPath)||"Unassigned"}let sf={in_progress:0,backlog:1,done:2};function sh(e){return e.hasSelected||e.tasks.some(e=>"done"!==e.column)}let sp={backlog:"Backlog",in_progress:"In Progress",done:"Done"};function sg({entry:e,selected:t,onSelectTask:s}){let r=(0,c.I)()??!1,a="done"===e.column?null:"in_progress"===e.column?{className:"text-warning",pillClassName:"bg-warning/10 text-warning",icon:(0,n.jsx)("span",{className:"flex size-3 shrink-0 items-center justify-center",children:(0,n.jsx)("span",{className:"size-1.5 rounded-full bg-warning animate-pulse"})})}:{className:"text-muted-foreground",pillClassName:"bg-muted-foreground/10 text-muted-foreground",icon:(0,n.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/60"})};return(0,n.jsxs)(d.PY1.button,{"data-selected-task":t||void 0,type:"button",onClick:()=>s(e.task.id),whileTap:r?void 0:{scale:.99,opacity:.9},transition:{duration:r?0:V.micro,ease:K.enter},className:(0,k.cn)("flex w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-left text-sm transition-colors motion-reduce:transition-none outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",t?"bg-primary/15 font-medium text-primary":"done"===e.column?"text-muted-foreground/60 hover:bg-accent/50 hover:text-muted-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:e.task.title,children:[(0,n.jsx)("span",{className:(0,k.cn)("flex size-3 shrink-0 items-center justify-center",a?.className),children:a?.icon}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.task.title}),a?(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 rounded-full px-1.5 py-0.5 text-xs font-medium",a.pillClassName),children:sp[e.column]}):null]})}function sb({id:e,project:t,selectedTaskId:s,onSelectTask:r}){let a=(0,H.tF)(),i=(0,c.I)()??!1;return(0,n.jsx)(d.PY1.div,{id:e,initial:"hidden",animate:"visible",exit:"exit",variants:X({timing:"standard",exitTiming:"micro",transform:{y:-4},reducedMotion:i}),inert:!a,"aria-hidden":!a||void 0,className:(0,k.cn)("ml-3 space-y-0.5",!a&&"pointer-events-none"),children:0===t.tasks.length?(0,n.jsx)("p",{className:"px-2 py-0.5 text-sm text-muted-foreground/60",children:"尚無任務"}):t.tasks.map(e=>(0,n.jsx)(sg,{entry:e,selected:e.task.id===s,onSelectTask:r},e.task.id))})}function sj({project:e,expanded:t,selectedTaskId:s,onToggle:a,onSelectTask:i,onNewTaskForProject:o,onDeleteProject:c}){let d=(0,r.useId)();return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:(0,k.cn)("group flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground",e.hasSelected&&"text-foreground"),children:[(0,n.jsxs)("button",{type:"button","aria-expanded":t,"aria-controls":d,onClick:a,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",title:e.path??e.name,children:[t?(0,n.jsx)(j.A,{className:"size-3 shrink-0"}):(0,n.jsx)(L.A,{className:"size-3 shrink-0"}),(0,n.jsx)(ed.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.name})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground group-hover:hidden",children:e.tasks.length}),(0,n.jsxs)("div",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[(0,n.jsx)(C,{"aria-label":`在 ${e.name} 新增任務`,title:"在此專案新增任務",onClick:()=>o(e.path),className:"p-0.5",children:(0,n.jsx)(N.A,{className:"size-3"})}),(0,n.jsx)(C,{"aria-label":`刪除專案 ${e.name}`,title:"刪除整個專案(含所有任務)",tone:"danger",onClick:()=>c(e.name,e.tasks.map(e=>e.task.id)),className:"p-0.5",children:(0,n.jsx)(x.A,{className:"size-3"})})]})]}),(0,n.jsx)(l.N,{initial:!1,children:t&&(0,n.jsx)(sb,{id:d,project:e,selectedTaskId:s,onSelectTask:i},e.key)})]})}function sv({mode:e,className:t,children:s}){let r=(0,c.I)()??!1;return(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:W({timing:"micro",reducedMotion:r}),className:t,children:s},e)}function sN({collapsed:e,onRemoteShare:t,remoteActive:s,onOpenSettings:r}){return e?(0,n.jsxs)(sv,{mode:"collapsed",className:"flex flex-col items-center gap-1 border-t border-border p-2",children:[t&&(0,n.jsx)(C,{"aria-label":"遠端控制",onClick:t,title:"遠端控制",className:(0,k.cn)("size-8",s&&"text-primary hover:text-primary"),children:(0,n.jsx)(si.A,{className:"size-4"})}),(0,n.jsx)(C,{"aria-label":"設定 System Prompt",onClick:r,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(sl.A,{className:"size-4"})})]}):(0,n.jsx)(sv,{mode:"expanded",className:"border-t border-border p-2",children:(0,n.jsxs)("div",{className:"flex items-center gap-1 px-1",children:[t&&(0,n.jsx)(C,{"aria-label":"遠端控制",onClick:t,title:"遠端控制",className:(0,k.cn)(s?"text-primary hover:text-primary":"text-muted-foreground hover:text-foreground"),children:(0,n.jsx)(si.A,{className:"size-4"})}),(0,n.jsx)(C,{"aria-label":"設定 System Prompt",onClick:r,title:"設定(System Prompt)",children:(0,n.jsx)(sl.A,{className:"size-4"})})]})})}function sy({value:e,onChange:t}){return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(so.A,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,n.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),onKeyDown:s=>{"Escape"===s.key&&e&&(s.preventDefault(),t(""))},placeholder:"搜尋任務","aria-label":"搜尋任務",className:"h-8 w-full rounded-md border border-border bg-background pl-7 pr-7 text-sm text-foreground outline-none transition-colors motion-reduce:transition-none placeholder:text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50"}),e?(0,n.jsx)("button",{type:"button","aria-label":"清除搜尋",title:"清除搜尋",onClick:()=>t(""),className:"absolute right-1.5 top-1/2 flex size-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)(O.A,{className:"size-3.5"})}):null]})}function sk({collapsed:e,onToggleCollapse:t,board:s,selectedTaskId:a,onSelectTask:i,onNewTask:l,onNewTaskForProject:o,onDeleteProject:u,onRemoteShare:m,remoteActive:x,onOpenSettings:f}){let[h,p]=(0,r.useState)({}),[g,b]=(0,r.useState)(""),j=(0,c.I)()??!1,v=W({timing:"micro",reducedMotion:j}),w=g.trim().toLowerCase(),A=!e&&w.length>0,S=function(e,t){var s;let n=new Map;for(let r of[...e.in_progress.map(e=>({task:e,column:"in_progress"})),...e.backlog.map(e=>({task:e,column:"backlog"})),...e.done.map(e=>({task:e,column:"done"}))]){let e=(s=r.task).projectPath||`name:${sx(s)}`,a=n.get(e)??{key:e,name:sx(r.task),path:r.task.projectPath??null,tasks:[],total:0,hasSelected:!1};a.tasks.push(r),a.total+=1,a.hasSelected||=r.task.id===t,n.set(e,a)}for(let e of n.values())e.tasks=[...e.tasks].sort((e,t)=>{var s,n;let r=sf[e.column]-sf[t.column];return 0!==r?r:(s=e.task,n=t.task,s.createdAt===n.createdAt?0:void 0===s.createdAt?1:void 0===n.createdAt?-1:n.createdAt-s.createdAt)});return Array.from(n.values()).sort((e,t)=>e.name.localeCompare(t.name))}(s,a),z=A?S.map(e=>({...e,tasks:e.tasks.filter(e=>e.task.title.toLowerCase().includes(w))})).filter(e=>e.tasks.length>0):S,E=S.map(e=>e.key).join(" ");(0,r.useEffect)(()=>{p(e=>{let t=!1,s={...e};for(let e of S)e.key in s||(s[e.key]=sh(e),t=!0);return t?s:e})},[E]);let I=e=>A||(h[e.key]??sh(e)),P=z.length>0&&z.every(e=>I(e));return(0,r.useEffect)(()=>{let e=document.querySelector("aside [data-selected-task]");e?.scrollIntoView({block:"nearest"})},[a]),(0,n.jsxs)(d.PY1.aside,{initial:!1,animate:{width:e?48:320},transition:{duration:j?0:V.spatial,ease:K.enter},className:"flex flex-shrink-0 flex-col overflow-x-clip border-r border-border bg-card text-card-foreground",children:[(0,n.jsxs)("div",{className:(0,k.cn)("flex h-12 shrink-0 items-center border-b border-border px-3",e?"justify-center":"justify-between"),children:[!e&&(0,n.jsxs)(d.PY1.span,{initial:"hidden",animate:"visible",variants:v,className:"flex items-center gap-2 text-[15px] font-semibold tracking-tight text-foreground",children:[(0,n.jsx)("img",{src:"/logo.svg",alt:"",className:"size-5"}),"VibeFlow"]}),(0,n.jsx)(C,{"aria-label":e?"展開選單":"收合選單",onClick:t,title:e?"展開選單":"收合選單",className:"group p-1",children:e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("img",{src:"/logo.svg",alt:"",className:"size-5 group-hover:hidden group-focus-visible:hidden"}),(0,n.jsx)(sc.A,{className:"hidden size-4 group-hover:block group-focus-visible:block"})]}):(0,n.jsx)(sd.A,{className:"size-4"})})]}),(0,n.jsx)(sv,{mode:e?"collapsed":"expanded",className:(0,k.cn)("shrink-0 px-2 pt-3",e?"flex justify-center":"w-full"),children:e?(0,n.jsx)(C,{"aria-label":"新增任務",onClick:l,title:"新增任務",className:"size-8 p-1.5",children:(0,n.jsx)(N.A,{className:"size-4"})}):(0,n.jsxs)(eh,{size:"sm",className:"w-full rounded-md active:scale-95",onClick:l,children:[(0,n.jsx)(N.A,{}),"新增任務"]})}),!e&&(0,n.jsx)(sv,{mode:"expanded",className:"shrink-0 px-2 pt-2",children:(0,n.jsx)(sy,{value:g,onChange:b})}),(0,n.jsx)("div",{className:(0,k.cn)("flex flex-1 flex-col py-3",e?"overflow-hidden":"overflow-y-auto"),children:(0,n.jsx)("div",{className:"px-2",children:e?null:(0,n.jsxs)(d.PY1.div,{initial:"hidden",animate:"visible",variants:v,children:[(0,n.jsxs)("div",{className:"mb-1 flex items-center gap-1 px-2",children:[(0,n.jsx)("span",{className:y,children:"Projects"}),!A&&z.length>0&&(0,n.jsx)(C,{"aria-label":P?"全部收合":"全部展開",title:P?"全部收合":"全部展開",onClick:()=>{let e=!P;p(t=>{let s={...t};for(let t of z)s[t.key]=e;return s})},className:"ml-auto p-0.5",children:P?(0,n.jsx)(su.A,{className:"size-3.5"}):(0,n.jsx)(sm.A,{className:"size-3.5"})})]}),(0,n.jsx)("div",{className:"space-y-1",children:0===z.length?(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground",children:A?"找不到符合的任務":"尚無任務"}):z.map(e=>{let t=I(e);return(0,n.jsx)(sj,{project:e,expanded:t,selectedTaskId:a,onToggle:()=>p(s=>({...s,[e.key]:!t})),onSelectTask:i,onNewTaskForProject:o,onDeleteProject:u},e.key)})})]},"expanded-projects")})}),(0,n.jsx)(sN,{collapsed:e,onRemoteShare:m,remoteActive:x,onOpenSettings:f})]})}function sw({entries:e,activeTaskId:t,onSelect:s,onPin:r,onClose:a}){return 0===e.length?null:(0,n.jsx)("div",{className:"flex h-9 shrink-0 items-stretch overflow-x-auto overflow-y-hidden border-b border-border bg-card/40",children:e.map(e=>{let i=e.taskId===t;return(0,n.jsxs)("div",{className:(0,k.cn)("group flex h-full min-w-0 max-w-52 shrink-0 items-center gap-1 border-r border-border/60 pl-3 pr-1.5 transition-colors motion-reduce:transition-none",i?"bg-background text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"),children:[(0,n.jsxs)("button",{type:"button","aria-current":i?"page":void 0,title:e.title,onClick:()=>s(e.taskId),onDoubleClick:()=>r(e.taskId),onAuxClick:t=>{1===t.button&&a(e.taskId)},className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm py-0.5 text-left text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:(0,k.cn)("size-1.5 shrink-0 rounded-full","in_progress"===e.column?"bg-warning animate-pulse":"bg-muted-foreground/50")}),(0,n.jsx)("span",{className:(0,k.cn)("min-w-0 truncate",e.preview&&"italic"),children:e.title})]}),(0,n.jsx)("button",{type:"button","aria-label":`關閉分頁 ${e.title}`,title:"關閉分頁(執行中的 agent 會繼續在背景執行)",onClick:()=>a(e.taskId),className:(0,k.cn)("flex size-5 shrink-0 items-center justify-center rounded-sm outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:opacity-100",i?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(O.A,{className:"size-3"})})]},e.taskId)})})}var sC=s(4504);function sA({roomCode:e,peerCount:t,onClose:a,onStop:i}){let l=`https://vibe-flow-remote.vercel.app/?room=${e}`,[o,c]=(0,r.useState)(""),[d,u]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=!0;return s.e(167).then(s.t.bind(s,20167,19)).then(({default:t})=>{t.toDataURL(l,{width:240,margin:2}).then(t=>{e&&c(t)})}),()=>{e=!1}},[l]),(0,n.jsxs)(q,{title:"遠端控制",onClose:a,showHeader:!0,contentClassName:"max-w-xs",children:[(0,n.jsx)("div",{className:"mb-4 flex justify-center",children:o?(0,n.jsx)("img",{src:o,alt:"QR Code",width:200,height:200,className:"rounded-md"}):(0,n.jsx)("div",{className:"flex h-[200px] w-[200px] items-center justify-center rounded-md bg-muted",children:(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"生成中…"})})}),(0,n.jsxs)("div",{className:"mb-3 text-center",children:[(0,n.jsx)("p",{className:"mb-1 text-sm text-muted-foreground",children:"Room Code"}),(0,n.jsx)("p",{className:"font-mono text-3xl font-bold tracking-widest",children:e})]}),(0,n.jsxs)("div",{className:"mb-4 flex items-center justify-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(sC.A,{className:"size-3"}),(0,n.jsx)("span",{children:t>0?`${t} 台裝置已連線`:"等待裝置連線…"})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:function(){navigator.clipboard.writeText(l),u(!0),setTimeout(()=>u(!1),2e3)},className:"flex flex-1 items-center justify-center gap-1.5 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[d?(0,n.jsx)(v.A,{className:"size-3.5"}):(0,n.jsx)(M.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(eh,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function sS(e,t){return{capabilities:{createTask:!1},tasks:["backlog","in_progress","done"].flatMap(t=>e[t].map(e=>({id:e.id,title:e.title,description:e.description,projectName:e.projectName,column:t,launchedAt:e.launchedAt}))),workspaces:[],settings:{autoMode:t}}}let sz={backlog:[],in_progress:[],done:[]},sE=["in_progress","backlog","done"];function sI(){let[e,t]=(0,r.useState)(sz),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)(!0),[m,x]=(0,r.useState)(""),[f,h]=(0,r.useState)(""),[p,g]=(0,r.useState)({}),[b,j]=(0,r.useState)(!1),[v,N]=(0,r.useState)(!1),[y,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)(null),[A,S]=(0,r.useState)(!1),[z,E]=(0,r.useState)(null),[I,P]=(0,r.useState)(null),[T,R]=(0,r.useState)(!1),[$,B]=(0,r.useState)(null),[_,M]=(0,r.useState)(!1),[L,F]=(0,r.useState)(!0),[G,O]=(0,r.useState)(null),[H,Y]=(0,r.useState)([]),[V,K]=(0,r.useState)(null),[U,W]=(0,r.useState)(0),[X,J]=(0,r.useState)(null),[Q,Z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=!0;return ej().then(s=>{e&&(s&&(t(s.board),d(s.settings.autoMode),x(s.settings.systemPrompt??""),h(s.settings.workstationPath??""),g(s.settings.agentConnections??{})),j(!0))}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let t;return e=({taskId:e,subAgents:t})=>{o(s=>({...s,[e]:t}))},(t=eb())?t.onSubAgentsUpdate(e):()=>{}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),d(e.settings.autoMode),x(e.settings.systemPrompt??""),h(e.settings.workstationPath??""),g(e.settings.agentConnections??{})},(s=eb())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{let t=new Set(Object.values(e).flat().map(e=>e.id));Y(e=>e.every(e=>t.has(e.taskId))?e:e.filter(e=>t.has(e.taskId))),O(e=>e&&!t.has(e)?null:e)},[e]);let ee=(e,t)=>{Y(s=>{let n=s.find(t=>t.taskId===e);if(n)return t?.pin&&n.preview?s.map(t=>t.taskId===e?{...t,preview:!1}:t):s;let r={taskId:e,preview:t?.pin!==!0},a=s.findIndex(e=>e.preview);if(r.preview&&-1!==a){let e=[...s];return e[a]=r,e}return[...s,r]}),O(e)},et=e=>{Y(t=>t.some(t=>t.taskId===e&&t.preview)?t.map(t=>t.taskId===e?{...t,preview:!1}:t):t)},es=e=>{let t=new Set(e);if(G&&t.has(G)){let e=H.findIndex(e=>e.taskId===G),s=H.slice(e+1).find(e=>!t.has(e.taskId)),n=H.slice(0,Math.max(e,0)).reverse().find(e=>!t.has(e.taskId));O(s?.taskId??n?.taskId??null)}Y(e=>e.filter(e=>!t.has(e.taskId)))},en=()=>{E(null),K(null),W(e=>e+1),O(null)},er=async(e,t,s)=>{k(!0),C(null);try{await eN({systemPrompt:e,workstationPath:t||void 0,autoMode:s}),x(e),h(t),d(s),N(!1)}catch(e){C(e instanceof Error?e.message:String(e))}finally{k(!1)}},ea=async(e,t)=>{k(!0),C(null);try{let s=await ey(e,t);return s&&g(s.settings.agentConnections??{}),null}catch(t){let e=t instanceof Error?t.message:String(t);return C(e),e}finally{k(!1)}},ei=async e=>{let t=await ek(e);t&&g(t.settings.agentConnections??{})},el=async(e,s,n,r,a,i,l,o,c,d)=>{S(!0),E(null);try{let u=await e$({title:e,description:s,projectPath:n,baseBranch:r,branch:a||void 0,agentCli:i,model:l||void 0,effort:o,autoMode:c,attachments:d});u&&(t(u.state.board),ee(u.task.id,{pin:!0}))}catch(e){E(e instanceof Error?e.message:String(e))}finally{S(!1)}},eo=async e=>{if(I){R(!0),B(null);try{let s=await eB({taskId:I.id,title:e.title,description:e.description,agentCli:e.agentCli,model:e.model||void 0,effort:e.effort,autoMode:e.autoMode,projectPath:e.projectPath,baseBranch:e.baseBranch});s&&t(s.board),P(null)}catch(e){B(e instanceof Error?e.message:String(e))}finally{R(!1)}}},ec=async e=>{let s=await eZ(e);s&&t(s.board)},ed=async e=>{let s=await e0(e);s&&(t(s.board),es([e]))},eu=async()=>{if(X){Z(!0);try{let e=null;for(let t of X.taskIds){let s=await e0(t);s&&(e=s.board)}e&&t(e),es(X.taskIds),J(null)}finally{Z(!1)}}},em=H.flatMap(t=>{for(let s of sE){let n=e[s].find(e=>e.id===t.taskId);if(n)return[{...t,title:n.title,column:s}]}return[]}),ex=function({board:e,autoMode:t,onStateChange:n}){let[a,i]=(0,r.useState)(null),[l,o]=(0,r.useState)(0),c=(0,r.useRef)(new Set),d=(0,r.useRef)(new Map),u=(0,r.useRef)(e),m=(0,r.useRef)(t),x=(0,r.useRef)(n);async function f(e,t){if(!e||"object"!=typeof e)return;let{type:s,payload:n}=e;switch(s){case"client:get-state":try{t.send({type:"vf:state",payload:sS(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;e2(e,String(t).slice(0,1e3));break}case"client:subscribe-terminal":{let{taskId:e}=n??{};if(!e)break;let s=d.current.get(e);s||(s=new Set,d.current.set(e,s)),s.add(t);break}case"client:unsubscribe-terminal":{let{taskId:e}=n??{};e&&d.current.get(e)?.delete(t);break}case"client:move-task":{let{taskId:e,targetColumn:t}=n??{};if(!e||!t)break;let s=function(e,t,s){let n,r={...e};for(let e of["backlog","in_progress","done"]){let s=r[e].findIndex(e=>e.id===t);if(-1!==s){n=r[e][s],r[e]=r[e].filter(e=>e.id!==t);break}}return n?(r[s]=[n,...r[s]],r):e}(u.current,e,t);x.current(s),await ev(s)}}}return(0,r.useEffect)(()=>{u.current=e},[e]),(0,r.useEffect)(()=>{m.current=t},[t]),(0,r.useEffect)(()=>{x.current=n},[n]),(0,r.useEffect)(()=>{if(!c.current.size)return;let s=sS(e,t);for(let e of c.current)try{e.send({type:"vf:state",payload:s})}catch{}},[e,t]),(0,r.useEffect)(()=>{let e;if(!a)return;let t=!1;return async function(){let{Peer:n}=await s.e(1886).then(s.bind(s,11886));t||((e=new n(`vibeflow-${a}`)).on("connection",e=>{c.current.add(e),o(e=>e+1),e.on("open",()=>{(async()=>{try{e.send({type:"vf:hello",payload:{version:"1.0"}}),e.send({type:"vf:state",payload:sS(u.current,m.current)})}catch{}})()}),e.on("data",t=>{f(t,e)}),e.on("close",()=>{for(let[,t]of(c.current.delete(e),o(e=>e-1),d.current))t.delete(e)})}),e.on("error",e=>{console.error("[VibeFlow Remote] PeerJS error:",e)}))}(),()=>{for(let e of(t=!0,c.current))try{e.close()}catch{}c.current.clear(),d.current.clear(),o(0),e?.destroy()}},[a]),(0,r.useEffect)(()=>{if(a){var e;let t;return e=({sessionKey:e,data:t})=>{let s=e.split(":")[0],n=d.current.get(s);if(!n?.size)return;let r={type:"vf:terminal-chunk",payload:{taskId:s,data:t}};for(let e of n)try{e.send(r)}catch{}},(t=eb())?t.term.onData(e):()=>{}}},[a]),{roomCode:a,peerCount:l,startSharing:()=>{i(String(Math.floor(1e5+9e5*Math.random())))},stopSharing:()=>i(null)}}({board:e,autoMode:c,onStateChange:e=>{t(e),ev(e)}});return(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(i(),{children:(0,n.jsx)("title",{children:"VibeFlow"})}),(0,n.jsx)("div",{className:"bg-background text-foreground",children:b?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(sk,{collapsed:L,onToggleCollapse:()=>F(e=>!e),board:e,selectedTaskId:G,onSelectTask:ee,onNewTask:en,onNewTaskForProject:e=>{E(null),K(e),W(e=>e+1),O(null)},onDeleteProject:(e,t)=>{0!==t.length&&J({name:e,taskIds:t})},remoteActive:!!ex.roomCode,onOpenSettings:()=>{C(null),N(!0)}}),(0,n.jsx)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:(0,n.jsx)("div",{className:"min-h-0 flex-1",children:(0,n.jsx)(tQ,{tabBar:(0,n.jsx)(sw,{entries:em,activeTaskId:G,onSelect:ee,onPin:et,onClose:e=>es([e])}),onSelectTask:ee,onNewTask:en,board:e,onBoardChange:e=>{t(e),ev(e)},onEditTask:t=>{B(null),P(function(e,t){for(let s of Object.values(e)){let e=s.find(e=>e.id===t);if(e)return e}return null}(e,t))},onTaskDone:ec,onDeleteTask:ed,autoMode:c,workstationPath:f,subAgents:a,selectedTaskId:G,onTaskInteract:et,openTabIds:H.map(e=>e.taskId),initialProjectPath:V,newTaskNonce:U,creating:A,createError:z,pickFolder:eE,loadRecentProjects:eP,loadGitInfo:eI,initRepository:eT,detectAgents:eR,agentConnections:p,onCreateTask:el})})})]}),(0,n.jsx)(t0,{task:I,defaultAutoMode:c,detectAgents:eR,agentConnections:p,pickFolder:eE,loadRecentProjects:eP,loadGitInfo:eI,saving:T,error:$,onSubmit:eo,onClose:()=>P(null)}),(0,n.jsx)(sa,{open:v,systemPrompt:m,workstationPath:f,autoMode:c,agentConnections:p,saving:y,error:w,onSave:er,onConnectAgent:ea,onRefreshModels:ei,onPickFolder:eE,onClose:()=>N(!1)}),(0,n.jsx)(l.N,{children:A&&(0,n.jsx)(q,{title:"建立任務中",saving:!0,onClose:()=>{},contentClassName:"max-w-sm rounded-lg p-5",children:(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary/15 text-primary",children:(0,n.jsx)(D.A,{className:"size-5 animate-spin"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"正在建立 workspace"}),(0,n.jsx)("p",{className:"text-base leading-6 text-muted-foreground",children:"正在建立 git worktree、分支與任務資料。完成前請先不要切換或操作其他任務。"})]})]})})},"creating-task-dialog")}),(0,n.jsx)(l.N,{children:X&&(0,n.jsx)(q,{title:"刪除專案",saving:Q,onClose:()=>{Q||J(null)},contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["刪除專案「",X.name,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除此專案底下的 ",X.taskIds.length," ","個任務,包含它們的 worktree、branch 與對話紀錄。此操作無法復原。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",className:"rounded-full",disabled:Q,onClick:()=>J(null),children:"取消"}),(0,n.jsx)(eh,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",disabled:Q,onClick:eu,children:Q?"刪除中…":"刪除專案"})]})]})},"delete-project-dialog")}),(0,n.jsx)(l.N,{children:_&&ex.roomCode&&(0,n.jsx)(sA,{roomCode:ex.roomCode,peerCount:ex.peerCount,onClose:()=>M(!1),onStop:()=>{ex.stopSharing(),M(!1)}},"remote-share-dialog")})]}):(0,n.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground",children:"載入中…"})})]})}},24464:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/home",function(){return s(2908)}])}},e=>{e.O(0,[5896,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},__routerFilterDynamic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-8f65b0f8749f42d2.js"],"/home":["static/chunks/5896-9ec24bfe388d6661.js","static/chunks/pages/home-132f9ce2b08bd09d.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},__routerFilterDynamic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-8f65b0f8749f42d2.js"],"/home":["static/chunks/5896-9ec24bfe388d6661.js","static/chunks/pages/home-24e1e93575324064.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/5576c1267923e491.css" as="style"/><link rel="stylesheet" href="/_next/static/css/5576c1267923e491.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8aa5df0425f6b7b.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-fde992b12936b886.js" defer=""></script><script src="/_next/static/chunks/5896-9ec24bfe388d6661.js" defer=""></script><script src="/_next/static/chunks/pages/home-132f9ce2b08bd09d.js" defer=""></script><script src="/_next/static/zygbxZW3DHGve5whWS7yR/_buildManifest.js" defer=""></script><script src="/_next/static/zygbxZW3DHGve5whWS7yR/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div class="bg-background text-foreground"><div class="flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground">載入中…</div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/home","query":{},"buildId":"zygbxZW3DHGve5whWS7yR","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/5576c1267923e491.css" as="style"/><link rel="stylesheet" href="/_next/static/css/5576c1267923e491.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8aa5df0425f6b7b.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-fde992b12936b886.js" defer=""></script><script src="/_next/static/chunks/5896-9ec24bfe388d6661.js" defer=""></script><script src="/_next/static/chunks/pages/home-24e1e93575324064.js" defer=""></script><script src="/_next/static/jWK_7LAWT3o0Q0pMgqN9g/_buildManifest.js" defer=""></script><script src="/_next/static/jWK_7LAWT3o0Q0pMgqN9g/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div class="bg-background text-foreground"><div class="flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground">載入中…</div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/home","query":{},"buildId":"jWK_7LAWT3o0Q0pMgqN9g","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kw-yeh/vibeflow",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "Intent-driven local kanban for coding agents: git worktree per card, Web UI and TUI.",
5
5
  "license": "MIT",
6
6
  "author": "KW-Yeh",
@@ -1,11 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9845],{2908:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>sE});var n=s(26514),r=s(75834),a=s(24322),i=s.n(a),l=s(18690),o=s(80527),c=s(67297),d=s(5026),u=s(29334),m=s(71520),x=s(44416),f=s(58629),h=s(17329),p=s(70170),g=s(87854),b=s(78999),j=s(85781),v=s(38031),N=s(74567);let y="text-xs font-semibold uppercase tracking-wider text-muted-foreground";var k=s(4416);let w={default:"text-muted-foreground hover:bg-accent hover:text-foreground",primary:"text-muted-foreground hover:bg-accent hover:text-primary",danger:"text-muted-foreground hover:bg-destructive/15 hover:text-destructive"},C=r.forwardRef(({className:e,children:t,tone:s="default",type:r="button",...a},i)=>(0,n.jsx)("button",{ref:i,type:r,className:(0,k.cn)("inline-flex shrink-0 items-center justify-center rounded-full p-1.5 transition-colors outline-none active:scale-95 motion-reduce:transform-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 disabled:active:scale-100 [&_svg]:pointer-events-none",w[s],e),...a,children:t}));C.displayName="IconButton";let A=["backlog","in_progress","done"],S={backlog:"Backlog",in_progress:"In Progress",done:"Done"},z={backlog:"bg-muted-foreground/60",in_progress:"bg-warning animate-pulse",done:"bg-success"};function E(e){if(e.projectName)return e.projectName;let t=(e.projectPath??"").split(/[/\\]/).filter(Boolean);return t[t.length-1]??"未指定專案"}function I(e,t){let s=(0,r.useRef)(null);return(0,r.useEffect)(()=>{if(!e)return;let n=e=>{s.current?.contains(e.target)||t()},r=e=>{"Escape"===e.key&&t()};return window.addEventListener("mousedown",n),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",r)}},[e,t]),s}let P="flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors motion-reduce:transition-none";function T({task:e,anchor:t,onEdit:s,onDelete:a,onClose:i}){let[l,o]=(0,r.useState)(!1),c=I(!0,i),d=Math.max(8,Math.min(t.right-208,window.innerWidth-208-8)),u=Math.max(8,Math.min(t.top,window.innerHeight-224));return(0,n.jsxs)("div",{ref:c,role:"menu",style:{top:u,left:d},onClick:e=>e.stopPropagation(),className:"fixed z-50 w-52 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:[(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{s(),i()},className:(0,k.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",P,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)(m.A,{className:"size-3.5 shrink-0"}),"編輯任務"]}),l?(0,n.jsxs)("div",{className:"flex items-center gap-1 rounded-sm bg-destructive/10 p-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>o(!1),className:"rounded-sm px-2 py-1 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:()=>{a(),i()},className:"ml-auto rounded-sm px-2 py-1 text-sm font-medium text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"確認刪除"})]}):(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>o(!0),className:(0,k.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",P,"text-destructive hover:bg-destructive/15"),title:`刪除任務「${e.title}」(清理 worktree)`,children:[(0,n.jsx)(x.A,{className:"size-3.5 shrink-0"}),"刪除任務"]})]})}function R({task:e,column:t,subAgentCount:s,selected:a,onSelect:i,onEdit:l,onDelete:o}){let c=(0,r.useRef)(null),[d,u]=(0,r.useState)(null),m=null!==d,x="done"===t;return(0,n.jsxs)("div",{ref:c,role:"button",tabIndex:0,"aria-label":`開啟任務:${e.title}`,onClick:i,onKeyDown:e=>{e.target!==e.currentTarget||("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},className:(0,k.cn)("relative cursor-pointer rounded-md border bg-card p-3 outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",x&&"bg-card/60",a?"border-primary shadow-[0_0_0_2px] shadow-primary/20":"border-border hover:border-input"),children:[(0,n.jsxs)("div",{className:"group/head flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(f.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:E(e)}),x?(0,n.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-xs bg-primary/15 px-1.5 py-0.5 font-medium text-primary",children:[(0,n.jsx)(h.A,{className:"size-2.5"}),"complete"]}):(0,n.jsxs)(n.Fragment,{children:[e.effort&&(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 font-medium",m?"hidden":"group-hover/head:hidden"),children:e.effort}),(0,n.jsx)(C,{"aria-label":`任務選項:${e.title}`,title:"移動、編輯或刪除",onClick:e=>{if(e.stopPropagation(),m)return void u(null);let t=c.current?.getBoundingClientRect();t&&u({top:t.top+32,right:t.right-4})},className:(0,k.cn)("size-5 p-0.5",m?"flex":"hidden group-hover/head:flex"),children:(0,n.jsx)(p.A,{className:"size-3.5"})})]})]}),(0,n.jsx)("div",{className:"mt-2",title:e.title,children:(0,n.jsx)("span",{className:(0,k.cn)("line-clamp-2 text-[15px] font-medium leading-[1.4]",x?"text-muted-foreground":"text-foreground"),children:e.title})}),(0,n.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.branch}),"in_progress"===t&&s>0&&(0,n.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,n.jsx)(b.A,{className:"size-3"}),s]})]}),d&&(0,n.jsx)(T,{task:e,anchor:d,onEdit:l,onDelete:o,onClose:()=>u(null)})]})}function $({projects:e,value:t,onChange:s}){let[a,i]=(0,r.useState)(!1),l=I(a,()=>i(!1));return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("button",{type:"button","aria-haspopup":"menu","aria-expanded":a,onClick:()=>i(e=>!e),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium text-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(f.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),t??"所有專案",(0,n.jsx)(j.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),a&&(0,n.jsx)("div",{ref:l,role:"menu",className:"absolute left-0 top-8 z-20 w-56 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:[null,...e].map(e=>(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{s(e),i(!1)},className:(0,k.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",P,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e??"所有專案"}),e===t&&(0,n.jsx)(v.A,{className:"size-3 shrink-0"})]},e??"__all__"))})]})}function B({board:e,subAgents:t,selectedTaskId:s,onSelectTask:a,onEditTask:i,onDeleteTask:l,onNewTask:o}){let[c,d]=(0,r.useState)(null),u=[...e.backlog,...e.in_progress,...e.done],m=Array.from(new Set(u.map(E))).sort((e,t)=>e.localeCompare(t)),x=c&&m.includes(c)?c:null,f=u.length;return(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,n.jsx)($,{projects:m,value:x,onChange:d}),(0,n.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[f," 個任務 \xb7 ",m.length," 個專案"]})]}),(0,n.jsx)("div",{className:"grid min-h-0 flex-1 grid-cols-3 gap-4 overflow-hidden px-5 pb-4 pt-3",children:A.map(r=>{let c=x?e[r].filter(e=>E(e)===x):e[r];return(0,n.jsxs)("section",{className:"flex min-h-0 flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 px-1",children:[(0,n.jsx)("span",{className:(0,k.cn)("size-1.5 shrink-0 rounded-full",z[r])}),(0,n.jsx)("h2",{className:(0,k.cn)(y,"in_progress"===r&&"text-warning"),children:S[r]}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:c.length})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto rounded-md p-1",children:[c.map(e=>(0,n.jsx)(R,{task:e,column:r,subAgentCount:(t[e.id]??[]).length,selected:e.id===s,onSelect:()=>a(e.id),onEdit:()=>i(e.id),onDelete:()=>l(e.id)},e.id)),"backlog"===r&&(0,n.jsxs)("button",{type:"button",onClick:o,className:"flex w-full items-center justify-center gap-1.5 rounded-md px-3 py-2.5 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(N.A,{className:"size-3.5"}),"新增任務"]}),0===c.length&&"backlog"!==r&&(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/60",children:"尚無任務"})]})]},r)})})]})}var D=s(78141),_=s(26392),M=s(85320),L=s(37055);let F=(0,r.lazy)(()=>Promise.all([s.e(7045),s.e(7915)]).then(s.bind(s,37915)));function G({source:e,compact:t=!1,className:s}){return(0,n.jsx)("div",{className:(0,k.cn)("prose max-w-none break-words rounded-md bg-muted/30 p-3 text-muted-foreground",t?"prose-xs":"prose-sm",s),children:(0,n.jsx)(r.Suspense,{fallback:null,children:(0,n.jsx)(F,{source:e,compact:t})})})}var O=s(72975),H=s(41487);let Y=0,V={micro:.12,standard:.16,spatial:.18},K={enter:[.2,0,0,1],exit:[.4,0,1,1]};function U(e,t,s,n=V[e]){return{duration:t?.01:n,ease:K[s]}}function W({timing:e,enterDuration:t,initialOpacity:s=0,transform:n,reducedMotion:r}){return{hidden:{opacity:s,...r?{}:n??{}},visible:{opacity:1,...r?{}:{...n?.x===void 0?{}:{x:0},...n?.y===void 0?{}:{y:0},...n?.scale===void 0?{}:{scale:1}},transition:U(e,r,"enter",t)}}}function X({timing:e,enterDuration:t,initialOpacity:s,exitTiming:n="micro",exitDuration:r,transform:a,exitTransform:i=a,reducedMotion:l}){return{...W({timing:e,enterDuration:t,initialOpacity:s,transform:a,reducedMotion:l}),exit:{opacity:0,...l?{}:i??{},transition:U(n,l,"exit",r)}}}function q({title:e,children:t,description:s,footer:a,showHeader:i=!1,className:l,contentClassName:o,bodyClassName:u,saving:m=!1,motionVariant:x="dialog",onClose:f}){let h=(0,r.useId)(),p=(0,r.useId)(),g=(0,r.useRef)(null),b=(0,r.useRef)("u">typeof document&&document.activeElement instanceof HTMLElement?document.activeElement:null),j=(0,r.useRef)(f),v=(0,r.useRef)(m),N=(0,H.tF)(),y=(0,c.I)()??!1,w=i||void 0!==s||void 0!==a||void 0!==u,A="drawer"===x,S=X({timing:"micro",enterDuration:.14,reducedMotion:y}),z=X({timing:A?"spatial":"standard",exitTiming:"micro",exitDuration:A?.14:void 0,transform:A?{x:16}:{scale:.98},reducedMotion:y});return(0,r.useEffect)(()=>{j.current=f,v.current=m},[f,m]),(0,r.useEffect)(()=>{let e;return Y+=1,e=!1,()=>{e||(e=!0,Y-=1)}},[]),(0,r.useEffect)(()=>{if(!N)return;g.current?.focus();let e=e=>{if("Escape"!==e.key||v.current)return;let t=document.querySelectorAll('[role="dialog"][aria-modal="true"]');t[t.length-1]===g.current&&j.current()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e),b.current?.focus()}},[N]),(0,n.jsxs)(d.PY1.div,{initial:"hidden",animate:"visible",exit:"exit",inert:!N,"aria-hidden":!N||void 0,"data-dialog-state":N?"present":"exiting",className:(0,k.cn)("fixed inset-0 z-50 flex items-center justify-center p-4",!N&&"pointer-events-none",l),children:[(0,n.jsx)(d.PY1.div,{variants:S,className:"absolute inset-0 bg-background/80",onClick:m||!N?void 0:f}),(0,n.jsx)(d.PY1.div,{variants:z,ref:g,role:N?"dialog":void 0,"aria-modal":N?"true":void 0,"aria-labelledby":N?h:void 0,"aria-describedby":N&&s?p:void 0,tabIndex:-1,className:(0,k.cn)("relative z-10 w-full rounded-lg border bg-card text-card-foreground shadow-lg outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",w&&"flex max-h-[min(90vh,760px)] flex-col overflow-hidden",o),children:w?(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsxs)("div",{className:"flex shrink-0 items-start justify-between gap-4 border-b border-border/70 px-5 py-4",children:[(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("h2",{id:h,className:"truncate text-lg font-semibold tracking-tight",children:e}),s&&(0,n.jsx)("div",{id:p,className:"text-sm leading-5 text-muted-foreground",children:s})]}),(0,n.jsx)(C,{"aria-label":`關閉${e}`,onClick:f,disabled:m,className:"mt-0.5 shrink-0 p-1",children:(0,n.jsx)(O.A,{className:"size-4"})})]}),!i&&(0,n.jsx)("h2",{id:h,className:"sr-only",children:e}),(0,n.jsx)("div",{className:(0,k.cn)("min-h-0 flex-1 overflow-y-auto px-5 py-4",u),children:t}),a&&(0,n.jsx)("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/70 bg-muted/20 px-5 py-3",children:a})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{id:h,className:"sr-only",children:e}),t]})})]})}let J={running:{label:"執行中",icon:D.A,tone:"text-warning",spin:!0},completed:{label:"已完成",icon:_.A,tone:"text-primary"},error:{label:"失敗",icon:u.A,tone:"text-destructive"}};function Q({text:e}){let[t,s]=(0,r.useState)(!1);return(0,n.jsxs)("button",{type:"button",onClick:()=>{"u">typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{s(!0),window.setTimeout(()=>s(!1),1500)})},title:"複製",className:"inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(M.A,{className:"size-3"}),t?"已複製":"複製"]})}function Z({label:e,text:t,defaultOpen:s,markdown:a=!1}){let[i,l]=(0,r.useState)(!!s),o=(0,r.useId)();return(0,n.jsxs)("div",{className:"rounded-md border border-border/40 bg-muted/30",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-2 py-1",children:[(0,n.jsxs)("button",{type:"button","aria-expanded":i,"aria-controls":o,onClick:()=>l(e=>!e),className:"inline-flex items-center gap-1 rounded-sm text-xs font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[i?(0,n.jsx)(j.A,{className:"size-3"}):(0,n.jsx)(L.A,{className:"size-3"}),e]}),i&&(0,n.jsx)(Q,{text:t})]}),i&&(a?(0,n.jsx)("div",{id:o,className:"border-t border-border/40",children:(0,n.jsx)(G,{source:t,compact:!0,className:"max-h-60 overflow-auto bg-transparent px-2.5 py-2 text-foreground/90"})}):(0,n.jsx)("pre",{id:o,className:"max-h-60 overflow-auto whitespace-pre-wrap break-words border-t border-border/40 px-2.5 py-2 text-xs leading-relaxed text-foreground/90",children:t}))]})}function ee({run:e,index:t}){let s=J[e.status],r=s.icon,a=0===t||"running"===e.status;return(0,n.jsxs)("li",{className:"rounded-lg border border-border/40 bg-card p-3 text-card-foreground",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,n.jsx)(r,{className:(0,k.cn)("size-4 shrink-0",s.tone,s.spin&&"animate-spin")}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 truncate text-base font-medium",children:[e.subagentType||"子代理",e.description?(0,n.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground",children:["\xb7 ",e.description]}):null]}),(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 text-xs font-medium",s.tone),children:s.label})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(Z,{label:"Prompt",text:e.prompt,defaultOpen:a}),"running"!==e.status&&null!=e.result&&(0,n.jsx)(Z,{label:"結果",text:e.result,markdown:!0})]})]})}function et({open:e,taskId:t,taskTitle:s,runs:r,onClose:a}){return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(q,{title:"子代理",description:s,onClose:a,showHeader:!0,motionVariant:"drawer",className:"justify-end p-0",contentClassName:"flex h-full max-h-none max-w-md flex-col rounded-none border-l",bodyClassName:"p-4",children:0===r.length?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-center text-base text-muted-foreground",children:"這個任務尚未衍生任何子代理"}):(0,n.jsx)("ul",{className:"space-y-3",children:r.map((e,t)=>(0,n.jsx)(ee,{run:e,index:t},e.id))})},`sub-agent-drawer-${t}`)})}var es=s(54903),en=s(19897),er=s(72752),ea=s(55985),ei=s(98201),el=s(55713),eo=s(41336),ec=s(50405),ed=s(6510),eu=s(1445),em=s(37763),ex=s(15344);let ef=(0,s(24779).F)("inline-flex items-center justify-center gap-2 whitespace-nowrap text-base font-medium transition-colors active:scale-95 motion-reduce:transform-none disabled:pointer-events-none disabled:opacity-50 disabled:active:scale-100 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",{variants:{variant:{default:"rounded-full bg-primary text-primary-foreground hover:bg-primary/90",destructive:"rounded-full bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"rounded-lg border bg-background hover:bg-accent hover:text-accent-foreground",secondary:"rounded-lg bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"rounded-lg hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),eh=r.forwardRef(({className:e,variant:t,size:s,...r},a)=>(0,n.jsx)("button",{ref:a,className:(0,k.cn)(ef({variant:t,size:s,className:e})),...r}));function ep(e){return new Promise((t,s)=>{let n=new FileReader;n.onload=()=>{if("string"!=typeof n.result)return void s(Error(`無法讀取附件:${e.name}`));let r=n.result.indexOf(",");r<0?s(Error(`無法解析附件:${e.name}`)):t({name:e.name,mime:e.type||"application/octet-stream",dataBase64:n.result.slice(r+1)})},n.onerror=()=>s(n.error??Error(`無法讀取附件:${e.name}`)),n.readAsDataURL(e)})}function eg(e){return Promise.all(Array.from(e).map(ep))}function eb(){return window.vibeflow??null}async function ej(){let e=eb();return e?e.getState():null}async function ev(e){let t=eb();t&&await t.setBoard(e)}async function eN(e){let t=eb();return t?t.setSettings(e):null}async function ey(e,t){let s=eb();return s?s.connectAgent(e,t):null}async function ek(e){let t=eb();return t?t.refreshAgentModels(e):null}async function ew(){let e=eb();return e?e.getGithubAuthStatus():null}async function eC(){let e=eb();e&&await e.startGithubAuthLogin()}async function eA(){let e=eb();e&&await e.cancelGithubAuthLogin()}async function eS(){let e=eb();return e?e.logoutGithubAuth():null}function ez(e){return window.prompt(e)?.trim()||null}async function eE(){return eb()?ez("輸入專案資料夾的絕對路徑"):null}async function eI(e){let t=eb();return t?t.getGitInfo(e):null}async function eP(){let e=eb();return e?e.listRecentProjects():[]}async function eT(e){let t=eb();return t?t.initRepository(e):null}async function eR(){let e=eb();return e?e.detectAgents():[]}async function e$(e){let t=eb();return t?t.createTask(e):null}async function eB(e){let t=eb();return t?t.updateTask(e):null}async function eD(e){let t=eb();return t?t.resetTaskRun(e):null}async function e_(e){let t=eb();return t?t.getDiff(e):[]}async function eM(e,t){let s=eb();return s?s.getDiffEntries(e,t):[]}async function eL(e,t){let s=eb();return s?s.getDiffFile(e,t):null}async function eF(e){let t=eb();return t?t.listArtifacts(e):[]}async function eG(e,t){let s=eb();return s?s.readArtifact(e,t):null}async function eO(e){let t=eb();return t?t.openArtifactsDir(e):"bridge unavailable"}async function eH(e){let t=eb();return t?t.getDecisions(e):null}async function eY(e){return eb()?ez("skill"===e?"輸入 skill 目錄的絕對路徑(需含 SKILL.md)":`輸入 ${e} 檔案的絕對路徑`):null}async function eV(){let e=eb();return e?e.listLibrary():[]}async function eK(e,t){let s=eb();return s?s.importLibraryEntry({kind:e,sourcePath:t}):null}async function eU(e,t,s,n){let r=eb();return r?r.createLibraryEntry({kind:e,name:t,content:s,description:n}):null}async function eW(e,t){let s=eb();return s?s.readLibraryEntry({kind:e,name:t}):null}async function eX(e,t,s){let n=eb();return n?n.updateLibraryEntry({kind:e,name:t,content:s}):null}async function eq(e,t,s){let n=eb();return!!n&&n.setLibraryEntryEnabled({kind:e,name:t,enabled:s})}async function eJ(e,t){let s=eb();return!!s&&s.deleteLibraryEntry({kind:e,name:t})}async function eQ(e){let t=eb();t&&await t.openExternal(e)}async function eZ(e){let t=eb();return t?t.cleanupTask(e):null}async function e0(e){let t=eb();return t?t.deleteTask(e):null}async function e1(e){let t=eb();return t?t.attachments.write(e):[]}async function e5(e){let t=eb();return t?t.term.start(e):null}function e2(e,t){eb()?.term.input(e,t)}async function e3(e){await eb()?.term.scrollToBottom(e)}async function e4(e){let t=eb();return!!t&&t.term.sessionExists(e)}eh.displayName="Button";var e6=s(9036),e8=s(7640),e7=s(62607);function e9({taskId:e,sessionKey:t,cwd:a,launchCommand:i,launchNonce:l=0,readOnly:o=!1,onReturnToBacklog:c,onLaunchAgent:d,onInteract:u}){let m=t??e,x=(0,r.useRef)(null),f=(0,r.useRef)(null),h=(0,r.useRef)(0),[p,g]=(0,r.useState)(!1),[b,j]=(0,r.useState)(!1),[v,N]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[C,A]=(0,r.useState)(!1),[S,z]=(0,r.useState)(!1),E=(0,r.useRef)(!1),I=(0,r.useRef)(-1),P=(0,r.useRef)(!1),T=(0,r.useRef)(i),R=(0,r.useRef)(l);T.current=i,R.current=l;let $=(0,r.useRef)(a);$.current=a;let B=(0,r.useRef)(o),D=(0,r.useRef)(u);D.current=u;let _=(0,r.useCallback)(t=>{let s=$.current,n=f.current;s&&(E.current=!1,P.current=!0,e5({taskId:e,sessionKey:m,launch:t,cols:n?.cols,rows:n?.rows}).then(()=>{E.current=!0,f.current?.focus()}))},[e,m]),M=(0,r.useCallback)(()=>{let t=$.current,s=f.current;t&&s&&null!==eb()&&!B.current&&(E.current=!1,P.current=!1,e5({taskId:e,sessionKey:m,cols:s.cols,rows:s.rows}).then(()=>{E.current=!0,s.focus()}))},[e,m]),L=(0,r.useCallback)(async()=>{let e=f.current;if(e&&c&&!B.current){D.current?.(),N(!0);try{if(!await c())return;e.reset(),e.clear(),M(),e.focus()}catch(s){let t=s instanceof Error?s.message:String(s);e.writeln(`\r
2
- ⚠️ 退回 Backlog 失敗:${t}`)}finally{N(!1)}}},[c,M]),F=(0,r.useCallback)(async()=>{let e=f.current;if(e&&d&&!B.current){D.current?.(),w(!0),e.reset(),e.clear();try{await d(),e.focus()}catch(s){let t=s instanceof Error?s.message:String(s);e.writeln(`\r
3
- ⚠️ 啟動 Agent 失敗:${t}`)}finally{w(!1)}}},[d]),G=(0,r.useCallback)(()=>{if(!E.current||B.current)return;let e=T.current;if(!e)return;let t=R.current;I.current!==t&&(I.current=t,_(e))},[_]);(0,r.useEffect)(()=>{B.current=o,f.current&&(f.current.options.disableStdin=o)},[o]),(0,r.useEffect)(()=>{let t,n,r,a,i,l,o=!1;return E.current=!1,(async()=>{let{Terminal:c}=await s.e(3779).then(s.bind(s,15167)),{FitAddon:d}=await s.e(5695).then(s.bind(s,95695));if(o||!x.current)return;let u=new c({fontSize:12,fontFamily:'Menlo, Monaco, "Courier New", monospace',cursorBlink:!0,disableStdin:B.current,theme:{background:"#191919",foreground:"#e6e6e6",cursor:"#4c9bf5",cursorAccent:"#191919",selectionBackground:"rgba(76, 155, 245, 0.30)",selectionForeground:"#ededed",black:"#3b3b3b",red:"#f0716a",green:"#4ec98a",yellow:"#e2b341",blue:"#4c9bf5",magenta:"#c58af9",cyan:"#4dd0e1",white:"#c8c8c8",brightBlack:"#6e6e6e",brightRed:"#ff8b84",brightGreen:"#6bdfa3",brightYellow:"#f2c862",brightBlue:"#7db8ff",brightMagenta:"#d7a6ff",brightCyan:"#72e0ee",brightWhite:"#ffffff"}}),h=new d;u.loadAddon(h),u.open(x.current);let p=()=>{h.fit();let e=u.element?.querySelector(".xterm-screen"),t=u.element?.querySelector(".xterm-viewport");if(!e||!t)return;let s=function(e,t,s){if(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(s)||e<=2||t<=0||s<=0||t<=s)return e;let n=Math.ceil((t-s)/(t/e));return Math.max(2,e-n)}(u.cols,e.getBoundingClientRect().width,t.clientWidth);s!==u.cols&&u.resize(s,u.rows)};if(f.current=u,await document.fonts.ready,await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o||f.current!==u)return;p();let g=window.vibeflow;if(!g)return u.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");if(B.current)return u.writeln("ℹ️ 任務已完成 — 終端為唯讀,僅供查閱訊息。");if(!$.current)return u.writeln("⚠️ 尚未設定工作目錄,請先選擇專案或建立任務。");let b=B.current?null:T.current;b&&(I.current=R.current),P.current=!!b;let{scrollback:j}=await g.term.start({taskId:e,sessionKey:m,launch:b??void 0,cols:u.cols,rows:u.rows});j&&u.write(j),t=g.term.onData(({sessionKey:e,data:t})=>{e===m&&u.write(t)}),n=g.term.onExit(({sessionKey:e,exitCode:t,intentional:s})=>{if(e!==m||s)return;let n=P.current;if(P.current=!1,!n){E.current=!1,u.writeln(`\r
4
- ℹ️ 終端已結束(exit code: ${t})`);return}0===t?u.writeln("\r\n✅ Agent 執行完成。"):u.writeln(`\r
5
- ⚠️ 連線中斷或異常結束(exit code: ${t})`),u.writeln("\r\nℹ️ 已切回互動終端,可手動輸入命令。"),M()}),u.attachCustomKeyEventHandler(e=>"Enter"!==e.key||!e.shiftKey||!!e.altKey||!!e.ctrlKey||!!e.metaKey||!!e.isComposing||!!B.current||(e.preventDefault(),e.stopPropagation(),"keydown"===e.type&&(D.current?.(),g.term.input(m,"\x1b\r")),!1)),u.onData(e=>{B.current||(D.current?.(),g.term.input(m,e),v())}),u.onScroll(()=>{let e=u.buffer.active;A(e.viewportY<e.baseY)});let v=()=>{clearTimeout(i),i=setTimeout(()=>{g.term.isScrolledBack(m).then(e=>{o||f.current!==u||z(e)})},150)},N=x.current;N?.addEventListener("wheel",v,{capture:!0,passive:!0}),l=()=>N?.removeEventListener("wheel",v,{capture:!0}),r=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{if(!o&&f.current===u)try{let{cols:e,rows:t}=u;if(p(),u.cols===e&&u.rows===t)return;g.term.resize(m,u.cols,u.rows)}catch{}},100)}),x.current&&r.observe(x.current),E.current=!0,G()})(),()=>{o=!0,E.current=!1,t?.(),n?.(),r?.disconnect(),clearTimeout(a),clearTimeout(i),l?.(),eb()?.term.kill(m),f.current?.dispose(),f.current=null}},[e,m,G,M]),(0,r.useEffect)(()=>{G()},[i,l,G]);let O=async t=>{if(!B.current&&E.current&&0!==t.length){D.current?.(),j(!0);try{let s=await eg(t),n=await e1({taskId:e,attachments:s});if(n.length>0){let e=n.map(({path:e})=>`'${e.replace(/'/g,"'\\''")}'`).join(" ");e2(m,`${e} `)}}catch(t){let e=t instanceof Error?t.message:String(t);f.current?.writeln(`\r
6
- ⚠️ 附加檔案失敗:${e}`)}finally{j(!1)}}},H=async()=>{f.current?.scrollToBottom(),A(!1),await e3(m),z(!1),f.current?.focus()};return(0,n.jsxs)("div",{onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!o&&E.current&&(h.current+=1,g(!0)))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect=o||!E.current?"none":"copy")},onDragLeave:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!o&&E.current&&(h.current=Math.max(0,h.current-1),0===h.current&&g(!1)))},onDrop:e=>{e.preventDefault(),h.current=0,g(!1),!o&&E.current&&O(e.dataTransfer.files)},className:(0,k.cn)("flex min-h-36 w-full flex-1 flex-col overflow-hidden rounded-md border border-border bg-card transition-colors",p&&"border-primary bg-primary/5"),children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-muted/50 px-2 py-1",children:[(0,n.jsx)("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:a??"(no cwd)"}),b?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs text-muted-foreground",children:"附加檔案中…"}):o?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs uppercase tracking-wide text-muted-foreground",children:"唯讀"}):(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[c&&(0,n.jsxs)(eh,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void L(),disabled:!a||v||y,title:"捨棄這次執行的程式碼變更、artifacts 與決策紀錄並退回 Backlog,之後按「開始」才會重新啟動 Agent",children:[(0,n.jsx)(e6.A,{className:(0,k.cn)("size-3",v&&"animate-pulse")}),v?"退回中…":"退回 Backlog"]}),d&&(0,n.jsxs)(eh,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void F(),disabled:!a||y||v,title:"只帶入 Agent 設定與 Artifact 資訊,不傳入任務內容",children:[(0,n.jsx)(e8.A,{className:(0,k.cn)("size-3",y&&"animate-pulse")}),y?"啟動中…":"啟動 Agent"]})]})]}),(0,n.jsxs)("div",{className:"relative min-h-0 w-full flex-1 overflow-hidden bg-background p-1",children:[(0,n.jsx)("div",{ref:x,className:"h-full w-full overflow-hidden"}),(C||S)&&(0,n.jsxs)(eh,{variant:"secondary",size:"sm",className:"absolute bottom-3 right-5 h-7 px-2 text-xs shadow-md",onClick:()=>void H(),children:[(0,n.jsx)(e7.A,{className:"size-3"}),"回到最新"]})]})]})}var te=s(18921),tt=s(79608);let ts={scale:1,x:0,y:0};function tn(e,t,s){return Math.min(s,Math.max(t,e))}function tr({src:e,alt:t,className:s}){let a=(0,r.useRef)(null),i=(0,r.useRef)(null),l=(0,r.useRef)(null),[o,c]=(0,r.useState)(ts),[d,u]=(0,r.useState)(!1),m=(0,r.useCallback)((e,t,s)=>{let n=a.current,r=i.current;if(!n||!r)return{x:e,y:t};let l=Math.max(0,(r.offsetWidth*s-n.clientWidth)/2),o=Math.max(0,(r.offsetHeight*s-n.clientHeight)/2);return{x:tn(e,-l,l),y:tn(t,-o,o)}},[]),x=(0,r.useCallback)((e,t=0,s=0)=>{c(n=>{let r=tn(e(n.scale),1,6);return r===n.scale?n:{scale:r,...m(t-(t-n.x)*r/n.scale,s-(s-n.y)*r/n.scale,r)}})},[m]);(0,r.useEffect)(()=>{c(ts)},[e]),(0,r.useEffect)(()=>{let e=a.current;if(!e)return;let t=t=>{t.preventDefault();let s=e.getBoundingClientRect();x(e=>e*Math.exp(-(.0015*t.deltaY)),t.clientX-s.left-s.width/2,t.clientY-s.top-s.height/2)};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[x]),(0,r.useEffect)(()=>{let e=()=>c(e=>({...e,...m(e.x,e.y,e.scale)}));return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[m]);let f=o.scale>1,h=e=>{l.current?.pointerId===e.pointerId&&(l.current=null,u(!1))};return(0,n.jsxs)("div",{className:(0,k.cn)("space-y-3",s),children:[(0,n.jsx)("div",{ref:a,onPointerDown:e=>{f&&0===e.button&&(e.currentTarget.setPointerCapture(e.pointerId),l.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,originX:o.x,originY:o.y},u(!0))},onPointerMove:e=>{let t=l.current;if(!t||t.pointerId!==e.pointerId)return;let s=t.originX+(e.clientX-t.startX),n=t.originY+(e.clientY-t.startY);c(e=>({...e,...m(s,n,e.scale)}))},onPointerUp:h,onPointerCancel:h,className:(0,k.cn)("flex h-[min(60vh,520px)] touch-none select-none items-center justify-center overflow-hidden rounded-md bg-muted/20",f&&(d?"cursor-grabbing":"cursor-grab")),children:(0,n.jsx)("img",{ref:i,src:e,alt:t,draggable:!1,className:"max-h-full max-w-full object-contain",style:{transform:`translate(${o.x}px, ${o.y}px) scale(${o.scale})`}})}),(0,n.jsxs)("div",{className:"flex items-center gap-3 px-1",children:[(0,n.jsx)(te.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("input",{type:"range",min:1,max:6,step:.05,value:o.scale,onChange:e=>{let t=Number(e.target.value);x(()=>t)},"aria-label":"縮放圖片",className:"h-4 min-w-0 flex-1 cursor-pointer accent-primary outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"}),(0,n.jsx)(tt.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,n.jsx)("p",{className:"px-1 text-xs text-muted-foreground",children:"滑桿或滾輪縮放,放大後可拖曳圖片平移。"})]})}function ta(e,t){return e.path===t.path&&e.status===t.status&&e.additions===t.additions&&e.deletions===t.deletions&&e.revision===t.revision}let ti=(0,r.lazy)(()=>s.e(1201).then(s.bind(s,31201)).then(e=>({default:e.default}))),tl={task:"任務",decisions:"決策",artifacts:"Artifacts",diff:"Git diff"},to=["task","decisions","artifacts","diff"],tc=["task","decisions"],td={A:"新增",M:"修改",D:"刪除",R:"更名","?":"未追蹤"},tu={image:"截圖",video:"影片",text:"文字",binary:"二進位"},tm="vibeflow:workspace-aside-px",tx="--vf-workspace-aside",tf=!1;function th(){if(tf)return;tf=!0;let e=Number(window.localStorage.getItem(tm));Number.isFinite(e)&&e>=336&&document.documentElement.style.setProperty(tx,`${e}px`)}function tp(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function tg(e){return("image"===e.kind||"video"===e.kind)&&!e.scratch}function tb({title:e,icon:t,children:s,actions:r,count:a,heading:i}){return(0,n.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col border-b border-border last:border-b-0",children:[(0,n.jsxs)("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[i??(0,n.jsxs)("h2",{className:(0,k.cn)(y,"flex min-w-0 items-center gap-2"),children:[t,(0,n.jsx)("span",{className:"truncate",children:e}),void 0!==a&&a>0&&(0,n.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/80",children:a})]}),r]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:s})]})}let tj={MERGED:"bg-primary/15 text-primary",OPEN:"bg-success/15 text-success",CLOSED:"bg-destructive/15 text-destructive"};function tv({outcome:e}){let[t,s]=(0,r.useState)(!1),{pr:a,commits:i,files:l}=e;return(0,n.jsxs)("div",{className:"space-y-4",children:[a&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,k.cn)(y,"flex items-center gap-1.5"),children:[(0,n.jsx)(es.A,{className:"size-3.5"}),"Pull Request"]}),(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5 text-sm",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 rounded-xs px-1.5 py-0.5 text-xs font-medium",tj[a.state]??"bg-secondary text-secondary-foreground"),children:a.state}),(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words text-foreground",children:a.title})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void eQ(a.url),className:"flex items-center gap-1.5 rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(en.A,{className:"size-3"}),"#",a.number]}),a.body&&(0,n.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:t?"收合說明":"展開說明"})]}),a.body&&t&&(0,n.jsx)(G,{source:a.body,compact:!0,className:"bg-transparent p-0"})]})]}),i.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,k.cn)(y,"flex items-center gap-1.5"),children:[(0,n.jsx)(er.A,{className:"size-3.5"}),"Commits",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:i.length})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:i.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("code",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.sha}),(0,n.jsx)("span",{className:"min-w-0 break-words",children:e.subject})]},e.sha))})]}),l.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,k.cn)(y,"flex items-center gap-1.5"),children:[(0,n.jsx)(ea.A,{className:"size-3.5"}),"變更檔案",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:l.length}),(0,n.jsxs)("span",{className:"ml-auto font-normal tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:l.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]},e.path))}),e.truncated&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["只列出前 ",l.length," 個檔案。"]})]})]})}function tN({task:e,column:t,subAgents:s,onOpenSubAgents:r}){return(0,n.jsxs)("div",{className:"space-y-4 text-base",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:"in_progress"===t?"In Progress":"done"===t?"Done":"Backlog"})}),(0,n.jsx)("h3",{className:"break-words text-lg font-semibold tracking-tight text-foreground",children:e.title})]}),(0,n.jsxs)("div",{className:"space-y-1.5 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:[e.projectName&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(f.A,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:e.projectName})]}),(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(g.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 break-all",children:e.branch})]}),e.baseBranch&&(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(ei.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:["base: ",e.baseBranch]})]})]}),e.description&&(0,n.jsx)(G,{source:e.description}),e.outcome&&(0,n.jsx)(tv,{outcome:e.outcome}),s.length>0&&(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.id),className:"flex w-full items-center justify-between rounded-md border border-border/70 px-2.5 py-2 text-left text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsxs)("span",{children:[s.length," sub-agent runs"]}),(0,n.jsx)("span",{children:"View"})]})]})}function ty({taskId:e,live:t}){let[s,a]=(0,r.useState)(void 0);return((0,r.useEffect)(()=>{let s,n=!0;a(void 0);let r=!1,i=async()=>{if(r&&Y>0){n&&t&&(s=setTimeout(()=>void i(),3e3));return}r=!0;try{let t=await eH(e);n&&a(t)}catch{n&&a(null)}finally{n&&t&&(s=setTimeout(()=>void i(),3e3))}};return i(),()=>{n=!1,s&&clearTimeout(s)}},[e,t]),void 0===s)?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取決策書中…"]}):s?.markdown?.trim()?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(G,{source:s.markdown,className:"bg-transparent p-0"}),s.truncated&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"內容過長,僅顯示前段。"}),null!=s.updatedAt&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:["更新於 ",new Date(s.updatedAt).toLocaleString()]})]}):(0,n.jsxs)("div",{className:"space-y-2 py-10 text-center",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"此任務還沒有記錄任何決策。"}),s?.path&&(0,n.jsxs)("p",{className:"break-all px-4 text-xs text-muted-foreground/70",children:["agent 會寫入 ",s.path]})]})}function tk({taskId:e,artifact:t}){let[s,a]=(0,r.useState)(null),[i,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let s=!0;return a(null),l(!1),eG(e,t.name).then(e=>{s&&a(e?.dataUrl??null)}).catch(()=>{s&&a(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]);let o="video"===t.kind;return!s||i?(0,n.jsx)("div",{className:"flex h-24 items-center justify-center rounded-md border border-border/70 bg-card",children:o?(0,n.jsx)(el.A,{className:"size-5 text-muted-foreground"}):(0,n.jsx)(eo.A,{className:"size-5 text-muted-foreground"})}):o?(0,n.jsxs)("div",{className:"relative h-24 w-full overflow-hidden rounded-md border border-border/70 bg-card",children:[(0,n.jsx)("video",{src:s,muted:!0,playsInline:!0,preload:"metadata",onError:()=>l(!0),className:"h-full w-full object-contain"}),(0,n.jsx)("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,n.jsx)("span",{className:"flex size-7 items-center justify-center rounded-full bg-background/80 ring-1 ring-border/70",children:(0,n.jsx)(ec.A,{className:"size-3.5 fill-current text-foreground"})})})]}):(0,n.jsx)("img",{src:s,alt:t.name,className:"h-24 w-full rounded-md border border-border/70 bg-card object-contain"})}function tw({taskId:e,artifact:t,onClose:s}){var a;let[i,l]=(0,r.useState)(void 0),[o,c]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=!0;return l(void 0),c(!1),eG(e,t.name).then(e=>{s&&l(e)}).catch(()=>{s&&l(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]),(0,n.jsx)(q,{title:t.name,description:`${tu[t.kind]} \xb7 ${tp(t.size)}${t.scratch?" \xb7 工作暫存":""}`,onClose:s,showHeader:!0,contentClassName:"max-w-5xl",bodyClassName:"p-4",children:void 0===i?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取中…"]}):null===i?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案,可能已被刪除。"}):"image"===i.kind&&i.dataUrl?(0,n.jsx)(tr,{src:i.dataUrl,alt:t.name}):"video"===i.kind&&i.dataUrl?o?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"這個影片的編碼無法在 app 內播放。用 Artifacts 分頁的「開啟資料夾」以系統播放器開啟。"}):(0,n.jsx)("video",{src:i.dataUrl,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,onError:()=>c(!0),className:"max-h-[70vh] w-full rounded-md bg-black"}):"binary"===i.kind?(0,n.jsxs)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:["無法內嵌預覽的檔案(",tp(t.size),")。用 Artifacts 分頁的「開啟資料夾」以系統播放器或編輯器開啟。"]}):(0,n.jsxs)(n.Fragment,{children:[(a=t.name,/\.(md|markdown|mdx)$/i.test(a))?(0,n.jsx)(G,{source:i.text??""}):(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded-md bg-muted/30 p-3 font-mono text-xs",children:i.text}),i.truncated&&(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"內容過長,僅顯示開頭 256 KB。"})]})})}function tC({taskId:e,artifacts:t,artifactsDir:s}){let[a,i]=(0,r.useState)(null),[o,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)("idle"),[m,x]=(0,r.useState)(null),f=t.filter(tg),h=t.filter(e=>!tg(e)),p=(0,r.useCallback)(()=>{x(null),eO(e).then(e=>x(e||null)).catch(()=>x("開啟失敗"))},[e]),g=(0,r.useCallback)(()=>{s&&navigator.clipboard.writeText(s).then(()=>{u("copied"),window.setTimeout(()=>u("idle"),1600)}).catch(()=>u("error"))},[s]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-3 space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Artifact 資料夾"}),(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("code",{className:"min-w-0 flex-1 select-all break-all rounded-xs bg-background px-2 py-1.5 font-mono text-xs text-foreground",title:s??"尚無可用路徑",children:s??"尚無可用路徑"}),(0,n.jsxs)(eh,{variant:"outline",size:"sm",onClick:g,disabled:!s,title:"複製 Artifact 資料夾路徑",className:"shrink-0 text-xs",children:["copied"===d?(0,n.jsx)(v.A,{className:"size-3.5"}):(0,n.jsx)(M.A,{className:"size-3.5"}),"copied"===d?"已複製":"error"===d?"複製失敗":"複製路徑"]})]})]}),(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-end gap-2",children:[m&&(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:m,children:m}),(0,n.jsxs)(eh,{variant:"outline",size:"sm",onClick:p,title:s??"任務的 artifacts 目錄",className:"text-xs",children:[(0,n.jsx)(ed.A,{className:"size-3.5"}),"開啟資料夾"]})]}),0===t.length?(0,n.jsxs)("div",{className:"space-y-2 py-8 text-center",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"還沒有暫存產物。"}),(0,n.jsxs)("p",{className:"text-xs leading-5 text-muted-foreground/80",children:["Agent 會把驗證截圖、錄影與報告寫進上方資料夾,工作暫存放其下的 ",(0,n.jsx)("code",{className:"rounded-xs bg-muted/40 px-1 py-0.5 font-mono",children:"scratch/"}),",完成任務時會一併清除。"]})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[f.length>0?(0,n.jsx)("ul",{className:"grid grid-cols-2 gap-2",children:f.map(t=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(t),title:t.name,className:"w-full rounded-md border border-border/70 bg-muted/20 p-2 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(tk,{taskId:e,artifact:t}),(0,n.jsxs)("div",{className:"mt-1.5 flex items-baseline gap-1.5",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.name}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:tp(t.size)})]})]})},t.name))}):(0,n.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"還沒有驗證截圖或錄影。"}),h.length>0&&(0,n.jsxs)("div",{className:"rounded-md border border-border/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>c(e=>!e),"aria-expanded":o,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(L.A,{className:(0,k.cn)("size-3.5 shrink-0 transition-transform motion-reduce:transition-none",o&&"rotate-90")}),"其他 ",h.length," 個檔案(報告、script、log)"]}),o&&(0,n.jsx)("ul",{className:"border-t border-border/70",children:h.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e),title:e.name,className:"flex w-full items-center gap-2 px-2 py-1 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:["image"===e.kind?(0,n.jsx)(eo.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):"video"===e.kind?(0,n.jsx)(el.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,n.jsx)(eu.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:e.name}),(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/80",children:[function(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return"剛剛";if(t<60)return`${t} 分前`;let s=Math.floor(t/60);return s<24?`${s} 小時前`:`${Math.floor(s/24)} 天前`}(e.modifiedAt)," \xb7 ",tp(e.size)]})]})},e.name))})]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(tw,{taskId:e,artifact:a,onClose:()=>i(null)},`artifact-${e}-${a.name}`)})]})}let tA=(0,r.memo)(function({file:e,showHeader:t=!0}){return(0,n.jsxs)("div",{className:(0,k.cn)("overflow-hidden",t&&"rounded-md border border-border/70"),children:[t&&(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/70 bg-muted/30 px-2 py-1.5",children:[(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:td[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),e.truncated&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:"已截斷"})]}),(0,n.jsx)("div",{className:"min-w-0 max-w-full overflow-x-auto text-xs [&_.diff-content]:whitespace-pre-wrap [&_.diff-content]:break-words [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_table]:min-w-full [&_table]:table-fixed [&_td]:min-w-0 [&_td]:align-top",children:(0,n.jsx)(r.Suspense,{fallback:null,children:(0,n.jsx)(ti,{oldValue:e.oldValue,newValue:e.newValue,splitView:!1,useDarkTheme:!0,compareMethod:"diffLines",renderContent:e=>(0,n.jsx)("span",{className:"block min-w-0 max-w-full whitespace-pre-wrap break-words",children:e}),styles:{variables:{dark:{diffViewerBackground:"var(--card)",diffViewerColor:"var(--card-foreground)",addedBackground:"rgba(78, 201, 138, 0.15)",addedColor:"var(--foreground)",removedBackground:"rgba(229, 72, 77, 0.15)",removedColor:"var(--foreground)",wordAddedBackground:"rgba(78, 201, 138, 0.32)",wordRemovedBackground:"rgba(229, 72, 77, 0.32)",addedGutterBackground:"rgba(78, 201, 138, 0.20)",removedGutterBackground:"rgba(229, 72, 77, 0.20)",gutterBackground:"var(--muted)",gutterBackgroundDark:"var(--muted)",gutterColor:"var(--muted-foreground)",addedGutterColor:"var(--foreground)",removedGutterColor:"var(--foreground)",highlightBackground:"rgba(76, 155, 245, 0.15)",highlightGutterBackground:"rgba(76, 155, 245, 0.20)",codeFoldGutterBackground:"var(--muted)",codeFoldBackground:"var(--secondary)",codeFoldContentColor:"var(--muted-foreground)",emptyLineBackground:"var(--card)"}},diffContainer:{width:"100%",maxWidth:"100%",overflowX:"visible"},line:{width:"100%"},content:{width:"100%",maxWidth:"100%",overflowX:"visible"},contentText:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},lineContent:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},gutter:{maxWidth:"2.5rem",minWidth:"2.5rem",width:"2.5rem",paddingLeft:"0.25rem",paddingRight:"0.25rem",whiteSpace:"nowrap"}}})})})]})});function tS({entry:e,file:t,onClose:s}){return(0,n.jsx)(q,{title:e.path,description:(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:td[e.status]??e.status}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"font-mono tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),t?.truncated&&(0,n.jsx)("span",{children:"\xb7 已截斷"})]}),onClose:s,showHeader:!0,contentClassName:"max-w-6xl",bodyClassName:"p-4",children:void 0===t?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取內容中…"]}):null===t?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案的內容。"}):(0,n.jsx)(tA,{file:t,showHeader:!1})})}function tz({diff:e}){return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(C,{"aria-label":"重新整理 Git diff",title:"重新整理(含 fetch origin)",className:"p-1",disabled:e.loading,onClick:e.manualRefresh,children:(0,n.jsx)(em.A,{className:(0,k.cn)("size-3.5",e.loading&&"animate-spin")})}),e.entries.length>0&&(0,n.jsx)(C,{"aria-label":"放大檢視 Git diff",title:"放大檢視(全部展開)",className:"p-1",onClick:e.expand,children:(0,n.jsx)(ex.A,{className:"size-3.5"})})]})}function tE({taskId:e,diff:t}){let{entries:s,contents:r,selectedEntry:a,setSelectedPath:i,loading:o,error:c,expanded:d,fullFiles:u,closeExpanded:m}=t;return(0,n.jsxs)(n.Fragment,{children:[o&&0===s.length?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取 diff 中…"]}):c?(0,n.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:c}):0===s.length?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"與基準分支相比沒有變更。"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.path),title:`檢視 ${e.path} 的 diff`,className:"flex w-full items-center gap-2 rounded-md border border-border/70 bg-muted/30 px-2 py-1.5 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:"shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:td[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),(0,n.jsx)(L.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]})},e.path))}),s.length>=80&&(0,n.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["變更檔案超過 ",80," 個,僅顯示前 ",80," 個。"]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(tS,{entry:a,file:a.path in r?r[a.path]:void 0,onClose:()=>i(null)},`diff-${e}-${a.path}`)}),d&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex bg-background/95 text-foreground",children:(0,n.jsxs)("div",{className:"flex min-h-0 w-full flex-col",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border px-5",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Git diff"}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[s.length," changed ",1===s.length?"file":"files"]})]}),(0,n.jsx)(C,{"aria-label":"關閉 diff 放大檢視",title:"關閉",onClick:m,children:(0,n.jsx)(O.A,{className:"size-4"})})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-6xl space-y-4",children:null===u?(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}),"讀取全部 diff 內容中…"]}):u.map(e=>(0,n.jsx)(tA,{file:e},e.path))})})]})})]})}function tI({task:e,column:t,subAgents:s,launch:a,onStart:i,onReturnToBacklog:l,onLaunchAgent:o,onComplete:c,onEdit:d,onDelete:u,onOpenSubAgents:f,onInteract:h}){let[p,b]=(0,r.useState)("task"),[j,N]=(0,r.useState)(!1),[y,w]=(0,r.useState)([]),A=(0,r.useId)(),S=`${A}-panel`,z=e=>`${A}-tab-${e}`,E=e.worktreePath??e.projectPath??null,I=function(e,t){let s,n;if(!e||!t)return null;let r=t.replace(/\\/g,"/"),a=(n=(s=e.replace(/\\/g,"/").replace(/\/+$/,"")).lastIndexOf("/"))>=0?s.slice(n+1):s;return`${r}/${a}.artifacts`}(e.worktreePath,e.workspacePath),P=function(e,t){let[s,n]=(0,r.useState)([]),[a,i]=(0,r.useState)({}),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[x,f]=(0,r.useState)(0),[h,p]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),j=(0,r.useRef)(new Map),v=(0,r.useCallback)(e=>{let t=new Set(e.map(e=>e.path));for(let e of j.current.keys())t.has(e)||j.current.delete(e);n(t=>(function(e,t){if(e.length!==t.length)return t;let s=!1,n=t.map((t,n)=>{let r=e[n];return ta(r,t)?r:(s=!0,t)});return s?n:e})(t,e)),i(t=>{let s;return s=new Set(e.map(e=>e.path)),Object.keys(t).every(e=>s.has(e))?t:Object.fromEntries(Object.entries(t).filter(([e])=>s.has(e)))})},[]),N=s.find(e=>e.path===l)??null;(0,r.useEffect)(()=>{if(!N)return;let t=N.path,s=j.current.get(t);if(t in a&&s&&ta(s,N))return;let n=!0;return eL(e,t).then(e=>{n&&(j.current.set(t,N),i(s=>{var n;return(n=s[t])===e||n&&e&&n.path===e.path&&n.status===e.status&&n.additions===e.additions&&n.deletions===e.deletions&&n.oldValue===e.oldValue&&n.newValue===e.newValue&&n.truncated===e.truncated?s:{...s,[t]:e}}))}).catch(()=>{n&&(j.current.set(t,N),i(e=>null===e[t]?e:{...e,[t]:null}))}),()=>{n=!1}},[e,N,a]),(0,r.useEffect)(()=>{let s;if(!t)return;let n=!0,r=!1,a=async t=>{if(r&&Y>0){n&&(s=setTimeout(()=>void a(!1),3e3));return}r=!0;try{let s=await eM(e,{fetch:t});if(!n)return;v(s),m(null)}catch(e){n&&m(e instanceof Error?e.message:String(e))}finally{n&&(d(!1),s=setTimeout(()=>void a(!1),3e3))}};return d(!0),a(!0),()=>{n=!1,s&&clearTimeout(s)}},[e,t,x,v]),(0,r.useEffect)(()=>{l&&!s.some(e=>e.path===l)&&o(null)},[s,l]),(0,r.useEffect)(()=>{if(!h)return;let t=!0;return e_(e).then(e=>{t&&b(e)}).catch(e=>{t&&m(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[h,e]);let y=(0,r.useCallback)(()=>{p(!1),b(null)},[]);return{entries:s,contents:a,selectedEntry:N,setSelectedPath:o,loading:c,error:u,expanded:h,fullFiles:g,expand:(0,r.useCallback)(()=>p(!0),[]),closeExpanded:y,manualRefresh:(0,r.useCallback)(()=>{i({}),j.current.clear(),f(e=>e+1)},[])}}(e.id,"done"!==t),T=y.filter(tg).length;(0,r.useEffect)(()=>{let s;if("done"===t)return void w([]);let n=!0,r=!1,a=async()=>{if(r&&Y>0){n&&(s=setTimeout(()=>void a(),3e3));return}r=!0;try{let t=await eF(e.id);n&&w(t)}catch{}finally{n&&(s=setTimeout(()=>void a(),3e3))}};return a(),()=>{n=!1,s&&clearTimeout(s)}},[e.id,t]),(0,r.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"!==e.key||document.querySelector('[role="dialog"][aria-modal="true"]')||N(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]);let R="backlog"===t,$=a?.launch,B=a?.nonce??0,D="done"===t?tc:to,_=D.includes(p)?p:D[0],M=(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視",className:"flex min-w-0 rounded-md border border-border/70 p-0.5",children:D.map(e=>{let t="artifacts"===e?T:"diff"===e?P.entries.length:0;return(0,n.jsxs)("button",{type:"button",role:"tab",id:z(e),"aria-selected":_===e,"aria-controls":S,onClick:()=>{h?.(),b(e)},className:(0,k.cn)("shrink-0 rounded-sm px-2 py-0.5 text-xs outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",_===e?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground"),children:[tl[e],t>0&&(0,n.jsx)("span",{className:"ml-1 tabular-nums text-muted-foreground/80",children:t})]},e)})}),L=(0,r.useRef)(null),F=(0,r.useRef)(null),G=(0,r.useRef)(null);(0,r.useLayoutEffect)(th,[]);let O=(e,t)=>{let s,n=Math.round(Math.max(336,Math.min(e,Math.max(336,(s=L.current?.clientWidth??0)>0?s-320-10:e))));document.documentElement.style.setProperty(tx,`${n}px`),t&&window.localStorage.setItem(tm,String(n))},H=()=>{if(!G.current)return;G.current=null;let e=F.current?.getBoundingClientRect().width??0;e>0&&O(e,!0)},V=e=>{let t=F.current?.getBoundingClientRect().width??0;t<=0||O(t+e,!0)};return(0,n.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(g.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 truncate text-base font-semibold",children:e.title})]})}),R&&(0,n.jsxs)(eh,{size:"sm",variant:"outline",onClick:()=>{h?.(),i(e)},disabled:!E,children:[(0,n.jsx)(ec.A,{className:"size-3.5"}),"開始"]}),"in_progress"===t&&(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(eh,{size:"sm",onClick:()=>{h?.(),c(e)},title:"標記完成後會清理 PTY 與 worktree",children:[(0,n.jsx)(v.A,{className:"size-3.5"}),"完成"]})}),(0,n.jsx)(C,{"aria-label":"編輯任務",title:"編輯任務",onClick:()=>{h?.(),d(e.id)},children:(0,n.jsx)(m.A,{className:"size-4"})}),j?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>N(!1),className:"rounded-md px-1.5 py-1 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:()=>u(e.id),className:"rounded-md px-1.5 py-1 text-sm text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"確認刪除"})]}):(0,n.jsx)(C,{"aria-label":"刪除任務",title:"刪除任務(清理 worktree)",tone:"danger",onClick:()=>N(!0),children:(0,n.jsx)(x.A,{className:"size-4"})})]}),"done"===t?(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:(0,n.jsx)(tb,{heading:M,children:(0,n.jsx)("div",{role:"tabpanel",id:S,"aria-labelledby":z(_),className:"h-full",children:"task"===_?(0,n.jsx)(tN,{task:e,column:t,subAgents:s,onOpenSubAgents:f}):(0,n.jsx)(ty,{taskId:e.id,live:!1})})})}):(0,n.jsxs)("main",{ref:L,className:"grid min-h-0 flex-1 grid-rows-[minmax(18rem,1fr)_minmax(18rem,45%)] overflow-hidden lg:grid-cols-[minmax(20rem,1fr)_auto_minmax(21rem,min(var(--vf-workspace-aside,24rem),100%_-_20.625rem))] lg:grid-rows-1 xl:grid-cols-[minmax(0,1fr)_auto_minmax(21rem,min(var(--vf-workspace-aside,27rem),100%_-_20.625rem))]",children:[(0,n.jsx)("div",{className:"flex min-h-0 min-w-0 flex-col border-b border-border bg-muted/30 p-3 lg:border-b-0",children:(0,n.jsx)(e9,{taskId:e.id,cwd:E,launchCommand:$,launchNonce:B,readOnly:!1,onReturnToBacklog:"in_progress"===t?()=>l(e):void 0,onLaunchAgent:"in_progress"===t?()=>o(e):void 0,onInteract:h})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"調整終端機與側邊面板的寬度",tabIndex:0,onPointerDown:e=>{let t=F.current?.getBoundingClientRect().width??0;t<=0||(G.current={x:e.clientX,width:t},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=G.current;t&&O(t.width-(e.clientX-t.x),!1)},onPointerUp:H,onPointerCancel:H,onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),V(24)):"ArrowRight"===e.key&&(e.preventDefault(),V(-24))},className:"hidden w-2.5 shrink-0 cursor-col-resize items-center justify-center border-x border-border bg-card outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50 lg:flex",children:(0,n.jsx)("span",{className:"h-12 w-0.5 rounded-full bg-input"})}),(0,n.jsx)("aside",{ref:F,className:"flex min-h-0 min-w-0 flex-col bg-card/40",children:(0,n.jsx)(tb,{heading:M,actions:"diff"===_?(0,n.jsx)(tz,{diff:P}):void 0,children:(0,n.jsx)("div",{role:"tabpanel",id:S,"aria-labelledby":z(_),className:"h-full",children:"task"===_?(0,n.jsx)(tN,{task:e,column:t,subAgents:s,onOpenSubAgents:f}):"decisions"===_?(0,n.jsx)(ty,{taskId:e.id,live:!0}):"artifacts"===_?(0,n.jsx)(tC,{taskId:e.id,artifacts:y,artifactsDir:I}):(0,n.jsx)(tE,{taskId:e.id,diff:P})})})})]})]})}var tP=s(93659),tT=s(9523);let tR="w-full rounded-md border bg-background px-3 py-2 text-base outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 transition-shadow motion-reduce:transition-none";var t$=s(81450);let tB=[{value:"low",label:"快速",description:"適合範圍明確、低風險的小任務。"},{value:"medium",label:"標準",description:"兼顧速度與推理深度,適合一般開發任務。"},{value:"high",label:"深入",description:"適合跨檔案、除錯或需要較多判斷的任務。"},{value:"xhigh",label:"極致",description:"適合高複雜度、長鏈推理或高風險變更。"}],tD="medium";function t_({value:e,onChange:t,disabled:s=!1}){let r=Math.max(0,tB.findIndex(t=>t.value===e)),a=tB[r];return(0,n.jsxs)("div",{className:"space-y-2.5 rounded-lg border border-border/50 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-base font-medium",children:[(0,n.jsx)(t$.A,{className:"size-4 text-muted-foreground"}),"任務複雜度"]}),(0,n.jsxs)("span",{className:"rounded-full bg-primary/10 px-2.5 py-1 text-sm font-medium text-primary",children:[a.label," \xb7 ",a.value]})]}),(0,n.jsx)("input",{type:"range",name:"task-effort",min:0,max:tB.length-1,step:1,value:r,disabled:s,"aria-label":"任務複雜度","aria-valuetext":`${a.label} (${a.value})`,onChange:e=>{let s=tB[Number(e.target.value)];s&&t(s.value)},className:"h-2 w-full cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50"}),(0,n.jsx)("div",{className:"grid grid-cols-4 text-center text-xs text-muted-foreground","aria-hidden":"true",children:tB.map(e=>(0,n.jsx)("span",{children:e.label},e.value))}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[a.description," Claude Code 與 Codex 會在啟動此任務時套用;實際可用級距依 model 而定。"]})]})}var tM=s(37614);function tL({value:e,onChange:t,disabled:s=!1}){return(0,n.jsxs)("div",{className:"space-y-2.5 rounded-lg border border-border/50 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-base font-medium",children:[(0,n.jsx)(tM.A,{className:"size-4 text-muted-foreground"}),"Auto Mode"]}),(0,n.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Mode",disabled:s,onClick:()=>t(!e),className:"rounded-full p-1 outline-none transition-opacity motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",children:(0,n.jsx)("span",{className:(0,k.cn)("relative inline-block h-4 w-7 shrink-0 rounded-full transition-colors motion-reduce:transition-none",e?"bg-primary":"bg-border"),children:(0,n.jsx)("span",{className:(0,k.cn)("absolute left-0 top-0.5 size-3 rounded-full bg-foreground ring-1 ring-border transition-transform motion-reduce:transform-none motion-reduce:transition-none",e?"translate-x-3.5":"translate-x-0.5")})})})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:e?"開啟:Agent 會直接修改檔案、執行指令,不會逐次向你確認。":"關閉:Agent 每次要動作前,都會在終端機裡等你允許。"})]})}var tF=s(28333);function tG(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function tO(e,t){return!!(t&&e.find(e=>e.path===t)?.missing)}function tH({projectPath:e,recentProjects:t,disabled:s,onSelect:a,onBrowse:i}){let l=e?tG(e):null,o=t.filter(t=>!(t.missing&&t.name===l&&t.path!==e));e&&!o.some(t=>t.path===e)&&o.unshift({path:e,name:l??e,lastUsedAt:0,missing:!1});let c=new Map;for(let e of o)c.set(e.name,(c.get(e.name)??0)+1);let d=tO(t,e),[m,x]=(0,r.useState)(""),f=()=>{let e=m.trim();e&&(a(e),x(""))};return(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("select",{name:"project-folder","aria-label":"專案資料夾",value:e??"",onChange:e=>e.target.value&&a(e.target.value),disabled:s||0===o.length,className:(0,k.cn)(tR,"min-w-0 flex-1",d&&"border-destructive/60"),children:[(0,n.jsx)("option",{value:"",disabled:!0,children:o.length>0?"選擇使用過的專案…":"尚無使用過的專案,請點右側按鈕選取"}),o.map(e=>{let t,s;return(0,n.jsxs)("option",{value:e.path,title:e.path,children:[e.name,(c.get(e.name)??0)>1?` — ${(s=Math.max((t=e.path.replace(/[\\/]+$/,"")).lastIndexOf("/"),t.lastIndexOf("\\")))>0?t.slice(0,s):t}`:"",e.missing?"(路徑遺失)":""]},e.path)})]}),(0,n.jsx)(C,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",onClick:i,disabled:s,tone:"primary",className:"rounded-md border border-border p-2",children:(0,n.jsx)(ed.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{type:"text",name:"project-path","aria-label":"輸入專案資料夾路徑",placeholder:"或輸入資料夾的絕對路徑,按 Enter 套用",value:m,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),f())},disabled:s,spellCheck:!1,className:(0,k.cn)(tR,"min-w-0 flex-1 font-mono text-sm")}),(0,n.jsx)(C,{"aria-label":"套用輸入的路徑",title:"套用輸入的路徑",onClick:f,disabled:s||""===m.trim(),className:"rounded-md border border-border p-2",children:(0,n.jsx)(tF.A,{className:"size-4"})})]}),e&&!d&&(0,n.jsx)("p",{className:"truncate text-sm text-muted-foreground",title:e,children:e}),d&&(0,n.jsxs)("p",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm",children:[(0,n.jsx)(u.A,{className:"mt-0.5 size-3.5 shrink-0 text-destructive"}),(0,n.jsxs)("span",{children:["找不到 ",(0,n.jsx)("code",{className:"break-all text-foreground",children:e}),",專案可能已被移動或刪除。請點右側資料夾按鈕重新選取,之後選單會改用新的路徑。"]})]})]})}function tY({show:e,enabled:t,id:s,className:r,children:a}){let i=(0,c.I)()??!1;return e?t?(0,n.jsx)(d.PY1.div,{id:s,initial:"hidden",animate:"visible",variants:W({timing:"standard",transform:{y:-4},reducedMotion:i}),className:r,children:a}):(0,n.jsx)("div",{id:s,className:r,children:a}):null}function tV({attachment:e,id:t,creating:s,animated:r,onRemove:a}){let i=(0,H.tF)(),l=(0,c.I)()??!1,o=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tP.A,{className:"size-3.5 shrink-0 text-primary"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",title:e.name,children:e.name}),(0,n.jsx)(C,{"aria-label":`移除附件 ${e.name}`,onClick:()=>a(t),disabled:s,className:"p-1",children:(0,n.jsx)(O.A,{className:"size-3.5"})})]});return r?(0,n.jsx)(d.PY1.li,{initial:"hidden",animate:"visible",exit:"exit",variants:X({timing:"micro",transform:{y:4},reducedMotion:l}),inert:!i,"aria-hidden":!i||void 0,className:(0,k.cn)("flex items-center gap-2 rounded-md border border-border/60 bg-muted/30 px-3 py-2",!i&&"pointer-events-none"),children:o}):(0,n.jsx)("li",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-muted/30 px-3 py-2",children:o})}function tK({title:e,agents:t,detectTimedOut:s,onRetry:r,agentCli:a,onAgentChange:i,model:l,onModelChange:o,agentConnections:c}){let d="claude"===a||"codex"===a?a:null,u=d?c?.[d]?.models??[]:[],m=l&&!u.includes(l)?[l,...u]:u,x=m.length>0;return(0,n.jsxs)("div",{className:"space-y-3 rounded-lg border border-border/50 p-4",children:[(0,n.jsx)("p",{className:"text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:e}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(e8.A,{className:"size-3"}),"Agent CLI"]}),null===t?s?(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"text-sm text-destructive",children:"偵測逾時,請確認 Agent CLI 已安裝。"}),(0,n.jsx)("button",{type:"button",onClick:r,className:"rounded-sm text-sm text-primary underline outline-none hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"重新偵測"})]}):(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),"偵測中…"]}):0===t.length?(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"未偵測到 Agent CLI(claude / codex)。"}):(0,n.jsx)("select",{name:`${e.toLowerCase().replace(/\s+/g,"-")}-agent-cli`,value:a,onChange:e=>i(e.target.value),className:tR,children:t.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Model"}),x?(0,n.jsxs)("select",{name:`${e.toLowerCase().replace(/\s+/g,"-")}-model`,value:l,onChange:e=>o(e.target.value),className:tR,children:[(0,n.jsx)("option",{value:"",children:"使用預設 model"}),m.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):(0,n.jsx)("p",{className:"rounded-md border border-border/50 bg-muted/20 p-2 text-sm text-muted-foreground",children:"尚未連線或無法取得 model list,將使用預設 model。"})]})]})}function tU({creating:e,error:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,initRepository:o,detectAgents:c,agentConnections:d,onSubmit:u,onClose:m,inline:x=!1,initialProjectPath:f,defaultAutoMode:h=!0,workstationPath:p}){let[b,N]=(0,r.useState)(1),[y,w]=(0,r.useState)(""),[A,S]=(0,r.useState)(""),[z,E]=(0,r.useState)(null),[I,P]=(0,r.useState)([]),[T,R]=(0,r.useState)(null),[$,B]=(0,r.useState)(!1),[_,M]=(0,r.useState)(!1),[L,F]=(0,r.useState)(""),[G,H]=(0,r.useState)(""),[Y,V]=(0,r.useState)(null),[K,U]=(0,r.useState)(!1),[W,X]=(0,r.useState)(0),[q,J]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)("claude"),[ee,et]=(0,r.useState)(""),[es,en]=(0,r.useState)(tD),[er,ea]=(0,r.useState)(h),[ei,el]=(0,r.useState)([]),[eo,ec]=(0,r.useState)(null),[ed,eu]=(0,r.useState)(!1),[em,ex]=(0,r.useState)(!1),ef=(0,r.useId)(),ep=(0,r.useRef)(0),eb=(0,r.useRef)(null),ej=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;U(!1),V(null);let t=setTimeout(()=>{e&&U(!0)},6e3);return c().then(s=>{e&&(clearTimeout(t),V(s),!s.some(e=>"claude"===e.id)&&s.length>0&&Z(s[0].id))}),()=>{e=!1,clearTimeout(t)}},[c,W]),(0,r.useEffect)(()=>{2===b&&eb.current?.focus()},[b]),(0,r.useEffect)(()=>{x&&eb.current?.focus()},[]),(0,r.useEffect)(()=>{let e=!0;return a().then(t=>{e&&P(t)}),()=>{e=!1}},[a]);let ev=tO(I,z),eN=async e=>{E(e),R(null),F(""),B(!0);try{let t=await i(e);R(t),F(t?.defaultBase??"")}finally{B(!1)}},ey=async e=>{if(tO(I,e)){E(e),R(null),F("");return}await eN(e)},ek=async()=>{let e=await s();e&&(P(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await eN(e))},ew=async()=>{if(z){M(!0);try{let e=await o(z);R(e),F(e?.defaultBase??"")}finally{M(!1)}}};(0,r.useEffect)(()=>{x&&f&&ey(f)},[]);let eC=T?.isRepo??!1,eA=T?.hasRemote??!1,eS=`${p?.trim()||"~/Desktop"}/${z?tG(z):"<專案名>"}`,ez=!!z&&!ev&&eC&&!$&&!_,eE=y.trim().length>0&&!e&&!em&&(!x||ez),eI=()=>{eE&&z&&u(y.trim(),A.trim(),z,eA&&L||null,G.trim(),Q,ee,es,er,ei.map(({input:e})=>e))},eP=async e=>{ec(null),ex(!0);try{let t=(await eg(e)).map(e=>({id:ep.current++,input:e}));el(e=>[...e,...t])}catch(e){ec(e instanceof Error?e.message:String(e))}finally{ex(!1)}},eT=(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium uppercase tracking-wide text-muted-foreground",children:"專案資料夾"}),(0,n.jsx)(tH,{projectPath:z,recentProjects:I,disabled:e||_||$,onSelect:e=>void ey(e),onBrowse:()=>void ek()})]}),(0,n.jsx)(tY,{show:$||_,enabled:x,children:(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),_?"初始化 Git…":"偵測 Git 狀態中…"]})}),(0,n.jsx)(tY,{show:!!T&&!ev&&!$&&!_&&!eC,enabled:x,children:(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/40 bg-destructive/10 p-3",children:[(0,n.jsxs)("p",{className:"text-base",children:["這個資料夾不是 Git repository。請改選一個 Git 專案,或在這裡初始化:會執行",(0,n.jsx)("code",{className:"text-foreground",children:" git init "}),"並建立一個空的初始 commit。"]}),(0,n.jsx)(eh,{size:"sm",variant:"outline",onClick:()=>void ew(),disabled:e,className:"rounded-full",children:"初始化 Git"})]})}),(0,n.jsx)(tY,{show:eC&&eA,enabled:x,children:(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsx)("select",{name:"base-branch",value:L,onChange:e=>F(e.target.value),className:tR,children:(T?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]})}),(0,n.jsx)(tY,{show:eC&&!eA,enabled:x,children:(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["此 repository 沒有 remote,將以目前分支 (",T?.currentBranch??"HEAD",") 為基準建立本地 worktree。"]})}),(0,n.jsx)(tY,{show:eC,enabled:x,children:(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3"}),"分支名稱 (選填)"]}),(0,n.jsx)("input",{name:"branch",value:G,onChange:e=>H(e.target.value),placeholder:"留空則自動命名,例如 feature/login-fix",className:tR}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:eA?"填寫後會建立同名分支;若 remote 已有這個分支,則直接取回並接續上面的工作。":"填寫後會建立同名分支。"})]})}),(0,n.jsx)(tY,{show:eC,enabled:x,children:(0,n.jsxs)("div",{className:"space-y-1.5 rounded-lg border border-border/50 bg-muted/20 p-4",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium",children:[(0,n.jsx)(tT.A,{className:"size-3.5 text-muted-foreground"}),"建立後會立刻做這些事"]}),(0,n.jsxs)("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:[(0,n.jsxs)("li",{children:["在 ",(0,n.jsx)("code",{className:"text-foreground",children:eS})," ","底下建立這張卡專用的 worktree 與分支,你的專案資料夾本身不會被切換。"]}),eA&&(0,n.jsx)("li",{children:"把新分支 push 到 origin;遠端會多出一條分支,有 CI 的話可能被觸發。"}),(0,n.jsxs)("li",{children:["把被 git 忽略的檔案(例如 ",(0,n.jsx)("code",{className:"text-foreground",children:".env"}),")複製一份進 worktree,相依套件資料夾則在背景複製,好讓新 worktree 能直接跑起來。"]}),(0,n.jsxs)("li",{children:["把 VibeFlow 的執行期檔案寫進"," ",(0,n.jsx)("code",{className:"text-foreground",children:".git/info/exclude"}),",不會動到專案的 .gitignore。"]})]})]})})]}),eR=(0,n.jsxs)("div",{className:"rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button","aria-expanded":q,"aria-controls":ef,onClick:()=>J(e=>!e),className:"flex w-full items-center justify-between px-4 py-3 text-left text-base font-medium transition-colors motion-reduce:transition-none outline-none hover:bg-accent/40 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{children:"Advanced"}),(0,n.jsx)(j.A,{className:(0,k.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",q&&"rotate-180")})]}),(0,n.jsx)(tY,{show:q,enabled:x,id:ef,className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(tK,{title:"Agent",agents:Y,detectTimedOut:K,onRetry:()=>X(e=>e+1),agentCli:Q,onAgentChange:e=>{Z(e),et("")},model:ee,onModelChange:et,agentConnections:d})})]}),e$=(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"附件(選填)"}),(0,n.jsxs)("button",{type:"button",disabled:e||em,onClick:()=>ej.current?.click(),onDragEnter:t=>{t.preventDefault(),e||em||eu(!0)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},onDragLeave:()=>eu(!1),onDrop:t=>{t.preventDefault(),eu(!1),e||em||!(t.dataTransfer.files.length>0)||eP(t.dataTransfer.files)},className:(0,k.cn)("flex w-full flex-col items-center gap-2 rounded-lg border-2 border-dashed border-border py-5 text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:border-primary/50 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",ed&&"border-primary/70 bg-primary/5 text-foreground"),children:[(0,n.jsx)(tP.A,{className:"size-5"}),(0,n.jsx)("span",{className:"text-sm",children:"拖放檔案到這裡,或點擊選擇檔案"})]}),(0,n.jsx)("input",{ref:ej,type:"file",multiple:!0,disabled:e||em,className:"hidden",onChange:e=>{e.target.files&&eP(e.target.files),e.target.value=""}}),em&&(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),"讀取附件中…"]}),(0,n.jsx)("ul",{className:"space-y-1.5",children:(0,n.jsx)(l.N,{initial:!1,children:ei.map(({id:t,input:s})=>(0,n.jsx)(tV,{attachment:s,id:t,creating:e,animated:x,onRemove:e=>el(t=>t.filter(t=>t.id!==e))},t))})}),eo&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:eo})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"新增任務"}),m&&(0,n.jsx)(C,{"aria-label":"關閉新增任務",onClick:m,disabled:e,className:"p-1",children:(0,n.jsx)(O.A,{className:"size-4"})})]}),!x&&(0,n.jsxs)("div",{className:"mb-5 flex items-center gap-2",children:[(0,n.jsx)("div",{className:(0,k.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",1===b?"bg-primary text-primary-foreground":"bg-primary/20 text-primary"),children:b>1?(0,n.jsx)(v.A,{className:"size-3.5",strokeWidth:3}):"1"}),(0,n.jsx)("span",{className:(0,k.cn)("text-base tracking-[-0.224px]",1===b?"font-medium text-foreground":"text-muted-foreground"),children:"專案設定"}),(0,n.jsx)("div",{className:(0,k.cn)("h-0.5 flex-1 transition-colors",b>1?"bg-primary/60":"bg-border")}),(0,n.jsx)("div",{className:(0,k.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",2===b?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"2"}),(0,n.jsx)("span",{className:(0,k.cn)("text-base tracking-[-0.224px]",2===b?"font-medium text-foreground":"text-muted-foreground"),children:"任務內容"})]}),x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"mb-5 block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{ref:eb,name:"task-title",autoComplete:"off",value:y,onChange:e=>w(e.target.value),placeholder:"例如:實作登入頁面",className:(0,k.cn)(tR,"text-lg")})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[(0,n.jsxs)("div",{className:"space-y-4",children:[eT,e$]}),(0,n.jsxs)("div",{className:"flex h-full flex-col gap-4",children:[(0,n.jsxs)("label",{className:"flex min-h-0 flex-1 flex-col gap-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"詳細描述(選填)"}),(0,n.jsx)("textarea",{name:"task-description",autoComplete:"off",value:A,onChange:e=>S(e.target.value),rows:12,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,k.cn)(tR,"mb-2 min-h-64 flex-1 resize-y")})]}),(0,n.jsx)(t_,{value:es,onChange:en,disabled:e}),(0,n.jsx)(tL,{value:er,onChange:ea,disabled:e}),t&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-base",children:t})]})]}),(0,n.jsx)("div",{className:"mt-5",children:eR})]}),!x&&(0,n.jsxs)("div",{children:[1===b&&(0,n.jsx)("div",{className:"space-y-4",children:eT}),2===b&&(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{ref:eb,name:"task-title",autoComplete:"off",value:y,onChange:e=>w(e.target.value),placeholder:"例如:實作登入頁面",className:tR})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"詳細描述(選填)"}),(0,n.jsx)("textarea",{value:A,name:"task-description",autoComplete:"off",onChange:e=>S(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,k.cn)(tR,"resize-y")})]}),(0,n.jsx)(t_,{value:es,onChange:en,disabled:e}),(0,n.jsx)(tL,{value:er,onChange:ea,disabled:e}),e$,eR,t&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-base",children:t})]})]}),x?(0,n.jsxs)("div",{className:"mt-6 space-y-2 pb-10",children:[!ez&&y.trim().length>0&&(0,n.jsx)("p",{className:"text-right text-sm text-muted-foreground",children:"請先在左側選擇專案資料夾"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[m&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:m,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:eI,disabled:!eE,className:(0,k.cn)("rounded-full px-5 active:scale-95 transition-transform motion-reduce:transform-none motion-reduce:transition-none",e&&"opacity-80"),children:[e&&(0,n.jsx)(D.A,{className:"animate-spin"}),e?"建立 Worktree 中…":"建立任務"]})]})]}):1===b?(0,n.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[m&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:m,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsx)(eh,{size:"sm",onClick:()=>N(2),disabled:!ez,className:"rounded-full px-5",children:"下一步 →"})]}):(0,n.jsxs)("div",{className:"mt-5 flex items-center justify-between",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>N(1),disabled:e,className:"rounded-full",children:"← 上一步"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[m&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:m,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:eI,disabled:!eE,className:(0,k.cn)("rounded-full px-5 active:scale-95 transition-transform motion-reduce:transform-none motion-reduce:transition-none",e&&"opacity-80"),children:[e&&(0,n.jsx)(D.A,{className:"animate-spin"}),e?"建立 Worktree 中…":"建立任務"]})]})]})]})}let tW="vibeflow:board-split-px";function tX(){let e=Number(window.localStorage.getItem(tW));return Number.isFinite(e)&&e>=180?e:null}function tq({active:e,children:t}){let s=(0,o.E)(),a=(0,c.I)()??!1,i=W({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:a});return(0,r.useEffect)(()=>{s.stop(),s.set("hidden"),e&&s.start("visible")},[e,s,a]),(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:s,variants:i,inert:!e,"aria-hidden":!e||void 0,className:(0,k.cn)("h-full",!e&&"hidden pointer-events-none"),children:t})}function tJ({board:e,onBoardChange:t,onEditTask:s,onTaskDone:a,onDeleteTask:i,autoMode:o,workstationPath:m,subAgents:x,selectedTaskId:f,onSelectTask:h,onNewTask:p,tabBar:g,onTaskInteract:b,openTabIds:j,initialProjectPath:v,newTaskNonce:N,creating:y,createError:w,pickFolder:C,loadRecentProjects:A,loadGitInfo:S,initRepository:z,detectAgents:E,agentConnections:I,onCreateTask:P}){let[T,R]=(0,r.useState)(null),$=(0,r.useRef)(null),[D,_]=(0,r.useState)(new Set),[M,L]=(0,r.useState)({}),F=(0,r.useRef)(M);F.current=M;let G=W({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:(0,c.I)()??!1}),O=e=>_(t=>t.has(e)?t:new Set(t).add(e)),[H,Y]=(0,r.useState)(null),[V,K]=(0,r.useState)(null),U=async(e,t={})=>{O(e.id),L(s=>({...s,[e.id]:{launch:t,nonce:(s[e.id]?.nonce??0)+1}}))};(0,r.useEffect)(()=>{if(!f||(O(f),M[f]))return;let t=e.in_progress.find(e=>e.id===f);if(!t||null==t.launchedAt||!t.worktreePath)return;let s=!1;return e4(t.id).then(e=>{s||!e||F.current[t.id]||U(t,{resume:!0})}),()=>{s=!0}},[f]);let X=s=>{let n={...s,launchedAt:Date.now()};t({backlog:e.backlog.filter(e=>e.id!==s.id),in_progress:[n,...e.in_progress],done:e.done}),U(n)},J=e=>new Promise((t,s)=>{K({task:e,settle:n=>{(K(null),n)?Q(e).then(()=>t(!0),s):t(!1)}})}),Q=async e=>{let s=await eD(e.id);if(!s)throw Error("未連線到 VibeFlow core");let n=s.state.board;t({backlog:[s.task,...n.backlog.filter(t=>t.id!==e.id)],in_progress:n.in_progress.filter(t=>t.id!==e.id),done:n.done.filter(t=>t.id!==e.id)})},Z=async e=>{await U(e,{includeTaskPrompt:!1})},ee=e=>Y(e),es=(0,r.useRef)(null),en=(0,r.useRef)(null),[er,ea]=(0,r.useState)(tX);(0,r.useLayoutEffect)(()=>{if(null!==er)return;let e=es.current?.clientHeight??0;e>0&&ea(Math.max(180,e-260))},[er]);let ei=e=>{let t=es.current?.clientHeight??0;return Math.max(180,Math.min(e,Math.max(180,t>0?t-260:e)))},el=()=>{en.current&&null!==er&&(en.current=null,window.localStorage.setItem(tW,String(er)))},eo=e=>{if(null===er)return;let t=ei(er+e);ea(t),window.localStorage.setItem(tW,String(t))},ec=T?Object.values(e).flat().find(e=>e.id===T):null,ed=T?x[T]:void 0,eu=T&&ec?{taskId:T,taskTitle:ec.title,runs:ed??[]}:null;(0,r.useEffect)(()=>{T&&ec&&($.current={taskId:T,taskTitle:ec.title,runs:ed??[]})},[T,ec,ed]);let em=eu??$.current;return(0,n.jsxs)("div",{ref:es,className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsx)("div",{style:null===er?void 0:{height:er},className:(0,k.cn)("min-h-0 overflow-hidden border-b border-border",null===er?"flex-1":"shrink-0"),children:(0,n.jsx)(B,{board:e,subAgents:x,selectedTaskId:f??null,onSelectTask:h,onEditTask:s,onDeleteTask:i,onNewTask:p})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":"調整看板與工作區的高度",tabIndex:0,onPointerDown:e=>{null!==er&&(en.current={y:e.clientY,height:er},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=en.current;t&&ea(ei(t.height+(e.clientY-t.y)))},onPointerUp:el,onPointerCancel:el,onKeyDown:e=>{"ArrowUp"===e.key?(e.preventDefault(),eo(-24)):"ArrowDown"===e.key&&(e.preventDefault(),eo(24))},className:"flex h-2.5 shrink-0 cursor-row-resize items-center justify-center border-y border-border bg-card outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)("span",{className:"h-0.5 w-12 rounded-full bg-input"})}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[g,(0,n.jsx)("main",{className:"min-h-0 flex-1",children:(()=>{let t=[...e.in_progress.map(e=>({task:e,column:"in_progress"})),...e.backlog.map(e=>({task:e,column:"backlog"})),...e.done.map(e=>({task:e,column:"done"}))],r=f?t.find(({task:e})=>e.id===f):null,a=new Set(j),l=new Set;for(let e of D){let s=t.find(({task:t})=>t.id===e);s&&(a.has(e)||"in_progress"===s.column)&&l.add(e)}return r&&l.add(r.task.id),(0,n.jsxs)(n.Fragment,{children:[Array.from(l).map(e=>{let r=t.find(({task:t})=>t.id===e);if(!r)return null;let a=e===f;return(0,n.jsx)(tq,{active:a,children:(0,n.jsx)(tI,{task:r.task,column:r.column,subAgents:x[r.task.id]??[],launch:M[e],onStart:X,onReturnToBacklog:J,onLaunchAgent:Z,onComplete:ee,onEdit:s,onDelete:i,onOpenSubAgents:R,onInteract:b?()=>b(e):void 0})},e)}),!r&&(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:G,className:"flex h-full overflow-y-auto p-8",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-5xl pb-8",children:(0,n.jsx)(tU,{inline:!0,initialProjectPath:v,creating:y,error:w,pickFolder:C,loadRecentProjects:A,loadGitInfo:S,initRepository:z,detectAgents:E,agentConnections:I,defaultAutoMode:o,workstationPath:m,onSubmit:P},`${v??"new"}:${N}`)})})]})})()})]}),(0,n.jsx)(et,{open:null!==T,taskId:em?.taskId??"",taskTitle:em?.taskTitle??"",runs:em?.runs??[],onClose:()=>R(null)}),(0,n.jsx)(l.N,{children:H&&(0,n.jsx)(q,{title:"完成任務",onClose:()=>Y(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["完成「",H.title,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除這張卡的 worktree(尚未 commit 的變更會一起消失)、本地分支",H.branch?`「${H.branch}」`:"","與 artifacts, 並把專案切回",H.baseBranch?`「${H.baseBranch}」`:"基準分支","後更新。此操作無法復原,請先確認要保留的變更都已經 commit 或 push。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>Y(null),children:"取消"}),(0,n.jsx)(eh,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>{var s;let n;H&&(Y(null),s="done",(n={backlog:e.backlog.filter(e=>e.id!==H.id),in_progress:e.in_progress.filter(e=>e.id!==H.id),done:e.done.filter(e=>e.id!==H.id)})[s]=[H,...n[s]],t(n),a(H.id))},children:"完成並清理"})]})]})},"confirm-done-dialog")}),(0,n.jsx)(l.N,{children:V&&(0,n.jsx)(q,{title:"退回 Backlog",onClose:()=>V.settle(!1),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["把「",V.task.title,"」退回 Backlog?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會停止 Agent,並把 worktree 還原到",V.task.baseBranch?`「${V.task.baseBranch}」`:"基準分支","——這張卡在本地的 commit 與未 commit 變更都會消失,artifacts 與決策紀錄也會一併刪除。遠端分支不會被改動。此操作無法復原。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>V.settle(!1),children:"取消"}),(0,n.jsx)(eh,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>V.settle(!0),children:"清除並退回"})]})]})},"confirm-return-dialog")})]})}var tQ=s(51662);function tZ({task:e,detectAgents:t,agentConnections:s,pickFolder:a,loadRecentProjects:i,loadGitInfo:o,saving:c,error:d,defaultAutoMode:u=!0,onSubmit:m,onClose:x}){let[f,h]=(0,r.useState)(""),[p,b]=(0,r.useState)(""),[v,N]=(0,r.useState)("claude"),[y,w]=(0,r.useState)(""),[C,A]=(0,r.useState)(tD),[S,z]=(0,r.useState)(!0),[E,I]=(0,r.useState)(null),[P,T]=(0,r.useState)(""),[R,$]=(0,r.useState)(null),[B,_]=(0,r.useState)(!1),[M,L]=(0,r.useState)(!1),[F,G]=(0,r.useState)([]),[O,H]=(0,r.useState)(null),[Y,V]=(0,r.useState)(!1),[K,U]=(0,r.useState)(0),[W,X]=(0,r.useState)(!0),[J,Q]=(0,r.useState)(!1),Z=(0,r.useRef)(null),ee=e??Z.current;if((0,r.useEffect)(()=>{e&&(Z.current=e)},[e]),(0,r.useEffect)(()=>{e&&(h(e.title),b(e.description??""),N(e.agentCli??"claude"),w(e.model??""),A(e.effort??tD),z(e.autoMode??u),I(e.projectPath??null),T(e.baseBranch??""),$(null),_(!1),L(!1),Q(!1))},[e,u]),(0,r.useEffect)(()=>{if(!e||e.launchedAt)return;let t=!0;return i().then(e=>{t&&G(e)}),()=>{t=!1}},[e,i]),(0,r.useEffect)(()=>{if(!e)return;let s=!0;V(!1),H(null);let n=setTimeout(()=>{s&&V(!0)},6e3);return t().then(e=>{s&&(clearTimeout(n),H(e))}),()=>{s=!1,clearTimeout(n)}},[e,t,K]),!ee)return null;let et=!ee.launchedAt,es=f!==ee.title||p!==(ee.description??"")||v!==(ee.agentCli??"claude")||y!==(ee.model??"")||C!==(ee.effort??tD)||S!==(ee.autoMode??u)||M||P!==(ee.baseBranch??""),en=()=>{c||(es?Q(!0):x())},er=tO(F,E),ea=async(e,t=!1)=>{if(I(e),L(e!==ee.projectPath),$(null),!(!t&&tO(F,e))){_(!0);try{let t=await o(e);$(t),T(t?.defaultBase??"")}finally{_(!1)}}},ei=async()=>{let e=await a();e&&(G(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await ea(e,!0))},el=R?.isRepo??!0,eo=R?.hasRemote??!1,ec=f.trim().length>0&&!c&&!B&&(!M||el&&!er);return(0,n.jsx)(l.N,{children:e&&(0,n.jsxs)(q,{title:"編輯任務",description:"更新任務內容與 agent 設定。",saving:c,onClose:en,showHeader:!0,contentClassName:"max-w-2xl",footer:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:en,disabled:c,children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:()=>{ec&&m({title:f.trim(),description:p.trim(),agentCli:v,model:y,effort:C,autoMode:S,...et&&E?{projectPath:E,baseBranch:P||null}:{}})},disabled:!ec,className:(0,k.cn)(c&&"opacity-80"),children:[c&&(0,n.jsx)(D.A,{className:"animate-spin"}),c?"儲存中…":"儲存變更"]})]})]}),children:[J&&(0,n.jsxs)("div",{className:"mb-4 flex items-center justify-between rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-base",children:[(0,n.jsx)("span",{className:"text-warning",children:"有未儲存的變更,確定要離開?"}),(0,n.jsxs)("div",{className:"flex gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>Q(!1),className:"rounded-md px-2 py-0.5 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"繼續編輯"}),(0,n.jsx)("button",{type:"button",onClick:x,className:"rounded-md px-2 py-0.5 text-sm text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"放棄離開"})]})]}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{autoFocus:!0,name:"edit-task-title",autoComplete:"off",value:f,onChange:e=>h(e.target.value),placeholder:"例如:實作登入頁面",className:tR})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"詳細描述(選填)"}),(0,n.jsx)("textarea",{name:"edit-task-description",autoComplete:"off",value:p,onChange:e=>b(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,k.cn)(tR,"resize-y")})]}),(0,n.jsx)(t_,{value:C,onChange:A,disabled:c}),(0,n.jsx)(tL,{value:S,onChange:z,disabled:c}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium uppercase tracking-wide text-muted-foreground",children:[(0,n.jsx)(ed.A,{className:"size-3"}),"專案資料夾"]}),et?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tH,{projectPath:E,recentProjects:F,disabled:c||B,onSelect:e=>void ea(e),onBrowse:()=>void ei()}),B&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(D.A,{className:"size-3 animate-spin"}),"偵測 Git 狀態中…"]}),M&&!er&&!B&&!el&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"這個資料夾不是 Git repository,請改選一個 Git 專案。"}),M&&!er&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"更換專案會在新專案重建 worktree(此任務尚未開始,無變更會遺失)。"}),M&&el&&eo&&(0,n.jsxs)("label",{className:"block space-y-1.5 pt-1",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[(0,n.jsx)(g.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsx)("select",{name:"edit-base-branch",value:P,onChange:e=>T(e.target.value),className:tR,children:(R?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 bg-muted/30 px-3 py-2.5",children:[(0,n.jsx)(tQ.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"flex-1 truncate text-base",title:ee.projectPath,children:ee.projectName??(ee.projectPath?tG(ee.projectPath):"—")}),(0,n.jsx)("span",{className:"shrink-0 text-sm text-muted-foreground",children:"任務已開始,鎖定"})]})]}),(0,n.jsxs)("div",{className:"rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>X(e=>!e),className:"flex w-full items-center justify-between px-4 py-3 text-left text-base font-medium transition-colors outline-none hover:bg-accent/40 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{children:"Advanced"}),(0,n.jsx)(j.A,{className:(0,k.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",W&&"rotate-180")})]}),W&&(0,n.jsx)("div",{className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(tK,{title:"Agent",agents:O,detectTimedOut:Y,onRetry:()=>U(e=>e+1),agentCli:v,onAgentChange:e=>{N(e),w("")},model:y,onModelChange:w,agentConnections:s})})]}),d&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:d})]})]},ee.id)})}var t0=s(1896),t1=s(87617),t5=s(6616),t2=s(37744),t3=s(80802),t4=s(69758),t6=s(21684),t8=s(18319),t7=s(37156);let t9=[{id:"skill",label:"Skills",hint:"兩個 agent 都會載入。import 需選擇含 SKILL.md 的目錄。"},{id:"prompt",label:"Prompts",hint:"啟用的內容會併入啟動時的 system prompt,排在 Settings 的 System Prompt 之前。"},{id:"script",label:"Scripts",hint:"路徑與用途會寫進 prompt,由 agent 自行決定要不要執行。"}],se={skill:t6.A,prompt:eu.A,script:t8.A};function st(e,t){return"skill"!==e?"":`---
7
- name: ${t}
8
- description:
9
- ---
10
-
11
- `}function ss({onEditingChange:e}){let[t,s]=(0,r.useState)([]),[a,i]=(0,r.useState)(!0),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(null),[u,m]=(0,r.useState)(null),[f,h]=(0,r.useState)(null),p=(0,r.useCallback)(async()=>{s(await eV()),i(!1)},[]);(0,r.useEffect)(()=>{p()},[p]),(0,r.useEffect)(()=>{e?.(null!==f)},[f,e]);let g=async(e,t)=>{o(e),d(null);try{await t(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{o(null)}};return f?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-base font-medium",children:f.entry.name}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"skill"===f.entry.kind?"編輯 SKILL.md。frontmatter 的 name 與 description 兩個 CLI 都會讀。":"編輯檔案內容。"})]}),(0,n.jsx)("textarea",{value:f.content,onChange:e=>h({...f,content:e.target.value}),rows:18,spellCheck:!1,className:(0,k.cn)(tR,"resize-y font-mono text-sm leading-5")}),c&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:c}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(eh,{size:"sm",onClick:()=>void(()=>{if(!f)return;let{entry:e,content:t}=f;return g(`save:${e.key}`,async()=>{await eX(e.kind,e.name,t),h(null)})})(),disabled:null!==l,children:"儲存"})]})]}):(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟用的項目會在每次啟動任務時自動投遞:Claude 以 session-only plugin 載入,Codex 以 VibeFlow 組出的 CODEX_HOME 載入。本機與專案自己的 skill 仍會照常載入,這裡的項目是額外加上去的。"}),c&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:c}),t9.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=se[e];return(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:(0,k.cn)(y,"flex items-center gap-2"),children:[(0,n.jsx)(o,{className:"size-3.5"}),s,(0,n.jsx)("span",{className:"tabular-nums text-muted-foreground/70",children:i.length})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(eh,{variant:"ghost",size:"sm",onClick:()=>{g(`import:${e}`,async()=>{let t=await eY(e);t&&await eK(e,t)})},disabled:null!==l,children:[l===`import:${e}`?(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(t7.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(eh,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:st(e,""),description:""}),disabled:null!==l,children:[(0,n.jsx)(N.A,{className:"size-3.5"}),"新建"]})]})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:r}),u?.kind===e&&(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border/60 p-3",children:[(0,n.jsx)("input",{autoFocus:!0,value:u.name,onChange:t=>{let s=t.target.value;m({...u,name:s,content:u.content===st(e,u.name)?st(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,k.cn)(tR,"font-mono text-sm")}),"skill"!==e&&(0,n.jsx)("input",{value:u.description,onChange:e=>m({...u,description:e.target.value}),placeholder:"用途說明(scripts 會寫進 prompt 給 agent 判斷)",className:(0,k.cn)(tR,"text-sm")}),(0,n.jsx)("textarea",{value:u.content,onChange:e=>m({...u,content:e.target.value}),rows:8,spellCheck:!1,placeholder:"skill"===e?"":"內容",className:(0,k.cn)(tR,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(eh,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return g("create",async()=>{await eU(e,t,s,n.trim()||void 0),m(null)})})(),disabled:null!==l||0===u.name.trim().length,children:"建立"})]})]}),a?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"讀取中…"}):0===i.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"尚無項目。"}):(0,n.jsx)("div",{className:"grid gap-2",children:i.map(e=>(0,n.jsxs)("div",{className:"flex items-start gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:t=>void g(`toggle:${e.key}`,()=>eq(e.kind,e.name,t.target.checked)),"aria-label":`啟用 ${e.name}`,className:"mt-1 size-4 shrink-0 rounded-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"truncate font-mono text-sm",children:e.name}),e.description&&(0,n.jsx)("p",{className:"line-clamp-2 text-sm text-muted-foreground",title:e.description,children:e.description}),e.sourcePath&&(0,n.jsxs)("p",{className:"truncate text-xs text-muted-foreground/70",children:["來源:",e.sourcePath]})]}),(0,n.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>{g(`open:${e.key}`,async()=>{h({entry:e,content:await eW(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.sourcePath&&(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>{g(`reimport:${e.key}`,async()=>{e.sourcePath&&await eK(e.kind,e.sourcePath)})},disabled:null!==l,title:"從來源重新複製一份快照",children:l===`reimport:${e.key}`?(0,n.jsx)(D.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(em.A,{className:"size-3.5"})}),(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>void g(`delete:${e.key}`,()=>eJ(e.kind,e.name)),disabled:null!==l,title:"從 library 刪除",children:(0,n.jsx)(x.A,{className:"size-3.5 text-destructive"})})]})]},e.key))})]},e)})]})}let sn=[{id:"claude",name:"Claude",platform:"Anthropic Console",keyUrl:"https://platform.claude.com/settings/workspaces/default/keys"},{id:"codex",name:"Codex",platform:"OpenAI Platform",keyUrl:"https://platform.openai.com/api-keys"}];function sr({open:e,systemPrompt:t,workstationPath:s,autoMode:a,agentConnections:i,saving:o,error:c,onSave:d,onConnectAgent:m,onRefreshModels:x,onPickFolder:f,onClose:h}){let[p,g]=(0,r.useState)(""),[b,j]=(0,r.useState)(""),[v,N]=(0,r.useState)(!0),[y,w]=(0,r.useState)(null),[C,A]=(0,r.useState)(""),[S,z]=(0,r.useState)(!1),[E,I]=(0,r.useState)(null),[P,T]=(0,r.useState)(!1),[R,$]=(0,r.useState)(null),[B,M]=(0,r.useState)(!1),[L,F]=(0,r.useState)(null),[G,O]=(0,r.useState)("idle"),[H,Y]=(0,r.useState)(""),[V,K]=(0,r.useState)("https://github.com/login/device"),[U,W]=(0,r.useState)(null),[X,J]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(g(t),j(s),N(a),w(null),M(!1),A(""),z(!1),I(null),T(!1),O("idle"),Y(""),W(null),Z(!1),ew().then(F))},[e,t,s,a]),(0,r.useEffect)(()=>{if(e){var t;let e;return t=e=>{if("starting"===e.type){O("starting"),W(null);return}if("code"===e.type){O("waiting"),Y(e.code),K(e.url),Z(!1),J(!1);return}if("success"===e.type){F(e.status),O("success"),J(!1);return}if("cancelled"===e.type){O("idle"),J(!1);return}O("error"),W(e.error),J(!1)},(e=eb())?e.onGithubAuthEvent(t):()=>{}}},[e]);let[ee,et]=(0,r.useState)(!1),[es,er]=(0,r.useState)(!1),ea=y?i?.[y.id]:void 0,ei=(0,r.useMemo)(()=>sn.reduce((e,t)=>e+(i?.[t.id]?.models??[]).length,0),[i]),el=p.trim(),eo=""===el,ec=!o&&!y&&!B,ed=async()=>{let e=await f();e&&j(e)},eu=async()=>{if(!y||P)return;T(!0),I(null);let e=await m(y.id,C);e?I(e):(A(""),w(null)),T(!1)},ex=async()=>{M(!0),O("starting"),Y(""),W(null),Z(!1),J(!0);try{await eC()}catch(e){O("error"),W(e instanceof Error?e.message:String(e)),J(!1)}},ef=async()=>{("starting"===G||"waiting"===G)&&await eA(),M(!1),O("idle"),J(!1),Y(""),W(null),Z(!1),F(await ew())},ep=async()=>{J(!0),W(null);try{let e=await eS();F(e)}catch(e){W(e instanceof Error?e.message:String(e))}finally{J(!1)}},eg=()=>{B&&("starting"===G||"waiting"===G)&&eA(),h()},ej=async()=>{H&&(await navigator.clipboard.writeText(H),Z(!0),window.setTimeout(()=>Z(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(q,{title:B?"登入 GitHub CLI":y?`連結 ${y.name}`:ee?"Library":"設定",description:B?"使用 GitHub CLI 的網頁授權流程登入 github.com。":y?"綁定個人 API key 以取得可用 model list。":ee?"VibeFlow 自有的 skill / prompt / script,啟動任務時投遞給 Claude 與 Codex。":"調整 system prompt 與 agent 帳號連線。",saving:o||P||X,onClose:eg,showHeader:!0,contentClassName:"max-w-2xl",footer:B?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>void ef(),disabled:X&&"success"!==G,children:"success"===G?"完成":"返回"}),"error"===G&&(0,n.jsx)(eh,{size:"sm",onClick:()=>void ex(),children:"重新登入"})]}):y?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:()=>w(null),disabled:P,children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:eu,disabled:P||0===C.trim().length,className:(0,k.cn)(P&&"opacity-80"),children:[P&&(0,n.jsx)(D.A,{className:"animate-spin"}),P?"驗證中…":"儲存 API key"]})]}):ee?es?null:(0,n.jsxs)(eh,{variant:"ghost",size:"sm",onClick:()=>et(!1),children:[(0,n.jsx)(t0.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",onClick:eg,disabled:o,children:"取消"}),(0,n.jsxs)(eh,{size:"sm",onClick:()=>{ec&&d(el,b.trim(),v)},disabled:!ec,className:(0,k.cn)(o&&"opacity-80"),children:[o&&(0,n.jsx)(D.A,{className:"animate-spin"}),o?"儲存中…":"儲存設定"]})]}),children:B?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void ef(),disabled:X&&"success"!==G,className:"inline-flex items-center gap-1.5 rounded-sm text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:[(0,n.jsx)(t0.A,{className:"size-4"}),"返回設定"]}),(0,n.jsx)("div",{className:"rounded-md border border-border/60 p-3",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:["success"===G?(0,n.jsx)(_.A,{className:"mt-0.5 size-5 shrink-0 text-success"}):"error"===G?(0,n.jsx)(u.A,{className:"mt-0.5 size-5 shrink-0 text-destructive"}):(0,n.jsx)(D.A,{className:"mt-0.5 size-5 shrink-0 animate-spin text-muted-foreground"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("p",{className:"text-base font-medium",children:"success"===G?"GitHub CLI 已完成授權":"error"===G?"GitHub CLI 授權失敗":"waiting"===G?"等待 GitHub 授權完成":"正在啟動 GitHub CLI 登入"}),(0,n.jsx)("p",{className:"text-sm leading-5 text-muted-foreground",children:"success"===G?`目前登入帳號:${L?.login??"GitHub"}`:"error"===G?U:"waiting"===G?"請複製授權碼並開啟 GitHub 授權頁,完成後 VibeFlow 會自動更新狀態。":"VibeFlow 正在背景準備 gh auth login。"})]})]})}),("waiting"===G||H)&&(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"授權碼"}),(0,n.jsxs)("div",{className:"flex rounded-md border bg-background focus-within:ring-[3px] focus-within:ring-ring/50",children:[(0,n.jsx)("input",{readOnly:!0,value:H,className:"min-w-0 flex-1 bg-transparent px-3 py-2 font-mono text-base tracking-wider outline-none"}),(0,n.jsxs)("button",{type:"button",onClick:()=>void ej(),className:"flex h-9 items-center gap-1.5 rounded-r-md px-3 text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset disabled:opacity-50",disabled:!H,children:[(0,n.jsx)(t1.A,{className:"size-4"}),Q?"已複製":"複製"]})]})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"登入網址"}),(0,n.jsxs)("div",{className:"flex rounded-md border bg-background focus-within:ring-[3px] focus-within:ring-ring/50",children:[(0,n.jsx)("input",{readOnly:!0,value:V,className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-base outline-none"}),(0,n.jsxs)("button",{type:"button",onClick:()=>void eQ(V),className:"flex h-9 items-center gap-1.5 rounded-r-md px-3 text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset",children:[(0,n.jsx)(en.A,{className:"size-4"}),"開啟"]})]})]})]})]}):y?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>w(null),disabled:P,className:"inline-flex items-center gap-1.5 rounded-sm text-base text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:[(0,n.jsx)(t0.A,{className:"size-4"}),"返回設定"]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["為了使用 AI 功能,請綁定您的個人 API 金鑰。前往 ",y.platform,"後台建立 API 金鑰並手動貼上。這是個本地執行的應用程式,因此不會將您所儲存的資訊上傳到任何地方。"]}),(0,n.jsxs)("button",{type:"button",onClick:()=>void eQ(y.keyUrl),className:"inline-flex items-center gap-1.5 rounded-sm text-base text-primary outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:["前往 ",y.platform,(0,n.jsx)(en.A,{className:"size-3.5"})]})]}),(0,n.jsxs)("label",{className:"block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"API key"}),(0,n.jsxs)("div",{className:"flex rounded-md border bg-background focus-within:ring-[3px] focus-within:ring-ring/50",children:[(0,n.jsx)("input",{name:`${y.id}-api-key`,autoComplete:"off",value:C,onChange:e=>A(e.target.value),type:S?"text":"password",placeholder:ea?.connected?"輸入新的 API key 以更新連線":"貼上 API key",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-base outline-none"}),(0,n.jsx)("button",{type:"button",onClick:()=>z(e=>!e),className:"flex w-9 items-center justify-center rounded-r-md text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset","aria-label":S?"隱藏 API key":"顯示 API key",children:S?(0,n.jsx)(t5.A,{className:"size-4"}):(0,n.jsx)(t2.A,{className:"size-4"})})]})]}),(E||ea?.error)&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:E??ea?.error})]}):ee?(0,n.jsx)(ss,{onEditingChange:er}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(tL,{value:v,onChange:N}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"flex items-center justify-between",children:(0,n.jsxs)("span",{className:"text-base font-medium",children:["工作站資料夾",(0,n.jsx)("span",{className:(0,k.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",""===b.trim()?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:""===b.trim()?"預設(~/Desktop)":"已自訂"})]})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{name:"workstation-path",autoComplete:"off",spellCheck:!1,value:b,placeholder:"~/Desktop",onChange:e=>j(e.target.value),className:(0,k.cn)(tR,"font-mono text-sm")}),(0,n.jsx)(eh,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void ed(),children:"選擇資料夾"})]}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["每個任務的 worktree 與執行期檔案會建立在 ","<工作站>/<專案名>/"," 底下;留空則預設為 ~/Desktop。"]})]}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"flex items-center justify-between",children:(0,n.jsxs)("span",{className:"text-base font-medium",children:["System Prompt",(0,n.jsx)("span",{className:(0,k.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",eo?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:eo?"未設定":"已自訂"})]})}),(0,n.jsx)("textarea",{name:"system-prompt",autoComplete:"off",value:p,onChange:e=>g(e.target.value),rows:10,spellCheck:!1,className:(0,k.cn)(tR,"resize-y font-mono text-sm leading-5")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟動 Agent 時會以此 prompt 作為 system prompt;留空則只帶入任務專屬的 Artifact 設定。"})]}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-base font-medium",children:"Library"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"VibeFlow 自有的 skill / prompt / script。啟用的項目會在啟動任務時自動投遞給 Claude 與 Codex,不必依賴本機的 ~/.claude 或 ~/.codex 佈局。"})]}),(0,n.jsxs)(eh,{variant:"secondary",size:"sm",onClick:()=>et(!0),children:[(0,n.jsx)(t3.A,{className:"size-3.5"}),"管理 Library"]})]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-base font-medium",children:"CLI 與帳號設定"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"設定 Agent CLI 的 API key 以同步 model;設定 GitHub CLI 以支援本機 GitHub 操作。"})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[sn.map(e=>{let t=i?.[e.id],s=t?.connected&&(t.models?.length??0)>0;return(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[s?(0,n.jsx)(_.A,{className:"size-4 shrink-0 text-success"}):t?.error?(0,n.jsx)(u.A,{className:"size-4 shrink-0 text-destructive"}):(0,n.jsx)("span",{className:"size-4 shrink-0 rounded-full border border-muted-foreground/50"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"text-base font-medium",children:e.name}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:s?`${t?.models?.length??0} 個 models 可用`:t?.error??"尚未連線"})]}),s&&x&&(0,n.jsx)(eh,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",disabled:R===e.id,"aria-label":"重新整理 model 列表",onClick:async()=>{$(e.id),await x(e.id),$(null)},children:(0,n.jsx)(em.A,{className:(0,k.cn)("size-4",R===e.id&&"animate-spin")})}),(0,n.jsx)(eh,{type:"button",size:"sm",variant:"outline",onClick:()=>{w(e),A(""),z(!1),I(null)},children:s?"設定":"Connect"})]},e.id)}),(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[L?.authenticated?(0,n.jsx)(_.A,{className:"size-4 shrink-0 text-success"}):L?.error?(0,n.jsx)(u.A,{className:"size-4 shrink-0 text-destructive"}):(0,n.jsx)("span",{className:"size-4 shrink-0 rounded-full border border-muted-foreground/50"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"text-base font-medium",children:"GitHub CLI"}),(0,n.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:L?.authenticated?`${L.login??"GitHub"} 已授權(${L.gitProtocol??"https"})`:L?.installed===!1?"找不到 GitHub CLI(gh)":L?.error?L.error:"尚未授權"})]}),L?.authenticated&&(0,n.jsx)(eh,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:X,onClick:()=>void ex(),children:"切換使用者"}),L?.authenticated&&(0,n.jsxs)(eh,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:X,onClick:()=>void ep(),children:[X?(0,n.jsx)(D.A,{className:"size-4 animate-spin"}):(0,n.jsx)(t4.A,{className:"size-4"}),"登出"]}),!L?.authenticated&&(0,n.jsx)(eh,{type:"button",size:"sm",variant:"outline",disabled:L?.installed===!1||X,onClick:()=>void ex(),children:X?"啟動中…":"登入"})]})]}),U&&!B&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:U}),ei>0&&(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["目前共有 ",ei," 個已同步 model 可供 task 選擇。"]})]}),c&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:c})]})},"settings-dialog")})}var sa=s(93202),si=s(51256),sl=s(27955),so=s(26814),sc=s(6684),sd=s(76750),su=s(80136);function sm(e){return e.projectName||function(e){if(!e)return"";let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}(e.projectPath)||"Unassigned"}let sx={in_progress:0,backlog:1,done:2};function sf(e){return e.hasSelected||e.tasks.some(e=>"done"!==e.column)}let sh={backlog:"Backlog",in_progress:"In Progress",done:"Done"};function sp({entry:e,selected:t,onSelectTask:s}){let r=(0,c.I)()??!1,a="done"===e.column?null:"in_progress"===e.column?{className:"text-warning",pillClassName:"bg-warning/10 text-warning",icon:(0,n.jsx)("span",{className:"flex size-3 shrink-0 items-center justify-center",children:(0,n.jsx)("span",{className:"size-1.5 rounded-full bg-warning animate-pulse"})})}:{className:"text-muted-foreground",pillClassName:"bg-muted-foreground/10 text-muted-foreground",icon:(0,n.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/60"})};return(0,n.jsxs)(d.PY1.button,{"data-selected-task":t||void 0,type:"button",onClick:()=>s(e.task.id),whileTap:r?void 0:{scale:.99,opacity:.9},transition:{duration:r?0:V.micro,ease:K.enter},className:(0,k.cn)("flex w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-left text-sm transition-colors motion-reduce:transition-none outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",t?"bg-primary/15 font-medium text-primary":"done"===e.column?"text-muted-foreground/60 hover:bg-accent/50 hover:text-muted-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:e.task.title,children:[(0,n.jsx)("span",{className:(0,k.cn)("flex size-3 shrink-0 items-center justify-center",a?.className),children:a?.icon}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.task.title}),a?(0,n.jsx)("span",{className:(0,k.cn)("shrink-0 rounded-full px-1.5 py-0.5 text-xs font-medium",a.pillClassName),children:sh[e.column]}):null]})}function sg({id:e,project:t,selectedTaskId:s,onSelectTask:r}){let a=(0,H.tF)(),i=(0,c.I)()??!1;return(0,n.jsx)(d.PY1.div,{id:e,initial:"hidden",animate:"visible",exit:"exit",variants:X({timing:"standard",exitTiming:"micro",transform:{y:-4},reducedMotion:i}),inert:!a,"aria-hidden":!a||void 0,className:(0,k.cn)("ml-3 space-y-0.5",!a&&"pointer-events-none"),children:0===t.tasks.length?(0,n.jsx)("p",{className:"px-2 py-0.5 text-sm text-muted-foreground/60",children:"尚無任務"}):t.tasks.map(e=>(0,n.jsx)(sp,{entry:e,selected:e.task.id===s,onSelectTask:r},e.task.id))})}function sb({project:e,expanded:t,selectedTaskId:s,onToggle:a,onSelectTask:i,onNewTaskForProject:o,onDeleteProject:c}){let d=(0,r.useId)();return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:(0,k.cn)("group flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground",e.hasSelected&&"text-foreground"),children:[(0,n.jsxs)("button",{type:"button","aria-expanded":t,"aria-controls":d,onClick:a,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",title:e.path??e.name,children:[t?(0,n.jsx)(j.A,{className:"size-3 shrink-0"}):(0,n.jsx)(L.A,{className:"size-3 shrink-0"}),(0,n.jsx)(ed.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.name})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground group-hover:hidden",children:e.tasks.length}),(0,n.jsxs)("div",{className:"hidden shrink-0 items-center gap-0.5 group-hover:flex",children:[(0,n.jsx)(C,{"aria-label":`在 ${e.name} 新增任務`,title:"在此專案新增任務",onClick:()=>o(e.path),className:"p-0.5",children:(0,n.jsx)(N.A,{className:"size-3"})}),(0,n.jsx)(C,{"aria-label":`刪除專案 ${e.name}`,title:"刪除整個專案(含所有任務)",tone:"danger",onClick:()=>c(e.name,e.tasks.map(e=>e.task.id)),className:"p-0.5",children:(0,n.jsx)(x.A,{className:"size-3"})})]})]}),(0,n.jsx)(l.N,{initial:!1,children:t&&(0,n.jsx)(sg,{id:d,project:e,selectedTaskId:s,onSelectTask:i},e.key)})]})}function sj({mode:e,className:t,children:s}){let r=(0,c.I)()??!1;return(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:W({timing:"micro",reducedMotion:r}),className:t,children:s},e)}function sv({collapsed:e,onRemoteShare:t,remoteActive:s,onOpenSettings:r}){return e?(0,n.jsxs)(sj,{mode:"collapsed",className:"flex flex-col items-center gap-1 border-t border-border p-2",children:[t&&(0,n.jsx)(C,{"aria-label":"遠端控制",onClick:t,title:"遠端控制",className:(0,k.cn)("size-8",s&&"text-primary hover:text-primary"),children:(0,n.jsx)(sa.A,{className:"size-4"})}),(0,n.jsx)(C,{"aria-label":"設定 System Prompt",onClick:r,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(si.A,{className:"size-4"})})]}):(0,n.jsx)(sj,{mode:"expanded",className:"border-t border-border p-2",children:(0,n.jsxs)("div",{className:"flex items-center gap-1 px-1",children:[t&&(0,n.jsx)(C,{"aria-label":"遠端控制",onClick:t,title:"遠端控制",className:(0,k.cn)(s?"text-primary hover:text-primary":"text-muted-foreground hover:text-foreground"),children:(0,n.jsx)(sa.A,{className:"size-4"})}),(0,n.jsx)(C,{"aria-label":"設定 System Prompt",onClick:r,title:"設定(System Prompt)",children:(0,n.jsx)(si.A,{className:"size-4"})})]})})}function sN({value:e,onChange:t}){return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(sl.A,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,n.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),onKeyDown:s=>{"Escape"===s.key&&e&&(s.preventDefault(),t(""))},placeholder:"搜尋任務","aria-label":"搜尋任務",className:"h-8 w-full rounded-md border border-border bg-background pl-7 pr-7 text-sm text-foreground outline-none transition-colors motion-reduce:transition-none placeholder:text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50"}),e?(0,n.jsx)("button",{type:"button","aria-label":"清除搜尋",title:"清除搜尋",onClick:()=>t(""),className:"absolute right-1.5 top-1/2 flex size-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)(O.A,{className:"size-3.5"})}):null]})}function sy({collapsed:e,onToggleCollapse:t,board:s,selectedTaskId:a,onSelectTask:i,onNewTask:l,onNewTaskForProject:o,onDeleteProject:u,onRemoteShare:m,remoteActive:x,onOpenSettings:f}){let[h,p]=(0,r.useState)({}),[g,b]=(0,r.useState)(""),j=(0,c.I)()??!1,v=W({timing:"micro",reducedMotion:j}),w=g.trim().toLowerCase(),A=!e&&w.length>0,S=function(e,t){var s;let n=new Map;for(let r of[...e.in_progress.map(e=>({task:e,column:"in_progress"})),...e.backlog.map(e=>({task:e,column:"backlog"})),...e.done.map(e=>({task:e,column:"done"}))]){let e=(s=r.task).projectPath||`name:${sm(s)}`,a=n.get(e)??{key:e,name:sm(r.task),path:r.task.projectPath??null,tasks:[],total:0,hasSelected:!1};a.tasks.push(r),a.total+=1,a.hasSelected||=r.task.id===t,n.set(e,a)}for(let e of n.values())e.tasks=[...e.tasks].sort((e,t)=>{var s,n;let r=sx[e.column]-sx[t.column];return 0!==r?r:(s=e.task,n=t.task,s.createdAt===n.createdAt?0:void 0===s.createdAt?1:void 0===n.createdAt?-1:n.createdAt-s.createdAt)});return Array.from(n.values()).sort((e,t)=>e.name.localeCompare(t.name))}(s,a),z=A?S.map(e=>({...e,tasks:e.tasks.filter(e=>e.task.title.toLowerCase().includes(w))})).filter(e=>e.tasks.length>0):S,E=S.map(e=>e.key).join(" ");(0,r.useEffect)(()=>{p(e=>{let t=!1,s={...e};for(let e of S)e.key in s||(s[e.key]=sf(e),t=!0);return t?s:e})},[E]);let I=e=>A||(h[e.key]??sf(e)),P=z.length>0&&z.every(e=>I(e));return(0,r.useEffect)(()=>{let e=document.querySelector("aside [data-selected-task]");e?.scrollIntoView({block:"nearest"})},[a]),(0,n.jsxs)(d.PY1.aside,{initial:!1,animate:{width:e?48:320},transition:{duration:j?0:V.spatial,ease:K.enter},className:"flex flex-shrink-0 flex-col overflow-x-clip border-r border-border bg-card text-card-foreground",children:[(0,n.jsxs)("div",{className:(0,k.cn)("flex h-12 shrink-0 items-center border-b border-border px-3",e?"justify-center":"justify-between"),children:[!e&&(0,n.jsxs)(d.PY1.span,{initial:"hidden",animate:"visible",variants:v,className:"flex items-center gap-2 text-[15px] font-semibold tracking-tight text-foreground",children:[(0,n.jsx)("img",{src:"/logo.svg",alt:"",className:"size-5"}),"VibeFlow"]}),(0,n.jsx)(C,{"aria-label":e?"展開選單":"收合選單",onClick:t,title:e?"展開選單":"收合選單",className:"group p-1",children:e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("img",{src:"/logo.svg",alt:"",className:"size-5 group-hover:hidden group-focus-visible:hidden"}),(0,n.jsx)(so.A,{className:"hidden size-4 group-hover:block group-focus-visible:block"})]}):(0,n.jsx)(sc.A,{className:"size-4"})})]}),(0,n.jsx)(sj,{mode:e?"collapsed":"expanded",className:(0,k.cn)("shrink-0 px-2 pt-3",e?"flex justify-center":"w-full"),children:e?(0,n.jsx)(C,{"aria-label":"新增任務",onClick:l,title:"新增任務",className:"size-8 p-1.5",children:(0,n.jsx)(N.A,{className:"size-4"})}):(0,n.jsxs)(eh,{size:"sm",className:"w-full rounded-md active:scale-95",onClick:l,children:[(0,n.jsx)(N.A,{}),"新增任務"]})}),!e&&(0,n.jsx)(sj,{mode:"expanded",className:"shrink-0 px-2 pt-2",children:(0,n.jsx)(sN,{value:g,onChange:b})}),(0,n.jsx)("div",{className:(0,k.cn)("flex flex-1 flex-col py-3",e?"overflow-hidden":"overflow-y-auto"),children:(0,n.jsx)("div",{className:"px-2",children:e?null:(0,n.jsxs)(d.PY1.div,{initial:"hidden",animate:"visible",variants:v,children:[(0,n.jsxs)("div",{className:"mb-1 flex items-center gap-1 px-2",children:[(0,n.jsx)("span",{className:y,children:"Projects"}),!A&&z.length>0&&(0,n.jsx)(C,{"aria-label":P?"全部收合":"全部展開",title:P?"全部收合":"全部展開",onClick:()=>{let e=!P;p(t=>{let s={...t};for(let t of z)s[t.key]=e;return s})},className:"ml-auto p-0.5",children:P?(0,n.jsx)(sd.A,{className:"size-3.5"}):(0,n.jsx)(su.A,{className:"size-3.5"})})]}),(0,n.jsx)("div",{className:"space-y-1",children:0===z.length?(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground",children:A?"找不到符合的任務":"尚無任務"}):z.map(e=>{let t=I(e);return(0,n.jsx)(sb,{project:e,expanded:t,selectedTaskId:a,onToggle:()=>p(s=>({...s,[e.key]:!t})),onSelectTask:i,onNewTaskForProject:o,onDeleteProject:u},e.key)})})]},"expanded-projects")})}),(0,n.jsx)(sv,{collapsed:e,onRemoteShare:m,remoteActive:x,onOpenSettings:f})]})}function sk({entries:e,activeTaskId:t,onSelect:s,onPin:r,onClose:a}){return 0===e.length?null:(0,n.jsx)("div",{className:"flex h-9 shrink-0 items-stretch overflow-x-auto overflow-y-hidden border-b border-border bg-card/40",children:e.map(e=>{let i=e.taskId===t;return(0,n.jsxs)("div",{className:(0,k.cn)("group flex h-full min-w-0 max-w-52 shrink-0 items-center gap-1 border-r border-border/60 pl-3 pr-1.5 transition-colors motion-reduce:transition-none",i?"bg-background text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"),children:[(0,n.jsxs)("button",{type:"button","aria-current":i?"page":void 0,title:e.title,onClick:()=>s(e.taskId),onDoubleClick:()=>r(e.taskId),onAuxClick:t=>{1===t.button&&a(e.taskId)},className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm py-0.5 text-left text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:(0,k.cn)("size-1.5 shrink-0 rounded-full","in_progress"===e.column?"bg-warning animate-pulse":"bg-muted-foreground/50")}),(0,n.jsx)("span",{className:(0,k.cn)("min-w-0 truncate",e.preview&&"italic"),children:e.title})]}),(0,n.jsx)("button",{type:"button","aria-label":`關閉分頁 ${e.title}`,title:"關閉分頁(執行中的 agent 會繼續在背景執行)",onClick:()=>a(e.taskId),className:(0,k.cn)("flex size-5 shrink-0 items-center justify-center rounded-sm outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:opacity-100",i?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(O.A,{className:"size-3"})})]},e.taskId)})})}var sw=s(4504);function sC({roomCode:e,peerCount:t,onClose:a,onStop:i}){let l=`https://vibe-flow-remote.vercel.app/?room=${e}`,[o,c]=(0,r.useState)(""),[d,u]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=!0;return s.e(167).then(s.t.bind(s,20167,19)).then(({default:t})=>{t.toDataURL(l,{width:240,margin:2}).then(t=>{e&&c(t)})}),()=>{e=!1}},[l]),(0,n.jsxs)(q,{title:"遠端控制",onClose:a,showHeader:!0,contentClassName:"max-w-xs",children:[(0,n.jsx)("div",{className:"mb-4 flex justify-center",children:o?(0,n.jsx)("img",{src:o,alt:"QR Code",width:200,height:200,className:"rounded-md"}):(0,n.jsx)("div",{className:"flex h-[200px] w-[200px] items-center justify-center rounded-md bg-muted",children:(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"生成中…"})})}),(0,n.jsxs)("div",{className:"mb-3 text-center",children:[(0,n.jsx)("p",{className:"mb-1 text-sm text-muted-foreground",children:"Room Code"}),(0,n.jsx)("p",{className:"font-mono text-3xl font-bold tracking-widest",children:e})]}),(0,n.jsxs)("div",{className:"mb-4 flex items-center justify-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(sw.A,{className:"size-3"}),(0,n.jsx)("span",{children:t>0?`${t} 台裝置已連線`:"等待裝置連線…"})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:function(){navigator.clipboard.writeText(l),u(!0),setTimeout(()=>u(!1),2e3)},className:"flex flex-1 items-center justify-center gap-1.5 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[d?(0,n.jsx)(v.A,{className:"size-3.5"}):(0,n.jsx)(M.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(eh,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function sA(e,t){return{capabilities:{createTask:!1},tasks:["backlog","in_progress","done"].flatMap(t=>e[t].map(e=>({id:e.id,title:e.title,description:e.description,projectName:e.projectName,column:t,launchedAt:e.launchedAt}))),workspaces:[],settings:{autoMode:t}}}let sS={backlog:[],in_progress:[],done:[]},sz=["in_progress","backlog","done"];function sE(){let[e,t]=(0,r.useState)(sS),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)(!0),[m,x]=(0,r.useState)(""),[f,h]=(0,r.useState)(""),[p,g]=(0,r.useState)({}),[b,j]=(0,r.useState)(!1),[v,N]=(0,r.useState)(!1),[y,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)(null),[A,S]=(0,r.useState)(!1),[z,E]=(0,r.useState)(null),[I,P]=(0,r.useState)(null),[T,R]=(0,r.useState)(!1),[$,B]=(0,r.useState)(null),[_,M]=(0,r.useState)(!1),[L,F]=(0,r.useState)(!0),[G,O]=(0,r.useState)(null),[H,Y]=(0,r.useState)([]),[V,K]=(0,r.useState)(null),[U,W]=(0,r.useState)(0),[X,J]=(0,r.useState)(null),[Q,Z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=!0;return ej().then(s=>{e&&(s&&(t(s.board),d(s.settings.autoMode),x(s.settings.systemPrompt??""),h(s.settings.workstationPath??""),g(s.settings.agentConnections??{})),j(!0))}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let t;return e=({taskId:e,subAgents:t})=>{o(s=>({...s,[e]:t}))},(t=eb())?t.onSubAgentsUpdate(e):()=>{}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),d(e.settings.autoMode),x(e.settings.systemPrompt??""),h(e.settings.workstationPath??""),g(e.settings.agentConnections??{})},(s=eb())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{let t=new Set(Object.values(e).flat().map(e=>e.id));Y(e=>e.every(e=>t.has(e.taskId))?e:e.filter(e=>t.has(e.taskId))),O(e=>e&&!t.has(e)?null:e)},[e]);let ee=(e,t)=>{Y(s=>{let n=s.find(t=>t.taskId===e);if(n)return t?.pin&&n.preview?s.map(t=>t.taskId===e?{...t,preview:!1}:t):s;let r={taskId:e,preview:t?.pin!==!0},a=s.findIndex(e=>e.preview);if(r.preview&&-1!==a){let e=[...s];return e[a]=r,e}return[...s,r]}),O(e)},et=e=>{Y(t=>t.some(t=>t.taskId===e&&t.preview)?t.map(t=>t.taskId===e?{...t,preview:!1}:t):t)},es=e=>{let t=new Set(e);if(G&&t.has(G)){let e=H.findIndex(e=>e.taskId===G),s=H.slice(e+1).find(e=>!t.has(e.taskId)),n=H.slice(0,Math.max(e,0)).reverse().find(e=>!t.has(e.taskId));O(s?.taskId??n?.taskId??null)}Y(e=>e.filter(e=>!t.has(e.taskId)))},en=()=>{E(null),K(null),W(e=>e+1),O(null)},er=async(e,t,s)=>{k(!0),C(null);try{await eN({systemPrompt:e,workstationPath:t||void 0,autoMode:s}),x(e),h(t),d(s),N(!1)}catch(e){C(e instanceof Error?e.message:String(e))}finally{k(!1)}},ea=async(e,t)=>{k(!0),C(null);try{let s=await ey(e,t);return s&&g(s.settings.agentConnections??{}),null}catch(t){let e=t instanceof Error?t.message:String(t);return C(e),e}finally{k(!1)}},ei=async e=>{let t=await ek(e);t&&g(t.settings.agentConnections??{})},el=async(e,s,n,r,a,i,l,o,c,d)=>{S(!0),E(null);try{let u=await e$({title:e,description:s,projectPath:n,baseBranch:r,branch:a||void 0,agentCli:i,model:l||void 0,effort:o,autoMode:c,attachments:d});u&&(t(u.state.board),ee(u.task.id,{pin:!0}))}catch(e){E(e instanceof Error?e.message:String(e))}finally{S(!1)}},eo=async e=>{if(I){R(!0),B(null);try{let s=await eB({taskId:I.id,title:e.title,description:e.description,agentCli:e.agentCli,model:e.model||void 0,effort:e.effort,autoMode:e.autoMode,projectPath:e.projectPath,baseBranch:e.baseBranch});s&&t(s.board),P(null)}catch(e){B(e instanceof Error?e.message:String(e))}finally{R(!1)}}},ec=async e=>{let s=await eZ(e);s&&t(s.board)},ed=async e=>{let s=await e0(e);s&&(t(s.board),es([e]))},eu=async()=>{if(X){Z(!0);try{let e=null;for(let t of X.taskIds){let s=await e0(t);s&&(e=s.board)}e&&t(e),es(X.taskIds),J(null)}finally{Z(!1)}}},em=H.flatMap(t=>{for(let s of sz){let n=e[s].find(e=>e.id===t.taskId);if(n)return[{...t,title:n.title,column:s}]}return[]}),ex=function({board:e,autoMode:t,onStateChange:n}){let[a,i]=(0,r.useState)(null),[l,o]=(0,r.useState)(0),c=(0,r.useRef)(new Set),d=(0,r.useRef)(new Map),u=(0,r.useRef)(e),m=(0,r.useRef)(t),x=(0,r.useRef)(n);async function f(e,t){if(!e||"object"!=typeof e)return;let{type:s,payload:n}=e;switch(s){case"client:get-state":try{t.send({type:"vf:state",payload:sA(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;e2(e,String(t).slice(0,1e3));break}case"client:subscribe-terminal":{let{taskId:e}=n??{};if(!e)break;let s=d.current.get(e);s||(s=new Set,d.current.set(e,s)),s.add(t);break}case"client:unsubscribe-terminal":{let{taskId:e}=n??{};e&&d.current.get(e)?.delete(t);break}case"client:move-task":{let{taskId:e,targetColumn:t}=n??{};if(!e||!t)break;let s=function(e,t,s){let n,r={...e};for(let e of["backlog","in_progress","done"]){let s=r[e].findIndex(e=>e.id===t);if(-1!==s){n=r[e][s],r[e]=r[e].filter(e=>e.id!==t);break}}return n?(r[s]=[n,...r[s]],r):e}(u.current,e,t);x.current(s),await ev(s)}}}return(0,r.useEffect)(()=>{u.current=e},[e]),(0,r.useEffect)(()=>{m.current=t},[t]),(0,r.useEffect)(()=>{x.current=n},[n]),(0,r.useEffect)(()=>{if(!c.current.size)return;let s=sA(e,t);for(let e of c.current)try{e.send({type:"vf:state",payload:s})}catch{}},[e,t]),(0,r.useEffect)(()=>{let e;if(!a)return;let t=!1;return async function(){let{Peer:n}=await s.e(1886).then(s.bind(s,11886));t||((e=new n(`vibeflow-${a}`)).on("connection",e=>{c.current.add(e),o(e=>e+1),e.on("open",()=>{(async()=>{try{e.send({type:"vf:hello",payload:{version:"1.0"}}),e.send({type:"vf:state",payload:sA(u.current,m.current)})}catch{}})()}),e.on("data",t=>{f(t,e)}),e.on("close",()=>{for(let[,t]of(c.current.delete(e),o(e=>e-1),d.current))t.delete(e)})}),e.on("error",e=>{console.error("[VibeFlow Remote] PeerJS error:",e)}))}(),()=>{for(let e of(t=!0,c.current))try{e.close()}catch{}c.current.clear(),d.current.clear(),o(0),e?.destroy()}},[a]),(0,r.useEffect)(()=>{if(a){var e;let t;return e=({sessionKey:e,data:t})=>{let s=e.split(":")[0],n=d.current.get(s);if(!n?.size)return;let r={type:"vf:terminal-chunk",payload:{taskId:s,data:t}};for(let e of n)try{e.send(r)}catch{}},(t=eb())?t.term.onData(e):()=>{}}},[a]),{roomCode:a,peerCount:l,startSharing:()=>{i(String(Math.floor(1e5+9e5*Math.random())))},stopSharing:()=>i(null)}}({board:e,autoMode:c,onStateChange:e=>{t(e),ev(e)}});return(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(i(),{children:(0,n.jsx)("title",{children:"VibeFlow"})}),(0,n.jsx)("div",{className:"bg-background text-foreground",children:b?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(sy,{collapsed:L,onToggleCollapse:()=>F(e=>!e),board:e,selectedTaskId:G,onSelectTask:ee,onNewTask:en,onNewTaskForProject:e=>{E(null),K(e),W(e=>e+1),O(null)},onDeleteProject:(e,t)=>{0!==t.length&&J({name:e,taskIds:t})},remoteActive:!!ex.roomCode,onOpenSettings:()=>{C(null),N(!0)}}),(0,n.jsx)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:(0,n.jsx)("div",{className:"min-h-0 flex-1",children:(0,n.jsx)(tJ,{tabBar:(0,n.jsx)(sk,{entries:em,activeTaskId:G,onSelect:ee,onPin:et,onClose:e=>es([e])}),onSelectTask:ee,onNewTask:en,board:e,onBoardChange:e=>{t(e),ev(e)},onEditTask:t=>{B(null),P(function(e,t){for(let s of Object.values(e)){let e=s.find(e=>e.id===t);if(e)return e}return null}(e,t))},onTaskDone:ec,onDeleteTask:ed,autoMode:c,workstationPath:f,subAgents:a,selectedTaskId:G,onTaskInteract:et,openTabIds:H.map(e=>e.taskId),initialProjectPath:V,newTaskNonce:U,creating:A,createError:z,pickFolder:eE,loadRecentProjects:eP,loadGitInfo:eI,initRepository:eT,detectAgents:eR,agentConnections:p,onCreateTask:el})})})]}),(0,n.jsx)(tZ,{task:I,defaultAutoMode:c,detectAgents:eR,agentConnections:p,pickFolder:eE,loadRecentProjects:eP,loadGitInfo:eI,saving:T,error:$,onSubmit:eo,onClose:()=>P(null)}),(0,n.jsx)(sr,{open:v,systemPrompt:m,workstationPath:f,autoMode:c,agentConnections:p,saving:y,error:w,onSave:er,onConnectAgent:ea,onRefreshModels:ei,onPickFolder:eE,onClose:()=>N(!1)}),(0,n.jsx)(l.N,{children:A&&(0,n.jsx)(q,{title:"建立任務中",saving:!0,onClose:()=>{},contentClassName:"max-w-sm rounded-lg p-5",children:(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary/15 text-primary",children:(0,n.jsx)(D.A,{className:"size-5 animate-spin"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"正在建立 workspace"}),(0,n.jsx)("p",{className:"text-base leading-6 text-muted-foreground",children:"正在建立 git worktree、分支與任務資料。完成前請先不要切換或操作其他任務。"})]})]})})},"creating-task-dialog")}),(0,n.jsx)(l.N,{children:X&&(0,n.jsx)(q,{title:"刪除專案",saving:Q,onClose:()=>{Q||J(null)},contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["刪除專案「",X.name,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除此專案底下的 ",X.taskIds.length," ","個任務,包含它們的 worktree、branch 與對話紀錄。此操作無法復原。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eh,{variant:"ghost",size:"sm",className:"rounded-full",disabled:Q,onClick:()=>J(null),children:"取消"}),(0,n.jsx)(eh,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",disabled:Q,onClick:eu,children:Q?"刪除中…":"刪除專案"})]})]})},"delete-project-dialog")}),(0,n.jsx)(l.N,{children:_&&ex.roomCode&&(0,n.jsx)(sC,{roomCode:ex.roomCode,peerCount:ex.peerCount,onClose:()=>M(!1),onStop:()=>{ex.stopSharing(),M(!1)}},"remote-share-dialog")})]}):(0,n.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground",children:"載入中…"})})]})}},24464:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/home",function(){return s(2908)}])}},e=>{e.O(0,[5896,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);