@kw-yeh/vibeflow 4.11.19 → 4.11.21

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 CHANGED
@@ -552,7 +552,10 @@ function claudeResumeOrFresh(sessionId, worktreePath, tail) {
552
552
  return `if [ -f ${sessionFile} ]; then claude --resume ${sessionId} ${tail}; else claude --session-id ${sessionId} ${tail}; fi\r`;
553
553
  }
554
554
  function buildClaudeSettings(worktreePath) {
555
- const settings = { theme: "dark" };
555
+ const settings = {
556
+ theme: "dark",
557
+ env: { CLAUDE_CODE_ENABLE_TODO_TOOLS: "1" }
558
+ };
556
559
  if (worktreePath) {
557
560
  const dir = `${toShellPath(worktreePath)}/${SUBAGENTS_DIR2}`;
558
561
  const command = `mkdir -p "${dir}" && cat > "${dir}/$(date +%s)-$$-$RANDOM.json"`;
@@ -5928,15 +5931,14 @@ async function logoutJira(run3 = defaultAcliRunner) {
5928
5931
  // packages/core/src/jira.ts
5929
5932
  var asRaw = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
5930
5933
  var nameOf = (v) => typeof v === "string" ? v : String(asRaw(v).name ?? "");
5931
- var JIRA_INBOX_JQL = "assignee = currentUser() AND (statusCategory != Done OR sprint in openSprints()) ORDER BY updated DESC";
5934
+ var JIRA_INBOX_JQL = "assignee = currentUser() ORDER BY updated DESC";
5932
5935
  var JIRA_SCOPE_JQL = {
5933
- current: JIRA_INBOX_JQL,
5934
5936
  sprint: "assignee = currentUser() AND sprint in openSprints() ORDER BY updated DESC",
5935
- all: "assignee = currentUser() ORDER BY updated DESC"
5937
+ all: JIRA_INBOX_JQL
5936
5938
  };
5937
5939
  var DEFAULT_POINT_FIELDS = ["customfield_10033", "customfield_10016"];
5938
5940
  var JIRA_CACHE_TTL_MS = 5 * 60 * 1e3;
5939
- function buildSearchArgs(scope = "current") {
5941
+ function buildSearchArgs(scope = "sprint") {
5940
5942
  return [
5941
5943
  "jira",
5942
5944
  "workitem",
@@ -5946,8 +5948,7 @@ function buildSearchArgs(scope = "current") {
5946
5948
  "--fields",
5947
5949
  "key,summary,status,issuetype,priority,description",
5948
5950
  "--json",
5949
- "--paginate",
5950
- ...scope === "all" ? [] : ["--limit", "200"]
5951
+ "--paginate"
5951
5952
  ];
5952
5953
  }
5953
5954
  function buildViewArgs(key, pointFields = DEFAULT_POINT_FIELDS) {
@@ -6053,7 +6054,7 @@ function createJiraService(options) {
6053
6054
  const auth = await authStatus();
6054
6055
  if (!auth.installed) return { status: "acli-missing", fetchedAt: 0, tickets: [] };
6055
6056
  if (!auth.authenticated || !auth.site) return { status: "unauthenticated", fetchedAt: 0, tickets: [] };
6056
- const scope = opts.scope ?? "current";
6057
+ const scope = opts.scope ?? "sprint";
6057
6058
  const cacheKey = `${auth.site}:${scope}`;
6058
6059
  const cached2 = cache.get(cacheKey);
6059
6060
  if (cached2 && !opts.force && now() - cached2.at < JIRA_CACHE_TTL_MS) return cached2.value;
@@ -7097,7 +7098,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
7097
7098
  },
7098
7099
  "jira:inbox": (payload) => {
7099
7100
  const p = payload === void 0 ? {} : obj(payload, "payload");
7100
- if (p.scope !== void 0 && p.scope !== "current" && p.scope !== "sprint" && p.scope !== "all") {
7101
+ if (p.scope !== void 0 && p.scope !== "sprint" && p.scope !== "all") {
7101
7102
  throw Object.assign(new Error("Invalid Jira scope"), { code: "INVALID_REQUEST" });
7102
7103
  }
7103
7104
  return jira.inbox({ force: p.force === true, scope: p.scope });
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/f8f64877c884206d.css" as="style"/><link rel="stylesheet" href="/_next/static/css/f8f64877c884206d.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-33344f7100190436.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-2571a2564f593899.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/76irYAZpsrcN0YAWmxJ47/_buildManifest.js" defer=""></script><script src="/_next/static/76irYAZpsrcN0YAWmxJ47/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"76irYAZpsrcN0YAWmxJ47","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/f8f64877c884206d.css" as="style"/><link rel="stylesheet" href="/_next/static/css/f8f64877c884206d.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-33344f7100190436.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-2571a2564f593899.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/m3seMgh7dEHDU9k_2URFv/_buildManifest.js" defer=""></script><script src="/_next/static/m3seMgh7dEHDU9k_2URFv/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"m3seMgh7dEHDU9k_2URFv","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
package/dist/web/404.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/f8f64877c884206d.css" as="style"/><link rel="stylesheet" href="/_next/static/css/f8f64877c884206d.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-33344f7100190436.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-2571a2564f593899.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/76irYAZpsrcN0YAWmxJ47/_buildManifest.js" defer=""></script><script src="/_next/static/76irYAZpsrcN0YAWmxJ47/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"76irYAZpsrcN0YAWmxJ47","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/f8f64877c884206d.css" as="style"/><link rel="stylesheet" href="/_next/static/css/f8f64877c884206d.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-33344f7100190436.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-2571a2564f593899.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/m3seMgh7dEHDU9k_2URFv/_buildManifest.js" defer=""></script><script src="/_next/static/m3seMgh7dEHDU9k_2URFv/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"m3seMgh7dEHDU9k_2URFv","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -10,4 +10,4 @@ name: ${t}
10
10
  description:
11
11
  ---
12
12
 
13
- `}function s1({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)(sh,"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)(ty,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(ty,{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}),sQ.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=sZ[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)(ty,{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)(sq.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(ty,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:s0(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===s0(e,u.name)?s0(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,z.cn)(sh,"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)(sh,"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)(sh,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(ty,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return N("create",async()=>{await ek(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)(ty,{variant:"ghost",size:"sm",onClick:()=>{N(`open:${e.key}`,async()=>{h({entry:e,content:await ew(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.builtin?.modified&&(0,n.jsxs)(ty,{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)(sX.A,{className:"size-3.5"}),b===e.name?"確定覆蓋?":"還原預設"]}),e.sourcePath&&(0,n.jsx)(ty,{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)(tp.A,{className:"size-3.5"})}),(0,n.jsx)(ty,{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)(ty,{variant:"ghost",size:"sm",onClick:()=>void N(`restore:${e}`,()=>eA(e)),disabled:null!==l,title:"放回 VibeFlow 出貨的版本",children:[(0,n.jsx)(sX.A,{className:"size-3.5"}),e]},e))]})]})}function s5({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)=>tS(t),hover:(e,t)=>tA(u,t),leave:()=>tz(u)}}),m=new r;u.loadAddon(m),u.loadAddon(new d((e,t)=>tS(t),{hover:(e,t)=>tA(u,t),leave:()=>tz(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 s2(e,t){return e instanceof Error&&e.message?e.message:t}function s3({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)(ty,{variant:"outline",size:"sm",disabled:t,onClick:()=>{s(!0),o(null),m(null),F().then(i).catch(e=>{i(null),o(s2(e,"無法連線到 npm registry"))}).finally(()=>s(!1))},children:[t?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(tp.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)(ty,{size:"sm",disabled:c,onClick:()=>{d(!0),m(null),_().catch(e=>m(s2(e,"無法開啟更新終端機"))).finally(()=>d(!1))},children:c?"開啟中…":"更新 VibeFlow"}),u&&(0,n.jsx)("p",{role:"alert",className:"text-destructive",children:u})]})]})}var s4=s(63252);let s6={enabled:!0,stepCompleted:!1,allCompleted:!0,waitingInput:!0,desktop:!1};function s7(e){return{...s6,...e??{}}}function s8(){return"Notification"in window?Notification.permission:"unsupported"}function s9({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 ne({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)(s9,{checked:s,label:e,disabled:r,onChange:a})]})}function nt({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)(s4.A,{className:"size-4 text-muted-foreground"}),"通知"]}),(0,n.jsx)(s9,{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)(ne,{label:"步驟完成",hint:"待辦清單中每完成一項就通知",checked:e.stepCompleted,disabled:i,onChange:e=>a({stepCompleted:e})}),(0,n.jsx)(ne,{label:"全部步驟完成",checked:e.allCompleted,disabled:i,onChange:e=>a({allCompleted:e})}),(0,n.jsx)(ne,{label:"等待輸入",hint:"Agent 停下來等你回覆或允許權限",checked:e.waitingInput,disabled:i,onChange:e=>a({waitingInput:e})}),(0,n.jsx)(ne,{label:"桌面通知",hint:s?"瀏覽器已封鎖通知,請在瀏覽器的網站設定中允許。":"頁面不在前景時也會跳出系統通知",checked:e.desktop&&!s,disabled:i,onChange:async e=>{if(!e)return a({desktop:!1});a({desktop:await r()})}})]})]})}let ns=[{id:"claude",name:"Claude Code"},{id:"codex",name:"Codex CLI"}],nn={builtin:"內建清單","claude-cli":"Claude Code CLI","codex-app-server":"Codex CLI","codex-cache":"Codex 本機快取"};function nr({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,k]=(0,r.useState)(!0),[w,C]=(0,r.useState)(i),[S,A]=(0,r.useState)(""),[E,P]=(0,r.useState)(!1),[$,I]=(0,r.useState)({}),[T,B]=(0,r.useState)(null),[F,_]=(0,r.useState)(void 0),[L,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),[ek,ew]=(0,r.useState)(null),[eC,eS]=(0,r.useState)("idle"),[eA,ez]=(0,r.useState)(""),[eP,e$]=(0,r.useState)("https://github.com/login/device"),[eI,eR]=(0,r.useState)(null),[eT,eD]=(0,r.useState)(!1),[eB,eF]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(p(t),v(s),k(a),C(i),A(o.join(", ")),P("denied"===s8()||"unsupported"===s8()),ei(!1),M(""),Z(null),_(void 0),V().then(_).catch(e=>{_(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),eF(!1),O().then(ew))},[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)}),ns))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 e_=async e=>{B(e);try{let t=await ec(e,!0).catch(()=>null);I(s=>({...s,[e]:t}))}finally{B(null)}},eL=async()=>{if(L.trim()){Y(!0),Z(null);try{let e=await K(L);if(!e)throw Error("未連線到 VibeFlow core");_(e),M("")}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(!1)}}},eM=async()=>{Y(!0),Z(null);try{let e=await G();if(!e)throw Error("未連線到 VibeFlow core");_(e),M("")}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),e$(e.url),eF(!1),eD(!1);return}if("success"===e.type){ew(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),eF(!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),eF(!1),ew(await O())},e0=async()=>{eD(!0),eR(null);try{let e=await es();ew(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),eF(!0),window.setTimeout(()=>eF(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(tK,{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)(ty,{variant:"ghost",size:"sm",onClick:()=>void e2(),children:"返回設定"}),(0,n.jsx)(ty,{size:"sm",disabled:c||eN||!eW,onClick:()=>m(eH,j.trim(),N,w,eU),children:"儲存設定"})]}):ea?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:()=>void eZ(),disabled:eT&&"success"!==eC,children:"success"===eC?"完成":"返回"}),"error"===eC&&(0,n.jsx)(ty,{size:"sm",onClick:()=>void eQ(),children:"重新登入"})]}):eV?eG?null:(0,n.jsxs)(ty,{variant:"ghost",size:"sm",onClick:()=>eK(!1),children:[(0,n.jsx)(sH.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:e1,disabled:c,children:"取消"}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>{eq&&m(eH,j.trim(),N,w,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)(sH.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)(s5,{output:eg,active:eN}),eu?.installed===!1?(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(ty,{variant:"outline",size:"sm",onClick:()=>void eE("https://developer.atlassian.com/cloud/acli/guides/install-acli/"),children:[(0,n.jsx)(ta.A,{}),"安裝說明"]}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>void J().then(em),children:[(0,n.jsx)(tp.A,{}),"重新檢查"]})]}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[eN?(0,n.jsx)(ty,{variant:"outline",size:"sm",onClick:()=>void W(),children:"取消"}):(0,n.jsx)(ty,{size:"sm",onClick:()=>void e5(),children:eu?.authenticated?"重新登入":"使用瀏覽器登入"}),eu?.authenticated&&(0,n.jsxs)(ty,{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)(sJ.A,{}),"登出"]}),eh&&(0,n.jsxs)(ty,{variant:"ghost",size:"sm",onClick:()=>void eE(eh),children:[(0,n.jsx)(ta.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)(sh,"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)(sH.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?`目前登入帳號:${ek?.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)(sU.A,{className:"size-4"}),eB?"已複製":"複製"]})]})]}),(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:eP,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(eP),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)(ta.A,{className:"size-4"}),"開啟"]})]})]})]})]}):eV?(0,n.jsx)(s1,{onEditingChange:eO}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(s3,{appVersion:g}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(sC,{value:N,onChange:k}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsx)("section",{className:"space-y-2",children:(0,n.jsx)(nt,{value:w,onChange:C,desktopBlocked:E,onRequestDesktop:async()=>{if("unsupported"===s8())return P(!0),!1;let e=await Notification.requestPermission()==="granted";return P(!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)(sh,"font-mono text-sm")}),(0,n.jsx)(ty,{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)(sh,"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)(ty,{variant:"secondary",size:"sm",onClick:()=>eK(!0),children:[(0,n.jsx)(sW.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===F?"讀取金鑰狀態中…":null===F?"無法讀取 Jev 金鑰狀態":"saved"===F.source?"已設定 Jev API key(本機儲存)":"environment"===F.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:L,onChange:e=>M(e.target.value),placeholder:"輸入 TypeSafe Jev API key",className:(0,z.cn)(sh,"min-w-48 flex-1 font-mono text-sm")}),(0,n.jsx)(ty,{size:"sm",disabled:H||!L.trim(),onClick:()=>void eL(),children:H?"處理中…":"儲存金鑰"}),F?.source==="saved"&&(0,n.jsx)(ty,{size:"sm",variant:"outline",disabled:H,onClick:()=>void eM(),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:[ns.map(e=>{let t=$[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 可用・來源:${nn[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)(ty,{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 e_(e.id),children:(0,n.jsx)(tp.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:[ek?.authenticated?(0,n.jsx)(eY.A,{className:"size-4 shrink-0 text-success"}):ek?.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:ek?.authenticated?`${ek.login??"GitHub"} 已授權(${ek.gitProtocol??"https"})`:ek?.installed===!1?"找不到 GitHub CLI(gh)":ek?.error?ek.error:"尚未授權"})]}),ek?.authenticated&&(0,n.jsx)(ty,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:eT,onClick:()=>void eQ(),children:"切換使用者"}),ek?.authenticated&&(0,n.jsxs)(ty,{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)(sJ.A,{className:"size-4"}),"登出"]}),!ek?.authenticated&&(0,n.jsx)(ty,{type:"button",size:"sm",variant:"outline",disabled:ek?.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 na=s(30592),ni=s(79751),nl=s(93202),no=s(51256);function nc({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)(P,{"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)(P,{"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)(na.A,{className:"size-4"})}),(0,n.jsx)(P,{"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)(ni.A,{className:"size-4"})}),(0,n.jsx)(P,{"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)(P,{"aria-label":"遠端控制",onClick:r,title:"遠端控制",className:(0,z.cn)("size-8",a&&"text-primary hover:text-primary"),children:(0,n.jsx)(nl.A,{className:"size-4"})}),(0,n.jsx)(P,{"aria-label":"設定 System Prompt",onClick:i,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(no.A,{className:"size-4"})})]})]})}var nd=s(32310),nu=s(2141),nm=s(4792);let nx={projects:[],assignees:[],authors:[]},nf=":unassigned",nh=(e,t)=>e.localeCompare(t);function np(e,t){return Array.from(new Set([...e,...t])).sort(nh)}function ng(e,t){return nh(e.projectName,t.projectName)||t.item.number-e.item.number}function nb(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,projectName:n}=e,{projects:r,assignees:a,authors:i}=t;return(!r.length||!!r.includes(n))&&(!a.length||!!(0===s.assignees.length?a.includes(nf):s.assignees.some(e=>a.includes(e.login))))&&(!i.length||!!(s.author&&i.includes(s.author.login)))})(e,s)).sort(ng)}function nj({name:e,allLabel:t,icon:s,options:a,value:i,onChange:l,optionLabel:o=e=>e}){let[c,d]=(0,r.useState)(!1),u=e8(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)(k.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",e9,"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)(w.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",e9,"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)(w.A,{className:"size-3 shrink-0"})]},e)})]})]})}function nv({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 nN({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 ny({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 nk({item:e}){return(0,n.jsxs)(n.Fragment,{children:["issue"===e.kind&&e.issueType&&(0,n.jsx)(ny,{className:"font-medium text-foreground",children:e.issueType.name}),"pr"===e.kind&&(0,n.jsx)(ny,{className:(0,z.cn)("font-medium",eV[e.state]),children:eK[e.state]}),"pr"===e.kind&&e.reviewDecision&&eG[e.reviewDecision]&&(0,n.jsx)(ny,{children:eG[e.reviewDecision]}),e.labels.map(e=>(0,n.jsxs)(ny,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))]})}function nw({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)(nv,{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)(nk,{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)(nN,{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)(nN,{user:e},e.login))})]})]})]})}function nC({label:e,children:t}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:e}),(0,n.jsx)("dd",{className:"min-w-0 text-foreground",children:t})]})}function nS({entry:e,taskId:t,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)(tK,{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)(ty,{variant:"outline",size:"sm",onClick:()=>void eE(d.url),children:[(0,n.jsx)(ta.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)(P,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",disabled:x,onClick:()=>void a().then(e=>{e&&b(e)}),children:(0,n.jsx)(tx.A,{className:"size-4"})})]}),v?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:()=>void j(),disabled:x||!g,title:"已經有對應卡片,仍可再建一張",children:"再建一張"}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>o(v),children:[(0,n.jsx)(nd.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)(ty,{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)(ny,{className:"bg-success/15 font-medium text-success",children:"Open"}):(0,n.jsx)(ny,{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)(nC,{label:"專案",children:e.projectName}),(0,n.jsx)(nC,{label:"發起人",children:d.author?.login??"—"}),(0,n.jsx)(nC,{label:"指派",children:(c=d.assignees).length?c.map(e=>e.login).join("、"):"—"}),(0,n.jsx)(nC,{label:"建立時間",children:eJ(d.createdAt)}),"issue"===d.kind&&(0,n.jsx)(nC,{label:"Issue Type",children:d.issueType?.name??"—"}),"pr"===d.kind&&(0,n.jsx)(nC,{label:"分支",children:(0,n.jsxs)("span",{className:"break-all",children:[d.headRefName," → ",d.baseRefName]})}),"pr"===d.kind&&d.reviewDecision&&(0,n.jsx)(nC,{label:"Review",children:eG[d.reviewDecision]??d.reviewDecision}),d.labels.length>0&&(0,n.jsx)(nC,{label:"Labels",children:(0,n.jsx)("span",{className:"flex flex-wrap gap-1",children:d.labels.map(e=>(0,n.jsxs)(ny,{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)(nC,{label:"Milestone",children:d.milestone})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:d.body.trim()?(0,n.jsx)(tv,{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 nA({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 nz({label:e,entries:t,empty:s,selectedKey:r,boardCards:a,now:i,onSelect:l}){return(0,n.jsxs)("section",{className:"flex min-h-0 flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 px-1",children:[(0,n.jsx)("h2",{className:A,children:e}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:t.length})]}),(0,n.jsx)("div",{className:"grid min-h-0 flex-1 grid-cols-[repeat(auto-fill,minmax(min(100%,300px),1fr))] content-start gap-3 overflow-y-auto rounded-md p-1",children:0===t.length?(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/60",children:s}):t.map(e=>{let t=eO(e.item);return(0,n.jsx)(nw,{entry:e,selected:t===r,onBoard:a.has(t),now:i,onSelect:()=>l(t)},t)})})]})}let nE=e=>e===nf?"未指派":e;function nP({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:b=!1}){let j,v,[N,y]=(0,r.useState)(null),k=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:[],C=(v=w.flatMap(e=>p?e[p]:[...e.issues,...e.prs]),{projects:np(w.map(e=>e.projectName),o.projects),assignees:[nf,...np(v.flatMap(e=>e.assignees.map(e=>e.login)),o.assignees.filter(e=>e!==nf))],authors:np(v.flatMap(e=>e.author?[e.author.login]:[]),o.authors)}),S=o.projects.length>0||o.assignees.length>0||o.authors.length>0,A=nb(w,"issues",o),E=nb(w,"prs",o),$=w.filter(e=>e.error&&(0===o.projects.length||o.projects.includes(e.projectName))),R=[..."prs"===p?[]:A,..."issues"===p?[]:E].find(e=>eO(e.item)===N)??null,T=s?.status==="ok"&&null!==N&&null===R;(0,r.useEffect)(()=>{T&&y(null)},[T]);let D=e=>t=>c({...o,[e]:t}),B=s?.fetchedAt??0,F=B?`${eH(new Date(B).toISOString(),k)}更新`:null;return j=s?"gh-missing"===s.status?(0,n.jsx)(nA,{children:"找不到 GitHub CLI(gh)。安裝後按右上角的重新整理,就能看到指派給你或你建立的 Issue 與 PR。"}):"unauthenticated"===s.status?(0,n.jsx)(nA,{action:(0,n.jsx)(ty,{size:"sm",onClick:h,children:"開啟設定登入 GitHub"}),children:"GitHub CLI 尚未登入。"}):0===w.length?(0,n.jsx)(nA,{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:[($.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}),$.map(e=>(0,n.jsxs)("p",{className:"truncate",title:e.error,children:[e.repo,":",e.error]},e.repo))]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1",children:["prs"!==p&&(0,n.jsx)(nz,{label:"Issues",entries:A,empty:S?"沒有符合篩選條件的 Issue":"沒有指派給你或你建立的 open Issue",selectedKey:N,boardCards:d,now:k,onSelect:y}),"issues"!==p&&(0,n.jsx)(nz,{label:"Pull Requests",entries:E,empty:S?"沒有符合篩選條件的 PR":"沒有指派給你、你建立、請你 review 或你 review 過的 open PR",selectedKey:N,boardCards:d,now:k,onSelect:y})]})]}):a?(0,n.jsx)(nA,{children:"讀取 GitHub 中…"}):i?(0,n.jsx)(nA,{children:i}):null,(0,n.jsxs)("div",{className:(0,z.cn)("flex min-h-0 flex-col bg-background",b?"flex-1":"h-full"),onKeyDown:e=>{"Escape"===e.key&&N&&(e.stopPropagation(),y(null))},children:[(0,n.jsxs)("div",{className:(0,z.cn)("flex shrink-0 items-center gap-3 border-b border-border px-5",b?"h-11":"h-12"),children:[!b&&(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"})]}),(0,n.jsx)(nj,{name:"專案",allLabel:"所有專案",icon:g.A,options:C.projects,value:o.projects,onChange:D("projects")}),"issues"!==p&&(0,n.jsx)(nj,{name:"Assignee",allLabel:"所有 Assignee",icon:nu.A,options:C.assignees,value:o.assignees,onChange:D("assignees"),optionLabel:nE}),"issues"!==p&&(0,n.jsx)(nj,{name:"發起人",allLabel:"所有發起人",icon:nm.A,options:C.authors,value:o.authors,onChange:D("authors")}),S&&(0,n.jsxs)("button",{type:"button",onClick:()=>c(nx),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)(tb.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?`${A.length} 筆`:"prs"===p?`${E.length} 筆`:"指派給我、我建立、我 review 的",F?` \xb7 ${F}`:""]}),(0,n.jsx)(P,{"aria-label":"重新整理 Issue 與 PR",title:"重新整理",onClick:l,disabled:a,children:(0,n.jsx)(tp.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:j}),R&&(0,n.jsx)(nS,{entry:R,taskId:d.get(eO(R.item)),projects:u,onBrowseProject:m,onClose:()=>y(null),onConvert:e=>x(R.item,e),onOpenTask:f},eO(R.item))]})]})}var n$=s(85499);function nI(e){return Number(e.split("-").at(-1))||0}function nR(e,t){return e.dueDate?t.dueDate?e.dueDate.localeCompare(t.dueDate)||nI(t.key)-nI(e.key):-1:t.dueDate?1:nI(t.key)-nI(e.key)}let nT={new:"bg-accent text-muted-foreground",indeterminate:"bg-primary/15 text-primary",done:"bg-success/15 text-success"};function nD(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 nB({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),[k,w]=(0,r.useState)(null),[S,A]=(0,r.useState)(null),[E,$]=(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(nR)}))}(I),T=I.find(e=>e.key===p),D=T?c.get(T.key):void 0,B=k??D;(0,r.useEffect)(()=>{p&&e?.status==="ok"&&!T&&g(null)},[p,T,e?.status]);let F=async()=>{if(T&&b&&!v){N(!0),A(null);try{let e=await m(T,b);w(e),$(!1)}catch(e){A(e instanceof Error?e.message:String(e))}finally{N(!1)}}},_=(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)(ty,{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:"current",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)(P,{"aria-label":"重新整理 Jira ticket",title:"重新整理 Jira ticket",onClick:o,disabled:t,children:(0,n.jsx)(tp.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"?_("找不到 Atlassian CLI(acli)。安裝並登入後就能看到指派給你的 Jira ticket。",!0):e?.status==="unauthenticated"?_("尚未登入 Atlassian。",!0):e?e.error&&0===I.length?_(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=nD(e.dueDate);return(0,n.jsxs)("button",{type:"button",onClick:()=>{g(e.key),j(""),A(null),w(null),$(!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",nT[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))})]}):_(t?"讀取 Jira 中…":s??"無法讀取 Jira ticket"),(0,n.jsx)(l.N,{children:T&&(0,n.jsx)(tK,{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:[k&&(0,n.jsx)("span",{className:"text-sm text-success",children:"已建立到 Backlog"}),B&&!E?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",title:"已經有對應卡片,仍可再建一張",onClick:()=>{$(!0),w(null),j("")},children:"再建一張"}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>{g(null),x(B)},children:[(0,n.jsx)(nd.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)(P,{"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)(tx.A,{className:"size-4"})}),(0,n.jsxs)(ty,{size:"sm",disabled:!b||v,title:b?void 0:"先選擇要建立到哪個專案",onClick:()=>void F(),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)(ta.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:nD(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)(ta.A,{className:"size-3"})]})})]})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:T.description?(0,n.jsx)(tv,{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)(n$.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 nF=[{id:"jira",label:"Jira"},{id:"issues",label:"Issues"},{id:"prs",label:"Pull Requests"}];function n_({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:nF.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+nF.length)%nF.length;b.current[n]?.focus(),a(nF[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)(nB,{...i,onRefresh:i.refresh,boardCards:d,projects:m,onBrowseProject:x,onCreate:f,onOpenTask:p,onOpenSettings:g}):(0,n.jsx)(nP,{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})]})}function nL({entries:e,activeTaskId:t,onSelect:s,onPin:r,onClose:a}){return 0===e.length?null:(0,n.jsx)("div",{className:"flex h-9 shrink-0 items-stretch overflow-x-auto overflow-y-hidden border-b border-border bg-card/40",children:e.map(e=>{let i=e.taskId===t;return(0,n.jsxs)("div",{className:(0,z.cn)("group flex h-full min-w-0 max-w-52 shrink-0 items-center gap-1 border-r border-border/60 pl-3 pr-1.5 transition-colors motion-reduce:transition-none",i?"bg-background text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"),children:[(0,n.jsxs)("button",{type:"button","aria-current":i?"page":void 0,title:e.title,onClick:()=>s(e.taskId),onDoubleClick:()=>r(e.taskId),onAuxClick:t=>{1===t.button&&a(e.taskId)},className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm py-0.5 text-left text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:(0,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:()=>a(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",i?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(tb.A,{className:"size-3"})})]},e.taskId)})})}var nM=s(4504);function nV({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)(tK,{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)(nM.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)(w.A,{className:"size-3.5"}):(0,n.jsx)(tm.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(ty,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function nK({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)(s4.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)(P,{"aria-label":"關閉通知",onClick:()=>s(e.id),className:"size-5 p-0.5",children:(0,n.jsx)(tb.A,{className:"size-3.5"})})]})}function nG({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)(nK,{toast:e,onOpen:t,onDismiss:s},e.id))})})}function nO(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 nH=["board","github","terminals"],nJ=["jira","issues","prs"],nU="vibeflow:terminal-tabs",nW="vibeflow:inbox-tab",nY="vibeflow:github-filters",nq="vibeflow:jira-scope";function nX(e){try{let t=window.localStorage.getItem(e);return null===t?null:JSON.parse(t)}catch{return null}}function nQ(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}let nZ=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);function n0(e){let t=e??{};return{projects:nZ(t.projects)?t.projects:nx.projects,assignees:nZ(t.assignees)?t.assignees:nx.assignees,authors:nZ(t.authors)?t.authors:nx.authors}}let n1={backlog:[],in_progress:[],done:[]},n5=["in_progress","backlog","done"];function n2(e,t){for(let s of Object.values(e)){let e=s.find(e=>e.id===t);if(e)return e}return null}function n3(e,t){let s=new Set(t.map(e=>e.sessionKey));return[...t,...e.filter(e=>e.pending&&!s.has(e.sessionKey))]}function n4(){let[e,t]=(0,r.useState)(n1),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)(s7()),[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,k]=(0,r.useState)(!0),[w,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),[F,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,ek]=(0,r.useState)(null),[ew,eC]=(0,r.useState)(0),[eS,eA]=(0,r.useState)("board"),[ez,eE]=(0,r.useState)({issues:nx,prs:nx}),[eR,eT]=(0,r.useState)(null),[eD,eL]=(0,r.useState)("current"),[eM,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),k(s.settings.autoMode),C(s.settings.systemPrompt??""),A(s.settings.workstationPath??""),E(s.settings.jira?.storyPointsFields??[]),d(s7(s.settings.notifications)),eb(e=>n3(e,s.terminals??[])));let c={view:(r=(n=new URLSearchParams(window.location.search)).get("view"))&&nH.includes(r)?r:"board",taskId:n.get("task")||null};eA(c.view),ef(c.taskId);let u=Array.isArray(a=nX(nU))?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=nX(nW),nJ.includes(i)?i:null)),eL("sprint"===(l=nX(nq))||"all"===l?l:"current"),eE({issues:n0((o=nX(nY)??{}).issues),prs:n0(o.prs)}),$(!0)}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),k(e.settings.autoMode),C(e.settings.systemPrompt??""),A(e.settings.workstationPath??""),E(e.settings.jira?.storyPointsFields??[]),d(s7(e.settings.notifications)),eb(t=>n3(t,e.terminals??[]))},(s=R())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{let e;P&&(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))},[P,eS,ex]),(0,r.useEffect)(()=>{P&&nQ(nU,eh)},[P,eh]),(0,r.useEffect)(()=>{P&&nQ(nW,eR)},[P,eR]),(0,r.useEffect)(()=>{P&&nQ(nq,eD)},[P,eD]),(0,r.useEffect)(()=>{P&&nQ(nY,ez)},[P,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 B().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(","):[])eP(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:sA(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),ek(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 M({systemPrompt:e,workstationPath:t||void 0,autoMode:s,notifications:n,jira:{storyPointsFields:r}}),C(e),A(t),k(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 e$(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 n5){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,P),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)}}(P,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,P),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}]),...eM.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)(()=>{P&&ei().then(eV)},[P,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:nO(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;eF(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 L(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=nO(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:nO(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),L(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:P?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(nc,{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),_().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)(tb.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)(sM,{tabBar:(0,n.jsx)(nL,{entries:e6,activeTaskId:ex,onSelect:eJ,onPin:eX,onClose:e=>eQ([e])}),onSelectTask:eJ,onNewTask:eZ,board:e,onBoardChange:e=>{t(e),L(e)},onEditTask:t=>{en(null),e.backlog.some(e=>e.id===t)&&q(n2(e,t))},onTaskDone:e3,onDeleteTask:e4,onOpenTaskTerminal:t=>{let s=n2(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:ew,view:eS,onViewChange:eA,taskLinks:e9.links,githubView:(0,n.jsx)(n_,{view:eS,onViewChange:eA,tab:tn,onTabChange:eT,jira:{...e8,scope:eD,onScopeChange:eL},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)(sK,{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:eM,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&&eB(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)),eB(e,t.title).catch(()=>{}))},onClose:e=>{e_(e),eb(t=>t.filter(t=>t.sessionKey!==e)),eN(t=>t===e?null:t)},onBrowse:eG})})]})]})]}),(0,n.jsx)(sO,{task:Y,defaultAutoMode:N,detectAgents:eo,pickFolder:eG,loadRecentProjects:ei,loadGitInfo:ea,saving:ee,error:es,onSubmit:e2,onClose:()=>q(null)}),(0,n.jsx)(nr,{open:I,systemPrompt:w,workstationPath:S,autoMode:N,notifications:c,jiraStoryPointsFields:z,saving:F,error:K,onSave:e1,onPickFolder:()=>er("選擇工作區資料夾"),onClose:()=>D(!1)}),(0,n.jsx)(l.N,{children:O&&(0,n.jsx)(tK,{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)(nV,{roomCode:ti.roomCode,peerCount:ti.peerCount,onClose:()=>em(!1),onStop:()=>{ti.stopSharing(),em(!1)}},"remote-share-dialog")}),(0,n.jsx)(nG,{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,[9296,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);
13
+ `}function s1({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)(sh,"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)(ty,{variant:"ghost",size:"sm",onClick:()=>h(null),children:"取消"}),(0,n.jsx)(ty,{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}),sQ.map(({id:e,label:s,hint:r})=>{let i=t.filter(t=>t.kind===e),o=sZ[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)(ty,{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)(sq.A,{className:"size-3.5"}),"Import"]}),(0,n.jsxs)(ty,{variant:"ghost",size:"sm",onClick:()=>m({kind:e,name:"",content:s0(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===s0(e,u.name)?s0(e,s):u.content})},placeholder:"skill"===e?"skill 名稱(目錄名)":"檔名,如 house-rules.md",className:(0,z.cn)(sh,"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)(sh,"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)(sh,"resize-y font-mono text-sm leading-5")}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"取消"}),(0,n.jsx)(ty,{size:"sm",onClick:()=>void(()=>{if(!u)return;let{kind:e,name:t,content:s,description:n}=u;return N("create",async()=>{await ek(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)(ty,{variant:"ghost",size:"sm",onClick:()=>{N(`open:${e.key}`,async()=>{h({entry:e,content:await ew(e.kind,e.name)??""})})},disabled:null!==l,children:"編輯"}),e.builtin?.modified&&(0,n.jsxs)(ty,{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)(sX.A,{className:"size-3.5"}),b===e.name?"確定覆蓋?":"還原預設"]}),e.sourcePath&&(0,n.jsx)(ty,{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)(tp.A,{className:"size-3.5"})}),(0,n.jsx)(ty,{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)(ty,{variant:"ghost",size:"sm",onClick:()=>void N(`restore:${e}`,()=>eA(e)),disabled:null!==l,title:"放回 VibeFlow 出貨的版本",children:[(0,n.jsx)(sX.A,{className:"size-3.5"}),e]},e))]})]})}function s5({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)=>tS(t),hover:(e,t)=>tA(u,t),leave:()=>tz(u)}}),m=new r;u.loadAddon(m),u.loadAddon(new d((e,t)=>tS(t),{hover:(e,t)=>tA(u,t),leave:()=>tz(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 s2(e,t){return e instanceof Error&&e.message?e.message:t}function s3({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)(ty,{variant:"outline",size:"sm",disabled:t,onClick:()=>{s(!0),o(null),m(null),F().then(i).catch(e=>{i(null),o(s2(e,"無法連線到 npm registry"))}).finally(()=>s(!1))},children:[t?(0,n.jsx)(y.A,{className:"animate-spin"}):(0,n.jsx)(tp.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)(ty,{size:"sm",disabled:c,onClick:()=>{d(!0),m(null),_().catch(e=>m(s2(e,"無法開啟更新終端機"))).finally(()=>d(!1))},children:c?"開啟中…":"更新 VibeFlow"}),u&&(0,n.jsx)("p",{role:"alert",className:"text-destructive",children:u})]})]})}var s4=s(63252);let s6={enabled:!0,stepCompleted:!1,allCompleted:!0,waitingInput:!0,desktop:!1};function s7(e){return{...s6,...e??{}}}function s8(){return"Notification"in window?Notification.permission:"unsupported"}function s9({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 ne({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)(s9,{checked:s,label:e,disabled:r,onChange:a})]})}function nt({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)(s4.A,{className:"size-4 text-muted-foreground"}),"通知"]}),(0,n.jsx)(s9,{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)(ne,{label:"步驟完成",hint:"待辦清單中每完成一項就通知",checked:e.stepCompleted,disabled:i,onChange:e=>a({stepCompleted:e})}),(0,n.jsx)(ne,{label:"全部步驟完成",checked:e.allCompleted,disabled:i,onChange:e=>a({allCompleted:e})}),(0,n.jsx)(ne,{label:"等待輸入",hint:"Agent 停下來等你回覆或允許權限",checked:e.waitingInput,disabled:i,onChange:e=>a({waitingInput:e})}),(0,n.jsx)(ne,{label:"桌面通知",hint:s?"瀏覽器已封鎖通知,請在瀏覽器的網站設定中允許。":"頁面不在前景時也會跳出系統通知",checked:e.desktop&&!s,disabled:i,onChange:async e=>{if(!e)return a({desktop:!1});a({desktop:await r()})}})]})]})}let ns=[{id:"claude",name:"Claude Code"},{id:"codex",name:"Codex CLI"}],nn={builtin:"內建清單","claude-cli":"Claude Code CLI","codex-app-server":"Codex CLI","codex-cache":"Codex 本機快取"};function nr({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,k]=(0,r.useState)(!0),[w,C]=(0,r.useState)(i),[S,A]=(0,r.useState)(""),[E,P]=(0,r.useState)(!1),[$,I]=(0,r.useState)({}),[T,B]=(0,r.useState)(null),[F,_]=(0,r.useState)(void 0),[L,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),[ek,ew]=(0,r.useState)(null),[eC,eS]=(0,r.useState)("idle"),[eA,ez]=(0,r.useState)(""),[eP,e$]=(0,r.useState)("https://github.com/login/device"),[eI,eR]=(0,r.useState)(null),[eT,eD]=(0,r.useState)(!1),[eB,eF]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(p(t),v(s),k(a),C(i),A(o.join(", ")),P("denied"===s8()||"unsupported"===s8()),ei(!1),M(""),Z(null),_(void 0),V().then(_).catch(e=>{_(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),eF(!1),O().then(ew))},[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)}),ns))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 e_=async e=>{B(e);try{let t=await ec(e,!0).catch(()=>null);I(s=>({...s,[e]:t}))}finally{B(null)}},eL=async()=>{if(L.trim()){Y(!0),Z(null);try{let e=await K(L);if(!e)throw Error("未連線到 VibeFlow core");_(e),M("")}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(!1)}}},eM=async()=>{Y(!0),Z(null);try{let e=await G();if(!e)throw Error("未連線到 VibeFlow core");_(e),M("")}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),e$(e.url),eF(!1),eD(!1);return}if("success"===e.type){ew(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),eF(!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),eF(!1),ew(await O())},e0=async()=>{eD(!0),eR(null);try{let e=await es();ew(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),eF(!0),window.setTimeout(()=>eF(!1),1500))};return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(tK,{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)(ty,{variant:"ghost",size:"sm",onClick:()=>void e2(),children:"返回設定"}),(0,n.jsx)(ty,{size:"sm",disabled:c||eN||!eW,onClick:()=>m(eH,j.trim(),N,w,eU),children:"儲存設定"})]}):ea?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:()=>void eZ(),disabled:eT&&"success"!==eC,children:"success"===eC?"完成":"返回"}),"error"===eC&&(0,n.jsx)(ty,{size:"sm",onClick:()=>void eQ(),children:"重新登入"})]}):eV?eG?null:(0,n.jsxs)(ty,{variant:"ghost",size:"sm",onClick:()=>eK(!1),children:[(0,n.jsx)(sH.A,{className:"size-3.5"}),"返回設定"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:e1,disabled:c,children:"取消"}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>{eq&&m(eH,j.trim(),N,w,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)(sH.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)(s5,{output:eg,active:eN}),eu?.installed===!1?(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(ty,{variant:"outline",size:"sm",onClick:()=>void eE("https://developer.atlassian.com/cloud/acli/guides/install-acli/"),children:[(0,n.jsx)(ta.A,{}),"安裝說明"]}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>void J().then(em),children:[(0,n.jsx)(tp.A,{}),"重新檢查"]})]}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[eN?(0,n.jsx)(ty,{variant:"outline",size:"sm",onClick:()=>void W(),children:"取消"}):(0,n.jsx)(ty,{size:"sm",onClick:()=>void e5(),children:eu?.authenticated?"重新登入":"使用瀏覽器登入"}),eu?.authenticated&&(0,n.jsxs)(ty,{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)(sJ.A,{}),"登出"]}),eh&&(0,n.jsxs)(ty,{variant:"ghost",size:"sm",onClick:()=>void eE(eh),children:[(0,n.jsx)(ta.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)(sh,"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)(sH.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?`目前登入帳號:${ek?.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)(sU.A,{className:"size-4"}),eB?"已複製":"複製"]})]})]}),(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:eP,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(eP),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)(ta.A,{className:"size-4"}),"開啟"]})]})]})]})]}):eV?(0,n.jsx)(s1,{onEditingChange:eO}):(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(s3,{appVersion:g}),(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(sC,{value:N,onChange:k}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"新卡片的預設值;每張卡片可在建立或編輯時各自調整。"})]}),(0,n.jsx)("section",{className:"space-y-2",children:(0,n.jsx)(nt,{value:w,onChange:C,desktopBlocked:E,onRequestDesktop:async()=>{if("unsupported"===s8())return P(!0),!1;let e=await Notification.requestPermission()==="granted";return P(!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)(sh,"font-mono text-sm")}),(0,n.jsx)(ty,{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)(sh,"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)(ty,{variant:"secondary",size:"sm",onClick:()=>eK(!0),children:[(0,n.jsx)(sW.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===F?"讀取金鑰狀態中…":null===F?"無法讀取 Jev 金鑰狀態":"saved"===F.source?"已設定 Jev API key(本機儲存)":"environment"===F.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:L,onChange:e=>M(e.target.value),placeholder:"輸入 TypeSafe Jev API key",className:(0,z.cn)(sh,"min-w-48 flex-1 font-mono text-sm")}),(0,n.jsx)(ty,{size:"sm",disabled:H||!L.trim(),onClick:()=>void eL(),children:H?"處理中…":"儲存金鑰"}),F?.source==="saved"&&(0,n.jsx)(ty,{size:"sm",variant:"outline",disabled:H,onClick:()=>void eM(),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:[ns.map(e=>{let t=$[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 可用・來源:${nn[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)(ty,{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 e_(e.id),children:(0,n.jsx)(tp.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:[ek?.authenticated?(0,n.jsx)(eY.A,{className:"size-4 shrink-0 text-success"}):ek?.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:ek?.authenticated?`${ek.login??"GitHub"} 已授權(${ek.gitProtocol??"https"})`:ek?.installed===!1?"找不到 GitHub CLI(gh)":ek?.error?ek.error:"尚未授權"})]}),ek?.authenticated&&(0,n.jsx)(ty,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2",disabled:eT,onClick:()=>void eQ(),children:"切換使用者"}),ek?.authenticated&&(0,n.jsxs)(ty,{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)(sJ.A,{className:"size-4"}),"登出"]}),!ek?.authenticated&&(0,n.jsx)(ty,{type:"button",size:"sm",variant:"outline",disabled:ek?.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 na=s(30592),ni=s(79751),nl=s(93202),no=s(51256);function nc({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)(P,{"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)(P,{"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)(na.A,{className:"size-4"})}),(0,n.jsx)(P,{"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)(ni.A,{className:"size-4"})}),(0,n.jsx)(P,{"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)(P,{"aria-label":"遠端控制",onClick:r,title:"遠端控制",className:(0,z.cn)("size-8",a&&"text-primary hover:text-primary"),children:(0,n.jsx)(nl.A,{className:"size-4"})}),(0,n.jsx)(P,{"aria-label":"設定 System Prompt",onClick:i,title:"設定(System Prompt)",className:"size-8",children:(0,n.jsx)(no.A,{className:"size-4"})})]})]})}var nd=s(32310),nu=s(2141),nm=s(4792);let nx={projects:[],assignees:[],authors:[]},nf=":unassigned",nh=(e,t)=>e.localeCompare(t);function np(e,t){return Array.from(new Set([...e,...t])).sort(nh)}function ng(e,t){return nh(e.projectName,t.projectName)||t.item.number-e.item.number}function nb(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,projectName:n}=e,{projects:r,assignees:a,authors:i}=t;return(!r.length||!!r.includes(n))&&(!a.length||!!(0===s.assignees.length?a.includes(nf):s.assignees.some(e=>a.includes(e.login))))&&(!i.length||!!(s.author&&i.includes(s.author.login)))})(e,s)).sort(ng)}function nj({name:e,allLabel:t,icon:s,options:a,value:i,onChange:l,optionLabel:o=e=>e}){let[c,d]=(0,r.useState)(!1),u=e8(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)(k.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",e9,"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)(w.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",e9,"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)(w.A,{className:"size-3 shrink-0"})]},e)})]})]})}function nv({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 nN({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 ny({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 nk({item:e}){return(0,n.jsxs)(n.Fragment,{children:["issue"===e.kind&&e.issueType&&(0,n.jsx)(ny,{className:"font-medium text-foreground",children:e.issueType.name}),"pr"===e.kind&&(0,n.jsx)(ny,{className:(0,z.cn)("font-medium",eV[e.state]),children:eK[e.state]}),"pr"===e.kind&&e.reviewDecision&&eG[e.reviewDecision]&&(0,n.jsx)(ny,{children:eG[e.reviewDecision]}),e.labels.map(e=>(0,n.jsxs)(ny,{children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:`#${e.color}`}}),e.name]},e.name))]})}function nw({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)(nv,{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)(nk,{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)(nN,{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)(nN,{user:e},e.login))})]})]})]})}function nC({label:e,children:t}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{className:"text-muted-foreground",children:e}),(0,n.jsx)("dd",{className:"min-w-0 text-foreground",children:t})]})}function nS({entry:e,taskId:t,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)(tK,{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)(ty,{variant:"outline",size:"sm",onClick:()=>void eE(d.url),children:[(0,n.jsx)(ta.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)(P,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",disabled:x,onClick:()=>void a().then(e=>{e&&b(e)}),children:(0,n.jsx)(tx.A,{className:"size-4"})})]}),v?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",onClick:()=>void j(),disabled:x||!g,title:"已經有對應卡片,仍可再建一張",children:"再建一張"}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>o(v),children:[(0,n.jsx)(nd.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)(ty,{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)(ny,{className:"bg-success/15 font-medium text-success",children:"Open"}):(0,n.jsx)(ny,{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)(nC,{label:"專案",children:e.projectName}),(0,n.jsx)(nC,{label:"發起人",children:d.author?.login??"—"}),(0,n.jsx)(nC,{label:"指派",children:(c=d.assignees).length?c.map(e=>e.login).join("、"):"—"}),(0,n.jsx)(nC,{label:"建立時間",children:eJ(d.createdAt)}),"issue"===d.kind&&(0,n.jsx)(nC,{label:"Issue Type",children:d.issueType?.name??"—"}),"pr"===d.kind&&(0,n.jsx)(nC,{label:"分支",children:(0,n.jsxs)("span",{className:"break-all",children:[d.headRefName," → ",d.baseRefName]})}),"pr"===d.kind&&d.reviewDecision&&(0,n.jsx)(nC,{label:"Review",children:eG[d.reviewDecision]??d.reviewDecision}),d.labels.length>0&&(0,n.jsx)(nC,{label:"Labels",children:(0,n.jsx)("span",{className:"flex flex-wrap gap-1",children:d.labels.map(e=>(0,n.jsxs)(ny,{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)(nC,{label:"Milestone",children:d.milestone})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:d.body.trim()?(0,n.jsx)(tv,{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 nA({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 nz({label:e,entries:t,empty:s,selectedKey:r,boardCards:a,now:i,onSelect:l}){return(0,n.jsxs)("section",{className:"flex min-h-0 flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 px-1",children:[(0,n.jsx)("h2",{className:A,children:e}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:t.length})]}),(0,n.jsx)("div",{className:"grid min-h-0 flex-1 grid-cols-[repeat(auto-fill,minmax(min(100%,300px),1fr))] content-start gap-3 overflow-y-auto rounded-md p-1",children:0===t.length?(0,n.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/60",children:s}):t.map(e=>{let t=eO(e.item);return(0,n.jsx)(nw,{entry:e,selected:t===r,onBoard:a.has(t),now:i,onSelect:()=>l(t)},t)})})]})}let nE=e=>e===nf?"未指派":e;function nP({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:b=!1}){let j,v,[N,y]=(0,r.useState)(null),k=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:[],C=(v=w.flatMap(e=>p?e[p]:[...e.issues,...e.prs]),{projects:np(w.map(e=>e.projectName),o.projects),assignees:[nf,...np(v.flatMap(e=>e.assignees.map(e=>e.login)),o.assignees.filter(e=>e!==nf))],authors:np(v.flatMap(e=>e.author?[e.author.login]:[]),o.authors)}),S=o.projects.length>0||o.assignees.length>0||o.authors.length>0,A=nb(w,"issues",o),E=nb(w,"prs",o),$=w.filter(e=>e.error&&(0===o.projects.length||o.projects.includes(e.projectName))),R=[..."prs"===p?[]:A,..."issues"===p?[]:E].find(e=>eO(e.item)===N)??null,T=s?.status==="ok"&&null!==N&&null===R;(0,r.useEffect)(()=>{T&&y(null)},[T]);let D=e=>t=>c({...o,[e]:t}),B=s?.fetchedAt??0,F=B?`${eH(new Date(B).toISOString(),k)}更新`:null;return j=s?"gh-missing"===s.status?(0,n.jsx)(nA,{children:"找不到 GitHub CLI(gh)。安裝後按右上角的重新整理,就能看到指派給你或你建立的 Issue 與 PR。"}):"unauthenticated"===s.status?(0,n.jsx)(nA,{action:(0,n.jsx)(ty,{size:"sm",onClick:h,children:"開啟設定登入 GitHub"}),children:"GitHub CLI 尚未登入。"}):0===w.length?(0,n.jsx)(nA,{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:[($.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}),$.map(e=>(0,n.jsxs)("p",{className:"truncate",title:e.error,children:[e.repo,":",e.error]},e.repo))]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1",children:["prs"!==p&&(0,n.jsx)(nz,{label:"Issues",entries:A,empty:S?"沒有符合篩選條件的 Issue":"沒有指派給你或你建立的 open Issue",selectedKey:N,boardCards:d,now:k,onSelect:y}),"issues"!==p&&(0,n.jsx)(nz,{label:"Pull Requests",entries:E,empty:S?"沒有符合篩選條件的 PR":"沒有指派給你、你建立、請你 review 或你 review 過的 open PR",selectedKey:N,boardCards:d,now:k,onSelect:y})]})]}):a?(0,n.jsx)(nA,{children:"讀取 GitHub 中…"}):i?(0,n.jsx)(nA,{children:i}):null,(0,n.jsxs)("div",{className:(0,z.cn)("flex min-h-0 flex-col bg-background",b?"flex-1":"h-full"),onKeyDown:e=>{"Escape"===e.key&&N&&(e.stopPropagation(),y(null))},children:[(0,n.jsxs)("div",{className:(0,z.cn)("flex shrink-0 items-center gap-3 border-b border-border px-5",b?"h-11":"h-12"),children:[!b&&(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"})]}),(0,n.jsx)(nj,{name:"專案",allLabel:"所有專案",icon:g.A,options:C.projects,value:o.projects,onChange:D("projects")}),"issues"!==p&&(0,n.jsx)(nj,{name:"Assignee",allLabel:"所有 Assignee",icon:nu.A,options:C.assignees,value:o.assignees,onChange:D("assignees"),optionLabel:nE}),"issues"!==p&&(0,n.jsx)(nj,{name:"發起人",allLabel:"所有發起人",icon:nm.A,options:C.authors,value:o.authors,onChange:D("authors")}),S&&(0,n.jsxs)("button",{type:"button",onClick:()=>c(nx),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)(tb.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?`${A.length} 筆`:"prs"===p?`${E.length} 筆`:"指派給我、我建立、我 review 的",F?` \xb7 ${F}`:""]}),(0,n.jsx)(P,{"aria-label":"重新整理 Issue 與 PR",title:"重新整理",onClick:l,disabled:a,children:(0,n.jsx)(tp.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:j}),R&&(0,n.jsx)(nS,{entry:R,taskId:d.get(eO(R.item)),projects:u,onBrowseProject:m,onClose:()=>y(null),onConvert:e=>x(R.item,e),onOpenTask:f},eO(R.item))]})]})}var n$=s(85499);function nI(e){return Number(e.split("-").at(-1))||0}function nR(e,t){return e.dueDate?t.dueDate?e.dueDate.localeCompare(t.dueDate)||nI(t.key)-nI(e.key):-1:t.dueDate?1:nI(t.key)-nI(e.key)}let nT={new:"bg-accent text-muted-foreground",indeterminate:"bg-primary/15 text-primary",done:"bg-success/15 text-success"};function nD(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 nB({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),[k,w]=(0,r.useState)(null),[S,A]=(0,r.useState)(null),[E,$]=(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(nR)}))}(I),T=I.find(e=>e.key===p),D=T?c.get(T.key):void 0,B=k??D;(0,r.useEffect)(()=>{p&&e?.status==="ok"&&!T&&g(null)},[p,T,e?.status]);let F=async()=>{if(T&&b&&!v){N(!0),A(null);try{let e=await m(T,b);w(e),$(!1)}catch(e){A(e instanceof Error?e.message:String(e))}finally{N(!1)}}},_=(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)(ty,{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)(P,{"aria-label":"重新整理 Jira ticket",title:"重新整理 Jira ticket",onClick:o,disabled:t,children:(0,n.jsx)(tp.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"?_("找不到 Atlassian CLI(acli)。安裝並登入後就能看到指派給你的 Jira ticket。",!0):e?.status==="unauthenticated"?_("尚未登入 Atlassian。",!0):e?e.error&&0===I.length?_(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=nD(e.dueDate);return(0,n.jsxs)("button",{type:"button",onClick:()=>{g(e.key),j(""),A(null),w(null),$(!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",nT[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))})]}):_(t?"讀取 Jira 中…":s??"無法讀取 Jira ticket"),(0,n.jsx)(l.N,{children:T&&(0,n.jsx)(tK,{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:[k&&(0,n.jsx)("span",{className:"text-sm text-success",children:"已建立到 Backlog"}),B&&!E?(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(ty,{variant:"ghost",size:"sm",title:"已經有對應卡片,仍可再建一張",onClick:()=>{$(!0),w(null),j("")},children:"再建一張"}),(0,n.jsxs)(ty,{size:"sm",onClick:()=>{g(null),x(B)},children:[(0,n.jsx)(nd.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)(P,{"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)(tx.A,{className:"size-4"})}),(0,n.jsxs)(ty,{size:"sm",disabled:!b||v,title:b?void 0:"先選擇要建立到哪個專案",onClick:()=>void F(),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)(ta.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:nD(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)(ta.A,{className:"size-3"})]})})]})]}),(0,n.jsx)("div",{className:"border-t border-border pt-4",children:T.description?(0,n.jsx)(tv,{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)(n$.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 nF=[{id:"jira",label:"Jira"},{id:"issues",label:"Issues"},{id:"prs",label:"Pull Requests"}];function n_({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:nF.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+nF.length)%nF.length;b.current[n]?.focus(),a(nF[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)(nB,{...i,onRefresh:i.refresh,boardCards:d,projects:m,onBrowseProject:x,onCreate:f,onOpenTask:p,onOpenSettings:g}):(0,n.jsx)(nP,{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})]})}function nL({entries:e,activeTaskId:t,onSelect:s,onPin:r,onClose:a}){return 0===e.length?null:(0,n.jsx)("div",{className:"flex h-9 shrink-0 items-stretch overflow-x-auto overflow-y-hidden border-b border-border bg-card/40",children:e.map(e=>{let i=e.taskId===t;return(0,n.jsxs)("div",{className:(0,z.cn)("group flex h-full min-w-0 max-w-52 shrink-0 items-center gap-1 border-r border-border/60 pl-3 pr-1.5 transition-colors motion-reduce:transition-none",i?"bg-background text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"),children:[(0,n.jsxs)("button",{type:"button","aria-current":i?"page":void 0,title:e.title,onClick:()=>s(e.taskId),onDoubleClick:()=>r(e.taskId),onAuxClick:t=>{1===t.button&&a(e.taskId)},className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm py-0.5 text-left text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:(0,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:()=>a(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",i?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,n.jsx)(tb.A,{className:"size-3"})})]},e.taskId)})})}var nM=s(4504);function nV({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)(tK,{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)(nM.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)(w.A,{className:"size-3.5"}):(0,n.jsx)(tm.A,{className:"size-3.5"}),d?"已複製":"複製連結"]}),(0,n.jsx)(ty,{size:"sm",variant:"destructive",onClick:i,children:"停止分享"})]})]})}function nK({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)(s4.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)(P,{"aria-label":"關閉通知",onClick:()=>s(e.id),className:"size-5 p-0.5",children:(0,n.jsx)(tb.A,{className:"size-3.5"})})]})}function nG({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)(nK,{toast:e,onOpen:t,onDismiss:s},e.id))})})}function nO(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 nH=["board","github","terminals"],nJ=["jira","issues","prs"],nU="vibeflow:terminal-tabs",nW="vibeflow:inbox-tab",nY="vibeflow:github-filters",nq="vibeflow:jira-scope";function nX(e){try{let t=window.localStorage.getItem(e);return null===t?null:JSON.parse(t)}catch{return null}}function nQ(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}let nZ=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);function n0(e){let t=e??{};return{projects:nZ(t.projects)?t.projects:nx.projects,assignees:nZ(t.assignees)?t.assignees:nx.assignees,authors:nZ(t.authors)?t.authors:nx.authors}}let n1={backlog:[],in_progress:[],done:[]},n5=["in_progress","backlog","done"];function n2(e,t){for(let s of Object.values(e)){let e=s.find(e=>e.id===t);if(e)return e}return null}function n3(e,t){let s=new Set(t.map(e=>e.sessionKey));return[...t,...e.filter(e=>e.pending&&!s.has(e.sessionKey))]}function n4(){let[e,t]=(0,r.useState)(n1),[a,o]=(0,r.useState)({}),[c,d]=(0,r.useState)(s7()),[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,k]=(0,r.useState)(!0),[w,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),[F,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,ek]=(0,r.useState)(null),[ew,eC]=(0,r.useState)(0),[eS,eA]=(0,r.useState)("board"),[ez,eE]=(0,r.useState)({issues:nx,prs:nx}),[eR,eT]=(0,r.useState)(null),[eD,eL]=(0,r.useState)("sprint"),[eM,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),k(s.settings.autoMode),C(s.settings.systemPrompt??""),A(s.settings.workstationPath??""),E(s.settings.jira?.storyPointsFields??[]),d(s7(s.settings.notifications)),eb(e=>n3(e,s.terminals??[])));let c={view:(r=(n=new URLSearchParams(window.location.search)).get("view"))&&nH.includes(r)?r:"board",taskId:n.get("task")||null};eA(c.view),ef(c.taskId);let u=Array.isArray(a=nX(nU))?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=nX(nW),nJ.includes(i)?i:null)),eL("all"===(l=nX(nq))?l:"sprint"),eE({issues:n0((o=nX(nY)??{}).issues),prs:n0(o.prs)}),$(!0)}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{var e;let s;return e=e=>{t(e.board),k(e.settings.autoMode),C(e.settings.systemPrompt??""),A(e.settings.workstationPath??""),E(e.settings.jira?.storyPointsFields??[]),d(s7(e.settings.notifications)),eb(t=>n3(t,e.terminals??[]))},(s=R())?s.onStateChanged(e):()=>{}},[]),(0,r.useEffect)(()=>{let e;P&&(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))},[P,eS,ex]),(0,r.useEffect)(()=>{P&&nQ(nU,eh)},[P,eh]),(0,r.useEffect)(()=>{P&&nQ(nW,eR)},[P,eR]),(0,r.useEffect)(()=>{P&&nQ(nq,eD)},[P,eD]),(0,r.useEffect)(()=>{P&&nQ(nY,ez)},[P,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 B().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(","):[])eP(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:sA(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),ek(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 M({systemPrompt:e,workstationPath:t||void 0,autoMode:s,notifications:n,jira:{storyPointsFields:r}}),C(e),A(t),k(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 e$(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 n5){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,P),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)}}(P,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,P),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}]),...eM.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)(()=>{P&&ei().then(eV)},[P,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:nO(u.current,m.current)})}catch{}break;case"client:send-command":{let{taskId:e,text:t}=n??{};if(!e||!t)break;eF(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 L(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=nO(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:nO(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),L(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:P?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,n.jsx)(nc,{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),_().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)(tb.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)(sM,{tabBar:(0,n.jsx)(nL,{entries:e6,activeTaskId:ex,onSelect:eJ,onPin:eX,onClose:e=>eQ([e])}),onSelectTask:eJ,onNewTask:eZ,board:e,onBoardChange:e=>{t(e),L(e)},onEditTask:t=>{en(null),e.backlog.some(e=>e.id===t)&&q(n2(e,t))},onTaskDone:e3,onDeleteTask:e4,onOpenTaskTerminal:t=>{let s=n2(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:ew,view:eS,onViewChange:eA,taskLinks:e9.links,githubView:(0,n.jsx)(n_,{view:eS,onViewChange:eA,tab:tn,onTabChange:eT,jira:{...e8,scope:eD,onScopeChange:eL},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)(sK,{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:eM,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&&eB(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)),eB(e,t.title).catch(()=>{}))},onClose:e=>{e_(e),eb(t=>t.filter(t=>t.sessionKey!==e)),eN(t=>t===e?null:t)},onBrowse:eG})})]})]})]}),(0,n.jsx)(sO,{task:Y,defaultAutoMode:N,detectAgents:eo,pickFolder:eG,loadRecentProjects:ei,loadGitInfo:ea,saving:ee,error:es,onSubmit:e2,onClose:()=>q(null)}),(0,n.jsx)(nr,{open:I,systemPrompt:w,workstationPath:S,autoMode:N,notifications:c,jiraStoryPointsFields:z,saving:F,error:K,onSave:e1,onPickFolder:()=>er("選擇工作區資料夾"),onClose:()=>D(!1)}),(0,n.jsx)(l.N,{children:O&&(0,n.jsx)(tK,{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)(nV,{roomCode:ti.roomCode,peerCount:ti.peerCount,onClose:()=>em(!1),onStop:()=>{ti.stopSharing(),em(!1)}},"remote-share-dialog")}),(0,n.jsx)(nG,{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,[9296,636,6593,8792],()=>e(e.s=24464)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},__routerFilterDynamic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-8f65b0f8749f42d2.js"],"/home":["static/chunks/9296-f476f95a89709fef.js","static/chunks/pages/home-307d0d7c49e4ee48.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},__routerFilterDynamic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-8f65b0f8749f42d2.js"],"/home":["static/chunks/9296-f476f95a89709fef.js","static/chunks/pages/home-05d35a1c1ac42965.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/f8f64877c884206d.css" as="style"/><link rel="stylesheet" href="/_next/static/css/f8f64877c884206d.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-33344f7100190436.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-2571a2564f593899.js" defer=""></script><script src="/_next/static/chunks/9296-f476f95a89709fef.js" defer=""></script><script src="/_next/static/chunks/pages/home-307d0d7c49e4ee48.js" defer=""></script><script src="/_next/static/76irYAZpsrcN0YAWmxJ47/_buildManifest.js" defer=""></script><script src="/_next/static/76irYAZpsrcN0YAWmxJ47/_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":"76irYAZpsrcN0YAWmxJ47","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/f8f64877c884206d.css" as="style"/><link rel="stylesheet" href="/_next/static/css/f8f64877c884206d.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-33344f7100190436.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-2571a2564f593899.js" defer=""></script><script src="/_next/static/chunks/9296-f476f95a89709fef.js" defer=""></script><script src="/_next/static/chunks/pages/home-05d35a1c1ac42965.js" defer=""></script><script src="/_next/static/m3seMgh7dEHDU9k_2URFv/_buildManifest.js" defer=""></script><script src="/_next/static/m3seMgh7dEHDU9k_2URFv/_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":"m3seMgh7dEHDU9k_2URFv","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kw-yeh/vibeflow",
3
- "version": "4.11.19",
3
+ "version": "4.11.21",
4
4
  "description": "Intent-driven local kanban for coding agents: git worktree per card, Web UI and TUI.",
5
5
  "license": "MIT",
6
6
  "author": "KW-Yeh",