agent-tower 0.7.2-beta.4 → 0.7.2-beta.7
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/runtime/__tests__/cli-driver-lifecycle.test.js +12 -8
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
- package/dist/runtime/cli-driver.js +15 -9
- package/dist/runtime/cli-driver.js.map +1 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js +69 -0
- package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.team-run.test.js +3 -1
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/__tests__/terminal-manager.test.js +70 -0
- package/dist/services/__tests__/terminal-manager.test.js.map +1 -1
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +2 -2
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +9 -4
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/web/assets/AgentDemoPage-CaR_Yk9_.js +1 -0
- package/dist/web/assets/{AgentEnvironmentSettingsPage-DQjnDr-h.js → AgentEnvironmentSettingsPage-SnxiaHvN.js} +1 -1
- package/dist/web/assets/BranchSelect-D-kqavDG.js +1 -0
- package/dist/web/assets/BrandLogo-CC1alVsd.js +1 -0
- package/dist/web/assets/ConversationPage-RWKLxe1j.js +3 -0
- package/dist/web/assets/CreateTaskInput-SHJ1YpRe.js +1 -0
- package/dist/web/assets/{DemoPage-BkkueMuL.js → DemoPage-BHbnnZFF.js} +1 -1
- package/dist/web/assets/DesignSystemPage-ChCrzeKT.js +12 -0
- package/dist/web/assets/EditableTaskTitle-CGVeZUSt.js +70 -0
- package/dist/web/assets/{ExecutionPermissionSelector-BX5Xx8ta.js → ExecutionPermissionSelector-DcC4IBOF.js} +10 -10
- package/dist/web/assets/GeneralSettingsPage-C_tkwpmF.js +1 -0
- package/dist/web/assets/{LoadingPreviewPage-BxjpxLLP.js → LoadingPreviewPage-dE_jyl19.js} +1 -1
- package/dist/web/assets/McpSettingsPage-CIuQ4bvy.js +1 -0
- package/dist/web/assets/MemberAvatar-BG0VDZKf.js +1 -0
- package/dist/web/assets/MobileTaskDetail-DxE6ZDAS.js +5 -0
- package/dist/web/assets/NotificationSettingsPage-B-Ot2OMg.js +1 -0
- package/dist/web/assets/ProfileSettingsPage-Dn1lrjJr.js +3 -0
- package/dist/web/assets/ProjectKanbanPage-jcW8sA7x.js +12 -0
- package/dist/web/assets/ProjectSettingsPage-BFPty2eA.js +2 -0
- package/dist/web/assets/ProviderSettingsPage-DLq-GBxp.js +67 -0
- package/dist/web/assets/SettingsMasterDetail-UfyoKAum.js +1 -0
- package/dist/web/assets/TaskDetail-a1jalILy.js +3 -0
- package/dist/web/assets/TeamSettingsPage-BxGc4W7K.js +1 -0
- package/dist/web/assets/arc-dhk0OSs5.js +1 -0
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-DWO_DRgk.js → architectureDiagram-3BPJPVTR-BCNj6ZWE.js} +1 -1
- package/dist/web/assets/{at-sign-BFf8Sz8T.js → at-sign-C4VhWike.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CJPYhE52.js → blockDiagram-GPEHLZMM-D1kmB9gz.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-Cx5IvcjB.js → c4Diagram-AAUBKEIU-DbWKTkSe.js} +1 -1
- package/dist/web/assets/channel-K0AG6Tl1.js +1 -0
- package/dist/web/assets/check-DYlb0A_N.js +1 -0
- package/dist/web/assets/{chevron-up-BwJT7iif.js → chevron-up-DOkDFvIc.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-D9cBNYgd.js → chunk-2J33WTMH-B3TA0-LD.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-BY8TNt6E.js → chunk-4BX2VUAB-CvPTiBSV.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-pT-HP-28.js → chunk-55IACEB6-xGe9Fu9Z.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-hy95xDLb.js → chunk-727SXJPM-H8pz3amK.js} +2 -2
- package/dist/web/assets/{chunk-AQP2D5EJ-DlUN-icr.js → chunk-AQP2D5EJ-BmYYNxcL.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-Dg2iMKZR.js → chunk-FMBD7UC4-BmOEsLTE.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-DMzFIsJ-.js → chunk-ND2GUHAM-C5MfA0xc.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-C6CgmKuM.js → chunk-QZHKN3VN-BcrGYZ7V.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BTJ44hwx.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BTJ44hwx.js +1 -0
- package/dist/web/assets/code-block-OCS4YCEC-DLPrDBDy.js +2 -0
- package/dist/web/assets/confirm-dialog-BRkrtULz.js +1 -0
- package/dist/web/assets/content-DPCGELMz.js +2 -0
- package/dist/web/assets/{copy-r0aUdsl8.js → copy-CdzVE3kf.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-D-fvmvw-.js → cose-bilkent-S5V4N54A-CLQ-m71G.js} +1 -1
- package/dist/web/assets/cssMode-ChMyv9Nj.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-H0bYI1f3.js → dagre-BM42HDAG-CmDqxOfn.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-DI568fLp.js → diagram-2AECGRRQ-D-fSbEll.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-BLcaBzw2.js → diagram-5GNKFQAL-HPywThAf.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-aL1cvl23.js → diagram-KO2AKTUF-DAzLhllz.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-DbOutAfH.js → diagram-LMA3HP47-DXYB9h8L.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-D_cWftAX.js → diagram-OG6HWLK6-vv4kz4Zo.js} +1 -1
- package/dist/web/assets/dialog-B_vC5R4B.js +5 -0
- package/dist/web/assets/{erDiagram-TEJ5UH35-DRe5V8Dx.js → erDiagram-TEJ5UH35-Cu6aVKAa.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-B5-vg_Nh.js → flowDiagram-I6XJVG4X-BKDe8WSQ.js} +1 -1
- package/dist/web/assets/{freemarker2-CXlYb2yX.js → freemarker2-DI2giuAo.js} +2 -2
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-B3iBFICN.js → ganttDiagram-6RSMTGT7-DMVLzmAE.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CZ9zsKVw.js → gitGraphDiagram-PVQCEYII-vogzYdKn.js} +1 -1
- package/dist/web/assets/{globe-JXfw4MCF.js → globe-Rnn-nKw-.js} +1 -1
- package/dist/web/assets/handlebars-B9tmKQPV.js +1 -0
- package/dist/web/assets/hooks-DK4m7-FN.js +1 -0
- package/dist/web/assets/html-B_E2U0g5.js +1 -0
- package/dist/web/assets/htmlMode-DRHM_Cwq.js +1 -0
- package/dist/web/assets/icon-button-CuSuXgr_.js +1 -0
- package/dist/web/assets/index-B6Lvy5Sr.js +1 -0
- package/dist/web/assets/{index-CWEbo6pZ.js → index-B88xAivn.js} +5 -5
- package/dist/web/assets/index-BCV57B4O.js +41 -0
- package/dist/web/assets/index-CMjLMilU.js +1 -0
- package/dist/web/assets/index-CTG-4w90.js +1 -0
- package/dist/web/assets/index-Cz73HpYH.js +122 -0
- package/dist/web/assets/index-CzvAGoau.css +1 -0
- package/dist/web/assets/index-DENY_U7o.js +1 -0
- package/dist/web/assets/index-ZO2tqdha.js +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-DQU_sN8x.js → infoDiagram-5YYISTIA-CEfSHkNq.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BVGrNzJa.js → ishikawaDiagram-YF4QCWOH-BXKZuWtD.js} +1 -1
- package/dist/web/assets/javascript-ClWqjgn3.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-DU4Md1Tq.js → journeyDiagram-JHISSGLW-wsOUYlu7.js} +1 -1
- package/dist/web/assets/{jsonMode-BMSvHUHa.js → jsonMode-DVAoDfae.js} +2 -2
- package/dist/web/assets/{kanban-definition-UN3LZRKU-DDPgCucq.js → kanban-definition-UN3LZRKU-DNsuvOrU.js} +1 -1
- package/dist/web/assets/kbd-B3m64lRd.js +1 -0
- package/dist/web/assets/{key-round-BHVp7u3Z.js → key-round-DpYSyeDH.js} +1 -1
- package/dist/web/assets/{layers-2tjjhM75.js → layers-CxqMQVmH.js} +1 -1
- package/dist/web/assets/{linear-D8yLBTVY.js → linear-BmmCZdOQ.js} +1 -1
- package/dist/web/assets/{link-CnunXc7X.js → link-DbSpzB1w.js} +1 -1
- package/dist/web/assets/liquid-CZf3xdoq.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-BiYvrSP0.js → lspLanguageFeatures-WhdC7zdf.js} +1 -1
- package/dist/web/assets/mdx-xzVEPP01.js +1 -0
- package/dist/web/assets/menu-0A0v_lRV.js +1 -0
- package/dist/web/assets/menu-styles-DWynpVVz.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-9-DTTfp6.js → mermaid-NOHMQCX5-DmKVQY9m.js} +61 -62
- package/dist/web/assets/{message-square-QM0c6Dcv.js → message-square-CfNb-MTd.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CCAuuWFZ.js → mindmap-definition-RKZ34NQL-0RzXjZ9G.js} +1 -1
- package/dist/web/assets/modal-Kpqn-nDO.js +1 -0
- package/dist/web/assets/{monaco-CrBn9oMJ.js → monaco-I1fXAMIt.js} +3 -3
- package/dist/web/assets/{paperclip-CC7nHUQ7.js → paperclip-BBrzKZQC.js} +1 -1
- package/dist/web/assets/{pencil-DIY0Hu5t.js → pencil-pzVKblxj.js} +1 -1
- package/dist/web/assets/people-C6b3eeLq.js +1 -0
- package/dist/web/assets/{pieDiagram-4H26LBE5-CXy_N5QX.js → pieDiagram-4H26LBE5-Bcvzb8TW.js} +2 -2
- package/dist/web/assets/popover-BYz89aiY.js +1 -0
- package/dist/web/assets/python-DL05HvW4.js +1 -0
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Dt44QsS8.js → quadrantDiagram-W4KKPZXB-DwNhxMxj.js} +1 -1
- package/dist/web/assets/razor-BCZ3_uDf.js +1 -0
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-BL8D7Np0.js → requirementDiagram-4Y6WPE33-D2wSGYn2.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-I5nefO3A.js → sankeyDiagram-5OEKKPKP-l3LLF--T.js} +1 -1
- package/dist/web/assets/search-field-B5czD2Pl.js +1 -0
- package/dist/web/assets/select-DGwKE4l0.js +1 -0
- package/dist/web/assets/select-yem-xN9Z.js +1 -0
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-lbPrhX8g.js → sequenceDiagram-3UESZ5HK-BAGsbTS_.js} +1 -1
- package/dist/web/assets/{server-BNBdQGor.js → server-BIPZ9Ka-.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Bw3qtv2M.js → stateDiagram-AJRCARHV-C0BHmXYX.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Be3UCkeQ.js +1 -0
- package/dist/web/assets/{textarea-CD82lB0Z.js → textarea-Bnfq7adW.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-Cfg_kgoa.js → timeline-definition-PNZ67QCA-Dt-DcRrG.js} +1 -1
- package/dist/web/assets/toggles-DxNDJZsN.js +1 -0
- package/dist/web/assets/tooltip-CHOgkFbE.js +1 -0
- package/dist/web/assets/track-B_K578io.js +1 -0
- package/dist/web/assets/{trash-2-BF_3L-qk.js → trash-2-ALAYDudv.js} +1 -1
- package/dist/web/assets/tsMode-kXxq-Lw7.js +11 -0
- package/dist/web/assets/typescript-E3_QcT_u.js +1 -0
- package/dist/web/assets/{upload-B2AMXrU-.js → upload-D7hKT2VA.js} +1 -1
- package/dist/web/assets/use-attachments-CK7y5KsN.js +2 -0
- package/dist/web/assets/use-profiles-Ncqxdw7S.js +1 -0
- package/dist/web/assets/{use-projects-BYUZwQ-q.js → use-projects-Dwy9AfAG.js} +1 -1
- package/dist/web/assets/{use-providers-DdV9gbj1.js → use-providers-BRyZjuBG.js} +1 -1
- package/dist/web/assets/use-workspaces-BBbahdwU.js +1 -0
- package/dist/web/assets/useNormalizedLogs-CRHRedwp.js +1 -0
- package/dist/web/assets/useTokenUsage-YwiF0xnT.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-CdEP03CK.js → vennDiagram-CIIHVFJN-Cr55FtiY.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-q_Enplrs.js → wardley-L42UT6IY-CtwMk9MJ.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DlL6fsid.js → wardleyDiagram-YWT4CUSO-BeyHmTu3.js} +1 -1
- package/dist/web/assets/xml-DxKND8qX.js +1 -0
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-B2OGqVKA.js → xychartDiagram-2RQKCTM6-9g34Lq8E.js} +1 -1
- package/dist/web/assets/yaml-BqpCqTY6.js +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/AgentDemoPage-Svq9Baa7.js +0 -1
- package/dist/web/assets/AgentLogo-I2etsqym.js +0 -1
- package/dist/web/assets/BranchSelect-Eb5UGWWX.js +0 -1
- package/dist/web/assets/BrandLogo-BjC1hcgv.js +0 -1
- package/dist/web/assets/ConversationPage-jEYUuSPT.js +0 -3
- package/dist/web/assets/CreateTaskInput-B_cRDkVq.js +0 -1
- package/dist/web/assets/DesignSystemPage-oM16R2Ta.js +0 -16
- package/dist/web/assets/GeneralSettingsPage-B0jFlgDl.js +0 -1
- package/dist/web/assets/McpSettingsPage-BErvd619.js +0 -1
- package/dist/web/assets/MemberAvatar-TVtoxQe8.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-BETMBdj1.js +0 -1
- package/dist/web/assets/ProfileSettingsPage-C03ZAft-.js +0 -3
- package/dist/web/assets/ProjectKanbanPage-DsPxwoVf.js +0 -86
- package/dist/web/assets/ProjectSettingsPage-BwNM6VWs.js +0 -2
- package/dist/web/assets/ProviderSettingsPage-CeNQPd74.js +0 -67
- package/dist/web/assets/SettingsMasterDetail-B_SI2h_k.js +0 -1
- package/dist/web/assets/TeamSettingsPage-BfgtMl_n.js +0 -1
- package/dist/web/assets/agent-meta-DOylIs2N.js +0 -1
- package/dist/web/assets/arc-BlZww3MO.js +0 -1
- package/dist/web/assets/channel-D9sA6Wxp.js +0 -1
- package/dist/web/assets/check-Cm7Vstpm.js +0 -1
- package/dist/web/assets/chevron-down-C6Ta4vyM.js +0 -1
- package/dist/web/assets/circle-alert-Dm2Pl-rU.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-2e2YVo9r.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-2e2YVo9r.js +0 -1
- package/dist/web/assets/code-block-OCS4YCEC-DizntuP_.js +0 -2
- package/dist/web/assets/confirm-dialog-DRpyE_qU.js +0 -1
- package/dist/web/assets/cssMode-DVorIr82.js +0 -1
- package/dist/web/assets/handlebars-BL0prPVZ.js +0 -1
- package/dist/web/assets/html-DJWeRkWe.js +0 -1
- package/dist/web/assets/htmlMode-D_fekqg9.js +0 -1
- package/dist/web/assets/index-CWbMMO6g.js +0 -122
- package/dist/web/assets/index-uXglTJ2_.css +0 -1
- package/dist/web/assets/javascript-CDfuzdfe.js +0 -1
- package/dist/web/assets/liquid-DHrNpv6c.js +0 -1
- package/dist/web/assets/mdx-CIEpgUOV.js +0 -1
- package/dist/web/assets/modal-BRoNvfhw.js +0 -1
- package/dist/web/assets/play-CIZVXiwM.js +0 -1
- package/dist/web/assets/python-BIs0pClJ.js +0 -1
- package/dist/web/assets/razor-JCx8NEwU.js +0 -1
- package/dist/web/assets/select-BmjoUfrV.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Xbc4HxDQ.js +0 -1
- package/dist/web/assets/switch-CEUHI4gI.js +0 -1
- package/dist/web/assets/task-kalEmHDc.js +0 -42
- package/dist/web/assets/task-priority-wLXAgVZZ.js +0 -1
- package/dist/web/assets/tsMode-DAHSkTAr.js +0 -11
- package/dist/web/assets/typescript-CptiLWGr.js +0 -1
- package/dist/web/assets/use-profiles-CQ-jIuiI.js +0 -1
- package/dist/web/assets/useNormalizedLogs-DdFsf-Z1.js +0 -1
- package/dist/web/assets/xml-DbPqkgZW.js +0 -1
- package/dist/web/assets/yaml-Deyq6Z5-.js +0 -1
- /package/dist/web/assets/{ProjectKanbanPage-DcpNTP1B.css → EditableTaskTitle-DcpNTP1B.css} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TaskDetail-a1jalILy.js","assets/index-Cz73HpYH.js","assets/index-CzvAGoau.css","assets/mermaid-NOHMQCX5-DmKVQY9m.js","assets/use-attachments-CK7y5KsN.js","assets/tooltip-CHOgkFbE.js","assets/kbd-B3m64lRd.js","assets/index-B6Lvy5Sr.js","assets/index-CTG-4w90.js","assets/index-CMjLMilU.js","assets/mermaid-NOHMQCX5-lI9o3AWT.css","assets/useTokenUsage-YwiF0xnT.js","assets/CreateTaskInput-SHJ1YpRe.js","assets/use-projects-Dwy9AfAG.js","assets/MemberAvatar-BG0VDZKf.js","assets/people-C6b3eeLq.js","assets/BrandLogo-CC1alVsd.js","assets/hooks-DK4m7-FN.js","assets/index-DENY_U7o.js","assets/index-ZO2tqdha.js","assets/use-providers-BRyZjuBG.js","assets/check-DYlb0A_N.js","assets/trash-2-ALAYDudv.js","assets/ExecutionPermissionSelector-DcC4IBOF.js","assets/paperclip-BBrzKZQC.js","assets/menu-0A0v_lRV.js","assets/menu-styles-DWynpVVz.js","assets/index-BCV57B4O.js","assets/useNormalizedLogs-CRHRedwp.js","assets/track-B_K578io.js","assets/EditableTaskTitle-CGVeZUSt.js","assets/chevron-up-DOkDFvIc.js","assets/at-sign-C4VhWike.js","assets/confirm-dialog-BRkrtULz.js","assets/dialog-B_vC5R4B.js","assets/modal-Kpqn-nDO.js","assets/select-DGwKE4l0.js","assets/select-yem-xN9Z.js","assets/layers-CxqMQVmH.js","assets/message-square-CfNb-MTd.js","assets/textarea-Bnfq7adW.js","assets/content-DPCGELMz.js","assets/copy-CdzVE3kf.js","assets/search-field-B5czD2Pl.js","assets/popover-BYz89aiY.js","assets/server-BIPZ9Ka-.js","assets/icon-button-CuSuXgr_.js","assets/use-workspaces-BBbahdwU.js","assets/upload-D7hKT2VA.js","assets/globe-Rnn-nKw-.js","assets/BranchSelect-D-kqavDG.js","assets/pencil-pzVKblxj.js","assets/EditableTaskTitle-DcpNTP1B.css","assets/MobileTaskDetail-DxE6ZDAS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Wr,r as u,a5 as F,aM as ct,u as Ie,j as o,an as Nn,n as ae,ax as gt,ay as Qr,aw as ne,bi as Dt,bk as Yr,bh as Hr,bl as qr,aC as ir,aG as Xr,aq as et,bm as De,a_ as Re,o as Vr,q as Bt,p as gn,s as me,v as Ke,X as Jr,S as Zr,aa as es,D as Me,ag as kt,aI as ts,t as Fe,bn as ns,ae as rs,bo as ss,bp as os,bq as is,aE as Rn,aF as jn,br as ar}from"./index-Cz73HpYH.js";import{C as as}from"./confirm-dialog-BRkrtULz.js";import{a as ls,F as cs}from"./use-workspaces-BBbahdwU.js";import{h as kn,i as us,c as ds,C as Tn}from"./CreateTaskInput-SHJ1YpRe.js";import{C as pt}from"./check-DYlb0A_N.js";import{T as fs,P as hs}from"./trash-2-ALAYDudv.js";import{S as lr}from"./hooks-DK4m7-FN.js";import{F as ms,c as gs,P as ps,a as vs,b as xs,I as bs}from"./popover-BYz89aiY.js";import{S as ys,B as An}from"./BrandLogo-CC1alVsd.js";import{M as ws}from"./message-square-CfNb-MTd.js";import{L as on}from"./layers-CxqMQVmH.js";import{e as Cs,a as Ss}from"./use-projects-Dwy9AfAG.js";import{I as Xt}from"./icon-button-CuSuXgr_.js";import{C as Dn}from"./copy-CdzVE3kf.js";import{u as Es}from"./use-providers-BRyZjuBG.js";import{M as Mn}from"./modal-Kpqn-nDO.js";import{a as Vt}from"./ExecutionPermissionSelector-DcC4IBOF.js";import{C as Ns}from"./index-B6Lvy5Sr.js";const Rs=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],In=Wr("smartphone",Rs),Ut=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function tt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function pn(e){return"nodeType"in e}function ve(e){var t,n;return e?tt(e)?e:pn(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function vn(e){const{Document:t}=ve(e);return e instanceof t}function yt(e){return tt(e)?!1:e instanceof ve(e).HTMLElement}function cr(e){return e instanceof ve(e).SVGElement}function nt(e){return e?tt(e)?e.document:pn(e)?vn(e)?e:yt(e)||cr(e)?e.ownerDocument:document:document:document}const _e=Ut?u.useLayoutEffect:u.useEffect;function $t(e){const t=u.useRef(e);return _e(()=>{t.current=e}),u.useCallback(function(){for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return t.current==null?void 0:t.current(...r)},[])}function js(){const e=u.useRef(null),t=u.useCallback((r,c)=>{e.current=setInterval(r,c)},[]),n=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function vt(e,t){t===void 0&&(t=[e]);const n=u.useRef(e);return _e(()=>{n.current!==e&&(n.current=e)},t),n}function wt(e,t){const n=u.useRef();return u.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Mt(e){const t=$t(e),n=u.useRef(null),r=u.useCallback(c=>{c!==n.current&&t?.(c,n.current),n.current=c},[]);return[n,r]}function It(e){const t=u.useRef();return u.useEffect(()=>{t.current=e},[e]),t.current}let Jt={};function Kt(e,t){return u.useMemo(()=>{if(t)return t;const n=Jt[e]==null?0:Jt[e]+1;return Jt[e]=n,e+"-"+n},[e,t])}function ur(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),c=1;c<n;c++)r[c-1]=arguments[c];return r.reduce((l,h)=>{const f=Object.entries(h);for(const[s,i]of f){const a=l[s];a!=null&&(l[s]=a+e*i)}return l},{...t})}}const Ze=ur(1),Pt=ur(-1);function ks(e){return"clientX"in e&&"clientY"in e}function xn(e){if(!e)return!1;const{KeyboardEvent:t}=ve(e.target);return t&&e instanceof t}function Ts(e){if(!e)return!1;const{TouchEvent:t}=ve(e.target);return t&&e instanceof t}function Ot(e){if(Ts(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 ks(e)?{x:e.clientX,y:e.clientY}:null}const xt=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[xt.Translate.toString(e),xt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Pn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function As(e){return e.matches(Pn)?e:e.querySelector(Pn)}const Ds={display:"none"};function Ms(e){let{id:t,value:n}=e;return F.createElement("div",{id:t,style:Ds},n)}function Is(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const c={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 F.createElement("div",{id:t,style:c,role:"status","aria-live":r,"aria-atomic":!0},n)}function Ps(){const[e,t]=u.useState("");return{announce:u.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const dr=u.createContext(null);function Os(e){const t=u.useContext(dr);u.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ls(){const[e]=u.useState(()=>new Set),t=u.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[u.useCallback(r=>{let{type:c,event:l}=r;e.forEach(h=>{var f;return(f=h[c])==null?void 0:f.call(h,l)})},[e]),t]}const zs={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
|
+
`},Fs={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 _s(e){let{announcements:t=Fs,container:n,hiddenTextDescribedById:r,screenReaderInstructions:c=zs}=e;const{announce:l,announcement:h}=Ps(),f=Kt("DndLiveRegion"),[s,i]=u.useState(!1);if(u.useEffect(()=>{i(!0)},[]),Os(u.useMemo(()=>({onDragStart(d){let{active:m}=d;l(t.onDragStart({active:m}))},onDragMove(d){let{active:m,over:p}=d;t.onDragMove&&l(t.onDragMove({active:m,over:p}))},onDragOver(d){let{active:m,over:p}=d;l(t.onDragOver({active:m,over:p}))},onDragEnd(d){let{active:m,over:p}=d;l(t.onDragEnd({active:m,over:p}))},onDragCancel(d){let{active:m,over:p}=d;l(t.onDragCancel({active:m,over:p}))}}),[l,t])),!s)return null;const a=F.createElement(F.Fragment,null,F.createElement(Ms,{id:r,value:c.draggable}),F.createElement(Is,{id:f,announcement:h}));return n?ct.createPortal(a,n):a}var ce;(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"})(ce||(ce={}));function Lt(){}function Bs(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Us(){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 je=Object.freeze({x:0,y:0});function $s(e,t){const n=Ot(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 Ks(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Gs(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Ws(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),c=Math.min(t.left+t.width,e.left+e.width),l=Math.min(t.top+t.height,e.top+e.height),h=c-r,f=l-n;if(r<c&&n<l){const s=t.width*t.height,i=e.width*e.height,a=h*f,d=a/(s+i-a);return Number(d.toFixed(4))}return 0}const Qs=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const c=[];for(const l of r){const{id:h}=l,f=n.get(h);if(f){const s=Ws(f,t);s>0&&c.push({id:h,data:{droppableContainer:l,value:s}})}}return c.sort(Ks)};function Ys(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function fr(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:je}function Hs(e){return function(n){for(var r=arguments.length,c=new Array(r>1?r-1:0),l=1;l<r;l++)c[l-1]=arguments[l];return c.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 qs=Hs(1);function hr(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 Xs(e,t,n){const r=hr(t);if(!r)return e;const{scaleX:c,scaleY:l,x:h,y:f}=r,s=e.left-h-(1-c)*parseFloat(n),i=e.top-f-(1-l)*parseFloat(n.slice(n.indexOf(" ")+1)),a=c?e.width/c:e.width,d=l?e.height/l:e.height;return{width:a,height:d,top:i,right:s+a,bottom:i+d,left:s}}const Vs={ignoreTransform:!1};function Ct(e,t){t===void 0&&(t=Vs);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:i,transformOrigin:a}=ve(e).getComputedStyle(e);i&&(n=Xs(n,i,a))}const{top:r,left:c,width:l,height:h,bottom:f,right:s}=n;return{top:r,left:c,width:l,height:h,bottom:f,right:s}}function On(e){return Ct(e,{ignoreTransform:!0})}function Js(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Zs(e,t){return t===void 0&&(t=ve(e).getComputedStyle(e)),t.position==="fixed"}function eo(e,t){t===void 0&&(t=ve(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(c=>{const l=t[c];return typeof l=="string"?n.test(l):!1})}function bn(e,t){const n=[];function r(c){if(t!=null&&n.length>=t||!c)return n;if(vn(c)&&c.scrollingElement!=null&&!n.includes(c.scrollingElement))return n.push(c.scrollingElement),n;if(!yt(c)||cr(c)||n.includes(c))return n;const l=ve(e).getComputedStyle(c);return c!==e&&eo(c,l)&&n.push(c),Zs(c,l)?n:r(c.parentNode)}return e?r(e):n}function mr(e){const[t]=bn(e,1);return t??null}function Zt(e){return!Ut||!e?null:tt(e)?e:pn(e)?vn(e)||e===nt(e).scrollingElement?window:yt(e)?e:null:null}function gr(e){return tt(e)?e.scrollX:e.scrollLeft}function pr(e){return tt(e)?e.scrollY:e.scrollTop}function an(e){return{x:gr(e),y:pr(e)}}var de;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(de||(de={}));function vr(e){return!Ut||!e?!1:e===document.scrollingElement}function xr(e){const t={x:0,y:0},n=vr(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},c=e.scrollTop<=t.y,l=e.scrollLeft<=t.x,h=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:c,isLeft:l,isBottom:h,isRight:f,maxScroll:r,minScroll:t}}const to={x:.2,y:.2};function no(e,t,n,r,c){let{top:l,left:h,right:f,bottom:s}=n;r===void 0&&(r=10),c===void 0&&(c=to);const{isTop:i,isBottom:a,isLeft:d,isRight:m}=xr(e),p={x:0,y:0},g={x:0,y:0},v={height:t.height*c.y,width:t.width*c.x};return!i&&l<=t.top+v.height?(p.y=de.Backward,g.y=r*Math.abs((t.top+v.height-l)/v.height)):!a&&s>=t.bottom-v.height&&(p.y=de.Forward,g.y=r*Math.abs((t.bottom-v.height-s)/v.height)),!m&&f>=t.right-v.width?(p.x=de.Forward,g.x=r*Math.abs((t.right-v.width-f)/v.width)):!d&&h<=t.left+v.width&&(p.x=de.Backward,g.x=r*Math.abs((t.left+v.width-h)/v.width)),{direction:p,speed:g}}function ro(e){if(e===document.scrollingElement){const{innerWidth:l,innerHeight:h}=window;return{top:0,left:0,right:l,bottom:h,width:l,height:h}}const{top:t,left:n,right:r,bottom:c}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:c,width:e.clientWidth,height:e.clientHeight}}function br(e){return e.reduce((t,n)=>Ze(t,an(n)),je)}function so(e){return e.reduce((t,n)=>t+gr(n),0)}function oo(e){return e.reduce((t,n)=>t+pr(n),0)}function yr(e,t){if(t===void 0&&(t=Ct),!e)return;const{top:n,left:r,bottom:c,right:l}=t(e);mr(e)&&(c<=0||l<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const io=[["x",["left","right"],so],["y",["top","bottom"],oo]];class yn{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=bn(n),c=br(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[l,h,f]of io)for(const s of h)Object.defineProperty(this,s,{get:()=>{const i=f(r),a=c[l]-i;return this.rect[s]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ft{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 c;(c=this.target)==null||c.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ao(e){const{EventTarget:t}=ve(e);return e instanceof t?e:nt(e)}function en(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 Se;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Se||(Se={}));function Ln(e){e.preventDefault()}function lo(e){e.stopPropagation()}var X;(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"})(X||(X={}));const wr={start:[X.Space,X.Enter],cancel:[X.Esc],end:[X.Space,X.Enter,X.Tab]},co=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case X.Right:return{...n,x:n.x+25};case X.Left:return{...n,x:n.x-25};case X.Down:return{...n,y:n.y+25};case X.Up:return{...n,y:n.y-25}}};class Cr{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 ft(nt(n)),this.windowListeners=new ft(ve(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Se.Resize,this.handleCancel),this.windowListeners.add(Se.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Se.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&yr(r),n(je)}handleKeyDown(t){if(xn(t)){const{active:n,context:r,options:c}=this.props,{keyboardCodes:l=wr,coordinateGetter:h=co,scrollBehavior:f="smooth"}=c,{code:s}=t;if(l.end.includes(s)){this.handleEnd(t);return}if(l.cancel.includes(s)){this.handleCancel(t);return}const{collisionRect:i}=r.current,a=i?{x:i.left,y:i.top}:je;this.referenceCoordinates||(this.referenceCoordinates=a);const d=h(t,{active:n,context:r.current,currentCoordinates:a});if(d){const m=Pt(d,a),p={x:0,y:0},{scrollableAncestors:g}=r.current;for(const v of g){const x=t.code,{isTop:S,isRight:b,isLeft:w,isBottom:E,maxScroll:R,minScroll:D}=xr(v),j=ro(v),C={x:Math.min(x===X.Right?j.right-j.width/2:j.right,Math.max(x===X.Right?j.left:j.left+j.width/2,d.x)),y:Math.min(x===X.Down?j.bottom-j.height/2:j.bottom,Math.max(x===X.Down?j.top:j.top+j.height/2,d.y))},P=x===X.Right&&!b||x===X.Left&&!w,k=x===X.Down&&!E||x===X.Up&&!S;if(P&&C.x!==d.x){const T=v.scrollLeft+m.x,_=x===X.Right&&T<=R.x||x===X.Left&&T>=D.x;if(_&&!m.y){v.scrollTo({left:T,behavior:f});return}_?p.x=v.scrollLeft-T:p.x=x===X.Right?v.scrollLeft-R.x:v.scrollLeft-D.x,p.x&&v.scrollBy({left:-p.x,behavior:f});break}else if(k&&C.y!==d.y){const T=v.scrollTop+m.y,_=x===X.Down&&T<=R.y||x===X.Up&&T>=D.y;if(_&&!m.x){v.scrollTo({top:T,behavior:f});return}_?p.y=v.scrollTop-T:p.y=x===X.Down?v.scrollTop-R.y:v.scrollTop-D.y,p.y&&v.scrollBy({top:-p.y,behavior:f});break}}this.handleMove(t,Ze(Pt(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()}}Cr.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=wr,onActivation:c}=t,{active:l}=n;const{code:h}=e.nativeEvent;if(r.start.includes(h)){const f=l.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),c?.({event:e.nativeEvent}),!0)}return!1}}];function zn(e){return!!(e&&"distance"in e)}function Fn(e){return!!(e&&"delay"in e)}class wn{constructor(t,n,r){var c;r===void 0&&(r=ao(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:l}=t,{target:h}=l;this.props=t,this.events=n,this.document=nt(h),this.documentListeners=new ft(this.document),this.listeners=new ft(r),this.windowListeners=new ft(ve(h)),this.initialCoordinates=(c=Ot(l))!=null?c:je,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(Se.Resize,this.handleCancel),this.windowListeners.add(Se.DragStart,Ln),this.windowListeners.add(Se.VisibilityChange,this.handleCancel),this.windowListeners.add(Se.ContextMenu,Ln),this.documentListeners.add(Se.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Fn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(zn(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:c}=this.props;c(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Se.Click,lo,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Se.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:c,props:l}=this,{onMove:h,options:{activationConstraint:f}}=l;if(!c)return;const s=(n=Ot(t))!=null?n:je,i=Pt(c,s);if(!r&&f){if(zn(f)){if(f.tolerance!=null&&en(i,f.tolerance))return this.handleCancel();if(en(i,f.distance))return this.handleStart()}if(Fn(f)&&en(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===X.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const uo={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Cn extends wn{constructor(t){const{event:n}=t,r=nt(n.target);super(t,uo,r)}}Cn.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 fo={move:{name:"mousemove"},end:{name:"mouseup"}};var ln;(function(e){e[e.RightClick=2]="RightClick"})(ln||(ln={}));class ho extends wn{constructor(t){super(t,fo,nt(t.event.target))}}ho.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ln.RightClick?!1:(r?.({event:n}),!0)}}];const tn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class mo extends wn{constructor(t){super(t,tn)}static setup(){return window.addEventListener(tn.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(tn.move.name,t)};function t(){}}}mo.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:c}=n;return c.length>1?!1:(r?.({event:n}),!0)}}];var ht;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(ht||(ht={}));var zt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(zt||(zt={}));function go(e){let{acceleration:t,activator:n=ht.Pointer,canScroll:r,draggingRect:c,enabled:l,interval:h=5,order:f=zt.TreeOrder,pointerCoordinates:s,scrollableAncestors:i,scrollableAncestorRects:a,delta:d,threshold:m}=e;const p=vo({delta:d,disabled:!l}),[g,v]=js(),x=u.useRef({x:0,y:0}),S=u.useRef({x:0,y:0}),b=u.useMemo(()=>{switch(n){case ht.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case ht.DraggableRect:return c}},[n,c,s]),w=u.useRef(null),E=u.useCallback(()=>{const D=w.current;if(!D)return;const j=x.current.x*S.current.x,C=x.current.y*S.current.y;D.scrollBy(j,C)},[]),R=u.useMemo(()=>f===zt.TreeOrder?[...i].reverse():i,[f,i]);u.useEffect(()=>{if(!l||!i.length||!b){v();return}for(const D of R){if(r?.(D)===!1)continue;const j=i.indexOf(D),C=a[j];if(!C)continue;const{direction:P,speed:k}=no(D,C,b,t,m);for(const T of["x","y"])p[T][P[T]]||(k[T]=0,P[T]=0);if(k.x>0||k.y>0){v(),w.current=D,g(E,h),x.current=k,S.current=P;return}}x.current={x:0,y:0},S.current={x:0,y:0},v()},[t,E,r,v,l,h,JSON.stringify(b),JSON.stringify(p),g,i,R,a,JSON.stringify(m)])}const po={x:{[de.Backward]:!1,[de.Forward]:!1},y:{[de.Backward]:!1,[de.Forward]:!1}};function vo(e){let{delta:t,disabled:n}=e;const r=It(t);return wt(c=>{if(n||!r||!c)return po;const l={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[de.Backward]:c.x[de.Backward]||l.x===-1,[de.Forward]:c.x[de.Forward]||l.x===1},y:{[de.Backward]:c.y[de.Backward]||l.y===-1,[de.Forward]:c.y[de.Forward]||l.y===1}}},[n,t,r])}function xo(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return wt(c=>{var l;return t==null?null:(l=r??c)!=null?l:null},[r,t])}function bo(e,t){return u.useMemo(()=>e.reduce((n,r)=>{const{sensor:c}=r,l=c.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,r)}));return[...n,...l]},[]),[e,t])}var bt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(bt||(bt={}));var cn;(function(e){e.Optimized="optimized"})(cn||(cn={}));const _n=new Map;function yo(e,t){let{dragging:n,dependencies:r,config:c}=t;const[l,h]=u.useState(null),{frequency:f,measure:s,strategy:i}=c,a=u.useRef(e),d=x(),m=vt(d),p=u.useCallback(function(S){S===void 0&&(S=[]),!m.current&&h(b=>b===null?S:b.concat(S.filter(w=>!b.includes(w))))},[m]),g=u.useRef(null),v=wt(S=>{if(d&&!n)return _n;if(!S||S===_n||a.current!==e||l!=null){const b=new Map;for(let w of e){if(!w)continue;if(l&&l.length>0&&!l.includes(w.id)&&w.rect.current){b.set(w.id,w.rect.current);continue}const E=w.node.current,R=E?new yn(s(E),E):null;w.rect.current=R,R&&b.set(w.id,R)}return b}return S},[e,l,n,d,s]);return u.useEffect(()=>{a.current=e},[e]),u.useEffect(()=>{d||p()},[n,d]),u.useEffect(()=>{l&&l.length>0&&h(null)},[JSON.stringify(l)]),u.useEffect(()=>{d||typeof f!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},f))},[f,d,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:l!=null};function x(){switch(i){case bt.Always:return!1;case bt.BeforeDragging:return n;default:return!n}}}function Sn(e,t){return wt(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function wo(e,t){return Sn(e,t)}function Co(e){let{callback:t,disabled:n}=e;const r=$t(t),c=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(r)},[r,n]);return u.useEffect(()=>()=>c?.disconnect(),[c]),c}function Gt(e){let{callback:t,disabled:n}=e;const r=$t(t),c=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(r)},[n]);return u.useEffect(()=>()=>c?.disconnect(),[c]),c}function So(e){return new yn(Ct(e),e)}function Bn(e,t,n){t===void 0&&(t=So);const[r,c]=u.useState(null);function l(){c(s=>{if(!e)return null;if(e.isConnected===!1){var i;return(i=s??n)!=null?i:null}const a=t(e);return JSON.stringify(s)===JSON.stringify(a)?s:a})}const h=Co({callback(s){if(e)for(const i of s){const{type:a,target:d}=i;if(a==="childList"&&d instanceof HTMLElement&&d.contains(e)){l();break}}}}),f=Gt({callback:l});return _e(()=>{l(),e?(f?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),h?.disconnect())},[e]),r}function Eo(e){const t=Sn(e);return fr(e,t)}const Un=[];function No(e){const t=u.useRef(e),n=wt(r=>e?r&&r!==Un&&e&&t.current&&e.parentNode===t.current.parentNode?r:bn(e):Un,[e]);return u.useEffect(()=>{t.current=e},[e]),n}function Ro(e){const[t,n]=u.useState(null),r=u.useRef(e),c=u.useCallback(l=>{const h=Zt(l.target);h&&n(f=>f?(f.set(h,an(h)),new Map(f)):null)},[]);return u.useEffect(()=>{const l=r.current;if(e!==l){h(l);const f=e.map(s=>{const i=Zt(s);return i?(i.addEventListener("scroll",c,{passive:!0}),[i,an(i)]):null}).filter(s=>s!=null);n(f.length?new Map(f):null),r.current=e}return()=>{h(e),h(l)};function h(f){f.forEach(s=>{const i=Zt(s);i?.removeEventListener("scroll",c)})}},[c,e]),u.useMemo(()=>e.length?t?Array.from(t.values()).reduce((l,h)=>Ze(l,h),je):br(e):je,[e,t])}function $n(e,t){t===void 0&&(t=[]);const n=u.useRef(null);return u.useEffect(()=>{n.current=null},t),u.useEffect(()=>{const r=e!==je;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Pt(e,n.current):je}function jo(e){u.useEffect(()=>{if(!Ut)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 ko(e,t){return u.useMemo(()=>e.reduce((n,r)=>{let{eventName:c,handler:l}=r;return n[c]=h=>{l(h,t)},n},{}),[e,t])}function Sr(e){return u.useMemo(()=>e?Js(e):null,[e])}const Kn=[];function To(e,t){t===void 0&&(t=Ct);const[n]=e,r=Sr(n?ve(n):null),[c,l]=u.useState(Kn);function h(){l(()=>e.length?e.map(s=>vr(s)?r:new yn(t(s),s)):Kn)}const f=Gt({callback:h});return _e(()=>{f?.disconnect(),h(),e.forEach(s=>f?.observe(s))},[e]),c}function Er(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return yt(t)?t:e}function Ao(e){let{measure:t}=e;const[n,r]=u.useState(null),c=u.useCallback(i=>{for(const{target:a}of i)if(yt(a)){r(d=>{const m=t(a);return d?{...d,width:m.width,height:m.height}:m});break}},[t]),l=Gt({callback:c}),h=u.useCallback(i=>{const a=Er(i);l?.disconnect(),a&&l?.observe(a),r(a?t(a):null)},[t,l]),[f,s]=Mt(h);return u.useMemo(()=>({nodeRef:f,rect:n,setRef:s}),[n,f,s])}const Do=[{sensor:Cn,options:{}},{sensor:Cr,options:{}}],Mo={current:{}},Tt={draggable:{measure:On},droppable:{measure:On,strategy:bt.WhileDragging,frequency:cn.Optimized},dragOverlay:{measure:Ct}};class mt 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 Io={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Lt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Tt,measureDroppableContainers:Lt,windowRect:null,measuringScheduled:!1},Nr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Lt,draggableNodes:new Map,over:null,measureDroppableContainers:Lt},St=u.createContext(Nr),Rr=u.createContext(Io);function Po(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mt}}}function Oo(e,t){switch(t.type){case ce.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ce.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 ce.DragEnd:case ce.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ce.RegisterDroppable:{const{element:n}=t,{id:r}=n,c=new mt(e.droppable.containers);return c.set(r,n),{...e,droppable:{...e.droppable,containers:c}}}case ce.SetDroppableDisabled:{const{id:n,key:r,disabled:c}=t,l=e.droppable.containers.get(n);if(!l||r!==l.key)return e;const h=new mt(e.droppable.containers);return h.set(n,{...l,disabled:c}),{...e,droppable:{...e.droppable,containers:h}}}case ce.UnregisterDroppable:{const{id:n,key:r}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const l=new mt(e.droppable.containers);return l.delete(n),{...e,droppable:{...e.droppable,containers:l}}}default:return e}}function Lo(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:c}=u.useContext(St),l=It(r),h=It(n?.id);return u.useEffect(()=>{if(!t&&!r&&l&&h!=null){if(!xn(l)||document.activeElement===l.target)return;const f=c.get(h);if(!f)return;const{activatorNode:s,node:i}=f;if(!s.current&&!i.current)return;requestAnimationFrame(()=>{for(const a of[s.current,i.current]){if(!a)continue;const d=As(a);if(d){d.focus();break}}})}},[r,t,c,h,l]),null}function jr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((c,l)=>l({transform:c,...r}),n):n}function zo(e){return u.useMemo(()=>({draggable:{...Tt.draggable,...e?.draggable},droppable:{...Tt.droppable,...e?.droppable},dragOverlay:{...Tt.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Fo(e){let{activeNode:t,measure:n,initialRect:r,config:c=!0}=e;const l=u.useRef(!1),{x:h,y:f}=typeof c=="boolean"?{x:c,y:c}:c;_e(()=>{if(!h&&!f||!t){l.current=!1;return}if(l.current||!r)return;const i=t?.node.current;if(!i||i.isConnected===!1)return;const a=n(i),d=fr(a,r);if(h||(d.x=0),f||(d.y=0),l.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const m=mr(i);m&&m.scrollBy({top:d.y,left:d.x})}},[t,h,f,r,n])}const Wt=u.createContext({...je,scaleX:1,scaleY:1});var $e;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})($e||($e={}));const _o=u.memo(function(t){var n,r,c,l;let{id:h,accessibility:f,autoScroll:s=!0,children:i,sensors:a=Do,collisionDetection:d=Qs,measuring:m,modifiers:p,...g}=t;const v=u.useReducer(Oo,void 0,Po),[x,S]=v,[b,w]=Ls(),[E,R]=u.useState($e.Uninitialized),D=E===$e.Initialized,{draggable:{active:j,nodes:C,translate:P},droppable:{containers:k}}=x,T=j!=null?C.get(j):null,_=u.useRef({initial:null,translated:null}),q=u.useMemo(()=>{var H;return j!=null?{id:j,data:(H=T?.data)!=null?H:Mo,rect:_}:null},[j,T]),N=u.useRef(null),[O,V]=u.useState(null),[L,M]=u.useState(null),B=vt(g,Object.values(g)),$=Kt("DndDescribedBy",h),oe=u.useMemo(()=>k.getEnabled(),[k]),ue=zo(m),{droppableRects:ee,measureDroppableContainers:A,measuringScheduled:Q}=yo(oe,{dragging:D,dependencies:[P.x,P.y],config:ue.droppable}),z=xo(C,j),re=u.useMemo(()=>L?Ot(L):null,[L]),G=Y(),K=wo(z,ue.draggable.measure);Fo({activeNode:j!=null?C.get(j):null,config:G.layoutShiftCompensation,initialRect:K,measure:ue.draggable.measure});const ie=Bn(z,ue.draggable.measure,K),ke=Bn(z?z.parentElement:null),be=u.useRef({activatorEvent:null,active:null,activeNode:z,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Te=k.getNodeFor((n=be.current.over)==null?void 0:n.id),ye=Ao({measure:ue.dragOverlay.measure}),Xe=(r=ye.nodeRef.current)!=null?r:z,Ee=D?(c=ye.rect)!=null?c:ie:null,Et=!!(ye.nodeRef.current&&ye.rect),Ve=Eo(Et?null:ie),Ge=Sr(Xe?ve(Xe):null),Ne=No(D?Te??z:null),We=To(Ne),Qe=jr(p,{transform:{x:P.x-Ve.x,y:P.y-Ve.y,scaleX:1,scaleY:1},activatorEvent:L,active:q,activeNodeRect:ie,containerNodeRect:ke,draggingNodeRect:Ee,over:be.current.over,overlayNodeRect:ye.rect,scrollableAncestors:Ne,scrollableAncestorRects:We,windowRect:Ge}),Ae=re?Ze(re,P):null,rt=Ro(Ne),st=$n(rt),Nt=$n(rt,[ie]),Pe=Ze(Qe,st),Oe=Ee?qs(Ee,Qe):null,Ye=q&&Oe?d({active:q,collisionRect:Oe,droppableRects:ee,droppableContainers:oe,pointerCoordinates:Ae}):null,Rt=Gs(Ye,"id"),[we,Le]=u.useState(null),Qt=Et?Qe:Ze(Qe,Nt),Yt=Ys(Qt,(l=we?.rect)!=null?l:null,ie),ot=u.useRef(null),jt=u.useCallback((H,Z)=>{let{sensor:J,options:pe}=Z;if(N.current==null)return;const te=C.get(N.current);if(!te)return;const fe=H.nativeEvent,xe=new J({active:N.current,activeNode:te,event:fe,options:pe,context:be,onAbort(le){if(!C.get(le))return;const{onDragAbort:ge}=B.current,Ce={id:le};ge?.(Ce),b({type:"onDragAbort",event:Ce})},onPending(le,he,ge,Ce){if(!C.get(le))return;const{onDragPending:it}=B.current,Ue={id:le,constraint:he,initialCoordinates:ge,offset:Ce};it?.(Ue),b({type:"onDragPending",event:Ue})},onStart(le){const he=N.current;if(he==null)return;const ge=C.get(he);if(!ge)return;const{onDragStart:Ce}=B.current,ze={activatorEvent:fe,active:{id:he,data:ge.data,rect:_}};ct.unstable_batchedUpdates(()=>{Ce?.(ze),R($e.Initializing),S({type:ce.DragStart,initialCoordinates:le,active:he}),b({type:"onDragStart",event:ze}),V(ot.current),M(fe)})},onMove(le){S({type:ce.DragMove,coordinates:le})},onEnd:Be(ce.DragEnd),onCancel:Be(ce.DragCancel)});ot.current=xe;function Be(le){return async function(){const{active:ge,collisions:Ce,over:ze,scrollAdjustedTranslate:it}=be.current;let Ue=null;if(ge&&it){const{cancelDrop:at}=B.current;Ue={activatorEvent:fe,active:ge,collisions:Ce,delta:it,over:ze},le===ce.DragEnd&&typeof at=="function"&&await Promise.resolve(at(Ue))&&(le=ce.DragCancel)}N.current=null,ct.unstable_batchedUpdates(()=>{S({type:le}),R($e.Uninitialized),Le(null),V(null),M(null),ot.current=null;const at=le===ce.DragEnd?"onDragEnd":"onDragCancel";if(Ue){const qt=B.current[at];qt?.(Ue),b({type:at,event:Ue})}})}}},[C]),Ht=u.useCallback((H,Z)=>(J,pe)=>{const te=J.nativeEvent,fe=C.get(pe);if(N.current!==null||!fe||te.dndKit||te.defaultPrevented)return;const xe={active:fe};H(J,Z.options,xe)===!0&&(te.dndKit={capturedBy:Z.sensor},N.current=pe,jt(J,Z))},[C,jt]),y=bo(a,Ht);jo(a),_e(()=>{ie&&E===$e.Initializing&&R($e.Initialized)},[ie,E]),u.useEffect(()=>{const{onDragMove:H}=B.current,{active:Z,activatorEvent:J,collisions:pe,over:te}=be.current;if(!Z||!J)return;const fe={active:Z,activatorEvent:J,collisions:pe,delta:{x:Pe.x,y:Pe.y},over:te};ct.unstable_batchedUpdates(()=>{H?.(fe),b({type:"onDragMove",event:fe})})},[Pe.x,Pe.y]),u.useEffect(()=>{const{active:H,activatorEvent:Z,collisions:J,droppableContainers:pe,scrollAdjustedTranslate:te}=be.current;if(!H||N.current==null||!Z||!te)return;const{onDragOver:fe}=B.current,xe=pe.get(Rt),Be=xe&&xe.rect.current?{id:xe.id,rect:xe.rect.current,data:xe.data,disabled:xe.disabled}:null,le={active:H,activatorEvent:Z,collisions:J,delta:{x:te.x,y:te.y},over:Be};ct.unstable_batchedUpdates(()=>{Le(Be),fe?.(le),b({type:"onDragOver",event:le})})},[Rt]),_e(()=>{be.current={activatorEvent:L,active:q,activeNode:z,collisionRect:Oe,collisions:Ye,droppableRects:ee,draggableNodes:C,draggingNode:Xe,draggingNodeRect:Ee,droppableContainers:k,over:we,scrollableAncestors:Ne,scrollAdjustedTranslate:Pe},_.current={initial:Ee,translated:Oe}},[q,z,Ye,Oe,C,Xe,Ee,ee,k,we,Ne,Pe]),go({...G,delta:P,draggingRect:Oe,pointerCoordinates:Ae,scrollableAncestors:Ne,scrollableAncestorRects:We});const I=u.useMemo(()=>({active:q,activeNode:z,activeNodeRect:ie,activatorEvent:L,collisions:Ye,containerNodeRect:ke,dragOverlay:ye,draggableNodes:C,droppableContainers:k,droppableRects:ee,over:we,measureDroppableContainers:A,scrollableAncestors:Ne,scrollableAncestorRects:We,measuringConfiguration:ue,measuringScheduled:Q,windowRect:Ge}),[q,z,ie,L,Ye,ke,ye,C,k,ee,we,A,Ne,We,ue,Q,Ge]),W=u.useMemo(()=>({activatorEvent:L,activators:y,active:q,activeNodeRect:ie,ariaDescribedById:{draggable:$},dispatch:S,draggableNodes:C,over:we,measureDroppableContainers:A}),[L,y,q,ie,S,$,C,we,A]);return F.createElement(dr.Provider,{value:w},F.createElement(St.Provider,{value:W},F.createElement(Rr.Provider,{value:I},F.createElement(Wt.Provider,{value:Yt},i)),F.createElement(Lo,{disabled:f?.restoreFocus===!1})),F.createElement(_s,{...f,hiddenTextDescribedById:$}));function Y(){const H=O?.autoScrollEnabled===!1,Z=typeof s=="object"?s.enabled===!1:s===!1,J=D&&!H&&!Z;return typeof s=="object"?{...s,enabled:J}:{enabled:J}}}),Bo=u.createContext(null),Gn="button",Uo="Draggable";function $o(e){let{id:t,data:n,disabled:r=!1,attributes:c}=e;const l=Kt(Uo),{activators:h,activatorEvent:f,active:s,activeNodeRect:i,ariaDescribedById:a,draggableNodes:d,over:m}=u.useContext(St),{role:p=Gn,roleDescription:g="draggable",tabIndex:v=0}=c??{},x=s?.id===t,S=u.useContext(x?Wt:Bo),[b,w]=Mt(),[E,R]=Mt(),D=ko(h,t),j=vt(n);_e(()=>(d.set(t,{id:t,key:l,node:b,activatorNode:E,data:j}),()=>{const P=d.get(t);P&&P.key===l&&d.delete(t)}),[d,t]);const C=u.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":x&&p===Gn?!0:void 0,"aria-roledescription":g,"aria-describedby":a.draggable}),[r,p,v,x,g,a.draggable]);return{active:s,activatorEvent:f,activeNodeRect:i,attributes:C,isDragging:x,listeners:r?void 0:D,node:b,over:m,setNodeRef:w,setActivatorNodeRef:R,transform:S}}function Ko(){return u.useContext(Rr)}const Go="Droppable",Wo={timeout:25};function Qo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:c}=e;const l=Kt(Go),{active:h,dispatch:f,over:s,measureDroppableContainers:i}=u.useContext(St),a=u.useRef({disabled:n}),d=u.useRef(!1),m=u.useRef(null),p=u.useRef(null),{disabled:g,updateMeasurementsFor:v,timeout:x}={...Wo,...c},S=vt(v??r),b=u.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{i(Array.isArray(S.current)?S.current:[S.current]),p.current=null},x)},[x]),w=Gt({callback:b,disabled:g||!h}),E=u.useCallback((C,P)=>{w&&(P&&(w.unobserve(P),d.current=!1),C&&w.observe(C))},[w]),[R,D]=Mt(E),j=vt(t);return u.useEffect(()=>{!w||!R.current||(w.disconnect(),d.current=!1,w.observe(R.current))},[R,w]),u.useEffect(()=>(f({type:ce.RegisterDroppable,element:{id:r,key:l,disabled:n,node:R,rect:m,data:j}}),()=>f({type:ce.UnregisterDroppable,key:l,id:r})),[r]),u.useEffect(()=>{n!==a.current.disabled&&(f({type:ce.SetDroppableDisabled,id:r,key:l,disabled:n}),a.current.disabled=n)},[r,l,n,f]),{active:h,rect:m,isOver:s?.id===r,node:R,over:s,setNodeRef:D}}function Yo(e){let{animation:t,children:n}=e;const[r,c]=u.useState(null),[l,h]=u.useState(null),f=It(n);return!n&&!r&&f&&c(f),_e(()=>{if(!l)return;const s=r?.key,i=r?.props.id;if(s==null||i==null){c(null);return}Promise.resolve(t(i,l)).then(()=>{c(null)})},[t,r,l]),F.createElement(F.Fragment,null,n,r?u.cloneElement(r,{ref:h}):null)}const Ho={x:0,y:0,scaleX:1,scaleY:1};function qo(e){let{children:t}=e;return F.createElement(St.Provider,{value:Nr},F.createElement(Wt.Provider,{value:Ho},t))}const Xo={position:"fixed",touchAction:"none"},Vo=e=>xn(e)?"transform 250ms ease":void 0,Jo=u.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:c,children:l,className:h,rect:f,style:s,transform:i,transition:a=Vo}=e;if(!f)return null;const d=c?i:{...i,scaleX:1,scaleY:1},m={...Xo,width:f.width,height:f.height,top:f.top,left:f.left,transform:xt.Transform.toString(d),transformOrigin:c&&r?$s(r,f):void 0,transition:typeof a=="function"?a(r):a,...s};return F.createElement(n,{className:h,style:m,ref:t},l)}),Zo=e=>t=>{let{active:n,dragOverlay:r}=t;const c={},{styles:l,className:h}=e;if(l!=null&&l.active)for(const[f,s]of Object.entries(l.active))s!==void 0&&(c[f]=n.node.style.getPropertyValue(f),n.node.style.setProperty(f,s));if(l!=null&&l.dragOverlay)for(const[f,s]of Object.entries(l.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(c))n.node.style.setProperty(s,i);h!=null&&h.active&&n.node.classList.remove(h.active)}},ei=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:xt.Transform.toString(t)},{transform:xt.Transform.toString(n)}]},ti={duration:250,easing:"ease",keyframes:ei,sideEffects:Zo({styles:{active:{opacity:"0"}}})};function ni(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:c}=e;return $t((l,h)=>{if(t===null)return;const f=n.get(l);if(!f)return;const s=f.node.current;if(!s)return;const i=Er(h);if(!i)return;const{transform:a}=ve(h).getComputedStyle(h),d=hr(a);if(!d)return;const m=typeof t=="function"?t:ri(t);return yr(s,c.draggable.measure),m({active:{id:l,data:f.data,node:s,rect:c.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:h,rect:c.dragOverlay.measure(i)},droppableContainers:r,measuringConfiguration:c,transform:d})})}function ri(e){const{duration:t,easing:n,sideEffects:r,keyframes:c}={...ti,...e};return l=>{let{active:h,dragOverlay:f,transform:s,...i}=l;if(!t)return;const a={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-a.x,y:s.y-a.y,...d},p=c({...i,active:h,dragOverlay:f,transform:{initial:s,final:m}}),[g]=p,v=p[p.length-1];if(JSON.stringify(g)===JSON.stringify(v))return;const x=r?.({active:h,dragOverlay:f,...i}),S=f.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(b=>{S.onfinish=()=>{x?.(),b()}})}}let Wn=0;function si(e){return u.useMemo(()=>{if(e!=null)return Wn++,Wn},[e])}const oi=F.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:c,transition:l,modifiers:h,wrapperElement:f="div",className:s,zIndex:i=999}=e;const{activatorEvent:a,active:d,activeNodeRect:m,containerNodeRect:p,draggableNodes:g,droppableContainers:v,dragOverlay:x,over:S,measuringConfiguration:b,scrollableAncestors:w,scrollableAncestorRects:E,windowRect:R}=Ko(),D=u.useContext(Wt),j=si(d?.id),C=jr(h,{activatorEvent:a,active:d,activeNodeRect:m,containerNodeRect:p,draggingNodeRect:x.rect,over:S,overlayNodeRect:x.rect,scrollableAncestors:w,scrollableAncestorRects:E,transform:D,windowRect:R}),P=Sn(m),k=ni({config:r,draggableNodes:g,droppableContainers:v,measuringConfiguration:b}),T=P?x.setRef:void 0;return F.createElement(qo,null,F.createElement(Yo,{animation:k},d&&j?F.createElement(Jo,{key:j,id:d.id,ref:T,as:f,activatorEvent:a,adjustScale:t,className:s,transition:l,rect:P,style:{zIndex:i,...c},transform:C},n):null))}),kr=768;function ii(e){const t=window.matchMedia(`(max-width: ${kr-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function ai(){return window.innerWidth<kr}function li(){return!1}function Tr(){return u.useSyncExternalStore(ii,ai,li)}function ci(e,t){const n=[];if(!e||e.length===0)return n;const r=e.some(l=>l.status==="ACTIVE");return e.some(l=>l.sessions?.some(h=>h.status===Nn.RUNNING||h.status===Nn.PENDING))&&n.push(t("正在运行的 Agent 将被停止")),r&&(n.push(t("分支上未合并的变更将丢失")),n.push(t("关联的工作目录(worktree)将被清理"))),n}function ui({isOpen:e,onClose:t,onConfirm:n,taskId:r,taskTitle:c,workspaces:l,isLoading:h}){const{t:f}=Ie(),{data:s,isLoading:i}=ls(l===void 0&&e?r:""),a=l??s,d=l===void 0&&e&&i,m=u.useMemo(()=>ci(a,f),[a,f]);return o.jsx(as,{isOpen:e,onClose:t,onConfirm:n,title:f("删除任务"),description:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:f("确认删除任务「{title}」?此操作不可撤销。",{title:c})}),d?o.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f("加载中...")}):m.length>0?o.jsx("ul",{className:"mt-2 space-y-1",children:m.map((p,g)=>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:p})]},g))}):null]}),confirmText:f("删除"),variant:"danger",isLoading:h||d})}const di="flex w-full min-w-0 items-center gap-2.5 rounded-md px-2 text-sm pointer-coarse:text-[15px] text-left transition-[background-color,box-shadow,color] duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",fi="h-8 pointer-coarse:h-10";function ut(e){return ae(di,fi,e?"bg-background text-foreground shadow-xs ring-1 ring-border/80":"text-foreground/80 hover:bg-accent hover:text-foreground active:bg-foreground/[0.06]")}const un=60,dn=60*un,nn=24*dn,Qn=new Map;function hi(e){let t=Qn.get(e);return t||(t={monthDay:new Intl.DateTimeFormat(e,{month:"numeric",day:"numeric"}),yearMonth:new Intl.DateTimeFormat(e,{year:"numeric",month:"numeric"})},Qn.set(e,t)),t}function mi(e,t,n){const r=new Date(e);if(!Number.isFinite(r.getTime()))return"—";const c=new Date,l=Math.max(0,Math.floor((c.getTime()-r.getTime())/1e3));if(l<un)return t("now");if(l<dn)return t("{count}m",{count:Math.floor(l/un)});if(l<nn)return t("{count}h",{count:Math.floor(l/dn)});if(l<7*nn)return t("{count}d",{count:Math.floor(l/nn)});const h=hi(n);return(r.getFullYear()===c.getFullYear()?h.monthDay:h.yearMonth).format(r)}let gi;function pi(e,t,n){const r=e.replace(/\s+/g," ").trim();if(n(r)<=t)return r;if(n("…")>t)return"";const c=typeof Intl.Segmenter>"u"?Array.from(r):Array.from((gi??=new Intl.Segmenter(void 0,{granularity:"grapheme"})).segment(r),f=>f.segment);let l=0,h=c.length;for(;l<h;){const f=Math.ceil((l+h)/2);n(`${c.slice(0,f).join("")}…`)<=t?l=f:h=f-1}return`${c.slice(0,l).join("")}…`}const dt=new Map,At=new Set;let He;function Yn(){for(const e of At)dt.get(e)?.(document.visibilityState!=="hidden")}function vi(e,t){if(typeof IntersectionObserver>"u")return()=>{};if(!He){const n=new IntersectionObserver(r=>{if(He===n)for(const c of r){const l=dt.get(c.target);if(!l)continue;const h=c.isIntersecting&&c.intersectionRatio>0;h?At.add(c.target):At.delete(c.target),l(h&&document.visibilityState!=="hidden")}});He=n,document.addEventListener("visibilitychange",Yn)}return dt.set(e,t),He.observe(e),()=>{dt.delete(e),At.delete(e),He?.unobserve(e),dt.size===0&&(He?.disconnect(),He=void 0,document.removeEventListener("visibilitychange",Yn))}}const fn=4200,Hn=fn*.4,xi=1e3/30;function bi(e){try{return e?.getContext("2d")??null}catch{return null}}function yi({hostRef:e,text:t,variant:n,animate:r}){const c=u.useRef(null);return u.useLayoutEffect(()=>{const l=e.current,h=c.current,f=bi(h);if(!l||!h||!f)return;const s=l.closest(".task-row"),i=matchMedia("(prefers-reduced-motion: reduce)"),a=matchMedia("(hover: hover)");let d=0,m,p=0,g=0,v=0,x=0,S=0,b=0,w="",E="",R="",D=!1;function j(){cancelAnimationFrame(d),clearTimeout(m),d=0,m=void 0}function C(N){if(!(!f||!l)){if(f.clearRect(0,0,v,x),f.globalCompositeOperation="source-over",n==="project"){const O=f.createLinearGradient(b*.6,0,b*2.6,0);O.addColorStop(0,w),O.addColorStop(1,E),f.fillStyle=O}else f.fillStyle=w;if(f.fillText(R,0,S),n==="running"&&N<1){const O=(-1.5+1.5*N)*v,V=f.createLinearGradient(O,0,O+v*2.5,0),L=M=>`rgba(0, 0, 0, ${M})`;V.addColorStop(0,L(1)),V.addColorStop(.4,L(1)),V.addColorStop(.5,L(.4)),V.addColorStop(.6,L(1)),V.addColorStop(1,L(1)),f.globalCompositeOperation="destination-in",f.fillStyle=V,f.fillRect(0,0,v,x),f.globalCompositeOperation="source-over"}l.dataset.gradientReady="true"}}function P(N){if(D)return;const O=(N-p)%fn;N-g>=xi&&(C(Math.min(O/Hn,1)),g=N),O>=Hn?(C(1),m=setTimeout(()=>{d=requestAnimationFrame(P)},fn-O)):d=requestAnimationFrame(P)}function k(){if(j(),!l||!h||!f||D||(delete l.dataset.gradientReady,v=l.clientWidth,x=l.clientHeight,!v||!x))return;const N=getComputedStyle(l),O=Math.min(window.devicePixelRatio||1,3);h.width=Math.ceil(v*O),h.height=Math.ceil(x*O),f.setTransform(O,0,0,O,0,0),f.font=`${N.fontStyle} ${N.fontWeight} ${N.fontSize} ${N.fontFamily}`,f.textBaseline="alphabetic",b=Number.parseFloat(N.fontSize);const V=f.measureText("Mg"),L=V.fontBoundingBoxAscent??b*.8,M=V.fontBoundingBoxDescent??b*.2;S=(x-L-M)/2+L,w=N.color,E=N.getPropertyValue("--muted-foreground").trim()||w,R=pi(t,v,$=>f.measureText($).width);try{C(1)}catch{return}const B=i.matches||s?.matches(":focus-visible")||a.matches&&s?.matches(":hover");n==="running"&&r&&!B&&(p=performance.now(),g=0,d=requestAnimationFrame(P))}const T=typeof ResizeObserver>"u"?void 0:new ResizeObserver(k);T?.observe(l);const _=new MutationObserver(k);_.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style"]}),_.observe(l,{attributes:!0,attributeFilter:["class","style"]});const q=()=>{j(),delete l.dataset.gradientReady};h.addEventListener("contextlost",q),h.addEventListener("contextrestored",k),i.addEventListener("change",k),a.addEventListener("change",k);for(const N of["pointerenter","pointerleave","focus","blur"])s?.addEventListener(N,k);return window.addEventListener("resize",k),document.fonts?.addEventListener("loadingdone",k),k(),()=>{D=!0,j(),T?.disconnect(),_.disconnect(),i.removeEventListener("change",k),a.removeEventListener("change",k);for(const N of["pointerenter","pointerleave","focus","blur"])s?.removeEventListener(N,k);window.removeEventListener("resize",k),document.fonts?.removeEventListener("loadingdone",k),h.removeEventListener("contextlost",q),h.removeEventListener("contextrestored",k),delete l.dataset.gradientReady,h.width=0,h.height=0}},[e,t,n,r]),o.jsx("canvas",{ref:c,className:"task-gradient-text__canvas","aria-hidden":"true"})}function qn({text:e,variant:t,animate:n=!0,className:r}){const c=u.useRef(null),[l,h]=u.useState(!1);return u.useEffect(()=>{if(c.current)return vi(c.current,h)},[]),o.jsxs("span",{ref:c,className:ae("task-gradient-text",r),"data-text-effect":t,children:[o.jsx("span",{className:"task-gradient-text__text",children:e}),l&&o.jsx(yi,{hostRef:c,text:e,variant:t,animate:n})]})}const Ar=u.createContext(null),wi=3e4;function Ci(e=wi){const[,t]=u.useState(0);u.useEffect(()=>{const n=setInterval(()=>t(r=>r+1),e);return()=>clearInterval(n)},[e])}function Si(e){const t=qr(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 rn="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",Xn="px-2 pb-1 pt-1.5 text-xs font-medium text-muted-foreground",Vn=o.jsx("div",{className:"-mx-1 my-1 h-px bg-border/60"});function Ei({task:e,status:t,isSelected:n,project:r,showProject:c,onSelectTask:l,onTaskStatusChange:h,onDeleteTask:f,onTaskPriorityChange:s,disableDrag:i}){const{t:a,locale:d}=Ie(),m=u.useContext(Ar),p=u.useRef(null),g=!!e.projectArchivedAt,v=g||!!i,{attributes:x,listeners:S,setNodeRef:b,isDragging:w}=$o({id:e.id,data:{task:e,fromStatus:t},disabled:v}),E=u.useCallback(M=>{p.current=M,b(M),m&&(M?m.registry.set(e.id,M):m.registry.delete(e.id))},[b,m,e.id]);u.useEffect(()=>()=>{m?.registry.delete(e.id)},[e.id,m]);const[R,D]=u.useState(null),[j,C]=u.useState(!1),P=u.useRef(null),k=u.useRef(null),T=u.useCallback(M=>{g||!h&&!f&&!s||(M.preventDefault(),D({x:M.clientX,y:M.clientY}))},[g,h,f,s]),_=u.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null)},[]),q=u.useCallback(M=>{if(!i||g||!h&&!f)return;const B=M.touches[0];if(!B)return;const{clientX:$,clientY:oe}=B;k.current=setTimeout(()=>{k.current=null,D({x:$,y:oe})},500)},[i,g,h,f]);u.useEffect(()=>{if(!R)return;const M=()=>D(null),B=oe=>{P.current&&!P.current.contains(oe.target)&&M()},$=oe=>{oe.key==="Escape"&&M()};return document.addEventListener("mousedown",B),document.addEventListener("touchstart",B),document.addEventListener("keydown",$),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("touchstart",B),document.removeEventListener("keydown",$),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M)}},[R]),u.useLayoutEffect(()=>{const M=P.current;if(!R||!M)return;const B=8;M.style.left=`${Math.max(B,Math.min(R.x,window.innerWidth-M.offsetWidth-B))}px`,M.style.top=`${Math.max(B,Math.min(R.y,window.innerHeight-M.offsetHeight-B))}px`},[R]);const N=r?r.name:void 0,O=c?r:void 0,V=e.updatedAt?mi(e.updatedAt,a,d):null,{titleClass:L}=gt[t];return o.jsxs(o.Fragment,{children:[o.jsxs("button",{ref:E,type:"button",onClick:()=>l(e.id),onContextMenu:T,onTouchStart:q,onTouchEnd:_,onTouchMove:_,title:O?`${e.title} · ${O.name}`:e.title,"aria-label":N?`${e.title} — ${N}`:e.title,"aria-current":n||void 0,"data-sidebar-item":"",className:ae("task-row animate-task-enter",ut(n),w&&"opacity-30"),...v?{}:S,...v?{}:x,children:[t===ne.Running?o.jsx(qn,{text:e.title,variant:"running",animate:!n,className:ae("min-w-0 flex-1 truncate",L)}):o.jsx("span",{className:ae("min-w-0 flex-1 truncate",L),children:e.title}),e.priority!==void 0&&e.priority!==Dt.NORMAL&&o.jsx(kn,{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?a("源码已删除"):a("已删除")}),(V||O)&&o.jsx("span",{className:"task-row-meta",children:o.jsxs("span",{className:"flex items-center gap-1",children:[O&&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(qn,{text:Si(O.name),variant:"project",className:O.color})}),V&&o.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:V})]})})]}),R&&o.jsxs("div",{ref:P,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:[h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:Xn,children:a("Move to")}),Yr.filter(M=>M!==t).map(M=>{const{icon:B,label:$,accentClass:oe}=gt[M];return o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{h(e.id,M),D(null)},className:rn,children:[o.jsx(B,{className:ae("size-3.5 shrink-0",oe)}),o.jsx("span",{children:a($)})]},M)})]}),s&&o.jsxs(o.Fragment,{children:[h&&Vn,o.jsx("div",{className:Xn,children:a("Priority")}),Hr.map(M=>{const B=(e.priority??Dt.NORMAL)===M.value;return o.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":B,onClick:()=>{s(e.id,M.value),D(null)},className:rn,children:[o.jsx(kn,{priority:M.value}),o.jsx("span",{className:"flex-1",children:a(M.label)}),B&&o.jsx(pt,{className:"size-3.5 shrink-0 text-foreground","aria-hidden":!0})]},M.value)})]}),f&&o.jsxs(o.Fragment,{children:[(h||s)&&Vn,o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{C(!0),D(null)},className:ae(rn,"text-destructive-ink hover:bg-destructive/10 hover:text-destructive-ink focus-visible:bg-destructive/10"),children:[o.jsx(fs,{className:"size-3.5 shrink-0","aria-hidden":!0}),o.jsx("span",{children:a("Delete Task")})]})]})]}),o.jsx(ui,{isOpen:j,onClose:()=>C(!1),onConfirm:()=>{f?.(e.id),C(!1)},taskId:e.id,taskTitle:e.title})]})}const Ni=u.memo(function({title:t,tasks:n,status:r,defaultOpen:c,selectedTaskId:l,onSelectTask:h,projects:f,showProject:s=!0,isDragging:i,dragFromStatus:a,onTaskStatusChange:d,onDeleteTask:m,onTaskPriorityChange:p,disableDrag:g}){const{t:v}=Ie(),[x,S]=u.useState(c);Ci();const b=n.length===0,w=i&&a===r,E=i&&a!==r,{setNodeRef:R,isOver:D}=Qo({id:`group-${r}`,data:{status:r}}),j=r===ne.Review,C=v(t),{icon:P,accentClass:k}=gt[r],T=u.useId(),_=i?w:x,q=_&&!E&&!b;return o.jsxs("div",{className:q?"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:()=>!i&&S(N=>!N),"aria-expanded":x,"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(P,{className:ae("mr-1.5 size-4 shrink-0 -translate-y-px",k)}),o.jsx("span",{id:T,className:"truncate",children:C}),o.jsx(Qr,{size:14,"aria-hidden":!0,className:ae("shrink-0 text-muted-foreground transition-transform duration-150 group-hover/header:text-muted-foreground",_&&"rotate-90")}),j&&!b?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})]})}),E&&o.jsx("div",{ref:R,className:ae("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",D?"border-foreground/30 bg-foreground/[0.04] text-foreground/80":"border-border bg-foreground/[0.02] text-muted-foreground"),children:D?v("Drop into {title}",{title:C}):v("Drop here")}),q&&o.jsx("div",{ref:w?void 0:R,role:"group","aria-labelledby":T,className:"mt-0.5 flex flex-col gap-px px-2",children:n.map(N=>{const O=l===N.id,V=N.projectId?f.find(L=>L.id===N.projectId):void 0;return o.jsx(Ei,{task:N,status:r,isSelected:O,project:V,showProject:s,onSelectTask:h,onTaskStatusChange:N.projectArchivedAt?void 0:d,onDeleteTask:N.projectArchivedAt?void 0:m,onTaskPriorityChange:N.projectArchivedAt?void 0:p,disableDrag:g},N.id)})})]})}),Ri=12,ji=50;function ki({isOpen:e,onClose:t,tasks:n,projects:r,onSelectTask:c}){const{t:l}=Ie(),[h,f]=u.useState(""),[s,i]=u.useState(0),a=u.useRef(null);u.useEffect(()=>{e&&(f(""),i(0))},[e]);const d=u.useMemo(()=>{const g=h.trim().toLowerCase();return g?n.filter(v=>v.title.toLowerCase().includes(g)).slice(0,ji):n.slice(0,Ri)},[n,h]);u.useEffect(()=>{i(0)},[h]),u.useEffect(()=>{a.current?.children[s]?.scrollIntoView({block:"nearest"})},[s]);const m=u.useCallback(g=>{c(g),t()},[c,t]),p=u.useCallback(g=>{if(g.key==="Escape")g.preventDefault(),t();else if(g.key==="ArrowDown")g.preventDefault(),i(v=>Math.min(v+1,d.length-1));else if(g.key==="ArrowUp")g.preventDefault(),i(v=>Math.max(v-1,0));else if(g.key==="Enter"&&!g.nativeEvent.isComposing){g.preventDefault();const v=d[s];v&&m(v.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(lr,{size:15,className:"text-muted-foreground/70 shrink-0"}),o.jsx("input",{value:h,onChange:g=>f(g.target.value),onKeyDown:p,placeholder:l("Search tasks..."),"aria-label":l("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:l("Recent tasks")}),o.jsx("div",{ref:a,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:d.map((g,v)=>{const x=r.find(w=>w.id===g.projectId),{icon:S,iconClass:b}=gt[g.status];return o.jsxs("button",{onClick:()=>m(g.id),onMouseEnter:()=>i(v),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
7
|
+
${v===s?"bg-accent":""}`,children:[o.jsx(S,{className:`${b} size-4 shrink-0`}),o.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:g.title,children:g.title}),x&&o.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground",children:x.name})]},g.id)})})]}):o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:l("No matching tasks")})]})]}):null}const Ti=260,Ai=220;function Di(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??Dt.NORMAL)-(n.priority??Dt.NORMAL)),t}const Mi=[{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 Ii(){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,onSelectTask:r,filterProjectId:c,setFilterProjectId:l,width:h=320,onCreateTask:f,onCreateProject:s,isCreateActive:i,onTaskStatusChange:a,onDeleteTask:d,onTaskPriorityChange:m,isLoading:p=!1}){const{t:g}=Ie(),{preserveDesktopSearch:v}=ir(),x=Tr(),[S,b]=u.useState(null),[w,E]=u.useState(null),[R,D]=u.useState(!1),j=u.useRef(new Map),C=u.useRef(new Set),P=u.useRef(new Map),k=u.useMemo(()=>({registry:j.current}),[]),T=u.useCallback(A=>{A.remove(),C.current.delete(A)},[]),_=c?e.filter(A=>A.projectId===c):e,q=u.useCallback((A,Q)=>{const z=document.querySelector(`[data-task-group-status="${A}"]`);if(!z)return null;const G=(z.querySelector("button")??z).getBoundingClientRect();return G.width===0||G.height===0?null:new DOMRect(G.left,G.bottom+2,Q.width,Q.height)},[]),N=u.useCallback((A,Q,z,re=!1)=>{const G=document.createElement("div");G.setAttribute("aria-hidden","true"),G.innerHTML=z,G.querySelectorAll("[data-gradient-ready]").forEach(Te=>Te.removeAttribute("data-gradient-ready")),G.querySelectorAll(".task-gradient-text__canvas").forEach(Te=>Te.remove());const K=G.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=`${A.width}px`,K.style.height=`${A.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(G.style,{position:"fixed",left:`${A.left}px`,top:`${A.top}px`,width:`${A.width}px`,height:`${A.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(G),C.current.add(G);const ie=Q.left-A.left,ke=Q.top-A.top;G.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${ie}px, ${ke}px)`,opacity:re?.12:.96,offset:1}],{duration:re?Ai:Ti,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>T(G),()=>T(G))},[T]);u.useLayoutEffect(()=>{const A=window.matchMedia("(prefers-reduced-motion: reduce)").matches,Q=new Map;for(const z of _){const re=j.current.get(z.id);if(!re)continue;const G={status:z.status,rect:re.getBoundingClientRect(),html:re.outerHTML};if(Q.set(z.id,G),A)continue;const K=P.current.get(z.id);if(!K||K.status===z.status)continue;const ie=G.rect.left-K.rect.left,ke=G.rect.top-K.rect.top;Math.abs(ie)<1&&Math.abs(ke)<1||N(K.rect,G.rect,K.html)}if(!A)for(const[z,re]of P.current){if(Q.has(z))continue;const G=_.find(ie=>ie.id===z);if(!G||G.status===re.status)continue;const K=q(G.status,re.rect);K&&N(re.rect,K,re.html,!0)}P.current=Q},[_,N,q]),u.useEffect(()=>()=>{for(const A of C.current)A.remove();C.current.clear()},[]);const O=Us(Bs(Cn,{activationConstraint:{distance:8}})),V=u.useCallback(A=>{const Q=A.active.data.current?.task,z=A.active.data.current?.fromStatus;Q&&b(Q),z&&E(z)},[]),L=u.useCallback(A=>{b(null),E(null);const{active:Q,over:z}=A;if(!z)return;const re=Q.data.current?.task,G=Q.data.current?.fromStatus,K=z.data.current?.status;!re||!G||!K||re.projectArchivedAt||G!==K&&a?.(re.id,K)},[a]),$=!!!(c?t.find(A=>A.id===c)??null:null)?.archivedAt,oe=Di(_),ue=S?gt[S.status]:null,ee=u.useCallback(A=>{if(A.key!=="ArrowDown"&&A.key!=="ArrowUp"||A.altKey||A.ctrlKey||A.metaKey||A.shiftKey)return;const Q=Array.from(A.currentTarget.querySelectorAll("[data-sidebar-item]:not(:disabled)")),z=Q.indexOf(A.target);z!==-1&&(A.preventDefault(),Q[z+(A.key==="ArrowDown"?1:-1)]?.focus())},[]);return o.jsxs("div",{className:"@container h-full flex flex-col flex-shrink-0",style:{width:h},onKeyDown:ee,children:[o.jsxs("div",{className:"px-2 pt-2 pb-1 flex flex-col gap-px flex-shrink-0",children:[s&&o.jsxs("button",{type:"button",onClick:s,"data-sidebar-item":"",className:ut(!1),children:[o.jsx(ms,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:g("New Project")})]}),o.jsxs("button",{type:"button",onClick:f,disabled:!$,"aria-current":i||void 0,"data-sidebar-item":"",className:ae(ut(!!i),"disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),title:$?void 0:g("Deleted projects are read-only"),children:[o.jsx(ys,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:g("New Task")})]}),o.jsxs("button",{type:"button",onClick:()=>D(!0),"data-sidebar-item":"",className:ut(!1),children:[o.jsx(lr,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:g("Search")})]}),o.jsxs(Xr,{to:v("/conversations"),"data-sidebar-item":"",className:ut(!1),children:[o.jsx(ws,{size:16,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:g("对话")})]})]}),p?o.jsx(Ii,{}):_.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(on,{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:g("No tasks")}),$&&f?o.jsx("button",{type:"button",onClick:f,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:g("New Task")}):null]}):o.jsx(Ar.Provider,{value:k,children:o.jsxs(_o,{sensors:O,onDragStart:V,onDragEnd:L,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:Mi.map(({status:A,title:Q,defaultOpen:z})=>o.jsx(Ni,{title:Q,tasks:oe[A],status:A,defaultOpen:z,selectedTaskId:n,onSelectTask:r,projects:t,showProject:!c,isDragging:S!==null,dragFromStatus:w,onTaskStatusChange:a,onDeleteTask:d,onTaskPriorityChange:m,disableDrag:x},A))})}),o.jsx(oi,{dropAnimation:null,children:S&&ue?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(ue.icon,{className:ae("size-4 shrink-0",ue.iconClass)}),o.jsx("span",{className:"truncate",title:S.title,children:S.title})]}):null})]})}),!p&&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:g("{count} tasks",{count:_.length})}),c?o.jsx("button",{type:"button",onClick:()=>l(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:g("Clear filter")}):null]}),o.jsx(ki,{isOpen:R,onClose:()=>D(!1),tasks:_,projects:t,onSelectTask:r})]})}function En(e){switch(e){case De.TODO:return ne.Pending;case De.IN_PROGRESS:return ne.Running;case De.IN_REVIEW:return ne.Review;case De.DONE:return ne.Done;case De.CANCELLED:return ne.Cancelled}}function Pi(e){switch(e){case ne.Pending:return De.TODO;case ne.Running:return De.IN_PROGRESS;case ne.Review:return De.IN_REVIEW;case ne.Done:return De.DONE;case ne.Cancelled:return De.CANCELLED}}function Oi(e){switch(e){case Re.CLAUDE_CODE:return"Claude Code";case Re.GEMINI_CLI:return"Gemini CLI";case Re.CURSOR_AGENT:return"Cursor Agent";case Re.CODEX:return"Codex";case Re.QWEN_CODE:return"Qwen Code";case Re.KIRO_CLI:return"Kiro CLI";case Re.OPENCODE:return"OpenCode";case Re.PI_CODING_AGENT:return"Pi Coding Agent";case Re.GROK_BUILD:return"Grok Build";case Re.MINION_CODE:return"Minion Code";case Re.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const Ft=["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 Dr(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 Li(e){return{id:e.id,name:e.name,color:e.color||Ft[Dr(e.name,Ft.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function zi(e,t){const n=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===et.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:En(e.status),priority:e.priority,agent:e.latestAgentType?Oi(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 Fi(e,t){const n=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===et.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||Ft[Dr(t.name,Ft.length)],title:e.title,status:En(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}}var _i=Object.defineProperty,_t=Object.getOwnPropertySymbols,Mr=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?_i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hn=(e,t)=>{for(var n in t||(t={}))Mr.call(t,n)&&Zn(e,n,t[n]);if(_t)for(var n of _t(t))Ir.call(t,n)&&Zn(e,n,t[n]);return e},mn=(e,t)=>{var n={};for(var r in e)Mr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_t)for(var r of _t(e))t.indexOf(r)<0&&Ir.call(e,r)&&(n[r]=e[r]);return n};var qe;(e=>{const t=class U{constructor(s,i,a,d){if(this.version=s,this.errorCorrectionLevel=i,this.modules=[],this.isFunction=[],s<U.MIN_VERSION||s>U.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(a);if(this.drawCodewords(p),d==-1){let g=1e9;for(let v=0;v<8;v++){this.applyMask(v),this.drawFormatBits(v);const x=this.getPenaltyScore();x<g&&(d=v,g=x),this.applyMask(v)}}c(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(s,i){const a=e.QrSegment.makeSegments(s);return U.encodeSegments(a,i)}static encodeBinary(s,i){const a=e.QrSegment.makeBytes(s);return U.encodeSegments([a],i)}static encodeSegments(s,i,a=1,d=40,m=-1,p=!0){if(!(U.MIN_VERSION<=a&&a<=d&&d<=U.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,v;for(g=a;;g++){const w=U.getNumDataCodewords(g,i)*8,E=h.getTotalBits(s,g);if(E<=w){v=E;break}if(g>=d)throw new RangeError("Data too long")}for(const w of[U.Ecc.MEDIUM,U.Ecc.QUARTILE,U.Ecc.HIGH])p&&v<=U.getNumDataCodewords(g,w)*8&&(i=w);let x=[];for(const w of s){n(w.mode.modeBits,4,x),n(w.numChars,w.mode.numCharCountBits(g),x);for(const E of w.getData())x.push(E)}c(x.length==v);const S=U.getNumDataCodewords(g,i)*8;c(x.length<=S),n(0,Math.min(4,S-x.length),x),n(0,(8-x.length%8)%8,x),c(x.length%8==0);for(let w=236;x.length<S;w^=253)n(w,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((w,E)=>b[E>>>3]|=w<<7-(E&7)),new U(g,i,b,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 a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2==0),this.setFunctionModule(a,6,a%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 a=0;a<i;a++)for(let d=0;d<i;d++)a==0&&d==0||a==0&&d==i-1||a==i-1&&d==0||this.drawAlignmentPattern(s[a],s[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(s){const i=this.errorCorrectionLevel.formatBits<<3|s;let a=i;for(let m=0;m<10;m++)a=a<<1^(a>>>9)*1335;const d=(i<<10|a)^21522;c(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 a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const i=this.version<<12|s;c(i>>>18==0);for(let a=0;a<18;a++){const d=r(i,a),m=this.size-11+a%3,p=Math.floor(a/3);this.setFunctionModule(m,p,d),this.setFunctionModule(p,m,d)}}drawFinderPattern(s,i){for(let a=-4;a<=4;a++)for(let d=-4;d<=4;d++){const m=Math.max(Math.abs(d),Math.abs(a)),p=s+d,g=i+a;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,m!=2&&m!=4)}}drawAlignmentPattern(s,i){for(let a=-2;a<=2;a++)for(let d=-2;d<=2;d++)this.setFunctionModule(s+d,i+a,Math.max(Math.abs(d),Math.abs(a))!=1)}setFunctionModule(s,i,a){this.modules[i][s]=a,this.isFunction[i][s]=!0}addEccAndInterleave(s){const i=this.version,a=this.errorCorrectionLevel;if(s.length!=U.getNumDataCodewords(i,a))throw new RangeError("Invalid argument");const d=U.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][i],m=U.ECC_CODEWORDS_PER_BLOCK[a.ordinal][i],p=Math.floor(U.getNumRawDataModules(i)/8),g=d-p%d,v=Math.floor(p/d);let x=[];const S=U.reedSolomonComputeDivisor(m);for(let w=0,E=0;w<d;w++){let R=s.slice(E,E+v-m+(w<g?0:1));E+=R.length;const D=U.reedSolomonComputeRemainder(R,S);w<g&&R.push(0),x.push(R.concat(D))}let b=[];for(let w=0;w<x[0].length;w++)x.forEach((E,R)=>{(w!=v-m||R>=g)&&b.push(E[w])});return c(b.length==p),b}drawCodewords(s){if(s.length!=Math.floor(U.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let i=0;for(let a=this.size-1;a>=1;a-=2){a==6&&(a=5);for(let d=0;d<this.size;d++)for(let m=0;m<2;m++){const p=a-m,v=(a+1&2)==0?this.size-1-d:d;!this.isFunction[v][p]&&i<s.length*8&&(this.modules[v][p]=r(s[i>>>3],7-(i&7)),i++)}}c(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 a=0;a<this.size;a++){let d;switch(s){case 0:d=(a+i)%2==0;break;case 1:d=i%2==0;break;case 2:d=a%3==0;break;case 3:d=(a+i)%3==0;break;case 4:d=(Math.floor(a/3)+Math.floor(i/2))%2==0;break;case 5:d=a*i%2+a*i%3==0;break;case 6:d=(a*i%2+a*i%3)%2==0;break;case 7:d=((a+i)%2+a*i%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[i][a]&&d&&(this.modules[i][a]=!this.modules[i][a])}}getPenaltyScore(){let s=0;for(let m=0;m<this.size;m++){let p=!1,g=0,v=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[m][x]==p?(g++,g==5?s+=U.PENALTY_N1:g>5&&s++):(this.finderPenaltyAddHistory(g,v),p||(s+=this.finderPenaltyCountPatterns(v)*U.PENALTY_N3),p=this.modules[m][x],g=1);s+=this.finderPenaltyTerminateAndCount(p,g,v)*U.PENALTY_N3}for(let m=0;m<this.size;m++){let p=!1,g=0,v=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][m]==p?(g++,g==5?s+=U.PENALTY_N1:g>5&&s++):(this.finderPenaltyAddHistory(g,v),p||(s+=this.finderPenaltyCountPatterns(v)*U.PENALTY_N3),p=this.modules[x][m],g=1);s+=this.finderPenaltyTerminateAndCount(p,g,v)*U.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+=U.PENALTY_N2)}let i=0;for(const m of this.modules)i=m.reduce((p,g)=>p+(g?1:0),i);const a=this.size*this.size,d=Math.ceil(Math.abs(i*20-a*10)/a)-1;return c(0<=d&&d<=9),s+=d*U.PENALTY_N4,c(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 a=[6];for(let d=this.size-7;a.length<s;d-=i)a.splice(1,0,d);return a}}static getNumRawDataModules(s){if(s<U.MIN_VERSION||s>U.MAX_VERSION)throw new RangeError("Version number out of range");let i=(16*s+128)*s+64;if(s>=2){const a=Math.floor(s/7)+2;i-=(25*a-10)*a-55,s>=7&&(i-=36)}return c(208<=i&&i<=29648),i}static getNumDataCodewords(s,i){return Math.floor(U.getNumRawDataModules(s)/8)-U.ECC_CODEWORDS_PER_BLOCK[i.ordinal][s]*U.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 a=1;for(let d=0;d<s;d++){for(let m=0;m<i.length;m++)i[m]=U.reedSolomonMultiply(i[m],a),m+1<i.length&&(i[m]^=i[m+1]);a=U.reedSolomonMultiply(a,2)}return i}static reedSolomonComputeRemainder(s,i){let a=i.map(d=>0);for(const d of s){const m=d^a.shift();a.push(0),i.forEach((p,g)=>a[g]^=U.reedSolomonMultiply(p,m))}return a}static reedSolomonMultiply(s,i){if(s>>>8||i>>>8)throw new RangeError("Byte out of range");let a=0;for(let d=7;d>=0;d--)a=a<<1^(a>>>7)*285,a^=(i>>>d&1)*s;return c(a>>>8==0),a}finderPenaltyCountPatterns(s){const i=s[1];c(i<=this.size*3);const a=i>0&&s[2]==i&&s[3]==i*3&&s[4]==i&&s[5]==i;return(a&&s[0]>=i*4&&s[6]>=i?1:0)+(a&&s[6]>=i*4&&s[0]>=i?1:0)}finderPenaltyTerminateAndCount(s,i,a){return s&&(this.finderPenaltyAddHistory(i,a),i=0),i+=this.size,this.finderPenaltyAddHistory(i,a),this.finderPenaltyCountPatterns(a)}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 a=s-1;a>=0;a--)i.push(f>>>a&1)}function r(f,s){return(f>>>s&1)!=0}function c(f){if(!f)throw new Error("Assertion error")}const l=class se{constructor(s,i,a){if(this.mode=s,this.numChars=i,this.bitData=a,i<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}static makeBytes(s){let i=[];for(const a of s)n(a,8,i);return new se(se.Mode.BYTE,s.length,i)}static makeNumeric(s){if(!se.isNumeric(s))throw new RangeError("String contains non-numeric characters");let i=[];for(let a=0;a<s.length;){const d=Math.min(s.length-a,3);n(parseInt(s.substring(a,a+d),10),d*3+1,i),a+=d}return new se(se.Mode.NUMERIC,s.length,i)}static makeAlphanumeric(s){if(!se.isAlphanumeric(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");let i=[],a;for(a=0;a+2<=s.length;a+=2){let d=se.ALPHANUMERIC_CHARSET.indexOf(s.charAt(a))*45;d+=se.ALPHANUMERIC_CHARSET.indexOf(s.charAt(a+1)),n(d,11,i)}return a<s.length&&n(se.ALPHANUMERIC_CHARSET.indexOf(s.charAt(a)),6,i),new se(se.Mode.ALPHANUMERIC,s.length,i)}static makeSegments(s){return s==""?[]:se.isNumeric(s)?[se.makeNumeric(s)]:se.isAlphanumeric(s)?[se.makeAlphanumeric(s)]:[se.makeBytes(se.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 se(se.Mode.ECI,0,i)}static isNumeric(s){return se.NUMERIC_REGEX.test(s)}static isAlphanumeric(s){return se.ALPHANUMERIC_REGEX.test(s)}getData(){return this.bitData.slice()}static getTotalBits(s,i){let a=0;for(const d of s){const m=d.mode.numCharCountBits(i);if(d.numChars>=1<<m)return 1/0;a+=4+m+d.bitData.length}return a}static toUtf8ByteArray(s){s=encodeURI(s);let i=[];for(let a=0;a<s.length;a++)s.charAt(a)!="%"?i.push(s.charCodeAt(a)):(i.push(parseInt(s.substring(a+1,a+3),16)),a+=2);return i}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let h=l;e.QrSegment=l})(qe||(qe={}));(e=>{(t=>{const n=class{constructor(c,l){this.ordinal=c,this.formatBits=l}};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(c,l){this.modeBits=c,this.numBitsCharCount=l}numCharCountBits(c){return this.numBitsCharCount[Math.floor((c+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 Je=qe;var Bi={L:Je.QrCode.Ecc.LOW,M:Je.QrCode.Ecc.MEDIUM,Q:Je.QrCode.Ecc.QUARTILE,H:Je.QrCode.Ecc.HIGH},Pr=128,Or="L",Lr="#FFFFFF",zr="#000000",Fr=!1,_r=1,Ui=4,$i=0,Ki=.1;function Br(e,t=0){const n=[];return e.forEach(function(r,c){let l=null;r.forEach(function(h,f){if(!h&&l!==null){n.push(`M${l+t} ${c+t}h${f-l}v1H${l+t}z`),l=null;return}if(f===r.length-1){if(!h)return;l===null?n.push(`M${f+t},${c+t} h1v1H${f+t}z`):n.push(`M${l+t},${c+t} h${f+1-l}v1H${l+t}z`);return}h&&l===null&&(l=f)})}),n.join("")}function Ur(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((c,l)=>l<t.x||l>=t.x+t.w?c:!1))}function Gi(e,t,n,r){if(r==null)return null;const c=e.length+n*2,l=Math.floor(t*Ki),h=c/t,f=(r.width||l)*h,s=(r.height||l)*h,i=r.x==null?e.length/2-f/2:r.x*h,a=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),v=Math.floor(a),x=Math.ceil(f+i-g),S=Math.ceil(s+a-v);m={x:g,y:v,w:x,h:S}}const p=r.crossOrigin;return{x:i,y:a,h:s,w:f,excavation:m,opacity:d,crossOrigin:p}}function Wi(e,t){return t!=null?Math.max(Math.floor(t),0):e?Ui:$i}function $r({value:e,level:t,minVersion:n,includeMargin:r,marginSize:c,imageSettings:l,size:h,boostLevel:f}){let s=F.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((v,x)=>(v.push(...Je.QrSegment.makeSegments(x)),v),[]);return Je.QrCode.encodeSegments(g,Bi[t],n,void 0,void 0,f)},[e,t,n,f]);const{cells:i,margin:a,numCells:d,calculatedImageSettings:m}=F.useMemo(()=>{let p=s.getModules();const g=Wi(r,c),v=p.length+g*2,x=Gi(p,h,g,l);return{cells:p,margin:g,numCells:v,calculatedImageSettings:x}},[s,h,l,r,c]);return{qrcode:s,margin:a,cells:i,numCells:d,calculatedImageSettings:m}}var Qi=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Yi=F.forwardRef(function(t,n){const r=t,{value:c,size:l=Pr,level:h=Or,bgColor:f=Lr,fgColor:s=zr,includeMargin:i=Fr,minVersion:a=_r,boostLevel:d,marginSize:m,imageSettings:p}=r,v=mn(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=v,S=mn(v,["style"]),b=p?.src,w=F.useRef(null),E=F.useRef(null),R=F.useCallback(N=>{w.current=N,typeof n=="function"?n(N):n&&(n.current=N)},[n]),[D,j]=F.useState(!1),{margin:C,cells:P,numCells:k,calculatedImageSettings:T}=$r({value:c,level:h,minVersion:a,boostLevel:d,includeMargin:i,marginSize:m,imageSettings:p,size:l});F.useEffect(()=>{if(w.current!=null){const N=w.current,O=N.getContext("2d");if(!O)return;let V=P;const L=E.current,M=T!=null&&L!==null&&L.complete&&L.naturalHeight!==0&&L.naturalWidth!==0;M&&T.excavation!=null&&(V=Ur(P,T.excavation));const B=window.devicePixelRatio||1;N.height=N.width=l*B;const $=l/k*B;O.scale($,$),O.fillStyle=f,O.fillRect(0,0,k,k),O.fillStyle=s,Qi?O.fill(new Path2D(Br(V,C))):P.forEach(function(oe,ue){oe.forEach(function(ee,A){ee&&O.fillRect(A+C,ue+C,1,1)})}),T&&(O.globalAlpha=T.opacity),M&&O.drawImage(L,T.x+C,T.y+C,T.w,T.h)}}),F.useEffect(()=>{j(!1)},[b]);const _=hn({height:l,width:l},x);let q=null;return b!=null&&(q=F.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{j(!0)},ref:E,crossOrigin:T?.crossOrigin})),F.createElement(F.Fragment,null,F.createElement("canvas",hn({style:_,height:l,width:l,ref:R,role:"img"},S)),q)});Yi.displayName="QRCodeCanvas";var Kr=F.forwardRef(function(t,n){const r=t,{value:c,size:l=Pr,level:h=Or,bgColor:f=Lr,fgColor:s=zr,includeMargin:i=Fr,minVersion:a=_r,boostLevel:d,title:m,marginSize:p,imageSettings:g}=r,v=mn(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:S,numCells:b,calculatedImageSettings:w}=$r({value:c,level:h,minVersion:a,boostLevel:d,includeMargin:i,marginSize:p,imageSettings:g,size:l});let E=S,R=null;g!=null&&w!=null&&(w.excavation!=null&&(E=Ur(S,w.excavation)),R=F.createElement("image",{href:g.src,height:w.h,width:w.w,x:w.x+x,y:w.y+x,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const D=Br(E,x);return F.createElement("svg",hn({height:l,width:l,viewBox:`0 0 ${b} ${b}`,ref:n,role:"img"},v),!!m&&F.createElement("title",null,m),F.createElement("path",{fill:f,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),F.createElement("path",{fill:s,d:D,shapeRendering:"crispEdges"}),R)});Kr.displayName="QRCodeSVG";function Gr(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Hi(){return Vr({queryKey:me.tunnel.status,queryFn:()=>Ke.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function qi(){const e=Bt();return gn({mutationFn:()=>Ke.post("/tunnel/start",{port:Gr()}),onSuccess:()=>{e.invalidateQueries({queryKey:me.tunnel.status})}})}function Xi(){const e=Bt();return gn({mutationFn:()=>Ke.post("/tunnel/regenerate",{port:Gr()}),onSuccess:()=>{e.invalidateQueries({queryKey:me.tunnel.status})}})}function Vi(){const e=Bt();return gn({mutationFn:()=>Ke.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:me.tunnel.status})}})}function Ji(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 Zi(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 ea(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 c=Math.round(r/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}function lt(e){const t=e?.trim();return t||null}function ta(e){if(!e)return"";const t=[lt(e.lastLocalError),lt(e.lastRemoteError),lt(e.lastError)].filter(c=>c!==null),n=lt(e.lastProcessOutput),r=!!n&&(e.status==="error"||e.status==="exited"||!!lt(e.lastError));return n&&r&&t.push(n),t.join(`
|
|
8
|
+
`)}function tr(){const{t:e}=Ie(),{data:t}=Hi(),n=qi(),r=Vi(),c=Xi(),[l,h]=u.useState(!1),[f,s]=u.useState(null),[i,a]=u.useState(!1),[d,m]=u.useState(!1),p=t?.status!==void 0&&t.status!=="stopped",g=n.isPending||t?.status==="starting",v=c.isPending,x=t?.shareableUrl,S=t?.token,b=Ji(t),w=Zi(t),E=ta(t),R=t?.status==="healthy"||t?.status==="checking"?"text-success-ink":t?.status==="exited"||t?.status==="error"?"text-destructive-ink":"text-warning-ink",D=u.useCallback(()=>{n.mutate(void 0,{onSuccess:()=>h(!0)})},[n]),j=u.useCallback(()=>{x&&(navigator.clipboard.writeText(x),s("url"),setTimeout(()=>s(null),2e3))},[x]),C=u.useCallback(()=>{S&&(navigator.clipboard.writeText(S),s("token"),setTimeout(()=>s(null),2e3))},[S]),P=u.useCallback(()=>{r.mutate(),h(!1),a(!1),m(!1)},[r]),k=u.useCallback(()=>{c.mutate(void 0,{onSuccess:()=>{m(!1),h(!0)}})},[c]),T=o.jsx(gs,{asChild:!0,children:o.jsx(Xt,{size:"xs",label:e("Close"),className:"-mr-1 -mt-0.5 shrink-0",children:o.jsx(Jr,{})})});return o.jsxs(ps,{open:l,onOpenChange:h,children:[o.jsxs("div",{className:"relative",children:[o.jsx(vs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:g,className:ae("p-1.5 rounded-md transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/60",b.button),title:e(b.label),"aria-label":e(b.label),children:g?o.jsx(Zr,{size:"md"}):b.icon==="warn"?o.jsx(es,{size:16}):o.jsx(In,{size:16})})}),p&&!g&&o.jsx("span",{className:`pointer-events-none absolute top-0.5 right-0.5 w-2 h-2 ${b.dot} rounded-full`})]}),o.jsx(xs,{align:"end",className:ae("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:ae("flex items-center gap-1.5 text-xs font-medium",R),children:[o.jsx("span",{className:`inline-block w-1.5 h-1.5 ${b.dot} rounded-full`}),e(w)]}),o.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e(ea(t))})]}),T]}),S&&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(us,{size:12}),o.jsx("span",{children:e("Token protected")})]}),x&&o.jsx("div",{className:"flex justify-center py-3",children:o.jsx(Kr,{value:x,size:160})}),x||t?.url?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(bs,{size:"sm",readOnly:!0,value:x??t?.url??"",onFocus:_=>_.target.select(),"aria-label":e("Copy shareable link"),className:"select-all text-xs"}),o.jsx(Xt,{size:"sm",label:e("Copy shareable link"),onClick:j,disabled:!x,children:f==="url"?o.jsx(pt,{className:"text-success"}):o.jsx(Dn,{})})]}):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)})]})]}),E&&o.jsx(kt,{tone:"warning",size:"sm",className:"mt-2 max-h-28 overflow-auto",children:o.jsx("div",{className:"whitespace-pre-wrap break-words",children:E})}),t?.status==="degraded"&&o.jsx(kt,{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(kt,{tone:"warning",size:"sm",className:"mt-2",children:e("The previous tunnel link and token are no longer valid.")}),S&&o.jsxs("div",{className:"mt-2",children:[o.jsx("button",{type:"button",onClick:()=>a(!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:S}),o.jsx(Xt,{size:"sm",label:e("Copy token"),onClick:C,className:"shrink-0",children:f==="token"?o.jsx(pt,{className:"text-success"}):o.jsx(Dn,{})})]})]}),d?o.jsxs(kt,{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(Me,{variant:"secondary",size:"xs",className:"flex-1",onClick:()=>m(!1),children:e("Cancel")}),o.jsx(Me,{variant:"primary",tone:"danger",size:"xs",className:"flex-1",onClick:k,loading:v,children:e(v?"Generating...":"Regenerate link")})]})]}):o.jsxs(Me,{variant:"ghost",size:"sm",block:!0,className:"mt-3",onClick:()=>m(!0),disabled:v||t?.canRegenerate===!1,children:[o.jsx(ts,{}),e("Regenerate link")]}),o.jsx(Me,{variant:"ghost",tone:"danger",size:"sm",block:!0,className:"mt-1",onClick:P,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(In,{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.")})]})]}),T]}),o.jsx(Me,{variant:"primary",size:"sm",block:!0,className:"mt-3",onClick:D,loading:g,children:e(g?"Starting tunnel...":"Enable phone access")})]})})]})}function sn({isOpen:e,onClose:t}){const{t:n}=Ie(),r=Cs(),[c,l]=u.useState(""),[h,f]=u.useState(""),[s,i]=u.useState(null),[a,d]=u.useState(!1),[m,p]=u.useState(!1),g=c.trim(),v=h.trim(),x=a||r.isPending,S=u.useMemo(()=>!!(g&&v&&!x),[g,v,x]),b=u.useCallback(()=>{l(""),f(""),i(null),p(!1)},[]),w=u.useCallback(()=>{x||(b(),t())},[x,t,b]);u.useEffect(()=>{e||b()},[e,b]);const E=u.useCallback(async C=>{try{await r.mutateAsync({name:g,repoPath:v,initEmptyRepo:C}),b(),t()}catch(P){const k=P instanceof Error?P.message:n("Failed to create project");i(k),Fe.error(k)}},[r,t,b,n,g,v]),R=u.useCallback(async()=>{if(!(!g||!v||x)){i(null),d(!0);try{const C=await Ke.get("/filesystem/validate",{params:{path:v}});if(!C.valid){i(C.error??n("Selected path is not a valid directory"));return}if(C.isGitRepo){await E(!1);return}if(C.reason==="no_git"&&C.isEmpty){p(!0);return}if(C.reason==="no_git"){await E(!1);return}await E(!1)}catch(C){i(C instanceof Error?C.message:n("Could not check project path"))}finally{d(!1)}}},[E,x,n,g,v]),D=u.useCallback(()=>{p(!1),E(!1)},[E]),j=u.useCallback(()=>{p(!1),E(!0)},[E]);return o.jsxs(o.Fragment,{children:[o.jsx(Mn,{isOpen:e,onClose:w,title:n("Create New Project"),action:o.jsxs(o.Fragment,{children:[o.jsx(Me,{onClick:w,disabled:x,children:n("Cancel")}),o.jsx(Me,{variant:"primary",onClick:R,disabled:!S,children:a?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:c,onChange:C=>l(C.target.value),placeholder:n("e.g., Agent Tower"),disabled:x,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(cs,{value:h,onChange:f,validationMode:"directory"})]}),s&&o.jsx("p",{className:"text-xs text-destructive-ink leading-relaxed",children:s})]})}),o.jsx(Mn,{isOpen:m,onClose:()=>{r.isPending||p(!1)},title:n("Initialize Git repository?"),action:o.jsxs(o.Fragment,{children:[o.jsx(Me,{onClick:()=>p(!1),disabled:r.isPending,children:n("Cancel")}),o.jsx(Me,{onClick:D,disabled:r.isPending,children:n("Create Local Project")}),o.jsx(Me,{variant:"primary",onClick:j,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 na(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 c=n.createdTime-t.createdTime;return c!==0?c:t.index-n.index}).map(({project:t})=>t)}const ra=u.lazy(()=>ar(()=>import("./TaskDetail-a1jalILy.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])).then(e=>({default:e.TaskDetail}))),sa=u.lazy(()=>ar(()=>import("./MobileTaskDetail-DxE6ZDAS.js"),__vite__mapDeps([53,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])).then(e=>({default:e.MobileTaskDetail})));function rr(){const{t:e}=Ie();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:c}){const{t:l}=Ie(),[h,f]=u.useState(!1),s=e.filter(a=>!a.archivedAt),i=t?e.find(a=>a.id===t)??null:null;return o.jsxs("div",{className:ae("relative flex items-center min-w-0",c),children:[o.jsx("span",{className:"mx-1.5 text-muted-foreground select-none",children:"/"}),o.jsxs("button",{onClick:()=>f(a=>!a),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(on,{size:13,className:"text-muted-foreground shrink-0"}),o.jsx("span",{className:"truncate max-w-[200px] font-medium",children:i?i.name:l("All Projects")}),o.jsx(Ns,{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(on,{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:l("All Projects")}),t===null?o.jsx(pt,{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(a=>{const d=t===a.id;return o.jsxs("button",{onClick:()=>{n(a.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 ${a.color.replace("text-","bg-")}`}),o.jsx("span",{className:`flex-1 truncate ${d?"text-foreground font-medium":"text-muted-foreground"}`,children:a.name}),d?o.jsx(pt,{size:14,className:"text-foreground shrink-0"}):null]},a.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(hs,{size:13}),o.jsx("span",{children:l("Create New Project...")})]})]})]}):null]})}const oa=260,ia=600,or=400,aa=100,la=1e3;function ca(e){const t=e.workspaces?.find(r=>r.status==="ACTIVE")??e.workspaces?.[0],n=t?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,priority:e.priority,...t?{preferredWorkspace:{...t.workspaceKind===et.MAIN_DIRECTORY?{workspaceKind:et.MAIN_DIRECTORY}:{},branchName:t.branchName}}:{},...n?{latestAgentType:n.agentType}:{},...e.workspaces?.some(r=>r.sessions?.some(c=>c.status==="RUNNING"||c.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function ua(){const{t:e,locale:t}=Ie(),[n,r]=u.useState(null),[c,l]=u.useState(null),[h,f]=u.useState(or),[s,i]=u.useState(!1),[a,d]=u.useState("idle"),[m,p]=u.useState({}),g=u.useRef(!1),v=u.useRef(0),x=u.useRef(or),S=u.useRef(null),b=Bt(),{data:w,isLoading:E}=Es(),{data:R,isLoading:D}=Ss({limit:aa}),j=u.useMemo(()=>R?.data??[],[R?.data]),C=c&&j.some(y=>y.id===c)?c:null,{data:P,isLoading:k}=ns({...C?{projectId:C}:{},limit:la}),T=u.useMemo(()=>P?.data??[],[P?.data]),[_,q]=u.useState([]),N=u.useMemo(()=>{if(_.length===0)return T;const y=new Set(T.map(I=>I.id));return[..._.filter(I=>!y.has(I.id)),...T]},[T,_]),[O,V]=u.useState(null),L=u.useMemo(()=>n&&N.some(y=>y.id===n)?n:O&&n===O?O:null,[n,N,O]);u.useEffect(()=>{O&&N.some(y=>y.id===O)&&V(null)},[O,N]),u.useEffect(()=>{if(_.length===0)return;const y=new Set(T.map(I=>I.id));_.some(I=>y.has(I.id))&&q(I=>I.filter(W=>!y.has(W.id)))},[T,_]);const M=u.useMemo(()=>na(j),[j]),B=u.useMemo(()=>M.map(Li),[M]),$=u.useMemo(()=>M.filter(y=>!y.archivedAt),[M]),oe=u.useMemo(()=>{if(!w)return[];const y=localStorage.getItem("providerUsageCount"),I=y?JSON.parse(y):{};return[...w].sort((W,Y)=>{const H=W.availability.type!=="NOT_FOUND",Z=Y.availability.type!=="NOT_FOUND";if(H!==Z)return H?-1:1;const J=I[W.provider.id]??0;return(I[Y.provider.id]??0)-J})},[w]),ue=u.useMemo(()=>N.map(y=>zi(y,j.find(I=>I.id===y.projectId))),[j,N]),ee=u.useMemo(()=>{if(!L)return null;const y=N.find(W=>W.id===L);if(!y)return null;const I=j.find(W=>W.id===y.projectId);if(!I){const W=y.preferredWorkspace?y.preferredWorkspace.workspaceKind===et.MAIN_DIRECTORY?"Project directory":y.preferredWorkspace.branchName:"—";return{id:y.id,projectId:y.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:y.title,status:En(y.status),priority:y.priority,branch:W,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return Fi(y,I)},[L,N,j]),A=rs(),Q=ss(),z=os(),re=is(),G=ds(),K=u.useCallback(y=>{const I=ca(y);q(W=>W.some(Y=>Y.id===y.id)?W.map(Y=>Y.id===y.id?I:Y):[I,...W]),b.setQueryData(me.tasks.detail(y.id),y),V(y.id),r(y.id)},[b]),ie=u.useCallback((y,I,W)=>{const Y=y.id,H=[y.title,y.description].filter(Boolean).join(`
|
|
9
|
+
|
|
10
|
+
`),Z=W===et.WORKTREE?$.find(J=>J.id===y.projectId)?.setupScript??null:null;p(J=>({...J,[Y]:{status:"creating-workspace",setupScript:Z}})),(async()=>{try{const J=await Ke.post(`/tasks/${Y}/workspaces`,{workspaceKind:W});p(te=>({...te,[Y]:{status:"creating-session",setupScript:Z}}));const pe=await Ke.post(`/workspaces/${J.id}/sessions`,{providerId:I,prompt:H});p(te=>({...te,[Y]:{status:"starting-session",setupScript:Z}})),await G.mutateAsync(pe.id),await b.invalidateQueries({queryKey:me.workspaces.list(Y)}),await b.invalidateQueries({queryKey:me.workspaces.setupProgress(Y)}),await b.invalidateQueries({queryKey:me.tasks.all}),p(te=>{const{[Y]:fe,...xe}=te;return xe})}catch(J){const pe=J instanceof Error?J.message:e("启动 Agent 失败");p(te=>({...te,[Y]:{status:"failed",error:pe,setupScript:Z}})),Fe.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),b.invalidateQueries({queryKey:me.workspaces.list(Y)}),b.invalidateQueries({queryKey:me.tasks.all})}})()},[$,b,G,e]),ke=u.useCallback(y=>{p(I=>{const{[y]:W,...Y}=I;return Y}),b.invalidateQueries({queryKey:me.workspaces.list(y)}),b.invalidateQueries({queryKey:me.tasks.all})},[b]),be=u.useCallback(y=>{Q.mutate(y,{onSuccess:()=>{L===y&&r(null),p(I=>{const{[y]:W,...Y}=I;return Y}),q(I=>I.filter(W=>W.id!==y)),b.invalidateQueries({queryKey:me.tasks.all})},onError:()=>{Fe.error(e("删除任务失败"))}})},[Q,L,b,e]),Te=u.useCallback((y,I)=>{z.mutate({id:y,status:Pi(I)},{onError:()=>{Fe.error(e("状态变更失败,该操作不被允许"))}})},[z,e]),ye=u.useCallback((y,I)=>{re.mutate({id:y,priority:I},{onError:()=>{Fe.error(e("优先级变更失败"))}})},[re,e]),Xe=u.useCallback(y=>{y.preventDefault(),g.current=!0,v.current=y.clientX,x.current=h,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[h]);u.useEffect(()=>{const y=W=>{if(!g.current)return;const Y=W.clientX-v.current,H=Math.max(oa,Math.min(ia,x.current+Y));f(H)},I=()=>{g.current&&(g.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",y),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",I)}},[]);const Ee=u.useCallback(()=>{i(!0)},[]),Et=u.useCallback(()=>{if($.length===0){Fe.error(e("没有可用项目,请先创建或恢复项目"));return}r(null)},[$,e]),Ve=u.useCallback(()=>{i(!1)},[]),Ge=u.useCallback(async y=>{const{title:I,description:W,projectId:Y,providerId:H,mode:Z,workspaceMode:J,teamRunMode:pe,teamTemplateId:te,memberPresetIds:fe,attachmentLinks:xe,priority:Be}=y,le=[W,xe].filter(Boolean).join(`
|
|
11
|
+
|
|
12
|
+
`);let he=null;try{if(d("creating-task"),he=await Ke.post(`/projects/${Y}/tasks`,{title:I,description:le||void 0,priority:Be}),localStorage.setItem("lastSelectedProjectId",Y),Z==="SOLO"&&H){localStorage.setItem("lastSelectedProviderId",H);const Ce=localStorage.getItem("providerUsageCount"),ze=Ce?JSON.parse(Ce):{};ze[H]=(ze[H]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ze))}Z==="TEAM"?(d("creating-teamrun"),await A.mutateAsync({taskId:he.id,mode:pe,...te?{teamTemplateId:te}:{},...fe.length>0?{memberPresetIds:fe}:{}})):H&&ie(he,H,J),C&&Y!==C&&l(null),K(he),d("idle"),b.invalidateQueries({queryKey:me.tasks.all}),b.invalidateQueries({queryKey:me.projects.all})}catch(ge){if(d("idle"),he&&Z==="TEAM"){try{await Q.mutateAsync(he.id)}catch{}throw Fe.error(e("TeamRun 创建失败,请检查团队配置后重试")),ge}else if(he)C&&Y!==C&&l(null),K(he),b.invalidateQueries({queryKey:me.tasks.all}),b.invalidateQueries({queryKey:me.projects.all});else throw Fe.error(ge instanceof Error?ge.message:e("Failed to create task")),ge}},[$,A,ie,Q,b,e,C,K]),Ne=D||k,We=u.useMemo(()=>$.map(y=>({id:y.id,name:y.name,color:B.find(I=>I.id===y.id)?.color,repoPath:y.repoPath,isGitRepo:y.isGitRepo,worktreeReady:y.worktreeReady,reason:y.reason})),[$,B]),Qe=u.useMemo(()=>oe.map(y=>{const I=Vt(y);return{id:y.provider.id,name:y.provider.name,agentType:y.provider.agentType,available:!I,permissionMode:y.provider.executionPermission,reason:I}}),[oe]),Ae=u.useMemo(()=>{if(C&&$.find(I=>I.id===C))return C;const y=localStorage.getItem("lastSelectedProjectId");return y&&$.find(I=>I.id===y)?y:$[0]?.id??""},[$,C]),[rt,st]=u.useState(Ae);u.useEffect(()=>{st(Ae)},[Ae]);const Nt=u.useMemo(()=>$.find(y=>y.id===rt)?.name??$.find(y=>y.id===Ae)?.name??e("Project"),[$,rt,Ae,e]),Pe=t==="zh-CN"?`你需要在 ${Nt} 中做点什么?`:`What do you need to do in ${Nt}?`,Oe=u.useMemo(()=>{const y=localStorage.getItem("lastSelectedProviderId");return y&&oe.find(W=>W.provider.id===y&&!Vt(W))?y:oe.find(W=>!Vt(W))?.provider.id??""},[oe]),Ye=Tr(),[Rt,we]=u.useState(!1),{usesIntegratedTitlebar:Le,desktopPlatform:Qt,hasMacTrafficLights:Yt}=ir(),ot=Le&&Qt==="win32",jt=u.useCallback(()=>{if($.length===0){Fe.error(e("没有可用项目,请先创建或恢复项目"));return}we(!0)},[$,e]),Ht=u.useCallback(async y=>{await Ge(y),we(!1)},[Ge]);return Ye?Rt?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:()=>we(!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:Pe}),o.jsx(Tn,{projects:We,providers:Qe,isProvidersLoading:E,onSubmit:Ht,defaultProjectId:Ae,defaultProviderId:Oe,onProjectChange:st,createStep:a})]})]}):L&&ee?o.jsxs(o.Fragment,{children:[o.jsx(u.Suspense,{fallback:o.jsx("div",{className:"flex h-dvh",children:o.jsx(rr,{})}),children:o.jsx(sa,{task:ee,onBack:()=>r(null),onDeleteTask:ee.projectArchivedAt?void 0:be,onTaskPriorityChange:ee.projectArchivedAt?void 0:ye,isDeleting:Q.isPending,autoStartState:m[ee.id]??null,onAutoStartRecovered:ke})}),o.jsx(sn,{isOpen:s,onClose:Ve})]}):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(An,{}),o.jsx(sr,{projects:B,filterProjectId:C,setFilterProjectId:l,onCreateProject:Ee})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(tr,{}),o.jsx("button",{onClick:()=>jn.getState().openSettings(),className:"p-1.5 text-muted-foreground active:text-foreground rounded-md",children:o.jsx(Rn,{size:16})})]})]}),o.jsx(Jn,{tasks:ue,projects:B,selectedTaskId:null,onSelectTask:r,filterProjectId:C,setFilterProjectId:l,width:"100%",onCreateTask:jt,onCreateProject:Ee,onTaskStatusChange:Te,onTaskPriorityChange:ye,isLoading:Ne&&ue.length===0})]}),o.jsx(sn,{isOpen:s,onClose:Ve})]}):o.jsxs("div",{ref:S,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[o.jsxs("header",{className:ae("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",Le&&"app-region-drag",ot&&"pr-[150px]"),children:[o.jsxs("div",{className:ae("flex items-center gap-2 min-w-0",Yt&&"pl-[72px]"),children:[o.jsx(An,{}),o.jsx(sr,{projects:B,filterProjectId:C,setFilterProjectId:l,onCreateProject:Ee,className:Le?"app-region-no-drag":void 0})]}),o.jsxs("div",{className:ae("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:()=>jn.getState().openSettings(),className:ae("p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-md transition-colors",Le&&"app-region-no-drag"),children:o.jsx(Rn,{size:16})})]})]}),o.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[o.jsx(Jn,{tasks:ue,projects:B,selectedTaskId:L,onSelectTask:r,filterProjectId:C,setFilterProjectId:l,width:h,onCreateTask:Et,onCreateProject:Ee,isCreateActive:!L,onTaskStatusChange:Te,onDeleteTask:be,onTaskPriorityChange:ye,isLoading:Ne&&ue.length===0}),o.jsx("div",{onMouseDown:Xe,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:L&&ee?o.jsx(u.Suspense,{fallback:o.jsx(rr,{}),children:o.jsx(ra,{task:ee,onDeleteTask:ee.projectArchivedAt?void 0:be,isDeleting:Q.isPending,onTaskStatusChange:ee.projectArchivedAt?void 0:Te,onTaskPriorityChange:ee.projectArchivedAt?void 0:ye,autoStartState:m[ee.id]??null,onAutoStartRecovered:ke})}):L&&!ee?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:Pe}),o.jsx(Tn,{projects:We,providers:Qe,isProvidersLoading:E,onSubmit:Ge,defaultProjectId:Ae,defaultProviderId:Oe,onProjectChange:st,createStep:a})]})})})]}),o.jsx(sn,{isOpen:s,onClose:Ve})]})}const Da=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:ua},Symbol.toStringTag,{value:"Module"}));export{ui as D,Da as P};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as B,r as o,v as ue,j as e,X as se,B as R,aI as me,t as T,i as $,aJ as xe,k as Q,x as H,n as J,ag as pe,aa as he,$ as fe,as as ge}from"./index-Cz73HpYH.js";import{u as re,a as je,b as be,c as ve}from"./use-projects-Dwy9AfAG.js";import{F as X}from"./search-field-B5czD2Pl.js";import{F as V}from"./hooks-DK4m7-FN.js";import{P as ne,T as ye}from"./trash-2-ALAYDudv.js";import{F as Ne}from"./popover-BYz89aiY.js";import{M as Y}from"./modal-Kpqn-nDO.js";import{f as ke,F as Pe}from"./use-workspaces-BBbahdwU.js";import{S as we}from"./SettingsMasterDetail-UfyoKAum.js";import{B as Se}from"./BranchSelect-D-kqavDG.js";import"./kbd-B3m64lRd.js";import"./index-B6Lvy5Sr.js";import"./index-BCV57B4O.js";import"./index-CTG-4w90.js";import"./dialog-B_vC5R4B.js";import"./check-DYlb0A_N.js";import"./menu-styles-DWynpVVz.js";function Ce({value:t,onChange:x,repoPath:a,placeholder:v,disabled:i,disabledMessage:c}){const{t:u}=B(),[d,j]=o.useState(""),[m,n]=o.useState([]),[p,h]=o.useState(!1),[f,N]=o.useState(-1),k=o.useRef(null),A=o.useRef(null),D=o.useRef(void 0),q=o.useCallback(async s=>{if(i||!a||!s){n([]),h(!1);return}try{const l=await ue.get("/filesystem/complete",{params:{basePath:a,prefix:s}});n(l.results),h(l.results.length>0),N(-1)}catch{n([]),h(!1)}},[i,a]);o.useEffect(()=>{if(clearTimeout(D.current),!d){n([]),h(!1);return}return D.current=setTimeout(()=>q(d),200),()=>clearTimeout(D.current)},[d,q]),o.useEffect(()=>{const s=l=>{A.current&&!A.current.contains(l.target)&&k.current&&!k.current.contains(l.target)&&h(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const w=s=>{if(i)return;const l=s.trim();!l||t.includes(l)||(x([...t,l]),j(""),h(!1),k.current?.focus())},S=s=>{i||x(t.filter((l,z)=>z!==s))},F=s=>{i||(s.type==="directory"?(j(s.path),k.current?.focus()):w(s.path))},M=(s,l)=>{i||(l.stopPropagation(),w(s.path.replace(/\/$/,"")))},E=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||i||(p&&m.length>0?s.key==="ArrowDown"?(s.preventDefault(),N(l=>Math.min(l+1,m.length-1))):s.key==="ArrowUp"?(s.preventDefault(),N(l=>Math.max(l-1,-1))):s.key==="Enter"?(s.preventDefault(),f>=0?F(m[f]):w(d)):s.key==="Escape"&&h(!1):s.key==="Enter"&&(s.preventDefault(),w(d)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-border rounded-lg mb-2 divide-y divide-border/60",children:t.map((s,l)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(X,{size:14,className:"text-muted-foreground/70 shrink-0"}):e.jsx(V,{size:14,className:"text-warning shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-foreground/80 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>S(l),disabled:i,className:"p-0.5 text-muted-foreground hover:text-destructive-ink opacity-0 group-hover:opacity-100 transition-opacity shrink-0 disabled:cursor-not-allowed disabled:hover:text-muted-foreground",children:e.jsx(se,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:k,type:"text",value:d,onChange:s=>j(s.target.value),onKeyDown:E,onFocus:()=>{d&&m.length>0&&h(!0)},placeholder:v??u("输入文件路径..."),disabled:i,className:"flex-1 px-3 py-2 border border-border rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-ring/60 disabled:cursor-not-allowed disabled:bg-muted/50 disabled:text-muted-foreground"}),e.jsxs("button",{onClick:()=>w(d),disabled:i||!d.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(ne,{size:14}),e.jsx("span",{children:u("添加")})]})]}),p&&e.jsx("div",{ref:A,className:"absolute z-50 left-0 right-0 mt-1 bg-background border border-border rounded-lg shadow-popover max-h-[200px] overflow-y-auto",children:m.map((s,l)=>e.jsxs("button",{onClick:()=>F(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-accent transition-colors ${l===f?"bg-muted":""}`,children:[s.type==="directory"?e.jsx(V,{size:14,className:"text-warning shrink-0"}):e.jsx(X,{size:14,className:"text-muted-foreground/70 shrink-0"}),e.jsx("span",{className:"font-mono text-foreground/80 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:z=>M(s,z),className:"p-0.5 text-muted-foreground hover:text-success-ink shrink-0",title:u("添加此目录"),children:e.jsx(Ne,{size:14})})]},s.path))})]}),i&&c&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:c})]})}function Re({value:t,onChange:x}){const{t:a}=B(),[v,i]=o.useState(""),[c,u]=o.useState(""),d=()=>{const n=v.trim(),p=c.trim();!n||!p||(x([...t,{name:n,command:p}]),i(""),u(""))},j=n=>{x(t.filter((p,h)=>h!==n))},m=n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.preventDefault(),d())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-border rounded-lg mb-2 divide-y divide-border/60",children:t.map((n,p)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-foreground/80 w-28 shrink-0 truncate",children:n.name}),e.jsx("span",{className:"text-sm font-mono text-muted-foreground flex-1 truncate",children:n.command}),e.jsx("button",{onClick:()=>j(p),className:"p-0.5 text-muted-foreground hover:text-destructive-ink opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(se,{size:14})})]},p))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:n=>i(n.target.value),onKeyDown:m,placeholder:a("名称"),className:"w-28 shrink-0 px-3 py-2 border border-border rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-ring/60"}),e.jsx("input",{type:"text",value:c,onChange:n=>u(n.target.value),onKeyDown:m,placeholder:a("命令"),className:"flex-1 px-3 py-2 border border-border rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-ring/60"}),e.jsxs("button",{onClick:d,disabled:!v.trim()||!c.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(ne,{size:14}),e.jsx("span",{children:a("添加")})]})]})]})}function De({projectId:t}){const{t:x}=B(),a=ke(t);return e.jsxs("div",{className:"py-5 first:pt-0 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:x("Default base branch")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:x("New task and TeamRun main workspaces start from this branch. Existing workspaces keep their base branch.")})]}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>{a.refetch()},disabled:a.isFetching,"aria-label":x("Refresh"),children:e.jsx(me,{size:13,className:a.isFetching?"animate-spin motion-reduce:[animation-duration:2.4s]":""})})]}),a.isPending?e.jsx("p",{className:"text-xs text-muted-foreground",children:x("Loading...")}):a.isError?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x("Could not load branches. Refresh to try again.")}):a.data&&e.jsx(Fe,{projectId:t,mainBranch:a.data.mainBranch,branches:a.data.branches,isRefreshing:a.isFetching,onRefresh:()=>{a.refetch()}},`${t}:${a.data.mainBranch}`)]})}function Fe({projectId:t,mainBranch:x,branches:a,isRefreshing:v,onRefresh:i}){const{t:c}=B(),u=o.useId(),[d,j]=o.useState(x),m=re(),n=async()=>{try{await m.mutateAsync({id:t,mainBranch:d}),T.success(c("Default base branch saved"))}catch{}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{htmlFor:u,className:"block text-xs font-medium",children:c("Default base branch")}),e.jsx(Se,{id:u,label:c("Default base branch"),value:d,branches:a,disabled:m.isPending,isRefreshing:v,onOpen:i,onChange:p=>{j(p),m.reset()}}),m.isError&&e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:c("Could not save the default base branch. Refresh and choose an existing local branch.")}),e.jsx(R,{size:"sm",onClick:()=>{n()},disabled:d===x||!a.includes(d)||m.isPending||v,children:m.isPending?c("Saving"):c("Save default base branch")})]})}function Z(t){return t?t.split(",").map(x=>x.trim()).filter(Boolean):[]}function ee(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function te(t){return typeof t.color!="string"||t.color.trim()===""?"bg-muted-foreground":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-muted-foreground"}function Qe(){const{t}=B(),{data:x,isLoading:a}=je({limit:100,includeArchived:!0}),v=re(),i=be(),c=ve(),[u,d]=o.useState(""),[j,m]=o.useState(null),[n,p]=o.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[h,f]=o.useState(!1),[N,k]=o.useState(null),[A,D]=o.useState(!1),[q,w]=o.useState(!1),[S,F]=o.useState(!1),[M,E]=o.useState(!1),[s,l]=o.useState(""),[z,U]=o.useState(!1),C=x?.data??[],y=o.useMemo(()=>C.filter(r=>!r.archivedAt),[C]),I=o.useMemo(()=>C.filter(r=>r.archivedAt),[C]),g=y.find(r=>r.id===u),L=o.useMemo(()=>C.find(r=>r.id===N)??null,[N,C]);if(o.useEffect(()=>{!u&&y.length>0&&d(y[0].id)},[y,u]),o.useEffect(()=>{if(j){y.some(r=>r.id===j)&&(d(j),m(null));return}u&&!y.some(r=>r.id===u)&&(d(y[0]?.id??""),f(!1))},[y,j,u]),o.useEffect(()=>{g&&!h&&p({copyFiles:Z(g.copyFiles),setupScript:g.setupScript??"",quickCommands:ee(g.quickCommands)})},[g,h]),a)return e.jsx($,{className:"max-w-5xl",children:e.jsx(xe,{})});if(C.length===0)return e.jsxs($,{className:"max-w-5xl",children:[e.jsx(Q,{title:t("项目配置")}),e.jsx(H,{message:t("暂无项目,请先创建项目")})]});const oe=()=>{u&&v.mutate({id:u,copyFiles:n.copyFiles.length>0?n.copyFiles.join(", "):null,setupScript:n.setupScript.trim()||null,quickCommands:n.quickCommands.length>0?JSON.stringify(n.quickCommands):null},{onSuccess:()=>f(!1)})},ie=r=>{m(null),d(r),f(!1),U(!0)},ae=()=>{g&&(k(g.id),F(!1),E(!1),D(!0))},G=()=>{i.isPending||(D(!1),k(null),F(!1),E(!1))},ce=async()=>{if(N)try{await i.mutateAsync({id:N,deleteRepo:S}),T.success(t(S?"项目已删除,并清理了本地文件":"项目已删除")),f(!1),G()}catch{}},le=r=>{const b=I.find(P=>P.id===r);k(r),l(b?.repoDeletedAt?b.repoPath:""),w(!0)},W=()=>{c.isPending||(w(!1),k(null),l(""))},de=async()=>{if(!(!N||L?.repoDeletedAt&&!s.trim()))try{const b=await c.mutateAsync({id:N,repoPath:s.trim()||void 0});T.success(t("项目已恢复"));for(const P of b.warnings)T.warning(P);f(!1),m(b.project.id),d(b.project.id),W()}catch{}},_=L?.name??t("this project"),K=!!L?.repoDeletedAt,O=g?.isGitRepo!==!1&&g?.worktreeReady!==!1;return e.jsxs(e.Fragment,{children:[e.jsxs($,{className:"max-w-5xl",children:[e.jsx(Q,{title:t("项目配置")}),y.length===0&&I.length===0?e.jsx(H,{message:t("暂无项目,请先创建项目")}):e.jsx(we,{items:y,selectedId:u,onSelectItem:ie,getItemId:r=>r.id,mobileShowDetail:z,onMobileBack:()=>U(!1),renderListItem:r=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:J("h-2 w-2 rounded-full shrink-0",te(r))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium",children:r.name}),e.jsx("div",{className:J("truncate text-[11px] font-mono","text-muted-foreground"),children:r.repoPath.split("/").pop()})]})]}),renderListFooter:I.length>0?()=>e.jsxs("div",{className:"pt-3 mt-2 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("已删除")}),e.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:I.length})]}),I.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px]",children:r.name})}),e.jsx("button",{onClick:()=>le(r.id),disabled:c.isPending,className:"shrink-0 text-xs hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","aria-label":t("恢复项目"),children:e.jsx(ge,{size:12})})]},r.id))]}):void 0,renderDetail:r=>r?e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:J("h-2.5 w-2.5 rounded-full shrink-0",te(r))}),e.jsx("h3",{className:"text-base font-semibold text-foreground",children:r.name}),r.isGitRepo===!1&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:t("Local project")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-mono mb-5",children:r.repoPath}),r.isGitRepo===!1&&e.jsx(pe,{tone:"info",size:"sm",className:"mb-5",children:t("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun.")}),e.jsxs("div",{className:"divide-y divide-border/60",children:[O&&e.jsx(De,{projectId:r.id},r.id),e.jsxs("div",{className:"py-5 first:pt-0",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("自动复制文件")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t("创建 worktree 时自动从主仓库复制的文件或目录,适用于 .env、node_modules 等不在 git 管理中的文件。支持 glob。")})]}),e.jsx(Ce,{value:n.copyFiles,onChange:b=>{p(P=>({...P,copyFiles:b})),f(!0)},repoPath:r.repoPath,disabled:!O,disabledMessage:t("This setting applies only to Git worktree projects.")})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("Setup 脚本")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t("创建 worktree 后自动执行的命令,每行一条。在 worktree 目录下执行,单条超时 5 分钟。")})]}),e.jsx("textarea",{value:n.setupScript,onChange:b=>{p(P=>({...P,setupScript:b.target.value})),f(!0)},placeholder:`pnpm install
|
|
2
|
+
pnpm run setup`,rows:4,disabled:!O,className:"w-full rounded-lg border border-input bg-muted/50 px-3 py-2 text-sm font-mono transition-colors focus:border-ring focus:bg-background focus:outline-none resize-none disabled:cursor-not-allowed disabled:opacity-50"}),!O&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:t("This setting applies only to Git worktree projects.")})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("常用命令")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t("在终端中可快速执行的命令,不会自动运行。")})]}),e.jsx(Re,{value:n.quickCommands,onChange:b=>{p(P=>({...P,quickCommands:b})),f(!0)}})]})]}),e.jsx("div",{className:"mt-2 rounded-lg border border-destructive/30 bg-destructive/10 p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(he,{size:15,className:"text-destructive mt-0.5 shrink-0","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:t("删除项目")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t("项目将从默认列表隐藏,历史记录保留。可选同时删除本地文件。")})]})]}),e.jsxs(R,{size:"sm",variant:"destructive",className:"shrink-0",onClick:ae,disabled:i.isPending||c.isPending,children:[e.jsx(ye,{size:13}),t("删除项目")]})]})}),h&&e.jsx(fe,{saving:v.isPending,onSave:oe,onCancel:()=>{g&&p({copyFiles:Z(g.copyFiles),setupScript:g.setupScript??"",quickCommands:ee(g.quickCommands)}),f(!1)},className:"-mx-5"})]}):e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:y.length>0?t("选择一个项目查看配置"):t("当前没有可配置的项目")})})]}),e.jsx(Y,{isOpen:A,onClose:G,title:t("Delete Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",onClick:G,disabled:i.isPending,children:t("Cancel")}),e.jsx(R,{variant:"destructive",onClick:ce,disabled:i.isPending||S&&!M,children:i.isPending?t("Deleting..."):t("Delete Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t("项目「{title}」将从默认项目列表隐藏,但历史任务、workspace 和会话记录仍会保留。",{title:_})}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-border bg-muted px-3 py-3",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:r=>{F(r.target.checked),r.target.checked||E(!1)},className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:t("同时删除本地项目文件")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("勾选后会删除项目路径指向的本地目录,并禁用代码/Git 相关能力。")})]})]}),S&&e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-destructive-ink",children:t("勾选后会连项目文件一起删除,请谨慎选择。")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("恢复该项目时需要重新绑定一个有效的项目路径。")}),e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-xs text-foreground",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:r=>E(r.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsx("span",{children:t("我已确认这会删除本地项目文件")})]})]}),i.isError&&e.jsx("p",{className:"text-xs text-destructive-ink",children:i.error instanceof Error?i.error.message:t("Failed to delete project")})]})}),e.jsx(Y,{isOpen:q,onClose:W,title:t("Restore Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",onClick:W,disabled:c.isPending,children:t("Cancel")}),e.jsx(R,{onClick:de,disabled:c.isPending||K&&!s.trim(),children:c.isPending?t("Restoring..."):t("Restore Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:K?t("项目「{title}」的本地项目文件已删除。恢复前需要重新绑定一个有效的项目路径。",{title:_}):t("恢复后,项目会重新出现在默认项目列表中。")}),K&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1.5",children:t("Project Path")}),e.jsx(Pe,{value:s,onChange:l,validationMode:"directory"}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:t("Agent Tower 会尽量校验项目 identity;如果 remote URL 或目录名不同,会给出警告但允许继续。")})]}),c.isError&&e.jsx("p",{className:"text-xs text-destructive-ink",children:c.error instanceof Error?c.error.message:t("Failed to restore project")})]})})]})}export{Qe as ProjectSettingsPage};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import{c as dt,o as ct,s as mt,v as ut,u as $,r as j,j as e,n as U,Z as ze,aa as Pe,aZ as G,a_ as P,a$ as pe,I as se,b0 as xt,b1 as pt,T as ae,B as A,E as ft,i as _e,aJ as gt,k as ht,b2 as vt,x as bt,b3 as yt,b4 as jt,t as M,as as Nt,m as xe,b5 as wt,az as ye}from"./index-Cz73HpYH.js";import{c as Pt,b as Ct,r as Fe,d as Oe,u as kt,e as Et,E as St,f as It,s as At,i as De,h as Re,a as Je,j as je,k as Tt,l as _t,m as Ot,p as Dt,n as Rt,o as Ut,q as Ue,w as Lt,t as Kt}from"./ExecutionPermissionSelector-DcC4IBOF.js";import{a as Mt,b as Bt,u as zt,c as Ft,d as Jt,e as $t,f as qt,g as Wt,h as Gt}from"./use-providers-BRyZjuBG.js";import{C as Xt}from"./confirm-dialog-BRkrtULz.js";import{M as Ce}from"./modal-Kpqn-nDO.js";import{S as Le}from"./select-DGwKE4l0.js";import{T as Ke}from"./textarea-Bnfq7adW.js";import{S as $e}from"./toggles-DxNDJZsN.js";import"./mermaid-NOHMQCX5-DmKVQY9m.js";import"./use-attachments-CK7y5KsN.js";import{C as qe}from"./index-B6Lvy5Sr.js";import{S as Vt}from"./SettingsMasterDetail-UfyoKAum.js";import{K as Yt}from"./key-round-DpYSyeDH.js";import{T as We,P as Ne}from"./trash-2-ALAYDudv.js";import{U as Ht}from"./upload-D7hKT2VA.js";import{P as Zt}from"./pencil-pzVKblxj.js";import"./check-DYlb0A_N.js";import"./dialog-B_vC5R4B.js";import"./index-BCV57B4O.js";import"./select-yem-xN9Z.js";import"./menu-styles-DWynpVVz.js";import"./index-ZO2tqdha.js";import"./index-CTG-4w90.js";import"./index-CMjLMilU.js";import"./index-DENY_U7o.js";import"./tooltip-CHOgkFbE.js";import"./kbd-B3m64lRd.js";const Qt=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],es=dt("flask-conical",Qt);function ts(){return ct({queryKey:mt.system.cursorAgentModels,queryFn:()=>ut.get("/system/cursor-agent-models"),staleTime:1e3*60*10})}function ss({value:t,onChange:i}){const{t:a}=$(),{data:u,isLoading:m,isError:C}=ts(),s=u?.models??[],[E,r]=j.useState(!1),[v,b]=j.useState(""),x=j.useMemo(()=>{const f=v.trim().toLowerCase();return f?s.filter(k=>k.id.toLowerCase().includes(f)||k.label.toLowerCase().includes(f)):s},[s,v]);return e.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-w-0",children:[e.jsx("input",{type:"text",value:t,onChange:f=>{const k=f.target.value;i(k===""?void 0:k)},placeholder:a("留空为 auto;或直接输入模型 ID(与 cursor-agent --model 一致)"),className:"w-full px-3 py-1.5 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring/60 font-mono"}),e.jsxs("button",{type:"button",onClick:()=>r(f=>!f),disabled:m,className:"flex items-center gap-1 text-xs text-foreground/70 hover:text-foreground disabled:opacity-50 w-fit",children:[e.jsx(qe,{size:14,className:U("transition-transform",E&&"rotate-180")}),m?a("正在加载 cursor-agent 模型列表…"):E?a("收起列表"):a("从本机 cursor-agent 选择({count} 个)",{count:s.length})]}),E&&!m&&e.jsxs("div",{className:"rounded-lg border border-border bg-background shadow-raised overflow-hidden",children:[e.jsx("input",{type:"text",value:v,onChange:f=>b(f.target.value),placeholder:a("筛选模型…"),className:"w-full px-3 py-2 text-sm border-b border-border/60 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-ring/60"}),e.jsxs("div",{className:"max-h-[min(50vh,22rem)] overflow-y-auto py-1",children:[e.jsx("button",{type:"button",onClick:()=>{i(void 0),r(!1),b("")},className:U("w-full px-3 py-2 text-left text-sm hover:bg-accent",t?"text-foreground/80":"bg-muted/50 font-medium"),children:a("默认 (auto)")}),x.map(f=>e.jsxs("button",{type:"button",onClick:()=>{i(f.id),r(!1),b("")},className:U("w-full px-3 py-2 text-left text-sm hover:bg-accent border-t border-border/60",t===f.id?"bg-foreground/[0.06]":""),children:[e.jsx("div",{className:"font-mono text-xs text-foreground break-all",children:f.id}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 break-words",children:f.label})]},f.id)),x.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground text-center",children:a("无匹配项")})]})]}),(C||u?.error)&&e.jsxs("p",{className:"text-xs text-warning-ink",children:[a("无法从本机加载模型列表({error})。仍可手动输入;或在安装 cursor-agent 的机器上运行",{error:u?.error??a("请求失败")}),e.jsx("code",{className:"mx-0.5 bg-muted px-1 rounded text-[11px]",children:"cursor-agent --list-models"}),a("查看 ID。")]})]})}function ns(t){if(!t)return null;try{const i=new URL(t);return i.protocol!=="http:"&&i.protocol!=="https:"?null:`${i.origin}${i.pathname}`}catch{return null}}function rs(t,i){if(!t)return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"medium"}).format(a)}function is({result:t}){const{locale:i,t:a}=$(),u=ns(t.target?.endpoint),m=rs(t.testedAt,i);return e.jsx("div",{"data-provider-test-result":!0,className:U("rounded-lg border px-4 py-3 text-sm",t.ok?"border-success/30 bg-success/10 text-success-ink":"border-warning/30 bg-warning/10 text-foreground"),children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.ok?e.jsx(ze,{size:16,className:"shrink-0"}):e.jsx(Pe,{size:16,className:"shrink-0 text-warning"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium",children:t.ok?t.stage==="connection"?a("连接测试通过"):a("本机可用性检查通过"):a("配置检查未通过")}),e.jsx("div",{className:"mt-0.5 break-words text-xs opacity-80",children:t.summary}),(u||m)&&e.jsxs("dl",{className:"mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs opacity-80",children:[u&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"font-medium",children:a("测试对象")}),e.jsx("dd",{className:"min-w-0",children:e.jsx("code",{className:"break-all",children:u})})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"font-medium",children:a("测试时间")}),e.jsx("dd",{className:"min-w-0 break-words",children:e.jsx("time",{dateTime:t.testedAt,children:m})})]})]}),!t.ok&&e.jsx("div",{className:"mt-1 text-xs opacity-80",children:a("测试失败不会阻止保存。")})]})]})})}function as({options:t,value:i,onChange:a,label:u,efficiencyLabel:m,intelligenceLabel:C,followCliLabel:s,currentLabel:E,disabled:r=!1,error:v}){const b=t.findIndex(g=>g.value===i),x=i==="",f=j.useRef(b>=0?i:void 0),k=j.useRef(null),S=j.useRef(null),[B,J]=j.useState(!1);j.useEffect(()=>{b>=0&&(f.current=i)},[b,i]);const q=g=>{if(r||x||t.length===0)return;const w=t[Math.max(0,Math.min(t.length-1,g))];w&&w.value!==i&&a(w.value)},X=g=>{const w=S.current?.getBoundingClientRect();if(!w||w.width<=0)return;const W=Math.max(0,Math.min(1,(g-w.left)/w.width));q(Math.round(W*(t.length-1)))},L=b>=0?t[b]:void 0,K=b<0||t.length<2?0:b/(t.length-1)*100,R=j.useId(),V=`${R}-label`,T=`${R}-current`,O=`${R}-error`;return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3",children:[e.jsx("label",{id:V,className:"text-xs font-medium text-foreground",children:u}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e.jsx($e,{checked:x,disabled:r,onCheckedChange:g=>{a(g?"":f.current??t.find(w=>w.value==="medium")?.value??t[0]?.value??"")},"aria-label":s})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground","aria-hidden":"true",children:[e.jsx("span",{children:m}),e.jsx("span",{children:C})]}),e.jsxs("div",{id:R,ref:S,role:"slider",tabIndex:x||r?-1:0,"aria-labelledby":V,"aria-disabled":x||r,"aria-valuemin":0,"aria-valuemax":Math.max(0,t.length-1),"aria-valuenow":b>=0?b:void 0,"aria-valuetext":L?`${L.label}, ${L.value}`:s,"aria-describedby":v?`${T} ${O}`:T,onKeyDown:g=>{if(x||r||b<0)return;let w=b;if(g.key==="ArrowLeft"||g.key==="ArrowDown")w-=1;else if(g.key==="ArrowRight"||g.key==="ArrowUp")w+=1;else if(g.key==="Home")w=0;else if(g.key==="End")w=t.length-1;else return;g.preventDefault(),q(w)},onPointerDown:g=>{x||r||(k.current=g.pointerId,J(!0),g.currentTarget.setPointerCapture?.(g.pointerId),X(g.clientX))},onPointerMove:g=>{k.current===g.pointerId&&X(g.clientX)},onPointerUp:g=>{k.current===g.pointerId&&(k.current=null,J(!1),g.currentTarget.releasePointerCapture?.(g.pointerId))},onPointerCancel:()=>{k.current=null,J(!1)},className:U("relative mx-2.5 flex h-11 touch-pan-y items-center outline-none select-none",x||r?"cursor-not-allowed opacity-55":"cursor-pointer","focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2"),children:[e.jsx("div",{className:"absolute inset-x-0 h-1 rounded-full bg-border"}),!x&&e.jsx("div",{className:"absolute left-0 h-1 rounded-full bg-primary transition-[width] duration-150 motion-reduce:transition-none",style:{width:`${K}%`}}),t.map((g,w)=>e.jsx("span",{"aria-hidden":"true",className:U("absolute size-3 -translate-x-1/2 rounded-full border-2 transition-colors motion-reduce:transition-none",!x&&w<=b?"border-primary bg-primary":"border-border bg-background"),style:{left:`${t.length<2?0:w/(t.length-1)*100}%`}},g.value)),!x&&L&&e.jsx("span",{"aria-hidden":"true",className:U("absolute size-5 -translate-x-1/2 rounded-full border-[5px] border-primary bg-background shadow-raised transition-[left,transform] duration-150 motion-reduce:transition-none",B&&"scale-110"),style:{left:`${K}%`}})]}),e.jsx("div",{id:T,className:"min-h-5 text-center text-xs text-muted-foreground",children:x?s:`${E}: ${L?.label??i} (${L?.value??i})`}),v&&e.jsx("p",{id:O,role:"alert",className:"text-xs text-destructive-ink",children:v})]})}const F={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},Ge={[P.CLAUDE_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},F],[P.GEMINI_CLI]:[{key:"yolo",label:"自动批准操作(YOLO)",type:"switch"},F],[P.CURSOR_AGENT]:[{key:"force",label:"强制执行",type:"switch"},F],[P.CODEX]:[{key:"dangerouslyBypassApprovalsAndSandbox",label:"跳过所有确认和沙盒",type:"switch"},{key:"fastMode",label:"Fast 模式",type:"switch"},{key:"disableResponsesWebsocket",label:"禁用 WebSocket",type:"switch"},{key:"profile",label:"Profile",type:"input",placeholder:"~/.codex/config.toml 中的 profile 名称"},F],[P.QWEN_CODE]:[F],[P.KIRO_CLI]:[{key:"trustAllTools",label:"信任所有工具",type:"switch"},F],[P.OPENCODE]:[{key:"autoApprove",label:"自动批准操作",type:"switch"},F],[P.PI_CODING_AGENT]:[{key:"autoApprove",label:"自动批准操作",type:"switch"},{key:"supportsImages",label:"模型支持图片输入",type:"switch"},F],[P.GROK_BUILD]:[{key:"alwaysApprove",label:"始终批准操作",type:"switch"},F],[P.MINION_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},F]};function Me(){return{}}function Xe(t,i){return{...i}}const os=JSON.stringify({env:{ANTHROPIC_API_KEY:"",ANTHROPIC_BASE_URL:""}},null,2),ls=`# Codex config.toml 配置片段 — 通过 -c 参数注入,不会修改 ~/.codex/config.toml
|
|
2
|
+
# 参考: https://developers.openai.com/codex/config-sample
|
|
3
|
+
|
|
4
|
+
# ─── 模型与推理 ─────────────────────────────────────────────
|
|
5
|
+
# model_reasoning_effort = "medium" # minimal | low | medium | high | xhigh | max | ultra
|
|
6
|
+
# model_reasoning_summary = "auto" # auto | concise | detailed | none
|
|
7
|
+
# model_verbosity = "medium" # low | medium | high
|
|
8
|
+
# service_tier = "fast"
|
|
9
|
+
# features.fast_mode = true
|
|
10
|
+
|
|
11
|
+
# ─── 自定义 Model Provider ──────────────────────────────────
|
|
12
|
+
# model_provider = "azure"
|
|
13
|
+
#
|
|
14
|
+
# [model_providers.azure]
|
|
15
|
+
# name = "Azure OpenAI"
|
|
16
|
+
# base_url = "https://YOUR_PROJECT.openai.azure.com/openai"
|
|
17
|
+
# env_key = "AZURE_OPENAI_API_KEY"
|
|
18
|
+
# env_key_instructions = "Set AZURE_OPENAI_API_KEY in Provider env"
|
|
19
|
+
# wire_api = "responses"
|
|
20
|
+
# query_params = { api-version = "2025-04-01-preview" }
|
|
21
|
+
|
|
22
|
+
# ─── OpenAI 数据驻留 ────────────────────────────────────────
|
|
23
|
+
# [model_providers.openai-us]
|
|
24
|
+
# name = "OpenAI US"
|
|
25
|
+
# base_url = "https://us.api.openai.com/v1"
|
|
26
|
+
# wire_api = "responses"
|
|
27
|
+
# requires_openai_auth = true
|
|
28
|
+
|
|
29
|
+
# ─── 本地 OSS (Ollama) ──────────────────────────────────────
|
|
30
|
+
# [model_providers.ollama]
|
|
31
|
+
# name = "Ollama"
|
|
32
|
+
# base_url = "http://localhost:11434/v1"
|
|
33
|
+
# wire_api = "responses"
|
|
34
|
+
`,ds=`# Codex config.toml snippet — injected through -c; ~/.codex/config.toml is not modified.
|
|
35
|
+
# Reference: https://developers.openai.com/codex/config-sample
|
|
36
|
+
|
|
37
|
+
# ─── Model and reasoning ────────────────────────────────────
|
|
38
|
+
# model_reasoning_effort = "medium" # minimal | low | medium | high | xhigh | max | ultra
|
|
39
|
+
# model_reasoning_summary = "auto" # auto | concise | detailed | none
|
|
40
|
+
# model_verbosity = "medium" # low | medium | high
|
|
41
|
+
# service_tier = "fast"
|
|
42
|
+
# features.fast_mode = true
|
|
43
|
+
|
|
44
|
+
# ─── Custom Model Provider ──────────────────────────────────
|
|
45
|
+
# model_provider = "azure"
|
|
46
|
+
#
|
|
47
|
+
# [model_providers.azure]
|
|
48
|
+
# name = "Azure OpenAI"
|
|
49
|
+
# base_url = "https://YOUR_PROJECT.openai.azure.com/openai"
|
|
50
|
+
# env_key = "AZURE_OPENAI_API_KEY"
|
|
51
|
+
# env_key_instructions = "Set AZURE_OPENAI_API_KEY in Provider env"
|
|
52
|
+
# wire_api = "responses"
|
|
53
|
+
# query_params = { api-version = "2025-04-01-preview" }
|
|
54
|
+
|
|
55
|
+
# ─── OpenAI data residency ──────────────────────────────────
|
|
56
|
+
# [model_providers.openai-us]
|
|
57
|
+
# name = "OpenAI US"
|
|
58
|
+
# base_url = "https://us.api.openai.com/v1"
|
|
59
|
+
# wire_api = "responses"
|
|
60
|
+
# requires_openai_auth = true
|
|
61
|
+
|
|
62
|
+
# ─── Local OSS (Ollama) ─────────────────────────────────────
|
|
63
|
+
# [model_providers.ollama]
|
|
64
|
+
# name = "Ollama"
|
|
65
|
+
# base_url = "http://localhost:11434/v1"
|
|
66
|
+
# wire_api = "responses"
|
|
67
|
+
`;function cs(t,i){return t===P.CLAUDE_CODE?os:t===P.CODEX?i==="zh-CN"?ls:ds:""}function ms(t){return t===P.CLAUDE_CODE||t===P.CODEX}const we="::ACP";function Be(t,i){return i===G.ACP?`${t}${we}`:String(t)}function oe(t,i){const a=jt(t);return i===G.ACP?`${a} (ACP)`:a}function us(t){return t.endsWith(we)?{agentType:t.slice(0,-we.length),runtimeType:G.ACP}:{agentType:t,runtimeType:G.CLI}}function xs(t,i){if(!t.trim())return t;try{const a=JSON.parse(t);if(!a.env||typeof a.env!="object"||Array.isArray(a.env))return t;const u=a.env;return i in u?(delete u[i],JSON.stringify(a,null,2)):t}catch{return t}}const Ve=Object.values(Ge).flat().reduce((t,i)=>(t[i.key]||(t[i.key]=i.label),t),{});Ve.permissionMode="权限策略";const Ye=Object.values(Ge).flat().reduce((t,i)=>(i.options&&(t[i.key]=Object.fromEntries(i.options.map(a=>[a.value,a.label]))),t),{});Ye.permissionMode={ASK:"每次询问",AUTO_APPROVE:"无限制",UNRESTRICTED:"无限制"};function ps(t,i){if(typeof i=="boolean")return i?ye("是"):ye("否");if(typeof i=="string"&&i){const a=Ye[t]?.[i];return a?ye(a):i}return String(i)}function H(t,i){return t instanceof Error?t.message:i}function fs(t){return t==="apiBaseUrl"?"API 地址":t==="apiKey"?"API Key":t==="reasoningEffort"?"思考强度":t==="model"?"模型":t==="executionPermission"?"执行权限":t==="fastMode"?"Fast 模式":t==="disableResponsesWebsocket"?"禁用 WebSocket":t}function gs(t){return{minimal:"最低",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最高",ultra:"Ultra"}[t]??t}function hs(t){return`agent-tower-provider-backup-${t.replace(/[:.]/g,"-")}.json`}function vs(t,i){const a=new Blob([JSON.stringify(i,null,2)],{type:"application/json"}),u=URL.createObjectURL(a),m=document.createElement("a");m.href=u,m.download=t,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}function bs(t){switch(t){case"CREATE":return{label:"新增",className:"bg-success/10 text-success-ink"};case"OVERWRITE":return{label:"覆盖",className:"bg-warning/10 text-warning-ink"};case"SKIP":return{label:"跳过",className:"bg-muted text-muted-foreground"}}}function ys({issue:t}){const{t:i}=$(),a=!t;return e.jsx("span",{className:U("inline-block h-2 w-2 rounded-full shrink-0",a?"bg-success":"bg-border"),title:t?`${i("不可用")}: ${i(t)}`:i("可用"),children:e.jsx("span",{className:"sr-only",children:i(a?"可用":"不可用")})})}function js({issue:t}){const{t:i}=$();return t?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[e.jsx(wt,{size:11,"aria-hidden":"true"}),i("不可用")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success-ink",children:[e.jsx(ze,{size:11,"aria-hidden":"true"}),i("可用")]})}function Ns({title:t,status:i,defaultOpen:a=!1,children:u}){const[m,C]=j.useState(a);return e.jsxs("div",{className:"rounded-lg border border-border",children:[e.jsxs("button",{type:"button",onClick:()=>C(s=>!s),"aria-expanded":m,className:"w-full flex items-center justify-between rounded-lg px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t}),i]}),e.jsx(qe,{size:14,"aria-hidden":"true",className:U("text-muted-foreground transition-transform motion-reduce:transition-none",m&&"rotate-180")})]}),m&&e.jsx("div",{className:"px-4 pb-4 space-y-3",children:u})]})}function ws({isOpen:t,onClose:i,providerId:a,initialData:u,onSave:m}){const{locale:C,t:s}=$(),E=Mt(),[r,v]=j.useState(u??{name:"",agentType:P.CLAUDE_CODE,runtimeType:G.CLI,executionPermission:"ASK",config:Me(),settings:"",env:[],simplified:{apiKey:{configured:!1,envKey:"ANTHROPIC_API_KEY"}},diagnostics:[],isDefault:!1}),[b,x]=j.useState(()=>JSON.stringify(r.config,null,2)),[f,k]=j.useState(""),[S,B]=j.useState(()=>r.diagnostics?.find(n=>n.field==="settings")?.message??""),[J,q]=j.useState(!1),[X,L]=j.useState(!1),[K,R]=j.useState(null),[V,T]=j.useState(()=>new Set),[O,g]=j.useState(()=>r.diagnostics?.filter(n=>n.code==="CONFLICT")??[]),[w,W]=j.useState({}),Z=j.useRef(Pt()),{data:fe}=Bt(r.agentType,r.simplified.model,{providerId:a,runtimeType:r.runtimeType,config:r.config,settings:r.settings}),y=fe?.[r.agentType]??pe[r.agentType],z=y.apiBaseUrl?Ct(r.simplified.apiBaseUrl):null,le=Fe(r),Q=r.executionPermission??le.mode,ne=y.executionPermissionOptions?.[r.runtimeType],de=ne?.find(n=>n.mode===Q),Y=le.diagnostics[0]?.message??(ne?de?.selectable?null:de?.reasons[0]?.message??s("This Agent has no available execution permission mode."):s("Loading permission support…")),c=y.disableResponsesWebsocket,p=c?Oe(r.config,c):null,I=y.fastMode,D=I?Oe(r.config,I):null,ke=I?r.config[I.path]:void 0,He=ke===!0?"fast":ke===!1?"standard":"inherit",ge=r.simplified.reasoningEffort??"",ce=ge&&!y.reasoningEffort?.options?.includes(ge)?s("请选择当前 Agent 支持的思考强度档位"):null,he=n=>{Z.current.invalidate(),n&&v(n),L(!0),R(null)},_=n=>{he(n)},Ee=()=>{X&&!window.confirm(s("存在未保存的修改,确定放弃吗?"))||i()},Ze=n=>r.env.find(o=>je(o.key,n)),re=(n,o,l="")=>{if(o.action!=="keep"){const d=n===y.apiBaseUrl?.path?"apiBaseUrl":n===y.apiKey?.path?"apiKey":null;d&&W(h=>{const N={...h};return delete N[d],N})}_(d=>{const h=d.env.findIndex(lt=>je(lt.key,n)),N=[...d.env],te=h>=0?N[h]:null,ie={key:te?.key??n,value:l,write:o,configured:te?.configured??!1,sensitive:je(n,d.simplified.apiKey?.envKey)||!!te?.sensitive||/key|token|secret|password|auth/i.test(n)};h>=0?N[h]=ie:N.push(ie);const ot=d.agentType===P.CLAUDE_CODE&&o.action!=="keep"&&(n===y.apiBaseUrl?.path||n===y.apiKey?.path);return{...d,env:N,settings:ot?xs(d.settings,n):d.settings}})},me=(n,o)=>{W(l=>{if(!(n in l))return l;const d={...l};return delete d[n],d}),T(l=>new Set(l).add(n)),n==="apiBaseUrl"&&y.apiBaseUrl?.kind==="env"&&re(y.apiBaseUrl.path,o?{action:"replace",value:o}:{action:"clear"},o),_(l=>{const d=Ut(l,n,o,y);return d.config!==l.config&&x(JSON.stringify(d.config,null,2)),d})},Qe=n=>{c&&_(o=>{const l=Ue(o,c,n);return x(JSON.stringify(l.config,null,2)),l})},et=n=>{I&&_(o=>{const l=Ue(o,I,n==="inherit"?void 0:n==="fast");return x(JSON.stringify(l.config,null,2)),l})},tt=n=>{if(X&&!window.confirm(s("切换 Agent 类型会清空当前类型的配置,是否继续?")))return;const{agentType:o,runtimeType:l}=us(n),d=pe[o],h=Me(),N={...r,agentType:o,runtimeType:l,executionPermission:Q,executionPermissionReviewRequired:void 0,config:h,settings:"",env:[],simplified:{apiKey:d.apiKey?{configured:!1,envKey:d.apiKey.path}:void 0}};he(()=>N),x(JSON.stringify(h,null,2)),k(""),B(""),q(!1),T(new Set),g([]),W({})},Se=(n=!1)=>{let o=!f&&!Y&&!D?.error&&!p?.error&&!ce;const l=r.settings.trim();if(l&&(J||n))try{if(r.agentType===P.CODEX)Dt(l);else if(r.agentType===P.CLAUDE_CODE){const d=JSON.parse(l);if(!d||typeof d!="object"||Array.isArray(d))throw new Error(s("JSON 顶层必须是对象"))}B("")}catch(d){B(s("{format} 语法错误: {message}",{format:r.agentType===P.CODEX?"TOML":"JSON",message:d instanceof Error?d.message:String(d)})),o=!1}return o},Ie=()=>{const n=Rt(r.env),o=Object.fromEntries([...V].map(l=>[l,r.simplified[l]]));return{providerId:a,name:r.name,agentType:r.agentType,runtimeType:r.runtimeType,executionPermission:Q,env:n,config:r.config,settings:r.settings,simplified:V.size>0?o:void 0,conflictResolutions:w,isDefault:r.isDefault}},st=()=>{if(z||!Se(!1))return;const o={...Ie()};delete o.providerId,a&&delete o.runtimeType,m(o)},nt=()=>{if(z||O.length>0||!Se(!0))return;const n=Z.current.begin();R(null),E.mutate(Ie(),{onSuccess:o=>{Z.current.isCurrent(n)&&R(o)},onError:o=>{Z.current.isCurrent(n)&&R({ok:!1,stage:"connection",errorKind:"unknown",summary:H(o,s("测试配置失败"))})}})};if(!t)return null;const rt=ms(r.agentType),ue=r.agentType===P.CODEX,ve=ue&&kt(r.settings),ee=r.simplified.apiKey?.envKey??y.apiKey?.path,be=ee?Ze(ee):void 0,Ae=Et(be,!!r.simplified.apiKey?.configured,w.apiKey),it=Ae==="advanced",Te=Ae!=="unconfigured",at=!r.name.trim()||!!z||!!f||!!Y||!!D?.error||!!p?.error||!!ce||!!S&&J||O.length>0;return e.jsx(e.Fragment,{children:e.jsx(Ce,{isOpen:t,onClose:Ee,title:s(u?"编辑 Provider":"新建 Provider"),className:"max-w-3xl",action:e.jsxs("div",{className:"flex w-full flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(A,{variant:"outline",onClick:nt,disabled:E.isPending||!!z||!!f||!!Y||!!D?.error||!!p?.error||!!ce||!!S&&J||O.length>0,children:[E.isPending?e.jsx(ft,{className:"animate-spin motion-reduce:[animation-duration:2.4s]"}):e.jsx(es,{}),E.isPending?s("测试中..."):s("测试配置")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{variant:"outline",onClick:Ee,children:s("取消")}),e.jsx(A,{onClick:st,disabled:at,children:s("保存 Provider")})]})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-name",className:"mb-1 block text-xs font-medium text-foreground",children:s("名称")}),e.jsx(se,{id:"provider-name",value:r.name,onChange:n=>_(o=>({...o,name:n.target.value})),placeholder:s("例如: Claude Code (官方)")})]}),!u&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("Agent 类型")}),e.jsx(Le,{value:Be(r.agentType,r.runtimeType),onChange:tt,options:xt.flatMap(n=>pt[n].map(o=>({value:Be(n,o),label:oe(n,o),icon:e.jsx(ae,{agentType:n,className:"size-4"})}))),placeholder:s("选择 Agent 类型")})]}),u&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("Agent 类型")}),e.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border bg-muted/30 px-3 text-sm text-muted-foreground",children:[e.jsx(ae,{agentType:r.agentType,className:"size-4"}),e.jsx("span",{className:"min-w-0 truncate",children:oe(r.agentType,r.runtimeType)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"isDefault",checked:r.isDefault,onChange:n=>_(o=>({...o,isDefault:n.target.checked})),className:"h-4 w-4 rounded border-border accent-primary"}),e.jsx("label",{htmlFor:"isDefault",className:"text-sm text-foreground",children:s("设为该类型的默认 Provider")})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/20 p-4",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s("基本配置")}),e.jsx(St,{value:Q,agentType:r.agentType,options:ne,error:Y,onChange:n=>_(o=>{const l=Lt(o.agentType,o.config);return x(JSON.stringify(l,null,2)),{...o,executionPermission:n,executionPermissionReviewRequired:void 0,config:l}})}),y.apiBaseUrl&&!ve&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-api-url",className:"mb-1 block text-xs font-medium text-foreground",children:s("API 地址")}),e.jsx(se,{id:"provider-api-url",type:"url",value:r.simplified.apiBaseUrl??"",onChange:n=>me("apiBaseUrl",n.target.value),placeholder:y.apiBaseUrl.placeholder,"aria-invalid":!!z,"aria-describedby":z?"provider-api-url-error":void 0}),z&&e.jsx("p",{id:"provider-api-url-error",role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("请输入以 http:// 或 https:// 开头的完整 API 地址")})]}),y.apiKey&&!ve&&(r.agentType!==P.CODEX||!!r.simplified.apiKey)&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:"API Key"}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Yt,{size:12}),s(it?"由高级配置管理":Te?"已配置":"未配置")]})]}),be?.write.action==="replace"||!Te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(se,{id:"provider-api-key",type:"password",autoComplete:"new-password",value:be?.value??"",onChange:n=>re(ee,{action:"replace",value:n.target.value},n.target.value),placeholder:s("输入 API Key")}),r.simplified.apiKey?.configured&&e.jsx(A,{variant:"outline",size:"sm",onClick:()=>re(ee,{action:"keep"}),children:s("取消替换")})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{variant:"outline",size:"sm",onClick:()=>re(ee,{action:"replace",value:""}),children:s("替换")}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>{window.confirm(s("确定清除此 API Key?"))&&re(ee,{action:"clear"})},children:s("清除")})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-model",className:"mb-1 block text-xs font-medium text-foreground",children:s("模型")}),r.agentType===P.CURSOR_AGENT?e.jsx(ss,{value:r.simplified.model??"",onChange:n=>me("model",n??"")}):e.jsx(se,{id:"provider-model",value:r.simplified.model??"",onChange:n=>me("model",n.target.value),placeholder:y.model.placeholder})]}),y.reasoningEffort&&e.jsx(as,{options:(y.reasoningEffort.options??[]).map(n=>({value:n,label:s(gs(n))})),value:ge,onChange:n=>me("reasoningEffort",n),label:s("思考强度"),efficiencyLabel:s("更高效"),intelligenceLabel:s("更智能"),followCliLabel:s("跟随 CLI"),currentLabel:s("当前"),error:ce}),I&&D&&e.jsxs("section",{className:"border-t border-border pt-3","data-fast-mode-control":!0,children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_180px] sm:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s("Fast 模式")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s("支持的模型速度约提升至 1.5 倍,并增加用量消耗。ChatGPT 登录消耗更多额度;API Key 按 Priority 处理计费。")})]}),e.jsx(Le,{value:He,disabled:!!D.error,onChange:et,options:[{value:"inherit",label:s("跟随 Codex")},{value:"standard",label:s("标准速度")},{value:"fast",label:"Fast"}]})]}),D.error&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("Fast 模式字段必须为 true 或 false,请在运行配置 JSON 中修正。")})]}),c&&p&&e.jsxs("section",{className:"border-t border-border pt-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s("禁用 WebSocket")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s(ve?"当前原生 Provider 已使用非 WebSocket 传输;此开关不会添加额外运行时覆盖。":"仅禁用 Codex Responses API 的 WebSocket 传输;新启动和后续继续的请求将使用 HTTP。")})]}),e.jsx($e,{checked:p.enabled,disabled:!!p.error,onCheckedChange:Qe,"aria-label":s("禁用 WebSocket")})]}),p.error&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("禁用 WebSocket 字段必须为 true 或 false,请在运行配置 JSON 中修正。")})]})]}),K&&e.jsx(is,{result:K}),O.length>0&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-warning/30 bg-warning/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx(Pe,{size:16,className:"text-warning"}),s("需要解决配置冲突")]}),O.map(n=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-warning/20 bg-background/70 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:s(fs(n.field))})," · ",s("简化字段与高级配置值不同")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["simple","advanced"].map(o=>e.jsx(A,{variant:"outline",size:"sm",onClick:()=>{const l=n.field,d=It(r,l,o,y);_(()=>d),x(JSON.stringify(d.config,null,2)),W(h=>({...h,[l]:o})),o==="advanced"&&(l==="apiBaseUrl"||l==="model"||l==="reasoningEffort")&&T(h=>{const N=new Set(h);return N.delete(l),N}),g(h=>h.filter(N=>N.field!==l))},children:s(o==="simple"?"采用简化值":"保留高级值")},o))})]},n.field))]}),e.jsxs(Ns,{title:s("高级配置"),defaultOpen:!!f||!!S||!!Y||!!D?.error||O.length>0,children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("运行配置 (JSON)")}),e.jsx(Ke,{value:b,onChange:n=>{const o=n.target.value;x(o);try{const l=JSON.parse(o);if(!l||typeof l!="object"||Array.isArray(l))throw new Error(s("JSON 顶层必须是对象"));const d=l;k(""),T(h=>{const N=new Set(h).add("model");return y.reasoningEffort?.kind==="config"&&N.add("reasoningEffort"),N}),_(h=>({...h,config:d,simplified:At(h.simplified,d,y)}))}catch(l){he(),k(l instanceof Error?l.message:s("JSON 语法错误"))}},rows:7,className:"font-mono","aria-invalid":!!f}),f&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:f})]}),e.jsxs("div",{className:"border-t border-border pt-3",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:s("环境变量")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:[s("注入到 Agent 进程的环境变量。Codex 的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"env_key"})," ",s("指定的是变量名,实际值需在此处设置。")]}),e.jsxs("div",{className:"space-y-2",children:[r.env.map((n,o)=>n.write.action!=="clear"&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(se,{value:n.key,disabled:n.configured,onChange:l=>{const d=l.target.value;_(h=>{const N=[...h.env],te=N[o];if(!te)return h;const ie={...te,key:d};return N[o]={...ie,sensitive:De(ie,h.simplified)},{...h,env:N}})},placeholder:s("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 py-1.5 font-mono"}),e.jsx(se,{value:n.value,type:De(n,r.simplified)?"password":"text",onChange:l=>{const d=[...r.env];d[o]={...d[o],value:l.target.value,write:{action:"replace",value:l.target.value}},_(h=>({...h,env:d,simplified:n.key===y.apiBaseUrl?.path?{...h.simplified,apiBaseUrl:l.target.value}:h.simplified})),n.key===y.apiBaseUrl?.path&&T(h=>new Set(h).add("apiBaseUrl"))},placeholder:n.configured&&n.write.action==="keep"?s("已配置,输入新值以替换"):s("值"),className:"flex-1 py-1.5 font-mono"}),e.jsx("button",{type:"button",onClick:()=>{const l=[...r.env];n.configured?l[o]={...n,value:"",write:{action:"clear"}}:l.splice(o,1),_(d=>({...d,env:l,simplified:n.key===y.apiBaseUrl?.path?{...d.simplified,apiBaseUrl:""}:d.simplified})),n.key===y.apiBaseUrl?.path&&T(d=>new Set(d).add("apiBaseUrl"))},"aria-label":s("删除"),className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsx(We,{size:14})})]},o)),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>_(n=>({...n,env:[...n.env,{key:"",value:"",write:{action:"replace",value:""},configured:!1,sensitive:!1}]})),children:[e.jsx(Ne,{size:12,className:"mr-1"}),s("添加变量")]})]})]}),rt&&e.jsxs("div",{className:"border-t border-border pt-3",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:s(ue?"Agent 原生配置 (config.toml)":"Agent 原生配置 (settings.json)")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:ue?e.jsxs(e.Fragment,{children:[s("直接填写 Codex")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"config.toml"})," ",s("格式的配置片段,由当前 Runtime 注入。不会修改你的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"~/.codex/config.toml"})," ",s("文件。")]}):e.jsxs(e.Fragment,{children:[s("对应 Claude Code 的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"~/.claude/settings.json"}),",",s("由当前 Runtime 注入。在")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"env"})," ",s("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),e.jsx(Ke,{value:r.settings,onChange:n=>{const o=n.target.value;q(!0),B("");let l;if(ue)try{l=Re(r.simplified,o,P.CODEX),T(d=>new Set(d).add("reasoningEffort"))}catch{}_(d=>{const h=l===void 0?d.simplified:Re(d.simplified,o,P.CODEX,new Set(d.env.flatMap(N=>N.write.action==="clear"?[]:N.write.action==="replace"?N.value?[N.key]:[]:N.configured?[N.key]:[])));return{...d,settings:o,env:Kt(d.env,h),simplified:h}})},rows:10,className:"font-mono",placeholder:cs(r.agentType,C),"aria-invalid":!!S}),S&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:S})]})]})]})})})}function Ps({isOpen:t,onClose:i,onConfirm:a,acknowledged:u,onAcknowledgedChange:m,isLoading:C}){const{t:s}=$();return e.jsx(Ce,{isOpen:t,onClose:i,title:s("导出 Provider 备份"),className:"max-w-xl",action:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",onClick:i,disabled:C,children:s("取消")}),e.jsx(A,{onClick:a,disabled:!u||C,children:s(C?"导出中...":"导出备份")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-warning/30 bg-warning/10 px-4 py-3 text-sm text-foreground",children:[e.jsx(Pe,{size:15,className:"mt-0.5 shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{children:s("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")})]}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:s("这个功能用于备份和迁移,不用于分享配置。")}),e.jsx("p",{children:s("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-border px-4 py-3 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:E=>m(E.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsx("span",{children:s("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function Cs({isOpen:t,onClose:i,preview:a,backup:u,onConfirm:m,isLoading:C}){const{t:s}=$();if(!a||!u)return null;const E=a.summary.create+a.summary.overwrite,r=[...a.items].sort((v,b)=>{const x={CREATE:0,OVERWRITE:1,SKIP:2};return x[v.action]-x[b.action]});return e.jsx(Ce,{isOpen:t,onClose:i,title:s("导入 Provider 备份"),className:"max-w-3xl",action:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",onClick:i,disabled:C,children:s("取消")}),e.jsx(A,{onClick:m,disabled:E===0||C,children:C?s("导入中..."):s("确认导入 {count} 项",{count:E})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{children:s("导出时间:{value}",{value:new Date(u.exportedAt).toLocaleString()})}),e.jsx("div",{children:s("模式:完整备份(含敏感信息)")}),e.jsx("div",{children:s("文件内 Provider 数量:{count}",{count:u.providers.length})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-success/25 bg-success/10 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-success-ink",children:s("新增")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.create})]}),e.jsxs("div",{className:"rounded-lg border border-warning/25 bg-warning/10 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-warning-ink",children:s("覆盖")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.overwrite})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s("跳过")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.skip})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:r.map(v=>{const b=bs(v.action);return e.jsxs("div",{className:"rounded-lg border border-border px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"truncate text-sm font-medium text-foreground",children:v.incoming.name}),e.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${b.className}`,children:s(b.label)})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ae,{agentType:v.incoming.agentType,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:oe(v.incoming.agentType,v.incoming.runtimeType)})," · ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:v.incoming.id})]})]})}),v.action==="OVERWRITE"&&v.existing&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("将覆盖当前已有的 Provider:{name}",{name:v.existing.name})}),v.action==="SKIP"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前同 ID Provider 配置一致,本次不会重复写入。")}),v.action==="CREATE"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前不存在同 ID Provider,将直接新增。")})]},v.incoming.id)})})]})})}function ks({item:t,onEdit:i,onDelete:a}){const{t:u}=$(),m=t.provider,C=Je(t),s=Tt(m),E=Xe(m.agentType,m.config),r=pe[m.agentType],v=Object.entries(E).filter(([x])=>x!=="cmd"&&x!==r.executionPermission.path),b=Object.keys(m.redactedEnv||{});return e.jsxs("div",{className:"min-w-0 space-y-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("h3",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:m.name}),e.jsx(js,{issue:C})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(ae,{agentType:m.agentType,className:"size-3.5"}),e.jsx("span",{className:"truncate",children:oe(m.agentType,m.runtimeType)})]}),m.isDefault&&e.jsx("span",{className:"rounded-full bg-primary/[0.06] px-2 py-0.5 text-xs font-medium text-primary",children:u("默认")}),m.builtIn&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:u("内置")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:shrink-0",children:[e.jsxs(A,{size:"sm",variant:"outline",onClick:i,children:[e.jsx(Zt,{size:13}),u("编辑")]}),e.jsxs(A,{size:"sm",variant:m.builtIn?"outline":"destructive",onClick:a,disabled:m.deletable===!1,children:[m.builtIn?e.jsx(Nt,{size:13}):e.jsx(We,{size:13}),m.builtIn?u("恢复默认"):u("删除")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:u("Execution permission")}),e.jsx("p",{className:"text-sm",children:u(_t[Fe(m).mode])}),s&&!m.diagnostics?.some(x=>x.field==="executionPermission")?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:u(s)}):null,m.diagnostics?.filter(x=>x.field==="executionPermission").map((x,f)=>e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:u(x.message)},`${x.code}-${f}`)),C&&!s?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:u(C)}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:u("Changes apply when a new runtime starts. Running sessions keep their launch mode.")})]}),v.length>0&&e.jsxs("div",{children:[e.jsx(xe,{className:"mb-3",children:u("运行配置")}),e.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:v.map(([x,f])=>e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1 bg-background px-4 py-2.5 sm:flex-row sm:items-center sm:gap-4",children:[e.jsx("span",{className:"min-w-0 break-words text-[13px] text-muted-foreground sm:w-32 sm:shrink-0",children:u(Ve[x]??x)}),e.jsx("span",{className:"min-w-0 max-w-full break-all font-mono text-[13px] text-foreground",children:ps(x,f)})]},x))})]}),b.length>0&&e.jsxs("div",{children:[e.jsx(xe,{className:"mb-3",children:u("环境变量")}),e.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:b.map(x=>e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 bg-background px-4 py-2.5 sm:gap-4",children:[e.jsx("span",{className:"min-w-0 max-w-full break-all font-mono text-[13px] text-foreground",children:x}),e.jsx("span",{className:"text-[13px] text-muted-foreground","aria-label":"hidden",children:"•••••"})]},x))})]}),m.settings?.trim()&&e.jsxs("div",{children:[e.jsx(xe,{className:"mb-3",children:u("Agent 原生配置")}),e.jsx("div",{className:"rounded-lg border border-border bg-muted/40 p-4",children:e.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:m.settings})})]}),v.length===0&&b.length===0&&!m.settings?.trim()&&e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:u('该 Provider 未配置额外参数。点击"编辑"添加运行配置、环境变量或 Agent 原生配置。')})]})}function en(){const{t}=$(),{data:i,isLoading:a}=zt(),u=Ft(),m=Jt(),C=$t(),s=qt(),E=Wt(),r=Gt(),v=j.useRef(null),[b,x]=j.useState(null),[f,k]=j.useState(null),[S,B]=j.useState(null),[J,q]=j.useState(!1),[X,L]=j.useState(!1),[K,R]=j.useState(null),[V,T]=j.useState(!1),O=i??[],g=b??O[0]?.provider.id??null,w=c=>{u.mutate(c,{onSuccess:()=>k(null),onError:p=>M.error(H(p,t("创建 Provider 失败")))})},W=(c,p)=>{m.mutate({id:c,data:p},{onSuccess:()=>k(null),onError:I=>M.error(H(I,t("更新 Provider 失败")))})},Z=c=>{if(!(c.deletable??!c.builtIn)){M.error(t("系统内置 Provider 不可删除"));return}B({id:c.id,name:c.name,builtIn:c.builtIn})},fe=()=>{S&&C.mutate(S.id,{onSuccess:()=>{M.success(S.builtIn?t("已恢复默认 Provider 配置"):t("Provider 已删除")),g===S.id&&x(null),B(null),T(!1)},onError:c=>M.error(H(c,t("删除 Provider 失败")))})},y=()=>{q(!1),L(!1)},z=()=>R(null),le=()=>{s.mutate(void 0,{onSuccess:c=>{vs(hs(c.exportedAt),c),M.success(t("Provider 备份已导出")),y()},onError:c=>M.error(H(c,t("导出 Provider 备份失败")))})},Q=()=>{v.current&&(v.current.value="",v.current.click())},ne=async c=>{const p=c.target.files?.[0];if(c.target.value="",!p)return;let I;try{I=JSON.parse(await p.text())}catch{M.error(t("备份文件不是有效的 JSON"));return}E.mutate(I,{onSuccess:D=>R({backup:I,preview:D}),onError:D=>M.error(H(D,t("导入预览失败")))})},de=()=>{K&&r.mutate(K.backup,{onSuccess:c=>{const p=c.summary.create+c.summary.overwrite;M.success(p===0?t("导入完成,当前配置无需变更"):t("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:c.summary.create,overwrite:c.summary.overwrite,skip:c.summary.skip})),z()},onError:c=>M.error(H(c,t("导入 Provider 备份失败")))})},Y=c=>{const p=c.provider,I=pe[p.agentType],D=Ot(p,I);k({id:p.id,data:{name:p.name,agentType:p.agentType,runtimeType:p.runtimeType===G.ACP?G.ACP:G.CLI,executionPermission:p.executionPermission,executionPermissionReviewRequired:p.executionPermissionReviewRequired,config:Xe(p.agentType,p.config),settings:p.settings??"",env:D,simplified:p.simplified??{},diagnostics:p.diagnostics,isDefault:p.isDefault}})};return a?e.jsx(_e,{className:"max-w-5xl",children:e.jsx(gt,{})}):e.jsxs(_e,{className:"max-w-5xl",children:[e.jsx("input",{ref:v,type:"file",accept:".json,application/json",className:"hidden",onChange:ne}),e.jsx(ht,{title:t("Agent 配置"),actions:e.jsxs(e.Fragment,{children:[e.jsxs(A,{variant:"outline",size:"sm",onClick:Q,disabled:E.isPending||r.isPending,children:[e.jsx(Ht,{size:13}),t("导入")]}),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>q(!0),disabled:s.isPending,children:[e.jsx(vt,{size:13}),t("导出")]}),e.jsxs(A,{size:"sm",onClick:()=>k({}),children:[e.jsx(Ne,{size:13,className:"mr-1"}),t("新建")]})]})}),O.length===0?e.jsx(bt,{icon:yt,message:t("暂无 Agent 配置"),action:e.jsxs(A,{size:"sm",onClick:()=>k({}),children:[e.jsx(Ne,{size:13,className:"mr-1"}),t("新建配置")]})}):e.jsx(Vt,{items:O,selectedId:g,onSelectItem:c=>{x(c),T(!0)},getItemId:c=>c.provider.id,mobileShowDetail:V,onMobileBack:()=>T(!1),renderListItem:c=>{const p=c.provider,I=Je(c);return e.jsxs(e.Fragment,{children:[e.jsx(ys,{issue:I}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium",children:p.name}),e.jsxs("div",{className:U("flex min-w-0 items-center gap-1.5 text-[11px]","text-muted-foreground"),children:[e.jsx(ae,{agentType:p.agentType,className:"size-3.5",fallbackClassName:"text-muted-foreground"}),e.jsx("span",{className:"min-w-0 truncate",children:oe(p.agentType,p.runtimeType)})]}),I?e.jsx("div",{className:U("mt-0.5 break-words text-xs leading-snug text-destructive-ink"),children:t(I)}):null]}),p.isDefault&&e.jsx("span",{className:U("shrink-0 rounded px-1.5 py-0.5 text-xs font-medium","bg-primary/[0.06] text-primary"),children:t("默认")})]})},renderDetail:c=>c?e.jsx("div",{className:"min-w-0 p-5",children:e.jsx(ks,{item:c,onEdit:()=>Y(c),onDelete:()=>Z(c.provider)})}):e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:t("选择一个 Provider 查看详情")})}),f&&e.jsx(ws,{isOpen:!0,onClose:()=>k(null),providerId:f.id,initialData:f.data,onSave:c=>{f.id?W(f.id,c):w(c)}}),e.jsx(Xt,{isOpen:S!==null,onClose:()=>{C.isPending||B(null)},onConfirm:fe,title:S?.builtIn?t("恢复默认 Provider"):t("删除 Provider"),description:S?.builtIn?t('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:S?.name}):t('确定删除 "{name}"?此操作不可撤销。',{name:S?.name}),confirmText:S?.builtIn?t("恢复默认"):t("删除"),cancelText:t("取消"),variant:"danger",isLoading:C.isPending}),e.jsx(Ps,{isOpen:J,onClose:y,onConfirm:le,acknowledged:X,onAcknowledgedChange:L,isLoading:s.isPending}),e.jsx(Cs,{isOpen:!!K,onClose:z,preview:K?.preview??null,backup:K?.backup??null,onConfirm:de,isLoading:r.isPending})]})}export{ws as ProviderFormModal,en as ProviderSettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as v,j as r,n as s,w as h}from"./index-Cz73HpYH.js";function j({items:o,selectedId:l,onSelectItem:a,getItemId:t,renderListItem:d,renderDetail:g,renderListFooter:u,mobileShowDetail:c,onMobileBack:x,listClassName:f,detailClassName:b}){const{t:m}=v(),p=o.find(e=>t(e)===l)??null;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)] gap-5 lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100vh-16rem)] lg:max-h-[640px]",children:[r.jsxs("div",{className:s("min-w-0 space-y-1 lg:overflow-y-auto lg:pr-1 scrollbar-app-thin",c&&"hidden lg:block",f),children:[o.map(e=>{const n=t(e),i=n===l;return r.jsx("button",{onClick:()=>a(n),"aria-current":i?"true":void 0,className:s("flex min-w-0 w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",i?"bg-background text-foreground shadow-raised ring-1 ring-border/80":"text-foreground hover:bg-accent"),children:d(e,i)},n)}),u?.()]}),r.jsxs("div",{className:s("min-w-0 rounded-xl border border-border bg-card lg:overflow-y-auto scrollbar-app-thin",!c&&"hidden lg:block",b),children:[r.jsxs("button",{onClick:x,className:"mb-4 flex items-center gap-1.5 px-5 pt-3 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 lg:hidden",children:[r.jsx(h,{size:14}),m("返回列表")]}),g(p)]})]})}export{j as S};
|