@kw-yeh/vibeflow 4.7.1 → 4.8.0

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/d25415d1bec170b4.css" as="style"/><link rel="stylesheet" href="/_next/static/css/d25415d1bec170b4.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-496c474d7f14dd07.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/rD1tZjqo_1oM7qAU7uvic/_buildManifest.js" defer=""></script><script src="/_next/static/rD1tZjqo_1oM7qAU7uvic/_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":"rD1tZjqo_1oM7qAU7uvic","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/0e63f58e447f85ed.css" as="style"/><link rel="stylesheet" href="/_next/static/css/0e63f58e447f85ed.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-496c474d7f14dd07.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/MCpYTSYna3Ll-2lXwbETR/_buildManifest.js" defer=""></script><script src="/_next/static/MCpYTSYna3Ll-2lXwbETR/_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":"MCpYTSYna3Ll-2lXwbETR","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/d25415d1bec170b4.css" as="style"/><link rel="stylesheet" href="/_next/static/css/d25415d1bec170b4.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-496c474d7f14dd07.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/rD1tZjqo_1oM7qAU7uvic/_buildManifest.js" defer=""></script><script src="/_next/static/rD1tZjqo_1oM7qAU7uvic/_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":"rD1tZjqo_1oM7qAU7uvic","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/0e63f58e447f85ed.css" as="style"/><link rel="stylesheet" href="/_next/static/css/0e63f58e447f85ed.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-496c474d7f14dd07.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/MCpYTSYna3Ll-2lXwbETR/_buildManifest.js" defer=""></script><script src="/_next/static/MCpYTSYna3Ll-2lXwbETR/_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":"MCpYTSYna3Ll-2lXwbETR","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -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/7451-e9f74fece50504ed.js","static/chunks/pages/home-78adf6369b572108.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/7451-e9f74fece50504ed.js","static/chunks/pages/home-ead2bccf81dc3d85.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1,12 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9845],{14549:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>nh});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(78617),h=s(42533),p=s(54903),g=s(58629),b=s(17329),j=s(70170),v=s(87854),N=s(78999),y=s(85781),k=s(38031),w=s(74567);let C="text-xs font-semibold uppercase tracking-wider text-muted-foreground";var S=s(4416);let A={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"},z=r.forwardRef(({className:e,children:t,tone:s="default",type:r="button",...a},i)=>(0,n.jsx)("button",{ref:i,type:r,className:(0,S.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",A[s],e),...a,children:t}));z.displayName="IconButton";let E=[{id:"board",label:"看板"},{id:"github",label:"Issues & PRs"}];function P({value:e,onChange:t}){return(0,n.jsx)("div",{role:"tablist","aria-label":"檢視",className:"flex h-full items-stretch gap-4",children:E.map(s=>{let r=s.id===e;return(0,n.jsx)("button",{type:"button",role:"tab","aria-selected":r,onClick:()=>t(s.id),className:(0,S.cn)("-mb-px flex items-center border-b-2 px-1 text-sm font-medium outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",r?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:s.label},s.id)})})}function I(){return window.vibeflow??null}async function $(){let e=I();return e?e.getState():null}async function R(e){let t=I();t&&await t.setBoard(e)}async function T(e){let t=I();return t?t.setSettings(e):null}async function D(){let e=I();return e?e.getGithubAuthStatus():null}async function _(e){let t=I();return t?t.getGithubInbox(e):null}async function B(e){let t=I();return t?t.getGithubTaskLinks(e):{}}async function M(){let e=I();e&&await e.startGithubAuthLogin()}async function L(){let e=I();e&&await e.cancelGithubAuthLogin()}async function F(){let e=I();return e?e.logoutGithubAuth():null}function G(e){return window.prompt(e)?.trim()||null}async function O(e="選擇資料夾"){let t=I();if(!t)return null;try{let s=await t.pickFolder({title:e});if("path"in s)return s.path;if("canceled"in s)return null}catch{}return G("輸入資料夾的絕對路徑")}async function H(e){let t=I();return t?t.getGitInfo(e):null}async function V(){let e=I();return e?e.listRecentProjects():[]}async function Y(e){let t=I();return t?t.initRepository(e):null}async function U(){let e=I();return e?e.detectAgents():[]}async function K(e,t=!1){let s=I();return s?s.listAgentModels(e,t):null}async function W(e){let t=I();return t?t.createTask(e):null}async function X(e){let t=I();return t?t.updateTask(e):null}async function q(e){let t=I();return t?t.resetTaskRun(e):null}async function Q(e){let t=I();return t?t.getDiff(e):[]}async function J(e,t){let s=I();return s?s.getDiffEntries(e,t):[]}async function Z(e,t){let s=I();return s?s.getDiffFile(e,t):null}async function ee(e){let t=I();return t?t.listArtifacts(e):[]}async function et(e,t){let s=I();return s?s.readArtifact(e,t):null}async function es(e){let t=I();return t?t.openArtifactsDir(e):"bridge unavailable"}async function en(e){let t=I();return t?t.getSpecs(e):[]}async function er(e){return I()?G("skill"===e?"輸入 skill 目錄的絕對路徑(需含 SKILL.md)":`輸入 ${e} 檔案的絕對路徑`):null}async function ea(){let e=I();return e?e.listLibrary():[]}async function ei(e,t){let s=I();return s?s.importLibraryEntry({kind:e,sourcePath:t}):null}async function el(e,t,s,n){let r=I();return r?r.createLibraryEntry({kind:e,name:t,content:s,description:n}):null}async function eo(e,t){let s=I();return s?s.readLibraryEntry({kind:e,name:t}):null}async function ec(e,t,s){let n=I();return n?n.updateLibraryEntry({kind:e,name:t,content:s}):null}async function ed(e,t,s){let n=I();return!!n&&n.setLibraryEntryEnabled({kind:e,name:t,enabled:s})}async function eu(e,t){let s=I();return!!s&&s.deleteLibraryEntry({kind:e,name:t})}async function em(e){let t=I();return t?t.restoreBuiltinSkill({name:e}):null}async function ex(){let e=I();return e?e.listRemovedBuiltinSkills():[]}async function ef(e){let t=I();t&&await t.openExternal(e)}async function eh(e){let t=I();if(!t)return null;try{return await t.getProgress(e)}catch{return null}}async function ep(e){let t=I();return t?t.cleanupTask(e):null}async function eg(e){let t=I();return t?t.deleteTask(e):null}async function eb(e){let t=I();return t?t.attachments.write(e):[]}async function ej(e){let t=I();return t?t.term.start(e):null}function ev(e,t){I()?.term.input(e,t)}async function eN(e){await I()?.term.scrollToBottom(e)}async function ey(e){let t=I();return!!t&&t.term.sessionExists(e)}let ek={open:"text-success",draft:"text-muted-foreground",merged:"text-primary",closed:"text-destructive"},ew={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},eC={APPROVED:"已核准",CHANGES_REQUESTED:"要求修改",REVIEW_REQUIRED:"待 review"};function eS(e){return`${e.repo}#${e.number}`}function eA(e,t=Date.now()){let s=Date.parse(e);if(Number.isNaN(s))return"";let n=Math.max(0,Math.floor((t-s)/6e4));if(n<1)return"剛剛";if(n<60)return`${n} 分鐘前`;let r=Math.floor(n/60);if(r<24)return`${r} 小時前`;let a=Math.floor(r/24);return a<7?`${a} 天前`:a<30?`${Math.floor(a/7)} 週前`:a<365?`${Math.floor(a/30)} 個月前`:`${Math.floor(a/365)} 年前`}function ez(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let s=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())} ${s(t.getHours())}:${s(t.getMinutes())}`}var eE=s(14940),eP=s(99088),eI=s(26392),e$=s(379),eR=s(78141);function eT(e){return e.input+e.output+e.cacheRead+e.cacheWrite}function eD(e){return e&&0!==e.length?{done:e.filter(e=>"completed"===e.status).length,total:e.length}:null}function e_({done:e,total:t,className:s}){return(0,n.jsx)("span",{role:"progressbar","aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":e,"aria-label":`完成 ${e}/${t} 個步驟`,className:(0,S.cn)("relative block h-1 overflow-hidden rounded-full bg-border",s),children:(0,n.jsx)("span",{className:"absolute inset-y-0 left-0 rounded-full bg-primary transition-[width] motion-reduce:transition-none",style:{width:`${e/t*100}%`}})})}function eB({progress:e,usage:t}){let s=e?.totalUsage??t;if(!e&&!s)return null;let r=eD(e?.todos??null),a=e?.activity.state==="waiting",i=s?eT(s):0;return(0,n.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground",children:[r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"shrink-0 tabular-nums",children:[r.done,"/",r.total]}),(0,n.jsx)(e_,{done:r.done,total:r.total,className:"min-w-8 flex-1"})]}),!r&&(0,n.jsx)("span",{className:"flex-1"}),a&&(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:[e?.activity.waitingFor==="permission"?(0,n.jsx)(eE.A,{className:"size-2.5"}):(0,n.jsx)(eP.A,{className:"size-2.5"}),e?.activity.waitingFor==="permission"?"等待權限":"等待輸入"]}),i>0&&(0,n.jsxs)("span",{className:"shrink-0 tabular-nums",title:`${i.toLocaleString()} tokens`,children:[i<1e3?String(i):i<1e6?`${(i/1e3).toFixed(+(i<1e4))}k`:`${(i/1e6).toFixed(2)}M`," tok"]})]})}function eM({status:e}){return"completed"===e?(0,n.jsx)(eI.A,{className:"mt-0.5 size-3.5 shrink-0 text-primary"}):"in_progress"===e?(0,n.jsx)(f.A,{className:"mt-0.5 size-3.5 shrink-0 text-foreground"}):(0,n.jsx)(e$.A,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground/60"})}function eL({usage:e,contextTokens:t}){let s=[["輸入",e.input],["輸出",e.output],["快取讀取",e.cacheRead],["快取寫入",e.cacheWrite]];return(0,n.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm",children:[s.map(([e,t])=>(0,n.jsxs)("div",{className:"contents",children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:e}),(0,n.jsx)("dd",{className:"text-right tabular-nums",children:t.toLocaleString()})]},e)),e.reasoning>0&&(0,n.jsxs)("div",{className:"contents",children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:" 其中推理"}),(0,n.jsx)("dd",{className:"text-right tabular-nums text-muted-foreground",children:e.reasoning.toLocaleString()})]}),(0,n.jsxs)("div",{className:"contents font-medium",children:[(0,n.jsx)("dt",{children:"合計"}),(0,n.jsx)("dd",{className:"text-right tabular-nums",children:eT(e).toLocaleString()})]}),null!=t&&t>0&&(0,n.jsxs)("div",{className:"contents",children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:"目前 context"}),(0,n.jsx)("dd",{className:"text-right tabular-nums text-muted-foreground",children:t.toLocaleString()})]})]})}function eF({progress:e,usage:t}){var s;let r=e?.totalUsage??t;if(!e&&!r)return null;let a=eD(e?.todos??null),i=e?"waiting"===(s=e.activity).state?"permission"===s.waitingFor?"等待權限":"等待輸入":"working"===s.state?s.tool?`執行中:${s.tool}`:"執行中":null:null,l=e?function(e){if(!e)return null;let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t} 秒前`:t<3600?`${Math.floor(t/60)} 分鐘前`:`${Math.floor(t/3600)} 小時前`}(e.activity.at):null,o=e&&eT(e.totalUsage)>eT(e.runUsage);return(0,n.jsxs)("section",{className:"space-y-3 rounded-md border border-border/70 p-3","aria-label":"任務進度",children:[e&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:C,children:"進度"}),a&&(0,n.jsxs)("span",{className:"text-xs tabular-nums text-muted-foreground",children:[a.done,"/",a.total]}),(0,n.jsx)("span",{className:"flex-1"}),i&&(0,n.jsxs)("span",{className:(0,S.cn)("flex items-center gap-1 text-xs","waiting"===e.activity.state?"text-primary":"text-muted-foreground"),children:["working"===e.activity.state&&(0,n.jsx)(eR.A,{className:"size-3 animate-spin motion-reduce:animate-none"}),i,l&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:["\xb7 ",l]})]})]}),a&&(0,n.jsx)(e_,{done:a.done,total:a.total}),e.todos&&e.todos.length>0?(0,n.jsx)("ul",{className:"space-y-1 text-sm",children:e.todos.map((e,t)=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)(eM,{status:e.status}),(0,n.jsx)("span",{className:(0,S.cn)("min-w-0 break-words","completed"===e.status&&"text-muted-foreground line-through","in_progress"===e.status&&"font-medium"),children:"in_progress"===e.status&&e.activeForm?e.activeForm:e.content})]},e.id??`${t}:${e.content}`))}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Agent 尚未建立待辦清單。"})]}),r&&eT(r)>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("span",{className:C,children:["Token 使用量",o?"(含先前執行)":""]}),(0,n.jsx)(eL,{usage:r,contextTokens:e?.contextTokens})]})]})}let eG=["backlog","in_progress","done"],eO={backlog:"Backlog",in_progress:"In Progress",done:"Done"},eH={backlog:"bg-muted-foreground/60",in_progress:"bg-warning animate-pulse",done:"bg-success"};function eV(e){if(e.projectName)return e.projectName;let t=(e.projectPath??"").split(/[/\\]/).filter(Boolean);return t[t.length-1]??"未指定專案"}function eY(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 eU="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 eK({task:e,anchor:t,onEdit:s,onDelete:a,onClose:i}){let[l,o]=(0,r.useState)(!1),c=eY(!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:[s&&(0,n.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{s(),i()},className:(0,S.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",eU,"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,S.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",eU,"text-destructive hover:bg-destructive/15"),title:`刪除任務「${e.title}」(清理 worktree)`,children:[(0,n.jsx)(x.A,{className:"size-3.5 shrink-0"}),"刪除任務"]})]})}function eW({link:e}){let t="issue"===e.kind?f.A:"draft"===e.state?h.A:p.A,s="issue"===e.kind?"Issue":"PR";return(0,n.jsxs)("button",{type:"button",title:`${s} #${e.number} \xb7 ${ew[e.state]}(在 GitHub 開啟)`,"aria-label":`在 GitHub 開啟 ${s} #${e.number}`,onClick:t=>{t.stopPropagation(),ef(e.url)},className:(0,S.cn)("flex shrink-0 items-center gap-0.5 rounded-xs outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50",ek[e.state]),children:[(0,n.jsx)(t,{className:"size-3"}),"#",e.number]})}function eX({task:e,column:t,subAgentCount:s,progress:a,links:i,selected:l,onSelect:o,onEdit:c,onDelete:d}){let u=(0,r.useRef)(null),[m,x]=(0,r.useState)(null),f=null!==m,h="in_progress"===t,p="done"===t;return(0,n.jsxs)("div",{ref:u,role:"button",tabIndex:0,"aria-label":`開啟任務:${e.title}`,onClick:o,onKeyDown:e=>{e.target!==e.currentTarget||("Enter"===e.key||" "===e.key)&&(e.preventDefault(),o())},className:(0,S.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",p&&"bg-card/60",l?"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)(g.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:eV(e)}),p?(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)(b.A,{className:"size-2.5"}),"complete"]}):(0,n.jsxs)(n.Fragment,{children:[e.effort&&(0,n.jsx)("span",{className:(0,S.cn)("shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 font-medium",f?"hidden":"group-hover/head:hidden"),children:e.effort}),(0,n.jsx)(z,{"aria-label":`任務選項:${e.title}`,title:"移動、編輯或刪除",onClick:e=>{if(e.stopPropagation(),f)return void x(null);let t=u.current?.getBoundingClientRect();t&&x({top:t.top+32,right:t.right-4})},className:(0,S.cn)("size-5 p-0.5",f?"flex":"hidden group-hover/head:flex"),children:(0,n.jsx)(j.A,{className:"size-3.5"})})]})]}),(0,n.jsx)("div",{className:"mt-2",title:e.title,children:(0,n.jsx)("span",{className:(0,S.cn)("line-clamp-2 text-[15px] font-medium leading-[1.4]",p?"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)(v.A,{className:"size-3 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 truncate",title:"backlog"!==t||e.worktreePath?void 0:"分支會在開始執行時建立",children:[e.branch,"backlog"===t&&!e.worktreePath&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:"(開始時建立)"})]}),h&&s>0&&(0,n.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,n.jsx)(N.A,{className:"size-3"}),s]}),i?.issue&&(0,n.jsx)(eW,{link:i.issue}),i?.pr&&(0,n.jsx)(eW,{link:i.pr})]}),(h||p)&&(0,n.jsx)(eB,{progress:a,usage:e.usage}),"backlog"===t&&e.launchError&&(0,n.jsxs)("p",{className:"mt-1.5 truncate text-xs text-destructive",title:e.launchError,children:["開始失敗:",e.launchError]}),m&&(0,n.jsx)(eK,{task:e,anchor:m,onEdit:c,onDelete:d,onClose:()=>x(null)})]})}function eq({projects:e,value:t,onChange:s}){let[a,i]=(0,r.useState)(!1),l=eY(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)(g.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),t??"所有專案",(0,n.jsx)(y.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,S.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",eU,"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)(k.A,{className:"size-3 shrink-0"})]},e??"__all__"))})]})}function eQ({board:e,subAgents:t,progress:s,view:a,onViewChange:i,taskLinks:l,selectedTaskId:o,onSelectTask:c,onEditTask:d,onDeleteTask:u,onNewTask:m}){let[x,f]=(0,r.useState)(null),h=[...e.backlog,...e.in_progress,...e.done],p=Array.from(new Set(h.map(eV))).sort((e,t)=>e.localeCompare(t)),g=x&&p.includes(x)?x:null,b=h.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)(P,{value:a,onChange:i}),(0,n.jsx)("span",{className:"h-4 w-px bg-border"}),(0,n.jsx)(eq,{projects:p,value:g,onChange:f}),(0,n.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[b," 個任務 \xb7 ",p.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:eG.map(r=>{let a=g?e[r].filter(e=>eV(e)===g):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,S.cn)("size-1.5 shrink-0 rounded-full",eH[r])}),(0,n.jsx)("h2",{className:(0,S.cn)(C,"in_progress"===r&&"text-warning"),children:eO[r]}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:a.length})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto rounded-md p-1",children:[a.map(e=>(0,n.jsx)(eX,{task:e,column:r,subAgentCount:(t[e.id]??[]).length,progress:"in_progress"===r?s[e.id]??null:null,links:l[e.id],selected:e.id===o,onSelect:()=>c(e.id),onEdit:"backlog"===r?()=>d(e.id):void 0,onDelete:()=>u(e.id)},e.id)),"backlog"===r&&(0,n.jsxs)("button",{type:"button",onClick:m,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)(w.A,{className:"size-3.5"}),"新增任務"]}),0===a.length&&"backlog"!==r&&(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/60",children:"尚無任務"})]})]},r)})})]})}var eJ=s(85320),eZ=s(37055);let e0=(0,r.lazy)(()=>Promise.all([s.e(7045),s.e(7915)]).then(s.bind(s,37915)));function e1({source:e,compact:t=!1,className:s}){return(0,n.jsx)("div",{className:(0,S.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)(e0,{source:e,compact:t})})})}var e5=s(72975),e2=s(41487);let e3=0,e4={micro:.12,standard:.16,spatial:.18},e6={enter:[.2,0,0,1],exit:[.4,0,1,1]};function e7(e,t,s,n=e4[e]){return{duration:t?.01:n,ease:e6[s]}}function e8({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:e7(e,r,"enter",t)}}}function e9({timing:e,enterDuration:t,initialOpacity:s,exitTiming:n="micro",exitDuration:r,transform:a,exitTransform:i=a,reducedMotion:l}){return{...e8({timing:e,enterDuration:t,initialOpacity:s,transform:a,reducedMotion:l}),exit:{opacity:0,...l?{}:i??{},transition:e7(n,l,"exit",r)}}}function te({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,e2.tF)(),y=(0,c.I)()??!1,k=i||void 0!==s||void 0!==a||void 0!==u,w="drawer"===x,C=e9({timing:"micro",enterDuration:.14,reducedMotion:y}),A=e9({timing:w?"spatial":"standard",exitTiming:"micro",exitDuration:w?.14:void 0,transform:w?{x:16}:{scale:.98},reducedMotion:y});return(0,r.useEffect)(()=>{j.current=f,v.current=m},[f,m]),(0,r.useEffect)(()=>{let e;return e3+=1,e=!1,()=>{e||(e=!0,e3-=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,S.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:C,className:"absolute inset-0 bg-background/80",onClick:m||!N?void 0:f}),(0,n.jsx)(d.PY1.div,{variants:A,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,S.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",k&&"flex max-h-[min(90vh,760px)] flex-col overflow-hidden",o),children:k?(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)(z,{"aria-label":`關閉${e}`,onClick:f,disabled:m,className:"mt-0.5 shrink-0 p-1",children:(0,n.jsx)(e5.A,{className:"size-4"})})]}),!i&&(0,n.jsx)("h2",{id:h,className:"sr-only",children:e}),(0,n.jsx)("div",{className:(0,S.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 tt={running:{label:"執行中",icon:eR.A,tone:"text-warning",spin:!0},completed:{label:"已完成",icon:eI.A,tone:"text-primary"},error:{label:"失敗",icon:u.A,tone:"text-destructive"}};function ts({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)(eJ.A,{className:"size-3"}),t?"已複製":"複製"]})}function tn({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)(y.A,{className:"size-3"}):(0,n.jsx)(eZ.A,{className:"size-3"}),e]}),i&&(0,n.jsx)(ts,{text:t})]}),i&&(a?(0,n.jsx)("div",{id:o,className:"border-t border-border/40",children:(0,n.jsx)(e1,{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 tr({run:e,index:t}){let s=tt[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,S.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,S.cn)("shrink-0 text-xs font-medium",s.tone),children:s.label})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(tn,{label:"Prompt",text:e.prompt,defaultOpen:a}),"running"!==e.status&&null!=e.result&&(0,n.jsx)(tn,{label:"結果",text:e.result,markdown:!0})]})]})}function ta({open:e,taskId:t,taskTitle:s,runs:r,onClose:a}){return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(te,{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)(tr,{run:e,index:t},e.id))})},`sub-agent-drawer-${t}`)})}var ti=s(19897),tl=s(72752),to=s(55985),tc=s(98201),td=s(55713),tu=s(41336),tm=s(50405),tx=s(6510),tf=s(1445),th=s(37763),tp=s(15344);let tg=(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"}}),tb=r.forwardRef(({className:e,variant:t,size:s,...r},a)=>(0,n.jsx)("button",{ref:a,className:(0,S.cn)(tg({variant:t,size:s,className:e})),...r}));function tj(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 tv(e){return Promise.all(Array.from(e).map(tj))}tb.displayName="Button";var tN=s(9036),ty=s(7640),tk=s(62607);function tw(e,t){t&&e.writeln(`⏳ ${t}`)}function tC(e,t){let s=t instanceof Error?t.message:String(t);e.writeln(`\r
2
+ ⚠️ 無法開始執行:${s}`)}function tS({taskId:e,sessionKey:t,cwd:a,launchCommand:i,launchNonce:l=0,provisionNotice:o=null,readOnly:c=!1,onReturnToBacklog:d,onLaunchAgent:u,onInteract:m}){let x=t??e,f=(0,r.useRef)(null),h=(0,r.useRef)(null),p=(0,r.useRef)(0),[g,b]=(0,r.useState)(!1),[j,v]=(0,r.useState)(!1),[N,y]=(0,r.useState)(!1),[k,w]=(0,r.useState)(!1),[C,A]=(0,r.useState)(!1),[z,E]=(0,r.useState)(!1),P=(0,r.useRef)(!1),$=(0,r.useRef)(-1),R=(0,r.useRef)(!1),T=(0,r.useRef)(i),D=(0,r.useRef)(l);T.current=i,D.current=l;let _=(0,r.useRef)(a);_.current=a;let B=(0,r.useRef)(c),M=(0,r.useRef)(o);M.current=o;let L=(0,r.useRef)(m);L.current=m;let F=(0,r.useCallback)(t=>{let s=_.current,n=h.current;s&&(P.current=!1,R.current=!0,n&&tw(n,M.current),ej({taskId:e,sessionKey:x,launch:t,cols:n?.cols,rows:n?.rows}).then(()=>{P.current=!0,h.current?.focus()}).catch(e=>{R.current=!1,h.current&&tC(h.current,e)}))},[e,x]),G=(0,r.useCallback)(()=>{let t=_.current,s=h.current;t&&s&&null!==I()&&!B.current&&(P.current=!1,R.current=!1,ej({taskId:e,sessionKey:x,cols:s.cols,rows:s.rows}).then(()=>{P.current=!0,s.focus()}))},[e,x]),O=(0,r.useCallback)(async()=>{let e=h.current;if(e&&d&&!B.current){L.current?.(),y(!0);try{if(!await d())return;e.reset(),e.clear(),G(),e.focus()}catch(s){let t=s instanceof Error?s.message:String(s);e.writeln(`\r
3
+ ⚠️ 退回 Backlog 失敗:${t}`)}finally{y(!1)}}},[d,G]),H=(0,r.useCallback)(async()=>{let e=h.current;if(e&&u&&!B.current){L.current?.(),w(!0),e.reset(),e.clear();try{await u(),e.focus()}catch(s){let t=s instanceof Error?s.message:String(s);e.writeln(`\r
4
+ ⚠️ 啟動 Agent 失敗:${t}`)}finally{w(!1)}}},[u]),V=(0,r.useCallback)(()=>{if(!P.current||B.current)return;let e=T.current;if(!e)return;let t=D.current;$.current!==t&&($.current=t,F(e))},[F]);(0,r.useEffect)(()=>{B.current=c,h.current&&(h.current.options.disableStdin=c)},[c]),(0,r.useEffect)(()=>{let t,n,r,a,i,l,o=!1;return P.current=!1,(async()=>{let c,{Terminal:d}=await s.e(3779).then(s.bind(s,15167)),{FitAddon:u}=await s.e(5695).then(s.bind(s,95695));if(o||!f.current)return;let m=new d({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"}}),p=new u;m.loadAddon(p),m.open(f.current);let g=()=>{p.fit();let e=m.element?.querySelector(".xterm-screen"),t=m.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)}(m.cols,e.getBoundingClientRect().width,t.clientWidth);s!==m.cols&&m.resize(s,m.rows)};if(h.current=m,await document.fonts.ready,await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o||h.current!==m)return;g();let b=window.vibeflow;if(!b)return m.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");if(B.current)return m.writeln("ℹ️ 任務已完成 — 終端為唯讀,僅供查閱訊息。");if(!_.current)return m.writeln("⚠️ 尚未設定工作目錄,請先選擇專案或建立任務。");let j=B.current?null:T.current;j&&($.current=D.current),R.current=!!j,j&&tw(m,M.current);try{c=await b.term.start({taskId:e,sessionKey:x,launch:j??void 0,cols:m.cols,rows:m.rows})}catch(e){R.current=!1,tC(m,e);return}let{scrollback:v}=c;v&&m.write(v),t=b.term.onData(({sessionKey:e,data:t})=>{e===x&&m.write(t)}),n=b.term.onExit(({sessionKey:e,exitCode:t,intentional:s})=>{if(e!==x||s)return;let n=R.current;if(R.current=!1,!n){P.current=!1,m.writeln(`\r
5
+ ℹ️ 終端已結束(exit code: ${t})`);return}0===t?m.writeln("\r\n✅ Agent 執行完成。"):m.writeln(`\r
6
+ ⚠️ 連線中斷或異常結束(exit code: ${t})`),m.writeln("\r\nℹ️ 已切回互動終端,可手動輸入命令。"),G()}),m.attachCustomKeyEventHandler(e=>"Enter"!==e.key||!e.shiftKey||!!e.altKey||!!e.ctrlKey||!!e.metaKey||!!e.isComposing||!!B.current||(e.preventDefault(),e.stopPropagation(),"keydown"===e.type&&(L.current?.(),b.term.input(x,"\x1b\r")),!1)),m.onData(e=>{B.current||(L.current?.(),b.term.input(x,e),N())}),m.onScroll(()=>{let e=m.buffer.active;A(e.viewportY<e.baseY)});let N=()=>{clearTimeout(i),i=setTimeout(()=>{b.term.isScrolledBack(x).then(e=>{o||h.current!==m||E(e)})},150)},y=f.current;y?.addEventListener("wheel",N,{capture:!0,passive:!0}),l=()=>y?.removeEventListener("wheel",N,{capture:!0}),r=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{if(!o&&h.current===m)try{let{cols:e,rows:t}=m;if(g(),m.cols===e&&m.rows===t)return;b.term.resize(x,m.cols,m.rows)}catch{}},100)}),f.current&&r.observe(f.current),P.current=!0,V()})(),()=>{o=!0,P.current=!1,t?.(),n?.(),r?.disconnect(),clearTimeout(a),clearTimeout(i),l?.(),I()?.term.kill(x),h.current?.dispose(),h.current=null}},[e,x,V,G]),(0,r.useEffect)(()=>{V()},[i,l,V]);let Y=async t=>{if(!B.current&&P.current&&0!==t.length){L.current?.(),v(!0);try{let s=await tv(t),n=await eb({taskId:e,attachments:s});if(n.length>0){let e=n.map(({path:e})=>`'${e.replace(/'/g,"'\\''")}'`).join(" ");ev(x,`${e} `)}}catch(t){let e=t instanceof Error?t.message:String(t);h.current?.writeln(`\r
7
+ ⚠️ 附加檔案失敗:${e}`)}finally{v(!1)}}},U=async()=>{h.current?.scrollToBottom(),A(!1),await eN(x),E(!1),h.current?.focus()};return(0,n.jsxs)("div",{onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&P.current&&(p.current+=1,b(!0)))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect=c||!P.current?"none":"copy")},onDragLeave:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&P.current&&(p.current=Math.max(0,p.current-1),0===p.current&&b(!1)))},onDrop:e=>{e.preventDefault(),p.current=0,b(!1),!c&&P.current&&Y(e.dataTransfer.files)},className:(0,S.cn)("flex min-h-36 w-full flex-1 flex-col overflow-hidden rounded-md border border-border bg-card transition-colors",g&&"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)"}),j?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs text-muted-foreground",children:"附加檔案中…"}):c?(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:[d&&(0,n.jsxs)(tb,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void O(),disabled:!a||N||k,title:"捨棄這次執行的程式碼變更與 artifacts 並退回 Backlog,之後按「開始」才會重新啟動 Agent",children:[(0,n.jsx)(tN.A,{className:(0,S.cn)("size-3",N&&"animate-pulse")}),N?"退回中…":"退回 Backlog"]}),u&&(0,n.jsxs)(tb,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void H(),disabled:!a||k||N,title:"只帶入 Agent 設定與 Artifact 資訊,不傳入任務內容",children:[(0,n.jsx)(ty.A,{className:(0,S.cn)("size-3",k&&"animate-pulse")}),k?"啟動中…":"啟動 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:f,className:"h-full w-full overflow-hidden"}),(C||z)&&(0,n.jsxs)(tb,{variant:"secondary",size:"sm",className:"absolute bottom-3 right-5 h-7 px-2 text-xs shadow-md",onClick:()=>void U(),children:[(0,n.jsx)(tk.A,{className:"size-3"}),"回到最新"]})]})]})}var tA=s(18921),tz=s(79608);let tE={scale:1,x:0,y:0};function tP(e,t,s){return Math.min(s,Math.max(t,e))}function tI({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)(tE),[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:tP(e,-l,l),y:tP(t,-o,o)}},[]),x=(0,r.useCallback)((e,t=0,s=0)=>{c(n=>{let r=tP(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(tE)},[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,S.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,S.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)(tA.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)(tz.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,n.jsx)("p",{className:"px-1 text-xs text-muted-foreground",children:"滑桿或滾輪縮放,放大後可拖曳圖片平移。"})]})}let t$={claude:"Claude Code",codex:"Codex CLI"},tR={claude:"sonnet",codex:"gpt-5.5"},tT={codex:{"gpt-5-codex":"gpt-5.5","gpt-5":"gpt-5.5"}};function tD(e,t){return e.path===t.path&&e.status===t.status&&e.additions===t.additions&&e.deletions===t.deletions&&e.revision===t.revision}let t_=(0,r.lazy)(()=>s.e(1201).then(s.bind(s,31201)).then(e=>({default:e.default}))),tB={task:"任務",spec:"決策",artifacts:"Artifacts",diff:"Git diff"},tM=["task","spec","artifacts","diff"],tL=["task","spec"],tF=["task"],tG={A:"新增",M:"修改",D:"刪除",R:"更名","?":"未追蹤"},tO={image:"截圖",video:"影片",text:"文字",binary:"二進位"},tH="vibeflow:workspace-aside-px",tV="--vf-workspace-aside",tY=!1;function tU(){if(tY)return;tY=!0;let e=Number(window.localStorage.getItem(tH));Number.isFinite(e)&&e>=336&&document.documentElement.style.setProperty(tV,`${e}px`)}function tK(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function tW(e){return("image"===e.kind||"video"===e.kind)&&!e.scratch}function tX({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,S.cn)(C,"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 tq={MERGED:"bg-primary/15 text-primary",OPEN:"bg-success/15 text-success",CLOSED:"bg-destructive/15 text-destructive"};function tQ({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,S.cn)(C,"flex items-center gap-1.5"),children:[(0,n.jsx)(p.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,S.cn)("shrink-0 rounded-xs px-1.5 py-0.5 text-xs font-medium",tq[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 ef(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)(ti.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)(e1,{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,S.cn)(C,"flex items-center gap-1.5"),children:[(0,n.jsx)(tl.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,S.cn)(C,"flex items-center gap-1.5"),children:[(0,n.jsx)(to.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 tJ({task:e,column:t,subAgents:s,progress:r,onOpenSubAgents:a}){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})]}),"backlog"===t&&e.launchError&&(0,n.jsxs)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2.5 text-sm",children:["上次開始執行時無法建立分支,卡片已退回 Backlog:",e.launchError,(0,n.jsx)("br",{}),(0,n.jsx)("span",{className:"text-muted-foreground",children:"可以編輯分支名稱或基準分支後再開始。"})]}),(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)(g.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)(v.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:[e.branch,"done"!==t&&!e.worktreePath&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:"backlog"===t?"(開始執行時建立)":"(建立中…)"})]})]}),e.baseBranch&&(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(tc.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)(e1,{source:e.description}),"backlog"!==t&&(0,n.jsx)(eF,{progress:"in_progress"===t?r:null,usage:e.usage}),e.outcome&&(0,n.jsx)(tQ,{outcome:e.outcome}),s.length>0&&(0,n.jsxs)("button",{type:"button",onClick:()=>a(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 tZ({specs:e}){return(0,n.jsx)("div",{className:"space-y-6",children:e.map(e=>(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.path}),(0,n.jsx)(e1,{source:e.markdown,className:"bg-transparent p-0"}),e.truncated&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"內容過長,僅顯示前段。"}),null!=e.updatedAt&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:["更新於 ",new Date(e.updatedAt).toLocaleString()]})]},e.path))})}function t0({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),et(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)(td.A,{className:"size-5 text-muted-foreground"}):(0,n.jsx)(tu.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)(tm.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 t1({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),et(e,t.name).then(e=>{s&&l(e)}).catch(()=>{s&&l(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]),(0,n.jsx)(te,{title:t.name,description:`${tO[t.kind]} \xb7 ${tK(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)(eR.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)(tI,{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:["無法內嵌預覽的檔案(",tK(t.size),")。用 Artifacts 分頁的「開啟資料夾」以系統播放器或編輯器開啟。"]}):(0,n.jsxs)(n.Fragment,{children:[(a=t.name,/\.(md|markdown|mdx)$/i.test(a))?(0,n.jsx)(e1,{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 t5({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(tW),h=t.filter(e=>!tW(e)),p=(0,r.useCallback)(()=>{x(null),es(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)(tb,{variant:"outline",size:"sm",onClick:g,disabled:!s,title:"複製 Artifact 資料夾路徑",className:"shrink-0 text-xs",children:["copied"===d?(0,n.jsx)(k.A,{className:"size-3.5"}):(0,n.jsx)(eJ.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)(tb,{variant:"outline",size:"sm",onClick:p,title:s??"任務的 artifacts 目錄",className:"text-xs",children:[(0,n.jsx)(tx.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)(t0,{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:tK(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)(eZ.A,{className:(0,S.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)(tu.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):"video"===e.kind?(0,n.jsx)(td.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,n.jsx)(tf.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 ",tK(e.size)]})]})},e.name))})]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(t1,{taskId:e,artifact:a,onClose:()=>i(null)},`artifact-${e}-${a.name}`)})]})}let t2=(0,r.memo)(function({file:e,showHeader:t=!0}){return(0,n.jsxs)("div",{className:(0,S.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:tG[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)(t_,{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 t3({entry:e,file:t,onClose:s}){return(0,n.jsx)(te,{title:e.path,description:(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:tG[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)(eR.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)(t2,{file:t,showHeader:!1})})}function t4({diff:e}){return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(z,{"aria-label":"重新整理 Git diff",title:"重新整理(含 fetch origin)",className:"p-1",disabled:e.loading,onClick:e.manualRefresh,children:(0,n.jsx)(th.A,{className:(0,S.cn)("size-3.5",e.loading&&"animate-spin")})}),e.entries.length>0&&(0,n.jsx)(z,{"aria-label":"放大檢視 Git diff",title:"放大檢視(全部展開)",className:"p-1",onClick:e.expand,children:(0,n.jsx)(tp.A,{className:"size-3.5"})})]})}function t6({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)(eR.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:tG[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)(eZ.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)(t3,{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)(z,{"aria-label":"關閉 diff 放大檢視",title:"關閉",onClick:m,children:(0,n.jsx)(e5.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)(eR.A,{className:"size-3.5 animate-spin"}),"讀取全部 diff 內容中…"]}):u.map(e=>(0,n.jsx)(t2,{file:e},e.path))})})]})})]})}function t7({task:e,column:t,subAgents:s,progress:a,launch:i,onStart:l,onReturnToBacklog:o,onLaunchAgent:c,onComplete:d,onEdit:u,onDelete:f,onOpenSubAgents:h,onInteract:p}){let[g,b]=(0,r.useState)(null),[j,N]=(0,r.useState)(!1),[y,w]=(0,r.useState)([]),C=(0,r.useId)(),A=`${C}-panel`,E=e=>`${C}-tab-${e}`,P=e.worktreePath??e.projectPath??null,I="in_progress"!==t||e.worktreePath?null:`正在準備工作環境:從最新的 ${e.baseBranch??"基準分支"} 建立分支 ${e.branch} 與 worktree,有 remote 時會一併推送到 origin。第一次開始執行需要幾秒鐘,完成後 agent 會自動啟動…`,$=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),R=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 tD(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&&tD(s,N))return;let n=!0;return Z(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&&e3>0){n&&(s=setTimeout(()=>void a(!1),3e3));return}r=!0;try{let s=await J(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 Q(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=function(e,t,s){let[n,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{let n;if(a([]),!t)return;let r=!0,i=!1,l=async()=>{if(i&&e3>0){r&&s&&(n=setTimeout(()=>void l(),3e3));return}i=!0;try{let t=await en(e);r&&a(t)}catch{}finally{r&&s&&(n=setTimeout(()=>void l(),3e3))}};return l(),()=>{r=!1,n&&clearTimeout(n)}},[e,t,s]),n}(e.id,"backlog"!==t,"in_progress"===t),D=y.filter(tW).length;(0,r.useEffect)(()=>{let s;if("in_progress"!==t)return void w([]);let n=!0,r=!1,a=async()=>{if(r&&e3>0){n&&(s=setTimeout(()=>void a(),3e3));return}r=!0;try{let t=await ee(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 _="backlog"===t,B=i?.launch,M=i?.nonce??0,L=("done"===t?tL:"backlog"===t?tF:tM).filter(e=>"spec"!==e||T.length>0),F="done"===t&&L.includes("spec")?"spec":L[0],G=g&&L.includes(g)?g:F,O=(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視",className:"flex min-w-0 rounded-md border border-border/70 p-0.5",children:L.map(e=>{let t="artifacts"===e?D:"diff"===e?R.entries.length:0;return(0,n.jsxs)("button",{type:"button",role:"tab",id:E(e),"aria-selected":G===e,"aria-controls":A,onClick:()=>{p?.(),b(e)},className:(0,S.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",G===e?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground"),children:[tB[e],t>0&&(0,n.jsx)("span",{className:"ml-1 tabular-nums text-muted-foreground/80",children:t})]},e)})}),H=(0,r.useRef)(null),V=(0,r.useRef)(null),Y=(0,r.useRef)(null);(0,r.useLayoutEffect)(tU,[]);let U=(e,t)=>{let s,n=Math.round(Math.max(336,Math.min(e,Math.max(336,(s=H.current?.clientWidth??0)>0?s-320-10:e))));document.documentElement.style.setProperty(tV,`${n}px`),t&&window.localStorage.setItem(tH,String(n))},K=()=>{if(!Y.current)return;Y.current=null;let e=V.current?.getBoundingClientRect().width??0;e>0&&U(e,!0)},W=e=>{let t=V.current?.getBoundingClientRect().width??0;t<=0||U(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)(v.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})]})}),_&&(0,n.jsxs)(tb,{size:"sm",variant:"outline",onClick:()=>{p?.(),l(e)},disabled:!P,children:[(0,n.jsx)(tm.A,{className:"size-3.5"}),"開始"]}),"in_progress"===t&&(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(tb,{size:"sm",onClick:()=>{p?.(),d(e)},title:"標記完成後會清理 PTY 與 worktree",children:[(0,n.jsx)(k.A,{className:"size-3.5"}),"完成"]})}),"backlog"===t&&(0,n.jsx)(z,{"aria-label":"編輯任務",title:"編輯任務",onClick:()=>{p?.(),u(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:()=>f(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)(z,{"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)(tX,{title:tB.task,children:(0,n.jsx)(tJ,{task:e,column:t,subAgents:s,progress:a,onOpenSubAgents:h})})}):"done"===t?(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:(0,n.jsx)(tX,{heading:O,children:(0,n.jsx)("div",{role:"tabpanel",id:A,"aria-labelledby":E(G),className:"h-full",children:"task"===G?(0,n.jsx)(tJ,{task:e,column:t,subAgents:s,progress:a,onOpenSubAgents:h}):(0,n.jsx)(tZ,{specs:T})})})}):(0,n.jsxs)("main",{ref:H,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)(tS,{taskId:e.id,cwd:P,launchCommand:B,launchNonce:M,provisionNotice:I,readOnly:!1,onReturnToBacklog:"in_progress"===t?()=>o(e):void 0,onLaunchAgent:"in_progress"===t?()=>c(e):void 0,onInteract:p})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"調整終端機與側邊面板的寬度",tabIndex:0,onPointerDown:e=>{let t=V.current?.getBoundingClientRect().width??0;t<=0||(Y.current={x:e.clientX,width:t},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=Y.current;t&&U(t.width-(e.clientX-t.x),!1)},onPointerUp:K,onPointerCancel:K,onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),W(24)):"ArrowRight"===e.key&&(e.preventDefault(),W(-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:V,className:"flex min-h-0 min-w-0 flex-col bg-card/40",children:(0,n.jsx)(tX,{heading:O,actions:"diff"===G?(0,n.jsx)(t4,{diff:R}):void 0,children:(0,n.jsx)("div",{role:"tabpanel",id:A,"aria-labelledby":E(G),className:"h-full",children:"task"===G?(0,n.jsx)(tJ,{task:e,column:t,subAgents:s,progress:a,onOpenSubAgents:h}):"spec"===G?(0,n.jsx)(tZ,{specs:T}):"artifacts"===G?(0,n.jsx)(t5,{taskId:e.id,artifacts:y,artifactsDir:$}):(0,n.jsx)(t6,{taskId:e.id,diff:R})})})})]})]})}var t8=s(93659),t9=s(9523);let se="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 st=s(81450);let ss=["low","medium","high","xhigh","max","ultra"],sn=["low","medium","high","xhigh"];function sr(e,t){if(0===t.length)return;if(void 0===e||t.includes(e))return e;let s=ss.indexOf(e),n=ss.filter(e=>t.includes(e)),r=n.filter(e=>ss.indexOf(e)<=s);return r.length>0?r[r.length-1]:n[0]}let sa=[{value:"low",label:"快速",description:"適合範圍明確、低風險的小任務。"},{value:"medium",label:"標準",description:"兼顧速度與推理深度,適合一般開發任務。"},{value:"high",label:"深入",description:"適合跨檔案、除錯或需要較多判斷的任務。"},{value:"xhigh",label:"極致",description:"適合高複雜度、長鏈推理或高風險變更。"},{value:"max",label:"最大",description:"最深的推理,適合最困難的問題。"},{value:"ultra",label:"委派",description:"最深推理並自動委派子任務,耗時與用量可能明顯增加。"}],si="medium";function sl({value:e,onChange:t,levels:s,disabled:r=!1}){let a=sa.filter(e=>s.includes(e.value));if(0===a.length)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)(st.A,{className:"size-4 text-muted-foreground"}),"任務複雜度"]}),(0,n.jsx)("span",{className:"rounded-full bg-muted px-2.5 py-1 text-sm font-medium text-muted-foreground",children:"不適用"})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"這個 model 不支援調整推理強度,啟動時不會指定任務複雜度。"})]});let i=sr(e,s)??a[0].value,l=Math.max(0,a.findIndex(e=>e.value===i)),o=a[l];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)(st.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:[o.label," \xb7 ",o.value]})]}),(0,n.jsx)("input",{type:"range",name:"task-effort",min:0,max:a.length-1,step:1,value:l,disabled:r||1===a.length,"aria-label":"任務複雜度","aria-valuetext":`${o.label} (${o.value})`,onChange:e=>{let s=a[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 text-center text-xs text-muted-foreground",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},"aria-hidden":"true",children:a.map(e=>(0,n.jsx)("span",{children:e.label},e.value))}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[o.description," Claude Code 與 Codex 會在啟動此任務時套用;可選的級距依 model 而定。"]})]})}var so=s(37614);function sc({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)(so.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,S.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,S.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 sd=s(28333);function su(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function sm(e,t){return!!(t&&e.find(e=>e.path===t)?.missing)}function sx({projectPath:e,recentProjects:t,disabled:s,onSelect:a,onBrowse:i}){let l=e?su(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=sm(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,S.cn)(se,"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)(z,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",onClick:i,disabled:s,tone:"primary",className:"rounded-md border border-border p-2",children:(0,n.jsx)(tx.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,S.cn)(se,"min-w-0 flex-1 font-mono text-sm")}),(0,n.jsx)(z,{"aria-label":"套用輸入的路徑",title:"套用輸入的路徑",onClick:f,disabled:s||""===m.trim(),className:"rounded-md border border-border p-2",children:(0,n.jsx)(sd.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 sf({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:e8({timing:"standard",transform:{y:-4},reducedMotion:i}),className:r,children:a}):(0,n.jsx)("div",{id:s,className:r,children:a}):null}function sh({attachment:e,id:t,creating:s,animated:r,onRemove:a}){let i=(0,e2.tF)(),l=(0,c.I)()??!1,o=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t8.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)(z,{"aria-label":`移除附件 ${e.name}`,onClick:()=>a(t),disabled:s,className:"p-1",children:(0,n.jsx)(e5.A,{className:"size-3.5"})})]});return r?(0,n.jsx)(d.PY1.li,{initial:"hidden",animate:"visible",exit:"exit",variants:e9({timing:"micro",transform:{y:4},reducedMotion:l}),inert:!i,"aria-hidden":!i||void 0,className:(0,S.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 sp(e){let[t,s]=(0,r.useState)(null);return(0,r.useEffect)(()=>{let t=!1;return K(e).then(n=>{t||s({agentCli:e,models:n?.models??[]})}).catch(()=>{t||s({agentCli:e,models:[]})}),()=>{t=!0}},[e]),t?.agentCli===e?t.models:null}function sg(e,t,s,n,a){var i;let l=(i=e?.find(e=>e.id===function(e){var t;let s,n=(s=e.agentCli)&&s in t$?s:"claude";return t=e.model||tR[n],tT[n]?.[t]??t}({agentCli:t,model:s})),i?.efforts??null??sn);return(0,r.useEffect)(()=>{if(null===e)return;let t=sr(n,l);t&&t!==n&&a(t)},[e,l,n,a]),l}let sb="__custom__";function sj({title:e,agents:t,detectTimedOut:s,onRetry:a,agentCli:i,onAgentChange:l,model:o,onModelChange:c,models:d}){let[u,m]=(0,r.useState)(!1);(0,r.useEffect)(()=>{m(!1)},[i]);let x=d??[],f=u?void 0:x.find(e=>e.id===o)?.description,h=!o||u||x.some(e=>e.id===o)?x:[{id:o,label:o},...x];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)(ty.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:a,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)(eR.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:i,onChange:e=>l(e.target.value),className:se,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"}),(0,n.jsxs)("select",{name:`${e.toLowerCase().replace(/\s+/g,"-")}-model`,value:u?sb:o,onChange:e=>{e.target.value===sb?m(!0):(m(!1),c(e.target.value))},className:se,children:[(0,n.jsx)("option",{value:"",children:"使用預設 model"}),h.map(e=>(0,n.jsx)("option",{value:e.id,children:e.label},e.id)),(0,n.jsx)("option",{value:sb,children:"自訂…"})]}),null===d&&(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(eR.A,{className:"size-3 animate-spin"}),"讀取 model list…"]}),f&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:f}),u&&(0,n.jsx)("input",{name:`${e.toLowerCase().replace(/\s+/g,"-")}-custom-model`,value:o,onChange:e=>c(e.target.value.trim()),placeholder:"輸入完整 model id,例如 claude-opus-5-5",autoFocus:!0,className:se})]})]})}function sv({creating:e,error:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,initRepository:o,detectAgents:c,onSubmit:d,onClose:u,inline:m=!1,initialProjectPath:x,initialDraft:f,defaultAutoMode:h=!0,workstationPath:p}){let[g,b]=(0,r.useState)(1),[j,N]=(0,r.useState)(f?.title??""),[w,C]=(0,r.useState)(f?.description??""),[A,E]=(0,r.useState)(null),[P,I]=(0,r.useState)([]),[$,R]=(0,r.useState)(null),[T,D]=(0,r.useState)(!1),[_,B]=(0,r.useState)(!1),[M,L]=(0,r.useState)(""),[F,G]=(0,r.useState)(f?.branch??""),[O,H]=(0,r.useState)(null),[V,Y]=(0,r.useState)(!1),[U,K]=(0,r.useState)(0),[W,X]=(0,r.useState)(!1),[q,Q]=(0,r.useState)("claude"),[J,Z]=(0,r.useState)(""),[ee,et]=(0,r.useState)(si),es=sp(q),en=sg(es,q,J,ee,et),[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)(),eh=(0,r.useRef)(0),ep=(0,r.useRef)(null),eg=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;Y(!1),H(null);let t=setTimeout(()=>{e&&Y(!0)},6e3);return c().then(s=>{e&&(clearTimeout(t),H(s),!s.some(e=>"claude"===e.id)&&s.length>0&&Q(s[0].id))}),()=>{e=!1,clearTimeout(t)}},[c,U]),(0,r.useEffect)(()=>{2===g&&ep.current?.focus()},[g]),(0,r.useEffect)(()=>{m&&ep.current?.focus()},[]),(0,r.useEffect)(()=>{let e=!0;return a().then(t=>{e&&I(t)}),()=>{e=!1}},[a]);let eb=sm(P,A),ej=async e=>{E(e),R(null),L(""),D(!0);try{let t=await i(e);R(t);let s=e===x&&f?.baseBranch?f.baseBranch:null;L(s??t?.defaultBase??"")}finally{D(!1)}},ev=async e=>{if(sm(P,e)){E(e),R(null),L("");return}await ej(e)},eN=async()=>{let e=await s();e&&(I(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await ej(e))},ey=async()=>{if(A){B(!0);try{let e=await o(A);R(e),L(e?.defaultBase??"")}finally{B(!1)}}};(0,r.useEffect)(()=>{m&&x&&ev(x)},[]);let ek=$?.isRepo??!1,ew=$?.hasRemote??!1,eC=`${p?.trim()||"~/Desktop"}/${A?su(A):"<專案名>"}`,eS=!!A&&!eb&&ek&&!T&&!_,eA=j.trim().length>0&&!e&&!em&&(!m||eS),ez=()=>{eA&&A&&d(j.trim(),w.trim(),A,ew&&M||null,F.trim(),q,J,ee,er,ei.map(({input:e})=>e),f?.github)},eE=async e=>{ec(null),ex(!0);try{let t=(await tv(e)).map(e=>({id:eh.current++,input:e}));el(e=>[...e,...t])}catch(e){ec(e instanceof Error?e.message:String(e))}finally{ex(!1)}},eP=(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)(sx,{projectPath:A,recentProjects:P,disabled:e||_||T,onSelect:e=>void ev(e),onBrowse:()=>void eN()})]}),(0,n.jsx)(sf,{show:T||_,enabled:m,children:(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(eR.A,{className:"size-3 animate-spin"}),_?"初始化 Git…":"偵測 Git 狀態中…"]})}),(0,n.jsx)(sf,{show:!!$&&!eb&&!T&&!_&&!ek,enabled:m,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)(tb,{size:"sm",variant:"outline",onClick:()=>void ey(),disabled:e,className:"rounded-full",children:"初始化 Git"})]})}),(0,n.jsx)(sf,{show:ek&&ew,enabled:m,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)(v.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsx)("select",{name:"base-branch",value:M,onChange:e=>L(e.target.value),className:se,children:($?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]})}),(0,n.jsx)(sf,{show:ek&&!ew,enabled:m,children:(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["此 repository 沒有 remote,將以目前分支 (",$?.currentBranch??"HEAD",") 為基準建立本地 worktree。"]})}),(0,n.jsx)(sf,{show:ek,enabled:m,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)(v.A,{className:"size-3"}),"分支名稱 (選填)"]}),(0,n.jsx)("input",{name:"branch",value:F,onChange:e=>G(e.target.value),placeholder:"留空則自動命名,例如 feature/login-fix",className:se}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:ew?"開始執行時會建立同名分支;若 remote 已有這個分支,則直接取回並接續上面的工作。":"開始執行時會建立同名分支。"})]})}),(0,n.jsx)(sf,{show:ek,enabled:m,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)(t9.A,{className:"size-3.5 text-muted-foreground"}),"卡片開始執行時才會做這些事"]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"建立卡片只會記下分支名稱,不會建立分支或推到 origin;放在 Backlog 期間都可以再編輯。"}),(0,n.jsxs)("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:[(0,n.jsxs)("li",{children:[ew?"從當下最新的 origin 基準分支":"從基準分支",",在"," ",(0,n.jsx)("code",{className:"text-foreground",children:eC})," ","底下建立這張卡專用的 worktree 與分支,你的專案資料夾本身不會被切換。"]}),ew&&(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。"]})]})]})})]}),eI=(0,n.jsxs)("div",{className:"rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button","aria-expanded":W,"aria-controls":ef,onClick:()=>X(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)(y.A,{className:(0,S.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",W&&"rotate-180")})]}),(0,n.jsx)(sf,{show:W,enabled:m,id:ef,className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(sj,{title:"Agent",agents:O,detectTimedOut:V,onRetry:()=>K(e=>e+1),agentCli:q,onAgentChange:e=>{Q(e),Z("")},model:J,onModelChange:Z,models:es})})]}),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:()=>eg.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)||eE(t.dataTransfer.files)},className:(0,S.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)(t8.A,{className:"size-5"}),(0,n.jsx)("span",{className:"text-sm",children:"拖放檔案到這裡,或點擊選擇檔案"})]}),(0,n.jsx)("input",{ref:eg,type:"file",multiple:!0,disabled:e||em,className:"hidden",onChange:e=>{e.target.files&&eE(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)(eR.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)(sh,{attachment:s,id:t,creating:e,animated:m,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:"新增任務"}),u&&(0,n.jsx)(z,{"aria-label":"關閉新增任務",onClick:u,disabled:e,className:"p-1",children:(0,n.jsx)(e5.A,{className:"size-4"})})]}),!m&&(0,n.jsxs)("div",{className:"mb-5 flex items-center gap-2",children:[(0,n.jsx)("div",{className:(0,S.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",1===g?"bg-primary text-primary-foreground":"bg-primary/20 text-primary"),children:g>1?(0,n.jsx)(k.A,{className:"size-3.5",strokeWidth:3}):"1"}),(0,n.jsx)("span",{className:(0,S.cn)("text-base tracking-[-0.224px]",1===g?"font-medium text-foreground":"text-muted-foreground"),children:"專案設定"}),(0,n.jsx)("div",{className:(0,S.cn)("h-0.5 flex-1 transition-colors",g>1?"bg-primary/60":"bg-border")}),(0,n.jsx)("div",{className:(0,S.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",2===g?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"2"}),(0,n.jsx)("span",{className:(0,S.cn)("text-base tracking-[-0.224px]",2===g?"font-medium text-foreground":"text-muted-foreground"),children:"任務內容"})]}),m&&(0,n.jsxs)(n.Fragment,{children:[f&&(0,n.jsxs)("p",{className:"mb-3 text-sm text-muted-foreground",children:["由 ","issue"===f.github.kind?"Issue":"PR"," #",f.github.number,"(",f.github.repo,")轉成 Backlog 卡片,確認內容後按建立。"]}),(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:ep,name:"task-title",autoComplete:"off",value:j,onChange:e=>N(e.target.value),placeholder:"例如:實作登入頁面",className:(0,S.cn)(se,"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:[eP,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:w,onChange:e=>C(e.target.value),rows:12,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,S.cn)(se,"mb-2 min-h-64 flex-1 resize-y")})]}),(0,n.jsx)(sl,{value:ee,onChange:et,levels:en,disabled:e}),(0,n.jsx)(sc,{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:eI})]}),!m&&(0,n.jsxs)("div",{children:[1===g&&(0,n.jsx)("div",{className:"space-y-4",children:eP}),2===g&&(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:ep,name:"task-title",autoComplete:"off",value:j,onChange:e=>N(e.target.value),placeholder:"例如:實作登入頁面",className:se})]}),(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:w,name:"task-description",autoComplete:"off",onChange:e=>C(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,S.cn)(se,"resize-y")})]}),(0,n.jsx)(sl,{value:ee,onChange:et,levels:en,disabled:e}),(0,n.jsx)(sc,{value:er,onChange:ea,disabled:e}),e$,eI,t&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-base",children:t})]})]}),m?(0,n.jsxs)("div",{className:"mt-6 space-y-2 pb-10",children:[!eS&&j.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:[u&&(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:u,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(tb,{size:"sm",onClick:ez,disabled:!eA,className:(0,S.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)(eR.A,{className:"animate-spin"}),e?"建立任務中…":"建立任務"]})]})]}):1===g?(0,n.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[u&&(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:u,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsx)(tb,{size:"sm",onClick:()=>b(2),disabled:!eS,className:"rounded-full px-5",children:"下一步 →"})]}):(0,n.jsxs)("div",{className:"mt-5 flex items-center justify-between",children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:()=>b(1),disabled:e,className:"rounded-full",children:"← 上一步"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[u&&(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:u,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(tb,{size:"sm",onClick:ez,disabled:!eA,className:(0,S.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)(eR.A,{className:"animate-spin"}),e?"建立任務中…":"建立任務"]})]})]})]})}let sN="vibeflow:board-split-px";function sy(){let e=Number(window.localStorage.getItem(sN));return Number.isFinite(e)&&e>=180?e:null}function sk({active:e,children:t}){let s=(0,o.E)(),a=(0,c.I)()??!1,i=e8({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,S.cn)("h-full",!e&&"hidden pointer-events-none"),children:t})}function sw({board:e,onBoardChange:t,onEditTask:s,onTaskDone:a,onDeleteTask:i,autoMode:o,workstationPath:m,subAgents:x,progress:f,selectedTaskId:h,onSelectTask:p,onNewTask:g,tabBar:b,onTaskInteract:j,openTabIds:v,initialProjectPath:N,newTaskDraft:y,newTaskNonce:k,view:w,onViewChange:C,githubView:A,taskLinks:z,creating:E,createError:P,pickFolder:I,loadRecentProjects:$,loadGitInfo:R,initRepository:T,detectAgents:D,onCreateTask:_}){let[B,M]=(0,r.useState)(null),L=(0,r.useRef)(null),[F,G]=(0,r.useState)(new Set),[O,H]=(0,r.useState)({}),V=(0,r.useRef)(O);V.current=O;let Y=e8({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:(0,c.I)()??!1}),U=e=>G(t=>t.has(e)?t:new Set(t).add(e)),[K,W]=(0,r.useState)(null),[X,Q]=(0,r.useState)(null),J=async(e,t={})=>{U(e.id),H(s=>({...s,[e.id]:{launch:t,nonce:(s[e.id]?.nonce??0)+1}}))};(0,r.useEffect)(()=>{if(!h||(U(h),O[h]))return;let t=e.in_progress.find(e=>e.id===h);if(!t||null==t.launchedAt||!t.worktreePath)return;let s=!1;return ey(t.id).then(e=>{s||!e||V.current[t.id]||J(t,{resume:!0})}),()=>{s=!0}},[h]);let Z=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}),J(n)},ee=e=>new Promise((t,s)=>{Q({task:e,settle:n=>{(Q(null),n)?et(e).then(()=>t(!0),s):t(!1)}})}),et=async e=>{let s=await q(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)})},es=async e=>{await J(e,{includeTaskPrompt:!1})},en=e=>W(e),er=(0,r.useRef)(null),ea=(0,r.useRef)(null),[ei,el]=(0,r.useState)(sy);(0,r.useLayoutEffect)(()=>{if(null!==ei)return;let e=er.current?.clientHeight??0;e>0&&el(Math.max(180,e-260))},[ei]);let eo=e=>{let t=er.current?.clientHeight??0;return Math.max(180,Math.min(e,Math.max(180,t>0?t-260:e)))},ec=()=>{ea.current&&null!==ei&&(ea.current=null,window.localStorage.setItem(sN,String(ei)))},ed=e=>{if(null===ei)return;let t=eo(ei+e);el(t),window.localStorage.setItem(sN,String(t))},eu=B?Object.values(e).flat().find(e=>e.id===B):null,em=B?x[B]:void 0,ex=B&&eu?{taskId:B,taskTitle:eu.title,runs:em??[]}:null;(0,r.useEffect)(()=>{B&&eu&&(L.current={taskId:B,taskTitle:eu.title,runs:em??[]})},[B,eu,em]);let ef=ex??L.current;return(0,n.jsxs)("div",{ref:er,className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsx)("div",{style:null===ei?void 0:{height:ei},className:(0,S.cn)("min-h-0 overflow-hidden border-b border-border",null===ei?"flex-1":"shrink-0"),children:"github"===w?A:(0,n.jsx)(eQ,{board:e,subAgents:x,progress:f,selectedTaskId:h??null,onSelectTask:p,onEditTask:s,onDeleteTask:i,onNewTask:g,view:w,onViewChange:C,taskLinks:z})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":"調整看板與工作區的高度",tabIndex:0,onPointerDown:e=>{null!==ei&&(ea.current={y:e.clientY,height:ei},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=ea.current;t&&el(eo(t.height+(e.clientY-t.y)))},onPointerUp:ec,onPointerCancel:ec,onKeyDown:e=>{"ArrowUp"===e.key?(e.preventDefault(),ed(-24)):"ArrowDown"===e.key&&(e.preventDefault(),ed(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:[b,(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=h?t.find(({task:e})=>e.id===h):null,a=new Set(v),l=new Set;for(let e of F){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===h;return(0,n.jsx)(sk,{active:a,children:(0,n.jsx)(t7,{task:r.task,column:r.column,subAgents:x[r.task.id]??[],progress:f[r.task.id]??null,launch:O[e],onStart:Z,onReturnToBacklog:ee,onLaunchAgent:es,onComplete:en,onEdit:s,onDelete:i,onOpenSubAgents:M,onInteract:j?()=>j(e):void 0})},e)}),!r&&(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:Y,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)(sv,{inline:!0,initialProjectPath:N,initialDraft:y,creating:E,error:P,pickFolder:I,loadRecentProjects:$,loadGitInfo:R,initRepository:T,detectAgents:D,defaultAutoMode:o,workstationPath:m,onSubmit:_},`${N??"new"}:${k}`)})})]})})()})]}),(0,n.jsx)(ta,{open:null!==B,taskId:ef?.taskId??"",taskTitle:ef?.taskTitle??"",runs:ef?.runs??[],onClose:()=>M(null)}),(0,n.jsx)(l.N,{children:K&&(0,n.jsx)(te,{title:"完成任務",onClose:()=>W(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:["完成「",K.title,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除這張卡的 worktree(尚未 commit 的變更會一起消失)、本地分支",K.branch?`「${K.branch}」`:"","與 artifacts, 並把專案切回",K.baseBranch?`「${K.baseBranch}」`:"基準分支","後更新。此操作無法復原,請先確認要保留的變更都已經 commit 或 push。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>W(null),children:"取消"}),(0,n.jsx)(tb,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>{var s;let n;K&&(W(null),s="done",(n={backlog:e.backlog.filter(e=>e.id!==K.id),in_progress:e.in_progress.filter(e=>e.id!==K.id),done:e.done.filter(e=>e.id!==K.id)})[s]=[K,...n[s]],t(n),a(K.id))},children:"完成並清理"})]})]})},"confirm-done-dialog")}),(0,n.jsx)(l.N,{children:X&&(0,n.jsx)(te,{title:"退回 Backlog",onClose:()=>X.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:["把「",X.task.title,"」退回 Backlog?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會停止 Agent,並把 worktree 還原到",X.task.baseBranch?`「${X.task.baseBranch}」`:"基準分支","——這張卡在本地的 commit 與未 commit 變更都會消失,artifacts 也會一併刪除。遠端分支不會被改動。此操作無法復原。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>X.settle(!1),children:"取消"}),(0,n.jsx)(tb,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>X.settle(!0),children:"清除並退回"})]})]})},"confirm-return-dialog")})]})}function sC({task:e,detectAgents:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,saving:o,error:c,defaultAutoMode:d=!0,onSubmit:u,onClose:m}){let[x,f]=(0,r.useState)(""),[h,p]=(0,r.useState)(""),[g,b]=(0,r.useState)("claude"),[j,N]=(0,r.useState)(""),[k,w]=(0,r.useState)(si),C=sp(g),A=sg(C,g,j,k,w),[z,E]=(0,r.useState)(!0),[P,I]=(0,r.useState)(null),[$,R]=(0,r.useState)(""),[T,D]=(0,r.useState)(""),[_,B]=(0,r.useState)(null),[M,L]=(0,r.useState)(!1),[F,G]=(0,r.useState)(!1),[O,H]=(0,r.useState)([]),[V,Y]=(0,r.useState)(null),[U,K]=(0,r.useState)(!1),[W,X]=(0,r.useState)(0),[q,Q]=(0,r.useState)(!0),[J,Z]=(0,r.useState)(!1),ee=(0,r.useRef)(null),et=e??ee.current;if((0,r.useEffect)(()=>{e&&(ee.current=e)},[e]),(0,r.useEffect)(()=>{e&&(f(e.title),p(e.description??""),b(e.agentCli??"claude"),N(e.model??""),w(e.effort??si),E(e.autoMode??d),I(e.projectPath??null),R(e.baseBranch??""),D(e.branch),B(null),L(!1),G(!1),Z(!1))},[e,d]),(0,r.useEffect)(()=>{if(!e)return;let t=!0;return a().then(e=>{t&&H(e)}),()=>{t=!1}},[e,a]),(0,r.useEffect)(()=>{if(!e?.projectPath)return;let t=!0;return L(!0),i(e.projectPath).then(e=>{t&&B(e)}).finally(()=>{t&&L(!1)}),()=>{t=!1}},[e,i]),(0,r.useEffect)(()=>{if(!e)return;let s=!0;K(!1),Y(null);let n=setTimeout(()=>{s&&K(!0)},6e3);return t().then(e=>{s&&(clearTimeout(n),Y(e))}),()=>{s=!1,clearTimeout(n)}},[e,t,W]),!et)return null;let es=!!et.worktreePath,en=x!==et.title||h!==(et.description??"")||g!==(et.agentCli??"claude")||j!==(et.model??"")||k!==(et.effort??si)||z!==(et.autoMode??d)||F||$!==(et.baseBranch??"")||T.trim()!==et.branch,er=()=>{o||(en?Z(!0):m())},ea=sm(O,P),ei=async(e,t=!1)=>{if(I(e),G(e!==et.projectPath),B(null),!(!t&&sm(O,e))){L(!0);try{let t=await i(e);B(t),R(t?.defaultBase??"")}finally{L(!1)}}},el=async()=>{let e=await s();e&&(H(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await ei(e,!0))},eo=_?.isRepo??!0,ec=_?.hasRemote??!1,ed=F||$!==(et.baseBranch??"")||""!==T.trim()&&T.trim()!==et.branch,eu=x.trim().length>0&&!o&&!M&&(!F||eo&&!ea);return(0,n.jsx)(l.N,{children:e&&(0,n.jsxs)(te,{title:"編輯任務",description:"更新任務內容與 agent 設定。",saving:o,onClose:er,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)(tb,{variant:"ghost",size:"sm",onClick:er,disabled:o,children:"取消"}),(0,n.jsxs)(tb,{size:"sm",onClick:()=>{eu&&u({title:x.trim(),description:h.trim(),agentCli:g,model:j,effort:k,autoMode:z,...P?{projectPath:P,baseBranch:$||null}:{},branch:T.trim()})},disabled:!eu,className:(0,S.cn)(o&&"opacity-80"),children:[o&&(0,n.jsx)(eR.A,{className:"animate-spin"}),o?"儲存中…":"儲存變更"]})]})]}),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:()=>Z(!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:m,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:x,onChange:e=>f(e.target.value),placeholder:"例如:實作登入頁面",className:se})]}),(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:h,onChange:e=>p(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,S.cn)(se,"resize-y")})]}),(0,n.jsx)(sl,{value:k,onChange:w,levels:A,disabled:o}),(0,n.jsx)(sc,{value:z,onChange:E,disabled:o}),(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)(tx.A,{className:"size-3"}),"專案資料夾"]}),(0,n.jsx)(sx,{projectPath:P,recentProjects:O,disabled:o||M,onSelect:e=>void ei(e),onBrowse:()=>void el()}),M&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(eR.A,{className:"size-3 animate-spin"}),"偵測 Git 狀態中…"]}),F&&!ea&&!M&&!eo&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"這個資料夾不是 Git repository,請改選一個 Git 專案。"})]}),eo&&ec&&(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)(v.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsxs)("select",{name:"edit-base-branch",value:$,onChange:e=>R(e.target.value),disabled:o||M,className:se,children:[$&&!(_?.branches??[]).includes($)&&(0,n.jsx)("option",{value:$,children:$}),(_?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]}),(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)(v.A,{className:"size-3"}),"分支名稱"]}),(0,n.jsx)("input",{name:"edit-branch",autoComplete:"off",value:T,onChange:e=>D(e.target.value),placeholder:"例如 feature/login-fix",disabled:o,className:se}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:"分支會在卡片開始執行時才建立並推到 origin。"})]}),es&&ed&&(0,n.jsx)("p",{className:"rounded-md border border-warning/40 bg-warning/10 p-2 text-sm text-warning",children:"這張卡已經有 worktree。儲存後會移除它與本地分支,下次開始執行時再重新建立; worktree 有未完成的變更時無法儲存。origin 上已推送的分支不會被刪除。"}),(0,n.jsxs)("div",{className:"rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>Q(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)(y.A,{className:(0,S.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",q&&"rotate-180")})]}),q&&(0,n.jsx)("div",{className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(sj,{title:"Agent",agents:V,detectTimedOut:U,onRetry:()=>X(e=>e+1),agentCli:g,onAgentChange:e=>{b(e),N("")},model:j,onModelChange:N,models:C})})]}),c&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:c})]})]},et.id)})}var sS=s(1896),sA=s(87617),sz=s(80802),sE=s(69758),sP=s(21684),sI=s(18319),s$=s(37156),sR=s(43812);let sT=[{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 自行決定要不要執行。"}],sD={skill:sP.A,prompt:tf.A,script:sI.A};function s_(e,t){return"skill"!==e?"":`---
8
+ name: ${t}
9
+ description:
10
+ ---
11
+
12
+ `}function sB({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,g]=(0,r.useState)([]),[b,j]=(0,r.useState)(null),v=(0,r.useCallback)(async()=>{let[e,t]=await Promise.all([ea(),ex()]);s(e),g(t),i(!1)},[]);(0,r.useEffect)(()=>{v()},[v]),(0,r.useEffect)(()=>{e?.(null!==f)},[f,e]);let N=async(e,t)=>{o(e),d(null);try{await t(),await v()}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,S.cn)(se,"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)(tb,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(tb,{size:"sm",onClick:()=>void(()=>{if(!f)return;let{entry:e,content:t}=f;return N(`save:${e.key}`,async()=>{await ec(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}),sT.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=sD[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,S.cn)(C,"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)(tb,{variant:"ghost",size:"sm",onClick:()=>{N(`import:${e}`,async()=>{let t=await er(e);t&&await ei(e,t)})},disabled:null!==l,children:[l===`import:${e}`?(0,n.jsx)(eR.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(s$.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(tb,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:s_(e,""),description:""}),disabled:null!==l,children:[(0,n.jsx)(w.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===s_(e,u.name)?s_(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,S.cn)(se,"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,S.cn)(se,"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,S.cn)(se,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(tb,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return N("create",async()=>{await el(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 N(`toggle:${e.key}`,()=>ed(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.jsxs)("p",{className:"flex items-center gap-2 font-mono text-sm",children:[(0,n.jsx)("span",{className:"truncate",children:e.name}),e.builtin&&(0,n.jsx)("span",{className:"shrink-0 rounded-sm bg-muted px-1.5 font-sans text-xs text-muted-foreground",children:"內建"}),e.builtin?.updateAvailable?(0,n.jsx)("span",{className:"shrink-0 rounded-sm bg-primary/15 px-1.5 font-sans text-xs text-primary",children:"有新版"}):e.builtin?.modified?(0,n.jsx)("span",{className:"shrink-0 rounded-sm bg-muted px-1.5 font-sans text-xs text-muted-foreground",children:"已修改"}):null]}),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)(tb,{variant:"ghost",size:"sm",onClick:()=>{N(`open:${e.key}`,async()=>{h({entry:e,content:await eo(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.builtin?.modified&&(0,n.jsxs)(tb,{variant:"ghost",size:"sm",onClick:()=>{var t;b!==(t=e.name)?j(t):(j(null),N(`restore:${t}`,()=>em(t)))},onBlur:()=>j(null),disabled:null!==l,title:"以 VibeFlow 出貨的版本覆蓋(會丟掉你的修改)",children:[l===`restore:${e.name}`?(0,n.jsx)(eR.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(sR.A,{className:"size-3.5"}),b===e.name?"確定覆蓋?":"還原預設"]}),e.sourcePath&&(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:()=>{N(`reimport:${e.key}`,async()=>{e.sourcePath&&await ei(e.kind,e.sourcePath)})},disabled:null!==l,title:"從來源重新複製一份快照",children:l===`reimport:${e.key}`?(0,n.jsx)(eR.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(th.A,{className:"size-3.5"})}),(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:()=>void N(`delete:${e.key}`,()=>eu(e.kind,e.name)),disabled:null!==l,title:"從 library 刪除",children:(0,n.jsx)(x.A,{className:"size-3.5 text-destructive"})})]})]},e.key))})]},e)}),p.length>0&&(0,n.jsxs)("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:["已移除的內建 skill:",p.map(e=>(0,n.jsxs)(tb,{variant:"ghost",size:"sm",onClick:()=>void N(`restore:${e}`,()=>em(e)),disabled:null!==l,title:"放回 VibeFlow 出貨的版本",children:[(0,n.jsx)(sR.A,{className:"size-3.5"}),e]},e))]})]})}var sM=s(63252);let sL={enabled:!0,stepCompleted:!1,allCompleted:!0,waitingInput:!0,desktop:!1};function sF(e){return{...sL,...e??{}}}function sG(){return"Notification"in window?Notification.permission:"unsupported"}function sO({checked:e,label:t,disabled:s,onChange:r}){return(0,n.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,disabled:s,onClick:()=>r(!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,S.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,S.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")})})})}function sH({label:e,hint:t,checked:s,disabled:r,onChange:a}){return(0,n.jsxs)("div",{className:(0,S.cn)("flex items-start justify-between gap-3",r&&"opacity-60"),children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm",children:e}),t&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:t})]}),(0,n.jsx)(sO,{checked:s,label:e,disabled:r,onChange:a})]})}function sV({value:e,onChange:t,desktopBlocked:s,onRequestDesktop:r}){let a=s=>t({...e,...s}),i=!e.enabled;return(0,n.jsxs)("div",{className:"space-y-3 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)(sM.A,{className:"size-4 text-muted-foreground"}),"通知"]}),(0,n.jsx)(sO,{checked:e.enabled,label:"通知",onChange:e=>a({enabled:e})})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"從 agent 的執行紀錄判斷階段,不需要 agent 額外回報。正在看的卡片不會跳通知。"}),(0,n.jsxs)("div",{className:"space-y-2.5 border-t border-border/50 pt-3",children:[(0,n.jsx)(sH,{label:"步驟完成",hint:"待辦清單中每完成一項就通知",checked:e.stepCompleted,disabled:i,onChange:e=>a({stepCompleted:e})}),(0,n.jsx)(sH,{label:"全部步驟完成",checked:e.allCompleted,disabled:i,onChange:e=>a({allCompleted:e})}),(0,n.jsx)(sH,{label:"等待輸入",hint:"Agent 停下來等你回覆或允許權限",checked:e.waitingInput,disabled:i,onChange:e=>a({waitingInput:e})}),(0,n.jsx)(sH,{label:"桌面通知",hint:s?"瀏覽器已封鎖通知,請在瀏覽器的網站設定中允許。":"頁面不在前景時也會跳出系統通知",checked:e.desktop&&!s,disabled:i,onChange:async e=>{if(!e)return a({desktop:!1});a({desktop:await r()})}})]})]})}let sY=[{id:"claude",name:"Claude Code"},{id:"codex",name:"Codex CLI"}],sU={builtin:"內建清單","claude-cli":"Claude Code CLI","codex-app-server":"Codex CLI","codex-cache":"Codex 本機快取"};function sK({open:e,systemPrompt:t,workstationPath:s,autoMode:a,notifications:i,saving:o,error:c,onSave:d,onPickFolder:m,onClose:x}){let[f,h]=(0,r.useState)(""),[p,g]=(0,r.useState)(""),[b,j]=(0,r.useState)(!0),[v,N]=(0,r.useState)(i),[y,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)({}),[A,z]=(0,r.useState)(null),[E,P]=(0,r.useState)(void 0),[$,R]=(0,r.useState)(!1),[T,_]=(0,r.useState)(null),[B,G]=(0,r.useState)("idle"),[O,H]=(0,r.useState)(""),[V,Y]=(0,r.useState)("https://github.com/login/device"),[W,X]=(0,r.useState)(null),[q,Q]=(0,r.useState)(!1),[J,Z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(h(t),g(s),j(a),N(i),k("denied"===sG()||"unsupported"===sG()),R(!1),G("idle"),H(""),X(null),Z(!1),D().then(_))},[e,t,s,a,i]),(0,r.useEffect)(()=>{if(!e)return;let t=!1;for(let e of(C({}),P(void 0),U().then(e=>e.map(e=>e.id)).catch(()=>null).then(e=>{t||P(e)}),sY))K(e.id).catch(()=>null).then(s=>{t||C(t=>({...t,[e.id]:s}))});return()=>{t=!0}},[e]);let ee=async e=>{z(e);try{let t=await K(e,!0).catch(()=>null);C(s=>({...s,[e]:t}))}finally{z(null)}};(0,r.useEffect)(()=>{if(e){var t;let e;return t=e=>{if("starting"===e.type){G("starting"),X(null);return}if("code"===e.type){G("waiting"),H(e.code),Y(e.url),Z(!1),Q(!1);return}if("success"===e.type){_(e.status),G("success"),Q(!1);return}if("cancelled"===e.type){G("idle"),Q(!1);return}G("error"),X(e.error),Q(!1)},(e=I())?e.onGithubAuthEvent(t):()=>{}}},[e]);let[et,es]=(0,r.useState)(!1),[en,er]=(0,r.useState)(!1),ea=f.trim(),ei=""===ea,el=!o&&!$,eo=async()=>{let e=await m();e&&g(e)},ec=async()=>{R(!0),G("starting"),H(""),X(null),Z(!1),Q(!0);try{await M()}catch(e){G("error"),X(e instanceof Error?e.message:String(e)),Q(!1)}},ed=async()=>{("starting"===B||"waiting"===B)&&await L(),R(!1),G("idle"),Q(!1),H(""),X(null),Z(!1),_(await D())},eu=async()=>{Q(!0),X(null);try{let e=await F();_(e)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Q(!1)}},em=()=>{$&&("starting"===B||"waiting"===B)&&L(),x()},ex=async()=>{O&&(await navigator.clipboard.writeText(O),Z(!0),window.setTimeout(()=>Z(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(te,{title:$?"登入 GitHub CLI":et?"Library":"設定",description:$?"使用 GitHub CLI 的網頁授權流程登入 github.com。":et?"VibeFlow 自有的 skill / prompt / script,啟動任務時投遞給 Claude 與 Codex。":"調整 system prompt 與 agent 帳號連線。",saving:o||q,onClose:em,showHeader:!0,contentClassName:"max-w-2xl",footer:$?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:()=>void ed(),disabled:q&&"success"!==B,children:"success"===B?"完成":"返回"}),"error"===B&&(0,n.jsx)(tb,{size:"sm",onClick:()=>void ec(),children:"重新登入"})]}):et?en?null:(0,n.jsxs)(tb,{variant:"ghost",size:"sm",onClick:()=>es(!1),children:[(0,n.jsx)(sS.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",onClick:em,disabled:o,children:"取消"}),(0,n.jsxs)(tb,{size:"sm",onClick:()=>{el&&d(ea,p.trim(),b,v)},disabled:!el,className:(0,S.cn)(o&&"opacity-80"),children:[o&&(0,n.jsx)(eR.A,{className:"animate-spin"}),o?"儲存中…":"儲存設定"]})]}),children:$?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void ed(),disabled:q&&"success"!==B,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)(sS.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"===B?(0,n.jsx)(eI.A,{className:"mt-0.5 size-5 shrink-0 text-success"}):"error"===B?(0,n.jsx)(u.A,{className:"mt-0.5 size-5 shrink-0 text-destructive"}):(0,n.jsx)(eR.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"===B?"GitHub CLI 已完成授權":"error"===B?"GitHub CLI 授權失敗":"waiting"===B?"等待 GitHub 授權完成":"正在啟動 GitHub CLI 登入"}),(0,n.jsx)("p",{className:"text-sm leading-5 text-muted-foreground",children:"success"===B?`目前登入帳號:${T?.login??"GitHub"}`:"error"===B?W:"waiting"===B?"請複製授權碼並開啟 GitHub 授權頁,完成後 VibeFlow 會自動更新狀態。":"VibeFlow 正在背景準備 gh auth login。"})]})]})}),("waiting"===B||O)&&(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:O,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 ex(),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:!O,children:[(0,n.jsx)(sA.A,{className:"size-4"}),J?"已複製":"複製"]})]})]}),(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 ef(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)(ti.A,{className:"size-4"}),"開啟"]})]})]})]})]}):et?(0,n.jsx)(sB,{onEditingChange:er}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(sc,{value:b,onChange:j}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsx)("section",{className:"space-y-2",children:(0,n.jsx)(sV,{value:v,onChange:N,desktopBlocked:y,onRequestDesktop:async()=>{if("unsupported"===sG())return k(!0),!1;let e=await Notification.requestPermission()==="granted";return k(!e),e}})}),(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,S.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",""===p.trim()?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:""===p.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:p,placeholder:"~/Desktop",onChange:e=>g(e.target.value),className:(0,S.cn)(se,"font-mono text-sm")}),(0,n.jsx)(tb,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void eo(),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,S.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",ei?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:ei?"未設定":"已自訂"})]})}),(0,n.jsx)("textarea",{name:"system-prompt",autoComplete:"off",value:f,onChange:e=>h(e.target.value),rows:10,spellCheck:!1,className:(0,S.cn)(se,"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)(tb,{variant:"secondary",size:"sm",onClick:()=>es(!0),children:[(0,n.jsx)(sz.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:"Model 清單直接取自已登入的 Agent CLI,不需要 API key;設定 GitHub CLI 以支援本機 GitHub 操作。"})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[sY.map(e=>{let t=w[e.id],s=Array.isArray(E)&&!E.includes(e.id),r=void 0===E||!s&&(void 0===t||t?.pending===!0||A===e.id);return(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[r?(0,n.jsx)(eR.A,{className:"size-4 shrink-0 animate-spin text-muted-foreground"}):s?(0,n.jsx)(u.A,{className:"size-4 shrink-0 text-muted-foreground"}):t?.error||!t?(0,n.jsx)(u.A,{className:"size-4 shrink-0 text-destructive"}):(0,n.jsx)(eI.A,{className:"size-4 shrink-0 text-success"}),(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:"truncate text-sm text-muted-foreground",children:void 0===E?"偵測 CLI…":s?`未安裝・PATH 中找不到 ${e.id} 指令`:void 0===t?"讀取 model 清單…":t?t.pending?`正在向 ${e.name} 取得 model 清單…`:`${t.models.length} 個 models 可用・來源:${sU[t.source]}`:"無法取得 model 清單"}),!s&&t?.loginRequired?(0,n.jsxs)("p",{className:"text-sm text-destructive",children:["尚未登入,請在終端機執行 ",(0,n.jsxs)("code",{children:[e.id," login"]})," 後重新整理。"]}):!s&&t?.error&&(0,n.jsx)("p",{className:"truncate text-sm text-destructive",title:t.error,children:t.error})]}),!s&&void 0!==E&&(0,n.jsx)(tb,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",disabled:A===e.id,"aria-label":`向 ${e.name} 重新取得 model 清單`,title:`向 ${e.name} 重新取得 model 清單`,onClick:()=>void ee(e.id),children:(0,n.jsx)(th.A,{className:(0,S.cn)("size-4",A===e.id&&"animate-spin")})})]},e.id)}),(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/60 px-3 py-2.5",children:[T?.authenticated?(0,n.jsx)(eI.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:"GitHub CLI"}),(0,n.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:T?.authenticated?`${T.login??"GitHub"} 已授權(${T.gitProtocol??"https"})`:T?.installed===!1?"找不到 GitHub CLI(gh)":T?.error?T.error:"尚未授權"})]}),T?.authenticated&&(0,n.jsx)(tb,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:q,onClick:()=>void ec(),children:"切換使用者"}),T?.authenticated&&(0,n.jsxs)(tb,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:q,onClick:()=>void eu(),children:[q?(0,n.jsx)(eR.A,{className:"size-4 animate-spin"}):(0,n.jsx)(sE.A,{className:"size-4"}),"登出"]}),!T?.authenticated&&(0,n.jsx)(tb,{type:"button",size:"sm",variant:"outline",disabled:T?.installed===!1||q,onClick:()=>void ec(),children:q?"啟動中…":"登入"})]})]}),W&&!$&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:W})]}),c&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:c})]})},"settings-dialog")})}var sW=s(93202),sX=s(51256),sq=s(26814),sQ=s(6684),sJ=s(30592),sZ=s(79751);let s0="flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors motion-reduce:transition-none";function s1(e){return e?"bg-primary/15 font-medium text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"}function s5({mode:e,className:t,children:s}){let r=(0,c.I)()??!1;return(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:e8({timing:"micro",reducedMotion:r}),className:t,children:s},e)}function s2({collapsed:e,onRemoteShare:t,remoteActive:s,onOpenSettings:r}){return e?(0,n.jsxs)(s5,{mode:"collapsed",className:"flex flex-col items-center gap-1 border-t border-border p-2",children:[t&&(0,n.jsx)(z,{"aria-label":"遠端控制",onClick:t,title:"遠端控制",className:(0,S.cn)("size-8",s&&"text-primary hover:text-primary"),children:(0,n.jsx)(sW.A,{className:"size-4"})}),(0,n.jsx)(z,{"aria-label":"設定 System Prompt",onClick:r,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(sX.A,{className:"size-4"})})]}):(0,n.jsx)(s5,{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)(z,{"aria-label":"遠端控制",onClick:t,title:"遠端控制",className:(0,S.cn)(s?"text-primary hover:text-primary":"text-muted-foreground hover:text-foreground"),children:(0,n.jsx)(sW.A,{className:"size-4"})}),(0,n.jsx)(z,{"aria-label":"設定 System Prompt",onClick:r,title:"設定(System Prompt)",children:(0,n.jsx)(sX.A,{className:"size-4"})})]})})}function s3({collapsed:e,onToggleCollapse:t,view:s,onSelectView:r,taskCount:a,githubCount:i,projects:l,activeProject:o,onSelectProject:u,onNewTask:m,onRemoteShare:x,remoteActive:f,onOpenSettings:h}){let p=(0,c.I)()??!1,g=e8({timing:"micro",reducedMotion:p});return(0,n.jsxs)(d.PY1.aside,{initial:!1,animate:{width:e?48:320},transition:{duration:p?0:e4.spatial,ease:e6.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,S.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:g,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)(z,{"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)(sq.A,{className:"hidden size-4 group-hover:block group-focus-visible:block"})]}):(0,n.jsx)(sQ.A,{className:"size-4"})})]}),(0,n.jsx)(s5,{mode:e?"collapsed":"expanded",className:(0,S.cn)("shrink-0 px-2 pt-3",e?"flex justify-center":"w-full"),children:e?(0,n.jsx)(z,{"aria-label":"新增任務",onClick:m,title:"新增任務",className:"size-8 p-1.5",children:(0,n.jsx)(w.A,{className:"size-4"})}):(0,n.jsxs)(tb,{size:"sm",className:"w-full rounded-md active:scale-95",onClick:m,children:[(0,n.jsx)(w.A,{}),"新增任務"]})}),(0,n.jsx)("div",{className:(0,S.cn)("flex flex-1 flex-col py-3",e?"items-center gap-1 overflow-hidden px-2":"overflow-y-auto"),children:e?(0,n.jsxs)(s5,{mode:"collapsed",className:"flex flex-col items-center gap-1",children:[(0,n.jsx)(z,{"aria-label":"看板",title:"看板",onClick:()=>r("board"),className:(0,S.cn)("size-8","board"===s&&"text-primary hover:text-primary"),children:(0,n.jsx)(sJ.A,{className:"size-4"})}),(0,n.jsx)(z,{"aria-label":"Issues & PRs",title:"Issues & PRs",onClick:()=>r("github"),className:(0,S.cn)("size-8","github"===s&&"text-primary hover:text-primary"),children:(0,n.jsx)(sZ.A,{className:"size-4"})})]}):(0,n.jsxs)(d.PY1.div,{initial:"hidden",animate:"visible",variants:g,className:"space-y-4 px-2",children:[(0,n.jsxs)("nav",{"aria-label":"檢視",className:"space-y-0.5",children:[(0,n.jsx)("div",{className:(0,S.cn)(C,"mb-1 px-2"),children:"檢視"}),(0,n.jsxs)("button",{type:"button","aria-current":"board"===s?"page":void 0,onClick:()=>r("board"),className:(0,S.cn)(s0,"focus-visible:ring-[3px] focus-visible:ring-ring/50",s1("board"===s)),children:[(0,n.jsx)(sJ.A,{className:"size-4 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"看板"}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:a})]}),(0,n.jsxs)("button",{type:"button","aria-current":"github"===s?"page":void 0,onClick:()=>r("github"),className:(0,S.cn)(s0,"focus-visible:ring-[3px] focus-visible:ring-ring/50",s1("github"===s)),children:[(0,n.jsx)(sZ.A,{className:"size-4 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Issues & PRs"}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i??"—"})]})]}),(0,n.jsxs)("div",{className:"space-y-0.5",children:[(0,n.jsxs)("div",{className:(0,S.cn)(C,"mb-1 flex items-center px-2"),children:[(0,n.jsx)("span",{className:"flex-1",children:"專案"}),(0,n.jsx)("span",{className:"normal-case tracking-normal text-muted-foreground/70",children:"Issue \xb7 PR"})]}),0===l.length?(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground",children:"尚無專案"}):l.map(e=>{let t="github"===s&&o===e.name;return(0,n.jsxs)("button",{type:"button","aria-pressed":t,title:null===e.issues?`${e.name}(沒有 GitHub origin 或尚未載入)`:`只看 ${e.name} 的 Issue 與 PR`,onClick:()=>u(t?null:e.name),className:(0,S.cn)(s0,"focus-visible:ring-[3px] focus-visible:ring-ring/50",s1(t)),children:[(0,n.jsx)(tx.A,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:null===e.issues||null===e.prs?"—":`${e.issues} \xb7 ${e.prs}`})]},e.name)})]})]},"expanded-nav")}),(0,n.jsx)(s2,{collapsed:e,onRemoteShare:x,remoteActive:f,onOpenSettings:h})]})}var s4=s(32310);function s6({item:e,className:t}){if("issue"===e.kind)return(0,n.jsx)(f.A,{className:(0,S.cn)("size-3 shrink-0 text-success",t)});let s="draft"===e.state?h.A:p.A;return(0,n.jsx)(s,{className:(0,S.cn)("size-3 shrink-0",ek[e.state],t)})}function s7({user:e}){return(0,n.jsx)("span",{title:e.login,className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-accent text-[9px] font-semibold text-foreground",children:e.login.replace(/[^A-Za-z0-9]/g,"").slice(0,2).toUpperCase()||"?"})}function s8({children:e,className:t}){return(0,n.jsx)("span",{className:(0,S.cn)("inline-flex items-center gap-1 rounded-xs bg-accent px-1.5 py-0.5 text-xs leading-4 text-muted-foreground",t),children:e})}function s9({item:e}){return(0,n.jsxs)(n.Fragment,{children:["issue"===e.kind&&e.issueType&&(0,n.jsx)(s8,{className:"font-medium text-foreground",children:e.issueType.name}),"pr"===e.kind&&(0,n.jsx)(s8,{className:(0,S.cn)("font-medium",ek[e.state]),children:ew[e.state]}),"pr"===e.kind&&e.reviewDecision&&eC[e.reviewDecision]&&(0,n.jsx)(s8,{children:eC[e.reviewDecision]}),e.labels.map(e=>(0,n.jsxs)(s8,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))]})}function ne({entry:e,selected:t,onBoard:s,now:r,onSelect:a}){let{item:i}=e,l="pr"===i.kind||i.issueType||i.labels.length>0;return(0,n.jsxs)("button",{type:"button","aria-pressed":t,onClick:a,className:(0,S.cn)("block w-full rounded-md border bg-card p-3 text-left outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",t?"border-primary shadow-[0_0_0_2px] shadow-primary/20":"border-border hover:border-input"),children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(s6,{item:i}),(0,n.jsxs)("span",{className:"min-w-0 truncate",children:[e.projectName," #",i.number]}),s&&(0,n.jsx)("span",{className:"shrink-0 rounded-xs bg-primary/15 px-1.5 py-0.5 font-medium text-primary",children:"已在看板"}),(0,n.jsx)("span",{className:"ml-auto shrink-0",title:ez(i.createdAt),children:eA(i.createdAt,r)})]}),(0,n.jsx)("span",{className:"mt-2 line-clamp-2 text-[15px] font-medium leading-[1.4] text-foreground",children:i.title}),l&&(0,n.jsx)("span",{className:"mt-2 flex flex-wrap gap-1",children:(0,n.jsx)(s9,{item:i})}),(0,n.jsxs)("span",{className:"mt-2.5 flex items-center gap-3 text-xs text-muted-foreground",children:[i.author&&(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,n.jsx)(s7,{user:i.author}),(0,n.jsxs)("span",{className:"truncate",children:[i.author.login," 發起"]})]}),i.assignees.length>0&&(0,n.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:["指派",(0,n.jsx)("span",{className:"flex -space-x-1",children:i.assignees.slice(0,3).map(e=>(0,n.jsx)(s7,{user:e},e.login))})]})]})]})}function nt({label:e,children:t}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:e}),(0,n.jsx)("dd",{className:"min-w-0 text-foreground",children:t})]})}function ns({entry:e,taskId:t,onClose:s,onConvert:r,onOpenTask:a}){let i,{item:l}=e;return(0,n.jsxs)("aside",{"aria-label":`${"issue"===l.kind?"Issue":"PR"} #${l.number} 詳細內容`,className:"flex w-[400px] shrink-0 flex-col border-l border-border bg-card",children:[(0,n.jsxs)("div",{className:"border-b border-border px-5 py-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["issue"===l.kind?(0,n.jsx)(s8,{className:"bg-success/15 font-medium text-success",children:"Open"}):(0,n.jsx)(s8,{className:(0,S.cn)("font-medium",ek[l.state]),children:ew[l.state]}),(0,n.jsxs)("span",{className:"min-w-0 truncate",children:[l.repo," \xb7 ","issue"===l.kind?"Issue":"PR"," #",l.number]}),(0,n.jsx)(z,{"aria-label":"關閉詳細內容",title:"關閉(Esc)",onClick:s,className:"ml-auto",children:(0,n.jsx)(e5.A,{className:"size-4"})})]}),(0,n.jsx)("p",{className:"mt-2 text-[17px] font-semibold leading-[1.4] text-foreground",children:l.title}),(0,n.jsxs)("dl",{className:"mt-3 grid grid-cols-[64px_minmax(0,1fr)] gap-y-1.5 text-xs",children:[(0,n.jsx)(nt,{label:"專案",children:e.projectName}),(0,n.jsx)(nt,{label:"發起人",children:l.author?.login??"—"}),(0,n.jsx)(nt,{label:"指派",children:(i=l.assignees).length?i.map(e=>e.login).join("、"):"—"}),(0,n.jsx)(nt,{label:"建立時間",children:ez(l.createdAt)}),"issue"===l.kind&&(0,n.jsx)(nt,{label:"Issue Type",children:l.issueType?.name??"—"}),"pr"===l.kind&&(0,n.jsx)(nt,{label:"分支",children:(0,n.jsxs)("span",{className:"break-all",children:[l.headRefName," → ",l.baseRefName]})}),"pr"===l.kind&&l.reviewDecision&&(0,n.jsx)(nt,{label:"Review",children:eC[l.reviewDecision]??l.reviewDecision}),l.labels.length>0&&(0,n.jsx)(nt,{label:"Labels",children:(0,n.jsx)("span",{className:"flex flex-wrap gap-1",children:l.labels.map(e=>(0,n.jsxs)(s8,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))})}),l.milestone&&(0,n.jsx)(nt,{label:"Milestone",children:l.milestone})]})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:l.body.trim()?(0,n.jsx)(e1,{source:l.body,compact:!0}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"沒有內文"})}),(0,n.jsxs)("div",{className:"flex items-center gap-2 border-t border-border px-5 py-4",children:[(0,n.jsxs)(tb,{variant:"outline",size:"sm",className:"text-[13px]",onClick:()=>void ef(l.url),children:[(0,n.jsx)(ti.A,{}),"在 GitHub 開啟"]}),t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tb,{variant:"ghost",size:"sm",className:"ml-auto text-[13px]",onClick:r,title:"已經有對應卡片,仍可再建一張",children:"再建一張"}),(0,n.jsxs)(tb,{size:"sm",className:"text-[13px]",onClick:()=>a(t),children:[(0,n.jsx)(s4.A,{}),"前往卡片"]})]}):(0,n.jsxs)(tb,{size:"sm",className:"ml-auto text-[13px]",onClick:r,children:[(0,n.jsx)(w.A,{}),"轉為 Backlog 卡片"]})]})]})}function nn({children:e,action:t}){return(0,n.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[(0,n.jsx)("p",{className:"max-w-md",children:e}),t]})}function nr({label:e,entries:t,empty:s,selectedKey:r,boardCards:a,now:i,onSelect:l}){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)("h2",{className:C,children:e}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:t.length})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto rounded-md p-1",children:0===t.length?(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/60",children:s}):t.map(e=>{let t=eS(e.item);return(0,n.jsx)(ne,{entry:e,selected:t===r,onBoard:a.has(t),now:i,onSelect:()=>l(t)},t)})})]})}function na(e,t){return t.item.createdAt.localeCompare(e.item.createdAt)}function ni({view:e,onViewChange:t,inbox:s,loading:a,error:i,onRefresh:l,projectFilter:o,onProjectFilterChange:c,boardCards:d,onConvert:u,onOpenTask:m,onOpenSettings:x}){let f,[h,p]=(0,r.useState)(null),g=function(){let[e,t]=(0,r.useState)(()=>Date.now());return(0,r.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),3e4);return()=>clearInterval(e)},[3e4]),e}(),b=s?.status==="ok"?s.repos:[],j=Array.from(new Set(b.map(e=>e.projectName))).sort((e,t)=>e.localeCompare(t)),v=o?b.filter(e=>e.projectName===o):b,N=v.flatMap(e=>e.issues.map(t=>({item:t,projectName:e.projectName,projectPath:e.projectPath}))).sort(na),y=v.flatMap(e=>e.prs.map(t=>({item:t,projectName:e.projectName,projectPath:e.projectPath}))).sort(na),k=v.filter(e=>e.error),w=[...N,...y].find(e=>eS(e.item)===h)??null,C=s?.fetchedAt??0,A=C?`${eA(new Date(C).toISOString(),g)}更新`:null;return f=s?"gh-missing"===s.status?(0,n.jsx)(nn,{children:"找不到 GitHub CLI(gh)。安裝後按右上角的重新整理,就能看到指派給你或你建立的 Issue 與 PR。"}):"unauthenticated"===s.status?(0,n.jsx)(nn,{action:(0,n.jsx)(tb,{size:"sm",onClick:x,children:"開啟設定登入 GitHub"}),children:"GitHub CLI 尚未登入。"}):0===b.length?(0,n.jsx)(nn,{children:"看板上的專案都沒有 GitHub 的 origin,因此沒有可顯示的 Issue 或 PR。"}):(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-5 pb-4 pt-3",children:[k.length>0&&(0,n.jsx)("div",{role:"alert",className:"shrink-0 space-y-1 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k.map(e=>(0,n.jsxs)("p",{className:"truncate",title:e.error,children:[e.repo,":",e.error]},e.repo))}),(0,n.jsxs)("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-4",children:[(0,n.jsx)(nr,{label:"Issues",entries:N,empty:"沒有指派給你或你建立的 open Issue",selectedKey:h,boardCards:d,now:g,onSelect:p}),(0,n.jsx)(nr,{label:"Pull Requests",entries:y,empty:"沒有指派給你、你建立或請你 review 的 open PR",selectedKey:h,boardCards:d,now:g,onSelect:p})]})]}):a?(0,n.jsx)(nn,{children:"讀取 GitHub 中…"}):i?(0,n.jsx)(nn,{children:i}):null,(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",onKeyDown:e=>{"Escape"===e.key&&h&&(e.stopPropagation(),p(null))},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)(P,{value:e,onChange:t}),(0,n.jsx)("span",{className:"h-4 w-px bg-border"}),(0,n.jsx)(eq,{projects:j,value:o,onChange:c}),(0,n.jsxs)("span",{className:"ml-auto min-w-0 truncate text-sm text-muted-foreground",children:[s?.login?`${s.login} \xb7 指派給我、我建立的`:"指派給我、我建立的",A?` \xb7 ${A}`:""]}),(0,n.jsx)(z,{"aria-label":"重新整理 Issue 與 PR",title:"重新整理",onClick:l,disabled:a,children:(0,n.jsx)(th.A,{className:(0,S.cn)("size-4",a&&"animate-spin motion-reduce:animate-none")})})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,n.jsx)("div",{className:"flex min-w-0 flex-1 flex-col",children:f}),w&&(0,n.jsx)(ns,{entry:w,taskId:d.get(eS(w.item)),onClose:()=>p(null),onConvert:()=>u(w.item,w.projectPath),onOpenTask:m},eS(w.item))]})]})}function nl({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,S.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,S.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,S.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,S.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)(e5.A,{className:"size-3"})})]},e.taskId)})})}var no=s(4504);function nc({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)(te,{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)(no.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)(k.A,{className:"size-3.5"}):(0,n.jsx)(eJ.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(tb,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function nd({toast:e,onOpen:t,onDismiss:s}){return(0,r.useEffect)(()=>{let t=setTimeout(()=>s(e.id),6e3);return()=>clearTimeout(t)},[e.id,s]),(0,n.jsxs)(d.PY1.li,{layout:!0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.15},className:"pointer-events-auto flex w-80 items-start gap-2 rounded-lg border border-border bg-popover p-3 text-popover-foreground shadow-lg",children:[(0,n.jsx)(sM.A,{className:"mt-0.5 size-4 shrink-0 text-primary"}),(0,n.jsxs)("button",{type:"button",onClick:()=>{t(e.taskId),s(e.id)},className:"min-w-0 flex-1 rounded-sm text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:e.body})]}),(0,n.jsx)(z,{"aria-label":"關閉通知",onClick:()=>s(e.id),className:"size-5 p-0.5",children:(0,n.jsx)(e5.A,{className:"size-3.5"})})]})}function nu({toasts:e,onOpen:t,onDismiss:s}){return(0,n.jsx)("ol",{"aria-live":"polite","aria-label":"通知",className:"pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col items-end gap-2",children:(0,n.jsx)(l.N,{initial:!1,children:e.map(e=>(0,n.jsx)(nd,{toast:e,onOpen:t,onDismiss:s},e.id))})})}function nm(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 nx={backlog:[],in_progress:[],done:[]},nf=["in_progress","backlog","done"];function nh(){let[e,t]=(0,r.useState)(nx),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)({}),[u,m]=(0,r.useState)(sF()),[x,f]=(0,r.useState)([]),[h,p]=(0,r.useState)(!0),[g,b]=(0,r.useState)(""),[j,v]=(0,r.useState)(""),[N,y]=(0,r.useState)(!1),[k,w]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[A,z]=(0,r.useState)(null),[E,P]=(0,r.useState)(!1),[D,M]=(0,r.useState)(null),[L,F]=(0,r.useState)(null),[G,K]=(0,r.useState)(!1),[q,Q]=(0,r.useState)(null),[J,Z]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(!0),[es,en]=(0,r.useState)(null),[er,ea]=(0,r.useState)([]),[ei,el]=(0,r.useState)(null),[eo,ec]=(0,r.useState)(0),[ed,eu]=(0,r.useState)(null),[em,ex]=(0,r.useState)("board"),[ef,eb]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=!0;return $().then(s=>{e&&(s&&(t(s.board),p(s.settings.autoMode),b(s.settings.systemPrompt??""),v(s.settings.workstationPath??""),m(sF(s.settings.notifications))),y(!0))}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let t;return e=({taskId:e,subAgents:t})=>{o(s=>({...s,[e]:t}))},(t=I())?t.onSubAgentsUpdate(e):()=>{}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),p(e.settings.autoMode),b(e.settings.systemPrompt??""),v(e.settings.workstationPath??""),m(sF(e.settings.notifications))},(s=I())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{var e;let t;return e=({taskId:e,progress:t})=>{d(s=>({...s,[e]:t}))},(t=I())?t.onProgressUpdate(e):()=>{}},[]);let ej=e.in_progress.map(e=>e.id).join(",");(0,r.useEffect)(()=>{let e=!0;for(let t of ej?ej.split(","):[])eh(t).then(s=>{e&&s&&d(e=>e[t]?e:{...e,[t]:s})});return()=>{e=!1}},[ej]),(0,r.useEffect)(()=>{let t=new Set(Object.values(e).flat().map(e=>e.id));ea(e=>e.every(e=>t.has(e.taskId))?e:e.filter(e=>t.has(e.taskId))),en(e=>e&&!t.has(e)?null:e)},[e]);let eN=()=>O("選擇專案資料夾"),ey=(e,t)=>{ea(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]}),en(e)},ek=(0,r.useRef)(ey);ek.current=ey;let ew=(0,r.useRef)(es);ew.current=es;let eC=(0,r.useRef)(u);eC.current=u;let eA=(0,r.useCallback)(e=>{f(t=>t.filter(t=>t.id!==e))},[]);(0,r.useEffect)(()=>{var e;let t,s=0;return e=({taskId:e,title:t,notifications:n})=>{let r=eC.current;if(!r.enabled||"visible"===document.visibilityState&&document.hasFocus()&&ew.current===e)return;let a=n.map(n=>({id:`${Date.now()}-${s++}`,taskId:e,title:t,body:function(e){switch(e.kind){case"step_completed":return`完成 ${e.done}/${e.total} — ${e.item??""}`;case"all_completed":return"所有步驟已完成";case"waiting_input":return"permission"===e.waitingFor?"等待你允許權限":"等待你的輸入"}}(n)}));if(f(e=>[...e,...a].slice(-5)),r.desktop&&"u">typeof Notification&&"granted"===Notification.permission&&!document.hasFocus())for(let t of a){let s=new Notification(t.title,{body:t.body,tag:`${e}:${t.body}`});s.onclick=()=>{window.focus(),ek.current(e),s.close()}}},(t=I())?t.onProgressNotify(e):()=>{}},[]);let ez=e=>{ea(t=>t.some(t=>t.taskId===e&&t.preview)?t.map(t=>t.taskId===e?{...t,preview:!1}:t):t)},eE=e=>{let t=new Set(e);if(es&&t.has(es)){let e=er.findIndex(e=>e.taskId===es),s=er.slice(e+1).find(e=>!t.has(e.taskId)),n=er.slice(0,Math.max(e,0)).reverse().find(e=>!t.has(e.taskId));en(s?.taskId??n?.taskId??null)}ea(e=>e.filter(e=>!t.has(e.taskId)))},eP=()=>{M(null),el(null),eu(null),ec(e=>e+1),en(null)},eI=async(e,t,s,n)=>{S(!0),z(null);try{await T({systemPrompt:e,workstationPath:t||void 0,autoMode:s,notifications:n}),b(e),v(t),p(s),m(n),w(!1)}catch(e){z(e instanceof Error?e.message:String(e))}finally{S(!1)}},e$=async(e,s,n,r,a,i,l,o,c,d,u)=>{P(!0),M(null);try{let m=await W({title:e,description:s,projectPath:n,baseBranch:r,branch:a||void 0,agentCli:i,model:l||void 0,effort:o,autoMode:c,attachments:d,github:u});m&&(t(m.state.board),eu(null),ey(m.task.id,{pin:!0}))}catch(e){M(e instanceof Error?e.message:String(e))}finally{P(!1)}},eT=async e=>{if(L){K(!0),Q(null);try{let s=await X({taskId:L.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,branch:e.branch});s&&t(s.board),F(null)}catch(e){Q(e instanceof Error?e.message:String(e))}finally{K(!1)}}},eD=async e=>{let s=await ep(e);s&&t(s.board)},e_=async e=>{let s=await eg(e);s&&(t(s.board),eE([e]))},eB=er.flatMap(t=>{for(let s of nf){let n=e[s].find(e=>e.id===t.taskId);if(n)return[{...t,title:n.title,column:s}]}return[]}),eM=function(e,t){let[s,n]=(0,r.useState)(null),[a,i]=(0,r.useState)(!1),[l,o]=(0,r.useState)(null),c=(0,r.useRef)(0),d=(0,r.useCallback)(async e=>{let t=++c.current;i(!0),o(null);try{let s=await _({force:e});t===c.current&&n(s)}catch(e){t===c.current&&o(e instanceof Error?e.message:String(e))}finally{t===c.current&&i(!1)}},[]),u=function(e){let t=new Set;for(let s of Object.values(e))for(let e of s)e.projectPath&&t.add(e.projectPath);return Array.from(t).sort().join("\n")}(e);return(0,r.useEffect)(()=>{t&&d(!1)},[t,u,d]),{inbox:s,loading:a,error:l,refresh:()=>d(!0),reload:()=>d(!1)}}(e,N),eL=function(e,t){let[s,n]=(0,r.useState)({}),a=(0,r.useRef)(0),i=(0,r.useCallback)(async e=>{let t=++a.current;try{let s=await B({force:e});t===a.current&&n(s)}catch{}},[]),l=function(e){let t=[];for(let s of Object.values(e))for(let e of s)t.push([e.id,e.projectPath,e.branch,e.provisionedAt??"",e.github?.number??"",e.outcome?.pr?.number??""].join("|"));return t.sort().join("\n")}(e);return(0,r.useEffect)(()=>{t&&i(!1)},[t,l,i]),{links:s,refresh:()=>i(!0)}}(e,N),eF=[...e.in_progress,...e.backlog,...e.done],eG=function(e){let t=new Map;for(let s of e)s.github&&t.set(eS(s.github),s.id);return t}(eF),eO=eM.inbox?.status==="ok"?eM.inbox.repos:null,eH=eO?eO.reduce((e,t)=>e+t.issues.length+t.prs.length,0):null,eV=Array.from(new Set(eF.map(e=>e.projectName).filter(e=>!!e))).sort((e,t)=>e.localeCompare(t)).map(e=>{let t=eO?.filter(t=>t.projectName===e)??[];return t.length?{name:e,issues:t.reduce((e,t)=>e+t.issues.length,0),prs:t.reduce((e,t)=>e+t.prs.length,0)}:{name:e,issues:null,prs:null}}),eY=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:nm(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;ev(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 R(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=nm(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:nm(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=I())?t.term.onData(e):()=>{}}},[a]),{roomCode:a,peerCount:l,startSharing:()=>{i(String(Math.floor(1e5+9e5*Math.random())))},stopSharing:()=>i(null)}}({board:e,autoMode:h,onStateChange:e=>{t(e),R(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:N?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(s3,{collapsed:ee,onToggleCollapse:()=>et(e=>!e),view:em,onSelectView:ex,taskCount:eF.length,githubCount:eH,projects:eV,activeProject:ef,onSelectProject:e=>{eb(e),ex("github")},onNewTask:eP,remoteActive:!!eY.roomCode,onOpenSettings:()=>{z(null),w(!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)(sw,{tabBar:(0,n.jsx)(nl,{entries:eB,activeTaskId:es,onSelect:ey,onPin:ez,onClose:e=>eE([e])}),onSelectTask:ey,onNewTask:eP,board:e,onBoardChange:e=>{t(e),R(e)},onEditTask:t=>{Q(null),e.backlog.some(e=>e.id===t)&&F(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:eD,onDeleteTask:e_,autoMode:h,workstationPath:j,subAgents:a,progress:c,selectedTaskId:es,onTaskInteract:ez,openTabIds:er.map(e=>e.taskId),initialProjectPath:ei,newTaskDraft:ed,newTaskNonce:eo,view:em,onViewChange:ex,taskLinks:eL.links,githubView:(0,n.jsx)(ni,{view:em,onViewChange:ex,inbox:eM.inbox,loading:eM.loading,error:eM.error,onRefresh:()=>{eM.refresh(),eL.refresh()},projectFilter:ef,onProjectFilterChange:eb,boardCards:eG,onConvert:(e,t)=>{let s;M(null),el(t),eu((s=[e.url,e.body.trim()].filter(Boolean).join("\n\n"),{title:e.title,description:s,..."pr"===e.kind?{branch:e.headRefName,baseBranch:e.baseRefName}:{},github:{kind:e.kind,repo:e.repo,number:e.number,url:e.url}})),ec(e=>e+1),en(null)},onOpenTask:ey,onOpenSettings:()=>{z(null),w(!0)}}),creating:E,createError:D,pickFolder:eN,loadRecentProjects:V,loadGitInfo:H,initRepository:Y,detectAgents:U,onCreateTask:e$})})})]}),(0,n.jsx)(sC,{task:L,defaultAutoMode:h,detectAgents:U,pickFolder:eN,loadRecentProjects:V,loadGitInfo:H,saving:G,error:q,onSubmit:eT,onClose:()=>F(null)}),(0,n.jsx)(sK,{open:k,systemPrompt:g,workstationPath:j,autoMode:h,notifications:u,saving:C,error:A,onSave:eI,onPickFolder:()=>O("選擇工作區資料夾"),onClose:()=>w(!1)}),(0,n.jsx)(l.N,{children:E&&(0,n.jsx)(te,{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)(eR.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:J&&eY.roomCode&&(0,n.jsx)(nc,{roomCode:eY.roomCode,peerCount:eY.peerCount,onClose:()=>Z(!1),onStop:()=>{eY.stopSharing(),Z(!1)}},"remote-share-dialog")}),(0,n.jsx)(nu,{toasts:x,onOpen:e=>ek.current(e),onDismiss:eA})]}):(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(14549)}])}},e=>{e.O(0,[7451,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);