agent-tower 0.7.4-beta.1 → 0.7.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executors/__tests__/codex-mcp-windows.test.d.ts +2 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.d.ts.map +1 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.js +128 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.js.map +1 -0
- package/dist/executors/__tests__/codex.executor.test.js +394 -1
- package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
- package/dist/executors/codex.executor.d.ts +6 -6
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +118 -32
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/mcp/tools/tasks.js +1 -1
- package/dist/mcp/tools/tasks.js.map +1 -1
- package/dist/mcp/types.js +1 -1
- package/dist/mcp/types.js.map +1 -1
- package/dist/runtime/__tests__/acp-process-manager.test.js +65 -0
- package/dist/runtime/__tests__/acp-process-manager.test.js.map +1 -1
- package/dist/runtime/acp/agents/pi-coding-agent.d.ts.map +1 -1
- package/dist/runtime/acp/agents/pi-coding-agent.js +3 -0
- package/dist/runtime/acp/agents/pi-coding-agent.js.map +1 -1
- package/dist/services/__tests__/task.service.test.js +69 -7
- package/dist/services/__tests__/task.service.test.js.map +1 -1
- package/dist/services/__tests__/workspace.service.test.js +31 -0
- package/dist/services/__tests__/workspace.service.test.js.map +1 -1
- package/dist/services/task-display-state.d.ts +10 -0
- package/dist/services/task-display-state.d.ts.map +1 -0
- package/dist/services/task-display-state.js +45 -0
- package/dist/services/task-display-state.js.map +1 -0
- package/dist/services/task.service.d.ts +14 -6
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +70 -83
- package/dist/services/task.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +2 -1
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-DiHEh1iv.js → AgentDemoPage-CrkoVCOZ.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-B_Xk7Bef.js → AgentEnvironmentSettingsPage-BRihy3_Q.js} +1 -1
- package/dist/web/assets/{AttachmentPreview-BngGSahV.js → AttachmentPreview-B9z1Mxb-.js} +1 -1
- package/dist/web/assets/{BranchSelect-BgVKUnxj.js → BranchSelect-Bo5uhKCt.js} +1 -1
- package/dist/web/assets/{BrandLogo-CBahjTd7.js → BrandLogo-DEL42B23.js} +1 -1
- package/dist/web/assets/{ConversationPage-kgJIlyS5.js → ConversationPage-C46RuN9U.js} +1 -1
- package/dist/web/assets/{CreateTaskInput-Cllw4abW.js → CreateTaskInput-4aHJpsfL.js} +1 -1
- package/dist/web/assets/{DemoPage-CkS__9CE.js → DemoPage-CAZqNag-.js} +1 -1
- package/dist/web/assets/{DesignSystemPage-BklN99GA.js → DesignSystemPage-CjCYC24B.js} +1 -1
- package/dist/web/assets/{ExecutionPermissionSelector-Bsi1aa7q.js → ExecutionPermissionSelector-CJgc_EVo.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-BC9TUWiu.js → GeneralSettingsPage-DFT7Cubi.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-Dx8Si6-g.js → LoadingPreviewPage-CB4VDPAZ.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-fqXRGtFu.js → McpSettingsPage-CgiyGvkH.js} +1 -1
- package/dist/web/assets/{MemberAvatar-CZ3F53Ep.js → MemberAvatar-Cfz8LU6k.js} +1 -1
- package/dist/web/assets/MobileTaskDetail-yZNyZMQt.js +3 -0
- package/dist/web/assets/{NotificationSettingsPage-D9KGIFVA.js → NotificationSettingsPage-BSMJ45yx.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-D_Hw5lpd.js → ProfileSettingsPage-BwNThOnH.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-DtZW0bOh.js +14 -0
- package/dist/web/assets/{ProjectSettingsPage-CJANCPJX.js → ProjectSettingsPage-CMBMkbgI.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-B6Ro5PQa.js → ProviderSettingsPage-D759BSRa.js} +1 -1
- package/dist/web/assets/{SettingsMasterDetail-Q-049Dvh.js → SettingsMasterDetail-DpYUTM-Q.js} +1 -1
- package/dist/web/assets/TaskDetail-rRHGOvSw.js +1 -0
- package/dist/web/assets/{TaskHandoffPanel-BpGiZ5eT.js → TaskHandoffPanel-DBcC1xQW.js} +24 -24
- package/dist/web/assets/{TeamSettingsPage-DbKgqEO_.js → TeamSettingsPage-BszQfKp0.js} +1 -1
- package/dist/web/assets/{TranslationSettingsPage-Ba-iypOV.js → TranslationSettingsPage-lLaxWCy3.js} +1 -1
- package/dist/web/assets/{arc-SOqs3Svk.js → arc-DtgXFw4D.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-BH25ukq_.js → architectureDiagram-3BPJPVTR-B3p3EMX1.js} +1 -1
- package/dist/web/assets/{at-sign-CEsum1vJ.js → at-sign-B8rXgKEE.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CKA17iNP.js → blockDiagram-GPEHLZMM-BmekCfr0.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-DnZ_8oOf.js → c4Diagram-AAUBKEIU-CF6hJhuL.js} +1 -1
- package/dist/web/assets/channel-BdK_fAel.js +1 -0
- package/dist/web/assets/check-DwK55QS2.js +1 -0
- package/dist/web/assets/{chevron-down-Bmwy-nvS.js → chevron-down-Dftc5hr4.js} +1 -1
- package/dist/web/assets/{chevron-up-CClL6-SF.js → chevron-up-CKRxN6zX.js} +1 -1
- package/dist/web/assets/{chip-BSMT2uT1.js → chip-ZTBHcXU2.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-BrtUyBDF.js → chunk-2J33WTMH-Bjelop4M.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-DZDNetDC.js → chunk-4BX2VUAB-B1rJPbL6.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-xVa3bJqv.js → chunk-55IACEB6-B5qfH7Gj.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-B7n9vxY4.js → chunk-727SXJPM-ClFMbgrH.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-DQd4G76y.js → chunk-AQP2D5EJ-BMFjTO7B.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-CXyP08kl.js → chunk-FMBD7UC4-Pr1oOFfR.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-BtnIS-HK.js → chunk-ND2GUHAM-BPm4TRpO.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-D4D-V_ex.js → chunk-QZHKN3VN-DCPA_U0M.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CFzCq0ml.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CFzCq0ml.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-DfERo9L1.js → code-block-OCS4YCEC-Cx53F4d7.js} +1 -1
- package/dist/web/assets/{confirm-dialog-8ItnHBi0.js → confirm-dialog-C_j-w4TS.js} +1 -1
- package/dist/web/assets/{content-DrW8KnXu.js → content-DeIfej_n.js} +1 -1
- package/dist/web/assets/{copy-prrQrInw.js → copy-B-BaLIlh.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-CXdH8Idq.js → cose-bilkent-S5V4N54A-gIys-0yu.js} +1 -1
- package/dist/web/assets/{cssMode-CJ6_f10q.js → cssMode-xF0bjbbU.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-XZydDwXe.js → dagre-BM42HDAG-Bwc3Ntc-.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CofEe0Fr.js → diagram-2AECGRRQ-zkydBsMT.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-BbTtW5WH.js → diagram-5GNKFQAL-p9As3QtI.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-BJHZXpUM.js → diagram-KO2AKTUF-N_pUU-iU.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-DN7A27YU.js → diagram-LMA3HP47-CA2rl4Gq.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-4IdYadiw.js → diagram-OG6HWLK6-BoXxBlUC.js} +1 -1
- package/dist/web/assets/{dialog-BUsI4h2U.js → dialog-CnjWIdWp.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-BFijhCWv.js → erDiagram-TEJ5UH35-CVBHQTCN.js} +1 -1
- package/dist/web/assets/{file-C6QMUr5_.js → file-jMLGlXos.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-D9MxC-El.js → flowDiagram-I6XJVG4X-kK7iKiAv.js} +1 -1
- package/dist/web/assets/{folder-picker-CBdw-4v3.js → folder-picker-CR8LiSQf.js} +1 -1
- package/dist/web/assets/{freemarker2-CJVobC22.js → freemarker2-CTMcTiBd.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-BijCAyPQ.js → ganttDiagram-6RSMTGT7-CJVvLTkW.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-AvI5QqxQ.js → gitGraphDiagram-PVQCEYII-D8uj_SCw.js} +1 -1
- package/dist/web/assets/{globe-BOfcTsvL.js → globe-FFVKce9-.js} +1 -1
- package/dist/web/assets/{handlebars-DTqWmI25.js → handlebars-NHxbmOs3.js} +1 -1
- package/dist/web/assets/{html-Bx7L8DX_.js → html-oFqzz32q.js} +1 -1
- package/dist/web/assets/{htmlMode-D_S0NjZc.js → htmlMode-sgeetciK.js} +1 -1
- package/dist/web/assets/index-408ws6FY.css +1 -0
- package/dist/web/assets/index-9KNEuwGB.js +122 -0
- package/dist/web/assets/{index-Bg8TlDo_.js → index-BzqyZD7L.js} +1 -1
- package/dist/web/assets/{index-BFcDmhr0.js → index-C5lNOKJb.js} +1 -1
- package/dist/web/assets/{index-BClyhWqz.js → index-C9vIrQ3Q.js} +1 -1
- package/dist/web/assets/{index-Cdmj8aPv.js → index-Cm_7q6ju.js} +1 -1
- package/dist/web/assets/{index-DUmVscrR.js → index-CwfWGzxi.js} +4 -4
- package/dist/web/assets/{index-COigMgrJ.js → index-D8TNxwWk.js} +1 -1
- package/dist/web/assets/{index-JXcQeorP.js → index-biTPUXAe.js} +1 -1
- package/dist/web/assets/{index-CtOu4p9B.js → index-gqrRO6ZJ.js} +1 -1
- package/dist/web/assets/{infoDiagram-5YYISTIA-76JLqjJ0.js → infoDiagram-5YYISTIA-CExRZE3Y.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CXHFTVly.js → ishikawaDiagram-YF4QCWOH-CsqM2X33.js} +1 -1
- package/dist/web/assets/javascript-COt-61wn.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-6SDJs9C5.js → journeyDiagram-JHISSGLW-DX9OMhPD.js} +1 -1
- package/dist/web/assets/{jsonMode-BGg9MhFR.js → jsonMode-VQg5cpLV.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-C0Y3zy1P.js → kanban-definition-UN3LZRKU-CWHMx6vc.js} +1 -1
- package/dist/web/assets/{kbd-D4KIW7lm.js → kbd-GGofKfKu.js} +1 -1
- package/dist/web/assets/{key-round-C4vhwqUu.js → key-round-p-Fpykfj.js} +1 -1
- package/dist/web/assets/{layers-BBHgMnhN.js → layers-pbPa_eZq.js} +1 -1
- package/dist/web/assets/{linear-CjeIgBwO.js → linear-9VwGhaEA.js} +1 -1
- package/dist/web/assets/{link-C-Jq7dnc.js → link-CG4UwIS1.js} +1 -1
- package/dist/web/assets/{liquid-guocpCJB.js → liquid-SJInUaiB.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-CPXERxVW.js → lspLanguageFeatures-DJOdVyBc.js} +1 -1
- package/dist/web/assets/{mdx-DA4ymd3l.js → mdx-CToYr-3b.js} +1 -1
- package/dist/web/assets/{menu-BgtmXAzT.js → menu-BFQ1mKU7.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-XQbfQDGS.js → mermaid-NOHMQCX5-BOViobLk.js} +58 -58
- package/dist/web/assets/{message-square-DIFv9yrO.js → message-square-BYZsUsLz.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-6ucD61UV.js → mindmap-definition-RKZ34NQL-BTcDnn6X.js} +1 -1
- package/dist/web/assets/{modal-Dx4N46s5.js → modal-BT_7Lhtw.js} +1 -1
- package/dist/web/assets/{monaco-Mn1xgio_.js → monaco-DUftz48_.js} +3 -3
- package/dist/web/assets/{nav-row-DwEkbw3N.js → nav-row-BjDckaPC.js} +1 -1
- package/dist/web/assets/{paperclip-CdQvl5ee.js → paperclip-CFAH5neE.js} +1 -1
- package/dist/web/assets/{pencil-ChX7G9j9.js → pencil-Bg9TWm_-.js} +1 -1
- package/dist/web/assets/{people-D_VwidfV.js → people-BIQwajM2.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-KVvAyrIn.js → pieDiagram-4H26LBE5-CRjqdnP8.js} +1 -1
- package/dist/web/assets/{popover-CGEFZKuu.js → popover-DpYhrrCE.js} +1 -1
- package/dist/web/assets/{python-BzNNRn8W.js → python-DbmUucgH.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-ClVzvpE7.js → quadrantDiagram-W4KKPZXB-uvA8TYC6.js} +1 -1
- package/dist/web/assets/{razor-DF2ZxqCE.js → razor-B0AJhw7W.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-uXN6Uoln.js → requirementDiagram-4Y6WPE33-BWLugaKX.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-Bi3Tc0wR.js → sankeyDiagram-5OEKKPKP-DHrbZZv8.js} +1 -1
- package/dist/web/assets/{search--FRFbCre.js → search-BH8nze-X.js} +1 -1
- package/dist/web/assets/{select-c5IIpQj0.js → select-BegY9RkP.js} +1 -1
- package/dist/web/assets/{select-D0sHgfcU.js → select-EcEr5QSS.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CLdrO2PY.js → sequenceDiagram-3UESZ5HK-CKwEKcTn.js} +1 -1
- package/dist/web/assets/{server-Dr_6KJFM.js → server-BxEUjx0l.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-BGInldGc.js → stateDiagram-AJRCARHV-vhgmSpa9.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-C0z5OTY4.js +1 -0
- package/dist/web/assets/{textarea-W-xQPto3.js → textarea-CvoGGROs.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BUp6Qykc.js → timeline-definition-PNZ67QCA-bSDKcwDZ.js} +1 -1
- package/dist/web/assets/{toggles-Bgp7vdwg.js → toggles-CEDUD08u.js} +1 -1
- package/dist/web/assets/{tooltip-DZcaSN1F.js → tooltip-CKaUbVZ7.js} +1 -1
- package/dist/web/assets/{track-Cj1Ogapu.js → track-1qw2cvTy.js} +1 -1
- package/dist/web/assets/{trash-2-DmFXzIhh.js → trash-2-ChiXon87.js} +1 -1
- package/dist/web/assets/{tsMode-CSHMQttX.js → tsMode-bnV8W2Ru.js} +1 -1
- package/dist/web/assets/{typescript-CyQKmnN-.js → typescript-d1MHIeEx.js} +1 -1
- package/dist/web/assets/{upload-C-4QDrwN.js → upload-CQ-cQaOz.js} +1 -1
- package/dist/web/assets/{use-profiles-D5mIgeQU.js → use-profiles-CJzoqarX.js} +1 -1
- package/dist/web/assets/{use-providers-BViTes-6.js → use-providers-S29TCag2.js} +1 -1
- package/dist/web/assets/{use-translation-settings-Dgw0oKP1.js → use-translation-settings-DifNJaCu.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-BX7pMg0-.js → useNormalizedLogs-BVdY8qDk.js} +1 -1
- package/dist/web/assets/{useTokenUsage-T03faPfn.js → useTokenUsage-nh_KDA3q.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-iQYnP9Ux.js → vennDiagram-CIIHVFJN-D7QbDYzC.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-J7vXwA5J.js → wardley-L42UT6IY-C9aHlNVa.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CdtM5GJv.js → wardleyDiagram-YWT4CUSO-CZhubDRC.js} +1 -1
- package/dist/web/assets/{xml-C79KdvcD.js → xml-DAKKxHAr.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-B3gcBChQ.js → xychartDiagram-2RQKCTM6-BgDlpFBh.js} +1 -1
- package/dist/web/assets/{yaml-C1WLpuVe.js → yaml-D_hSVVz0.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +12 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/assets/MobileTaskDetail-B68iYPOI.js +0 -3
- package/dist/web/assets/ProjectKanbanPage-CUX0Kh-t.js +0 -12
- package/dist/web/assets/TaskDetail-DBtWf0YV.js +0 -1
- package/dist/web/assets/channel-xU45IQlP.js +0 -1
- package/dist/web/assets/check-DUA2DjGH.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-pvRulc6s.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-pvRulc6s.js +0 -1
- package/dist/web/assets/index-BDON669P.css +0 -1
- package/dist/web/assets/index-BRu1Yhrx.js +0 -122
- package/dist/web/assets/javascript-80FDzX3y.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-D44x8SXb.js +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TaskDetail-DBtWf0YV.js","assets/index-BRu1Yhrx.js","assets/index-BDON669P.css","assets/TaskHandoffPanel-BpGiZ5eT.js","assets/trash-2-DmFXzIhh.js","assets/mermaid-NOHMQCX5-XQbfQDGS.js","assets/AttachmentPreview-BngGSahV.js","assets/tooltip-DZcaSN1F.js","assets/kbd-D4KIW7lm.js","assets/index-BFcDmhr0.js","assets/index-BClyhWqz.js","assets/index-Cdmj8aPv.js","assets/use-translation-settings-Dgw0oKP1.js","assets/copy-prrQrInw.js","assets/index-COigMgrJ.js","assets/chevron-down-Bmwy-nvS.js","assets/mermaid-NOHMQCX5-lI9o3AWT.css","assets/use-providers-BViTes-6.js","assets/MemberAvatar-CZ3F53Ep.js","assets/people-D_VwidfV.js","assets/chevron-up-CClL6-SF.js","assets/at-sign-CEsum1vJ.js","assets/paperclip-CdQvl5ee.js","assets/check-DUA2DjGH.js","assets/useTokenUsage-T03faPfn.js","assets/CreateTaskInput-Cllw4abW.js","assets/BranchSelect-BgVKUnxj.js","assets/popover-CGEFZKuu.js","assets/search--FRFbCre.js","assets/menu-styles-DWynpVVz.js","assets/BrandLogo-CBahjTd7.js","assets/index-Bg8TlDo_.js","assets/index-CtOu4p9B.js","assets/ExecutionPermissionSelector-Bsi1aa7q.js","assets/menu-BgtmXAzT.js","assets/provider-selection-DSu7SCI7.js","assets/confirm-dialog-8ItnHBi0.js","assets/dialog-BUsI4h2U.js","assets/modal-Dx4N46s5.js","assets/select-c5IIpQj0.js","assets/select-D0sHgfcU.js","assets/index-JXcQeorP.js","assets/layers-BBHgMnhN.js","assets/message-square-DIFv9yrO.js","assets/textarea-W-xQPto3.js","assets/content-DrW8KnXu.js","assets/file-C6QMUr5_.js","assets/server-Dr_6KJFM.js","assets/upload-C-4QDrwN.js","assets/globe-BOfcTsvL.js","assets/pencil-ChX7G9j9.js","assets/TaskHandoffPanel-DcpNTP1B.css","assets/useNormalizedLogs-BX7pMg0-.js","assets/track-Cj1Ogapu.js","assets/chip-BSMT2uT1.js","assets/folder-picker-CBdw-4v3.js","assets/MobileTaskDetail-B68iYPOI.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as ar,aY as ss,p as Ue,r as u,ab as _,aG as pt,as as Xe,bn as Le,az as ne,b5 as Te,u as ze,bo as os,j as o,a5 as De,ap as Rn,aA as it,l as ce,a2 as lr,bp as is,au as vt,bq as Lt,br as as,bs as ls,bt as cs,aO as cr,bu as ur,N as us,m as ds,o as Wt,n as vn,q as fe,X as fs,aB as hs,ae as ms,aj as Pt,aU as gs,t as Oe,bv as ps,bw as en,ai as vs,bx as bs,by as xs,bz as ys,bA as tn,aQ as An,aR as Tn,bB as dr}from"./index-BRu1Yhrx.js";import{C as ws}from"./confirm-dialog-8ItnHBi0.js";import{a as Cs,k as Ss,h as Ns}from"./BranchSelect-BgVKUnxj.js";import{f as Es,g as Dn,j as In,s as bt,k as js,c as ks,C as Mn}from"./CreateTaskInput-Cllw4abW.js";import{P as fr,T as Rs}from"./trash-2-DmFXzIhh.js";import{C as Ct}from"./check-DUA2DjGH.js";import{S as hr}from"./search--FRFbCre.js";import{F as As}from"./chip-BSMT2uT1.js";import{S as Ts,I as nn,B as Pn}from"./BrandLogo-CBahjTd7.js";import{M as Ds}from"./message-square-DIFv9yrO.js";import{L as dn}from"./layers-BBHgMnhN.js";import{c as Is,P as Ms,a as Ps,b as Os,I as Ls}from"./popover-CGEFZKuu.js";import{C as On}from"./copy-prrQrInw.js";import{u as zs}from"./use-providers-BViTes-6.js";import{i as Bs}from"./provider-selection-DSu7SCI7.js";import{F as Fs}from"./folder-picker-CBdw-4v3.js";import{M as Ln}from"./modal-Dx4N46s5.js";import{a as mt}from"./ExecutionPermissionSelector-Bsi1aa7q.js";import{C as _s}from"./chevron-down-Bmwy-nvS.js";const Us=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],$s=ar("list-tree",Us);const Ks=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],zn=ar("smartphone",Ks),rn=new Map;async function Gs(e,t,n){const r=`tower:task-start:${e}:${JSON.stringify(t)}`;let a=rn.get(r);if(!a)try{const h=sessionStorage.getItem(r);h&&(a=JSON.parse(h))}catch{}a??={creationId:ss()},rn.set(r,a);const c=()=>{try{sessionStorage.setItem(r,JSON.stringify(a))}catch{}};c(),a.workspace||(n.onStep?.("creating-workspace"),a.workspace=await n.createWorkspace(a.creationId),c()),a.session||(n.onStep?.("creating-session"),a.session=await Ue.post(`/workspaces/${a.workspace.id}/sessions`,{providerId:t.providerId,prompt:t.prompt,retryTask:t.retryTask,clientSubmissionId:a.creationId}),c()),n.onStep?.("starting-session"),await n.startSession(a.session.id),rn.delete(r);try{sessionStorage.removeItem(r)}catch{}return{workspace:a.workspace,session:a.session}}const Qt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function lt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bn(e){return"nodeType"in e}function be(e){var t,n;return e?lt(e)?e:bn(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xn(e){const{Document:t}=be(e);return e instanceof t}function jt(e){return lt(e)?!1:e instanceof be(e).HTMLElement}function mr(e){return e instanceof be(e).SVGElement}function ct(e){return e?lt(e)?e.document:bn(e)?xn(e)?e:jt(e)||mr(e)?e.ownerDocument:document:document:document}const $e=Qt?u.useLayoutEffect:u.useEffect;function Yt(e){const t=u.useRef(e);return $e(()=>{t.current=e}),u.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function Ws(){const e=u.useRef(null),t=u.useCallback((r,a)=>{e.current=setInterval(r,a)},[]),n=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function St(e,t){t===void 0&&(t=[e]);const n=u.useRef(e);return $e(()=>{n.current!==e&&(n.current=e)},t),n}function kt(e,t){const n=u.useRef();return u.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function zt(e){const t=Yt(e),n=u.useRef(null),r=u.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}function Bt(e){const t=u.useRef();return u.useEffect(()=>{t.current=e},[e]),t.current}let sn={};function Ht(e,t){return u.useMemo(()=>{if(t)return t;const n=sn[e]==null?0:sn[e]+1;return sn[e]=n,e+"-"+n},[e,t])}function gr(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((c,h)=>{const f=Object.entries(h);for(const[s,i]of f){const l=c[s];l!=null&&(c[s]=l+e*i)}return c},{...t})}}const at=gr(1),Ft=gr(-1);function Qs(e){return"clientX"in e&&"clientY"in e}function yn(e){if(!e)return!1;const{KeyboardEvent:t}=be(e.target);return t&&e instanceof t}function Ys(e){if(!e)return!1;const{TouchEvent:t}=be(e.target);return t&&e instanceof t}function _t(e){if(Ys(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Qs(e)?{x:e.clientX,y:e.clientY}:null}const Nt=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Nt.Translate.toString(e),Nt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Bn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Hs(e){return e.matches(Bn)?e:e.querySelector(Bn)}const Xs={display:"none"};function qs(e){let{id:t,value:n}=e;return _.createElement("div",{id:t,style:Xs},n)}function Vs(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return _.createElement("div",{id:t,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function Js(){const[e,t]=u.useState("");return{announce:u.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const pr=u.createContext(null);function Zs(e){const t=u.useContext(pr);u.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function eo(){const[e]=u.useState(()=>new Set),t=u.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[u.useCallback(r=>{let{type:a,event:c}=r;e.forEach(h=>{var f;return(f=h[a])==null?void 0:f.call(h,c)})},[e]),t]}const to={draggable:`
|
|
3
|
-
To pick up a draggable item, press the space bar.
|
|
4
|
-
While dragging, use the arrow keys to move the item.
|
|
5
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
-
`},no={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function ro(e){let{announcements:t=no,container:n,hiddenTextDescribedById:r,screenReaderInstructions:a=to}=e;const{announce:c,announcement:h}=Js(),f=Ht("DndLiveRegion"),[s,i]=u.useState(!1);if(u.useEffect(()=>{i(!0)},[]),Zs(u.useMemo(()=>({onDragStart(d){let{active:m}=d;c(t.onDragStart({active:m}))},onDragMove(d){let{active:m,over:p}=d;t.onDragMove&&c(t.onDragMove({active:m,over:p}))},onDragOver(d){let{active:m,over:p}=d;c(t.onDragOver({active:m,over:p}))},onDragEnd(d){let{active:m,over:p}=d;c(t.onDragEnd({active:m,over:p}))},onDragCancel(d){let{active:m,over:p}=d;c(t.onDragCancel({active:m,over:p}))}}),[c,t])),!s)return null;const l=_.createElement(_.Fragment,null,_.createElement(qs,{id:r,value:a.draggable}),_.createElement(Vs,{id:f,announcement:h}));return n?pt.createPortal(l,n):l}var de;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(de||(de={}));function Ut(){}function so(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function oo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return u.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Ie=Object.freeze({x:0,y:0});function io(e,t){const n=_t(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function ao(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function lo(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function co(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),a=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=a-r,f=c-n;if(r<a&&n<c){const s=t.width*t.height,i=e.width*e.height,l=h*f,d=l/(s+i-l);return Number(d.toFixed(4))}return 0}const uo=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const a=[];for(const c of r){const{id:h}=c,f=n.get(h);if(f){const s=co(f,t);s>0&&a.push({id:h,data:{droppableContainer:c,value:s}})}}return a.sort(ao)};function fo(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function vr(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ie}function ho(e){return function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),c=1;c<r;c++)a[c-1]=arguments[c];return a.reduce((h,f)=>({...h,top:h.top+e*f.y,bottom:h.bottom+e*f.y,left:h.left+e*f.x,right:h.right+e*f.x}),{...n})}}const mo=ho(1);function br(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function go(e,t,n){const r=br(t);if(!r)return e;const{scaleX:a,scaleY:c,x:h,y:f}=r,s=e.left-h-(1-a)*parseFloat(n),i=e.top-f-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),l=a?e.width/a:e.width,d=c?e.height/c:e.height;return{width:l,height:d,top:i,right:s+l,bottom:i+d,left:s}}const po={ignoreTransform:!1};function Rt(e,t){t===void 0&&(t=po);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:i,transformOrigin:l}=be(e).getComputedStyle(e);i&&(n=go(n,i,l))}const{top:r,left:a,width:c,height:h,bottom:f,right:s}=n;return{top:r,left:a,width:c,height:h,bottom:f,right:s}}function Fn(e){return Rt(e,{ignoreTransform:!0})}function vo(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function bo(e,t){return t===void 0&&(t=be(e).getComputedStyle(e)),t.position==="fixed"}function xo(e,t){t===void 0&&(t=be(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const c=t[a];return typeof c=="string"?n.test(c):!1})}function wn(e,t){const n=[];function r(a){if(t!=null&&n.length>=t||!a)return n;if(xn(a)&&a.scrollingElement!=null&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!jt(a)||mr(a)||n.includes(a))return n;const c=be(e).getComputedStyle(a);return a!==e&&xo(a,c)&&n.push(a),bo(a,c)?n:r(a.parentNode)}return e?r(e):n}function xr(e){const[t]=wn(e,1);return t??null}function on(e){return!Qt||!e?null:lt(e)?e:bn(e)?xn(e)||e===ct(e).scrollingElement?window:jt(e)?e:null:null}function yr(e){return lt(e)?e.scrollX:e.scrollLeft}function wr(e){return lt(e)?e.scrollY:e.scrollTop}function fn(e){return{x:yr(e),y:wr(e)}}var he;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(he||(he={}));function Cr(e){return!Qt||!e?!1:e===document.scrollingElement}function Sr(e){const t={x:0,y:0},n=Cr(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},a=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:a,isLeft:c,isBottom:h,isRight:f,maxScroll:r,minScroll:t}}const yo={x:.2,y:.2};function wo(e,t,n,r,a){let{top:c,left:h,right:f,bottom:s}=n;r===void 0&&(r=10),a===void 0&&(a=yo);const{isTop:i,isBottom:l,isLeft:d,isRight:m}=Sr(e),p={x:0,y:0},g={x:0,y:0},x={height:t.height*a.y,width:t.width*a.x};return!i&&c<=t.top+x.height?(p.y=he.Backward,g.y=r*Math.abs((t.top+x.height-c)/x.height)):!l&&s>=t.bottom-x.height&&(p.y=he.Forward,g.y=r*Math.abs((t.bottom-x.height-s)/x.height)),!m&&f>=t.right-x.width?(p.x=he.Forward,g.x=r*Math.abs((t.right-x.width-f)/x.width)):!d&&h<=t.left+x.width&&(p.x=he.Backward,g.x=r*Math.abs((t.left+x.width-h)/x.width)),{direction:p,speed:g}}function Co(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:n,right:r,bottom:a}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:a,width:e.clientWidth,height:e.clientHeight}}function Nr(e){return e.reduce((t,n)=>at(t,fn(n)),Ie)}function So(e){return e.reduce((t,n)=>t+yr(n),0)}function No(e){return e.reduce((t,n)=>t+wr(n),0)}function Er(e,t){if(t===void 0&&(t=Rt),!e)return;const{top:n,left:r,bottom:a,right:c}=t(e);xr(e)&&(a<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Eo=[["x",["left","right"],So],["y",["top","bottom"],No]];class Cn{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=wn(n),a=Nr(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,f]of Eo)for(const s of h)Object.defineProperty(this,s,{get:()=>{const i=f(r),l=a[c]-i;return this.rect[s]+l},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class xt{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var a;(a=this.target)==null||a.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function jo(e){const{EventTarget:t}=be(e);return e instanceof t?e:ct(e)}function an(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Ne;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Ne||(Ne={}));function _n(e){e.preventDefault()}function ko(e){e.stopPropagation()}var V;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(V||(V={}));const jr={start:[V.Space,V.Enter],cancel:[V.Esc],end:[V.Space,V.Enter,V.Tab]},Ro=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case V.Right:return{...n,x:n.x+25};case V.Left:return{...n,x:n.x-25};case V.Down:return{...n,y:n.y+25};case V.Up:return{...n,y:n.y-25}}};class kr{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new xt(ct(n)),this.windowListeners=new xt(be(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ne.Resize,this.handleCancel),this.windowListeners.add(Ne.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ne.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Er(r),n(Ie)}handleKeyDown(t){if(yn(t)){const{active:n,context:r,options:a}=this.props,{keyboardCodes:c=jr,coordinateGetter:h=Ro,scrollBehavior:f="smooth"}=a,{code:s}=t;if(c.end.includes(s)){this.handleEnd(t);return}if(c.cancel.includes(s)){this.handleCancel(t);return}const{collisionRect:i}=r.current,l=i?{x:i.left,y:i.top}:Ie;this.referenceCoordinates||(this.referenceCoordinates=l);const d=h(t,{active:n,context:r.current,currentCoordinates:l});if(d){const m=Ft(d,l),p={x:0,y:0},{scrollableAncestors:g}=r.current;for(const x of g){const v=t.code,{isTop:k,isRight:C,isLeft:y,isBottom:A,maxScroll:S,minScroll:P}=Sr(x),D=Co(x),j={x:Math.min(v===V.Right?D.right-D.width/2:D.right,Math.max(v===V.Right?D.left:D.left+D.width/2,d.x)),y:Math.min(v===V.Down?D.bottom-D.height/2:D.bottom,Math.max(v===V.Down?D.top:D.top+D.height/2,d.y))},O=v===V.Right&&!C||v===V.Left&&!y,F=v===V.Down&&!A||v===V.Up&&!k;if(O&&j.x!==d.x){const L=x.scrollLeft+m.x,Q=v===V.Right&&L<=S.x||v===V.Left&&L>=P.x;if(Q&&!m.y){x.scrollTo({left:L,behavior:f});return}Q?p.x=x.scrollLeft-L:p.x=v===V.Right?x.scrollLeft-S.x:x.scrollLeft-P.x,p.x&&x.scrollBy({left:-p.x,behavior:f});break}else if(F&&j.y!==d.y){const L=x.scrollTop+m.y,Q=v===V.Down&&L<=S.y||v===V.Up&&L>=P.y;if(Q&&!m.x){x.scrollTo({top:L,behavior:f});return}Q?p.y=x.scrollTop-L:p.y=v===V.Down?x.scrollTop-S.y:x.scrollTop-P.y,p.y&&x.scrollBy({top:-p.y,behavior:f});break}}this.handleMove(t,at(Ft(d,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}kr.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=jr,onActivation:a}=t,{active:c}=n;const{code:h}=e.nativeEvent;if(r.start.includes(h)){const f=c.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),a?.({event:e.nativeEvent}),!0)}return!1}}];function Un(e){return!!(e&&"distance"in e)}function $n(e){return!!(e&&"delay"in e)}class Sn{constructor(t,n,r){var a;r===void 0&&(r=jo(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:h}=c;this.props=t,this.events=n,this.document=ct(h),this.documentListeners=new xt(this.document),this.listeners=new xt(r),this.windowListeners=new xt(be(h)),this.initialCoordinates=(a=_t(c))!=null?a:Ie,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Ne.Resize,this.handleCancel),this.windowListeners.add(Ne.DragStart,_n),this.windowListeners.add(Ne.VisibilityChange,this.handleCancel),this.windowListeners.add(Ne.ContextMenu,_n),this.documentListeners.add(Ne.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if($n(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Un(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:a}=this.props;a(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Ne.Click,ko,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ne.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:c}=this,{onMove:h,options:{activationConstraint:f}}=c;if(!a)return;const s=(n=_t(t))!=null?n:Ie,i=Ft(a,s);if(!r&&f){if(Un(f)){if(f.tolerance!=null&&an(i,f.tolerance))return this.handleCancel();if(an(i,f.distance))return this.handleStart()}if($n(f)&&an(i,f.tolerance))return this.handleCancel();this.handlePending(f,i);return}t.cancelable&&t.preventDefault(),h(s)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===V.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ao={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Nn extends Sn{constructor(t){const{event:n}=t,r=ct(n.target);super(t,Ao,r)}}Nn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const To={move:{name:"mousemove"},end:{name:"mouseup"}};var hn;(function(e){e[e.RightClick=2]="RightClick"})(hn||(hn={}));class Do extends Sn{constructor(t){super(t,To,ct(t.event.target))}}Do.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===hn.RightClick?!1:(r?.({event:n}),!0)}}];const ln={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Io extends Sn{constructor(t){super(t,ln)}static setup(){return window.addEventListener(ln.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ln.move.name,t)};function t(){}}}Io.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:a}=n;return a.length>1?!1:(r?.({event:n}),!0)}}];var yt;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(yt||(yt={}));var $t;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})($t||($t={}));function Mo(e){let{acceleration:t,activator:n=yt.Pointer,canScroll:r,draggingRect:a,enabled:c,interval:h=5,order:f=$t.TreeOrder,pointerCoordinates:s,scrollableAncestors:i,scrollableAncestorRects:l,delta:d,threshold:m}=e;const p=Oo({delta:d,disabled:!c}),[g,x]=Ws(),v=u.useRef({x:0,y:0}),k=u.useRef({x:0,y:0}),C=u.useMemo(()=>{switch(n){case yt.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case yt.DraggableRect:return a}},[n,a,s]),y=u.useRef(null),A=u.useCallback(()=>{const P=y.current;if(!P)return;const D=v.current.x*k.current.x,j=v.current.y*k.current.y;P.scrollBy(D,j)},[]),S=u.useMemo(()=>f===$t.TreeOrder?[...i].reverse():i,[f,i]);u.useEffect(()=>{if(!c||!i.length||!C){x();return}for(const P of S){if(r?.(P)===!1)continue;const D=i.indexOf(P),j=l[D];if(!j)continue;const{direction:O,speed:F}=wo(P,j,C,t,m);for(const L of["x","y"])p[L][O[L]]||(F[L]=0,O[L]=0);if(F.x>0||F.y>0){x(),y.current=P,g(A,h),v.current=F,k.current=O;return}}v.current={x:0,y:0},k.current={x:0,y:0},x()},[t,A,r,x,c,h,JSON.stringify(C),JSON.stringify(p),g,i,S,l,JSON.stringify(m)])}const Po={x:{[he.Backward]:!1,[he.Forward]:!1},y:{[he.Backward]:!1,[he.Forward]:!1}};function Oo(e){let{delta:t,disabled:n}=e;const r=Bt(t);return kt(a=>{if(n||!r||!a)return Po;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[he.Backward]:a.x[he.Backward]||c.x===-1,[he.Forward]:a.x[he.Forward]||c.x===1},y:{[he.Backward]:a.y[he.Backward]||c.y===-1,[he.Forward]:a.y[he.Forward]||c.y===1}}},[n,t,r])}function Lo(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return kt(a=>{var c;return t==null?null:(c=r??a)!=null?c:null},[r,t])}function zo(e,t){return u.useMemo(()=>e.reduce((n,r)=>{const{sensor:a}=r,c=a.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,r)}));return[...n,...c]},[]),[e,t])}var Et;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Et||(Et={}));var mn;(function(e){e.Optimized="optimized"})(mn||(mn={}));const Kn=new Map;function Bo(e,t){let{dragging:n,dependencies:r,config:a}=t;const[c,h]=u.useState(null),{frequency:f,measure:s,strategy:i}=a,l=u.useRef(e),d=v(),m=St(d),p=u.useCallback(function(k){k===void 0&&(k=[]),!m.current&&h(C=>C===null?k:C.concat(k.filter(y=>!C.includes(y))))},[m]),g=u.useRef(null),x=kt(k=>{if(d&&!n)return Kn;if(!k||k===Kn||l.current!==e||c!=null){const C=new Map;for(let y of e){if(!y)continue;if(c&&c.length>0&&!c.includes(y.id)&&y.rect.current){C.set(y.id,y.rect.current);continue}const A=y.node.current,S=A?new Cn(s(A),A):null;y.rect.current=S,S&&C.set(y.id,S)}return C}return k},[e,c,n,d,s]);return u.useEffect(()=>{l.current=e},[e]),u.useEffect(()=>{d||p()},[n,d]),u.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),u.useEffect(()=>{d||typeof f!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},f))},[f,d,p,...r]),{droppableRects:x,measureDroppableContainers:p,measuringScheduled:c!=null};function v(){switch(i){case Et.Always:return!1;case Et.BeforeDragging:return n;default:return!n}}}function En(e,t){return kt(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Fo(e,t){return En(e,t)}function _o(e){let{callback:t,disabled:n}=e;const r=Yt(t),a=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,n]);return u.useEffect(()=>()=>a?.disconnect(),[a]),a}function Xt(e){let{callback:t,disabled:n}=e;const r=Yt(t),a=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[n]);return u.useEffect(()=>()=>a?.disconnect(),[a]),a}function Uo(e){return new Cn(Rt(e),e)}function Gn(e,t,n){t===void 0&&(t=Uo);const[r,a]=u.useState(null);function c(){a(s=>{if(!e)return null;if(e.isConnected===!1){var i;return(i=s??n)!=null?i:null}const l=t(e);return JSON.stringify(s)===JSON.stringify(l)?s:l})}const h=_o({callback(s){if(e)for(const i of s){const{type:l,target:d}=i;if(l==="childList"&&d instanceof HTMLElement&&d.contains(e)){c();break}}}}),f=Xt({callback:c});return $e(()=>{c(),e?(f?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),h?.disconnect())},[e]),r}function $o(e){const t=En(e);return vr(e,t)}const Wn=[];function Ko(e){const t=u.useRef(e),n=kt(r=>e?r&&r!==Wn&&e&&t.current&&e.parentNode===t.current.parentNode?r:wn(e):Wn,[e]);return u.useEffect(()=>{t.current=e},[e]),n}function Go(e){const[t,n]=u.useState(null),r=u.useRef(e),a=u.useCallback(c=>{const h=on(c.target);h&&n(f=>f?(f.set(h,fn(h)),new Map(f)):null)},[]);return u.useEffect(()=>{const c=r.current;if(e!==c){h(c);const f=e.map(s=>{const i=on(s);return i?(i.addEventListener("scroll",a,{passive:!0}),[i,fn(i)]):null}).filter(s=>s!=null);n(f.length?new Map(f):null),r.current=e}return()=>{h(e),h(c)};function h(f){f.forEach(s=>{const i=on(s);i?.removeEventListener("scroll",a)})}},[a,e]),u.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>at(c,h),Ie):Nr(e):Ie,[e,t])}function Qn(e,t){t===void 0&&(t=[]);const n=u.useRef(null);return u.useEffect(()=>{n.current=null},t),u.useEffect(()=>{const r=e!==Ie;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Ft(e,n.current):Ie}function Wo(e){u.useEffect(()=>{if(!Qt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Qo(e,t){return u.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:c}=r;return n[a]=h=>{c(h,t)},n},{}),[e,t])}function Rr(e){return u.useMemo(()=>e?vo(e):null,[e])}const Yn=[];function Yo(e,t){t===void 0&&(t=Rt);const[n]=e,r=Rr(n?be(n):null),[a,c]=u.useState(Yn);function h(){c(()=>e.length?e.map(s=>Cr(s)?r:new Cn(t(s),s)):Yn)}const f=Xt({callback:h});return $e(()=>{f?.disconnect(),h(),e.forEach(s=>f?.observe(s))},[e]),a}function Ar(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return jt(t)?t:e}function Ho(e){let{measure:t}=e;const[n,r]=u.useState(null),a=u.useCallback(i=>{for(const{target:l}of i)if(jt(l)){r(d=>{const m=t(l);return d?{...d,width:m.width,height:m.height}:m});break}},[t]),c=Xt({callback:a}),h=u.useCallback(i=>{const l=Ar(i);c?.disconnect(),l&&c?.observe(l),r(l?t(l):null)},[t,c]),[f,s]=zt(h);return u.useMemo(()=>({nodeRef:f,rect:n,setRef:s}),[n,f,s])}const Xo=[{sensor:Nn,options:{}},{sensor:kr,options:{}}],qo={current:{}},Ot={draggable:{measure:Fn},droppable:{measure:Fn,strategy:Et.WhileDragging,frequency:mn.Optimized},dragOverlay:{measure:Rt}};class wt extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Vo={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new wt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ut},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ot,measureDroppableContainers:Ut,windowRect:null,measuringScheduled:!1},Tr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ut,draggableNodes:new Map,over:null,measureDroppableContainers:Ut},At=u.createContext(Tr),Dr=u.createContext(Vo);function Jo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new wt}}}function Zo(e,t){switch(t.type){case de.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case de.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case de.DragEnd:case de.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case de.RegisterDroppable:{const{element:n}=t,{id:r}=n,a=new wt(e.droppable.containers);return a.set(r,n),{...e,droppable:{...e.droppable,containers:a}}}case de.SetDroppableDisabled:{const{id:n,key:r,disabled:a}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const h=new wt(e.droppable.containers);return h.set(n,{...c,disabled:a}),{...e,droppable:{...e.droppable,containers:h}}}case de.UnregisterDroppable:{const{id:n,key:r}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;const c=new wt(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function ei(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:a}=u.useContext(At),c=Bt(r),h=Bt(n?.id);return u.useEffect(()=>{if(!t&&!r&&c&&h!=null){if(!yn(c)||document.activeElement===c.target)return;const f=a.get(h);if(!f)return;const{activatorNode:s,node:i}=f;if(!s.current&&!i.current)return;requestAnimationFrame(()=>{for(const l of[s.current,i.current]){if(!l)continue;const d=Hs(l);if(d){d.focus();break}}})}},[r,t,a,h,c]),null}function Ir(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((a,c)=>c({transform:a,...r}),n):n}function ti(e){return u.useMemo(()=>({draggable:{...Ot.draggable,...e?.draggable},droppable:{...Ot.droppable,...e?.droppable},dragOverlay:{...Ot.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function ni(e){let{activeNode:t,measure:n,initialRect:r,config:a=!0}=e;const c=u.useRef(!1),{x:h,y:f}=typeof a=="boolean"?{x:a,y:a}:a;$e(()=>{if(!h&&!f||!t){c.current=!1;return}if(c.current||!r)return;const i=t?.node.current;if(!i||i.isConnected===!1)return;const l=n(i),d=vr(l,r);if(h||(d.x=0),f||(d.y=0),c.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const m=xr(i);m&&m.scrollBy({top:d.y,left:d.x})}},[t,h,f,r,n])}const qt=u.createContext({...Ie,scaleX:1,scaleY:1});var We;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(We||(We={}));const ri=u.memo(function(t){var n,r,a,c;let{id:h,accessibility:f,autoScroll:s=!0,children:i,sensors:l=Xo,collisionDetection:d=uo,measuring:m,modifiers:p,...g}=t;const x=u.useReducer(Zo,void 0,Jo),[v,k]=x,[C,y]=eo(),[A,S]=u.useState(We.Uninitialized),P=A===We.Initialized,{draggable:{active:D,nodes:j,translate:O},droppable:{containers:F}}=v,L=D!=null?j.get(D):null,Q=u.useRef({initial:null,translated:null}),z=u.useMemo(()=>{var ae;return D!=null?{id:D,data:(ae=L?.data)!=null?ae:qo,rect:Q}:null},[D,L]),q=u.useRef(null),[te,J]=u.useState(null),[U,Y]=u.useState(null),G=St(g,Object.values(g)),re=Ht("DndDescribedBy",h),ie=u.useMemo(()=>F.getEnabled(),[F]),H=ti(m),{droppableRects:me,measureDroppableContainers:xe,measuringScheduled:Me}=Bo(ie,{dragging:P,dependencies:[O.x,O.y],config:H.droppable}),Z=Lo(j,D),Ee=u.useMemo(()=>U?_t(U):null,[U]),E=Zt(),w=Fo(Z,H.draggable.measure);ni({activeNode:D!=null?j.get(D):null,config:E.layoutShiftCompensation,initialRect:w,measure:H.draggable.measure});const R=Gn(Z,H.draggable.measure,w),M=Gn(Z?Z.parentElement:null),I=u.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:me,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:F,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),K=F.getNodeFor((n=I.current.over)==null?void 0:n.id),W=Ho({measure:H.dragOverlay.measure}),je=(r=W.nodeRef.current)!=null?r:Z,Ce=P?(a=W.rect)!=null?a:R:null,Be=!!(W.nodeRef.current&&W.rect),ut=$o(Be?null:R),Ve=Rr(je?be(je):null),we=Ko(P?K??Z:null),Qe=Yo(we),Ye=Ir(p,{transform:{x:O.x-ut.x,y:O.y-ut.y,scaleX:1,scaleY:1},activatorEvent:U,active:z,activeNodeRect:R,containerNodeRect:M,draggingNodeRect:Ce,over:I.current.over,overlayNodeRect:W.rect,scrollableAncestors:we,scrollableAncestorRects:Qe,windowRect:Ve}),He=Ee?at(Ee,O):null,Je=Go(we),Ze=Qn(Je),Jt=Qn(Je,[R]),ke=at(Ye,Ze),Ke=Ce?mo(Ce,Ye):null,Fe=z&&Ke?d({active:z,collisionRect:Ke,droppableRects:me,droppableContainers:ie,pointerCoordinates:He}):null,et=lo(Fe,"id"),[Re,dt]=u.useState(null),Tt=Be?Ye:at(Ye,Jt),_e=fo(Tt,(c=Re?.rect)!=null?c:null,R),tt=u.useRef(null),nt=u.useCallback((ae,le)=>{let{sensor:ge,options:Pe}=le;if(q.current==null)return;const ye=j.get(q.current);if(!ye)return;const pe=ae.nativeEvent,ve=new ge({active:q.current,activeNode:ye,event:pe,options:Pe,context:I,onAbort(ue){if(!j.get(ue))return;const{onDragAbort:N}=G.current,T={id:ue};N?.(T),C({type:"onDragAbort",event:T})},onPending(ue,b,N,T){if(!j.get(ue))return;const{onDragPending:se}=G.current,X={id:ue,constraint:b,initialCoordinates:N,offset:T};se?.(X),C({type:"onDragPending",event:X})},onStart(ue){const b=q.current;if(b==null)return;const N=j.get(b);if(!N)return;const{onDragStart:T}=G.current,B={activatorEvent:pe,active:{id:b,data:N.data,rect:Q}};pt.unstable_batchedUpdates(()=>{T?.(B),S(We.Initializing),k({type:de.DragStart,initialCoordinates:ue,active:b}),C({type:"onDragStart",event:B}),J(tt.current),Y(pe)})},onMove(ue){k({type:de.DragMove,coordinates:ue})},onEnd:Ae(de.DragEnd),onCancel:Ae(de.DragCancel)});tt.current=ve;function Ae(ue){return async function(){const{active:N,collisions:T,over:B,scrollAdjustedTranslate:se}=I.current;let X=null;if(N&&se){const{cancelDrop:ee}=G.current;X={activatorEvent:pe,active:N,collisions:T,delta:se,over:B},ue===de.DragEnd&&typeof ee=="function"&&await Promise.resolve(ee(X))&&(ue=de.DragCancel)}q.current=null,pt.unstable_batchedUpdates(()=>{k({type:ue}),S(We.Uninitialized),dt(null),J(null),Y(null),tt.current=null;const ee=ue===de.DragEnd?"onDragEnd":"onDragCancel";if(X){const Se=G.current[ee];Se?.(X),C({type:ee,event:X})}})}}},[j]),Dt=u.useCallback((ae,le)=>(ge,Pe)=>{const ye=ge.nativeEvent,pe=j.get(Pe);if(q.current!==null||!pe||ye.dndKit||ye.defaultPrevented)return;const ve={active:pe};ae(ge,le.options,ve)===!0&&(ye.dndKit={capturedBy:le.sensor},q.current=Pe,nt(ge,le))},[j,nt]),ft=zo(l,Dt);Wo(l),$e(()=>{R&&A===We.Initializing&&S(We.Initialized)},[R,A]),u.useEffect(()=>{const{onDragMove:ae}=G.current,{active:le,activatorEvent:ge,collisions:Pe,over:ye}=I.current;if(!le||!ge)return;const pe={active:le,activatorEvent:ge,collisions:Pe,delta:{x:ke.x,y:ke.y},over:ye};pt.unstable_batchedUpdates(()=>{ae?.(pe),C({type:"onDragMove",event:pe})})},[ke.x,ke.y]),u.useEffect(()=>{const{active:ae,activatorEvent:le,collisions:ge,droppableContainers:Pe,scrollAdjustedTranslate:ye}=I.current;if(!ae||q.current==null||!le||!ye)return;const{onDragOver:pe}=G.current,ve=Pe.get(et),Ae=ve&&ve.rect.current?{id:ve.id,rect:ve.rect.current,data:ve.data,disabled:ve.disabled}:null,ue={active:ae,activatorEvent:le,collisions:ge,delta:{x:ye.x,y:ye.y},over:Ae};pt.unstable_batchedUpdates(()=>{dt(Ae),pe?.(ue),C({type:"onDragOver",event:ue})})},[et]),$e(()=>{I.current={activatorEvent:U,active:z,activeNode:Z,collisionRect:Ke,collisions:Fe,droppableRects:me,draggableNodes:j,draggingNode:je,draggingNodeRect:Ce,droppableContainers:F,over:Re,scrollableAncestors:we,scrollAdjustedTranslate:ke},Q.current={initial:Ce,translated:Ke}},[z,Z,Fe,Ke,j,je,Ce,me,F,Re,we,ke]),Mo({...E,delta:O,draggingRect:Ke,pointerCoordinates:He,scrollableAncestors:we,scrollableAncestorRects:Qe});const It=u.useMemo(()=>({active:z,activeNode:Z,activeNodeRect:R,activatorEvent:U,collisions:Fe,containerNodeRect:M,dragOverlay:W,draggableNodes:j,droppableContainers:F,droppableRects:me,over:Re,measureDroppableContainers:xe,scrollableAncestors:we,scrollableAncestorRects:Qe,measuringConfiguration:H,measuringScheduled:Me,windowRect:Ve}),[z,Z,R,U,Fe,M,W,j,F,me,Re,xe,we,Qe,H,Me,Ve]),ht=u.useMemo(()=>({activatorEvent:U,activators:ft,active:z,activeNodeRect:R,ariaDescribedById:{draggable:re},dispatch:k,draggableNodes:j,over:Re,measureDroppableContainers:xe}),[U,ft,z,R,k,re,j,Re,xe]);return _.createElement(pr.Provider,{value:y},_.createElement(At.Provider,{value:ht},_.createElement(Dr.Provider,{value:It},_.createElement(qt.Provider,{value:_e},i)),_.createElement(ei,{disabled:f?.restoreFocus===!1})),_.createElement(ro,{...f,hiddenTextDescribedById:re}));function Zt(){const ae=te?.autoScrollEnabled===!1,le=typeof s=="object"?s.enabled===!1:s===!1,ge=P&&!ae&&!le;return typeof s=="object"?{...s,enabled:ge}:{enabled:ge}}}),si=u.createContext(null),Hn="button",oi="Draggable";function ii(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const c=Ht(oi),{activators:h,activatorEvent:f,active:s,activeNodeRect:i,ariaDescribedById:l,draggableNodes:d,over:m}=u.useContext(At),{role:p=Hn,roleDescription:g="draggable",tabIndex:x=0}=a??{},v=s?.id===t,k=u.useContext(v?qt:si),[C,y]=zt(),[A,S]=zt(),P=Qo(h,t),D=St(n);$e(()=>(d.set(t,{id:t,key:c,node:C,activatorNode:A,data:D}),()=>{const O=d.get(t);O&&O.key===c&&d.delete(t)}),[d,t]);const j=u.useMemo(()=>({role:p,tabIndex:x,"aria-disabled":r,"aria-pressed":v&&p===Hn?!0:void 0,"aria-roledescription":g,"aria-describedby":l.draggable}),[r,p,x,v,g,l.draggable]);return{active:s,activatorEvent:f,activeNodeRect:i,attributes:j,isDragging:v,listeners:r?void 0:P,node:C,over:m,setNodeRef:y,setActivatorNodeRef:S,transform:k}}function ai(){return u.useContext(Dr)}const li="Droppable",ci={timeout:25};function ui(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:a}=e;const c=Ht(li),{active:h,dispatch:f,over:s,measureDroppableContainers:i}=u.useContext(At),l=u.useRef({disabled:n}),d=u.useRef(!1),m=u.useRef(null),p=u.useRef(null),{disabled:g,updateMeasurementsFor:x,timeout:v}={...ci,...a},k=St(x??r),C=u.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{i(Array.isArray(k.current)?k.current:[k.current]),p.current=null},v)},[v]),y=Xt({callback:C,disabled:g||!h}),A=u.useCallback((j,O)=>{y&&(O&&(y.unobserve(O),d.current=!1),j&&y.observe(j))},[y]),[S,P]=zt(A),D=St(t);return u.useEffect(()=>{!y||!S.current||(y.disconnect(),d.current=!1,y.observe(S.current))},[S,y]),u.useEffect(()=>(f({type:de.RegisterDroppable,element:{id:r,key:c,disabled:n,node:S,rect:m,data:D}}),()=>f({type:de.UnregisterDroppable,key:c,id:r})),[r]),u.useEffect(()=>{n!==l.current.disabled&&(f({type:de.SetDroppableDisabled,id:r,key:c,disabled:n}),l.current.disabled=n)},[r,c,n,f]),{active:h,rect:m,isOver:s?.id===r,node:S,over:s,setNodeRef:P}}function di(e){let{animation:t,children:n}=e;const[r,a]=u.useState(null),[c,h]=u.useState(null),f=Bt(n);return!n&&!r&&f&&a(f),$e(()=>{if(!c)return;const s=r?.key,i=r?.props.id;if(s==null||i==null){a(null);return}Promise.resolve(t(i,c)).then(()=>{a(null)})},[t,r,c]),_.createElement(_.Fragment,null,n,r?u.cloneElement(r,{ref:h}):null)}const fi={x:0,y:0,scaleX:1,scaleY:1};function hi(e){let{children:t}=e;return _.createElement(At.Provider,{value:Tr},_.createElement(qt.Provider,{value:fi},t))}const mi={position:"fixed",touchAction:"none"},gi=e=>yn(e)?"transform 250ms ease":void 0,pi=u.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:a,children:c,className:h,rect:f,style:s,transform:i,transition:l=gi}=e;if(!f)return null;const d=a?i:{...i,scaleX:1,scaleY:1},m={...mi,width:f.width,height:f.height,top:f.top,left:f.left,transform:Nt.Transform.toString(d),transformOrigin:a&&r?io(r,f):void 0,transition:typeof l=="function"?l(r):l,...s};return _.createElement(n,{className:h,style:m,ref:t},c)}),vi=e=>t=>{let{active:n,dragOverlay:r}=t;const a={},{styles:c,className:h}=e;if(c!=null&&c.active)for(const[f,s]of Object.entries(c.active))s!==void 0&&(a[f]=n.node.style.getPropertyValue(f),n.node.style.setProperty(f,s));if(c!=null&&c.dragOverlay)for(const[f,s]of Object.entries(c.dragOverlay))s!==void 0&&r.node.style.setProperty(f,s);return h!=null&&h.active&&n.node.classList.add(h.active),h!=null&&h.dragOverlay&&r.node.classList.add(h.dragOverlay),function(){for(const[s,i]of Object.entries(a))n.node.style.setProperty(s,i);h!=null&&h.active&&n.node.classList.remove(h.active)}},bi=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Nt.Transform.toString(t)},{transform:Nt.Transform.toString(n)}]},xi={duration:250,easing:"ease",keyframes:bi,sideEffects:vi({styles:{active:{opacity:"0"}}})};function yi(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:a}=e;return Yt((c,h)=>{if(t===null)return;const f=n.get(c);if(!f)return;const s=f.node.current;if(!s)return;const i=Ar(h);if(!i)return;const{transform:l}=be(h).getComputedStyle(h),d=br(l);if(!d)return;const m=typeof t=="function"?t:wi(t);return Er(s,a.draggable.measure),m({active:{id:c,data:f.data,node:s,rect:a.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:h,rect:a.dragOverlay.measure(i)},droppableContainers:r,measuringConfiguration:a,transform:d})})}function wi(e){const{duration:t,easing:n,sideEffects:r,keyframes:a}={...xi,...e};return c=>{let{active:h,dragOverlay:f,transform:s,...i}=c;if(!t)return;const l={x:f.rect.left-h.rect.left,y:f.rect.top-h.rect.top},d={scaleX:s.scaleX!==1?h.rect.width*s.scaleX/f.rect.width:1,scaleY:s.scaleY!==1?h.rect.height*s.scaleY/f.rect.height:1},m={x:s.x-l.x,y:s.y-l.y,...d},p=a({...i,active:h,dragOverlay:f,transform:{initial:s,final:m}}),[g]=p,x=p[p.length-1];if(JSON.stringify(g)===JSON.stringify(x))return;const v=r?.({active:h,dragOverlay:f,...i}),k=f.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(C=>{k.onfinish=()=>{v?.(),C()}})}}let Xn=0;function Ci(e){return u.useMemo(()=>{if(e!=null)return Xn++,Xn},[e])}const Si=_.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:a,transition:c,modifiers:h,wrapperElement:f="div",className:s,zIndex:i=999}=e;const{activatorEvent:l,active:d,activeNodeRect:m,containerNodeRect:p,draggableNodes:g,droppableContainers:x,dragOverlay:v,over:k,measuringConfiguration:C,scrollableAncestors:y,scrollableAncestorRects:A,windowRect:S}=ai(),P=u.useContext(qt),D=Ci(d?.id),j=Ir(h,{activatorEvent:l,active:d,activeNodeRect:m,containerNodeRect:p,draggingNodeRect:v.rect,over:k,overlayNodeRect:v.rect,scrollableAncestors:y,scrollableAncestorRects:A,transform:P,windowRect:S}),O=En(m),F=yi({config:r,draggableNodes:g,droppableContainers:x,measuringConfiguration:C}),L=O?v.setRef:void 0;return _.createElement(hi,null,_.createElement(di,{animation:F},d&&D?_.createElement(pi,{key:D,id:d.id,ref:L,as:f,activatorEvent:l,adjustScale:t,className:s,transition:c,rect:O,style:{zIndex:i,...a},transform:j},n):null))}),Mr=768;function Ni(e){const t=window.matchMedia(`(max-width: ${Mr-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Ei(){return window.innerWidth<Mr}function ji(){return!1}function Pr(){return u.useSyncExternalStore(Ni,Ei,ji)}function Vt(e){switch(e){case Le.TODO:return ne.Pending;case Le.IN_PROGRESS:return ne.Running;case Le.IN_REVIEW:return ne.Review;case Le.DONE:return ne.Done;case Le.CANCELLED:return ne.Cancelled}}function ki(e){switch(e){case ne.Pending:return Le.TODO;case ne.Running:return Le.IN_PROGRESS;case ne.Review:return Le.IN_REVIEW;case ne.Done:return Le.DONE;case ne.Cancelled:return Le.CANCELLED}}function Or(e){switch(e){case Te.CLAUDE_CODE:return"Claude Code";case Te.GEMINI_CLI:return"Gemini CLI";case Te.CURSOR_AGENT:return"Cursor Agent";case Te.CODEX:return"Codex";case Te.QWEN_CODE:return"Qwen Code";case Te.KIRO_CLI:return"Kiro CLI";case Te.OPENCODE:return"OpenCode";case Te.PI_CODING_AGENT:return"Pi Coding Agent";case Te.GROK_BUILD:return"Grok Build";case Te.MINION_CODE:return"Minion Code";case Te.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const Kt=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Lr(e,t){let n=0;for(let r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r)|0;return Math.abs(n)%t}function Ri(e,t){return e?.find(n=>n.status==="ACTIVE")??e?.[0]}function Ai(e){return e?e.workspaceKind===Xe.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function Ti(e){return{id:e.id,name:e.name,color:e.color||Kt[Lr(e.name,Kt.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Di(e){const t=Ri(e);if(!t)return{agent:"—",branch:"—"};const n=Ai(t),r=t.sessions;if(r&&r.length>0){const a=r[r.length-1];return{agent:Or(a.agentType),branch:n}}return{agent:"—",branch:n}}function qn(e){const{agent:t,branch:n}=Di(e.workspaces),r=e.project;return{id:e.id,parentTaskId:e.parentTaskId,ancestorIds:e.ancestorIds,subtaskCount:e.subtaskCount,projectId:e.projectId,title:e.titlePreview??e.title,status:Vt(e.status),priority:e.priority,agent:t,branch:n,description:e.contentPreview??e.description??"",updatedAt:e.updatedAt,isGitRepo:r?.isGitRepo,worktreeReady:r?.worktreeReady,reason:r?.reason,projectArchivedAt:r?.archivedAt??null,projectRepoDeletedAt:r?.repoDeletedAt??null}}function zr(e,t){const n=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===Xe.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,parentTaskId:e.parentTaskId,ancestorIds:e.ancestorIds,subtaskCount:e.subtaskCount,runningSubtaskCount:e.runningSubtaskCount,projectId:e.projectId,title:e.title,status:Vt(e.status),priority:e.priority,agent:e.latestAgentType?Or(e.latestAgentType):"—",branch:n,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:t?.isGitRepo,worktreeReady:t?.worktreeReady,reason:t?.reason,projectArchivedAt:t?.archivedAt??null,projectRepoDeletedAt:t?.repoDeletedAt??null}}function Ii(e,t){const n=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===Xe.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,parentTaskId:e.parentTaskId,ancestorIds:e.ancestorIds,subtaskCount:e.subtaskCount,projectId:t.id,projectName:t.name,projectColor:t.color||Kt[Lr(t.name,Kt.length)],title:e.title,status:Vt(e.status),priority:e.priority,branch:n,mainBranch:t.mainBranch??"main",description:"",isGitRepo:t.isGitRepo,worktreeReady:t.worktreeReady,reason:t.reason,projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const Br=u.createContext(null);function Mi(e,t){const n=[];if(!e||e.length===0)return n;const r=e.some(c=>c.status==="ACTIVE");return e.some(c=>c.sessions?.some(h=>h.status===Rn.RUNNING||h.status===Rn.PENDING))&&n.push(t("正在运行的 Agent 将被停止")),r&&(n.push(t("分支上未合并的变更将丢失")),n.push(t("关联的工作目录(worktree)将被清理"))),n}function Pi({isOpen:e,onClose:t,onConfirm:n,taskId:r,taskTitle:a,workspaces:c,isLoading:h}){const{t:f}=ze(),{data:s,isLoading:i}=Cs(c===void 0&&e?r:""),l=os(r,e),d=l.data?.descendantCount??0,m=c??s,p=c===void 0&&e&&i,g=u.useMemo(()=>Mi(m,f),[m,f]);return o.jsx(ws,{isOpen:e,onClose:t,onConfirm:()=>n(d),title:f("删除任务"),description:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:d>0?f("Delete “{title}” and all {count} descendants? This cannot be undone.",{title:a,count:d}):f("确认删除任务「{title}」?此操作不可撤销。",{title:a})}),d>0&&o.jsx("p",{className:"mt-2 text-warning-ink",children:f("All related Agents and services will stop. Their worktrees and owned branches will be deleted.")}),l.isError&&o.jsx(De,{variant:"ghost",size:"sm",onClick:()=>l.refetch(),children:f("Could not load subtasks. Retry")}),l.isFetching&&o.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f("Loading...")}),p?o.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f("加载中...")}):g.length>0?o.jsx("ul",{className:"mt-2 space-y-1",children:g.map((x,v)=>o.jsxs("li",{className:"flex items-start gap-1.5 text-warning-ink",children:[o.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-warning"}),o.jsx("span",{children:x})]},v))}):null]}),confirmText:d>0?f("Delete all"):f("删除"),variant:"danger",isLoading:h,confirmDisabled:p||l.isFetching||l.isError||!l.data})}const Oi=3e4;function Li(e=Oi){const[,t]=u.useState(0);u.useEffect(()=>{const n=setInterval(()=>t(r=>r+1),e);return()=>clearInterval(n)},[e])}function zi(e){const t=cs(e,9,"..");if(t===e)return e;const n=t.slice(0,-2),r=n.search(/[-_.\s][^-_.\s]*$/);return`${r>=3?n.slice(0,r):n}..`}const st="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:outline-none",Vn="px-2 pb-1 pt-1.5 text-xs font-medium text-muted-foreground",cn=o.jsx("div",{className:"-mx-1 my-1 h-px bg-border/60"});function Fr({task:e,status:t,isSelected:n,project:r,showProject:a,onSelectTask:c,onTaskStatusChange:h,onDeleteTask:f,onTaskPriorityChange:s,disableDrag:i,onCreateSubtask:l,selectedTaskId:d,expandForSelection:m,selectionPath:p}){const{t:g,locale:x}=ze(),[v,k]=u.useState({open:!1}),C=v.open||!!(m&&v.selection!==d),y=is(e.id,C&&vt(e)),A=y.data?.pages[0]?.total??e.subtaskCount??0,S=y.data?.pages.flatMap(w=>w.data).map(w=>zr(w))??[],P=p?.find(w=>w.parentTaskId===e.id);P?.parentTaskId===e.id&&!S.some(w=>w.id===P.id)&&S.push(P);const D=u.useContext(Br),j=u.useRef(null),O=!!e.projectArchivedAt,F=O||!!i,{attributes:L,listeners:Q,setNodeRef:z,isDragging:q}=ii({id:e.id,data:{task:e,fromStatus:t},disabled:F}),te=u.useCallback(w=>{j.current=w,z(w),D&&(w?D.registry.set(e.id,w):D.registry.delete(e.id))},[z,D,e.id]);u.useEffect(()=>()=>{D?.registry.delete(e.id)},[e.id,D]);const[J,U]=u.useState(null),[Y,G]=u.useState(!1),re=u.useRef(null),ie=u.useRef(null),H=u.useCallback(w=>{O||!h&&!f&&!s&&!l||(w.preventDefault(),U({x:w.clientX,y:w.clientY}))},[O,h,f,s,l,U]),me=u.useCallback(()=>{ie.current&&(clearTimeout(ie.current),ie.current=null)},[]),xe=u.useCallback(w=>{if(!i||O||!h&&!f&&!l)return;const R=w.touches[0];if(!R)return;const{clientX:M,clientY:I}=R;ie.current=setTimeout(()=>{ie.current=null,U({x:M,y:I})},500)},[i,O,h,f,l,U]);u.useEffect(()=>{if(!J)return;const w=()=>U(null),R=I=>{re.current&&!re.current.contains(I.target)&&w()},M=I=>{I.key==="Escape"&&w()};return document.addEventListener("mousedown",R),document.addEventListener("touchstart",R),document.addEventListener("keydown",M),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("touchstart",R),document.removeEventListener("keydown",M),window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[J]),u.useLayoutEffect(()=>{const w=re.current;if(!J||!w)return;const R=8;w.style.left=`${Math.max(R,Math.min(J.x,window.innerWidth-w.offsetWidth-R))}px`,w.style.top=`${Math.max(R,Math.min(J.y,window.innerHeight-w.offsetHeight-R))}px`},[J]);const Me=r?r.name:void 0,Z=a?r:void 0,Ee=e.updatedAt?Es(e.updatedAt,g,x):null,{titleClass:E}=it[t];return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-0.5",children:[o.jsxs("button",{ref:te,type:"button",onClick:()=>c(e.id),onContextMenu:H,onTouchStart:xe,onTouchEnd:me,onTouchMove:me,title:Z?`${e.title} · ${Z.name}`:e.title,"aria-label":Me?`${e.title} — ${Me}`:e.title,"aria-current":n||void 0,"data-sidebar-item":"",className:ce("task-row animate-task-enter",bt(n),"min-w-0 flex-1",q&&"opacity-30"),...F?{}:Q,...F?{}:L,children:[e.parentTaskId&&(()=>{const{icon:w,accentClass:R,label:M}=it[t];return o.jsx("span",{className:"shrink-0",title:g(M),"aria-label":g(M),children:o.jsx(w,{className:ce("size-3.5",R)})})})(),t===ne.Running?o.jsx(Dn,{text:e.title,variant:"running",animate:!n,className:ce("min-w-0 flex-1 truncate",E)}):o.jsx("span",{className:ce("min-w-0 flex-1 truncate",E),children:e.title}),e.priority!==void 0&&e.priority!==Lt.NORMAL&&o.jsx(In,{priority:e.priority}),e.projectArchivedAt&&o.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-foreground/[0.06] px-1.5 py-0.5 text-xs font-medium leading-none text-muted-foreground",children:e.projectRepoDeletedAt?g("源码已删除"):g("已删除")}),(Ee||Z)&&o.jsx("span",{className:"task-row-meta",children:o.jsxs("span",{className:"flex items-center gap-1",children:[Z&&o.jsx("span",{className:"shrink-0 whitespace-nowrap rounded bg-foreground/[0.05] px-1 py-0.5 text-[10px] font-medium leading-none @max-[22rem]:hidden",children:o.jsx(Dn,{text:zi(Z.name),variant:"project",className:Z.color})}),Ee&&o.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:Ee})]})})]}),vt(e)&&A>0&&o.jsxs("button",{type:"button","data-sidebar-item":"","aria-expanded":C,"aria-label":g("Subtasks of {title}",{title:e.title}),title:g("{count} subtasks, {running} running",{count:A,running:e.runningSubtaskCount??0}),onClick:()=>k({selection:d,open:!C}),className:"flex h-8 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 pointer-coarse:h-10",children:[o.jsx($s,{size:14}),o.jsx("span",{className:"tabular-nums",children:A}),o.jsx(lr,{size:12,className:ce("transition-transform",C&&"rotate-90")})]})]}),vt(e)&&C&&o.jsxs("div",{className:"ml-4 border-l border-border/60 pl-1",role:"group","aria-label":g("Subtasks of {title}",{title:e.title}),children:[y.isLoading&&o.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:g("Loading...")}),y.isError&&o.jsx("button",{type:"button",className:st,onClick:()=>y.refetch(),children:g("Could not load subtasks. Retry")}),S.map(w=>o.jsx(Fr,{task:{...w,projectArchivedAt:e.projectArchivedAt},status:w.status,isSelected:d===w.id,project:r,showProject:!1,selectedTaskId:d,selectionPath:p,expandForSelection:p?.some(R=>R.parentTaskId===w.id),onCreateSubtask:l,onSelectTask:c,onTaskStatusChange:h,onDeleteTask:f,onTaskPriorityChange:s,disableDrag:i},w.id)),y.hasNextPage&&o.jsx("button",{type:"button",className:st,disabled:y.isFetchingNextPage,onClick:()=>y.fetchNextPage(),children:g("Load more")})]}),J&&o.jsxs("div",{ref:re,role:"menu",className:"fixed z-[100] w-48 rounded-lg border border-border bg-popover p-1 shadow-popover shadow-black/5 animate-in fade-in zoom-in-95 duration-100",children:[l&&vt(e)&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",role:"menuitem",className:st,onClick:()=>{l(e.id),U(null)},children:[o.jsx(fr,{className:"size-3.5 shrink-0"}),o.jsx("span",{children:g("Create subtask")})]}),cn]}),h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:Vn,children:g("Move to")}),as.filter(w=>w!==t).map(w=>{const{icon:R,label:M,accentClass:I}=it[w];return o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{h(e.id,w),U(null)},className:st,children:[o.jsx(R,{className:ce("size-3.5 shrink-0",I)}),o.jsx("span",{children:g(M)})]},w)})]}),s&&o.jsxs(o.Fragment,{children:[h&&cn,o.jsx("div",{className:Vn,children:g("Priority")}),ls.map(w=>{const R=(e.priority??Lt.NORMAL)===w.value;return o.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":R,onClick:()=>{s(e.id,w.value),U(null)},className:st,children:[o.jsx(In,{priority:w.value}),o.jsx("span",{className:"flex-1",children:g(w.label)}),R&&o.jsx(Ct,{className:"size-3.5 shrink-0 text-foreground","aria-hidden":!0})]},w.value)})]}),f&&o.jsxs(o.Fragment,{children:[(h||s)&&cn,o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{G(!0),U(null)},className:ce(st,"text-destructive-ink hover:bg-destructive/10 hover:text-destructive-ink focus-visible:bg-destructive/10"),children:[o.jsx(Rs,{className:"size-3.5 shrink-0","aria-hidden":!0}),o.jsx("span",{children:g("Delete Task")})]})]})]}),o.jsx(Pi,{isOpen:Y,onClose:()=>G(!1),onConfirm:w=>{f?.(e.id,w),G(!1)},taskId:e.id,taskTitle:e.title})]})}const Bi=u.memo(function({title:t,tasks:n,status:r,defaultOpen:a,selectedTaskId:c,selectedParentTaskId:h,selectionPath:f,onCreateSubtask:s,onSelectTask:i,projects:l,showProject:d=!0,isDragging:m,dragFromStatus:p,onTaskStatusChange:g,onDeleteTask:x,onTaskPriorityChange:v,disableDrag:k}){const{t:C}=ze(),[y,A]=u.useState({selection:null,open:a}),S=y.open||!!(c&&y.selection!==c&&n.some(Y=>Y.id===c||Y.id===h||f?.some(G=>G.id===Y.id)));Li();const P=n.length===0,D=m&&p===r,j=m&&p!==r,{setNodeRef:O,isOver:F}=ui({id:`group-${r}`,data:{status:r}}),L=r===ne.Review,Q=C(t),{icon:z,accentClass:q}=it[r],te=u.useId(),J=m?D:S,U=J&&!j&&!P;return o.jsxs("div",{className:U?"mb-4":"mb-2","data-task-group-status":r,children:[o.jsx("div",{className:"sticky top-0 z-10 bg-sidebar px-2",children:o.jsxs("button",{type:"button",onClick:()=>!m&&A({selection:c,open:!S}),"aria-expanded":S,"data-sidebar-item":"",className:"group/header flex h-8 w-full items-center gap-1 rounded-md px-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 pointer-coarse:h-10 pointer-coarse:text-[15px]",children:[o.jsx(z,{className:ce("mr-1.5 size-4 shrink-0 -translate-y-px",q)}),o.jsx("span",{id:te,className:"truncate",children:Q}),o.jsx(lr,{size:14,"aria-hidden":!0,className:ce("shrink-0 text-muted-foreground transition-transform duration-150 group-hover/header:text-muted-foreground",J&&"rotate-90")}),L&&!P?o.jsx("span",{className:"ml-auto rounded-full bg-warning/15 px-1.5 text-xs font-semibold leading-5 tabular-nums text-warning-ink",children:n.length}):o.jsx("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:n.length})]})}),j&&o.jsx("div",{ref:O,className:ce("mx-2 mt-0.5 flex h-9 items-center justify-center rounded-md border border-dashed text-xs font-medium transition-colors duration-150",F?"border-foreground/30 bg-foreground/[0.04] text-foreground/80":"border-border bg-foreground/[0.02] text-muted-foreground"),children:F?C("Drop into {title}",{title:Q}):C("Drop here")}),U&&o.jsx("div",{ref:D?void 0:O,role:"group","aria-labelledby":te,className:"mt-0.5 flex flex-col gap-px px-2",children:n.map(Y=>{const G=c===Y.id,re=Y.projectId?l.find(ie=>ie.id===Y.projectId):void 0;return o.jsx(Fr,{selectedTaskId:c,selectionPath:f,expandForSelection:h===Y.id||f?.some(ie=>ie.parentTaskId===Y.id),onCreateSubtask:Y.projectArchivedAt?void 0:s,task:Y,status:r,isSelected:G,project:re,showProject:d,onSelectTask:i,onTaskStatusChange:Y.projectArchivedAt?void 0:g,onDeleteTask:Y.projectArchivedAt?void 0:x,onTaskPriorityChange:Y.projectArchivedAt?void 0:v,disableDrag:k},Y.id)})})]})}),Fi=12,_i=50;function Ui({isOpen:e,onClose:t,tasks:n,projects:r,onSelectTask:a}){const{t:c}=ze(),[h,f]=u.useState(""),[s,i]=u.useState(0),l=u.useRef(null);u.useEffect(()=>{e&&(f(""),i(0))},[e]);const d=u.useMemo(()=>{const g=h.trim().toLowerCase();return g?n.filter(x=>x.title.toLowerCase().includes(g)).slice(0,_i):n.slice(0,Fi)},[n,h]);u.useEffect(()=>{i(0)},[h]),u.useEffect(()=>{l.current?.children[s]?.scrollIntoView({block:"nearest"})},[s]);const m=u.useCallback(g=>{a(g),t()},[a,t]),p=u.useCallback(g=>{if(g.key==="Escape")g.preventDefault(),t();else if(g.key==="ArrowDown")g.preventDefault(),i(x=>Math.min(x+1,d.length-1));else if(g.key==="ArrowUp")g.preventDefault(),i(x=>Math.max(x-1,0));else if(g.key==="Enter"&&!g.nativeEvent.isComposing){g.preventDefault();const x=d[s];x&&m(x.id)}},[t,d,s,m]);return e?o.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[o.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:t}),o.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-popover overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[o.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[o.jsx(hr,{size:15,className:"text-muted-foreground/70 shrink-0"}),o.jsx("input",{value:h,onChange:g=>f(g.target.value),onKeyDown:p,placeholder:c("Search tasks..."),"aria-label":c("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),d.length>0?o.jsxs(o.Fragment,{children:[!h.trim()&&o.jsx("div",{className:"px-4 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",children:c("Recent tasks")}),o.jsx("div",{ref:l,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:d.map((g,x)=>{const v=r.find(y=>y.id===g.projectId),{icon:k,iconClass:C}=it[g.status];return o.jsxs("button",{onClick:()=>m(g.id),onMouseEnter:()=>i(x),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
7
|
-
${x===s?"bg-accent":""}`,children:[o.jsx(k,{className:`${C} size-4 shrink-0`}),o.jsxs("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:g.title,children:[g.title,g.parentTaskId&&o.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c("Parent task: {title}",{title:n.find(y=>y.id===g.parentTaskId)?.title??"…"})})]}),v&&o.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground",children:v.name})]},g.id)})})]}):o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:c("No matching tasks")})]})]}):null}const $i=260,Ki=220;function Gi(e){const t={[ne.Review]:[],[ne.Running]:[],[ne.Pending]:[],[ne.Done]:[],[ne.Cancelled]:[]};for(const n of e)t[n.status].push(n);return t[ne.Review].sort((n,r)=>(r.priority??Lt.NORMAL)-(n.priority??Lt.NORMAL)),t}const Wi=[{status:ne.Review,title:"Review",defaultOpen:!0},{status:ne.Running,title:"Running",defaultOpen:!0},{status:ne.Pending,title:"Pending",defaultOpen:!1},{status:ne.Done,title:"Done",defaultOpen:!1},{status:ne.Cancelled,title:"Cancelled",defaultOpen:!1}];function Qi(){return o.jsx("div",{className:"flex-1 overflow-hidden px-2 pt-3 motion-safe:animate-pulse","aria-hidden":!0,children:[3,4].map((e,t)=>o.jsxs("div",{className:"mb-4",children:[o.jsxs("div",{className:"flex h-8 items-center gap-2.5 px-2 pointer-coarse:h-10",children:[o.jsx("div",{className:"size-4 shrink-0 rounded-full bg-foreground/[0.06]"}),o.jsx("div",{className:"h-3 w-14 rounded-full bg-foreground/[0.06]"})]}),Array.from({length:e}).map((n,r)=>o.jsxs("div",{className:"flex h-8 items-center gap-2.5 px-2 pointer-coarse:h-10",children:[o.jsx("div",{className:"h-3 rounded-full bg-foreground/[0.06]",style:{width:`${64-(r+t)%3*14}%`}}),o.jsx("div",{className:"ml-auto h-2.5 w-8 shrink-0 rounded-full bg-foreground/[0.05]"})]},r))]},t))})}function Jn({tasks:e=[],projects:t=[],selectedTaskId:n,selectedParentTaskId:r,onCreateSubtask:a,onSelectTask:c,filterProjectId:h,setFilterProjectId:f,width:s=320,onCreateTask:i,onCreateProject:l,isCreateActive:d,onTaskStatusChange:m,onDeleteTask:p,onTaskPriorityChange:g,isLoading:x=!1}){const{t:v}=ze(),{preserveDesktopSearch:k}=cr(),C=Pr(),[y,A]=u.useState(null),[S,P]=u.useState(null),[D,j]=u.useState(!1),O=u.useRef(new Set),F=u.useRef(new Map),[L]=u.useState(()=>({registry:new Map})),Q=u.useCallback(E=>{E.remove(),O.current.delete(E)},[]),z=h?e.filter(E=>E.projectId===h):e,q=u.useCallback((E,w)=>{const R=document.querySelector(`[data-task-group-status="${E}"]`);if(!R)return null;const I=(R.querySelector("button")??R).getBoundingClientRect();return I.width===0||I.height===0?null:new DOMRect(I.left,I.bottom+2,w.width,w.height)},[]),te=u.useCallback((E,w,R,M=!1)=>{const I=document.createElement("div");I.setAttribute("aria-hidden","true"),I.innerHTML=R,I.querySelectorAll("[data-gradient-ready]").forEach(Be=>Be.removeAttribute("data-gradient-ready")),I.querySelectorAll(".task-gradient-text__canvas").forEach(Be=>Be.remove());const K=I.firstElementChild;K&&(K.style.cssText="",K.className=K.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),K.style.pointerEvents="none",K.style.width=`${E.width}px`,K.style.height=`${E.height}px`,K.style.margin="0",K.style.backgroundColor="var(--background)",K.style.borderRadius="0.5rem",K.style.boxShadow="var(--shadow-popover), 0 0 0 1px var(--border)",K.style.opacity="0.96",K.style.transition="none",K.setAttribute("tabindex","-1")),Object.assign(I.style,{position:"fixed",left:`${E.left}px`,top:`${E.top}px`,width:`${E.width}px`,height:`${E.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(I),O.current.add(I);const W=w.left-E.left,je=w.top-E.top;I.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${W}px, ${je}px)`,opacity:M?.12:.96,offset:1}],{duration:M?Ki:$i,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>Q(I),()=>Q(I))},[Q]);u.useLayoutEffect(()=>{const E=window.matchMedia("(prefers-reduced-motion: reduce)").matches,w=new Map;for(const R of z){const M=L.registry.get(R.id);if(!M)continue;const I={status:R.status,rect:M.getBoundingClientRect(),html:M.outerHTML};if(w.set(R.id,I),E)continue;const K=F.current.get(R.id);if(!K||K.status===R.status)continue;const W=I.rect.left-K.rect.left,je=I.rect.top-K.rect.top;Math.abs(W)<1&&Math.abs(je)<1||te(K.rect,I.rect,K.html)}if(!E)for(const[R,M]of F.current){if(w.has(R))continue;const I=z.find(W=>W.id===R);if(!I||I.status===M.status)continue;const K=q(I.status,M.rect);K&&te(M.rect,K,M.html,!0)}F.current=w},[z,te,q,L]),u.useEffect(()=>()=>{for(const E of O.current)E.remove();O.current.clear()},[]);const J=oo(so(Nn,{activationConstraint:{distance:8}})),U=u.useCallback(E=>{const w=E.active.data.current?.task,R=E.active.data.current?.fromStatus;w&&A(w),R&&P(R)},[]),Y=u.useCallback(E=>{A(null),P(null);const{active:w,over:R}=E;if(!R)return;const M=w.data.current?.task,I=w.data.current?.fromStatus,K=R.data.current?.status;!M||!I||!K||M.projectArchivedAt||I!==K&&m?.(M.id,K)},[m]),ie=!!!(h?t.find(E=>E.id===h)??null:null)?.archivedAt,H=e.find(E=>E.id===n),me=H?ur(H):[],xe=e.filter(E=>E.id===n||me.includes(E.id)||E.id===r),Me=Gi(z.filter(E=>!E.parentTaskId)),Z=y?it[y.status]:null,Ee=u.useCallback(E=>{if(E.key!=="ArrowDown"&&E.key!=="ArrowUp"||E.altKey||E.ctrlKey||E.metaKey||E.shiftKey)return;const w=Array.from(E.currentTarget.querySelectorAll("[data-sidebar-item]:not(:disabled)")),R=w.indexOf(E.target);R!==-1&&(E.preventDefault(),w[R+(E.key==="ArrowDown"?1:-1)]?.focus())},[]);return o.jsxs("div",{className:"@container h-full flex flex-col flex-shrink-0",style:{width:s},onKeyDown:Ee,children:[o.jsxs("div",{className:"px-2 pt-2 pb-1 flex flex-col gap-px flex-shrink-0",children:[l&&o.jsxs("button",{type:"button",onClick:l,"data-sidebar-item":"",className:bt(!1),children:[o.jsx(As,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:v("New Project")})]}),o.jsxs("button",{type:"button",onClick:i,disabled:!ie,"aria-current":d||void 0,"data-sidebar-item":"",className:ce(bt(!!d),"disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),title:ie?void 0:v("Deleted projects are read-only"),children:[o.jsx(Ts,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:v("New Task")})]}),o.jsxs("button",{type:"button",onClick:()=>j(!0),"data-sidebar-item":"",className:bt(!1),children:[o.jsx(hr,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:v("Search")})]}),o.jsxs(us,{to:k("/conversations"),"data-sidebar-item":"",className:bt(!1),children:[o.jsx(Ds,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:v("对话")})]})]}),x?o.jsx(Qi,{}):z.length===0?o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 pb-[10vh] text-center select-none",children:[o.jsx(dn,{size:36,"aria-hidden":"true",className:"text-muted-foreground/50 mb-3",strokeWidth:1.5}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:v("No tasks")}),ie&&i?o.jsx("button",{type:"button",onClick:i,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2",children:v("New Task")}):null]}):o.jsx(Br.Provider,{value:L,children:o.jsxs(ri,{sensors:J,onDragStart:U,onDragEnd:Y,children:[o.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin scroll-pt-8 pointer-coarse:scroll-pt-10 relative",children:o.jsx("div",{className:"pt-3 pb-4",children:Wi.map(({status:E,title:w,defaultOpen:R})=>o.jsx(Bi,{title:w,tasks:Me[E],status:E,defaultOpen:R,selectedTaskId:n,selectionPath:xe,selectedParentTaskId:r??e.find(M=>M.id===n)?.parentTaskId,onCreateSubtask:a,onSelectTask:c,projects:t,showProject:!h,isDragging:y!==null,dragFromStatus:S,onTaskStatusChange:m,onDeleteTask:p,onTaskPriorityChange:g,disableDrag:C},E))})}),o.jsx(Si,{dropAnimation:null,children:y&&Z?o.jsxs("div",{className:"flex h-8 w-fit max-w-[280px] items-center gap-2.5 rounded-md bg-background px-2 text-sm text-foreground shadow-overlay ring-1 ring-border/80",children:[o.jsx(Z.icon,{className:ce("size-4 shrink-0",Z.iconClass)}),o.jsx("span",{className:"truncate",title:y.title,children:y.title})]}):null})]})}),!x&&o.jsxs("div",{className:"h-9 px-4 flex flex-shrink-0 items-center justify-between border-t border-border/60 text-xs text-muted-foreground",children:[o.jsx("span",{className:"tabular-nums",children:v("{count} tasks",{count:z.length})}),h?o.jsx("button",{type:"button",onClick:()=>f(null),className:"rounded-sm hover:text-foreground underline decoration-border underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:v("Clear filter")}):null]}),o.jsx(Ui,{isOpen:D,onClose:()=>j(!1),tasks:z,projects:t,onSelectTask:c})]})}var Yi=Object.defineProperty,Gt=Object.getOwnPropertySymbols,_r=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?Yi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gn=(e,t)=>{for(var n in t||(t={}))_r.call(t,n)&&Zn(e,n,t[n]);if(Gt)for(var n of Gt(t))Ur.call(t,n)&&Zn(e,n,t[n]);return e},pn=(e,t)=>{var n={};for(var r in e)_r.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Gt)for(var r of Gt(e))t.indexOf(r)<0&&Ur.call(e,r)&&(n[r]=e[r]);return n};var qe;(e=>{const t=class ${constructor(s,i,l,d){if(this.version=s,this.errorCorrectionLevel=i,this.modules=[],this.isFunction=[],s<$.MIN_VERSION||s>$.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=s*4+17;let m=[];for(let g=0;g<this.size;g++)m.push(!1);for(let g=0;g<this.size;g++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(l);if(this.drawCodewords(p),d==-1){let g=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const v=this.getPenaltyScore();v<g&&(d=x,g=v),this.applyMask(x)}}a(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(s,i){const l=e.QrSegment.makeSegments(s);return $.encodeSegments(l,i)}static encodeBinary(s,i){const l=e.QrSegment.makeBytes(s);return $.encodeSegments([l],i)}static encodeSegments(s,i,l=1,d=40,m=-1,p=!0){if(!($.MIN_VERSION<=l&&l<=d&&d<=$.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,x;for(g=l;;g++){const y=$.getNumDataCodewords(g,i)*8,A=h.getTotalBits(s,g);if(A<=y){x=A;break}if(g>=d)throw new RangeError("Data too long")}for(const y of[$.Ecc.MEDIUM,$.Ecc.QUARTILE,$.Ecc.HIGH])p&&x<=$.getNumDataCodewords(g,y)*8&&(i=y);let v=[];for(const y of s){n(y.mode.modeBits,4,v),n(y.numChars,y.mode.numCharCountBits(g),v);for(const A of y.getData())v.push(A)}a(v.length==x);const k=$.getNumDataCodewords(g,i)*8;a(v.length<=k),n(0,Math.min(4,k-v.length),v),n(0,(8-v.length%8)%8,v),a(v.length%8==0);for(let y=236;v.length<k;y^=253)n(y,8,v);let C=[];for(;C.length*8<v.length;)C.push(0);return v.forEach((y,A)=>C[A>>>3]|=y<<7-(A&7)),new $(g,i,C,m)}getModule(s,i){return 0<=s&&s<this.size&&0<=i&&i<this.size&&this.modules[i][s]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const s=this.getAlignmentPatternPositions(),i=s.length;for(let l=0;l<i;l++)for(let d=0;d<i;d++)l==0&&d==0||l==0&&d==i-1||l==i-1&&d==0||this.drawAlignmentPattern(s[l],s[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(s){const i=this.errorCorrectionLevel.formatBits<<3|s;let l=i;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const d=(i<<10|l)^21522;a(d>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,r(d,m));this.setFunctionModule(8,7,r(d,6)),this.setFunctionModule(8,8,r(d,7)),this.setFunctionModule(7,8,r(d,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,r(d,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,r(d,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,r(d,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let s=this.version;for(let l=0;l<12;l++)s=s<<1^(s>>>11)*7973;const i=this.version<<12|s;a(i>>>18==0);for(let l=0;l<18;l++){const d=r(i,l),m=this.size-11+l%3,p=Math.floor(l/3);this.setFunctionModule(m,p,d),this.setFunctionModule(p,m,d)}}drawFinderPattern(s,i){for(let l=-4;l<=4;l++)for(let d=-4;d<=4;d++){const m=Math.max(Math.abs(d),Math.abs(l)),p=s+d,g=i+l;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,m!=2&&m!=4)}}drawAlignmentPattern(s,i){for(let l=-2;l<=2;l++)for(let d=-2;d<=2;d++)this.setFunctionModule(s+d,i+l,Math.max(Math.abs(d),Math.abs(l))!=1)}setFunctionModule(s,i,l){this.modules[i][s]=l,this.isFunction[i][s]=!0}addEccAndInterleave(s){const i=this.version,l=this.errorCorrectionLevel;if(s.length!=$.getNumDataCodewords(i,l))throw new RangeError("Invalid argument");const d=$.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i],m=$.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i],p=Math.floor($.getNumRawDataModules(i)/8),g=d-p%d,x=Math.floor(p/d);let v=[];const k=$.reedSolomonComputeDivisor(m);for(let y=0,A=0;y<d;y++){let S=s.slice(A,A+x-m+(y<g?0:1));A+=S.length;const P=$.reedSolomonComputeRemainder(S,k);y<g&&S.push(0),v.push(S.concat(P))}let C=[];for(let y=0;y<v[0].length;y++)v.forEach((A,S)=>{(y!=x-m||S>=g)&&C.push(A[y])});return a(C.length==p),C}drawCodewords(s){if(s.length!=Math.floor($.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let i=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let d=0;d<this.size;d++)for(let m=0;m<2;m++){const p=l-m,x=(l+1&2)==0?this.size-1-d:d;!this.isFunction[x][p]&&i<s.length*8&&(this.modules[x][p]=r(s[i>>>3],7-(i&7)),i++)}}a(i==s.length*8)}applyMask(s){if(s<0||s>7)throw new RangeError("Mask value out of range");for(let i=0;i<this.size;i++)for(let l=0;l<this.size;l++){let d;switch(s){case 0:d=(l+i)%2==0;break;case 1:d=i%2==0;break;case 2:d=l%3==0;break;case 3:d=(l+i)%3==0;break;case 4:d=(Math.floor(l/3)+Math.floor(i/2))%2==0;break;case 5:d=l*i%2+l*i%3==0;break;case 6:d=(l*i%2+l*i%3)%2==0;break;case 7:d=((l+i)%2+l*i%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[i][l]&&d&&(this.modules[i][l]=!this.modules[i][l])}}getPenaltyScore(){let s=0;for(let m=0;m<this.size;m++){let p=!1,g=0,x=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[m][v]==p?(g++,g==5?s+=$.PENALTY_N1:g>5&&s++):(this.finderPenaltyAddHistory(g,x),p||(s+=this.finderPenaltyCountPatterns(x)*$.PENALTY_N3),p=this.modules[m][v],g=1);s+=this.finderPenaltyTerminateAndCount(p,g,x)*$.PENALTY_N3}for(let m=0;m<this.size;m++){let p=!1,g=0,x=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[v][m]==p?(g++,g==5?s+=$.PENALTY_N1:g>5&&s++):(this.finderPenaltyAddHistory(g,x),p||(s+=this.finderPenaltyCountPatterns(x)*$.PENALTY_N3),p=this.modules[v][m],g=1);s+=this.finderPenaltyTerminateAndCount(p,g,x)*$.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let p=0;p<this.size-1;p++){const g=this.modules[m][p];g==this.modules[m][p+1]&&g==this.modules[m+1][p]&&g==this.modules[m+1][p+1]&&(s+=$.PENALTY_N2)}let i=0;for(const m of this.modules)i=m.reduce((p,g)=>p+(g?1:0),i);const l=this.size*this.size,d=Math.ceil(Math.abs(i*20-l*10)/l)-1;return a(0<=d&&d<=9),s+=d*$.PENALTY_N4,a(0<=s&&s<=2568888),s}getAlignmentPatternPositions(){if(this.version==1)return[];{const s=Math.floor(this.version/7)+2,i=this.version==32?26:Math.ceil((this.version*4+4)/(s*2-2))*2;let l=[6];for(let d=this.size-7;l.length<s;d-=i)l.splice(1,0,d);return l}}static getNumRawDataModules(s){if(s<$.MIN_VERSION||s>$.MAX_VERSION)throw new RangeError("Version number out of range");let i=(16*s+128)*s+64;if(s>=2){const l=Math.floor(s/7)+2;i-=(25*l-10)*l-55,s>=7&&(i-=36)}return a(208<=i&&i<=29648),i}static getNumDataCodewords(s,i){return Math.floor($.getNumRawDataModules(s)/8)-$.ECC_CODEWORDS_PER_BLOCK[i.ordinal][s]*$.NUM_ERROR_CORRECTION_BLOCKS[i.ordinal][s]}static reedSolomonComputeDivisor(s){if(s<1||s>255)throw new RangeError("Degree out of range");let i=[];for(let d=0;d<s-1;d++)i.push(0);i.push(1);let l=1;for(let d=0;d<s;d++){for(let m=0;m<i.length;m++)i[m]=$.reedSolomonMultiply(i[m],l),m+1<i.length&&(i[m]^=i[m+1]);l=$.reedSolomonMultiply(l,2)}return i}static reedSolomonComputeRemainder(s,i){let l=i.map(d=>0);for(const d of s){const m=d^l.shift();l.push(0),i.forEach((p,g)=>l[g]^=$.reedSolomonMultiply(p,m))}return l}static reedSolomonMultiply(s,i){if(s>>>8||i>>>8)throw new RangeError("Byte out of range");let l=0;for(let d=7;d>=0;d--)l=l<<1^(l>>>7)*285,l^=(i>>>d&1)*s;return a(l>>>8==0),l}finderPenaltyCountPatterns(s){const i=s[1];a(i<=this.size*3);const l=i>0&&s[2]==i&&s[3]==i*3&&s[4]==i&&s[5]==i;return(l&&s[0]>=i*4&&s[6]>=i?1:0)+(l&&s[6]>=i*4&&s[0]>=i?1:0)}finderPenaltyTerminateAndCount(s,i,l){return s&&(this.finderPenaltyAddHistory(i,l),i=0),i+=this.size,this.finderPenaltyAddHistory(i,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(s,i){i[0]==0&&(s+=this.size),i.pop(),i.unshift(s)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(f,s,i){if(s<0||s>31||f>>>s)throw new RangeError("Value out of range");for(let l=s-1;l>=0;l--)i.push(f>>>l&1)}function r(f,s){return(f>>>s&1)!=0}function a(f){if(!f)throw new Error("Assertion error")}const c=class oe{constructor(s,i,l){if(this.mode=s,this.numChars=i,this.bitData=l,i<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(s){let i=[];for(const l of s)n(l,8,i);return new oe(oe.Mode.BYTE,s.length,i)}static makeNumeric(s){if(!oe.isNumeric(s))throw new RangeError("String contains non-numeric characters");let i=[];for(let l=0;l<s.length;){const d=Math.min(s.length-l,3);n(parseInt(s.substring(l,l+d),10),d*3+1,i),l+=d}return new oe(oe.Mode.NUMERIC,s.length,i)}static makeAlphanumeric(s){if(!oe.isAlphanumeric(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");let i=[],l;for(l=0;l+2<=s.length;l+=2){let d=oe.ALPHANUMERIC_CHARSET.indexOf(s.charAt(l))*45;d+=oe.ALPHANUMERIC_CHARSET.indexOf(s.charAt(l+1)),n(d,11,i)}return l<s.length&&n(oe.ALPHANUMERIC_CHARSET.indexOf(s.charAt(l)),6,i),new oe(oe.Mode.ALPHANUMERIC,s.length,i)}static makeSegments(s){return s==""?[]:oe.isNumeric(s)?[oe.makeNumeric(s)]:oe.isAlphanumeric(s)?[oe.makeAlphanumeric(s)]:[oe.makeBytes(oe.toUtf8ByteArray(s))]}static makeEci(s){let i=[];if(s<0)throw new RangeError("ECI assignment value out of range");if(s<128)n(s,8,i);else if(s<16384)n(2,2,i),n(s,14,i);else if(s<1e6)n(6,3,i),n(s,21,i);else throw new RangeError("ECI assignment value out of range");return new oe(oe.Mode.ECI,0,i)}static isNumeric(s){return oe.NUMERIC_REGEX.test(s)}static isAlphanumeric(s){return oe.ALPHANUMERIC_REGEX.test(s)}getData(){return this.bitData.slice()}static getTotalBits(s,i){let l=0;for(const d of s){const m=d.mode.numCharCountBits(i);if(d.numChars>=1<<m)return 1/0;l+=4+m+d.bitData.length}return l}static toUtf8ByteArray(s){s=encodeURI(s);let i=[];for(let l=0;l<s.length;l++)s.charAt(l)!="%"?i.push(s.charCodeAt(l)):(i.push(parseInt(s.substring(l+1,l+3),16)),l+=2);return i}};c.NUMERIC_REGEX=/^[0-9]*$/,c.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,c.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let h=c;e.QrSegment=c})(qe||(qe={}));(e=>{(t=>{const n=class{constructor(a,c){this.ordinal=a,this.formatBits=c}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(qe||(qe={}));(e=>{(t=>{const n=class{constructor(a,c){this.modeBits=a,this.numBitsCharCount=c}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(qe||(qe={}));var ot=qe;var Hi={L:ot.QrCode.Ecc.LOW,M:ot.QrCode.Ecc.MEDIUM,Q:ot.QrCode.Ecc.QUARTILE,H:ot.QrCode.Ecc.HIGH},$r=128,Kr="L",Gr="#FFFFFF",Wr="#000000",Qr=!1,Yr=1,Xi=4,qi=0,Vi=.1;function Hr(e,t=0){const n=[];return e.forEach(function(r,a){let c=null;r.forEach(function(h,f){if(!h&&c!==null){n.push(`M${c+t} ${a+t}h${f-c}v1H${c+t}z`),c=null;return}if(f===r.length-1){if(!h)return;c===null?n.push(`M${f+t},${a+t} h1v1H${f+t}z`):n.push(`M${c+t},${a+t} h${f+1-c}v1H${c+t}z`);return}h&&c===null&&(c=f)})}),n.join("")}function Xr(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((a,c)=>c<t.x||c>=t.x+t.w?a:!1))}function Ji(e,t,n,r){if(r==null)return null;const a=e.length+n*2,c=Math.floor(t*Vi),h=a/t,f=(r.width||c)*h,s=(r.height||c)*h,i=r.x==null?e.length/2-f/2:r.x*h,l=r.y==null?e.length/2-s/2:r.y*h,d=r.opacity==null?1:r.opacity;let m=null;if(r.excavate){let g=Math.floor(i),x=Math.floor(l),v=Math.ceil(f+i-g),k=Math.ceil(s+l-x);m={x:g,y:x,w:v,h:k}}const p=r.crossOrigin;return{x:i,y:l,h:s,w:f,excavation:m,opacity:d,crossOrigin:p}}function Zi(e,t){return t!=null?Math.max(Math.floor(t),0):e?Xi:qi}function qr({value:e,level:t,minVersion:n,includeMargin:r,marginSize:a,imageSettings:c,size:h,boostLevel:f}){let s=_.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((x,v)=>(x.push(...ot.QrSegment.makeSegments(v)),x),[]);return ot.QrCode.encodeSegments(g,Hi[t],n,void 0,void 0,f)},[e,t,n,f]);const{cells:i,margin:l,numCells:d,calculatedImageSettings:m}=_.useMemo(()=>{let p=s.getModules();const g=Zi(r,a),x=p.length+g*2,v=Ji(p,h,g,c);return{cells:p,margin:g,numCells:x,calculatedImageSettings:v}},[s,h,c,r,a]);return{qrcode:s,margin:l,cells:i,numCells:d,calculatedImageSettings:m}}var ea=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ta=_.forwardRef(function(t,n){const r=t,{value:a,size:c=$r,level:h=Kr,bgColor:f=Gr,fgColor:s=Wr,includeMargin:i=Qr,minVersion:l=Yr,boostLevel:d,marginSize:m,imageSettings:p}=r,x=pn(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=x,k=pn(x,["style"]),C=p?.src,y=_.useRef(null),A=_.useRef(null),S=_.useCallback(q=>{y.current=q,typeof n=="function"?n(q):n&&(n.current=q)},[n]),[P,D]=_.useState(!1),{margin:j,cells:O,numCells:F,calculatedImageSettings:L}=qr({value:a,level:h,minVersion:l,boostLevel:d,includeMargin:i,marginSize:m,imageSettings:p,size:c});_.useEffect(()=>{if(y.current!=null){const q=y.current,te=q.getContext("2d");if(!te)return;let J=O;const U=A.current,Y=L!=null&&U!==null&&U.complete&&U.naturalHeight!==0&&U.naturalWidth!==0;Y&&L.excavation!=null&&(J=Xr(O,L.excavation));const G=window.devicePixelRatio||1;q.height=q.width=c*G;const re=c/F*G;te.scale(re,re),te.fillStyle=f,te.fillRect(0,0,F,F),te.fillStyle=s,ea?te.fill(new Path2D(Hr(J,j))):O.forEach(function(ie,H){ie.forEach(function(me,xe){me&&te.fillRect(xe+j,H+j,1,1)})}),L&&(te.globalAlpha=L.opacity),Y&&te.drawImage(U,L.x+j,L.y+j,L.w,L.h)}}),_.useEffect(()=>{D(!1)},[C]);const Q=gn({height:c,width:c},v);let z=null;return C!=null&&(z=_.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{D(!0)},ref:A,crossOrigin:L?.crossOrigin})),_.createElement(_.Fragment,null,_.createElement("canvas",gn({style:Q,height:c,width:c,ref:S,role:"img"},k)),z)});ta.displayName="QRCodeCanvas";var Vr=_.forwardRef(function(t,n){const r=t,{value:a,size:c=$r,level:h=Kr,bgColor:f=Gr,fgColor:s=Wr,includeMargin:i=Qr,minVersion:l=Yr,boostLevel:d,title:m,marginSize:p,imageSettings:g}=r,x=pn(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:v,cells:k,numCells:C,calculatedImageSettings:y}=qr({value:a,level:h,minVersion:l,boostLevel:d,includeMargin:i,marginSize:p,imageSettings:g,size:c});let A=k,S=null;g!=null&&y!=null&&(y.excavation!=null&&(A=Xr(k,y.excavation)),S=_.createElement("image",{href:g.src,height:y.h,width:y.w,x:y.x+v,y:y.y+v,preserveAspectRatio:"none",opacity:y.opacity,crossOrigin:y.crossOrigin}));const P=Hr(A,v);return _.createElement("svg",gn({height:c,width:c,viewBox:`0 0 ${C} ${C}`,ref:n,role:"img"},x),!!m&&_.createElement("title",null,m),_.createElement("path",{fill:f,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),_.createElement("path",{fill:s,d:P,shapeRendering:"crispEdges"}),S)});Vr.displayName="QRCodeSVG";function Jr(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function na(){return ds({queryKey:fe.tunnel.status,queryFn:()=>Ue.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function ra(){const e=Wt();return vn({mutationFn:()=>Ue.post("/tunnel/start",{port:Jr()}),onSuccess:()=>{e.invalidateQueries({queryKey:fe.tunnel.status})}})}function sa(){const e=Wt();return vn({mutationFn:()=>Ue.post("/tunnel/regenerate",{port:Jr()}),onSuccess:()=>{e.invalidateQueries({queryKey:fe.tunnel.status})}})}function oa(){const e=Wt();return vn({mutationFn:()=>Ue.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:fe.tunnel.status})}})}function ia(e){if(!e||e.status==="stopped")return{button:"text-muted-foreground hover:text-foreground hover:bg-accent",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-success-ink hover:bg-success/10",dot:"bg-success",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-warning-ink hover:bg-warning/10",dot:"bg-warning",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-destructive-ink hover:bg-destructive/10",dot:"bg-destructive",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-warning-ink hover:bg-warning/10",dot:"bg-warning",label:"Tunnel starting",icon:"loading"}}}function aa(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function la(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function er(e){if(!e)return"Never";const t=new Date(e).getTime();if(!Number.isFinite(t))return e;const n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r}m ago`;const a=Math.round(r/60);return a<24?`${a}h ago`:`${Math.round(a/24)}d ago`}function gt(e){const t=e?.trim();return t||null}function ca(e){if(!e)return"";const t=[gt(e.lastLocalError),gt(e.lastRemoteError),gt(e.lastError)].filter(a=>a!==null),n=gt(e.lastProcessOutput),r=!!n&&(e.status==="error"||e.status==="exited"||!!gt(e.lastError));return n&&r&&t.push(n),t.join(`
|
|
8
|
-
`)}function tr(){const{t:e}=ze(),{data:t}=na(),n=ra(),r=oa(),a=sa(),[c,h]=u.useState(!1),[f,s]=u.useState(null),[i,l]=u.useState(!1),[d,m]=u.useState(!1),p=t?.status!==void 0&&t.status!=="stopped",g=n.isPending||t?.status==="starting",x=a.isPending,v=t?.shareableUrl,k=t?.token,C=ia(t),y=aa(t),A=ca(t),S=t?.status==="healthy"||t?.status==="checking"?"text-success-ink":t?.status==="exited"||t?.status==="error"?"text-destructive-ink":"text-warning-ink",P=u.useCallback(()=>{n.mutate(void 0,{onSuccess:()=>h(!0)})},[n]),D=u.useCallback(()=>{v&&(navigator.clipboard.writeText(v),s("url"),setTimeout(()=>s(null),2e3))},[v]),j=u.useCallback(()=>{k&&(navigator.clipboard.writeText(k),s("token"),setTimeout(()=>s(null),2e3))},[k]),O=u.useCallback(()=>{r.mutate(),h(!1),l(!1),m(!1)},[r]),F=u.useCallback(()=>{a.mutate(void 0,{onSuccess:()=>{m(!1),h(!0)}})},[a]),L=o.jsx(Is,{asChild:!0,children:o.jsx(nn,{size:"xs",label:e("Close"),className:"-mr-1 -mt-0.5 shrink-0",children:o.jsx(fs,{})})});return o.jsxs(Ms,{open:c,onOpenChange:h,children:[o.jsxs("div",{className:"relative",children:[o.jsx(Ps,{asChild:!0,children:o.jsx("button",{type:"button",disabled:g,className:ce("p-1.5 rounded-md transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/60",C.button),title:e(C.label),"aria-label":e(C.label),children:g?o.jsx(hs,{size:"md"}):C.icon==="warn"?o.jsx(ms,{size:16}):o.jsx(zn,{size:16})})}),p&&!g&&o.jsx("span",{className:`pointer-events-none absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`})]}),o.jsx(Os,{align:"end",className:ce("max-w-[calc(100vw-1rem)]",p?"w-96":"w-80"),children:p?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("span",{className:ce("flex items-center gap-1.5 text-xs font-medium",S),children:[o.jsx("span",{className:`inline-block w-1.5 h-1.5 ${C.dot} rounded-full`}),e(y)]}),o.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e(la(t))})]}),L]}),k&&o.jsxs("div",{className:"mb-2 flex items-center gap-1.5 rounded-md bg-muted/50 px-2 py-1 text-xs text-foreground/80",children:[o.jsx(js,{size:12}),o.jsx("span",{children:e("Token protected")})]}),v&&o.jsx("div",{className:"flex justify-center py-3",children:o.jsx(Vr,{value:v,size:160})}),v||t?.url?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ls,{size:"sm",readOnly:!0,value:v??t?.url??"",onFocus:Q=>Q.target.select(),"aria-label":e("Copy shareable link"),className:"select-all text-xs"}),o.jsx(nn,{size:"sm",label:e("Copy shareable link"),onClick:D,disabled:!v,children:f==="url"?o.jsx(Ct,{className:"text-success"}):o.jsx(On,{})})]}):o.jsx("div",{className:"rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs text-muted-foreground",children:e("No tunnel link available")}),o.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[o.jsxs("div",{className:"rounded-md border border-border px-2 py-1.5",children:[o.jsx("div",{className:"text-muted-foreground",children:e("Last checked")}),o.jsx("div",{className:"mt-0.5 text-foreground",children:er(t?.lastCheckedAt)})]}),o.jsxs("div",{className:"rounded-md border border-border px-2 py-1.5",children:[o.jsx("div",{className:"text-muted-foreground",children:e("Last healthy")}),o.jsx("div",{className:"mt-0.5 text-foreground",children:er(t?.lastHealthyAt)})]})]}),A&&o.jsx(Pt,{tone:"warning",size:"sm",className:"mt-2 max-h-28 overflow-auto",children:o.jsx("div",{className:"whitespace-pre-wrap break-words",children:A})}),t?.status==="degraded"&&o.jsx(Pt,{tone:"warning",size:"sm",className:"mt-2",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),t?.status==="linkReplaced"&&o.jsx(Pt,{tone:"warning",size:"sm",className:"mt-2",children:e("The previous tunnel link and token are no longer valid.")}),k&&o.jsxs("div",{className:"mt-2",children:[o.jsx("button",{type:"button",onClick:()=>l(!i),className:"rounded-sm text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e(i?"Hide token":"Show token")}),i&&o.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 min-w-0 break-all rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs text-foreground/80",children:k}),o.jsx(nn,{size:"sm",label:e("Copy token"),onClick:j,className:"shrink-0",children:f==="token"?o.jsx(Ct,{className:"text-success"}):o.jsx(On,{})})]})]}),d?o.jsxs(Pt,{tone:"danger",size:"sm",className:"mt-3",children:[e("Generating a new link will invalidate the current link. People using the old URL must receive the new one."),o.jsxs("div",{className:"mt-2 flex gap-2",children:[o.jsx(De,{variant:"secondary",size:"xs",className:"flex-1",onClick:()=>m(!1),children:e("Cancel")}),o.jsx(De,{variant:"primary",tone:"danger",size:"xs",className:"flex-1",onClick:F,loading:x,children:e(x?"Generating...":"Regenerate link")})]})]}):o.jsxs(De,{variant:"ghost",size:"sm",block:!0,className:"mt-3",onClick:()=>m(!0),disabled:x||t?.canRegenerate===!1,children:[o.jsx(gs,{}),e("Regenerate link")]}),o.jsx(De,{variant:"ghost",tone:"danger",size:"sm",block:!0,className:"mt-1",onClick:O,loading:r.isPending,children:r.isPending?e("Stopping..."):e("Stop Tunnel")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-foreground/80",children:o.jsx(zn,{size:16})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:e("Use Agent Tower on your phone")}),o.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),L]}),o.jsx(De,{variant:"primary",size:"sm",block:!0,className:"mt-3",onClick:P,loading:g,children:e(g?"Starting tunnel...":"Enable phone access")})]})})]})}function un({isOpen:e,onClose:t}){const{t:n}=ze(),r=Ss(),[a,c]=u.useState(""),[h,f]=u.useState(""),[s,i]=u.useState(null),[l,d]=u.useState(!1),[m,p]=u.useState(!1),g=a.trim(),x=h.trim(),v=l||r.isPending,k=u.useMemo(()=>!!(g&&x&&!v),[g,x,v]),C=u.useCallback(()=>{c(""),f(""),i(null),p(!1)},[]),y=u.useCallback(()=>{v||(C(),t())},[v,t,C]);u.useEffect(()=>{e||C()},[e,C]);const A=u.useCallback(async j=>{try{await r.mutateAsync({name:g,repoPath:x,initEmptyRepo:j}),C(),t()}catch(O){const F=O instanceof Error?O.message:n("Failed to create project");i(F),Oe.error(F)}},[r,t,C,n,g,x]),S=u.useCallback(async()=>{if(!(!g||!x||v)){i(null),d(!0);try{const j=await Ue.get("/filesystem/validate",{params:{path:x}});if(!j.valid){i(j.error??n("Selected path is not a valid directory"));return}if(j.isGitRepo){await A(!1);return}if(j.reason==="no_git"&&j.isEmpty){p(!0);return}if(j.reason==="no_git"){await A(!1);return}await A(!1)}catch(j){i(j instanceof Error?j.message:n("Could not check project path"))}finally{d(!1)}}},[A,v,n,g,x]),P=u.useCallback(()=>{p(!1),A(!1)},[A]),D=u.useCallback(()=>{p(!1),A(!0)},[A]);return o.jsxs(o.Fragment,{children:[o.jsx(Ln,{isOpen:e,onClose:y,title:n("Create New Project"),action:o.jsxs(o.Fragment,{children:[o.jsx(De,{onClick:y,disabled:v,children:n("Cancel")}),o.jsx(De,{variant:"primary",onClick:S,disabled:!k,children:l?n("Checking..."):r.isPending?n("Creating..."):n("Create Project")})]}),children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-1.5",children:n("Project Name")}),o.jsx("input",{type:"text",value:a,onChange:j=>c(j.target.value),placeholder:n("e.g., Agent Tower"),disabled:v,className:"w-full px-3 py-2 border border-border rounded-lg text-sm focus:outline-none focus:border-ring transition-colors disabled:bg-muted/50 disabled:text-muted-foreground",autoFocus:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-1.5",children:n("Project Path")}),o.jsx(Fs,{value:h,onChange:f,validationMode:"directory"})]}),s&&o.jsx("p",{className:"text-xs text-destructive-ink leading-relaxed",children:s})]})}),o.jsx(Ln,{isOpen:m,onClose:()=>{r.isPending||p(!1)},title:n("Initialize Git repository?"),action:o.jsxs(o.Fragment,{children:[o.jsx(De,{onClick:()=>p(!1),disabled:r.isPending,children:n("Cancel")}),o.jsx(De,{onClick:P,disabled:r.isPending,children:n("Create Local Project")}),o.jsx(De,{variant:"primary",onClick:D,disabled:r.isPending,children:r.isPending?n("Creating..."):n("Initialize and Create")})]}),children:o.jsxs("div",{className:"space-y-3 text-sm text-foreground/70 leading-relaxed",children:[o.jsx("p",{children:n("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),o.jsx("p",{children:n("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function nr(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function ua(e){return e.map((t,n)=>({project:t,index:n,activityTime:nr(t.lastActivityAt??t.createdAt),createdTime:nr(t.createdAt)})).sort((t,n)=>{const r=n.activityTime-t.activityTime;if(r!==0)return r;const a=n.createdTime-t.createdTime;return a!==0?a:t.index-n.index}).map(({project:t})=>t)}const Zr="providerLastUsedAt";function da(){const e={};try{const t=localStorage.getItem(Zr),n=t?JSON.parse(t):{};if(n&&typeof n=="object"&&!Array.isArray(n))for(const[r,a]of Object.entries(n))typeof a=="number"&&Number.isFinite(a)&&a>0&&(e[r]=a)}catch{}try{const t=localStorage.getItem("lastSelectedProviderId");t&&Object.keys(e).length===0&&(e[t]=1)}catch{}return e}function fa(e){try{localStorage.setItem(Zr,JSON.stringify(e))}catch{}}const ha=u.lazy(()=>dr(()=>import("./TaskDetail-DBtWf0YV.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(e=>({default:e.TaskDetail}))),ma=u.lazy(()=>dr(()=>import("./MobileTaskDetail-B68iYPOI.js"),__vite__mapDeps([56,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(e=>({default:e.MobileTaskDetail})));function rr(){const{t:e}=ze();return o.jsx("div",{role:"status",className:"flex flex-1 items-center justify-center bg-background p-4 text-sm text-muted-foreground",children:e("Loading...")})}function sr({projects:e,filterProjectId:t,setFilterProjectId:n,onCreateProject:r,className:a}){const{t:c}=ze(),[h,f]=u.useState(!1),s=e.filter(l=>!l.archivedAt),i=t?e.find(l=>l.id===t)??null:null;return o.jsxs("div",{className:ce("relative flex items-center min-w-0",a),children:[o.jsx("span",{className:"mx-1.5 text-muted-foreground select-none",children:"/"}),o.jsxs("button",{onClick:()=>f(l=>!l),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[i?o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${i.color.replace("text-","bg-")}`}):o.jsx(dn,{size:13,className:"text-muted-foreground shrink-0"}),o.jsx("span",{className:"truncate max-w-[200px] font-medium",children:i?i.name:c("All Projects")}),o.jsx(_s,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${h?"rotate-180":""}`})]}),h?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>f(!1)}),o.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-popover shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[o.jsxs("button",{onClick:()=>{n(null),f(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[o.jsx(dn,{size:13,className:"text-muted-foreground shrink-0"}),o.jsx("span",{className:`flex-1 truncate ${t===null?"text-foreground font-medium":"text-muted-foreground"}`,children:c("All Projects")}),t===null?o.jsx(Ct,{size:14,className:"text-foreground shrink-0"}):null]}),o.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),o.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:s.map(l=>{const d=t===l.id;return o.jsxs("button",{onClick:()=>{n(l.id),f(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}),o.jsx("span",{className:`flex-1 truncate ${d?"text-foreground font-medium":"text-muted-foreground"}`,children:l.name}),d?o.jsx(Ct,{size:14,className:"text-foreground shrink-0"}):null]},l.id)})}),o.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),o.jsxs("button",{onClick:()=>{f(!1),r()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[o.jsx(fr,{size:13}),o.jsx("span",{children:c("Create New Project...")})]})]})]}):null]})}const ga=260,pa=600,or=400,va=100,ba=1e3;function ir(e){const t=e.workspaces?.find(r=>r.status==="ACTIVE")??e.workspaces?.[0],n=t?.sessions?.at(-1);return{id:e.id,parentTaskId:e.parentTaskId,ancestorIds:e.ancestorIds,subtaskCount:e.subtaskCount,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,priority:e.priority,...t?{preferredWorkspace:{...t.workspaceKind===Xe.MAIN_DIRECTORY?{workspaceKind:Xe.MAIN_DIRECTORY}:{},branchName:t.branchName}}:{},...n?{latestAgentType:n.agentType}:{},...e.workspaces?.some(r=>r.sessions?.some(a=>a.status==="RUNNING"||a.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function xa(){const{t:e,locale:t}=ze(),[n,r]=u.useState(void 0),a=u.useRef(0),[c,h]=u.useState(null),[f,s]=u.useState(null),[i,l]=u.useState(or),[d,m]=u.useState(!1),[p,g]=u.useState("idle"),[x,v]=u.useState({}),k=u.useRef(!1),C=u.useRef(0),y=u.useRef(or),A=u.useRef(null),S=Wt(),{data:P,isLoading:D}=zs(),[j,O]=u.useState(da),{data:F,isLoading:L}=Ns({limit:va}),Q=u.useMemo(()=>F?.data??[],[F?.data]),z=f&&Q.some(b=>b.id===f)?f:null,{data:q,isLoading:te}=ps({...z?{projectId:z}:{},limit:ba}),J=u.useMemo(()=>[...q?.data??[],...q?.parents??[]],[q]),[U,Y]=u.useState([]),G=u.useMemo(()=>{if(U.length===0)return J;const b=new Set(J.map(N=>N.id));return[...U.filter(N=>!b.has(N.id)),...J]},[J,U]),[re,ie]=u.useState(null),H=en(c&&!G.some(b=>b.id===c)?c:""),me=G.find(b=>b.id===c)??H.data,xe=u.useMemo(()=>me?ur(me):[],[me]),Me=b=>{const N=xe[b];return N&&!G.some(T=>T.id===N)?N:""},Z=en(Me(0)),Ee=en(Me(1)),E=u.useMemo(()=>c&&G.some(b=>b.id===c)?c:re&&c===re?re:c&&(H.isLoading||H.data&&(!z||H.data.projectId===z))?c:null,[c,G,re,H.data,H.isLoading,z]);u.useEffect(()=>{re&&G.some(b=>b.id===re)&&ie(null)},[re,G]),u.useEffect(()=>{if(U.length===0)return;const b=new Set(J.map(N=>N.id));U.some(N=>b.has(N.id))&&Y(N=>N.filter(T=>!b.has(T.id)))},[J,U]);const w=u.useMemo(()=>ua(Q),[Q]),R=u.useMemo(()=>w.map(Ti),[w]),M=u.useMemo(()=>w.filter(b=>!b.archivedAt),[w]),I=u.useMemo(()=>P?P.filter(Bs).sort((b,N)=>{const T=!mt(b),B=!mt(N);return T!==B?T?-1:1:(j[N.provider.id]??0)-(j[b.provider.id]??0)}):[],[P,j]),K=u.useMemo(()=>{const b=G.map(N=>zr(N,Q.find(T=>T.id===N.projectId)));H.data&&E===H.data.id&&!b.some(N=>N.id===H.data.id)&&b.push(qn(H.data));for(const N of[Z.data,Ee.data])N&&xe.includes(N.id)&&!b.some(T=>T.id===N.id)&&b.push(qn(N));return b},[Q,G,H.data,E,Z.data,Ee.data,xe]),W=u.useMemo(()=>{if(!E)return null;const b=G.find(T=>T.id===E)??(H.data?ir(H.data):void 0);if(!b)return null;const N=Q.find(T=>T.id===b.projectId);if(!N){const T=b.preferredWorkspace?b.preferredWorkspace.workspaceKind===Xe.MAIN_DIRECTORY?"Project directory":b.preferredWorkspace.branchName:"—";return{id:b.id,parentTaskId:b.parentTaskId,ancestorIds:b.ancestorIds,subtaskCount:b.subtaskCount,projectId:b.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:b.title,status:Vt(b.status),priority:b.priority,branch:T,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return Ii(b,N)},[E,G,Q,H.data]),je=vs(),Ce=bs(),Be=xs(),ut=ys(),Ve=ks(),we=u.useCallback(b=>{const N=ir(b);Y(T=>T.some(B=>B.id===b.id)?T.map(B=>B.id===b.id?N:B):[N,...T]),S.setQueryData(fe.tasks.detail(b.id),b),ie(b.id),h(b.id)},[S]),Qe=u.useCallback((b,N,T)=>{const B=b.id,se=[b.title,b.description].filter(Boolean).join(`
|
|
9
|
-
|
|
10
|
-
`),X=T===Xe.WORKTREE?M.find(ee=>ee.id===b.projectId)?.setupScript??null:null;v(ee=>({...ee,[B]:{status:"creating-workspace",setupScript:X}})),(async()=>{try{await Gs(B,{providerId:N,prompt:se,workspaceKind:T},{createWorkspace:ee=>Ue.post(`/tasks/${B}/workspaces`,{clientSubmissionId:ee,workspaceKind:T}),startSession:ee=>Ve.mutateAsync(ee),onStep:ee=>v(Se=>({...Se,[B]:{status:ee,setupScript:X}}))}),await S.invalidateQueries({queryKey:fe.workspaces.list(B)}),await S.invalidateQueries({queryKey:fe.workspaces.setupProgress(B)}),await S.invalidateQueries({queryKey:fe.tasks.all}),v(ee=>{const Se={...ee};return delete Se[B],Se})}catch(ee){const Se=ee instanceof Error?ee.message:e("启动 Agent 失败");v(Mt=>({...Mt,[B]:{status:"failed",error:Se,setupScript:X}})),Oe.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),S.invalidateQueries({queryKey:fe.workspaces.list(B)}),S.invalidateQueries({queryKey:fe.tasks.all})}})()},[M,S,Ve,e]),Ye=u.useCallback(b=>{v(N=>{const T={...N};return delete T[b],T}),S.invalidateQueries({queryKey:fe.workspaces.list(b)}),S.invalidateQueries({queryKey:fe.tasks.all})},[S]),He=u.useCallback((b,N)=>{const T=new Set([b,...G.filter(B=>tn(B,b)).map(B=>B.id)]);Ce.mutate({id:b,expectedSubtaskCount:N},{onSuccess:()=>{(E===b||W&&tn(W,b))&&h(null),v(B=>{const se={...B};for(const X of T)delete se[X];return se}),Y(B=>B.filter(se=>!tn(se,b))),S.invalidateQueries({queryKey:fe.tasks.all})},onError:B=>{Oe.error(B instanceof Error?e(B.message):e("删除任务失败"))}})},[Ce,E,W,G,S,e]),Je=u.useCallback((b,N)=>{Be.mutate({id:b,status:ki(N)},{onError:()=>{Oe.error(e("状态变更失败,该操作不被允许"))}})},[Be,e]),Ze=u.useCallback((b,N)=>{ut.mutate({id:b,priority:N},{onError:()=>{Oe.error(e("优先级变更失败"))}})},[ut,e]),Jt=u.useCallback(b=>{b.preventDefault(),k.current=!0,C.current=b.clientX,y.current=i,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[i]);u.useEffect(()=>{const b=T=>{if(!k.current)return;const B=T.clientX-C.current,se=Math.max(ga,Math.min(pa,y.current+B));l(se)},N=()=>{k.current&&(k.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",b),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",N)}},[]);const ke=u.useCallback(()=>{m(!0)},[]),Ke=u.useCallback(()=>{if(a.current++,r(void 0),M.length===0){Oe.error(e("没有可用项目,请先创建或恢复项目"));return}h(null)},[M,e]),Fe=u.useCallback(()=>{m(!1)},[]),et=u.useCallback(async b=>{const{title:N,description:T,projectId:B,providerId:se,mode:X,workspaceMode:ee,teamRunMode:Se,teamTemplateId:Mt,memberPresetIds:jn,attachmentLinks:es,priority:ts,baseBranch:ns}=b,rs=[T,es].filter(Boolean).join(`
|
|
11
|
-
|
|
12
|
-
`);let Ge=null;try{if(g("creating-task"),Ge=await Ue.post(`/projects/${B}/tasks`,{title:N,description:rs||void 0,priority:ts,baseBranch:ns,parentTaskId:b.parentTaskId}),localStorage.setItem("lastSelectedProjectId",B),X==="SOLO"&&se){localStorage.setItem("lastSelectedProviderId",se);const kn={...j,[se]:Date.now()};fa(kn),O(kn)}X==="TEAM"?(g("creating-teamrun"),await je.mutateAsync({taskId:Ge.id,mode:Se,...Mt?{teamTemplateId:Mt}:{},...jn.length>0?{memberPresetIds:jn}:{}})):se&&Qe(Ge,se,ee),z&&B!==z&&s(null),we(Ge),r(void 0),g("idle"),S.invalidateQueries({queryKey:fe.tasks.all}),S.invalidateQueries({queryKey:fe.projects.all})}catch(rt){if(g("idle"),Ge&&X==="TEAM")we(Ge),S.invalidateQueries({queryKey:fe.tasks.all}),Oe.error(rt instanceof Error?rt.message:e("TeamRun 创建失败,请检查团队配置后重试"));else if(Ge)z&&B!==z&&s(null),we(Ge),S.invalidateQueries({queryKey:fe.tasks.all}),S.invalidateQueries({queryKey:fe.projects.all});else throw Oe.error(rt instanceof Error?rt.message:e("Failed to create task")),rt}},[je,Qe,S,e,z,we,j]),Re=L||te,dt=u.useMemo(()=>M.filter(b=>!n||b.id===n.projectId).map(b=>({id:b.id,name:b.name,color:R.find(N=>N.id===b.id)?.color,repoPath:b.repoPath,mainBranch:b.mainBranch,isGitRepo:b.isGitRepo,worktreeReady:b.worktreeReady,reason:b.reason})),[M,R,n]),Tt=u.useMemo(()=>I.map(b=>{const N=mt(b);return{id:b.provider.id,name:b.provider.name,agentType:b.provider.agentType,available:!N,permissionMode:b.provider.executionPermission,reason:N}}),[I]),_e=u.useMemo(()=>{if(n)return n.projectId;if(z&&M.find(N=>N.id===z))return z;const b=localStorage.getItem("lastSelectedProjectId");return b&&M.find(N=>N.id===b)?b:M[0]?.id??""},[M,z,n]),[tt,nt]=u.useState(_e);u.useEffect(()=>{nt(_e)},[_e]);const Dt=u.useMemo(()=>M.find(b=>b.id===tt)?.name??M.find(b=>b.id===_e)?.name??e("Project"),[M,tt,_e,e]),ft=n?e("Create subtask"):t==="zh-CN"?`你需要在 ${Dt} 中做点什么?`:`What do you need to do in ${Dt}?`,It=u.useMemo(()=>{const b=localStorage.getItem("lastSelectedProviderId");return b&&I.find(T=>T.provider.id===b&&!mt(T))?b:I.find(T=>!mt(T))?.provider.id??""},[I]),ht=Pr(),[Zt,ae]=u.useState(!1),{usesIntegratedTitlebar:le,desktopPlatform:ge,hasMacTrafficLights:Pe}=cr(),ye=le&&ge==="win32",pe=u.useCallback(()=>{if(a.current++,r(void 0),M.length===0){Oe.error(e("没有可用项目,请先创建或恢复项目"));return}ae(!0)},[M,e]),ve=u.useCallback(b=>{a.current++,r(void 0),h(b)},[]),Ae=u.useCallback(async b=>{const N=++a.current;try{const T=await Ue.get(`/tasks/${b}`);if(N!==a.current)return;if(!vt(T))throw new Error(e("Tasks support at most three levels"));const B=(T.workspaces?.filter(X=>!X.parentWorkspaceId&&!X.cleanedAt&&X.status!=="ABANDONED")??[]).sort((X,ee)=>(ee.createdAt??"").localeCompare(X.createdAt??"")),se=B.find(X=>X.status==="ACTIVE")??B.find(X=>X.status==="HIBERNATED")??B[0];r({id:b,title:T.titlePreview??T.title,projectId:T.projectId,baseBranch:se?.branchName||T.baseBranch}),h(null),ht&&ae(!0)}catch(T){N===a.current&&Oe.error(T instanceof Error?T.message:e("Failed to create task"))}},[ht,e]),ue=u.useCallback(async b=>{await et(b),ae(!1)},[et]);return ht?Zt?o.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[o.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:o.jsx("button",{onClick:()=>{a.current++,n&&h(n.id),r(void 0),ae(!1)},className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[o.jsx("h1",{className:"max-w-full text-center text-[22px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:ft}),o.jsx(Mn,{parentTask:n,projects:dt,providers:Tt,isProvidersLoading:D,onSubmit:ue,defaultProjectId:_e,defaultProviderId:It,onProjectChange:nt,createStep:p},n?.id??"root")]})]}):E&&W?o.jsxs(o.Fragment,{children:[o.jsx(u.Suspense,{fallback:o.jsx("div",{className:"flex h-dvh",children:o.jsx(rr,{})}),children:o.jsx(ma,{task:W,onSelectTask:ve,onCreateSubtask:Ae,onBack:()=>h(null),onDeleteTask:W.projectArchivedAt?void 0:He,onTaskPriorityChange:W.projectArchivedAt?void 0:Ze,isDeleting:Ce.isPending,autoStartState:x[W.id]??null,onAutoStartRecovered:Ye})}),o.jsx(un,{isOpen:d,onClose:Fe})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[o.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(Pn,{}),o.jsx(sr,{projects:R,filterProjectId:z,setFilterProjectId:s,onCreateProject:ke})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(tr,{}),o.jsx("button",{onClick:()=>Tn.getState().openSettings(),className:"p-1.5 text-muted-foreground active:text-foreground rounded-md",children:o.jsx(An,{size:16})})]})]}),o.jsx(Jn,{tasks:K,projects:R,selectedTaskId:null,onSelectTask:ve,onCreateSubtask:Ae,selectedParentTaskId:W?.parentTaskId,filterProjectId:z,setFilterProjectId:s,width:"100%",onDeleteTask:He,onCreateTask:pe,onCreateProject:ke,onTaskStatusChange:Je,onTaskPriorityChange:Ze,isLoading:Re&&K.length===0})]}),o.jsx(un,{isOpen:d,onClose:Fe})]}):o.jsxs("div",{ref:A,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[o.jsxs("header",{className:ce("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",le&&"app-region-drag",ye&&"pr-[150px]"),children:[o.jsxs("div",{className:ce("flex items-center gap-2 min-w-0",Pe&&"pl-[72px]"),children:[o.jsx(Pn,{}),o.jsx(sr,{projects:R,filterProjectId:z,setFilterProjectId:s,onCreateProject:ke,className:le?"app-region-no-drag":void 0})]}),o.jsxs("div",{className:ce("flex items-center gap-1",le&&"app-region-no-drag"),children:[o.jsx("div",{className:le?"app-region-no-drag":void 0,children:o.jsx(tr,{})}),o.jsx("button",{onClick:()=>Tn.getState().openSettings(),className:ce("p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-md transition-colors",le&&"app-region-no-drag"),children:o.jsx(An,{size:16})})]})]}),o.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[o.jsx(Jn,{tasks:K,projects:R,selectedTaskId:E,onSelectTask:ve,onCreateSubtask:Ae,selectedParentTaskId:W?.parentTaskId,filterProjectId:z,setFilterProjectId:s,width:i,onCreateTask:Ke,onCreateProject:ke,isCreateActive:!E,onTaskStatusChange:Je,onDeleteTask:He,onTaskPriorityChange:Ze,isLoading:Re&&K.length===0}),o.jsx("div",{onMouseDown:Jt,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),o.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:E&&W?o.jsx(u.Suspense,{fallback:o.jsx(rr,{}),children:o.jsx(ha,{task:W,onSelectTask:ve,onCreateSubtask:Ae,onDeleteTask:W.projectArchivedAt?void 0:He,isDeleting:Ce.isPending,onTaskStatusChange:W.projectArchivedAt?void 0:Je,onTaskPriorityChange:W.projectArchivedAt?void 0:Ze,autoStartState:x[W.id]??null,onAutoStartRecovered:Ye})}):E&&!W?o.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:o.jsx("span",{className:"text-sm text-muted-foreground",children:e("Loading...")})}):o.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:o.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[o.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:ft}),o.jsx(Mn,{parentTask:n,projects:dt,providers:Tt,isProvidersLoading:D,onSubmit:et,defaultProjectId:_e,defaultProviderId:It,onProjectChange:nt,createStep:p},n?.id??"root")]})})})]}),o.jsx(un,{isOpen:d,onClose:Fe})]})}const Ua=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:xa},Symbol.toStringTag,{value:"Module"}));export{Pi as D,$s as L,Ua as P,Vt as m,Gs as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as Re,r as n,ai as Ft,j as e,B as oe,aj as Ut,a5 as Js,a6 as _t,ak as Kt,al as qt,am as Vt,an as Gt,ao as Ht,ap as F,aq as Qt,ar as $t,o as Xt,p as Yt,q as Ie,as as ms,at as Jt,af as Zs,ag as U,au as Zt,av as en,s as sn,aw as et,ax as tn,a3 as nn,ay as rn,az as W,a0 as on,aA as an}from"./index-BRu1Yhrx.js";import{u as ln,r as cn,c as dn,g as _e,a as un,b as mn,d as pn,e as fn,f as xn,h as gn,W as hn,E as bn,i as vn,C as jn,S as yn,T as st,R as kn,j as Cn,k as wn,l as Nn,m as In,n as Sn,o as Rn,p as Tn}from"./TaskHandoffPanel-BpGiZ5eT.js";import{r as An,a as tt,Q as En,s as Wn}from"./mermaid-NOHMQCX5-XQbfQDGS.js";import{t as Pn,D as Dn}from"./ProjectKanbanPage-CUX0Kh-t.js";import{u as Mn,a as On,R as Ln,P as Bn,T as zn}from"./useTokenUsage-T03faPfn.js";import{u as Fn,a as Un,L as nt,T as rt}from"./useNormalizedLogs-BX7pMg0-.js";import{g as _n}from"./ExecutionPermissionSelector-Bsi1aa7q.js";import{u as Kn,A as qn}from"./AttachmentPreview-BngGSahV.js";import{T as Vn,u as Gn,a as Hn,b as Qn,c as $n,d as Xn,e as Yn,S as ot}from"./CreateTaskInput-Cllw4abW.js";import{u as Jn,a as Zn,b as er,c as sr,d as tr,e as nr}from"./BranchSelect-BgVKUnxj.js";import{u as rr}from"./use-providers-BViTes-6.js";import{i as or}from"./provider-selection-DSu7SCI7.js";import{M as ar}from"./modal-Dx4N46s5.js";import{C as ir}from"./confirm-dialog-8ItnHBi0.js";import{C as lr,P as ps}from"./content-DrW8KnXu.js";import{P as fs,T as cr}from"./trash-2-DmFXzIhh.js";import{P as dr}from"./paperclip-CdQvl5ee.js";import"./use-translation-settings-Dgw0oKP1.js";import"./MemberAvatar-CZ3F53Ep.js";import"./people-D_VwidfV.js";import"./chevron-down-Bmwy-nvS.js";import"./chevron-up-CClL6-SF.js";import"./at-sign-CEsum1vJ.js";import"./check-DUA2DjGH.js";import"./tooltip-DZcaSN1F.js";import"./kbd-D4KIW7lm.js";import"./index-BFcDmhr0.js";import"./index-BClyhWqz.js";import"./index-Cdmj8aPv.js";import"./BrandLogo-CBahjTd7.js";import"./popover-CGEFZKuu.js";import"./search--FRFbCre.js";import"./index-COigMgrJ.js";import"./index-Bg8TlDo_.js";import"./index-CtOu4p9B.js";import"./select-c5IIpQj0.js";import"./select-D0sHgfcU.js";import"./menu-styles-DWynpVVz.js";import"./index-JXcQeorP.js";import"./layers-BBHgMnhN.js";import"./message-square-DIFv9yrO.js";import"./textarea-W-xQPto3.js";import"./menu-BgtmXAzT.js";import"./server-Dr_6KJFM.js";import"./upload-C-4QDrwN.js";import"./globe-BOfcTsvL.js";import"./pencil-ChX7G9j9.js";import"./copy-prrQrInw.js";import"./chip-BSMT2uT1.js";import"./folder-picker-CBdw-4v3.js";import"./track-Cj1Ogapu.js";import"./dialog-BUsI4h2U.js";import"./file-C6QMUr5_.js";function ur({isOpen:t,onClose:f,taskId:N}){const{t:d}=Re(),[I,S]=n.useState("AUTO"),[R,l]=n.useState(null),[T,o]=n.useState([]),[k,P]=n.useState(null),Te=Ft();n.useEffect(()=>{t&&(S("AUTO"),l(null),o([]),P(null))},[t]);const D=Te.isPending,Ke=!!R||T.length>0,ae=async()=>{if(!D){if(!R&&T.length===0){P(d("请选择至少一个团队模板或成员预设。"));return}P(null);try{await Te.mutateAsync({taskId:N,mode:I,...R?{teamTemplateId:R}:{},...T.length>0?{memberPresetIds:T}:{}}),f()}catch(G){P(G instanceof Error?G.message:d("创建 TeamRun 失败"))}}},qe=D||!Ke;return e.jsxs(ar,{isOpen:t,onClose:D?()=>{}:f,title:d("创建 TeamRun"),className:"max-w-5xl",action:e.jsxs(e.Fragment,{children:[e.jsx(oe,{type:"button",variant:"outline",onClick:f,disabled:D,children:d("取消")}),e.jsx(oe,{type:"button",onClick:ae,disabled:qe,children:d(D?"处理中...":"创建 TeamRun")})]}),children:[e.jsx(Vn,{mode:I,setMode:S,selectedTemplateId:R,setSelectedTemplateId:l,selectedMemberPresetIds:T,setSelectedMemberPresetIds:o,disabled:D}),k&&e.jsx("div",{role:"alert",className:"rounded-lg border border-destructive/25 bg-destructive/10 px-4 py-3 text-sm text-destructive-ink",children:k})]})}function mr({workspaceId:t,gitStatus:f,onResolve:N}){const{t:d}=Re(),I=Jn();if(f.operation==="idle"||f.conflictedFiles.length===0)return null;const S=f.operation==="rebase"?"Rebase":"Merge";return e.jsx(Ut,{tone:"warning",className:"mx-6 mt-3 items-center",title:e.jsxs("span",{className:"flex items-center gap-2",children:[S," ",d("冲突"),e.jsxs(_t,{tone:"warning",className:"tabular-nums",children:[f.conflictedFiles.length," ",d("个文件")]})]}),action:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Js,{variant:"ghost",onClick:()=>I.mutate(t),loading:I.isPending,children:d("中止操作")}),e.jsx(Js,{variant:"primary",onClick:N,children:d("解决冲突")})]})})}const pr=on(),fr=t=>t.includes("://")||t.startsWith("/api/")?t:t.startsWith("/")?`${pr}/attachments/by-path?path=${encodeURIComponent(t)}`:t,re=520,xs=48,xr=4,gr=420;function hr(){const{t}=Re();return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground select-none",children:[e.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-xl border border-border/60 flex items-center justify-center mb-6",children:e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground",children:[e.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),e.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("h3",{className:"text-foreground font-medium mb-2 text-[15px]",children:"Agent Tower"}),e.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:t("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}function Se(t){const f=an[t].icon;return e.jsx(f,{className:"size-3"})}const at=[{status:W.Review,className:"bg-warning/10 text-warning-ink",hoverClass:"hover:bg-warning/15",icon:Se(W.Review)},{status:W.Running,className:"bg-info/10 text-info-ink",hoverClass:"hover:bg-info/15",icon:Se(W.Running)},{status:W.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:Se(W.Pending)},{status:W.Done,className:"bg-success/10 text-success-ink",hoverClass:"hover:bg-success/15",icon:Se(W.Done)},{status:W.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:Se(W.Cancelled)}];function br({status:t,onChangeStatus:f}){const{t:N}=Re(),[d,I]=n.useState(!1),S=n.useRef(null);n.useEffect(()=>{if(!d)return;const l=T=>{S.current&&!S.current.contains(T.target)&&I(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[d]);const R=at.find(l=>l.status===t);return e.jsxs("div",{className:"relative",ref:S,children:[e.jsxs("button",{onClick:()=>f&&I(l=>!l),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${R.className} ${f?"cursor-pointer hover:opacity-80":""}`,children:[R.icon,e.jsx("span",{children:N(t)}),f&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${d?"rotate-180":""}`,children:e.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),d&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-popover z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:at.filter(l=>l.status!==t).map(l=>e.jsxs("button",{onClick:()=>{f?.(l.status),I(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${l.hoverClass}`,children:[e.jsx("span",{className:l.className.split(" ").find(T=>T.startsWith("text-")),children:l.icon}),e.jsx("span",{className:"text-foreground/80",children:N(l.status)})]},l.status))})]})}function vo({task:t,onSelectTask:f,onCreateSubtask:N,onDeleteTask:d,isDeleting:I,onTaskStatusChange:S,onTaskPriorityChange:R,autoStartState:l,onAutoStartRecovered:T}){const{t:o}=Re(),[k,P]=n.useState(""),[Te,D]=n.useState(!1),[Ke,ae]=n.useState(!1),[qe,G]=n.useState(!1),[it,Ve]=n.useState(!1),[lt,gs]=n.useState(!1),Ae=n.useRef(null),[Ge,H]=n.useState(!1),[A,He]=n.useState(null),[ie,Q]=n.useState(void 0),[$,Ee]=n.useState(!1),Qe=n.useRef(null),$e=n.useRef(null),le=n.useRef(null),hs=n.useRef(null),{scrollRef:_,contentRef:bs,isAtBottom:vs,scrollToBottom:We,stopScroll:js}=Mn({resize:"smooth",initial:"instant"}),[M,ys]=n.useState(!1),[Xe,ce]=n.useState(re),[Pe,ks]=n.useState(!1),Cs=n.useRef(0),ws=n.useRef(re),Ns=n.useRef(null),Ye=n.useCallback((s,r,i)=>{Ae.current?.openFile(s,r,i)},[]),{data:a,isLoading:ct}=Zn(t?.id??""),de=ln(t?.id),Is=de?.status==="completed"&&l?.status!=="failed"?null:l,Je=!!(Is||de&&de.status!=="completed"),{data:ue}=Kt(t?.id??""),{data:dt}=qt(ue?.id??""),Ss=Vt(ue?.id??""),u=ue??null,me=!!u,X=t?.isGitRepo!==!1&&t?.worktreeReady!==!1,De=ue===null&&X,ut=!!(t?.id&&ue===null),{data:Y,isLoading:Rs}=Gt(t?.id??"",ut);n.useEffect(()=>{Ee(!1),He(null),Q(void 0)},[t?.id]);const K=n.useMemo(()=>cn(a,u,ie),[ie,u,a]);n.useEffect(()=>{ie&&!a?.some(s=>s.id===ie)&&Q(void 0)},[ie,a]);const x=n.useMemo(()=>a?.find(s=>s.id===K),[K,a]),y=x?.status===Ht.ACTIVE?x.id:void 0,pe=X&&dn(x,u);n.useEffect(()=>{if(!$||!a)return;a.some(r=>r.status==="ACTIVE"&&r.sessions&&r.sessions.length>0)&&Ee(!1)},[a,$]);const g=n.useMemo(()=>{if($||!a)return null;const s=c=>{const us=c.createdAt,Ne=c.endedAt??c.startedAt??us;if(!Ne)return 0;const ne=Date.parse(Ne);return Number.isNaN(ne)?0:ne},r=(c,us)=>{const Ne=c.filter(ne=>us.includes(ne.status));return Ne.length===0?null:Ne.sort((ne,zt)=>s(zt)-s(ne))[0]??null},i=a.filter(c=>c.status==="ACTIVE"&&Array.isArray(c.sessions)).flatMap(c=>c.sessions??[]),p=r(i,[F.RUNNING])??r(i,[F.PENDING])??r(i,[F.COMPLETED,F.FAILED,F.CANCELLED]);if(p)return p;const w=a.filter(c=>(c.status==="MERGED"||c.status==="ABANDONED"||c.status==="HIBERNATED")&&Array.isArray(c.sessions)).flatMap(c=>c.sessions??[]);return r(w,[F.COMPLETED,F.FAILED,F.CANCELLED])},[a,$]),J=g?.id??"",h=me?A??"":J,mt=n.useMemo(()=>{if(!A||!a)return null;for(const s of a){const r=s.sessions?.find(i=>i.id===A);if(r)return r}return null},[A,a]),Ze=n.useMemo(()=>{if(!A||!u?.invocations)return null;const s=u.invocations.filter(r=>r.sessionId===A);return s.length===0?null:s.sort((r,i)=>{const p=Date.parse(r.updatedAt??r.createdAt??""),w=Date.parse(i.updatedAt??i.createdAt??"");return(Number.isNaN(w)?0:w)-(Number.isNaN(p)?0:p)})[0]??null},[A,u?.invocations]),pt=n.useMemo(()=>!Ze?.memberId||!u?.members?null:u.members.find(s=>s.id===Ze.memberId)??null,[Ze?.memberId,u?.members]),b=A?mt:g??null,L=b?.id,Z=n.useMemo(()=>{if(b?.workspaceId)return b.workspaceId;if(!(!b||!a))return a.find(s=>s.sessions?.some(r=>r.id===b.id))?.id},[b,a]),Me=n.useCallback((s,r)=>{const p=(r&&a?.some(w=>w.id===r)?r:void 0)??Z??K??void 0;p&&Q(p),Ae.current?.openPreview(s,p)},[Z,K,a]),es=n.useCallback((s,r)=>{Me({kind:"web",url:s},r)},[Me]),ss=n.useCallback((s,r,i)=>{Me({kind:"visualization",sessionId:s,file:r},i)},[Me]),Ts=n.useCallback(s=>{es(s,Z)},[Z,es]),As=n.useCallback(s=>{L&&ss(L,s,Z)},[L,Z,ss]),{isActive:fe,isCancelling:xe}=Gn(L??"",b?.status),m=!!t?.projectArchivedAt,Es=!!t?.projectRepoDeletedAt,ts=o(Es?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ee}=rr(),[Oe,Ws]=n.useState(null),Le=g?_n(ee,Oe??g.providerId):void 0;n.useEffect(()=>{Ws(g?.providerId??null)},[g?.providerId]);const ft=n.useMemo(()=>!g||!a?!1:!a.some(r=>r.status==="ACTIVE"&&r.sessions?.some(i=>i.id===g.id)),[g,a]),C=n.useMemo(()=>{if(!(!a||$)){if(x)return _e(x);for(const s of a)if(s.status==="ACTIVE"&&_e(s))return _e(s);return _e(a[0])}},[$,x,a]),q=Hn({agentType:g?.agentType,workingDir:C,input:k,setInput:P,textareaRef:le,minHeight:60,maxHeight:300}),V=un({agentType:g?.agentType,workingDir:C,input:k,setInput:P,textareaRef:le,minHeight:60,maxHeight:300}),ns=Qt(s=>s.setVisibleContext),ge=!!(pe&&y&&C&&!m),{data:E,isLoading:xt}=er(y??"",{enabled:ge}),{data:gt}=mn(C,{enabled:ge});n.useEffect(()=>{if(!(M||!ge||!y||!C))return ns({workspaceId:y,workingDir:C,tab:"changes"}),()=>{ns(null)}},[M,y,ns,ge,C]);const ht=x?.sessions??[],he=pn(x),Ps=x?.commitMessage,be=n.useMemo(()=>fn(x,a,t?.mainBranch??""),[x,t?.mainBranch,a]),ve=xn((a??[]).map(s=>s.id),!me),{pendingConflictDetails:je}=ve,Ds=!!je,v=n.useMemo(()=>je||(E?.conflictOp&&E.conflictedFiles.length>0?$t({conflictOp:E.conflictOp,conflictedFiles:E.conflictedFiles,resolutionContextToken:E.resolutionContextToken,sourceWorkspaceId:y,sourceWorktreePath:x?.worktreePath,sourceBranch:he,targetBranch:be}):je),[E,je,y,x?.worktreePath,he,be]),Ms=v?.targetWorkspaceId??y,bt=v?.targetWorktreePath??x?.worktreePath,vt=v?.sourceBranch??he,jt=v?.targetBranch??be,j=Xt(),Be=n.useCallback(async()=>t?.id?j.fetchQuery({queryKey:Ie.tasks.body(t.id),queryFn:()=>Yt.get(`/tasks/${t.id}/body`)}):null,[j,t?.id]),Os=n.useCallback(()=>t?.id?j.invalidateQueries({queryKey:Ie.workspaces.list(t.id)}):Promise.resolve(),[t?.id,j]);n.useEffect(()=>{if(!Ge)return;const s=r=>{$e.current&&!$e.current.contains(r.target)&&H(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[Ge]);const B=Qn(),Ls=sr(),Bs=tr(t?.id??""),zs=$n(),rs=nr(),ye=n.useMemo(()=>!a||a.some(r=>r.status==="ACTIVE")?null:a.find(r=>r.status==="HIBERNATED")??null,[a]),os=n.useRef(null);n.useEffect(()=>{ye&&os.current!==ye.id&&(rs.isPending||(os.current=ye.id,rs.mutate(ye.id,{onSettled:()=>{os.current=null}})))},[ye,rs]);const yt=n.useCallback(async()=>{if(!t?.id)return;const s=g?.providerId??ee?.find(r=>or(r)&&r.availability.type!=="NOT_FOUND")?.provider.id;if(s){Ve(!1),gs(!0);try{const i=(await Be())?.prompt??t.title;Ee(!0),await Pn(t.id,{providerId:s,prompt:i,retryTask:!0,workspaceKind:X?ms.WORKTREE:ms.MAIN_DIRECTORY},{createWorkspace:p=>Bs.mutateAsync({clientSubmissionId:p,workspaceKind:X?void 0:ms.MAIN_DIRECTORY}),startSession:p=>zs.mutateAsync(p)}),await j.invalidateQueries({queryKey:Ie.workspaces.list(t.id)})}catch(r){console.error("[retry] failed:",r),Ee(!1)}finally{gs(!1)}}},[t?.id,t?.title,X,g?.providerId,ee,Be,Bs,zs,j]),as=n.useCallback(async()=>{t?.id&&(await Be(),D(!0))},[Be,t?.id]),kt=n.useCallback(()=>{x?.id&&Ls.mutate({workspaceId:x.id})},[Ls,x?.id]),Ct=n.useCallback(s=>{!t?.id||!d||(d(t.id,s),G(!1))},[t?.id,d]),Fs=n.useCallback(s=>{He(s),requestAnimationFrame(()=>{We()})},[We]),wt=n.useCallback(()=>{He(null)},[]),ke=n.useCallback(s=>{const r=s??v;r&&ve.openDialog(r)},[v,ve]),Nt=n.useCallback(s=>Ss.mutateAsync(s),[Ss]),se=n.useCallback(()=>{j.invalidateQueries({queryKey:Jt.all})},[j]),{isConnected:Us,isLoadingSnapshot:_s,isOutputActive:Ks,lastExitAt:qs,logs:Ce,entries:It,attach:ze}=Fn({sessionId:h,sessionStatus:b?.status,sessionStartedAt:b?.startedAt??b?.createdAt,sessionEndedAt:b?.endedAt??(fe?null:b?.updatedAt),onExit:n.useCallback(()=>{j.invalidateQueries({queryKey:["workspaces"]})},[j])});n.useEffect(()=>{if(!t?.id)return;const s=Zs.connect(),r=An(t.id),i=c=>{c.taskId===t.id&&(j.invalidateQueries({queryKey:["tasks"]}),se())},p=c=>{c.taskId===t.id&&(j.invalidateQueries({queryKey:Ie.workspaces.list(t.id)}),se())},w=c=>{c.taskId===t.id&&(j.invalidateQueries({queryKey:Ie.workspaces.list(t.id)}),se())};return s.on(U.TASK_UPDATED,i),s.on(U.WORKSPACE_COMMIT_MESSAGE_UPDATED,p),s.on(U.WORKSPACE_HIBERNATED,w),()=>{s.off(U.TASK_UPDATED,i),s.off(U.WORKSPACE_COMMIT_MESSAGE_UPDATED,p),s.off(U.WORKSPACE_HIBERNATED,w),r()}},[t?.id,j,se]),n.useEffect(()=>{if(!h)return;const s=Zs.connect(),r=i=>{i.sessionId===h&&(j.invalidateQueries({queryKey:["workspaces"]}),se())};return s.on(U.SESSION_COMPLETED,r),()=>{s.off(U.SESSION_COMPLETED,r)}},[h,j,se]);const{todos:Fe}=Un(It),{files:St,addFiles:te,removeFile:Rt,clear:Vs,getDoneAttachments:Gs,hasFiles:we,isUploading:Ue}=Kn(),Tt=n.useMemo(()=>gn(b),[b?.tokenUsage]),Hs=On(Ce,Tt);n.useEffect(()=>{h&&Us&&ze()},[h,Us,ze]);const Qs=n.useRef(t?.id);n.useEffect(()=>{if(Qs.current!==t?.id&&_.current){const s=_.current;requestAnimationFrame(()=>{s.scrollTop=s.scrollHeight})}Qs.current=t?.id},[t?.id,_]);const z=Xn(),is=n.useRef(!1),$s=n.useCallback(async()=>{if(!k.trim()&&!we||!h||is.current||z.isPending||xe||Ue||Le)return;is.current=!0;const s=Gs().map(i=>i.id),r=k.trim()||(s.length?" ":"");P(""),Vs(),le.current&&(le.current.style.height="60px"),B.mutate({id:h,message:r,attachmentIds:s,providerId:Oe??void 0},{onSuccess:()=>{ze()},onSettled:()=>{is.current=!1}})},[k,h,B,ze,we,Ue,Gs,Vs,Oe,Le,z.isPending,xe]),At=n.useCallback(()=>{!h||z.isPending||z.mutate(h)},[h,z]),Et=n.useCallback(s=>{const r=s.target.files;r&&r.length>0&&te(Array.from(r)),s.target.value=""},[te]),Wt=n.useCallback(s=>{const r=s.clipboardData.items,i=[];for(const p of r)if(p.kind==="file"){const w=p.getAsFile();w&&i.push(w)}i.length>0&&(s.preventDefault(),te(i))},[te]),[Xs,ls]=n.useState(!1),Pt=n.useCallback(s=>{s.preventDefault(),ls(!0)},[]),Dt=n.useCallback(s=>{s.preventDefault(),ls(!1)},[]),Mt=n.useCallback(s=>{s.preventDefault(),ls(!1);const r=s.dataTransfer.files;r.length>0&&te(Array.from(r))},[te]),O=n.useCallback(s=>{const r=Ns.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),i=r?Math.max(re,r-xs-xr-gr):re;return Math.max(re,Math.min(Math.round(s),i))},[]),cs=n.useCallback(s=>{const r=s.clientX-Cs.current;ce(O(ws.current-r))},[O]),ds=n.useCallback(()=>{ks(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);n.useEffect(()=>{if(Pe)return document.addEventListener("mousemove",cs),document.addEventListener("mouseup",ds),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",cs),document.removeEventListener("mouseup",ds),document.body.style.cursor="",document.body.style.userSelect=""}},[ds,cs,Pe]);const Ot=n.useCallback(s=>{s.preventDefault(),Cs.current=s.clientX,ws.current=Xe,ks(!0)},[Xe]);n.useEffect(()=>{!M||Pe||ce(s=>O(s))},[O,M,Pe]),n.useEffect(()=>{if(!M)return;const s=()=>{ce(r=>O(r))};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[O,M]);const Lt=n.useCallback(()=>{ce(s=>O(s)),ys(!0),requestAnimationFrame(()=>{Ae.current?.setTab("review")})},[O]),Bt=n.useCallback(s=>{P(s.target.value);const r=s.target;r.style.height="auto";const i=r.scrollHeight;r.style.height=`${Math.max(60,Math.min(i,300))}px`},[]),Ys=ge&&y?e.jsx(hn,{projectId:t?.projectId??"",workspaceId:y,branchName:he,targetBranch:be,commitMessage:Ps,changes:gt,gitStatus:E,isGitStatusLoading:xt,canRunGitOperations:pe,onOpenChanges:Lt,onRefreshCommitMessage:Os,onConflict:ke,className:"mb-1.5"}):null;return t?e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t.projectColor.replace("text-","bg-")}`}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.projectName}),t.projectArchivedAt&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground shrink-0",children:t.projectRepoDeletedAt?o("源码已删除"):o("已删除")}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"/"}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate",children:t.branch})]}),e.jsx(bn,{taskId:t.id,title:t.title,readOnly:m})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx(br,{status:t.status,onChangeStatus:!m&&S?s=>S(t.id,s):void 0}),e.jsx(Yn,{value:t.priority,onChange:!m&&R?s=>R(t.id,s):void 0}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:kt,disabled:!C||m,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:o("Open in IDE"),children:e.jsx(lr,{size:16})}),(d||N||De)&&!m&&e.jsxs("div",{className:"relative",ref:$e,children:[e.jsx("button",{onClick:()=>H(s=>!s),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:o("More actions"),children:e.jsx(vn,{size:16})}),Ge&&e.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-popover z-50 py-1",children:[N&&Zt(t)&&e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50",onClick:()=>{H(!1),N(t.id)},children:[e.jsx(fs,{size:15}),e.jsx("span",{children:o("Create subtask")})]}),De&&e.jsxs("button",{onClick:()=>{ae(!0),H(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[e.jsx(fs,{size:15}),e.jsx("span",{children:o("创建 TeamRun")})]}),e.jsxs("button",{onClick:()=>{Ve(!0),H(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[e.jsx(en,{size:15}),e.jsx("span",{children:o("重新开始")})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-1 border-t border-border/60"}),e.jsxs("button",{onClick:()=>{G(!0),H(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive-ink hover:bg-destructive/10 transition-colors",children:[e.jsx(cr,{size:15}),e.jsx("span",{children:o("删除任务")})]})]})]})]})]})]})]}),!me&&e.jsx(jn,{recovery:ve,onRecover:s=>{Q(s.sourceWorkspaceId),ke(s)}}),pe&&y&&E&&e.jsx(mr,{workspaceId:y,gitStatus:E,onResolve:()=>ke()}),e.jsxs("div",{ref:Ns,className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:me&&u?A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:o("Invocation details")}),e.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:A})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(yn,{session:b,providers:ee,usage:Hs,providerIdFallback:pt?.providerId,agentTypeFallback:b?.agentType,tokenTooltipSide:"bottom"}),e.jsxs(oe,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:wt,children:[e.jsx(sn,{size:13}),e.jsx("span",{children:o("Team room")})]})]})]}),e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:_,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:e.jsxs("div",{ref:bs,className:"w-full max-w-4xl mx-auto",children:[!u&&t&&e.jsx(st,{taskId:t.id}),_s?e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground",children:[e.jsxs("svg",{className:"animate-spin motion-reduce:[animation-duration:2.4s] h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:o("Loading logs...")})]}):Ce.length===0&&!h?e.jsx("div",{className:"text-muted-foreground text-center py-8",children:o(fe?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(nt,{children:e.jsx(tt,{logs:Ce,sessionId:L,downloadSessionId:L,isOutputActive:Ks,lastExitAt:qs,onUserToggleDetails:js,workingDir:C,scrollElementRef:_,onOpenWorkspaceFile:Ye,onOpenPreviewUrl:Ts,onOpenVisualization:As})})]})}),!vs&&e.jsxs("button",{onClick:()=>We(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-raised text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":o("Scroll to bottom"),children:[e.jsx(et,{size:14}),e.jsx("span",{children:o("回到底部")})]})]}),Fe.length>0&&e.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(rt,{todos:Fe})})})]}):e.jsx(kn,{teamRun:u,messages:dt??u.messages??[],readOnly:m,readOnlyMessage:ts,onSendMessage:Nt,onViewInvocationSession:Fs,changeSummaryBar:Ys,centered:!0,workingDir:C,onOpenWorkspaceFile:Ye,onOpenPreviewUrl:es,onOpenVisualization:ss}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:_,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:e.jsxs("div",{ref:bs,className:"w-full min-w-0 max-w-4xl mx-auto",children:[!u&&t&&e.jsx(st,{taskId:t.id}),(Rs||Y?.body)&&e.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Rs?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:o("Loading...")}):Y?.body?e.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:e.jsx(En,{urlTransform:fr,components:Wn,children:Y.body})}):null}),!m&&e.jsx(Cn,{state:Is,setupProgress:de,sessionStarted:!!g?.startedAt,onRetry:J&&l?.status==="failed"?as:void 0},t.id),ct?(!Je||m)&&e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground",children:[e.jsxs("svg",{className:"animate-spin motion-reduce:[animation-duration:2.4s] h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:o("Loading...")})]}):J?_s?e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground",children:[e.jsxs("svg",{className:"animate-spin motion-reduce:[animation-duration:2.4s] h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:o("Loading logs...")})]}):Ce.length===0&&!h?e.jsx("div",{className:"text-muted-foreground text-center py-8",children:o(fe?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(nt,{children:e.jsx(tt,{logs:Ce,sessionId:L,downloadSessionId:L,isOutputActive:Ks,lastExitAt:qs,onUserToggleDetails:js,workingDir:C,scrollElementRef:_,onOpenWorkspaceFile:Ye,onOpenPreviewUrl:Ts,onOpenVisualization:As})}):!Je||l?.status==="failed"||de?.status==="failed"||m?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(!Je||m)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-xl border border-border/60 flex items-center justify-center mb-5",children:e.jsx(ps,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:o(m?"项目为只读历史":"尚未启动 Agent")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:m?ts:o("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")})]}),!m&&(!l||l.status==="failed")&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[e.jsxs(oe,{onClick:as,disabled:!!(l&&l.status!=="failed"),children:[e.jsx(ps,{size:16,className:"mr-1.5"}),l?.status==="failed"?o("重试启动 Agent"):o("启动 Agent")]}),De&&e.jsxs(oe,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(fs,{size:16,className:"mr-1.5"}),o("创建 TeamRun")]})]})]}):null]})}),!vs&&e.jsxs("button",{onClick:()=>We(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-raised text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":o("Scroll to bottom"),children:[e.jsx(et,{size:14}),e.jsx("span",{children:o("回到底部")})]})]}),Fe.length>0&&e.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(rt,{todos:Fe})})}),m?e.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:ts})})}):ft?e.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:o("代码已合并,以上为历史沟通记录")}),e.jsxs(oe,{size:"sm",onClick:as,children:[e.jsx(ps,{size:14,className:"mr-1.5"}),o("启动新 Agent")]})]})})}):e.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Pt,onDragLeave:Dt,onDrop:Mt,children:[e.jsxs("div",{className:"max-w-4xl mx-auto",children:[Ys,h?e.jsx(Ln,{sessionId:h}):null,e.jsxs("div",{ref:Qe,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Xs?"border-foreground/40 bg-foreground/[0.02]":"border-border"}`,children:[e.jsx(qn,{files:St,onRemove:Rt}),e.jsx("textarea",{ref:le,value:k,onChange:Bt,onPaste:Wt,onKeyDown:s=>{V.handleKeyDown(s)||q.handleKeyDown(s)||s.key==="Enter"&&!s.shiftKey&&!s.repeat&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229&&(s.preventDefault(),$s())},rows:1,placeholder:o(Xs?"Drop files here...":J&&!fe?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),e.jsx("input",{ref:hs,type:"file",multiple:!0,className:"hidden",onChange:Et}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("button",{onClick:()=>hs.current?.click(),className:"p-2 text-muted-foreground hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:o("Upload file"),children:e.jsx(dr,{size:18})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[g&&ee&&e.jsx(Bn,{providers:ee,currentProviderId:Oe,agentType:g.agentType,runtimeType:g.runtimeType,onSelect:Ws}),e.jsx(zn,{usage:Hs}),fe&&!B.isPending&&!k.trim()&&!we?e.jsx("button",{onClick:At,disabled:z.isPending||xe,"aria-label":o("Stop"),title:o("Stop"),className:"p-2 rounded-lg transition-all duration-200 bg-destructive-ink text-white hover:bg-destructive-ink/90 disabled:opacity-50",children:e.jsx(tn,{size:14})}):e.jsx("button",{onClick:$s,"aria-label":o(B.isPending?"发送中...":"Send"),"aria-busy":B.isPending,disabled:!k.trim()&&!we||Ue||B.isPending||z.isPending||xe||!!Le,className:`p-2 rounded-lg transition-all duration-200 ${(k.trim()||we)&&!Ue&&!B.isPending&&!z.isPending&&!xe&&!Le?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground cursor-not-allowed"}`,children:B.isPending?e.jsx(nn,{size:18,className:"animate-spin"}):e.jsx(rn,{size:18})})]})]})]})]}),e.jsx(ot,{open:q.query!==null,anchorRef:Qe,commands:q.filteredCommands,selectedIndex:q.selectedIndex,query:q.query??"",hasCatalog:q.allCommands.length>0,onSelect:q.applyCommand}),e.jsx(ot,{open:V.query!==null,anchorRef:Qe,commands:V.filteredSkills,selectedIndex:V.selectedIndex,query:V.query??"",hasCatalog:V.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:V.applySkill})]})]})}),M&&e.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Ot,role:"separator","aria-orientation":"vertical","aria-label":o("调整工作区宽度")}),e.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:M?xs+Xe:xs},children:e.jsx(wn,{handoff:e.jsx(Sn,{taskId:t.id,readOnly:m},t.id),subtasks:e.jsx(In,{task:t,onSelectTask:f,onCreateSubtask:N},t.id),sessionId:J||void 0,workspaceId:K,workingDir:C,projectId:t.projectId,readOnly:m,repoDeleted:Es,teamRun:u,teamStatus:u?e.jsx(Nn,{teamRun:u,workspaces:a,selectedWorkspaceId:K,onSelectWorkspace:Q,onViewInvocationSession:Fs}):void 0,workspaces:a,selectedWorkspaceId:K,onSelectWorkspace:Q,variant:"rail",expanded:M,onExpandedChange:s=>{s&&ce(r=>O(r)),ys(s)},minContentWidth:re,tabRef:Ae,gitAvailable:X,gitProps:pe&&y?{branchName:he,targetBranch:be,commitMessage:Ps,canRunGitOperations:!0,onRefreshCommitMessage:Os,onConflict:ke,onResolveConflicts:()=>ke()}:void 0})})]}),!m&&e.jsx(Rn,{isOpen:Te,onClose:()=>D(!1),taskId:t.id,projectId:t.projectId,taskTitle:Y?.title??t.title,taskDescription:Y?.body??"",taskPrompt:Y?.prompt,projectIsGitRepo:t.isGitRepo,projectWorktreeReady:t.worktreeReady,projectGitReason:t.reason,onStarted:()=>T?.(t.id)}),De&&!m&&e.jsx(ur,{isOpen:Ke,onClose:()=>ae(!1),taskId:t.id}),Ds&&pe&&Ms&&v&&e.jsx(Tn,{open:Ds,onOpenChange:s=>{s||ve.closeDialog()},workspaceId:Ms,conflictOp:v.conflictOp,conflictedFiles:v.conflictedFiles,resolutionContextToken:v.resolutionContextToken,sourceBranch:vt,targetBranch:jt,operation:E?.operation,worktreePath:bt,mergeAborted:v.mergeAborted,mergeStrategy:v.mergeStrategy,sourceWorkspaceId:v.sourceWorkspaceId,targetWorkspaceId:v.targetWorkspaceId,sourceWorktreePath:v.sourceWorktreePath,targetWorktreePath:v.targetWorktreePath,sessions:ht,currentSessionId:me?void 0:J,teamRunId:u?.id}),e.jsx(ir,{isOpen:it,onClose:()=>Ve(!1),onConfirm:yt,title:o("重新开始任务"),description:e.jsx("p",{children:o("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:o("确认重试"),variant:"default",isLoading:lt}),e.jsx(Dn,{isOpen:qe,onClose:()=>G(!1),onConfirm:Ct,taskId:t.id,taskTitle:t.title,workspaces:a,isLoading:I})]}):e.jsx(hr,{})}export{vo as TaskDetail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,M as n}from"./index-DUmVscrR.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c}from"./index-BRu1Yhrx.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-B7n9vxY4.js";import{_ as i}from"./index-DUmVscrR.js";import"./chunk-FMBD7UC4-CXyP08kl.js";import"./chunk-ND2GUHAM-BtnIS-HK.js";import"./chunk-55IACEB6-xVa3bJqv.js";import"./chunk-2J33WTMH-BrtUyBDF.js";import"./index-BRu1Yhrx.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-B7n9vxY4.js";import{_ as i}from"./index-DUmVscrR.js";import"./chunk-FMBD7UC4-CXyP08kl.js";import"./chunk-ND2GUHAM-BtnIS-HK.js";import"./chunk-55IACEB6-xVa3bJqv.js";import"./chunk-2J33WTMH-BrtUyBDF.js";import"./index-BRu1Yhrx.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|