@baique/pi-web-sky 0.1.46 → 0.1.48

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.
Files changed (48) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +18 -18
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/react-loadable-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +1 -1
  15. package/.next/server/app/_not-found.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  19. package/.next/server/app/api/app-update/route.js +1 -1
  20. package/.next/server/app/index.html +1 -1
  21. package/.next/server/app/index.rsc +4 -4
  22. package/.next/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  23. package/.next/server/app/index.segments/_full.segment.rsc +4 -4
  24. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  25. package/.next/server/app/page.js +3 -3
  26. package/.next/server/app/page_client-reference-manifest.js +1 -1
  27. package/.next/server/app-paths-manifest.json +18 -18
  28. package/.next/server/middleware-build-manifest.js +1 -1
  29. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  30. package/.next/server/pages/404.html +1 -1
  31. package/.next/server/pages/500.html +1 -1
  32. package/.next/static/chunks/752.5a689906a0814bce.js +1 -0
  33. package/.next/static/chunks/7975.12644bfea1bf2410.js +1 -0
  34. package/.next/static/chunks/app/{layout-4131e9abd303855e.js → layout-34c3afa7e57644fe.js} +1 -1
  35. package/.next/static/chunks/app/{page-60d31cc657a66941.js → page-72aa0bf9f2c8b93d.js} +2 -2
  36. package/.next/static/chunks/{webpack-7e7a6ac5aadb603f.js → webpack-4a321ad1cc2cd898.js} +1 -1
  37. package/.next/trace +7 -8
  38. package/.next/trace-build +1 -1
  39. package/lib/card-time.ts +18 -0
  40. package/lib/i18n/messages/en.ts +1 -0
  41. package/lib/i18n/messages/zh-CN.ts +1 -0
  42. package/lib/note-time.ts +10 -0
  43. package/lib/yjs-room-server.mjs +5 -0
  44. package/package.json +1 -1
  45. package/.next/static/chunks/752.395b1b6b288c0c89.js +0 -1
  46. package/.next/static/chunks/9272.7b010df4c209349b.js +0 -1
  47. /package/.next/static/{bwC_pehF8TcdwJmfZPhhX → m9gWh8uFYWdcMxBdc3tY5}/_buildManifest.js +0 -0
  48. /package/.next/static/{bwC_pehF8TcdwJmfZPhhX → m9gWh8uFYWdcMxBdc3tY5}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-7e7a6ac5aadb603f.js"/><script src="/_next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js" async=""></script><script src="/_next/static/chunks/3794-d29203733ca4633c.js" async=""></script><script src="/_next/static/chunks/main-app-dd2385a1a5a588df.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><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;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-7e7a6ac5aadb603f.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n7:X\n0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$7\"]},null,false,\"$7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"bwC_pehF8TcdwJmfZPhhX\"}\n7:C\n9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n6:null\nb:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-4a321ad1cc2cd898.js"/><script src="/_next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js" async=""></script><script src="/_next/static/chunks/3794-d29203733ca4633c.js" async=""></script><script src="/_next/static/chunks/main-app-dd2385a1a5a588df.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><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;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-4a321ad1cc2cd898.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n7:X\n0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$7\"]},null,false,\"$7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"m9gWh8uFYWdcMxBdc3tY5\"}\n7:C\n9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n6:null\nb:[]\n"])</script></body></html>
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[752],{15934:(e,t,r)=>{function n(e,t){window.dispatchEvent(new CustomEvent("pi-web:board-open-file",{detail:{sessionId:e,filePath:t}}))}function i(e,t){window.dispatchEvent(new CustomEvent("pi-web:board-session-forked",{detail:{sessionId:e,newSessionId:t}}))}function s(e,t){window.dispatchEvent(new CustomEvent("pi-web:board-session-created",{detail:{sessionId:e,nodeId:t}}))}function a(e){window.dispatchEvent(new CustomEvent("pi-web:board-session-deleted",{detail:{sessionId:e}}))}function o(e,t){window.dispatchEvent(new CustomEvent("pi-web:board-session-renamed",{detail:{sessionId:e,name:t}}))}function l(e){window.dispatchEvent(new CustomEvent("pi-web:board-cwd-switch",{detail:{cwd:e}}))}function d(e,t){window.dispatchEvent(new CustomEvent("pi-web:board-agent-end",{detail:{sessionId:e,sessionName:t}}))}function c(e,t){window.dispatchEvent(new CustomEvent("pi-web:board-attention-needed",{detail:{sessionId:e,...t}}))}function u(){window.dispatchEvent(new CustomEvent("pi-web:board-tasks-changed",{detail:{}}))}r.d(t,{$T:()=>l,Ho:()=>d,PH:()=>s,PK:()=>n,Qp:()=>a,RF:()=>u,Wd:()=>i,sV:()=>c,z6:()=>o})},24456:(e,t,r)=>{r.d(t,{l:()=>c});var n=r(95155),i=r(12115),s=r(12669);let a=null,o=null,l=null;function d(e){a?.(e),a=null,l?.unmount(),o?.remove(),l=null,o=null}function c(e){return new Promise(t=>{a&&d(!1),a=t;let r=o;r||(r=document.createElement("div"),document.body.appendChild(r),o=r);let i=l;i||(l=i=(0,s.createRoot)(r)),i.render((0,n.jsx)(u,{opts:e,onClose:d}))})}function u({opts:e,onClose:t}){let[r]=(0,i.useState)(!1);return(0,n.jsx)("div",{role:"alertdialog","aria-modal":"true",onPointerDown:()=>t(!1),style:{position:"fixed",inset:0,zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.35)"},children:(0,n.jsxs)("div",{onPointerDown:e=>e.stopPropagation(),style:{width:360,maxWidth:"calc(100vw - 48px)",borderRadius:"var(--bubble-radius, 14px)",background:"var(--board-card-glass)",backdropFilter:"blur(var(--board-blur)) saturate(var(--glass-saturate))",WebkitBackdropFilter:"blur(var(--board-blur)) saturate(var(--glass-saturate))",border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 10px 40px -12px rgba(0,0,0,0.4)",color:"var(--text)",padding:"16px 18px",display:"flex",flexDirection:"column",gap:10},children:[e.title&&(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600},children:e.title}),(0,n.jsx)("div",{style:{fontSize:12.5,lineHeight:1.6,color:"var(--text-muted)",whiteSpace:"pre-wrap"},children:e.message}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:6},children:[(0,n.jsx)("button",{type:"button",onClick:()=>t(!1),style:{border:"none",background:"color-mix(in srgb, var(--border) 30%, transparent)",color:"var(--text-muted)",borderRadius:6,padding:"5px 14px",fontSize:12,cursor:"pointer"},children:e.cancelText??"取消"}),(0,n.jsx)("button",{type:"button",disabled:r,onClick:()=>t(!0),style:{border:"none",background:!1===e.danger?"var(--accent)":"color-mix(in srgb, #ef4444 85%, transparent)",color:"#fff",borderRadius:6,padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer"},children:e.confirmText??"删除"})]})]})})}},25535:(e,t,r)=>{r.d(t,{U:()=>o,u:()=>a});var n=r(95155),i=r(12115);let s=(0,i.createContext)(null);function a({value:e,children:t}){return(0,n.jsx)(s.Provider,{value:e,children:t})}function o(){let e=(0,i.useContext)(s);return e||{updateNode:()=>{},updateNodeDebounced:()=>{},deleteNode:()=>{},normalizeNodeId:()=>{},deleteEdge:()=>{},addEdge:()=>{},updateEdge:()=>{},addNode:()=>{},setSnapLines:()=>{},boardId:null,isTaskBoard:!1}}},56314:(e,t,r)=>{r.d(t,{Lv:()=>s,Nc:()=>i,ZY:()=>a});var n=r(12115);let i=(0,n.createContext)(null);function s(){return(0,n.useContext)(i)?.boardId??null}function a(){return(0,n.useContext)(i)?.defaultCwd??null}},60752:(e,t,r)=>{r.r(t),r.d(t,{SessionCanvas:()=>R});var n=r(95155),i=r(12115),s=r(37206),a=r(81750),o=r(96793),l=r(39247),d=r(64536),c=r(71309),u=r(34229),p=r(84876),h=r(56314),x=r(24456),f=r(71459);function g({editor:e,inputRef:t,nodes:r,onViewportSave:s}){let{t:o}=(0,l.s)(),{setHighlight:d}=(0,c.kz)(),{setCenter:u,getViewport:p,getNodes:h}=(0,a.VH)(),[x,b]=(0,i.useState)(""),[y,v]=(0,i.useState)(!1),[w,k]=(0,i.useState)(-1),[j,S]=(0,i.useState)(null),C=(0,i.useRef)(null),I=t??C,R=(0,i.useRef)(null),E=(0,i.useMemo)(()=>{let e=r??h(),t=[];for(let r of e){if("session-card"!==r.type)continue;let e=String(r.data.sessionId??"");e&&t.push(e)}return t},[r,h]).join(",");(0,i.useEffect)(()=>{let e=x.trim();if(!e)return void S(null);if(!E)return void S([]);let t=setTimeout(()=>{R.current?.abort();let t=new AbortController;R.current=t,fetch(`/api/search?q=${encodeURIComponent(e)}&limit=30&sessionIds=${encodeURIComponent(E)}`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&S((e.results??[]).filter(e=>"session"===e.kind&&e.result).map(e=>{let t=e.result.session;return{sessionId:t.id,title:t.name||(t.firstMessage||"").slice(0,50)||t.id.slice(0,12),snippet:e.result.snippet??"",titleMatch:!!e.result.titleMatch}}))}).catch(()=>S([]))},350);return()=>{clearTimeout(t),R.current?.abort()}},[x,E]);let z=(0,i.useMemo)(()=>{let e=r??h(),t=[];for(let r of e)if("session-card"===r.type){let e=String(r.data.title??"").trim();e&&t.push({nodeId:r.id,kind:"session-card",text:e})}else if("sticky-note"===r.type||"text"===r.type||"text-node"===r.type){let e=String(r.data.text??"").trim();e&&t.push({nodeId:r.id,kind:"sticky-note",text:e})}return t},[r,h]),T=(0,i.useMemo)(()=>{let e=x.trim().toLowerCase().split(/\s+/).filter(Boolean);return 0===e.length?[]:z.filter(t=>{let r=t.text.toLowerCase();return e.every(e=>r.includes(e))}).map(t=>({item:t,snippet:function(e,t,r=44){let n=t.trim().toLowerCase(),i=e.toLowerCase().indexOf(n);if(i<0)return e.length>r?`${e.slice(0,r)}…`:e;let s=Math.max(0,i-Math.floor((r-n.length)/2)),a=Math.min(e.length,s+r),o=s>0?"…":"",l=a<e.length?"…":"";return`${o}${e.slice(s,a)}${l}`}(t.text,e[0])}))},[z,x]),A=(0,i.useCallback)(e=>{let t=h().find(t=>t.id===e);if(!t)return;let r=t.measured?.width??340,n=t.measured?.height??160;Promise.resolve(u(t.position.x+r/2,t.position.y+n/2,{zoom:p().zoom})).then(()=>{s?.(p())}),d(e)},[h,p,u,d,s]),L=T.length+(j?.length??0),M=(0,i.useCallback)(e=>{if(e<T.length){let t=T[e];t&&A(t.item.nodeId)}else{let t=j?.[e-T.length];if(!t)return;let r=h().find(e=>"session-card"===e.type&&String(e.data.sessionId??"")===t.sessionId)?.id;if(!r)return;A(r)}k(e)},[T,j,A,h]),W=(0,i.useCallback)(()=>{0!==L&&M((w+1)%L)},[L,w,M]),$=(0,i.useCallback)(()=>{0!==L&&M((w-1+L)%L)},[L,w,M]),D=(0,i.useCallback)(e=>{"Enter"===e.key||"ArrowDown"===e.key?(e.preventDefault(),W()):"ArrowUp"===e.key?(e.preventDefault(),$()):"Escape"===e.key&&(e.preventDefault(),y?v(!1):(b(""),k(-1),I.current?.blur()))},[y,W,$,I]),P=y&&x.trim().length>0,N=null===j,B=T.length>0,H=(j?.length??0)>0;return(0,n.jsxs)("div",{style:{position:"relative",width:320},"data-testid":"board-search",children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,height:34,padding:"0 8px 0 10px",borderRadius:999,...f.r,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)"},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.35-4.35"})]}),(0,n.jsx)("input",{ref:I,value:x,onChange:e=>{b(e.target.value),k(-1),v(!0)},onKeyDown:D,onFocus:()=>{x.trim()&&v(!0)},onBlur:()=>v(!1),onPointerDown:e=>e.stopPropagation(),placeholder:o("boards.searchPlaceholder"),spellCheck:!1,"aria-label":o("boards.searchPlaceholder"),style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text)",fontSize:12.5,fontFamily:"inherit"}}),x&&(0,n.jsx)("button",{type:"button",title:o("common.close"),onPointerDown:e=>e.stopPropagation(),onClick:()=>{b(""),k(-1),I.current?.focus()},style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"none",borderRadius:"50%",background:"color-mix(in srgb, var(--border) 35%, transparent)",color:"var(--text-muted)",cursor:"pointer",fontSize:11,lineHeight:1},children:"\xd7"})]}),P&&(0,n.jsxs)("div",{"data-testid":"board-search-dropdown",onPointerDown:e=>e.stopPropagation(),style:{position:"absolute",top:40,left:0,right:0,zIndex:60,maxHeight:320,overflowY:"auto",borderRadius:12,padding:4,...f.r,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 4px 18px -6px rgba(0,0,0,0.28)"},children:[!B&&!H&&!N&&(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:12,color:"var(--text-muted)"},children:o("boards.searchNoResults")}),N&&(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:12,color:"var(--text-muted)"},children:o("search.indexing")}),B&&(0,n.jsxs)(n.Fragment,{children:[H&&(0,n.jsx)(m,{text:o("boards.searchGroupNodes")}),T.map((e,t)=>{let r=t===w;return(0,n.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>M(t),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",border:"none",borderRadius:8,background:r?"color-mix(in srgb, var(--accent) 14%, transparent)":"transparent",color:"var(--text)",fontSize:12.5,textAlign:"left",cursor:"pointer"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0,display:"inline-flex",color:r?"var(--accent)":"var(--text-dim)"},children:"session-card"===e.item.kind?(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3z"}),(0,n.jsx)("path",{d:"M15 3v6h6"})]})}),(0,n.jsx)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.snippet}),(0,n.jsx)("span",{style:{flexShrink:0,fontSize:10,color:"var(--text-dim)"},children:"session-card"===e.item.kind?o("boards.searchSession"):o("boards.searchNote")})]},e.item.nodeId)})]}),H&&(0,n.jsxs)(n.Fragment,{children:[B&&(0,n.jsx)(m,{text:o("boards.searchGroupBody")}),j.map((e,t)=>{let r,i,s=T.length+t,a=s===w;return(0,n.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>M(s),style:{display:"flex",flexDirection:"column",gap:2,width:"100%",padding:"6px 10px",border:"none",borderRadius:8,background:a?"color-mix(in srgb, var(--accent) 14%, transparent)":"transparent",color:"var(--text)",fontSize:12.5,textAlign:"left",cursor:"pointer"},children:[(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[e.titleMatch&&(0,n.jsx)("span",{style:{flexShrink:0,fontSize:9,fontFamily:"var(--font-mono)",color:"var(--accent)",background:"color-mix(in srgb, var(--accent) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--accent) 30%, transparent)",borderRadius:3,padding:"0 4px",lineHeight:"15px"},children:o("search.title")}),(0,n.jsx)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:e.title}),(0,n.jsx)("span",{style:{flexShrink:0,fontSize:10,color:"var(--text-dim)"},children:o("boards.searchBodyTag")})]}),e.snippet&&(0,n.jsx)("span",{style:{minWidth:0,fontSize:11,color:"var(--text-muted)",lineHeight:1.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(r=e.snippet.split(/([\[\]])/g),i=!1,r.map((e,t)=>"["===e?(i=!0,null):"]"===e?(i=!1,null):e?i?(0,n.jsx)("mark",{style:{background:"color-mix(in srgb, var(--accent) 22%, transparent)",color:"var(--text)",borderRadius:2},children:e},t):(0,n.jsx)("span",{children:e},t):null))})]},e.sessionId)})]})]})]})}function m({text:e}){return(0,n.jsx)("div",{style:{padding:"6px 12px 2px",fontSize:10,fontWeight:700,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.5},children:e})}function b({boardName:e,isTaskBoard:t,reloading:r,onReload:s,onClear:o,onAddSessionCard:l,wallSettings:d,updateWallSettings:c}){let{screenToFlowPosition:u}=(0,a.VH)(),[p,h]=(0,i.useState)(!1),[x,g]=(0,i.useState)(!1),m=(0,i.useRef)(null);return(0,i.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,n.jsxs)("div",{style:{position:"absolute",top:12,left:12,zIndex:40,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:6,maxWidth:"min(420px, calc(100% - 320px))"},children:[(0,n.jsxs)("div",{style:{...f.r,display:"flex",alignItems:"center",gap:4,height:36,padding:"0 6px 0 12px",borderRadius:999,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)",color:"var(--text)"},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,opacity:.7},children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1.5"}),(0,n.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1.5"}),(0,n.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1.5"}),(0,n.jsx)("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1.5"})]}),(0,n.jsx)("span",{title:e,style:{fontSize:12.5,fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:220},children:e||"看板"}),(0,n.jsx)("button",{type:"button",onClick:s,title:"刷新画布","aria-label":"刷新画布",style:{...y,cursor:r?"default":"pointer"},...r?{}:v(),children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{animation:r?"spin 0.8s linear infinite":void 0},children:[(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),(0,n.jsx)("path",{d:"M21 3v5h-5"})]})}),(0,n.jsx)("span",{style:{flexShrink:0,width:1,height:18,background:"color-mix(in srgb, var(--border) 70%, transparent)",margin:"0 2px"}}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(x)return;let e=document.querySelector(".react-flow__pane"),t=e?.getBoundingClientRect();if(!t)return;let r=u({x:t.left+t.width/2,y:t.top+t.height/2});g(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>g(!1),600),l(r)},title:"新建会话","aria-label":"新建会话",disabled:x,style:{...y,opacity:x?.7:1},...x?{}:v(),children:x?(0,n.jsx)("span",{"aria-hidden":!0,style:{width:13,height:13,borderRadius:"50%",border:"2px solid color-mix(in srgb, var(--accent) 25%, transparent)",borderTopColor:"var(--accent)",animation:"spin 0.8s linear infinite"}}):(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),(0,n.jsx)("button",{type:"button",onClick:()=>h(e=>!e),title:"磨砂调节","aria-label":"磨砂调节","aria-expanded":p,style:{...y,color:p?"var(--accent)":"var(--text-muted)",background:p?"color-mix(in srgb, var(--accent) 12%, transparent)":void 0},...p?{}:v(),children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M12 3v2"}),(0,n.jsx)("path",{d:"M12 19v2"}),(0,n.jsx)("path",{d:"M5 7l1.5 1.5"}),(0,n.jsx)("path",{d:"M17.5 15.5L19 17"}),(0,n.jsx)("path",{d:"M3 12h2"}),(0,n.jsx)("path",{d:"M19 12h2"}),(0,n.jsx)("path",{d:"M5 17l1.5-1.5"}),(0,n.jsx)("path",{d:"M17.5 8.5L19 7"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),(0,n.jsx)("button",{type:"button",onClick:o,title:t?"清空画布(任务卡片保留)":"清空画布","aria-label":"清空画布",style:y,...v(),children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]}),p&&(0,n.jsx)("div",{style:w,children:(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{width:14,flexShrink:0,textAlign:"center",fontSize:12},children:"❄"}),(0,n.jsx)("span",{style:{flexShrink:0,fontSize:12.5},children:"磨砂"}),(0,n.jsx)("input",{type:"range",min:0,max:30,value:d.scrimBlur,onChange:e=>c({scrimBlur:Number(e.target.value)}),style:{flex:1,minWidth:120,accentColor:"var(--accent)",cursor:"pointer"},"aria-label":"磨砂强度"}),(0,n.jsxs)("span",{style:{width:30,flexShrink:0,textAlign:"right",fontSize:11,color:"var(--text)"},children:[d.scrimBlur,"px"]})]})})]})}let y={display:"flex",alignItems:"center",justifyContent:"center",gap:2,width:30,height:30,padding:0,flexShrink:0,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",borderRadius:999,transition:"background 0.12s, color 0.12s"};function v(){return{onMouseEnter:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--text) 8%, transparent)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"}}}let w={...f.r,display:"flex",flexDirection:"column",gap:6,padding:"8px 10px",borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)",color:"var(--text)",whiteSpace:"nowrap"},k={dispatch:"正在派发",resume:"续会话",review:"AI 审核中",blockcheck:"阻塞巡检"};function j({nodes:e,onViewportSave:t}){let{setCenter:r,getViewport:s,getNodes:o}=(0,a.VH)(),{setHighlight:l}=(0,c.kz)(),[d,u]=(0,i.useState)(null),[p,h]=(0,i.useState)(!1),x=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=!1,t=null,r=async()=>{try{let t=await fetch("/api/task-scheduler/status",{cache:"no-store"});if(!t.ok)return;let r=await t.json();e||u(r.status)}catch{}},n=async()=>{await r(),e||(t=setTimeout(n,2500))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[]),(0,i.useEffect)(()=>{if(!p)return;let e=e=>{x.current&&!x.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);let g=(0,i.useMemo)(()=>{let t=new Map;for(let r of e){let e=r.data;e.cardId&&t.set(e.cardId,r.id)}return t},[e]),m=!!d?.activity,b=d?d.activity?k[d.activity.kind]??"工作中":d.running.length>0?`运行中 ${d.running.length}`:d.queue.review.length>0?`待审核 ${d.queue.review.length}`:null:null;return(0,n.jsxs)("div",{ref:x,style:{position:"absolute",top:12,right:12,zIndex:40,display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>h(e=>!e),"aria-expanded":p,"aria-label":"调度器状态",title:"调度器状态",style:{...f.r,display:"flex",alignItems:"center",gap:7,height:36,padding:"0 6px 0 14px",borderRadius:999,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)",color:"var(--text)",cursor:"pointer",whiteSpace:"nowrap"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,background:m?"#f59e0b":(d?.running.length??0)>0?"#10b981":"var(--text-dim)",boxShadow:m?"0 0 6px 1px rgba(245,158,11,0.6)":(d?.running.length??0)>0?"0 0 6px 1px rgba(16,185,129,0.5)":"none",animation:m?"pulse 1.6s ease-in-out infinite":void 0}}),(0,n.jsx)("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--text)"},children:"调度器"}),d?.started===!1&&(0,n.jsx)("span",{style:{fontSize:10.5,color:"var(--text-muted)"},children:"未启动"}),d?.started===!0&&d?.leader===!1&&(0,n.jsx)("span",{style:{fontSize:10.5,color:"var(--text-muted)"},children:"跟随"}),b&&(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:b}),(0,n.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--text-muted)",transform:p?"rotate(180deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),p&&(0,n.jsxs)("div",{style:{...f.r,display:"flex",flexDirection:"column",marginTop:6,padding:"8px 0",width:340,borderRadius:14,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 8px 30px -8px rgba(0,0,0,0.3)",color:"var(--text)"},children:[(0,n.jsxs)("div",{style:{padding:"2px 14px 8px",borderBottom:"1px solid color-mix(in srgb, var(--border) 50%, transparent)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"var(--text)"},children:"调度器"}),(0,n.jsx)("span",{style:{fontSize:10.5,color:"var(--text-muted)"},children:d?.started===!1?"未启动":d?.started===!0&&d?.leader===!1?"跟随(非调度者)":m?"工作中":"休眠"})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6,padding:"10px 12px 8px"},children:[(0,n.jsx)(S,{label:"派发",active:d?.activity?.kind==="dispatch"||d?.activity?.kind==="resume",activityLabel:d?.activity&&("dispatch"===d.activity.kind||"resume"===d.activity.kind)?k[d.activity.kind]:void 0}),(0,n.jsx)(S,{label:"审查",active:d?.activity?.kind==="review"||d?.activity?.kind==="blockcheck",activityLabel:d?.activity&&("review"===d.activity.kind||"blockcheck"===d.activity.kind)?k[d.activity.kind]:void 0})]}),d&&(0,n.jsx)(C,{title:"任务队列",groups:[{label:"运行中",color:"#10b981",cards:d.running},{label:"待审核",color:"#f59e0b",cards:d.queue.review},{label:"待派发",color:"var(--accent)",cards:d.queue.dispatchable},{label:"等回复",color:"var(--text-muted)",cards:d.queue.waitingReply},{label:"失败",color:"#ef4444",cards:d.queue.failed}],nodeIdByCardId:g,onLocate:e=>{let n=o().find(t=>t.id===e);if(!n)return;let i=n.measured?.width??n.style?.width??380,a=n.measured?.height??n.style?.height??270;Promise.resolve(r(n.position.x+i/2,n.position.y+a/2,{zoom:s().zoom})).then(()=>{t?.(s())}),l(e)}}),!d&&(0,n.jsx)("div",{style:{padding:"10px 14px",fontSize:12,color:"var(--text-muted)"},children:"加载中…"})]})]})}function S({label:e,active:t,activityLabel:r}){return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:8,border:"1px solid color-mix(in srgb, var(--border) 55%, transparent)",background:t?"color-mix(in srgb, var(--accent) 8%, transparent)":"transparent"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:t?"#f59e0b":"var(--text-dim)",boxShadow:t?"0 0 6px 1px rgba(245,158,11,0.6)":"none",animation:t?"pulse 1.6s ease-in-out infinite":void 0}}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,n.jsx)("span",{style:{fontSize:12,fontWeight:700,color:"var(--text)",lineHeight:1.2},children:e}),(0,n.jsx)("span",{style:{fontSize:10,fontWeight:600,color:"var(--text-muted)",whiteSpace:"nowrap"},children:r??"休眠"})]})]})}function C({title:e,groups:t,nodeIdByCardId:r,onLocate:i}){let s=t.filter(e=>e.cards.length>0),a=t.reduce((e,t)=>e+t.cards.length,0);return(0,n.jsxs)("div",{style:{padding:"8px 12px 4px"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 2px 4px"},children:[(0,n.jsx)("span",{style:{fontSize:10.5,fontWeight:700,color:"var(--text-muted)",letterSpacing:.3},children:e}),(0,n.jsxs)("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--text-dim)"},children:["共 ",a]})]}),0===s.length?(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)",padding:"2px 2px 6px"},children:"队列空闲"}):s.map(e=>(0,n.jsxs)("div",{style:{marginBottom:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,padding:"0 2px 3px"},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:e.color,flexShrink:0}}),(0,n.jsx)("span",{style:{fontSize:10.5,fontWeight:700,color:"var(--text-muted)"},children:e.label}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:e.cards.length})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[e.cards.slice(0,4).map(e=>{let t=r.get(e.id);return(0,n.jsxs)("button",{type:"button",onClick:()=>{t&&i(t)},disabled:!t,title:t?"点击定位到本看板任务卡":"该任务不在当前看板",style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"4px 6px",border:"none",borderRadius:6,background:"transparent",color:"var(--text)",fontSize:12,textAlign:"left",cursor:t?"pointer":"default",opacity:t?1:.55},children:[(0,n.jsxs)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,n.jsxs)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:["#",e.number]})," ",e.name]}),!t&&(0,n.jsx)("span",{style:{flexShrink:0,fontSize:9.5,color:"var(--text-dim)"},children:"其它看板"})]},e.id)}),e.cards.length>4&&(0,n.jsxs)("div",{style:{padding:"2px 6px",fontSize:10,color:"var(--text-dim)"},children:["…共 ",e.cards.length," 个"]})]})]},e.label))]})}let I=(0,s.default)(()=>Promise.all([r.e(6126),r.e(5004),r.e(277),r.e(2666),r.e(3922),r.e(7975)]).then(r.bind(r,90356)).then(e=>e.CanvasStage),{loadableGenerated:{webpack:()=>[90356]},ssr:!1,loading:()=>(0,n.jsx)(p.N,{label:"正在加载画布…"})});function R({boardId:e,taskId:t,newSessionCwd:r,onRunningSessionIdsChange:s,wallSettings:p,updateWallSettings:f}){let{t:m}=(0,l.s)(),{isDark:y}=(0,o.D)(),v=(0,d.C6)({boardId:e,taskId:t,newSessionCwd:r}),w=!!(v.board?.taskId??t),k=(0,i.useMemo)(()=>({getStatus:e=>v.taskCardStatus[e],register:v.registerVisibleTaskCard,unregister:v.unregisterVisibleTaskCard}),[v.taskCardStatus,v.registerVisibleTaskCard,v.unregisterVisibleTaskCard]),S=(0,i.useMemo)(()=>({getRunning:e=>v.sessionRunning[e],getSummary:e=>v.sessionTitles[e]}),[v.sessionRunning,v.sessionTitles]),C=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||"f"!==e.key.toLowerCase())return;let t=document.activeElement;if(t&&t!==C.current){let e=t.tagName;if("INPUT"===e||"TEXTAREA"===e||t.isContentEditable)return}e.preventDefault(),C.current?.focus(),C.current?.select()};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]);let[E,z]=(0,i.useState)(!1),T=(0,i.useCallback)(async()=>{if(!E){z(!0);try{v.loadSessionSummaries(),await v.reloadCanvas()}finally{setTimeout(()=>z(!1),800)}}},[v,E]);return(0,i.useEffect)(()=>{s?.(new Set(v.running?.runningSessionIds??[]))},[v.running,s]),(0,n.jsx)("div",{"data-glass-scope":"board",style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"},children:(0,n.jsx)(u.I,{value:"board",children:(0,n.jsx)(h.Nc.Provider,{value:{boardId:v.board?.id??null,defaultCwd:r??null},children:(0,n.jsx)(c.eR,{children:(0,n.jsx)(a.Ln,{children:(0,n.jsx)(d.x_,{value:k,children:(0,n.jsxs)(d.XK,{value:S,children:[!v.loading&&(0,n.jsx)(b,{boardName:v.board?.name??"",isTaskBoard:w,reloading:E,onReload:()=>void T(),onClear:()=>{(0,x.l)({message:w?m("boards.clearTaskConfirm"):m("boards.clearConfirm"),confirmText:m("boards.clear")}).then(e=>{e&&v.clearBoard()})},onAddSessionCard:e=>v.addNewSessionCard(e),wallSettings:p,updateWallSettings:f}),(0,n.jsx)(j,{nodes:v.nodes,onViewportSave:v.saveViewport}),!v.loading&&(0,n.jsx)("div",{style:{position:"absolute",top:12,left:0,right:0,display:"flex",justifyContent:"center",pointerEvents:"none",zIndex:40},children:(0,n.jsx)("div",{style:{pointerEvents:"auto"},children:(0,n.jsx)(g,{inputRef:C,nodes:v.nodes,onViewportSave:v.saveViewport})})}),(0,n.jsx)(I,{board:v,isDark:y})]})})})})})})})}},64536:(e,t,r)=>{r.d(t,{C6:()=>x,Nz:()=>w,Uh:()=>k,VX:()=>b,XK:()=>v,ZI:()=>u,eo:()=>p,rD:()=>m,x_:()=>g});var n=r(12115),i=r(67816),s=r(44706),a=r(81750),o=r(15934),l=r(24456),d=r(94315),c=r(41463);let u=340,p=160,h=c.env.NEXT_PUBLIC_SYNC_WS??`${"https:"===window.location.protocol?"wss":"ws"}://${window.location.host}`;function x({boardId:e,taskId:t,newSessionCwd:r}){let[c,f]=(0,n.useState)(null),[g,m]=(0,n.useState)(null),[b,y]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1);(0,n.useEffect)(()=>{w(!1);let e=setTimeout(()=>w(!0),450);return()=>clearTimeout(e)},[e]);let[k,j]=(0,n.useState)([]),[S,C]=(0,n.useState)([]),[I,R]=(0,n.useState)({x:0,y:0,zoom:1}),[E,z]=(0,n.useState)(null),T=(0,n.useRef)(null),A=(0,n.useRef)(null),L=(0,n.useRef)(null),M=(0,n.useRef)(null),W=(0,n.useRef)(!1);W.current=b;let $=(0,n.useRef)(null),D=(0,n.useRef)(e);D.current=e;let P=(0,n.useRef)(new Set),N=(0,n.useRef)(null);N.current=c;let B=(0,n.useRef)(t??null);B.current=t??null;let H=(0,n.useRef)(r);H.current=r;let U=(0,n.useMemo)(()=>`${h}/connect`,[]);(0,n.useEffect)(()=>{let t=new i.m({url:U,name:e,forceSyncInterval:!1,flushDelay:500});T.current=t,z(t);let r=t.document.getMap("nodes"),n=t.document.getMap("edges"),a=t.document.getMap("view");A.current=r,L.current=n,M.current=a;let l=e=>{let t=e?new Set(Array.from(e.keys.keys())):null;if(e&&W.current){let t=null;for(let[n,i]of e.keys){if(i?.action!=="add")continue;let e=r.get(n);if(e?.type!=="session-card")continue;let s=e.data;s?.sessionId&&!s.cwd&&(P.current.has(s.sessionId)||(P.current.add(s.sessionId),t=t??s.sessionId))}t&&(0,o.PH)(t)}j(e=>{let n=new Set(e.filter(e=>e.selected).map(e=>e.id)),i=new Set(e.filter(e=>e.dragging).map(e=>e.id)),s=ea.current,a=new Map(e.map(e=>[e.id,e]));return Array.from(r.values()).map(e=>{if(t&&!t.has(e.id)){let t=a.get(e.id);if(t)return t}let r={...e};if(s.has(e.id)){let t=a.get(e.id);t&&(r.position=t.position)}return delete r.selected,delete r.dragging,n.has(e.id)&&(r.selected=!0),i.has(e.id)&&(r.dragging=!0),r})})},d=()=>C(Array.from(n.values())),c=()=>{let e=M.current;e&&R({x:e.get("x")??0,y:e.get("y")??0,zoom:e.get("zoom")??1})},u=()=>{c(),y(!0)};r.observe(l),n.observe(d),a.observe(c),t.on("synced",u),l(),d();let p=new s.ad([r,n],{captureTimeout:500,trackedOrigins:new Set([null])});return $.current=p,()=>{p.destroy(),$.current=null,r.unobserve(l),n.unobserve(d),a.unobserve(c),t.off("synced",u),t.flushPendingUpdates?.(),t.destroy(),T.current=null,A.current=null,L.current=null,M.current=null,y(!1)}},[U,e]);let _=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/boards/${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok)return void m(`HTTP ${t.status}`);let r=await t.json();f(r.board)}catch(e){m(e instanceof Error?e.message:String(e))}},[e]);(0,n.useEffect)(()=>{_()},[_]);let V=(0,n.useCallback)(async()=>{try{await fetch(`/api/boards/${encodeURIComponent(e)}/reconcile`,{method:"POST"})}catch{}await _()},[e,_]),[O,F]=(0,n.useState)(()=>globalThis.__piRunningSnapshot??null),q=(0,n.useCallback)(e=>{globalThis.__piRunningSnapshot=e,F(e)},[]),K=(0,n.useRef)(!1),X=(0,n.useRef)(new Set),[G,J]=(0,n.useState)({}),Q=(0,n.useCallback)(e=>{X.current.add(e)},[]),Y=(0,n.useCallback)(e=>{X.current.delete(e)},[]),[Z,ee]=(0,n.useState)({});(0,n.useEffect)(()=>{let e=!1,t=null,r=async()=>{if(!e&&!K.current&&"visible"===document.visibilityState){K.current=!0;try{let t=Array.from(X.current),r=t.length>0&&D.current?`?boardId=${encodeURIComponent(D.current)}&cardIds=${encodeURIComponent(t.join(","))}`:"",n=await fetch(`/api/agent/running${r}`,{cache:"no-store"});if(!n.ok)return;let i=await n.json();if(e)return;q(i);let s=e=>{J(t=>{let r=e(t);if(r===t)return t;let n=Object.keys(t),i=Object.keys(r);return n.length===i.length&&n.every(e=>r[e]===t[e])?t:r})};i.taskCards.length>0?s(e=>{let t=!1,r={...e};for(let e of i.taskCards)r[e.cardId]!==e&&(r[e.cardId]=e,t=!0);return t?r:e}):t.length>0&&s(e=>{let r=!1,n={...e};for(let e of t)n[e]&&(delete n[e],r=!0);return r?n:e});let a=A.current,o={};if(a)for(let e of Array.from(a.values())){if("session-card"!==e.type)continue;let t=e.data;if(!t.sessionId)continue;let r=i.states[t.sessionId];if(i.runningSessionIds.includes(t.sessionId)&&r){let e=r.phase??"waiting_model",n=r.startedAt?Date.now()-r.startedAt:0;o[t.sessionId]={phase:e,runningMs:n,endedAt:0}}else o[t.sessionId]={phase:"idle",runningMs:0,endedAt:0}}ee(e=>{let t=!1,r={...e};for(let[n,i]of Object.entries(o)){let s=e[n];s&&s.phase===i.phase&&s.runningMs===i.runningMs&&s.endedAt===i.endedAt||(r[n]=i,t=!0)}return t?r:e})}catch{}finally{K.current=!1}}},n=()=>{e||(t=setTimeout(async()=>{await r(),n()},2500))};r(),n();let i=()=>{"visible"===document.visibilityState&&r()};return document.addEventListener("visibilitychange",i),()=>{e=!0,t&&clearTimeout(t),document.removeEventListener("visibilitychange",i)}},[q]);let[et,er]=(0,n.useState)({}),en=(0,n.useRef)({});en.current=et;let ei=(0,n.useRef)(!1),es=(0,n.useCallback)(async()=>{if(!ei.current){ei.current=!0;try{let e=A.current;if(!e)return;let t=[];for(let r of Array.from(e.values())){if(r?.type!=="session-card")continue;let e=r.data;e?.sessionId&&!e.cwd&&t.push(e.sessionId)}if(0===t.length)return void er({});let r=await fetch("/api/sessions/summary",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t}),cache:"no-store"});if(!r.ok)return;let n=await r.json(),i={};for(let e of n.sessions)i[e.id]={title:e.name??e.firstMessage??"Untitled",messageCount:e.messageCount??0,projectName:e.projectKey??e.projectRoot??"",lastReply:e.lastReply??"",lastActivityAt:e.modified?Date.parse(e.modified):0,projectRoot:e.projectRoot,cwd:e.cwd,worktreeBranch:e.worktreeBranch,isWorktree:e.isWorktree};er(i)}catch{}finally{ei.current=!1}}},[]);(0,n.useEffect)(()=>{let e,t=!1,r=async()=>{await es(),t||(e=setTimeout(r,5e3))};r();let n=()=>{"visible"===document.visibilityState&&(e&&clearTimeout(e),r())};return document.addEventListener("visibilitychange",n),()=>{t=!0,e&&clearTimeout(e),document.removeEventListener("visibilitychange",n)}},[es]),(0,n.useEffect)(()=>{let e=T.current,t=A.current;e&&t&&W.current&&0!==Object.keys(et).length&&e.document.transact(()=>{for(let e of Array.from(t.values())){if("session-card"!==e.type)continue;let r=e.data,n=et[r.sessionId];n&&(r.title!==n.title||r.lastReply!==n.lastReply||r.messageCount!==n.messageCount||r.lastActivityAt!==n.lastActivityAt)&&t.set(e.id,{...e,data:{...r,title:n.title,lastReply:n.lastReply,messageCount:n.messageCount,lastActivityAt:n.lastActivityAt}})}},"board-summary")},[et,b]);let ea=(0,n.useRef)(new Set),eo=(0,n.useCallback)(e=>{let t=A.current;if(!t)return;let r=e.filter(e=>"select"===e.type);r.length&&j(e=>(0,a._0)(r,e));let n=e.filter(e=>"select"!==e.type);if(0===n.length)return;let i=Array.from(t.values()),s=(0,a._0)(n,i),o=new Set(n.filter(e=>"dimensions"===e.type&&!0===e.resizing).map(e=>e.id));for(let e of n)if("add"===e.type||"replace"===e.type)t.set(e.item.id,e.item);else if("remove"===e.type&&t.has(e.id)){t.delete(e.id);let r=L.current;if(r)for(let t of Array.from(r.values()))(t.source===e.id||t.target===e.id)&&r.delete(t.id)}else if("position"===e.type){!0===e.dragging?ea.current.add(e.id):ea.current.delete(e.id);let r=s.find(t=>t.id===e.id);r&&(!0===e.dragging||o.has(e.id)?j(t=>t.map(t=>t.id===e.id?{...t,position:r.position}:t)):(t.set(e.id,{...function(e){let{selected:t,dragging:r,resizing:n,...i}=e;return i}(r),position:r.position}),j(t=>t.map(t=>t.id===e.id?{...t,position:r.position}:t))))}else"dimensions"===e.type&&j(t=>(0,a._0)([e],t))},[]),el=(0,n.useCallback)(e=>{let t=L.current;if(!t)return;let r=Array.from(t.values()),n=(0,a.zW)(e,r);for(let r of e)if("add"===r.type||"replace"===r.type)t.set(r.item.id,r.item);else if("remove"===r.type&&t.has(r.id)){let e=t.get(r.id);if(e&&e.data?.execLink||e&&e.data?.forkLink||e&&e.data?.taskLink)continue;t.delete(r.id)}else{let e=n.find(e=>e.id===r.id);e&&t.set(r.id,e)}},[]),ed=(0,n.useCallback)(e=>{let t=L.current,r=A.current;if(!t||!r)return;let n=`edge-${e.source}-${e.target}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,i=r.get(e.source),s=r.get(e.target),a=(0,d.dk)(i),o=(0,d.dk)(s),l=i?.type==="session-card",c=s?.type==="session-card",u=a&&c||l&&o;t.set(n,{id:n,source:e.source,target:e.target,type:u?"send-note":"default",data:u?{sendNote:!0,sent:!1}:void 0,markerEnd:{type:"arrowclosed"},style:{strokeWidth:1.5,stroke:"#8b8fa3"}})},[]),ec=(0,n.useCallback)(e=>{let t=A.current;if(!t)return;let r=crypto.randomUUID(),n=`session-${r}`,i=e?.x??60,s=e?.y??60,a=i-420+t.size%3*24,o=s-300+t.size%3*24;t.set(n,{id:n,type:"session-card",position:{x:a,y:o},style:{width:840,height:600},data:{sessionId:r,title:"",emoji:"\uD83D\uDCAC",projectName:"",messageCount:0,lastReply:"",phase:"idle",runningMs:0,endedAt:0,lastActivityAt:0,stale:!1,expanded:!0,cwd:H.current??"",taskId:B.current??N.current?.taskId??"",w:840,h:600,expandedW:0,expandedH:0,collapsedW:0,collapsedH:0}})},[]),eu=(0,n.useCallback)(async(e,t,r,n)=>{let i=A.current;if(!i)return;let s=B.current??N.current?.taskId??null;if(s){try{let t=await fetch(`/api/tasks/${encodeURIComponent(s)}/assign-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e})});if(!t.ok)throw Error(`HTTP ${t.status}`)}catch(t){console.warn(`[board] 拖入会话归属任务失败,未落卡 ${e}:`,t instanceof Error?t.message:t);return}(0,o.PH)(e)}let a=en.current[e],l=`session-${e}`,d=i.get(l);d?i.set(l,{...d,position:{x:t,y:r}}):i.set(l,{id:l,type:"session-card",position:{x:t,y:r},style:{width:u,height:p},data:{sessionId:e,title:n??a?.title??"Untitled",emoji:"\uD83D\uDCAC",projectName:a?.projectName??"",messageCount:a?.messageCount??0,lastReply:a?.lastReply??"",lastActivityAt:a?.lastActivityAt??0,phase:"idle",runningMs:0,endedAt:0,stale:!1,expanded:!1,taskId:s??"",w:u,h:p,expandedW:0,expandedH:0,collapsedW:0,collapsedH:0}})},[]),ep=(0,n.useCallback)(async e=>{let t=A.current,r=L.current;if(t&&r)if("session-card"===e.type){let n=e.data;if(!n.sessionId||n.cwd){if(n.sessionId)try{let e=await fetch(`/api/sessions/${encodeURIComponent(n.sessionId)}`,{method:"DELETE"});e.ok?(0,o.Qp)(n.sessionId):console.warn(`[board] 清理新会话卡关联会话 ${n.sessionId} 失败 HTTP ${e.status}`)}catch(e){console.warn(`[board] 清理新会话卡关联会话 ${n.sessionId} 异常`,e)}for(let n of(t.delete(e.id),Array.from(r.values())))(n.source===e.id||n.target===e.id)&&r.delete(n.id);return}if(B.current??N.current?.taskId){if(!await (0,l.l)({message:"删除该会话?\n将同时删除会话文件并移除画布卡片。此操作不可撤销。"}))return;await fetch(`/api/sessions/${encodeURIComponent(n.sessionId)}`,{method:"DELETE"}).then(()=>(0,o.Qp)(n.sessionId)).catch(e=>console.warn(`[board] 删除会话 ${n.sessionId} 异常`,e))}else if(!await (0,l.l)({message:"移除该会话卡片?\n会话本身将保留在会话列表中,可随时重新拖入。"}))return;for(let n of(t.delete(e.id),Array.from(r.values())))(n.source===e.id||n.target===e.id)&&r.delete(n.id)}else if("task-card"===e.type){let n=e.data;if(!n.cardId)return void t.delete(e.id);if(!await (0,l.l)({message:"删除该任务卡?\n将删除任务卡、依赖线与执行会话连线;关联的执行会话保留。此操作不可撤销。"}))return;try{let e=await fetch(`/api/task-cards/${encodeURIComponent(n.cardId)}`,{method:"DELETE"});if(!e.ok)return void console.warn(`[board] 删除任务卡 ${n.cardId} 失败 HTTP ${e.status},保留画布卡`)}catch(e){console.warn(`[board] 删除任务卡 ${n.cardId} 异常,保留画布卡`,e);return}for(let n of(t.delete(e.id),Array.from(r.values())))(n.source===e.id||n.target===e.id)&&r.delete(n.id)}else{for(let n of(t.delete(e.id),Array.from(r.values())))(n.source===e.id||n.target===e.id)&&r.delete(n.id);if("image-node"===e.type){let r=e.data.src,n=r?.match(/^\/api\/board-assets\/([^/?#]+)$/)?.[1];n&&(Array.from(t.values()).some(t=>t.id!==e.id&&t.data?.src?.includes(n))||fetch(`/api/board-assets/${encodeURIComponent(n)}`,{method:"DELETE"}).catch(e=>console.warn(`[board] 回收图片资产 ${n} 异常`,e)))}}},[]),eh=(0,n.useCallback)((e,t)=>{let r=A.current;if(!r)return;let n=r.get(e);n&&r.set(e,{...n,...t,data:t.data?{...n.data,...t.data}:n.data,style:t.style?{...n.style??{},...t.style}:n.style})},[]),ex=(0,n.useRef)(new Map),ef=(0,n.useRef)(new Map),eg=(0,n.useCallback)((e,t,r=400)=>{let n=A.current;if(!n||!n.has(e))return;let i=ex.current.get(e)??{},s={...i,...t,data:{...i.data,...t.data}};ex.current.set(e,s);let a=ef.current.get(e);a&&clearTimeout(a),ef.current.set(e,setTimeout(()=>{let t=ex.current.get(e);ex.current.delete(e),ef.current.delete(e),t&&eh(e,t)},r))},[eh]),em=(0,n.useCallback)((e,t)=>{let r=A.current;if(!r||!e||e===t)return;let n=r.get(e);if(!n)return;r.delete(e),r.set(t,{...n,id:t});let i=L.current;if(i)for(let r of Array.from(i.values()))(r.source===e||r.target===e)&&i.set(r.id,{...r,source:r.source===e?t:r.source,target:r.target===e?t:r.target})},[]),eb=(0,n.useCallback)(e=>{let t=L.current;t&&t.set(e.id,e)},[]),ey=(0,n.useCallback)((e,t)=>{let r=L.current;if(!r)return;let n=r.get(e);n&&r.set(e,{...n,...t,data:{...n.data,...t.data}})},[]),ev=(0,n.useCallback)(e=>{let t=A.current;t&&t.set(e.id,e)},[]),ew=(0,n.useCallback)(async()=>{let e=A.current,t=L.current;if(!e||!t)return;let r=!!(B.current??N.current?.taskId);for(let n of Array.from(e.values()).filter(e=>!r||"session-card"!==e.type))for(let r of(e.delete(n.id),Array.from(t.values())))(r.source===n.id||r.target===n.id)&&t.delete(r.id)},[]),ek=(0,n.useCallback)(()=>{$.current?.undo()},[]),ej=(0,n.useCallback)(()=>{$.current?.redo()},[]),eS=!b||!v,eC=(0,n.useCallback)(e=>{let t=M.current;t&&(t.get("x")!==e.x||t.get("y")!==e.y||t.get("zoom")!==e.zoom)&&(t.set("x",e.x),t.set("y",e.y),t.set("zoom",e.zoom))},[]);return(0,n.useMemo)(()=>({board:c,loading:eS,error:g,running:O,runningCount:O?.runningSessionIds.length??0,taskCardStatus:G,sessionRunning:Z,registerVisibleTaskCard:Q,unregisterVisibleTaskCard:Y,nodes:k,edges:S,viewport:I,saveViewport:eC,onNodesChange:eo,onEdgesChange:el,onConnect:ed,provider:E,ready:b,addSessionNode:eu,addNewSessionCard:ec,deleteNodeWithConfirm:ep,updateNode:eh,updateNodeDebounced:eg,normalizeNodeId:em,addEdge:eb,updateEdge:ey,addNode:ev,clearBoard:ew,sessionTitles:et,loadSessionSummaries:es,reloadCanvas:V,undo:ek,redo:ej}),[c,eS,g,O,k,S,I,eC,eo,el,ed,E,b,eu,ec,ep,eh,eg,em,eb,ey,ev,ew,et,es,V,_,G,Z,Q,Y,ek,ej])}let f=(0,n.createContext)(null);function g({value:e,children:t}){return(0,n.createElement)(f.Provider,{value:e},t)}function m(e){let t=(0,n.useContext)(f);return e&&t?t.getStatus(e):void 0}function b(){let e=(0,n.useContext)(f);return{register:e?.register??(()=>{}),unregister:e?.unregister??(()=>{})}}let y=(0,n.createContext)(null);function v({value:e,children:t}){return(0,n.createElement)(y.Provider,{value:e},t)}function w(e){let t=(0,n.useContext)(y);return e&&t?t.getRunning(e):void 0}function k(e){let t=(0,n.useContext)(y);return e&&t?t.getSummary(e):void 0}},71309:(e,t,r)=>{r.d(t,{eR:()=>o,kz:()=>l,u:()=>s});var n=r(95155),i=r(12115);let s="0 0 0 3px var(--accent), 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent)",a=(0,i.createContext)(null);function o({children:e}){let[t,r]=(0,i.useState)(null),s=(0,i.useRef)(null),l=(0,i.useCallback)(e=>{s.current&&clearTimeout(s.current),s.current=null,r(e),e&&(s.current=setTimeout(()=>r(null),1800))},[]);return(0,i.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),(0,n.jsx)(a.Provider,{value:{highlightId:t,setHighlight:l},children:e})}function l(){let e=(0,i.useContext)(a);return e||{highlightId:null,setHighlight:()=>{}}}},71459:(e,t,r)=>{r.d(t,{r:()=>n});let n={backgroundImage:"linear-gradient(var(--board-card-glass), var(--board-card-glass)), var(--glass-bg-image-card, var(--glass-bg-image, none))",backgroundAttachment:"fixed",backgroundSize:"100% 100%, 100% 100%",backgroundRepeat:"no-repeat, no-repeat",backgroundPosition:"0 0, 0 0"}},94315:(e,t,r)=>{r.d(t,{OX:()=>u,dk:()=>c});var n=r(95155),i=r(12115),s=r(81750),a=r(85610),o=r(32383),l=r(25535);let d=new Set(["sticky-note","text","text-node"]);function c(e){return!!(e&&d.has(e.type??""))}function u({id:e,source:t,target:r,sourceX:d,sourceY:p,targetX:h,targetY:x,sourcePosition:f,targetPosition:g,markerEnd:m,style:b,data:y}){let{getNodes:v}=(0,s.VH)(),{updateEdge:w}=(0,l.U)(),[k,j,S]=(0,a.Fp)({sourceX:d,sourceY:p,sourcePosition:f,targetX:h,targetY:x,targetPosition:g}),C=!!y?.sent,[I,R]=(0,i.useState)(!1),[E,z]=(0,i.useState)(!1),T=(0,i.useRef)(!1),A=v(),L=A.find(e=>e.id===t&&c(e))??A.find(e=>e.id===r&&c(e)),M=A.find(e=>e.id===r&&"session-card"===e.type)??A.find(e=>e.id===t&&"session-card"===e.type),W=M?.data?.sessionId,$=!!M?.data?.cwd,D=(L?.data?.text??"").trim(),P=(0,i.useCallback)(async()=>{if(C||T.current)return;let n=v(),i=n.find(e=>e.id===t&&c(e))??n.find(e=>e.id===r&&c(e)),s=n.find(e=>e.id===r&&"session-card"===e.type)??n.find(e=>e.id===t&&"session-card"===e.type),a=s?.data?.sessionId,l=s?.data;if(!i||!s||!a||l?.cwd)return;let d=(i.data?.text??"").trim();if(d){T.current=!0,R(!0),z(!1),w(e,{data:{sent:!0}});try{await (0,o.$J)(a,{type:"prompt",message:d})}catch(t){w(e,{data:{sent:!1}}),z(!0),console.warn("[board] 发送便笺内容到会话失败:",t instanceof Error?t.message:t)}T.current=!1,R(!1)}},[e,t,r,C,w,v]),N="发送",B="把便笺内容作为消息发送给该会话",H=!1;return C?(N="✓ 已发送",B="已发送(每条连线只发送一次)",H=!0):I?(N="发送中…",H=!0):E?(N="重试",B="上次发送失败,点击重试"):D?W?$&&(B="新会话卡尚未创建会话,无法发送",H=!0):(B="会话不存在",H=!0):(B="便笺内容为空,无法发送",H=!0),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(s.tE,{path:k,markerEnd:m,style:b}),(0,n.jsx)(s.rV,{children:(0,n.jsx)("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${j}px, ${S}px)`,pointerEvents:"all",zIndex:1e3},children:(0,n.jsx)("button",{type:"button",onClick:P,disabled:H,title:B,"data-testid":`send-note-${e}`,style:{display:"flex",alignItems:"center",gap:4,padding:"2px 10px",borderRadius:999,border:H?"1px solid color-mix(in srgb, var(--border) 60%, transparent)":"1px solid color-mix(in srgb, var(--accent) 45%, transparent)",background:"var(--board-card-glass)",backdropFilter:"blur(var(--board-blur)) saturate(var(--glass-saturate))",WebkitBackdropFilter:"blur(var(--board-blur)) saturate(var(--glass-saturate))",color:H?"var(--text-muted)":"var(--accent)",fontSize:11,fontWeight:600,cursor:H?"default":"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 6px -2px rgba(0,0,0,0.25)",userSelect:"none"},children:N})})})]})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7975],{90356:(e,t,r)=>{r.r(t),r.d(t,{CanvasStage:()=>e$});var n=r(95155),o=r(12115),a=r(81750);function i(e){if("number"==typeof e)return e;if("string"==typeof e){let t=parseFloat(e);return Number.isFinite(t)?t:0}return 0}function s(e){let t=e.data??{},r=i(e.width)||i(e.style?.width)||i(t.w)||0,n=i(e.height)||i(e.style?.height)||i(t.h)||0;return{left:e.position.x,right:e.position.x+r,cx:e.position.x+r/2,top:e.position.y,bottom:e.position.y+n,cy:e.position.y+n/2,w:r,h:n}}function l(e,t){return Math.hypot(Math.max(0,Math.max(e.left-t.right,t.left-e.right)),Math.max(0,Math.max(e.top-t.bottom,t.top-e.bottom)))}function d(e,t,r,n=8){let o=r.find(t=>t.id===e);if(!o)return{lines:[],snapX:null,snapY:null};let a=s({...o,position:{...o.position,...t}}),i=Math.min(a.left,a.right),c=Math.max(a.left,a.right),u=Math.min(a.top,a.bottom),p=Math.max(a.top,a.bottom),x=null,h=null,g=n,f=n,b=null,m=null,v=null,y=null;for(let o of r){if(o.id===e)continue;let r=s(o);if(l(a,r)>200)continue;let i=Math.min(r.left,r.right),d=Math.max(r.left,r.right),c=Math.min(r.top,r.bottom),u=Math.max(r.top,r.bottom);for(let[e,n]of[[a.left,r.left],[a.left,r.cx],[a.left,r.right],[a.cx,r.left],[a.cx,r.cx],[a.cx,r.right],[a.right,r.left],[a.right,r.cx],[a.right,r.right]]){let r=Math.abs(e-n);r<g&&(g=r,x=t.x+(n-e),b=n,m={minY:c,maxY:u})}for(let[e,n]of[[a.top,r.top],[a.top,r.cy],[a.top,r.bottom],[a.cy,r.top],[a.cy,r.cy],[a.cy,r.bottom],[a.bottom,r.top],[a.bottom,r.cy],[a.bottom,r.bottom]]){let r=Math.abs(e-n);r<f&&(f=r,h=t.y+(n-e),v=n,y={minX:i,maxX:d})}if(g<n&&f<n)break}let w=[];return null!==b&&m&&w.push({x1:b,y1:Math.min(u,m.minY)-6,x2:b,y2:Math.max(p,m.maxY)+6}),null!==v&&y&&w.push({x1:Math.min(i,y.minX)-6,y1:v,x2:Math.max(c,y.maxX)+6,y2:v}),{lines:w,snapX:x,snapY:h}}function c(e,t,r,n,o,a=8){if(!o.find(t=>t.id===e))return{lines:[],snapW:null,snapH:null};let i={left:t.x,right:t.x+r,cx:t.x+r/2,top:t.y,bottom:t.y+n,cy:t.y+n/2,w:r,h:n},d=Math.min(i.left,i.right),u=Math.max(i.left,i.right),p=Math.min(i.top,i.bottom),x=Math.max(i.top,i.bottom),h=null,g=null,f=a,b=a,m=null,v=null,y=null,w=null;for(let r of o){if(r.id===e)continue;let n=s(r);if(l(i,n)>200)continue;let o=Math.min(n.left,n.right),d=Math.max(n.left,n.right),c=Math.min(n.top,n.bottom),u=Math.max(n.top,n.bottom);for(let[e,r]of[[i.right,n.left],[i.right,n.cx],[i.right,n.right]]){let n=Math.abs(e-r);n<f&&(f=n,h=r-t.x,m=r,v={minY:c,maxY:u})}for(let[e,r]of[[i.bottom,n.top],[i.bottom,n.cy],[i.bottom,n.bottom]]){let n=Math.abs(e-r);n<b&&(b=n,g=r-t.y,y=r,w={minX:o,maxX:d})}if(f<a&&b<a)break}let k=[];return null!==m&&v&&k.push({x1:m,y1:Math.min(p,v.minY)-6,x2:m,y2:Math.max(x,v.maxY)+6}),null!==y&&w&&k.push({x1:Math.min(d,w.minX)-6,y1:y,x2:Math.max(u,w.maxX)+6,y2:y}),{lines:k,snapW:h,snapH:g}}r(53255);var u=r(39247),p=r(85610),x=r(47650),h=r(71594);function g({stats:e,contextUsage:t}){if(!e)return null;let r=e.tokens,o=e.cost??0,a=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),i=o>0?o>=.01?`$${o.toFixed(2)}`:"<$0.01":null,s="var(--text-muted)",l=null;if(t?.contextWindow){let e=t.percent;null!==e&&e>90?s="#ef4444":null!==e&&e>70&&(s="rgba(234,179,8,0.95)"),l=null!==e?`${e.toFixed(0)}% / ${a(t.contextWindow)}`:`? / ${a(t.contextWindow)}`}let d={display:"flex",alignItems:"center",gap:4,flexShrink:0};return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0,fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[r.input>0&&(0,n.jsxs)("span",{style:d,children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("line",{x1:"5",y1:"8.5",x2:"5",y2:"1.5"}),(0,n.jsx)("polyline",{points:"2 4 5 1.5 8 4"})]}),a(r.input)]}),r.output>0&&(0,n.jsxs)("span",{style:d,children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,n.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),a(r.output)]}),r.cacheRead>0&&(0,n.jsxs)("span",{style:d,children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M8.5 5a3.5 3.5 0 1 1-1-2.45"}),(0,n.jsx)("polyline",{points:"6.5 1.5 8.5 2.5 7.5 4.5"})]}),a(r.cacheRead)]}),i&&(0,n.jsx)("span",{style:{display:"flex",alignItems:"center",color:"var(--text)",fontWeight:500,flexShrink:0},children:i}),l&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:s,flexShrink:0},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M1 9 L1 5 Q1 1 5 1 Q9 1 9 5 L9 9"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"9",y2:"9"})]}),l]})]})}let f=(0,o.forwardRef)(function({sessionId:e,stats:t,contextUsage:r,todos:a,systemPrompt:i,systemPromptLoading:s,cwd:l,projectRoot:d,isWorktree:c,worktreeBranch:p},x){let{t:h}=(0,u.s)(),[g,f]=(0,o.useState)(!1),[E,R]=(0,o.useState)(!1),[M,L]=(0,o.useState)(!1),W=(0,o.useRef)(null),z=(0,o.useRef)(null),T=(0,o.useRef)(null),I=(0,o.useRef)(null);(0,o.useImperativeHandle)(x,()=>({openStats:()=>{f(!0),R(!1)}}),[]);let N=e=>{f("stats"===e),R("todo"===e),L("system"===e)},D=(0,o.useCallback)(()=>{window.open(`/api/sessions/${encodeURIComponent(e)}/export?inline=1`,"_blank","noopener,noreferrer")},[e]),H=r?.contextWindow&&null!==r.percent?`${r.percent.toFixed(0)}% / ${k(r.contextWindow)}`:h("nav.stats"),$=a.filter(e=>"completed"!==e.status).length,B=(0,o.useCallback)(()=>{let e=W.current?.closest("[data-session-titlebar]");return e?.getBoundingClientRect().width??300},[]),F=g||E||M;return(0,o.useEffect)(()=>{if(!F)return;let e=e=>{let t=e.target;t instanceof Node&&(W.current?.contains(t)||document.querySelector("[data-session-nav-popover]")?.contains(t)||document.querySelector("[data-session-nav-todo]")?.contains(t)||document.querySelector("[data-session-nav-system]")?.contains(t)||document.querySelector(".glass-top-panel")?.contains(t))||(f(!1),R(!1),L(!1))},t=e=>{"Escape"===e.key&&(f(!1),R(!1),L(!1))};return document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t,!0),()=>{document.removeEventListener("pointerdown",e,!0),document.removeEventListener("keydown",t,!0)}},[F]),(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{ref:W,style:{display:"flex",alignItems:"center",gap:2,padding:"0 4px",position:"relative",pointerEvents:"all",height:"100%"},children:[(0,n.jsxs)("button",{type:"button",onClick:D,title:h("history.full"),"aria-label":h("history.full"),style:b,onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background=y},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="transparent"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"}),(0,n.jsx)("path",{d:"M12 7v5l3 2"})]}),(0,n.jsx)("span",{style:m,children:h("history.full")})]}),(0,n.jsx)("span",{style:v}),(0,n.jsxs)("button",{ref:I,type:"button",onClick:()=>N(M?"none":"system"),title:h("system.prompt"),"aria-label":h("system.prompt"),"aria-expanded":M,style:{...b,background:M?w:"transparent",color:M?"var(--accent)":"var(--text-muted)"},onMouseEnter:e=>{M||(e.currentTarget.style.color="var(--text)",e.currentTarget.style.background=y)},onMouseLeave:e=>{M||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:i?"var(--accent)":"var(--text-dim)"},"aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,n.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,n.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),(0,n.jsx)("polyline",{points:"10 9 9 9 8 9"})]}),(0,n.jsx)("span",{style:m,children:h("system.label")})]}),(0,n.jsx)("span",{style:v}),(0,n.jsxs)("button",{ref:z,type:"button",onClick:()=>N(g?"none":"stats"),title:h("session.title"),"aria-label":h("session.title"),"aria-expanded":g,style:{...b,background:g?w:"transparent",color:g?"var(--accent)":"var(--text-muted)"},onMouseEnter:e=>{g||(e.currentTarget.style.color="var(--text)",e.currentTarget.style.background=y)},onMouseLeave:e=>{g||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("line",{x1:"12",y1:"20",x2:"12",y2:"10"}),(0,n.jsx)("line",{x1:"18",y1:"20",x2:"18",y2:"4"}),(0,n.jsx)("line",{x1:"6",y1:"20",x2:"6",y2:"16"})]}),(0,n.jsx)("span",{style:m,children:H})]}),a.length>0&&(0,n.jsxs)("button",{ref:T,type:"button",onClick:()=>N(E?"none":"todo"),title:h("todo.title"),"aria-label":h("todo.title"),"aria-expanded":E,style:{...b,background:E?w:"transparent",color:E?"var(--accent)":"var(--text-muted)"},onMouseEnter:e=>{E||(e.currentTarget.style.color="var(--text)",e.currentTarget.style.background=y)},onMouseLeave:e=>{E||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"3"}),(0,n.jsx)("path",{d:"M8 9h8M8 13h5"})]}),(0,n.jsx)("span",{style:m,children:h("nav.todo")}),(0,n.jsx)("span",{style:{fontSize:10,fontWeight:700,color:"var(--text-muted)"},children:$>0?$:"✓"})]}),g&&t&&(0,n.jsx)(j,{navRef:W,navWidth:B(),stats:t,contextUsage:r,onClose:()=>f(!1),cwd:l,projectRoot:d,isWorktree:c,worktreeBranch:p}),E&&a.length>0&&(0,n.jsx)(C,{navRef:W,navWidth:B(),todos:a,onClose:()=>R(!1)}),M&&(0,n.jsx)(S,{navRef:W,navWidth:B(),prompt:i,loading:s,onClose:()=>L(!1)})]})})}),b={flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",gap:4,width:"auto",height:26,padding:"0 6px",border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s, background 0.12s"},m={fontSize:11,fontWeight:600,lineHeight:1,whiteSpace:"nowrap"},v={flexShrink:0,width:1,height:16,alignSelf:"center",background:"color-mix(in srgb, var(--border) 70%, transparent)",margin:"0 3px"},y="color-mix(in srgb, var(--glass-bg-strong) 40%, transparent)",w="color-mix(in srgb, var(--glass-bg-strong) 60%, transparent)";function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}function j({navRef:e,navWidth:t,stats:r,contextUsage:a,onClose:i,cwd:s,projectRoot:l,isWorktree:d,worktreeBranch:c}){let{t:p}=(0,u.s)(),[h,f]=(0,o.useState)(null),b=(0,o.useRef)(null);if((0,o.useEffect)(()=>{let r=()=>{let r=e.current;if(!r)return;let n=r.getBoundingClientRect(),o=r.closest("[data-session-titlebar]"),a=o?.getBoundingClientRect(),i=a?a.left:Math.min(n.right-t,Math.max(8,n.left));f({top:a?a.bottom:n.bottom,left:i})};r();let n=new ResizeObserver(r);return e.current&&n.observe(e.current),e.current?.closest("[data-session-titlebar]")&&n.observe(e.current.closest("[data-session-titlebar]")),window.addEventListener("resize",r),()=>{n.disconnect(),window.removeEventListener("resize",r)}},[e,t]),(0,o.useEffect)(()=>{let t=t=>{let r=t.target;b.current?.contains(r)||e.current?.contains(r)||i()};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[e,i]),!h)return null;let m=r.totalActiveMs??0,v=[...r.sessionName?[{label:p("session.name"),value:r.sessionName}]:[],{label:p("session.id"),value:r.sessionId},...s?[{label:p("session.projectDir"),value:d&&c?`${c} \xb7 ${s}`:l??s}]:[],...m>0?[{label:p("session.totalActive"),value:(e=>{if(e<=0)return"0s";let t=Math.floor(e/1e3),r=Math.floor(t/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h ${n}m`:n>0?`${n}m ${o}s`:`${o}s`})(m)}]:[]],y=[[p("session.user"),r.userMessages.toLocaleString()],[p("session.assistant"),r.assistantMessages.toLocaleString()],[p("session.toolCalls"),r.toolCalls.toLocaleString()],[p("session.toolResults"),r.toolResults.toLocaleString()],[p("session.total"),r.totalMessages.toLocaleString()]],w=[[p("session.input"),r.tokens.input.toLocaleString()],[p("session.output"),r.tokens.output.toLocaleString()],...r.tokens.cacheRead>0?[[p("session.cacheRead"),r.tokens.cacheRead.toLocaleString()]]:[],...r.tokens.cacheWrite>0?[[p("session.cacheWrite"),r.tokens.cacheWrite.toLocaleString()]]:[],[p("session.total"),r.tokens.total.toLocaleString()],...r.cost>0?[[p("session.cost"),`$${r.cost.toFixed(4)}`]]:[],...r.contextUsage?.contextWindow?[[p("session.context"),`${null!==r.contextUsage.percent?`${r.contextUsage.percent.toFixed(1)}%`:"?"} / ${k(r.contextUsage.contextWindow)}`]]:[]],S=(e,t,r="left",o=!1)=>(0,n.jsxs)("div",{style:{minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:e}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:o?"max-content minmax(0, 1fr)":"auto minmax(0, 1fr)",columnGap:o?14:12,rowGap:4,justifyContent:o?"start":void 0},children:t.map(([t,o])=>(0,n.jsxs)("div",{style:{display:"contents"},children:[(0,n.jsx)("div",{style:{color:"var(--text-meta)",whiteSpace:"nowrap"},children:t}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",textAlign:r,whiteSpace:"normal"},children:o})]},`${e}:${t}`))})]}),C=(0,n.jsx)("div",{ref:b,"data-session-nav-popover":!0,role:"dialog","aria-label":p("session.title"),className:"glass-panel",style:{position:"fixed",top:h.top,left:h.left,width:t,maxHeight:"min(560px, calc(100dvh - 44px))",overflowY:"auto",zIndex:1200,padding:"12px 16px",fontSize:12,lineHeight:1.5,fontFamily:"var(--font-mono)",borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)"},children:(0,n.jsxs)("div",{style:{display:"grid",gap:16,fontSize:12,lineHeight:1.5,fontFamily:"var(--font-mono)"},children:[(0,n.jsx)(g,{stats:r,contextUsage:a}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:8,alignItems:"start"},children:v.map(e=>(0,n.jsxs)("div",{style:{display:"contents"},children:[(0,n.jsx)("div",{style:{color:"var(--text-meta)",whiteSpace:"nowrap"},children:e.label}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"},children:e.value})]},e.label))}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(160px, 0.5fr) minmax(240px, 0.7fr)",gap:24},children:[S(p("session.messages"),y),S(p("session.tokens"),w,"right",!0)]})]})});return(0,x.createPortal)(C,document.body)}function S({navRef:e,navWidth:t,prompt:r,loading:a,onClose:i}){let{t:s}=(0,u.s)(),[l,d]=(0,o.useState)(null),c=(0,o.useRef)(null);if((0,o.useEffect)(()=>{let r=()=>{let r=e.current;if(!r)return;let n=r.closest("[data-session-titlebar]"),o=n?.getBoundingClientRect(),a=o?o.left:Math.min(r.getBoundingClientRect().right-t,Math.max(8,r.getBoundingClientRect().left));d({top:o?o.bottom:r.getBoundingClientRect().bottom,left:a})};r();let n=new ResizeObserver(r);return e.current&&n.observe(e.current),e.current?.closest("[data-session-titlebar]")&&n.observe(e.current.closest("[data-session-titlebar]")),window.addEventListener("resize",r),()=>{n.disconnect(),window.removeEventListener("resize",r)}},[e,t]),(0,o.useEffect)(()=>{let t=t=>{let r=t.target;c.current?.contains(r)||e.current?.contains(r)||i()};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[e,i]),!l)return null;let p=(0,n.jsx)("div",{ref:c,"data-session-nav-system":!0,role:"dialog","aria-label":s("system.prompt"),className:"glass-panel",style:{position:"fixed",top:l.top,left:l.left,width:t,maxHeight:"min(420px, 52vh)",overflowY:"auto",zIndex:1200,padding:"12px 16px",fontSize:12,lineHeight:1.6,fontFamily:"var(--font-mono)",borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",whiteSpace:"pre-wrap",color:"var(--text-muted)"},children:r?(0,n.jsx)("div",{children:r}):""===r?(0,n.jsx)("div",{style:{fontStyle:"italic"},children:s("system.empty")}):(0,n.jsx)("div",{style:{fontStyle:"italic"},children:s(a?"system.loading":"system.load")})});return(0,x.createPortal)(p,document.body)}function C({navRef:e,navWidth:t,todos:r,onClose:a}){let{t:i}=(0,u.s)(),[s,l]=(0,o.useState)(null),d=(0,o.useRef)(null);if((0,o.useEffect)(()=>{let r=()=>{let r=e.current;if(!r)return;let n=r.getBoundingClientRect(),o=r.closest("[data-session-titlebar]"),a=o?.getBoundingClientRect(),i=a?a.left:Math.min(n.right-t,Math.max(8,n.left));l({top:a?a.bottom:n.bottom,left:i})};r();let n=new ResizeObserver(r);return e.current&&n.observe(e.current),e.current?.closest("[data-session-titlebar]")&&n.observe(e.current.closest("[data-session-titlebar]")),window.addEventListener("resize",r),()=>{n.disconnect(),window.removeEventListener("resize",r)}},[e,t]),(0,o.useEffect)(()=>{let t=t=>{let r=t.target;d.current?.contains(r)||e.current?.contains(r)||a()};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[e,a]),!s)return null;let c=(0,n.jsxs)("div",{ref:d,"data-session-nav-todo":!0,role:"menu","aria-label":i("todo.title"),className:"glass-panel",style:{position:"fixed",top:s.top,left:s.left,width:t,maxHeight:"min(440px, calc(100dvh - 44px))",overflowY:"auto",zIndex:1200,fontFamily:"inherit",borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 12px",borderBottom:"1px solid color-mix(in srgb, var(--border) 70%, transparent)",fontSize:12,fontWeight:650,color:"var(--text)"},children:[i("todo.title"),(0,n.jsxs)("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-meta)",fontWeight:500},children:[r.filter(e=>"completed"===e.status).length,"/",r.length," ",i("todo.completed")]})]}),0===r.length?(0,n.jsx)("div",{style:{padding:"12px 14px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:i("todo.empty")}):(0,n.jsx)("div",{style:{maxHeight:330,overflowY:"auto"},children:r.map(e=>{let t="completed"===e.status,r="high"===e.priority?"#ef4444":"medium"===e.priority?"rgba(234,179,8,0.9)":"var(--text-meta)";return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,padding:"7px 12px",borderBottom:"1px solid color-mix(in srgb, var(--border) 45%, transparent)"},children:[(0,n.jsx)("span",{"aria-hidden":"true",style:{flexShrink:0,marginTop:2,width:13,height:13,borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:800,lineHeight:1,color:t?"#fff":"transparent",background:t?"#16a34a":"color-mix(in srgb, var(--border) 70%, transparent)",border:t?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:"✓"}),(0,n.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12,lineHeight:1.4,color:t?"var(--text-meta)":"var(--text)",textDecoration:t?"line-through":"none",wordBreak:"break-word"},children:e.content}),(0,n.jsx)("span",{"aria-hidden":"true",style:{flexShrink:0,marginTop:5,width:7,height:7,borderRadius:"50%",background:r}})]},e.id??e.content)})})]});return(0,x.createPortal)(c,document.body)}var E=r(32782),R=r(15934);let M=(0,o.memo)(function({sessionId:e,cwd:t,taskId:r,onPromote:a,onCwdChange:i}){let{t:s}=(0,u.s)(),{soundEnabled:l,onSoundToggle:d,playDoneSound:c,unlockAudio:p}=(0,E.G)(),[g,b]=(0,o.useState)(null),[m,v]=(0,o.useState)(null),[y,w]=(0,o.useState)(0),k=(0,o.useRef)(null),j=(0,o.useRef)(null),S=(0,o.useRef)(null),C=!!t,M=(0,o.useRef)(null);M.current=C&&r?{taskId:r}:null;let W=(0,o.useRef)(e),z=(0,o.useRef)(t??null);(0,o.useEffect)(()=>{t&&(z.current=t)},[t]);let T=(0,o.useRef)(C),I=(0,o.useRef)(!1),N=(0,o.useRef)(t);(0,o.useEffect)(()=>{let e=N.current;N.current=t,!e||t||T.current&&!I.current&&(T.current=!1,w(e=>e+1))},[t]);let[D,H]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=k.current?.closest("[data-board-node]"),t=e?.querySelector("[data-session-navbar-slot]")??null;H(e=>e===t?e:t)});let[$,B]=(0,o.useState)(null),[F,P]=(0,o.useState)(null),[A,O]=(0,o.useState)([]),[Y,_]=(0,o.useState)(null),[U,X]=(0,o.useState)(!1),q=(0,o.useRef)(null),K=(0,o.useRef)(0),V=(0,o.useCallback)(e=>{B(e)},[]),J=(0,o.useCallback)(()=>{S.current?.openStats()},[]),G=(0,o.useCallback)(e=>{P(e)},[]),Z=(0,o.useCallback)(e=>{O(e)},[]),Q=(0,o.useCallback)(e=>{_(e),X(!1)},[]),ee=(0,o.useCallback)(e=>{K.current+=1,q.current=e,X(!1)},[]);(0,o.useEffect)(()=>{if(C||!D||!(null===Y&&!U))return;let e=q.current;if(!e)return;let t=++K.current;X(!0),e().then(()=>{K.current===t&&X(!1)})},[D,Y,U,C]);let et=(0,o.useCallback)(e=>{e?.id&&(I.current=!0,a?.(),(0,R.PH)(e.id))},[a]),er=(0,o.useCallback)(t=>{(0,R.PK)(e,t)},[e]),en=(0,o.useCallback)(t=>{(0,R.Wd)(e,t)},[e]),eo=(0,o.useCallback)(()=>{(0,R.Ho)(e,g?.name)},[e,g?.name]),ea=(0,o.useCallback)(t=>{(0,R.sV)(e,{title:"custom"===t.method?void 0:t.title,method:t.method})},[e]);return((0,o.useEffect)(()=>{let e=k.current;if(!e)return;let t=t=>{if(t.ctrlKey||t.metaKey)return;let r=t.target;r instanceof Node&&e.contains(r)&&function(e,t){let r=e instanceof Element?e:e.parentElement;for(;r&&r instanceof HTMLElement&&r!==t;){let e=r.scrollHeight>r.clientHeight,t=r.scrollWidth>r.clientWidth;if(e||t){let n=getComputedStyle(r),o=n.overflowY,a=n.overflowX;if(e&&("auto"===o||"scroll"===o||"overlay"===o)||t&&("auto"===a||"scroll"===a||"overlay"===a))return!0}r=r.parentElement}return!1}(r,e)&&t.stopPropagation()};return e.addEventListener("wheel",t),()=>{e.removeEventListener("wheel",t)}}),(0,o.useEffect)(()=>{let e=k.current;if(!e)return;let t=e=>{let t=window.getSelection();t&&t.toString().length>0&&e.stopPropagation()};return e.addEventListener("copy",t),()=>e.removeEventListener("copy",t)}),(0,o.useEffect)(()=>{if(C)return;let t=!1,r=async()=>{let t=await fetch("/api/sessions/summary",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[e]}),cache:"no-store"});if(!t.ok)throw Error(`HTTP ${t.status}`);return(await t.json()).sessions[0]??null};return T.current?(v(null),(async()=>{try{let e=await r();if(t)return;e&&b(e)}catch(e){console.warn("new session metadata load failed:",e)}})(),()=>{t=!0}):(b(null),v(null),(async()=>{try{let e=await r();if(t)return;if(!e)return void v(s("boards.sessionMissing"));b(e),w(e=>e+1)}catch(e){t||v(e instanceof Error?e.message:String(e))}})(),()=>{t=!0})},[e,s,C]),m)?(0,n.jsx)("div",{style:L,children:(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:m})}):g||C||T.current?(0,n.jsxs)("div",{ref:k,className:"board-workbench",style:L,onPointerDown:e=>{0===e.button&&e.stopPropagation()},onPointerUp:e=>{0===e.button&&e.stopPropagation()},onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[D&&g&&(0,x.createPortal)((0,n.jsx)(f,{ref:S,sessionId:g.id,stats:$,contextUsage:F,todos:A,systemPrompt:Y,systemPromptLoading:U,cwd:g.cwd,projectRoot:g.projectRoot,isWorktree:g.isWorktree,worktreeBranch:g.worktreeBranch}),D),(0,n.jsx)(h.l,{session:C||T.current?null:g,newSessionCwd:C||T.current?z.current??null:null,newSessionDraftKey:C||T.current?W.current:null,pendingNewSessionTaskRef:C||T.current?M:void 0,chatInputRef:j,inWorkbench:!0,onSessionStatsChange:V,onContextUsageChange:G,onSessionStatsPanelOpen:J,onTodosChange:Z,onOpenFile:er,onSystemPromptChange:Q,onSystemPromptLoaderChange:ee,onSessionCreated:C?e=>et(e):void 0,onSessionForked:en,onEnvWorktreeChange:i,onAgentEnd:eo,onAttentionNeeded:ea,soundEnabled:l,onSoundToggle:d,playDoneSound:c,unlockAudio:p},y)]}):(0,n.jsx)("div",{style:L,children:(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:s("boards.loadingSession")})})}),L={display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"visible",color:"var(--text)"};var W=r(64536);function z(e,t=[]){let r=(0,a.FC)(),{flowToScreenPosition:n}=(0,a.VH)(),i=(0,a.PI)(),s=(0,o.useRef)(null),l=(0,o.useRef)(""),d=(0,o.useCallback)(()=>{let e=s.current;if(!e||!r)return;let t=i.getState(),o=t.nodeLookup.get(r);if(!o)return;let a=t.transform[2],d=n({x:o.position.x,y:o.position.y}),c=window.innerWidth/a,u=window.innerHeight/a,p=`${d.x.toFixed(1)}|${d.y.toFixed(1)}|${a.toFixed(3)}|${c}|${u}`;p!==l.current&&(l.current=p,e.style.width=`${c}px`,e.style.height=`${u}px`,e.style.transform=`translate(${-d.x/a}px, ${-d.y/a}px)`)},[r,i,n]),c=(0,o.useCallback)(t=>{if(!t)return;let r=t.querySelector("[data-glass-clip]");if(r){s.current=r.querySelector("[data-glass-layer]"),d();return}let n=document.createElement("div");n.dataset.glassClip="1",n.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;border-radius:inherit;overflow:hidden;pointer-events:none;z-index:-1;";let o=document.createElement("div");o.dataset.glassLayer="1",o.style.cssText=`position:absolute;left:0;top:0;pointer-events:none;will-change:transform;background-image:linear-gradient(${e}, ${e}), var(--glass-bg-image-card, var(--glass-bg-image, none));background-repeat:no-repeat,no-repeat;background-size:100% 100%,100% 100%;`,n.appendChild(o),t.prepend(n),s.current=o,d()},[d]);return(0,o.useEffect)(()=>{if(!r)return;let e=0,t="",n=()=>{let n=i.getState(),o=n.nodeLookup.get(r);if(!o)return;let a=n.transform[2],s=`${o.position.x.toFixed(2)}|${o.position.y.toFixed(2)}|${n.transform[0].toFixed(1)}|${n.transform[1].toFixed(1)}|${a.toFixed(4)}`;s===t||(t=s,e||(e=requestAnimationFrame(()=>{e=0,d()})))},o=i.subscribe(n);return n(),()=>{o(),e&&cancelAnimationFrame(e)}},t),{setContainer:c}}var T=r(25535);function I(e,t){return e.id===t.id&&e.type===t.type&&e.data===t.data&&e.selected===t.selected&&e.width===t.width&&e.height===t.height}function N(e){let t=(0,o.memo)(e,I);return t.displayName=`MemoBoardNode(${e.displayName??e.name??"Node"})`,t}function D(e){if(!e||e<=0)return"";let t=new Date(e),r=new Date,n=t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate(),o=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return n?o:`${t.getMonth()+1}/${t.getDate()} ${o}`}var H=r(68090),$=r(96793);let B={session:"\uD83D\uDCAC",task:"\uD83D\uDEA9",note:"\uD83D\uDCDD"},F={session:{waiting_model:"\uD83E\uDD14",running_tools:"\uD83D\uDE80",running_command:"\uD83D\uDE80",waiting_input:"⏳"},task:{running:"\uD83D\uDE80",review:"\uD83E\uDD14",waiting_reply:"⏳",failed:"\uD83D\uDE31"}},P=["\uD83D\uDE80","\uD83E\uDD14","\uD83D\uDCA1","\uD83C\uDFAF","\uD83D\uDD25","✨","\uD83C\uDF1F","\uD83C\uDF40","\uD83C\uDF08","\uD83C\uDFA8","\uD83D\uDCCC","\uD83D\uDDC2️","\uD83E\uDDE9","⚡","\uD83D\uDD27","\uD83E\uDDEA","\uD83D\uDC1B","\uD83E\uDD8B","\uD83D\uDC1D","\uD83E\uDD84","\uD83C\uDF55","☕","\uD83C\uDF7A","\uD83C\uDFAE","\uD83C\uDFB5","\uD83C\uDFAC","\uD83D\uDCDA","\uD83C\uDFD7️","\uD83C\uDF31","\uD83C\uDFD4️","⚓","\uD83E\uDDED","\uD83D\uDDFA️","\uD83E\uDD16","\uD83D\uDC7E","\uD83D\uDC8E","\uD83C\uDF81","\uD83C\uDFC6","\uD83E\uDD47","\uD83D\uDEE0️"],A={"--epr-bg-color":"var(--popover-glass)","--epr-dark-bg-color":"var(--popover-glass)","--epr-text-color":"var(--text)","--epr-dark-text-color":"var(--text)","--epr-picker-border-color":"transparent","--epr-dark-picker-border-color":"transparent","--epr-picker-border-radius":"16px","--epr-hover-bg-color":"var(--side-hover)","--epr-dark-hover-bg-color":"var(--side-hover)","--epr-dark-hover-bg-color-reduced-opacity":"var(--side-hover)","--epr-focus-bg-color":"var(--side-hover)","--epr-dark-focus-bg-color":"var(--side-hover)","--epr-search-input-bg-color":"var(--side-input)","--epr-dark-search-input-bg-color":"var(--side-input)","--epr-search-input-bg-color-active":"var(--side-input)","--epr-dark-search-input-bg-color-active":"var(--side-input)","--epr-search-border-color":"var(--border)","--epr-dark-search-border-color":"var(--border)","--epr-search-input-border-radius":"8px","--epr-search-input-text-color":"var(--text)","--epr-dark-search-input-text-color":"var(--text)","--epr-search-input-placeholder-color":"var(--text-dim)","--epr-dark-search-input-placeholder-color":"var(--text-dim)","--epr-category-label-bg-color":"var(--popover-glass)","--epr-dark-category-label-bg-color":"var(--popover-glass)","--epr-category-label-text-color":"var(--text-muted)","--epr-dark-category-label-text-color":"var(--text-muted)","--epr-category-icon-active-color":"var(--accent)","--epr-dark-category-icon-active-color":"var(--accent)","--epr-emoji-size":"18px","--epr-emoji-padding":"2px","--epr-category-navigation-button-size":"22px","--epr-search-input-height":"30px","--epr-category-label-height":"26px","--epr-header-padding":"6px 8px 0","--epr-horizontal-padding":"8px","--epr-category-padding":"6px","--epr-highlight-color":"var(--accent)","--epr-dark-highlight-color":"var(--accent)"};function O({kind:e,value:t,status:r,onChange:a}){let i,{isDark:s}=(0,$.D)(),[l,d]=(0,o.useState)(!1),[c,u]=(0,o.useState)(!1),p=(0,o.useRef)(null),h=(0,o.useRef)(null),[g,f]=(0,o.useState)(null),b=r?F[e]?.[r]??null:null,m=(i=F[e],r&&i?.[r]?i[r]:t||B[e]),v=(0,o.useCallback)(()=>{let e=p.current;if(!e)return;let t=e.getBoundingClientRect(),r=t.left;r+288>window.innerWidth-8&&(r=Math.max(8,window.innerWidth-288-8));let n=t.bottom+4;n+340>window.innerHeight-8&&(n=Math.max(8,t.top-4-340)),f({left:r,top:n}),d(!0)},[]);(0,o.useEffect)(()=>{if(!l)return;let e=e=>{h.current?.contains(e.target)||p.current?.contains(e.target)||d(!1)},t=e=>{"Escape"===e.key&&d(!1)},r=e=>{!h.current?.contains(e.target)&&e.target?.nodeType===Node.ELEMENT_NODE&&e.target.closest?.(".react-flow__pane")&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),document.addEventListener("wheel",r,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t),document.removeEventListener("wheel",r)}},[l]);let y=(0,o.useCallback)(e=>{a(e.emoji),d(!1)},[a]),w=(0,o.useCallback)(e=>{(e.stopPropagation(),l)?d(!1):v()},[l,v]),k=(0,o.useCallback)(e=>{e.stopPropagation()},[]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:p,type:"button",className:"nodrag",title:b?`状态跟随:${b}(点击设置 emoji)`:`选择 emoji(当前:${m})`,"aria-label":"选择 emoji",onClick:w,onDoubleClick:k,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:22,padding:0,border:"none",borderRadius:6,background:c?"var(--side-hover)":"transparent",fontSize:13,lineHeight:1,cursor:"pointer",transition:"background 0.12s"},children:m}),l&&g&&(0,x.createPortal)((0,n.jsx)("div",{ref:h,className:"nodrag",style:{position:"fixed",left:g.left,top:g.top,width:288,zIndex:300},children:(0,n.jsxs)("div",{style:{borderRadius:16,overflow:"hidden",border:"1px solid var(--border)",background:"var(--popover-glass)",backdropFilter:"blur(var(--glass-blur-popover)) saturate(var(--glass-saturate))",WebkitBackdropFilter:"blur(var(--glass-blur-popover)) saturate(var(--glass-saturate))",boxShadow:"0 18px 44px -14px rgba(0,0,0,0.42)"},children:[(0,n.jsx)(H.Ay,{theme:s?H.Sx.DARK:H.Sx.LIGHT,emojiStyle:H.Ai.NATIVE,lazyLoadEmojis:!0,skinTonesDisabled:!0,autoFocusSearch:!1,width:288,height:300,previewConfig:{showPreview:!1},onEmojiClick:y,style:A}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 10px 9px",borderTop:"1px solid var(--bubble-hairline)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>{let e;return a((e=P.filter(e=>e!==t))[Math.floor(Math.random()*e.length)]??"\uD83C\uDFB2")},title:"随机换一个",style:Y,children:"\uD83C\uDFB2 随机"}),(0,n.jsx)("button",{type:"button",onClick:()=>{a(""),d(!1)},title:`清除,恢复默认 ${B[e]}`,style:Y,children:"清除"}),(0,n.jsx)("div",{style:{flex:1}}),(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",whiteSpace:"nowrap"},children:["已设置:",t||B[e]]})]})]})}),document.body)]})}let Y={border:"none",background:"color-mix(in srgb, var(--border) 30%, transparent)",color:"var(--text-muted)",borderRadius:6,padding:"3px 10px",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"};var _=r(71309);let U={waiting_model:{dot:"var(--accent)",label:"thinking"},running_tools:{dot:"#f59e0b",label:"tools"},running_command:{dot:"#f59e0b",label:"command"},waiting_input:{dot:"var(--text)",label:"waiting"},idle:{dot:"var(--text-dim)",label:"idle"},"just-ended":{dot:"#10b981",label:"done"}};function X(){return(0,n.jsxs)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",gap:8,padding:"4px 8px",opacity:.55},children:[(0,n.jsx)("div",{className:"board-skeleton-line",style:{width:"38%"}}),(0,n.jsx)("div",{className:"board-skeleton-line",style:{width:"72%"}}),(0,n.jsx)("div",{className:"board-skeleton-line",style:{width:"55%"}}),(0,n.jsx)("div",{className:"board-skeleton-line",style:{width:"88%"}}),(0,n.jsx)("div",{style:{flex:1}}),(0,n.jsx)("div",{className:"board-skeleton-line",style:{width:"100%",height:28,borderRadius:8}})]})}let q=N(function({id:e,data:t,selected:r,width:i,height:s}){let{getNodes:l}=(0,a.VH)(),{updateNode:d,deleteNode:u,setSnapLines:x}=(0,T.U)(),{highlightId:h}=(0,_.kz)(),g=h===e,f=i??t.w??W.ZI,b=s??t.h??W.eo,m=!!t.expanded,v=(0,o.useRef)(t);v.current=t;let{title:y,projectName:w,messageCount:k,lastActivityAt:j,stale:S,sessionId:C,lastReply:E,cwd:L,taskId:I}=t,N=(0,W.Nz)(C??null),H=N?.phase??t.phase,$=N?.runningMs??t.runningMs,B=(0,W.Uh)(C??null),F=B?.worktreeBranch??t.worktreeBranch,P=B?.isWorktree??t.isWorktree,A=!!L,{setContainer:Y}=z("var(--board-card-glass)"),q=(0,o.useRef)(null),[K,V]=(0,o.useState)(!0),J=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=q.current;if(!e)return;let t=e.closest(".react-flow"),r=e.closest(".react-flow__node")??e,n=new IntersectionObserver(e=>{if(e[0]?.isIntersecting??!0)J.current&&(clearTimeout(J.current),J.current=null),V(!0);else if(!J.current){let e=q.current;if(e){let r=e.getBoundingClientRect(),n=t?.getBoundingClientRect();if(n&&r.right>n.left-400&&r.left<n.right+400&&r.bottom>n.top-400&&r.top<n.bottom+400)return void V(!0)}J.current=setTimeout(()=>{J.current=null,V(!1)},5e3)}},{root:t,rootMargin:"400px"});return n.observe(r),()=>{n.disconnect(),J.current&&(clearTimeout(J.current),J.current=null)}},[]),(0,o.useEffect)(()=>{if(K)return;let e=q.current?.closest(".react-flow"),t=q.current;if(!e||!t)return;let r=setInterval(()=>{let n=t.getBoundingClientRect(),o=e.getBoundingClientRect();n.right>o.left-400&&n.left<o.right+400&&n.bottom>o.top-400&&n.top<o.bottom+400&&(clearInterval(r),V(!0))},1e3);return()=>clearInterval(r)},[K]);let G=(0,o.useCallback)(e=>{q.current=e,Y(e)},[Y]),Z=(0,o.useRef)(null),[Q,ee]=(0,o.useState)(!1),[et,er]=(0,o.useState)(""),en=(0,o.useRef)(null),eo=(0,o.useRef)(!1),ea=async()=>{if(eo.current||(eo.current=!0,!C))return;let t=et.trim();if(ee(!1),t&&t!==y){d(e,{data:{title:t}});try{(await fetch(`/api/sessions/${encodeURIComponent(C)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})})).ok?(0,R.z6)(C,t):d(e,{data:{title:y}})}catch{d(e,{data:{title:y}})}}},ei=r=>{var n,o,a;if(r.stopPropagation(),A)return;let i=(n=t,o=f,a=b,n.expanded?{data:{expanded:!1,expandedW:o,expandedH:a,w:n.collapsedW||W.ZI,h:n.collapsedH||W.eo},w:n.collapsedW||W.ZI,h:n.collapsedH||W.eo}:{data:{expanded:!0,collapsedW:o,collapsedH:a,w:n.expandedW||840,h:n.expandedH||600},w:n.expandedW||840,h:n.expandedH||600}),s=i.data.expanded&&!t.expanded;if(d(e,{data:i.data}),d(e,{width:i.w,height:i.h,style:{width:i.w,height:i.h}}),s){let e=B?.cwd||B?.projectRoot||L||"";e&&(0,R.$T)(e)}},es=(0,o.useRef)(!1),el=(0,o.useCallback)(()=>{es.current=!0,x([])},[x]),ed=(0,o.useCallback)((t,r)=>{if(!es.current)return;es.current=!1,x([]),requestAnimationFrame(()=>x([]));let n=Math.round(r.width),o=Math.round(r.height);d(e,{width:n,height:o,style:{width:n,height:o},data:{w:n,h:o},...void 0!==r.x&&void 0!==r.y?{position:{x:r.x,y:r.y}}:{}})},[e,d,x]),ec=(0,o.useCallback)((t,r)=>{if(!es.current)return;let n=l(),o=n.find(t=>t.id===e);x(c(e,o?.position??{x:0,y:0},r.width,r.height,n).lines)},[e,x,l]),eu=(0,o.useCallback)(()=>{d(e,{data:{cwd:""}})},[e,d]),ep=U[H]??U.idle,ex=(0,n.jsxs)("div",{style:{flexShrink:0,display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--text-muted)",borderTop:"1px solid color-mix(in srgb, var(--border) 50%, transparent)",paddingTop:3,marginTop:2},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0},children:"\uD83D\uDD52"}),(0,n.jsx)("span",{children:D(j)}),!A&&P&&F&&(0,n.jsxs)("span",{title:`Worktree: ${F}`,style:{display:"inline-flex",alignItems:"center",gap:3,color:"var(--text-muted)",minWidth:0,flexShrink:0},children:[(0,n.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:10,maxWidth:90},children:F})]}),(0,n.jsx)("div",{style:{flex:1}}),$>0&&"idle"!==H&&(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",whiteSpace:"nowrap",flexShrink:0},children:function(e){let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60)return`${r}m${t%60}s`;let n=Math.floor(r/60);return`${n}h${r%60}m`}($)})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.PN,{isVisible:r,minWidth:m?600:W.ZI,minHeight:m?500:W.eo,onResizeStart:el,onResize:ec,onResizeEnd:ed,keepAspectRatio:!1}),(0,n.jsx)(a.h7,{type:"target",position:p.yX.Left,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsx)(a.h7,{type:"source",position:p.yX.Right,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsxs)("div",{ref:G,"data-board-node":!0,"data-testid":`session-card-${C}`,onDoubleClick:ei,style:{position:"relative",width:"100%",height:"100%",borderRadius:m?18:14,border:g?"2px solid var(--accent)":`1px solid ${S?"color-mix(in srgb, var(--border) 80%, transparent)":"color-mix(in srgb, var(--border) 60%, transparent)"}`,background:"transparent",boxShadow:r?"0 0 0 5px transparent, 0 0 16px 5px color-mix(in srgb, var(--accent) 28%, transparent), 0 2px 12px -6px rgba(0,0,0,0.18)":g?_.u:"0 2px 12px -6px rgba(0,0,0,0.18)",animation:g?"board-search-glow 1.8s ease-out forwards":void 0,opacity:S?.55:1,display:"flex",flexDirection:"column",color:"var(--text)",userSelect:"none",padding:m?8:"8px 10px 6px",cursor:"grab",overflow:m?"visible":"hidden"},children:[(0,n.jsxs)("div",{"data-session-titlebar":!0,style:{flexShrink:0,display:"flex",alignItems:"center",gap:6,padding:"0 10px",height:m?"calc(36px + env(safe-area-inset-top))":void 0,minHeight:m?void 0:20,borderBottom:m?"1px solid color-mix(in srgb, var(--border) 50%, transparent)":"none",cursor:"grab",position:"relative",...m?{}:{marginBottom:2}},children:[(0,n.jsx)(O,{kind:"session",value:t.emoji,onChange:t=>d(e,{data:{emoji:t}})}),(0,n.jsx)("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",background:ep.dot,flexShrink:0}}),Q?(0,n.jsx)("input",{ref:en,value:et,onChange:e=>er(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(eo.current=!1,ea()),"Escape"===e.key&&(eo.current=!0,ee(!1))},onBlur:()=>void ea(),className:"nodrag",style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:600,padding:"2px 6px 2px 0",border:"1px solid transparent",borderRadius:5,outline:"none",background:"transparent",color:"var(--text)",boxSizing:"border-box"}}):(0,n.jsx)("span",{onClick:A?void 0:e=>{e.stopPropagation(),er(y||""),ee(!0),eo.current=!1,requestAnimationFrame(()=>{en.current?.focus(),en.current?.select()})},className:"nodrag",style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5,fontWeight:600,color:"var(--text)",padding:"2px 6px 2px 0",border:"1px solid transparent",borderRadius:5,boxSizing:"border-box",cursor:A?"default":"text"},children:A?"New session":y||"Untitled"}),S&&(0,n.jsx)("span",{style:{flexShrink:0,fontSize:9.5,color:"var(--text-dim)",border:"1px solid color-mix(in srgb, var(--border) 70%, transparent)",borderRadius:4,padding:"0 4px"},children:"stale"}),(0,n.jsx)("div",{"data-session-navbar-slot":!0,className:"nodrag",style:{display:"flex",alignItems:"center"}}),(0,n.jsx)("button",{type:"button",onClick:A?t=>{t.stopPropagation(),A&&u(e)}:ei,className:"nodrag",title:A?"Discard":m?"Collapse":"Expand",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,border:"none",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:"pointer"},children:A?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,n.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,n.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}):m?(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M18 15l-6-6-6 6"})}):(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M6 9l6 6 6-6"})})})]}),m?(0,n.jsx)("div",{className:"nodrag",style:{flex:1,minHeight:0,padding:"0 12px 0",pointerEvents:"all",overflow:"visible",cursor:"default",userSelect:"text"},children:K||A?(0,n.jsx)(M,{sessionId:C,cwd:L,taskId:I,onPromote:eu,onCwdChange:t=>{d(e,{data:{...v.current,cwd:t}}),(0,R.$T)(t)}}):(0,n.jsx)(X,{})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{ref:Z,className:"nowheel nodrag",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",gap:2,overflowY:"auto",overflowX:"hidden",padding:"2px 12px 0",scrollbarWidth:"thin",scrollbarColor:"color-mix(in srgb, var(--border) 70%, transparent) transparent",userSelect:"text",cursor:"default"},children:E?(0,n.jsx)("div",{style:{fontSize:11.5,lineHeight:1.45,color:"var(--text-muted)",wordBreak:"break-word",overflowWrap:"anywhere",whiteSpace:"pre-wrap",maxWidth:"100%",userSelect:"text"},children:E}):(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10.5,color:"var(--text-muted)"},children:[w&&(0,n.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1},children:w}),k>0&&(0,n.jsxs)("span",{style:{flexShrink:0,whiteSpace:"nowrap"},children:[k," msgs"]})]})}),ex]})]})]})});var K=r(32316),V=r(13439),J=r(57575),G=r(17366);function Z(e){let t=new Date(e),r=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())} ${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`}r(54420);let Q={border:"none",background:"color-mix(in srgb, var(--border) 30%, transparent)",color:"var(--text-muted)",borderRadius:5,padding:"2px 10px",fontSize:11,cursor:"pointer"};function ee({initialText:e,onDraftChange:t,onExit:r,onCancel:a,onBlurExit:i,rootRef:s}){let l=(0,o.useRef)(!1),d=(0,V.hGv)({extensions:[J.A,G.oz],content:e||"",contentType:"markdown",editorProps:{attributes:{class:"markdown-body sticky-note-editor",spellcheck:"false"}},onUpdate:({editor:e})=>{l.current||t(e.getMarkdown())},onBlur:({editor:e,event:r})=>{if(l.current)return;t(e.getMarkdown());let n=r.relatedTarget,o=s.current;o&&n instanceof Node&&o.contains(n)||i()}});(0,o.useEffect)(()=>{requestAnimationFrame(()=>{window.getSelection()?.removeAllRanges(),d?.commands.focus("start")})},[d]);let c=(0,o.useCallback)(()=>{l.current=!0,requestAnimationFrame(()=>{a()})},[a]),u=(0,o.useCallback)(e=>{e.stopPropagation(),"Enter"===e.key&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),d&&t(d.getMarkdown()),r()):"Escape"===e.key&&(e.preventDefault(),c())},[d,t,r,c]);return(0,n.jsx)("div",{className:"nodrag nowheel sticky-note-edit-wrap","data-testid":"sticky-note-editor",onKeyDown:u,style:{flex:1,minHeight:0,overflowY:"auto",userSelect:"text",padding:"var(--bubble-pad-y, 8px) var(--bubble-pad-x, 12px)"},children:(0,n.jsx)(V.$Z$,{editor:d})})}let et=N(function({id:e,data:t,selected:r,width:i,height:s}){let{getNodes:l}=(0,a.VH)(),{updateNode:d,deleteNode:u,setSnapLines:x}=(0,T.U)(),{highlightId:h}=(0,_.kz)(),g=h===e,f=t.text??"",{setContainer:b}=z("var(--assistant-card-glass)"),[m,v]=(0,o.useState)(!!t.autofocus),[y,w]=(0,o.useState)(!1),[k,j]=(0,o.useState)(""),S=(0,o.useRef)(null),C=(0,o.useRef)(null),E=(0,o.useRef)(null),R=(0,o.useRef)(f),[M]=(0,o.useState)(()=>t.createdAt??Date.now()),L=t.title?.trim()||Z(M),[W,I]=(0,o.useState)(!1),N=(0,o.useRef)(null);(0,o.useEffect)(()=>{m&&(R.current=f)},[m,f]);let H=(0,o.useCallback)(e=>{R.current=e},[]),$=(0,o.useCallback)(()=>{let t=R.current;t!==f&&d(e,{data:{text:t}})},[f,d,e]),B=(0,o.useCallback)(()=>{t.autofocus&&d(e,{data:{autofocus:void 0}})},[t.autofocus,d,e]),F=(0,o.useCallback)(()=>{$(),B(),v(!1)},[$,B]),P=()=>{let r=k.trim();d(e,{data:{...t,title:r}}),w(!1)},A=(0,o.useCallback)(()=>{R.current=f,B(),v(!1)},[f,B]),Y=(0,o.useCallback)(()=>{$(),B(),v(!1)},[$,B]),U=(0,o.useCallback)(e=>{e.stopPropagation();let t=C.current?.querySelector(".markdown-body")?.innerText??f;navigator.clipboard.writeText(t).then(()=>{I(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>I(!1),1200)}).catch(()=>{})},[f]);(0,o.useEffect)(()=>()=>{N.current&&clearTimeout(N.current)},[]);let X={position:"relative",width:"100%",height:"100%",borderRadius:"var(--bubble-radius, 12px)",border:g?"2px solid var(--accent)":"1px solid var(--bubble-border)",background:"transparent",boxShadow:g?_.u:r?"0 2px 10px -6px rgba(0,0,0,0.2), 0 0 0 5px transparent, 0 0 16px 5px color-mix(in srgb, var(--accent) 28%, transparent)":"0 2px 10px -6px rgba(0,0,0,0.2)",animation:g?"board-search-glow 1.8s ease-out forwards":void 0,color:"var(--text)",display:"flex",flexDirection:"column",overflow:"hidden",fontSize:13,lineHeight:1.5,userSelect:"none",cursor:"default",padding:m?10:6},q=(0,o.useCallback)(e=>{0===e.button&&e.stopPropagation()},[]),V=(0,o.useRef)(!1),J=(0,o.useCallback)(()=>{V.current=!0,x([])},[x]),G=(0,o.useCallback)((t,r)=>{if(!V.current)return;V.current=!1,x([]),requestAnimationFrame(()=>x([]));let n=Math.round(r.width),o=Math.round(r.height);d(e,{width:n,height:o,style:{width:n,height:o},data:{w:n,h:o},...void 0!==r.x&&void 0!==r.y?{position:{x:r.x,y:r.y}}:{}})},[e,d,x]),et=(0,o.useCallback)((t,r)=>{if(!V.current)return;let n=l(),o=n.find(t=>t.id===e);x(c(e,o?.position??{x:0,y:0},r.width,r.height,n).lines)},[e,x,l]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.PN,{isVisible:r,minWidth:120,minHeight:60,onResizeStart:J,onResize:et,onResizeEnd:G,keepAspectRatio:!1}),(0,n.jsx)(a.h7,{type:"target",position:p.yX.Left,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsx)(a.h7,{type:"source",position:p.yX.Right,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsxs)("div",{ref:e=>{b(e),E.current=e},"data-board-node":!0,"data-testid":`sticky-note-${e}`,style:X,className:"nowheel",onDoubleClick:e=>{e.stopPropagation(),e.preventDefault(),window.getSelection()?.removeAllRanges(),v(!0)},children:[(0,n.jsxs)("div",{style:{flexShrink:0,height:32,display:"flex",alignItems:"center",gap:6,padding:"0 var(--bubble-pad-x, 12px)",fontSize:10,color:"var(--text-muted)",cursor:"grab",boxSizing:"border-box"},children:[(0,n.jsx)(O,{kind:"note",value:t.emoji,onChange:t=>d(e,{data:{emoji:t}})}),y?(0,n.jsx)("input",{ref:S,value:k,onChange:e=>j(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&P(),"Escape"===e.key&&(j(L),w(!1))},onBlur:P,className:"nodrag",style:{flex:1,minWidth:0,fontSize:11,fontWeight:600,padding:"1px 5px 1px 0",border:"1px solid transparent",borderRadius:5,outline:"none",background:"transparent",color:"var(--text)",boxSizing:"border-box"}}):(0,n.jsx)("span",{className:"nodrag",onClick:e=>{e.stopPropagation(),j(L),w(!0),requestAnimationFrame(()=>{S.current?.focus(),S.current?.select()})},title:"点击改名",style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,fontWeight:600,color:"var(--text)",cursor:"text",padding:"1px 5px 1px 0",boxSizing:"border-box"},children:L}),m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{flex:1}}),(0,n.jsx)("button",{type:"button",className:"nodrag",onClick:A,style:Q,title:"放弃变更 (Esc)",children:"取消"}),(0,n.jsx)("button",{type:"button",className:"nodrag",onClick:F,style:Q,title:"保存 (Ctrl+Enter)",children:"保存"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{flex:1}}),(0,n.jsx)("button",{type:"button",title:W?"已复制":"复制内容",onClick:U,className:"nodrag",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:22,height:20,padding:0,border:"none",borderRadius:5,background:"transparent",color:W?"var(--accent)":"var(--text-muted)",cursor:"pointer"},children:W?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 6L9 17l-5-5"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),m?(0,n.jsx)(ee,{initialText:f,onDraftChange:H,onExit:F,onCancel:A,onBlurExit:Y,rootRef:E},`${e}-edit`):(0,n.jsx)("div",{ref:C,className:"nowheel nodrag",style:{flex:1,minHeight:0,overflowY:"auto",padding:"4px var(--bubble-pad-x, 12px) var(--bubble-pad-y, 8px)",textAlign:"left",cursor:"text",userSelect:"text"},onPointerDown:q,onPointerUp:q,onDoubleClick:e=>{e.stopPropagation(),e.preventDefault(),window.getSelection()?.removeAllRanges(),v(!0)},children:f.trim()?(0,n.jsx)("div",{className:"markdown-body",style:{wordBreak:"break-word"},children:(0,n.jsx)(K.oz,{children:f})}):(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12,cursor:"text"},children:"双击编辑"})}),(0,n.jsxs)("div",{className:"nodrag",style:{flexShrink:0,display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--text-muted)",borderTop:"1px solid color-mix(in srgb, var(--border) 50%, transparent)",padding:"3px var(--bubble-pad-x, 12px)"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0},children:"\uD83D\uDD52"}),(0,n.jsx)("span",{children:D(M)})]})]})]})});var er=r(43561);function en(e,t){return(e??[]).filter(e=>e.kind===t).map(e=>e.targetCardId)}var eo=r(20985);function ea({value:e,options:t,onChange:r,width:a="100%"}){let[i,s]=(0,o.useState)(!1),[l,d]=(0,o.useState)(!1),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!i)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let u=t.find(t=>t.value===e);return(0,n.jsxs)("div",{ref:c,style:{position:"relative",width:a},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>s(e=>!e),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{width:"100%",height:28,boxSizing:"border-box",display:"flex",alignItems:"center",gap:6,padding:"0 8px",background:i?"var(--side-active)":l?"var(--side-hover)":"transparent",border:"1px solid var(--border)",borderRadius:5,cursor:"pointer",fontSize:11,color:"var(--text)",textAlign:"left",transition:"background 0.12s"},children:[(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u?.label??""}),(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-dim)"},children:(0,n.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),i&&(0,n.jsx)(eo.f,{open:!0,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:120,minWidth:120,maxHeight:200,overflowY:"auto",background:"var(--popover-glass)",border:"1px solid var(--border)",borderRadius:6,boxShadow:"0 6px 20px -6px rgba(0,0,0,0.35)",padding:4},children:t.map(t=>(0,n.jsx)("button",{type:"button",onClick:()=>{r(t.value),s(!1)},style:{display:"block",width:"100%",boxSizing:"border-box",padding:"5px 8px",border:"none",borderRadius:4,background:t.value===e?"var(--side-active)":"transparent",color:"var(--text)",fontSize:11,textAlign:"left",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="var(--side-hover)"},onMouseLeave:r=>{r.currentTarget.style.background=t.value===e?"var(--side-active)":"transparent"},children:t.label},t.value))})]})}function ei({candidates:e,selected:t,onChange:r,placeholder:a="选择任务卡…",excludeId:i,width:s="100%"}){let[l,d]=(0,o.useState)(!1),[c,u]=(0,o.useState)(!1),p=(0,o.useRef)(null),x=e.filter(e=>e.id!==i),h=new Set(t);(0,o.useEffect)(()=>{if(!l)return;let e=e=>{p.current&&!p.current.contains(e.target)&&d(!1)},t=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]);let g=x.filter(e=>h.has(e.id)),f=g.length>3?g.length-3:0,b=g.slice(0,3);return(0,n.jsxs)("div",{ref:p,style:{position:"relative",width:s},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{width:"100%",height:28,boxSizing:"border-box",display:"flex",alignItems:"center",gap:4,padding:"0 6px",background:l?"var(--side-active)":c?"var(--side-hover)":"transparent",border:"1px solid var(--border)",borderRadius:5,cursor:"pointer",fontSize:11,color:"var(--text)",textAlign:"left",transition:"background 0.12s"},children:[b.length>0?(0,n.jsxs)(n.Fragment,{children:[b.map(e=>(0,n.jsxs)("span",{style:{flexShrink:0,display:"inline-flex",alignItems:"center",gap:3,padding:"1px 5px",borderRadius:999,background:"var(--side-selected)",color:"var(--accent)",fontFamily:"var(--font-mono)",fontSize:10},children:["#",e.number]},e.id)),f>0&&(0,n.jsxs)("span",{style:{flexShrink:0,color:"var(--text-muted)",fontSize:10},children:["+",f]})]}):(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)"},children:a}),(0,n.jsx)("span",{style:{flex:1}}),(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-dim)"},children:(0,n.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),l&&(0,n.jsx)(eo.f,{open:!0,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:120,minWidth:160,maxHeight:180,overflowY:"auto",background:"var(--popover-glass)",border:"1px solid var(--border)",borderRadius:6,boxShadow:"0 6px 20px -6px rgba(0,0,0,0.35)",padding:4},children:0===x.length?(0,n.jsx)("div",{style:{padding:"8px",color:"var(--text-dim)",fontSize:11},children:"本看板无其他任务卡"}):x.map(e=>{let o=h.has(e.id);return(0,n.jsxs)("button",{type:"button",onClick:n=>{var o;n.stopPropagation(),o=e.id,r(h.has(o)?t.filter(e=>e!==o):[...t,o])},style:{display:"flex",alignItems:"center",gap:7,width:"100%",boxSizing:"border-box",padding:"5px 8px",border:"none",borderRadius:4,background:o?"var(--side-selected)":"transparent",color:"var(--text)",fontSize:11,textAlign:"left",cursor:"pointer"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--side-hover)")},onMouseLeave:e=>{e.currentTarget.style.background=o?"var(--side-selected)":"transparent"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0,width:12,height:12,borderRadius:3,border:"1px solid var(--border)",background:o?"var(--accent)":"transparent",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--accent-contrast, #fff)"},children:o&&(0,n.jsx)("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"1.5 5 3.5 7 8.5 2"})})}),(0,n.jsxs)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text-muted)",flexShrink:0},children:["#",e.number]}),(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id)})})]})}var es=r(29608);function el({cwd:e,value:t,onChange:r}){let[a,i]=(0,o.useState)(null),[s,l]=(0,o.useState)(!1),[d,c]=(0,o.useState)(!1),[u,p]=(0,o.useState)(""),[x,h]=(0,o.useState)(!1),[g,f]=(0,o.useState)(null),b=(0,o.useRef)(null),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!e)return void i(null);let t=!1;return(async()=>{try{let r=await fetch(`/api/worktrees?cwd=${encodeURIComponent(e)}`,{cache:"no-store"});if(!r.ok)return;let n=await r.json();if(t)return;i({forCwd:e,projectRoot:n.projectRoot??e,isGit:n.isGit??!1,currentWorktreePath:n.currentWorktreePath??null,worktrees:(n.worktrees??[]).map(e=>({path:e.path,branch:e.branch??null,isMain:!!e.isMain}))})}catch{t||i(null)}})(),()=>{t=!0}},[e]);let v=a?.worktrees.find(e=>e.path===t)??a?.worktrees.find(t=>t.path===e)??(a?.currentWorktreePath?a.worktrees.find(e=>e.path===a.currentWorktreePath):void 0)??a?.worktrees.find(e=>e.isMain)??null,y=async()=>{let e=u.trim();if(e&&!x&&a){h(!0),f(null);try{let t=await fetch("/api/worktrees",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a.projectRoot,branch:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.path){f(n.error??"创建失败"),h(!1);return}p(""),c(!1),l(!1),r(n.path)}catch(e){f(e instanceof Error?e.message:String(e))}h(!1)}};(0,o.useEffect)(()=>{if(!s)return;let e=e=>{b.current&&!b.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]);let w=v?v.isMain?`主 checkout(${v.branch??""})`:v.branch??v.path:a?.isGit?"选择工作区…":"非 git 项目";return(0,n.jsxs)("div",{ref:b,style:{position:"relative"},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>{l(e=>!e),f(null)},style:{width:"100%",height:28,boxSizing:"border-box",display:"flex",alignItems:"center",gap:6,padding:"0 8px",background:s?"var(--side-active)":"transparent",border:"1px solid var(--border)",borderRadius:5,cursor:"pointer",fontSize:11,color:"var(--text)",textAlign:"left",fontFamily:"var(--font-mono)"},title:v?.path??void 0,children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:v&&!v.isMain?"var(--accent)":"var(--text-dim)"},children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,n.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w}),(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-dim)"},children:(0,n.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),(0,n.jsxs)(eo.f,{open:s,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:120,minWidth:200,background:"var(--popover-glass)",border:"1px solid var(--border)",borderRadius:6,boxShadow:"0 6px 20px -6px rgba(0,0,0,0.35)",overflow:"hidden"},children:[(0,n.jsx)("div",{style:{maxHeight:"min(40vh, 260px)",overflowY:"auto",padding:4},children:0===(a?.worktrees??[]).length?(0,n.jsx)("div",{style:{padding:"8px 10px",fontSize:11,color:"var(--text-dim)"},children:a?.isGit===!1?"非 git 项目,无法创建工作区":"暂无工作区"}):(a?.worktrees??[]).map(e=>{let o=e.path===(v?.path??t);return(0,n.jsxs)("button",{type:"button",onClick:()=>{r(e.path),l(!1),f(null)},title:e.path,style:{display:"block",width:"100%",boxSizing:"border-box",padding:"6px 8px",border:"none",borderRadius:4,background:o?"var(--side-active)":"transparent",color:"var(--text)",fontSize:11,textAlign:"left",cursor:"pointer",fontFamily:"var(--font-mono)"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--side-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="transparent")},children:[(0,n.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.isMain?`主 checkout(${e.branch??""})`:e.branch??e.path}),(0,n.jsx)("span",{style:{display:"block",fontSize:9.5,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.path})]},e.path)})}),d?(0,n.jsxs)("div",{style:{padding:"6px 8px",borderTop:"1px solid var(--bubble-hairline)"},children:[(0,n.jsx)("input",{ref:m,value:u,onChange:e=>{p(e.target.value),f(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),y()),"Escape"===e.key&&(c(!1),p(""),f(null))},placeholder:"新分支名",style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--side-input)",color:"var(--text)",boxSizing:"border-box"}}),(0,n.jsxs)("div",{style:{display:"flex",gap:5,marginTop:5},children:[(0,n.jsx)("button",{type:"button",onClick:()=>void y(),disabled:x||!u.trim(),style:{flex:1,padding:"4px 0",background:"var(--accent)",border:"none",borderRadius:5,color:"var(--accent-contrast, #fff)",fontSize:11,fontWeight:600,cursor:x||!u.trim()?"not-allowed":"pointer",opacity:x||!u.trim()?.65:1},children:x?"创建中…":"创建"}),(0,n.jsx)("button",{type:"button",onClick:()=>{c(!1),p(""),f(null)},style:{flex:1,padding:"4px 0",background:"transparent",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:"取消"})]})]}):(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),c(!0),f(null),setTimeout(()=>m.current?.focus(),0)},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"7px 10px",background:"none",border:"none",borderTop:"1px solid var(--bubble-hairline)",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,n.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,n.jsx)("span",{children:"新建工作区"})]}),g&&(0,n.jsx)("div",{style:{padding:"5px 10px 8px",color:"#dc2626",fontSize:11,lineHeight:1.35,overflowWrap:"anywhere"},children:g})]})]})}var ed=r(13405),ec=r(56314);let eu={not_started:{color:"#9ca3af",label:"未开始"},running:{color:"#10b981",label:"进行中"},review:{color:"#f59e0b",label:"待审核"},done:{color:"#10b981",label:"完成"},failed:{color:"#ef4444",label:"失败"},abandoned:{color:"#9ca3af",label:"放弃"},waiting_reply:{color:"#3184f8",label:"等回复"}},ep={width:"100%",boxSizing:"border-box",border:"1px solid var(--border)",borderRadius:6,background:"transparent",color:"var(--text)",fontSize:12,padding:"4px 8px",outline:"none"},ex={display:"block",fontSize:10,color:"var(--text)",fontWeight:600,margin:"8px 0 3px"},eh={border:"none",background:"color-mix(in srgb, var(--border) 30%, transparent)",color:"var(--text-muted)",borderRadius:5,padding:"2px 10px",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"};function eg({title:e,open:t,onToggle:r,children:o}){return(0,n.jsxs)("div",{children:[(0,n.jsxs)("button",{type:"button",onClick:r,style:{display:"flex",alignItems:"center",gap:4,width:"100%",marginTop:10,padding:"5px 0 3px",border:"none",borderTop:"1px solid var(--bubble-hairline)",background:"transparent",color:"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",textAlign:"left"},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:t?"rotate(90deg)":"none",transition:"transform 0.12s"},children:(0,n.jsx)("polyline",{points:"3 2 6.5 5 3 8"})}),e]}),t&&(0,n.jsx)("div",{children:o})]})}function ef({due:e,onChange:t}){let r=new Date,o=e?new Date(e):r,[a,i,s]=[o.getFullYear(),o.getMonth()+1,o.getDate()],l=[];for(let e=r.getFullYear()-2;e<=r.getFullYear()+3;e++)l.push(String(e));let d=Array.from({length:12},(e,t)=>String(t+1)),c=new Date(a,i,0).getDate(),u=Array.from({length:c},(e,t)=>String(t+1)),p=(e,r,n)=>{let o=new Date(e,r-1,n,0,0,0,0).getTime();t(Number.isNaN(o)?null:o)};return(0,n.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,n.jsx)("div",{style:{flex:1.4,minWidth:0},children:(0,n.jsx)(ea,{value:String(a),options:l.map(e=>({value:e,label:e})),onChange:e=>p(Number(e),i,Math.min(s,c))})}),(0,n.jsx)("div",{style:{flex:1,minWidth:0},children:(0,n.jsx)(ea,{value:String(i),options:d.map(e=>({value:e,label:`${e}月`})),onChange:e=>p(a,Number(e),Math.min(s,new Date(a,Number(e),0).getDate()))})}),(0,n.jsx)("div",{style:{flex:1,minWidth:0},children:(0,n.jsx)(ea,{value:String(s),options:u.map(e=>({value:e,label:e})),onChange:e=>p(a,i,Number(e))})})]})}function eb({value:e,onChange:t,placeholder:r}){let a=(0,V.hGv)({extensions:[J.A,G.oz,er.O.configure({placeholder:r})],content:e||"",contentType:"markdown",editorProps:{attributes:{class:"markdown-body task-card-md-field",spellcheck:"false"}},onUpdate:({editor:e})=>{t(e.getMarkdown())}});(0,o.useEffect)(()=>{a&&a.getMarkdown()!==e&&a.commands.setContent(e||"",{contentType:"markdown"})},[a,e]);let i=(0,o.useCallback)(e=>{!a||a.view.dom.contains(e.target)||a.commands.focus("end")},[a]);return(0,n.jsx)("div",{className:"nodrag nowheel task-card-md-wrap",style:{...ep,flex:1,minHeight:70,overflowY:"auto",cursor:"text",padding:0,userSelect:"text"},onMouseDown:i,children:(0,n.jsx)(V.$Z$,{editor:a})})}let em={feat:{label:"feat",content:"## 需求\n\n\n## 背景\n\n\n## 约束\n\n\n## 验收标准\n\n"},bug:{label:"bug",content:"## 问题说明\n\n\n## 最小复现步骤\n\n\n## 是否只报告原因不执行修复\n\n"},design:{label:"design",content:"## 需求\n\n\n## 约束\n\n"}};function ev({onSelect:e}){let[t,r]=(0,o.useState)(!1),a=(0,o.useRef)(null);return(0,o.useEffect)(()=>{if(!t)return;let e=e=>{a.current&&!a.current.contains(e.target)&&r(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,n.jsxs)("div",{ref:a,style:{position:"relative"},children:[(0,n.jsxs)("span",{onClick:()=>r(e=>!e),style:{fontSize:10,color:"var(--text-muted)",cursor:"pointer",userSelect:"none",display:"inline-flex",alignItems:"center",gap:2},children:["模板",(0,n.jsx)("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),t&&(0,n.jsx)("div",{style:{position:"absolute",top:"calc(100% + 4px)",right:0,zIndex:120,minWidth:90,background:"var(--popover-glass)",border:"1px solid var(--border)",borderRadius:6,boxShadow:"0 6px 20px -6px rgba(0,0,0,0.35)",padding:4},children:Object.entries(em).map(([t,{label:o,content:a}])=>(0,n.jsx)("button",{type:"button",onClick:()=>{e(a),r(!1)},style:{display:"block",width:"100%",boxSizing:"border-box",padding:"5px 8px",border:"none",borderRadius:4,background:"transparent",color:"var(--text)",fontSize:11,textAlign:"left",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="var(--side-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:o},t))})]})}let ey=N(function({id:e,data:t,selected:r,width:i,height:s}){let{getNodes:l}=(0,a.VH)(),{updateNode:d,updateNodeDebounced:u,deleteNode:x,normalizeNodeId:h,setSnapLines:g}=(0,T.U)(),f=i??t.w??380,b=s??t.h??270,m=!!t.expanded,{cardId:v}=t,y=(0,ec.Lv)(),w=(0,ec.ZY)(),{detail:k,candidates:j,loading:S,error:C,reload:E,createCard:M,saveCard:L}=function(e,t){let[r,n]=(0,o.useState)(null),[a,i]=(0,o.useState)([]),[s,l]=(0,o.useState)(!1),[d,c]=(0,o.useState)(null);(0,o.useRef)(null).current=r;let u=(0,o.useCallback)(async(t=!1)=>{if(!e)return void n(null);t||l(!0);try{let t=await fetch(`/api/task-cards/${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok){if(404===t.status)return void n(null);throw Error(`HTTP ${t.status}`)}let r=await t.json();n(r)}catch(e){t||c(e instanceof Error?e.message:String(e))}finally{t||l(!1)}},[e]),p=(0,o.useCallback)(()=>u(!1),[u]);(0,o.useEffect)(()=>{p()},[p]),(0,o.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{try{let r=await fetch(`/api/task-cards?boardId=${encodeURIComponent(t)}`,{cache:"no-store"});if(!r.ok)return;let n=await r.json();e||i(n.cards)}catch{}})(),()=>{e=!0}},[t]);let x=(0,o.useCallback)(async e=>{try{let t=await fetch("/api/task-cards",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let r=await t.json();return(0,R.RF)(),r.card}catch(e){return c(e instanceof Error?e.message:String(e)),null}},[]),h=(0,o.useCallback)(async t=>{if(!e)return!1;try{let r=await fetch(`/api/task-cards/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}return await r.json(),(0,R.RF)(),await p(),!0}catch(e){return c(e instanceof Error?e.message:String(e)),!1}},[e,p]);return{detail:r,candidates:a,loading:s,error:d,reload:p,createCard:x,saveCard:h}}(v||null,y),{setContainer:I}=z("var(--assistant-card-glass)"),N=!v;k?.card.sessionId;let{register:H,unregister:$}=(0,W.VX)();(0,o.useEffect)(()=>{if(v)return H(v),()=>$(v)},[v,H,$]);let B=(0,W.rD)(v),F=B?.execStatus??"not_started";(0,o.useEffect)(()=>{m&&!N&&E()},[m,N,E]);let[P,A]=(0,o.useState)(()=>N?{id:"",boardId:"",projectKey:"",number:0,name:"新建任务"===t.name?"":t.name,description:t.description??"",readyStatus:"draft",execStatus:"not_started",priority:0,due:null,attachments:[],cwd:w,useWorktree:!1,maxRetries:3,retryCount:0,sessionId:null,dispatchToken:null,owner:null,heartbeat:0,created:0,updated:0}:null);(0,o.useEffect)(()=>{!N&&k?.card&&!P&&A({...k.card})},[N,k,P]);let[Y,_]=(0,o.useState)([]),[U,X]=(0,o.useState)([]),q=(0,o.useRef)(!1);(0,o.useEffect)(()=>{k&&!q.current&&(q.current=!0,_(en(k.links,"prerequisite")),X(en(k.links,"related")))},[k]);let[K,V]=(0,o.useState)(!1),J=(0,o.useRef)(!1),[G,Z]=(0,o.useState)(null),[Q,ee]=(0,o.useState)(null),[et,er]=(0,o.useState)(!1);(0,o.useEffect)(()=>{er(m)},[m]);let[eo,em]=(0,o.useState)(!1),[ey,ew]=(0,o.useState)(null),ek=(0,o.useRef)(null),ej=(t,r)=>{A(n=>{let o=n?{...n,[t]:r}:n;return o&&("name"===t||"description"===t)&&u(e,{data:{name:"name"===t?r:o.name,description:"description"===t?r:o.description??""}}),o})},eS=async()=>{if(!y)return void Z("缺少看板上下文,无法创建");if(!P?.name.trim())return void ee("请填写任务名称");if(J.current)return;V(!0),J.current=!0,Z(null);let t=await M({boardId:y,name:P.name,description:P.description,readyStatus:"todo",priority:P.priority,due:P.due??null,cwd:P.cwd??void 0,useWorktree:P.useWorktree,maxRetries:P.maxRetries,attachments:P.attachments,prerequisites:Y,related:U});if(J.current=!1,V(!1),t){let r=`task-${t.id}`;h(e,r),d(r,{data:{cardId:t.id,number:t.number,name:t.name,readyStatus:t.readyStatus,priority:t.priority,due:t.due??void 0}}),A(e=>e?{...e,...t,sessionId:t.sessionId}:e),E()}},eC=async()=>{if(!P?.name.trim())return void ee("请填写任务名称");if(J.current)return;V(!0),J.current=!0,Z(null);let t=await L({name:P.name,description:P.description,readyStatus:P.readyStatus,priority:P.priority,due:P.due??null,attachments:P.attachments,cwd:P.cwd??null,useWorktree:P.useWorktree,maxRetries:P.maxRetries,prerequisites:Y,related:U});J.current=!1,V(!1),t?d(e,{data:{name:P.name,description:P.description??"",readyStatus:P.readyStatus,priority:P.priority,due:P.due??void 0}}):Z(C??"保存失败")},eE=(0,o.useMemo)(()=>{if(N||!k?.card||!P)return!1;let e=k.card;return P.name!==e.name||P.description!==e.description||P.priority!==e.priority||P.due!==e.due||P.cwd!==e.cwd||P.useWorktree!==e.useWorktree||P.maxRetries!==e.maxRetries||JSON.stringify(P.attachments??[])!==JSON.stringify(e.attachments??[])||JSON.stringify([...Y].sort())!==JSON.stringify(en(k.links,"prerequisite").sort())||JSON.stringify([...U].sort())!==JSON.stringify(en(k.links,"related").sort())},[N,k,P,Y,U]),eR=()=>{k&&(A({...k.card}),_(en(k.links,"prerequisite")),X(en(k.links,"related")),ew(null),Z(null),ee(null))},[eM,eL]=(0,o.useState)(!1),eW=(0,o.useRef)(null),ez=()=>{(eL(!1),P?.name.trim())?eE&&eC():eR()},eT=(0,o.useRef)(r),eI=(0,o.useRef)(eE);eI.current=eE,(0,o.useEffect)(()=>{let e=eT.current;eT.current=r,e&&!r&&!N&&eI.current&&eC()},[r,N]);let eN=(0,o.useCallback)(r=>{if(r.stopPropagation(),m){let r=t.collapsedW>=380&&t.collapsedH>=240,n=r?t.collapsedW:380,o=r?t.collapsedH:270;d(e,{data:{expanded:!1,expandedW:f,expandedH:b,w:n,h:o},width:n,height:o,style:{width:n,height:o}})}else{let r=t.expandedW>=480&&t.expandedH>=400,n=r?t.expandedW:760,o=r?t.expandedH:620;d(e,{data:{expanded:!0,collapsedW:f,collapsedH:b,w:n,h:o},width:n,height:o,style:{width:n,height:o}})}},[e,t,m,f,b,d]),eD=(0,o.useRef)(!1),eH=(0,o.useCallback)(()=>{eD.current=!0,g([])},[g]),e$=(0,o.useCallback)((t,r)=>{if(!eD.current)return;eD.current=!1,g([]),requestAnimationFrame(()=>g([]));let n=Math.round(r.width),o=Math.round(r.height);d(e,{width:n,height:o,style:{width:n,height:o},data:{w:n,h:o},...void 0!==r.x&&void 0!==r.y?{position:{x:r.x,y:r.y}}:{}})},[e,d,g]),eB=(0,o.useCallback)((t,r)=>{if(!eD.current)return;let n=l(),o=n.find(t=>t.id===e);g(c(e,o?.position??{x:0,y:0},r.width,r.height,n).lines)},[e,g,l]),eF=P?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",margin:"8px 0 3px"},children:[(0,n.jsx)("label",{style:{...ex,margin:0},children:"任务名称 *"}),P.cwd&&(0,n.jsx)(ed.J,{cwd:P.cwd,onSelect:e=>{ej("cwd",e),ew(e),(0,R.$T)(e)},showMainLabel:!1,compact:!0,style:{height:"auto",background:"transparent",flexShrink:0,borderRadius:0}})]}),(0,n.jsx)("input",{style:{...ep,...Q?{borderColor:"#f87171",boxShadow:"0 0 0 1px #f87171"}:{}},value:P.name,onChange:e=>{ej("name",e.target.value),Q&&ee(null)},placeholder:"任务名称"}),Q&&(0,n.jsx)("div",{style:{color:"#f87171",fontSize:11,marginTop:3},children:Q}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",margin:"8px 0 3px"},children:[(0,n.jsx)("label",{style:{...ex,margin:0},children:"需求说明"}),(0,n.jsx)(ev,{onSelect:e=>ej("description",(P?.description??"")+(P?.description?"\n\n":"")+e)})]}),(0,n.jsx)(eb,{value:P.description,onChange:e=>ej("description",e),placeholder:"任务描述"}),(0,n.jsxs)(eg,{title:"高级",open:et,onToggle:()=>er(e=>!e),children:[(0,n.jsx)("label",{style:ex,children:"工作目录"}),(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)("input",{style:{...ep,flex:1},value:P.cwd??"",onChange:e=>ej("cwd",e.target.value||null),placeholder:"默认项目根目录",readOnly:!0}),(0,n.jsx)("button",{type:"button",style:eh,onClick:()=>em(!0),children:"选择目录"})]}),eo&&P&&(0,n.jsx)(es.K,{onCancel:()=>em(!1),onSelect:e=>{ej("cwd",e),em(!1)}}),(0,n.jsx)("label",{style:ex,children:"工作区"}),(0,n.jsx)(el,{cwd:P.cwd,value:ey,onChange:e=>{ew(e),ej("cwd",e)}}),(0,n.jsx)("label",{style:ex,children:"预计截止"}),(0,n.jsx)(ef,{due:P.due??null,onChange:e=>ej("due",e)}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsxs)("div",{style:{flex:1},children:[(0,n.jsx)("label",{style:ex,children:"优先级"}),(0,n.jsx)(ea,{value:String(P.priority),onChange:e=>ej("priority",Number(e)),options:[{value:"1",label:"高"},{value:"0",label:"中"},{value:"-1",label:"低"}]})]}),(0,n.jsxs)("div",{style:{flex:1},children:[(0,n.jsx)("label",{style:ex,children:"最大重试次数"}),(0,n.jsx)("input",{style:ep,type:"number",min:0,value:P.maxRetries,onChange:e=>ej("maxRetries",Math.max(0,Number(e.target.value)||0))})]})]}),(0,n.jsx)("label",{style:ex,children:"前置任务(可多选)"}),(0,n.jsx)(ei,{candidates:j,selected:Y,onChange:_,excludeId:v,placeholder:"本看板内选择前置任务…"}),(0,n.jsx)("label",{style:ex,children:"关联任务(可多选)"}),(0,n.jsx)(ei,{candidates:j,selected:U,onChange:X,excludeId:v,placeholder:"本看板内选择关联任务…"}),(0,n.jsx)("label",{style:ex,children:"附件(引用文件路径,每行一个)"}),(0,n.jsx)("textarea",{style:{...ep,minHeight:46,resize:"vertical",fontFamily:"var(--font-mono)",fontSize:11},value:(P.attachments??[]).join("\n"),onChange:e=>ej("attachments",e.target.value.split("\n").map(e=>e.trim()).filter(Boolean)),placeholder:"/path/to/file",spellCheck:!1})]}),(G||C)&&(0,n.jsx)("div",{style:{color:"#f87171",fontSize:11,marginTop:6},children:G??C})]}):S?(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12,padding:20,textAlign:"center"},children:"加载中…"}):(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12,padding:20,textAlign:"center"},children:"未找到任务卡"});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.PN,{isVisible:r,minWidth:m?480:380,minHeight:m?400:240,onResizeStart:eH,onResize:eB,onResizeEnd:e$,keepAspectRatio:!1}),(0,n.jsx)(a.h7,{type:"target",position:p.yX.Left,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsx)(a.h7,{type:"source",position:p.yX.Right,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsxs)("div",{ref:e=>{ek.current=e,I(e)},"data-board-node":!0,"data-testid":`task-card-${e}`,onDoubleClick:eN,style:{position:"relative",width:"100%",height:"100%",borderRadius:"var(--bubble-radius, 12px)",border:"1px solid var(--bubble-border)",background:"transparent",boxShadow:r?"0 2px 10px -6px rgba(0,0,0,0.2), 0 0 0 5px transparent, 0 0 16px 5px color-mix(in srgb, var(--accent) 28%, transparent)":"0 2px 10px -6px rgba(0,0,0,0.2)",color:"var(--text)",display:"flex",flexDirection:"column",overflow:"hidden",userSelect:"none",cursor:"grab",padding:6},children:[(0,n.jsxs)("div",{style:{flexShrink:0,height:36,display:"flex",alignItems:"center",gap:6,padding:"0 10px",borderBottom:"1px solid var(--bubble-hairline)",cursor:"grab",fontSize:11,color:"var(--text-muted)"},children:[(0,n.jsx)(O,{kind:"task",value:t.emoji,status:F,onChange:t=>d(e,{data:{emoji:t}})}),eM?(0,n.jsx)("input",{ref:eW,value:P?.name??"",onChange:e=>ej("name",e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&ez(),"Escape"===e.key&&(eL(!1),eR())},onBlur:ez,className:"nodrag",style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:600,padding:"2px 6px 2px 0",border:"1px solid transparent",borderRadius:5,outline:"none",background:"transparent",color:"var(--text)",boxSizing:"border-box"}}):(0,n.jsx)("span",{onClick:N?void 0:e=>{e.stopPropagation(),eL(!0),requestAnimationFrame(()=>{eW.current?.focus(),eW.current?.select()})},title:N?void 0:"点击改名",className:"nodrag",style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5,fontWeight:600,color:"var(--text)",cursor:N?"default":"text",padding:"2px 6px 2px 0",boxSizing:"border-box"},children:P?.name||(N?"新建任务卡":"任务卡")}),P?.number?(0,n.jsxs)("span",{style:{flexShrink:0,fontSize:12.5,fontWeight:600,color:"var(--text)",marginLeft:4},children:["#",P.number]}):null,(0,n.jsxs)("div",{className:"nodrag",style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},onPointerDown:e=>e.stopPropagation(),children:[N?(0,n.jsx)("button",{type:"button",style:eh,disabled:K||!y,onClick:()=>void eS(),title:"创建任务并派发(转待办,调度器可执行)",children:K?"创建中…":"派发"}):P?.readyStatus==="draft"?(0,n.jsx)("button",{type:"button",style:eh,disabled:K,onClick:()=>{ej("readyStatus","todo"),!N&&v&&L({readyStatus:"todo"})},title:"派发(转待办,调度器可执行)",children:K?"派发中…":"派发"}):P?.readyStatus==="todo"?(0,n.jsxs)("span",{title:`执行状态:${(eu[F]??eu.not_started).label}`,style:{display:"flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:(eu[F]??eu.not_started).color,whiteSpace:"nowrap"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",background:(eu[F]??eu.not_started).color,..."running"===F?{animation:"pulse-dot 1.6s ease-in-out infinite"}:{}}}),(eu[F]??eu.not_started).label]}):null,N?null:eE?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",style:eh,onClick:eR,title:"撤销本次编辑",children:"取消"}),(0,n.jsx)("button",{type:"button",style:eh,disabled:K,onClick:()=>void eC(),title:"完成(保存)",children:K?"保存中…":"完成"})]}):null]})]}),(0,n.jsx)("div",{onDoubleClick:e=>e.stopPropagation(),style:{flex:1,minHeight:0,display:"flex"},children:(0,n.jsx)("div",{className:"[scrollbar-width:none] nodrag nowheel",style:{flex:"1 1 auto",minWidth:0,overflowY:"auto",padding:"10px 12px",display:"flex",flexDirection:"column",cursor:"default",userSelect:"text"},children:eF})}),!m&&(0,n.jsxs)("div",{style:{flexShrink:0,display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--text-muted)",borderTop:"1px solid color-mix(in srgb, var(--border) 50%, transparent)",padding:"3px 12px"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0},children:"\uD83D\uDD52"}),(0,n.jsx)("span",{children:D(P?.updated??P?.created??0)})]})]})]})}),ew=N(function({id:e,data:t,selected:r}){let{updateNode:i}=(0,T.U)(),{setContainer:s}=z("var(--board-card-glass)"),l=(0,o.useCallback)(e=>s(e),[s]),d=t.src??"",[c,u]=(0,o.useState)(!1),[x,h]=(0,o.useState)(!1),g=(0,o.useCallback)(r=>{let n=r.currentTarget;u(!0),h(!1);let o=n.naturalWidth,a=n.naturalHeight;o&&a&&(t.naturalW!==o||t.naturalH!==a)&&i(e,{data:{...t,naturalW:o,naturalH:a}})},[e,t,i]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.PN,{isVisible:r,minWidth:48,minHeight:48,keepAspectRatio:!1,color:"var(--accent)",lineStyle:{borderColor:"color-mix(in srgb, var(--accent) 60%, transparent)"},handleStyle:{width:8,height:8,borderRadius:2,border:"1px solid var(--bg-panel)",background:"var(--accent)"}}),(0,n.jsx)(a.h7,{type:"target",position:p.yX.Left,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsx)(a.h7,{type:"source",position:p.yX.Right,className:"board-handle",style:{background:"var(--text-dim)",width:8,height:8,border:"1px solid var(--bg-panel)",opacity:.85}}),(0,n.jsxs)("div",{ref:l,"data-board-node":!0,"data-testid":`image-node-${e}`,className:"nowheel",style:{position:"relative",width:"100%",height:"100%",borderRadius:10,overflow:"hidden",backgroundColor:"var(--board-card-glass)",border:r?"1px solid color-mix(in srgb, var(--accent) 70%, transparent)":"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:r?"0 2px 12px -6px rgba(0,0,0,0.25), 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)":"0 2px 10px -6px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},children:[d&&!x?(0,n.jsx)("img",{src:d,alt:t.name??"board image",draggable:!1,className:"nodrag",onLoad:g,onError:()=>h(!0),style:{width:"100%",height:"100%",objectFit:"contain",opacity:c?1:.1,transition:"opacity 0.15s",userSelect:"none",pointerEvents:"none"}}):(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,color:"var(--text-dim)",fontSize:11},children:x?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("path",{d:"m21 15-5-5L5 21"})]}),(0,n.jsx)("span",{children:"图片加载失败"})]}):(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("path",{d:"m21 15-5-5L5 21"})]})}),t.name&&(0,n.jsx)("div",{className:"nodrag",style:{position:"absolute",left:6,bottom:6,maxWidth:"calc(100% - 12px)",padding:"1px 6px",borderRadius:4,background:"color-mix(in srgb, var(--bg-panel) 82%, transparent)",fontSize:10,color:"var(--text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",pointerEvents:"none"},children:t.name})]})]})});var ek=r(94315);function ej({menu:e,onClose:t}){let r=(0,T.U)(),{node:a,edgeId:i,x:s,y:l,flowX:d,flowY:c,edgeDerived:u}=e,p=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=e=>{if(0!==e.button)return;let r=p.current;r&&e.target instanceof Element&&r.contains(e.target)||t()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[t]);let x=!!(i&&u),h=(0,o.useCallback)(()=>{a&&r.deleteNode(a.id),t()},[a,r,t]),g=(0,o.useCallback)(()=>{i&&!x&&r.deleteEdge(i),t()},[i,x,r,t]),f=(0,o.useCallback)(()=>{r.addNode({id:crypto.randomUUID(),type:"sticky-note",position:{x:d??0,y:c??0},style:{width:380,height:280},data:{text:"",badge:"blue",emoji:"\uD83D\uDCDD",autofocus:!0}}),t()},[r,d,c,t]),b=(0,o.useCallback)(()=>{t(),window.dispatchEvent(new CustomEvent("pi:board-pick-image"))},[t]),m=(0,o.useCallback)(()=>{r.addNode({id:crypto.randomUUID(),type:"task-card",position:{x:d??0,y:c??0},style:{width:380,height:270},data:{cardId:"",number:0,name:"新建任务",description:"",readyStatus:"draft",priority:0,expanded:!1,w:380,h:270,expandedW:0,expandedH:0,collapsedW:0,collapsedH:0,emoji:"✅"}}),t()},[r,d,c,t]),v=a?.type??null,y="session-card"===v?r.isTaskBoard?"删除会话":"移除会话卡片":"task-card"===v?"删除任务卡":("sticky-note"===v||"text"===v,"删除");return(0,n.jsxs)("div",{ref:p,className:"glass-popover",onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),style:{position:"fixed",left:s,top:l,zIndex:1200,minWidth:168,padding:4,borderRadius:10,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 8px 30px -8px rgba(0,0,0,0.4)",color:"var(--text)",fontSize:12.5,userSelect:"none"},children:[i&&(x?(0,n.jsx)(eS,{disabled:!0,label:"派生连线(自动生成,不可删除)"}):(0,n.jsx)(eS,{danger:!0,label:"删除连线",onClick:g})),a&&(0,n.jsx)(eS,{label:y,danger:!0,onClick:h}),!a&&!i&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eS,{label:"新建便笺",onClick:f}),(0,n.jsx)(eS,{label:"新建图片",onClick:b}),(0,n.jsx)(eS,{label:"新建任务卡",onClick:m})]})]})}function eS({label:e,onClick:t,danger:r,disabled:o}){return(0,n.jsx)("button",{type:"button",disabled:o,onClick:t,style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 10px",border:"none",borderRadius:7,background:"transparent",color:r?"#ef4444":o?"var(--text-dim)":"var(--text)",fontSize:12.5,textAlign:"left",cursor:o?"default":"pointer"},onMouseEnter:e=>{o||(e.currentTarget.style.background="color-mix(in srgb, var(--accent) 14%, transparent)")},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:e})}var eC=r(84876),eE=r(71459);let eR=new Set(["waiting_model","running_tools","running_command"]);function eM({nodes:e,sessionRunning:t}){let{zoomIn:r,zoomOut:i,fitView:s,setViewport:l,getNodes:d,getViewport:c}=(0,a.VH)(),{setHighlight:u}=(0,_.kz)(),[p,x]=(0,o.useState)(!1),h=(0,o.useMemo)(()=>{let r=[];for(let n of e){if("session-card"!==n.type)continue;let e=n.data;if(!e.sessionId)continue;let o=t[e.sessionId],a=o?o.phase:e.phase;if(!(void 0!==a&&eR.has(a)))continue;let i=(e.title??"").trim();i&&r.push({nodeId:n.id,label:i})}return r},[e,t]),g=(0,o.useMemo)(()=>{let r=[];for(let n of e){if("session-card"!==n.type)continue;let e=n.data;if(!e.expanded||!e.sessionId)continue;let o=t[e.sessionId],a=o?o.phase:e.phase;if(void 0!==a&&eR.has(a))continue;let i=(e.title??"").trim();i&&r.push({nodeId:n.id,label:i})}return r},[e,t]),f=h.length+g.length,b=e=>{let t=d().find(t=>t.id===e);if(!t)return;let r=t.measured?.width??t.style?.width??340,n=t.measured?.height??t.style?.height??160,o=t.position.x+r/2,a=t.position.y+n/2,i=c();l({x:-o*i.zoom+window.innerWidth/2,y:-a*i.zoom+window.innerHeight/2,zoom:i.zoom},{duration:300}),u(e)};return(0,n.jsxs)("div",{style:{position:"absolute",left:12,bottom:12,zIndex:30,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:6},children:[p&&(0,n.jsx)("div",{style:{...eE.r,display:"flex",flexDirection:"column",gap:4,maxHeight:300,overflowY:"auto",padding:6,borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 -2px 12px -6px rgba(0,0,0,0.18), 0 8px 30px -8px rgba(0,0,0,0.3)",color:"var(--text)",width:240,whiteSpace:"nowrap"},children:0===f?(0,n.jsx)("div",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-muted)"},children:"画面中没有运行中或展开的会话"}):(0,n.jsxs)(n.Fragment,{children:[h.length>0&&(0,n.jsxs)("div",{style:{padding:"4px 10px 2px",fontSize:10.5,fontWeight:600,color:"var(--text-muted)",letterSpacing:.2},children:["运行中 \xb7 ",h.length]}),h.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>b(e.nodeId),title:"点击定位到卡片",style:eT,onMouseEnter:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0,width:6,height:6,borderRadius:"50%",background:"#10b981",boxShadow:"0 0 6px 1px rgba(16,185,129,0.6)",animation:"pulse 1.6s ease-in-out infinite"}}),(0,n.jsx)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label})]},e.nodeId)),g.length>0&&(0,n.jsxs)("div",{style:{padding:"4px 10px 2px",fontSize:10.5,fontWeight:600,color:"var(--text-muted)",letterSpacing:.2},children:["工作中 \xb7 ",g.length]}),g.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>b(e.nodeId),title:"点击定位到卡片",style:eT,onMouseEnter:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,n.jsx)("span",{"aria-hidden":!0,style:{flexShrink:0,width:6,height:6,borderRadius:"50%",background:"var(--accent)",boxShadow:"0 0 6px 1px color-mix(in srgb, var(--accent) 45%, transparent)"}}),(0,n.jsx)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label})]},e.nodeId))]})}),(0,n.jsxs)("div",{style:{...eE.r,display:"flex",flexDirection:"row",gap:2,padding:4,borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)",color:"var(--text)",width:"fit-content"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>r({duration:150}),title:"放大","aria-label":"放大",style:eL,onMouseEnter:eW,onMouseLeave:ez,children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.35-4.35"}),(0,n.jsx)("path",{d:"M8 11h6"}),(0,n.jsx)("path",{d:"M11 8v6"})]})}),(0,n.jsx)("button",{type:"button",onClick:()=>i({duration:150}),title:"缩小","aria-label":"缩小",style:eL,onMouseEnter:eW,onMouseLeave:ez,children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.35-4.35"}),(0,n.jsx)("path",{d:"M8 11h6"})]})}),(0,n.jsx)("button",{type:"button",onClick:()=>s({padding:.2,duration:300}),title:"适配视口","aria-label":"适配视口",style:eL,onMouseEnter:eW,onMouseLeave:ez,children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),(0,n.jsx)("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),(0,n.jsx)("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),(0,n.jsx)("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]})}),(0,n.jsx)("div",{style:{width:1,alignSelf:"stretch",background:"color-mix(in srgb, var(--border) 70%, transparent)",margin:"2px 1px"}}),(0,n.jsxs)("button",{type:"button",onClick:()=>x(e=>!e),title:p?"收起进行中":"展开进行中","aria-label":p?"收起进行中":"展开进行中","aria-expanded":p,style:{...eL,color:p?"var(--accent)":"var(--text-muted)",background:p?"color-mix(in srgb, var(--accent) 12%, transparent)":void 0},onMouseEnter:eW,onMouseLeave:ez,children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{transform:p?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})}),f>0&&(0,n.jsx)("span",{style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:999,fontSize:9,fontWeight:700,lineHeight:1,background:"color-mix(in srgb, var(--accent) 18%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in srgb, var(--border) 40%, transparent)"},children:f})]})]})]})}let eL={display:"flex",alignItems:"center",justifyContent:"center",position:"relative",width:34,height:30,padding:0,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",borderRadius:8,transition:"background 0.12s, color 0.12s"};function eW(e){e.currentTarget.style.background="color-mix(in srgb, var(--text) 8%, transparent)",e.currentTarget.style.color="var(--text)"}function ez(e){e.currentTarget.style.background="transparent",e.currentTarget.style.color="var(--text-muted)"}let eT={display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",border:"none",borderRadius:8,background:"transparent",color:"var(--text)",fontSize:12.5,textAlign:"left",cursor:"pointer"};async function eI(e){let t=new FormData;t.append("file",e);try{let e=await fetch("/api/board-assets",{method:"POST",body:t});if(!e.ok)return null;return(await e.json()).url??null}catch{return null}}let eN={"session-card":q,"task-card":ey,"sticky-note":et,text:et,"text-node":et,"image-node":ew},eD={"send-note":ek.OX},eH="application/x-pi-board-nodes";function e$({board:e,isDark:t}){let r,{t:i}=(0,u.s)(),{screenToFlowPosition:s,setViewport:l,getNodes:c,getViewport:p,fitView:x}=(0,a.VH)(),[h,g]=(0,o.useState)(!1),[f,b]=(0,o.useState)(null),[m,v]=(0,o.useState)(!1),[y,w]=(0,o.useState)([]),k=(0,o.useRef)(null);(0,o.useEffect)(()=>{e.ready&&l(e.viewport)},[e.ready]);let j=(0,o.useMemo)(()=>({boardId:e.board?.id??null,isTaskBoard:!!e.board?.taskId,updateNode:(t,r)=>{e.updateNode?.(t,r)},updateNodeDebounced:(t,r,n)=>{e.updateNodeDebounced?.(t,r,n)},deleteNode:t=>{let r=e.nodes.find(e=>e.id===t);r&&e.deleteNodeWithConfirm?.(r)},normalizeNodeId:(t,r)=>{e.normalizeNodeId?.(t,r)},deleteEdge:t=>{e.onEdgesChange?.([{type:"remove",id:t}])},addEdge:t=>e.addEdge?.(t),updateEdge:(t,r)=>e.updateEdge?.(t,r),addNode:t=>e.addNode?.(t),setSnapLines:e=>w(e)}),[e]),S=(0,o.useCallback)((e,t,r)=>{let n=crypto.randomUUID();if("sticky-note"===e){let r=Date.now();j.addNode({id:n,type:e,position:{x:t.x,y:t.y},style:{width:380,height:280},data:{text:"",badge:"blue",emoji:"\uD83D\uDCDD",autofocus:!0,createdAt:r,title:Z(r)}})}else if("task-card"===e)j.addNode({id:n,type:e,position:{x:t.x,y:t.y},style:{width:380,height:270},data:{cardId:"",number:0,name:"新建任务",description:"",readyStatus:"draft",priority:0,expanded:!1,w:380,h:270,expandedW:0,expandedH:0,collapsedW:0,collapsedH:0,emoji:"✅"}});else if("image-node"===e&&r?.src){let o=240,a=180;if(r.naturalW&&r.naturalH){let e=Math.min(1,400/Math.max(r.naturalW,r.naturalH));o=Math.max(80,Math.round(r.naturalW*e)),a=Math.max(80,Math.round(r.naturalH*e))}j.addNode({id:n,type:e,position:{x:t.x,y:t.y},style:{width:o,height:a},data:{src:r.src,naturalW:r.naturalW,naturalH:r.naturalH,name:r.name}})}},[j]),C=(0,o.useCallback)(async(e,t)=>{let r=await eI(e);if(!r)return;let n=await new Promise(e=>{let t=new Image;t.onload=()=>e({naturalW:t.naturalWidth,naturalH:t.naturalHeight}),t.onerror=()=>e({}),t.src=r});S("image-node",t,{src:r,name:e.name,...n})},[S]),E=(0,o.useCallback)(e=>{let t=document.querySelector(".react-flow__pane"),r=t?.getBoundingClientRect();S(e,s({x:r?r.left+r.width/2:window.innerWidth/2,y:r?r.top+r.height/2:window.innerHeight/2}))},[S,s]),M=(0,o.useCallback)((e,t)=>{e.dataTransfer.setData("text/board-tool",t),e.dataTransfer.effectAllowed="copy"},[]),L=(0,o.useRef)(null);(0,o.useEffect)(()=>{let t=L.current;if(!t)return;let r=e=>{let t=e.dataTransfer?.types??[],r=Array.from(e.dataTransfer?.files??[]).some(e=>e.type.startsWith("image/"));(t.includes("text/session-id")||t.includes("text/board-tool")||r)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=r||t.includes("text/board-tool")?"copy":"move"),g(!0))},n=e=>{let r=e.relatedTarget;r&&t.contains(r)||g(!1)},o=()=>g(!1),a=t=>{let r=t.dataTransfer?.types??[],n=t.dataTransfer,o=Array.from(n?.files??[]).some(e=>e.type.startsWith("image/"));if(!r.includes("text/session-id")&&!r.includes("text/board-tool")&&!o||(t.preventDefault(),t.stopPropagation(),g(!1),!n))return;let a=s({x:t.clientX,y:t.clientY}),i=Array.from(n.files??[]).filter(e=>e.type.startsWith("image/"));if(i.length>0)return void i.forEach((e,t)=>{C(e,{x:a.x+20*t,y:a.y+20*t})});let l=n.getData("text/session-id");if(l){let t=n.getData("text/session-title")||void 0;e.addSessionNode(l,a.x,a.y,t);return}let d=n.getData("text/board-tool");"sticky-note"===d?S("sticky-note",a):"task-card"===d?S("task-card",a):"image-node"===d?k.current?.click():"session-card"===d&&e.addNewSessionCard(a)};return t.addEventListener("dragover",r,!0),t.addEventListener("dragleave",n,!0),t.addEventListener("dragend",o,!0),t.addEventListener("drop",a,!0),()=>{t.removeEventListener("dragover",r,!0),t.removeEventListener("dragleave",n,!0),t.removeEventListener("dragend",o,!0),t.removeEventListener("drop",a,!0)}},[e,s,S,C]);let W=(0,o.useCallback)(async({nodes:t})=>{if(!t||0===t.length)return!0;for(let r of t){let t=e.nodes.find(e=>e.id===r.id);t&&e.deleteNodeWithConfirm?.(t)}return!1},[e]),z=(0,o.useRef)(null),I=(0,o.useCallback)(e=>{b(null);let t=Date.now(),r=z.current;if(r&&t-r.t<320){z.current=null,S("sticky-note",s({x:e.clientX,y:e.clientY}));return}z.current={t:t}},[s,S]),N=(0,o.useCallback)((t,r)=>{e.saveViewport?.(r)},[e]),D=(0,o.useCallback)((e,t)=>{e.preventDefault();let r=s({x:e.clientX,y:e.clientY});b({x:e.clientX,y:e.clientY,flowX:r.x,flowY:r.y,node:t,edgeId:null})},[s]),H=(0,o.useCallback)(e=>{e.preventDefault();let t=s({x:e.clientX,y:e.clientY});b({x:e.clientX,y:e.clientY,flowX:t.x,flowY:t.y,node:null,edgeId:null})},[s]),$=(0,o.useRef)(!1),B=(0,o.useCallback)(()=>{$.current=!0,w([])},[]),F=(0,o.useCallback)((e,t)=>{$.current&&w(d(t.id,t.position,c()).lines)},[c]),P=(0,o.useCallback)((t,r)=>{$.current=!1;let n=d(r.id,r.position,c());e.updateNode?.(r.id,{position:{x:n.snapX??r.position.x,y:n.snapY??r.position.y}}),w([]),requestAnimationFrame(()=>w([]))},[e,c]),A=(0,o.useCallback)((t,r)=>{if("session-card"!==r.type)return;let n=r.data;if(!n||!n.sessionId)return;let o=String(n.sessionId);if(!n.expanded||n.cwd)return;let a=e.sessionTitles?.[o],i=a?.cwd||a?.projectRoot||"";i&&(0,R.$T)(i)},[e.sessionTitles]),O=(0,o.useCallback)((t,r)=>{t.preventDefault();let n=e.edges.find(e=>e.id===r.id),o=n?.data,a=s({x:t.clientX,y:t.clientY});b({x:t.clientX,y:t.clientY,flowX:a.x,flowY:a.y,node:null,edgeId:n?.id??null,edgeDerived:!!(o?.execLink||o?.taskLink)})},[e.edges,s]),Y=(0,o.useCallback)(e=>{E(e)},[E]),_=(0,o.useCallback)(()=>{let t=document.querySelector(".react-flow__pane"),r=t?.getBoundingClientRect();if(!r)return;let n=s({x:r.left+r.width/2,y:r.top+r.height/2});e.addNewSessionCard(n)},[e,s]),U=(0,o.useCallback)(async()=>{let t=e.nodes.filter(e=>e.selected&&"session-card"!==e.type);if(0===t.length)return!1;let r=t.map(e=>({type:e.type,data:e.data,style:e.style,width:e.measured?.width??e.style?.width,height:e.measured?.height??e.style?.height}));try{return await navigator.clipboard.writeText(JSON.stringify({app:eH,nodes:r})),!0}catch{return!1}},[e.nodes]),X=(0,o.useCallback)(async t=>{let r,n="";try{n=await navigator.clipboard.readText()}catch{return!1}try{r=JSON.parse(n)}catch{return!1}if(r?.app!==eH||!Array.isArray(r.nodes)||0===r.nodes.length)return!1;let o=t;if(!o){let e=document.querySelector(".react-flow__pane"),t=e?.getBoundingClientRect();o=s({x:t?t.left+t.width/2:window.innerWidth/2,y:t?t.top+t.height/2:window.innerHeight/2})}let a=r.nodes.map(e=>e.width??0),i=r.nodes.map(e=>e.height??0),l=Math.max(0,...a),d=Math.max(0,...i),c=o.x-l/2,u=o.y-d/2;for(let t of r.nodes){if(!t.type)continue;let r={...t.data??{}};delete r.selected,delete r.dragging,delete r.autofocus,"task-card"===t.type&&(delete r.cardId,r.number=0,r.name=r.name??"新建任务",r.description=r.description??"",r.readyStatus="draft",r.priority=r.priority??0,r.expanded=!1,r.w=r.w??380,r.h=r.h??270,r.expandedW=0,r.expandedH=0,r.collapsedW=0,r.collapsedH=0),e.addNode?.({id:crypto.randomUUID(),type:t.type,position:{x:c,y:u},style:t.style??{},data:r}),c+=24,u+=24}return!0},[e,s]);(0,o.useEffect)(()=>{let t=t=>{if(!(t.ctrlKey||t.metaKey))return;let r=t.key.toLowerCase(),n=document.activeElement;if(!n||"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName&&!n.isContentEditable)if("c"===r){let e=window.getSelection();if(e&&e.toString().length>0)return;U()}else"v"===r?X():"z"!==r||t.shiftKey?("z"===r&&t.shiftKey||"y"===r)&&(t.preventDefault(),e.redo?.()):(t.preventDefault(),e.undo?.())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e,U,X]),(0,o.useEffect)(()=>{let t=t=>{if((()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||e.isContentEditable})()||!(t.ctrlKey||t.metaKey)||t.altKey)return;if(" "===t.key||"Space"===t.code){t.preventDefault();let r=e.nodes.filter(e=>e.selected);r.length>0?x({nodes:r,padding:.3,duration:400}):x({padding:.2,duration:400});return}let r={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"}[t.key];if(!r)return;t.preventDefault();let n=c();if(0===n.length)return;let o=document.querySelector(".react-flow__pane"),a=o?.getBoundingClientRect();if(!a)return;let i=s({x:a.left+a.width/2,y:a.top+a.height/2}),l=null,d=1/0;for(let e of n){let t=e.measured?.width??e.style?.width??340,n=e.measured?.height??e.style?.height??160,o=e.position.x+t/2,a=e.position.y+n/2,s=o-i.x,c=a-i.y,u=!1;if("left"===r?u=s<0:"right"===r?u=s>0:"up"===r?u=c<0:"down"===r&&(u=c>0),!u)continue;let p=s*s+c*c;p<d&&(d=p,l=e)}l&&x({nodes:[l],padding:.3,duration:400})};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[x,c,s,e.nodes]),(0,o.useEffect)(()=>{let e=e=>{let t=document.activeElement;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;let r=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);if(0===r.length)return;e.preventDefault();let n=document.querySelector(".react-flow__pane"),o=n?.getBoundingClientRect(),a=s({x:o?o.left+o.width/2:window.innerWidth/2,y:o?o.top+o.height/2:window.innerHeight/2});r.forEach((e,t)=>{C(e,{x:a.x+20*t,y:a.y+20*t})})};return window.addEventListener("paste",e,!0),()=>window.removeEventListener("paste",e,!0)},[C,s]);let q=(0,o.useCallback)(e=>{let t=e.target.files?.[0];e.target.value="",t&&C(t,s({x:window.innerWidth/2,y:window.innerHeight/2}))},[C,s]);return(0,o.useEffect)(()=>{let e=()=>k.current?.click();return window.addEventListener("pi:board-pick-image",e),()=>window.removeEventListener("pi:board-pick-image",e)},[]),(0,n.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:(0,n.jsxs)("div",{ref:L,style:{flex:1,minHeight:0,position:"relative"},children:[(0,n.jsx)("div",{style:{position:"absolute",inset:0,zIndex:0,pointerEvents:"none",backgroundColor:"var(--board-scrim-bg)",backgroundImage:"var(--glass-bg-image-scrim, none)",backgroundAttachment:"fixed",backgroundSize:"100% 100%, 100% 100%",backgroundRepeat:"no-repeat, no-repeat",backgroundPosition:"0 0, 0 0",backdropFilter:"var(--board-scrim-filter, none)",WebkitBackdropFilter:"var(--board-scrim-filter, none)"}}),h&&(0,n.jsx)("div",{style:{position:"absolute",inset:0,zIndex:30,display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--accent) 10%, transparent)",border:"2px dashed var(--accent)",borderRadius:10,pointerEvents:"none",color:"var(--accent)",fontSize:13,fontWeight:600},children:i("boards.dropToAdd")}),e.error?(0,n.jsx)("div",{style:{position:"absolute",inset:0,zIndex:30,display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:e.error}):e.loading?(0,n.jsx)(eC.N,{label:i("boards.loadingCanvas")}):(0,n.jsxs)(T.u,{value:j,children:[(0,n.jsxs)(a.Gc,{nodes:e.nodes,edges:e.edges,onNodesChange:e.onNodesChange,onEdgesChange:e.onEdgesChange,onConnect:e.onConnect,nodeTypes:eN,edgeTypes:eD,onBeforeDelete:W,onNodeContextMenu:D,onNodeClick:A,onPaneContextMenu:H,onEdgeContextMenu:O,onPaneClick:I,onMoveEnd:N,onNodeDragStart:B,onNodeDrag:F,onNodeDragStop:P,zoomOnDoubleClick:!1,minZoom:.1,maxZoom:2,colorMode:t?"dark":"light",deleteKeyCode:["Backspace","Delete"],proOptions:{hideAttribution:!1},defaultEdgeOptions:{markerEnd:{type:"arrowclosed"},style:{strokeWidth:1.5,stroke:"#8b8fa3"}},children:[m&&(0,n.jsx)(a.of,{pannable:!0,zoomable:!0,style:{...eE.r,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",borderRadius:12,boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)",overflow:"hidden",bottom:52},maskColor:"color-mix(in srgb, var(--board-card-glass) 78%, transparent)",nodeColor:()=>"color-mix(in srgb, var(--accent) 50%, transparent)",nodeStrokeColor:()=>"var(--accent)"}),y.length>0&&(r=p(),(0,n.jsx)("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible",zIndex:20,transform:`translate(${r.x}px, ${r.y}px) scale(${r.zoom})`,transformOrigin:"0 0"},children:y.map((e,t)=>(0,n.jsx)("line",{className:"board-align-line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:"var(--accent)",strokeWidth:1.2,strokeDasharray:"4 3",opacity:.7},t))}))]}),f&&(0,n.jsx)(ej,{menu:f,onClose:()=>b(null)}),(0,n.jsx)(eM,{nodes:e.nodes,sessionRunning:e.sessionRunning}),(0,n.jsxs)("div",{style:{position:"absolute",left:0,right:0,bottom:16,margin:"0 auto",width:"fit-content",zIndex:30,display:"flex",gap:4,padding:4,borderRadius:10,...eE.r,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)"},children:[(0,n.jsx)(eB,{label:"会话",onClick:_,onDragStart:e=>M(e,"session-card")}),(0,n.jsx)("span",{style:{width:1,height:18,background:"color-mix(in srgb, var(--border) 70%, transparent)",margin:"0 2px"}}),(0,n.jsx)(eB,{label:"便笺",onClick:()=>Y("sticky-note"),onDragStart:e=>M(e,"sticky-note")}),(0,n.jsx)(eB,{label:"任务",onClick:()=>Y("task-card"),onDragStart:e=>M(e,"task-card")}),(0,n.jsx)(eB,{label:"图片",onClick:()=>k.current?.click(),onDragStart:e=>M(e,"image-node")}),(0,n.jsx)("span",{style:{width:1,height:18,background:"color-mix(in srgb, var(--border) 70%, transparent)",margin:"0 2px"}}),(0,n.jsx)(eB,{label:"撤销",onClick:()=>e.undo?.(),draggable:!1}),(0,n.jsx)(eB,{label:"重做",onClick:()=>e.redo?.(),draggable:!1})]}),(0,n.jsx)("input",{ref:k,type:"file",accept:"image/*",multiple:!1,onChange:q,style:{display:"none"},"aria-hidden":!0,tabIndex:-1}),(0,n.jsx)("button",{type:"button",onClick:()=>v(e=>!e),title:m?"收起小地图":"展开小地图","aria-label":m?"收起小地图":"展开小地图","aria-expanded":m,style:{position:"absolute",right:12,bottom:12,zIndex:30,display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,padding:0,borderRadius:8,border:"1px solid color-mix(in srgb, var(--border) 60%, transparent)",background:m?"color-mix(in srgb, var(--accent) 14%, transparent)":"var(--board-card-glass)",backdropFilter:"blur(var(--board-blur)) saturate(var(--glass-saturate))",WebkitBackdropFilter:"blur(var(--board-blur)) saturate(var(--glass-saturate))",boxShadow:"0 2px 12px -6px rgba(0,0,0,0.18)",color:m?"var(--accent)":"var(--text-muted)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--accent) 12%, transparent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.background=m?"color-mix(in srgb, var(--accent) 14%, transparent)":"var(--board-card-glass)",e.currentTarget.style.color=m?"var(--accent)":"var(--text-muted)"},children:m?(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("path",{d:"M9 3v18"}),(0,n.jsx)("path",{d:"M15 3v18"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M9 21V9"})]})})]})]})})}function eB({label:e,onClick:t,onDragStart:r,draggable:o=!0}){return(0,n.jsx)("button",{type:"button",draggable:o,title:e,"aria-label":e,onClick:t,onDragStart:r,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 14px",border:"none",borderRadius:7,background:"transparent",color:"var(--text-muted)",fontSize:12.5,cursor:"grab",userSelect:"none",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--accent) 12%, transparent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.color="var(--text-muted)"},children:e})}}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{35871:(e,o,r)=>{Promise.resolve().then(r.bind(r,57788)),Promise.resolve().then(r.t.bind(r,83683,23)),Promise.resolve().then(r.t.bind(r,84559,23)),Promise.resolve().then(r.t.bind(r,66872,23))},57788:(e,o,r)=>{"use strict";r.d(o,{PwaRegistration:()=>n});var t=r(12115);function n(){return(0,t.useEffect)(()=>{if(!("serviceWorker"in navigator))return;let e=()=>{let e=`/sw.js?v=${encodeURIComponent("0.1.46")}`;navigator.serviceWorker.register(e,{scope:"/",updateViaCache:"none"}).catch(e=>{console.error("Failed to register the Pi Web service worker:",e)})};return"complete"===document.readyState?void e():(window.addEventListener("load",e,{once:!0}),()=>window.removeEventListener("load",e))},[]),null}},66872:()=>{},83683:e=>{e.exports={style:{fontFamily:"'Noto Sans Mono', 'Noto Sans Mono Fallback'",fontStyle:"normal"},className:"__className_66b8ca",variable:"__variable_66b8ca"}},84559:()=>{}},e=>{e.O(0,[7389,7513,8441,3794,7358],()=>e(e.s=35871)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{35871:(e,o,r)=>{Promise.resolve().then(r.bind(r,57788)),Promise.resolve().then(r.t.bind(r,83683,23)),Promise.resolve().then(r.t.bind(r,84559,23)),Promise.resolve().then(r.t.bind(r,66872,23))},57788:(e,o,r)=>{"use strict";r.d(o,{PwaRegistration:()=>n});var t=r(12115);function n(){return(0,t.useEffect)(()=>{if(!("serviceWorker"in navigator))return;let e=()=>{let e=`/sw.js?v=${encodeURIComponent("0.1.48")}`;navigator.serviceWorker.register(e,{scope:"/",updateViaCache:"none"}).catch(e=>{console.error("Failed to register the Pi Web service worker:",e)})};return"complete"===document.readyState?void e():(window.addEventListener("load",e,{once:!0}),()=>window.removeEventListener("load",e))},[]),null}},66872:()=>{},83683:e=>{e.exports={style:{fontFamily:"'Noto Sans Mono', 'Noto Sans Mono Fallback'",fontStyle:"normal"},className:"__className_66b8ca",variable:"__variable_66b8ca"}},84559:()=>{}},e=>{e.O(0,[7389,7513,8441,3794,7358],()=>e(e.s=35871)),_N_E=e.O()}]);