@kw-yeh/vibeflow 4.11.28 → 4.11.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vibeflow.mjs +12 -5
- package/dist/web/404/index.html +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/_next/static/chunks/pages/{home-a8c6396c4ddf261a.js → home-8e76d4b251bec98a.js} +2 -2
- package/dist/web/_next/static/{Zo3ZVJ1bFZjYU3Bt-ZmLO → rb9awHxbd75L3Vz0R-TtG}/_buildManifest.js +1 -1
- package/dist/web/home/index.html +1 -1
- package/package.json +1 -1
- /package/dist/web/_next/static/{Zo3ZVJ1bFZjYU3Bt-ZmLO → rb9awHxbd75L3Vz0R-TtG}/_ssgManifest.js +0 -0
package/dist/vibeflow.mjs
CHANGED
|
@@ -7312,7 +7312,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
7312
7312
|
const p = obj(payload, "payload");
|
|
7313
7313
|
const key = str(p.sessionKey, "sessionKey");
|
|
7314
7314
|
if (!STANDALONE_KEY.test(key)) invalid("invalid standalone terminal key");
|
|
7315
|
-
if (
|
|
7315
|
+
if (p.taskId && p.projectPath) invalid("provide taskId or projectPath, not both");
|
|
7316
7316
|
const saved = listTerminals().find((t) => t.sessionKey === key);
|
|
7317
7317
|
if (saved && (saved.taskId ? saved.taskId !== p.taskId : saved.projectPath !== p.projectPath)) {
|
|
7318
7318
|
invalid("terminal key already belongs to another directory");
|
|
@@ -7325,17 +7325,24 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
7325
7325
|
const task = column === "in_progress" && !requested.worktreePath ? await ensureProvisioned(requested) : requested;
|
|
7326
7326
|
cwd = str(column === "backlog" ? task.projectPath : task.worktreePath ?? task.projectPath, "directory");
|
|
7327
7327
|
projectPath = task.projectPath ?? cwd;
|
|
7328
|
-
} else {
|
|
7328
|
+
} else if (p.projectPath) {
|
|
7329
7329
|
cwd = str(p.projectPath, "projectPath");
|
|
7330
7330
|
projectPath = cwd;
|
|
7331
|
+
} else {
|
|
7332
|
+
cwd = os7.homedir();
|
|
7331
7333
|
}
|
|
7332
7334
|
if (!path23.isAbsolute(cwd) || !fs20.existsSync(cwd) || !fs20.statSync(cwd).isDirectory()) {
|
|
7333
7335
|
invalid("terminal directory must be an existing absolute directory");
|
|
7334
7336
|
}
|
|
7335
|
-
const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || path23.basename(projectPath);
|
|
7336
|
-
saveTerminal({
|
|
7337
|
+
const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ? path23.basename(projectPath) : "~");
|
|
7338
|
+
saveTerminal({
|
|
7339
|
+
sessionKey: key,
|
|
7340
|
+
title,
|
|
7341
|
+
...projectPath ? { projectPath } : {},
|
|
7342
|
+
...p.taskId ? { taskId: p.taskId } : {}
|
|
7343
|
+
});
|
|
7337
7344
|
standaloneTerminals.set(key, cwd);
|
|
7338
|
-
if (!p.taskId) recordRecentProject(getStore(), cwd);
|
|
7345
|
+
if (!p.taskId && projectPath) recordRecentProject(getStore(), cwd);
|
|
7339
7346
|
const cols = typeof p.cols === "number" ? p.cols : void 0;
|
|
7340
7347
|
const rows = typeof p.rows === "number" ? p.rows : void 0;
|
|
7341
7348
|
if (sessions.kind === "pty" && await sessions.isAlive(key)) {
|
package/dist/web/404/index.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=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/517bd79243800caf.css" as="style"/><link rel="stylesheet" href="/_next/static/css/517bd79243800caf.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-30f420d055cbcd0c.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-401e9322101b6533.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/
|
|
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=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/517bd79243800caf.css" as="style"/><link rel="stylesheet" href="/_next/static/css/517bd79243800caf.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-30f420d055cbcd0c.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-401e9322101b6533.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/rb9awHxbd75L3Vz0R-TtG/_buildManifest.js" defer=""></script><script src="/_next/static/rb9awHxbd75L3Vz0R-TtG/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";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":"rb9awHxbd75L3Vz0R-TtG","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=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/517bd79243800caf.css" as="style"/><link rel="stylesheet" href="/_next/static/css/517bd79243800caf.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-30f420d055cbcd0c.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-401e9322101b6533.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/
|
|
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=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/517bd79243800caf.css" as="style"/><link rel="stylesheet" href="/_next/static/css/517bd79243800caf.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-30f420d055cbcd0c.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-401e9322101b6533.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/rb9awHxbd75L3Vz0R-TtG/_buildManifest.js" defer=""></script><script src="/_next/static/rb9awHxbd75L3Vz0R-TtG/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";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":"rb9awHxbd75L3Vz0R-TtG","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
package/dist/web/_next/static/chunks/pages/{home-a8c6396c4ddf261a.js → home-8e76d4b251bec98a.js}
RENAMED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
ℹ️ 終端已結束(exit code: ${t})`);return}0===t?x.writeln("\r\n✅ Agent 執行完成。"):x.writeln(`\r
|
|
6
6
|
⚠️ 連線中斷或異常結束(exit code: ${t})`),x.writeln("\r\nℹ️ 已切回互動終端,可手動輸入命令。"),J()}),x.attachCustomKeyEventHandler(e=>"Enter"!==e.key||!e.shiftKey||!!e.altKey||!!e.ctrlKey||!!e.metaKey||!!e.isComposing||!!V.current||(e.preventDefault(),e.stopPropagation(),"keydown"===e.type&&(G.current?.(),p.term.input(g,"\x1b\r")),!1)),x.onData(e=>{V.current||(G.current?.(),p.term.input(g,e),y())}),x.onScroll(()=>{let e=x.buffer.active;P(e.viewportY<e.baseY)});let y=()=>{clearTimeout(i),i=setTimeout(()=>{p.term.isScrolledBack(g).then(e=>{o||j.current!==x||T(e)})},150)},w=b.current;w?.addEventListener("wheel",y,{capture:!0,passive:!0}),l=()=>w?.removeEventListener("wheel",y,{capture:!0}),r=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{if(!o&&j.current===x)try{let{cols:e,rows:t}=x;if(h(),x.cols===e&&x.rows===t)return;p.term.resize(g,x.cols,x.rows)}catch{}},100)}),b.current&&r.observe(b.current),D.current=!0,Y()})(),()=>{o=!0,D.current=!1,t?.(),n?.(),r?.disconnect(),clearTimeout(a),clearTimeout(i),l?.(),eL(g),j.current?.dispose(),j.current=null}},[e,g,Y,J]),(0,r.useEffect)(()=>{Y()},[i,l,Y]);let q=async t=>{if(!V.current&&D.current&&0!==t.length){G.current?.(),k(!0);try{let s=await tz(t),n=await eR({taskId:e,attachments:s});if(n.length>0){let e=n.map(({path:e})=>`'${e.replace(/'/g,"'\\''")}'`).join(" ");eB(g,`${e} `)}}catch(t){let e=t instanceof Error?t.message:String(t);j.current?.writeln(`\r
|
|
7
7
|
⚠️ 附加檔案失敗:${e}`)}finally{k(!1)}}},X=async()=>{j.current?.scrollToBottom(),P(!1),await eM(g),T(!1),j.current?.focus()};return(0,n.jsxs)("div",{onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&D.current&&(v.current+=1,y(!0)))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect=c||!D.current?"none":"copy")},onDragLeave:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&D.current&&(v.current=Math.max(0,v.current-1),0===v.current&&y(!1)))},onDrop:e=>{e.preventDefault(),v.current=0,y(!1),!c&&D.current&&q(e.dataTransfer.files)},className:(0,z.cn)("flex min-h-36 w-full flex-1 flex-col overflow-hidden transition-colors",p?"bg-background":"rounded-md border border-border bg-card",N&&(p?"bg-primary/5 ring-1 ring-inset ring-primary":"border-primary bg-primary/5")),children:[(0,n.jsxs)("div",{className:(0,z.cn)("flex shrink-0 items-center border-b border-border",p?"h-10 gap-2 px-3":"justify-between bg-muted/50 px-2 py-1"),children:[p?(0,n.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:f}):(0,n.jsx)("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:a??"(no cwd)"}),w?(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)(tS,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void U(),disabled:!a||C||A,title:"捨棄這次執行的程式碼變更與 artifacts 並退回 Backlog,之後按「開始」才會重新啟動 Agent",children:[(0,n.jsx)(tR.A,{className:(0,z.cn)("size-3",C&&"animate-pulse")}),C?"退回中…":"退回 Backlog"]}),u&&(0,n.jsxs)(tS,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void W(),disabled:!a||A||C,title:"只帶入 Agent 設定,不傳入任務內容",children:[(0,n.jsx)(tT.A,{className:(0,z.cn)("size-3",A&&"animate-pulse")}),A?"啟動中…":"啟動 Agent"]})]}),h]}),(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:b,className:"h-full w-full overflow-hidden"}),($||I)&&(0,n.jsxs)(tS,{variant:"secondary",size:"sm",className:"absolute bottom-3 right-5 h-7 px-2 text-xs shadow-md",onClick:()=>void X(),children:[(0,n.jsx)(tD.A,{className:"size-3"}),"回到最新"]})]})]})}var tM=s(41487);let t_=0,tV={micro:.12,standard:.16,spatial:.18},tK={enter:[.2,0,0,1],exit:[.4,0,1,1]};function tG(e,t,s,n=tV[e]){return{duration:t?.01:n,ease:tK[s]}}function tO({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:tG(e,r,"enter",t)}}}function tH({timing:e,enterDuration:t,initialOpacity:s,exitTiming:n="micro",exitDuration:r,transform:a,exitTransform:i=a,reducedMotion:l}){return{...tO({timing:e,enterDuration:t,initialOpacity:s,transform:a,reducedMotion:l}),exit:{opacity:0,...l?{}:i??{},transition:tG(n,l,"exit",r)}}}function tJ({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,tM.tF)(),y=(0,c.I)()??!1,w=i||void 0!==s||void 0!==a||void 0!==u,k="drawer"===x,C=tH({timing:"micro",enterDuration:.14,reducedMotion:y}),S=tH({timing:k?"spatial":"standard",exitTiming:"micro",exitDuration:k?.14:void 0,transform:k?{x:16}:{scale:.98},reducedMotion:y});return(0,r.useEffect)(()=>{j.current=f,v.current=m},[f,m]),(0,r.useEffect)(()=>{let e;return t_+=1,e=!1,()=>{e||(e=!0,t_-=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,z.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:S,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,z.cn)("relative z-10 w-full rounded-lg border bg-card text-card-foreground shadow-lg outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",w&&"flex max-h-[min(90vh,760px)] flex-col overflow-hidden",o),children:w?(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsxs)("div",{className:"flex shrink-0 items-start justify-between gap-4 border-b border-border/70 px-5 py-4",children:[(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("h2",{id:h,className:"truncate text-lg font-semibold tracking-tight",children:e}),s&&(0,n.jsx)("div",{id:p,className:"text-sm leading-5 text-muted-foreground",children:s})]}),(0,n.jsx)($,{"aria-label":`關閉${e}`,onClick:f,disabled:m,className:"mt-0.5 shrink-0 p-1",children:(0,n.jsx)(tv.A,{className:"size-4"})})]}),!i&&(0,n.jsx)("h2",{id:h,className:"sr-only",children:e}),(0,n.jsx)("div",{className:(0,z.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]})})]})}var tU=s(18921),tW=s(79608);let tY={scale:1,x:0,y:0};function tq(e,t,s){return Math.min(s,Math.max(t,e))}function tX({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)(tY),[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:tq(e,-l,l),y:tq(t,-o,o)}},[]),x=(0,r.useCallback)((e,t=0,s=0)=>{c(n=>{let r=tq(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(tY)},[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,z.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,z.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)(tU.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)(tW.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,n.jsx)("p",{className:"px-1 text-xs text-muted-foreground",children:"滑桿或滾輪縮放,放大後可拖曳圖片平移。"})]})}let tQ={claude:"Claude Code",codex:"Codex CLI"},tZ={codex:["gpt-5-codex","gpt-5"]};function t0(e,t){return e.path===t.path&&e.status===t.status&&e.additions===t.additions&&e.deletions===t.deletions&&e.revision===t.revision}let t1=(0,r.lazy)(()=>s.e(1201).then(s.bind(s,31201)).then(e=>({default:e.default}))),t5={task:"任務",spec:"決策",artifacts:"Artifacts",diff:"Git diff"},t2=["task","spec","artifacts","diff"],t3=["task","spec"],t4=["task"],t6={A:"新增",M:"修改",D:"刪除",R:"更名","?":"未追蹤"},t7={image:"截圖",video:"影片",text:"文字",binary:"二進位"},t8="vibeflow:workspace-aside-px",t9="--vf-workspace-aside",se={task:ti.A,spec:tl.A,artifacts:to.A,diff:tc.A},st="vibeflow:workspace-inspector",ss=new Set,sn=null;function sr(){return null===sn&&(sn="rail"===window.localStorage.getItem(st)?"rail":"docked"),sn}function sa(e){for(let t of(sn=e,window.localStorage.setItem(st,e),ss))t()}function si(e){return ss.add(e),()=>{ss.delete(e)}}let sl="(min-width: 1024px)";function so(e){let t=window.matchMedia(sl);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}let sc=!1;function sd(){if(sc)return;sc=!0;let e=Number(window.localStorage.getItem(t8));Number.isFinite(e)&&e>=336&&document.documentElement.style.setProperty(t9,`${e}px`)}function su(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function sm(e){return("image"===e.kind||"video"===e.kind)&&!e.scratch}function sx({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,z.cn)(A,"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 sf={MERGED:"bg-primary/15 text-primary",OPEN:"bg-success/15 text-success",CLOSED:"bg-destructive/15 text-destructive"};function sh({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,z.cn)(A,"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,z.cn)("shrink-0 rounded-xs px-1.5 py-0.5 text-xs font-medium",sf[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 eE(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)(td.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)(tk,{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,z.cn)(A,"flex items-center gap-1.5"),children:[(0,n.jsx)(tu.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,z.cn)(A,"flex items-center gap-1.5"),children:[(0,n.jsx)(tc.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 sp({task:e,column:t,progress:s}){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:"可以編輯分支名稱或基準分支後再開始。"})]}),"auto"===e.effort&&e.jevRoute?.status==="routing"&&(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",role:"status",children:[(0,n.jsx)(y.A,{className:"size-3.5 shrink-0 animate-spin"}),"Jev:",S(e.jevRoute),"(完成後才會啟動 agent)"]}),"auto"===e.effort&&e.jevRoute&&"routing"!==e.jevRoute.status&&(0,n.jsxs)("div",{className:"rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:["Jev effort:",e.jevRoute.effort??"模型預設值",e.jevRoute.reason&&(0,n.jsxs)("p",{children:["自動選擇未完成:",e.jevRoute.reason]})]}),(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)(N.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)(tm.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)(tk,{source:e.description}),"backlog"!==t&&(0,n.jsx)(e3,{progress:"in_progress"===t?s:null,usage:e.usage}),e.outcome&&(0,n.jsx)(sh,{outcome:e.outcome})]})}function sg({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)(tk,{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 sb({taskId:e,artifact:t}){let[s,a]=(0,r.useState)(null),[i,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let s=!0;return a(null),l(!1),eg(e,t.name).then(e=>{s&&a(e?.dataUrl??null)}).catch(()=>{s&&a(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]);let o="video"===t.kind;return!s||i?(0,n.jsx)("div",{className:"flex h-24 items-center justify-center rounded-md border border-border/70 bg-card",children:o?(0,n.jsx)(tx.A,{className:"size-5 text-muted-foreground"}):(0,n.jsx)(to.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)(tf.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 sj({taskId:e,artifact:t,onClose:s}){var a;let[i,l]=(0,r.useState)(void 0),[o,c]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=!0;return l(void 0),c(!1),eg(e,t.name).then(e=>{s&&l(e)}).catch(()=>{s&&l(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]),(0,n.jsx)(tJ,{title:t.name,description:`${t7[t.kind]} \xb7 ${su(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)(y.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)(tX,{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:["無法內嵌預覽的檔案(",su(t.size),")。用 Artifacts 分頁的「開啟資料夾」以系統播放器或編輯器開啟。"]}):(0,n.jsxs)(n.Fragment,{children:[(a=t.name,/\.(md|markdown|mdx)$/i.test(a))?(0,n.jsx)(tk,{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 sv({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(sm),h=t.filter(e=>!sm(e)),p=(0,r.useCallback)(()=>{x(null),eb(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)(tS,{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)(th.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)(tS,{variant:"outline",size:"sm",onClick:p,title:s??"任務的 artifacts 目錄",className:"text-xs",children:[(0,n.jsx)(tp.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:["驗證截圖、錄影與報告可放在上方資料夾,工作暫存可放在其下的 ",(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)(sb,{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:su(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)(tg.A,{className:(0,z.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)(to.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):"video"===e.kind?(0,n.jsx)(tx.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,n.jsx)(tl.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 ",su(e.size)]})]})},e.name))})]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(sj,{taskId:e,artifact:a,onClose:()=>i(null)},`artifact-${e}-${a.name}`)})]})}let sN=(0,r.memo)(function({file:e,showHeader:t=!0}){return(0,n.jsxs)("div",{className:(0,z.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:t6[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)(t1,{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 sy({entry:e,file:t,onClose:s}){return(0,n.jsx)(tJ,{title:e.path,description:(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:t6[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)(y.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)(sN,{file:t,showHeader:!1})})}function sw({diff:e}){return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)($,{"aria-label":"重新整理 Git diff",title:"重新整理(含 fetch origin)",className:"p-1",disabled:e.loading,onClick:e.manualRefresh,children:(0,n.jsx)(tb.A,{className:(0,z.cn)("size-3.5",e.loading&&"animate-spin")})}),e.entries.length>0&&(0,n.jsx)($,{"aria-label":"放大檢視 Git diff",title:"放大檢視(全部展開)",className:"p-1",onClick:e.expand,children:(0,n.jsx)(tj.A,{className:"size-3.5"})})]})}function sk({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)(y.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:t6[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)(tg.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)(sy,{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)($,{"aria-label":"關閉 diff 放大檢視",title:"關閉",onClick:m,children:(0,n.jsx)(tv.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)(y.A,{className:"size-3.5 animate-spin"}),"讀取全部 diff 內容中…"]}):u.map(e=>(0,n.jsx)(sN,{file:e},e.path))})})]})})]})}function sC({task:e,column:t,progress:s,launch:a,onStart:i,onReturnToBacklog:l,onLaunchAgent:o,onComplete:c,onEdit:d,onDelete:u,onInteract:f,active:h=!0}){let[p,g]=(0,r.useState)(null),[b,j]=(0,r.useState)(!1),[v,y]=(0,r.useState)([]),w=(0,r.useId)(),C=`${w}-panel`,S=e=>`${w}-tab-${e}`,A=e.worktreePath??e.projectPath??null,E="in_progress"!==t||e.worktreePath?null:`正在準備工作環境:從最新的 ${e.baseBranch??"基準分支"} 建立分支 ${e.branch} 與 worktree,有 remote 時會一併推送到 origin。第一次開始執行需要幾秒鐘,完成後 agent 會自動啟動…`,P=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),I=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 t0(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&&t0(s,N))return;let n=!0;return eh(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&&t_>0){n&&(s=setTimeout(()=>void a(!1),3e3));return}r=!0;try{let s=await ef(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 ex(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),R=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&&t_>0){r&&s&&(n=setTimeout(()=>void l(),3e3));return}i=!0;try{let t=await ej(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),T=v.filter(sm).length;(0,r.useEffect)(()=>{let s;if("in_progress"!==t)return void y([]);let n=!0,r=!1,a=async()=>{if(r&&t_>0){n&&(s=setTimeout(()=>void a(),3e3));return}r=!0;try{let t=await ep(e.id);n&&y(t)}catch{}finally{n&&(s=setTimeout(()=>void a(),3e3))}};return a(),()=>{n=!1,s&&clearTimeout(s)}},[e.id,t]),(0,r.useEffect)(()=>{if(!b)return;let e=e=>{"Escape"!==e.key||document.querySelector('[role="dialog"][aria-modal="true"]')||j(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[b]);let D="backlog"===t,F=a?.launch,B=a?.nonce??0,L=("done"===t?t3:"backlog"===t?t4:t2).filter(e=>"spec"!==e||R.length>0),M="done"===t&&L.includes("spec")?"spec":L[0],_=p&&L.includes(p)?p:M,V=e=>"artifacts"===e?T:"diff"===e?I.entries.length:0,K=(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=V(e);return(0,n.jsxs)("button",{type:"button",role:"tab",id:S(e),"aria-selected":_===e,"aria-controls":C,onClick:()=>{f?.(),g(e)},className:(0,z.cn)("shrink-0 rounded-sm px-2 py-0.5 text-xs outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",_===e?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground"),children:[t5[e],t>0&&(0,n.jsx)("span",{className:"ml-1 tabular-nums text-muted-foreground/80",children:t})]},e)})}),G="task"===_?(0,n.jsx)(sp,{task:e,column:t,progress:s}):"spec"===_?(0,n.jsx)(sg,{specs:R}):"artifacts"===_?(0,n.jsx)(sv,{taskId:e.id,artifacts:v,artifactsDir:P}):(0,n.jsx)(sk,{taskId:e.id,diff:I}),O=(0,n.jsx)("div",{role:"tabpanel",id:C,"aria-labelledby":S(_),className:"h-full",children:G}),H=(0,r.useSyncExternalStore)(si,sr,()=>"docked"),J=(0,r.useSyncExternalStore)(so,()=>window.matchMedia(sl).matches,()=>!0),U=J&&"docked"===H,[W,Y]=(0,r.useState)(!1),q=U||W,X=(0,n.jsx)(sx,{title:t5[_],count:V(_),actions:(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:["diff"===_&&(0,n.jsx)(sw,{diff:I}),U?(0,n.jsx)($,{"aria-label":"收合側欄",title:"收合成圖示列,讓終端機佔滿寬度",className:"p-1",onClick:()=>sa("rail"),children:(0,n.jsx)(tN.A,{className:"size-3.5"})}):(0,n.jsxs)(n.Fragment,{children:[J&&(0,n.jsx)($,{"aria-label":"固定側欄",title:"固定在終端機旁",className:"p-1",onClick:()=>{Y(!1),sa("docked")},children:(0,n.jsx)(ty.A,{className:"size-3.5"})}),(0,n.jsx)($,{"aria-label":"關閉側欄",className:"p-1",onClick:()=>Y(!1),children:(0,n.jsx)(tv.A,{className:"size-3.5"})})]})]}),children:O}),Q=(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視","aria-orientation":"vertical",className:"flex w-11 shrink-0 flex-col items-center gap-1 border-l border-border bg-card/40 py-1.5",children:L.map(e=>{let t=se[e],s=V(e),r=q&&_===e;return(0,n.jsxs)("button",{type:"button",role:"tab",id:S(e),"aria-selected":r,"aria-controls":C,"aria-label":s>0?`${t5[e]}(${s})`:t5[e],title:t5[e],onClick:()=>{var t;return t=e,void((f?.(),q&&t===_)?U?sa("rail"):Y(!1):(g(t),U||Y(!0)))},className:(0,z.cn)("relative flex size-8 items-center justify-center rounded-md outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",r?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,n.jsx)(t,{className:"size-4"}),s>0&&(0,n.jsx)("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-semibold tabular-nums text-primary-foreground",children:s})]},e)})}),[Z,ee]=(0,r.useState)("idle"),et=(0,r.useRef)(null),es=(0,r.useRef)(null),en=(0,r.useRef)(null);(0,r.useLayoutEffect)(sd,[]);let er=(e,t)=>{let s,n=Math.round(Math.max(336,Math.min(e,Math.max(336,(s=et.current?.clientWidth??0)>0?s-320-10-44:e))));document.documentElement.style.setProperty(t9,`${n}px`),t&&window.localStorage.setItem(t8,String(n))},ea=()=>{if(!en.current)return;en.current=null;let e=es.current?.getBoundingClientRect().width??0;e>0&&er(e,!0)},ei=e=>{let t=es.current?.getBoundingClientRect().width??0;t<=0||er(t+e,!0)},el=b?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>j(!1),className:"rounded-md px-1.5 py-1 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:()=>u(e.id),className:"rounded-md px-1.5 py-1 text-sm text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"確認刪除"})]}):(0,n.jsx)($,{"aria-label":"刪除任務",title:"刪除任務(清理 worktree)",tone:"danger",onClick:()=>j(!0),children:(0,n.jsx)(x.A,{className:"size-4"})});return"in_progress"===t?(0,n.jsx)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:(0,n.jsxs)("main",{ref:et,className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",onPointerDown:()=>Y(!1),children:(0,n.jsx)(tL,{taskId:e.id,cwd:A,launchCommand:F,launchNonce:B,provisionNotice:E,readOnly:!1,onReturnToBacklog:()=>l(e),onLaunchAgent:()=>o(e),onInteract:f,active:h,toolbarStart:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 rounded-xs bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",title:e.branch,children:[(0,n.jsx)(N.A,{className:"size-3 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"truncate",children:e.branch})]}),e.baseBranch&&(0,n.jsxs)("span",{className:"min-w-0 shrink truncate font-mono text-xs text-muted-foreground",title:`基準分支:${e.baseBranch}`,children:["← ",e.baseBranch]}),(0,n.jsx)($,{"aria-label":"copied"===Z?"已複製 worktree 路徑":"error"===Z?"複製 worktree 路徑失敗":"複製 worktree 路徑",title:A??void 0,className:"p-1",disabled:!A,onClick:()=>{A&&navigator.clipboard.writeText(A).then(()=>ee("copied")).catch(()=>ee("error")).finally(()=>window.setTimeout(()=>ee("idle"),1600))},children:"copied"===Z?(0,n.jsx)(k.A,{className:"size-3.5"}):(0,n.jsx)(th.A,{className:"size-3.5"})}),(0,n.jsx)(e1,{progress:s})]}),toolbarEnd:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-border"}),(0,n.jsxs)(tS,{size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:()=>{f?.(),c(e)},title:"標記完成後會清理 PTY 與 worktree",children:[(0,n.jsx)(k.A,{className:"size-3.5"}),"完成"]}),el]})})}),!U&&W&&(0,n.jsx)("aside",{"aria-label":t5[_],onKeyDown:e=>{"Escape"!==e.key||t_>0||Y(!1)},className:"absolute bottom-0 right-0 top-10 z-20 flex w-[min(var(--vf-workspace-aside,24rem),calc(100%-2rem))] flex-col border-l border-border bg-card shadow-xl xl:w-[min(var(--vf-workspace-aside,27rem),calc(100%-2rem))]",children:X})]}),U&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"調整終端機與側邊面板的寬度",tabIndex:0,onPointerDown:e=>{let t=es.current?.getBoundingClientRect().width??0;t<=0||(en.current={x:e.clientX,width:t},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=en.current;t&&er(t.width-(e.clientX-t.x),!1)},onPointerUp:ea,onPointerCancel:ea,onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),ei(24)):"ArrowRight"===e.key&&(e.preventDefault(),ei(-24))},className:"flex 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",children:(0,n.jsx)("span",{className:"h-12 w-0.5 rounded-full bg-input"})}),(0,n.jsx)("aside",{ref:es,className:"flex min-h-0 w-[var(--vf-workspace-aside,24rem)] min-w-0 max-w-[calc(100%-23.375rem)] shrink-0 flex-col bg-card/40 xl:w-[var(--vf-workspace-aside,27rem)]",children:X})]}),Q]})}):(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)(N.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})]})}),D&&(0,n.jsxs)(tS,{size:"sm",variant:"outline",onClick:()=>{f?.(),i(e)},disabled:!A,children:[(0,n.jsx)(tf.A,{className:"size-3.5"}),"開始"]}),"backlog"===t&&(0,n.jsx)($,{"aria-label":"編輯任務",title:"編輯任務",onClick:()=>{f?.(),d(e.id)},children:(0,n.jsx)(m.A,{className:"size-4"})}),el]}),(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:"backlog"===t?(0,n.jsx)(sx,{title:t5.task,children:(0,n.jsx)(sp,{task:e,column:t,progress:s})}):(0,n.jsx)(sx,{heading:K,children:O})})]})}var sS=s(93659);let sA="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 sz=s(81450);let sE=["low","medium","high","xhigh","max","ultra"];[...sE];let s$=["low","medium","high","xhigh"];function sP(e,t){return t?e?.find(e=>e.id===t):e?.find(e=>e.isDefault)}function sI(e,t){if(0===t.length||void 0===e||"auto"===e)return;if(t.includes(e))return e;let s=sE.indexOf(e),n=sE.filter(e=>t.includes(e)),r=n.filter(e=>sE.indexOf(e)<=s);return r.length>0?r[r.length-1]:n[0]}let sR=[{value:"auto",label:"自動",description:"Jev 會依任務與目前模型選擇合適的推理強度。"},{value:"low",label:"快速",description:"適合範圍明確、低風險的小任務。"},{value:"medium",label:"標準",description:"兼顧速度與推理深度,適合一般開發任務。"},{value:"high",label:"深入",description:"適合跨檔案、除錯或需要較多判斷的任務。"},{value:"xhigh",label:"極致",description:"適合高複雜度、長鏈推理或高風險變更。"},{value:"max",label:"最大",description:"最深的推理,適合最困難的問題。"},{value:"ultra",label:"委派",description:"最深推理並自動委派子任務,耗時與用量可能明顯增加。"}],sT="auto";function sD({value:e,onChange:t,levels:s,disabled:r=!1}){let a=sR.filter(e=>"auto"===e.value||s.includes(e.value)),i="auto"===e?e:sI(e,s)??"auto",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)(sz.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.jsx)("p",{className:"text-sm text-muted-foreground",children:0===s.length?"這個 model 不支援調整推理強度,啟動時使用模型預設值。":o.description})]})}var sF=s(37614);function sB({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)(sF.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,z.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,z.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 sL=s(28333);function sM(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function s_(e,t){return!!(t&&e.find(e=>e.path===t)?.missing)}function sV({projectPath:e,recentProjects:t,disabled:s,onSelect:a,onBrowse:i}){let l=e?sM(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=s_(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,z.cn)(sA,"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)($,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",onClick:i,disabled:s,tone:"primary",className:"rounded-md border border-border p-2",children:(0,n.jsx)(tp.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,z.cn)(sA,"min-w-0 flex-1 font-mono text-sm")}),(0,n.jsx)($,{"aria-label":"套用輸入的路徑",title:"套用輸入的路徑",onClick:f,disabled:s||""===m.trim(),className:"rounded-md border border-border p-2",children:(0,n.jsx)(sL.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 sK({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:tO({timing:"standard",transform:{y:-4},reducedMotion:i}),className:r,children:a}):(0,n.jsx)("div",{id:s,className:r,children:a}):null}function sG({attachment:e,id:t,creating:s,animated:r,onRemove:a}){let i=(0,tM.tF)(),l=(0,c.I)()??!1,o=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(sS.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)($,{"aria-label":`移除附件 ${e.name}`,onClick:()=>a(t),disabled:s,className:"p-1",children:(0,n.jsx)(tv.A,{className:"size-3.5"})})]});return r?(0,n.jsx)(d.PY1.li,{initial:"hidden",animate:"visible",exit:"exit",variants:tH({timing:"micro",transform:{y:4},reducedMotion:l}),inert:!i,"aria-hidden":!i||void 0,className:(0,z.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 sO(e){let[t,s]=(0,r.useState)(null);return(0,r.useEffect)(()=>{let t=!1;return ec(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 sH(e,t,s,n,a){var i;let l=(i=sP(e,function(e){let t,s=e.model?.trim();if(!(!s||tZ[(t=e.agentCli)&&t in tQ?t:"claude"]?.includes(s)))return s}({agentCli:t,model:s})),i?.efforts??null??s$);return(0,r.useEffect)(()=>{if(null===e)return;let t=sI(n,l);"auto"!==n&&t&&t!==n&&a(t)},[e,l,n,a]),l}let sJ="__custom__";function sU({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:sP(x,o||void 0)?.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)(tT.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)(y.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:sA,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?sJ:o,onChange:e=>{e.target.value===sJ?m(!0):(m(!1),c(e.target.value))},className:sA,children:[(0,n.jsx)("option",{value:"",children:"使用 CLI 預設模型"}),h.map(e=>(0,n.jsx)("option",{value:e.id,children:e.label},e.id)),(0,n.jsx)("option",{value:sJ,children:"自訂…"})]}),null===d&&(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(y.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:sA})]})]})}function sW({creating:e,error:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,initRepository:o,detectAgents:c,onSubmit:d,onClose:u,inline:m=!1,initialProjectPath:x,defaultAutoMode:f=!0,workstationPath:h}){let[p,g]=(0,r.useState)(1),[b,j]=(0,r.useState)(""),[v,C]=(0,r.useState)(""),[S,A]=(0,r.useState)(null),[E,P]=(0,r.useState)([]),[I,R]=(0,r.useState)(null),[T,D]=(0,r.useState)(!1),[F,B]=(0,r.useState)(!1),[L,M]=(0,r.useState)(""),[_,V]=(0,r.useState)(""),[K,G]=(0,r.useState)(null),[O,H]=(0,r.useState)(!1),[J,U]=(0,r.useState)(0),[W,Y]=(0,r.useState)(!1),[q,X]=(0,r.useState)("claude"),[Q,Z]=(0,r.useState)(""),[ee,et]=(0,r.useState)(sT),es=sO(q),en=sH(es,q,Q,ee,et),[er,ea]=(0,r.useState)(f),[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;H(!1),G(null);let t=setTimeout(()=>{e&&H(!0)},6e3);return c().then(s=>{e&&(clearTimeout(t),G(s),!s.some(e=>"claude"===e.id)&&s.length>0&&X(s[0].id))}),()=>{e=!1,clearTimeout(t)}},[c,J]),(0,r.useEffect)(()=>{2===p&&ep.current?.focus()},[p]),(0,r.useEffect)(()=>{m&&ep.current?.focus()},[]),(0,r.useEffect)(()=>{let e=!0;return a().then(t=>{e&&P(t)}),()=>{e=!1}},[a]);let eb=s_(E,S),ej=async e=>{A(e),R(null),M(""),D(!0);try{let t=await i(e);R(t),M(t?.defaultBase??"")}finally{D(!1)}},ev=async e=>{if(s_(E,e)){A(e),R(null),M("");return}await ej(e)},eN=async()=>{let e=await s();e&&(P(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await ej(e))},ey=async()=>{if(S){B(!0);try{let e=await o(S);R(e),M(e?.defaultBase??"")}finally{B(!1)}}};(0,r.useEffect)(()=>{m&&x&&ev(x)},[]);let ew=I?.isRepo??!1,ek=I?.hasRemote??!1,eC=`${h?.trim()||"~/Desktop"}/${S?sM(S):"<專案名>"}`,eS=!!S&&!eb&&ew&&!T&&!F,eA=b.trim().length>0&&!e&&!em&&(!m||eS),ez=()=>{eA&&S&&d(b.trim(),v.trim(),S,ek&&L||null,_.trim(),q,Q,ee,er,ei.map(({input:e})=>e))},eE=async e=>{ec(null),ex(!0);try{let t=(await tz(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)}},e$=(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)(sV,{projectPath:S,recentProjects:E,disabled:e||F||T,onSelect:e=>void ev(e),onBrowse:()=>void eN()})]}),(0,n.jsx)(sK,{show:T||F,enabled:m,children:(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"size-3 animate-spin"}),F?"初始化 Git…":"偵測 Git 狀態中…"]})}),(0,n.jsx)(sK,{show:!!I&&!eb&&!T&&!F&&!ew,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)(tS,{size:"sm",variant:"outline",onClick:()=>void ey(),disabled:e,className:"rounded-full",children:"初始化 Git"})]})}),(0,n.jsx)(sK,{show:ew&&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)(N.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsx)("select",{name:"base-branch",value:L,onChange:e=>M(e.target.value),className:sA,children:(I?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]})}),(0,n.jsx)(sK,{show:ew&&!ek,enabled:m,children:(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["此 repository 沒有 remote,將以目前分支 (",I?.currentBranch??"HEAD",") 為基準建立本地 worktree。"]})}),(0,n.jsx)(sK,{show: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)(N.A,{className:"size-3"}),"分支名稱 (選填)"]}),(0,n.jsx)("input",{name:"branch",value:_,onChange:e=>V(e.target.value),placeholder:"留空則自動命名,例如 feature/login-fix",className:sA}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:ek?"開始執行時會建立同名分支;若 remote 已有這個分支,則直接取回並接續上面的工作。":"開始執行時會建立同名分支。"})]})}),(0,n.jsx)(sK,{show:ew,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)(ti.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:[ek?"從當下最新的 origin 基準分支":"從基準分支",",在"," ",(0,n.jsx)("code",{className:"text-foreground",children:eC})," ","底下建立這張卡專用的 worktree 與分支,你的專案資料夾本身不會被切換。"]}),ek&&(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。"]})]})]})})]}),eP=(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:()=>Y(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)(w.A,{className:(0,z.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",W&&"rotate-180")})]}),(0,n.jsx)(sK,{show:W,enabled:m,id:ef,className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(sU,{title:"Agent",agents:K,detectTimedOut:O,onRetry:()=>U(e=>e+1),agentCli:q,onAgentChange:e=>{X(e),Z("")},model:Q,onModelChange:Z,models:es})})]}),eI=(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,z.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)(sS.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)(y.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)(sG,{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)($,{"aria-label":"關閉新增任務",onClick:u,disabled:e,className:"p-1",children:(0,n.jsx)(tv.A,{className:"size-4"})})]}),!m&&(0,n.jsxs)("div",{className:"mb-5 flex items-center gap-2",children:[(0,n.jsx)("div",{className:(0,z.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",1===p?"bg-primary text-primary-foreground":"bg-primary/20 text-primary"),children:p>1?(0,n.jsx)(k.A,{className:"size-3.5",strokeWidth:3}):"1"}),(0,n.jsx)("span",{className:(0,z.cn)("text-base tracking-[-0.224px]",1===p?"font-medium text-foreground":"text-muted-foreground"),children:"專案設定"}),(0,n.jsx)("div",{className:(0,z.cn)("h-0.5 flex-1 transition-colors",p>1?"bg-primary/60":"bg-border")}),(0,n.jsx)("div",{className:(0,z.cn)("flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-bold transition-colors",2===p?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"2"}),(0,n.jsx)("span",{className:(0,z.cn)("text-base tracking-[-0.224px]",2===p?"font-medium text-foreground":"text-muted-foreground"),children:"任務內容"})]}),m&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"mb-5 block space-y-1.5",children:[(0,n.jsx)("span",{className:"text-base font-medium",children:"任務標題"}),(0,n.jsx)("input",{ref:ep,name:"task-title",autoComplete:"off",value:b,onChange:e=>j(e.target.value),placeholder:"例如:實作登入頁面",className:(0,z.cn)(sA,"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:[e$,eI]}),(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:v,onChange:e=>C(e.target.value),rows:12,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,z.cn)(sA,"mb-2 min-h-64 flex-1 resize-y")})]}),(0,n.jsx)(sD,{value:ee,onChange:et,levels:en,disabled:e}),(0,n.jsx)(sB,{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:eP})]}),!m&&(0,n.jsxs)("div",{children:[1===p&&(0,n.jsx)("div",{className:"space-y-4",children:e$}),2===p&&(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:b,onChange:e=>j(e.target.value),placeholder:"例如:實作登入頁面",className:sA})]}),(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:v,name:"task-description",autoComplete:"off",onChange:e=>C(e.target.value),rows:4,placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,z.cn)(sA,"resize-y")})]}),(0,n.jsx)(sD,{value:ee,onChange:et,levels:en,disabled:e}),(0,n.jsx)(sB,{value:er,onChange:ea,disabled:e}),eI,eP,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&&b.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)(tS,{variant:"ghost",size:"sm",onClick:u,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(tS,{size:"sm",onClick:ez,disabled:!eA,className:(0,z.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)(y.A,{className:"animate-spin"}),e?"建立任務中…":"建立任務"]})]})]}):1===p?(0,n.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[u&&(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:u,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsx)(tS,{size:"sm",onClick:()=>g(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)(tS,{variant:"ghost",size:"sm",onClick:()=>g(1),disabled:e,className:"rounded-full",children:"← 上一步"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[u&&(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:u,disabled:e,className:"rounded-full",children:"取消"}),(0,n.jsxs)(tS,{size:"sm",onClick:ez,disabled:!eA,className:(0,z.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)(y.A,{className:"animate-spin"}),e?"建立任務中…":"建立任務"]})]})]})]})}let sY="vibeflow:board-split-px";function sq(){let e=Number(window.localStorage.getItem(sY));return Number.isFinite(e)&&e>=180?e:null}function sX({active:e,children:t}){let s=(0,o.E)(),a=(0,c.I)()??!1,i=tO({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,z.cn)("h-full",!e&&"hidden pointer-events-none"),children:t})}function sQ({board:e,onBoardChange:t,onEditTask:s,onTaskDone:a,onDeleteTask:i,onOpenTaskTerminal:o,taskTerminals:m,onShowTaskTerminal:x,autoMode:f,workstationPath:h,progress:p,selectedTaskId:g,onSelectTask:b,onNewTask:j,tabBar:v,onTaskInteract:N,openTabIds:y,initialProjectPath:w,newTaskNonce:k,view:C,onViewChange:S,githubView:A,taskLinks:E,creating:$,createError:P,pickFolder:I,loadRecentProjects:R,loadGitInfo:T,initRepository:D,detectAgents:F,onCreateTask:B}){let[L,M]=(0,r.useState)(new Set),[_,V]=(0,r.useState)({}),K=(0,r.useRef)(_);K.current=_;let G=tO({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:(0,c.I)()??!1}),O=e=>M(t=>t.has(e)?t:new Set(t).add(e)),[H,J]=(0,r.useState)(null),[U,W]=(0,r.useState)(null),Y=async(e,t={})=>{O(e.id),V(s=>({...s,[e.id]:{launch:t,nonce:(s[e.id]?.nonce??0)+1}}))};(0,r.useEffect)(()=>{if(!g||(O(g),_[g]))return;let t=e.in_progress.find(e=>e.id===g);if(!t||null==t.launchedAt||!t.worktreePath)return;let s=!1;return e_(t.id).then(e=>{s||!e||K.current[t.id]||Y(t,{resume:!0})}),()=>{s=!0}},[g]);let q=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}),Y(n)},X=e=>new Promise((t,s)=>{W({task:e,settle:n=>{(W(null),n)?Q(e).then(()=>t(!0),s):t(!1)}})}),Q=async e=>{let s=await em(e.id);if(!s)throw Error("未連線到 VibeFlow core");let n=s.state.board;t({backlog:[s.task,...n.backlog.filter(t=>t.id!==e.id)],in_progress:n.in_progress.filter(t=>t.id!==e.id),done:n.done.filter(t=>t.id!==e.id)})},Z=async e=>{await Y(e,{includeTaskPrompt:!1})},ee=e=>J(e),et=(0,r.useRef)(null),es=(0,r.useRef)(null),[en,er]=(0,r.useState)(sq);(0,r.useLayoutEffect)(()=>{if(null!==en)return;let e=et.current?.clientHeight??0;e>0&&er(Math.max(180,e-260))},[en]);let ea=e=>{let t=et.current?.clientHeight??0;return Math.max(180,Math.min(e,Math.max(180,t>0?t-260:e)))},ei=()=>{es.current&&null!==en&&(es.current=null,window.localStorage.setItem(sY,String(en)))},el=e=>{if(null===en)return;let t=ea(en+e);er(t),window.localStorage.setItem(sY,String(t))};return(0,n.jsxs)("div",{ref:et,className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsx)("div",{style:"github"===C||null===en?void 0:{height:en},className:(0,z.cn)("min-h-0 overflow-hidden border-b border-border","github"===C||null===en?"flex-1":"shrink-0"),children:"github"===C?A:(0,n.jsx)(ta,{board:e,progress:p,selectedTaskId:g??null,onSelectTask:b,onEditTask:s,onDeleteTask:i,onOpenTaskTerminal:o,taskTerminals:m,onShowTaskTerminal:x,onNewTask:j,view:C,onViewChange:S,taskLinks:E})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":"調整看板與工作區的高度",tabIndex:0,onPointerDown:e=>{null!==en&&(es.current={y:e.clientY,height:en},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=es.current;t&&er(ea(t.height+(e.clientY-t.y)))},onPointerUp:ei,onPointerCancel:ei,onKeyDown:e=>{"ArrowUp"===e.key?(e.preventDefault(),el(-24)):"ArrowDown"===e.key&&(e.preventDefault(),el(24))},className:(0,z.cn)("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","github"===C&&"hidden"),children:(0,n.jsx)("span",{className:"h-0.5 w-12 rounded-full bg-input"})}),(0,n.jsxs)("div",{className:(0,z.cn)("flex min-h-0 flex-1 flex-col overflow-hidden","github"===C&&"hidden"),children:[v,(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=g?t.find(({task:e})=>e.id===g):null,a=new Set(y),l=new Set;for(let e of L){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===g;return(0,n.jsx)(sX,{active:a,children:(0,n.jsx)(sC,{task:r.task,column:r.column,active:a,progress:p[r.task.id]??null,launch:_[e],onStart:q,onReturnToBacklog:X,onLaunchAgent:Z,onComplete:ee,onEdit:s,onDelete:i,onInteract:N?()=>N(e):void 0})},e)}),!r&&(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:G,className:"flex h-full overflow-y-auto p-8",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-5xl pb-8",children:(0,n.jsx)(sW,{inline:!0,initialProjectPath:w,creating:$,error:P,pickFolder:I,loadRecentProjects:R,loadGitInfo:T,initRepository:D,detectAgents:F,defaultAutoMode:f,workstationPath:h,onSubmit:B},`${w??"new"}:${k}`)})})]})})()})]}),(0,n.jsx)(l.N,{children:H&&(0,n.jsx)(tJ,{title:"完成任務",onClose:()=>J(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(u.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["完成「",H.title,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除這張卡的 worktree(尚未 commit 的變更會一起消失)、本地分支",H.branch?`「${H.branch}」`:"","與 artifacts, 並把專案切回",H.baseBranch?`「${H.baseBranch}」`:"基準分支","後更新。此操作無法復原,請先確認要保留的變更都已經 commit 或 push。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>J(null),children:"取消"}),(0,n.jsx)(tS,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>{var s;let n;H&&(J(null),s="done",(n={backlog:e.backlog.filter(e=>e.id!==H.id),in_progress:e.in_progress.filter(e=>e.id!==H.id),done:e.done.filter(e=>e.id!==H.id)})[s]=[H,...n[s]],t(n),a(H.id))},children:"完成並清理"})]})]})},"confirm-done-dialog")}),(0,n.jsx)(l.N,{children:U&&(0,n.jsx)(tJ,{title:"退回 Backlog",onClose:()=>U.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:["把「",U.task.title,"」退回 Backlog?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會停止 Agent,並把 worktree 還原到",U.task.baseBranch?`「${U.task.baseBranch}」`:"基準分支","——這張卡在本地的 commit 與未 commit 變更都會消失,artifacts 也會一併刪除。遠端分支不會被改動。此操作無法復原。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>U.settle(!1),children:"取消"}),(0,n.jsx)(tS,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>U.settle(!0),children:"清除並退回"})]})]})},"confirm-return-dialog")})]})}function sZ({sessionKey:e,projectPath:t,displayPath:a,taskId:i,title:l,onStarted:o}){let c=(0,r.useRef)(null),d=(0,r.useRef)(l);d.current=l;let u=(0,r.useRef)(o);return u.current=o,(0,r.useEffect)(()=>{let n,r,a,l,o=!1,m=null;return(async()=>{let[{Terminal:x},{FitAddon:f},{WebLinksAddon:h}]=await Promise.all([s.e(3779).then(s.bind(s,15167)),s.e(5695).then(s.bind(s,95695)),s.e(4847).then(s.bind(s,54847))]);if(o||!c.current)return;let p=new x({fontSize:12,fontFamily:'Menlo, Monaco, "Courier New", monospace',cursorBlink:!0,theme:{background:"#191919",foreground:"#e6e6e6",cursor:"#4c9bf5"},linkHandler:{activate:(e,t)=>t$(t),hover:(e,t)=>tP(p,t),leave:()=>tI(p)}});m=p;let g=new f;p.loadAddon(g),p.loadAddon(new h((e,t)=>t$(t),{hover:(e,t)=>tP(p,t),leave:()=>tI(p)})),p.open(c.current);let b=()=>{if(!c.current||0===c.current.clientWidth||0===c.current.clientHeight)return;g.fit();let e=p.element?.querySelector(".xterm-screen"),t=p.element?.querySelector(".xterm-viewport");if(e&&t){let s=tE(p.cols,e.getBoundingClientRect().width,t.clientWidth);s!==p.cols&&p.resize(s,p.rows)}};if(await document.fonts.ready,await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o)return;b();let j=window.vibeflow;if(!j)return p.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");n=j.term.onData(({sessionKey:t,data:s})=>{t===e&&p.write(s)}),r=j.term.onExit(({sessionKey:t,exitCode:s,intentional:n})=>{t!==e||n||p.writeln(`\r
|
|
8
|
-
ℹ️ 終端已結束(exit code: ${s})`)});try{let s=await eD({sessionKey:e,...i?{taskId:i}:{projectPath:t},title:d.current,cols:p.cols,rows:p.rows});if(!s)throw Error("未連線到 VibeFlow core");if(o)return void eL(e);u.current?.(),s.scrollback&&p.write(s.scrollback),p.onData(t=>eB(e,t)),p.focus()}catch(e){o||p.writeln(`⚠️ 無法開啟終端:${e instanceof Error?e.message:String(e)}`)}a=new ResizeObserver(()=>{clearTimeout(l),l=setTimeout(()=>{var t,s;if(o)return;let n=p.cols,r=p.rows;b(),(n!==p.cols||r!==p.rows)&&(t=p.cols,s=p.rows,R()?.term.resize(e,t,s))},100)}),c.current&&a.observe(c.current)})(),()=>{o=!0,n?.(),r?.(),a?.disconnect(),clearTimeout(l),m?.dispose()}},[e,t,i]),(0,n.jsx)("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden p-2",children:(0,n.jsx)("div",{ref:c,className:"h-full w-full overflow-hidden","aria-label":`終端機:${a??t}`})})}function s0({view:e,onViewChange:t,terminals:s,taskWorktreePaths:a,focusedSessionKey:i,recentProjects:l,onCreate:o,onRename:c,onStarted:d,onClose:u,onBrowse:m}){let[x,f]=(0,r.useState)(!1),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(null),j=s.find(e=>e.sessionKey===g),v=(0,r.useRef)(new Map);return(0,r.useEffect)(()=>{if("terminals"!==e||!i)return;let t=v.current.get(i);t?.scrollIntoView({block:"center"}),t?.focus({preventScroll:!0})},[i,e]),(0,n.jsxs)("div",{className:"@container flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border px-5",children:[(0,n.jsx)(I,{value:e,onChange:t}),(0,n.jsxs)(tS,{size:"sm","aria-label":"新增 Terminal",onClick:()=>f(!0),children:[(0,n.jsx)(C.A,{className:"size-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"新增 Terminal"})]})]}),0===s.length?(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 text-center text-muted-foreground",children:[(0,n.jsx)("p",{children:"尚未開啟 Terminal"}),(0,n.jsx)("p",{className:"text-sm",children:"選擇專案或資料夾,即可在該目錄開啟獨立終端機。"})]}):(0,n.jsx)("div",{className:"terminal-grid-scroll grid min-h-0 w-full flex-1 auto-rows-[480px] grid-cols-1 content-start gap-4 overflow-y-auto p-4 @min-[728px]:grid-cols-2 @min-[1084px]:grid-cols-3",children:s.map(e=>{let t=e.taskId?a[e.taskId]??e.projectPath:e.projectPath;return(0,n.jsxs)("section",{ref:t=>{t?v.current.set(e.sessionKey,t):v.current.delete(e.sessionKey)},tabIndex:-1,"aria-label":`Terminal:${e.title}`,className:(0,z.cn)("flex h-[480px] w-full min-w-0 flex-col overflow-hidden rounded-md border bg-card outline-none",i===e.sessionKey?"border-primary ring-2 ring-primary/30":"border-border"),children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[(0,n.jsx)(s1,{title:e.title,fallback:sM(e.projectPath),onCommit:t=>c(e.sessionKey,t)}),(0,n.jsx)($,{"aria-label":`關閉 Terminal:${e.title}`,title:"關閉並釋放 Terminal",onClick:()=>b(e.sessionKey),className:"size-7 shrink-0",children:(0,n.jsx)(tv.A,{className:"size-4"})})]}),(0,n.jsx)("div",{className:"truncate border-b border-border px-3 py-1 font-mono text-xs text-muted-foreground",title:t,children:t}),(0,n.jsx)(sZ,{sessionKey:e.sessionKey,title:e.title,onStarted:()=>d(e.sessionKey),projectPath:e.projectPath,displayPath:t,taskId:e.taskId})]},e.sessionKey)})}),x&&(0,n.jsx)(tJ,{title:"新增 Terminal",onClose:()=>f(!1),contentClassName:"max-w-lg rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"選擇專案或資料夾"}),(0,n.jsx)(sV,{projectPath:h,recentProjects:l,disabled:!1,onSelect:p,onBrowse:()=>{m().then(e=>{e&&p(e)})}}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>f(!1),children:"取消"}),(0,n.jsx)(tS,{size:"sm",disabled:!h||s_(l,h),onClick:()=>{h&&(o(h),p(null),f(!1))},children:"開啟 Terminal"})]})]})}),j&&(0,n.jsx)(tJ,{title:"關閉 Terminal",onClose:()=>b(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold",children:["關閉「",j.title,"」?"]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"關閉 Terminal 會結束這個 session,正在執行的指令也會中止。"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>b(null),children:"取消"}),(0,n.jsx)(tS,{variant:"destructive",size:"sm",onClick:()=>{u(j.sessionKey),b(null)},children:"確認關閉"})]})]})})]})}function s1({title:e,fallback:t,onCommit:s}){let[a,i]=(0,r.useState)(e),[l,o]=(0,r.useState)(!1),c=l?a:e;return(0,n.jsx)("input",{"aria-label":`編輯 Terminal 標題:${e}`,title:"點擊編輯標題",value:c,onFocus:()=>{i(e),o(!0)},onChange:e=>i(e.target.value),onBlur:()=>{o(!1);let n=a.trim()||t;n!==e&&s(n)},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"min-w-0 flex-1 rounded-sm bg-transparent px-1 text-sm font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function s5({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,v]=(0,r.useState)(""),[k,C]=(0,r.useState)(sT),S=sO(g),A=sH(S,g,j,k,C),[E,$]=(0,r.useState)(!0),[P,I]=(0,r.useState)(null),[R,T]=(0,r.useState)(""),[D,F]=(0,r.useState)(""),[B,L]=(0,r.useState)(null),[M,_]=(0,r.useState)(!1),[V,K]=(0,r.useState)(!1),[G,O]=(0,r.useState)([]),[H,J]=(0,r.useState)(null),[U,W]=(0,r.useState)(!1),[Y,q]=(0,r.useState)(0),[X,Q]=(0,r.useState)(!0),[Z,ee]=(0,r.useState)(!1),et=(0,r.useRef)(null),es=e??et.current;if((0,r.useEffect)(()=>{e&&(et.current=e)},[e]),(0,r.useEffect)(()=>{e&&(f(e.title),p(e.description??""),b(e.agentCli??"claude"),v(e.model??""),C(e.effort??sT),$(e.autoMode??d),I(e.projectPath??null),T(e.baseBranch??""),F(e.branch),L(null),_(!1),K(!1),ee(!1))},[e,d]),(0,r.useEffect)(()=>{if(!e)return;let t=!0;return a().then(e=>{t&&O(e)}),()=>{t=!1}},[e,a]),(0,r.useEffect)(()=>{if(!e?.projectPath)return;let t=!0;return _(!0),i(e.projectPath).then(e=>{t&&L(e)}).finally(()=>{t&&_(!1)}),()=>{t=!1}},[e,i]),(0,r.useEffect)(()=>{if(!e)return;let s=!0;W(!1),J(null);let n=setTimeout(()=>{s&&W(!0)},6e3);return t().then(e=>{s&&(clearTimeout(n),J(e))}),()=>{s=!1,clearTimeout(n)}},[e,t,Y]),!es)return null;let en=!!es.worktreePath,er=x!==es.title||h!==(es.description??"")||g!==(es.agentCli??"claude")||j!==(es.model??"")||k!==(es.effort??sT)||E!==(es.autoMode??d)||V||R!==(es.baseBranch??"")||D.trim()!==es.branch,ea=()=>{o||(er?ee(!0):m())},ei=s_(G,P),el=async(e,t=!1)=>{if(I(e),K(e!==es.projectPath),L(null),!(!t&&s_(G,e))){_(!0);try{let t=await i(e);L(t),T(t?.defaultBase??"")}finally{_(!1)}}},eo=async()=>{let e=await s();e&&(O(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await el(e,!0))},ec=B?.isRepo??!0,ed=B?.hasRemote??!1,eu=V||R!==(es.baseBranch??"")||""!==D.trim()&&D.trim()!==es.branch,em=x.trim().length>0&&!o&&!M&&(!V||ec&&!ei);return(0,n.jsx)(l.N,{children:e&&(0,n.jsxs)(tJ,{title:"編輯任務",description:"更新任務內容與 agent 設定。",saving:o,onClose:ea,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)(tS,{variant:"ghost",size:"sm",onClick:ea,disabled:o,children:"取消"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>{em&&u({title:x.trim(),description:h.trim(),agentCli:g,model:j,effort:k,autoMode:E,...P?{projectPath:P,baseBranch:R||null}:{},branch:D.trim()})},disabled:!em,className:(0,z.cn)(o&&"opacity-80"),children:[o&&(0,n.jsx)(y.A,{className:"animate-spin"}),o?"儲存中…":"儲存變更"]})]})]}),children:[Z&&(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:()=>ee(!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:sA})]}),(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,z.cn)(sA,"resize-y")})]}),(0,n.jsx)(sD,{value:k,onChange:C,levels:A,disabled:o}),(0,n.jsx)(sB,{value:E,onChange:$,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)(tp.A,{className:"size-3"}),"專案資料夾"]}),(0,n.jsx)(sV,{projectPath:P,recentProjects:G,disabled:o||M,onSelect:e=>void el(e),onBrowse:()=>void eo()}),M&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"size-3 animate-spin"}),"偵測 Git 狀態中…"]}),V&&!ei&&!M&&!ec&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"這個資料夾不是 Git repository,請改選一個 Git 專案。"})]}),ec&&ed&&(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)(N.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsxs)("select",{name:"edit-base-branch",value:R,onChange:e=>T(e.target.value),disabled:o||M,className:sA,children:[R&&!(B?.branches??[]).includes(R)&&(0,n.jsx)("option",{value:R,children:R}),(B?.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)(N.A,{className:"size-3"}),"分支名稱"]}),(0,n.jsx)("input",{name:"edit-branch",autoComplete:"off",value:D,onChange:e=>F(e.target.value),placeholder:"例如 feature/login-fix",disabled:o,className:sA}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:"分支會在卡片開始執行時才建立並推到 origin。"})]}),en&&eu&&(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)(w.A,{className:(0,z.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",X&&"rotate-180")})]}),X&&(0,n.jsx)("div",{className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(sU,{title:"Agent",agents:H,detectTimedOut:U,onRetry:()=>q(e=>e+1),agentCli:g,onAgentChange:e=>{b(e),v("")},model:j,onModelChange:v,models:S})})]}),c&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:c})]})]},es.id)})}var s2=s(1896),s3=s(69758),s4=s(87617),s6=s(80802),s7=s(21684),s8=s(37156),s9=s(43812);let ne=[{id:"skill",label:"Skills",hint:"儲存可重複使用的 skill;啟動任務時不會自動載入。import 需選擇含 SKILL.md 的目錄。"},{id:"prompt",label:"Prompts",hint:"儲存可重複使用的文字片段;啟動任務時不會自動加入 prompt。"},{id:"script",label:"Scripts",hint:"儲存可重複使用的腳本;啟動任務時不會把清單寫進 prompt。"}],nt={skill:s7.A,prompt:tl.A,script:b.A};function ns(e,t){return"skill"!==e?"":`---
|
|
8
|
+
ℹ️ 終端已結束(exit code: ${s})`)});try{let s=await eD({sessionKey:e,...i?{taskId:i}:t?{projectPath:t}:{},title:d.current,cols:p.cols,rows:p.rows});if(!s)throw Error("未連線到 VibeFlow core");if(o)return void eL(e);u.current?.(),s.scrollback&&p.write(s.scrollback),p.onData(t=>eB(e,t)),p.focus()}catch(e){o||p.writeln(`⚠️ 無法開啟終端:${e instanceof Error?e.message:String(e)}`)}a=new ResizeObserver(()=>{clearTimeout(l),l=setTimeout(()=>{var t,s;if(o)return;let n=p.cols,r=p.rows;b(),(n!==p.cols||r!==p.rows)&&(t=p.cols,s=p.rows,R()?.term.resize(e,t,s))},100)}),c.current&&a.observe(c.current)})(),()=>{o=!0,n?.(),r?.(),a?.disconnect(),clearTimeout(l),m?.dispose()}},[e,t,i]),(0,n.jsx)("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden p-2",children:(0,n.jsx)("div",{ref:c,className:"h-full w-full overflow-hidden","aria-label":`終端機:${a??t??"~"}`})})}function s0({view:e,onViewChange:t,terminals:s,taskWorktreePaths:a,focusedSessionKey:i,recentProjects:l,onCreate:o,onRename:c,onStarted:d,onClose:u,onBrowse:m}){let[x,f]=(0,r.useState)(!1),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(null),j=s.find(e=>e.sessionKey===g),v=(0,r.useRef)(new Map);return(0,r.useEffect)(()=>{if("terminals"!==e||!i)return;let t=v.current.get(i);t?.scrollIntoView({block:"center"}),t?.focus({preventScroll:!0})},[i,e]),(0,n.jsxs)("div",{className:"@container flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border px-5",children:[(0,n.jsx)(I,{value:e,onChange:t}),(0,n.jsxs)(tS,{size:"sm","aria-label":"新增 Terminal",onClick:()=>f(!0),children:[(0,n.jsx)(C.A,{className:"size-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"新增 Terminal"})]})]}),0===s.length?(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 text-center text-muted-foreground",children:[(0,n.jsx)("p",{children:"尚未開啟 Terminal"}),(0,n.jsx)("p",{className:"text-sm",children:"選擇專案或資料夾,即可在該目錄開啟獨立終端機;不選則在家目錄開啟。"})]}):(0,n.jsx)("div",{className:"terminal-grid-scroll grid min-h-0 w-full flex-1 auto-rows-[480px] grid-cols-1 content-start gap-4 overflow-y-auto p-4 @min-[728px]:grid-cols-2 @min-[1084px]:grid-cols-3",children:s.map(e=>{let t=e.taskId?a[e.taskId]??e.projectPath:e.projectPath??"~";return(0,n.jsxs)("section",{ref:t=>{t?v.current.set(e.sessionKey,t):v.current.delete(e.sessionKey)},tabIndex:-1,"aria-label":`Terminal:${e.title}`,className:(0,z.cn)("flex h-[480px] w-full min-w-0 flex-col overflow-hidden rounded-md border bg-card outline-none",i===e.sessionKey?"border-primary ring-2 ring-primary/30":"border-border"),children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[(0,n.jsx)(s1,{title:e.title,fallback:e.projectPath?sM(e.projectPath):"~",onCommit:t=>c(e.sessionKey,t)}),(0,n.jsx)($,{"aria-label":`關閉 Terminal:${e.title}`,title:"關閉並釋放 Terminal",onClick:()=>b(e.sessionKey),className:"size-7 shrink-0",children:(0,n.jsx)(tv.A,{className:"size-4"})})]}),(0,n.jsx)("div",{className:"truncate border-b border-border px-3 py-1 font-mono text-xs text-muted-foreground",title:t,children:t}),(0,n.jsx)(sZ,{sessionKey:e.sessionKey,title:e.title,onStarted:()=>d(e.sessionKey),projectPath:e.projectPath,displayPath:t,taskId:e.taskId})]},e.sessionKey)})}),x&&(0,n.jsx)(tJ,{title:"新增 Terminal",onClose:()=>f(!1),contentClassName:"max-w-lg rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"選擇專案或資料夾"}),(0,n.jsx)(sV,{projectPath:h,recentProjects:l,disabled:!1,onSelect:p,onBrowse:()=>{m().then(e=>{e&&p(e)})}}),(0,n.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>f(!1),children:"取消"}),(0,n.jsx)(tS,{variant:"outline",size:"sm",onClick:()=>{o(),p(null),f(!1)},children:"不選專案(家目錄)"}),(0,n.jsx)(tS,{size:"sm",disabled:!h||s_(l,h),onClick:()=>{h&&(o(h),p(null),f(!1))},children:"開啟 Terminal"})]})]})}),j&&(0,n.jsx)(tJ,{title:"關閉 Terminal",onClose:()=>b(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold",children:["關閉「",j.title,"」?"]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"關閉 Terminal 會結束這個 session,正在執行的指令也會中止。"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>b(null),children:"取消"}),(0,n.jsx)(tS,{variant:"destructive",size:"sm",onClick:()=>{u(j.sessionKey),b(null)},children:"確認關閉"})]})]})})]})}function s1({title:e,fallback:t,onCommit:s}){let[a,i]=(0,r.useState)(e),[l,o]=(0,r.useState)(!1),c=l?a:e;return(0,n.jsx)("input",{"aria-label":`編輯 Terminal 標題:${e}`,title:"點擊編輯標題",value:c,onFocus:()=>{i(e),o(!0)},onChange:e=>i(e.target.value),onBlur:()=>{o(!1);let n=a.trim()||t;n!==e&&s(n)},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"min-w-0 flex-1 rounded-sm bg-transparent px-1 text-sm font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function s5({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,v]=(0,r.useState)(""),[k,C]=(0,r.useState)(sT),S=sO(g),A=sH(S,g,j,k,C),[E,$]=(0,r.useState)(!0),[P,I]=(0,r.useState)(null),[R,T]=(0,r.useState)(""),[D,F]=(0,r.useState)(""),[B,L]=(0,r.useState)(null),[M,_]=(0,r.useState)(!1),[V,K]=(0,r.useState)(!1),[G,O]=(0,r.useState)([]),[H,J]=(0,r.useState)(null),[U,W]=(0,r.useState)(!1),[Y,q]=(0,r.useState)(0),[X,Q]=(0,r.useState)(!0),[Z,ee]=(0,r.useState)(!1),et=(0,r.useRef)(null),es=e??et.current;if((0,r.useEffect)(()=>{e&&(et.current=e)},[e]),(0,r.useEffect)(()=>{e&&(f(e.title),p(e.description??""),b(e.agentCli??"claude"),v(e.model??""),C(e.effort??sT),$(e.autoMode??d),I(e.projectPath??null),T(e.baseBranch??""),F(e.branch),L(null),_(!1),K(!1),ee(!1))},[e,d]),(0,r.useEffect)(()=>{if(!e)return;let t=!0;return a().then(e=>{t&&O(e)}),()=>{t=!1}},[e,a]),(0,r.useEffect)(()=>{if(!e?.projectPath)return;let t=!0;return _(!0),i(e.projectPath).then(e=>{t&&L(e)}).finally(()=>{t&&_(!1)}),()=>{t=!1}},[e,i]),(0,r.useEffect)(()=>{if(!e)return;let s=!0;W(!1),J(null);let n=setTimeout(()=>{s&&W(!0)},6e3);return t().then(e=>{s&&(clearTimeout(n),J(e))}),()=>{s=!1,clearTimeout(n)}},[e,t,Y]),!es)return null;let en=!!es.worktreePath,er=x!==es.title||h!==(es.description??"")||g!==(es.agentCli??"claude")||j!==(es.model??"")||k!==(es.effort??sT)||E!==(es.autoMode??d)||V||R!==(es.baseBranch??"")||D.trim()!==es.branch,ea=()=>{o||(er?ee(!0):m())},ei=s_(G,P),el=async(e,t=!1)=>{if(I(e),K(e!==es.projectPath),L(null),!(!t&&s_(G,e))){_(!0);try{let t=await i(e);L(t),T(t?.defaultBase??"")}finally{_(!1)}}},eo=async()=>{let e=await s();e&&(O(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await el(e,!0))},ec=B?.isRepo??!0,ed=B?.hasRemote??!1,eu=V||R!==(es.baseBranch??"")||""!==D.trim()&&D.trim()!==es.branch,em=x.trim().length>0&&!o&&!M&&(!V||ec&&!ei);return(0,n.jsx)(l.N,{children:e&&(0,n.jsxs)(tJ,{title:"編輯任務",description:"更新任務內容與 agent 設定。",saving:o,onClose:ea,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)(tS,{variant:"ghost",size:"sm",onClick:ea,disabled:o,children:"取消"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>{em&&u({title:x.trim(),description:h.trim(),agentCli:g,model:j,effort:k,autoMode:E,...P?{projectPath:P,baseBranch:R||null}:{},branch:D.trim()})},disabled:!em,className:(0,z.cn)(o&&"opacity-80"),children:[o&&(0,n.jsx)(y.A,{className:"animate-spin"}),o?"儲存中…":"儲存變更"]})]})]}),children:[Z&&(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:()=>ee(!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:sA})]}),(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,z.cn)(sA,"resize-y")})]}),(0,n.jsx)(sD,{value:k,onChange:C,levels:A,disabled:o}),(0,n.jsx)(sB,{value:E,onChange:$,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)(tp.A,{className:"size-3"}),"專案資料夾"]}),(0,n.jsx)(sV,{projectPath:P,recentProjects:G,disabled:o||M,onSelect:e=>void el(e),onBrowse:()=>void eo()}),M&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"size-3 animate-spin"}),"偵測 Git 狀態中…"]}),V&&!ei&&!M&&!ec&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:"這個資料夾不是 Git repository,請改選一個 Git 專案。"})]}),ec&&ed&&(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)(N.A,{className:"size-3"}),"基準分支 (Base Branch)"]}),(0,n.jsxs)("select",{name:"edit-base-branch",value:R,onChange:e=>T(e.target.value),disabled:o||M,className:sA,children:[R&&!(B?.branches??[]).includes(R)&&(0,n.jsx)("option",{value:R,children:R}),(B?.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)(N.A,{className:"size-3"}),"分支名稱"]}),(0,n.jsx)("input",{name:"edit-branch",autoComplete:"off",value:D,onChange:e=>F(e.target.value),placeholder:"例如 feature/login-fix",disabled:o,className:sA}),(0,n.jsx)("span",{className:"block text-sm text-muted-foreground",children:"分支會在卡片開始執行時才建立並推到 origin。"})]}),en&&eu&&(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)(w.A,{className:(0,z.cn)("size-4 text-muted-foreground transition-transform motion-reduce:transform-none motion-reduce:transition-none",X&&"rotate-180")})]}),X&&(0,n.jsx)("div",{className:"space-y-4 border-t border-border/50 p-4",children:(0,n.jsx)(sU,{title:"Agent",agents:H,detectTimedOut:U,onRetry:()=>q(e=>e+1),agentCli:g,onAgentChange:e=>{b(e),v("")},model:j,onModelChange:v,models:S})})]}),c&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:c})]})]},es.id)})}var s2=s(1896),s3=s(69758),s4=s(87617),s6=s(80802),s7=s(21684),s8=s(37156),s9=s(43812);let ne=[{id:"skill",label:"Skills",hint:"儲存可重複使用的 skill;啟動任務時不會自動載入。import 需選擇含 SKILL.md 的目錄。"},{id:"prompt",label:"Prompts",hint:"儲存可重複使用的文字片段;啟動任務時不會自動加入 prompt。"},{id:"script",label:"Scripts",hint:"儲存可重複使用的腳本;啟動任務時不會把清單寫進 prompt。"}],nt={skill:s7.A,prompt:tl.A,script:b.A};function ns(e,t){return"skill"!==e?"":`---
|
|
9
9
|
name: ${t}
|
|
10
10
|
description:
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
`}function nn({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([eN(),ez()]);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,z.cn)(sA,"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)(tS,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(tS,{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}),ne.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=nt[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,z.cn)(A,"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)(tS,{variant:"ghost",size:"sm",onClick:()=>{N(`import:${e}`,async()=>{let t=await ev(e);t&&await ey(e,t)})},disabled:null!==l,children:[l===`import:${e}`?(0,n.jsx)(y.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(s8.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:ns(e,""),description:""}),disabled:null!==l,children:[(0,n.jsx)(C.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===ns(e,u.name)?ns(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,z.cn)(sA,"font-mono text-sm")}),"skill"!==e&&(0,n.jsx)("input",{value:u.description,onChange:e=>m({...u,description:e.target.value}),placeholder:"用途說明",className:(0,z.cn)(sA,"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,z.cn)(sA,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(tS,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return N("create",async()=>{await ew(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.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)(tS,{variant:"ghost",size:"sm",onClick:()=>{N(`open:${e.key}`,async()=>{h({entry:e,content:await ek(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.builtin?.modified&&(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>{var t;b!==(t=e.name)?j(t):(j(null),N(`restore:${t}`,()=>eA(t)))},onBlur:()=>j(null),disabled:null!==l,title:"以 VibeFlow 出貨的版本覆蓋(會丟掉你的修改)",children:[l===`restore:${e.name}`?(0,n.jsx)(y.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(s9.A,{className:"size-3.5"}),b===e.name?"確定覆蓋?":"還原預設"]}),e.sourcePath&&(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>{N(`reimport:${e.key}`,async()=>{e.sourcePath&&await ey(e.kind,e.sourcePath)})},disabled:null!==l,title:"從來源重新複製一份快照",children:l===`reimport:${e.key}`?(0,n.jsx)(y.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(tb.A,{className:"size-3.5"})}),(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void N(`delete:${e.key}`,()=>eS(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)(tS,{variant:"ghost",size:"sm",onClick:()=>void N(`restore:${e}`,()=>eA(e)),disabled:null!==l,title:"放回 VibeFlow 出貨的版本",children:[(0,n.jsx)(s9.A,{className:"size-3.5"}),e]},e))]})]})}function nr({output:e,active:t}){let a=(0,r.useRef)(null),i=(0,r.useRef)(null),l=(0,r.useRef)(""),o=(0,r.useRef)(t),c=(0,r.useRef)(e);return o.current=t,c.current=e,(0,r.useEffect)(()=>{let e=!1,t=null,n=null;return Promise.all([s.e(3779).then(s.bind(s,15167)),s.e(5695).then(s.bind(s,95695)),s.e(4847).then(s.bind(s,54847))]).then(([{Terminal:s},{FitAddon:r},{WebLinksAddon:d}])=>{if(e||!a.current)return;let u=new s({convertEol:!0,cursorBlink:!0,fontSize:12,rows:12,theme:{background:"#111827"},linkHandler:{activate:(e,t)=>t$(t),hover:(e,t)=>tP(u,t),leave:()=>tI(u)}}),m=new r;u.loadAddon(m),u.loadAddon(new d((e,t)=>t$(t),{hover:(e,t)=>tP(u,t),leave:()=>tI(u)})),u.open(a.current),m.fit(),(t=new ResizeObserver(()=>m.fit())).observe(a.current),u.onData(e=>{o.current&&Y(e)}),n=u,i.current=u,l.current="",c.current&&(u.write(c.current),l.current=c.current)}),()=>{e=!0,t?.disconnect(),n?.dispose(),i.current=null}},[]),(0,r.useEffect)(()=>{let t=i.current;if(!t)return;e.startsWith(l.current)||(t.reset(),l.current="");let s=e.slice(l.current.length);s&&t.write(s),l.current=e},[e]),(0,n.jsx)("div",{ref:a,className:"h-48 w-full overflow-hidden rounded-sm border border-border bg-[#111827] p-1",tabIndex:0,"aria-label":"Atlassian CLI 登入終端"})}function na(e,t){return e instanceof Error&&e.message?e.message:t}function ni({appVersion:e}){let[t,s]=(0,r.useState)(!1),[a,i]=(0,r.useState)(null),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null);return(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["VibeFlow 版本:",void 0===e?"讀取中…":e?`v${e}`:"無法取得"]}),(0,n.jsxs)(tS,{variant:"outline",size:"sm",disabled:t,onClick:()=>{s(!0),o(null),m(null),B().then(i).catch(e=>{i(null),o(na(e,"無法連線到 npm registry"))}).finally(()=>s(!1))},children:[t?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(tb.A,{}),t?"檢查中…":"檢查更新"]})]}),l&&(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:["檢查更新失敗:",l]}),a?.status==="current"&&(0,n.jsxs)("p",{role:"status",className:"text-sm text-muted-foreground",children:["已是最新版本(v",a.currentVersion,")。"]}),a?.status==="unsupported"&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"目前不是全域 npm 安裝(例如原始碼執行),無法從這裡更新。"}),a?.status==="available"&&(0,n.jsxs)("div",{role:"status",className:"space-y-2 rounded-md border border-border bg-primary/10 p-3 text-sm",children:[(0,n.jsxs)("p",{children:["VibeFlow v",a.latestVersion," 已發布(目前 v",a.currentVersion,")。 按下更新會開啟系統終端機執行更新指令(Windows:",(0,n.jsx)("code",{children:"vibeflow update"}),";其他平台:",(0,n.jsx)("code",{children:"sudo vibeflow update"}),")。安裝完成後 host 會自動重新啟動。"]}),(0,n.jsx)(tS,{size:"sm",disabled:c,onClick:()=>{d(!0),m(null),L().catch(e=>m(na(e,"無法開啟更新終端機"))).finally(()=>d(!1))},children:c?"開啟中…":"更新 VibeFlow"}),u&&(0,n.jsx)("p",{role:"alert",className:"text-destructive",children:u})]})]})}var nl=s(63252);let no={enabled:!0,stepCompleted:!1,allCompleted:!0,waitingInput:!0,desktop:!1};function nc(e){return{...no,...e??{}}}function nd(){return"Notification"in window?Notification.permission:"unsupported"}function nu({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,z.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,z.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 nm({label:e,hint:t,checked:s,disabled:r,onChange:a}){return(0,n.jsxs)("div",{className:(0,z.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)(nu,{checked:s,label:e,disabled:r,onChange:a})]})}function nx({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)(nl.A,{className:"size-4 text-muted-foreground"}),"通知"]}),(0,n.jsx)(nu,{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)(nm,{label:"步驟完成",hint:"待辦清單中每完成一項就通知",checked:e.stepCompleted,disabled:i,onChange:e=>a({stepCompleted:e})}),(0,n.jsx)(nm,{label:"全部步驟完成",checked:e.allCompleted,disabled:i,onChange:e=>a({allCompleted:e})}),(0,n.jsx)(nm,{label:"等待輸入",hint:"Agent 停下來等你回覆或允許權限",checked:e.waitingInput,disabled:i,onChange:e=>a({waitingInput:e})}),(0,n.jsx)(nm,{label:"桌面通知",hint:s?"瀏覽器已封鎖通知,請在瀏覽器的網站設定中允許。":"頁面不在前景時也會跳出系統通知。從瀏覽器網址列「安裝 VibeFlow」後,通知會以 VibeFlow App 顯示,不帶網址。",checked:e.desktop&&!s,disabled:i,onChange:async e=>{if(!e)return a({desktop:!1});a({desktop:await r()})}})]})]})}let nf=[{id:"claude",name:"Claude Code"},{id:"codex",name:"Codex CLI"}],nh={builtin:"內建清單","claude-cli":"Claude Code CLI","codex-app-server":"Codex CLI","codex-cache":"Codex 本機快取"};function np({open:e,systemPrompt:t,workstationPath:s,autoMode:a,notifications:i,jiraStoryPointsFields:o,saving:c,error:d,onSave:m,onPickFolder:x,onClose:f}){let[h,p]=(0,r.useState)(""),[g,b]=(0,r.useState)(void 0),[j,v]=(0,r.useState)(""),[N,w]=(0,r.useState)(!0),[k,C]=(0,r.useState)(i),[S,A]=(0,r.useState)(""),[E,$]=(0,r.useState)(!1),[P,I]=(0,r.useState)({}),[T,F]=(0,r.useState)(null),[B,L]=(0,r.useState)(void 0),[M,_]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)(null),[en,er]=(0,r.useState)(void 0),[ea,ei]=(0,r.useState)(!1),[el,ed]=(0,r.useState)(!1),[eu,em]=(0,r.useState)(null),[ex,ef]=(0,r.useState)("idle"),[eh,ep]=(0,r.useState)(""),[eg,eb]=(0,r.useState)(""),[ej,ev]=(0,r.useState)(null),[eN,ey]=(0,r.useState)(!1),[ew,ek]=(0,r.useState)(null),[eC,eS]=(0,r.useState)("idle"),[eA,ez]=(0,r.useState)(""),[e$,eP]=(0,r.useState)("https://github.com/login/device"),[eI,eR]=(0,r.useState)(null),[eT,eD]=(0,r.useState)(!1),[eF,eB]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(p(t),v(s),w(a),C(i),A(o.join(", ")),$("denied"===nd()||"unsupported"===nd()),ei(!1),_(""),Z(null),L(void 0),V().then(L).catch(e=>{L(null),Z(e instanceof Error?e.message:String(e))}),ed(!1),ef("idle"),ev(null),ep(""),eb(""),J().then(em),eS("idle"),ez(""),eR(null),eB(!1),O().then(ek))},[e,t,s,a,i,o]),(0,r.useEffect)(()=>{if(!e)return;let t=!1;for(let e of(b(void 0),D().then(e=>{t||b(e)}).catch(()=>{t||b(null)}),I({}),er(void 0),eo().then(e=>e.map(e=>e.id)).catch(()=>null).then(e=>{t||er(e)}),nf))ec(e.id).catch(()=>null).then(s=>{t||I(t=>({...t,[e.id]:s}))});return()=>{t=!0}},[e]),(0,r.useEffect)(()=>{if(e)return X(e=>{"starting"===e.type&&(ef("waiting"),ey(!0),ev(null)),"output"===e.type&&eb(t=>(t+e.data).slice(-32e3)),"url"===e.type&&ep(e.url),"success"===e.type&&(em(e.status),ef("idle"),ey(!1)),"signed-out"===e.type&&(em(e.status),ef("idle"),ey(!1)),"cancelled"===e.type&&(ef("idle"),ey(!1)),"error"===e.type&&(ef("error"),ey(!1),ev(e.error))})},[e]);let eL=async e=>{F(e);try{let t=await ec(e,!0).catch(()=>null);I(s=>({...s,[e]:t}))}finally{F(null)}},eM=async()=>{if(M.trim()){Y(!0),Z(null);try{let e=await K(M);if(!e)throw Error("未連線到 VibeFlow core");L(e),_("")}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(!1)}}},e_=async()=>{Y(!0),Z(null);try{let e=await G();if(!e)throw Error("未連線到 VibeFlow core");L(e),_("")}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(!1)}};(0,r.useEffect)(()=>{if(e){var t;let e;return t=e=>{if("starting"===e.type){eS("starting"),eR(null);return}if("code"===e.type){eS("waiting"),ez(e.code),eP(e.url),eB(!1),eD(!1);return}if("success"===e.type){ek(e.status),eS("success"),eD(!1);return}if("cancelled"===e.type){eS("idle"),eD(!1);return}eS("error"),eR(e.error),eD(!1)},(e=R())?e.onGithubAuthEvent(t):()=>{}}},[e]);let[eV,eK]=(0,r.useState)(!1),[eG,eO]=(0,r.useState)(!1),eH=h.trim(),eJ=""===eH,eU=S.split(",").map(e=>e.trim()).filter(Boolean),eW=eU.every(e=>/^customfield_\d+$/.test(e)),eq=!c&&!ea&&!el&&eW,eX=async()=>{let e=await x();e&&v(e)},eQ=async()=>{ei(!0),eS("starting"),ez(""),eR(null),eB(!1),eD(!0);try{await ee()}catch(e){eS("error"),eR(e instanceof Error?e.message:String(e)),eD(!1)}},eZ=async()=>{("starting"===eC||"waiting"===eC)&&await et(),ei(!1),eS("idle"),eD(!1),ez(""),eR(null),eB(!1),ek(await O())},e0=async()=>{eD(!0),eR(null);try{let e=await es();ek(e)}catch(e){eR(e instanceof Error?e.message:String(e))}finally{eD(!1)}},e1=()=>{eN&&W(),ea&&("starting"===eC||"waiting"===eC)&&et(),f()},e5=async()=>{ef("waiting"),ey(!0),ev(null),ep(""),eb("");try{await U()}catch(e){ey(!1),ef("error"),ev(e instanceof Error?e.message:String(e))}},e2=async()=>{eN&&await W(),ed(!1),ey(!1),ef("idle"),em(await J())},e3=async()=>{eA&&(await navigator.clipboard.writeText(eA),eB(!0),window.setTimeout(()=>eB(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(tJ,{title:el?"Atlassian(Jira)":ea?"登入 GitHub CLI":eV?"Library":"設定",description:el?"登入 Atlassian 以讀取指派給你的 Jira ticket。":ea?"使用 GitHub CLI 的網頁授權流程登入 github.com。":eV?"管理 VibeFlow 的 skills、文字片段與腳本;啟動任務時都不會自動載入。":"調整 system prompt 與 agent 帳號連線。",saving:c||eT,onClose:e1,showHeader:!0,contentClassName:"max-w-2xl",footer:el?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void e2(),children:"返回設定"}),(0,n.jsx)(tS,{size:"sm",disabled:c||eN||!eW,onClick:()=>m(eH,j.trim(),N,k,eU),children:"儲存設定"})]}):ea?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void eZ(),disabled:eT&&"success"!==eC,children:"success"===eC?"完成":"返回"}),"error"===eC&&(0,n.jsx)(tS,{size:"sm",onClick:()=>void eQ(),children:"重新登入"})]}):eV?eG?null:(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>eK(!1),children:[(0,n.jsx)(s2.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:e1,disabled:c,children:"取消"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>{eq&&m(eH,j.trim(),N,k,eU)},disabled:!eq,className:(0,z.cn)(c&&"opacity-80"),children:[c&&(0,n.jsx)(y.A,{className:"animate-spin"}),c?"儲存中…":"儲存設定"]})]}),children:el?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void e2(),className:"inline-flex items-center gap-1.5 rounded-sm text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(s2.A,{className:"size-4"}),"返回設定"]}),(0,n.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,n.jsx)("p",{className:"font-medium",children:eu?.installed===!1?"找不到 Atlassian CLI(acli)。":eu?.authenticated?"已登入 Atlassian":"尚未登入 Atlassian。"}),eu?.authenticated&&(0,n.jsxs)("p",{className:"text-muted-foreground",children:[eu.email??"帳號"," \xb7 ",eu.site]}),"waiting"===ex&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"size-4 animate-spin"}),"請在瀏覽器完成授權;若帳號有多個 site,再於下方終端選擇。"]}),ej&&(0,n.jsx)("p",{role:"alert",className:"text-destructive",children:ej})]}),(eN||eg)&&(0,n.jsx)(nr,{output:eg,active:eN}),eu?.installed===!1?(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(tS,{variant:"outline",size:"sm",onClick:()=>void eE("https://developer.atlassian.com/cloud/acli/guides/install-acli/"),children:[(0,n.jsx)(td.A,{}),"安裝說明"]}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>void J().then(em),children:[(0,n.jsx)(tb.A,{}),"重新檢查"]})]}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[eN?(0,n.jsx)(tS,{variant:"outline",size:"sm",onClick:()=>void W(),children:"取消"}):(0,n.jsx)(tS,{size:"sm",onClick:()=>void e5(),children:eu?.authenticated?"重新登入":"使用瀏覽器登入"}),eu?.authenticated&&(0,n.jsxs)(tS,{variant:"outline",size:"sm",disabled:eN,onClick:async()=>{try{em(await q())}catch(e){ev(e instanceof Error?e.message:String(e))}},children:[(0,n.jsx)(s3.A,{}),"登出"]}),eh&&(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>void eE(eh),children:[(0,n.jsx)(td.A,{}),"手動開啟登入頁"]})]}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Story Points 欄位 ID"}),(0,n.jsx)("input",{value:S,onChange:e=>A(e.target.value),placeholder:"customfield_10033, customfield_10016",className:(0,z.cn)(sA,"font-mono text-sm")}),!eW&&(0,n.jsx)("span",{className:"text-destructive",children:"請使用 customfield_12345 格式,以逗號分隔。"})]})]}):ea?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void eZ(),disabled:eT&&"success"!==eC,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)(s2.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"===eC?(0,n.jsx)(eY.A,{className:"mt-0.5 size-5 shrink-0 text-success"}):"error"===eC?(0,n.jsx)(u.A,{className:"mt-0.5 size-5 shrink-0 text-destructive"}):(0,n.jsx)(y.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"===eC?"GitHub CLI 已完成授權":"error"===eC?"GitHub CLI 授權失敗":"waiting"===eC?"等待 GitHub 授權完成":"正在啟動 GitHub CLI 登入"}),(0,n.jsx)("p",{className:"text-sm leading-5 text-muted-foreground",children:"success"===eC?`目前登入帳號:${ew?.login??"GitHub"}`:"error"===eC?eI:"waiting"===eC?"請複製授權碼並開啟 GitHub 授權頁,完成後 VibeFlow 會自動更新狀態。":"VibeFlow 正在背景準備 gh auth login。"})]})]})}),("waiting"===eC||eA)&&(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:eA,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 e3(),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:!eA,children:[(0,n.jsx)(s4.A,{className:"size-4"}),eF?"已複製":"複製"]})]})]}),(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:e$,className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-base outline-none"}),(0,n.jsxs)("button",{type:"button",onClick:()=>void eE(e$),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)(td.A,{className:"size-4"}),"開啟"]})]})]})]})]}):eV?(0,n.jsx)(nn,{onEditingChange:eO}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(ni,{appVersion:g}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(sB,{value:N,onChange:w}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsx)("section",{className:"space-y-2",children:(0,n.jsx)(nx,{value:k,onChange:C,desktopBlocked:E,onRequestDesktop:async()=>{if("unsupported"===nd())return $(!0),!1;let e=await Notification.requestPermission()==="granted";return $(!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,z.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",""===j.trim()?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:""===j.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:j,placeholder:"~/Desktop",onChange:e=>v(e.target.value),className:(0,z.cn)(sA,"font-mono text-sm")}),(0,n.jsx)(tS,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void eX(),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,z.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",eJ?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:eJ?"未設定":"已自訂"})]})}),(0,n.jsx)("textarea",{name:"system-prompt",autoComplete:"off",value:h,onChange:e=>p(e.target.value),rows:10,spellCheck:!1,className:(0,z.cn)(sA,"resize-y font-mono text-sm leading-5")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟動 Agent 時會以此 prompt 作為 system prompt;留空則不附加 system prompt。"})]}),(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:"保存可重複使用的 skills、文字片段與腳本。啟動任務時不會載入或加入 prompt, agent 只會收到 system prompt 與任務內容。"})]}),(0,n.jsxs)(tS,{variant:"secondary",size:"sm",onClick:()=>eK(!0),children:[(0,n.jsx)(s6.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:"Jev 自動選擇 effort"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"任務的 effort 設為 auto 時,Jev 會依目前模型選擇推理強度。金鑰只儲存在本機主機資料目錄,不會放入看板狀態或回傳給瀏覽器。"})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:void 0===B?"讀取金鑰狀態中…":null===B?"無法讀取 Jev 金鑰狀態":"saved"===B.source?"已設定 Jev API key(本機儲存)":"environment"===B.source?"已透過 TYPESAFE_API_KEY 環境變數設定":"尚未設定 Jev API key"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)("input",{type:"password","aria-label":"Jev API key",name:"jev-api-key",autoComplete:"off",spellCheck:!1,value:M,onChange:e=>_(e.target.value),placeholder:"輸入 TypeSafe Jev API key",className:(0,z.cn)(sA,"min-w-48 flex-1 font-mono text-sm")}),(0,n.jsx)(tS,{size:"sm",disabled:H||!M.trim(),onClick:()=>void eM(),children:H?"處理中…":"儲存金鑰"}),B?.source==="saved"&&(0,n.jsx)(tS,{size:"sm",variant:"outline",disabled:H,onClick:()=>void e_(),children:"移除金鑰"})]}),Q&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Q})]}),(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;Jev 自動選擇 effort 使用上方獨立的金鑰。設定 GitHub CLI 以支援本機 GitHub 操作。"})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[nf.map(e=>{let t=P[e.id],s=Array.isArray(en)&&!en.includes(e.id),r=void 0===en||!s&&(void 0===t||t?.pending===!0||T===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)(y.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)(eY.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===en?"偵測 CLI…":s?`未安裝・PATH 中找不到 ${e.id} 指令`:void 0===t?"讀取 model 清單…":t?t.pending?`正在向 ${e.name} 取得 model 清單…`:`${t.models.length} 個 models 可用・來源:${nh[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!==en&&(0,n.jsx)(tS,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",disabled:T===e.id,"aria-label":`向 ${e.name} 重新取得 model 清單`,title:`向 ${e.name} 重新取得 model 清單`,onClick:()=>void eL(e.id),children:(0,n.jsx)(tb.A,{className:(0,z.cn)("size-4",T===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:[ew?.authenticated?(0,n.jsx)(eY.A,{className:"size-4 shrink-0 text-success"}):ew?.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:ew?.authenticated?`${ew.login??"GitHub"} 已授權(${ew.gitProtocol??"https"})`:ew?.installed===!1?"找不到 GitHub CLI(gh)":ew?.error?ew.error:"尚未授權"})]}),ew?.authenticated&&(0,n.jsx)(tS,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:eT,onClick:()=>void eQ(),children:"切換使用者"}),ew?.authenticated&&(0,n.jsxs)(tS,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:eT,onClick:()=>void e0(),children:[eT?(0,n.jsx)(y.A,{className:"size-4 animate-spin"}):(0,n.jsx)(s3.A,{className:"size-4"}),"登出"]}),!ew?.authenticated&&(0,n.jsx)(tS,{type:"button",size:"sm",variant:"outline",disabled:ew?.installed===!1||eT,onClick:()=>void eQ(),children:eT?"啟動中…":"登入"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>ed(!0),className:"flex w-full items-center gap-3 rounded-md border border-border/60 px-3 py-2.5 text-left outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[eu?.authenticated?(0,n.jsx)(eY.A,{className:"size-4 shrink-0 text-success"}):(0,n.jsx)("span",{className:"size-4 shrink-0 rounded-full border border-muted-foreground/50"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-base font-medium",children:"Atlassian(Jira)"}),(0,n.jsx)("span",{className:"block truncate text-sm text-muted-foreground",children:eu?.authenticated?`${eu.email??"帳號"} \xb7 ${eu.site}`:eu?.installed===!1?"找不到 Atlassian CLI(acli)":"尚未登入"})]})]})]}),eI&&!ea&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:eI})]}),d&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:d})]})},"settings-dialog")})}var ng=s(30592),nb=s(79751),nj=s(93202),nv=s(51256);function nN({view:e,onSelectView:t,onNewTask:s,onRemoteShare:r,remoteActive:a,onOpenSettings:i}){return(0,n.jsxs)("aside",{className:"flex w-12 flex-shrink-0 flex-col overflow-hidden border-r border-border bg-card text-card-foreground",children:[(0,n.jsx)("div",{className:"flex h-12 shrink-0 items-center justify-center border-b border-border",children:(0,n.jsx)("img",{src:"/logo.svg",alt:"VibeFlow",className:"size-5"})}),(0,n.jsx)("div",{className:"flex shrink-0 justify-center px-2 pt-3",children:(0,n.jsx)($,{"aria-label":"新增任務",onClick:s,title:"新增任務",className:"size-8 p-1.5",children:(0,n.jsx)(C.A,{className:"size-4"})})}),(0,n.jsxs)("nav",{"aria-label":"檢視",className:"flex flex-1 flex-col items-center gap-1 px-2 py-3",children:[(0,n.jsx)($,{"aria-label":"看板","aria-current":"board"===e?"page":void 0,title:"看板",onClick:()=>t("board"),className:(0,z.cn)("size-8","board"===e&&"text-primary hover:text-primary"),children:(0,n.jsx)(ng.A,{className:"size-4"})}),(0,n.jsx)($,{"aria-label":"工作項目","aria-current":"github"===e?"page":void 0,title:"工作項目",onClick:()=>t("github"),className:(0,z.cn)("size-8","github"===e&&"text-primary hover:text-primary"),children:(0,n.jsx)(nb.A,{className:"size-4"})}),(0,n.jsx)($,{"aria-label":"終端機","aria-current":"terminals"===e?"page":void 0,title:"終端機",onClick:()=>t("terminals"),className:(0,z.cn)("size-8","terminals"===e&&"text-primary hover:text-primary"),children:(0,n.jsx)(b.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"flex flex-col items-center gap-1 border-t border-border p-2",children:[r&&(0,n.jsx)($,{"aria-label":"遠端控制",onClick:r,title:"遠端控制",className:(0,z.cn)("size-8",a&&"text-primary hover:text-primary"),children:(0,n.jsx)(nj.A,{className:"size-4"})}),(0,n.jsx)($,{"aria-label":"設定 System Prompt",onClick:i,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(nv.A,{className:"size-4"})})]})]})}var ny=s(32310),nw=s(2141),nk=s(4792);let nC={assignees:[],authors:[]},nS=":unassigned",nA=(e,t)=>e.localeCompare(t);function nz(e,t){return Array.from(new Set([...e,...t])).sort(nA)}function nE(e,t){return nA(e.projectName,t.projectName)||t.item.number-e.item.number}function n$(e,t,s){return e.flatMap(e=>e[t].map(t=>({item:t,projectName:e.projectName,projectPath:e.projectPath}))).filter(e=>(function(e,t){let{item:s}=e,{assignees:n,authors:r}=t;return(!n.length||!!(0===s.assignees.length?n.includes(nS):s.assignees.some(e=>n.includes(e.login))))&&(!r.length||!!(s.author&&r.includes(s.author.login)))})(e,s)).sort(nE)}function nP({name:e,allLabel:t,icon:s,options:a,value:i,onChange:l,optionLabel:o=e=>e}){let[c,d]=(0,r.useState)(!1),u=e9(c,()=>d(!1)),m=0===i.length?t:1===i.length?o(i[0]):`${e} \xb7 ${i.length}`;return(0,n.jsxs)("div",{ref:u,className:"relative shrink-0",onKeyDown:e=>{"Escape"===e.key&&c&&(e.stopPropagation(),d(!1))},children:[(0,n.jsxs)("button",{type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-label":`${e}篩選:${m}`,onClick:()=>d(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)(s,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"max-w-40 truncate",children:m}),(0,n.jsx)(w.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),c&&(0,n.jsxs)("div",{role:"menu","aria-label":`${e}篩選`,className:"absolute left-0 top-8 z-20 max-h-80 w-56 overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:[(0,n.jsxs)("button",{type:"button",role:"menuitemcheckbox","aria-checked":0===i.length,onClick:()=>l([]),className:(0,z.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",te,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t}),0===i.length&&(0,n.jsx)(k.A,{className:"size-3 shrink-0"})]}),a.map(e=>{let t=i.includes(e);return(0,n.jsxs)("button",{type:"button",role:"menuitemcheckbox","aria-checked":t,onClick:()=>l(i.includes(e)?i.filter(t=>t!==e):[...i,e]),className:(0,z.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",te,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:o(e)}),t&&(0,n.jsx)(k.A,{className:"size-3 shrink-0"})]},e)})]})]})}function nI({item:e,className:t}){if("issue"===e.kind)return(0,n.jsx)(f.A,{className:(0,z.cn)("size-3 shrink-0 text-success",t)});let s="draft"===e.state?h.A:p.A;return(0,n.jsx)(s,{className:(0,z.cn)("size-3 shrink-0",eV[e.state],t)})}function nR({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 nT({children:e,className:t}){return(0,n.jsx)("span",{className:(0,z.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 nD({item:e}){return(0,n.jsxs)(n.Fragment,{children:["issue"===e.kind&&e.issueType&&(0,n.jsx)(nT,{className:"font-medium text-foreground",children:e.issueType.name}),"pr"===e.kind&&(0,n.jsx)(nT,{className:(0,z.cn)("font-medium",eV[e.state]),children:eK[e.state]}),"pr"===e.kind&&e.reviewDecision&&eG[e.reviewDecision]&&(0,n.jsx)(nT,{children:eG[e.reviewDecision]}),e.labels.map(e=>(0,n.jsxs)(nT,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))]})}function nF({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,z.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)(nI,{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:eJ(i.createdAt),children:eH(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)(nD,{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)(nR,{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)(nR,{user:e},e.login))})]})]})]})}function nB({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 nL({entry:e,taskId:t,projects:s,onBrowseProject:a,onClose:i,onConvert:l,onOpenTask:o}){let c,{item:d}=e,[u,m]=(0,r.useState)(null),[x,f]=(0,r.useState)(!1),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(e.projectPath??""),j=async()=>{if(!x&&g){f(!0),p(null);try{m(await l(g))}catch(e){p(e instanceof Error?e.message:String(e))}finally{f(!1)}}},v=u??t;return(0,n.jsx)(tJ,{title:d.title,description:`${d.repo} \xb7 ${"issue"===d.kind?"Issue":"PR"} #${d.number}`,showHeader:!0,saving:x,onClose:i,contentClassName:"max-w-3xl",footer:(0,n.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-2",children:[(0,n.jsxs)(tS,{variant:"outline",size:"sm",onClick:()=>void eE(d.url),children:[(0,n.jsx)(td.A,{}),"在 GitHub 開啟"]}),u&&(0,n.jsx)("span",{className:"text-sm text-success",children:"已建立到 Backlog"}),!e.projectPath&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,n.jsxs)("select",{"aria-label":"建立到專案",value:g,onChange:e=>b(e.target.value),disabled:x,className:"h-9 max-w-56 rounded-md border border-input bg-background px-2 text-sm focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("option",{value:"",children:"選擇本機專案…"}),g&&!s.some(e=>e.path===g)&&(0,n.jsx)("option",{value:g,children:g}),s.map(e=>(0,n.jsxs)("option",{value:e.path,children:[e.name," \xb7 ",e.path]},e.path))]}),(0,n.jsx)($,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",disabled:x,onClick:()=>void a().then(e=>{e&&b(e)}),children:(0,n.jsx)(tp.A,{className:"size-4"})})]}),v?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void j(),disabled:x||!g,title:"已經有對應卡片,仍可再建一張",children:"再建一張"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>o(v),children:[(0,n.jsx)(ny.A,{}),"前往卡片"]})]}):(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm",children:[e.projectPath&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:["建立到:",e.projectName]}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>void j(),disabled:x||!g,children:[x?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(C.A,{}),x?"建立中…":"建立卡片"]})]})]}),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["issue"===d.kind?(0,n.jsx)(nT,{className:"bg-success/15 font-medium text-success",children:"Open"}):(0,n.jsx)(nT,{className:(0,z.cn)("font-medium",eV[d.state]),children:eK[d.state]}),(0,n.jsxs)("span",{className:"min-w-0 truncate",children:[d.repo," \xb7 ","issue"===d.kind?"Issue":"PR"," #",d.number]})]}),(0,n.jsxs)("dl",{className:"mt-3 grid grid-cols-[64px_minmax(0,1fr)] gap-y-1.5 text-xs",children:[(0,n.jsx)(nB,{label:"專案",children:e.projectName}),(0,n.jsx)(nB,{label:"發起人",children:d.author?.login??"—"}),(0,n.jsx)(nB,{label:"指派",children:(c=d.assignees).length?c.map(e=>e.login).join("、"):"—"}),(0,n.jsx)(nB,{label:"建立時間",children:eJ(d.createdAt)}),"issue"===d.kind&&(0,n.jsx)(nB,{label:"Issue Type",children:d.issueType?.name??"—"}),"pr"===d.kind&&(0,n.jsx)(nB,{label:"分支",children:(0,n.jsxs)("span",{className:"break-all",children:[d.headRefName," → ",d.baseRefName]})}),"pr"===d.kind&&d.reviewDecision&&(0,n.jsx)(nB,{label:"Review",children:eG[d.reviewDecision]??d.reviewDecision}),d.labels.length>0&&(0,n.jsx)(nB,{label:"Labels",children:(0,n.jsx)("span",{className:"flex flex-wrap gap-1",children:d.labels.map(e=>(0,n.jsxs)(nT,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))})}),d.milestone&&(0,n.jsx)(nB,{label:"Milestone",children:d.milestone})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:d.body.trim()?(0,n.jsx)(tk,{source:d.body,compact:!0}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"沒有內文"})}),h&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:h})]})})}function nM({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 n_({column:e,selectedKey:t,boardCards:s,now:r,onSelect:a}){return(0,n.jsxs)("section",{"aria-label":e.repo,className:"flex min-h-0 w-[320px] shrink-0 flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 px-1",title:e.repo,children:[(0,n.jsx)("h2",{className:(0,z.cn)(A,"min-w-0 truncate"),children:e.projectName.split("/").pop()}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:e.entries.length})]}),(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto rounded-md p-1",children:e.entries.map(e=>{let i=eO(e.item);return(0,n.jsx)(nF,{entry:e,selected:i===t,onBoard:s.has(i),now:r,onSelect:()=>a(i)},i)})})]})}let nV=e=>e===nS?"未指派":e;function nK({view:e,onViewChange:t,inbox:s,loading:a,error:i,onRefresh:l,filters:o,onFiltersChange:c,boardCards:d,projects:u,onBrowseProject:m,onConvert:x,onOpenTask:f,onOpenSettings:h,sourceKind:p,embedded:g=!1}){let b,j,[v,N]=(0,r.useState)(null),y=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}(),w=s?.status==="ok"?s.repos:[],k={assignees:[nS,...nz((j=w.flatMap(e=>p?e[p]:[...e.issues,...e.prs])).flatMap(e=>e.assignees.map(e=>e.login)),o.assignees.filter(e=>e!==nS))],authors:nz(j.flatMap(e=>e.author?[e.author.login]:[]),o.authors)},C=o.assignees.length>0||o.authors.length>0,S=n$(w,"issues",o),A=n$(w,"prs",o),E=w.filter(e=>e.error),P="issues"===p?S:"prs"===p?A:[...S,...A],R=function(e){let t=new Map;for(let s of e){let e=t.get(s.item.repo);e?e.entries.push(s):t.set(s.item.repo,{repo:s.item.repo,projectName:s.projectName,entries:[s]})}return[...t.values()]}(P),T=P.find(e=>eO(e.item)===v)??null,D=s?.status==="ok"&&null!==v&&null===T;(0,r.useEffect)(()=>{D&&N(null)},[D]);let F=e=>t=>c({...o,[e]:t}),B=s?.fetchedAt??0,L=B?`${eH(new Date(B).toISOString(),y)}更新`:null;return b=s?"gh-missing"===s.status?(0,n.jsx)(nM,{children:"找不到 GitHub CLI(gh)。安裝後按右上角的重新整理,就能看到指派給你或你建立的 Issue 與 PR。"}):"unauthenticated"===s.status?(0,n.jsx)(nM,{action:(0,n.jsx)(tS,{size:"sm",onClick:h,children:"開啟設定登入 GitHub"}),children:"GitHub CLI 尚未登入。"}):0===w.length?(0,n.jsx)(nM,{children:i??"目前沒有與你相關的 open 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:[(E.length>0||i)&&(0,n.jsxs)("div",{role:"alert",className:"shrink-0 space-y-1 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[i&&(0,n.jsx)("p",{children:i}),E.map(e=>(0,n.jsxs)("p",{className:"truncate",title:e.error,children:[e.repo,":",e.error]},e.repo))]}),0===R.length?(0,n.jsx)("p",{className:"px-1 text-sm text-muted-foreground/60",children:C?"沒有符合篩選條件的項目":"prs"===p?"沒有指派給你、你建立、請你 review 或你 review 過的 open PR":"issues"===p?"沒有指派給你或你建立的 open Issue":"目前沒有與你相關的 open Issue 或 PR"}):(0,n.jsx)("div",{className:"flex min-h-0 flex-1 gap-4 overflow-x-auto pb-2",children:R.map(e=>(0,n.jsx)(n_,{column:e,selectedKey:v,boardCards:d,now:y,onSelect:N},e.repo))})]}):a?(0,n.jsx)(nM,{children:"讀取 GitHub 中…"}):i?(0,n.jsx)(nM,{children:i}):null,(0,n.jsxs)("div",{className:(0,z.cn)("flex min-h-0 flex-col bg-background",g?"flex-1":"h-full"),onKeyDown:e=>{"Escape"===e.key&&v&&(e.stopPropagation(),N(null))},children:[(0,n.jsxs)("div",{className:(0,z.cn)("flex shrink-0 items-center gap-3 border-b border-border px-5",g?"h-11":"h-12"),children:[!g&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I,{value:e,onChange:t}),(0,n.jsx)("span",{className:"h-4 w-px bg-border"})]}),"issues"!==p&&(0,n.jsx)(nP,{name:"Assignee",allLabel:"所有 Assignee",icon:nw.A,options:k.assignees,value:o.assignees,onChange:F("assignees"),optionLabel:nV}),"issues"!==p&&(0,n.jsx)(nP,{name:"發起人",allLabel:"所有發起人",icon:nk.A,options:k.authors,value:o.authors,onChange:F("authors")}),C&&(0,n.jsxs)("button",{type:"button",onClick:()=>c(nC),className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 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)(tv.A,{className:"size-3.5 shrink-0"}),"清除篩選"]}),(0,n.jsxs)("span",{className:"ml-auto min-w-0 truncate text-sm text-muted-foreground",children:[s?.login?`${s.login} \xb7 `:"","issues"===p?`${S.length} 筆`:"prs"===p?`${A.length} 筆`:"指派給我、我建立、我 review 的",L?` \xb7 ${L}`:""]}),(0,n.jsx)($,{"aria-label":"重新整理 Issue 與 PR",title:"重新整理",onClick:l,disabled:a,children:(0,n.jsx)(tb.A,{className:(0,z.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:b}),T&&(0,n.jsx)(nL,{entry:T,taskId:d.get(eO(T.item)),projects:u,onBrowseProject:m,onClose:()=>N(null),onConvert:e=>x(T.item,e),onOpenTask:f},eO(T.item))]})]})}var nG=s(85499);function nO(e){return Number(e.split("-").at(-1))||0}function nH(e,t){return e.dueDate?t.dueDate?e.dueDate.localeCompare(t.dueDate)||nO(t.key)-nO(e.key):-1:t.dueDate?1:nO(t.key)-nO(e.key)}let nJ={new:"bg-accent text-muted-foreground",indeterminate:"bg-primary/15 text-primary",done:"bg-success/15 text-success"};function nU(e,t=Date.now()){if(!e)return{text:"無期限",tone:"none",title:""};let s=new Date(`${e.slice(0,10)}T00:00:00`).getTime();if(!Number.isFinite(s))return{text:"無期限",tone:"none",title:""};let n=new Date(t);n.setHours(0,0,0,0);let r=Math.round((s-n.getTime())/864e5);return r<0?{text:`已逾期 ${-r} 天`,tone:"overdue",title:e}:0===r?{text:"今天到期",tone:"today",title:e}:r<=3?{text:`剩 ${r} 天`,tone:"soon",title:e}:{text:`截止 ${new Date(s).getMonth()+1}/${new Date(s).getDate()}`,tone:"normal",title:e}}function nW({inbox:e,loading:t,error:s,scope:a,onScopeChange:i,onRefresh:o,boardCards:c,projects:d,onBrowseProject:u,onCreate:m,onOpenTask:x,onOpenSettings:h}){let[p,g]=(0,r.useState)(null),[b,j]=(0,r.useState)(""),[v,N]=(0,r.useState)(!1),[w,k]=(0,r.useState)(null),[S,A]=(0,r.useState)(null),[E,P]=(0,r.useState)(!1),I=e?.tickets??[],R=function(e){let t=[{name:"To Do",tickets:[]},{name:"In Progress",tickets:[]},{name:"To be Released",tickets:[]},{name:"Done",tickets:[]}];for(let s of e)t["to be released"===s.status.name.toLowerCase()?2:"done"===s.status.category?3:+("new"!==s.status.category)].tickets.push(s);return t.map(e=>({...e,tickets:e.tickets.sort(nH)}))}(I),T=I.find(e=>e.key===p),D=T?c.get(T.key):void 0,F=w??D;(0,r.useEffect)(()=>{p&&e?.status==="ok"&&!T&&g(null)},[p,T,e?.status]);let B=async()=>{if(T&&b&&!v){N(!0),A(null);try{let e=await m(T,b);k(e),P(!1)}catch(e){A(e instanceof Error?e.message:String(e))}finally{N(!1)}}},L=(e,t=!1)=>(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-5 text-center text-sm text-muted-foreground",children:[(0,n.jsx)("p",{className:"max-w-md",children:e}),t&&(0,n.jsx)(tS,{size:"sm",onClick:h,children:"開啟設定"})]});return(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex min-h-11 shrink-0 flex-wrap items-center gap-3 border-b border-border px-5 py-1",children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"抓取範圍"}),(0,n.jsxs)("select",{"aria-label":"Jira 抓取範圍",value:a,onChange:e=>i(e.target.value),className:"h-8 max-w-40 rounded-md border border-input bg-background px-2 text-sm focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("option",{value:"sprint",children:"Active Sprint"}),(0,n.jsx)("option",{value:"all",children:"全部指派給我"})]})]}),(0,n.jsxs)("span",{className:"ml-auto min-w-0 truncate text-sm text-muted-foreground",children:[e?.email??e?.site??"",e?.status==="ok"?` \xb7 ${I.length} 筆`:"",e?.fetchedAt?` \xb7 ${new Date(e.fetchedAt).toLocaleTimeString()} 更新`:""]}),(0,n.jsx)($,{"aria-label":"重新整理 Jira ticket",title:"重新整理 Jira ticket",onClick:o,disabled:t,children:(0,n.jsx)(tb.A,{className:(0,z.cn)("size-4",t&&"animate-spin motion-reduce:animate-none")})})]}),e?.error&&(0,n.jsx)("div",{role:"alert",className:"border-b border-destructive/30 bg-destructive/10 px-5 py-2 text-sm text-destructive",children:e.error}),e?.status==="acli-missing"?L("找不到 Atlassian CLI(acli)。安裝並登入後就能看到指派給你的 Jira ticket。",!0):e?.status==="unauthenticated"?L("尚未登入 Atlassian。",!0):e?e.error&&0===I.length?L(e.error):(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[0===I.length&&(0,n.jsx)("p",{className:"mb-4 text-sm text-muted-foreground",children:"目前沒有符合抓取範圍的 Jira ticket"}),(0,n.jsx)("div",{className:"grid min-h-full min-w-[1040px] grid-cols-4 items-start gap-3",children:R.map(e=>(0,n.jsxs)("section",{"aria-label":`${e.name},${e.tickets.length} 筆`,className:"min-w-0 rounded-md border border-border bg-muted/20 p-2",children:[(0,n.jsxs)("h3",{className:"flex min-w-0 items-center gap-2 px-1 py-1 text-sm font-medium",children:[(0,n.jsx)("span",{className:(0,z.cn)("size-2 shrink-0 rounded-full","To Do"===e.name?"bg-muted-foreground":"Done"===e.name?"bg-success":"bg-primary")}),(0,n.jsx)("span",{className:"min-w-0 truncate",title:e.name,children:e.name}),(0,n.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.tickets.length})]}),(0,n.jsx)("div",{className:"mt-2 space-y-2",children:e.tickets.map(e=>{let t=nU(e.dueDate);return(0,n.jsxs)("button",{type:"button",onClick:()=>{g(e.key),j(""),A(null),k(null),P(!1)},"aria-pressed":e.key===p,className:(0,z.cn)("min-h-32 w-full rounded-md border bg-card p-3 text-left outline-none transition-colors hover:border-input focus-visible:ring-[3px] focus-visible:ring-ring/50",e.key===p?"border-primary":"border-border"),children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(f.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"font-mono tabular-nums",children:e.key}),c.has(e.key)&&(0,n.jsx)("span",{className:"rounded-xs bg-primary/15 px-1.5 py-0.5 text-primary",children:"已在看板"}),(0,n.jsx)("span",{className:(0,z.cn)("ml-auto max-w-[45%] truncate rounded-xs px-1.5 py-0.5",nJ[e.status.category]),children:e.status.name})]}),(0,n.jsx)("span",{className:"mt-2 line-clamp-2 min-h-10 text-[15px] font-medium leading-5",children:e.summary}),(0,n.jsxs)("span",{className:"mt-3 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{children:null===e.storyPoints?"— pt":`◆ ${e.storyPoints} pt`}),(0,n.jsx)("span",{title:t.title,className:(0,z.cn)("overdue"===t.tone&&"text-destructive",("soon"===t.tone||"today"===t.tone)&&"text-warning"),children:t.text})]})]},e.key)})})]},e.name))})]}):L(t?"讀取 Jira 中…":s??"無法讀取 Jira ticket"),(0,n.jsx)(l.N,{children:T&&(0,n.jsx)(tJ,{title:`${T.key} ${T.summary}`,showHeader:!0,saving:v,description:`${T.issueType} \xb7 ${T.status.name}`,onClose:()=>g(null),contentClassName:"max-w-3xl",bodyClassName:"min-h-0",footer:(0,n.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-2",children:[w&&(0,n.jsx)("span",{className:"text-sm text-success",children:"已建立到 Backlog"}),F&&!E?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",title:"已經有對應卡片,仍可再建一張",onClick:()=>{P(!0),k(null),j("")},children:"再建一張"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>{g(null),x(F)},children:[(0,n.jsx)(ny.A,{}),"前往卡片"]})]}):(0,n.jsxs)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("select",{"aria-label":"建立到專案",value:b,onChange:e=>j(e.target.value),disabled:v,className:"h-9 max-w-56 rounded-md border border-input bg-background px-2 text-sm focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("option",{value:"",children:"選擇專案…"}),b&&!d.some(e=>e.path===b)&&(0,n.jsx)("option",{value:b,children:b}),d.map(e=>(0,n.jsxs)("option",{value:e.path,children:[e.name," \xb7 ",e.path]},e.path))]}),(0,n.jsx)($,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",disabled:v,className:"rounded-md border border-border p-2",onClick:()=>void u().then(e=>{e&&j(e)}),children:(0,n.jsx)(tp.A,{className:"size-4"})}),(0,n.jsxs)(tS,{size:"sm",disabled:!b||v,title:b?void 0:"先選擇要建立到哪個專案",onClick:()=>void B(),children:[v?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(C.A,{}),v?"建立中…":"建立卡片"]})]})]}),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("dl",{className:"grid grid-cols-[90px_minmax(0,1fr)] gap-2 text-sm",children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:"編號"}),(0,n.jsx)("dd",{children:(0,n.jsxs)("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",onClick:e=>{e.preventDefault(),eE(T.url)},className:"inline-flex items-center gap-1 text-primary underline outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[T.key,(0,n.jsx)(td.A,{className:"size-3"})]})}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"狀態"}),(0,n.jsx)("dd",{children:T.status.name}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"Story Points"}),(0,n.jsx)("dd",{children:T.storyPoints??"—"}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"期限"}),(0,n.jsx)("dd",{children:nU(T.dueDate).text}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"Sprint"}),(0,n.jsx)("dd",{children:T.sprint??"—"}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"優先度"}),(0,n.jsx)("dd",{children:T.priority??"—"}),T.parentKey&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:"Parent"}),(0,n.jsx)("dd",{children:(0,n.jsxs)("a",{href:`https://${e?.site}/browse/${T.parentKey}`,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),eE(`https://${e?.site}/browse/${T.parentKey}`)},className:"inline-flex items-center gap-1 text-primary underline outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[T.parentKey,(0,n.jsx)(td.A,{className:"size-3"})]})})]})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:T.description?(0,n.jsx)(tk,{source:T.description,compact:!0}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"沒有內文"})}),T.attachments.length>0&&(0,n.jsxs)("section",{className:"border-t border-border pt-4","aria-label":"附件",children:[(0,n.jsxs)("h3",{className:"mb-2 flex items-center gap-2 text-sm font-medium",children:[(0,n.jsx)(nG.A,{className:"size-4"}),"附件 ",(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground",children:T.attachments.length})]}),(0,n.jsx)("ul",{className:"space-y-1.5",children:T.attachments.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,n.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",title:e.filename,onClick:t=>{t.preventDefault(),eE(e.url)},className:"min-w-0 truncate text-primary underline outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:e.filename}),null!==e.size&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:function(e){if(e<1024)return`${e} B`;let t=e<1048576?"KB":e<0x40000000?"MB":"GB";return`${new Intl.NumberFormat("zh-TW",{maximumFractionDigits:1}).format(e/("KB"===t?1024:"MB"===t?1048576:0x40000000))} ${t}`}(e.size)})]},e.id))})]}),S&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:S})]})},T.key)})]})}let nY=[{id:"jira",label:"Jira"},{id:"issues",label:"Issues"},{id:"prs",label:"Pull Requests"}];function nq({view:e,onViewChange:t,tab:s,onTabChange:a,jira:i,github:l,githubFilters:o,onGithubFiltersChange:c,jiraCards:d,githubCards:u,projects:m,onBrowseProject:x,onCreateJira:f,onConvertGithub:h,onOpenTask:p,onOpenSettings:g}){let b=(0,r.useRef)([]),j={jira:i.inbox?.status==="ok"?i.inbox.tickets.length:null,issues:l.inbox?.status==="ok"?l.inbox.repos.reduce((e,t)=>e+t.issues.length,0):null,prs:l.inbox?.status==="ok"?l.inbox.repos.reduce((e,t)=>e+t.prs.length,0):null};return(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsx)("div",{className:"flex h-12 shrink-0 items-center border-b border-border px-5",children:(0,n.jsx)(I,{value:e,onChange:t})}),(0,n.jsx)("div",{role:"tablist","aria-label":"來源",className:"flex h-10 shrink-0 items-stretch gap-5 border-b border-border px-5",children:nY.map((e,t)=>(0,n.jsxs)("button",{ref:e=>{b.current[t]=e},type:"button",role:"tab","aria-selected":s===e.id,tabIndex:s===e.id?0:-1,onKeyDown:e=>((e,t)=>{let s="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0;if(!s)return;e.preventDefault();let n=(t+s+nY.length)%nY.length;b.current[n]?.focus(),a(nY[n].id)})(e,t),onClick:()=>a(e.id),className:(0,z.cn)("-mb-px flex items-center gap-1.5 border-b-2 px-1 text-sm font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",s===e.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:[e.label,null!==j[e.id]&&(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:j[e.id]})]},e.id))}),"jira"===s?(0,n.jsx)(nW,{...i,onRefresh:i.refresh,boardCards:d,projects:m,onBrowseProject:x,onCreate:f,onOpenTask:p,onOpenSettings:g}):(0,n.jsx)(nK,{view:e,onViewChange:t,inbox:l.inbox,loading:l.loading,error:l.error,onRefresh:l.refresh,filters:o[s],onFiltersChange:e=>c(s,e),boardCards:u,onConvert:h,onOpenTask:p,onOpenSettings:g,projects:m,onBrowseProject:x,sourceKind:s,embedded:!0})]})}var nX=s(3805),nQ=s(96807),nZ=s(59232),n0=s(98014),n1=s(34720);function n5({entries:e,activeTaskId:t,onSelect:s,onPin:a,onClose:i,onReorder:l}){let o=(0,r.useRef)(null),[c,d]=(0,r.useState)({left:!1,right:!1}),u=(0,r.useCallback)(()=>{let e=o.current;if(!e)return;let t=e.scrollLeft>0,s=e.scrollLeft+e.clientWidth<e.scrollWidth-1;d(e=>e.left===t&&e.right===s?e:{left:t,right:s})},[]);(0,r.useEffect)(()=>{let e=o.current;if(!e)return;u();let t=new ResizeObserver(u);for(let s of(t.observe(e),Array.from(e.children)))t.observe(s);return()=>t.disconnect()},[e,u]),(0,r.useEffect)(()=>{t&&o.current?.querySelector(`[data-tab-id="${CSS.escape(t)}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[t]);let m=e=>{let t=o.current;t&&t.scrollBy({left:e*t.clientWidth*.8,behavior:"smooth"})};if(0===e.length)return null;let x=c.left||c.right;return(0,n.jsxs)("div",{className:"flex h-9 shrink-0 items-stretch border-b border-border bg-card/40",children:[x&&(0,n.jsx)("div",{className:"flex shrink-0 items-center border-r border-border/60 px-0.5",children:(0,n.jsx)($,{"aria-label":"向左捲動分頁",disabled:!c.left,onClick:()=>m(-1),className:"rounded-sm p-1",children:(0,n.jsx)(n0.A,{className:"size-4"})})}),(0,n.jsx)(nX.x,{as:"div",axis:"x",values:e,onReorder:e=>l(e.map(e=>e.taskId)),ref:o,layoutScroll:!0,onScroll:u,onWheel:e=>{let t=o.current;t&&0===e.deltaX&&0!==e.deltaY&&(t.scrollLeft+=e.deltaY)},className:"flex min-w-0 flex-1 items-stretch overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map(e=>(0,n.jsx)(n2,{entry:e,active:e.taskId===t,onSelect:s,onPin:a,onClose:i},e.taskId))}),x&&(0,n.jsx)("div",{className:"flex shrink-0 items-center border-l border-border/60 px-0.5",children:(0,n.jsx)($,{"aria-label":"向右捲動分頁",disabled:!c.right,onClick:()=>m(1),className:"rounded-sm p-1",children:(0,n.jsx)(tg.A,{className:"size-4"})})})]})}function n2({entry:e,active:t,onSelect:s,onPin:a,onClose:i}){let l=(0,nQ.m)(),[o,c]=(0,r.useState)(!1);return(0,n.jsxs)(nZ.N,{as:"div",value:e,dragListener:!1,dragControls:l,"data-tab-id":e.taskId,onDragStart:()=>c(!0),onDragEnd:()=>c(!1),className:(0,z.cn)("group relative flex h-full min-w-0 max-w-52 shrink-0 select-none items-center gap-1 border-r border-border/60 pl-1 pr-1.5 transition-colors motion-reduce:transition-none",t?"bg-background text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground",o&&"z-10 bg-card shadow-lg"),children:[(0,n.jsx)("span",{title:"按住拖曳以調整分頁順序",onPointerDown:e=>{e.preventDefault(),l.start(e)},className:(0,z.cn)("flex h-5 w-3.5 shrink-0 cursor-grab touch-none items-center justify-center rounded-sm text-muted-foreground/70 transition-opacity active:cursor-grabbing motion-reduce:transition-none hover:text-foreground",t?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(n1.A,{className:"size-3"})}),(0,n.jsxs)("button",{type:"button","aria-current":t?"page":void 0,title:e.title,onClick:()=>s(e.taskId),onDoubleClick:()=>a(e.taskId),onAuxClick:t=>{1===t.button&&i(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,z.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,z.cn)("min-w-0 truncate",e.preview&&"italic"),children:e.title})]}),(0,n.jsx)("button",{type:"button","aria-label":`關閉分頁 ${e.title}`,title:"關閉分頁(執行中的 agent 會繼續在背景執行)",onClick:()=>i(e.taskId),className:(0,z.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",t?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(tv.A,{className:"size-3"})})]})}var n3=s(4504);function n4({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)(tJ,{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)(n3.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)(th.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(tS,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function n6({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)(nl.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)($,{"aria-label":"關閉通知",onClick:()=>s(e.id),className:"size-5 p-0.5",children:(0,n.jsx)(tv.A,{className:"size-3.5"})})]})}function n7({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)(n6,{toast:e,onOpen:t,onDismiss:s},e.id))})})}function n8(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 n9=["board","github","terminals"],re=["jira","issues","prs"],rt="vibeflow:terminal-tabs",rs="vibeflow:inbox-tab",rn="vibeflow:github-filters",rr="vibeflow:jira-scope";function ra(e){try{let t=window.localStorage.getItem(e);return null===t?null:JSON.parse(t)}catch{return null}}function ri(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}let rl=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);function ro(e){let t=e??{};return{assignees:rl(t.assignees)?t.assignees:nC.assignees,authors:rl(t.authors)?t.authors:nC.authors}}let rc={backlog:[],in_progress:[],done:[]},rd=["in_progress","backlog","done"];function ru(e,t){for(let s of Object.values(e)){let e=s.find(e=>e.id===t);if(e)return e}return null}function rm(e,t){let s=new Set(t.map(e=>e.sessionKey));return[...t,...e.filter(e=>e.pending&&!s.has(e.sessionKey))]}function rx(){let[e,t]=(0,r.useState)(rc),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)(nc()),[u,m]=(0,r.useState)([]),[x,f]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(null),[j,v]=(0,r.useState)(!1),[N,w]=(0,r.useState)(!0),[k,C]=(0,r.useState)(""),[S,A]=(0,r.useState)(""),[z,E]=(0,r.useState)([]),[$,P]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),[B,V]=(0,r.useState)(!1),[K,G]=(0,r.useState)(null),[O,J]=(0,r.useState)(!1),[U,W]=(0,r.useState)(null),[Y,q]=(0,r.useState)(null),[ee,et]=(0,r.useState)(!1),[es,en]=(0,r.useState)(null),[ec,em]=(0,r.useState)(!1),[ex,ef]=(0,r.useState)(null),[eh,ep]=(0,r.useState)([]),[eg,eb]=(0,r.useState)([]),ej=(0,r.useRef)(eg);ej.current=eg;let[ev,eN]=(0,r.useState)(null),[ey,ew]=(0,r.useState)(null),[ek,eC]=(0,r.useState)(0),[eS,eA]=(0,r.useState)("board"),[ez,eE]=(0,r.useState)({issues:nC,prs:nC}),[eR,eT]=(0,r.useState)(null),[eD,eM]=(0,r.useState)("sprint"),[e_,eV]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!0;return T().then(s=>{let n,r,a,i,l,o;if(!e)return;s&&(t(s.board),w(s.settings.autoMode),C(s.settings.systemPrompt??""),A(s.settings.workstationPath??""),E(s.settings.jira?.storyPointsFields??[]),d(nc(s.settings.notifications)),eb(e=>rm(e,s.terminals??[])));let c={view:(r=(n=new URLSearchParams(window.location.search)).get("view"))&&n9.includes(r)?r:"board",taskId:n.get("task")||null};eA(c.view),ef(c.taskId);let u=Array.isArray(a=ra(rt))?a.filter(e=>!!e&&"string"==typeof e.taskId&&"boolean"==typeof e.preview):[];ep(c.taskId&&!u.some(e=>e.taskId===c.taskId)?[...u,{taskId:c.taskId,preview:!0}]:u),eT((i=ra(rs),re.includes(i)?i:null)),eM("all"===(l=ra(rr))?l:"sprint"),eE({issues:ro((o=ra(rn)??{}).issues),prs:ro(o.prs)}),P(!0)}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),w(e.settings.autoMode),C(e.settings.systemPrompt??""),A(e.settings.workstationPath??""),E(e.settings.jira?.storyPointsFields??[]),d(nc(e.settings.notifications)),eb(t=>rm(t,e.terminals??[]))},(s=R())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{let e;$&&(e=new URL(window.location.href),"board"===eS?e.searchParams.delete("view"):e.searchParams.set("view",eS),ex?e.searchParams.set("task",ex):e.searchParams.delete("task"),e.href!==window.location.href&&window.history.replaceState(window.history.state,"",e))},[$,eS,ex]),(0,r.useEffect)(()=>{$&&ri(rt,eh)},[$,eh]),(0,r.useEffect)(()=>{$&&ri(rs,eR)},[$,eR]),(0,r.useEffect)(()=>{$&&ri(rr,eD)},[$,eD]),(0,r.useEffect)(()=>{$&&ri(rn,ez)},[$,ez]),(0,r.useEffect)(()=>{var e;let t;return e=({taskId:e,progress:t})=>{o(s=>({...s,[e]:t}))},(t=R())?t.onProgressUpdate(e):()=>{}},[]),(0,r.useEffect)(()=>{let e,t=!0,s=(e=R())?e.onUpdateAvailable(f):()=>{};return F().then(e=>{t&&f(e)}).catch(()=>{}),()=>{t=!1,s()}},[]);let eK=e.in_progress.map(e=>e.id).join(",");(0,r.useEffect)(()=>{let e=!0;for(let t of eK?eK.split(","):[])e$(t).then(s=>{e&&s&&o(e=>e[t]?e:{...e,[t]:s})});return()=>{e=!1}},[eK]),(0,r.useEffect)(()=>{let t=new Set(Object.values(e).flat().map(e=>e.id));ep(e=>e.every(e=>t.has(e.taskId))?e:e.filter(e=>t.has(e.taskId))),ef(e=>e&&!t.has(e)?null:e)},[e]);let eG=()=>er("選擇專案資料夾"),eH=(e,t)=>{let s=`terminal_${window.crypto.randomUUID()}`;eN(s),eb(n=>[...n,{pending:!0,sessionKey:s,title:sM(e),projectPath:e,...t?{taskId:t}:{}}]),eA("terminals")},eJ=(e,t)=>{eA("board"),ep(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]}),ef(e)},eU=(0,r.useRef)(eJ);eU.current=eJ;let eW=(0,r.useRef)(ex);eW.current=ex;let eY=(0,r.useRef)(c);eY.current=c;let eq=(0,r.useCallback)(e=>{m(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=eY.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(m(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(),eU.current(e),s.close()}}},(t=R())?t.onProgressNotify(e):()=>{}},[]);let eX=e=>{ep(t=>t.some(t=>t.taskId===e&&t.preview)?t.map(t=>t.taskId===e?{...t,preview:!1}:t):t)},eQ=e=>{let t=new Set(e);if(ex&&t.has(ex)){let e=eh.findIndex(e=>e.taskId===ex),s=eh.slice(e+1).find(e=>!t.has(e.taskId)),n=eh.slice(0,Math.max(e,0)).reverse().find(e=>!t.has(e.taskId));ef(s?.taskId??n?.taskId??null)}ep(e=>e.filter(e=>!t.has(e.taskId)))},eZ=()=>{eA("board"),W(null),ew(null),eC(e=>e+1),ef(null)},e0=async(e,s)=>{let n,r=await ed({baseBranch:null,...(n=[e.url,e.body.trim()].filter(Boolean).join("\n\n"),{title:e.title,description:n,..."pr"===e.kind?{branch:e.headRefName,baseBranch:e.baseRefName}:{},github:{kind:e.kind,repo:e.repo,number:e.number,url:e.url}}),projectPath:s,autoMode:N});if(!r)throw Error("未連線到 VibeFlow core");return t(r.state.board),r.task.id},e1=async(e,t,s,n,r)=>{V(!0),G(null);try{await _({systemPrompt:e,workstationPath:t||void 0,autoMode:s,notifications:n,jira:{storyPointsFields:r}}),C(e),A(t),w(s),d(n),E(r),D(!1)}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(!1)}},e5=async(e,s,n,r,a,i,l,o,c,d)=>{J(!0),W(null);try{let u=await ed({title:e,description:s,projectPath:n,baseBranch:r,branch:a||void 0,agentCli:i,model:l||void 0,effort:o,autoMode:c,attachments:d});u&&(t(u.state.board),eJ(u.task.id,{pin:!0}))}catch(e){W(e instanceof Error?e.message:String(e))}finally{J(!1)}},e2=async e=>{if(Y){et(!0),en(null);try{let s=await eu({taskId:Y.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),q(null)}catch(e){en(e instanceof Error?e.message:String(e))}finally{et(!1)}}},e3=async e=>{let s=await eP(e);s&&t(s.board)},e4=async e=>{let s=await eI(e);s&&(t(s.board),eQ([e]))},e6=eh.flatMap(t=>{for(let s of rd){let n=e[s].find(e=>e.id===t.taskId);if(n)return[{...t,title:n.title,column:s}]}return[]}),e7=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 H({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,$),e8=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 s=++c.current;i(!0),o(null);try{let r=await Q({force:e,scope:t});s===c.current&&r&&n(e=>({scope:t,inbox:r.error&&e?.scope===t&&"ok"===e.inbox.status&&e.inbox.tickets.length?{...e.inbox,error:r.error}:r}))}catch(e){s===c.current&&o(e instanceof Error?e.message:String(e))}finally{s===c.current&&i(!1)}},[t]);return(0,r.useEffect)(()=>{e&&d(!1)},[e,d]),(0,r.useEffect)(()=>X(e=>{("success"===e.type||"signed-out"===e.type)&&d(!0)}),[d]),{inbox:s?.scope===t?s.inbox:null,loading:a,error:l,refresh:()=>d(!0),reload:()=>d(!1)}}($,eD),e9=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 Z({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,$),te=[...e.in_progress,...e.backlog,...e.done],tt=function(e){let t=new Map;for(let s of e)s.github&&t.set(eO(s.github),s.id);return t}(te),ts=function(e){let t=new Map;for(let s of e)s.jira&&!t.has(s.jira.key)&&t.set(s.jira.key,s.id);return t}(te),tn=eR??(e8.inbox?.status==="ok"?"jira":"issues"),tr=Array.from(new Map([...te.filter(e=>e.projectPath).map(e=>[e.projectPath,{path:e.projectPath,name:e.projectName??e.projectPath}]),...e_.filter(e=>!e.missing).map(e=>[e.path,{path:e.path,name:e.name}])]).values()).sort((e,t)=>e.name.localeCompare(t.name));(0,r.useEffect)(()=>{$&&ei().then(eV)},[$,e.backlog.length]);let ta=async(e,s)=>{let n={title:`${e.key} ${e.summary}`,description:[e.url,e.description].filter(Boolean).join("\n\n"),jira:{key:e.key,url:e.url,site:new URL(e.url).host}},r=await ed({...n,projectPath:s,baseBranch:null,autoMode:N});if(!r)throw Error("未連線到 VibeFlow core");return t(r.state.board),r.task.id},ti=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:n8(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;eB(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 M(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=n8(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:n8(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=R())?t.term.onData(e):()=>{}}},[a]),{roomCode:a,peerCount:l,startSharing:()=>{i(String(Math.floor(1e5+9e5*Math.random())))},stopSharing:()=>i(null)}}({board:e,autoMode:N,onStateChange:e=>{t(e),M(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:$?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(nN,{view:eS,onSelectView:eA,onNewTask:eZ,remoteActive:!!ti.roomCode,onOpenSettings:()=>{G(null),D(!0)}}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[x&&h!==x.latestVersion&&(0,n.jsxs)("div",{role:"status",className:"flex items-center gap-3 border-b border-border bg-primary/10 px-4 py-2 text-sm",children:[(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[x.installedVersion?(0,n.jsxs)(n.Fragment,{children:["VibeFlow v",x.installedVersion," 已安裝,但 host 沒有自動重新啟動:",x.restartBlocked,"。 要立即使用新版,請執行 ",(0,n.jsx)("code",{children:"vibeflow shutdown"})," 後再執行 ",(0,n.jsx)("code",{children:"vibeflow"}),"。"]}):(0,n.jsxs)(n.Fragment,{children:["VibeFlow v",x.latestVersion," 已發布(目前 v",x.currentVersion,")。 按下更新會開啟系統終端機執行更新指令(Windows:",(0,n.jsx)("code",{children:"vibeflow update"}),";其他平台:",(0,n.jsx)("code",{children:"sudo vibeflow update"}),")。安裝完成後 host 會自動重新啟動。"]}),g&&(0,n.jsx)("span",{role:"alert",className:"block text-destructive",children:g})]}),!x.installedVersion&&(0,n.jsx)("button",{type:"button",disabled:j,onClick:()=>{v(!0),b(null),L().catch(e=>{b(e instanceof Error?e.message:"無法開啟更新終端機")}).finally(()=>v(!1))},className:"shrink-0 rounded-sm border border-border bg-background px-3 py-1 hover:bg-accent focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:j?"開啟中…":"更新 VibeFlow"}),(0,n.jsx)("button",{type:"button","aria-label":"關閉更新提示",onClick:()=>p(x.latestVersion),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)(tv.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1",children:[(0,n.jsx)("div",{className:"terminals"===eS?"hidden":"h-full",children:(0,n.jsx)(sQ,{tabBar:(0,n.jsx)(n5,{entries:e6,activeTaskId:ex,onSelect:eJ,onPin:eX,onClose:e=>eQ([e]),onReorder:e=>{ep(t=>{let s=new Map(e.map((e,t)=>[e,t]));return[...t].sort((e,t)=>(s.get(e.taskId)??1/0)-(s.get(t.taskId)??1/0))})}}),onSelectTask:eJ,onNewTask:eZ,board:e,onBoardChange:e=>{t(e),M(e)},onEditTask:t=>{en(null),e.backlog.some(e=>e.id===t)&&q(ru(e,t))},onTaskDone:e3,onDeleteTask:e4,onOpenTaskTerminal:t=>{let s=ru(e,t);s?.projectPath&&eH(s.projectPath,t)},taskTerminals:eg,onShowTaskTerminal:e=>{eN(e),eA("terminals")},autoMode:N,workstationPath:S,progress:a,selectedTaskId:ex,onTaskInteract:eX,openTabIds:eh.map(e=>e.taskId),initialProjectPath:ey,newTaskNonce:ek,view:eS,onViewChange:eA,taskLinks:e9.links,githubView:(0,n.jsx)(nq,{view:eS,onViewChange:eA,tab:tn,onTabChange:eT,jira:{...e8,scope:eD,onScopeChange:eM},github:{...e7,refresh:()=>{e7.refresh(),e9.refresh()}},githubFilters:ez,onGithubFiltersChange:(e,t)=>eE(s=>({...s,[e]:t})),jiraCards:ts,githubCards:tt,projects:tr,onBrowseProject:eG,onCreateJira:ta,onConvertGithub:e0,onOpenTask:e=>{eA("board"),eJ(e,{pin:!0})},onOpenSettings:()=>{G(null),D(!0)}}),creating:O,createError:U,pickFolder:eG,loadRecentProjects:ei,loadGitInfo:ea,initRepository:el,detectAgents:eo,onCreateTask:e5})}),(0,n.jsx)("div",{className:"terminals"===eS?"h-full":"hidden",children:(0,n.jsx)(s0,{view:eS,onViewChange:eA,terminals:eg,taskWorktreePaths:Object.fromEntries([...e.in_progress,...e.done].filter(e=>e.worktreePath).map(e=>[e.id,e.worktreePath])),focusedSessionKey:ev,recentProjects:e_,onCreate:e=>eH(e),onRename:(e,t)=>{let s=ej.current.find(t=>t.sessionKey===e);eb(s=>s.map(s=>s.sessionKey===e?{...s,title:t}:s)),s&&!s.pending&&eF(e,t).catch(()=>{})},onStarted:e=>{let t=ej.current.find(t=>t.sessionKey===e);t?.pending&&(eb(t=>t.map(t=>t.sessionKey===e?(({pending:e,...t})=>t)(t):t)),eF(e,t.title).catch(()=>{}))},onClose:e=>{eL(e),eb(t=>t.filter(t=>t.sessionKey!==e)),eN(t=>t===e?null:t)},onBrowse:eG})})]})]})]}),(0,n.jsx)(s5,{task:Y,defaultAutoMode:N,detectAgents:eo,pickFolder:eG,loadRecentProjects:ei,loadGitInfo:ea,saving:ee,error:es,onSubmit:e2,onClose:()=>q(null)}),(0,n.jsx)(np,{open:I,systemPrompt:k,workstationPath:S,autoMode:N,notifications:c,jiraStoryPointsFields:z,saving:B,error:K,onSave:e1,onPickFolder:()=>er("選擇工作區資料夾"),onClose:()=>D(!1)}),(0,n.jsx)(l.N,{children:O&&(0,n.jsx)(tJ,{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)(y.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:ec&&ti.roomCode&&(0,n.jsx)(n4,{roomCode:ti.roomCode,peerCount:ti.peerCount,onClose:()=>em(!1),onStop:()=>{ti.stopSharing(),em(!1)}},"remote-share-dialog")}),(0,n.jsx)(n7,{toasts:u,onOpen:e=>eU.current(e),onDismiss:eq})]}):(0,n.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground",children:"載入中…"})})]})}}},e=>{e.O(0,[8760,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);
|
|
13
|
+
`}function nn({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([eN(),ez()]);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,z.cn)(sA,"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)(tS,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(tS,{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}),ne.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=nt[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,z.cn)(A,"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)(tS,{variant:"ghost",size:"sm",onClick:()=>{N(`import:${e}`,async()=>{let t=await ev(e);t&&await ey(e,t)})},disabled:null!==l,children:[l===`import:${e}`?(0,n.jsx)(y.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(s8.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:ns(e,""),description:""}),disabled:null!==l,children:[(0,n.jsx)(C.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===ns(e,u.name)?ns(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,z.cn)(sA,"font-mono text-sm")}),"skill"!==e&&(0,n.jsx)("input",{value:u.description,onChange:e=>m({...u,description:e.target.value}),placeholder:"用途說明",className:(0,z.cn)(sA,"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,z.cn)(sA,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(tS,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return N("create",async()=>{await ew(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.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)(tS,{variant:"ghost",size:"sm",onClick:()=>{N(`open:${e.key}`,async()=>{h({entry:e,content:await ek(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.builtin?.modified&&(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>{var t;b!==(t=e.name)?j(t):(j(null),N(`restore:${t}`,()=>eA(t)))},onBlur:()=>j(null),disabled:null!==l,title:"以 VibeFlow 出貨的版本覆蓋(會丟掉你的修改)",children:[l===`restore:${e.name}`?(0,n.jsx)(y.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(s9.A,{className:"size-3.5"}),b===e.name?"確定覆蓋?":"還原預設"]}),e.sourcePath&&(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>{N(`reimport:${e.key}`,async()=>{e.sourcePath&&await ey(e.kind,e.sourcePath)})},disabled:null!==l,title:"從來源重新複製一份快照",children:l===`reimport:${e.key}`?(0,n.jsx)(y.A,{className:"size-3.5 animate-spin"}):(0,n.jsx)(tb.A,{className:"size-3.5"})}),(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void N(`delete:${e.key}`,()=>eS(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)(tS,{variant:"ghost",size:"sm",onClick:()=>void N(`restore:${e}`,()=>eA(e)),disabled:null!==l,title:"放回 VibeFlow 出貨的版本",children:[(0,n.jsx)(s9.A,{className:"size-3.5"}),e]},e))]})]})}function nr({output:e,active:t}){let a=(0,r.useRef)(null),i=(0,r.useRef)(null),l=(0,r.useRef)(""),o=(0,r.useRef)(t),c=(0,r.useRef)(e);return o.current=t,c.current=e,(0,r.useEffect)(()=>{let e=!1,t=null,n=null;return Promise.all([s.e(3779).then(s.bind(s,15167)),s.e(5695).then(s.bind(s,95695)),s.e(4847).then(s.bind(s,54847))]).then(([{Terminal:s},{FitAddon:r},{WebLinksAddon:d}])=>{if(e||!a.current)return;let u=new s({convertEol:!0,cursorBlink:!0,fontSize:12,rows:12,theme:{background:"#111827"},linkHandler:{activate:(e,t)=>t$(t),hover:(e,t)=>tP(u,t),leave:()=>tI(u)}}),m=new r;u.loadAddon(m),u.loadAddon(new d((e,t)=>t$(t),{hover:(e,t)=>tP(u,t),leave:()=>tI(u)})),u.open(a.current),m.fit(),(t=new ResizeObserver(()=>m.fit())).observe(a.current),u.onData(e=>{o.current&&Y(e)}),n=u,i.current=u,l.current="",c.current&&(u.write(c.current),l.current=c.current)}),()=>{e=!0,t?.disconnect(),n?.dispose(),i.current=null}},[]),(0,r.useEffect)(()=>{let t=i.current;if(!t)return;e.startsWith(l.current)||(t.reset(),l.current="");let s=e.slice(l.current.length);s&&t.write(s),l.current=e},[e]),(0,n.jsx)("div",{ref:a,className:"h-48 w-full overflow-hidden rounded-sm border border-border bg-[#111827] p-1",tabIndex:0,"aria-label":"Atlassian CLI 登入終端"})}function na(e,t){return e instanceof Error&&e.message?e.message:t}function ni({appVersion:e}){let[t,s]=(0,r.useState)(!1),[a,i]=(0,r.useState)(null),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null);return(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["VibeFlow 版本:",void 0===e?"讀取中…":e?`v${e}`:"無法取得"]}),(0,n.jsxs)(tS,{variant:"outline",size:"sm",disabled:t,onClick:()=>{s(!0),o(null),m(null),B().then(i).catch(e=>{i(null),o(na(e,"無法連線到 npm registry"))}).finally(()=>s(!1))},children:[t?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(tb.A,{}),t?"檢查中…":"檢查更新"]})]}),l&&(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:["檢查更新失敗:",l]}),a?.status==="current"&&(0,n.jsxs)("p",{role:"status",className:"text-sm text-muted-foreground",children:["已是最新版本(v",a.currentVersion,")。"]}),a?.status==="unsupported"&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"目前不是全域 npm 安裝(例如原始碼執行),無法從這裡更新。"}),a?.status==="available"&&(0,n.jsxs)("div",{role:"status",className:"space-y-2 rounded-md border border-border bg-primary/10 p-3 text-sm",children:[(0,n.jsxs)("p",{children:["VibeFlow v",a.latestVersion," 已發布(目前 v",a.currentVersion,")。 按下更新會開啟系統終端機執行更新指令(Windows:",(0,n.jsx)("code",{children:"vibeflow update"}),";其他平台:",(0,n.jsx)("code",{children:"sudo vibeflow update"}),")。安裝完成後 host 會自動重新啟動。"]}),(0,n.jsx)(tS,{size:"sm",disabled:c,onClick:()=>{d(!0),m(null),L().catch(e=>m(na(e,"無法開啟更新終端機"))).finally(()=>d(!1))},children:c?"開啟中…":"更新 VibeFlow"}),u&&(0,n.jsx)("p",{role:"alert",className:"text-destructive",children:u})]})]})}var nl=s(63252);let no={enabled:!0,stepCompleted:!1,allCompleted:!0,waitingInput:!0,desktop:!1};function nc(e){return{...no,...e??{}}}function nd(){return"Notification"in window?Notification.permission:"unsupported"}function nu({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,z.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,z.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 nm({label:e,hint:t,checked:s,disabled:r,onChange:a}){return(0,n.jsxs)("div",{className:(0,z.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)(nu,{checked:s,label:e,disabled:r,onChange:a})]})}function nx({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)(nl.A,{className:"size-4 text-muted-foreground"}),"通知"]}),(0,n.jsx)(nu,{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)(nm,{label:"步驟完成",hint:"待辦清單中每完成一項就通知",checked:e.stepCompleted,disabled:i,onChange:e=>a({stepCompleted:e})}),(0,n.jsx)(nm,{label:"全部步驟完成",checked:e.allCompleted,disabled:i,onChange:e=>a({allCompleted:e})}),(0,n.jsx)(nm,{label:"等待輸入",hint:"Agent 停下來等你回覆或允許權限",checked:e.waitingInput,disabled:i,onChange:e=>a({waitingInput:e})}),(0,n.jsx)(nm,{label:"桌面通知",hint:s?"瀏覽器已封鎖通知,請在瀏覽器的網站設定中允許。":"頁面不在前景時也會跳出系統通知。從瀏覽器網址列「安裝 VibeFlow」後,通知會以 VibeFlow App 顯示,不帶網址。",checked:e.desktop&&!s,disabled:i,onChange:async e=>{if(!e)return a({desktop:!1});a({desktop:await r()})}})]})]})}let nf=[{id:"claude",name:"Claude Code"},{id:"codex",name:"Codex CLI"}],nh={builtin:"內建清單","claude-cli":"Claude Code CLI","codex-app-server":"Codex CLI","codex-cache":"Codex 本機快取"};function np({open:e,systemPrompt:t,workstationPath:s,autoMode:a,notifications:i,jiraStoryPointsFields:o,saving:c,error:d,onSave:m,onPickFolder:x,onClose:f}){let[h,p]=(0,r.useState)(""),[g,b]=(0,r.useState)(void 0),[j,v]=(0,r.useState)(""),[N,w]=(0,r.useState)(!0),[k,C]=(0,r.useState)(i),[S,A]=(0,r.useState)(""),[E,$]=(0,r.useState)(!1),[P,I]=(0,r.useState)({}),[T,F]=(0,r.useState)(null),[B,L]=(0,r.useState)(void 0),[M,_]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)(null),[en,er]=(0,r.useState)(void 0),[ea,ei]=(0,r.useState)(!1),[el,ed]=(0,r.useState)(!1),[eu,em]=(0,r.useState)(null),[ex,ef]=(0,r.useState)("idle"),[eh,ep]=(0,r.useState)(""),[eg,eb]=(0,r.useState)(""),[ej,ev]=(0,r.useState)(null),[eN,ey]=(0,r.useState)(!1),[ew,ek]=(0,r.useState)(null),[eC,eS]=(0,r.useState)("idle"),[eA,ez]=(0,r.useState)(""),[e$,eP]=(0,r.useState)("https://github.com/login/device"),[eI,eR]=(0,r.useState)(null),[eT,eD]=(0,r.useState)(!1),[eF,eB]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(p(t),v(s),w(a),C(i),A(o.join(", ")),$("denied"===nd()||"unsupported"===nd()),ei(!1),_(""),Z(null),L(void 0),V().then(L).catch(e=>{L(null),Z(e instanceof Error?e.message:String(e))}),ed(!1),ef("idle"),ev(null),ep(""),eb(""),J().then(em),eS("idle"),ez(""),eR(null),eB(!1),O().then(ek))},[e,t,s,a,i,o]),(0,r.useEffect)(()=>{if(!e)return;let t=!1;for(let e of(b(void 0),D().then(e=>{t||b(e)}).catch(()=>{t||b(null)}),I({}),er(void 0),eo().then(e=>e.map(e=>e.id)).catch(()=>null).then(e=>{t||er(e)}),nf))ec(e.id).catch(()=>null).then(s=>{t||I(t=>({...t,[e.id]:s}))});return()=>{t=!0}},[e]),(0,r.useEffect)(()=>{if(e)return X(e=>{"starting"===e.type&&(ef("waiting"),ey(!0),ev(null)),"output"===e.type&&eb(t=>(t+e.data).slice(-32e3)),"url"===e.type&&ep(e.url),"success"===e.type&&(em(e.status),ef("idle"),ey(!1)),"signed-out"===e.type&&(em(e.status),ef("idle"),ey(!1)),"cancelled"===e.type&&(ef("idle"),ey(!1)),"error"===e.type&&(ef("error"),ey(!1),ev(e.error))})},[e]);let eL=async e=>{F(e);try{let t=await ec(e,!0).catch(()=>null);I(s=>({...s,[e]:t}))}finally{F(null)}},eM=async()=>{if(M.trim()){Y(!0),Z(null);try{let e=await K(M);if(!e)throw Error("未連線到 VibeFlow core");L(e),_("")}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(!1)}}},e_=async()=>{Y(!0),Z(null);try{let e=await G();if(!e)throw Error("未連線到 VibeFlow core");L(e),_("")}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(!1)}};(0,r.useEffect)(()=>{if(e){var t;let e;return t=e=>{if("starting"===e.type){eS("starting"),eR(null);return}if("code"===e.type){eS("waiting"),ez(e.code),eP(e.url),eB(!1),eD(!1);return}if("success"===e.type){ek(e.status),eS("success"),eD(!1);return}if("cancelled"===e.type){eS("idle"),eD(!1);return}eS("error"),eR(e.error),eD(!1)},(e=R())?e.onGithubAuthEvent(t):()=>{}}},[e]);let[eV,eK]=(0,r.useState)(!1),[eG,eO]=(0,r.useState)(!1),eH=h.trim(),eJ=""===eH,eU=S.split(",").map(e=>e.trim()).filter(Boolean),eW=eU.every(e=>/^customfield_\d+$/.test(e)),eq=!c&&!ea&&!el&&eW,eX=async()=>{let e=await x();e&&v(e)},eQ=async()=>{ei(!0),eS("starting"),ez(""),eR(null),eB(!1),eD(!0);try{await ee()}catch(e){eS("error"),eR(e instanceof Error?e.message:String(e)),eD(!1)}},eZ=async()=>{("starting"===eC||"waiting"===eC)&&await et(),ei(!1),eS("idle"),eD(!1),ez(""),eR(null),eB(!1),ek(await O())},e0=async()=>{eD(!0),eR(null);try{let e=await es();ek(e)}catch(e){eR(e instanceof Error?e.message:String(e))}finally{eD(!1)}},e1=()=>{eN&&W(),ea&&("starting"===eC||"waiting"===eC)&&et(),f()},e5=async()=>{ef("waiting"),ey(!0),ev(null),ep(""),eb("");try{await U()}catch(e){ey(!1),ef("error"),ev(e instanceof Error?e.message:String(e))}},e2=async()=>{eN&&await W(),ed(!1),ey(!1),ef("idle"),em(await J())},e3=async()=>{eA&&(await navigator.clipboard.writeText(eA),eB(!0),window.setTimeout(()=>eB(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(tJ,{title:el?"Atlassian(Jira)":ea?"登入 GitHub CLI":eV?"Library":"設定",description:el?"登入 Atlassian 以讀取指派給你的 Jira ticket。":ea?"使用 GitHub CLI 的網頁授權流程登入 github.com。":eV?"管理 VibeFlow 的 skills、文字片段與腳本;啟動任務時都不會自動載入。":"調整 system prompt 與 agent 帳號連線。",saving:c||eT,onClose:e1,showHeader:!0,contentClassName:"max-w-2xl",footer:el?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void e2(),children:"返回設定"}),(0,n.jsx)(tS,{size:"sm",disabled:c||eN||!eW,onClick:()=>m(eH,j.trim(),N,k,eU),children:"儲存設定"})]}):ea?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void eZ(),disabled:eT&&"success"!==eC,children:"success"===eC?"完成":"返回"}),"error"===eC&&(0,n.jsx)(tS,{size:"sm",onClick:()=>void eQ(),children:"重新登入"})]}):eV?eG?null:(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>eK(!1),children:[(0,n.jsx)(s2.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:e1,disabled:c,children:"取消"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>{eq&&m(eH,j.trim(),N,k,eU)},disabled:!eq,className:(0,z.cn)(c&&"opacity-80"),children:[c&&(0,n.jsx)(y.A,{className:"animate-spin"}),c?"儲存中…":"儲存設定"]})]}),children:el?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void e2(),className:"inline-flex items-center gap-1.5 rounded-sm text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(s2.A,{className:"size-4"}),"返回設定"]}),(0,n.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,n.jsx)("p",{className:"font-medium",children:eu?.installed===!1?"找不到 Atlassian CLI(acli)。":eu?.authenticated?"已登入 Atlassian":"尚未登入 Atlassian。"}),eu?.authenticated&&(0,n.jsxs)("p",{className:"text-muted-foreground",children:[eu.email??"帳號"," \xb7 ",eu.site]}),"waiting"===ex&&(0,n.jsxs)("p",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"size-4 animate-spin"}),"請在瀏覽器完成授權;若帳號有多個 site,再於下方終端選擇。"]}),ej&&(0,n.jsx)("p",{role:"alert",className:"text-destructive",children:ej})]}),(eN||eg)&&(0,n.jsx)(nr,{output:eg,active:eN}),eu?.installed===!1?(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(tS,{variant:"outline",size:"sm",onClick:()=>void eE("https://developer.atlassian.com/cloud/acli/guides/install-acli/"),children:[(0,n.jsx)(td.A,{}),"安裝說明"]}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>void J().then(em),children:[(0,n.jsx)(tb.A,{}),"重新檢查"]})]}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[eN?(0,n.jsx)(tS,{variant:"outline",size:"sm",onClick:()=>void W(),children:"取消"}):(0,n.jsx)(tS,{size:"sm",onClick:()=>void e5(),children:eu?.authenticated?"重新登入":"使用瀏覽器登入"}),eu?.authenticated&&(0,n.jsxs)(tS,{variant:"outline",size:"sm",disabled:eN,onClick:async()=>{try{em(await q())}catch(e){ev(e instanceof Error?e.message:String(e))}},children:[(0,n.jsx)(s3.A,{}),"登出"]}),eh&&(0,n.jsxs)(tS,{variant:"ghost",size:"sm",onClick:()=>void eE(eh),children:[(0,n.jsx)(td.A,{}),"手動開啟登入頁"]})]}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Story Points 欄位 ID"}),(0,n.jsx)("input",{value:S,onChange:e=>A(e.target.value),placeholder:"customfield_10033, customfield_10016",className:(0,z.cn)(sA,"font-mono text-sm")}),!eW&&(0,n.jsx)("span",{className:"text-destructive",children:"請使用 customfield_12345 格式,以逗號分隔。"})]})]}):ea?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void eZ(),disabled:eT&&"success"!==eC,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)(s2.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"===eC?(0,n.jsx)(eY.A,{className:"mt-0.5 size-5 shrink-0 text-success"}):"error"===eC?(0,n.jsx)(u.A,{className:"mt-0.5 size-5 shrink-0 text-destructive"}):(0,n.jsx)(y.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"===eC?"GitHub CLI 已完成授權":"error"===eC?"GitHub CLI 授權失敗":"waiting"===eC?"等待 GitHub 授權完成":"正在啟動 GitHub CLI 登入"}),(0,n.jsx)("p",{className:"text-sm leading-5 text-muted-foreground",children:"success"===eC?`目前登入帳號:${ew?.login??"GitHub"}`:"error"===eC?eI:"waiting"===eC?"請複製授權碼並開啟 GitHub 授權頁,完成後 VibeFlow 會自動更新狀態。":"VibeFlow 正在背景準備 gh auth login。"})]})]})}),("waiting"===eC||eA)&&(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:eA,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 e3(),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:!eA,children:[(0,n.jsx)(s4.A,{className:"size-4"}),eF?"已複製":"複製"]})]})]}),(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:e$,className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-base outline-none"}),(0,n.jsxs)("button",{type:"button",onClick:()=>void eE(e$),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)(td.A,{className:"size-4"}),"開啟"]})]})]})]})]}):eV?(0,n.jsx)(nn,{onEditingChange:eO}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(ni,{appVersion:g}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(sB,{value:N,onChange:w}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsx)("section",{className:"space-y-2",children:(0,n.jsx)(nx,{value:k,onChange:C,desktopBlocked:E,onRequestDesktop:async()=>{if("unsupported"===nd())return $(!0),!1;let e=await Notification.requestPermission()==="granted";return $(!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,z.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",""===j.trim()?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:""===j.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:j,placeholder:"~/Desktop",onChange:e=>v(e.target.value),className:(0,z.cn)(sA,"font-mono text-sm")}),(0,n.jsx)(tS,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void eX(),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,z.cn)("ml-2 rounded-xs px-1.5 py-0.5 text-xs font-medium",eJ?"bg-secondary text-secondary-foreground":"bg-primary/15 text-primary"),children:eJ?"未設定":"已自訂"})]})}),(0,n.jsx)("textarea",{name:"system-prompt",autoComplete:"off",value:h,onChange:e=>p(e.target.value),rows:10,spellCheck:!1,className:(0,z.cn)(sA,"resize-y font-mono text-sm leading-5")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟動 Agent 時會以此 prompt 作為 system prompt;留空則不附加 system prompt。"})]}),(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:"保存可重複使用的 skills、文字片段與腳本。啟動任務時不會載入或加入 prompt, agent 只會收到 system prompt 與任務內容。"})]}),(0,n.jsxs)(tS,{variant:"secondary",size:"sm",onClick:()=>eK(!0),children:[(0,n.jsx)(s6.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:"Jev 自動選擇 effort"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"任務的 effort 設為 auto 時,Jev 會依目前模型選擇推理強度。金鑰只儲存在本機主機資料目錄,不會放入看板狀態或回傳給瀏覽器。"})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:void 0===B?"讀取金鑰狀態中…":null===B?"無法讀取 Jev 金鑰狀態":"saved"===B.source?"已設定 Jev API key(本機儲存)":"environment"===B.source?"已透過 TYPESAFE_API_KEY 環境變數設定":"尚未設定 Jev API key"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)("input",{type:"password","aria-label":"Jev API key",name:"jev-api-key",autoComplete:"off",spellCheck:!1,value:M,onChange:e=>_(e.target.value),placeholder:"輸入 TypeSafe Jev API key",className:(0,z.cn)(sA,"min-w-48 flex-1 font-mono text-sm")}),(0,n.jsx)(tS,{size:"sm",disabled:H||!M.trim(),onClick:()=>void eM(),children:H?"處理中…":"儲存金鑰"}),B?.source==="saved"&&(0,n.jsx)(tS,{size:"sm",variant:"outline",disabled:H,onClick:()=>void e_(),children:"移除金鑰"})]}),Q&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Q})]}),(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;Jev 自動選擇 effort 使用上方獨立的金鑰。設定 GitHub CLI 以支援本機 GitHub 操作。"})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[nf.map(e=>{let t=P[e.id],s=Array.isArray(en)&&!en.includes(e.id),r=void 0===en||!s&&(void 0===t||t?.pending===!0||T===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)(y.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)(eY.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===en?"偵測 CLI…":s?`未安裝・PATH 中找不到 ${e.id} 指令`:void 0===t?"讀取 model 清單…":t?t.pending?`正在向 ${e.name} 取得 model 清單…`:`${t.models.length} 個 models 可用・來源:${nh[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!==en&&(0,n.jsx)(tS,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",disabled:T===e.id,"aria-label":`向 ${e.name} 重新取得 model 清單`,title:`向 ${e.name} 重新取得 model 清單`,onClick:()=>void eL(e.id),children:(0,n.jsx)(tb.A,{className:(0,z.cn)("size-4",T===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:[ew?.authenticated?(0,n.jsx)(eY.A,{className:"size-4 shrink-0 text-success"}):ew?.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:ew?.authenticated?`${ew.login??"GitHub"} 已授權(${ew.gitProtocol??"https"})`:ew?.installed===!1?"找不到 GitHub CLI(gh)":ew?.error?ew.error:"尚未授權"})]}),ew?.authenticated&&(0,n.jsx)(tS,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:eT,onClick:()=>void eQ(),children:"切換使用者"}),ew?.authenticated&&(0,n.jsxs)(tS,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:eT,onClick:()=>void e0(),children:[eT?(0,n.jsx)(y.A,{className:"size-4 animate-spin"}):(0,n.jsx)(s3.A,{className:"size-4"}),"登出"]}),!ew?.authenticated&&(0,n.jsx)(tS,{type:"button",size:"sm",variant:"outline",disabled:ew?.installed===!1||eT,onClick:()=>void eQ(),children:eT?"啟動中…":"登入"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>ed(!0),className:"flex w-full items-center gap-3 rounded-md border border-border/60 px-3 py-2.5 text-left outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[eu?.authenticated?(0,n.jsx)(eY.A,{className:"size-4 shrink-0 text-success"}):(0,n.jsx)("span",{className:"size-4 shrink-0 rounded-full border border-muted-foreground/50"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-base font-medium",children:"Atlassian(Jira)"}),(0,n.jsx)("span",{className:"block truncate text-sm text-muted-foreground",children:eu?.authenticated?`${eu.email??"帳號"} \xb7 ${eu.site}`:eu?.installed===!1?"找不到 Atlassian CLI(acli)":"尚未登入"})]})]})]}),eI&&!ea&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:eI})]}),d&&(0,n.jsx)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-base",children:d})]})},"settings-dialog")})}var ng=s(30592),nb=s(79751),nj=s(93202),nv=s(51256);function nN({view:e,onSelectView:t,onNewTask:s,onRemoteShare:r,remoteActive:a,onOpenSettings:i}){return(0,n.jsxs)("aside",{className:"flex w-12 flex-shrink-0 flex-col overflow-hidden border-r border-border bg-card text-card-foreground",children:[(0,n.jsx)("div",{className:"flex h-12 shrink-0 items-center justify-center border-b border-border",children:(0,n.jsx)("img",{src:"/logo.svg",alt:"VibeFlow",className:"size-5"})}),(0,n.jsx)("div",{className:"flex shrink-0 justify-center px-2 pt-3",children:(0,n.jsx)($,{"aria-label":"新增任務",onClick:s,title:"新增任務",className:"size-8 p-1.5",children:(0,n.jsx)(C.A,{className:"size-4"})})}),(0,n.jsxs)("nav",{"aria-label":"檢視",className:"flex flex-1 flex-col items-center gap-1 px-2 py-3",children:[(0,n.jsx)($,{"aria-label":"看板","aria-current":"board"===e?"page":void 0,title:"看板",onClick:()=>t("board"),className:(0,z.cn)("size-8","board"===e&&"text-primary hover:text-primary"),children:(0,n.jsx)(ng.A,{className:"size-4"})}),(0,n.jsx)($,{"aria-label":"工作項目","aria-current":"github"===e?"page":void 0,title:"工作項目",onClick:()=>t("github"),className:(0,z.cn)("size-8","github"===e&&"text-primary hover:text-primary"),children:(0,n.jsx)(nb.A,{className:"size-4"})}),(0,n.jsx)($,{"aria-label":"終端機","aria-current":"terminals"===e?"page":void 0,title:"終端機",onClick:()=>t("terminals"),className:(0,z.cn)("size-8","terminals"===e&&"text-primary hover:text-primary"),children:(0,n.jsx)(b.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"flex flex-col items-center gap-1 border-t border-border p-2",children:[r&&(0,n.jsx)($,{"aria-label":"遠端控制",onClick:r,title:"遠端控制",className:(0,z.cn)("size-8",a&&"text-primary hover:text-primary"),children:(0,n.jsx)(nj.A,{className:"size-4"})}),(0,n.jsx)($,{"aria-label":"設定 System Prompt",onClick:i,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(nv.A,{className:"size-4"})})]})]})}var ny=s(32310),nw=s(2141),nk=s(4792);let nC={assignees:[],authors:[]},nS=":unassigned",nA=(e,t)=>e.localeCompare(t);function nz(e,t){return Array.from(new Set([...e,...t])).sort(nA)}function nE(e,t){return nA(e.projectName,t.projectName)||t.item.number-e.item.number}function n$(e,t,s){return e.flatMap(e=>e[t].map(t=>({item:t,projectName:e.projectName,projectPath:e.projectPath}))).filter(e=>(function(e,t){let{item:s}=e,{assignees:n,authors:r}=t;return(!n.length||!!(0===s.assignees.length?n.includes(nS):s.assignees.some(e=>n.includes(e.login))))&&(!r.length||!!(s.author&&r.includes(s.author.login)))})(e,s)).sort(nE)}function nP({name:e,allLabel:t,icon:s,options:a,value:i,onChange:l,optionLabel:o=e=>e}){let[c,d]=(0,r.useState)(!1),u=e9(c,()=>d(!1)),m=0===i.length?t:1===i.length?o(i[0]):`${e} \xb7 ${i.length}`;return(0,n.jsxs)("div",{ref:u,className:"relative shrink-0",onKeyDown:e=>{"Escape"===e.key&&c&&(e.stopPropagation(),d(!1))},children:[(0,n.jsxs)("button",{type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-label":`${e}篩選:${m}`,onClick:()=>d(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)(s,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"max-w-40 truncate",children:m}),(0,n.jsx)(w.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),c&&(0,n.jsxs)("div",{role:"menu","aria-label":`${e}篩選`,className:"absolute left-0 top-8 z-20 max-h-80 w-56 overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:[(0,n.jsxs)("button",{type:"button",role:"menuitemcheckbox","aria-checked":0===i.length,onClick:()=>l([]),className:(0,z.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",te,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t}),0===i.length&&(0,n.jsx)(k.A,{className:"size-3 shrink-0"})]}),a.map(e=>{let t=i.includes(e);return(0,n.jsxs)("button",{type:"button",role:"menuitemcheckbox","aria-checked":t,onClick:()=>l(i.includes(e)?i.filter(t=>t!==e):[...i,e]),className:(0,z.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",te,"hover:bg-accent hover:text-accent-foreground"),children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:o(e)}),t&&(0,n.jsx)(k.A,{className:"size-3 shrink-0"})]},e)})]})]})}function nI({item:e,className:t}){if("issue"===e.kind)return(0,n.jsx)(f.A,{className:(0,z.cn)("size-3 shrink-0 text-success",t)});let s="draft"===e.state?h.A:p.A;return(0,n.jsx)(s,{className:(0,z.cn)("size-3 shrink-0",eV[e.state],t)})}function nR({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 nT({children:e,className:t}){return(0,n.jsx)("span",{className:(0,z.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 nD({item:e}){return(0,n.jsxs)(n.Fragment,{children:["issue"===e.kind&&e.issueType&&(0,n.jsx)(nT,{className:"font-medium text-foreground",children:e.issueType.name}),"pr"===e.kind&&(0,n.jsx)(nT,{className:(0,z.cn)("font-medium",eV[e.state]),children:eK[e.state]}),"pr"===e.kind&&e.reviewDecision&&eG[e.reviewDecision]&&(0,n.jsx)(nT,{children:eG[e.reviewDecision]}),e.labels.map(e=>(0,n.jsxs)(nT,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))]})}function nF({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,z.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)(nI,{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:eJ(i.createdAt),children:eH(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)(nD,{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)(nR,{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)(nR,{user:e},e.login))})]})]})]})}function nB({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 nL({entry:e,taskId:t,projects:s,onBrowseProject:a,onClose:i,onConvert:l,onOpenTask:o}){let c,{item:d}=e,[u,m]=(0,r.useState)(null),[x,f]=(0,r.useState)(!1),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(e.projectPath??""),j=async()=>{if(!x&&g){f(!0),p(null);try{m(await l(g))}catch(e){p(e instanceof Error?e.message:String(e))}finally{f(!1)}}},v=u??t;return(0,n.jsx)(tJ,{title:d.title,description:`${d.repo} \xb7 ${"issue"===d.kind?"Issue":"PR"} #${d.number}`,showHeader:!0,saving:x,onClose:i,contentClassName:"max-w-3xl",footer:(0,n.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-2",children:[(0,n.jsxs)(tS,{variant:"outline",size:"sm",onClick:()=>void eE(d.url),children:[(0,n.jsx)(td.A,{}),"在 GitHub 開啟"]}),u&&(0,n.jsx)("span",{className:"text-sm text-success",children:"已建立到 Backlog"}),!e.projectPath&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,n.jsxs)("select",{"aria-label":"建立到專案",value:g,onChange:e=>b(e.target.value),disabled:x,className:"h-9 max-w-56 rounded-md border border-input bg-background px-2 text-sm focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("option",{value:"",children:"選擇本機專案…"}),g&&!s.some(e=>e.path===g)&&(0,n.jsx)("option",{value:g,children:g}),s.map(e=>(0,n.jsxs)("option",{value:e.path,children:[e.name," \xb7 ",e.path]},e.path))]}),(0,n.jsx)($,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",disabled:x,onClick:()=>void a().then(e=>{e&&b(e)}),children:(0,n.jsx)(tp.A,{className:"size-4"})})]}),v?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",onClick:()=>void j(),disabled:x||!g,title:"已經有對應卡片,仍可再建一張",children:"再建一張"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>o(v),children:[(0,n.jsx)(ny.A,{}),"前往卡片"]})]}):(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm",children:[e.projectPath&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:["建立到:",e.projectName]}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>void j(),disabled:x||!g,children:[x?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(C.A,{}),x?"建立中…":"建立卡片"]})]})]}),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["issue"===d.kind?(0,n.jsx)(nT,{className:"bg-success/15 font-medium text-success",children:"Open"}):(0,n.jsx)(nT,{className:(0,z.cn)("font-medium",eV[d.state]),children:eK[d.state]}),(0,n.jsxs)("span",{className:"min-w-0 truncate",children:[d.repo," \xb7 ","issue"===d.kind?"Issue":"PR"," #",d.number]})]}),(0,n.jsxs)("dl",{className:"mt-3 grid grid-cols-[64px_minmax(0,1fr)] gap-y-1.5 text-xs",children:[(0,n.jsx)(nB,{label:"專案",children:e.projectName}),(0,n.jsx)(nB,{label:"發起人",children:d.author?.login??"—"}),(0,n.jsx)(nB,{label:"指派",children:(c=d.assignees).length?c.map(e=>e.login).join("、"):"—"}),(0,n.jsx)(nB,{label:"建立時間",children:eJ(d.createdAt)}),"issue"===d.kind&&(0,n.jsx)(nB,{label:"Issue Type",children:d.issueType?.name??"—"}),"pr"===d.kind&&(0,n.jsx)(nB,{label:"分支",children:(0,n.jsxs)("span",{className:"break-all",children:[d.headRefName," → ",d.baseRefName]})}),"pr"===d.kind&&d.reviewDecision&&(0,n.jsx)(nB,{label:"Review",children:eG[d.reviewDecision]??d.reviewDecision}),d.labels.length>0&&(0,n.jsx)(nB,{label:"Labels",children:(0,n.jsx)("span",{className:"flex flex-wrap gap-1",children:d.labels.map(e=>(0,n.jsxs)(nT,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))})}),d.milestone&&(0,n.jsx)(nB,{label:"Milestone",children:d.milestone})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:d.body.trim()?(0,n.jsx)(tk,{source:d.body,compact:!0}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"沒有內文"})}),h&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:h})]})})}function nM({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 n_({column:e,selectedKey:t,boardCards:s,now:r,onSelect:a}){return(0,n.jsxs)("section",{"aria-label":e.repo,className:"flex min-h-0 w-[320px] shrink-0 flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 px-1",title:e.repo,children:[(0,n.jsx)("h2",{className:(0,z.cn)(A,"min-w-0 truncate"),children:e.projectName.split("/").pop()}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:e.entries.length})]}),(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto rounded-md p-1",children:e.entries.map(e=>{let i=eO(e.item);return(0,n.jsx)(nF,{entry:e,selected:i===t,onBoard:s.has(i),now:r,onSelect:()=>a(i)},i)})})]})}let nV=e=>e===nS?"未指派":e;function nK({view:e,onViewChange:t,inbox:s,loading:a,error:i,onRefresh:l,filters:o,onFiltersChange:c,boardCards:d,projects:u,onBrowseProject:m,onConvert:x,onOpenTask:f,onOpenSettings:h,sourceKind:p,embedded:g=!1}){let b,j,[v,N]=(0,r.useState)(null),y=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}(),w=s?.status==="ok"?s.repos:[],k={assignees:[nS,...nz((j=w.flatMap(e=>p?e[p]:[...e.issues,...e.prs])).flatMap(e=>e.assignees.map(e=>e.login)),o.assignees.filter(e=>e!==nS))],authors:nz(j.flatMap(e=>e.author?[e.author.login]:[]),o.authors)},C=o.assignees.length>0||o.authors.length>0,S=n$(w,"issues",o),A=n$(w,"prs",o),E=w.filter(e=>e.error),P="issues"===p?S:"prs"===p?A:[...S,...A],R=function(e){let t=new Map;for(let s of e){let e=t.get(s.item.repo);e?e.entries.push(s):t.set(s.item.repo,{repo:s.item.repo,projectName:s.projectName,entries:[s]})}return[...t.values()]}(P),T=P.find(e=>eO(e.item)===v)??null,D=s?.status==="ok"&&null!==v&&null===T;(0,r.useEffect)(()=>{D&&N(null)},[D]);let F=e=>t=>c({...o,[e]:t}),B=s?.fetchedAt??0,L=B?`${eH(new Date(B).toISOString(),y)}更新`:null;return b=s?"gh-missing"===s.status?(0,n.jsx)(nM,{children:"找不到 GitHub CLI(gh)。安裝後按右上角的重新整理,就能看到指派給你或你建立的 Issue 與 PR。"}):"unauthenticated"===s.status?(0,n.jsx)(nM,{action:(0,n.jsx)(tS,{size:"sm",onClick:h,children:"開啟設定登入 GitHub"}),children:"GitHub CLI 尚未登入。"}):0===w.length?(0,n.jsx)(nM,{children:i??"目前沒有與你相關的 open 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:[(E.length>0||i)&&(0,n.jsxs)("div",{role:"alert",className:"shrink-0 space-y-1 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[i&&(0,n.jsx)("p",{children:i}),E.map(e=>(0,n.jsxs)("p",{className:"truncate",title:e.error,children:[e.repo,":",e.error]},e.repo))]}),0===R.length?(0,n.jsx)("p",{className:"px-1 text-sm text-muted-foreground/60",children:C?"沒有符合篩選條件的項目":"prs"===p?"沒有指派給你、你建立、請你 review 或你 review 過的 open PR":"issues"===p?"沒有指派給你或你建立的 open Issue":"目前沒有與你相關的 open Issue 或 PR"}):(0,n.jsx)("div",{className:"flex min-h-0 flex-1 gap-4 overflow-x-auto pb-2",children:R.map(e=>(0,n.jsx)(n_,{column:e,selectedKey:v,boardCards:d,now:y,onSelect:N},e.repo))})]}):a?(0,n.jsx)(nM,{children:"讀取 GitHub 中…"}):i?(0,n.jsx)(nM,{children:i}):null,(0,n.jsxs)("div",{className:(0,z.cn)("flex min-h-0 flex-col bg-background",g?"flex-1":"h-full"),onKeyDown:e=>{"Escape"===e.key&&v&&(e.stopPropagation(),N(null))},children:[(0,n.jsxs)("div",{className:(0,z.cn)("flex shrink-0 items-center gap-3 border-b border-border px-5",g?"h-11":"h-12"),children:[!g&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I,{value:e,onChange:t}),(0,n.jsx)("span",{className:"h-4 w-px bg-border"})]}),"issues"!==p&&(0,n.jsx)(nP,{name:"Assignee",allLabel:"所有 Assignee",icon:nw.A,options:k.assignees,value:o.assignees,onChange:F("assignees"),optionLabel:nV}),"issues"!==p&&(0,n.jsx)(nP,{name:"發起人",allLabel:"所有發起人",icon:nk.A,options:k.authors,value:o.authors,onChange:F("authors")}),C&&(0,n.jsxs)("button",{type:"button",onClick:()=>c(nC),className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 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)(tv.A,{className:"size-3.5 shrink-0"}),"清除篩選"]}),(0,n.jsxs)("span",{className:"ml-auto min-w-0 truncate text-sm text-muted-foreground",children:[s?.login?`${s.login} \xb7 `:"","issues"===p?`${S.length} 筆`:"prs"===p?`${A.length} 筆`:"指派給我、我建立、我 review 的",L?` \xb7 ${L}`:""]}),(0,n.jsx)($,{"aria-label":"重新整理 Issue 與 PR",title:"重新整理",onClick:l,disabled:a,children:(0,n.jsx)(tb.A,{className:(0,z.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:b}),T&&(0,n.jsx)(nL,{entry:T,taskId:d.get(eO(T.item)),projects:u,onBrowseProject:m,onClose:()=>N(null),onConvert:e=>x(T.item,e),onOpenTask:f},eO(T.item))]})]})}var nG=s(85499);function nO(e){return Number(e.split("-").at(-1))||0}function nH(e,t){return e.dueDate?t.dueDate?e.dueDate.localeCompare(t.dueDate)||nO(t.key)-nO(e.key):-1:t.dueDate?1:nO(t.key)-nO(e.key)}let nJ={new:"bg-accent text-muted-foreground",indeterminate:"bg-primary/15 text-primary",done:"bg-success/15 text-success"};function nU(e,t=Date.now()){if(!e)return{text:"無期限",tone:"none",title:""};let s=new Date(`${e.slice(0,10)}T00:00:00`).getTime();if(!Number.isFinite(s))return{text:"無期限",tone:"none",title:""};let n=new Date(t);n.setHours(0,0,0,0);let r=Math.round((s-n.getTime())/864e5);return r<0?{text:`已逾期 ${-r} 天`,tone:"overdue",title:e}:0===r?{text:"今天到期",tone:"today",title:e}:r<=3?{text:`剩 ${r} 天`,tone:"soon",title:e}:{text:`截止 ${new Date(s).getMonth()+1}/${new Date(s).getDate()}`,tone:"normal",title:e}}function nW({inbox:e,loading:t,error:s,scope:a,onScopeChange:i,onRefresh:o,boardCards:c,projects:d,onBrowseProject:u,onCreate:m,onOpenTask:x,onOpenSettings:h}){let[p,g]=(0,r.useState)(null),[b,j]=(0,r.useState)(""),[v,N]=(0,r.useState)(!1),[w,k]=(0,r.useState)(null),[S,A]=(0,r.useState)(null),[E,P]=(0,r.useState)(!1),I=e?.tickets??[],R=function(e){let t=[{name:"To Do",tickets:[]},{name:"In Progress",tickets:[]},{name:"To be Released",tickets:[]},{name:"Done",tickets:[]}];for(let s of e)t["to be released"===s.status.name.toLowerCase()?2:"done"===s.status.category?3:+("new"!==s.status.category)].tickets.push(s);return t.map(e=>({...e,tickets:e.tickets.sort(nH)}))}(I),T=I.find(e=>e.key===p),D=T?c.get(T.key):void 0,F=w??D;(0,r.useEffect)(()=>{p&&e?.status==="ok"&&!T&&g(null)},[p,T,e?.status]);let B=async()=>{if(T&&b&&!v){N(!0),A(null);try{let e=await m(T,b);k(e),P(!1)}catch(e){A(e instanceof Error?e.message:String(e))}finally{N(!1)}}},L=(e,t=!1)=>(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-5 text-center text-sm text-muted-foreground",children:[(0,n.jsx)("p",{className:"max-w-md",children:e}),t&&(0,n.jsx)(tS,{size:"sm",onClick:h,children:"開啟設定"})]});return(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex min-h-11 shrink-0 flex-wrap items-center gap-3 border-b border-border px-5 py-1",children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"抓取範圍"}),(0,n.jsxs)("select",{"aria-label":"Jira 抓取範圍",value:a,onChange:e=>i(e.target.value),className:"h-8 max-w-40 rounded-md border border-input bg-background px-2 text-sm focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("option",{value:"sprint",children:"Active Sprint"}),(0,n.jsx)("option",{value:"all",children:"全部指派給我"})]})]}),(0,n.jsxs)("span",{className:"ml-auto min-w-0 truncate text-sm text-muted-foreground",children:[e?.email??e?.site??"",e?.status==="ok"?` \xb7 ${I.length} 筆`:"",e?.fetchedAt?` \xb7 ${new Date(e.fetchedAt).toLocaleTimeString()} 更新`:""]}),(0,n.jsx)($,{"aria-label":"重新整理 Jira ticket",title:"重新整理 Jira ticket",onClick:o,disabled:t,children:(0,n.jsx)(tb.A,{className:(0,z.cn)("size-4",t&&"animate-spin motion-reduce:animate-none")})})]}),e?.error&&(0,n.jsx)("div",{role:"alert",className:"border-b border-destructive/30 bg-destructive/10 px-5 py-2 text-sm text-destructive",children:e.error}),e?.status==="acli-missing"?L("找不到 Atlassian CLI(acli)。安裝並登入後就能看到指派給你的 Jira ticket。",!0):e?.status==="unauthenticated"?L("尚未登入 Atlassian。",!0):e?e.error&&0===I.length?L(e.error):(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[0===I.length&&(0,n.jsx)("p",{className:"mb-4 text-sm text-muted-foreground",children:"目前沒有符合抓取範圍的 Jira ticket"}),(0,n.jsx)("div",{className:"grid min-h-full min-w-[1040px] grid-cols-4 items-start gap-3",children:R.map(e=>(0,n.jsxs)("section",{"aria-label":`${e.name},${e.tickets.length} 筆`,className:"min-w-0 rounded-md border border-border bg-muted/20 p-2",children:[(0,n.jsxs)("h3",{className:"flex min-w-0 items-center gap-2 px-1 py-1 text-sm font-medium",children:[(0,n.jsx)("span",{className:(0,z.cn)("size-2 shrink-0 rounded-full","To Do"===e.name?"bg-muted-foreground":"Done"===e.name?"bg-success":"bg-primary")}),(0,n.jsx)("span",{className:"min-w-0 truncate",title:e.name,children:e.name}),(0,n.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.tickets.length})]}),(0,n.jsx)("div",{className:"mt-2 space-y-2",children:e.tickets.map(e=>{let t=nU(e.dueDate);return(0,n.jsxs)("button",{type:"button",onClick:()=>{g(e.key),j(""),A(null),k(null),P(!1)},"aria-pressed":e.key===p,className:(0,z.cn)("min-h-32 w-full rounded-md border bg-card p-3 text-left outline-none transition-colors hover:border-input focus-visible:ring-[3px] focus-visible:ring-ring/50",e.key===p?"border-primary":"border-border"),children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(f.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"font-mono tabular-nums",children:e.key}),c.has(e.key)&&(0,n.jsx)("span",{className:"rounded-xs bg-primary/15 px-1.5 py-0.5 text-primary",children:"已在看板"}),(0,n.jsx)("span",{className:(0,z.cn)("ml-auto max-w-[45%] truncate rounded-xs px-1.5 py-0.5",nJ[e.status.category]),children:e.status.name})]}),(0,n.jsx)("span",{className:"mt-2 line-clamp-2 min-h-10 text-[15px] font-medium leading-5",children:e.summary}),(0,n.jsxs)("span",{className:"mt-3 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{children:null===e.storyPoints?"— pt":`◆ ${e.storyPoints} pt`}),(0,n.jsx)("span",{title:t.title,className:(0,z.cn)("overdue"===t.tone&&"text-destructive",("soon"===t.tone||"today"===t.tone)&&"text-warning"),children:t.text})]})]},e.key)})})]},e.name))})]}):L(t?"讀取 Jira 中…":s??"無法讀取 Jira ticket"),(0,n.jsx)(l.N,{children:T&&(0,n.jsx)(tJ,{title:`${T.key} ${T.summary}`,showHeader:!0,saving:v,description:`${T.issueType} \xb7 ${T.status.name}`,onClose:()=>g(null),contentClassName:"max-w-3xl",bodyClassName:"min-h-0",footer:(0,n.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-2",children:[w&&(0,n.jsx)("span",{className:"text-sm text-success",children:"已建立到 Backlog"}),F&&!E?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(tS,{variant:"ghost",size:"sm",title:"已經有對應卡片,仍可再建一張",onClick:()=>{P(!0),k(null),j("")},children:"再建一張"}),(0,n.jsxs)(tS,{size:"sm",onClick:()=>{g(null),x(F)},children:[(0,n.jsx)(ny.A,{}),"前往卡片"]})]}):(0,n.jsxs)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("select",{"aria-label":"建立到專案",value:b,onChange:e=>j(e.target.value),disabled:v,className:"h-9 max-w-56 rounded-md border border-input bg-background px-2 text-sm focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("option",{value:"",children:"選擇專案…"}),b&&!d.some(e=>e.path===b)&&(0,n.jsx)("option",{value:b,children:b}),d.map(e=>(0,n.jsxs)("option",{value:e.path,children:[e.name," \xb7 ",e.path]},e.path))]}),(0,n.jsx)($,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",disabled:v,className:"rounded-md border border-border p-2",onClick:()=>void u().then(e=>{e&&j(e)}),children:(0,n.jsx)(tp.A,{className:"size-4"})}),(0,n.jsxs)(tS,{size:"sm",disabled:!b||v,title:b?void 0:"先選擇要建立到哪個專案",onClick:()=>void B(),children:[v?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(C.A,{}),v?"建立中…":"建立卡片"]})]})]}),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("dl",{className:"grid grid-cols-[90px_minmax(0,1fr)] gap-2 text-sm",children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:"編號"}),(0,n.jsx)("dd",{children:(0,n.jsxs)("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",onClick:e=>{e.preventDefault(),eE(T.url)},className:"inline-flex items-center gap-1 text-primary underline outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[T.key,(0,n.jsx)(td.A,{className:"size-3"})]})}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"狀態"}),(0,n.jsx)("dd",{children:T.status.name}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"Story Points"}),(0,n.jsx)("dd",{children:T.storyPoints??"—"}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"期限"}),(0,n.jsx)("dd",{children:nU(T.dueDate).text}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"Sprint"}),(0,n.jsx)("dd",{children:T.sprint??"—"}),(0,n.jsx)("dt",{className:"text-muted-foreground",children:"優先度"}),(0,n.jsx)("dd",{children:T.priority??"—"}),T.parentKey&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:"Parent"}),(0,n.jsx)("dd",{children:(0,n.jsxs)("a",{href:`https://${e?.site}/browse/${T.parentKey}`,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),eE(`https://${e?.site}/browse/${T.parentKey}`)},className:"inline-flex items-center gap-1 text-primary underline outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[T.parentKey,(0,n.jsx)(td.A,{className:"size-3"})]})})]})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:T.description?(0,n.jsx)(tk,{source:T.description,compact:!0}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"沒有內文"})}),T.attachments.length>0&&(0,n.jsxs)("section",{className:"border-t border-border pt-4","aria-label":"附件",children:[(0,n.jsxs)("h3",{className:"mb-2 flex items-center gap-2 text-sm font-medium",children:[(0,n.jsx)(nG.A,{className:"size-4"}),"附件 ",(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground",children:T.attachments.length})]}),(0,n.jsx)("ul",{className:"space-y-1.5",children:T.attachments.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,n.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",title:e.filename,onClick:t=>{t.preventDefault(),eE(e.url)},className:"min-w-0 truncate text-primary underline outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:e.filename}),null!==e.size&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:function(e){if(e<1024)return`${e} B`;let t=e<1048576?"KB":e<0x40000000?"MB":"GB";return`${new Intl.NumberFormat("zh-TW",{maximumFractionDigits:1}).format(e/("KB"===t?1024:"MB"===t?1048576:0x40000000))} ${t}`}(e.size)})]},e.id))})]}),S&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:S})]})},T.key)})]})}let nY=[{id:"jira",label:"Jira"},{id:"issues",label:"Issues"},{id:"prs",label:"Pull Requests"}];function nq({view:e,onViewChange:t,tab:s,onTabChange:a,jira:i,github:l,githubFilters:o,onGithubFiltersChange:c,jiraCards:d,githubCards:u,projects:m,onBrowseProject:x,onCreateJira:f,onConvertGithub:h,onOpenTask:p,onOpenSettings:g}){let b=(0,r.useRef)([]),j={jira:i.inbox?.status==="ok"?i.inbox.tickets.length:null,issues:l.inbox?.status==="ok"?l.inbox.repos.reduce((e,t)=>e+t.issues.length,0):null,prs:l.inbox?.status==="ok"?l.inbox.repos.reduce((e,t)=>e+t.prs.length,0):null};return(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsx)("div",{className:"flex h-12 shrink-0 items-center border-b border-border px-5",children:(0,n.jsx)(I,{value:e,onChange:t})}),(0,n.jsx)("div",{role:"tablist","aria-label":"來源",className:"flex h-10 shrink-0 items-stretch gap-5 border-b border-border px-5",children:nY.map((e,t)=>(0,n.jsxs)("button",{ref:e=>{b.current[t]=e},type:"button",role:"tab","aria-selected":s===e.id,tabIndex:s===e.id?0:-1,onKeyDown:e=>((e,t)=>{let s="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0;if(!s)return;e.preventDefault();let n=(t+s+nY.length)%nY.length;b.current[n]?.focus(),a(nY[n].id)})(e,t),onClick:()=>a(e.id),className:(0,z.cn)("-mb-px flex items-center gap-1.5 border-b-2 px-1 text-sm font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",s===e.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:[e.label,null!==j[e.id]&&(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:j[e.id]})]},e.id))}),"jira"===s?(0,n.jsx)(nW,{...i,onRefresh:i.refresh,boardCards:d,projects:m,onBrowseProject:x,onCreate:f,onOpenTask:p,onOpenSettings:g}):(0,n.jsx)(nK,{view:e,onViewChange:t,inbox:l.inbox,loading:l.loading,error:l.error,onRefresh:l.refresh,filters:o[s],onFiltersChange:e=>c(s,e),boardCards:u,onConvert:h,onOpenTask:p,onOpenSettings:g,projects:m,onBrowseProject:x,sourceKind:s,embedded:!0})]})}var nX=s(3805),nQ=s(96807),nZ=s(59232),n0=s(98014),n1=s(34720);function n5({entries:e,activeTaskId:t,onSelect:s,onPin:a,onClose:i,onReorder:l}){let o=(0,r.useRef)(null),[c,d]=(0,r.useState)({left:!1,right:!1}),u=(0,r.useCallback)(()=>{let e=o.current;if(!e)return;let t=e.scrollLeft>0,s=e.scrollLeft+e.clientWidth<e.scrollWidth-1;d(e=>e.left===t&&e.right===s?e:{left:t,right:s})},[]);(0,r.useEffect)(()=>{let e=o.current;if(!e)return;u();let t=new ResizeObserver(u);for(let s of(t.observe(e),Array.from(e.children)))t.observe(s);return()=>t.disconnect()},[e,u]),(0,r.useEffect)(()=>{t&&o.current?.querySelector(`[data-tab-id="${CSS.escape(t)}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[t]);let m=e=>{let t=o.current;t&&t.scrollBy({left:e*t.clientWidth*.8,behavior:"smooth"})};if(0===e.length)return null;let x=c.left||c.right;return(0,n.jsxs)("div",{className:"flex h-9 shrink-0 items-stretch border-b border-border bg-card/40",children:[x&&(0,n.jsx)("div",{className:"flex shrink-0 items-center border-r border-border/60 px-0.5",children:(0,n.jsx)($,{"aria-label":"向左捲動分頁",disabled:!c.left,onClick:()=>m(-1),className:"rounded-sm p-1",children:(0,n.jsx)(n0.A,{className:"size-4"})})}),(0,n.jsx)(nX.x,{as:"div",axis:"x",values:e,onReorder:e=>l(e.map(e=>e.taskId)),ref:o,layoutScroll:!0,onScroll:u,onWheel:e=>{let t=o.current;t&&0===e.deltaX&&0!==e.deltaY&&(t.scrollLeft+=e.deltaY)},className:"flex min-w-0 flex-1 items-stretch overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map(e=>(0,n.jsx)(n2,{entry:e,active:e.taskId===t,onSelect:s,onPin:a,onClose:i},e.taskId))}),x&&(0,n.jsx)("div",{className:"flex shrink-0 items-center border-l border-border/60 px-0.5",children:(0,n.jsx)($,{"aria-label":"向右捲動分頁",disabled:!c.right,onClick:()=>m(1),className:"rounded-sm p-1",children:(0,n.jsx)(tg.A,{className:"size-4"})})})]})}function n2({entry:e,active:t,onSelect:s,onPin:a,onClose:i}){let l=(0,nQ.m)(),[o,c]=(0,r.useState)(!1);return(0,n.jsxs)(nZ.N,{as:"div",value:e,dragListener:!1,dragControls:l,"data-tab-id":e.taskId,onDragStart:()=>c(!0),onDragEnd:()=>c(!1),className:(0,z.cn)("group relative flex h-full min-w-0 max-w-52 shrink-0 select-none items-center gap-1 border-r border-border/60 pl-1 pr-1.5 transition-colors motion-reduce:transition-none",t?"bg-background text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground",o&&"z-10 bg-card shadow-lg"),children:[(0,n.jsx)("span",{title:"按住拖曳以調整分頁順序",onPointerDown:e=>{e.preventDefault(),l.start(e)},className:(0,z.cn)("flex h-5 w-3.5 shrink-0 cursor-grab touch-none items-center justify-center rounded-sm text-muted-foreground/70 transition-opacity active:cursor-grabbing motion-reduce:transition-none hover:text-foreground",t?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(n1.A,{className:"size-3"})}),(0,n.jsxs)("button",{type:"button","aria-current":t?"page":void 0,title:e.title,onClick:()=>s(e.taskId),onDoubleClick:()=>a(e.taskId),onAuxClick:t=>{1===t.button&&i(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,z.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,z.cn)("min-w-0 truncate",e.preview&&"italic"),children:e.title})]}),(0,n.jsx)("button",{type:"button","aria-label":`關閉分頁 ${e.title}`,title:"關閉分頁(執行中的 agent 會繼續在背景執行)",onClick:()=>i(e.taskId),className:(0,z.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",t?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(tv.A,{className:"size-3"})})]})}var n3=s(4504);function n4({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)(tJ,{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)(n3.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)(th.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(tS,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function n6({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)(nl.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)($,{"aria-label":"關閉通知",onClick:()=>s(e.id),className:"size-5 p-0.5",children:(0,n.jsx)(tv.A,{className:"size-3.5"})})]})}function n7({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)(n6,{toast:e,onOpen:t,onDismiss:s},e.id))})})}function n8(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 n9=["board","github","terminals"],re=["jira","issues","prs"],rt="vibeflow:terminal-tabs",rs="vibeflow:inbox-tab",rn="vibeflow:github-filters",rr="vibeflow:jira-scope";function ra(e){try{let t=window.localStorage.getItem(e);return null===t?null:JSON.parse(t)}catch{return null}}function ri(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}let rl=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);function ro(e){let t=e??{};return{assignees:rl(t.assignees)?t.assignees:nC.assignees,authors:rl(t.authors)?t.authors:nC.authors}}let rc={backlog:[],in_progress:[],done:[]},rd=["in_progress","backlog","done"];function ru(e,t){for(let s of Object.values(e)){let e=s.find(e=>e.id===t);if(e)return e}return null}function rm(e,t){let s=new Set(t.map(e=>e.sessionKey));return[...t,...e.filter(e=>e.pending&&!s.has(e.sessionKey))]}function rx(){let[e,t]=(0,r.useState)(rc),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)(nc()),[u,m]=(0,r.useState)([]),[x,f]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(null),[j,v]=(0,r.useState)(!1),[N,w]=(0,r.useState)(!0),[k,C]=(0,r.useState)(""),[S,A]=(0,r.useState)(""),[z,E]=(0,r.useState)([]),[$,P]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),[B,V]=(0,r.useState)(!1),[K,G]=(0,r.useState)(null),[O,J]=(0,r.useState)(!1),[U,W]=(0,r.useState)(null),[Y,q]=(0,r.useState)(null),[ee,et]=(0,r.useState)(!1),[es,en]=(0,r.useState)(null),[ec,em]=(0,r.useState)(!1),[ex,ef]=(0,r.useState)(null),[eh,ep]=(0,r.useState)([]),[eg,eb]=(0,r.useState)([]),ej=(0,r.useRef)(eg);ej.current=eg;let[ev,eN]=(0,r.useState)(null),[ey,ew]=(0,r.useState)(null),[ek,eC]=(0,r.useState)(0),[eS,eA]=(0,r.useState)("board"),[ez,eE]=(0,r.useState)({issues:nC,prs:nC}),[eR,eT]=(0,r.useState)(null),[eD,eM]=(0,r.useState)("sprint"),[e_,eV]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!0;return T().then(s=>{let n,r,a,i,l,o;if(!e)return;s&&(t(s.board),w(s.settings.autoMode),C(s.settings.systemPrompt??""),A(s.settings.workstationPath??""),E(s.settings.jira?.storyPointsFields??[]),d(nc(s.settings.notifications)),eb(e=>rm(e,s.terminals??[])));let c={view:(r=(n=new URLSearchParams(window.location.search)).get("view"))&&n9.includes(r)?r:"board",taskId:n.get("task")||null};eA(c.view),ef(c.taskId);let u=Array.isArray(a=ra(rt))?a.filter(e=>!!e&&"string"==typeof e.taskId&&"boolean"==typeof e.preview):[];ep(c.taskId&&!u.some(e=>e.taskId===c.taskId)?[...u,{taskId:c.taskId,preview:!0}]:u),eT((i=ra(rs),re.includes(i)?i:null)),eM("all"===(l=ra(rr))?l:"sprint"),eE({issues:ro((o=ra(rn)??{}).issues),prs:ro(o.prs)}),P(!0)}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),w(e.settings.autoMode),C(e.settings.systemPrompt??""),A(e.settings.workstationPath??""),E(e.settings.jira?.storyPointsFields??[]),d(nc(e.settings.notifications)),eb(t=>rm(t,e.terminals??[]))},(s=R())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{let e;$&&(e=new URL(window.location.href),"board"===eS?e.searchParams.delete("view"):e.searchParams.set("view",eS),ex?e.searchParams.set("task",ex):e.searchParams.delete("task"),e.href!==window.location.href&&window.history.replaceState(window.history.state,"",e))},[$,eS,ex]),(0,r.useEffect)(()=>{$&&ri(rt,eh)},[$,eh]),(0,r.useEffect)(()=>{$&&ri(rs,eR)},[$,eR]),(0,r.useEffect)(()=>{$&&ri(rr,eD)},[$,eD]),(0,r.useEffect)(()=>{$&&ri(rn,ez)},[$,ez]),(0,r.useEffect)(()=>{var e;let t;return e=({taskId:e,progress:t})=>{o(s=>({...s,[e]:t}))},(t=R())?t.onProgressUpdate(e):()=>{}},[]),(0,r.useEffect)(()=>{let e,t=!0,s=(e=R())?e.onUpdateAvailable(f):()=>{};return F().then(e=>{t&&f(e)}).catch(()=>{}),()=>{t=!1,s()}},[]);let eK=e.in_progress.map(e=>e.id).join(",");(0,r.useEffect)(()=>{let e=!0;for(let t of eK?eK.split(","):[])e$(t).then(s=>{e&&s&&o(e=>e[t]?e:{...e,[t]:s})});return()=>{e=!1}},[eK]),(0,r.useEffect)(()=>{let t=new Set(Object.values(e).flat().map(e=>e.id));ep(e=>e.every(e=>t.has(e.taskId))?e:e.filter(e=>t.has(e.taskId))),ef(e=>e&&!t.has(e)?null:e)},[e]);let eG=()=>er("選擇專案資料夾"),eH=(e,t)=>{let s=`terminal_${window.crypto.randomUUID()}`;eN(s),eb(n=>[...n,{pending:!0,sessionKey:s,title:e?sM(e):"~",...e?{projectPath:e}:{},...t?{taskId:t}:{}}]),eA("terminals")},eJ=(e,t)=>{eA("board"),ep(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]}),ef(e)},eU=(0,r.useRef)(eJ);eU.current=eJ;let eW=(0,r.useRef)(ex);eW.current=ex;let eY=(0,r.useRef)(c);eY.current=c;let eq=(0,r.useCallback)(e=>{m(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=eY.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(m(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(),eU.current(e),s.close()}}},(t=R())?t.onProgressNotify(e):()=>{}},[]);let eX=e=>{ep(t=>t.some(t=>t.taskId===e&&t.preview)?t.map(t=>t.taskId===e?{...t,preview:!1}:t):t)},eQ=e=>{let t=new Set(e);if(ex&&t.has(ex)){let e=eh.findIndex(e=>e.taskId===ex),s=eh.slice(e+1).find(e=>!t.has(e.taskId)),n=eh.slice(0,Math.max(e,0)).reverse().find(e=>!t.has(e.taskId));ef(s?.taskId??n?.taskId??null)}ep(e=>e.filter(e=>!t.has(e.taskId)))},eZ=()=>{eA("board"),W(null),ew(null),eC(e=>e+1),ef(null)},e0=async(e,s)=>{let n,r=await ed({baseBranch:null,...(n=[e.url,e.body.trim()].filter(Boolean).join("\n\n"),{title:e.title,description:n,..."pr"===e.kind?{branch:e.headRefName,baseBranch:e.baseRefName}:{},github:{kind:e.kind,repo:e.repo,number:e.number,url:e.url}}),projectPath:s,autoMode:N});if(!r)throw Error("未連線到 VibeFlow core");return t(r.state.board),r.task.id},e1=async(e,t,s,n,r)=>{V(!0),G(null);try{await _({systemPrompt:e,workstationPath:t||void 0,autoMode:s,notifications:n,jira:{storyPointsFields:r}}),C(e),A(t),w(s),d(n),E(r),D(!1)}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(!1)}},e5=async(e,s,n,r,a,i,l,o,c,d)=>{J(!0),W(null);try{let u=await ed({title:e,description:s,projectPath:n,baseBranch:r,branch:a||void 0,agentCli:i,model:l||void 0,effort:o,autoMode:c,attachments:d});u&&(t(u.state.board),eJ(u.task.id,{pin:!0}))}catch(e){W(e instanceof Error?e.message:String(e))}finally{J(!1)}},e2=async e=>{if(Y){et(!0),en(null);try{let s=await eu({taskId:Y.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),q(null)}catch(e){en(e instanceof Error?e.message:String(e))}finally{et(!1)}}},e3=async e=>{let s=await eP(e);s&&t(s.board)},e4=async e=>{let s=await eI(e);s&&(t(s.board),eQ([e]))},e6=eh.flatMap(t=>{for(let s of rd){let n=e[s].find(e=>e.id===t.taskId);if(n)return[{...t,title:n.title,column:s}]}return[]}),e7=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 H({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,$),e8=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 s=++c.current;i(!0),o(null);try{let r=await Q({force:e,scope:t});s===c.current&&r&&n(e=>({scope:t,inbox:r.error&&e?.scope===t&&"ok"===e.inbox.status&&e.inbox.tickets.length?{...e.inbox,error:r.error}:r}))}catch(e){s===c.current&&o(e instanceof Error?e.message:String(e))}finally{s===c.current&&i(!1)}},[t]);return(0,r.useEffect)(()=>{e&&d(!1)},[e,d]),(0,r.useEffect)(()=>X(e=>{("success"===e.type||"signed-out"===e.type)&&d(!0)}),[d]),{inbox:s?.scope===t?s.inbox:null,loading:a,error:l,refresh:()=>d(!0),reload:()=>d(!1)}}($,eD),e9=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 Z({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,$),te=[...e.in_progress,...e.backlog,...e.done],tt=function(e){let t=new Map;for(let s of e)s.github&&t.set(eO(s.github),s.id);return t}(te),ts=function(e){let t=new Map;for(let s of e)s.jira&&!t.has(s.jira.key)&&t.set(s.jira.key,s.id);return t}(te),tn=eR??(e8.inbox?.status==="ok"?"jira":"issues"),tr=Array.from(new Map([...te.filter(e=>e.projectPath).map(e=>[e.projectPath,{path:e.projectPath,name:e.projectName??e.projectPath}]),...e_.filter(e=>!e.missing).map(e=>[e.path,{path:e.path,name:e.name}])]).values()).sort((e,t)=>e.name.localeCompare(t.name));(0,r.useEffect)(()=>{$&&ei().then(eV)},[$,e.backlog.length]);let ta=async(e,s)=>{let n={title:`${e.key} ${e.summary}`,description:[e.url,e.description].filter(Boolean).join("\n\n"),jira:{key:e.key,url:e.url,site:new URL(e.url).host}},r=await ed({...n,projectPath:s,baseBranch:null,autoMode:N});if(!r)throw Error("未連線到 VibeFlow core");return t(r.state.board),r.task.id},ti=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:n8(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;eB(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 M(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=n8(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:n8(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=R())?t.term.onData(e):()=>{}}},[a]),{roomCode:a,peerCount:l,startSharing:()=>{i(String(Math.floor(1e5+9e5*Math.random())))},stopSharing:()=>i(null)}}({board:e,autoMode:N,onStateChange:e=>{t(e),M(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:$?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(nN,{view:eS,onSelectView:eA,onNewTask:eZ,remoteActive:!!ti.roomCode,onOpenSettings:()=>{G(null),D(!0)}}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[x&&h!==x.latestVersion&&(0,n.jsxs)("div",{role:"status",className:"flex items-center gap-3 border-b border-border bg-primary/10 px-4 py-2 text-sm",children:[(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[x.installedVersion?(0,n.jsxs)(n.Fragment,{children:["VibeFlow v",x.installedVersion," 已安裝,但 host 沒有自動重新啟動:",x.restartBlocked,"。 要立即使用新版,請執行 ",(0,n.jsx)("code",{children:"vibeflow shutdown"})," 後再執行 ",(0,n.jsx)("code",{children:"vibeflow"}),"。"]}):(0,n.jsxs)(n.Fragment,{children:["VibeFlow v",x.latestVersion," 已發布(目前 v",x.currentVersion,")。 按下更新會開啟系統終端機執行更新指令(Windows:",(0,n.jsx)("code",{children:"vibeflow update"}),";其他平台:",(0,n.jsx)("code",{children:"sudo vibeflow update"}),")。安裝完成後 host 會自動重新啟動。"]}),g&&(0,n.jsx)("span",{role:"alert",className:"block text-destructive",children:g})]}),!x.installedVersion&&(0,n.jsx)("button",{type:"button",disabled:j,onClick:()=>{v(!0),b(null),L().catch(e=>{b(e instanceof Error?e.message:"無法開啟更新終端機")}).finally(()=>v(!1))},className:"shrink-0 rounded-sm border border-border bg-background px-3 py-1 hover:bg-accent focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:j?"開啟中…":"更新 VibeFlow"}),(0,n.jsx)("button",{type:"button","aria-label":"關閉更新提示",onClick:()=>p(x.latestVersion),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)(tv.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1",children:[(0,n.jsx)("div",{className:"terminals"===eS?"hidden":"h-full",children:(0,n.jsx)(sQ,{tabBar:(0,n.jsx)(n5,{entries:e6,activeTaskId:ex,onSelect:eJ,onPin:eX,onClose:e=>eQ([e]),onReorder:e=>{ep(t=>{let s=new Map(e.map((e,t)=>[e,t]));return[...t].sort((e,t)=>(s.get(e.taskId)??1/0)-(s.get(t.taskId)??1/0))})}}),onSelectTask:eJ,onNewTask:eZ,board:e,onBoardChange:e=>{t(e),M(e)},onEditTask:t=>{en(null),e.backlog.some(e=>e.id===t)&&q(ru(e,t))},onTaskDone:e3,onDeleteTask:e4,onOpenTaskTerminal:t=>{let s=ru(e,t);s?.projectPath&&eH(s.projectPath,t)},taskTerminals:eg,onShowTaskTerminal:e=>{eN(e),eA("terminals")},autoMode:N,workstationPath:S,progress:a,selectedTaskId:ex,onTaskInteract:eX,openTabIds:eh.map(e=>e.taskId),initialProjectPath:ey,newTaskNonce:ek,view:eS,onViewChange:eA,taskLinks:e9.links,githubView:(0,n.jsx)(nq,{view:eS,onViewChange:eA,tab:tn,onTabChange:eT,jira:{...e8,scope:eD,onScopeChange:eM},github:{...e7,refresh:()=>{e7.refresh(),e9.refresh()}},githubFilters:ez,onGithubFiltersChange:(e,t)=>eE(s=>({...s,[e]:t})),jiraCards:ts,githubCards:tt,projects:tr,onBrowseProject:eG,onCreateJira:ta,onConvertGithub:e0,onOpenTask:e=>{eA("board"),eJ(e,{pin:!0})},onOpenSettings:()=>{G(null),D(!0)}}),creating:O,createError:U,pickFolder:eG,loadRecentProjects:ei,loadGitInfo:ea,initRepository:el,detectAgents:eo,onCreateTask:e5})}),(0,n.jsx)("div",{className:"terminals"===eS?"h-full":"hidden",children:(0,n.jsx)(s0,{view:eS,onViewChange:eA,terminals:eg,taskWorktreePaths:Object.fromEntries([...e.in_progress,...e.done].filter(e=>e.worktreePath).map(e=>[e.id,e.worktreePath])),focusedSessionKey:ev,recentProjects:e_,onCreate:e=>eH(e),onRename:(e,t)=>{let s=ej.current.find(t=>t.sessionKey===e);eb(s=>s.map(s=>s.sessionKey===e?{...s,title:t}:s)),s&&!s.pending&&eF(e,t).catch(()=>{})},onStarted:e=>{let t=ej.current.find(t=>t.sessionKey===e);t?.pending&&(eb(t=>t.map(t=>t.sessionKey===e?(({pending:e,...t})=>t)(t):t)),eF(e,t.title).catch(()=>{}))},onClose:e=>{eL(e),eb(t=>t.filter(t=>t.sessionKey!==e)),eN(t=>t===e?null:t)},onBrowse:eG})})]})]})]}),(0,n.jsx)(s5,{task:Y,defaultAutoMode:N,detectAgents:eo,pickFolder:eG,loadRecentProjects:ei,loadGitInfo:ea,saving:ee,error:es,onSubmit:e2,onClose:()=>q(null)}),(0,n.jsx)(np,{open:I,systemPrompt:k,workstationPath:S,autoMode:N,notifications:c,jiraStoryPointsFields:z,saving:B,error:K,onSave:e1,onPickFolder:()=>er("選擇工作區資料夾"),onClose:()=>D(!1)}),(0,n.jsx)(l.N,{children:O&&(0,n.jsx)(tJ,{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)(y.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:ec&&ti.roomCode&&(0,n.jsx)(n4,{roomCode:ti.roomCode,peerCount:ti.peerCount,onClose:()=>em(!1),onStop:()=>{ti.stopSharing(),em(!1)}},"remote-share-dialog")}),(0,n.jsx)(n7,{toasts:u,onOpen:e=>eU.current(e),onDismiss:eq})]}):(0,n.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground",children:"載入中…"})})]})}}},e=>{e.O(0,[8760,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);
|
package/dist/web/_next/static/{Zo3ZVJ1bFZjYU3Bt-ZmLO → rb9awHxbd75L3Vz0R-TtG}/_buildManifest.js
RENAMED
|
@@ -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/8760-7450ee0068d05bca.js","static/chunks/pages/home-
|
|
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/8760-7450ee0068d05bca.js","static/chunks/pages/home-8e76d4b251bec98a.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
package/dist/web/home/index.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=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/517bd79243800caf.css" as="style"/><link rel="stylesheet" href="/_next/static/css/517bd79243800caf.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-30f420d055cbcd0c.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-401e9322101b6533.js" defer=""></script><script src="/_next/static/chunks/8760-7450ee0068d05bca.js" defer=""></script><script src="/_next/static/chunks/pages/home-
|
|
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=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/517bd79243800caf.css" as="style"/><link rel="stylesheet" href="/_next/static/css/517bd79243800caf.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-30f420d055cbcd0c.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-401e9322101b6533.js" defer=""></script><script src="/_next/static/chunks/8760-7450ee0068d05bca.js" defer=""></script><script src="/_next/static/chunks/pages/home-8e76d4b251bec98a.js" defer=""></script><script src="/_next/static/rb9awHxbd75L3Vz0R-TtG/_buildManifest.js" defer=""></script><script src="/_next/static/rb9awHxbd75L3Vz0R-TtG/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div class="bg-background text-foreground"><div class="flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground">載入中…</div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/home","query":{},"buildId":"rb9awHxbd75L3Vz0R-TtG","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
|
package/package.json
CHANGED
/package/dist/web/_next/static/{Zo3ZVJ1bFZjYU3Bt-ZmLO → rb9awHxbd75L3Vz0R-TtG}/_ssgManifest.js
RENAMED
|
File without changes
|