agent-tower 0.5.4 → 0.6.0-beta.0
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/README.md +1 -1
- package/dist/core/event-bus.d.ts +4 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/executors/__tests__/codex.executor.test.js +27 -21
- package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
- package/dist/executors/__tests__/providers-availability.test.js +23 -0
- package/dist/executors/__tests__/providers-availability.test.js.map +1 -1
- package/dist/executors/__tests__/providers.test.js +34 -1
- package/dist/executors/__tests__/providers.test.js.map +1 -1
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +4 -0
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/default-providers.json +106 -0
- package/dist/executors/index.d.ts +1 -1
- package/dist/executors/index.d.ts.map +1 -1
- package/dist/executors/index.js +32 -13
- package/dist/executors/index.js.map +1 -1
- package/dist/executors/providers.d.ts +12 -3
- package/dist/executors/providers.d.ts.map +1 -1
- package/dist/executors/providers.js +45 -18
- package/dist/executors/providers.js.map +1 -1
- package/dist/output/types.d.ts +32 -2
- package/dist/output/types.d.ts.map +1 -1
- package/dist/output/types.js +10 -0
- package/dist/output/types.js.map +1 -1
- package/dist/routes/__tests__/providers.test.js +181 -1
- package/dist/routes/__tests__/providers.test.js.map +1 -1
- package/dist/routes/__tests__/sessions-runtime.test.d.ts +2 -0
- package/dist/routes/__tests__/sessions-runtime.test.d.ts.map +1 -0
- package/dist/routes/__tests__/sessions-runtime.test.js +107 -0
- package/dist/routes/__tests__/sessions-runtime.test.js.map +1 -0
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +3 -1
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +50 -3
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/system.d.ts.map +1 -1
- package/dist/routes/system.js +8 -0
- package/dist/routes/system.js.map +1 -1
- package/dist/runtime/__tests__/acp-agent-definitions.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-agent-definitions.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-agent-definitions.test.js +360 -0
- package/dist/runtime/__tests__/acp-agent-definitions.test.js.map +1 -0
- package/dist/runtime/__tests__/acp-driver-cleanup.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-driver-cleanup.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-driver-cleanup.test.js +39 -0
- package/dist/runtime/__tests__/acp-driver-cleanup.test.js.map +1 -0
- package/dist/runtime/__tests__/acp-driver.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-driver.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-driver.test.js +122 -0
- package/dist/runtime/__tests__/acp-driver.test.js.map +1 -0
- package/dist/runtime/__tests__/acp-process-manager.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-process-manager.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-process-manager.test.js +51 -0
- package/dist/runtime/__tests__/acp-process-manager.test.js.map +1 -0
- package/dist/runtime/__tests__/acp-projector.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-projector.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-projector.test.js +195 -0
- package/dist/runtime/__tests__/acp-projector.test.js.map +1 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.d.ts +2 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.js +134 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -0
- package/dist/runtime/acp/acp-driver.d.ts +7 -0
- package/dist/runtime/acp/acp-driver.d.ts.map +1 -0
- package/dist/runtime/acp/acp-driver.js +406 -0
- package/dist/runtime/acp/acp-driver.js.map +1 -0
- package/dist/runtime/acp/agents/claude-code.d.ts +3 -0
- package/dist/runtime/acp/agents/claude-code.d.ts.map +1 -0
- package/dist/runtime/acp/agents/claude-code.js +147 -0
- package/dist/runtime/acp/agents/claude-code.js.map +1 -0
- package/dist/runtime/acp/agents/codex.d.ts +3 -0
- package/dist/runtime/acp/agents/codex.d.ts.map +1 -0
- package/dist/runtime/acp/agents/codex.js +68 -0
- package/dist/runtime/acp/agents/codex.js.map +1 -0
- package/dist/runtime/acp/agents/cursor-agent.d.ts +2 -0
- package/dist/runtime/acp/agents/cursor-agent.d.ts.map +1 -0
- package/dist/runtime/acp/agents/cursor-agent.js +12 -0
- package/dist/runtime/acp/agents/cursor-agent.js.map +1 -0
- package/dist/runtime/acp/agents/executable-resolution.d.ts +6 -0
- package/dist/runtime/acp/agents/executable-resolution.d.ts.map +1 -0
- package/dist/runtime/acp/agents/executable-resolution.js +72 -0
- package/dist/runtime/acp/agents/executable-resolution.js.map +1 -0
- package/dist/runtime/acp/agents/gemini-cli.d.ts +2 -0
- package/dist/runtime/acp/agents/gemini-cli.d.ts.map +1 -0
- package/dist/runtime/acp/agents/gemini-cli.js +13 -0
- package/dist/runtime/acp/agents/gemini-cli.js.map +1 -0
- package/dist/runtime/acp/agents/grok-build.d.ts +2 -0
- package/dist/runtime/acp/agents/grok-build.d.ts.map +1 -0
- package/dist/runtime/acp/agents/grok-build.js +26 -0
- package/dist/runtime/acp/agents/grok-build.js.map +1 -0
- package/dist/runtime/acp/agents/kiro-cli.d.ts +2 -0
- package/dist/runtime/acp/agents/kiro-cli.d.ts.map +1 -0
- package/dist/runtime/acp/agents/kiro-cli.js +18 -0
- package/dist/runtime/acp/agents/kiro-cli.js.map +1 -0
- package/dist/runtime/acp/agents/managed-directory.d.ts +6 -0
- package/dist/runtime/acp/agents/managed-directory.d.ts.map +1 -0
- package/dist/runtime/acp/agents/managed-directory.js +31 -0
- package/dist/runtime/acp/agents/managed-directory.js.map +1 -0
- package/dist/runtime/acp/agents/minion-acp-sitecustomize.d.ts +2 -0
- package/dist/runtime/acp/agents/minion-acp-sitecustomize.d.ts.map +1 -0
- package/dist/runtime/acp/agents/minion-acp-sitecustomize.js +118 -0
- package/dist/runtime/acp/agents/minion-acp-sitecustomize.js.map +1 -0
- package/dist/runtime/acp/agents/minion-code.d.ts +2 -0
- package/dist/runtime/acp/agents/minion-code.d.ts.map +1 -0
- package/dist/runtime/acp/agents/minion-code.js +53 -0
- package/dist/runtime/acp/agents/minion-code.js.map +1 -0
- package/dist/runtime/acp/agents/native-agent.d.ts +23 -0
- package/dist/runtime/acp/agents/native-agent.d.ts.map +1 -0
- package/dist/runtime/acp/agents/native-agent.js +158 -0
- package/dist/runtime/acp/agents/native-agent.js.map +1 -0
- package/dist/runtime/acp/agents/opencode.d.ts +2 -0
- package/dist/runtime/acp/agents/opencode.d.ts.map +1 -0
- package/dist/runtime/acp/agents/opencode.js +35 -0
- package/dist/runtime/acp/agents/opencode.js.map +1 -0
- package/dist/runtime/acp/agents/pi-coding-agent.d.ts +3 -0
- package/dist/runtime/acp/agents/pi-coding-agent.d.ts.map +1 -0
- package/dist/runtime/acp/agents/pi-coding-agent.js +178 -0
- package/dist/runtime/acp/agents/pi-coding-agent.js.map +1 -0
- package/dist/runtime/acp/agents/qwen-code.d.ts +3 -0
- package/dist/runtime/acp/agents/qwen-code.d.ts.map +1 -0
- package/dist/runtime/acp/agents/qwen-code.js +67 -0
- package/dist/runtime/acp/agents/qwen-code.js.map +1 -0
- package/dist/runtime/acp/agents/registry.d.ts +5 -0
- package/dist/runtime/acp/agents/registry.d.ts.map +1 -0
- package/dist/runtime/acp/agents/registry.js +34 -0
- package/dist/runtime/acp/agents/registry.js.map +1 -0
- package/dist/runtime/acp/agents/types.d.ts +35 -0
- package/dist/runtime/acp/agents/types.d.ts.map +1 -0
- package/dist/runtime/acp/agents/types.js +2 -0
- package/dist/runtime/acp/agents/types.js.map +1 -0
- package/dist/runtime/acp/codex-provider-config.d.ts +9 -0
- package/dist/runtime/acp/codex-provider-config.d.ts.map +1 -0
- package/dist/runtime/acp/codex-provider-config.js +107 -0
- package/dist/runtime/acp/codex-provider-config.js.map +1 -0
- package/dist/runtime/acp/process-manager.d.ts +33 -0
- package/dist/runtime/acp/process-manager.d.ts.map +1 -0
- package/dist/runtime/acp/process-manager.js +204 -0
- package/dist/runtime/acp/process-manager.js.map +1 -0
- package/dist/runtime/acp/projector.d.ts +23 -0
- package/dist/runtime/acp/projector.d.ts.map +1 -0
- package/dist/runtime/acp/projector.js +354 -0
- package/dist/runtime/acp/projector.js.map +1 -0
- package/dist/runtime/cli-driver.d.ts +7 -0
- package/dist/runtime/cli-driver.d.ts.map +1 -0
- package/dist/runtime/cli-driver.js +282 -0
- package/dist/runtime/cli-driver.js.map +1 -0
- package/dist/runtime/cli-parser.d.ts +5 -0
- package/dist/runtime/cli-parser.d.ts.map +1 -0
- package/dist/runtime/cli-parser.js +15 -0
- package/dist/runtime/cli-parser.js.map +1 -0
- package/dist/runtime/contracts.d.ts +109 -0
- package/dist/runtime/contracts.d.ts.map +1 -0
- package/dist/runtime/contracts.js +2 -0
- package/dist/runtime/contracts.js.map +1 -0
- package/dist/runtime/errors.d.ts +9 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +29 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +9 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/runtime-coordinator.d.ts +32 -0
- package/dist/runtime/runtime-coordinator.d.ts.map +1 -0
- package/dist/runtime/runtime-coordinator.js +327 -0
- package/dist/runtime/runtime-coordinator.js.map +1 -0
- package/dist/runtime/runtime-registry.d.ts +8 -0
- package/dist/runtime/runtime-registry.d.ts.map +1 -0
- package/dist/runtime/runtime-registry.js +17 -0
- package/dist/runtime/runtime-registry.js.map +1 -0
- package/dist/runtime/runtime-state-view.d.ts +5 -0
- package/dist/runtime/runtime-state-view.d.ts.map +1 -0
- package/dist/runtime/runtime-state-view.js +15 -0
- package/dist/runtime/runtime-state-view.js.map +1 -0
- package/dist/services/__tests__/provider-config.service.test.js +31 -2
- package/dist/services/__tests__/provider-config.service.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js +105 -2
- package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.team-run.test.js +16 -14
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/conversation.service.d.ts.map +1 -1
- package/dist/services/conversation.service.js +3 -0
- package/dist/services/conversation.service.js.map +1 -1
- package/dist/services/provider-config.service.d.ts.map +1 -1
- package/dist/services/provider-config.service.js +34 -5
- package/dist/services/provider-config.service.js.map +1 -1
- package/dist/services/provider-effective-connection.service.d.ts +7 -1
- package/dist/services/provider-effective-connection.service.d.ts.map +1 -1
- package/dist/services/provider-effective-connection.service.js +56 -1
- package/dist/services/provider-effective-connection.service.js.map +1 -1
- package/dist/services/session-manager.d.ts +32 -24
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +265 -448
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/team-reconciler.service.d.ts +3 -0
- package/dist/services/team-reconciler.service.d.ts.map +1 -1
- package/dist/services/team-reconciler.service.js +14 -3
- package/dist/services/team-reconciler.service.js.map +1 -1
- package/dist/services/team-run.service.d.ts.map +1 -1
- package/dist/services/team-run.service.js +5 -1
- package/dist/services/team-run.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts +2 -0
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/socket/__tests__/socket-gateway.test.js +42 -0
- package/dist/socket/__tests__/socket-gateway.test.js.map +1 -1
- package/dist/socket/events.d.ts +1 -1
- package/dist/socket/events.d.ts.map +1 -1
- package/dist/socket/events.js.map +1 -1
- package/dist/socket/index.js +1 -1
- package/dist/socket/index.js.map +1 -1
- package/dist/socket/socket-gateway.d.ts.map +1 -1
- package/dist/socket/socket-gateway.js +13 -1
- package/dist/socket/socket-gateway.js.map +1 -1
- package/dist/types/index.d.ts +7 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +3 -1
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +17 -2
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-C3SHOCDR.js → AgentDemoPage-BpUO2gR6.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-D-BWLcC0.js → AgentEnvironmentSettingsPage-CSBMaAvL.js} +1 -1
- package/dist/web/assets/AgentLogo-C190Z6bw.js +1 -0
- package/dist/web/assets/ConversationPage-Cer_WtdC.js +3 -0
- package/dist/web/assets/CreateTaskInput-ByeWDjc8.js +1 -0
- package/dist/web/assets/{DemoPage-Cd1ggnZY.js → DemoPage-Dpb9aAKX.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-B9D9wA_9.js → GeneralSettingsPage-TqbAsCZM.js} +1 -1
- package/dist/web/assets/{Icons-CM6Yg2lw.js → Icons-CyNNz4Z5.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-BJ_Se_T_.js → LoadingPreviewPage-DmH1TGln.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-B5GtqNme.js → McpSettingsPage-z1_NcsMR.js} +1 -1
- package/dist/web/assets/{MemberAvatar-yC8O30hv.js → MemberAvatar-BPoYS6Il.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-BaJpYHLD.js → NotificationSettingsPage-CNsRJ6nN.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-DYXew66J.js → ProfileSettingsPage-g1RKcEbo.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DbgIwiUC.js → ProjectKanbanPage-j2v5fLfg.js} +37 -36
- package/dist/web/assets/{ProjectSettingsPage-B2K8Kw_S.js → ProjectSettingsPage-Cp89NvwE.js} +1 -1
- package/dist/web/assets/ProviderSettingsPage-B-bBs2qN.js +93 -0
- package/dist/web/assets/{SettingsMasterDetail-ByKe_zcK.js → SettingsMasterDetail-BYB-1oyf.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-4sHo9Wpb.js → TeamSettingsPage-Y2zCVbVD.js} +1 -1
- package/dist/web/assets/agent-tower-lockup-DPAcheCt.png +0 -0
- package/dist/web/assets/{arc-g6Y4qqcK.js → arc-BmDnqN7Q.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-ILRcqNPe.js → architectureDiagram-3BPJPVTR-BIG4K9gT.js} +1 -1
- package/dist/web/assets/{arrow-left-D0MkHwKU.js → arrow-left-CB4qTjQs.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-ZTMQ6CTT.js → blockDiagram-GPEHLZMM-CowveYw0.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-CAW8PcM8.js → c4Diagram-AAUBKEIU-CLjbYgNG.js} +1 -1
- package/dist/web/assets/channel-BsOpjSZw.js +1 -0
- package/dist/web/assets/check-BVOtZt28.js +1 -0
- package/dist/web/assets/{chevron-down-CmGXPki1.js → chevron-down-BXYCSpWd.js} +1 -1
- package/dist/web/assets/{chevron-right-jrkLz9qG.js → chevron-right-CkcSaX8x.js} +1 -1
- package/dist/web/assets/{chevron-up-UwBybVMK.js → chevron-up-Y8L6pbzc.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-BvuLBX1d.js → chunk-2J33WTMH-DRf_miP4.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-DJO5Yx2A.js → chunk-4BX2VUAB-C6Ne_vwR.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-Dc117Qwf.js → chunk-55IACEB6-DejCglMr.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-DsZmTw67.js → chunk-727SXJPM-B0MC9Ojc.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-DgmF7gD6.js → chunk-AQP2D5EJ-D9f4hbMX.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-vgh3Erl0.js → chunk-FMBD7UC4-k90hkOQq.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-Ogtl4wwd.js → chunk-ND2GUHAM-CX2-qxPx.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-Cif7bPpF.js → chunk-QZHKN3VN-CpFs7UD0.js} +1 -1
- package/dist/web/assets/{circle-alert-B6ZM3dSn.js → circle-alert-ClX4sQ2K.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-KkLqUSdB.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-KkLqUSdB.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-BQnKZly0.js → code-block-OCS4YCEC-_lkU1VUC.js} +1 -1
- package/dist/web/assets/{confirm-dialog-BZeaAl5j.js → confirm-dialog-BJwzwwOk.js} +1 -1
- package/dist/web/assets/{copy-DqNqPI8d.js → copy-jQAntc98.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-rxJB-TPw.js → cose-bilkent-S5V4N54A-CLWAfEVg.js} +1 -1
- package/dist/web/assets/cssMode-q0rL0Hjc.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-BkB6VpXn.js → dagre-BM42HDAG-DKviWU-X.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-BH2e-eqy.js → diagram-2AECGRRQ-L6emXRJ1.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-B0I47Yhs.js → diagram-5GNKFQAL-CXGUerks.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-BVXUYRvI.js → diagram-KO2AKTUF-C8FHXqeH.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-C1fEOLke.js → diagram-LMA3HP47-Cng_aa5j.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-CVE8cOcO.js → diagram-OG6HWLK6-BEC6IDf4.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-qCfnXmfp.js → erDiagram-TEJ5UH35-BWMCTdYK.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-KMhbF5QC.js → flowDiagram-I6XJVG4X-aAEYIyx2.js} +1 -1
- package/dist/web/assets/{folder-picker-C3BgqamQ.js → folder-picker-CioQjSzV.js} +1 -1
- package/dist/web/assets/{freemarker2-tYgVOcFl.js → freemarker2-DZgAIr6s.js} +2 -2
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-CaX3qYV1.js → ganttDiagram-6RSMTGT7-DVqWnwcH.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CBAlZX7C.js → gitGraphDiagram-PVQCEYII-BVWrTXBv.js} +1 -1
- package/dist/web/assets/handlebars-9RRQrLUb.js +1 -0
- package/dist/web/assets/html-BVI4F9TT.js +1 -0
- package/dist/web/assets/htmlMode-t0djrjSv.js +1 -0
- package/dist/web/assets/index-CjAJoGg5.css +1 -0
- package/dist/web/assets/{index-BuQDZjol.js → index-Da9mzleR.js} +4 -4
- package/dist/web/assets/{index-DHKgc87I.js → index-RYlllU6n.js} +18 -18
- package/dist/web/assets/{infoDiagram-5YYISTIA-Bp_GeFtA.js → infoDiagram-5YYISTIA-DYG1ew4x.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BfBNEV_D.js → ishikawaDiagram-YF4QCWOH-COBW1j3-.js} +1 -1
- package/dist/web/assets/javascript-DaUCpDvL.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-DJkUQG4Z.js → journeyDiagram-JHISSGLW-BI_FlncW.js} +1 -1
- package/dist/web/assets/{jsonMode-D4_2geMa.js → jsonMode-A5wuW-PC.js} +2 -2
- package/dist/web/assets/{kanban-definition-UN3LZRKU-Bk7sA26p.js → kanban-definition-UN3LZRKU-BKrHEd7r.js} +1 -1
- package/dist/web/assets/{layers-BFkjcml2.js → layers-BZMh9pqm.js} +1 -1
- package/dist/web/assets/{linear-CmC68WUf.js → linear-DyoMQJGq.js} +1 -1
- package/dist/web/assets/liquid-HXqG_RIQ.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-vY541IS0.js → lspLanguageFeatures-s3xWnrXc.js} +1 -1
- package/dist/web/assets/mdx-k_7JTYp2.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-C6wHDXti.js → mermaid-NOHMQCX5-orMHhlAj.js} +59 -61
- package/dist/web/assets/{message-square-Wwixl9YA.js → message-square-CStQg7sr.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-Ck1je2Hf.js → mindmap-definition-RKZ34NQL-CKOIIjUJ.js} +1 -1
- package/dist/web/assets/{modal-kFSArLJi.js → modal-ZYdX5Krr.js} +1 -1
- package/dist/web/assets/{monaco-D3FVQqPj.js → monaco-DX9iObLO.js} +3 -3
- package/dist/web/assets/{pencil-5Kegi5_H.js → pencil-DoB4p30x.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-6Ao8YaoY.js → pieDiagram-4H26LBE5-BW18kL8l.js} +1 -1
- package/dist/web/assets/python-abx8p9WS.js +1 -0
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-md1eBgjS.js → quadrantDiagram-W4KKPZXB-Df_F1INR.js} +1 -1
- package/dist/web/assets/razor-DGdDlX86.js +1 -0
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-DJOb4wf-.js → requirementDiagram-4Y6WPE33-De6R8t8O.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-B7srXhHb.js → sankeyDiagram-5OEKKPKP-ChlLeN5m.js} +1 -1
- package/dist/web/assets/{select-C2v0aFwN.js → select-B9kjO67b.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-L0qwgf37.js → sequenceDiagram-3UESZ5HK-CPVnbcvz.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-DGbH9dJ5.js → stateDiagram-AJRCARHV-BFS1G-aJ.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DSxC8AfE.js +1 -0
- package/dist/web/assets/{switch-DjnF5A3R.js → switch-C2r5pofB.js} +1 -1
- package/dist/web/assets/{textarea-CbZnd5PO.js → textarea-BB3UoYxg.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-Dku_Yjmk.js → timeline-definition-PNZ67QCA-C1Rgs32y.js} +1 -1
- package/dist/web/assets/{trash-2-DA--Uikt.js → trash-2-BNiAEW-6.js} +1 -1
- package/dist/web/assets/{tsMode-CRNPFR24.js → tsMode-DHruHjGh.js} +2 -2
- package/dist/web/assets/typescript-SLYiKRhJ.js +1 -0
- package/dist/web/assets/{upload-hWnFHuhE.js → upload-BLLmywZY.js} +1 -1
- package/dist/web/assets/{use-profiles-roHXR8He.js → use-profiles-OJaV4lOv.js} +1 -1
- package/dist/web/assets/{use-projects-DiJMGduU.js → use-projects-D_Sq7ahS.js} +1 -1
- package/dist/web/assets/{use-providers-efX4HCcr.js → use-providers-SSHcslI-.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-xEobyuGF.js → useNormalizedLogs-DeA-fso_.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-_ufI1hxk.js → vennDiagram-CIIHVFJN-DLGPZTKg.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-Dve662aX.js → wardley-L42UT6IY-BVMPWfq9.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-Dn2x3M_Q.js → wardleyDiagram-YWT4CUSO-_KXuEg6G.js} +1 -1
- package/dist/web/assets/xml-BmreQojr.js +1 -0
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-BMe6JPre.js → xychartDiagram-2RQKCTM6-a-Do3v5G.js} +1 -1
- package/dist/web/assets/yaml-CJoLHuqv.js +1 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.d.ts +9 -0
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.js +21 -0
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts +1 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/index.js +1 -0
- package/node_modules/@agent-tower/shared/dist/index.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts +38 -3
- package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/log-adapter.js +21 -2
- package/node_modules/@agent-tower/shared/dist/log-adapter.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.js +58 -0
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +17 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.js +3 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts +63 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js +12 -0
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +9 -3
- package/prisma/migrations/20260723000000_add_agent_runtime/migration.sql +2 -0
- package/prisma/schema.prisma +2 -0
- package/scripts/patch-claude-agent-acp.mjs +77 -0
- package/scripts/postinstall.js +5 -0
- package/dist/web/assets/AgentLogo-DOc8QQHe.js +0 -1
- package/dist/web/assets/ConversationPage-sknzMK-I.js +0 -3
- package/dist/web/assets/CreateTaskInput-Cn0k5D8K.js +0 -1
- package/dist/web/assets/ProviderSettingsPage-n2AFrtkZ.js +0 -93
- package/dist/web/assets/channel-DpisCjBV.js +0 -1
- package/dist/web/assets/check-VMcYyBr4.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-ByrAXg7x.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ByrAXg7x.js +0 -1
- package/dist/web/assets/cssMode-BvIKUSIl.js +0 -1
- package/dist/web/assets/handlebars-O23dzm6n.js +0 -1
- package/dist/web/assets/html-QaPgl834.js +0 -1
- package/dist/web/assets/htmlMode-CWyii3pY.js +0 -1
- package/dist/web/assets/index-BeEbDvc9.css +0 -1
- package/dist/web/assets/javascript-C_IpQDkn.js +0 -1
- package/dist/web/assets/liquid-C6FS7ekL.js +0 -1
- package/dist/web/assets/mdx-LQJToB8m.js +0 -1
- package/dist/web/assets/python-HMxhKAEt.js +0 -1
- package/dist/web/assets/razor-CfDc2DcT.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Bq1LxgY_.js +0 -1
- package/dist/web/assets/typescript-CNopspEc.js +0 -1
- package/dist/web/assets/xml-dqhfYLW3.js +0 -1
- package/dist/web/assets/yaml-BOxNX83z.js +0 -1
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-
|
|
2
|
-
import{ai as Hc,aj as Gn,ak as $c,al as Uc,am as qc,k as qe,r as S,an as le,z as fs,m as Ot,ao as xs,n as kt,p as Se,o as ht,q as ae,u as de,j as t,a9 as vt,V as ga,W as Kc,l as se,Z as Ms,B as Te,ap as va,aq as xa,ar as _a,ag as ps,X as Xt,as as an,at as Xc,O as cr,au as Yc,D as Vc,av as Gc,aw as Qc,ax as Zc,T as dr,t as ut,P as Zt,Q as ct,U as Es,a5 as Br,ay as ur,az as Jc,a3 as Xe,aA as ln,ah as ed,ad as td,ae as sd,aB as ba,aC as cn,aD as ya,aE as Sa,aF as wa,aG as rd,aH as id,a0 as nd,aI as od,aJ as ad,aK as ld,Y as Qn,a8 as Zn}from"./index-DHKgc87I.js";import{S as et,u as dn,A as un,k as cd,F as Ca,l as dd,m as ud,Q as hn,o as hd,p as At,W as yt,q as ka,C as rr,r as Rr,t as fd,v as md,T as pd,h as js,b as Fr,w as Ea,x as Wt}from"./mermaid-NOHMQCX5-C6wHDXti.js";import{C as fn}from"./confirm-dialog-BZeaAl5j.js";import{c as ja,a as Na,b as Ra,I as Aa,d as Ta,A as Jn,G as Ma}from"./Icons-CM6Yg2lw.js";import{C as Ct}from"./chevron-down-CmGXPki1.js";import{C as Mt}from"./chevron-right-jrkLz9qG.js";import{d as mn,S as gd,u as pn,A as ir,b as gn,G as Da,Z as vd,T as vn,e as xd,g as eo,f as _d,h as Pa,a as La,P as Ia,i as zr,j as bd,C as to,B as so,c as ro}from"./CreateTaskInput-Cn0k5D8K.js";import{a as yd,F as Sd,b as wd}from"./folder-picker-C3BgqamQ.js";import{M as ei}from"./message-square-Wwixl9YA.js";import{L as Ds}from"./layers-BFkjcml2.js";import{P as xn,u as Oa,a as Ba,T as Wr}from"./useNormalizedLogs-xEobyuGF.js";import{u as Os}from"./use-providers-efX4HCcr.js";import{A as ti}from"./AgentLogo-DOc8QQHe.js";import{M as Ht}from"./MemberAvatar-yC8O30hv.js";import{C as Fa}from"./chevron-up-UwBybVMK.js";import{C as Yt}from"./check-VMcYyBr4.js";import{M as gs}from"./modal-kFSArLJi.js";import{S as Jt}from"./select-C2v0aFwN.js";import{P as es,T as _n}from"./trash-2-DA--Uikt.js";import{F as za,e as Cd,d as kd,f as Ed,u as jd}from"./use-projects-DiJMGduU.js";import{U as Hr}from"./upload-hWnFHuhE.js";import{A as Ps}from"./arrow-left-D0MkHwKU.js";import{C as io}from"./copy-DqNqPI8d.js";var Nd=class extends Hc{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Gn()})}getOptimisticResult(e){return e.behavior=Gn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:g,isRefetching:p,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",d=g&&i==="forward",c=v&&i==="backward",m=g&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Uc(s,r.data),hasPreviousPage:$c(s,r.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:c,isFetchingPreviousPage:m,isRefetchError:n&&!l&&!c,isRefetching:p&&!d&&!m}}};function bn(e,s){return qc(e,Nd)}const Rd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Wa=qe("arrow-right",Rd);const Ad=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ha=qe("ban",Ad);const Td=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Md=qe("chevron-left",Td);const Dd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ns=qe("clock-3",Dd);const Pd=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],si=qe("code-xml",Pd);const Ld=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],no=qe("copy-plus",Ld);const Id=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Od=qe("earth",Id);const Bd=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],$a=qe("ellipsis-vertical",Bd);const Fd=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],zd=qe("file-braces-corner",Fd);const Wd=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],$r=qe("file-code-corner",Wd);const Hd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],$d=qe("file-exclamation-point",Hd);const Ud=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ri=qe("folder-open",Ud);const qd=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Bs=qe("git-graph",qd);const Kd=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Ls=qe("history",Kd);const Xd=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Yd=qe("maximize",Xd);const Vd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Gd=qe("panel-left-close",Vd);const Qd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Zd=qe("panel-left-open",Qd);const Jd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],eu=qe("panel-right-close",Jd);const tu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Ui=qe("panel-right-open",tu);const su=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ru=qe("pen-line",su);const iu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Kt=qe("play",iu);const nu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ua=qe("settings-2",nu);const ou=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],oo=qe("smartphone",ou);const au=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Ar=qe("user-plus",au);const lu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],cu=qe("zoom-in",lu);const du=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],uu=qe("zoom-out",du),ii=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function yn(e){return"nodeType"in e}function St(e){var s,r;return e?Fs(e)?e:yn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Sn(e){const{Document:s}=St(e);return e instanceof s}function hr(e){return Fs(e)?!1:e instanceof St(e).HTMLElement}function qa(e){return e instanceof St(e).SVGElement}function zs(e){return e?Fs(e)?e.document:yn(e)?Sn(e)?e:hr(e)||qa(e)?e.ownerDocument:document:document:document}const Vt=ii?S.useLayoutEffect:S.useEffect;function ni(e){const s=S.useRef(e);return Vt(()=>{s.current=e}),S.useCallback(function(){for(var r=arguments.length,o=new Array(r),g=0;g<r;g++)o[g]=arguments[g];return s.current==null?void 0:s.current(...o)},[])}function hu(){const e=S.useRef(null),s=S.useCallback((o,g)=>{e.current=setInterval(o,g)},[]),r=S.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function nr(e,s){s===void 0&&(s=[e]);const r=S.useRef(e);return Vt(()=>{r.current!==e&&(r.current=e)},s),r}function fr(e,s){const r=S.useRef();return S.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Ur(e){const s=ni(e),r=S.useRef(null),o=S.useCallback(g=>{g!==r.current&&s?.(g,r.current),r.current=g},[]);return[r,o]}function qr(e){const s=S.useRef();return S.useEffect(()=>{s.current=e},[e]),s.current}let wi={};function oi(e,s){return S.useMemo(()=>{if(s)return s;const r=wi[e]==null?0:wi[e]+1;return wi[e]=r,e+"-"+r},[e,s])}function Ka(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),g=1;g<r;g++)o[g-1]=arguments[g];return o.reduce((p,v)=>{const n=Object.entries(v);for(const[i,l]of n){const d=p[i];d!=null&&(p[i]=d+e*l)}return p},{...s})}}const Ts=Ka(1),Kr=Ka(-1);function fu(e){return"clientX"in e&&"clientY"in e}function wn(e){if(!e)return!1;const{KeyboardEvent:s}=St(e.target);return s&&e instanceof s}function mu(e){if(!e)return!1;const{TouchEvent:s}=St(e.target);return s&&e instanceof s}function Xr(e){if(mu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return fu(e)?{x:e.clientX,y:e.clientY}:null}const or=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[or.Translate.toString(e),or.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),ao="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pu(e){return e.matches(ao)?e:e.querySelector(ao)}const gu={display:"none"};function vu(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:gu},r)}function xu(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const g={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 le.createElement("div",{id:s,style:g,role:"status","aria-live":o,"aria-atomic":!0},r)}function _u(){const[e,s]=S.useState("");return{announce:S.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const Xa=S.createContext(null);function bu(e){const s=S.useContext(Xa);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function yu(){const[e]=S.useState(()=>new Set),s=S.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[S.useCallback(o=>{let{type:g,event:p}=o;e.forEach(v=>{var n;return(n=v[g])==null?void 0:n.call(v,p)})},[e]),s]}const Su={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-DX9iObLO.js","assets/index-RYlllU6n.js","assets/index-CjAJoGg5.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ah as Uc,ai as Qn,aj as qc,ak as Kc,al as Xc,k as He,r as S,am as ae,z as ps,m as Bt,an as _s,n as Ft,p as Ce,o as bt,q as de,u as ce,j as t,a9 as gt,V as ga,W as Yc,l as se,Z as Ds,B as Te,ao as va,ap as xa,aq as _a,af as vs,X as Yt,ar as ln,as as Vc,O as dr,at as Gc,D as Qc,au as Zc,av as Jc,aw as ed,T as ur,t as rt,P as Jt,Q as ct,U as Ns,a5 as Fr,a3 as Ke,ax as hr,ay as td,az as cn,ag as sd,ad as rd,ae as id,aA as ba,aB as dn,aC as ya,aD as Sa,aE as wa,aF as nd,aG as od,a0 as ad,aH as ld,aI as cd,aJ as dd,Y as Zn,a8 as Jn}from"./index-RYlllU6n.js";import{S as dt,u as un,A as hn,l as ud,F as Ca,m as hd,o as fd,Q as fn,p as md,q as At,W as _t,r as ka,C as ir,t as Ar,v as pd,w as gd,T as vd,h as Nt,b as zr,x as Ea,y as Ht}from"./mermaid-NOHMQCX5-orMHhlAj.js";import{C as mn}from"./confirm-dialog-BJwzwwOk.js";import{c as ja,a as Na,b as Ra,I as Aa,d as Ta,A as eo,G as Ma}from"./Icons-CyNNz4Z5.js";import{C as wt}from"./chevron-down-BXYCSpWd.js";import{C as Mt}from"./chevron-right-CkcSaX8x.js";import{d as pn,S as xd,u as gn,A as nr,c as vn,G as Da,Z as _d,e as xn,T as _n,f as bd,g as bn,h as to,i as yd,b as Pa,j as La,a as Ia,k as Oa,R as Ba,P as Fa,l as Wr,m as Sd,C as so,B as ro}from"./CreateTaskInput-ByeWDjc8.js";import{a as wd,F as Cd,b as kd}from"./folder-picker-CioQjSzV.js";import{M as ti}from"./message-square-CStQg7sr.js";import{L as Ps}from"./layers-BZMh9pqm.js";import{P as yn,u as za,a as Wa,T as Hr}from"./useNormalizedLogs-DeA-fso_.js";import{u as Bs}from"./use-providers-SSHcslI-.js";import{A as si}from"./AgentLogo-C190Z6bw.js";import{M as $t}from"./MemberAvatar-BPoYS6Il.js";import{C as Ha}from"./chevron-up-Y8L6pbzc.js";import{C as Vt}from"./check-BVOtZt28.js";import{M as ns}from"./modal-ZYdX5Krr.js";import{S as es}from"./select-B9kjO67b.js";import{P as ts,T as Sn}from"./trash-2-BNiAEW-6.js";import{T as Ed}from"./textarea-BB3UoYxg.js";import{F as $a,e as jd,d as Nd,f as Rd,u as Ad}from"./use-projects-D_Sq7ahS.js";import{U as $r}from"./upload-BLLmywZY.js";import{A as Ls}from"./arrow-left-CB4qTjQs.js";import{C as io}from"./copy-jQAntc98.js";var Td=class extends Uc{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Qn()})}getOptimisticResult(e){return e.behavior=Qn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:g,isRefetching:p,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",d=g&&i==="forward",c=v&&i==="backward",m=g&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Kc(s,r.data),hasPreviousPage:qc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:c,isFetchingPreviousPage:m,isRefetchError:n&&!l&&!c,isRefetching:p&&!d&&!m}}};function wn(e,s){return Xc(e,Td)}const Md=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ua=He("arrow-right",Md);const Dd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qa=He("ban",Dd);const Pd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ld=He("chevron-left",Pd);const Id=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],Od=He("clipboard-paste",Id);const Bd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Rs=He("clock-3",Bd);const Fd=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ri=He("code-xml",Fd);const zd=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],no=He("copy-plus",zd);const Wd=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hd=He("earth",Wd);const $d=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ka=He("ellipsis-vertical",$d);const Ud=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],qd=He("file-braces-corner",Ud);const Kd=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Ur=He("file-code-corner",Kd);const Xd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Yd=He("file-exclamation-point",Xd);const Vd=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ii=He("folder-open",Vd);const Gd=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Fs=He("git-graph",Gd);const Qd=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Is=He("history",Qd);const Zd=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Jd=He("maximize",Zd);const eu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],tu=He("panel-left-close",eu);const su=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],ru=He("panel-left-open",su);const iu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],nu=He("panel-right-close",iu);const ou=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],qi=He("panel-right-open",ou);const au=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],lu=He("pen-line",au);const cu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Xt=He("play",cu);const du=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Xa=He("settings-2",du);const uu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],oo=He("smartphone",uu);const hu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Tr=He("user-plus",hu);const fu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],mu=He("zoom-in",fu);const pu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],gu=He("zoom-out",pu),ni=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Cn(e){return"nodeType"in e}function yt(e){var s,r;return e?zs(e)?e:Cn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function kn(e){const{Document:s}=yt(e);return e instanceof s}function fr(e){return zs(e)?!1:e instanceof yt(e).HTMLElement}function Ya(e){return e instanceof yt(e).SVGElement}function Ws(e){return e?zs(e)?e.document:Cn(e)?kn(e)?e:fr(e)||Ya(e)?e.ownerDocument:document:document:document}const Gt=ni?S.useLayoutEffect:S.useEffect;function oi(e){const s=S.useRef(e);return Gt(()=>{s.current=e}),S.useCallback(function(){for(var r=arguments.length,o=new Array(r),g=0;g<r;g++)o[g]=arguments[g];return s.current==null?void 0:s.current(...o)},[])}function vu(){const e=S.useRef(null),s=S.useCallback((o,g)=>{e.current=setInterval(o,g)},[]),r=S.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function or(e,s){s===void 0&&(s=[e]);const r=S.useRef(e);return Gt(()=>{r.current!==e&&(r.current=e)},s),r}function mr(e,s){const r=S.useRef();return S.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function qr(e){const s=oi(e),r=S.useRef(null),o=S.useCallback(g=>{g!==r.current&&s?.(g,r.current),r.current=g},[]);return[r,o]}function Kr(e){const s=S.useRef();return S.useEffect(()=>{s.current=e},[e]),s.current}let Ci={};function ai(e,s){return S.useMemo(()=>{if(s)return s;const r=Ci[e]==null?0:Ci[e]+1;return Ci[e]=r,e+"-"+r},[e,s])}function Va(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),g=1;g<r;g++)o[g-1]=arguments[g];return o.reduce((p,v)=>{const n=Object.entries(v);for(const[i,l]of n){const d=p[i];d!=null&&(p[i]=d+e*l)}return p},{...s})}}const Ms=Va(1),Xr=Va(-1);function xu(e){return"clientX"in e&&"clientY"in e}function En(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function _u(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Yr(e){if(_u(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return xu(e)?{x:e.clientX,y:e.clientY}:null}const ar=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[ar.Translate.toString(e),ar.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),ao="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function bu(e){return e.matches(ao)?e:e.querySelector(ao)}const yu={display:"none"};function Su(e){let{id:s,value:r}=e;return ae.createElement("div",{id:s,style:yu},r)}function wu(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const g={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 ae.createElement("div",{id:s,style:g,role:"status","aria-live":o,"aria-atomic":!0},r)}function Cu(){const[e,s]=S.useState("");return{announce:S.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const Ga=S.createContext(null);function ku(e){const s=S.useContext(Ga);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Eu(){const[e]=S.useState(()=>new Set),s=S.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[S.useCallback(o=>{let{type:g,event:p}=o;e.forEach(v=>{var n;return(n=v[g])==null?void 0:n.call(v,p)})},[e]),s]}const ju={draggable:`
|
|
3
3
|
To pick up a draggable item, press the space bar.
|
|
4
4
|
While dragging, use the arrow keys to move the item.
|
|
5
5
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
-
`},wu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Cu(e){let{announcements:s=wu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:g=Su}=e;const{announce:p,announcement:v}=_u(),n=oi("DndLiveRegion"),[i,l]=S.useState(!1);if(S.useEffect(()=>{l(!0)},[]),bu(S.useMemo(()=>({onDragStart(c){let{active:m}=c;p(s.onDragStart({active:m}))},onDragMove(c){let{active:m,over:x}=c;s.onDragMove&&p(s.onDragMove({active:m,over:x}))},onDragOver(c){let{active:m,over:x}=c;p(s.onDragOver({active:m,over:x}))},onDragEnd(c){let{active:m,over:x}=c;p(s.onDragEnd({active:m,over:x}))},onDragCancel(c){let{active:m,over:x}=c;p(s.onDragCancel({active:m,over:x}))}}),[p,s])),!i)return null;const d=le.createElement(le.Fragment,null,le.createElement(vu,{id:o,value:g.draggable}),le.createElement(xu,{id:n,announcement:v}));return r?fs.createPortal(d,r):d}var it;(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"})(it||(it={}));function Yr(){}function ku(e,s){return S.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Eu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return S.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const It=Object.freeze({x:0,y:0});function ju(e,s){const r=Xr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Nu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Ru(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Au(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),g=Math.min(s.left+s.width,e.left+e.width),p=Math.min(s.top+s.height,e.top+e.height),v=g-o,n=p-r;if(o<g&&r<p){const i=s.width*s.height,l=e.width*e.height,d=v*n,c=d/(i+l-d);return Number(c.toFixed(4))}return 0}const Tu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const g=[];for(const p of o){const{id:v}=p,n=r.get(v);if(n){const i=Au(n,s);i>0&&g.push({id:v,data:{droppableContainer:p,value:i}})}}return g.sort(Nu)};function Mu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Ya(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:It}function Du(e){return function(r){for(var o=arguments.length,g=new Array(o>1?o-1:0),p=1;p<o;p++)g[p-1]=arguments[p];return g.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const Pu=Du(1);function Va(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Lu(e,s,r){const o=Va(s);if(!o)return e;const{scaleX:g,scaleY:p,x:v,y:n}=o,i=e.left-v-(1-g)*parseFloat(r),l=e.top-n-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),d=g?e.width/g:e.width,c=p?e.height/p:e.height;return{width:d,height:c,top:l,right:i+d,bottom:l+c,left:i}}const Iu={ignoreTransform:!1};function mr(e,s){s===void 0&&(s=Iu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:d}=St(e).getComputedStyle(e);l&&(r=Lu(r,l,d))}const{top:o,left:g,width:p,height:v,bottom:n,right:i}=r;return{top:o,left:g,width:p,height:v,bottom:n,right:i}}function lo(e){return mr(e,{ignoreTransform:!0})}function Ou(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Bu(e,s){return s===void 0&&(s=St(e).getComputedStyle(e)),s.position==="fixed"}function Fu(e,s){s===void 0&&(s=St(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(g=>{const p=s[g];return typeof p=="string"?r.test(p):!1})}function Cn(e,s){const r=[];function o(g){if(s!=null&&r.length>=s||!g)return r;if(Sn(g)&&g.scrollingElement!=null&&!r.includes(g.scrollingElement))return r.push(g.scrollingElement),r;if(!hr(g)||qa(g)||r.includes(g))return r;const p=St(e).getComputedStyle(g);return g!==e&&Fu(g,p)&&r.push(g),Bu(g,p)?r:o(g.parentNode)}return e?o(e):r}function Ga(e){const[s]=Cn(e,1);return s??null}function Ci(e){return!ii||!e?null:Fs(e)?e:yn(e)?Sn(e)||e===zs(e).scrollingElement?window:hr(e)?e:null:null}function Qa(e){return Fs(e)?e.scrollX:e.scrollLeft}function Za(e){return Fs(e)?e.scrollY:e.scrollTop}function qi(e){return{x:Qa(e),y:Za(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function Ja(e){return!ii||!e?!1:e===document.scrollingElement}function el(e){const s={x:0,y:0},r=Ja(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},g=e.scrollTop<=s.y,p=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:g,isLeft:p,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const zu={x:.2,y:.2};function Wu(e,s,r,o,g){let{top:p,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),g===void 0&&(g=zu);const{isTop:l,isBottom:d,isLeft:c,isRight:m}=el(e),x={x:0,y:0},w={x:0,y:0},_={height:s.height*g.y,width:s.width*g.x};return!l&&p<=s.top+_.height?(x.y=dt.Backward,w.y=o*Math.abs((s.top+_.height-p)/_.height)):!d&&i>=s.bottom-_.height&&(x.y=dt.Forward,w.y=o*Math.abs((s.bottom-_.height-i)/_.height)),!m&&n>=s.right-_.width?(x.x=dt.Forward,w.x=o*Math.abs((s.right-_.width-n)/_.width)):!c&&v<=s.left+_.width&&(x.x=dt.Backward,w.x=o*Math.abs((s.left+_.width-v)/_.width)),{direction:x,speed:w}}function Hu(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:v}=window;return{top:0,left:0,right:p,bottom:v,width:p,height:v}}const{top:s,left:r,right:o,bottom:g}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:g,width:e.clientWidth,height:e.clientHeight}}function tl(e){return e.reduce((s,r)=>Ts(s,qi(r)),It)}function $u(e){return e.reduce((s,r)=>s+Qa(r),0)}function Uu(e){return e.reduce((s,r)=>s+Za(r),0)}function sl(e,s){if(s===void 0&&(s=mr),!e)return;const{top:r,left:o,bottom:g,right:p}=s(e);Ga(e)&&(g<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const qu=[["x",["left","right"],$u],["y",["top","bottom"],Uu]];class kn{constructor(s,r){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 o=Cn(r),g=tl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[p,v,n]of qu)for(const i of v)Object.defineProperty(this,i,{get:()=>{const l=n(o),d=g[p]-l;return this.rect[i]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Js{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var g;(g=this.target)==null||g.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Ku(e){const{EventTarget:s}=St(e);return e instanceof s?e:zs(e)}function ki(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Rt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rt||(Rt={}));function co(e){e.preventDefault()}function Xu(e){e.stopPropagation()}var We;(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"})(We||(We={}));const rl={start:[We.Space,We.Enter],cancel:[We.Esc],end:[We.Space,We.Enter,We.Tab]},Yu=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case We.Right:return{...r,x:r.x+25};case We.Left:return{...r,x:r.x-25};case We.Down:return{...r,y:r.y+25};case We.Up:return{...r,y:r.y-25}}};class il{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new Js(zs(r)),this.windowListeners=new Js(St(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&sl(o),r(It)}handleKeyDown(s){if(wn(s)){const{active:r,context:o,options:g}=this.props,{keyboardCodes:p=rl,coordinateGetter:v=Yu,scrollBehavior:n="smooth"}=g,{code:i}=s;if(p.end.includes(i)){this.handleEnd(s);return}if(p.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:l}=o.current,d=l?{x:l.left,y:l.top}:It;this.referenceCoordinates||(this.referenceCoordinates=d);const c=v(s,{active:r,context:o.current,currentCoordinates:d});if(c){const m=Kr(c,d),x={x:0,y:0},{scrollableAncestors:w}=o.current;for(const _ of w){const a=s.code,{isTop:h,isRight:u,isLeft:f,isBottom:y,maxScroll:C,minScroll:k}=el(_),E=Hu(_),b={x:Math.min(a===We.Right?E.right-E.width/2:E.right,Math.max(a===We.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(a===We.Down?E.bottom-E.height/2:E.bottom,Math.max(a===We.Down?E.top:E.top+E.height/2,c.y))},j=a===We.Right&&!u||a===We.Left&&!f,A=a===We.Down&&!y||a===We.Up&&!h;if(j&&b.x!==c.x){const L=_.scrollLeft+m.x,T=a===We.Right&&L<=C.x||a===We.Left&&L>=k.x;if(T&&!m.y){_.scrollTo({left:L,behavior:n});return}T?x.x=_.scrollLeft-L:x.x=a===We.Right?_.scrollLeft-C.x:_.scrollLeft-k.x,x.x&&_.scrollBy({left:-x.x,behavior:n});break}else if(A&&b.y!==c.y){const L=_.scrollTop+m.y,T=a===We.Down&&L<=C.y||a===We.Up&&L>=k.y;if(T&&!m.x){_.scrollTo({top:L,behavior:n});return}T?x.y=_.scrollTop-L:x.y=a===We.Down?_.scrollTop-C.y:_.scrollTop-k.y,x.y&&_.scrollBy({top:-x.y,behavior:n});break}}this.handleMove(s,Ts(Kr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}il.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=rl,onActivation:g}=s,{active:p}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=p.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),g?.({event:e.nativeEvent}),!0)}return!1}}];function uo(e){return!!(e&&"distance"in e)}function ho(e){return!!(e&&"delay"in e)}class En{constructor(s,r,o){var g;o===void 0&&(o=Ku(s.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=s,this.events=r;const{event:p}=s,{target:v}=p;this.props=s,this.events=r,this.document=zs(v),this.documentListeners=new Js(this.document),this.listeners=new Js(o),this.windowListeners=new Js(St(v)),this.initialCoordinates=(g=Xr(p))!=null?g:It,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:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,co),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,co),this.documentListeners.add(Rt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ho(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(uo(r)){this.handlePending(r);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(s,r){const{active:o,onPending:g}=this.props;g(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Rt.Click,Xu,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:g,props:p}=this,{onMove:v,options:{activationConstraint:n}}=p;if(!g)return;const i=(r=Xr(s))!=null?r:It,l=Kr(g,i);if(!o&&n){if(uo(n)){if(n.tolerance!=null&&ki(l,n.tolerance))return this.handleCancel();if(ki(l,n.distance))return this.handleStart()}if(ho(n)&&ki(l,n.tolerance))return this.handleCancel();this.handlePending(n,l);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===We.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const Vu={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jn extends En{constructor(s){const{event:r}=s,o=zs(r.target);super(s,Vu,o)}}jn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Gu={move:{name:"mousemove"},end:{name:"mouseup"}};var Ki;(function(e){e[e.RightClick=2]="RightClick"})(Ki||(Ki={}));class Qu extends En{constructor(s){super(s,Gu,zs(s.event.target))}}Qu.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Ki.RightClick?!1:(o?.({event:r}),!0)}}];const Ei={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Zu extends En{constructor(s){super(s,Ei)}static setup(){return window.addEventListener(Ei.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Ei.move.name,s)};function s(){}}}Zu.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:g}=r;return g.length>1?!1:(o?.({event:r}),!0)}}];var er;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(er||(er={}));var Vr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Vr||(Vr={}));function Ju(e){let{acceleration:s,activator:r=er.Pointer,canScroll:o,draggingRect:g,enabled:p,interval:v=5,order:n=Vr.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:d,delta:c,threshold:m}=e;const x=th({delta:c,disabled:!p}),[w,_]=hu(),a=S.useRef({x:0,y:0}),h=S.useRef({x:0,y:0}),u=S.useMemo(()=>{switch(r){case er.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case er.DraggableRect:return g}},[r,g,i]),f=S.useRef(null),y=S.useCallback(()=>{const k=f.current;if(!k)return;const E=a.current.x*h.current.x,b=a.current.y*h.current.y;k.scrollBy(E,b)},[]),C=S.useMemo(()=>n===Vr.TreeOrder?[...l].reverse():l,[n,l]);S.useEffect(()=>{if(!p||!l.length||!u){_();return}for(const k of C){if(o?.(k)===!1)continue;const E=l.indexOf(k),b=d[E];if(!b)continue;const{direction:j,speed:A}=Wu(k,b,u,s,m);for(const L of["x","y"])x[L][j[L]]||(A[L]=0,j[L]=0);if(A.x>0||A.y>0){_(),f.current=k,w(y,v),a.current=A,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},_()},[s,y,o,_,p,v,JSON.stringify(u),JSON.stringify(x),w,l,C,d,JSON.stringify(m)])}const eh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function th(e){let{delta:s,disabled:r}=e;const o=qr(s);return fr(g=>{if(r||!o||!g)return eh;const p={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[dt.Backward]:g.x[dt.Backward]||p.x===-1,[dt.Forward]:g.x[dt.Forward]||p.x===1},y:{[dt.Backward]:g.y[dt.Backward]||p.y===-1,[dt.Forward]:g.y[dt.Forward]||p.y===1}}},[r,s,o])}function sh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return fr(g=>{var p;return s==null?null:(p=o??g)!=null?p:null},[o,s])}function rh(e,s){return S.useMemo(()=>e.reduce((r,o)=>{const{sensor:g}=o,p=g.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...p]},[]),[e,s])}var ar;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ar||(ar={}));var Xi;(function(e){e.Optimized="optimized"})(Xi||(Xi={}));const fo=new Map;function ih(e,s){let{dragging:r,dependencies:o,config:g}=s;const[p,v]=S.useState(null),{frequency:n,measure:i,strategy:l}=g,d=S.useRef(e),c=a(),m=nr(c),x=S.useCallback(function(h){h===void 0&&(h=[]),!m.current&&v(u=>u===null?h:u.concat(h.filter(f=>!u.includes(f))))},[m]),w=S.useRef(null),_=fr(h=>{if(c&&!r)return fo;if(!h||h===fo||d.current!==e||p!=null){const u=new Map;for(let f of e){if(!f)continue;if(p&&p.length>0&&!p.includes(f.id)&&f.rect.current){u.set(f.id,f.rect.current);continue}const y=f.node.current,C=y?new kn(i(y),y):null;f.rect.current=C,C&&u.set(f.id,C)}return u}return h},[e,p,r,c,i]);return S.useEffect(()=>{d.current=e},[e]),S.useEffect(()=>{c||x()},[r,c]),S.useEffect(()=>{p&&p.length>0&&v(null)},[JSON.stringify(p)]),S.useEffect(()=>{c||typeof n!="number"||w.current!==null||(w.current=setTimeout(()=>{x(),w.current=null},n))},[n,c,x,...o]),{droppableRects:_,measureDroppableContainers:x,measuringScheduled:p!=null};function a(){switch(l){case ar.Always:return!1;case ar.BeforeDragging:return r;default:return!r}}}function Nn(e,s){return fr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function nh(e,s){return Nn(e,s)}function oh(e){let{callback:s,disabled:r}=e;const o=ni(s),g=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return S.useEffect(()=>()=>g?.disconnect(),[g]),g}function ai(e){let{callback:s,disabled:r}=e;const o=ni(s),g=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return S.useEffect(()=>()=>g?.disconnect(),[g]),g}function ah(e){return new kn(mr(e),e)}function mo(e,s,r){s===void 0&&(s=ah);const[o,g]=S.useState(null);function p(){g(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??r)!=null?l:null}const d=s(e);return JSON.stringify(i)===JSON.stringify(d)?i:d})}const v=oh({callback(i){if(e)for(const l of i){const{type:d,target:c}=l;if(d==="childList"&&c instanceof HTMLElement&&c.contains(e)){p();break}}}}),n=ai({callback:p});return Vt(()=>{p(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function lh(e){const s=Nn(e);return Ya(e,s)}const po=[];function ch(e){const s=S.useRef(e),r=fr(o=>e?o&&o!==po&&e&&s.current&&e.parentNode===s.current.parentNode?o:Cn(e):po,[e]);return S.useEffect(()=>{s.current=e},[e]),r}function dh(e){const[s,r]=S.useState(null),o=S.useRef(e),g=S.useCallback(p=>{const v=Ci(p.target);v&&r(n=>n?(n.set(v,qi(v)),new Map(n)):null)},[]);return S.useEffect(()=>{const p=o.current;if(e!==p){v(p);const n=e.map(i=>{const l=Ci(i);return l?(l.addEventListener("scroll",g,{passive:!0}),[l,qi(l)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(p)};function v(n){n.forEach(i=>{const l=Ci(i);l?.removeEventListener("scroll",g)})}},[g,e]),S.useMemo(()=>e.length?s?Array.from(s.values()).reduce((p,v)=>Ts(p,v),It):tl(e):It,[e,s])}function go(e,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.useEffect(()=>{const o=e!==It;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Kr(e,r.current):It}function uh(e){S.useEffect(()=>{if(!ii)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function hh(e,s){return S.useMemo(()=>e.reduce((r,o)=>{let{eventName:g,handler:p}=o;return r[g]=v=>{p(v,s)},r},{}),[e,s])}function nl(e){return S.useMemo(()=>e?Ou(e):null,[e])}const vo=[];function fh(e,s){s===void 0&&(s=mr);const[r]=e,o=nl(r?St(r):null),[g,p]=S.useState(vo);function v(){p(()=>e.length?e.map(i=>Ja(i)?o:new kn(s(i),i)):vo)}const n=ai({callback:v});return Vt(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),g}function ol(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return hr(s)?s:e}function mh(e){let{measure:s}=e;const[r,o]=S.useState(null),g=S.useCallback(l=>{for(const{target:d}of l)if(hr(d)){o(c=>{const m=s(d);return c?{...c,width:m.width,height:m.height}:m});break}},[s]),p=ai({callback:g}),v=S.useCallback(l=>{const d=ol(l);p?.disconnect(),d&&p?.observe(d),o(d?s(d):null)},[s,p]),[n,i]=Ur(v);return S.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const ph=[{sensor:jn,options:{}},{sensor:il,options:{}}],gh={current:{}},Ir={draggable:{measure:lo},droppable:{measure:lo,strategy:ar.WhileDragging,frequency:Xi.Optimized},dragOverlay:{measure:mr}};class tr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const vh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new tr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Yr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ir,measureDroppableContainers:Yr,windowRect:null,measuringScheduled:!1},al={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Yr,draggableNodes:new Map,over:null,measureDroppableContainers:Yr},pr=S.createContext(al),ll=S.createContext(vh);function xh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new tr}}}function _h(e,s){switch(s.type){case it.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case it.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case it.DragEnd:case it.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case it.RegisterDroppable:{const{element:r}=s,{id:o}=r,g=new tr(e.droppable.containers);return g.set(o,r),{...e,droppable:{...e.droppable,containers:g}}}case it.SetDroppableDisabled:{const{id:r,key:o,disabled:g}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const v=new tr(e.droppable.containers);return v.set(r,{...p,disabled:g}),{...e,droppable:{...e.droppable,containers:v}}}case it.UnregisterDroppable:{const{id:r,key:o}=s,g=e.droppable.containers.get(r);if(!g||o!==g.key)return e;const p=new tr(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function bh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:g}=S.useContext(pr),p=qr(o),v=qr(r?.id);return S.useEffect(()=>{if(!s&&!o&&p&&v!=null){if(!wn(p)||document.activeElement===p.target)return;const n=g.get(v);if(!n)return;const{activatorNode:i,node:l}=n;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const d of[i.current,l.current]){if(!d)continue;const c=pu(d);if(c){c.focus();break}}})}},[o,s,g,v,p]),null}function cl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((g,p)=>p({transform:g,...o}),r):r}function yh(e){return S.useMemo(()=>({draggable:{...Ir.draggable,...e?.draggable},droppable:{...Ir.droppable,...e?.droppable},dragOverlay:{...Ir.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Sh(e){let{activeNode:s,measure:r,initialRect:o,config:g=!0}=e;const p=S.useRef(!1),{x:v,y:n}=typeof g=="boolean"?{x:g,y:g}:g;Vt(()=>{if(!v&&!n||!s){p.current=!1;return}if(p.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const d=r(l),c=Ya(d,o);if(v||(c.x=0),n||(c.y=0),p.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const m=Ga(l);m&&m.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const li=S.createContext({...It,scaleX:1,scaleY:1});var Qt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Qt||(Qt={}));const wh=S.memo(function(s){var r,o,g,p;let{id:v,accessibility:n,autoScroll:i=!0,children:l,sensors:d=ph,collisionDetection:c=Tu,measuring:m,modifiers:x,...w}=s;const _=S.useReducer(_h,void 0,xh),[a,h]=_,[u,f]=yu(),[y,C]=S.useState(Qt.Uninitialized),k=y===Qt.Initialized,{draggable:{active:E,nodes:b,translate:j},droppable:{containers:A}}=a,L=E!=null?b.get(E):null,T=S.useRef({initial:null,translated:null}),D=S.useMemo(()=>{var pe;return E!=null?{id:E,data:(pe=L?.data)!=null?pe:gh,rect:T}:null},[E,L]),F=S.useRef(null),[I,$]=S.useState(null),[W,R]=S.useState(null),M=nr(w,Object.values(w)),P=oi("DndDescribedBy",v),O=S.useMemo(()=>A.getEnabled(),[A]),U=yh(m),{droppableRects:Y,measureDroppableContainers:B,measuringScheduled:H}=ih(O,{dragging:k,dependencies:[j.x,j.y],config:U.droppable}),q=sh(b,E),N=S.useMemo(()=>W?Xr(W):null,[W]),z=we(),X=nh(q,U.draggable.measure);Sh({activeNode:E!=null?b.get(E):null,config:z.layoutShiftCompensation,initialRect:X,measure:U.draggable.measure});const K=mo(q,U.draggable.measure,X),ne=mo(q?q.parentElement:null),te=S.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),fe=A.getNodeFor((r=te.current.over)==null?void 0:r.id),ce=mh({measure:U.dragOverlay.measure}),G=(o=ce.nodeRef.current)!=null?o:q,ge=k?(g=ce.rect)!=null?g:K:null,re=!!(ce.nodeRef.current&&ce.rect),Ae=lh(re?null:K),nt=nl(G?St(G):null),Ke=ch(k?fe??q:null),be=fh(Ke),Oe=cl(x,{transform:{x:j.x-Ae.x,y:j.y-Ae.y,scaleX:1,scaleY:1},activatorEvent:W,active:D,activeNodeRect:K,containerNodeRect:ne,draggingNodeRect:ge,over:te.current.over,overlayNodeRect:ce.rect,scrollableAncestors:Ke,scrollableAncestorRects:be,windowRect:nt}),Pe=N?Ts(N,j):null,He=dh(Ke),Be=go(He),Ye=go(He,[K]),Ze=Ts(Oe,Be),Me=ge?Pu(ge,Oe):null,Re=D&&Me?c({active:D,collisionRect:Me,droppableRects:Y,droppableContainers:O,pointerCoordinates:Pe}):null,ve=Ru(Re,"id"),[ze,xe]=S.useState(null),ot=re?Oe:Ts(Oe,Ye),st=Mu(ot,(p=ze?.rect)!=null?p:null,K),jt=S.useRef(null),J=S.useCallback((pe,ue)=>{let{sensor:Le,options:_e}=ue;if(F.current==null)return;const Ce=b.get(F.current);if(!Ce)return;const De=pe.nativeEvent,ke=new Le({active:F.current,activeNode:Ce,event:De,options:_e,context:te,onAbort(je){if(!b.get(je))return;const{onDragAbort:tt}=M.current,xt={id:je};tt?.(xt),u({type:"onDragAbort",event:xt})},onPending(je,Ge,tt,xt){if(!b.get(je))return;const{onDragPending:at}=M.current,lt={id:je,constraint:Ge,initialCoordinates:tt,offset:xt};at?.(lt),u({type:"onDragPending",event:lt})},onStart(je){const Ge=F.current;if(Ge==null)return;const tt=b.get(Ge);if(!tt)return;const{onDragStart:xt}=M.current,_t={activatorEvent:De,active:{id:Ge,data:tt.data,rect:T}};fs.unstable_batchedUpdates(()=>{xt?.(_t),C(Qt.Initializing),h({type:it.DragStart,initialCoordinates:je,active:Ge}),u({type:"onDragStart",event:_t}),$(jt.current),R(De)})},onMove(je){h({type:it.DragMove,coordinates:je})},onEnd:Ve(it.DragEnd),onCancel:Ve(it.DragCancel)});jt.current=ke;function Ve(je){return async function(){const{active:tt,collisions:xt,over:_t,scrollAdjustedTranslate:at}=te.current;let lt=null;if(tt&&at){const{cancelDrop:bt}=M.current;lt={activatorEvent:De,active:tt,collisions:xt,delta:at,over:_t},je===it.DragEnd&&typeof bt=="function"&&await Promise.resolve(bt(lt))&&(je=it.DragCancel)}F.current=null,fs.unstable_batchedUpdates(()=>{h({type:je}),C(Qt.Uninitialized),xe(null),$(null),R(null),jt.current=null;const bt=je===it.DragEnd?"onDragEnd":"onDragCancel";if(lt){const Bt=M.current[bt];Bt?.(lt),u({type:bt,event:lt})}})}}},[b]),he=S.useCallback((pe,ue)=>(Le,_e)=>{const Ce=Le.nativeEvent,De=b.get(_e);if(F.current!==null||!De||Ce.dndKit||Ce.defaultPrevented)return;const ke={active:De};pe(Le,ue.options,ke)===!0&&(Ce.dndKit={capturedBy:ue.sensor},F.current=_e,J(Le,ue))},[b,J]),V=rh(d,he);uh(d),Vt(()=>{K&&y===Qt.Initializing&&C(Qt.Initialized)},[K,y]),S.useEffect(()=>{const{onDragMove:pe}=M.current,{active:ue,activatorEvent:Le,collisions:_e,over:Ce}=te.current;if(!ue||!Le)return;const De={active:ue,activatorEvent:Le,collisions:_e,delta:{x:Ze.x,y:Ze.y},over:Ce};fs.unstable_batchedUpdates(()=>{pe?.(De),u({type:"onDragMove",event:De})})},[Ze.x,Ze.y]),S.useEffect(()=>{const{active:pe,activatorEvent:ue,collisions:Le,droppableContainers:_e,scrollAdjustedTranslate:Ce}=te.current;if(!pe||F.current==null||!ue||!Ce)return;const{onDragOver:De}=M.current,ke=_e.get(ve),Ve=ke&&ke.rect.current?{id:ke.id,rect:ke.rect.current,data:ke.data,disabled:ke.disabled}:null,je={active:pe,activatorEvent:ue,collisions:Le,delta:{x:Ce.x,y:Ce.y},over:Ve};fs.unstable_batchedUpdates(()=>{xe(Ve),De?.(je),u({type:"onDragOver",event:je})})},[ve]),Vt(()=>{te.current={activatorEvent:W,active:D,activeNode:q,collisionRect:Me,collisions:Re,droppableRects:Y,draggableNodes:b,draggingNode:G,draggingNodeRect:ge,droppableContainers:A,over:ze,scrollableAncestors:Ke,scrollAdjustedTranslate:Ze},T.current={initial:ge,translated:Me}},[D,q,Re,Me,b,G,ge,Y,A,ze,Ke,Ze]),Ju({...z,delta:j,draggingRect:Me,pointerCoordinates:Pe,scrollableAncestors:Ke,scrollableAncestorRects:be});const Z=S.useMemo(()=>({active:D,activeNode:q,activeNodeRect:K,activatorEvent:W,collisions:Re,containerNodeRect:ne,dragOverlay:ce,draggableNodes:b,droppableContainers:A,droppableRects:Y,over:ze,measureDroppableContainers:B,scrollableAncestors:Ke,scrollableAncestorRects:be,measuringConfiguration:U,measuringScheduled:H,windowRect:nt}),[D,q,K,W,Re,ne,ce,b,A,Y,ze,B,Ke,be,U,H,nt]),ie=S.useMemo(()=>({activatorEvent:W,activators:V,active:D,activeNodeRect:K,ariaDescribedById:{draggable:P},dispatch:h,draggableNodes:b,over:ze,measureDroppableContainers:B}),[W,V,D,K,h,P,b,ze,B]);return le.createElement(Xa.Provider,{value:f},le.createElement(pr.Provider,{value:ie},le.createElement(ll.Provider,{value:Z},le.createElement(li.Provider,{value:st},l)),le.createElement(bh,{disabled:n?.restoreFocus===!1})),le.createElement(Cu,{...n,hiddenTextDescribedById:P}));function we(){const pe=I?.autoScrollEnabled===!1,ue=typeof i=="object"?i.enabled===!1:i===!1,Le=k&&!pe&&!ue;return typeof i=="object"?{...i,enabled:Le}:{enabled:Le}}}),Ch=S.createContext(null),xo="button",kh="Draggable";function Eh(e){let{id:s,data:r,disabled:o=!1,attributes:g}=e;const p=oi(kh),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:d,draggableNodes:c,over:m}=S.useContext(pr),{role:x=xo,roleDescription:w="draggable",tabIndex:_=0}=g??{},a=i?.id===s,h=S.useContext(a?li:Ch),[u,f]=Ur(),[y,C]=Ur(),k=hh(v,s),E=nr(r);Vt(()=>(c.set(s,{id:s,key:p,node:u,activatorNode:y,data:E}),()=>{const j=c.get(s);j&&j.key===p&&c.delete(s)}),[c,s]);const b=S.useMemo(()=>({role:x,tabIndex:_,"aria-disabled":o,"aria-pressed":a&&x===xo?!0:void 0,"aria-roledescription":w,"aria-describedby":d.draggable}),[o,x,_,a,w,d.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:b,isDragging:a,listeners:o?void 0:k,node:u,over:m,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function jh(){return S.useContext(ll)}const Nh="Droppable",Rh={timeout:25};function Ah(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:g}=e;const p=oi(Nh),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=S.useContext(pr),d=S.useRef({disabled:r}),c=S.useRef(!1),m=S.useRef(null),x=S.useRef(null),{disabled:w,updateMeasurementsFor:_,timeout:a}={...Rh,...g},h=nr(_??o),u=S.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),f=ai({callback:u,disabled:w||!v}),y=S.useCallback((b,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),b&&f.observe(b))},[f]),[C,k]=Ur(y),E=nr(s);return S.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),S.useEffect(()=>(n({type:it.RegisterDroppable,element:{id:o,key:p,disabled:r,node:C,rect:m,data:E}}),()=>n({type:it.UnregisterDroppable,key:p,id:o})),[o]),S.useEffect(()=>{r!==d.current.disabled&&(n({type:it.SetDroppableDisabled,id:o,key:p,disabled:r}),d.current.disabled=r)},[o,p,r,n]),{active:v,rect:m,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function Th(e){let{animation:s,children:r}=e;const[o,g]=S.useState(null),[p,v]=S.useState(null),n=qr(r);return!r&&!o&&n&&g(n),Vt(()=>{if(!p)return;const i=o?.key,l=o?.props.id;if(i==null||l==null){g(null);return}Promise.resolve(s(l,p)).then(()=>{g(null)})},[s,o,p]),le.createElement(le.Fragment,null,r,o?S.cloneElement(o,{ref:v}):null)}const Mh={x:0,y:0,scaleX:1,scaleY:1};function Dh(e){let{children:s}=e;return le.createElement(pr.Provider,{value:al},le.createElement(li.Provider,{value:Mh},s))}const Ph={position:"fixed",touchAction:"none"},Lh=e=>wn(e)?"transform 250ms ease":void 0,Ih=S.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:g,children:p,className:v,rect:n,style:i,transform:l,transition:d=Lh}=e;if(!n)return null;const c=g?l:{...l,scaleX:1,scaleY:1},m={...Ph,width:n.width,height:n.height,top:n.top,left:n.left,transform:or.Transform.toString(c),transformOrigin:g&&o?ju(o,n):void 0,transition:typeof d=="function"?d(o):d,...i};return le.createElement(r,{className:v,style:m,ref:s},p)}),Oh=e=>s=>{let{active:r,dragOverlay:o}=s;const g={},{styles:p,className:v}=e;if(p!=null&&p.active)for(const[n,i]of Object.entries(p.active))i!==void 0&&(g[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(p!=null&&p.dragOverlay)for(const[n,i]of Object.entries(p.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,l]of Object.entries(g))r.node.style.setProperty(i,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},Bh=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:or.Transform.toString(s)},{transform:or.Transform.toString(r)}]},Fh={duration:250,easing:"ease",keyframes:Bh,sideEffects:Oh({styles:{active:{opacity:"0"}}})};function zh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:g}=e;return ni((p,v)=>{if(s===null)return;const n=r.get(p);if(!n)return;const i=n.node.current;if(!i)return;const l=ol(v);if(!l)return;const{transform:d}=St(v).getComputedStyle(v),c=Va(d);if(!c)return;const m=typeof s=="function"?s:Wh(s);return sl(i,g.draggable.measure),m({active:{id:p,data:n.data,node:i,rect:g.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:g.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:g,transform:c})})}function Wh(e){const{duration:s,easing:r,sideEffects:o,keyframes:g}={...Fh,...e};return p=>{let{active:v,dragOverlay:n,transform:i,...l}=p;if(!s)return;const d={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},c={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},m={x:i.x-d.x,y:i.y-d.y,...c},x=g({...l,active:v,dragOverlay:n,transform:{initial:i,final:m}}),[w]=x,_=x[x.length-1];if(JSON.stringify(w)===JSON.stringify(_))return;const a=o?.({active:v,dragOverlay:n,...l}),h=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(u=>{h.onfinish=()=>{a?.(),u()}})}}let _o=0;function Hh(e){return S.useMemo(()=>{if(e!=null)return _o++,_o},[e])}const $h=le.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:g,transition:p,modifiers:v,wrapperElement:n="div",className:i,zIndex:l=999}=e;const{activatorEvent:d,active:c,activeNodeRect:m,containerNodeRect:x,draggableNodes:w,droppableContainers:_,dragOverlay:a,over:h,measuringConfiguration:u,scrollableAncestors:f,scrollableAncestorRects:y,windowRect:C}=jh(),k=S.useContext(li),E=Hh(c?.id),b=cl(v,{activatorEvent:d,active:c,activeNodeRect:m,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:y,transform:k,windowRect:C}),j=Nn(m),A=zh({config:o,draggableNodes:w,droppableContainers:_,measuringConfiguration:u}),L=j?a.setRef:void 0;return le.createElement(Dh,null,le.createElement(Th,{animation:A},c&&E?le.createElement(Ih,{key:E,id:c.id,ref:L,as:n,activatorEvent:d,adjustScale:s,className:i,transition:p,rect:j,style:{zIndex:l,...g},transform:b},r):null))}),dl=768;function Uh(e){const s=window.matchMedia(`(max-width: ${dl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function qh(){return window.innerWidth<dl}function Kh(){return!1}function ul(){return S.useSyncExternalStore(Uh,qh,Kh)}const Xh=1500,Yh=2e3,Vh=5e3;function hl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?Xh:!1}function Gh(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?Yh:!1}function Qh(e,s){return e&&s?.workingDir===e&&s.tab==="history"?Vh:!1}function Rn(e){return Ot({queryKey:ae.workspaces.list(e),queryFn:()=>Se.get(`/tasks/${e}/workspaces`),enabled:!!e})}function fl(e){const s=ht();return kt({mutationFn:r=>Se.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ae.workspaces.list(e)}),s.invalidateQueries({queryKey:ae.tasks.all})}})}function ml(){const e=ht();return kt({mutationFn:({id:s,commitMessage:r})=>Se.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all}),e.invalidateQueries({queryKey:ae.git.all})},onError:()=>{e.invalidateQueries({queryKey:ae.git.all})}})}function Zh(){const e=ht();return kt({mutationFn:s=>Se.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function An(){return kt({mutationFn:({workspaceId:e,editorType:s})=>Se.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Tn(e,s={}){const r=xs(g=>g.visibleContext),o=Gh(e,r);return Ot({queryKey:ae.workspaces.gitStatus(e),queryFn:()=>Se.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function pl(){const e=ht();return kt({mutationFn:s=>Se.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})}})}function Mn(){const e=ht();return kt({mutationFn:s=>Se.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})}})}function Jh(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(v=>v.status===et.RUNNING||v.status===et.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Dn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:g,workspaces:p,isLoading:v}){const{t:n}=de(),{data:i,isLoading:l}=Rn(p===void 0&&e?o:""),d=p??i,c=p===void 0&&e&&l,m=S.useMemo(()=>Jh(d,n),[d,n]);return t.jsx(fn,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:g})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):m.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:m.map((x,w)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:x})]},w))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const ye={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Yi={[ye.Review]:{label:"Review",icon:Ta,iconClass:"text-warning",accentClass:"text-warning"},[ye.Running]:{label:"Running",icon:Aa,iconClass:"text-info",accentClass:"text-info"},[ye.Pending]:{label:"Pending",icon:Ra,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ye.Done]:{label:"Done",icon:Na,iconClass:"text-success/80",accentClass:"text-success"},[ye.Cancelled]:{label:"Cancelled",icon:ja,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},ef=[ye.Review,ye.Running,ye.Pending,ye.Done,ye.Cancelled],gl=S.createContext(null),tf=3e4;function sf(e=tf){const[,s]=S.useState(0);S.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function rf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?vt("{count}s ago",{count:s}):s<3600?vt("{count}m ago",{count:Math.floor(s/60)}):s<86400?vt("{count}h ago",{count:Math.floor(s/3600)}):vt("{count}d ago",{count:Math.floor(s/86400)})}function nf({task:e,status:s,isSelected:r,project:o,onSelectTask:g,onTaskStatusChange:p,onDeleteTask:v,disableDrag:n}){const{t:i}=de(),l=S.useContext(gl),d=S.useRef(null),c=!!e.projectArchivedAt,m=c||!!n,{attributes:x,listeners:w,setNodeRef:_,isDragging:a}=Eh({id:e.id,data:{task:e,fromStatus:s},disabled:m}),h=S.useCallback(T=>{d.current=T,_(T),l&&(T?l.registry.set(e.id,T):l.registry.delete(e.id))},[_,l,e.id]);S.useEffect(()=>()=>{l?.registry.delete(e.id)},[e.id,l]);const[u,f]=S.useState(null),[y,C]=S.useState(!1),k=S.useRef(null),E=S.useRef(null),b=S.useCallback(T=>{c||!p&&!v||(T.preventDefault(),f({x:T.clientX,y:T.clientY}))},[c,p,v]),j=S.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),A=S.useCallback(T=>{if(!n||c||!p&&!v)return;const D=T.touches[0];if(!D)return;const{clientX:F,clientY:I}=D;E.current=setTimeout(()=>{E.current=null,f({x:F,y:I})},500)},[n,c,p,v]);S.useEffect(()=>{if(!u)return;const T=D=>{k.current&&!k.current.contains(D.target)&&f(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[u]);const L=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:h,onClick:()=>g(e.id),onContextMenu:b,onTouchStart:A,onTouchEnd:j,onTouchMove:j,title:L,"aria-label":L?`${e.title} — ${L}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
6
|
+
`},Nu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Ru(e){let{announcements:s=Nu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:g=ju}=e;const{announce:p,announcement:v}=Cu(),n=ai("DndLiveRegion"),[i,l]=S.useState(!1);if(S.useEffect(()=>{l(!0)},[]),ku(S.useMemo(()=>({onDragStart(c){let{active:m}=c;p(s.onDragStart({active:m}))},onDragMove(c){let{active:m,over:x}=c;s.onDragMove&&p(s.onDragMove({active:m,over:x}))},onDragOver(c){let{active:m,over:x}=c;p(s.onDragOver({active:m,over:x}))},onDragEnd(c){let{active:m,over:x}=c;p(s.onDragEnd({active:m,over:x}))},onDragCancel(c){let{active:m,over:x}=c;p(s.onDragCancel({active:m,over:x}))}}),[p,s])),!i)return null;const d=ae.createElement(ae.Fragment,null,ae.createElement(Su,{id:o,value:g.draggable}),ae.createElement(wu,{id:n,announcement:v}));return r?ps.createPortal(d,r):d}var ot;(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"})(ot||(ot={}));function Vr(){}function Au(e,s){return S.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Tu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return S.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ot=Object.freeze({x:0,y:0});function Mu(e,s){const r=Yr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Du(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Pu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Lu(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),g=Math.min(s.left+s.width,e.left+e.width),p=Math.min(s.top+s.height,e.top+e.height),v=g-o,n=p-r;if(o<g&&r<p){const i=s.width*s.height,l=e.width*e.height,d=v*n,c=d/(i+l-d);return Number(c.toFixed(4))}return 0}const Iu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const g=[];for(const p of o){const{id:v}=p,n=r.get(v);if(n){const i=Lu(n,s);i>0&&g.push({id:v,data:{droppableContainer:p,value:i}})}}return g.sort(Du)};function Ou(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Qa(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ot}function Bu(e){return function(r){for(var o=arguments.length,g=new Array(o>1?o-1:0),p=1;p<o;p++)g[p-1]=arguments[p];return g.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const Fu=Bu(1);function Za(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function zu(e,s,r){const o=Za(s);if(!o)return e;const{scaleX:g,scaleY:p,x:v,y:n}=o,i=e.left-v-(1-g)*parseFloat(r),l=e.top-n-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),d=g?e.width/g:e.width,c=p?e.height/p:e.height;return{width:d,height:c,top:l,right:i+d,bottom:l+c,left:i}}const Wu={ignoreTransform:!1};function pr(e,s){s===void 0&&(s=Wu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:d}=yt(e).getComputedStyle(e);l&&(r=zu(r,l,d))}const{top:o,left:g,width:p,height:v,bottom:n,right:i}=r;return{top:o,left:g,width:p,height:v,bottom:n,right:i}}function lo(e){return pr(e,{ignoreTransform:!0})}function Hu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function $u(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function Uu(e,s){s===void 0&&(s=yt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(g=>{const p=s[g];return typeof p=="string"?r.test(p):!1})}function jn(e,s){const r=[];function o(g){if(s!=null&&r.length>=s||!g)return r;if(kn(g)&&g.scrollingElement!=null&&!r.includes(g.scrollingElement))return r.push(g.scrollingElement),r;if(!fr(g)||Ya(g)||r.includes(g))return r;const p=yt(e).getComputedStyle(g);return g!==e&&Uu(g,p)&&r.push(g),$u(g,p)?r:o(g.parentNode)}return e?o(e):r}function Ja(e){const[s]=jn(e,1);return s??null}function ki(e){return!ni||!e?null:zs(e)?e:Cn(e)?kn(e)||e===Ws(e).scrollingElement?window:fr(e)?e:null:null}function el(e){return zs(e)?e.scrollX:e.scrollLeft}function tl(e){return zs(e)?e.scrollY:e.scrollTop}function Ki(e){return{x:el(e),y:tl(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function sl(e){return!ni||!e?!1:e===document.scrollingElement}function rl(e){const s={x:0,y:0},r=sl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},g=e.scrollTop<=s.y,p=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:g,isLeft:p,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const qu={x:.2,y:.2};function Ku(e,s,r,o,g){let{top:p,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),g===void 0&&(g=qu);const{isTop:l,isBottom:d,isLeft:c,isRight:m}=rl(e),x={x:0,y:0},w={x:0,y:0},y={height:s.height*g.y,width:s.width*g.x};return!l&&p<=s.top+y.height?(x.y=ut.Backward,w.y=o*Math.abs((s.top+y.height-p)/y.height)):!d&&i>=s.bottom-y.height&&(x.y=ut.Forward,w.y=o*Math.abs((s.bottom-y.height-i)/y.height)),!m&&n>=s.right-y.width?(x.x=ut.Forward,w.x=o*Math.abs((s.right-y.width-n)/y.width)):!c&&v<=s.left+y.width&&(x.x=ut.Backward,w.x=o*Math.abs((s.left+y.width-v)/y.width)),{direction:x,speed:w}}function Xu(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:v}=window;return{top:0,left:0,right:p,bottom:v,width:p,height:v}}const{top:s,left:r,right:o,bottom:g}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:g,width:e.clientWidth,height:e.clientHeight}}function il(e){return e.reduce((s,r)=>Ms(s,Ki(r)),Ot)}function Yu(e){return e.reduce((s,r)=>s+el(r),0)}function Vu(e){return e.reduce((s,r)=>s+tl(r),0)}function nl(e,s){if(s===void 0&&(s=pr),!e)return;const{top:r,left:o,bottom:g,right:p}=s(e);Ja(e)&&(g<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Gu=[["x",["left","right"],Yu],["y",["top","bottom"],Vu]];class Nn{constructor(s,r){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 o=jn(r),g=il(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[p,v,n]of Gu)for(const i of v)Object.defineProperty(this,i,{get:()=>{const l=n(o),d=g[p]-l;return this.rect[i]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class er{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var g;(g=this.target)==null||g.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Qu(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Ws(e)}function Ei(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Rt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rt||(Rt={}));function co(e){e.preventDefault()}function Zu(e){e.stopPropagation()}var We;(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"})(We||(We={}));const ol={start:[We.Space,We.Enter],cancel:[We.Esc],end:[We.Space,We.Enter,We.Tab]},Ju=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case We.Right:return{...r,x:r.x+25};case We.Left:return{...r,x:r.x-25};case We.Down:return{...r,y:r.y+25};case We.Up:return{...r,y:r.y-25}}};class al{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new er(Ws(r)),this.windowListeners=new er(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&nl(o),r(Ot)}handleKeyDown(s){if(En(s)){const{active:r,context:o,options:g}=this.props,{keyboardCodes:p=ol,coordinateGetter:v=Ju,scrollBehavior:n="smooth"}=g,{code:i}=s;if(p.end.includes(i)){this.handleEnd(s);return}if(p.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:l}=o.current,d=l?{x:l.left,y:l.top}:Ot;this.referenceCoordinates||(this.referenceCoordinates=d);const c=v(s,{active:r,context:o.current,currentCoordinates:d});if(c){const m=Xr(c,d),x={x:0,y:0},{scrollableAncestors:w}=o.current;for(const y of w){const a=s.code,{isTop:h,isRight:u,isLeft:f,isBottom:b,maxScroll:C,minScroll:k}=rl(y),E=Xu(y),_={x:Math.min(a===We.Right?E.right-E.width/2:E.right,Math.max(a===We.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(a===We.Down?E.bottom-E.height/2:E.bottom,Math.max(a===We.Down?E.top:E.top+E.height/2,c.y))},j=a===We.Right&&!u||a===We.Left&&!f,A=a===We.Down&&!b||a===We.Up&&!h;if(j&&_.x!==c.x){const P=y.scrollLeft+m.x,T=a===We.Right&&P<=C.x||a===We.Left&&P>=k.x;if(T&&!m.y){y.scrollTo({left:P,behavior:n});return}T?x.x=y.scrollLeft-P:x.x=a===We.Right?y.scrollLeft-C.x:y.scrollLeft-k.x,x.x&&y.scrollBy({left:-x.x,behavior:n});break}else if(A&&_.y!==c.y){const P=y.scrollTop+m.y,T=a===We.Down&&P<=C.y||a===We.Up&&P>=k.y;if(T&&!m.x){y.scrollTo({top:P,behavior:n});return}T?x.y=y.scrollTop-P:x.y=a===We.Down?y.scrollTop-C.y:y.scrollTop-k.y,x.y&&y.scrollBy({top:-x.y,behavior:n});break}}this.handleMove(s,Ms(Xr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}al.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=ol,onActivation:g}=s,{active:p}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=p.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),g?.({event:e.nativeEvent}),!0)}return!1}}];function uo(e){return!!(e&&"distance"in e)}function ho(e){return!!(e&&"delay"in e)}class Rn{constructor(s,r,o){var g;o===void 0&&(o=Qu(s.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=s,this.events=r;const{event:p}=s,{target:v}=p;this.props=s,this.events=r,this.document=Ws(v),this.documentListeners=new er(this.document),this.listeners=new er(o),this.windowListeners=new er(yt(v)),this.initialCoordinates=(g=Yr(p))!=null?g:Ot,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:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,co),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,co),this.documentListeners.add(Rt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ho(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(uo(r)){this.handlePending(r);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(s,r){const{active:o,onPending:g}=this.props;g(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Rt.Click,Zu,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:g,props:p}=this,{onMove:v,options:{activationConstraint:n}}=p;if(!g)return;const i=(r=Yr(s))!=null?r:Ot,l=Xr(g,i);if(!o&&n){if(uo(n)){if(n.tolerance!=null&&Ei(l,n.tolerance))return this.handleCancel();if(Ei(l,n.distance))return this.handleStart()}if(ho(n)&&Ei(l,n.tolerance))return this.handleCancel();this.handlePending(n,l);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===We.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const eh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class An extends Rn{constructor(s){const{event:r}=s,o=Ws(r.target);super(s,eh,o)}}An.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const th={move:{name:"mousemove"},end:{name:"mouseup"}};var Xi;(function(e){e[e.RightClick=2]="RightClick"})(Xi||(Xi={}));class sh extends Rn{constructor(s){super(s,th,Ws(s.event.target))}}sh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Xi.RightClick?!1:(o?.({event:r}),!0)}}];const ji={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class rh extends Rn{constructor(s){super(s,ji)}static setup(){return window.addEventListener(ji.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(ji.move.name,s)};function s(){}}}rh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:g}=r;return g.length>1?!1:(o?.({event:r}),!0)}}];var tr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(tr||(tr={}));var Gr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gr||(Gr={}));function ih(e){let{acceleration:s,activator:r=tr.Pointer,canScroll:o,draggingRect:g,enabled:p,interval:v=5,order:n=Gr.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:d,delta:c,threshold:m}=e;const x=oh({delta:c,disabled:!p}),[w,y]=vu(),a=S.useRef({x:0,y:0}),h=S.useRef({x:0,y:0}),u=S.useMemo(()=>{switch(r){case tr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case tr.DraggableRect:return g}},[r,g,i]),f=S.useRef(null),b=S.useCallback(()=>{const k=f.current;if(!k)return;const E=a.current.x*h.current.x,_=a.current.y*h.current.y;k.scrollBy(E,_)},[]),C=S.useMemo(()=>n===Gr.TreeOrder?[...l].reverse():l,[n,l]);S.useEffect(()=>{if(!p||!l.length||!u){y();return}for(const k of C){if(o?.(k)===!1)continue;const E=l.indexOf(k),_=d[E];if(!_)continue;const{direction:j,speed:A}=Ku(k,_,u,s,m);for(const P of["x","y"])x[P][j[P]]||(A[P]=0,j[P]=0);if(A.x>0||A.y>0){y(),f.current=k,w(b,v),a.current=A,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},y()},[s,b,o,y,p,v,JSON.stringify(u),JSON.stringify(x),w,l,C,d,JSON.stringify(m)])}const nh={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function oh(e){let{delta:s,disabled:r}=e;const o=Kr(s);return mr(g=>{if(r||!o||!g)return nh;const p={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[ut.Backward]:g.x[ut.Backward]||p.x===-1,[ut.Forward]:g.x[ut.Forward]||p.x===1},y:{[ut.Backward]:g.y[ut.Backward]||p.y===-1,[ut.Forward]:g.y[ut.Forward]||p.y===1}}},[r,s,o])}function ah(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return mr(g=>{var p;return s==null?null:(p=o??g)!=null?p:null},[o,s])}function lh(e,s){return S.useMemo(()=>e.reduce((r,o)=>{const{sensor:g}=o,p=g.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...p]},[]),[e,s])}var lr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(lr||(lr={}));var Yi;(function(e){e.Optimized="optimized"})(Yi||(Yi={}));const fo=new Map;function ch(e,s){let{dragging:r,dependencies:o,config:g}=s;const[p,v]=S.useState(null),{frequency:n,measure:i,strategy:l}=g,d=S.useRef(e),c=a(),m=or(c),x=S.useCallback(function(h){h===void 0&&(h=[]),!m.current&&v(u=>u===null?h:u.concat(h.filter(f=>!u.includes(f))))},[m]),w=S.useRef(null),y=mr(h=>{if(c&&!r)return fo;if(!h||h===fo||d.current!==e||p!=null){const u=new Map;for(let f of e){if(!f)continue;if(p&&p.length>0&&!p.includes(f.id)&&f.rect.current){u.set(f.id,f.rect.current);continue}const b=f.node.current,C=b?new Nn(i(b),b):null;f.rect.current=C,C&&u.set(f.id,C)}return u}return h},[e,p,r,c,i]);return S.useEffect(()=>{d.current=e},[e]),S.useEffect(()=>{c||x()},[r,c]),S.useEffect(()=>{p&&p.length>0&&v(null)},[JSON.stringify(p)]),S.useEffect(()=>{c||typeof n!="number"||w.current!==null||(w.current=setTimeout(()=>{x(),w.current=null},n))},[n,c,x,...o]),{droppableRects:y,measureDroppableContainers:x,measuringScheduled:p!=null};function a(){switch(l){case lr.Always:return!1;case lr.BeforeDragging:return r;default:return!r}}}function Tn(e,s){return mr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function dh(e,s){return Tn(e,s)}function uh(e){let{callback:s,disabled:r}=e;const o=oi(s),g=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return S.useEffect(()=>()=>g?.disconnect(),[g]),g}function li(e){let{callback:s,disabled:r}=e;const o=oi(s),g=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return S.useEffect(()=>()=>g?.disconnect(),[g]),g}function hh(e){return new Nn(pr(e),e)}function mo(e,s,r){s===void 0&&(s=hh);const[o,g]=S.useState(null);function p(){g(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??r)!=null?l:null}const d=s(e);return JSON.stringify(i)===JSON.stringify(d)?i:d})}const v=uh({callback(i){if(e)for(const l of i){const{type:d,target:c}=l;if(d==="childList"&&c instanceof HTMLElement&&c.contains(e)){p();break}}}}),n=li({callback:p});return Gt(()=>{p(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function fh(e){const s=Tn(e);return Qa(e,s)}const po=[];function mh(e){const s=S.useRef(e),r=mr(o=>e?o&&o!==po&&e&&s.current&&e.parentNode===s.current.parentNode?o:jn(e):po,[e]);return S.useEffect(()=>{s.current=e},[e]),r}function ph(e){const[s,r]=S.useState(null),o=S.useRef(e),g=S.useCallback(p=>{const v=ki(p.target);v&&r(n=>n?(n.set(v,Ki(v)),new Map(n)):null)},[]);return S.useEffect(()=>{const p=o.current;if(e!==p){v(p);const n=e.map(i=>{const l=ki(i);return l?(l.addEventListener("scroll",g,{passive:!0}),[l,Ki(l)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(p)};function v(n){n.forEach(i=>{const l=ki(i);l?.removeEventListener("scroll",g)})}},[g,e]),S.useMemo(()=>e.length?s?Array.from(s.values()).reduce((p,v)=>Ms(p,v),Ot):il(e):Ot,[e,s])}function go(e,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.useEffect(()=>{const o=e!==Ot;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Xr(e,r.current):Ot}function gh(e){S.useEffect(()=>{if(!ni)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function vh(e,s){return S.useMemo(()=>e.reduce((r,o)=>{let{eventName:g,handler:p}=o;return r[g]=v=>{p(v,s)},r},{}),[e,s])}function ll(e){return S.useMemo(()=>e?Hu(e):null,[e])}const vo=[];function xh(e,s){s===void 0&&(s=pr);const[r]=e,o=ll(r?yt(r):null),[g,p]=S.useState(vo);function v(){p(()=>e.length?e.map(i=>sl(i)?o:new Nn(s(i),i)):vo)}const n=li({callback:v});return Gt(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),g}function cl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return fr(s)?s:e}function _h(e){let{measure:s}=e;const[r,o]=S.useState(null),g=S.useCallback(l=>{for(const{target:d}of l)if(fr(d)){o(c=>{const m=s(d);return c?{...c,width:m.width,height:m.height}:m});break}},[s]),p=li({callback:g}),v=S.useCallback(l=>{const d=cl(l);p?.disconnect(),d&&p?.observe(d),o(d?s(d):null)},[s,p]),[n,i]=qr(v);return S.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const bh=[{sensor:An,options:{}},{sensor:al,options:{}}],yh={current:{}},Or={draggable:{measure:lo},droppable:{measure:lo,strategy:lr.WhileDragging,frequency:Yi.Optimized},dragOverlay:{measure:pr}};class sr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const Sh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new sr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Or,measureDroppableContainers:Vr,windowRect:null,measuringScheduled:!1},dl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vr,draggableNodes:new Map,over:null,measureDroppableContainers:Vr},gr=S.createContext(dl),ul=S.createContext(Sh);function wh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new sr}}}function Ch(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,g=new sr(e.droppable.containers);return g.set(o,r),{...e,droppable:{...e.droppable,containers:g}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:g}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const v=new sr(e.droppable.containers);return v.set(r,{...p,disabled:g}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,g=e.droppable.containers.get(r);if(!g||o!==g.key)return e;const p=new sr(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function kh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:g}=S.useContext(gr),p=Kr(o),v=Kr(r?.id);return S.useEffect(()=>{if(!s&&!o&&p&&v!=null){if(!En(p)||document.activeElement===p.target)return;const n=g.get(v);if(!n)return;const{activatorNode:i,node:l}=n;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const d of[i.current,l.current]){if(!d)continue;const c=bu(d);if(c){c.focus();break}}})}},[o,s,g,v,p]),null}function hl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((g,p)=>p({transform:g,...o}),r):r}function Eh(e){return S.useMemo(()=>({draggable:{...Or.draggable,...e?.draggable},droppable:{...Or.droppable,...e?.droppable},dragOverlay:{...Or.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function jh(e){let{activeNode:s,measure:r,initialRect:o,config:g=!0}=e;const p=S.useRef(!1),{x:v,y:n}=typeof g=="boolean"?{x:g,y:g}:g;Gt(()=>{if(!v&&!n||!s){p.current=!1;return}if(p.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const d=r(l),c=Qa(d,o);if(v||(c.x=0),n||(c.y=0),p.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const m=Ja(l);m&&m.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const ci=S.createContext({...Ot,scaleX:1,scaleY:1});var Zt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Zt||(Zt={}));const Nh=S.memo(function(s){var r,o,g,p;let{id:v,accessibility:n,autoScroll:i=!0,children:l,sensors:d=bh,collisionDetection:c=Iu,measuring:m,modifiers:x,...w}=s;const y=S.useReducer(Ch,void 0,wh),[a,h]=y,[u,f]=Eu(),[b,C]=S.useState(Zt.Uninitialized),k=b===Zt.Initialized,{draggable:{active:E,nodes:_,translate:j},droppable:{containers:A}}=a,P=E!=null?_.get(E):null,T=S.useRef({initial:null,translated:null}),D=S.useMemo(()=>{var me;return E!=null?{id:E,data:(me=P?.data)!=null?me:yh,rect:T}:null},[E,P]),W=S.useRef(null),[I,B]=S.useState(null),[F,R]=S.useState(null),M=or(w,Object.values(w)),L=ai("DndDescribedBy",v),O=S.useMemo(()=>A.getEnabled(),[A]),U=Eh(m),{droppableRects:Y,measureDroppableContainers:z,measuringScheduled:$}=ch(O,{dragging:k,dependencies:[j.x,j.y],config:U.droppable}),q=ah(_,E),N=S.useMemo(()=>F?Yr(F):null,[F]),H=ye(),X=dh(q,U.draggable.measure);jh({activeNode:E!=null?_.get(E):null,config:H.layoutShiftCompensation,initialRect:X,measure:U.draggable.measure});const K=mo(q,U.draggable.measure,X),ne=mo(q?q.parentElement:null),te=S.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:_,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),he=A.getNodeFor((r=te.current.over)==null?void 0:r.id),le=_h({measure:U.dragOverlay.measure}),G=(o=le.nodeRef.current)!=null?o:q,pe=k?(g=le.rect)!=null?g:K:null,ie=!!(le.nodeRef.current&&le.rect),Ae=fh(ie?null:K),at=ll(G?yt(G):null),Xe=mh(k?he??q:null),_e=xh(Xe),Ie=hl(x,{transform:{x:j.x-Ae.x,y:j.y-Ae.y,scaleX:1,scaleY:1},activatorEvent:F,active:D,activeNodeRect:K,containerNodeRect:ne,draggingNodeRect:pe,over:te.current.over,overlayNodeRect:le.rect,scrollableAncestors:Xe,scrollableAncestorRects:_e,windowRect:at}),Pe=N?Ms(N,j):null,$e=ph(Xe),Oe=go($e),Ve=go($e,[K]),Ze=Ms(Ie,Oe),Me=pe?Fu(pe,Ie):null,Re=D&&Me?c({active:D,collisionRect:Me,droppableRects:Y,droppableContainers:O,pointerCoordinates:Pe}):null,ve=Pu(Re,"id"),[Fe,ge]=S.useState(null),lt=ie?Ie:Ms(Ie,Ve),Je=Ou(lt,(p=Fe?.rect)!=null?p:null,K),Et=S.useRef(null),J=S.useCallback((me,Se)=>{let{sensor:we,options:xe}=Se;if(W.current==null)return;const ke=_.get(W.current);if(!ke)return;const De=me.nativeEvent,Ee=new we({active:W.current,activeNode:ke,event:De,options:xe,context:te,onAbort(Ge){if(!_.get(Ge))return;const{onDragAbort:et}=M.current,it={id:Ge};et?.(it),u({type:"onDragAbort",event:it})},onPending(Ge,ze,et,it){if(!_.get(Ge))return;const{onDragPending:vt}=M.current,st={id:Ge,constraint:ze,initialCoordinates:et,offset:it};vt?.(st),u({type:"onDragPending",event:st})},onStart(Ge){const ze=W.current;if(ze==null)return;const et=_.get(ze);if(!et)return;const{onDragStart:it}=M.current,Dt={activatorEvent:De,active:{id:ze,data:et.data,rect:T}};ps.unstable_batchedUpdates(()=>{it?.(Dt),C(Zt.Initializing),h({type:ot.DragStart,initialCoordinates:Ge,active:ze}),u({type:"onDragStart",event:Dt}),B(Et.current),R(De)})},onMove(Ge){h({type:ot.DragMove,coordinates:Ge})},onEnd:Ye(ot.DragEnd),onCancel:Ye(ot.DragCancel)});Et.current=Ee;function Ye(Ge){return async function(){const{active:et,collisions:it,over:Dt,scrollAdjustedTranslate:vt}=te.current;let st=null;if(et&&vt){const{cancelDrop:xt}=M.current;st={activatorEvent:De,active:et,collisions:it,delta:vt,over:Dt},Ge===ot.DragEnd&&typeof xt=="function"&&await Promise.resolve(xt(st))&&(Ge=ot.DragCancel)}W.current=null,ps.unstable_batchedUpdates(()=>{h({type:Ge}),C(Zt.Uninitialized),ge(null),B(null),R(null),Et.current=null;const xt=Ge===ot.DragEnd?"onDragEnd":"onDragCancel";if(st){const Ct=M.current[xt];Ct?.(st),u({type:xt,event:st})}})}}},[_]),ue=S.useCallback((me,Se)=>(we,xe)=>{const ke=we.nativeEvent,De=_.get(xe);if(W.current!==null||!De||ke.dndKit||ke.defaultPrevented)return;const Ee={active:De};me(we,Se.options,Ee)===!0&&(ke.dndKit={capturedBy:Se.sensor},W.current=xe,J(we,Se))},[_,J]),V=lh(d,ue);gh(d),Gt(()=>{K&&b===Zt.Initializing&&C(Zt.Initialized)},[K,b]),S.useEffect(()=>{const{onDragMove:me}=M.current,{active:Se,activatorEvent:we,collisions:xe,over:ke}=te.current;if(!Se||!we)return;const De={active:Se,activatorEvent:we,collisions:xe,delta:{x:Ze.x,y:Ze.y},over:ke};ps.unstable_batchedUpdates(()=>{me?.(De),u({type:"onDragMove",event:De})})},[Ze.x,Ze.y]),S.useEffect(()=>{const{active:me,activatorEvent:Se,collisions:we,droppableContainers:xe,scrollAdjustedTranslate:ke}=te.current;if(!me||W.current==null||!Se||!ke)return;const{onDragOver:De}=M.current,Ee=xe.get(ve),Ye=Ee&&Ee.rect.current?{id:Ee.id,rect:Ee.rect.current,data:Ee.data,disabled:Ee.disabled}:null,Ge={active:me,activatorEvent:Se,collisions:we,delta:{x:ke.x,y:ke.y},over:Ye};ps.unstable_batchedUpdates(()=>{ge(Ye),De?.(Ge),u({type:"onDragOver",event:Ge})})},[ve]),Gt(()=>{te.current={activatorEvent:F,active:D,activeNode:q,collisionRect:Me,collisions:Re,droppableRects:Y,draggableNodes:_,draggingNode:G,draggingNodeRect:pe,droppableContainers:A,over:Fe,scrollableAncestors:Xe,scrollAdjustedTranslate:Ze},T.current={initial:pe,translated:Me}},[D,q,Re,Me,_,G,pe,Y,A,Fe,Xe,Ze]),ih({...H,delta:j,draggingRect:Me,pointerCoordinates:Pe,scrollableAncestors:Xe,scrollableAncestorRects:_e});const Z=S.useMemo(()=>({active:D,activeNode:q,activeNodeRect:K,activatorEvent:F,collisions:Re,containerNodeRect:ne,dragOverlay:le,draggableNodes:_,droppableContainers:A,droppableRects:Y,over:Fe,measureDroppableContainers:z,scrollableAncestors:Xe,scrollableAncestorRects:_e,measuringConfiguration:U,measuringScheduled:$,windowRect:at}),[D,q,K,F,Re,ne,le,_,A,Y,Fe,z,Xe,_e,U,$,at]),re=S.useMemo(()=>({activatorEvent:F,activators:V,active:D,activeNodeRect:K,ariaDescribedById:{draggable:L},dispatch:h,draggableNodes:_,over:Fe,measureDroppableContainers:z}),[F,V,D,K,h,L,_,Fe,z]);return ae.createElement(Ga.Provider,{value:f},ae.createElement(gr.Provider,{value:re},ae.createElement(ul.Provider,{value:Z},ae.createElement(ci.Provider,{value:Je},l)),ae.createElement(kh,{disabled:n?.restoreFocus===!1})),ae.createElement(Ru,{...n,hiddenTextDescribedById:L}));function ye(){const me=I?.autoScrollEnabled===!1,Se=typeof i=="object"?i.enabled===!1:i===!1,we=k&&!me&&!Se;return typeof i=="object"?{...i,enabled:we}:{enabled:we}}}),Rh=S.createContext(null),xo="button",Ah="Draggable";function Th(e){let{id:s,data:r,disabled:o=!1,attributes:g}=e;const p=ai(Ah),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:d,draggableNodes:c,over:m}=S.useContext(gr),{role:x=xo,roleDescription:w="draggable",tabIndex:y=0}=g??{},a=i?.id===s,h=S.useContext(a?ci:Rh),[u,f]=qr(),[b,C]=qr(),k=vh(v,s),E=or(r);Gt(()=>(c.set(s,{id:s,key:p,node:u,activatorNode:b,data:E}),()=>{const j=c.get(s);j&&j.key===p&&c.delete(s)}),[c,s]);const _=S.useMemo(()=>({role:x,tabIndex:y,"aria-disabled":o,"aria-pressed":a&&x===xo?!0:void 0,"aria-roledescription":w,"aria-describedby":d.draggable}),[o,x,y,a,w,d.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:_,isDragging:a,listeners:o?void 0:k,node:u,over:m,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function Mh(){return S.useContext(ul)}const Dh="Droppable",Ph={timeout:25};function Lh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:g}=e;const p=ai(Dh),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=S.useContext(gr),d=S.useRef({disabled:r}),c=S.useRef(!1),m=S.useRef(null),x=S.useRef(null),{disabled:w,updateMeasurementsFor:y,timeout:a}={...Ph,...g},h=or(y??o),u=S.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),f=li({callback:u,disabled:w||!v}),b=S.useCallback((_,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),_&&f.observe(_))},[f]),[C,k]=qr(b),E=or(s);return S.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),S.useEffect(()=>(n({type:ot.RegisterDroppable,element:{id:o,key:p,disabled:r,node:C,rect:m,data:E}}),()=>n({type:ot.UnregisterDroppable,key:p,id:o})),[o]),S.useEffect(()=>{r!==d.current.disabled&&(n({type:ot.SetDroppableDisabled,id:o,key:p,disabled:r}),d.current.disabled=r)},[o,p,r,n]),{active:v,rect:m,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function Ih(e){let{animation:s,children:r}=e;const[o,g]=S.useState(null),[p,v]=S.useState(null),n=Kr(r);return!r&&!o&&n&&g(n),Gt(()=>{if(!p)return;const i=o?.key,l=o?.props.id;if(i==null||l==null){g(null);return}Promise.resolve(s(l,p)).then(()=>{g(null)})},[s,o,p]),ae.createElement(ae.Fragment,null,r,o?S.cloneElement(o,{ref:v}):null)}const Oh={x:0,y:0,scaleX:1,scaleY:1};function Bh(e){let{children:s}=e;return ae.createElement(gr.Provider,{value:dl},ae.createElement(ci.Provider,{value:Oh},s))}const Fh={position:"fixed",touchAction:"none"},zh=e=>En(e)?"transform 250ms ease":void 0,Wh=S.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:g,children:p,className:v,rect:n,style:i,transform:l,transition:d=zh}=e;if(!n)return null;const c=g?l:{...l,scaleX:1,scaleY:1},m={...Fh,width:n.width,height:n.height,top:n.top,left:n.left,transform:ar.Transform.toString(c),transformOrigin:g&&o?Mu(o,n):void 0,transition:typeof d=="function"?d(o):d,...i};return ae.createElement(r,{className:v,style:m,ref:s},p)}),Hh=e=>s=>{let{active:r,dragOverlay:o}=s;const g={},{styles:p,className:v}=e;if(p!=null&&p.active)for(const[n,i]of Object.entries(p.active))i!==void 0&&(g[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(p!=null&&p.dragOverlay)for(const[n,i]of Object.entries(p.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,l]of Object.entries(g))r.node.style.setProperty(i,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},$h=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:ar.Transform.toString(s)},{transform:ar.Transform.toString(r)}]},Uh={duration:250,easing:"ease",keyframes:$h,sideEffects:Hh({styles:{active:{opacity:"0"}}})};function qh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:g}=e;return oi((p,v)=>{if(s===null)return;const n=r.get(p);if(!n)return;const i=n.node.current;if(!i)return;const l=cl(v);if(!l)return;const{transform:d}=yt(v).getComputedStyle(v),c=Za(d);if(!c)return;const m=typeof s=="function"?s:Kh(s);return nl(i,g.draggable.measure),m({active:{id:p,data:n.data,node:i,rect:g.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:g.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:g,transform:c})})}function Kh(e){const{duration:s,easing:r,sideEffects:o,keyframes:g}={...Uh,...e};return p=>{let{active:v,dragOverlay:n,transform:i,...l}=p;if(!s)return;const d={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},c={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},m={x:i.x-d.x,y:i.y-d.y,...c},x=g({...l,active:v,dragOverlay:n,transform:{initial:i,final:m}}),[w]=x,y=x[x.length-1];if(JSON.stringify(w)===JSON.stringify(y))return;const a=o?.({active:v,dragOverlay:n,...l}),h=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(u=>{h.onfinish=()=>{a?.(),u()}})}}let _o=0;function Xh(e){return S.useMemo(()=>{if(e!=null)return _o++,_o},[e])}const Yh=ae.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:g,transition:p,modifiers:v,wrapperElement:n="div",className:i,zIndex:l=999}=e;const{activatorEvent:d,active:c,activeNodeRect:m,containerNodeRect:x,draggableNodes:w,droppableContainers:y,dragOverlay:a,over:h,measuringConfiguration:u,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:C}=Mh(),k=S.useContext(ci),E=Xh(c?.id),_=hl(v,{activatorEvent:d,active:c,activeNodeRect:m,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:C}),j=Tn(m),A=qh({config:o,draggableNodes:w,droppableContainers:y,measuringConfiguration:u}),P=j?a.setRef:void 0;return ae.createElement(Bh,null,ae.createElement(Ih,{animation:A},c&&E?ae.createElement(Wh,{key:E,id:c.id,ref:P,as:n,activatorEvent:d,adjustScale:s,className:i,transition:p,rect:j,style:{zIndex:l,...g},transform:_},r):null))}),fl=768;function Vh(e){const s=window.matchMedia(`(max-width: ${fl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Gh(){return window.innerWidth<fl}function Qh(){return!1}function ml(){return S.useSyncExternalStore(Vh,Gh,Qh)}const Zh=1500,Jh=2e3,ef=5e3;function pl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?Zh:!1}function tf(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?Jh:!1}function sf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?ef:!1}function Mn(e){return Bt({queryKey:de.workspaces.list(e),queryFn:()=>Ce.get(`/tasks/${e}/workspaces`),enabled:!!e})}function gl(e){const s=bt();return Ft({mutationFn:r=>Ce.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:de.workspaces.list(e)}),s.invalidateQueries({queryKey:de.tasks.all})}})}function vl(){const e=bt();return Ft({mutationFn:({id:s,commitMessage:r})=>Ce.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.git.all})},onError:()=>{e.invalidateQueries({queryKey:de.git.all})}})}function rf(){const e=bt();return Ft({mutationFn:s=>Ce.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function Dn(){return Ft({mutationFn:({workspaceId:e,editorType:s})=>Ce.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Pn(e,s={}){const r=_s(g=>g.visibleContext),o=tf(e,r);return Bt({queryKey:de.workspaces.gitStatus(e),queryFn:()=>Ce.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function xl(){const e=bt();return Ft({mutationFn:s=>Ce.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function Ln(){const e=bt();return Ft({mutationFn:s=>Ce.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function nf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(v=>v.status===dt.RUNNING||v.status===dt.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function In({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:g,workspaces:p,isLoading:v}){const{t:n}=ce(),{data:i,isLoading:l}=Mn(p===void 0&&e?o:""),d=p??i,c=p===void 0&&e&&l,m=S.useMemo(()=>nf(d,n),[d,n]);return t.jsx(mn,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:g})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):m.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:m.map((x,w)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:x})]},w))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const be={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Vi={[be.Review]:{label:"Review",icon:Ta,iconClass:"text-warning",accentClass:"text-warning"},[be.Running]:{label:"Running",icon:Aa,iconClass:"text-info",accentClass:"text-info"},[be.Pending]:{label:"Pending",icon:Ra,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[be.Done]:{label:"Done",icon:Na,iconClass:"text-success/80",accentClass:"text-success"},[be.Cancelled]:{label:"Cancelled",icon:ja,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},of=[be.Review,be.Running,be.Pending,be.Done,be.Cancelled],_l=S.createContext(null),af=3e4;function lf(e=af){const[,s]=S.useState(0);S.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function cf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?gt("{count}s ago",{count:s}):s<3600?gt("{count}m ago",{count:Math.floor(s/60)}):s<86400?gt("{count}h ago",{count:Math.floor(s/3600)}):gt("{count}d ago",{count:Math.floor(s/86400)})}function df({task:e,status:s,isSelected:r,project:o,onSelectTask:g,onTaskStatusChange:p,onDeleteTask:v,disableDrag:n}){const{t:i}=ce(),l=S.useContext(_l),d=S.useRef(null),c=!!e.projectArchivedAt,m=c||!!n,{attributes:x,listeners:w,setNodeRef:y,isDragging:a}=Th({id:e.id,data:{task:e,fromStatus:s},disabled:m}),h=S.useCallback(T=>{d.current=T,y(T),l&&(T?l.registry.set(e.id,T):l.registry.delete(e.id))},[y,l,e.id]);S.useEffect(()=>()=>{l?.registry.delete(e.id)},[e.id,l]);const[u,f]=S.useState(null),[b,C]=S.useState(!1),k=S.useRef(null),E=S.useRef(null),_=S.useCallback(T=>{c||!p&&!v||(T.preventDefault(),f({x:T.clientX,y:T.clientY}))},[c,p,v]),j=S.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),A=S.useCallback(T=>{if(!n||c||!p&&!v)return;const D=T.touches[0];if(!D)return;const{clientX:W,clientY:I}=D;E.current=setTimeout(()=>{E.current=null,f({x:W,y:I})},500)},[n,c,p,v]);S.useEffect(()=>{if(!u)return;const T=D=>{k.current&&!k.current.contains(D.target)&&f(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[u]);const P=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:h,onClick:()=>g(e.id),onContextMenu:_,onTouchStart:A,onTouchEnd:j,onTouchMove:j,title:P,"aria-label":P?`${e.title} — ${P}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
7
7
|
${a?"opacity-30":""}
|
|
8
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,...m?{}:w,...m?{}:x,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:D}=
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${a&&i?"border border-dashed border-border mx-2":""}`,children:a?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:x("No tasks")}):r.map(
|
|
12
|
-
${
|
|
13
|
-
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:m(R?"New Task":"Deleted projects are read-only"),children:[t.jsx(
|
|
8
|
+
${r?"bg-accent":"hover:bg-accent/50"}`,...m?{}:w,...m?{}:x,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:D}=Vi[s];return t.jsx(T,{className:`${D} ${s===be.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:cf(e.updatedAt)}),o&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${o.color.replace("text-","bg-")}`})]}),u&&t.jsxs("div",{ref:k,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:u.x,top:u.y},children:[p&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:i("Move to")}),of.filter(T=>T!==s).map(T=>{const{icon:D,label:W,accentClass:I}=Vi[T];return t.jsxs("button",{onClick:()=>{p(e.id,T),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(D,{className:`w-3.5 h-3.5 ${I}`}),t.jsx("span",{className:"text-foreground/80",children:i(W)})]},T)})]}),v&&t.jsxs(t.Fragment,{children:[p&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{C(!0),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:i("Delete Task")})]})]})]}),t.jsx(In,{isOpen:b,onClose:()=>C(!1),onConfirm:()=>{v?.(e.id),C(!1)},taskId:e.id,taskTitle:e.title})]})}const uf=S.memo(function({title:s,tasks:r,status:o,defaultOpen:g,selectedTaskId:p,onSelectTask:v,projects:n,isDragging:i,dragFromStatus:l,onTaskStatusChange:d,onDeleteTask:c,disableDrag:m}){const{t:x}=ce(),[w,y]=S.useState(g);lf();const a=r.length===0,h=i&&l===o,u=i&&l!==o,{setNodeRef:f,isOver:b}=Lh({id:`group-${o}`,data:{status:o}}),C=o===be.Review,k=x(s),E=i?h&&(w||!0):w;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!i&&y(_=>!_),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:k}),C&&!a?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:E?t.jsx(wt,{size:12}):t.jsx(Mt,{size:12})})]}),u&&t.jsx("div",{ref:f,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
|
+
${b?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:b?x("Drop into {title}",{title:k}):x("Drop here")})}),E&&!u&&t.jsx("div",{ref:h?void 0:f,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
10
|
+
${b&&!h?"bg-info/10 ring-1 ring-info/30":""}
|
|
11
|
+
${a&&i?"border border-dashed border-border mx-2":""}`,children:a?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:x("No tasks")}):r.map(_=>{const j=p===_.id,A=_.projectId?n.find(P=>P.id===_.projectId):void 0;return t.jsx(df,{task:_,status:o,isSelected:j,project:A,onSelectTask:v,onTaskStatusChange:_.projectArchivedAt?void 0:d,onDeleteTask:_.projectArchivedAt?void 0:c,disableDrag:m},_.id)})})]})}),hf=12,ff=50;function mf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:g}){const{t:p}=ce(),[v,n]=S.useState(""),[i,l]=S.useState(0),d=S.useRef(null);S.useEffect(()=>{e&&(n(""),l(0))},[e]);const c=S.useMemo(()=>{const w=v.trim().toLowerCase();return w?r.filter(y=>y.title.toLowerCase().includes(w)).slice(0,ff):r.slice(0,hf)},[r,v]);S.useEffect(()=>{l(0)},[v]),S.useEffect(()=>{d.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const m=S.useCallback(w=>{g(w),s()},[g,s]),x=S.useCallback(w=>{if(w.key==="Escape")w.preventDefault(),s();else if(w.key==="ArrowDown")w.preventDefault(),l(y=>Math.min(y+1,c.length-1));else if(w.key==="ArrowUp")w.preventDefault(),l(y=>Math.max(y-1,0));else if(w.key==="Enter"&&!w.nativeEvent.isComposing){w.preventDefault();const y=c[i];y&&m(y.id)}},[s,c,i,m]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.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-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(pn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:w=>n(w.target.value),onKeyDown:x,placeholder:p("Search tasks..."),"aria-label":p("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:p("Recent tasks")}),t.jsx("div",{ref:d,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((w,y)=>{const a=o.find(f=>f.id===w.projectId),{icon:h,iconClass:u}=Vi[w.status];return t.jsxs("button",{onClick:()=>m(w.id),onMouseEnter:()=>l(y),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
12
|
+
${y===i?"bg-accent":""}`,children:[t.jsx(h,{className:`${u} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:w.title,children:w.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},w.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:p("No matching tasks")})]})]}):null}const pf=260,gf=220;function vf(e){const s={[be.Review]:[],[be.Running]:[],[be.Pending]:[],[be.Done]:[],[be.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const xf=[{status:be.Review,title:"Review",defaultOpen:!0},{status:be.Running,title:"Running",defaultOpen:!0},{status:be.Pending,title:"Pending",defaultOpen:!1},{status:be.Done,title:"Done",defaultOpen:!1},{status:be.Cancelled,title:"Cancelled",defaultOpen:!1}];function bo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:g,setFilterProjectId:p,width:v=320,onCreateTask:n,onCreateProject:i,isCreateActive:l,onTaskStatusChange:d,onDeleteTask:c}){const{t:m}=ce(),{preserveDesktopSearch:x}=ga(),w=ml(),[y,a]=S.useState(null),[h,u]=S.useState(null),[f,b]=S.useState(!1),C=S.useRef(new Map),k=S.useRef(new Set),E=S.useRef(new Map),_=S.useMemo(()=>({registry:C.current}),[]),j=S.useCallback(L=>{L.remove(),k.current.delete(L)},[]),A=g?e.filter(L=>L.projectId===g):e,P=S.useCallback((L,O)=>{const U=document.querySelector(`[data-task-group-status="${L}"]`);if(!U)return null;const z=(U.querySelector("button")??U).getBoundingClientRect();return z.width===0||z.height===0?null:new DOMRect(z.left+8,z.bottom+4,O.width,O.height)},[]),T=S.useCallback((L,O,U,Y=!1)=>{const z=document.createElement("div");z.setAttribute("aria-hidden","true"),z.innerHTML=U;const $=z.firstElementChild;$&&($.style.cssText="",$.className=$.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),$.style.pointerEvents="none",$.style.width=`${L.width}px`,$.style.height=`${L.height}px`,$.style.margin="0",$.style.backgroundColor="var(--sidebar-accent)",$.style.borderRadius="0.375rem",$.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",$.style.opacity="0.96",$.style.transition="none",$.setAttribute("tabindex","-1")),Object.assign(z.style,{position:"fixed",left:`${L.left}px`,top:`${L.top}px`,width:`${L.width}px`,height:`${L.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(z),k.current.add(z);const q=O.left-L.left,N=O.top-L.top;z.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${q}px, ${N}px)`,opacity:Y?.12:.96,offset:1}],{duration:Y?gf:pf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>j(z),()=>j(z))},[j]);S.useLayoutEffect(()=>{const L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,O=new Map;for(const U of A){const Y=C.current.get(U.id);if(!Y)continue;const z={status:U.status,rect:Y.getBoundingClientRect(),html:Y.outerHTML};if(O.set(U.id,z),L)continue;const $=E.current.get(U.id);if(!$||$.status===U.status)continue;const q=z.rect.left-$.rect.left,N=z.rect.top-$.rect.top;Math.abs(q)<1&&Math.abs(N)<1||T($.rect,z.rect,$.html)}if(!L)for(const[U,Y]of E.current){if(O.has(U))continue;const z=A.find(q=>q.id===U);if(!z||z.status===Y.status)continue;const $=P(z.status,Y.rect);$&&T(Y.rect,$,Y.html,!0)}E.current=O},[A,T,P]),S.useEffect(()=>()=>{for(const L of k.current)L.remove();k.current.clear()},[]);const D=Tu(Au(An,{activationConstraint:{distance:8}})),W=S.useCallback(L=>{const O=L.active.data.current?.task,U=L.active.data.current?.fromStatus;O&&a(O),U&&u(U)},[]),I=S.useCallback(L=>{a(null),u(null);const{active:O,over:U}=L;if(!U)return;const Y=O.data.current?.task,z=O.data.current?.fromStatus,$=U.data.current?.status;!Y||!z||!$||Y.projectArchivedAt||z!==$&&d?.(Y.id,$)},[d]),R=!!!(g?s.find(L=>L.id===g)??null:null)?.archivedAt,M=vf(A);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:m("New Project"),children:[t.jsx(wd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!R,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
|
|
13
|
+
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:m(R?"New Task":"Deleted projects are read-only"),children:[t.jsx(xd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("New Task")})]}),t.jsxs("button",{onClick:()=>b(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:m("Search"),children:[t.jsx(pn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("Search")})]}),t.jsxs(Yc,{to:x("/conversations"),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:m("对话"),children:[t.jsx(ti,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("对话")})]})]}),A.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Ps,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:m("No tasks")}),R&&n?t.jsx("button",{onClick:n,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:m("New Task")}):null]}):t.jsx(_l.Provider,{value:_,children:t.jsxs(Nh,{sensors:D,onDragStart:W,onDragEnd:I,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:xf.map(({status:L,title:O,defaultOpen:U})=>t.jsx(uf,{title:O,tasks:M[L],status:L,defaultOpen:U,selectedTaskId:r,onSelectTask:o,projects:s,isDragging:y!==null,dragFromStatus:h,onTaskStatusChange:d,onDeleteTask:c,disableDrag:w},L))}),t.jsx(Yh,{dropAnimation:null,children:y?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:y.title,children:y.title})}):null})]})}),A.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:m("{count} tasks",{count:A.length})}),g?t.jsx("button",{onClick:()=>p(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:m("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:m("{count} tasks",{count:0})})}),t.jsx(mf,{isOpen:f,onClose:()=>b(!1),tasks:A,projects:s,onSelectTask:o})]})}const _f=10,bf=24,bl=_f*bf,yf=8;function Sf(e,s=bl){return e>s+yf}function wf(e,s){return e.includes(s)?e:[...e,s]}function Cf(e,s){return e.filter(r=>r!==s)}function kf(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const di=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function yo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Ef(e,s=[],r=[]){const o=new Set(r.filter(p=>di.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...s.filter(p=>p.status==="PENDING_APPROVAL").filter(p=>!o.has(p.id)).map(p=>({kind:"pendingApproval",key:`pending-approval:${p.id}`,sortTime:p.updatedAt??p.createdAt,order:1,request:p}))].sort((p,v)=>{const n=yo(p.sortTime)-yo(v.sortTime);return n!==0?n:p.order!==v.order?p.order-v.order:p.key.localeCompare(v.key)})}function jf(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function Nf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Rf(e,s){const r=e.reduce((g,p)=>(g[p.status]=(g[p.status]??0)+1,g),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([g,p])=>{const v=r[g];return v?`${v} ${s(p)}`:null}).filter(g=>!!g).join(" · ")}function Af(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Tf({status:e}){const{t:s}=ce();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(jf(e))})}function Mf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:g,isStopPending:p,stoppingMemberId:v,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:l}=ce(),[d,c]=S.useState(Af),m=S.useMemo(()=>e.filter(w=>di.has(w.status)).sort((w,y)=>Date.parse(y.updatedAt??y.createdAt??"")-Date.parse(w.updatedAt??w.createdAt??"")),[e]);if(m.length===0)return null;const x=Rf(m,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(w=>!w),"aria-expanded":d,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:x})]}),d?t.jsx(wt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Ha,{size:15,className:"shrink-0 text-neutral-400"})]}),d&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:m.map(w=>{const y=s.get(w.memberId),a=r.get(w.workRequestId),h=!!(w.sessionId&&o),u=!!y,f=n===w.id,b=p&&v===w.memberId,C=a?.instruction??w.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:se("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>w.sessionId&&o?.(w.sessionId),onKeyDown:k=>{!h||!w.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(w.sessionId))},children:[t.jsx($t,{name:y?.name??l("Agent"),avatar:y?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:y?.name??l("Agent")}),t.jsx("span",{className:se("shrink-0",Nf(w.status)),children:t.jsx(Tf,{status:w.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),w.sessionId&&o?.(w.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:l("View log"),"aria-label":`${l("View log")} ${y?.name??l("Agent")}`,children:t.jsx(qi,{size:13})}),u&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(w.id)},onKeyDown:k=>k.stopPropagation(),disabled:b,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:l("Stop"),"aria-label":`${l("Stop")} ${y?.name??l("Agent")}`,children:t.jsx(Ds,{size:12})})]}),u&&f&&y&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:l("Stop running work?")}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>g(y.id,!1),children:[t.jsx(Ds,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop only")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:b,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>g(y.id,!0),children:[t.jsx(qa,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop + clear queue")})]})]})]},w.id)})})]})}const Gi=dr(),Df=240;let So=0;function Pf(e,s){return So+=1,{id:`pending-room-message-${Date.now()}-${So}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function yl(e){return"pendingStatus"in e}function Lf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function If(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Qi(e,s){if(s.length===0)return e;const r=new Set(s.map(If));return e.split(`
|
|
14
14
|
`).map(o=>{const g=o.match(/^\s*/)?.[0]??"",p=o.trimStart();for(const v of r){if(p===v)return null;if(p.startsWith(`${v} `)||p.startsWith(`${v} `))return`${g}${p.slice(v.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
|
-
`).trim()}function
|
|
17
|
+
`).trim()}function Of(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zi(e,s){return e instanceof Error?e.message:s}function Bf(e,s=Df){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Ff(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function zf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(g=>g.toLowerCase().includes(r)):!0}function wo(e){return e.membershipStatus!=="REMOVED"}function Wf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Hf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function $f(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const g=r.map(v=>Wf(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(g.length===0)return o;const p=g.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${p}`:p}function Uf(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function qf({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:g}){const p=hd(e),v=S.useMemo(()=>fd({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:g}),[g,o,r]);return t.jsx("div",{className:se("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(fn,{components:v,plugins:p,controls:p?md:void 0,children:e})})}function Kf({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const g=s.filter(v=>v.mimeType.startsWith("image/")),p=new Map(g.map((v,n)=>[v.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const n=`${Gi}${v.url}`;if(v.mimeType.startsWith("image/")){const l=p.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(g,l),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:n,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(Ca,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:Lf(v.sizeBytes)})]}),t.jsx(ln,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Xf({message:e,content:s,attachmentIds:r,isUser:o,tone:g,onOpenImage:p,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i}){const l=S.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:d=[],isLoading:c}=ud(l),m=d.length>0?Qi(s,d):s;return t.jsxs(t.Fragment,{children:[m.trim()&&t.jsx(Gf,{message:e,content:m,attachments:d,isUser:o,tone:g,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i}),t.jsx(Kf,{hasAttachmentIds:l.length>0,attachments:d,isLoading:c,onOpenImage:p})]})}function Yf({images:e,index:s,onClose:r,onSelect:o}){const g=e[s];if(!g)return null;const p=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Yt,{size:20})}),p&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(Ld,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${Gi}${g.url}`,alt:g.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:g.originalName}),t.jsxs("a",{href:`${Gi}${g.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(ln,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Mt,{size:24,"aria-hidden":!0})})]})}function Vf({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const p=[e.trim(),s].filter(Boolean).join(`
|
|
18
18
|
|
|
19
|
-
`);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function qf({message:e,content:s,attachments:r,isUser:o,tone:g=o?"user":"agent",workingDir:p,onOpenWorkspaceFile:v,onOpenPreviewUrl:n}){const{t:i}=de(),l=S.useId(),d=S.useRef(null),[c,m]=S.useState(null),[x,w]=S.useState(!1),[_,a]=S.useState(null),h=Yc(e.teamRunId,e.id,!1),u=h.data?.content,f=u?Gi(u,r):void 0,C=!!(f&&f!==s)?f:s,k=!!(e.isTruncated&&!xl(e)),E=c?.messageId===e.id&&c.content===C&&c.expanded,b=S.useCallback(()=>{const D=d.current;D&&w(vf(D.scrollHeight))},[]);S.useLayoutEffect(()=>{b();const D=d.current;if(!D)return;const F=window.requestAnimationFrame(b),I=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return I?.observe(D),window.addEventListener("resize",b),()=>{window.cancelAnimationFrame(F),I?.disconnect(),window.removeEventListener("resize",b)}},[C,b]);const j=S.useCallback(async()=>{if(a(null),E){m({messageId:e.id,content:C,expanded:!1});return}if(k&&!u){const D=await h.refetch();if(D.error){a(Qi(D.error,i("Failed to load full message")));return}const F=D.data?.content?Gi(D.data.content,r):C;m({messageId:e.id,content:F,expanded:!0});return}m({messageId:e.id,content:C,expanded:!0})},[r,k,u,h,E,e.id,C,i]),A=(x||k)&&!E,L=x||k,T=h.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:l,ref:d,onLoadCapture:b,className:se("relative transition-[max-height] duration-200 ease-out",A?"overflow-hidden":""),style:A?{maxHeight:vl}:void 0,children:[t.jsx(zf,{content:C,isUser:o,workingDir:p,onOpenWorkspaceFile:v,onOpenPreviewUrl:n}),A&&t.jsx("div",{className:se("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",g==="system"?"to-amber-50":g==="user"?"to-neutral-900":"to-neutral-100")})]}),L&&t.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":l,"aria-label":i(E?"Collapse message":"Expand full message"),disabled:T,onClick:()=>{j()},className:se("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",g==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":g==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",T?"cursor-wait opacity-70":""),children:[E?t.jsx(Fa,{size:13}):t.jsx(Ct,{size:13}),t.jsx("span",{children:i(T?"Loading":E?"Collapse message":"Expand full message")})]}),_&&t.jsx("div",{className:se("mt-1 text-xs",g==="user"?"text-red-200":"text-red-600"),children:_})]})}function _l({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:g,children:p,headerAddon:v,bubbleClassName:n,isPending:i}){return g?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:p})}):t.jsxs("div",{className:se("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Ht,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:se("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:se("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Ns,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Mf(r)}),v]}),t.jsx("div",{className:se("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:p})]}),o&&t.jsx(Ht,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Kf({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(ti,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Xf({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:g,displayContent:p,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l,previewWorkspaceId:d}){const{t:c}=de(),m=e.senderType==="user",x=e.senderType==="system",w=xl(e)?e.pendingStatus:null,_=e.mentions??[],a=e.workRequestIds?.length??0,h=e.visibility==="PRIVATE",u=S.useCallback(C=>{l?.(C,d)},[l,d]),f=h?Of(e,g):[],y=t.jsxs(t.Fragment,{children:[!m&&!x&&o&&t.jsx(Kf,{provider:o}),h&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:f.join(", "),children:[t.jsx(Xc,{size:10}),t.jsxs("span",{className:"truncate",children:[c("Private"),f.length>0?`: ${f.join(", ")}`:""]})]}),!x&&a>0&&_.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[c("Work requests"),": ",a]}),w==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:c("发送中...")}),w==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:c("发送失败")})]});return t.jsx(_l,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:m,isSystem:x,headerAddon:y,bubbleClassName:m&&w==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:w==="sending",children:t.jsx(Hf,{message:e,content:p,attachmentIds:e.attachmentIds,isUser:m&&w!=="failed",tone:x?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l?u:void 0})})}function Yf({request:e,member:s,onApprove:r,onReject:o,isActionPending:g,isApprovePending:p,isRejectPending:v}){const{t:n}=de();return t.jsx(_l,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Ns,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Df(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:g,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Yt,{size:12}),t.jsx("span",{children:n(p?"Approving":"Approve")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:g,onClick:o,children:[t.jsx(Xt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function bl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:g,onViewInvocationSession:p,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:l,onOpenWorkspaceFile:d,onOpenPreviewUrl:c}){const{t:m}=de(),x=va(e.id),w=xa(e.id),_=_a(e.id),[a,h]=S.useState(""),[u,f]=S.useState(!1),[y,C]=S.useState(null),[k,E]=S.useState(0),[b,j]=S.useState([]),[A,L]=S.useState(!1),[T,D]=S.useState(null),[F,I]=S.useState([]),[$,W]=S.useState(null),R=S.useRef(null),M=S.useRef(null),{files:P,addFiles:O,removeFile:U,clear:Y,restoreFiles:B,buildMarkdownLinks:H,getDoneAttachments:q,isUploading:N}=dn(),z=P.some(V=>V.status==="done"&&V.attachment),[X,K]=S.useState(null),{scrollRef:ne,contentRef:te,isAtBottom:fe,scrollToBottom:ce}=pn({resize:"smooth",initial:"instant"}),{data:G}=Os(),ge=S.useMemo(()=>{const V=new Map;for(const Z of G??[])V.set(Z.provider.id,Z.provider);return V},[G]),re=S.useMemo(()=>new Map((e.members??[]).map(V=>[V.id,V])),[e.members]),Ae=S.useMemo(()=>(e.members??[]).filter(wo),[e.members]),nt=S.useMemo(()=>new Map((e.invocations??[]).map(V=>[V.id,V])),[e.invocations]),Ke=S.useMemo(()=>{const V=new Set(s.map(ie=>ie.id)),Z=F.filter(ie=>!V.has(ie.id));return[...s,...Z].sort((ie,we)=>{const pe=Date.parse(ie.createdAt??""),ue=Date.parse(we.createdAt??"");return(Number.isNaN(pe)?0:pe)-(Number.isNaN(ue)?0:ue)})},[s,F]),be=S.useMemo(()=>new Map((e.workRequests??[]).map(V=>[V.id,V])),[e.workRequests]),Oe=S.useMemo(()=>yf(Ke,e.workRequests??[],e.invocations??[]),[Ke,e.invocations,e.workRequests]),Pe=S.useMemo(()=>(e.invocations??[]).filter(V=>ci.has(V.status)),[e.invocations]),He=S.useMemo(()=>b.map(V=>re.get(V)).filter(V=>!!V).filter(wo),[re,b]),Be=S.useMemo(()=>{const V=y?.query??"";return Ae.filter(Z=>Lf(Z,V)).sort((Z,ie)=>{const we=b.includes(Z.id),pe=b.includes(ie.id);return we!==pe?we?1:-1:Z.name.localeCompare(ie.name)})},[Ae,y?.query,b]),Ye=!r&&(u||!!y)&&Be.length>0,Ze=S.useCallback((V,Z)=>{if(Z==null){C(null);return}C(Pf(V,Z)),E(0)},[]),Me=S.useCallback(V=>{j(ue=>xf(ue,V.id));const Z=`@${V.name} `;if(y){const ue=`${a.slice(0,y.start)}${Z}${a.slice(y.end)}`,Le=y.start+Z.length;h(ue),C(null),f(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(Le,Le)});return}const ie=a.length===0||/\s$/.test(a)?"":" ",we=`${a}${ie}${Z}`,pe=we.length;h(we),f(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(pe,pe)})},[a,y]),Re=S.useCallback(V=>{j(Z=>_f(Z,V))},[]),ve=S.useCallback(V=>{const Z=V.target.value;h(Z),D(null);const ie=V.target;ie.style.height="auto",ie.style.height=`${Math.max(n?40:72,Math.min(ie.scrollHeight,n?140:240))}px`,f(!1),Ze(Z,ie.selectionStart)},[n,Ze]),ze=S.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&(O(Array.from(Z)),D(null)),V.target.value=""},[O]),xe=S.useCallback(V=>{const Z=[];for(const ie of V.clipboardData.items)if(ie.kind==="file"){const we=ie.getAsFile();we&&Z.push(we)}Z.length>0&&(V.preventDefault(),O(Z),D(null))},[O]),ot=S.useCallback(async()=>{if(r||A||N)return;const V=H(),Z=q().map(Ce=>Ce.id),ie=bf(b,Ae),we=Uf({draft:a,attachmentMarkdown:V,attachmentIds:Z,mentions:ie});if(!we||!a.trim()&&!z)return;const pe=Rf(e.id,we),ue=a,Le=b,_e=P;I(Ce=>[...Ce,pe]),h(""),j([]),f(!1),C(null),Y(),R.current&&(R.current.style.height=n?"40px":"72px"),requestAnimationFrame(()=>ce()),L(!0),D(null);try{const Ce=await g(we);I(De=>De.filter(ke=>ke.id!==pe.id)),Ce&&typeof Ce=="object"&&"id"in Ce&&requestAnimationFrame(()=>ce())}catch(Ce){const De=Ce instanceof Error?Ce.message:"Failed to send room message";I(ke=>ke.map(Ve=>Ve.id===pe.id?{...Ve,pendingStatus:"failed",error:De}:Ve)),h(ke=>ke.length===0?ue:ke),j(ke=>ke.length===0?Le:ke),B(_e),D(De),requestAnimationFrame(()=>ce())}finally{L(!1)}},[Ae,P,H,Y,n,a,q,z,A,N,g,r,B,ce,b,e.id]),st=S.useCallback(V=>{const Z=V.nativeEvent.isComposing||V.nativeEvent.keyCode===229;if(Ye){if(V.key==="ArrowDown"){V.preventDefault(),E(ie=>(ie+1)%Be.length);return}if(V.key==="ArrowUp"){V.preventDefault(),E(ie=>(ie-1+Be.length)%Be.length);return}if(V.key==="Enter"&&!Z||V.key==="Tab"){V.preventDefault();const ie=Be[k]??Be[0];ie&&Me(ie);return}if(V.key==="Escape"){V.preventDefault(),C(null),f(!1);return}}V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!Z&&(V.preventDefault(),ot())},[Me,ot,k,Be,Ye]);S.useEffect(()=>{h(""),j([]),f(!1),C(null),D(null),I([]),Y(),W(null),R.current&&(R.current.style.height=n?"40px":"72px")},[Y,n,e.id]);const jt=x.isError?x.error:w.isError?w.error:null,J=x.isPending||w.isPending,he=S.useCallback((V,Z)=>{_.mutate({memberId:V,cancelQueued:Z},{onSuccess:()=>W(null)})},[_]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[X&&t.jsx($f,{images:X.images,index:X.index,onClose:()=>K(null),onSelect:V=>K(Z=>Z&&{...Z,index:V})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:ne,className:se("h-full overflow-y-auto scrollbar-app-thin bg-white",n?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:te,className:se(n?"space-y-2.5":"space-y-3",i&&"max-w-4xl mx-auto"),children:[Oe.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(ps,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):Oe.map(V=>{if(V.kind==="pendingApproval"){const _e=V.request,Ce=re.get(_e.targetMemberId),De=x.isPending&&x.variables===_e.id,ke=w.isPending&&w.variables===_e.id;return t.jsx(Yf,{request:_e,member:Ce,onApprove:()=>x.mutate(_e.id),onReject:()=>w.mutate(_e.id),isActionPending:J,isApprovePending:De,isRejectPending:ke},V.key)}const Z=V.message,ie=Ff(Z,re,nt),we=Z.senderType==="user"?m("你"):Z.senderType==="system"?m("System"):ie?.name??m("Agent"),pe=Bf(Z,re),ue=ie?.providerId?ge.get(ie.providerId)??null:null,Le=Z.senderInvocationId?nt.get(Z.senderInvocationId)?.workspaceId??void 0:void 0;return t.jsx(Xf,{message:Z,senderName:we,senderMember:ie,senderProvider:ue,memberById:re,displayContent:pe,onOpenImage:(_e,Ce)=>K({images:_e,index:Ce}),workingDir:l,onOpenWorkspaceFile:d,onOpenPreviewUrl:c,previewWorkspaceId:Le},V.key)}),jt&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Qi(jt,m("Failed to update work request"))}),_.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Qi(_.error,m("Failed to stop member work"))})]})}),!fe&&t.jsxs("button",{type:"button",onClick:()=>ce(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(ir,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:se("shrink-0 border-t border-transparent bg-white",n?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:se(i&&"max-w-4xl mx-auto"),children:[t.jsx(jf,{invocations:Pe,memberById:re,workRequestById:be,onViewInvocationSession:p,onStopMember:he,isStopPending:_.isPending,stoppingMemberId:_.variables?.memberId??null,stopPromptInvocationId:$,onToggleStopConfirm:V=>W(Z=>Z===V?null:V)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ye&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:m(y?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Be.map((V,Z)=>{const ie=b.includes(V.id),we=Z===k;return t.jsxs("button",{type:"button",onMouseEnter:()=>E(Z),onMouseDown:pe=>{pe.preventDefault(),Me(V)},className:se("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",we?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ht,{name:V.name,avatar:V.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:V.name}),ie&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[V.providerId,V.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(Jn,{size:15,className:"text-neutral-400"})]},V.id)})})]}),He.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:He.map(V=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",V.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:V.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Re(V.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${V.name}`,children:t.jsx(Xt,{size:12})})]},V.id))}),t.jsx(un,{files:P,onRemove:U}),t.jsx("textarea",{ref:R,value:a,rows:n?1:void 0,onChange:ve,onKeyDown:st,onPaste:xe,onClick:V=>Ze(a,V.currentTarget.selectionStart),onSelect:V=>Ze(a,V.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:se("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",n?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:n?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:se("flex items-center justify-between",n?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:ze}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(xn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{f(V=>!V),C(null),requestAnimationFrame(()=>R.current?.focus())},disabled:He.length===0&&Ae.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:se("rounded-lg transition-colors",n?"p-1.5":"p-2",u?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",He.length===0&&Ae.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Jn,{size:n?15:18})}),He.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[He.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{ot()},disabled:r||A||N||!a.trim()&&!z,title:m(N?"Uploading...":A?"发送中...":"发送"),"aria-label":m(N?"Uploading...":A?"发送中...":"发送"),className:se("rounded-lg transition-all duration-200",n?"p-1.5":"p-2",(a.trim()||z)&&!r&&!A&&!N?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",A||N?"opacity-70":""),children:t.jsx(gn,{size:n?15:18})})]}),T&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:T})]})]})})]})}function Vf(e){return e?e.slice(0,8):""}function Co(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Pn(e){return e?.workspaceKind===yt.MAIN_DIRECTORY}function Is(e){return e?Pn(e)?"Project directory":e.branchName:"—"}function ts(e){return e?.workingDir||e?.worktreePath||void 0}function Ln(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),g=s?.mainWorkspaceId??null;return e.map(p=>{const v=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,n=p.ownerMemberId?r.get(p.ownerMemberId):void 0,i=!!(g&&p.id===g),l=i?"main":p.parentWorkspaceId?"child":"root",d=n?.name??(p.ownerMemberId?`Member ${Vf(p.ownerMemberId)}`:void 0),c=Pn(p)?"Project directory":i?"Main workspace":l==="child"?d?`${d} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:p,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:d,parentBranchName:v?Is(v):void 0,isMain:i}}).sort((p,v)=>{const n=l=>l.kind==="main"?0:l.kind==="child"?1:2,i=n(p)-n(v);return i!==0?i:Co(p.workspace.createdAt)-Co(v.workspace.createdAt)})}function yl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===At.ACTIVE)?.id??e[0]?.id}function Sl(e,s){return!e||e.status!==At.ACTIVE||Pn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function wl(e,s,r){return e?.parentWorkspaceId?s?.find(g=>g.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const In={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Gf=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],Cl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Qf=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],kl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Zf=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Vs(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...In},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ws(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...In,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function ji(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...In,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Jf(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function em(e){return{name:e.name.trim(),aliases:Jf(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function ko(e,s){return e instanceof Error?e.message:s}function Eo(e){return e.membershipStatus!=="REMOVED"}function Zi(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function jo(e){return Zi(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function No(e){return Cl.find(s=>s.value===e)?.label??e}function tm(e){return kl.find(s=>s.value===e)?.label??e}function zt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Ro({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function sm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=de(),{data:g=[]}=Vc(),{data:p=[]}=Os(),v=Gc(r.id),n=Qc(r.id),i=Zc(r.id),l=S.useRef(!1),[d,c]=S.useState("edit"),[m,x]=S.useState(null),[w,_]=S.useState(""),[a,h]=S.useState(Vs()),[u,f]=S.useState(null),[y,C]=S.useState(null),k=r.members??[],E=S.useMemo(()=>k.filter(Eo),[k]),b=S.useMemo(()=>y&&Eo(y)&&!E.some(q=>q.id===y.id)?[...E,y]:E,[y,E]),j=m?E.find(q=>q.id===m)??null:null,A=y?.id===m?y:j,L=w?g.find(q=>q.id===w)??null:null,T=v.isPending||n.isPending||i.isPending,D=b.filter(Zi).length,F=S.useMemo(()=>{const q=p.map(({provider:N,availability:z})=>({value:N.id,label:N.name+(z.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(ti,{agentType:N.agentType,className:"size-4"}),disabled:z.type==="NOT_FOUND"}));return a.providerId&&!q.some(N=>N.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),q},[a.providerId,p,o]);S.useEffect(()=>{if(!e){l.current=!1,C(null);return}if(l.current)return;l.current=!0;const q=b[0]??null;c(q?"edit":"add-preset"),x(q?.id??null),_(""),h(q?ws(q):Vs()),f(null)},[b,e]),S.useEffect(()=>{y&&E.some(q=>q.id===y.id)&&C(null)},[y,E]),S.useEffect(()=>{d==="add-preset"&&L&&h(ji(L))},[d,L]);const I=(q,N)=>{h(z=>({...z,[q]:N}))},$=(q,N)=>{h(z=>({...z,capabilities:{...z.capabilities,[q]:N}}))},W=q=>{c("edit"),x(q.id),_(""),h(ws(q))},R=()=>{c("add-preset"),x(null);const q=L??g[0]??null;_(q?.id??""),h(q?ji(q):Vs())},M=()=>{c("add-custom"),x(null),_(""),h(Vs())},P=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),O=d==="add-preset"?!!w:d==="edit"?!!(A&&P):P,U=async()=>{try{if(d==="add-preset"){if(!w)return;const N=await v.mutateAsync({memberPresetId:w});ut.success(o("Member added")),C(N),c("edit"),x(N.id),_(""),h(ws(N));return}const q=em(a);if(!q.name||!q.providerId||!q.rolePrompt){ut.error(o("Name, provider, and role prompt are required"));return}if(d==="add-custom"){const N=await v.mutateAsync({member:q});ut.success(o("Member added")),C(N),c("edit"),x(N.id),h(ws(N));return}if(A){const N=await n.mutateAsync({memberId:A.id,data:q});ut.success(o("Member updated")),C(z=>z?.id===N.id?N:z),x(N.id),h(ws(N))}}catch(q){ut.error(ko(q,o("Failed to save member")))}},Y=async()=>{if(u)try{if(await i.mutateAsync({memberId:u.id,stopActive:!0,cancelQueued:!0}),m===u.id){const q=b.find(N=>N.id!==u.id)??null;x(q?.id??null),c(q?"edit":"add-preset"),h(q?ws(q):Vs())}C(q=>q?.id===u.id?null:q),f(null),ut.success(o("Member removed"))}catch(q){ut.error(ko(q,o("Failed to remove member")))}},B=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Ar,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(no,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:g.length===0?t.jsx(Ro,{icon:t.jsx(Ar,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(es,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:g.map(q=>{const N=w===q.id;return t.jsxs("button",{type:"button",onClick:()=>{_(q.id),h(ji(q))},className:se("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ht,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(No(q.workspacePolicy))," · ",o(tm(q.sessionPolicy))]})]}),N?t.jsx(Yt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),H=()=>{const q=d==="edit";return q&&!A?t.jsx("div",{className:"p-5",children:t.jsx(Ro,{icon:t.jsx(ps,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(es,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[q?t.jsx(Ua,{size:15,className:"text-neutral-500"}):t.jsx(es,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&A?t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:()=>f(A),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(_n,{size:13}),o("Remove")]}):t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(Ar,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&A?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ht,{name:A.name,avatar:A.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:se("h-2 w-2 shrink-0 rounded-full",jo(A))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:A.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[A.providerId," · ",o(No(A.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Provider")}),t.jsx(Jt,{value:a.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Workspace policy")}),t.jsx(Jt,{value:a.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:Cl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Trigger policy")}),t.jsx(Jt,{value:a.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:Qf.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Session policy")}),t.jsx(Jt,{value:a.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:kl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Queue policy")}),t.jsx(Jt,{value:a.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:Zf.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(zt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Gf.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:z=>$(N.key,z.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(gs,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Te,{type:"button",onClick:U,disabled:T||!O,children:o(T?"Processing...":d==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(ps,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[b.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"outline",onClick:R,disabled:T,title:o("Add member"),children:t.jsx(es,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:b.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:b.map(q=>{const N=d==="edit"&&m===q.id;return t.jsxs("button",{type:"button",onClick:()=>W(q),className:se("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ht,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",jo(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(ru,{size:13,className:se("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:R,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Ar,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:M,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(no,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:d==="add-preset"?B():H()})]})}),t.jsx(fn,{isOpen:!!u,onClose:()=>f(null),onConfirm:Y,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:u?o("Remove this member from future TeamRun work?"):""}),u&&Zi(u)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(dr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const rm=[],im=[],nm=[],om=240;function am(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const Ao={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Ni(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function To(e,s){return e instanceof Error?e.message:s}function lm(e,s=om){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Tr(e){return e?e.instructionPreview??lm(e.instruction):""}function cm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function dm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function um(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function hm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function fm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function mm(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function pm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function gm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function vm(e,s){return s.find(r=>r.memberId===e.id&&ci.has(r.status))}function El({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:g}){const{t:p}=de(),v=va(e.id),n=xa(e.id),i=_a(e.id),[l,d]=S.useState(null),[c,m]=S.useState(null),[x,w]=S.useState(!1),[_,a]=S.useState(!1),h=e.members??rm,u=S.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??im,y=e.invocations??nm,C=S.useMemo(()=>Ln(s,e),[e,s]),k=S.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=S.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,$)=>Date.parse($.updatedAt??$.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),b=S.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,$)=>Date.parse($.updatedAt??$.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=S.useMemo(()=>[...h].map(I=>({member:I,status:am(I.status)})).sort((I,$)=>Ao[I.status]-Ao[$.status]),[h]),A=v.isError?v.error:n.isError?n.error:null,L=v.isPending||n.isPending,T=C.find(I=>I.workspace.id===r),D=e.messages??[],F=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(sm,{isOpen:_,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ds,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:p("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Messages"),children:[t.jsx(ei,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[t.jsx(ps,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:F>0?`${F}/${u.length}`:u.length}),F>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),b.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[t.jsx(Ns,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:b.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[t.jsx(Ns,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Ns,{size:13}),t.jsx("span",{children:p("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const $=h.find(M=>M.id===I.targetMemberId),W=v.isPending&&v.variables===I.id,R=n.isPending&&n.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ht,{name:$?.name??"Agent",avatar:$?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:$?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Tr(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:p(hm(I.requesterType))}),t.jsx("span",{children:Ni(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Yt,{size:11}),t.jsx("span",{className:"truncate",children:p(W?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Xt,{size:11}),t.jsx("span",{className:"truncate",children:p(R?"Rejecting":"Reject")})]})]})]},I.id)})}),A&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:To(A,p("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(ps,{size:13}),t.jsx("span",{children:p("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:u.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("Manage Team Members"),"aria-label":p("Manage Team Members"),children:t.jsx(Ua,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:$})=>{const W=vm(I,y),R=gm(y.filter(H=>H.memberId===I.id)),M=W?k.get(W.workRequestId):void 0,P=c===I.id,O=$==="running"||$==="waiting room reply",U=O&&!!W,Y=l===I.id,B=i.isPending&&i.variables?.memberId===I.id;return t.jsxs("div",{className:se("bg-white",P&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ht,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",um($))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",dm($)),children:p(cm($))})]}),O&&M?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Tr(M)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&t.jsx("button",{type:"button",onClick:()=>d(Y?null:I.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:p("Stop"),"aria-label":p("Stop"),children:t.jsx(Ms,{size:12})}),W?.sessionId&&g&&t.jsx("button",{type:"button",onClick:()=>g(W.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("View log"),"aria-label":p("View log"),children:t.jsx(Ui,{size:12})}),t.jsx("button",{type:"button",onClick:()=>m(P?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:p("Details"),"aria-label":p("Details"),"aria-expanded":P,children:P?t.jsx(Ct,{size:13}):t.jsx(Mt,{size:13})})]})]}),U&&Y&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>d(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ms,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>d(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ha,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),P&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?p("Resume last session"):p("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:R.length})]}),R.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:R.map(H=>{const q=k.get(H.workRequestId),N=!!(H.sessionId&&g);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:se("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",fm(H.status)),children:H.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Ni(H.updatedAt??H.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Tr(q)||H.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>H.sessionId&&g?.(H.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:p("View log"),"aria-label":p("View log"),children:[t.jsx(Ui,{size:10}),t.jsx("span",{children:p("Log")})]})]})},H.id)})})]}),j[j.length-1]?.member.id!==I.id&&!P&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:To(i.error,p("Failed to stop member work"))})]}),b.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Ns,{size:13}),t.jsx("span",{children:p("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:b.length})]}),t.jsx("div",{className:"space-y-1",children:b.map(I=>{const $=h.find(W=>W.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ht,{name:$?.name??"Agent",avatar:$?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:$?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Tr(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Ni(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":x,"aria-label":p("Workspaces"),children:[t.jsx(Ds,{size:13}),t.jsx("span",{children:p("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Is(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),x?t.jsx(Ct,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const $=r===I.workspace.id;return t.jsx("div",{className:se("rounded-md border bg-white px-3 py-2",$?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(I.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",pm(I.roleLabel)),children:p(I.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",mm(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Is(I.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[I.ownerName&&t.jsxs("span",{children:[p("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[p("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||$,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:p("View workspace"),children:[$?t.jsx(Yt,{size:11}):t.jsx(Da,{size:11}),t.jsx("span",{children:p($?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&b.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var Ri={exports:{}},Mo;function xm(){return Mo||(Mo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var l=this&&this.__decorate||function(f,y,C,k){var E,b=arguments.length,j=b<3?y:k===null?k=Object.getOwnPropertyDescriptor(y,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,y,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(b<3?E(j):b>3?E(y,C,j):E(y,C))||j);return b>3&&j&&Object.defineProperty(y,C,j),j},d=this&&this.__param||function(f,y){return function(C,k){y(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),m=i(6114),x=i(9924),w=i(844),_=i(5596),a=i(4725),h=i(3656);let u=n.AccessibilityManager=class extends w.Disposable{constructor(f,y){super(),this._terminal=f,this._renderService=y,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
-
`)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new
|
|
21
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),m.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,m.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,y){this._liveRegionDebouncer.refresh(f,y,this._terminal.rows)}_renderRows(f,y){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=y;E++){const b=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),A=this._rowElements[E];A&&(b.length===0?A.innerText=" ":A.textContent=b,A.setAttribute("aria-posinset",j),A.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,y){const C=f.target,k=this._rowElements[y===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(y===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,b;if(y===0?(E=C,b=this._rowElements.pop(),this._rowContainer.removeChild(b)):(E=this._rowElements.shift(),b=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),b.removeEventListener("focus",this._bottomBoundaryFocusListener),y===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(y===0?-1:1),this._rowElements[y===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let y=this._rowContainer.children.length;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=u=l([d(1,a.IRenderService)],u)},3614:(v,n)=>{function i(m){return m.replace(/\r?\n/g,"\r")}function l(m,x){return x?"\x1B[200~"+m+"\x1B[201~":m}function d(m,x,w,_){m=l(m=i(m),w.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(m,!0),x.value=""}function c(m,x,w){const _=w.getBoundingClientRect(),a=m.clientX-_.left-10,h=m.clientY-_.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=l,n.copyHandler=function(m,x){m.clipboardData&&m.clipboardData.setData("text/plain",x.selectionText),m.preventDefault()},n.handlePasteEvent=function(m,x,w,_){m.stopPropagation(),m.clipboardData&&d(m.clipboardData.getData("text/plain"),x,w,_)},n.paste=d,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(m,x,w,_,a){c(m,x,w),a&&_.rightClickSelect(m),x.value=_.selectionText,x.select()}},7239:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const l=i(1505);n.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(d,c,m){this._css.set(d,c,m)}getCss(d,c){return this._css.get(d,c)}setColor(d,c,m){this._color.set(d,c,m)}getColor(d,c){return this._color.get(d,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,l,d,c){i.addEventListener(l,d,c);let m=!1;return{dispose:()=>{m||(m=!0,i.removeEventListener(l,d,c))}}}},6465:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(y=a[E])&&(k=(C<3?y(k):C>3?y(h,u,k):y(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),m=i(8460),x=i(844),w=i(2585);let _=n.Linkifier2=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new m.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new m.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,u){this._element=a,this._mouseService=h,this._renderService=u,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const u=a.composedPath();for(let f=0;f<u.length;f++){const y=u[f];if(y.classList.contains("xterm"))break;if(y.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var u,f;this._activeProviderReplies&&h||((u=this._activeProviderReplies)===null||u===void 0||u.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let y=!1;for(const[C,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(y=this._checkLinkProviderResult(C,a,y)):k.provideLinks(a.y,(E=>{var b,j;if(this._isMouseOut)return;const A=E?.map((L=>({link:L})));(b=this._activeProviderReplies)===null||b===void 0||b.set(C,A),y=this._checkLinkProviderResult(C,a,y),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const u=new Set;for(let f=0;f<h.size;f++){const y=h.get(f);if(y)for(let C=0;C<y.length;C++){const k=y[C],E=k.link.range.start.y<a?0:k.link.range.start.x,b=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=b;j++){if(u.has(j)){y.splice(C--,1);break}u.add(j)}}}}_checkLinkProviderResult(a,h,u){var f;if(!this._activeProviderReplies)return u;const y=this._activeProviderReplies.get(a);let C=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&y){const k=y.find((E=>this._linkAtPosition(E.link,h)));k&&(u=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!u)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((b=>this._linkAtPosition(b.link,h)));if(E){u=!0,this._handleNewLink(E);break}}return u}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:u=>{var f,y;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==u&&(this._currentLink.state.decorations.pointerCursor=u,this._currentLink.state.isHovered&&((y=this._element)===null||y===void 0||y.classList.toggle("xterm-cursor-pointer",u)))}},underline:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.underline},set:u=>{var f,y,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(y=this._currentLink)===null||y===void 0?void 0:y.state)===null||C===void 0?void 0:C.decorations.underline)!==u&&(this._currentLink.state.decorations.underline=u,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,u))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((u=>{if(!this._currentLink)return;const f=u.start===0?0:u.start+1+this._bufferService.buffer.ydisp,y=this._bufferService.buffer.ydisp+1+u.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=y&&(this._clearCurrentLink(f,y),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(a,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(u,h.text)}_fireUnderlineEvent(a,h){const u=a.range,f=this._bufferService.buffer.ydisp,y=this._createLinkUnderlineEvent(u.start.x-1,u.start.y-f-1,u.end.x,u.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(y)}_linkLeave(a,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(u,h.text)}_linkAtPosition(a,h){const u=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,y=h.y*this._bufferService.cols+h.x;return u<=y&&y<=f}_positionFromMouseEvent(a,h,u){const f=u.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,u,f,y){return{x1:a,y1:h,x2:u,y2:f,cols:this._bufferService.cols,fg:y}}};n.Linkifier2=_=l([d(0,w.IBufferService)],_)},9042:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,n,i){var l=this&&this.__decorate||function(_,a,h,u){var f,y=arguments.length,C=y<3?a:u===null?u=Object.getOwnPropertyDescriptor(a,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(_,a,h,u);else for(var k=_.length-1;k>=0;k--)(f=_[k])&&(C=(y<3?f(C):y>3?f(a,h,C):f(a,h))||C);return y>3&&C&&Object.defineProperty(a,h,C),C},d=this&&this.__param||function(_,a){return function(h,u){a(h,u,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=i(511),m=i(2585);let x=n.OscLinkProvider=class{constructor(_,a,h){this._bufferService=_,this._optionsService=a,this._oscLinkService=h}provideLinks(_,a){var h;const u=this._bufferService.buffer.lines.get(_-1);if(!u)return void a(void 0);const f=[],y=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=u.getTrimmedLength();let E=-1,b=-1,j=!1;for(let A=0;A<k;A++)if(b!==-1||u.hasContent(A)){if(u.loadCell(A,C),C.hasExtendedAttrs()&&C.extended.urlId){if(b===-1){b=A,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else b!==-1&&(j=!0);if(j||b!==-1&&A===k-1){const L=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(L){const T={start:{x:b+1,y:_},end:{x:A+(j||A!==k-1?0:1),y:_}};let D=!1;if(!y?.allowNonHttpProtocols)try{const F=new URL(L);["http:","https:"].includes(F.protocol)||(D=!0)}catch{D=!0}D||f.push({text:L,range:T,activate:(F,I)=>y?y.activate(F,I,T):w(0,I),hover:(F,I)=>{var $;return($=y?.hover)===null||$===void 0?void 0:$.call(y,F,I,T)},leave:(F,I)=>{var $;return($=y?.leave)===null||$===void 0?void 0:$.call(y,F,I,T)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(b=A,E=C.extended.urlId):(b=-1,E=-1)}}a(f)}};function w(_,a){if(confirm(`Do you want to navigate to ${a}?
|
|
19
|
+
`);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Gf({message:e,content:s,attachments:r,isUser:o,tone:g=o?"user":"agent",workingDir:p,onOpenWorkspaceFile:v,onOpenPreviewUrl:n}){const{t:i}=ce(),l=S.useId(),d=S.useRef(null),[c,m]=S.useState(null),[x,w]=S.useState(!1),[y,a]=S.useState(null),h=Gc(e.teamRunId,e.id,!1),u=h.data?.content,f=u?Qi(u,r):void 0,C=!!(f&&f!==s)?f:s,k=!!(e.isTruncated&&!yl(e)),E=c?.messageId===e.id&&c.content===C&&c.expanded,_=S.useCallback(()=>{const D=d.current;D&&w(Sf(D.scrollHeight))},[]);S.useLayoutEffect(()=>{_();const D=d.current;if(!D)return;const W=window.requestAnimationFrame(_),I=typeof ResizeObserver>"u"?null:new ResizeObserver(_);return I?.observe(D),window.addEventListener("resize",_),()=>{window.cancelAnimationFrame(W),I?.disconnect(),window.removeEventListener("resize",_)}},[C,_]);const j=S.useCallback(async()=>{if(a(null),E){m({messageId:e.id,content:C,expanded:!1});return}if(k&&!u){const D=await h.refetch();if(D.error){a(Zi(D.error,i("Failed to load full message")));return}const W=D.data?.content?Qi(D.data.content,r):C;m({messageId:e.id,content:W,expanded:!0});return}m({messageId:e.id,content:C,expanded:!0})},[r,k,u,h,E,e.id,C,i]),A=(x||k)&&!E,P=x||k,T=h.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:l,ref:d,onLoadCapture:_,className:se("relative transition-[max-height] duration-200 ease-out",A?"overflow-hidden":""),style:A?{maxHeight:bl}:void 0,children:[t.jsx(qf,{content:C,isUser:o,workingDir:p,onOpenWorkspaceFile:v,onOpenPreviewUrl:n}),A&&t.jsx("div",{className:se("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",g==="system"?"to-amber-50":g==="user"?"to-neutral-900":"to-neutral-100")})]}),P&&t.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":l,"aria-label":i(E?"Collapse message":"Expand full message"),disabled:T,onClick:()=>{j()},className:se("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",g==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":g==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",T?"cursor-wait opacity-70":""),children:[E?t.jsx(Ha,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:i(T?"Loading":E?"Collapse message":"Expand full message")})]}),y&&t.jsx("div",{className:se("mt-1 text-xs",g==="user"?"text-red-200":"text-red-600"),children:y})]})}function Sl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:g,children:p,headerAddon:v,bubbleClassName:n,isPending:i}){return g?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:p})}):t.jsxs("div",{className:se("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx($t,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:se("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:se("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Rs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Of(r)}),v]}),t.jsx("div",{className:se("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:p})]}),o&&t.jsx($t,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Qf({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(si,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Zf({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:g,displayContent:p,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l,previewWorkspaceId:d}){const{t:c}=ce(),m=e.senderType==="user",x=e.senderType==="system",w=yl(e)?e.pendingStatus:null,y=e.mentions??[],a=e.workRequestIds?.length??0,h=e.visibility==="PRIVATE",u=S.useCallback(C=>{l?.(C,d)},[l,d]),f=h?Hf(e,g):[],b=t.jsxs(t.Fragment,{children:[!m&&!x&&o&&t.jsx(Qf,{provider:o}),h&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:f.join(", "),children:[t.jsx(Vc,{size:10}),t.jsxs("span",{className:"truncate",children:[c("Private"),f.length>0?`: ${f.join(", ")}`:""]})]}),!x&&a>0&&y.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[c("Work requests"),": ",a]}),w==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:c("发送中...")}),w==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:c("发送失败")})]});return t.jsx(Sl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:m,isSystem:x,headerAddon:b,bubbleClassName:m&&w==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:w==="sending",children:t.jsx(Xf,{message:e,content:p,attachmentIds:e.attachmentIds,isUser:m&&w!=="failed",tone:x?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l?u:void 0})})}function Jf({request:e,member:s,onApprove:r,onReject:o,isActionPending:g,isApprovePending:p,isRejectPending:v}){const{t:n}=ce();return t.jsx(Sl,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Rs,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Bf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:g,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Vt,{size:12}),t.jsx("span",{children:n(p?"Approving":"Approve")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:g,onClick:o,children:[t.jsx(Yt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function wl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:g,onViewInvocationSession:p,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:l,onOpenWorkspaceFile:d,onOpenPreviewUrl:c}){const{t:m}=ce(),x=va(e.id),w=xa(e.id),y=_a(e.id),[a,h]=S.useState(""),[u,f]=S.useState(!1),[b,C]=S.useState(null),[k,E]=S.useState(0),[_,j]=S.useState([]),[A,P]=S.useState(!1),[T,D]=S.useState(null),[W,I]=S.useState([]),[B,F]=S.useState(null),R=S.useRef(null),M=S.useRef(null),{files:L,addFiles:O,removeFile:U,clear:Y,restoreFiles:z,buildMarkdownLinks:$,getDoneAttachments:q,isUploading:N}=un(),H=L.some(V=>V.status==="done"&&V.attachment),[X,K]=S.useState(null),{scrollRef:ne,contentRef:te,isAtBottom:he,scrollToBottom:le}=gn({resize:"smooth",initial:"instant"}),{data:G}=Bs(),pe=S.useMemo(()=>{const V=new Map;for(const Z of G??[])V.set(Z.provider.id,Z.provider);return V},[G]),ie=S.useMemo(()=>new Map((e.members??[]).map(V=>[V.id,V])),[e.members]),Ae=S.useMemo(()=>(e.members??[]).filter(wo),[e.members]),at=S.useMemo(()=>new Map((e.invocations??[]).map(V=>[V.id,V])),[e.invocations]),Xe=S.useMemo(()=>{const V=new Set(s.map(re=>re.id)),Z=W.filter(re=>!V.has(re.id));return[...s,...Z].sort((re,ye)=>{const me=Date.parse(re.createdAt??""),Se=Date.parse(ye.createdAt??"");return(Number.isNaN(me)?0:me)-(Number.isNaN(Se)?0:Se)})},[s,W]),_e=S.useMemo(()=>new Map((e.workRequests??[]).map(V=>[V.id,V])),[e.workRequests]),Ie=S.useMemo(()=>Ef(Xe,e.workRequests??[],e.invocations??[]),[Xe,e.invocations,e.workRequests]),Pe=S.useMemo(()=>(e.invocations??[]).filter(V=>di.has(V.status)),[e.invocations]),$e=S.useMemo(()=>_.map(V=>ie.get(V)).filter(V=>!!V).filter(wo),[ie,_]),Oe=S.useMemo(()=>{const V=b?.query??"";return Ae.filter(Z=>zf(Z,V)).sort((Z,re)=>{const ye=_.includes(Z.id),me=_.includes(re.id);return ye!==me?ye?1:-1:Z.name.localeCompare(re.name)})},[Ae,b?.query,_]),Ve=!r&&(u||!!b)&&Oe.length>0,Ze=S.useCallback((V,Z)=>{if(Z==null){C(null);return}C(Ff(V,Z)),E(0)},[]),Me=S.useCallback(V=>{j(Se=>wf(Se,V.id));const Z=`@${V.name} `;if(b){const Se=`${a.slice(0,b.start)}${Z}${a.slice(b.end)}`,we=b.start+Z.length;h(Se),C(null),f(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(we,we)});return}const re=a.length===0||/\s$/.test(a)?"":" ",ye=`${a}${re}${Z}`,me=ye.length;h(ye),f(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(me,me)})},[a,b]),Re=S.useCallback(V=>{j(Z=>Cf(Z,V))},[]),ve=S.useCallback(V=>{const Z=V.target.value;h(Z),D(null);const re=V.target;re.style.height="auto",re.style.height=`${Math.max(n?40:72,Math.min(re.scrollHeight,n?140:240))}px`,f(!1),Ze(Z,re.selectionStart)},[n,Ze]),Fe=S.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&(O(Array.from(Z)),D(null)),V.target.value=""},[O]),ge=S.useCallback(V=>{const Z=[];for(const re of V.clipboardData.items)if(re.kind==="file"){const ye=re.getAsFile();ye&&Z.push(ye)}Z.length>0&&(V.preventDefault(),O(Z),D(null))},[O]),lt=S.useCallback(async()=>{if(r||A||N)return;const V=$(),Z=q().map(ke=>ke.id),re=kf(_,Ae),ye=Vf({draft:a,attachmentMarkdown:V,attachmentIds:Z,mentions:re});if(!ye||!a.trim()&&!H)return;const me=Pf(e.id,ye),Se=a,we=_,xe=L;I(ke=>[...ke,me]),h(""),j([]),f(!1),C(null),Y(),R.current&&(R.current.style.height=n?"40px":"72px"),requestAnimationFrame(()=>le()),P(!0),D(null);try{const ke=await g(ye);I(De=>De.filter(Ee=>Ee.id!==me.id)),ke&&typeof ke=="object"&&"id"in ke&&requestAnimationFrame(()=>le())}catch(ke){const De=ke instanceof Error?ke.message:"Failed to send room message";I(Ee=>Ee.map(Ye=>Ye.id===me.id?{...Ye,pendingStatus:"failed",error:De}:Ye)),h(Ee=>Ee.length===0?Se:Ee),j(Ee=>Ee.length===0?we:Ee),z(xe),D(De),requestAnimationFrame(()=>le())}finally{P(!1)}},[Ae,L,$,Y,n,a,q,H,A,N,g,r,z,le,_,e.id]),Je=S.useCallback(V=>{const Z=V.nativeEvent.isComposing||V.nativeEvent.keyCode===229;if(Ve){if(V.key==="ArrowDown"){V.preventDefault(),E(re=>(re+1)%Oe.length);return}if(V.key==="ArrowUp"){V.preventDefault(),E(re=>(re-1+Oe.length)%Oe.length);return}if(V.key==="Enter"&&!Z||V.key==="Tab"){V.preventDefault();const re=Oe[k]??Oe[0];re&&Me(re);return}if(V.key==="Escape"){V.preventDefault(),C(null),f(!1);return}}V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!Z&&(V.preventDefault(),lt())},[Me,lt,k,Oe,Ve]);S.useEffect(()=>{h(""),j([]),f(!1),C(null),D(null),I([]),Y(),F(null),R.current&&(R.current.style.height=n?"40px":"72px")},[Y,n,e.id]);const Et=x.isError?x.error:w.isError?w.error:null,J=x.isPending||w.isPending,ue=S.useCallback((V,Z)=>{y.mutate({memberId:V,cancelQueued:Z},{onSuccess:()=>F(null)})},[y]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[X&&t.jsx(Yf,{images:X.images,index:X.index,onClose:()=>K(null),onSelect:V=>K(Z=>Z&&{...Z,index:V})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:ne,className:se("h-full overflow-y-auto scrollbar-app-thin bg-white",n?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:te,className:se(n?"space-y-2.5":"space-y-3",i&&"max-w-4xl mx-auto"),children:[Ie.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(vs,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):Ie.map(V=>{if(V.kind==="pendingApproval"){const xe=V.request,ke=ie.get(xe.targetMemberId),De=x.isPending&&x.variables===xe.id,Ee=w.isPending&&w.variables===xe.id;return t.jsx(Jf,{request:xe,member:ke,onApprove:()=>x.mutate(xe.id),onReject:()=>w.mutate(xe.id),isActionPending:J,isApprovePending:De,isRejectPending:Ee},V.key)}const Z=V.message,re=Uf(Z,ie,at),ye=Z.senderType==="user"?m("你"):Z.senderType==="system"?m("System"):re?.name??m("Agent"),me=$f(Z,ie),Se=re?.providerId?pe.get(re.providerId)??null:null,we=Z.senderInvocationId?at.get(Z.senderInvocationId)?.workspaceId??void 0:void 0;return t.jsx(Zf,{message:Z,senderName:ye,senderMember:re,senderProvider:Se,memberById:ie,displayContent:me,onOpenImage:(xe,ke)=>K({images:xe,index:ke}),workingDir:l,onOpenWorkspaceFile:d,onOpenPreviewUrl:c,previewWorkspaceId:we},V.key)}),Et&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Zi(Et,m("Failed to update work request"))}),y.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Zi(y.error,m("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>le(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(nr,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:se("shrink-0 border-t border-transparent bg-white",n?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:se(i&&"max-w-4xl mx-auto"),children:[t.jsx(Mf,{invocations:Pe,memberById:ie,workRequestById:_e,onViewInvocationSession:p,onStopMember:ue,isStopPending:y.isPending,stoppingMemberId:y.variables?.memberId??null,stopPromptInvocationId:B,onToggleStopConfirm:V=>F(Z=>Z===V?null:V)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ve&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:m(b?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Oe.map((V,Z)=>{const re=_.includes(V.id),ye=Z===k;return t.jsxs("button",{type:"button",onMouseEnter:()=>E(Z),onMouseDown:me=>{me.preventDefault(),Me(V)},className:se("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ye?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx($t,{name:V.name,avatar:V.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:V.name}),re&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[V.providerId,V.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(eo,{size:15,className:"text-neutral-400"})]},V.id)})})]}),$e.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:$e.map(V=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",V.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:V.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Re(V.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${V.name}`,children:t.jsx(Yt,{size:12})})]},V.id))}),t.jsx(hn,{files:L,onRemove:U}),t.jsx("textarea",{ref:R,value:a,rows:n?1:void 0,onChange:ve,onKeyDown:Je,onPaste:ge,onClick:V=>Ze(a,V.currentTarget.selectionStart),onSelect:V=>Ze(a,V.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:se("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",n?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:n?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:se("flex items-center justify-between",n?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Fe}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(yn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{f(V=>!V),C(null),requestAnimationFrame(()=>R.current?.focus())},disabled:$e.length===0&&Ae.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:se("rounded-lg transition-colors",n?"p-1.5":"p-2",u?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",$e.length===0&&Ae.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(eo,{size:n?15:18})}),$e.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[$e.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{lt()},disabled:r||A||N||!a.trim()&&!H,title:m(N?"Uploading...":A?"发送中...":"发送"),"aria-label":m(N?"Uploading...":A?"发送中...":"发送"),className:se("rounded-lg transition-all duration-200",n?"p-1.5":"p-2",(a.trim()||H)&&!r&&!A&&!N?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",A||N?"opacity-70":""),children:t.jsx(vn,{size:n?15:18})})]}),T&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:T})]})]})})]})}function em(e){return e?e.slice(0,8):""}function Co(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function On(e){return e?.workspaceKind===_t.MAIN_DIRECTORY}function Os(e){return e?On(e)?"Project directory":e.branchName:"—"}function ss(e){return e?.workingDir||e?.worktreePath||void 0}function Bn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),g=s?.mainWorkspaceId??null;return e.map(p=>{const v=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,n=p.ownerMemberId?r.get(p.ownerMemberId):void 0,i=!!(g&&p.id===g),l=i?"main":p.parentWorkspaceId?"child":"root",d=n?.name??(p.ownerMemberId?`Member ${em(p.ownerMemberId)}`:void 0),c=On(p)?"Project directory":i?"Main workspace":l==="child"?d?`${d} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:p,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:d,parentBranchName:v?Os(v):void 0,isMain:i}}).sort((p,v)=>{const n=l=>l.kind==="main"?0:l.kind==="child"?1:2,i=n(p)-n(v);return i!==0?i:Co(p.workspace.createdAt)-Co(v.workspace.createdAt)})}function Cl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===At.ACTIVE)?.id??e[0]?.id}function kl(e,s){return!e||e.status!==At.ACTIVE||On(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function El(e,s,r){return e?.parentWorkspaceId?s?.find(g=>g.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Fn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},tm=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],jl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],sm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Nl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],rm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Gs(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Fn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ks(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Fn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Ni(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Fn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function im(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function nm(e){return{name:e.name.trim(),aliases:im(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function ko(e,s){return e instanceof Error?e.message:s}function Eo(e){return e.membershipStatus!=="REMOVED"}function Ji(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function jo(e){return Ji(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function No(e){return jl.find(s=>s.value===e)?.label??e}function om(e){return Nl.find(s=>s.value===e)?.label??e}function Wt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Ro({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function am({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ce(),{data:g=[]}=Qc(),{data:p=[]}=Bs(),v=Zc(r.id),n=Jc(r.id),i=ed(r.id),l=S.useRef(!1),[d,c]=S.useState("edit"),[m,x]=S.useState(null),[w,y]=S.useState(""),[a,h]=S.useState(Gs()),[u,f]=S.useState(null),[b,C]=S.useState(null),k=r.members??[],E=S.useMemo(()=>k.filter(Eo),[k]),_=S.useMemo(()=>b&&Eo(b)&&!E.some(q=>q.id===b.id)?[...E,b]:E,[b,E]),j=m?E.find(q=>q.id===m)??null:null,A=b?.id===m?b:j,P=w?g.find(q=>q.id===w)??null:null,T=v.isPending||n.isPending||i.isPending,D=_.filter(Ji).length,W=S.useMemo(()=>{const q=p.map(({provider:N,availability:H})=>({value:N.id,label:N.name+(H.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(si,{agentType:N.agentType,className:"size-4"}),disabled:H.type==="NOT_FOUND"}));return a.providerId&&!q.some(N=>N.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),q},[a.providerId,p,o]);S.useEffect(()=>{if(!e){l.current=!1,C(null);return}if(l.current)return;l.current=!0;const q=_[0]??null;c(q?"edit":"add-preset"),x(q?.id??null),y(""),h(q?ks(q):Gs()),f(null)},[_,e]),S.useEffect(()=>{b&&E.some(q=>q.id===b.id)&&C(null)},[b,E]),S.useEffect(()=>{d==="add-preset"&&P&&h(Ni(P))},[d,P]);const I=(q,N)=>{h(H=>({...H,[q]:N}))},B=(q,N)=>{h(H=>({...H,capabilities:{...H.capabilities,[q]:N}}))},F=q=>{c("edit"),x(q.id),y(""),h(ks(q))},R=()=>{c("add-preset"),x(null);const q=P??g[0]??null;y(q?.id??""),h(q?Ni(q):Gs())},M=()=>{c("add-custom"),x(null),y(""),h(Gs())},L=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),O=d==="add-preset"?!!w:d==="edit"?!!(A&&L):L,U=async()=>{try{if(d==="add-preset"){if(!w)return;const N=await v.mutateAsync({memberPresetId:w});rt.success(o("Member added")),C(N),c("edit"),x(N.id),y(""),h(ks(N));return}const q=nm(a);if(!q.name||!q.providerId||!q.rolePrompt){rt.error(o("Name, provider, and role prompt are required"));return}if(d==="add-custom"){const N=await v.mutateAsync({member:q});rt.success(o("Member added")),C(N),c("edit"),x(N.id),h(ks(N));return}if(A){const N=await n.mutateAsync({memberId:A.id,data:q});rt.success(o("Member updated")),C(H=>H?.id===N.id?N:H),x(N.id),h(ks(N))}}catch(q){rt.error(ko(q,o("Failed to save member")))}},Y=async()=>{if(u)try{if(await i.mutateAsync({memberId:u.id,stopActive:!0,cancelQueued:!0}),m===u.id){const q=_.find(N=>N.id!==u.id)??null;x(q?.id??null),c(q?"edit":"add-preset"),h(q?ks(q):Gs())}C(q=>q?.id===u.id?null:q),f(null),rt.success(o("Member removed"))}catch(q){rt.error(ko(q,o("Failed to remove member")))}},z=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Tr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(no,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:g.length===0?t.jsx(Ro,{icon:t.jsx(Tr,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(ts,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:g.map(q=>{const N=w===q.id;return t.jsxs("button",{type:"button",onClick:()=>{y(q.id),h(Ni(q))},className:se("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx($t,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(No(q.workspacePolicy))," · ",o(om(q.sessionPolicy))]})]}),N?t.jsx(Vt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),$=()=>{const q=d==="edit";return q&&!A?t.jsx("div",{className:"p-5",children:t.jsx(Ro,{icon:t.jsx(vs,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(ts,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[q?t.jsx(Xa,{size:15,className:"text-neutral-500"}):t.jsx(ts,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&A?t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:()=>f(A),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Sn,{size:13}),o("Remove")]}):t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(Tr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&A?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx($t,{name:A.name,avatar:A.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:se("h-2 w-2 shrink-0 rounded-full",jo(A))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:A.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[A.providerId," · ",o(No(A.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Provider")}),t.jsx(es,{value:a.providerId,onChange:N=>I("providerId",N),options:W})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Workspace policy")}),t.jsx(es,{value:a.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:jl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Trigger policy")}),t.jsx(es,{value:a.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:sm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Session policy")}),t.jsx(es,{value:a.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Nl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Queue policy")}),t.jsx(es,{value:a.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:rm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Wt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:tm.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:H=>B(N.key,H.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(ns,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Te,{type:"button",onClick:U,disabled:T||!O,children:o(T?"Processing...":d==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(vs,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[_.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"outline",onClick:R,disabled:T,title:o("Add member"),children:t.jsx(ts,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:_.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:_.map(q=>{const N=d==="edit"&&m===q.id;return t.jsxs("button",{type:"button",onClick:()=>F(q),className:se("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx($t,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",jo(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(lu,{size:13,className:se("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:R,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Tr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:M,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(no,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:d==="add-preset"?z():$()})]})}),t.jsx(mn,{isOpen:!!u,onClose:()=>f(null),onConfirm:Y,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:u?o("Remove this member from future TeamRun work?"):""}),u&&Ji(u)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(ur,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const lm=[],cm=[],dm=[],um=240;function hm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const Ao={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Ri(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function To(e,s){return e instanceof Error?e.message:s}function fm(e,s=um){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Mr(e){return e?e.instructionPreview??fm(e.instruction):""}function mm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function pm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function gm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function vm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function xm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function _m(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function bm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function ym(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Sm(e,s){return s.find(r=>r.memberId===e.id&&di.has(r.status))}function Rl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:g}){const{t:p}=ce(),v=va(e.id),n=xa(e.id),i=_a(e.id),[l,d]=S.useState(null),[c,m]=S.useState(null),[x,w]=S.useState(!1),[y,a]=S.useState(!1),h=e.members??lm,u=S.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??cm,b=e.invocations??dm,C=S.useMemo(()=>Bn(s,e),[e,s]),k=S.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=S.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,B)=>Date.parse(B.updatedAt??B.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),_=S.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,B)=>Date.parse(B.updatedAt??B.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=S.useMemo(()=>[...h].map(I=>({member:I,status:hm(I.status)})).sort((I,B)=>Ao[I.status]-Ao[B.status]),[h]),A=v.isError?v.error:n.isError?n.error:null,P=v.isPending||n.isPending,T=C.find(I=>I.workspace.id===r),D=e.messages??[],W=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(am,{isOpen:y,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ps,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:p("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Messages"),children:[t.jsx(ti,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[t.jsx(vs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:W>0?`${W}/${u.length}`:u.length}),W>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),_.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[t.jsx(Rs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:_.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[t.jsx(Rs,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Rs,{size:13}),t.jsx("span",{children:p("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const B=h.find(M=>M.id===I.targetMemberId),F=v.isPending&&v.variables===I.id,R=n.isPending&&n.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx($t,{name:B?.name??"Agent",avatar:B?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:B?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Mr(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:p(vm(I.requesterType))}),t.jsx("span",{children:Ri(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(I.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Vt,{size:11}),t.jsx("span",{className:"truncate",children:p(F?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(I.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Yt,{size:11}),t.jsx("span",{className:"truncate",children:p(R?"Rejecting":"Reject")})]})]})]},I.id)})}),A&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:To(A,p("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(vs,{size:13}),t.jsx("span",{children:p("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:u.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("Manage Team Members"),"aria-label":p("Manage Team Members"),children:t.jsx(Xa,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:B})=>{const F=Sm(I,b),R=ym(b.filter($=>$.memberId===I.id)),M=F?k.get(F.workRequestId):void 0,L=c===I.id,O=B==="running"||B==="waiting room reply",U=O&&!!F,Y=l===I.id,z=i.isPending&&i.variables?.memberId===I.id;return t.jsxs("div",{className:se("bg-white",L&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx($t,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",gm(B))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",pm(B)),children:p(mm(B))})]}),O&&M?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Mr(M)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&t.jsx("button",{type:"button",onClick:()=>d(Y?null:I.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:p("Stop"),"aria-label":p("Stop"),children:t.jsx(Ds,{size:12})}),F?.sessionId&&g&&t.jsx("button",{type:"button",onClick:()=>g(F.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("View log"),"aria-label":p("View log"),children:t.jsx(qi,{size:12})}),t.jsx("button",{type:"button",onClick:()=>m(L?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:p("Details"),"aria-label":p("Details"),"aria-expanded":L,children:L?t.jsx(wt,{size:13}):t.jsx(Mt,{size:13})})]})]}),U&&Y&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>d(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ds,{size:10}),t.jsx("span",{children:z&&i.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>d(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qa,{size:10}),t.jsx("span",{children:z&&i.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),L&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?p("Resume last session"):p("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:R.length})]}),R.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:R.map($=>{const q=k.get($.workRequestId),N=!!($.sessionId&&g);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:se("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",xm($.status)),children:$.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Ri($.updatedAt??$.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Mr(q)||$.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>$.sessionId&&g?.($.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:p("View log"),"aria-label":p("View log"),children:[t.jsx(qi,{size:10}),t.jsx("span",{children:p("Log")})]})]})},$.id)})})]}),j[j.length-1]?.member.id!==I.id&&!L&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:To(i.error,p("Failed to stop member work"))})]}),_.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Rs,{size:13}),t.jsx("span",{children:p("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:_.length})]}),t.jsx("div",{className:"space-y-1",children:_.map(I=>{const B=h.find(F=>F.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx($t,{name:B?.name??"Agent",avatar:B?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:B?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Mr(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Ri(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":x,"aria-label":p("Workspaces"),children:[t.jsx(Ps,{size:13}),t.jsx("span",{children:p("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Os(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),x?t.jsx(wt,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const B=r===I.workspace.id;return t.jsx("div",{className:se("rounded-md border bg-white px-3 py-2",B?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(I.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",bm(I.roleLabel)),children:p(I.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",_m(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Os(I.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[I.ownerName&&t.jsxs("span",{children:[p("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[p("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||B,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:p("View workspace"),children:[B?t.jsx(Vt,{size:11}):t.jsx(Da,{size:11}),t.jsx("span",{children:p(B?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&_.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var Ai={exports:{}},Mo;function wm(){return Mo||(Mo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var l=this&&this.__decorate||function(f,b,C,k){var E,_=arguments.length,j=_<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,b,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(_<3?E(j):_>3?E(b,C,j):E(b,C))||j);return _>3&&j&&Object.defineProperty(b,C,j),j},d=this&&this.__param||function(f,b){return function(C,k){b(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),m=i(6114),x=i(9924),w=i(844),y=i(5596),a=i(4725),h=i(3656);let u=n.AccessibilityManager=class extends w.Disposable{constructor(f,b){super(),this._terminal=f,this._renderService=b,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
+
`)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new y.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,w.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let b=0;b<f;b++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
21
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),m.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,m.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,b){this._liveRegionDebouncer.refresh(f,b,this._terminal.rows)}_renderRows(f,b){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=b;E++){const _=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),A=this._rowElements[E];A&&(_.length===0?A.innerText=" ":A.textContent=_,A.setAttribute("aria-posinset",j),A.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,b){const C=f.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,_;if(b===0?(E=C,_=this._rowElements.pop(),this._rowContainer.removeChild(_)):(E=this._rowElements.shift(),_=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),_.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=u=l([d(1,a.IRenderService)],u)},3614:(v,n)=>{function i(m){return m.replace(/\r?\n/g,"\r")}function l(m,x){return x?"\x1B[200~"+m+"\x1B[201~":m}function d(m,x,w,y){m=l(m=i(m),w.decPrivateModes.bracketedPasteMode&&y.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(m,!0),x.value=""}function c(m,x,w){const y=w.getBoundingClientRect(),a=m.clientX-y.left-10,h=m.clientY-y.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=l,n.copyHandler=function(m,x){m.clipboardData&&m.clipboardData.setData("text/plain",x.selectionText),m.preventDefault()},n.handlePasteEvent=function(m,x,w,y){m.stopPropagation(),m.clipboardData&&d(m.clipboardData.getData("text/plain"),x,w,y)},n.paste=d,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(m,x,w,y,a){c(m,x,w),a&&y.rightClickSelect(m),x.value=y.selectionText,x.select()}},7239:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const l=i(1505);n.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(d,c,m){this._css.set(d,c,m)}getCss(d,c){return this._css.get(d,c)}setColor(d,c,m){this._color.set(d,c,m)}getColor(d,c){return this._color.get(d,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,l,d,c){i.addEventListener(l,d,c);let m=!1;return{dispose:()=>{m||(m=!0,i.removeEventListener(l,d,c))}}}},6465:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),m=i(8460),x=i(844),w=i(2585);let y=n.Linkifier2=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new m.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new m.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,u){this._element=a,this._mouseService=h,this._renderService=u,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const u=a.composedPath();for(let f=0;f<u.length;f++){const b=u[f];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var u,f;this._activeProviderReplies&&h||((u=this._activeProviderReplies)===null||u===void 0||u.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[C,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(b=this._checkLinkProviderResult(C,a,b)):k.provideLinks(a.y,(E=>{var _,j;if(this._isMouseOut)return;const A=E?.map((P=>({link:P})));(_=this._activeProviderReplies)===null||_===void 0||_.set(C,A),b=this._checkLinkProviderResult(C,a,b),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const u=new Set;for(let f=0;f<h.size;f++){const b=h.get(f);if(b)for(let C=0;C<b.length;C++){const k=b[C],E=k.link.range.start.y<a?0:k.link.range.start.x,_=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=_;j++){if(u.has(j)){b.splice(C--,1);break}u.add(j)}}}}_checkLinkProviderResult(a,h,u){var f;if(!this._activeProviderReplies)return u;const b=this._activeProviderReplies.get(a);let C=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&b){const k=b.find((E=>this._linkAtPosition(E.link,h)));k&&(u=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!u)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((_=>this._linkAtPosition(_.link,h)));if(E){u=!0,this._handleNewLink(E);break}}return u}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:u=>{var f,b;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==u&&(this._currentLink.state.decorations.pointerCursor=u,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",u)))}},underline:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.underline},set:u=>{var f,b,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||C===void 0?void 0:C.decorations.underline)!==u&&(this._currentLink.state.decorations.underline=u,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,u))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((u=>{if(!this._currentLink)return;const f=u.start===0?0:u.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+u.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(f,b),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(a,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(u,h.text)}_fireUnderlineEvent(a,h){const u=a.range,f=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(u.start.x-1,u.start.y-f-1,u.end.x,u.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(u,h.text)}_linkAtPosition(a,h){const u=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return u<=b&&b<=f}_positionFromMouseEvent(a,h,u){const f=u.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,u,f,b){return{x1:a,y1:h,x2:u,y2:f,cols:this._bufferService.cols,fg:b}}};n.Linkifier2=y=l([d(0,w.IBufferService)],y)},9042:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,n,i){var l=this&&this.__decorate||function(y,a,h,u){var f,b=arguments.length,C=b<3?a:u===null?u=Object.getOwnPropertyDescriptor(a,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,a,h,u);else for(var k=y.length-1;k>=0;k--)(f=y[k])&&(C=(b<3?f(C):b>3?f(a,h,C):f(a,h))||C);return b>3&&C&&Object.defineProperty(a,h,C),C},d=this&&this.__param||function(y,a){return function(h,u){a(h,u,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=i(511),m=i(2585);let x=n.OscLinkProvider=class{constructor(y,a,h){this._bufferService=y,this._optionsService=a,this._oscLinkService=h}provideLinks(y,a){var h;const u=this._bufferService.buffer.lines.get(y-1);if(!u)return void a(void 0);const f=[],b=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=u.getTrimmedLength();let E=-1,_=-1,j=!1;for(let A=0;A<k;A++)if(_!==-1||u.hasContent(A)){if(u.loadCell(A,C),C.hasExtendedAttrs()&&C.extended.urlId){if(_===-1){_=A,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else _!==-1&&(j=!0);if(j||_!==-1&&A===k-1){const P=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(P){const T={start:{x:_+1,y},end:{x:A+(j||A!==k-1?0:1),y}};let D=!1;if(!b?.allowNonHttpProtocols)try{const W=new URL(P);["http:","https:"].includes(W.protocol)||(D=!0)}catch{D=!0}D||f.push({text:P,range:T,activate:(W,I)=>b?b.activate(W,I,T):w(0,I),hover:(W,I)=>{var B;return(B=b?.hover)===null||B===void 0?void 0:B.call(b,W,I,T)},leave:(W,I)=>{var B;return(B=b?.leave)===null||B===void 0?void 0:B.call(b,W,I,T)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(_=A,E=C.extended.urlId):(_=-1,E=-1)}}a(f)}};function w(y,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
22
|
|
|
23
|
-
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=l([d(0,m.IBufferService),d(1,m.IOptionsService),d(2,m.IOscLinkService)],x)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const l=i(844);class d extends l.Disposable{constructor(m){super(),this._parentWindow=m,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(m){this._listener&&this.clearListener(),this._listener=m,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var m;this._outerListener&&((m=this._resolutionMediaMatchList)===null||m===void 0||m.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}n.ScreenDprMonitor=d},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),d=i(3656),c=i(6465),m=i(9042),x=i(3730),w=i(1680),_=i(3107),a=i(5744),h=i(2950),u=i(1296),f=i(428),y=i(4269),C=i(5114),k=i(8934),E=i(3230),b=i(9312),j=i(4725),A=i(6731),L=i(8055),T=i(8969),D=i(8460),F=i(844),I=i(6114),$=i(8437),W=i(2584),R=i(7399),M=i(5941),P=i(9074),O=i(2585),U=i(5435),Y=i(4567),B=typeof window<"u"?window.document:null;class H extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((z,X)=>this.refresh(z,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((z=>this._reportWindowsOptions(z)))),this.register(this._inputHandler.onColor((z=>this._handleColorEvent(z)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((z=>this._afterResize(z.cols,z.rows)))),this.register((0,F.toDisposable)((()=>{var z,X;this._customKeyEventHandler=void 0,(X=(z=this.element)===null||z===void 0?void 0:z.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const z of N){let X,K="";switch(z.index){case 256:X="foreground",K="10";break;case 257:X="background",K="11";break;case 258:X="cursor",K="12";break;default:X="ansi",K="4;"+z.index}switch(z.type){case 0:const ne=L.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[z.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${K};${(0,M.toRgbString)(ne)}${W.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((te=>te.ansi[z.index]=L.rgba.toColor(...z.color)));else{const te=X;this._themeService.modifyColors((fe=>fe[te]=L.rgba.toColor(...z.color)))}break;case 2:this._themeService.restoreColor(z.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,z=this.buffer.lines.get(N);if(!z)return;const X=Math.min(this.buffer.x,this.cols-1),K=this._renderService.dimensions.css.cell.height,ne=z.getWidth(X),te=this._renderService.dimensions.css.cell.width*ne,fe=this.buffer.y*this._renderService.dimensions.css.cell.height,ce=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ce+"px",this.textarea.style.top=fe+"px",this.textarea.style.width=te+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(z=>{this.hasSelection()&&(0,l.copyHandler)(z,this._selectionService)})));const N=z=>(0,l.handlePasteEvent)(z,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,d.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(z=>{z.button===2&&(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(z=>{(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(z=>{z.button===1&&(0,l.moveTextAreaUnderMouseCursor)(z,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var z;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=B.createDocumentFragment();this._viewportElement=B.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=B.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=B.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=B.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=B.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",m.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(z=this._document.defaultView)!==null&&z!==void 0?z:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(A.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=B.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(b.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(_.BufferDecorationRenderer,this.screenElement)),this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(u.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,z=this.element;function X(te){const fe=N._mouseService.getMouseReportCoords(te,N.screenElement);if(!fe)return!1;let ce,G;switch(te.overrideType||te.type){case"mousemove":G=32,te.buttons===void 0?(ce=3,te.button!==void 0&&(ce=te.button<3?te.button:3)):ce=1&te.buttons?0:4&te.buttons?1:2&te.buttons?2:3;break;case"mouseup":G=0,ce=te.button<3?te.button:3;break;case"mousedown":G=1,ce=te.button<3?te.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(te)===0)return!1;G=te.deltaY<0?0:1,ce=4;break;default:return!1}return!(G===void 0||ce===void 0||ce>4)&&N.coreMouseService.triggerMouseEvent({col:fe.col,row:fe.row,x:fe.x,y:fe.y,button:ce,action:G,ctrl:te.ctrlKey,alt:te.altKey,shift:te.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ne={mouseup:te=>(X(te),te.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(te)),wheel:te=>(X(te),this.cancel(te,!0)),mousedrag:te=>{te.buttons&&X(te)},mousemove:te=>{te.buttons||X(te)}};this.register(this.coreMouseService.onProtocolChange((te=>{te?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(te)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&te?K.mousemove||(z.addEventListener("mousemove",ne.mousemove),K.mousemove=ne.mousemove):(z.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&te?K.wheel||(z.addEventListener("wheel",ne.wheel,{passive:!1}),K.wheel=ne.wheel):(z.removeEventListener("wheel",K.wheel),K.wheel=null),2&te?K.mouseup||(z.addEventListener("mouseup",ne.mouseup),K.mouseup=ne.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),z.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&te?K.mousedrag||(K.mousedrag=ne.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(z,"mousedown",(te=>{if(te.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(te))return X(te),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(te)}))),this.register((0,d.addDisposableDomListener)(z,"wheel",(te=>{if(!K.wheel){if(!this.buffer.hasScrollback){const fe=this.viewport.getLinesScrolled(te);if(fe===0)return;const ce=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(te.deltaY<0?"A":"B");let G="";for(let ge=0;ge<Math.abs(fe);ge++)G+=ce;return this.coreService.triggerDataEvent(G,!0),this.cancel(te,!0)}return this.viewport.handleWheel(te)?this.cancel(te):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(z,"touchstart",(te=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(te),this.cancel(te)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(z,"touchmove",(te=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(te)?void 0:this.cancel(te)}),{passive:!1}))}refresh(N,z){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,z)}updateCursorStyle(N){var z;!((z=this._selectionService)===null||z===void 0)&&z.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,z,X=0){var K;X===1?(super.scrollLines(N,z,X),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const z=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),z}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,z,X){this._selectionService.setSelection(N,z,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,z){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,z)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const z=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!z&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;z||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,R.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const K=this.rows-1;return this.scrollLines(X.type===2?-K:K),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==W.C0.ETX&&X.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,z){const X=N.isMac&&!this.options.macOptionIsMeta&&z.altKey&&!z.ctrlKey&&!z.metaKey||N.isWindows&&z.altKey&&z.ctrlKey&&!z.metaKey||N.isWindows&&z.getModifierState("AltGraph");return z.type==="keypress"?X:X&&(!z.keyCode||z.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(z){return z.keyCode===16||z.keyCode===17||z.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let z;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)z=N.charCode;else if(N.which===null||N.which===void 0)z=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;z=N.which}return!(!z||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(z=String.fromCharCode(z),this._onKey.fire({key:z,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(z,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const z=N.data;return this.coreService.triggerDataEvent(z,!0),this.cancel(N),!0}return!1}resize(N,z){N!==this.cols||z!==this.rows?super.resize(N,z):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,z){var X,K;(X=this._charSizeService)===null||X===void 0||X.measure(),(K=this.viewport)===null||K===void 0||K.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let z=1;z<this.rows;z++)this.buffer.lines.push(this.buffer.getBlankLine($.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,z;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(z=this.viewport)===null||z===void 0||z.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(W.C0.ESC+"[I"):this.coreService.triggerDataEvent(W.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const z=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${X};${z}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),ne=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${ne};${K}t`)}}cancel(N,z){if(this.options.cancelEvents||z)return N.preventDefault(),N.stopPropagation(),!1}}n.Terminal=H},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const m=c-this._lastRefreshMs,x=this._debounceThresholdMS-m;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(v,n,i){var l=this&&this.__decorate||function(h,u,f,y){var C,k=arguments.length,E=k<3?u:y===null?y=Object.getOwnPropertyDescriptor(u,f):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,y);else for(var b=h.length-1;b>=0;b--)(C=h[b])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,y){u(f,y,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),m=i(4725),x=i(8460),w=i(844),_=i(2585);let a=n.Viewport=class extends w.Disposable{constructor(h,u,f,y,C,k,E,b){super(),this._viewportElement=h,this._scrollArea=u,this._bufferService=f,this._optionsService=y,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(b.colors),this.register(b.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const u=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==u&&(this._lastRecordedBufferHeight=u,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const u=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,u){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(u<0&&this._viewportElement.scrollTop!==0||u>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const u=this._getPixelsScrolled(h);return u!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+u:this._smoothScrollState.target+=u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const u=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?u*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._currentRowHeight*this._bufferService.rows),u}getBufferElements(h,u){var f;let y,C="";const k=[],E=u??this._bufferService.buffer.lines.length,b=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const A=b.get(j);if(!A)continue;const L=(f=b.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=A.translateToString(!L),!L||j===b.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(y=T),C=""}}return{bufferElements:k,cursorElement:y}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(u/=this._currentRowHeight+0,this._wheelPartialScroll+=u,u=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._bufferService.rows),u}_applyScrollModifier(h,u){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&u.altKey||f==="ctrl"&&u.ctrlKey||f==="shift"&&u.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const u=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,u!==0&&(this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}};n.Viewport=a=l([d(2,_.IBufferService),d(3,_.IOptionsService),d(4,m.ICharSizeService),d(5,m.IRenderService),d(6,m.ICoreBrowserService),d(7,m.IThemeService)],a)},3107:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(y=a[E])&&(k=(C<3?y(k):C>3?y(h,u,k):y(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),m=i(4725),x=i(844),w=i(2585);let _=n.BufferDecorationRenderer=class extends x.Disposable{constructor(a,h,u,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=u,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((y=>this._removeDecoration(y)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,u;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const y=(u=a.options.x)!==null&&u!==void 0?u:0;return y&&y>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let u=this._decorationElements.get(a);u||(u=this._createElement(a),a.element=u,this._decorationElements.set(a,u),this._container.appendChild(u),a.onDispose((()=>{this._decorationElements.delete(a),u.remove()}))),u.style.top=h*this._renderService.dimensions.css.cell.height+"px",u.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(u)}}_refreshXPosition(a,h=a.element){var u;if(!h)return;const f=(u=a.options.x)!==null&&u!==void 0?u:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=_=l([d(1,w.IBufferService),d(2,w.IDecorationService),d(3,m.IRenderService)],_)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,d){return l>=i.startBufferLine-this._linePadding[d||"full"]&&l<=i.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(v,n,i){var l=this&&this.__decorate||function(y,C,k,E){var b,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(y,C,k,E);else for(var L=y.length-1;L>=0;L--)(b=y[L])&&(A=(j<3?b(A):j>3?b(C,k,A):b(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(y,C){return function(k,E){C(k,E,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),m=i(3656),x=i(4725),w=i(844),_=i(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends w.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(y,C,k,E,b,j,A){var L;super(),this._viewportElement=y,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=b,this._optionsService=j,this._coreBrowseService=A,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,w.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,m.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const y=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=y,h.center=C,h.right=y,this._refreshDrawHeightConstants(),u.full=0,u.left=0,u.center=h.left,u.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const y=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(y,12),6)*this._coreBrowseService.dpr);a.left=C,a.center=C,a.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const y=this._colorZoneStore.zones;for(const C of y)C.position!=="full"&&this._renderColorZone(C);for(const C of y)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(y){this._ctx.fillStyle=y.color,this._ctx.fillRect(u[y.position||"full"],Math.round((this._canvas.height-1)*(y.startBufferLine/this._bufferService.buffers.active.lines.length)-a[y.position||"full"]/2),h[y.position||"full"],Math.round((this._canvas.height-1)*((y.endBufferLine-y.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[y.position||"full"]))}_queueRefresh(y,C){this._shouldUpdateDimensions=y||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=l([d(2,_.IBufferService),d(3,_.IDecorationService),d(4,x.IRenderService),d(5,_.IOptionsService),d(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var l=this&&this.__decorate||function(_,a,h,u){var f,y=arguments.length,C=y<3?a:u===null?u=Object.getOwnPropertyDescriptor(a,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(_,a,h,u);else for(var k=_.length-1;k>=0;k--)(f=_[k])&&(C=(y<3?f(C):y>3?f(a,h,C):f(a,h))||C);return y>3&&C&&Object.defineProperty(a,h,C),C},d=this&&this.__param||function(_,a){return function(h,u){a(h,u,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),m=i(2585),x=i(2584);let w=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,a,h,u,f,y){this._textarea=_,this._compositionView=a,this._bufferService=h,this._optionsService=u,this._coreService=f,this._renderService=y,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(_,"");this._dataAlreadySent=h,a.length>_.length?this._coreService.triggerDataEvent(h,!0):a.length<_.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===_.length&&a!==_&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(_){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,u=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=u+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const y=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=u+"px",this._textarea.style.width=Math.max(y.width,1)+"px",this._textarea.style.height=Math.max(y.height,1)+"px",this._textarea.style.lineHeight=y.height+"px"}_||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=w=l([d(2,m.IBufferService),d(3,m.IOptionsService),d(4,m.ICoreService),d(5,c.IRenderService)],w)},9806:(v,n)=>{function i(l,d,c){const m=c.getBoundingClientRect(),x=l.getComputedStyle(c),w=parseInt(x.getPropertyValue("padding-left")),_=parseInt(x.getPropertyValue("padding-top"));return[d.clientX-m.left-w,d.clientY-m.top-_]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,d,c,m,x,w,_,a,h){if(!w)return;const u=i(l,d,c);return u?(u[0]=Math.ceil((u[0]+(h?_/2:0))/_),u[1]=Math.ceil(u[1]/a),u[0]=Math.min(Math.max(u[0],1),m+(h?1:0)),u[1]=Math.min(Math.max(u[1],1),x),u):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const l=i(2584);function d(a,h,u,f){const y=a-c(a,u),C=h-c(h,u),k=Math.abs(y-C)-(function(E,b,j){let A=0;const L=E-c(E,j),T=b-c(b,j);for(let D=0;D<Math.abs(L-T);D++){const F=m(E,b)==="A"?-1:1,I=j.buffer.lines.get(L+F*D);I?.isWrapped&&A++}return A})(a,h,u);return _(k,w(m(a,h),f))}function c(a,h){let u=0,f=h.buffer.lines.get(a),y=f?.isWrapped;for(;y&&a>=0&&a<h.rows;)u++,f=h.buffer.lines.get(--a),y=f?.isWrapped;return u}function m(a,h){return a>h?"A":"B"}function x(a,h,u,f,y,C){let k=a,E=h,b="";for(;k!==u||E!==f;)k+=y?1:-1,y&&k>C.cols-1?(b+=C.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!y&&k<0&&(b+=C.buffer.translateBufferLineToString(E,!1,0,a+1),k=C.cols-1,a=k,E--);return b+C.buffer.translateBufferLineToString(E,!1,a,k)}function w(a,h){const u=h?"O":"[";return l.C0.ESC+u+a}function _(a,h){a=Math.floor(a);let u="";for(let f=0;f<a;f++)u+=h;return u}n.moveToCellSequence=function(a,h,u,f){const y=u.buffer.x,C=u.buffer.y;if(!u.buffer.hasScrollback)return(function(b,j,A,L,T,D){return d(j,L,T,D).length===0?"":_(x(b,j,b,j-c(j,T),!1,T).length,w("D",D))})(y,C,0,h,u,f)+d(C,h,u,f)+(function(b,j,A,L,T,D){let F;F=d(j,L,T,D).length>0?L-c(L,T):j;const I=L,$=(function(W,R,M,P,O,U){let Y;return Y=d(M,P,O,U).length>0?P-c(P,O):R,W<M&&Y<=P||W>=M&&Y<P?"C":"D"})(b,j,A,L,T,D);return _(x(b,F,A,I,$==="C",T).length,w($,D))})(y,C,a,h,u,f);let k;if(C===h)return k=y>a?"D":"C",_(Math.abs(y-a),w(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return _((function(b,j){return j.cols-b})(C>h?a:y,u)+(E-1)*u.cols+1+((C>h?y:a)-1),w(k,f))}},1296:function(v,n,i){var l=this&&this.__decorate||function(T,D,F,I){var $,W=arguments.length,R=W<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,F):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(T,D,F,I);else for(var M=T.length-1;M>=0;M--)($=T[M])&&(R=(W<3?$(R):W>3?$(D,F,R):$(D,F))||R);return W>3&&R&&Object.defineProperty(D,F,R),R},d=this&&this.__param||function(T,D){return function(F,I){D(F,I,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),m=i(2550),x=i(2223),w=i(6171),_=i(4725),a=i(8055),h=i(8460),u=i(844),f=i(2585),y="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",b="xterm-focus",j="xterm-selection";let A=1,L=n.DomRenderer=class extends u.Disposable{constructor(T,D,F,I,$,W,R,M,P,O){super(),this._element=T,this._screenElement=D,this._viewportElement=F,this._linkifier2=I,this._charSizeService=W,this._optionsService=R,this._bufferService=M,this._coreBrowserService=P,this._themeService=O,this._terminalClass=A++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=$.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(y+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,u.toDisposable)((()=>{this._element.classList.remove(y+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new m.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${C} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${C}.${b} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${b} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[F,I]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${F} { color: ${I.css}; }${this._terminalSelector} .${k}${F}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${F} { background-color: ${I.css}; }`;D+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let F=this._rowElements.length;F<=D;F++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(b)}handleFocus(){this._rowContainer.classList.add(b),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,F),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const I=T[1]-this._bufferService.buffer.ydisp,$=D[1]-this._bufferService.buffer.ydisp,W=Math.max(I,0),R=Math.min($,this._bufferService.rows-1);if(W>=this._bufferService.rows||R<0)return;const M=document.createDocumentFragment();if(F){const P=T[0]>D[0];M.appendChild(this._createSelectionElement(W,P?D[0]:T[0],P?T[0]:D[0],R-W+1))}else{const P=I===W?T[0]:0,O=W===$?D[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(W,P,O));const U=R-W-1;if(M.appendChild(this._createSelectionElement(W+1,0,this._bufferService.cols,U)),W!==R){const Y=$===R?D[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(R,0,Y))}}this._selectionContainer.appendChild(M)}_createSelectionElement(T,D,F,I=1){const $=document.createElement("div");return $.style.height=I*this.dimensions.css.cell.height+"px",$.style.top=T*this.dimensions.css.cell.height+"px",$.style.left=D*this.dimensions.css.cell.width+"px",$.style.width=this.dimensions.css.cell.width*(F-D)+"px",$}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,D){const F=this._bufferService.buffer,I=F.ybase+F.y,$=Math.min(F.x,this._bufferService.cols-1),W=this._optionsService.rawOptions.cursorBlink,R=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=T;P<=D;P++){const O=P+F.ydisp,U=this._rowElements[P],Y=F.lines.get(O);if(!U||!Y)break;U.replaceChildren(...this._rowFactory.createRow(Y,O,O===I,R,M,$,W,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${y}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,F,I,$,W){F<0&&(T=0),I<0&&(D=0);const R=this._bufferService.rows-1;F=Math.max(Math.min(F,R),0),I=Math.max(Math.min(I,R),0),$=Math.min($,this._bufferService.cols);const M=this._bufferService.buffer,P=M.ybase+M.y,O=Math.min(M.x,$-1),U=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,B=this._optionsService.rawOptions.cursorInactiveStyle;for(let H=F;H<=I;++H){const q=H+M.ydisp,N=this._rowElements[H],z=M.lines.get(q);if(!N||!z)break;N.replaceChildren(...this._rowFactory.createRow(z,q,q===P,Y,B,O,U,this.dimensions.css.cell.width,this._widthCache,W?H===F?T:0:-1,W?(H===I?D:$)-1:-1))}}};n.DomRenderer=L=l([d(4,f.IInstantiationService),d(5,_.ICharSizeService),d(6,f.IOptionsService),d(7,f.IBufferService),d(8,_.ICoreBrowserService),d(9,_.IThemeService)],L)},3787:function(v,n,i){var l=this&&this.__decorate||function(k,E,b,j){var A,L=arguments.length,T=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,b,j);else for(var D=k.length-1;D>=0;D--)(A=k[D])&&(T=(L<3?A(T):L>3?A(E,b,T):A(E,b))||T);return L>3&&T&&Object.defineProperty(E,b,T),T},d=this&&this.__param||function(k,E){return function(b,j){E(b,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),m=i(643),x=i(511),w=i(2585),_=i(8055),a=i(4725),h=i(4269),u=i(6171),f=i(3734);let y=n.DomRendererRowFactory=class{constructor(k,E,b,j,A,L,T){this._document=k,this._characterJoinerService=E,this._optionsService=b,this._coreBrowserService=j,this._coreService=A,this._decorationService=L,this._themeService=T,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,b){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=b}createRow(k,E,b,j,A,L,T,D,F,I,$){const W=[],R=this._characterJoinerService.getJoinedCharacters(E),M=this._themeService.colors;let P,O=k.getNoBgTrimmedLength();b&&O<L+1&&(O=L+1);let U=0,Y="",B=0,H=0,q=0,N=!1,z=0,X=!1,K=0;const ne=[],te=I!==-1&&$!==-1;for(let fe=0;fe<O;fe++){k.loadCell(fe,this._workCell);let ce=this._workCell.getWidth();if(ce===0)continue;let G=!1,ge=fe,re=this._workCell;if(R.length>0&&fe===R[0][0]){G=!0;const xe=R.shift();re=new h.JoinedCellData(this._workCell,k.translateToString(!0,xe[0],xe[1]),xe[1]-xe[0]),ge=xe[1]-1,ce=re.getWidth()}const Ae=this._isCellInSelection(fe,E),nt=b&&fe===L,Ke=te&&fe>=I&&fe<=$;let be=!1;this._decorationService.forEachDecorationAtCell(fe,E,void 0,(xe=>{be=!0}));let Oe=re.getChars()||m.WHITESPACE_CELL_CHAR;if(Oe===" "&&(re.isUnderline()||re.isOverline())&&(Oe=" "),K=ce*D-F.get(Oe,re.isBold(),re.isItalic()),P){if(U&&(Ae&&X||!Ae&&!X&&re.bg===B)&&(Ae&&X&&M.selectionForeground||re.fg===H)&&re.extended.ext===q&&Ke===N&&K===z&&!nt&&!G&&!be){Y+=Oe,U++;continue}U&&(P.textContent=Y),P=this._document.createElement("span"),U=0,Y=""}else P=this._document.createElement("span");if(B=re.bg,H=re.fg,q=re.extended.ext,N=Ke,z=K,X=Ae,G&&L>=fe&&L<=ge&&(L=fe),!this._coreService.isCursorHidden&&nt){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ne.push("xterm-cursor-blink"),ne.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(A)switch(A){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline")}}if(re.isBold()&&ne.push("xterm-bold"),re.isItalic()&&ne.push("xterm-italic"),re.isDim()&&ne.push("xterm-dim"),Y=re.isInvisible()?m.WHITESPACE_CELL_CHAR:re.getChars()||m.WHITESPACE_CELL_CHAR,re.isUnderline()&&(ne.push(`xterm-underline-${re.extended.underlineStyle}`),Y===" "&&(Y=" "),!re.isUnderlineColorDefault()))if(re.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(re.getUnderlineColor()).join(",")})`;else{let xe=re.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&re.isBold()&&xe<8&&(xe+=8),P.style.textDecorationColor=M.ansi[xe].css}re.isOverline()&&(ne.push("xterm-overline"),Y===" "&&(Y=" ")),re.isStrikethrough()&&ne.push("xterm-strikethrough"),Ke&&(P.style.textDecoration="underline");let Pe=re.getFgColor(),He=re.getFgColorMode(),Be=re.getBgColor(),Ye=re.getBgColorMode();const Ze=!!re.isInverse();if(Ze){const xe=Pe;Pe=Be,Be=xe;const ot=He;He=Ye,Ye=ot}let Me,Re,ve,ze=!1;switch(this._decorationService.forEachDecorationAtCell(fe,E,void 0,(xe=>{xe.options.layer!=="top"&&ze||(xe.backgroundColorRGB&&(Ye=50331648,Be=xe.backgroundColorRGB.rgba>>8&16777215,Me=xe.backgroundColorRGB),xe.foregroundColorRGB&&(He=50331648,Pe=xe.foregroundColorRGB.rgba>>8&16777215,Re=xe.foregroundColorRGB),ze=xe.options.layer==="top")})),!ze&&Ae&&(Me=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,Be=Me.rgba>>8&16777215,Ye=50331648,ze=!0,M.selectionForeground&&(He=50331648,Pe=M.selectionForeground.rgba>>8&16777215,Re=M.selectionForeground)),ze&&ne.push("xterm-decoration-top"),Ye){case 16777216:case 33554432:ve=M.ansi[Be],ne.push(`xterm-bg-${Be}`);break;case 50331648:ve=_.rgba.toColor(Be>>16,Be>>8&255,255&Be),this._addStyle(P,`background-color:#${C((Be>>>0).toString(16),"0",6)}`);break;default:Ze?(ve=M.foreground,ne.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):ve=M.background}switch(Me||re.isDim()&&(Me=_.color.multiplyOpacity(ve,.5)),He){case 16777216:case 33554432:re.isBold()&&Pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Pe+=8),this._applyMinimumContrast(P,ve,M.ansi[Pe],re,Me,void 0)||ne.push(`xterm-fg-${Pe}`);break;case 50331648:const xe=_.rgba.toColor(Pe>>16&255,Pe>>8&255,255&Pe);this._applyMinimumContrast(P,ve,xe,re,Me,Re)||this._addStyle(P,`color:#${C(Pe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,ve,M.foreground,re,Me,void 0)||Ze&&ne.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ne.length&&(P.className=ne.join(" "),ne.length=0),nt||G||be?P.textContent=Y:U++,K!==this.defaultSpacing&&(P.style.letterSpacing=`${K}px`),W.push(P),fe=ge}return P&&U&&(P.textContent=Y),W}_applyMinimumContrast(k,E,b,j,A,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,u.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(A||L||(D=T.getColor(E.rgba,b.rgba)),D===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=_.color.ensureContrastRatio(A||E,L||b,F),T.setColor((A||E).rgba,(L||b).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const b=this._selectionStart,j=this._selectionEnd;return!(!b||!j)&&(this._columnSelectMode?b[0]<=j[0]?k>=b[0]&&E>=b[1]&&k<j[0]&&E<=j[1]:k<b[0]&&E>=b[1]&&k>=j[0]&&E<=j[1]:E>b[1]&&E<j[1]||b[1]===j[1]&&E===b[1]&&k>=b[0]&&k<j[0]||b[1]<j[1]&&E===j[1]&&k<j[0]||b[1]<j[1]&&E===b[1]&&k>=b[0])}};function C(k,E,b){for(;k.length<b;)k=E+k;return k}n.DomRendererRowFactory=y=l([d(1,a.ICharacterJoinerService),d(2,w.IOptionsService),d(3,a.ICoreBrowserService),d(4,w.ICoreService),d(5,w.IDecorationService),d(6,a.IThemeService)],y)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=i.createElement("span"),d=i.createElement("span");d.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const m=i.createElement("span");m.style.fontWeight="bold",m.style.fontStyle="italic",this._measureElements=[l,d,c,m],this._container.appendChild(l),this._container.appendChild(d),this._container.appendChild(c),this._container.appendChild(m),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,l,d,c){i===this._font&&l===this._fontSize&&d===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=d,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,d){let c=0;if(!l&&!d&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let m=i;l&&(m+="B"),d&&(m+="I");let x=this._holey.get(m);if(x===void 0){let w=0;l&&(w|=1),d&&(w|=2),x=this._measure(i,w),this._holey.set(m,x)}return x}_measure(i,l){const d=this._measureElements[l];return d.textContent=i.repeat(32),d.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},n.excludeFromContrastRatioDemands=function(l){return i(l)||(function(d){return 9472<=d&&d<=9631})(l)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(y=a[E])&&(k=(C<3?y(k):C>3?y(h,u,k):y(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),m=i(8460),x=i(844);let w=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,u){super(),this._optionsService=u,this.width=0,this.height=0,this._onCharSizeChange=this.register(new m.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new _(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=w=l([d(2,c.IOptionsService)],w);class _{constructor(h,u,f){this._document=h,this._parentElement=u,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var l=this&&this.__decorate||function(h,u,f,y){var C,k=arguments.length,E=k<3?u:y===null?y=Object.getOwnPropertyDescriptor(u,f):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,y);else for(var b=h.length-1;b>=0;b--)(C=h[b])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,y){u(f,y,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),m=i(643),x=i(511),w=i(2585);class _ extends c.AttributeData{constructor(u,f,y){super(),this.content=0,this.combinedData="",this.fg=u.fg,this.bg=u.bg,this.combinedData=f,this._width=y}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(u){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=_;let a=n.CharacterJoinerService=class jl{constructor(u){this._bufferService=u,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(u){const f={id:this._nextCharacterJoinerId++,handler:u};return this._characterJoiners.push(f),f.id}deregister(u){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===u)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(u){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(u);if(!f||f.length===0)return[];const y=[],C=f.translateToString(!0);let k=0,E=0,b=0,j=f.getFg(0),A=f.getBg(0);for(let L=0;L<f.getTrimmedLength();L++)if(f.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==A){if(L-k>1){const T=this._getJoinedRanges(C,b,E,f,k);for(let D=0;D<T.length;D++)y.push(T[D])}k=L,b=E,j=this._workCell.fg,A=this._workCell.bg}E+=this._workCell.getChars().length||m.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(C,b,E,f,k);for(let T=0;T<L.length;T++)y.push(L[T])}return y}_getJoinedRanges(u,f,y,C,k){const E=u.substring(f,y);let b=[];try{b=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const A=this._characterJoiners[j].handler(E);for(let L=0;L<A.length;L++)jl._mergeRanges(b,A[L])}catch(A){console.error(A)}return this._stringRangesToCellRanges(b,C,k),b}_stringRangesToCellRanges(u,f,y){let C=0,k=!1,E=0,b=u[C];if(b){for(let j=y;j<this._bufferService.cols;j++){const A=f.getWidth(j),L=f.getString(j).length||m.WHITESPACE_CELL_CHAR.length;if(A!==0){if(!k&&b[0]<=E&&(b[0]=j,k=!0),b[1]<=E){if(b[1]=j,b=u[++C],!b)break;b[0]<=E?(b[0]=j,k=!0):k=!1}E+=L}}b&&(b[1]=this._bufferService.cols)}}static _mergeRanges(u,f){let y=!1;for(let C=0;C<u.length;C++){const k=u[C];if(y){if(f[1]<=k[0])return u[C-1][1]=f[1],u;if(f[1]<=k[1])return u[C-1][1]=Math.max(f[1],k[1]),u.splice(C,1),u;u.splice(C,1),C--}else{if(f[1]<=k[0])return u.splice(C,0,f),u;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),u;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),y=!0)}}return y?u[u.length-1][1]=f[1]:u.push(f),u}};n.CharacterJoinerService=a=l([d(0,w.IBufferService)],a)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,n,i){var l=this&&this.__decorate||function(w,_,a,h){var u,f=arguments.length,y=f<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(w,_,a,h);else for(var C=w.length-1;C>=0;C--)(u=w[C])&&(y=(f<3?u(y):f>3?u(_,a,y):u(_,a))||y);return f>3&&y&&Object.defineProperty(_,a,y),y},d=this&&this.__param||function(w,_){return function(a,h){_(a,h,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),m=i(9806);let x=n.MouseService=class{constructor(w,_){this._renderService=w,this._charSizeService=_}getCoords(w,_,a,h,u){return(0,m.getCoords)(window,w,_,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,u)}getMouseReportCoords(w,_){const a=(0,m.getCoordsRelativeToElement)(window,w,_);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=x=l([d(0,c.IRenderService),d(1,c.ICharSizeService)],x)},3230:function(v,n,i){var l=this&&this.__decorate||function(y,C,k,E){var b,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(y,C,k,E);else for(var L=y.length-1;L>=0;L--)(b=y[L])&&(A=(j<3?b(A):j>3?b(C,k,A):b(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(y,C){return function(k,E){C(k,E,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),m=i(6193),x=i(5596),w=i(4725),_=i(8460),a=i(844),h=i(7226),u=i(2585);let f=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(y,C,k,E,b,j,A,L){if(super(),this._rowCount=y,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(A.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(A.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(b.onDecorationRegistered((()=>this._fullRefresh()))),this.register(b.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(A.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in A.window){const T=new A.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(y){this._isPaused=y.isIntersecting===void 0?y.intersectionRatio===0:!y.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(y,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(y,C,this._rowCount))}_renderRows(y,C){this._renderer.value&&(y=Math.min(y,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(y,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:y,end:C}),this._onRender.fire({start:y,end:C}),this._isNextRenderRedrawOnly=!0)}resize(y,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(y){this._renderer.value=y,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(y){return this._renderDebouncer.addRefreshCallback(y)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var y,C;this._renderer.value&&((C=(y=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(y),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(y,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(y,C))):this._renderer.value.handleResize(y,C),this._fullRefresh())}handleCharSizeChanged(){var y;(y=this._renderer.value)===null||y===void 0||y.handleCharSizeChanged()}handleBlur(){var y;(y=this._renderer.value)===null||y===void 0||y.handleBlur()}handleFocus(){var y;(y=this._renderer.value)===null||y===void 0||y.handleFocus()}handleSelectionChanged(y,C,k){var E;this._selectionState.start=y,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(y,C,k)}handleCursorMove(){var y;(y=this._renderer.value)===null||y===void 0||y.handleCursorMove()}clear(){var y;(y=this._renderer.value)===null||y===void 0||y.clear()}};n.RenderService=f=l([d(2,u.IOptionsService),d(3,w.ICharSizeService),d(4,u.IDecorationService),d(5,u.IBufferService),d(6,w.ICoreBrowserService),d(7,w.IThemeService)],f)},9312:function(v,n,i){var l=this&&this.__decorate||function(b,j,A,L){var T,D=arguments.length,F=D<3?j:L===null?L=Object.getOwnPropertyDescriptor(j,A):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(b,j,A,L);else for(var I=b.length-1;I>=0;I--)(T=b[I])&&(F=(D<3?T(F):D>3?T(j,A,F):T(j,A))||F);return D>3&&F&&Object.defineProperty(j,A,F),F},d=this&&this.__param||function(b,j){return function(A,L){j(A,L,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),m=i(9504),x=i(456),w=i(4725),_=i(8460),a=i(844),h=i(6114),u=i(4841),f=i(511),y=i(2585),C=" ",k=new RegExp(C,"g");let E=n.SelectionService=class extends a.Disposable{constructor(b,j,A,L,T,D,F,I,$){super(),this._element=b,this._screenElement=j,this._linkifier=A,this._bufferService=L,this._coreService=T,this._mouseService=D,this._optionsService=F,this._renderService=I,this._coreBrowserService=$,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=W=>this._handleMouseMove(W),this._mouseUpListener=W=>this._handleMouseUp(W),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((W=>this._handleTrim(W))),this.register(this._bufferService.buffers.onBufferActivate((W=>this._handleBufferActivate(W)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const b=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!b||!j||b[0]===j[0]&&b[1]===j[1])}get selectionText(){const b=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!b||!j)return"";const A=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(b[0]===j[0])return"";const T=b[0]<j[0]?b[0]:j[0],D=b[0]<j[0]?j[0]:b[0];for(let F=b[1];F<=j[1];F++){const I=A.translateBufferLineToString(F,!0,T,D);L.push(I)}}else{const T=b[1]===j[1]?j[0]:void 0;L.push(A.translateBufferLineToString(b[1],!0,b[0],T));for(let D=b[1]+1;D<=j[1]-1;D++){const F=A.lines.get(D),I=A.translateBufferLineToString(D,!0);F?.isWrapped?L[L.length-1]+=I:L.push(I)}if(b[1]!==j[1]){const D=A.lines.get(j[1]),F=A.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?L[L.length-1]+=F:L.push(F)}}return L.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
23
|
+
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=l([d(0,m.IBufferService),d(1,m.IOptionsService),d(2,m.IOscLinkService)],x)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const l=i(844);class d extends l.Disposable{constructor(m){super(),this._parentWindow=m,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(m){this._listener&&this.clearListener(),this._listener=m,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var m;this._outerListener&&((m=this._resolutionMediaMatchList)===null||m===void 0||m.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}n.ScreenDprMonitor=d},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),d=i(3656),c=i(6465),m=i(9042),x=i(3730),w=i(1680),y=i(3107),a=i(5744),h=i(2950),u=i(1296),f=i(428),b=i(4269),C=i(5114),k=i(8934),E=i(3230),_=i(9312),j=i(4725),A=i(6731),P=i(8055),T=i(8969),D=i(8460),W=i(844),I=i(6114),B=i(8437),F=i(2584),R=i(7399),M=i(5941),L=i(9074),O=i(2585),U=i(5435),Y=i(4567),z=typeof window<"u"?window.document:null;class $ extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new W.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(L.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,X)=>this.refresh(H,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,W.toDisposable)((()=>{var H,X;this._customKeyEventHandler=void 0,(X=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const H of N){let X,K="";switch(H.index){case 256:X="foreground",K="10";break;case 257:X="background",K="11";break;case 258:X="cursor",K="12";break;default:X="ansi",K="4;"+H.index}switch(H.type){case 0:const ne=P.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${F.C0.ESC}]${K};${(0,M.toRgbString)(ne)}${F.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((te=>te.ansi[H.index]=P.rgba.toColor(...H.color)));else{const te=X;this._themeService.modifyColors((he=>he[te]=P.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(F.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(F.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(N);if(!H)return;const X=Math.min(this.buffer.x,this.cols-1),K=this._renderService.dimensions.css.cell.height,ne=H.getWidth(X),te=this._renderService.dimensions.css.cell.width*ne,he=this.buffer.y*this._renderService.dimensions.css.cell.height,le=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=le+"px",this.textarea.style.top=he+"px",this.textarea.style.width=te+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,l.copyHandler)(H,this._selectionService)})));const N=H=>(0,l.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,d.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,l.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,l.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,l.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var H;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=z.createDocumentFragment();this._viewportElement=z.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=z.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=z.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=z.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=z.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",m.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(A.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=z.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(_.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(y.BufferDecorationRenderer,this.screenElement)),this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(u.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,H=this.element;function X(te){const he=N._mouseService.getMouseReportCoords(te,N.screenElement);if(!he)return!1;let le,G;switch(te.overrideType||te.type){case"mousemove":G=32,te.buttons===void 0?(le=3,te.button!==void 0&&(le=te.button<3?te.button:3)):le=1&te.buttons?0:4&te.buttons?1:2&te.buttons?2:3;break;case"mouseup":G=0,le=te.button<3?te.button:3;break;case"mousedown":G=1,le=te.button<3?te.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(te)===0)return!1;G=te.deltaY<0?0:1,le=4;break;default:return!1}return!(G===void 0||le===void 0||le>4)&&N.coreMouseService.triggerMouseEvent({col:he.col,row:he.row,x:he.x,y:he.y,button:le,action:G,ctrl:te.ctrlKey,alt:te.altKey,shift:te.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ne={mouseup:te=>(X(te),te.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(te)),wheel:te=>(X(te),this.cancel(te,!0)),mousedrag:te=>{te.buttons&&X(te)},mousemove:te=>{te.buttons||X(te)}};this.register(this.coreMouseService.onProtocolChange((te=>{te?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(te)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&te?K.mousemove||(H.addEventListener("mousemove",ne.mousemove),K.mousemove=ne.mousemove):(H.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&te?K.wheel||(H.addEventListener("wheel",ne.wheel,{passive:!1}),K.wheel=ne.wheel):(H.removeEventListener("wheel",K.wheel),K.wheel=null),2&te?K.mouseup||(H.addEventListener("mouseup",ne.mouseup),K.mouseup=ne.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),H.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&te?K.mousedrag||(K.mousedrag=ne.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(H,"mousedown",(te=>{if(te.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(te))return X(te),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(te)}))),this.register((0,d.addDisposableDomListener)(H,"wheel",(te=>{if(!K.wheel){if(!this.buffer.hasScrollback){const he=this.viewport.getLinesScrolled(te);if(he===0)return;const le=F.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(te.deltaY<0?"A":"B");let G="";for(let pe=0;pe<Math.abs(he);pe++)G+=le;return this.coreService.triggerDataEvent(G,!0),this.cancel(te,!0)}return this.viewport.handleWheel(te)?this.cancel(te):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(H,"touchstart",(te=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(te),this.cancel(te)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(H,"touchmove",(te=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(te)?void 0:this.cancel(te)}),{passive:!1}))}refresh(N,H){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,H)}updateCursorStyle(N){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,H,X=0){var K;X===1?(super.scrollLines(N,H,X),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,H,X){this._selectionService.setSelection(N,H,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,H){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,H)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!H&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,R.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const K=this.rows-1;return this.scrollLines(X.type===2?-K:K),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==F.C0.ETX&&X.key!==F.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,H){const X=N.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||N.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||N.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?X:X&&(!H.keyCode||H.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)H=N.charCode;else if(N.which===null||N.which===void 0)H=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;H=N.which}return!(!H||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=N.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(N),!0}return!1}resize(N,H){N!==this.cols||H!==this.rows?super.resize(N,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,H){var X,K;(X=this._charSizeService)===null||X===void 0||X.measure(),(K=this.viewport)===null||K===void 0||K.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(B.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,H;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(F.C0.ESC+"[I"):this.coreService.triggerDataEvent(F.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${F.C0.ESC}[4;${X};${H}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),ne=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${F.C0.ESC}[6;${ne};${K}t`)}}cancel(N,H){if(this.options.cancelEvents||H)return N.preventDefault(),N.stopPropagation(),!1}}n.Terminal=$},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const m=c-this._lastRefreshMs,x=this._debounceThresholdMS-m;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(v,n,i){var l=this&&this.__decorate||function(h,u,f,b){var C,k=arguments.length,E=k<3?u:b===null?b=Object.getOwnPropertyDescriptor(u,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,b);else for(var _=h.length-1;_>=0;_--)(C=h[_])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,b){u(f,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),m=i(4725),x=i(8460),w=i(844),y=i(2585);let a=n.Viewport=class extends w.Disposable{constructor(h,u,f,b,C,k,E,_){super(),this._viewportElement=h,this._scrollArea=u,this._bufferService=f,this._optionsService=b,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(_.colors),this.register(_.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const u=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==u&&(this._lastRecordedBufferHeight=u,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const u=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,u){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(u<0&&this._viewportElement.scrollTop!==0||u>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const u=this._getPixelsScrolled(h);return u!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+u:this._smoothScrollState.target+=u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const u=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?u*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._currentRowHeight*this._bufferService.rows),u}getBufferElements(h,u){var f;let b,C="";const k=[],E=u??this._bufferService.buffer.lines.length,_=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const A=_.get(j);if(!A)continue;const P=(f=_.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=A.translateToString(!P),!P||j===_.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(b=T),C=""}}return{bufferElements:k,cursorElement:b}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(u/=this._currentRowHeight+0,this._wheelPartialScroll+=u,u=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._bufferService.rows),u}_applyScrollModifier(h,u){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&u.altKey||f==="ctrl"&&u.ctrlKey||f==="shift"&&u.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const u=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,u!==0&&(this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}};n.Viewport=a=l([d(2,y.IBufferService),d(3,y.IOptionsService),d(4,m.ICharSizeService),d(5,m.IRenderService),d(6,m.ICoreBrowserService),d(7,m.IThemeService)],a)},3107:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),m=i(4725),x=i(844),w=i(2585);let y=n.BufferDecorationRenderer=class extends x.Disposable{constructor(a,h,u,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=u,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((b=>this._removeDecoration(b)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,u;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(u=a.options.x)!==null&&u!==void 0?u:0;return b&&b>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let u=this._decorationElements.get(a);u||(u=this._createElement(a),a.element=u,this._decorationElements.set(a,u),this._container.appendChild(u),a.onDispose((()=>{this._decorationElements.delete(a),u.remove()}))),u.style.top=h*this._renderService.dimensions.css.cell.height+"px",u.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(u)}}_refreshXPosition(a,h=a.element){var u;if(!h)return;const f=(u=a.options.x)!==null&&u!==void 0?u:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=y=l([d(1,w.IBufferService),d(2,w.IDecorationService),d(3,m.IRenderService)],y)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,d){return l>=i.startBufferLine-this._linePadding[d||"full"]&&l<=i.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(v,n,i){var l=this&&this.__decorate||function(b,C,k,E){var _,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,C,k,E);else for(var P=b.length-1;P>=0;P--)(_=b[P])&&(A=(j<3?_(A):j>3?_(C,k,A):_(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(b,C){return function(k,E){C(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),m=i(3656),x=i(4725),w=i(844),y=i(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends w.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,C,k,E,_,j,A){var P;super(),this._viewportElement=b,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=_,this._optionsService=j,this._coreBrowseService=A,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(P=this._viewportElement.parentElement)===null||P===void 0||P.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,w.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,m.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=C,h.right=b,this._refreshDrawHeightConstants(),u.full=0,u.left=0,u.center=h.left,u.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=C,a.center=C,a.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const C of b)C.position!=="full"&&this._renderColorZone(C);for(const C of b)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(u[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,C){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=l([d(2,y.IBufferService),d(3,y.IDecorationService),d(4,x.IRenderService),d(5,y.IOptionsService),d(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var l=this&&this.__decorate||function(y,a,h,u){var f,b=arguments.length,C=b<3?a:u===null?u=Object.getOwnPropertyDescriptor(a,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,a,h,u);else for(var k=y.length-1;k>=0;k--)(f=y[k])&&(C=(b<3?f(C):b>3?f(a,h,C):f(a,h))||C);return b>3&&C&&Object.defineProperty(a,h,C),C},d=this&&this.__param||function(y,a){return function(h,u){a(h,u,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),m=i(2585),x=i(2584);let w=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(y,a,h,u,f,b){this._textarea=y,this._compositionView=a,this._bufferService=h,this._optionsService=u,this._coreService=f,this._renderService=b,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(y){this._compositionView.textContent=y.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(y){if(this._isComposing||this._isSendingComposition){if(y.keyCode===229||y.keyCode===16||y.keyCode===17||y.keyCode===18)return!1;this._finalizeComposition(!1)}return y.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(y){if(this._compositionView.classList.remove("active"),this._isComposing=!1,y){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const y=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(y,"");this._dataAlreadySent=h,a.length>y.length?this._coreService.triggerDataEvent(h,!0):a.length<y.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===y.length&&a!==y&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(y){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,u=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=u+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const b=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=u+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}y||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=w=l([d(2,m.IBufferService),d(3,m.IOptionsService),d(4,m.ICoreService),d(5,c.IRenderService)],w)},9806:(v,n)=>{function i(l,d,c){const m=c.getBoundingClientRect(),x=l.getComputedStyle(c),w=parseInt(x.getPropertyValue("padding-left")),y=parseInt(x.getPropertyValue("padding-top"));return[d.clientX-m.left-w,d.clientY-m.top-y]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,d,c,m,x,w,y,a,h){if(!w)return;const u=i(l,d,c);return u?(u[0]=Math.ceil((u[0]+(h?y/2:0))/y),u[1]=Math.ceil(u[1]/a),u[0]=Math.min(Math.max(u[0],1),m+(h?1:0)),u[1]=Math.min(Math.max(u[1],1),x),u):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const l=i(2584);function d(a,h,u,f){const b=a-c(a,u),C=h-c(h,u),k=Math.abs(b-C)-(function(E,_,j){let A=0;const P=E-c(E,j),T=_-c(_,j);for(let D=0;D<Math.abs(P-T);D++){const W=m(E,_)==="A"?-1:1,I=j.buffer.lines.get(P+W*D);I?.isWrapped&&A++}return A})(a,h,u);return y(k,w(m(a,h),f))}function c(a,h){let u=0,f=h.buffer.lines.get(a),b=f?.isWrapped;for(;b&&a>=0&&a<h.rows;)u++,f=h.buffer.lines.get(--a),b=f?.isWrapped;return u}function m(a,h){return a>h?"A":"B"}function x(a,h,u,f,b,C){let k=a,E=h,_="";for(;k!==u||E!==f;)k+=b?1:-1,b&&k>C.cols-1?(_+=C.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!b&&k<0&&(_+=C.buffer.translateBufferLineToString(E,!1,0,a+1),k=C.cols-1,a=k,E--);return _+C.buffer.translateBufferLineToString(E,!1,a,k)}function w(a,h){const u=h?"O":"[";return l.C0.ESC+u+a}function y(a,h){a=Math.floor(a);let u="";for(let f=0;f<a;f++)u+=h;return u}n.moveToCellSequence=function(a,h,u,f){const b=u.buffer.x,C=u.buffer.y;if(!u.buffer.hasScrollback)return(function(_,j,A,P,T,D){return d(j,P,T,D).length===0?"":y(x(_,j,_,j-c(j,T),!1,T).length,w("D",D))})(b,C,0,h,u,f)+d(C,h,u,f)+(function(_,j,A,P,T,D){let W;W=d(j,P,T,D).length>0?P-c(P,T):j;const I=P,B=(function(F,R,M,L,O,U){let Y;return Y=d(M,L,O,U).length>0?L-c(L,O):R,F<M&&Y<=L||F>=M&&Y<L?"C":"D"})(_,j,A,P,T,D);return y(x(_,W,A,I,B==="C",T).length,w(B,D))})(b,C,a,h,u,f);let k;if(C===h)return k=b>a?"D":"C",y(Math.abs(b-a),w(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return y((function(_,j){return j.cols-_})(C>h?a:b,u)+(E-1)*u.cols+1+((C>h?b:a)-1),w(k,f))}},1296:function(v,n,i){var l=this&&this.__decorate||function(T,D,W,I){var B,F=arguments.length,R=F<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,W):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(T,D,W,I);else for(var M=T.length-1;M>=0;M--)(B=T[M])&&(R=(F<3?B(R):F>3?B(D,W,R):B(D,W))||R);return F>3&&R&&Object.defineProperty(D,W,R),R},d=this&&this.__param||function(T,D){return function(W,I){D(W,I,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),m=i(2550),x=i(2223),w=i(6171),y=i(4725),a=i(8055),h=i(8460),u=i(844),f=i(2585),b="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",_="xterm-focus",j="xterm-selection";let A=1,P=n.DomRenderer=class extends u.Disposable{constructor(T,D,W,I,B,F,R,M,L,O){super(),this._element=T,this._screenElement=D,this._viewportElement=W,this._linkifier2=I,this._charSizeService=F,this._optionsService=R,this._bufferService=M,this._coreBrowserService=L,this._themeService=O,this._terminalClass=A++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=B.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,u.toDisposable)((()=>{this._element.classList.remove(b+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new m.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const W of this._rowElements)W.style.width=`${this.dimensions.css.canvas.width}px`,W.style.height=`${this.dimensions.css.cell.height}px`,W.style.lineHeight=`${this.dimensions.css.cell.height}px`,W.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${C} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${C}.${_} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[W,I]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${W} { color: ${I.css}; }${this._terminalSelector} .${k}${W}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${W} { background-color: ${I.css}; }`;D+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let W=this._rowElements.length;W<=D;W++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(_)}handleFocus(){this._rowContainer.classList.add(_),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,W){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,W),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const I=T[1]-this._bufferService.buffer.ydisp,B=D[1]-this._bufferService.buffer.ydisp,F=Math.max(I,0),R=Math.min(B,this._bufferService.rows-1);if(F>=this._bufferService.rows||R<0)return;const M=document.createDocumentFragment();if(W){const L=T[0]>D[0];M.appendChild(this._createSelectionElement(F,L?D[0]:T[0],L?T[0]:D[0],R-F+1))}else{const L=I===F?T[0]:0,O=F===B?D[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(F,L,O));const U=R-F-1;if(M.appendChild(this._createSelectionElement(F+1,0,this._bufferService.cols,U)),F!==R){const Y=B===R?D[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(R,0,Y))}}this._selectionContainer.appendChild(M)}_createSelectionElement(T,D,W,I=1){const B=document.createElement("div");return B.style.height=I*this.dimensions.css.cell.height+"px",B.style.top=T*this.dimensions.css.cell.height+"px",B.style.left=D*this.dimensions.css.cell.width+"px",B.style.width=this.dimensions.css.cell.width*(W-D)+"px",B}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,D){const W=this._bufferService.buffer,I=W.ybase+W.y,B=Math.min(W.x,this._bufferService.cols-1),F=this._optionsService.rawOptions.cursorBlink,R=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let L=T;L<=D;L++){const O=L+W.ydisp,U=this._rowElements[L],Y=W.lines.get(O);if(!U||!Y)break;U.replaceChildren(...this._rowFactory.createRow(Y,O,O===I,R,M,B,F,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,W,I,B,F){W<0&&(T=0),I<0&&(D=0);const R=this._bufferService.rows-1;W=Math.max(Math.min(W,R),0),I=Math.max(Math.min(I,R),0),B=Math.min(B,this._bufferService.cols);const M=this._bufferService.buffer,L=M.ybase+M.y,O=Math.min(M.x,B-1),U=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,z=this._optionsService.rawOptions.cursorInactiveStyle;for(let $=W;$<=I;++$){const q=$+M.ydisp,N=this._rowElements[$],H=M.lines.get(q);if(!N||!H)break;N.replaceChildren(...this._rowFactory.createRow(H,q,q===L,Y,z,O,U,this.dimensions.css.cell.width,this._widthCache,F?$===W?T:0:-1,F?($===I?D:B)-1:-1))}}};n.DomRenderer=P=l([d(4,f.IInstantiationService),d(5,y.ICharSizeService),d(6,f.IOptionsService),d(7,f.IBufferService),d(8,y.ICoreBrowserService),d(9,y.IThemeService)],P)},3787:function(v,n,i){var l=this&&this.__decorate||function(k,E,_,j){var A,P=arguments.length,T=P<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,_,j);else for(var D=k.length-1;D>=0;D--)(A=k[D])&&(T=(P<3?A(T):P>3?A(E,_,T):A(E,_))||T);return P>3&&T&&Object.defineProperty(E,_,T),T},d=this&&this.__param||function(k,E){return function(_,j){E(_,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),m=i(643),x=i(511),w=i(2585),y=i(8055),a=i(4725),h=i(4269),u=i(6171),f=i(3734);let b=n.DomRendererRowFactory=class{constructor(k,E,_,j,A,P,T){this._document=k,this._characterJoinerService=E,this._optionsService=_,this._coreBrowserService=j,this._coreService=A,this._decorationService=P,this._themeService=T,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,_){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=_}createRow(k,E,_,j,A,P,T,D,W,I,B){const F=[],R=this._characterJoinerService.getJoinedCharacters(E),M=this._themeService.colors;let L,O=k.getNoBgTrimmedLength();_&&O<P+1&&(O=P+1);let U=0,Y="",z=0,$=0,q=0,N=!1,H=0,X=!1,K=0;const ne=[],te=I!==-1&&B!==-1;for(let he=0;he<O;he++){k.loadCell(he,this._workCell);let le=this._workCell.getWidth();if(le===0)continue;let G=!1,pe=he,ie=this._workCell;if(R.length>0&&he===R[0][0]){G=!0;const ge=R.shift();ie=new h.JoinedCellData(this._workCell,k.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),pe=ge[1]-1,le=ie.getWidth()}const Ae=this._isCellInSelection(he,E),at=_&&he===P,Xe=te&&he>=I&&he<=B;let _e=!1;this._decorationService.forEachDecorationAtCell(he,E,void 0,(ge=>{_e=!0}));let Ie=ie.getChars()||m.WHITESPACE_CELL_CHAR;if(Ie===" "&&(ie.isUnderline()||ie.isOverline())&&(Ie=" "),K=le*D-W.get(Ie,ie.isBold(),ie.isItalic()),L){if(U&&(Ae&&X||!Ae&&!X&&ie.bg===z)&&(Ae&&X&&M.selectionForeground||ie.fg===$)&&ie.extended.ext===q&&Xe===N&&K===H&&!at&&!G&&!_e){Y+=Ie,U++;continue}U&&(L.textContent=Y),L=this._document.createElement("span"),U=0,Y=""}else L=this._document.createElement("span");if(z=ie.bg,$=ie.fg,q=ie.extended.ext,N=Xe,H=K,X=Ae,G&&P>=he&&P<=pe&&(P=he),!this._coreService.isCursorHidden&&at){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ne.push("xterm-cursor-blink"),ne.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(A)switch(A){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline")}}if(ie.isBold()&&ne.push("xterm-bold"),ie.isItalic()&&ne.push("xterm-italic"),ie.isDim()&&ne.push("xterm-dim"),Y=ie.isInvisible()?m.WHITESPACE_CELL_CHAR:ie.getChars()||m.WHITESPACE_CELL_CHAR,ie.isUnderline()&&(ne.push(`xterm-underline-${ie.extended.underlineStyle}`),Y===" "&&(Y=" "),!ie.isUnderlineColorDefault()))if(ie.isUnderlineColorRGB())L.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(ie.getUnderlineColor()).join(",")})`;else{let ge=ie.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ie.isBold()&&ge<8&&(ge+=8),L.style.textDecorationColor=M.ansi[ge].css}ie.isOverline()&&(ne.push("xterm-overline"),Y===" "&&(Y=" ")),ie.isStrikethrough()&&ne.push("xterm-strikethrough"),Xe&&(L.style.textDecoration="underline");let Pe=ie.getFgColor(),$e=ie.getFgColorMode(),Oe=ie.getBgColor(),Ve=ie.getBgColorMode();const Ze=!!ie.isInverse();if(Ze){const ge=Pe;Pe=Oe,Oe=ge;const lt=$e;$e=Ve,Ve=lt}let Me,Re,ve,Fe=!1;switch(this._decorationService.forEachDecorationAtCell(he,E,void 0,(ge=>{ge.options.layer!=="top"&&Fe||(ge.backgroundColorRGB&&(Ve=50331648,Oe=ge.backgroundColorRGB.rgba>>8&16777215,Me=ge.backgroundColorRGB),ge.foregroundColorRGB&&($e=50331648,Pe=ge.foregroundColorRGB.rgba>>8&16777215,Re=ge.foregroundColorRGB),Fe=ge.options.layer==="top")})),!Fe&&Ae&&(Me=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,Oe=Me.rgba>>8&16777215,Ve=50331648,Fe=!0,M.selectionForeground&&($e=50331648,Pe=M.selectionForeground.rgba>>8&16777215,Re=M.selectionForeground)),Fe&&ne.push("xterm-decoration-top"),Ve){case 16777216:case 33554432:ve=M.ansi[Oe],ne.push(`xterm-bg-${Oe}`);break;case 50331648:ve=y.rgba.toColor(Oe>>16,Oe>>8&255,255&Oe),this._addStyle(L,`background-color:#${C((Oe>>>0).toString(16),"0",6)}`);break;default:Ze?(ve=M.foreground,ne.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):ve=M.background}switch(Me||ie.isDim()&&(Me=y.color.multiplyOpacity(ve,.5)),$e){case 16777216:case 33554432:ie.isBold()&&Pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Pe+=8),this._applyMinimumContrast(L,ve,M.ansi[Pe],ie,Me,void 0)||ne.push(`xterm-fg-${Pe}`);break;case 50331648:const ge=y.rgba.toColor(Pe>>16&255,Pe>>8&255,255&Pe);this._applyMinimumContrast(L,ve,ge,ie,Me,Re)||this._addStyle(L,`color:#${C(Pe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(L,ve,M.foreground,ie,Me,void 0)||Ze&&ne.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ne.length&&(L.className=ne.join(" "),ne.length=0),at||G||_e?L.textContent=Y:U++,K!==this.defaultSpacing&&(L.style.letterSpacing=`${K}px`),F.push(L),he=pe}return L&&U&&(L.textContent=Y),F}_applyMinimumContrast(k,E,_,j,A,P){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,u.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(A||P||(D=T.getColor(E.rgba,_.rgba)),D===void 0){const W=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=y.color.ensureContrastRatio(A||E,P||_,W),T.setColor((A||E).rgba,(P||_).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const _=this._selectionStart,j=this._selectionEnd;return!(!_||!j)&&(this._columnSelectMode?_[0]<=j[0]?k>=_[0]&&E>=_[1]&&k<j[0]&&E<=j[1]:k<_[0]&&E>=_[1]&&k>=j[0]&&E<=j[1]:E>_[1]&&E<j[1]||_[1]===j[1]&&E===_[1]&&k>=_[0]&&k<j[0]||_[1]<j[1]&&E===j[1]&&k<j[0]||_[1]<j[1]&&E===_[1]&&k>=_[0])}};function C(k,E,_){for(;k.length<_;)k=E+k;return k}n.DomRendererRowFactory=b=l([d(1,a.ICharacterJoinerService),d(2,w.IOptionsService),d(3,a.ICoreBrowserService),d(4,w.ICoreService),d(5,w.IDecorationService),d(6,a.IThemeService)],b)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=i.createElement("span"),d=i.createElement("span");d.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const m=i.createElement("span");m.style.fontWeight="bold",m.style.fontStyle="italic",this._measureElements=[l,d,c,m],this._container.appendChild(l),this._container.appendChild(d),this._container.appendChild(c),this._container.appendChild(m),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,l,d,c){i===this._font&&l===this._fontSize&&d===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=d,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,d){let c=0;if(!l&&!d&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let m=i;l&&(m+="B"),d&&(m+="I");let x=this._holey.get(m);if(x===void 0){let w=0;l&&(w|=1),d&&(w|=2),x=this._measure(i,w),this._holey.set(m,x)}return x}_measure(i,l){const d=this._measureElements[l];return d.textContent=i.repeat(32),d.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},n.excludeFromContrastRatioDemands=function(l){return i(l)||(function(d){return 9472<=d&&d<=9631})(l)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),m=i(8460),x=i(844);let w=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,u){super(),this._optionsService=u,this.width=0,this.height=0,this._onCharSizeChange=this.register(new m.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new y(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=w=l([d(2,c.IOptionsService)],w);class y{constructor(h,u,f){this._document=h,this._parentElement=u,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var l=this&&this.__decorate||function(h,u,f,b){var C,k=arguments.length,E=k<3?u:b===null?b=Object.getOwnPropertyDescriptor(u,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,b);else for(var _=h.length-1;_>=0;_--)(C=h[_])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,b){u(f,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),m=i(643),x=i(511),w=i(2585);class y extends c.AttributeData{constructor(u,f,b){super(),this.content=0,this.combinedData="",this.fg=u.fg,this.bg=u.bg,this.combinedData=f,this._width=b}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(u){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=y;let a=n.CharacterJoinerService=class Al{constructor(u){this._bufferService=u,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(u){const f={id:this._nextCharacterJoinerId++,handler:u};return this._characterJoiners.push(f),f.id}deregister(u){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===u)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(u){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(u);if(!f||f.length===0)return[];const b=[],C=f.translateToString(!0);let k=0,E=0,_=0,j=f.getFg(0),A=f.getBg(0);for(let P=0;P<f.getTrimmedLength();P++)if(f.loadCell(P,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==A){if(P-k>1){const T=this._getJoinedRanges(C,_,E,f,k);for(let D=0;D<T.length;D++)b.push(T[D])}k=P,_=E,j=this._workCell.fg,A=this._workCell.bg}E+=this._workCell.getChars().length||m.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const P=this._getJoinedRanges(C,_,E,f,k);for(let T=0;T<P.length;T++)b.push(P[T])}return b}_getJoinedRanges(u,f,b,C,k){const E=u.substring(f,b);let _=[];try{_=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const A=this._characterJoiners[j].handler(E);for(let P=0;P<A.length;P++)Al._mergeRanges(_,A[P])}catch(A){console.error(A)}return this._stringRangesToCellRanges(_,C,k),_}_stringRangesToCellRanges(u,f,b){let C=0,k=!1,E=0,_=u[C];if(_){for(let j=b;j<this._bufferService.cols;j++){const A=f.getWidth(j),P=f.getString(j).length||m.WHITESPACE_CELL_CHAR.length;if(A!==0){if(!k&&_[0]<=E&&(_[0]=j,k=!0),_[1]<=E){if(_[1]=j,_=u[++C],!_)break;_[0]<=E?(_[0]=j,k=!0):k=!1}E+=P}}_&&(_[1]=this._bufferService.cols)}}static _mergeRanges(u,f){let b=!1;for(let C=0;C<u.length;C++){const k=u[C];if(b){if(f[1]<=k[0])return u[C-1][1]=f[1],u;if(f[1]<=k[1])return u[C-1][1]=Math.max(f[1],k[1]),u.splice(C,1),u;u.splice(C,1),C--}else{if(f[1]<=k[0])return u.splice(C,0,f),u;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),u;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),b=!0)}}return b?u[u.length-1][1]=f[1]:u.push(f),u}};n.CharacterJoinerService=a=l([d(0,w.IBufferService)],a)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,n,i){var l=this&&this.__decorate||function(w,y,a,h){var u,f=arguments.length,b=f<3?y:h===null?h=Object.getOwnPropertyDescriptor(y,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(w,y,a,h);else for(var C=w.length-1;C>=0;C--)(u=w[C])&&(b=(f<3?u(b):f>3?u(y,a,b):u(y,a))||b);return f>3&&b&&Object.defineProperty(y,a,b),b},d=this&&this.__param||function(w,y){return function(a,h){y(a,h,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),m=i(9806);let x=n.MouseService=class{constructor(w,y){this._renderService=w,this._charSizeService=y}getCoords(w,y,a,h,u){return(0,m.getCoords)(window,w,y,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,u)}getMouseReportCoords(w,y){const a=(0,m.getCoordsRelativeToElement)(window,w,y);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=x=l([d(0,c.IRenderService),d(1,c.ICharSizeService)],x)},3230:function(v,n,i){var l=this&&this.__decorate||function(b,C,k,E){var _,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,C,k,E);else for(var P=b.length-1;P>=0;P--)(_=b[P])&&(A=(j<3?_(A):j>3?_(C,k,A):_(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(b,C){return function(k,E){C(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),m=i(6193),x=i(5596),w=i(4725),y=i(8460),a=i(844),h=i(7226),u=i(2585);let f=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,C,k,E,_,j,A,P){if(super(),this._rowCount=b,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(A.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(A.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(_.onDecorationRegistered((()=>this._fullRefresh()))),this.register(_.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(A.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(P.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in A.window){const T=new A.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,C,this._rowCount))}_renderRows(b,C){this._renderer.value&&(b=Math.min(b,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(b,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:C}),this._onRender.fire({start:b,end:C}),this._isNextRenderRedrawOnly=!0)}resize(b,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,C;this._renderer.value&&((C=(b=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,C))):this._renderer.value.handleResize(b,C),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,C,k){var E;this._selectionState.start=b,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(b,C,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};n.RenderService=f=l([d(2,u.IOptionsService),d(3,w.ICharSizeService),d(4,u.IDecorationService),d(5,u.IBufferService),d(6,w.ICoreBrowserService),d(7,w.IThemeService)],f)},9312:function(v,n,i){var l=this&&this.__decorate||function(_,j,A,P){var T,D=arguments.length,W=D<3?j:P===null?P=Object.getOwnPropertyDescriptor(j,A):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(_,j,A,P);else for(var I=_.length-1;I>=0;I--)(T=_[I])&&(W=(D<3?T(W):D>3?T(j,A,W):T(j,A))||W);return D>3&&W&&Object.defineProperty(j,A,W),W},d=this&&this.__param||function(_,j){return function(A,P){j(A,P,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),m=i(9504),x=i(456),w=i(4725),y=i(8460),a=i(844),h=i(6114),u=i(4841),f=i(511),b=i(2585),C=" ",k=new RegExp(C,"g");let E=n.SelectionService=class extends a.Disposable{constructor(_,j,A,P,T,D,W,I,B){super(),this._element=_,this._screenElement=j,this._linkifier=A,this._bufferService=P,this._coreService=T,this._mouseService=D,this._optionsService=W,this._renderService=I,this._coreBrowserService=B,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new y.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new y.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new y.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=F=>this._handleMouseMove(F),this._mouseUpListener=F=>this._handleMouseUp(F),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((F=>this._handleTrim(F))),this.register(this._bufferService.buffers.onBufferActivate((F=>this._handleBufferActivate(F)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!_||!j||_[0]===j[0]&&_[1]===j[1])}get selectionText(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!_||!j)return"";const A=this._bufferService.buffer,P=[];if(this._activeSelectionMode===3){if(_[0]===j[0])return"";const T=_[0]<j[0]?_[0]:j[0],D=_[0]<j[0]?j[0]:_[0];for(let W=_[1];W<=j[1];W++){const I=A.translateBufferLineToString(W,!0,T,D);P.push(I)}}else{const T=_[1]===j[1]?j[0]:void 0;P.push(A.translateBufferLineToString(_[1],!0,_[0],T));for(let D=_[1]+1;D<=j[1]-1;D++){const W=A.lines.get(D),I=A.translateBufferLineToString(D,!0);W?.isWrapped?P[P.length-1]+=I:P.push(I)}if(_[1]!==j[1]){const D=A.lines.get(j[1]),W=A.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?P[P.length-1]+=W:P.push(W)}}return P.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
24
24
|
`:`
|
|
25
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(b){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&b&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(b){const j=this._getMouseBufferCoords(b),A=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(A&&L&&j)&&this._areCoordsInSelection(j,A,L)}isCellInSelection(b,j){const A=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!A||!L)&&this._areCoordsInSelection([b,j],A,L)}_areCoordsInSelection(b,j,A){return b[1]>j[1]&&b[1]<A[1]||j[1]===A[1]&&b[1]===j[1]&&b[0]>=j[0]&&b[0]<A[0]||j[1]<A[1]&&b[1]===A[1]&&b[0]<A[0]||j[1]<A[1]&&b[1]===j[1]&&b[0]>=j[0]}_selectWordAtCursor(b,j){var A,L;const T=(L=(A=this._linkifier.currentLink)===null||A===void 0?void 0:A.link)===null||L===void 0?void 0:L.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,u.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(b);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(b,j){this._model.clearSelection(),b=Math.max(b,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,b],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(b){this._model.handleTrim(b)&&this.refresh()}_getMouseBufferCoords(b){const j=this._mouseService.getCoords(b,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(b){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,b,this._screenElement)[1];const A=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=A?0:(j>A&&(j-=A),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(b){return h.isMac?b.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:b.shiftKey}handleMouseDown(b){if(this._mouseDownTimeStamp=b.timeStamp,(b.button!==2||!this.hasSelection)&&b.button===0){if(!this._enabled){if(!this.shouldForceSelection(b))return;b.stopPropagation()}b.preventDefault(),this._dragScrollAmount=0,this._enabled&&b.shiftKey?this._handleIncrementalClick(b):b.detail===1?this._handleSingleClick(b):b.detail===2?this._handleDoubleClick(b):b.detail===3&&this._handleTripleClick(b),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(b){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(b))}_handleSingleClick(b){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(b)?3:0,this._model.selectionStart=this._getMouseBufferCoords(b),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(b){this._selectWordAtCursor(b,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(b){const j=this._getMouseBufferCoords(b);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(b){return b.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(b){if(b.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(b),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(b),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const A=this._bufferService.buffer;if(this._model.selectionEnd[1]<A.lines.length){const L=A.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const b=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(b.ydisp+this._bufferService.rows,b.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=b.ydisp),this.refresh()}}_handleMouseUp(b){const j=b.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&b.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const A=this._mouseService.getCoords(b,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(A&&A[0]!==void 0&&A[1]!==void 0){const L=(0,m.moveToCellSequence)(A[0]-1,A[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const b=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,A=!(!b||!j||b[0]===j[0]&&b[1]===j[1]);A?b&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&b[0]===this._oldSelectionStart[0]&&b[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(b,j,A)):this._oldHasSelection&&this._fireOnSelectionChange(b,j,A)}_fireOnSelectionChange(b,j,A){this._oldSelectionStart=b,this._oldSelectionEnd=j,this._oldHasSelection=A,this._onSelectionChange.fire()}_handleBufferActivate(b){this.clearSelection(),this._trimListener.dispose(),this._trimListener=b.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(b,j){let A=j;for(let L=0;j>=L;L++){const T=b.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?A--:T>1&&j!==L&&(A+=T-1)}return A}setSelection(b,j,A){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[b,j],this._model.selectionStartLength=A,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(b){this._isClickInSelection(b)||(this._selectWordAtCursor(b,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(b,j,A=!0,L=!0){if(b[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(b[1]);if(!D)return;const F=T.translateBufferLineToString(b[1],!1);let I=this._convertViewportColToCharacterIndex(D,b[0]),$=I;const W=b[0]-I;let R=0,M=0,P=0,O=0;if(F.charAt(I)===" "){for(;I>0&&F.charAt(I-1)===" ";)I--;for(;$<F.length&&F.charAt($+1)===" ";)$++}else{let B=b[0],H=b[0];D.getWidth(B)===0&&(R++,B--),D.getWidth(H)===2&&(M++,H++);const q=D.getString(H).length;for(q>1&&(O+=q-1,$+=q-1);B>0&&I>0&&!this._isCharWordSeparator(D.loadCell(B-1,this._workCell));){D.loadCell(B-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(R++,B--):N>1&&(P+=N-1,I-=N-1),I--,B--}for(;H<D.length&&$+1<F.length&&!this._isCharWordSeparator(D.loadCell(H+1,this._workCell));){D.loadCell(H+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,H++):N>1&&(O+=N-1,$+=N-1),$++,H++}}$++;let U=I+W-R+P,Y=Math.min(this._bufferService.cols,$-I+R+M-P-O);if(j||F.slice(I,$).trim()!==""){if(A&&U===0&&D.getCodePoint(0)!==32){const B=T.lines.get(b[1]-1);if(B&&D.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){const H=this._getWordAt([this._bufferService.cols-1,b[1]-1],!1,!0,!1);if(H){const q=this._bufferService.cols-H.start;U-=q,Y+=q}}}if(L&&U+Y===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const B=T.lines.get(b[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){const H=this._getWordAt([0,b[1]+1],!1,!1,!0);H&&(Y+=H.length)}}return{start:U,length:Y}}}_selectWordAt(b,j){const A=this._getWordAt(b,j);if(A){for(;A.start<0;)A.start+=this._bufferService.cols,b[1]--;this._model.selectionStart=[A.start,b[1]],this._model.selectionStartLength=A.length}}_selectToWordAt(b){const j=this._getWordAt(b,!0);if(j){let A=b[1];for(;j.start<0;)j.start+=this._bufferService.cols,A--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,A++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,A]}}_isCharWordSeparator(b){return b.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(b.getChars())>=0}_selectLineAt(b){const j=this._bufferService.buffer.getWrappedRangeForLine(b),A={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,u.getRangeLength)(A,this._bufferService.cols)}};n.SelectionService=E=l([d(3,y.IBufferService),d(4,y.ICoreService),d(5,w.IMouseService),d(6,y.IOptionsService),d(7,w.IRenderService),d(8,w.ICoreBrowserService)],E)},4725:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const l=i(8343);n.ICharSizeService=(0,l.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),n.IMouseService=(0,l.createDecorator)("MouseService"),n.IRenderService=(0,l.createDecorator)("RenderService"),n.ISelectionService=(0,l.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,n,i){var l=this&&this.__decorate||function(E,b,j,A){var L,T=arguments.length,D=T<3?b:A===null?A=Object.getOwnPropertyDescriptor(b,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,b,j,A);else for(var F=E.length-1;F>=0;F--)(L=E[F])&&(D=(T<3?L(D):T>3?L(b,j,D):L(b,j))||D);return T>3&&D&&Object.defineProperty(b,j,D),D},d=this&&this.__param||function(E,b){return function(j,A){b(j,A,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=i(7239),m=i(8055),x=i(8460),w=i(844),_=i(2585),a=m.css.toColor("#ffffff"),h=m.css.toColor("#000000"),u=m.css.toColor("#ffffff"),f=m.css.toColor("#000000"),y={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[m.css.toColor("#2e3436"),m.css.toColor("#cc0000"),m.css.toColor("#4e9a06"),m.css.toColor("#c4a000"),m.css.toColor("#3465a4"),m.css.toColor("#75507b"),m.css.toColor("#06989a"),m.css.toColor("#d3d7cf"),m.css.toColor("#555753"),m.css.toColor("#ef2929"),m.css.toColor("#8ae234"),m.css.toColor("#fce94f"),m.css.toColor("#729fcf"),m.css.toColor("#ad7fa8"),m.css.toColor("#34e2e2"),m.css.toColor("#eeeeec")],b=[0,95,135,175,215,255];for(let j=0;j<216;j++){const A=b[j/36%6|0],L=b[j/6%6|0],T=b[j%6];E.push({css:m.channels.toCss(A,L,T),rgba:m.channels.toRgba(A,L,T)})}for(let j=0;j<24;j++){const A=8+10*j;E.push({css:m.channels.toCss(A,A,A),rgba:m.channels.toRgba(A,A,A)})}return E})());let C=n.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:u,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:y,selectionBackgroundOpaque:m.color.blend(h,y),selectionInactiveBackgroundTransparent:y,selectionInactiveBackgroundOpaque:m.color.blend(h,y),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const b=this._colors;if(b.foreground=k(E.foreground,a),b.background=k(E.background,h),b.cursor=k(E.cursor,u),b.cursorAccent=k(E.cursorAccent,f),b.selectionBackgroundTransparent=k(E.selectionBackground,y),b.selectionBackgroundOpaque=m.color.blend(b.background,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundOpaque=m.color.blend(b.background,b.selectionInactiveBackgroundTransparent),b.selectionForeground=E.selectionForeground?k(E.selectionForeground,m.NULL_COLOR):void 0,b.selectionForeground===m.NULL_COLOR&&(b.selectionForeground=void 0),m.color.isOpaque(b.selectionBackgroundTransparent)&&(b.selectionBackgroundTransparent=m.color.opacity(b.selectionBackgroundTransparent,.3)),m.color.isOpaque(b.selectionInactiveBackgroundTransparent)&&(b.selectionInactiveBackgroundTransparent=m.color.opacity(b.selectionInactiveBackgroundTransparent,.3)),b.ansi=n.DEFAULT_ANSI_COLORS.slice(),b.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),b.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),b.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),b.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),b.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),b.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),b.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),b.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),b.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),b.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),b.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),b.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),b.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),b.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),b.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),b.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(b.ansi.length-16,E.extendedAnsi.length);for(let A=0;A<j;A++)b.ansi[A+16]=k(E.extendedAnsi[A],n.DEFAULT_ANSI_COLORS[A+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let b=0;b<this._restoreColors.ansi.length;++b)this._colors.ansi[b]=this._restoreColors.ansi[b]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,b){if(E!==void 0)try{return m.css.toColor(E)}catch{}return b}n.ThemeService=C=l([d(0,_.IOptionsService)],C)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const l=i(8460),d=i(844);class c extends d.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const w=new Array(x);for(let _=0;_<Math.min(x,this.length);_++)w[_]=this._array[this._getCyclicIndex(_)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,w,..._){if(w){for(let a=x;a<this._length-w;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+_.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<_.length;a++)this._array[this._getCyclicIndex(x+a)]=_[a];if(_.length&&this.onInsertEmitter.fire({index:x,amount:_.length}),this._length+_.length>this._maxLength){const a=this._length+_.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=_.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,_){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+_<0)throw new Error("Cannot shift elements in list beyond index 0");if(_>0){for(let h=w-1;h>=0;h--)this.set(x+h+_,this.get(x+h));const a=x+w+_-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<w;a++)this.set(x+a+_,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}n.CircularList=c},1439:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(l,d=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const m in l)c[m]=d<=1?l[m]:l[m]&&i(l[m],d-1);return c}},8055:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const l=i(6114);let d=0,c=0,m=0,x=0;var w,_,a,h,u;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function y(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,b,j){return j!==void 0?`#${f(k)}${f(E)}${f(b)}${f(j)}`:`#${f(k)}${f(E)}${f(b)}`},C.toRgba=function(k,E,b,j=255){return(k<<24|E<<16|b<<8|j)>>>0}})(w||(n.channels=w={})),(function(C){function k(E,b){return x=Math.round(255*b),[d,c,m]=u.toChannels(E.rgba),{css:w.toCss(d,c,m,x),rgba:w.toRgba(d,c,m,x)}}C.blend=function(E,b){if(x=(255&b.rgba)/255,x===1)return{css:b.css,rgba:b.rgba};const j=b.rgba>>24&255,A=b.rgba>>16&255,L=b.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,F=E.rgba>>8&255;return d=T+Math.round((j-T)*x),c=D+Math.round((A-D)*x),m=F+Math.round((L-F)*x),{css:w.toCss(d,c,m),rgba:w.toRgba(d,c,m)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,b,j){const A=u.ensureContrastRatio(E.rgba,b.rgba,j);if(A)return u.toColor(A>>24&255,A>>16&255,A>>8&255)},C.opaque=function(E){const b=(255|E.rgba)>>>0;return[d,c,m]=u.toChannels(b),{css:w.toCss(d,c,m),rgba:b}},C.opacity=k,C.multiplyOpacity=function(E,b){return x=255&E.rgba,k(E,x*b/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(_||(n.color=_={})),(function(C){let k,E;if(!l.isNode){const b=document.createElement("canvas");b.width=1,b.height=1;const j=b.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(b){if(b.match(/#[\da-f]{3,8}/i))switch(b.length){case 4:return d=parseInt(b.slice(1,2).repeat(2),16),c=parseInt(b.slice(2,3).repeat(2),16),m=parseInt(b.slice(3,4).repeat(2),16),u.toColor(d,c,m);case 5:return d=parseInt(b.slice(1,2).repeat(2),16),c=parseInt(b.slice(2,3).repeat(2),16),m=parseInt(b.slice(3,4).repeat(2),16),x=parseInt(b.slice(4,5).repeat(2),16),u.toColor(d,c,m,x);case 7:return{css:b,rgba:(parseInt(b.slice(1),16)<<8|255)>>>0};case 9:return{css:b,rgba:parseInt(b.slice(1),16)>>>0}}const j=b.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return d=parseInt(j[1]),c=parseInt(j[2]),m=parseInt(j[3]),x=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),u.toColor(d,c,m,x);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=b,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,c,m,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:w.toRgba(d,c,m,x),css:b}}})(a||(n.css=a={})),(function(C){function k(E,b,j){const A=E/255,L=b/255,T=j/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(h||(n.rgb=h={})),(function(C){function k(b,j,A){const L=b>>24&255,T=b>>16&255,D=b>>8&255;let F=j>>24&255,I=j>>16&255,$=j>>8&255,W=y(h.relativeLuminance2(F,I,$),h.relativeLuminance2(L,T,D));for(;W<A&&(F>0||I>0||$>0);)F-=Math.max(0,Math.ceil(.1*F)),I-=Math.max(0,Math.ceil(.1*I)),$-=Math.max(0,Math.ceil(.1*$)),W=y(h.relativeLuminance2(F,I,$),h.relativeLuminance2(L,T,D));return(F<<24|I<<16|$<<8|255)>>>0}function E(b,j,A){const L=b>>24&255,T=b>>16&255,D=b>>8&255;let F=j>>24&255,I=j>>16&255,$=j>>8&255,W=y(h.relativeLuminance2(F,I,$),h.relativeLuminance2(L,T,D));for(;W<A&&(F<255||I<255||$<255);)F=Math.min(255,F+Math.ceil(.1*(255-F))),I=Math.min(255,I+Math.ceil(.1*(255-I))),$=Math.min(255,$+Math.ceil(.1*(255-$))),W=y(h.relativeLuminance2(F,I,$),h.relativeLuminance2(L,T,D));return(F<<24|I<<16|$<<8|255)>>>0}C.ensureContrastRatio=function(b,j,A){const L=h.relativeLuminance(b>>8),T=h.relativeLuminance(j>>8);if(y(L,T)<A){if(T<L){const I=k(b,j,A),$=y(L,h.relativeLuminance(I>>8));if($<A){const W=E(b,j,A);return $>y(L,h.relativeLuminance(W>>8))?I:W}return I}const D=E(b,j,A),F=y(L,h.relativeLuminance(D>>8));if(F<A){const I=k(b,j,A);return F>y(L,h.relativeLuminance(I>>8))?D:I}return D}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(b){return[b>>24&255,b>>16&255,b>>8&255,255&b]},C.toColor=function(b,j,A,L){return{css:w.toCss(b,j,A,L),rgba:w.toRgba(b,j,A,L)}}})(u||(n.rgba=u={})),n.toPaddedHex=f,n.contrastRatio=y},8969:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const l=i(844),d=i(2585),c=i(4348),m=i(7866),x=i(744),w=i(7302),_=i(6975),a=i(8460),h=i(1753),u=i(1480),f=i(7994),y=i(9282),C=i(5435),k=i(5981),E=i(2660);let b=!1;class j extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((L=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(L.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(L){for(const T in L)this.optionsService.options[T]=L[T]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new w.OptionsService(L)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(m.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(u.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((T,D)=>this._inputHandler.parse(T,D)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,T){this._writeBuffer.write(L,T)}writeSync(L,T){this._logService.logLevel<=d.LogLevelEnum.WARN&&!b&&(this._logService.warn("writeSync is unreliable and will be removed soon."),b=!0),this._writeBuffer.writeSync(L,T)}resize(L,T){isNaN(L)||isNaN(T)||(L=Math.max(L,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(L,T))}scroll(L,T=!1){this._bufferService.scroll(L,T)}scrollLines(L,T,D){this._bufferService.scrollLines(L,T,D)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const T=L-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(L,T){return this._inputHandler.registerEscHandler(L,T)}registerDcsHandler(L,T){return this._inputHandler.registerDcsHandler(L,T)}registerCsiHandler(L,T){return this._inputHandler.registerCsiHandler(L,T)}registerOscHandler(L,T){return this._inputHandler.registerOscHandler(L,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?L=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(y.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,y.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const T of L)T.dispose()}))}}}n.CoreTerminal=j},8460:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===i)return void this._listeners.splice(l,1)}}})),this._event}fire(i,l){const d=[];for(let c=0;c<this._listeners.length;c++)d.push(this._listeners[c]);for(let c=0;c<d.length;c++)d[c].call(void 0,i,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,l){return i((d=>l.fire(d)))}},5435:function(v,n,i){var l=this&&this.__decorate||function(W,R,M,P){var O,U=arguments.length,Y=U<3?R:P===null?P=Object.getOwnPropertyDescriptor(R,M):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(W,R,M,P);else for(var B=W.length-1;B>=0;B--)(O=W[B])&&(Y=(U<3?O(Y):U>3?O(R,M,Y):O(R,M))||Y);return U>3&&Y&&Object.defineProperty(R,M,Y),Y},d=this&&this.__param||function(W,R){return function(M,P){R(M,P,W)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=i(2584),m=i(7116),x=i(2015),w=i(844),_=i(482),a=i(8437),h=i(8460),u=i(643),f=i(511),y=i(3734),C=i(2585),k=i(6242),E=i(6351),b=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function L(W,R){if(W>24)return R.setWinLines||!1;switch(W){case 1:return!!R.restoreWin;case 2:return!!R.minimizeWin;case 3:return!!R.setWinPosition;case 4:return!!R.setWinSizePixels;case 5:return!!R.raiseWin;case 6:return!!R.lowerWin;case 7:return!!R.refreshWin;case 8:return!!R.setWinSizeChars;case 9:return!!R.maximizeWin;case 10:return!!R.fullscreenWin;case 11:return!!R.getWinState;case 13:return!!R.getWinPosition;case 14:return!!R.getWinSizePixels;case 15:return!!R.getScreenSizePixels;case 16:return!!R.getCellSizePixels;case 18:return!!R.getWinSizeChars;case 19:return!!R.getScreenSizeChars;case 20:return!!R.getIconTitle;case 21:return!!R.getWinTitle;case 22:return!!R.pushTitle;case 23:return!!R.popTitle;case 24:return!!R.setWinLines}return!1}var T;(function(W){W[W.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",W[W.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(n.WindowsOptionsReportType=T={}));let D=0;class F extends w.Disposable{getAttrData(){return this._curAttrData}constructor(R,M,P,O,U,Y,B,H,q=new x.EscapeSequenceParser){super(),this._bufferService=R,this._charsetService=M,this._coreService=P,this._logService=O,this._optionsService=U,this._oscLinkService=Y,this._coreMouseService=B,this._unicodeService=H,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,z)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:z.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,z,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:z,data:X})})),this._parser.setDcsHandlerFallback(((N,z,X)=>{z==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:z,payload:X})})),this._parser.setPrintHandler(((N,z,X)=>this.print(N,z,X))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const N in m.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,z)=>this.requestStatusString(N,z))))}_preserveStack(R,M,P,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=R,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=P,this._parseStack.position=O}_logSlowResolvingAsync(R){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([R,new Promise(((M,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(R,M){let P,O=this._activeBuffer.x,U=this._activeBuffer.y,Y=0;const B=this._parseStack.paused;if(B){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(P),P;O=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,R.length>A&&(Y=this._parseStack.position+A)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof R=="string"?` "${R}"`:` "${Array.prototype.map.call(R,(H=>String.fromCharCode(H))).join("")}"`),typeof R=="string"?R.split("").map((H=>H.charCodeAt(0))):R),this._parseBuffer.length<R.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min(R.length,A))),B||this._dirtyRowTracker.clearRange(),R.length>A)for(let H=Y;H<R.length;H+=A){const q=H+A<R.length?H+A:R.length,N=typeof R=="string"?this._stringDecoder.decode(R.substring(H,q),this._parseBuffer):this._utf8Decoder.decode(R.subarray(H,q),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,U,N,H),this._logSlowResolvingAsync(P),P}else if(!B){const H=typeof R=="string"?this._stringDecoder.decode(R,this._parseBuffer):this._utf8Decoder.decode(R,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,H))return this._preserveStack(O,U,H,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===O&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(R,M,P){let O,U;const Y=this._charsetService.charset,B=this._optionsService.rawOptions.screenReaderMode,H=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,z=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-M>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,z.fg,z.bg,z.extended);for(let K=M;K<P;++K){if(O=R[K],U=this._unicodeService.wcwidth(O),O<127&&Y){const ne=Y[String.fromCharCode(O)];ne&&(O=ne.charCodeAt(0))}if(B&&this._onA11yChar.fire((0,_.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=H){if(q){for(;this._activeBuffer.x<H;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,z.fg,z.bg,z.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=H-1,U===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(z),z),X.getWidth(H-1)===2&&X.setCellFromCodePoint(H-1,u.NULL_CELL_CODE,u.NULL_CELL_WIDTH,z.fg,z.bg,z.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,U,z.fg,z.bg,z.extended),U>0)for(;--U;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,z.fg,z.bg,z.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}P-M>0&&(X.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<H&&P-M>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,z.fg,z.bg,z.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(R,M){return R.final!=="t"||R.prefix||R.intermediates?this._parser.registerCsiHandler(R,M):this._parser.registerCsiHandler(R,(P=>!L(P.params[0],this._optionsService.rawOptions.windowOptions)||M(P)))}registerDcsHandler(R,M){return this._parser.registerDcsHandler(R,new E.DcsHandler(M))}registerEscHandler(R,M){return this._parser.registerEscHandler(R,M)}registerOscHandler(R,M){return this._parser.registerOscHandler(R,new k.OscHandler(M))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var R;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||R===void 0)&&R.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const R=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-R),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(R=this._bufferService.cols-1){this._activeBuffer.x=Math.min(R,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(R,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=R,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=R,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(R,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+R,this._activeBuffer.y+M)}cursorUp(R){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,R.params[0]||1)):this._moveCursor(0,-(R.params[0]||1)),!0}cursorDown(R){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,R.params[0]||1)):this._moveCursor(0,R.params[0]||1),!0}cursorForward(R){return this._moveCursor(R.params[0]||1,0),!0}cursorBackward(R){return this._moveCursor(-(R.params[0]||1),0),!0}cursorNextLine(R){return this.cursorDown(R),this._activeBuffer.x=0,!0}cursorPrecedingLine(R){return this.cursorUp(R),this._activeBuffer.x=0,!0}cursorCharAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(R){return this._setCursor(R.length>=2?(R.params[1]||1)-1:0,(R.params[0]||1)-1),!0}charPosAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(R){return this._moveCursor(R.params[0]||1,0),!0}linePosAbsolute(R){return this._setCursor(this._activeBuffer.x,(R.params[0]||1)-1),!0}vPositionRelative(R){return this._moveCursor(0,R.params[0]||1),!0}hVPosition(R){return this.cursorPosition(R),!0}tabClear(R){const M=R.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=R.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=R.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(R){const M=R.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(R,M,P,O=!1,U=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);Y.replaceCells(M,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),O&&(Y.isWrapped=!1)}_resetBufferLine(R,M=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+R),P.isWrapped=!1)}eraseInDisplay(R,M=!1){let P;switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);P<this._bufferService.rows;P++)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(R,M=!1){switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(R){this._restrictCursor();let M=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;M--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(R){this._restrictCursor();let M=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;M--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(R){let M=R.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(R){let M=R.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(R.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(R){if(!this._parser.precedingCodepoint)return!0;const M=R.params[0]||1,P=new Uint32Array(M);for(let O=0;O<M;++O)P[O]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(R){return R.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(R){return R.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(R.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(R){return(this._optionsService.rawOptions.termName+"").indexOf(R)===0}setMode(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),this._charsetService.setgCharset(1,m.DEFAULT_CHARSET),this._charsetService.setgCharset(2,m.DEFAULT_CHARSET),this._charsetService.setgCharset(3,m.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),R.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(R,M){const P=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:U}=this._coreMouseService,Y=this._coreService,{buffers:B,cols:H}=this._bufferService,{active:q,alt:N}=B,z=this._optionsService.rawOptions,X=fe=>fe?1:2,K=R.params[0];return ne=K,te=M?K===2?4:K===4?X(Y.modes.insertMode):K===12?3:K===20?X(z.convertEol):0:K===1?X(P.applicationCursorKeys):K===3?z.windowOptions.setWinLines?H===80?2:H===132?1:0:0:K===6?X(P.origin):K===7?X(P.wraparound):K===8?3:K===9?X(O==="X10"):K===12?X(z.cursorBlink):K===25?X(!Y.isCursorHidden):K===45?X(P.reverseWraparound):K===66?X(P.applicationKeypad):K===67?4:K===1e3?X(O==="VT200"):K===1002?X(O==="DRAG"):K===1003?X(O==="ANY"):K===1004?X(P.sendFocus):K===1005?4:K===1006?X(U==="SGR"):K===1015?4:K===1016?X(U==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?X(q===N):K===2004?X(P.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${M?"":"?"}${ne};${te}$y`),!0;var ne,te}_updateAttrColor(R,M,P,O,U){return M===2?(R|=50331648,R&=-16777216,R|=y.AttributeData.fromColorRGB([P,O,U])):M===5&&(R&=-50331904,R|=33554432|255&P),R}_extractColor(R,M,P){const O=[0,0,-1,0,0,0];let U=0,Y=0;do{if(O[Y+U]=R.params[M+Y],R.hasSubParams(M+Y)){const B=R.getSubParams(M+Y);let H=0;do O[1]===5&&(U=1),O[Y+H+1+U]=B[H];while(++H<B.length&&H+Y+1+U<O.length);break}if(O[1]===5&&Y+U>=2||O[1]===2&&Y+U>=5)break;O[1]&&(U=1)}while(++Y+M<R.length&&Y+U<O.length);for(let B=2;B<O.length;++B)O[B]===-1&&(O[B]=0);switch(O[0]){case 38:P.fg=this._updateAttrColor(P.fg,O[1],O[3],O[4],O[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,O[1],O[3],O[4],O[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,O[1],O[3],O[4],O[5])}return Y}_processUnderline(R,M){M.extended=M.extended.clone(),(!~R||R>5)&&(R=1),M.extended.underlineStyle=R,M.fg|=268435456,R===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(R){R.fg=a.DEFAULT_ATTR_DATA.fg,R.bg=a.DEFAULT_ATTR_DATA.bg,R.extended=R.extended.clone(),R.extended.underlineStyle=0,R.extended.underlineColor&=-67108864,R.updateExtended()}charAttributes(R){if(R.length===1&&R.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=R.length;let P;const O=this._curAttrData;for(let U=0;U<M;U++)P=R.params[U],P>=30&&P<=37?(O.fg&=-50331904,O.fg|=16777216|P-30):P>=40&&P<=47?(O.bg&=-50331904,O.bg|=16777216|P-40):P>=90&&P<=97?(O.fg&=-50331904,O.fg|=16777224|P-90):P>=100&&P<=107?(O.bg&=-50331904,O.bg|=16777224|P-100):P===0?this._processSGR0(O):P===1?O.fg|=134217728:P===3?O.bg|=67108864:P===4?(O.fg|=268435456,this._processUnderline(R.hasSubParams(U)?R.getSubParams(U)[0]:1,O)):P===5?O.fg|=536870912:P===7?O.fg|=67108864:P===8?O.fg|=1073741824:P===9?O.fg|=2147483648:P===2?O.bg|=134217728:P===21?this._processUnderline(2,O):P===22?(O.fg&=-134217729,O.bg&=-134217729):P===23?O.bg&=-67108865:P===24?(O.fg&=-268435457,this._processUnderline(0,O)):P===25?O.fg&=-536870913:P===27?O.fg&=-67108865:P===28?O.fg&=-1073741825:P===29?O.fg&=2147483647:P===39?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):P===49?(O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?U+=this._extractColor(R,U,O):P===53?O.bg|=1073741824:P===55?O.bg&=-1073741825:P===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):P===100?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(R){switch(R.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${M};${P}R`)}return!0}deviceStatusPrivate(R){if(R.params[0]===6){const M=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${M};${P}R`)}return!0}softReset(R){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(R){const M=R.params[0]||1;switch(M){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const P=M%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(R){const M=R.params[0]||1;let P;return(R.length<2||(P=R.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(R){if(!L(R.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=R.length>1?R.params[1]:0;switch(R.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(R){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(R){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(R){return this._windowTitle=R,this._onTitleChange.fire(R),!0}setIconName(R){return this._iconName=R,!0}setOrReportIndexedColor(R){const M=[],P=R.split(";");for(;P.length>1;){const O=P.shift(),U=P.shift();if(/^\d+$/.exec(O)){const Y=parseInt(O);if($(Y))if(U==="?")M.push({type:0,index:Y});else{const B=(0,b.parseColor)(U);B&&M.push({type:1,index:Y,color:B})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(R){const M=R.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(R,M){this._getCurrentLinkId()&&this._finishHyperlink();const P=R.split(":");let O;const U=P.findIndex((Y=>Y.startsWith("id=")));return U!==-1&&(O=P[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(R,M){const P=R.split(";");for(let O=0;O<P.length&&!(M>=this._specialColors.length);++O,++M)if(P[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const U=(0,b.parseColor)(P[O]);U&&this._onColor.fire([{type:1,index:this._specialColors[M],color:U}])}return!0}setOrReportFgColor(R){return this._setOrReportSpecialColor(R,0)}setOrReportBgColor(R){return this._setOrReportSpecialColor(R,1)}setOrReportCursorColor(R){return this._setOrReportSpecialColor(R,2)}restoreIndexedColor(R){if(!R)return this._onColor.fire([{type:2}]),!0;const M=[],P=R.split(";");for(let O=0;O<P.length;++O)if(/^\d+$/.exec(P[O])){const U=parseInt(P[O]);$(U)&&M.push({type:2,index:U})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(R){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(R){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(R){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),!0}selectCharset(R){return R.length!==2?(this.selectDefaultCharset(),!0):(R[0]==="/"||this._charsetService.setgCharset(j[R[0]],m.CHARSETS[R[1]]||m.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const R=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,R,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(R){return this._charsetService.setgLevel(R),!0}screenAlignmentPattern(){const R=new f.CellData;R.content=4194373,R.fg=this._curAttrData.fg,R.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const P=this._activeBuffer.ybase+this._activeBuffer.y+M,O=this._activeBuffer.lines.get(P);O&&(O.fill(R),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(R,M){const P=this._bufferService.buffer,O=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${U}${c.C0.ESC}\\`),!0))(R==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:R==='"p'?'P1$r61;1"p':R==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:R==="m"?"P1$r0m":R===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(R,M){this._dirtyRowTracker.markRangeDirty(R,M)}}n.InputHandler=F;let I=class{constructor(W){this._bufferService=W,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(W){W<this.start?this.start=W:W>this.end&&(this.end=W)}markRangeDirty(W,R){W>R&&(D=W,W=R,R=D),W<this.start&&(this.start=W),R>this.end&&(this.end=R)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function $(W){return 0<=W&&W<256}I=l([d(0,C.IBufferService)],I)},844:(v,n)=>{function i(l){for(const d of l)d.dispose();l.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const d=this._disposables.indexOf(l);d!==-1&&this._disposables.splice(d,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var d;this._isDisposed||l===this._value||((d=this._value)===null||d===void 0||d.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},n.toDisposable=function(l){return{dispose:l}},n.disposeArray=i,n.getDisposeArrayDisposable=function(l){return{dispose:()=>i(l)}}},1505:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(d,c,m){this._data[d]||(this._data[d]={}),this._data[d][c]=m}get(d,c){return this._data[d]?this._data[d][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(l,d,c,m,x){this._data.get(l,d)||this._data.set(l,d,new i),this._data.get(l,d).set(c,m,x)}get(l,d,c,m){var x;return(x=this._data.get(l,d))===null||x===void 0?void 0:x.get(c,m)}clear(){this._data.clear()}}},6114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,l=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const d=i.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),n.isIpad=l==="iPad",n.isIphone=l==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),n.isLinux=l.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(i=this._search(this._getKey(l)),this._array.splice(i,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const d=this._getKey(l);if(d===void 0||(i=this._search(d),i===-1)||this._getKey(this._array[i])!==d)return!1;do if(this._array[i]===l)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===d);return!1}*getKeyIterator(l){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===l)}forEachByKey(l,d){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do d(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let d=0,c=this._array.length-1;for(;c>=d;){let m=d+c>>1;const x=this._getKey(this._array[m]);if(x>l)c=m-1;else{if(!(x<l)){for(;m>0&&this._getKey(this._array[m-1])===l;)m--;return m}d=m+1}}return d}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const l=i(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let w=0,_=0,a=x.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),_=Math.max(w,_),h=x.timeRemaining(),1.5*_>h)return a-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-w))}ms`),void this._start();a=h}this.clear()}}class c extends d{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(m){return requestIdleCallback(m)}_cancelCallback(m){cancelIdleCallback(m)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(m){this._queue.clear(),this._queue.enqueue(m)}flush(){this._queue.flush()}}},9282:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const l=i(643);n.updateWindowsModeWrappedState=function(d){const c=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),m=c?.get(d.cols-1),x=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);x&&m&&(x.isWrapped=m[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&m[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new i;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}n.AttributeData=i;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,m=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=m}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=l},9092:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const l=i(6349),d=i(7226),c=i(3734),m=i(8437),x=i(4634),w=i(511),_=i(643),a=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(u,f,y){this._hasScrollback=u,this._optionsService=f,this._bufferService=y,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=m.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(u){return u?(this._nullCell.fg=u.fg,this._nullCell.bg=u.bg,this._nullCell.extended=u.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(u){return u?(this._whitespaceCell.fg=u.fg,this._whitespaceCell.bg=u.bg,this._whitespaceCell.extended=u.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(u,f){return new m.BufferLine(this._bufferService.cols,this.getNullCell(u),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const u=this.ybase+this.y-this.ydisp;return u>=0&&u<this._rows}_getCorrectBufferLength(u){if(!this._hasScrollback)return u;const f=u+this._optionsService.rawOptions.scrollback;return f>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:f}fillViewportRows(u){if(this.lines.length===0){u===void 0&&(u=m.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(u))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(u,f){const y=this.getNullCell(m.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<u)for(let b=0;b<this.lines.length;b++)C+=+this.lines.get(b).resize(u,y);let E=0;if(this._rows<f)for(let b=this._rows;b<f;b++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new m.BufferLine(u,y)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new m.BufferLine(u,y)));else for(let b=this._rows;b>f;b--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const b=this.lines.length-k;b>0&&(this.lines.trimStart(b),this.ybase=Math.max(this.ybase-b,0),this.ydisp=Math.max(this.ydisp-b,0),this.savedY=Math.max(this.savedY-b,0)),this.lines.maxLength=k}this.x=Math.min(this.x,u-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,u-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(u,f),this._cols>u))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(u,y);this._cols=u,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let u=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,u=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return u}get _isReflowEnabled(){const u=this._optionsService.rawOptions.windowsPty;return u&&u.buildNumber?this._hasScrollback&&u.backend==="conpty"&&u.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(u,f){this._cols!==u&&(u>this._cols?this._reflowLarger(u,f):this._reflowSmaller(u,f))}_reflowLarger(u,f){const y=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,u,this.ybase+this.y,this.getNullCell(m.DEFAULT_ATTR_DATA));if(y.length>0){const C=(0,x.reflowLargerCreateNewLayout)(this.lines,y);(0,x.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(u,f,C.countRemoved)}}_reflowLargerAdjustViewport(u,f,y){const C=this.getNullCell(m.DEFAULT_ATTR_DATA);let k=y;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new m.BufferLine(u,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-y,0)}_reflowSmaller(u,f){const y=this.getNullCell(m.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let b=this.lines.get(E);if(!b||!b.isWrapped&&b.getTrimmedLength()<=u)continue;const j=[b];for(;b.isWrapped&&E>0;)b=this.lines.get(--E),j.unshift(b);const A=this.ybase+this.y;if(A>=E&&A<E+j.length)continue;const L=j[j.length-1].getTrimmedLength(),T=(0,x.reflowSmallerGetNewLineLengths)(j,this._cols,u),D=T.length-j.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+D):Math.max(0,this.lines.length-this.lines.maxLength+D);const I=[];for(let O=0;O<D;O++){const U=this.getBlankLine(m.DEFAULT_ATTR_DATA,!0);I.push(U)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let $=T.length-1,W=T[$];W===0&&($--,W=T[$]);let R=j.length-D-1,M=L;for(;R>=0;){const O=Math.min(M,W);if(j[$]===void 0)break;if(j[$].copyCellsFrom(j[R],M-O,W-O,O,!0),W-=O,W===0&&($--,W=T[$]),M-=O,M===0){R--;const U=Math.max(R,0);M=(0,x.getWrappedLineTrimmedLength)(j,U,this._cols)}}for(let O=0;O<j.length;O++)T[O]<u&&j[O].setCell(T[O],y);let P=D-F;for(;P-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+f-1)}if(C.length>0){const E=[],b=[];for(let $=0;$<this.lines.length;$++)b.push(this.lines.get($));const j=this.lines.length;let A=j-1,L=0,T=C[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let $=Math.min(this.lines.maxLength-1,j+k-1);$>=0;$--)if(T&&T.start>A+D){for(let W=T.newLines.length-1;W>=0;W--)this.lines.set($--,T.newLines[W]);$++,E.push({index:A+1,amount:T.newLines.length}),D+=T.newLines.length,T=C[++L]}else this.lines.set($,b[A--]);let F=0;for(let $=E.length-1;$>=0;$--)E[$].index+=F,this.lines.onInsertEmitter.fire(E[$]),F+=E[$].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(u,f,y=0,C){const k=this.lines.get(u);return k?k.translateToString(f,y,C):""}getWrappedRangeForLine(u){let f=u,y=u;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;y+1<this.lines.length&&this.lines.get(y+1).isWrapped;)y++;return{first:f,last:y}}setupTabStops(u){for(u!=null?this.tabs[u]||(u=this.prevStop(u)):(this.tabs={},u=0);u<this._cols;u+=this._optionsService.rawOptions.tabStopWidth)this.tabs[u]=!0}prevStop(u){for(u==null&&(u=this.x);!this.tabs[--u]&&u>0;);return u>=this._cols?this._cols-1:u<0?0:u}nextStop(u){for(u==null&&(u=this.x);!this.tabs[++u]&&u<this._cols;);return u>=this._cols?this._cols-1:u<0?0:u}clearMarkers(u){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===u&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].dispose(),this.markers.splice(u--,1);this._isClearing=!1}addMarker(u){const f=new a.Marker(u);return this.markers.push(f),f.register(this.lines.onTrim((y=>{f.line-=y,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((y=>{f.line>=y.index&&(f.line+=y.amount)}))),f.register(this.lines.onDelete((y=>{f.line>=y.index&&f.line<y.index+y.amount&&f.dispose(),f.line>y.index&&(f.line-=y.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(u){this._isClearing||this.markers.splice(this.markers.indexOf(u),1)}}},8437:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const l=i(3734),d=i(511),c=i(643),m=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let x=0;class w{constructor(a,h,u=!1){this.isWrapped=u,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||d.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let y=0;y<a;++y)this.setCell(y,f);this.length=a}get(a){const h=this._data[3*a+0],u=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:u?(0,m.stringFromCodePoint)(u):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):u]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,m.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,u,f,y,C){268435456&y&&(this._extendedAttrs[a]=C),this._data[3*a+0]=h|u<<22,this._data[3*a+1]=f,this._data[3*a+2]=y}addCodepointToCell(a,h){let u=this._data[3*a+0];2097152&u?this._combined[a]+=(0,m.stringFromCodePoint)(h):(2097151&u?(this._combined[a]=(0,m.stringFromCodePoint)(2097151&u)+(0,m.stringFromCodePoint)(h),u&=-2097152,u|=2097152):u=h|4194304,this._data[3*a+0]=u)}insertCells(a,h,u,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const y=new d.CellData;for(let C=this.length-a-h-1;C>=0;--C)this.setCell(a+h+C,this.loadCell(a+C,y));for(let C=0;C<h;++C)this.setCell(a+C,u)}else for(let y=a;y<this.length;++y)this.setCell(y,u);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,u,f){if(a%=this.length,h<this.length-a){const y=new d.CellData;for(let C=0;C<this.length-a-h;++C)this.setCell(a+C,this.loadCell(a+h+C,y));for(let C=this.length-h;C<this.length;++C)this.setCell(C,u)}else for(let y=a;y<this.length;++y)this.setCell(y,u);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,u,f,y=!1){if(y)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,u),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,u)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const u=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*u)this._data=new Uint32Array(this._data.buffer,0,u);else{const f=new Uint32Array(u);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,u);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=a&&delete this._combined[k]}const y=Object.keys(this._extendedAttrs);for(let C=0;C<y.length;C++){const k=parseInt(y[C],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*u*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let u=0;u<this.length;++u)this.isProtected(u)||this.setCell(u,a);else{this._combined={},this._extendedAttrs={};for(let u=0;u<this.length;++u)this.setCell(u,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new w(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,u,f,y){const C=a._data;if(y)for(let E=f-1;E>=0;E--){for(let b=0;b<3;b++)this._data[3*(u+E)+b]=C[3*(h+E)+b];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=a._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let b=0;b<3;b++)this._data[3*(u+E)+b]=C[3*(h+E)+b];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=a._extendedAttrs[h+E])}const k=Object.keys(a._combined);for(let E=0;E<k.length;E++){const b=parseInt(k[E],10);b>=h&&(this._combined[b-h+u]=a._combined[b])}}translateToString(a=!1,h=0,u=this.length){a&&(u=Math.min(u,this.getTrimmedLength()));let f="";for(;h<u;){const y=this._data[3*h+0],C=2097151&y;f+=2097152&y?this._combined[h]:C?(0,m.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,h+=y>>22||1}return f}}n.BufferLine=w},4841:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,l){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return l*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(v,n)=>{function i(l,d,c){if(d===l.length-1)return l[d].getTrimmedLength();const m=!l[d].hasContent(c-1)&&l[d].getWidth(c-1)===1,x=l[d+1].getWidth(0)===2;return m&&x?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(l,d,c,m,x){const w=[];for(let _=0;_<l.length-1;_++){let a=_,h=l.get(++a);if(!h.isWrapped)continue;const u=[l.get(_)];for(;a<l.length&&h.isWrapped;)u.push(h),h=l.get(++a);if(m>=_&&m<a){_+=u.length-1;continue}let f=0,y=i(u,f,d),C=1,k=0;for(;C<u.length;){const b=i(u,C,d),j=b-k,A=c-y,L=Math.min(j,A);u[f].copyCellsFrom(u[C],k,y,L,!1),y+=L,y===c&&(f++,y=0),k+=L,k===b&&(C++,k=0),y===0&&f!==0&&u[f-1].getWidth(c-1)===2&&(u[f].copyCellsFrom(u[f-1],c-1,y++,1,!1),u[f-1].setCell(c-1,x))}u[f].replaceCells(y,c,x);let E=0;for(let b=u.length-1;b>0&&(b>f||u[b].getTrimmedLength()===0);b--)E++;E>0&&(w.push(_+u.length-E),w.push(E)),_+=u.length-1}return w},n.reflowLargerCreateNewLayout=function(l,d){const c=[];let m=0,x=d[m],w=0;for(let _=0;_<l.length;_++)if(x===_){const a=d[++m];l.onDeleteEmitter.fire({index:_-w,amount:a}),_+=a-1,w+=a,x=d[++m]}else c.push(_);return{layout:c,countRemoved:w}},n.reflowLargerApplyNewLayout=function(l,d){const c=[];for(let m=0;m<d.length;m++)c.push(l.get(d[m]));for(let m=0;m<c.length;m++)l.set(m,c[m]);l.length=d.length},n.reflowSmallerGetNewLineLengths=function(l,d,c){const m=[],x=l.map(((h,u)=>i(l,u,d))).reduce(((h,u)=>h+u));let w=0,_=0,a=0;for(;a<x;){if(x-a<c){m.push(x-a);break}w+=c;const h=i(l,_,d);w>h&&(w-=h,_++);const u=l[_].getWidth(w-1)===2;u&&w--;const f=u?c-1:c;m.push(f),a+=f}return m},n.getWrappedLineTrimmedLength=i},5295:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const l=i(8460),d=i(844),c=i(9092);class m extends d.Disposable{constructor(w,_){super(),this._optionsService=w,this._bufferService=_,this._onBufferActivate=this.register(new l.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,_){this._normal.resize(w,_),this._alt.resize(w,_),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}n.BufferSet=m},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const l=i(482),d=i(643),c=i(3734);class m extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const _=new m;return _.setFromCharData(w),_}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(w[d.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(w[d.CHAR_DATA_CHAR_INDEX].length===2){const a=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|w[d.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[d.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=w[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=m},643:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const l=i(8460),d=i(844);class c{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}n.Marker=c,c._nextId=1},7116:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,n)=>{var i,l,d;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
-
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(i||(n.C0=i={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(l||(n.C1=l={})),(function(c){c.ST=`${i.ESC}\\`})(d||(n.C1_ESCAPED=d={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const l=i(2584),d={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(c,m,x,w){const _={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?_.key=m?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?_.key=m?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?_.key=m?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(_.key=m?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){_.key=l.C0.ESC+l.C0.DEL;break}_.key=l.C0.DEL;break;case 9:if(c.shiftKey){_.key=l.C0.ESC+"[Z";break}_.key=l.C0.HT,_.cancel=!0;break;case 13:_.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,_.cancel=!0;break;case 27:_.key=l.C0.ESC,c.altKey&&(_.key=l.C0.ESC+l.C0.ESC),_.cancel=!0;break;case 37:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"D",_.key===l.C0.ESC+"[1;3D"&&(_.key=l.C0.ESC+(x?"b":"[1;5D"))):_.key=m?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"C",_.key===l.C0.ESC+"[1;3C"&&(_.key=l.C0.ESC+(x?"f":"[1;5C"))):_.key=m?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"A",x||_.key!==l.C0.ESC+"[1;3A"||(_.key=l.C0.ESC+"[1;5A")):_.key=m?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"B",x||_.key!==l.C0.ESC+"[1;3B"||(_.key=l.C0.ESC+"[1;5B")):_.key=m?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(_.key=l.C0.ESC+"[2~");break;case 46:_.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:_.key=a?l.C0.ESC+"[1;"+(a+1)+"H":m?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:_.key=a?l.C0.ESC+"[1;"+(a+1)+"F":m?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?_.type=2:c.ctrlKey?_.key=l.C0.ESC+"[5;"+(a+1)+"~":_.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?_.type=3:c.ctrlKey?_.key=l.C0.ESC+"[6;"+(a+1)+"~":_.key=l.C0.ESC+"[6~";break;case 112:_.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:_.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:_.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:_.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:_.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:_.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:_.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:_.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:_.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:_.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:_.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:_.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(x&&!w||!c.altKey||c.metaKey)!x||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?_.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(_.key=l.C0.US),c.key==="@"&&(_.key=l.C0.NUL)):c.keyCode===65&&(_.type=1);else{const h=d[c.keyCode],u=h?.[c.shiftKey?1:0];if(u)_.key=l.C0.ESC+u;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let y=String.fromCharCode(f);c.shiftKey&&(y=y.toUpperCase()),_.key=l.C0.ESC+y}else if(c.keyCode===32)_.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),_.key=l.C0.ESC+f,_.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?_.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?_.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?_.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?_.key=l.C0.DEL:c.keyCode===219?_.key=l.C0.ESC:c.keyCode===220?_.key=l.C0.FS:c.keyCode===221&&(_.key=l.C0.GS)}return _}},482:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,l=0,d=i.length){let c="";for(let m=l;m<d;++m){let x=i[m];x>65535?(x-=65536,c+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):c+=String.fromCharCode(x)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,l){const d=i.length;if(!d)return 0;let c=0,m=0;if(this._interim){const x=i.charCodeAt(m++);56320<=x&&x<=57343?l[c++]=1024*(this._interim-55296)+x-56320+65536:(l[c++]=this._interim,l[c++]=x),this._interim=0}for(let x=m;x<d;++x){const w=i.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=d)return this._interim=w,c;const _=i.charCodeAt(x);56320<=_&&_<=57343?l[c++]=1024*(w-55296)+_-56320+65536:(l[c++]=w,l[c++]=_)}else w!==65279&&(l[c++]=w)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const d=i.length;if(!d)return 0;let c,m,x,w,_=0,a=0,h=0;if(this.interim[0]){let y=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const b=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=b-E;for(;h<j;){if(h>=d)return 0;if(k=i[h++],(192&k)!=128){h--,y=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}y||(b===2?C<128?h--:l[_++]=C:b===3?C<2048||C>=55296&&C<=57343||C===65279||(l[_++]=C):C<65536||C>1114111||(l[_++]=C)),this.interim.fill(0)}const u=d-4;let f=h;for(;f<d;){for(;!(!(f<u)||128&(c=i[f])||128&(m=i[f+1])||128&(x=i[f+2])||128&(w=i[f+3]));)l[_++]=c,l[_++]=m,l[_++]=x,l[_++]=w,f+=4;if(c=i[f++],c<128)l[_++]=c;else if((224&c)==192){if(f>=d)return this.interim[0]=c,_;if(m=i[f++],(192&m)!=128){f--;continue}if(a=(31&c)<<6|63&m,a<128){f--;continue}l[_++]=a}else if((240&c)==224){if(f>=d)return this.interim[0]=c,_;if(m=i[f++],(192&m)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,_;if(x=i[f++],(192&x)!=128){f--;continue}if(a=(15&c)<<12|(63&m)<<6|63&x,a<2048||a>=55296&&a<=57343||a===65279)continue;l[_++]=a}else if((248&c)==240){if(f>=d)return this.interim[0]=c,_;if(m=i[f++],(192&m)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,_;if(x=i[f++],(192&x)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,this.interim[2]=x,_;if(w=i[f++],(192&w)!=128){f--;continue}if(a=(7&c)<<18|(63&m)<<12|(63&x)<<6|63&w,a<65536||a>1114111)continue;l[_++]=a}}return _}}},225:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let d;n.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let c=0;c<i.length;++c)d.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?d[c]:(function(m,x){let w,_=0,a=x.length-1;if(m<x[0][0]||m>x[a][1])return!1;for(;a>=_;)if(w=_+a>>1,m>x[w][1])_=w+1;else{if(!(m<x[w][0]))return!0;a=w-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const l=i(8460),d=i(844);class c extends d.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const _=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,w);if(h){const f=y=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,y))):this._innerWrite(_,y);return void h.catch((y=>(queueMicrotask((()=>{throw y})),Promise.resolve(!1)))).then(f)}const u=this._callbacks[this._bufferOffset];if(u&&u(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-_>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=c},5941:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function d(c,m){const x=c.toString(16),w=x.length<2?"0"+x:x;switch(m){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}n.parseColor=function(c){if(!c)return;let m=c.toLowerCase();if(m.indexOf("rgb:")===0){m=m.slice(4);const x=i.exec(m);if(x){const w=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/w*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/w*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/w*255)]}}else if(m.indexOf("#")===0&&(m=m.slice(1),l.exec(m)&&[3,6,9,12].includes(m.length))){const x=m.length/3,w=[0,0,0];for(let _=0;_<3;++_){const a=parseInt(m.slice(x*_,x*_+x),16);w[_]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return w}},n.toRgbString=function(c,m=16){const[x,w,_]=c;return`rgb:${d(x,m)}/${d(w,m)}/${d(_,m)}`}},5770:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const l=i(482),d=i(8742),c=i(5770),m=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=m,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}registerHandler(w,_){this._handlers[w]===void 0&&(this._handlers[w]=[]);const a=this._handlers[w];return a.push(_),{dispose:()=>{const h=a.indexOf(_);h!==-1&&a.splice(h,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=m,this._ident=0}hook(w,_){if(this.reset(),this._ident=w,this._active=this._handlers[w]||m,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(_);else this._handlerFb(this._ident,"HOOK",_)}put(w,_,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(w,_,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(w,_,a))}unhook(w,_=!0){if(this._active.length){let a=!1,h=this._active.length-1,u=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=_,u=this._stack.fallThrough,this._stack.paused=!1),!u&&a===!1){for(;h>=0&&(a=this._active[h].unhook(w),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",w);this._active=m,this._ident=0}};const x=new d.Params;x.addParam(0),n.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,_,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(w,_,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let _=!1;if(this._hitLimit)_=!1;else if(w&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((a=>(this._params=x,this._data="",this._hitLimit=!1,a)));return this._params=x,this._data="",this._hitLimit=!1,_}}},2015:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const l=i(844),d=i(8742),c=i(6242),m=i(6351);class x{constructor(h){this.table=new Uint8Array(h)}setDefault(h,u){this.table.fill(h<<4|u)}add(h,u,f,y){this.table[u<<8|h]=f<<4|y}addMany(h,u,f,y){for(let C=0;C<h.length;C++)this.table[u<<8|h[C]]=f<<4|y}}n.TransitionTable=x;const w=160;n.VT500_TRANSITION_TABLE=(function(){const a=new x(4095),h=Array.apply(null,Array(256)).map(((E,b)=>b)),u=(E,b)=>h.slice(E,b),f=u(32,127),y=u(0,24);y.push(25),y.push.apply(y,u(28,32));const C=u(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),C)a.addMany([24,26,153,154],k,3,0),a.addMany(u(128,144),k,3,0),a.addMany(u(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(y,0,3,0),a.addMany(y,1,3,1),a.add(127,1,0,1),a.addMany(y,8,0,8),a.addMany(y,3,3,3),a.add(127,3,0,3),a.addMany(y,4,3,4),a.add(127,4,0,4),a.addMany(y,6,3,6),a.addMany(y,5,3,5),a.add(127,5,0,5),a.addMany(y,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(u(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(y,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(u(64,127),3,7,0),a.addMany(u(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(u(48,60),4,8,4),a.addMany(u(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(u(32,64),6,0,6),a.add(127,6,0,6),a.addMany(u(64,127),6,0,0),a.addMany(u(32,48),3,9,5),a.addMany(u(32,48),5,9,5),a.addMany(u(48,64),5,0,6),a.addMany(u(64,127),5,7,0),a.addMany(u(32,48),4,9,5),a.addMany(u(32,48),1,9,2),a.addMany(u(32,48),2,9,2),a.addMany(u(48,127),2,10,0),a.addMany(u(48,80),1,10,0),a.addMany(u(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(u(96,127),1,10,0),a.add(80,1,11,9),a.addMany(y,9,0,9),a.add(127,9,0,9),a.addMany(u(28,32),9,0,9),a.addMany(u(32,48),9,9,12),a.addMany(u(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(y,11,0,11),a.addMany(u(32,128),11,0,11),a.addMany(u(28,32),11,0,11),a.addMany(y,10,0,10),a.add(127,10,0,10),a.addMany(u(28,32),10,0,10),a.addMany(u(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(u(32,48),10,9,12),a.addMany(y,12,0,12),a.add(127,12,0,12),a.addMany(u(28,32),12,0,12),a.addMany(u(32,48),12,9,12),a.addMany(u(48,64),12,0,11),a.addMany(u(64,127),12,12,13),a.addMany(u(64,127),10,12,13),a.addMany(u(64,127),9,12,13),a.addMany(y,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(w,0,2,0),a.add(w,8,5,8),a.add(w,6,0,6),a.add(w,11,0,11),a.add(w,13,13,13),a})();class _ extends l.Disposable{constructor(h=n.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(u,f,y)=>{},this._executeHandlerFb=u=>{},this._csiHandlerFb=(u,f)=>{},this._escHandlerFb=u=>{},this._errorHandlerFb=u=>u,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new m.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,u=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const k=h.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const y=h.final.charCodeAt(0);if(u[0]>y||y>u[1])throw new Error(`final must be in range ${u[0]} .. ${u[1]}`);return f<<=8,f|=y,f}identToString(h){const u=[];for(;h;)u.push(String.fromCharCode(255&h)),h>>=8;return u.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,u){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const y=this._escHandlers[f];return y.push(u),{dispose:()=>{const C=y.indexOf(u);C!==-1&&y.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,u){this._executeHandlers[h.charCodeAt(0)]=u}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,u){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const y=this._csiHandlers[f];return y.push(u),{dispose:()=>{const C=y.indexOf(u);C!==-1&&y.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,u){return this._dcsParser.registerHandler(this._identifier(h),u)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,u){return this._oscParser.registerHandler(h,u)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,u,f,y,C){this._parseStack.state=h,this._parseStack.handlers=u,this._parseStack.handlerPos=f,this._parseStack.transition=y,this._parseStack.chunkPos=C}parse(h,u,f){let y,C=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const b=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(y=b[j](this._params),y!==!0);j--)if(y instanceof Promise)return this._parseStack.handlerPos=j,y}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(y=b[j](),y!==!0);j--)if(y instanceof Promise)return this._parseStack.handlerPos=j,y}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],y=this._dcsParser.unhook(C!==24&&C!==26,f),y)return y;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],y=this._oscParser.end(C!==24&&C!==26,f),y)return y;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let b=E;b<u;++b){switch(C=h[b],k=this._transitions.table[this.currentState<<8|(C<160?C:w)],k>>4){case 2:for(let D=b+1;;++D){if(D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,b,D),b=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,b,D),b=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,b,D),b=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,b,D),b=D-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:b,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let A=j?j.length-1:-1;for(;A>=0&&(y=j[A](this._params),y!==!0);A--)if(y instanceof Promise)return this._preserveStack(3,j,A,k,b),y;A<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++b<u&&(C=h[b])>47&&C<60);b--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const L=this._escHandlers[this._collect<<8|C];let T=L?L.length-1:-1;for(;T>=0&&(y=L[T](),y!==!0);T--)if(y instanceof Promise)return this._preserveStack(4,L,T,k,b),y;T<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let D=b+1;;++D)if(D>=u||(C=h[D])===24||C===26||C===27||C>127&&C<w){this._dcsParser.put(h,b,D),b=D-1;break}break;case 14:if(y=this._dcsParser.unhook(C!==24&&C!==26),y)return this._preserveStack(6,[],0,k,b),y;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let D=b+1;;D++)if(D>=u||(C=h[D])<32||C>127&&C<w){this._oscParser.put(h,b,D),b=D-1;break}break;case 6:if(y=this._oscParser.end(C!==24&&C!==26),y)return this._preserveStack(5,[],0,k,b),y;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=_},6242:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const l=i(5770),d=i(482),c=[];n.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(m,x){this._handlers[m]===void 0&&(this._handlers[m]=[]);const w=this._handlers[m];return w.push(x),{dispose:()=>{const _=w.indexOf(x);_!==-1&&w.splice(_,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].start();else this._handlerFb(this._id,"START")}_put(m,x,w){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(m,x,w);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(m,x,w))}start(){this.reset(),this._state=1}put(m,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const _=m[x++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&w-x>0&&this._put(m,x,w)}}end(m,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,_=this._active.length-1,a=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,w=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&w===!1){for(;_>=0&&(w=this._active[_].end(m),w!==!0);_--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,w;_--}for(;_>=0;_--)if(w=this._active[_].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",m);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(m){this._handler=m,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(m,x,w){this._hitLimit||(this._data+=(0,d.utf32ToString)(m,x,w),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(m){let x=!1;if(this._hitLimit)x=!1;else if(m&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class l{static fromArray(c){const m=new l;if(!c.length)return m;for(let x=Array.isArray(c[0])?1:0;x<c.length;++x){const w=c[x];if(Array.isArray(w))for(let _=0;_<w.length;++_)m.addSubParam(w[_]);else m.addParam(w)}return m}constructor(c=32,m=32){if(this.maxLength=c,this.maxSubParamsLength=m,m>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(m),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let m=0;m<this.length;++m){c.push(this.params[m]);const x=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,w))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>i?i:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>i?i:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const m=this._subParamsIdx[c]>>8,x=255&this._subParamsIdx[c];return x-m>0?this._subParams.subarray(m,x):null}getSubParamsAll(){const c={};for(let m=0;m<this.length;++m){const x=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-x>0&&(c[m]=this._subParams.slice(x,w))}return c}addDigit(c){let m;if(this._rejectDigits||!(m=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[m-1];x[m-1]=~w?Math.min(10*w+c,i):c}}n.Params=l},5741:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,l){const d={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(d),l.dispose=()=>this._wrappedAddonDispose(d),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===i){l=d;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(l,1)}}},8771:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const l=i(3785),d=i(511);n.BufferApiView=class{constructor(c,m){this._buffer=c,this.type=m}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const m=this._buffer.lines.get(c);if(m)return new l.BufferLineApiView(m)}getNullCell(){return new d.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const l=i(511);n.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,c){if(!(d<0||d>=this._line.length))return c?(this._line.loadCell(d,c),c):this._line.loadCell(d,new l.CellData)}translateToString(d,c,m){return this._line.translateToString(d,c,m)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const l=i(8771),d=i(8460),c=i(844);class m extends c.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=m},7975:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,l){return this._core.registerCsiHandler(i,(d=>l(d.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((d,c)=>l(d,c.toArray())))}addDcsHandler(i,l){return this.registerDcsHandler(i,l)}registerEscHandler(i,l){return this._core.registerEscHandler(i,l)}addEscHandler(i,l){return this.registerEscHandler(i,l)}registerOscHandler(i,l){return this._core.registerOscHandler(i,l)}addOscHandler(i,l){return this.registerOscHandler(i,l)}}},7090:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(y=a[E])&&(k=(C<3?y(k):C>3?y(h,u,k):y(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=i(8460),m=i(844),x=i(5295),w=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let _=n.BufferService=class extends m.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const u=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=u.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const y=u.ybase+u.scrollTop,C=u.ybase+u.scrollBottom;if(u.scrollTop===0){const k=u.lines.isFull;C===u.lines.length-1?k?u.lines.recycle().copyFrom(f):u.lines.push(f.clone()):u.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(u.ydisp=Math.max(u.ydisp-1,0)):(u.ybase++,this.isUserScrolling||u.ydisp++)}else{const k=C-y+1;u.lines.shiftElements(y+1,k-1,-1),u.lines.set(C,f.clone())}this.isUserScrolling||(u.ydisp=u.ybase),this._onScroll.fire(u.ydisp)}scrollLines(a,h,u){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const y=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),y!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};n.BufferService=_=l([d(0,w.IOptionsService)],_)},7994:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,l){this._charsets[i]=l,this.glevel===i&&(this.charset=l)}}},1753:function(v,n,i){var l=this&&this.__decorate||function(f,y,C,k){var E,b=arguments.length,j=b<3?y:k===null?k=Object.getOwnPropertyDescriptor(y,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,y,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(b<3?E(j):b>3?E(y,C,j):E(y,C))||j);return b>3&&j&&Object.defineProperty(y,C,j),j},d=this&&this.__param||function(f,y){return function(C,k){y(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=i(2585),m=i(8460),x=i(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function _(f,y){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||y||(C|=3)),C}const a=String.fromCharCode,h={DEFAULT:f=>{const y=[_(f,!1)+32,f.col+32,f.row+32];return y[0]>255||y[1]>255||y[2]>255?"":`\x1B[M${a(y[0])}${a(y[1])}${a(y[2])}`},SGR:f=>{const y=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${_(f,!0)};${f.col};${f.row}${y}`},SGR_PIXELS:f=>{const y=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${_(f,!0)};${f.x};${f.y}${y}`}};let u=n.CoreMouseService=class extends x.Disposable{constructor(f,y){super(),this._bufferService=f,this._coreService=y,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new m.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(w))this.addProtocol(C,w[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(f,y){this._protocols[f]=y}addEncoding(f,y){this._encodings[f]=y}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const y=this._encodings[this._activeEncoding](f);return y&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(y):this._coreService.triggerDataEvent(y,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,y,C){if(C){if(f.x!==y.x||f.y!==y.y)return!1}else if(f.col!==y.col||f.row!==y.row)return!1;return f.button===y.button&&f.action===y.action&&f.ctrl===y.ctrl&&f.alt===y.alt&&f.shift===y.shift}};n.CoreMouseService=u=l([d(0,c.IBufferService),d(1,c.ICoreService)],u)},6975:function(v,n,i){var l=this&&this.__decorate||function(u,f,y,C){var k,E=arguments.length,b=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,y):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(u,f,y,C);else for(var j=u.length-1;j>=0;j--)(k=u[j])&&(b=(E<3?k(b):E>3?k(f,y,b):k(f,y))||b);return E>3&&b&&Object.defineProperty(f,y,b),b},d=this&&this.__param||function(u,f){return function(y,C){f(y,C,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=i(1439),m=i(8460),x=i(844),w=i(2585),_=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=n.CoreService=class extends x.Disposable{constructor(u,f,y){super(),this._bufferService=u,this._logService=f,this._optionsService=y,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new m.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new m.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(_),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(_),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(u,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const y=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&y.ybase!==y.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${u}"`,(()=>u.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(u)}triggerBinaryEvent(u){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${u}"`,(()=>u.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(u))}};n.CoreService=h=l([d(0,w.IBufferService),d(1,w.ILogService),d(2,w.IOptionsService)],h)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const l=i(8055),d=i(8460),c=i(844),m=i(6106);let x=0,w=0;class _ extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new m.SortedList((u=>u?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(u){if(u.marker.isDisposed)return;const f=new a(u);if(f){const y=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),y.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const u of this._decorations.values())u.dispose();this._decorations.clear()}*getDecorationsAtCell(u,f,y){var C,k,E;let b=0,j=0;for(const A of this._decorations.getKeyIterator(f))b=(C=A.options.x)!==null&&C!==void 0?C:0,j=b+((k=A.options.width)!==null&&k!==void 0?k:1),u>=b&&u<j&&(!y||((E=A.options.layer)!==null&&E!==void 0?E:"bottom")===y)&&(yield A)}forEachDecorationAtCell(u,f,y,C){this._decorations.forEachByKey(f,(k=>{var E,b,j;x=(E=k.options.x)!==null&&E!==void 0?E:0,w=x+((b=k.options.width)!==null&&b!==void 0?b:1),u>=x&&u<w&&(!y||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===y)&&C(k)}))}}n.DecorationService=_;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(u){super(),this.options=u,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=u.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const l=i(2585),d=i(8343);class c{constructor(...x){this._entries=new Map;for(const[w,_]of x)this.set(w,_)}set(x,w){const _=this._entries.get(x);return this._entries.set(x,w),_}forEach(x){for(const[w,_]of this._entries.entries())x(w,_)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(m,x){this._services.set(m,x)}getService(m){return this._services.get(m)}createInstance(m,...x){const w=(0,d.getServiceDependencies)(m).sort(((h,u)=>h.index-u.index)),_=[];for(const h of w){const u=this._services.get(h.id);if(!u)throw new Error(`[createInstance] ${m.name} depends on UNKNOWN service ${h.id}.`);_.push(u)}const a=w.length>0?w[0].index:x.length;if(x.length!==a)throw new Error(`[createInstance] First service dependency of ${m.name} at position ${a+1} conflicts with ${x.length} static arguments`);return new m(...x,..._)}}},7866:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(y=a[E])&&(k=(C<3?y(k):C>3?y(h,u,k):y(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=i(844),m=i(2585),x={trace:m.LogLevelEnum.TRACE,debug:m.LogLevelEnum.DEBUG,info:m.LogLevelEnum.INFO,warn:m.LogLevelEnum.WARN,error:m.LogLevelEnum.ERROR,off:m.LogLevelEnum.OFF};let w,_=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=m.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,u){this._evalLazyOptionalParams(u),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...u)}trace(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.TRACE&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.DEBUG&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.INFO&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.WARN&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.ERROR&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};n.LogService=_=l([d(0,m.IOptionsService)],_),n.setTraceLogger=function(a){w=a},n.traceCall=function(a,h,u){if(typeof u.value!="function")throw new Error("not supported");const f=u.value;u.value=function(...y){if(w.logLevel!==m.LogLevelEnum.TRACE)return f.apply(this,y);w.trace(`GlyphRenderer#${f.name}(${y.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,y);return w.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const l=i(8460),d=i(844),c=i(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const m=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends d.Disposable{constructor(_){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const h in _)if(h in a)try{const u=_[h];a[h]=this._sanitizeAndValidateOption(h,u)}catch(u){console.error(u)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(_,a){return this.onOptionChange((h=>{h===_&&a(this.rawOptions[_])}))}onMultipleOptionChange(_,a){return this.onOptionChange((h=>{_.indexOf(h)!==-1&&a()}))}_setupOptions(){const _=h=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,u)=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);u=this._sanitizeAndValidateOption(h,u),this.rawOptions[h]!==u&&(this.rawOptions[h]=u,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const u={get:_.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,u)}}_sanitizeAndValidateOption(_,a){switch(_){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[_]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${_}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=m.includes(a)?a:n.DEFAULT_OPTIONS[_];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${_} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${_} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${_} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=x},2660:function(v,n,i){var l=this&&this.__decorate||function(x,w,_,a){var h,u=arguments.length,f=u<3?w:a===null?a=Object.getOwnPropertyDescriptor(w,_):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,w,_,a);else for(var y=x.length-1;y>=0;y--)(h=x[y])&&(f=(u<3?h(f):u>3?h(w,_,f):h(w,_))||f);return u>3&&f&&Object.defineProperty(w,_,f),f},d=this&&this.__param||function(x,w){return function(_,a){w(_,a,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=i(2585);let m=n.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const w=this._bufferService.buffer;if(x.id===void 0){const y=w.addMarker(w.ybase+w.y),C={data:x,id:this._nextId++,lines:[y]};return y.onDispose((()=>this._removeMarkerFromLink(C,y))),this._dataByLinkId.set(C.id,C),C.id}const _=x,a=this._getEntryIdKey(_),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,w.ybase+w.y),h.id;const u=w.addMarker(w.ybase+w.y),f={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[u]};return u.onDispose((()=>this._removeMarkerFromLink(f,u))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(x,w){const _=this._dataByLinkId.get(x);if(_&&_.lines.every((a=>a.line!==w))){const a=this._bufferService.buffer.addMarker(w);_.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(_,a)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))===null||w===void 0?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const _=x.lines.indexOf(w);_!==-1&&(x.lines.splice(_,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};n.OscLinkService=m=l([d(0,c.IBufferService)],m)},8343:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",l="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(d){return d[l]||[]},n.createDecorator=function(d){if(n.serviceRegistry.has(d))return n.serviceRegistry.get(d);const c=function(m,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,a,h){a[i]===a?a[l].push({id:_,index:h}):(a[l]=[{id:_,index:h}],a[i]=a)})(c,m,w)};return c.toString=()=>d,n.serviceRegistry.set(d,c),c}},2585:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const l=i(8343);var d;n.IBufferService=(0,l.createDecorator)("BufferService"),n.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),n.ICoreService=(0,l.createDecorator)("CoreService"),n.ICharsetService=(0,l.createDecorator)("CharsetService"),n.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(d||(n.LogLevelEnum=d={})),n.ILogService=(0,l.createDecorator)("LogService"),n.IOptionsService=(0,l.createDecorator)("OptionsService"),n.IOscLinkService=(0,l.createDecorator)("OscLinkService"),n.IUnicodeService=(0,l.createDecorator)("UnicodeService"),n.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const l=i(8460),d=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new d.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let m=0;const x=c.length;for(let w=0;w<x;++w){let _=c.charCodeAt(w);if(55296<=_&&_<=56319){if(++w>=x)return m+this.wcwidth(_);const a=c.charCodeAt(w);56320<=a&&a<=57343?_=1024*(_-55296)+a-56320+65536:m+=this.wcwidth(a)}m+=this.wcwidth(_)}return m}}}},o={};function g(v){var n=o[v];if(n!==void 0)return n.exports;var i=o[v]={exports:{}};return r[v].call(i.exports,i,i.exports,g),i.exports}var p={};return(()=>{var v=p;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const n=g(9042),i=g(3236),l=g(844),d=g(5741),c=g(8285),m=g(7975),x=g(7090),w=["cols","rows"];class _ extends l.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const u=y=>this._core.options[y],f=(y,C)=>{this._checkReadonlyOptions(y),this._core.options[y]=C};for(const y in this._core.options){const C={get:u.bind(this,y),set:f.bind(this,y)};Object.defineProperty(this._publicOptions,y,C)}}_checkReadonlyOptions(h){if(w.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new m.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let u="none";switch(this._core.coreMouseService.activeProtocol){case"X10":u="x10";break;case"VT200":u="vt200";break;case"DRAG":u="drag";break;case"ANY":u="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:u,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const u in h)this._publicOptions[u]=h[u]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,u){this._verifyIntegers(h,u),this._core.resize(h,u)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var u,f,y;return this._checkProposedApi(),this._verifyPositiveIntegers((u=h.x)!==null&&u!==void 0?u:0,(f=h.width)!==null&&f!==void 0?f:0,(y=h.height)!==null&&y!==void 0?y:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,u,f){this._verifyIntegers(h,u,f),this._core.select(h,u,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,u){this._verifyIntegers(h,u),this._core.selectLines(h,u)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,u){this._core.write(h,u)}writeln(h,u){this._core.write(h),this._core.write(`\r
|
|
27
|
-
`,u)}paste(h){this._core.paste(h)}refresh(h,u){this._verifyIntegers(h,u),this._core.refresh(h,u)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const u of h)if(u===1/0||isNaN(u)||u%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const u of h)if(u&&(u===1/0||isNaN(u)||u%1!=0||u<0))throw new Error("This API only accepts positive integers")}}v.Terminal=
|
|
28
|
-
\x1B[90m[Process exited with code ${
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),m()},[c,m]),S.useLayoutEffect(()=>{if(!p.current)return;const
|
|
30
|
-
|
|
25
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(_){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&_&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(_){const j=this._getMouseBufferCoords(_),A=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!!(A&&P&&j)&&this._areCoordsInSelection(j,A,P)}isCellInSelection(_,j){const A=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!(!A||!P)&&this._areCoordsInSelection([_,j],A,P)}_areCoordsInSelection(_,j,A){return _[1]>j[1]&&_[1]<A[1]||j[1]===A[1]&&_[1]===j[1]&&_[0]>=j[0]&&_[0]<A[0]||j[1]<A[1]&&_[1]===A[1]&&_[0]<A[0]||j[1]<A[1]&&_[1]===j[1]&&_[0]>=j[0]}_selectWordAtCursor(_,j){var A,P;const T=(P=(A=this._linkifier.currentLink)===null||A===void 0?void 0:A.link)===null||P===void 0?void 0:P.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,u.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(_);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(_,j){this._model.clearSelection(),_=Math.max(_,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,_],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(_){this._model.handleTrim(_)&&this.refresh()}_getMouseBufferCoords(_){const j=this._mouseService.getCoords(_,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(_){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,_,this._screenElement)[1];const A=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=A?0:(j>A&&(j-=A),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(_){return h.isMac?_.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:_.shiftKey}handleMouseDown(_){if(this._mouseDownTimeStamp=_.timeStamp,(_.button!==2||!this.hasSelection)&&_.button===0){if(!this._enabled){if(!this.shouldForceSelection(_))return;_.stopPropagation()}_.preventDefault(),this._dragScrollAmount=0,this._enabled&&_.shiftKey?this._handleIncrementalClick(_):_.detail===1?this._handleSingleClick(_):_.detail===2?this._handleDoubleClick(_):_.detail===3&&this._handleTripleClick(_),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(_){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(_))}_handleSingleClick(_){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(_)?3:0,this._model.selectionStart=this._getMouseBufferCoords(_),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(_){this._selectWordAtCursor(_,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(_){const j=this._getMouseBufferCoords(_);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(_){return _.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(_){if(_.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(_),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(_),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const A=this._bufferService.buffer;if(this._model.selectionEnd[1]<A.lines.length){const P=A.lines.get(this._model.selectionEnd[1]);P&&P.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const _=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(_.ydisp+this._bufferService.rows,_.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=_.ydisp),this.refresh()}}_handleMouseUp(_){const j=_.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&_.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const A=this._mouseService.getCoords(_,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(A&&A[0]!==void 0&&A[1]!==void 0){const P=(0,m.moveToCellSequence)(A[0]-1,A[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(P,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,A=!(!_||!j||_[0]===j[0]&&_[1]===j[1]);A?_&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&_[0]===this._oldSelectionStart[0]&&_[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(_,j,A)):this._oldHasSelection&&this._fireOnSelectionChange(_,j,A)}_fireOnSelectionChange(_,j,A){this._oldSelectionStart=_,this._oldSelectionEnd=j,this._oldHasSelection=A,this._onSelectionChange.fire()}_handleBufferActivate(_){this.clearSelection(),this._trimListener.dispose(),this._trimListener=_.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(_,j){let A=j;for(let P=0;j>=P;P++){const T=_.loadCell(P,this._workCell).getChars().length;this._workCell.getWidth()===0?A--:T>1&&j!==P&&(A+=T-1)}return A}setSelection(_,j,A){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[_,j],this._model.selectionStartLength=A,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(_){this._isClickInSelection(_)||(this._selectWordAtCursor(_,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(_,j,A=!0,P=!0){if(_[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(_[1]);if(!D)return;const W=T.translateBufferLineToString(_[1],!1);let I=this._convertViewportColToCharacterIndex(D,_[0]),B=I;const F=_[0]-I;let R=0,M=0,L=0,O=0;if(W.charAt(I)===" "){for(;I>0&&W.charAt(I-1)===" ";)I--;for(;B<W.length&&W.charAt(B+1)===" ";)B++}else{let z=_[0],$=_[0];D.getWidth(z)===0&&(R++,z--),D.getWidth($)===2&&(M++,$++);const q=D.getString($).length;for(q>1&&(O+=q-1,B+=q-1);z>0&&I>0&&!this._isCharWordSeparator(D.loadCell(z-1,this._workCell));){D.loadCell(z-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(R++,z--):N>1&&(L+=N-1,I-=N-1),I--,z--}for(;$<D.length&&B+1<W.length&&!this._isCharWordSeparator(D.loadCell($+1,this._workCell));){D.loadCell($+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,$++):N>1&&(O+=N-1,B+=N-1),B++,$++}}B++;let U=I+F-R+L,Y=Math.min(this._bufferService.cols,B-I+R+M-L-O);if(j||W.slice(I,B).trim()!==""){if(A&&U===0&&D.getCodePoint(0)!==32){const z=T.lines.get(_[1]-1);if(z&&D.isWrapped&&z.getCodePoint(this._bufferService.cols-1)!==32){const $=this._getWordAt([this._bufferService.cols-1,_[1]-1],!1,!0,!1);if($){const q=this._bufferService.cols-$.start;U-=q,Y+=q}}}if(P&&U+Y===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const z=T.lines.get(_[1]+1);if(z?.isWrapped&&z.getCodePoint(0)!==32){const $=this._getWordAt([0,_[1]+1],!1,!1,!0);$&&(Y+=$.length)}}return{start:U,length:Y}}}_selectWordAt(_,j){const A=this._getWordAt(_,j);if(A){for(;A.start<0;)A.start+=this._bufferService.cols,_[1]--;this._model.selectionStart=[A.start,_[1]],this._model.selectionStartLength=A.length}}_selectToWordAt(_){const j=this._getWordAt(_,!0);if(j){let A=_[1];for(;j.start<0;)j.start+=this._bufferService.cols,A--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,A++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,A]}}_isCharWordSeparator(_){return _.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(_.getChars())>=0}_selectLineAt(_){const j=this._bufferService.buffer.getWrappedRangeForLine(_),A={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,u.getRangeLength)(A,this._bufferService.cols)}};n.SelectionService=E=l([d(3,b.IBufferService),d(4,b.ICoreService),d(5,w.IMouseService),d(6,b.IOptionsService),d(7,w.IRenderService),d(8,w.ICoreBrowserService)],E)},4725:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const l=i(8343);n.ICharSizeService=(0,l.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),n.IMouseService=(0,l.createDecorator)("MouseService"),n.IRenderService=(0,l.createDecorator)("RenderService"),n.ISelectionService=(0,l.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,n,i){var l=this&&this.__decorate||function(E,_,j,A){var P,T=arguments.length,D=T<3?_:A===null?A=Object.getOwnPropertyDescriptor(_,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,_,j,A);else for(var W=E.length-1;W>=0;W--)(P=E[W])&&(D=(T<3?P(D):T>3?P(_,j,D):P(_,j))||D);return T>3&&D&&Object.defineProperty(_,j,D),D},d=this&&this.__param||function(E,_){return function(j,A){_(j,A,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=i(7239),m=i(8055),x=i(8460),w=i(844),y=i(2585),a=m.css.toColor("#ffffff"),h=m.css.toColor("#000000"),u=m.css.toColor("#ffffff"),f=m.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[m.css.toColor("#2e3436"),m.css.toColor("#cc0000"),m.css.toColor("#4e9a06"),m.css.toColor("#c4a000"),m.css.toColor("#3465a4"),m.css.toColor("#75507b"),m.css.toColor("#06989a"),m.css.toColor("#d3d7cf"),m.css.toColor("#555753"),m.css.toColor("#ef2929"),m.css.toColor("#8ae234"),m.css.toColor("#fce94f"),m.css.toColor("#729fcf"),m.css.toColor("#ad7fa8"),m.css.toColor("#34e2e2"),m.css.toColor("#eeeeec")],_=[0,95,135,175,215,255];for(let j=0;j<216;j++){const A=_[j/36%6|0],P=_[j/6%6|0],T=_[j%6];E.push({css:m.channels.toCss(A,P,T),rgba:m.channels.toRgba(A,P,T)})}for(let j=0;j<24;j++){const A=8+10*j;E.push({css:m.channels.toCss(A,A,A),rgba:m.channels.toRgba(A,A,A)})}return E})());let C=n.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:u,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:m.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:m.color.blend(h,b),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const _=this._colors;if(_.foreground=k(E.foreground,a),_.background=k(E.background,h),_.cursor=k(E.cursor,u),_.cursorAccent=k(E.cursorAccent,f),_.selectionBackgroundTransparent=k(E.selectionBackground,b),_.selectionBackgroundOpaque=m.color.blend(_.background,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundOpaque=m.color.blend(_.background,_.selectionInactiveBackgroundTransparent),_.selectionForeground=E.selectionForeground?k(E.selectionForeground,m.NULL_COLOR):void 0,_.selectionForeground===m.NULL_COLOR&&(_.selectionForeground=void 0),m.color.isOpaque(_.selectionBackgroundTransparent)&&(_.selectionBackgroundTransparent=m.color.opacity(_.selectionBackgroundTransparent,.3)),m.color.isOpaque(_.selectionInactiveBackgroundTransparent)&&(_.selectionInactiveBackgroundTransparent=m.color.opacity(_.selectionInactiveBackgroundTransparent,.3)),_.ansi=n.DEFAULT_ANSI_COLORS.slice(),_.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),_.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),_.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),_.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),_.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),_.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),_.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),_.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),_.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),_.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),_.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),_.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),_.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),_.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),_.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),_.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(_.ansi.length-16,E.extendedAnsi.length);for(let A=0;A<j;A++)_.ansi[A+16]=k(E.extendedAnsi[A],n.DEFAULT_ANSI_COLORS[A+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let _=0;_<this._restoreColors.ansi.length;++_)this._colors.ansi[_]=this._restoreColors.ansi[_]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,_){if(E!==void 0)try{return m.css.toColor(E)}catch{}return _}n.ThemeService=C=l([d(0,y.IOptionsService)],C)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const l=i(8460),d=i(844);class c extends d.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const w=new Array(x);for(let y=0;y<Math.min(x,this.length);y++)w[y]=this._array[this._getCyclicIndex(y)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,w,...y){if(w){for(let a=x;a<this._length-w;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+y.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<y.length;a++)this._array[this._getCyclicIndex(x+a)]=y[a];if(y.length&&this.onInsertEmitter.fire({index:x,amount:y.length}),this._length+y.length>this._maxLength){const a=this._length+y.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=y.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,y){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+y<0)throw new Error("Cannot shift elements in list beyond index 0");if(y>0){for(let h=w-1;h>=0;h--)this.set(x+h+y,this.get(x+h));const a=x+w+y-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<w;a++)this.set(x+a+y,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}n.CircularList=c},1439:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(l,d=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const m in l)c[m]=d<=1?l[m]:l[m]&&i(l[m],d-1);return c}},8055:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const l=i(6114);let d=0,c=0,m=0,x=0;var w,y,a,h,u;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function b(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,_,j){return j!==void 0?`#${f(k)}${f(E)}${f(_)}${f(j)}`:`#${f(k)}${f(E)}${f(_)}`},C.toRgba=function(k,E,_,j=255){return(k<<24|E<<16|_<<8|j)>>>0}})(w||(n.channels=w={})),(function(C){function k(E,_){return x=Math.round(255*_),[d,c,m]=u.toChannels(E.rgba),{css:w.toCss(d,c,m,x),rgba:w.toRgba(d,c,m,x)}}C.blend=function(E,_){if(x=(255&_.rgba)/255,x===1)return{css:_.css,rgba:_.rgba};const j=_.rgba>>24&255,A=_.rgba>>16&255,P=_.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,W=E.rgba>>8&255;return d=T+Math.round((j-T)*x),c=D+Math.round((A-D)*x),m=W+Math.round((P-W)*x),{css:w.toCss(d,c,m),rgba:w.toRgba(d,c,m)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,_,j){const A=u.ensureContrastRatio(E.rgba,_.rgba,j);if(A)return u.toColor(A>>24&255,A>>16&255,A>>8&255)},C.opaque=function(E){const _=(255|E.rgba)>>>0;return[d,c,m]=u.toChannels(_),{css:w.toCss(d,c,m),rgba:_}},C.opacity=k,C.multiplyOpacity=function(E,_){return x=255&E.rgba,k(E,x*_/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(y||(n.color=y={})),(function(C){let k,E;if(!l.isNode){const _=document.createElement("canvas");_.width=1,_.height=1;const j=_.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(_){if(_.match(/#[\da-f]{3,8}/i))switch(_.length){case 4:return d=parseInt(_.slice(1,2).repeat(2),16),c=parseInt(_.slice(2,3).repeat(2),16),m=parseInt(_.slice(3,4).repeat(2),16),u.toColor(d,c,m);case 5:return d=parseInt(_.slice(1,2).repeat(2),16),c=parseInt(_.slice(2,3).repeat(2),16),m=parseInt(_.slice(3,4).repeat(2),16),x=parseInt(_.slice(4,5).repeat(2),16),u.toColor(d,c,m,x);case 7:return{css:_,rgba:(parseInt(_.slice(1),16)<<8|255)>>>0};case 9:return{css:_,rgba:parseInt(_.slice(1),16)>>>0}}const j=_.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return d=parseInt(j[1]),c=parseInt(j[2]),m=parseInt(j[3]),x=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),u.toColor(d,c,m,x);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=_,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,c,m,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:w.toRgba(d,c,m,x),css:_}}})(a||(n.css=a={})),(function(C){function k(E,_,j){const A=E/255,P=_/255,T=j/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(h||(n.rgb=h={})),(function(C){function k(_,j,A){const P=_>>24&255,T=_>>16&255,D=_>>8&255;let W=j>>24&255,I=j>>16&255,B=j>>8&255,F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));for(;F<A&&(W>0||I>0||B>0);)W-=Math.max(0,Math.ceil(.1*W)),I-=Math.max(0,Math.ceil(.1*I)),B-=Math.max(0,Math.ceil(.1*B)),F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));return(W<<24|I<<16|B<<8|255)>>>0}function E(_,j,A){const P=_>>24&255,T=_>>16&255,D=_>>8&255;let W=j>>24&255,I=j>>16&255,B=j>>8&255,F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));for(;F<A&&(W<255||I<255||B<255);)W=Math.min(255,W+Math.ceil(.1*(255-W))),I=Math.min(255,I+Math.ceil(.1*(255-I))),B=Math.min(255,B+Math.ceil(.1*(255-B))),F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));return(W<<24|I<<16|B<<8|255)>>>0}C.ensureContrastRatio=function(_,j,A){const P=h.relativeLuminance(_>>8),T=h.relativeLuminance(j>>8);if(b(P,T)<A){if(T<P){const I=k(_,j,A),B=b(P,h.relativeLuminance(I>>8));if(B<A){const F=E(_,j,A);return B>b(P,h.relativeLuminance(F>>8))?I:F}return I}const D=E(_,j,A),W=b(P,h.relativeLuminance(D>>8));if(W<A){const I=k(_,j,A);return W>b(P,h.relativeLuminance(I>>8))?D:I}return D}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(_){return[_>>24&255,_>>16&255,_>>8&255,255&_]},C.toColor=function(_,j,A,P){return{css:w.toCss(_,j,A,P),rgba:w.toRgba(_,j,A,P)}}})(u||(n.rgba=u={})),n.toPaddedHex=f,n.contrastRatio=b},8969:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const l=i(844),d=i(2585),c=i(4348),m=i(7866),x=i(744),w=i(7302),y=i(6975),a=i(8460),h=i(1753),u=i(1480),f=i(7994),b=i(9282),C=i(5435),k=i(5981),E=i(2660);let _=!1;class j extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((P=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(P.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(P){for(const T in P)this.optionsService.options[T]=P[T]}constructor(P){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new w.OptionsService(P)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(m.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(y.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(u.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((T,D)=>this._inputHandler.parse(T,D)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(P,T){this._writeBuffer.write(P,T)}writeSync(P,T){this._logService.logLevel<=d.LogLevelEnum.WARN&&!_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_=!0),this._writeBuffer.writeSync(P,T)}resize(P,T){isNaN(P)||isNaN(T)||(P=Math.max(P,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(P,T))}scroll(P,T=!1){this._bufferService.scroll(P,T)}scrollLines(P,T,D){this._bufferService.scrollLines(P,T,D)}scrollPages(P){this.scrollLines(P*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(P){const T=P-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(P,T){return this._inputHandler.registerEscHandler(P,T)}registerDcsHandler(P,T){return this._inputHandler.registerDcsHandler(P,T)}registerCsiHandler(P,T){return this._inputHandler.registerCsiHandler(P,T)}registerOscHandler(P,T){return this._inputHandler.registerOscHandler(P,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let P=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?P=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(P=!0),P?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const P=[];P.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),P.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const T of P)T.dispose()}))}}}n.CoreTerminal=j},8460:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===i)return void this._listeners.splice(l,1)}}})),this._event}fire(i,l){const d=[];for(let c=0;c<this._listeners.length;c++)d.push(this._listeners[c]);for(let c=0;c<d.length;c++)d[c].call(void 0,i,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,l){return i((d=>l.fire(d)))}},5435:function(v,n,i){var l=this&&this.__decorate||function(F,R,M,L){var O,U=arguments.length,Y=U<3?R:L===null?L=Object.getOwnPropertyDescriptor(R,M):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(F,R,M,L);else for(var z=F.length-1;z>=0;z--)(O=F[z])&&(Y=(U<3?O(Y):U>3?O(R,M,Y):O(R,M))||Y);return U>3&&Y&&Object.defineProperty(R,M,Y),Y},d=this&&this.__param||function(F,R){return function(M,L){R(M,L,F)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=i(2584),m=i(7116),x=i(2015),w=i(844),y=i(482),a=i(8437),h=i(8460),u=i(643),f=i(511),b=i(3734),C=i(2585),k=i(6242),E=i(6351),_=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function P(F,R){if(F>24)return R.setWinLines||!1;switch(F){case 1:return!!R.restoreWin;case 2:return!!R.minimizeWin;case 3:return!!R.setWinPosition;case 4:return!!R.setWinSizePixels;case 5:return!!R.raiseWin;case 6:return!!R.lowerWin;case 7:return!!R.refreshWin;case 8:return!!R.setWinSizeChars;case 9:return!!R.maximizeWin;case 10:return!!R.fullscreenWin;case 11:return!!R.getWinState;case 13:return!!R.getWinPosition;case 14:return!!R.getWinSizePixels;case 15:return!!R.getScreenSizePixels;case 16:return!!R.getCellSizePixels;case 18:return!!R.getWinSizeChars;case 19:return!!R.getScreenSizeChars;case 20:return!!R.getIconTitle;case 21:return!!R.getWinTitle;case 22:return!!R.pushTitle;case 23:return!!R.popTitle;case 24:return!!R.setWinLines}return!1}var T;(function(F){F[F.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",F[F.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(n.WindowsOptionsReportType=T={}));let D=0;class W extends w.Disposable{getAttrData(){return this._curAttrData}constructor(R,M,L,O,U,Y,z,$,q=new x.EscapeSequenceParser){super(),this._bufferService=R,this._charsetService=M,this._coreService=L,this._logService=O,this._optionsService=U,this._oscLinkService=Y,this._coreMouseService=z,this._unicodeService=$,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new y.StringToUtf32,this._utf8Decoder=new y.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:H.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,H,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:H,data:X})})),this._parser.setDcsHandlerFallback(((N,H,X)=>{H==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:H,payload:X})})),this._parser.setPrintHandler(((N,H,X)=>this.print(N,H,X))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const N in m.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,H)=>this.requestStatusString(N,H))))}_preserveStack(R,M,L,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=R,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=L,this._parseStack.position=O}_logSlowResolvingAsync(R){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([R,new Promise(((M,L)=>setTimeout((()=>L("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(R,M){let L,O=this._activeBuffer.x,U=this._activeBuffer.y,Y=0;const z=this._parseStack.paused;if(z){if(L=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(L),L;O=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,R.length>A&&(Y=this._parseStack.position+A)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof R=="string"?` "${R}"`:` "${Array.prototype.map.call(R,($=>String.fromCharCode($))).join("")}"`),typeof R=="string"?R.split("").map(($=>$.charCodeAt(0))):R),this._parseBuffer.length<R.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min(R.length,A))),z||this._dirtyRowTracker.clearRange(),R.length>A)for(let $=Y;$<R.length;$+=A){const q=$+A<R.length?$+A:R.length,N=typeof R=="string"?this._stringDecoder.decode(R.substring($,q),this._parseBuffer):this._utf8Decoder.decode(R.subarray($,q),this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,U,N,$),this._logSlowResolvingAsync(L),L}else if(!z){const $=typeof R=="string"?this._stringDecoder.decode(R,this._parseBuffer):this._utf8Decoder.decode(R,this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,$))return this._preserveStack(O,U,$,0),this._logSlowResolvingAsync(L),L}this._activeBuffer.x===O&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(R,M,L){let O,U;const Y=this._charsetService.charset,z=this._optionsService.rawOptions.screenReaderMode,$=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,H=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&L-M>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let K=M;K<L;++K){if(O=R[K],U=this._unicodeService.wcwidth(O),O<127&&Y){const ne=Y[String.fromCharCode(O)];ne&&(O=ne.charCodeAt(0))}if(z&&this._onA11yChar.fire((0,y.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=$){if(q){for(;this._activeBuffer.x<$;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=$-1,U===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(H),H),X.getWidth($-1)===2&&X.setCellFromCodePoint($-1,u.NULL_CELL_CODE,u.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,U,H.fg,H.bg,H.extended),U>0)for(;--U;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}L-M>0&&(X.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<$&&L-M>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(R,M){return R.final!=="t"||R.prefix||R.intermediates?this._parser.registerCsiHandler(R,M):this._parser.registerCsiHandler(R,(L=>!P(L.params[0],this._optionsService.rawOptions.windowOptions)||M(L)))}registerDcsHandler(R,M){return this._parser.registerDcsHandler(R,new E.DcsHandler(M))}registerEscHandler(R,M){return this._parser.registerEscHandler(R,M)}registerOscHandler(R,M){return this._parser.registerOscHandler(R,new k.OscHandler(M))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var R;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||R===void 0)&&R.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const R=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-R),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(R=this._bufferService.cols-1){this._activeBuffer.x=Math.min(R,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(R,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=R,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=R,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(R,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+R,this._activeBuffer.y+M)}cursorUp(R){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,R.params[0]||1)):this._moveCursor(0,-(R.params[0]||1)),!0}cursorDown(R){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,R.params[0]||1)):this._moveCursor(0,R.params[0]||1),!0}cursorForward(R){return this._moveCursor(R.params[0]||1,0),!0}cursorBackward(R){return this._moveCursor(-(R.params[0]||1),0),!0}cursorNextLine(R){return this.cursorDown(R),this._activeBuffer.x=0,!0}cursorPrecedingLine(R){return this.cursorUp(R),this._activeBuffer.x=0,!0}cursorCharAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(R){return this._setCursor(R.length>=2?(R.params[1]||1)-1:0,(R.params[0]||1)-1),!0}charPosAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(R){return this._moveCursor(R.params[0]||1,0),!0}linePosAbsolute(R){return this._setCursor(this._activeBuffer.x,(R.params[0]||1)-1),!0}vPositionRelative(R){return this._moveCursor(0,R.params[0]||1),!0}hVPosition(R){return this.cursorPosition(R),!0}tabClear(R){const M=R.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=R.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=R.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(R){const M=R.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(R,M,L,O=!1,U=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);Y.replaceCells(M,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),O&&(Y.isWrapped=!1)}_resetBufferLine(R,M=!1){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);L&&(L.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+R),L.isWrapped=!1)}eraseInDisplay(R,M=!1){let L;switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);L<this._bufferService.rows;L++)this._resetBufferLine(L,M);this._dirtyRowTracker.markDirty(L);break;case 1:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(L+1).isWrapped=!1);L--;)this._resetBufferLine(L,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(L=this._bufferService.rows,this._dirtyRowTracker.markDirty(L-1);L--;)this._resetBufferLine(L,M);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(R,M=!1){switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(R){this._restrictCursor();let M=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;M--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(R){this._restrictCursor();let M=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;M--;)this._activeBuffer.lines.splice(L,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(R){let M=R.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(R){let M=R.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(R.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(R){if(!this._parser.precedingCodepoint)return!0;const M=R.params[0]||1,L=new Uint32Array(M);for(let O=0;O<M;++O)L[O]=this._parser.precedingCodepoint;return this.print(L,0,L.length),!0}sendDeviceAttributesPrimary(R){return R.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(R){return R.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(R.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(R){return(this._optionsService.rawOptions.termName+"").indexOf(R)===0}setMode(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),this._charsetService.setgCharset(1,m.DEFAULT_CHARSET),this._charsetService.setgCharset(2,m.DEFAULT_CHARSET),this._charsetService.setgCharset(3,m.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),R.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(R,M){const L=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:U}=this._coreMouseService,Y=this._coreService,{buffers:z,cols:$}=this._bufferService,{active:q,alt:N}=z,H=this._optionsService.rawOptions,X=he=>he?1:2,K=R.params[0];return ne=K,te=M?K===2?4:K===4?X(Y.modes.insertMode):K===12?3:K===20?X(H.convertEol):0:K===1?X(L.applicationCursorKeys):K===3?H.windowOptions.setWinLines?$===80?2:$===132?1:0:0:K===6?X(L.origin):K===7?X(L.wraparound):K===8?3:K===9?X(O==="X10"):K===12?X(H.cursorBlink):K===25?X(!Y.isCursorHidden):K===45?X(L.reverseWraparound):K===66?X(L.applicationKeypad):K===67?4:K===1e3?X(O==="VT200"):K===1002?X(O==="DRAG"):K===1003?X(O==="ANY"):K===1004?X(L.sendFocus):K===1005?4:K===1006?X(U==="SGR"):K===1015?4:K===1016?X(U==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?X(q===N):K===2004?X(L.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${M?"":"?"}${ne};${te}$y`),!0;var ne,te}_updateAttrColor(R,M,L,O,U){return M===2?(R|=50331648,R&=-16777216,R|=b.AttributeData.fromColorRGB([L,O,U])):M===5&&(R&=-50331904,R|=33554432|255&L),R}_extractColor(R,M,L){const O=[0,0,-1,0,0,0];let U=0,Y=0;do{if(O[Y+U]=R.params[M+Y],R.hasSubParams(M+Y)){const z=R.getSubParams(M+Y);let $=0;do O[1]===5&&(U=1),O[Y+$+1+U]=z[$];while(++$<z.length&&$+Y+1+U<O.length);break}if(O[1]===5&&Y+U>=2||O[1]===2&&Y+U>=5)break;O[1]&&(U=1)}while(++Y+M<R.length&&Y+U<O.length);for(let z=2;z<O.length;++z)O[z]===-1&&(O[z]=0);switch(O[0]){case 38:L.fg=this._updateAttrColor(L.fg,O[1],O[3],O[4],O[5]);break;case 48:L.bg=this._updateAttrColor(L.bg,O[1],O[3],O[4],O[5]);break;case 58:L.extended=L.extended.clone(),L.extended.underlineColor=this._updateAttrColor(L.extended.underlineColor,O[1],O[3],O[4],O[5])}return Y}_processUnderline(R,M){M.extended=M.extended.clone(),(!~R||R>5)&&(R=1),M.extended.underlineStyle=R,M.fg|=268435456,R===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(R){R.fg=a.DEFAULT_ATTR_DATA.fg,R.bg=a.DEFAULT_ATTR_DATA.bg,R.extended=R.extended.clone(),R.extended.underlineStyle=0,R.extended.underlineColor&=-67108864,R.updateExtended()}charAttributes(R){if(R.length===1&&R.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=R.length;let L;const O=this._curAttrData;for(let U=0;U<M;U++)L=R.params[U],L>=30&&L<=37?(O.fg&=-50331904,O.fg|=16777216|L-30):L>=40&&L<=47?(O.bg&=-50331904,O.bg|=16777216|L-40):L>=90&&L<=97?(O.fg&=-50331904,O.fg|=16777224|L-90):L>=100&&L<=107?(O.bg&=-50331904,O.bg|=16777224|L-100):L===0?this._processSGR0(O):L===1?O.fg|=134217728:L===3?O.bg|=67108864:L===4?(O.fg|=268435456,this._processUnderline(R.hasSubParams(U)?R.getSubParams(U)[0]:1,O)):L===5?O.fg|=536870912:L===7?O.fg|=67108864:L===8?O.fg|=1073741824:L===9?O.fg|=2147483648:L===2?O.bg|=134217728:L===21?this._processUnderline(2,O):L===22?(O.fg&=-134217729,O.bg&=-134217729):L===23?O.bg&=-67108865:L===24?(O.fg&=-268435457,this._processUnderline(0,O)):L===25?O.fg&=-536870913:L===27?O.fg&=-67108865:L===28?O.fg&=-1073741825:L===29?O.fg&=2147483647:L===39?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):L===49?(O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):L===38||L===48||L===58?U+=this._extractColor(R,U,O):L===53?O.bg|=1073741824:L===55?O.bg&=-1073741825:L===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):L===100?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",L);return!0}deviceStatus(R){switch(R.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${M};${L}R`)}return!0}deviceStatusPrivate(R){if(R.params[0]===6){const M=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${M};${L}R`)}return!0}softReset(R){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(R){const M=R.params[0]||1;switch(M){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const L=M%2==1;return this._optionsService.options.cursorBlink=L,!0}setScrollRegion(R){const M=R.params[0]||1;let L;return(R.length<2||(L=R.params[1])>this._bufferService.rows||L===0)&&(L=this._bufferService.rows),L>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=L-1,this._setCursor(0,0)),!0}windowOptions(R){if(!P(R.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=R.length>1?R.params[1]:0;switch(R.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(R){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(R){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(R){return this._windowTitle=R,this._onTitleChange.fire(R),!0}setIconName(R){return this._iconName=R,!0}setOrReportIndexedColor(R){const M=[],L=R.split(";");for(;L.length>1;){const O=L.shift(),U=L.shift();if(/^\d+$/.exec(O)){const Y=parseInt(O);if(B(Y))if(U==="?")M.push({type:0,index:Y});else{const z=(0,_.parseColor)(U);z&&M.push({type:1,index:Y,color:z})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(R){const M=R.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(R,M){this._getCurrentLinkId()&&this._finishHyperlink();const L=R.split(":");let O;const U=L.findIndex((Y=>Y.startsWith("id=")));return U!==-1&&(O=L[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(R,M){const L=R.split(";");for(let O=0;O<L.length&&!(M>=this._specialColors.length);++O,++M)if(L[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const U=(0,_.parseColor)(L[O]);U&&this._onColor.fire([{type:1,index:this._specialColors[M],color:U}])}return!0}setOrReportFgColor(R){return this._setOrReportSpecialColor(R,0)}setOrReportBgColor(R){return this._setOrReportSpecialColor(R,1)}setOrReportCursorColor(R){return this._setOrReportSpecialColor(R,2)}restoreIndexedColor(R){if(!R)return this._onColor.fire([{type:2}]),!0;const M=[],L=R.split(";");for(let O=0;O<L.length;++O)if(/^\d+$/.exec(L[O])){const U=parseInt(L[O]);B(U)&&M.push({type:2,index:U})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(R){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(R){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(R){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),!0}selectCharset(R){return R.length!==2?(this.selectDefaultCharset(),!0):(R[0]==="/"||this._charsetService.setgCharset(j[R[0]],m.CHARSETS[R[1]]||m.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const R=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,R,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(R){return this._charsetService.setgLevel(R),!0}screenAlignmentPattern(){const R=new f.CellData;R.content=4194373,R.fg=this._curAttrData.fg,R.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const L=this._activeBuffer.ybase+this._activeBuffer.y+M,O=this._activeBuffer.lines.get(L);O&&(O.fill(R),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(R,M){const L=this._bufferService.buffer,O=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${U}${c.C0.ESC}\\`),!0))(R==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:R==='"p'?'P1$r61;1"p':R==="r"?`P1$r${L.scrollTop+1};${L.scrollBottom+1}r`:R==="m"?"P1$r0m":R===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(R,M){this._dirtyRowTracker.markRangeDirty(R,M)}}n.InputHandler=W;let I=class{constructor(F){this._bufferService=F,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(F){F<this.start?this.start=F:F>this.end&&(this.end=F)}markRangeDirty(F,R){F>R&&(D=F,F=R,R=D),F<this.start&&(this.start=F),R>this.end&&(this.end=R)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function B(F){return 0<=F&&F<256}I=l([d(0,C.IBufferService)],I)},844:(v,n)=>{function i(l){for(const d of l)d.dispose();l.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const d=this._disposables.indexOf(l);d!==-1&&this._disposables.splice(d,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var d;this._isDisposed||l===this._value||((d=this._value)===null||d===void 0||d.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},n.toDisposable=function(l){return{dispose:l}},n.disposeArray=i,n.getDisposeArrayDisposable=function(l){return{dispose:()=>i(l)}}},1505:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(d,c,m){this._data[d]||(this._data[d]={}),this._data[d][c]=m}get(d,c){return this._data[d]?this._data[d][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(l,d,c,m,x){this._data.get(l,d)||this._data.set(l,d,new i),this._data.get(l,d).set(c,m,x)}get(l,d,c,m){var x;return(x=this._data.get(l,d))===null||x===void 0?void 0:x.get(c,m)}clear(){this._data.clear()}}},6114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,l=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const d=i.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),n.isIpad=l==="iPad",n.isIphone=l==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),n.isLinux=l.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(i=this._search(this._getKey(l)),this._array.splice(i,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const d=this._getKey(l);if(d===void 0||(i=this._search(d),i===-1)||this._getKey(this._array[i])!==d)return!1;do if(this._array[i]===l)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===d);return!1}*getKeyIterator(l){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===l)}forEachByKey(l,d){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do d(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let d=0,c=this._array.length-1;for(;c>=d;){let m=d+c>>1;const x=this._getKey(this._array[m]);if(x>l)c=m-1;else{if(!(x<l)){for(;m>0&&this._getKey(this._array[m-1])===l;)m--;return m}d=m+1}}return d}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const l=i(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let w=0,y=0,a=x.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),y=Math.max(w,y),h=x.timeRemaining(),1.5*y>h)return a-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-w))}ms`),void this._start();a=h}this.clear()}}class c extends d{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(m){return requestIdleCallback(m)}_cancelCallback(m){cancelIdleCallback(m)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(m){this._queue.clear(),this._queue.enqueue(m)}flush(){this._queue.flush()}}},9282:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const l=i(643);n.updateWindowsModeWrappedState=function(d){const c=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),m=c?.get(d.cols-1),x=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);x&&m&&(x.isWrapped=m[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&m[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new i;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}n.AttributeData=i;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,m=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=m}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=l},9092:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const l=i(6349),d=i(7226),c=i(3734),m=i(8437),x=i(4634),w=i(511),y=i(643),a=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(u,f,b){this._hasScrollback=u,this._optionsService=f,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=m.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,y.NULL_CELL_CHAR,y.NULL_CELL_WIDTH,y.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,y.WHITESPACE_CELL_CHAR,y.WHITESPACE_CELL_WIDTH,y.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(u){return u?(this._nullCell.fg=u.fg,this._nullCell.bg=u.bg,this._nullCell.extended=u.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(u){return u?(this._whitespaceCell.fg=u.fg,this._whitespaceCell.bg=u.bg,this._whitespaceCell.extended=u.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(u,f){return new m.BufferLine(this._bufferService.cols,this.getNullCell(u),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const u=this.ybase+this.y-this.ydisp;return u>=0&&u<this._rows}_getCorrectBufferLength(u){if(!this._hasScrollback)return u;const f=u+this._optionsService.rawOptions.scrollback;return f>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:f}fillViewportRows(u){if(this.lines.length===0){u===void 0&&(u=m.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(u))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(u,f){const b=this.getNullCell(m.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<u)for(let _=0;_<this.lines.length;_++)C+=+this.lines.get(_).resize(u,b);let E=0;if(this._rows<f)for(let _=this._rows;_<f;_++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new m.BufferLine(u,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new m.BufferLine(u,b)));else for(let _=this._rows;_>f;_--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const _=this.lines.length-k;_>0&&(this.lines.trimStart(_),this.ybase=Math.max(this.ybase-_,0),this.ydisp=Math.max(this.ydisp-_,0),this.savedY=Math.max(this.savedY-_,0)),this.lines.maxLength=k}this.x=Math.min(this.x,u-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,u-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(u,f),this._cols>u))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(u,b);this._cols=u,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let u=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,u=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return u}get _isReflowEnabled(){const u=this._optionsService.rawOptions.windowsPty;return u&&u.buildNumber?this._hasScrollback&&u.backend==="conpty"&&u.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(u,f){this._cols!==u&&(u>this._cols?this._reflowLarger(u,f):this._reflowSmaller(u,f))}_reflowLarger(u,f){const b=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,u,this.ybase+this.y,this.getNullCell(m.DEFAULT_ATTR_DATA));if(b.length>0){const C=(0,x.reflowLargerCreateNewLayout)(this.lines,b);(0,x.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(u,f,C.countRemoved)}}_reflowLargerAdjustViewport(u,f,b){const C=this.getNullCell(m.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new m.BufferLine(u,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(u,f){const b=this.getNullCell(m.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let _=this.lines.get(E);if(!_||!_.isWrapped&&_.getTrimmedLength()<=u)continue;const j=[_];for(;_.isWrapped&&E>0;)_=this.lines.get(--E),j.unshift(_);const A=this.ybase+this.y;if(A>=E&&A<E+j.length)continue;const P=j[j.length-1].getTrimmedLength(),T=(0,x.reflowSmallerGetNewLineLengths)(j,this._cols,u),D=T.length-j.length;let W;W=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+D):Math.max(0,this.lines.length-this.lines.maxLength+D);const I=[];for(let O=0;O<D;O++){const U=this.getBlankLine(m.DEFAULT_ATTR_DATA,!0);I.push(U)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let B=T.length-1,F=T[B];F===0&&(B--,F=T[B]);let R=j.length-D-1,M=P;for(;R>=0;){const O=Math.min(M,F);if(j[B]===void 0)break;if(j[B].copyCellsFrom(j[R],M-O,F-O,O,!0),F-=O,F===0&&(B--,F=T[B]),M-=O,M===0){R--;const U=Math.max(R,0);M=(0,x.getWrappedLineTrimmedLength)(j,U,this._cols)}}for(let O=0;O<j.length;O++)T[O]<u&&j[O].setCell(T[O],b);let L=D-W;for(;L-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+f-1)}if(C.length>0){const E=[],_=[];for(let B=0;B<this.lines.length;B++)_.push(this.lines.get(B));const j=this.lines.length;let A=j-1,P=0,T=C[P];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let B=Math.min(this.lines.maxLength-1,j+k-1);B>=0;B--)if(T&&T.start>A+D){for(let F=T.newLines.length-1;F>=0;F--)this.lines.set(B--,T.newLines[F]);B++,E.push({index:A+1,amount:T.newLines.length}),D+=T.newLines.length,T=C[++P]}else this.lines.set(B,_[A--]);let W=0;for(let B=E.length-1;B>=0;B--)E[B].index+=W,this.lines.onInsertEmitter.fire(E[B]),W+=E[B].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(u,f,b=0,C){const k=this.lines.get(u);return k?k.translateToString(f,b,C):""}getWrappedRangeForLine(u){let f=u,b=u;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:f,last:b}}setupTabStops(u){for(u!=null?this.tabs[u]||(u=this.prevStop(u)):(this.tabs={},u=0);u<this._cols;u+=this._optionsService.rawOptions.tabStopWidth)this.tabs[u]=!0}prevStop(u){for(u==null&&(u=this.x);!this.tabs[--u]&&u>0;);return u>=this._cols?this._cols-1:u<0?0:u}nextStop(u){for(u==null&&(u=this.x);!this.tabs[++u]&&u<this._cols;);return u>=this._cols?this._cols-1:u<0?0:u}clearMarkers(u){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===u&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].dispose(),this.markers.splice(u--,1);this._isClearing=!1}addMarker(u){const f=new a.Marker(u);return this.markers.push(f),f.register(this.lines.onTrim((b=>{f.line-=b,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((b=>{f.line>=b.index&&(f.line+=b.amount)}))),f.register(this.lines.onDelete((b=>{f.line>=b.index&&f.line<b.index+b.amount&&f.dispose(),f.line>b.index&&(f.line-=b.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(u){this._isClearing||this.markers.splice(this.markers.indexOf(u),1)}}},8437:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const l=i(3734),d=i(511),c=i(643),m=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let x=0;class w{constructor(a,h,u=!1){this.isWrapped=u,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||d.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,f);this.length=a}get(a){const h=this._data[3*a+0],u=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:u?(0,m.stringFromCodePoint)(u):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):u]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,m.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,u,f,b,C){268435456&b&&(this._extendedAttrs[a]=C),this._data[3*a+0]=h|u<<22,this._data[3*a+1]=f,this._data[3*a+2]=b}addCodepointToCell(a,h){let u=this._data[3*a+0];2097152&u?this._combined[a]+=(0,m.stringFromCodePoint)(h):(2097151&u?(this._combined[a]=(0,m.stringFromCodePoint)(2097151&u)+(0,m.stringFromCodePoint)(h),u&=-2097152,u|=2097152):u=h|4194304,this._data[3*a+0]=u)}insertCells(a,h,u,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const b=new d.CellData;for(let C=this.length-a-h-1;C>=0;--C)this.setCell(a+h+C,this.loadCell(a+C,b));for(let C=0;C<h;++C)this.setCell(a+C,u)}else for(let b=a;b<this.length;++b)this.setCell(b,u);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,u,f){if(a%=this.length,h<this.length-a){const b=new d.CellData;for(let C=0;C<this.length-a-h;++C)this.setCell(a+C,this.loadCell(a+h+C,b));for(let C=this.length-h;C<this.length;++C)this.setCell(C,u)}else for(let b=a;b<this.length;++b)this.setCell(b,u);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,u,f,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,u),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,u)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const u=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*u)this._data=new Uint32Array(this._data.buffer,0,u);else{const f=new Uint32Array(u);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,u);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let C=0;C<b.length;C++){const k=parseInt(b[C],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*u*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let u=0;u<this.length;++u)this.isProtected(u)||this.setCell(u,a);else{this._combined={},this._extendedAttrs={};for(let u=0;u<this.length;++u)this.setCell(u,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new w(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,u,f,b){const C=a._data;if(b)for(let E=f-1;E>=0;E--){for(let _=0;_<3;_++)this._data[3*(u+E)+_]=C[3*(h+E)+_];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=a._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let _=0;_<3;_++)this._data[3*(u+E)+_]=C[3*(h+E)+_];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=a._extendedAttrs[h+E])}const k=Object.keys(a._combined);for(let E=0;E<k.length;E++){const _=parseInt(k[E],10);_>=h&&(this._combined[_-h+u]=a._combined[_])}}translateToString(a=!1,h=0,u=this.length){a&&(u=Math.min(u,this.getTrimmedLength()));let f="";for(;h<u;){const b=this._data[3*h+0],C=2097151&b;f+=2097152&b?this._combined[h]:C?(0,m.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,h+=b>>22||1}return f}}n.BufferLine=w},4841:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,l){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return l*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(v,n)=>{function i(l,d,c){if(d===l.length-1)return l[d].getTrimmedLength();const m=!l[d].hasContent(c-1)&&l[d].getWidth(c-1)===1,x=l[d+1].getWidth(0)===2;return m&&x?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(l,d,c,m,x){const w=[];for(let y=0;y<l.length-1;y++){let a=y,h=l.get(++a);if(!h.isWrapped)continue;const u=[l.get(y)];for(;a<l.length&&h.isWrapped;)u.push(h),h=l.get(++a);if(m>=y&&m<a){y+=u.length-1;continue}let f=0,b=i(u,f,d),C=1,k=0;for(;C<u.length;){const _=i(u,C,d),j=_-k,A=c-b,P=Math.min(j,A);u[f].copyCellsFrom(u[C],k,b,P,!1),b+=P,b===c&&(f++,b=0),k+=P,k===_&&(C++,k=0),b===0&&f!==0&&u[f-1].getWidth(c-1)===2&&(u[f].copyCellsFrom(u[f-1],c-1,b++,1,!1),u[f-1].setCell(c-1,x))}u[f].replaceCells(b,c,x);let E=0;for(let _=u.length-1;_>0&&(_>f||u[_].getTrimmedLength()===0);_--)E++;E>0&&(w.push(y+u.length-E),w.push(E)),y+=u.length-1}return w},n.reflowLargerCreateNewLayout=function(l,d){const c=[];let m=0,x=d[m],w=0;for(let y=0;y<l.length;y++)if(x===y){const a=d[++m];l.onDeleteEmitter.fire({index:y-w,amount:a}),y+=a-1,w+=a,x=d[++m]}else c.push(y);return{layout:c,countRemoved:w}},n.reflowLargerApplyNewLayout=function(l,d){const c=[];for(let m=0;m<d.length;m++)c.push(l.get(d[m]));for(let m=0;m<c.length;m++)l.set(m,c[m]);l.length=d.length},n.reflowSmallerGetNewLineLengths=function(l,d,c){const m=[],x=l.map(((h,u)=>i(l,u,d))).reduce(((h,u)=>h+u));let w=0,y=0,a=0;for(;a<x;){if(x-a<c){m.push(x-a);break}w+=c;const h=i(l,y,d);w>h&&(w-=h,y++);const u=l[y].getWidth(w-1)===2;u&&w--;const f=u?c-1:c;m.push(f),a+=f}return m},n.getWrappedLineTrimmedLength=i},5295:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const l=i(8460),d=i(844),c=i(9092);class m extends d.Disposable{constructor(w,y){super(),this._optionsService=w,this._bufferService=y,this._onBufferActivate=this.register(new l.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,y){this._normal.resize(w,y),this._alt.resize(w,y),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}n.BufferSet=m},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const l=i(482),d=i(643),c=i(3734);class m extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const y=new m;return y.setFromCharData(w),y}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let y=!1;if(w[d.CHAR_DATA_CHAR_INDEX].length>2)y=!0;else if(w[d.CHAR_DATA_CHAR_INDEX].length===2){const a=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|w[d.CHAR_DATA_WIDTH_INDEX]<<22:y=!0}else y=!0}else this.content=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[d.CHAR_DATA_WIDTH_INDEX]<<22;y&&(this.combinedData=w[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=m},643:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const l=i(8460),d=i(844);class c{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}n.Marker=c,c._nextId=1},7116:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,n)=>{var i,l,d;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
+
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(i||(n.C0=i={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(l||(n.C1=l={})),(function(c){c.ST=`${i.ESC}\\`})(d||(n.C1_ESCAPED=d={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const l=i(2584),d={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(c,m,x,w){const y={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?y.key=m?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?y.key=m?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?y.key=m?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(y.key=m?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){y.key=l.C0.ESC+l.C0.DEL;break}y.key=l.C0.DEL;break;case 9:if(c.shiftKey){y.key=l.C0.ESC+"[Z";break}y.key=l.C0.HT,y.cancel=!0;break;case 13:y.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,y.cancel=!0;break;case 27:y.key=l.C0.ESC,c.altKey&&(y.key=l.C0.ESC+l.C0.ESC),y.cancel=!0;break;case 37:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"D",y.key===l.C0.ESC+"[1;3D"&&(y.key=l.C0.ESC+(x?"b":"[1;5D"))):y.key=m?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"C",y.key===l.C0.ESC+"[1;3C"&&(y.key=l.C0.ESC+(x?"f":"[1;5C"))):y.key=m?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"A",x||y.key!==l.C0.ESC+"[1;3A"||(y.key=l.C0.ESC+"[1;5A")):y.key=m?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"B",x||y.key!==l.C0.ESC+"[1;3B"||(y.key=l.C0.ESC+"[1;5B")):y.key=m?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(y.key=l.C0.ESC+"[2~");break;case 46:y.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:y.key=a?l.C0.ESC+"[1;"+(a+1)+"H":m?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:y.key=a?l.C0.ESC+"[1;"+(a+1)+"F":m?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?y.type=2:c.ctrlKey?y.key=l.C0.ESC+"[5;"+(a+1)+"~":y.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?y.type=3:c.ctrlKey?y.key=l.C0.ESC+"[6;"+(a+1)+"~":y.key=l.C0.ESC+"[6~";break;case 112:y.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:y.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:y.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:y.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:y.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:y.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:y.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:y.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:y.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:y.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:y.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:y.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(x&&!w||!c.altKey||c.metaKey)!x||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?y.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(y.key=l.C0.US),c.key==="@"&&(y.key=l.C0.NUL)):c.keyCode===65&&(y.type=1);else{const h=d[c.keyCode],u=h?.[c.shiftKey?1:0];if(u)y.key=l.C0.ESC+u;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let b=String.fromCharCode(f);c.shiftKey&&(b=b.toUpperCase()),y.key=l.C0.ESC+b}else if(c.keyCode===32)y.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),y.key=l.C0.ESC+f,y.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?y.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?y.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?y.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?y.key=l.C0.DEL:c.keyCode===219?y.key=l.C0.ESC:c.keyCode===220?y.key=l.C0.FS:c.keyCode===221&&(y.key=l.C0.GS)}return y}},482:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,l=0,d=i.length){let c="";for(let m=l;m<d;++m){let x=i[m];x>65535?(x-=65536,c+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):c+=String.fromCharCode(x)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,l){const d=i.length;if(!d)return 0;let c=0,m=0;if(this._interim){const x=i.charCodeAt(m++);56320<=x&&x<=57343?l[c++]=1024*(this._interim-55296)+x-56320+65536:(l[c++]=this._interim,l[c++]=x),this._interim=0}for(let x=m;x<d;++x){const w=i.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=d)return this._interim=w,c;const y=i.charCodeAt(x);56320<=y&&y<=57343?l[c++]=1024*(w-55296)+y-56320+65536:(l[c++]=w,l[c++]=y)}else w!==65279&&(l[c++]=w)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const d=i.length;if(!d)return 0;let c,m,x,w,y=0,a=0,h=0;if(this.interim[0]){let b=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const _=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=_-E;for(;h<j;){if(h>=d)return 0;if(k=i[h++],(192&k)!=128){h--,b=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}b||(_===2?C<128?h--:l[y++]=C:_===3?C<2048||C>=55296&&C<=57343||C===65279||(l[y++]=C):C<65536||C>1114111||(l[y++]=C)),this.interim.fill(0)}const u=d-4;let f=h;for(;f<d;){for(;!(!(f<u)||128&(c=i[f])||128&(m=i[f+1])||128&(x=i[f+2])||128&(w=i[f+3]));)l[y++]=c,l[y++]=m,l[y++]=x,l[y++]=w,f+=4;if(c=i[f++],c<128)l[y++]=c;else if((224&c)==192){if(f>=d)return this.interim[0]=c,y;if(m=i[f++],(192&m)!=128){f--;continue}if(a=(31&c)<<6|63&m,a<128){f--;continue}l[y++]=a}else if((240&c)==224){if(f>=d)return this.interim[0]=c,y;if(m=i[f++],(192&m)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,y;if(x=i[f++],(192&x)!=128){f--;continue}if(a=(15&c)<<12|(63&m)<<6|63&x,a<2048||a>=55296&&a<=57343||a===65279)continue;l[y++]=a}else if((248&c)==240){if(f>=d)return this.interim[0]=c,y;if(m=i[f++],(192&m)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,y;if(x=i[f++],(192&x)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,this.interim[2]=x,y;if(w=i[f++],(192&w)!=128){f--;continue}if(a=(7&c)<<18|(63&m)<<12|(63&x)<<6|63&w,a<65536||a>1114111)continue;l[y++]=a}}return y}}},225:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let d;n.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let c=0;c<i.length;++c)d.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?d[c]:(function(m,x){let w,y=0,a=x.length-1;if(m<x[0][0]||m>x[a][1])return!1;for(;a>=y;)if(w=y+a>>1,m>x[w][1])y=w+1;else{if(!(m<x[w][0]))return!0;a=w-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const l=i(8460),d=i(844);class c extends d.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let y;for(this._isSyncWriting=!0;y=this._writeBuffer.shift();){this._action(y);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const y=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,w);if(h){const f=b=>Date.now()-y>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(y,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(f)}const u=this._callbacks[this._bufferOffset];if(u&&u(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-y>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=c},5941:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function d(c,m){const x=c.toString(16),w=x.length<2?"0"+x:x;switch(m){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}n.parseColor=function(c){if(!c)return;let m=c.toLowerCase();if(m.indexOf("rgb:")===0){m=m.slice(4);const x=i.exec(m);if(x){const w=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/w*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/w*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/w*255)]}}else if(m.indexOf("#")===0&&(m=m.slice(1),l.exec(m)&&[3,6,9,12].includes(m.length))){const x=m.length/3,w=[0,0,0];for(let y=0;y<3;++y){const a=parseInt(m.slice(x*y,x*y+x),16);w[y]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return w}},n.toRgbString=function(c,m=16){const[x,w,y]=c;return`rgb:${d(x,m)}/${d(w,m)}/${d(y,m)}`}},5770:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const l=i(482),d=i(8742),c=i(5770),m=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=m,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}registerHandler(w,y){this._handlers[w]===void 0&&(this._handlers[w]=[]);const a=this._handlers[w];return a.push(y),{dispose:()=>{const h=a.indexOf(y);h!==-1&&a.splice(h,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=m,this._ident=0}hook(w,y){if(this.reset(),this._ident=w,this._active=this._handlers[w]||m,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(y);else this._handlerFb(this._ident,"HOOK",y)}put(w,y,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(w,y,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(w,y,a))}unhook(w,y=!0){if(this._active.length){let a=!1,h=this._active.length-1,u=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=y,u=this._stack.fallThrough,this._stack.paused=!1),!u&&a===!1){for(;h>=0&&(a=this._active[h].unhook(w),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",w);this._active=m,this._ident=0}};const x=new d.Params;x.addParam(0),n.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,y,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(w,y,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let y=!1;if(this._hitLimit)y=!1;else if(w&&(y=this._handler(this._data,this._params),y instanceof Promise))return y.then((a=>(this._params=x,this._data="",this._hitLimit=!1,a)));return this._params=x,this._data="",this._hitLimit=!1,y}}},2015:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const l=i(844),d=i(8742),c=i(6242),m=i(6351);class x{constructor(h){this.table=new Uint8Array(h)}setDefault(h,u){this.table.fill(h<<4|u)}add(h,u,f,b){this.table[u<<8|h]=f<<4|b}addMany(h,u,f,b){for(let C=0;C<h.length;C++)this.table[u<<8|h[C]]=f<<4|b}}n.TransitionTable=x;const w=160;n.VT500_TRANSITION_TABLE=(function(){const a=new x(4095),h=Array.apply(null,Array(256)).map(((E,_)=>_)),u=(E,_)=>h.slice(E,_),f=u(32,127),b=u(0,24);b.push(25),b.push.apply(b,u(28,32));const C=u(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),C)a.addMany([24,26,153,154],k,3,0),a.addMany(u(128,144),k,3,0),a.addMany(u(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(u(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(b,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(u(64,127),3,7,0),a.addMany(u(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(u(48,60),4,8,4),a.addMany(u(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(u(32,64),6,0,6),a.add(127,6,0,6),a.addMany(u(64,127),6,0,0),a.addMany(u(32,48),3,9,5),a.addMany(u(32,48),5,9,5),a.addMany(u(48,64),5,0,6),a.addMany(u(64,127),5,7,0),a.addMany(u(32,48),4,9,5),a.addMany(u(32,48),1,9,2),a.addMany(u(32,48),2,9,2),a.addMany(u(48,127),2,10,0),a.addMany(u(48,80),1,10,0),a.addMany(u(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(u(96,127),1,10,0),a.add(80,1,11,9),a.addMany(b,9,0,9),a.add(127,9,0,9),a.addMany(u(28,32),9,0,9),a.addMany(u(32,48),9,9,12),a.addMany(u(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(b,11,0,11),a.addMany(u(32,128),11,0,11),a.addMany(u(28,32),11,0,11),a.addMany(b,10,0,10),a.add(127,10,0,10),a.addMany(u(28,32),10,0,10),a.addMany(u(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(u(32,48),10,9,12),a.addMany(b,12,0,12),a.add(127,12,0,12),a.addMany(u(28,32),12,0,12),a.addMany(u(32,48),12,9,12),a.addMany(u(48,64),12,0,11),a.addMany(u(64,127),12,12,13),a.addMany(u(64,127),10,12,13),a.addMany(u(64,127),9,12,13),a.addMany(b,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(w,0,2,0),a.add(w,8,5,8),a.add(w,6,0,6),a.add(w,11,0,11),a.add(w,13,13,13),a})();class y extends l.Disposable{constructor(h=n.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(u,f,b)=>{},this._executeHandlerFb=u=>{},this._csiHandlerFb=(u,f)=>{},this._escHandlerFb=u=>{},this._errorHandlerFb=u=>u,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new m.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,u=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const k=h.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(u[0]>b||b>u[1])throw new Error(`final must be in range ${u[0]} .. ${u[1]}`);return f<<=8,f|=b,f}identToString(h){const u=[];for(;h;)u.push(String.fromCharCode(255&h)),h>>=8;return u.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,u){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const b=this._escHandlers[f];return b.push(u),{dispose:()=>{const C=b.indexOf(u);C!==-1&&b.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,u){this._executeHandlers[h.charCodeAt(0)]=u}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,u){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const b=this._csiHandlers[f];return b.push(u),{dispose:()=>{const C=b.indexOf(u);C!==-1&&b.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,u){return this._dcsParser.registerHandler(this._identifier(h),u)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,u){return this._oscParser.registerHandler(h,u)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,u,f,b,C){this._parseStack.state=h,this._parseStack.handlers=u,this._parseStack.handlerPos=f,this._parseStack.transition=b,this._parseStack.chunkPos=C}parse(h,u,f){let b,C=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const _=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(b=_[j](this._params),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(b=_[j](),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(C!==24&&C!==26,f),b)return b;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],b=this._oscParser.end(C!==24&&C!==26,f),b)return b;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let _=E;_<u;++_){switch(C=h[_],k=this._transitions.table[this.currentState<<8|(C<160?C:w)],k>>4){case 2:for(let D=_+1;;++D){if(D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:_,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let A=j?j.length-1:-1;for(;A>=0&&(b=j[A](this._params),b!==!0);A--)if(b instanceof Promise)return this._preserveStack(3,j,A,k,_),b;A<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++_<u&&(C=h[_])>47&&C<60);_--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const P=this._escHandlers[this._collect<<8|C];let T=P?P.length-1:-1;for(;T>=0&&(b=P[T](),b!==!0);T--)if(b instanceof Promise)return this._preserveStack(4,P,T,k,_),b;T<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let D=_+1;;++D)if(D>=u||(C=h[D])===24||C===26||C===27||C>127&&C<w){this._dcsParser.put(h,_,D),_=D-1;break}break;case 14:if(b=this._dcsParser.unhook(C!==24&&C!==26),b)return this._preserveStack(6,[],0,k,_),b;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let D=_+1;;D++)if(D>=u||(C=h[D])<32||C>127&&C<w){this._oscParser.put(h,_,D),_=D-1;break}break;case 6:if(b=this._oscParser.end(C!==24&&C!==26),b)return this._preserveStack(5,[],0,k,_),b;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=y},6242:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const l=i(5770),d=i(482),c=[];n.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(m,x){this._handlers[m]===void 0&&(this._handlers[m]=[]);const w=this._handlers[m];return w.push(x),{dispose:()=>{const y=w.indexOf(x);y!==-1&&w.splice(y,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].start();else this._handlerFb(this._id,"START")}_put(m,x,w){if(this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].put(m,x,w);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(m,x,w))}start(){this.reset(),this._state=1}put(m,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const y=m[x++];if(y===59){this._state=2,this._start();break}if(y<48||57<y)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+y-48}this._state===2&&w-x>0&&this._put(m,x,w)}}end(m,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,y=this._active.length-1,a=!1;if(this._stack.paused&&(y=this._stack.loopPosition-1,w=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&w===!1){for(;y>=0&&(w=this._active[y].end(m),w!==!0);y--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!1,w;y--}for(;y>=0;y--)if(w=this._active[y].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",m);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(m){this._handler=m,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(m,x,w){this._hitLimit||(this._data+=(0,d.utf32ToString)(m,x,w),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(m){let x=!1;if(this._hitLimit)x=!1;else if(m&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class l{static fromArray(c){const m=new l;if(!c.length)return m;for(let x=Array.isArray(c[0])?1:0;x<c.length;++x){const w=c[x];if(Array.isArray(w))for(let y=0;y<w.length;++y)m.addSubParam(w[y]);else m.addParam(w)}return m}constructor(c=32,m=32){if(this.maxLength=c,this.maxSubParamsLength=m,m>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(m),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let m=0;m<this.length;++m){c.push(this.params[m]);const x=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,w))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>i?i:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>i?i:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const m=this._subParamsIdx[c]>>8,x=255&this._subParamsIdx[c];return x-m>0?this._subParams.subarray(m,x):null}getSubParamsAll(){const c={};for(let m=0;m<this.length;++m){const x=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-x>0&&(c[m]=this._subParams.slice(x,w))}return c}addDigit(c){let m;if(this._rejectDigits||!(m=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[m-1];x[m-1]=~w?Math.min(10*w+c,i):c}}n.Params=l},5741:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,l){const d={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(d),l.dispose=()=>this._wrappedAddonDispose(d),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===i){l=d;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(l,1)}}},8771:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const l=i(3785),d=i(511);n.BufferApiView=class{constructor(c,m){this._buffer=c,this.type=m}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const m=this._buffer.lines.get(c);if(m)return new l.BufferLineApiView(m)}getNullCell(){return new d.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const l=i(511);n.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,c){if(!(d<0||d>=this._line.length))return c?(this._line.loadCell(d,c),c):this._line.loadCell(d,new l.CellData)}translateToString(d,c,m){return this._line.translateToString(d,c,m)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const l=i(8771),d=i(8460),c=i(844);class m extends c.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=m},7975:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,l){return this._core.registerCsiHandler(i,(d=>l(d.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((d,c)=>l(d,c.toArray())))}addDcsHandler(i,l){return this.registerDcsHandler(i,l)}registerEscHandler(i,l){return this._core.registerEscHandler(i,l)}addEscHandler(i,l){return this.registerEscHandler(i,l)}registerOscHandler(i,l){return this._core.registerOscHandler(i,l)}addOscHandler(i,l){return this.registerOscHandler(i,l)}}},7090:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=i(8460),m=i(844),x=i(5295),w=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let y=n.BufferService=class extends m.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const u=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=u.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const b=u.ybase+u.scrollTop,C=u.ybase+u.scrollBottom;if(u.scrollTop===0){const k=u.lines.isFull;C===u.lines.length-1?k?u.lines.recycle().copyFrom(f):u.lines.push(f.clone()):u.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(u.ydisp=Math.max(u.ydisp-1,0)):(u.ybase++,this.isUserScrolling||u.ydisp++)}else{const k=C-b+1;u.lines.shiftElements(b+1,k-1,-1),u.lines.set(C,f.clone())}this.isUserScrolling||(u.ydisp=u.ybase),this._onScroll.fire(u.ydisp)}scrollLines(a,h,u){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const b=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),b!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};n.BufferService=y=l([d(0,w.IOptionsService)],y)},7994:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,l){this._charsets[i]=l,this.glevel===i&&(this.charset=l)}}},1753:function(v,n,i){var l=this&&this.__decorate||function(f,b,C,k){var E,_=arguments.length,j=_<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,b,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(_<3?E(j):_>3?E(b,C,j):E(b,C))||j);return _>3&&j&&Object.defineProperty(b,C,j),j},d=this&&this.__param||function(f,b){return function(C,k){b(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=i(2585),m=i(8460),x=i(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function y(f,b){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||b||(C|=3)),C}const a=String.fromCharCode,h={DEFAULT:f=>{const b=[y(f,!1)+32,f.col+32,f.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${y(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${y(f,!0)};${f.x};${f.y}${b}`}};let u=n.CoreMouseService=class extends x.Disposable{constructor(f,b){super(),this._bufferService=f,this._coreService=b,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new m.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(w))this.addProtocol(C,w[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(f,b){this._protocols[f]=b}addEncoding(f,b){this._encodings[f]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const b=this._encodings[this._activeEncoding](f);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,b,C){if(C){if(f.x!==b.x||f.y!==b.y)return!1}else if(f.col!==b.col||f.row!==b.row)return!1;return f.button===b.button&&f.action===b.action&&f.ctrl===b.ctrl&&f.alt===b.alt&&f.shift===b.shift}};n.CoreMouseService=u=l([d(0,c.IBufferService),d(1,c.ICoreService)],u)},6975:function(v,n,i){var l=this&&this.__decorate||function(u,f,b,C){var k,E=arguments.length,_=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,b):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(u,f,b,C);else for(var j=u.length-1;j>=0;j--)(k=u[j])&&(_=(E<3?k(_):E>3?k(f,b,_):k(f,b))||_);return E>3&&_&&Object.defineProperty(f,b,_),_},d=this&&this.__param||function(u,f){return function(b,C){f(b,C,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=i(1439),m=i(8460),x=i(844),w=i(2585),y=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=n.CoreService=class extends x.Disposable{constructor(u,f,b){super(),this._bufferService=u,this._logService=f,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new m.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new m.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(y),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(y),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(u,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${u}"`,(()=>u.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(u)}triggerBinaryEvent(u){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${u}"`,(()=>u.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(u))}};n.CoreService=h=l([d(0,w.IBufferService),d(1,w.ILogService),d(2,w.IOptionsService)],h)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const l=i(8055),d=i(8460),c=i(844),m=i(6106);let x=0,w=0;class y extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new m.SortedList((u=>u?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(u){if(u.marker.isDisposed)return;const f=new a(u);if(f){const b=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),b.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const u of this._decorations.values())u.dispose();this._decorations.clear()}*getDecorationsAtCell(u,f,b){var C,k,E;let _=0,j=0;for(const A of this._decorations.getKeyIterator(f))_=(C=A.options.x)!==null&&C!==void 0?C:0,j=_+((k=A.options.width)!==null&&k!==void 0?k:1),u>=_&&u<j&&(!b||((E=A.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&(yield A)}forEachDecorationAtCell(u,f,b,C){this._decorations.forEachByKey(f,(k=>{var E,_,j;x=(E=k.options.x)!==null&&E!==void 0?E:0,w=x+((_=k.options.width)!==null&&_!==void 0?_:1),u>=x&&u<w&&(!b||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&C(k)}))}}n.DecorationService=y;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(u){super(),this.options=u,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=u.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const l=i(2585),d=i(8343);class c{constructor(...x){this._entries=new Map;for(const[w,y]of x)this.set(w,y)}set(x,w){const y=this._entries.get(x);return this._entries.set(x,w),y}forEach(x){for(const[w,y]of this._entries.entries())x(w,y)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(m,x){this._services.set(m,x)}getService(m){return this._services.get(m)}createInstance(m,...x){const w=(0,d.getServiceDependencies)(m).sort(((h,u)=>h.index-u.index)),y=[];for(const h of w){const u=this._services.get(h.id);if(!u)throw new Error(`[createInstance] ${m.name} depends on UNKNOWN service ${h.id}.`);y.push(u)}const a=w.length>0?w[0].index:x.length;if(x.length!==a)throw new Error(`[createInstance] First service dependency of ${m.name} at position ${a+1} conflicts with ${x.length} static arguments`);return new m(...x,...y)}}},7866:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=i(844),m=i(2585),x={trace:m.LogLevelEnum.TRACE,debug:m.LogLevelEnum.DEBUG,info:m.LogLevelEnum.INFO,warn:m.LogLevelEnum.WARN,error:m.LogLevelEnum.ERROR,off:m.LogLevelEnum.OFF};let w,y=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=m.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,u){this._evalLazyOptionalParams(u),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...u)}trace(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.TRACE&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.DEBUG&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.INFO&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.WARN&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.ERROR&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};n.LogService=y=l([d(0,m.IOptionsService)],y),n.setTraceLogger=function(a){w=a},n.traceCall=function(a,h,u){if(typeof u.value!="function")throw new Error("not supported");const f=u.value;u.value=function(...b){if(w.logLevel!==m.LogLevelEnum.TRACE)return f.apply(this,b);w.trace(`GlyphRenderer#${f.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,b);return w.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const l=i(8460),d=i(844),c=i(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const m=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends d.Disposable{constructor(y){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const h in y)if(h in a)try{const u=y[h];a[h]=this._sanitizeAndValidateOption(h,u)}catch(u){console.error(u)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(y,a){return this.onOptionChange((h=>{h===y&&a(this.rawOptions[y])}))}onMultipleOptionChange(y,a){return this.onOptionChange((h=>{y.indexOf(h)!==-1&&a()}))}_setupOptions(){const y=h=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,u)=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);u=this._sanitizeAndValidateOption(h,u),this.rawOptions[h]!==u&&(this.rawOptions[h]=u,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const u={get:y.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,u)}}_sanitizeAndValidateOption(y,a){switch(y){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[y]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${y}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[y]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=m.includes(a)?a:n.DEFAULT_OPTIONS[y];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${y} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${y} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${y} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${y} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=x},2660:function(v,n,i){var l=this&&this.__decorate||function(x,w,y,a){var h,u=arguments.length,f=u<3?w:a===null?a=Object.getOwnPropertyDescriptor(w,y):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,w,y,a);else for(var b=x.length-1;b>=0;b--)(h=x[b])&&(f=(u<3?h(f):u>3?h(w,y,f):h(w,y))||f);return u>3&&f&&Object.defineProperty(w,y,f),f},d=this&&this.__param||function(x,w){return function(y,a){w(y,a,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=i(2585);let m=n.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const w=this._bufferService.buffer;if(x.id===void 0){const b=w.addMarker(w.ybase+w.y),C={data:x,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(C,b))),this._dataByLinkId.set(C.id,C),C.id}const y=x,a=this._getEntryIdKey(y),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,w.ybase+w.y),h.id;const u=w.addMarker(w.ybase+w.y),f={id:this._nextId++,key:this._getEntryIdKey(y),data:y,lines:[u]};return u.onDispose((()=>this._removeMarkerFromLink(f,u))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(x,w){const y=this._dataByLinkId.get(x);if(y&&y.lines.every((a=>a.line!==w))){const a=this._bufferService.buffer.addMarker(w);y.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(y,a)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))===null||w===void 0?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const y=x.lines.indexOf(w);y!==-1&&(x.lines.splice(y,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};n.OscLinkService=m=l([d(0,c.IBufferService)],m)},8343:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",l="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(d){return d[l]||[]},n.createDecorator=function(d){if(n.serviceRegistry.has(d))return n.serviceRegistry.get(d);const c=function(m,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(y,a,h){a[i]===a?a[l].push({id:y,index:h}):(a[l]=[{id:y,index:h}],a[i]=a)})(c,m,w)};return c.toString=()=>d,n.serviceRegistry.set(d,c),c}},2585:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const l=i(8343);var d;n.IBufferService=(0,l.createDecorator)("BufferService"),n.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),n.ICoreService=(0,l.createDecorator)("CoreService"),n.ICharsetService=(0,l.createDecorator)("CharsetService"),n.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(d||(n.LogLevelEnum=d={})),n.ILogService=(0,l.createDecorator)("LogService"),n.IOptionsService=(0,l.createDecorator)("OptionsService"),n.IOscLinkService=(0,l.createDecorator)("OscLinkService"),n.IUnicodeService=(0,l.createDecorator)("UnicodeService"),n.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const l=i(8460),d=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new d.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let m=0;const x=c.length;for(let w=0;w<x;++w){let y=c.charCodeAt(w);if(55296<=y&&y<=56319){if(++w>=x)return m+this.wcwidth(y);const a=c.charCodeAt(w);56320<=a&&a<=57343?y=1024*(y-55296)+a-56320+65536:m+=this.wcwidth(a)}m+=this.wcwidth(y)}return m}}}},o={};function g(v){var n=o[v];if(n!==void 0)return n.exports;var i=o[v]={exports:{}};return r[v].call(i.exports,i,i.exports,g),i.exports}var p={};return(()=>{var v=p;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const n=g(9042),i=g(3236),l=g(844),d=g(5741),c=g(8285),m=g(7975),x=g(7090),w=["cols","rows"];class y extends l.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const u=b=>this._core.options[b],f=(b,C)=>{this._checkReadonlyOptions(b),this._core.options[b]=C};for(const b in this._core.options){const C={get:u.bind(this,b),set:f.bind(this,b)};Object.defineProperty(this._publicOptions,b,C)}}_checkReadonlyOptions(h){if(w.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new m.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let u="none";switch(this._core.coreMouseService.activeProtocol){case"X10":u="x10";break;case"VT200":u="vt200";break;case"DRAG":u="drag";break;case"ANY":u="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:u,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const u in h)this._publicOptions[u]=h[u]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,u){this._verifyIntegers(h,u),this._core.resize(h,u)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var u,f,b;return this._checkProposedApi(),this._verifyPositiveIntegers((u=h.x)!==null&&u!==void 0?u:0,(f=h.width)!==null&&f!==void 0?f:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,u,f){this._verifyIntegers(h,u,f),this._core.select(h,u,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,u){this._verifyIntegers(h,u),this._core.selectLines(h,u)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,u){this._core.write(h,u)}writeln(h,u){this._core.write(h),this._core.write(`\r
|
|
27
|
+
`,u)}paste(h){this._core.paste(h)}refresh(h,u){this._verifyIntegers(h,u),this._core.refresh(h,u)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const u of h)if(u===1/0||isNaN(u)||u%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const u of h)if(u&&(u===1/0||isNaN(u)||u%1!=0||u<0))throw new Error("This API only accepts positive integers")}}v.Terminal=y})(),p})()))})(Ai)),Ai.exports}var Cm=wm();var km=2,Em=1,jm=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),g=Math.max(0,parseInt(r.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),v={top:parseInt(p.getPropertyValue("padding-top")),bottom:parseInt(p.getPropertyValue("padding-bottom")),right:parseInt(p.getPropertyValue("padding-right")),left:parseInt(p.getPropertyValue("padding-left"))},n=v.top+v.bottom,i=v.right+v.left,l=o-n,d=g-i-s;return{cols:Math.max(km,Math.floor(d/e.css.cell.width)),rows:Math.max(Em,Math.floor(l/e.css.cell.height))}}};function Nm(e={}){const{cwd:s,cols:r,rows:o,onOutput:g,onExit:p}=e,[v,n]=S.useState(null),[i,l]=S.useState(()=>Jt.isConnected()),[d,c]=S.useState(!1),[m,x]=S.useState(!1),[w,y]=S.useState(!1),a=S.useRef({onOutput:g,onExit:p});a.current={onOutput:g,onExit:p};const h=S.useRef(null);h.current=v,S.useEffect(()=>{if(!v)return;const k=Jt.getSocket(),E=()=>{l(!0),c(!1),n(null),y(!0)},_=()=>{l(!1),c(!1)},j=D=>{D.terminalId===v&&a.current.onOutput?.(D.data)},A=D=>{D.terminalId===v&&(c(!1),a.current.onExit?.(D.exitCode),n(null))},P=D=>{D.terminalId===v&&c(!0)},T=D=>{D.terminalId===v&&c(!1)};return k.on("connect",E),k.on("disconnect",_),k.on(ct.TERMINAL_STDOUT,j),k.on(ct.TERMINAL_EXIT,A),k.on(ct.TERMINAL_SUBSCRIBED,P),k.on(ct.TERMINAL_UNSUBSCRIBED,T),l(k.connected),k.connected&&k.emit(Ns.SUBSCRIBE,{topic:"terminal",id:v},D=>{D.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",_),k.off(ct.TERMINAL_STDOUT,j),k.off(ct.TERMINAL_EXIT,A),k.off(ct.TERMINAL_SUBSCRIBED,P),k.off(ct.TERMINAL_UNSUBSCRIBED,T),k.emit(Ns.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const u=S.useCallback(async()=>{const k=Jt.getSocket();if(!k.connected)return null;x(!0);try{const E=await Ce.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),y(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{x(!1)}},[s,r,o]),f=S.useCallback(async()=>{const k=h.current;if(k){try{await Ce.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),c(!1)}},[]),b=S.useCallback(k=>{const E=h.current;if(!E)return;Jt.getSocket().emit(Ns.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=S.useCallback((k,E)=>{const _=h.current;if(!_)return;Jt.getSocket().emit(Ns.TERMINAL_RESIZE,{terminalId:_,cols:k,rows:E})},[]);return S.useEffect(()=>()=>{const k=h.current;k&&Ce.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:i,isAttached:d,isCreating:m,needsRecreate:w,create:u,destroy:f,sendInput:b,resize:C}}function Rm({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:g}){const p=S.useRef(null),v=S.useRef(null),n=S.useRef(0),i=S.useCallback(()=>{p.current!=null&&(window.clearTimeout(p.current),p.current=null),v.current!=null&&(window.cancelAnimationFrame(v.current),v.current=null)},[]),l=S.useCallback(()=>{const m=r.current,x=s.current,w=e.current;if(!m||!x||!w||w.clientWidth<=0||w.clientHeight<=0)return!1;try{return m.fit(),x.cols>0&&x.rows>0&&g(x.cols,x.rows),!0}catch{return!1}},[r,g,e,s]),d=S.useCallback((m=6)=>{i();const x=n.current+1;n.current=x;let w=0;const y=()=>{n.current===x&&(v.current=window.requestAnimationFrame(()=>{if(v.current=null,n.current!==x)return;const a=l(),h=w<2;w<m&&(!a||h)&&(w+=1,p.current=window.setTimeout(y,50))}))};y()},[i,l]),c=S.useCallback(()=>{n.current+=1,i()},[i]);return S.useEffect(()=>c,[c]),S.useEffect(()=>{o&&d(8)},[o,d]),S.useEffect(()=>{const m=e.current;if(!m)return;if(typeof ResizeObserver>"u"){d(8);return}const x=new ResizeObserver(()=>{d(4)});return x.observe(m),m.parentElement&&x.observe(m.parentElement),d(8),()=>{x.disconnect()}},[d,e]),{fitNow:l,scheduleFit:d}}const Am={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Tm=ae.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:g}){const p=S.useRef(null),v=S.useRef(null),n=S.useRef(null),i=S.useRef(!1),{terminalId:l,isAttached:d,needsRecreate:c,create:m,sendInput:x,resize:w}=Nm({cwd:s,onOutput:S.useCallback(h=>{v.current?.write(h)},[]),onExit:S.useCallback(h=>{v.current?.writeln(`\r
|
|
28
|
+
\x1B[90m[Process exited with code ${h}]\x1B[0m`),o?.(h)},[o])}),{scheduleFit:y}=Rm({terminalRef:p,xtermRef:v,fitAddonRef:n,isVisible:r,onResize:w}),a=S.useCallback(h=>{v.current?.paste(h)},[]);return S.useEffect(()=>{r||v.current?.blur()},[r]),S.useEffect(()=>{if(!c)return;const h=v.current;h&&h.writeln(`\r
|
|
29
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),m()},[c,m]),S.useLayoutEffect(()=>{if(!p.current)return;const h=new Cm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Am,scrollback:5e3,convertEol:!0}),u=new jm;return h.loadAddon(u),h.open(p.current),v.current=h,n.current=u,y(8),()=>{h.dispose(),v.current=null,n.current=null}},[y]),S.useEffect(()=>{i.current||(i.current=!0,m())},[m]),S.useEffect(()=>{const h=v.current;if(!h||!d)return;const u=h.onData(f=>{x(f)});return()=>u.dispose()},[x,d]),S.useEffect(()=>{d&&(y(4),g?.({sendInput:x,paste:a}))},[d,g,a,y,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!l&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:p,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Mm=ae.memo(function({commands:s,onSelect:r}){const{t:o}=ce(),[g,p]=S.useState(!1),v=S.useRef(null),n=S.useRef(null);return S.useEffect(()=>{if(!g)return;const i=l=>{v.current&&!v.current.contains(l.target)&&n.current&&!n.current.contains(l.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[g]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:n,onClick:()=>p(!g),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${g?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(_d,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(wt,{size:10,className:`transition-transform ${g?"rotate-180":""}`})]}),g&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((i,l)=>t.jsxs("button",{onClick:()=>{r(i.command),p(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(Xt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},l))})})]})]})});let Ti=0;function Do(){return Ti+=1,{id:`shell-${Ti}`,order:Ti}}const Dm=ae.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:g}=ce(),[p,v]=S.useState(()=>[Do()]),[n,i]=S.useState(()=>p[0].id),[l,d]=S.useState(()=>new Set),[c,m]=S.useState(!1),[x,w]=S.useState(!1),[y,a]=S.useState(""),[h,u]=S.useState(null),f=S.useRef(new Map),b=S.useCallback(B=>{f.current.delete(B),d(F=>{if(!F.has(B))return F;const R=new Set(F);return R.delete(B),R})},[]),C=S.useCallback(()=>{const B=Do();v(F=>[...F,B]),i(B.id)},[]),k=S.useCallback((B,F)=>{F.stopPropagation(),b(B),v(R=>{const M=R.filter(L=>L.id!==B);return B===n&&M.length>0&&i(M[M.length-1].id),M})},[n,b]),E=S.useCallback(B=>{b(B),v(F=>{const R=F.filter(M=>M.id!==B);return B===n&&R.length>0&&i(R[R.length-1].id),R})},[n,b]),_=S.useCallback((B,F)=>{f.current.set(B,F),d(R=>{if(R.has(B))return R;const M=new Set(R);return M.add(B),M})},[]),j=S.useCallback(B=>{const F=f.current.get(n);F&&F.sendInput(B+"\r")},[n]),A=S.useCallback((B,F="")=>{u(B),a(F),w(!0)},[]),P=S.useCallback((B,F)=>{const R=f.current.get(B);return R?(R.paste(F),rt.success(g("Pasted into terminal")),!0):(rt.error(g("Terminal is not ready")),!1)},[g]),T=S.useCallback(async()=>{if(!f.current.has(n)){rt.error(g("Terminal is not ready"));return}const B=navigator.clipboard;if(!B?.readText){A(n);return}m(!0);try{const F=await B.readText();if(!F||F.includes(`
|
|
30
|
+
`)||F.includes("\r")){A(n,F);return}P(n,F)}catch{A(n)}finally{m(!1)}},[n,A,P,g]),D=S.useCallback(()=>{!y||!h||!P(h,y)||(w(!1),a(""),u(null))},[y,P,h]),W=S.useCallback(()=>{w(!1),a(""),u(null)},[]),I=l.has(n);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:p.map(B=>t.jsxs("button",{onClick:()=>i(B.id),className:se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",B.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Fr,{size:11,className:"shrink-0"}),t.jsx("span",{children:g("Shell {count}",{count:B.order})}),p.length>1&&t.jsx("span",{onClick:F=>k(B.id,F),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Yt,{size:10})})]},B.id))}),p.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:T,disabled:!I||c,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:g("Paste into terminal"),"aria-label":g("Paste into terminal"),children:c?t.jsx(Ke,{size:18,className:"animate-spin"}):t.jsx(Od,{size:18})})]}),t.jsx("button",{type:"button",onClick:C,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:g("New Terminal"),"aria-label":g("New Terminal"),children:t.jsx(ts,{size:14})}),o.length>0&&t.jsx(Mm,{commands:o,onSelect:j})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:p.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Fr,{size:28}),t.jsx("span",{className:"text-xs",children:g("No terminals open")}),t.jsx("button",{onClick:C,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:g("New Terminal")})]})}):p.map(B=>t.jsx("div",{"aria-hidden":B.id!==n,className:se("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",B.id===n?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Tm,{cwd:s,isVisible:r&&B.id===n,onExit:()=>E(B.id),onReady:F=>_(B.id,F)})},B.id))}),t.jsx(ns,{isOpen:x,onClose:W,title:g("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:W,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:g("Cancel")}),t.jsx("button",{type:"button",onClick:D,disabled:!y,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:g("Paste")})]}),children:t.jsx(Ed,{autoFocus:!0,value:y,onChange:B=>a(B.target.value),placeholder:g("Paste terminal input here"),"aria-label":g("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function Po(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function Pm(e){if(Array.isArray(e))return e}function Lm(e,s,r){return(s=Hm(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Im(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,g,p,v,n=[],i=!0,l=!1;try{if(p=(r=r.call(e)).next,s!==0)for(;!(i=(o=p.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(d){l=!0,g=d}finally{try{if(!i&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw g}}return n}}function Om(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
31
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),r.push.apply(r,o)}return r}function Io(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Lo(Object(r),!0).forEach(function(o){Lm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Bm(e,s){if(e==null)return{};var r,o,g=Fm(e,s);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(o=0;o<p.length;o++)r=p[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(g[r]=e[r])}return g}function Fm(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function zm(e,s){return Pm(e)||Im(e,s)||$m(e,s)||Om()}function Wm(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Hm(e){var s=Wm(e,"string");return typeof s=="symbol"?s:s+""}function $m(e,s){if(e){if(typeof e=="string")return Po(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Po(e,s):void 0}}function Um(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Oo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),r.push.apply(r,o)}return r}function Bo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Oo(Object(r),!0).forEach(function(o){Um(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Oo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function qm(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(g,p){return p(g)},o)}}function Js(e){return function s(){for(var r=this,o=arguments.length,g=new Array(o),p=0;p<o;p++)g[p]=arguments[p];return g.length>=e.length?e.apply(this,g):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(g,n))}}}function Qr(e){return{}.toString.call(e).includes("Object")}function Km(e){return!Object.keys(e).length}function cr(e){return typeof e=="function"}function Xm(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Ym(e,s){return Qr(s)||rs("changeType"),Object.keys(s).some(function(r){return!Xm(e,r)})&&rs("changeField"),s}function Vm(e){cr(e)||rs("selectorType")}function Gm(e){cr(e)||Qr(e)||rs("handlerType"),Qr(e)&&Object.values(e).some(function(s){return!cr(s)})&&rs("handlersType")}function Qm(e){e||rs("initialIsRequired"),Qr(e)||rs("initialType"),Km(e)&&rs("initialContent")}function Zm(e,s){throw new Error(e[s]||e.default)}var Jm={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},rs=Js(Zm)(Jm),Dr={changes:Ym,selector:Vm,handler:Gm,initial:Qm};function ep(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Dr.initial(e),Dr.handler(s);var r={current:e},o=Js(rp)(r,s),g=Js(sp)(r),p=Js(Dr.changes)(e),v=Js(tp)(r);function n(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return Dr.selector(l),l(r.current)}function i(l){qm(o,g,p,v)(l)}return[n,i]}function tp(e,s){return cr(s)?s(e.current):s}function sp(e,s){return e.current=Bo(Bo({},e.current),s),s}function rp(e,s,r){return cr(s)?s(e.current):Object.keys(r).forEach(function(o){var g;return(g=s[o])===null||g===void 0?void 0:g.call(s,e.current[o])}),r}var ip={create:ep},np={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function op(e){return function s(){for(var r=this,o=arguments.length,g=new Array(o),p=0;p<o;p++)g[p]=arguments[p];return g.length>=e.length?e.apply(this,g):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(g,n))}}}function ap(e){return{}.toString.call(e).includes("Object")}function lp(e){return e||Fo("configIsRequired"),ap(e)||Fo("configType"),e.urls?(cp(),{paths:{vs:e.urls.monacoBase}}):e}function cp(){console.warn(Tl.deprecation)}function dp(e,s){throw new Error(e[s]||e.default)}var Tl={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
31
32
|
You are using deprecated way of configuration.
|
|
32
33
|
|
|
33
34
|
Instead of using
|
|
@@ -36,7 +37,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
36
37
|
monaco.config({ paths: { vs: '...' } })
|
|
37
38
|
|
|
38
39
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
-
`},Fo=tp(np)(Nl),op={config:rp},ap=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(g){return r.reduceRight(function(p,v){return v(p)},g)}};function Rl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Rl(e[r],s[r]))}),Io(Io({},e),s)}var lp={type:"cancelation",msg:"operation is manually canceled"};function Ti(e){var s=!1,r=new Promise(function(o,g){e.then(function(p){return s?g(lp):o(p)}),e.catch(g)});return r.cancel=function(){return s=!0},r}var cp=["monaco"],dp=Jm.create({config:ep,isInitialized:!1,resolve:null,reject:null,monaco:null}),Al=Lm(dp,2),gr=Al[0],di=Al[1];function up(e){var s=op.config(e),r=s.monaco,o=Dm(s,cp);di(function(g){return{config:Rl(g.config,o),monaco:r}})}function hp(){var e=gr(function(s){var r=s.monaco,o=s.isInitialized,g=s.resolve;return{monaco:r,isInitialized:o,resolve:g}});if(!e.isInitialized){if(di({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ti(Mi);if(window.monaco&&window.monaco.editor)return Tl(window.monaco),e.resolve(window.monaco),Ti(Mi);ap(fp,pp)(gp)}return Ti(Mi)}function fp(e){return document.body.appendChild(e)}function mp(e){var s=document.createElement("script");return e&&(s.src=e),s}function pp(e){var s=gr(function(o){var g=o.config,p=o.reject;return{config:g,reject:p}}),r=mp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function gp(){var e=gr(function(r){var o=r.config,g=r.resolve,p=r.reject;return{config:o,resolve:g,reject:p}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Tl(o),e.resolve(o)},function(r){e.reject(r)})}function Tl(e){gr().monaco||di({monaco:e})}function vp(){return gr(function(e){var s=e.monaco;return s})}var Mi=new Promise(function(e,s){return di({resolve:e,reject:s})}),Ml={config:up,init:hp,__getMonacoInstance:vp},xp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Di=xp,_p={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},bp=_p;function yp({children:e}){return le.createElement("div",{style:bp.container},e)}var Sp=yp,wp=Sp;function Cp({width:e,height:s,isEditorReady:r,loading:o,_ref:g,className:p,wrapperProps:v}){return le.createElement("section",{style:{...Di.wrapper,width:e,height:s},...v},!r&&le.createElement(wp,null,o),le.createElement("div",{ref:g,style:{...Di.fullWidth,...!r&&Di.hide},className:p}))}var kp=Cp,Dl=S.memo(kp);function Ep(e){S.useEffect(e,[])}var Pl=Ep;function jp(e,s,r=!0){let o=S.useRef(!0);S.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var Et=jp;function sr(){}function Rs(e,s,r,o){return Np(e,o)||Rp(e,s,r,o)}function Np(e,s){return e.editor.getModel(Ll(e,s))}function Rp(e,s,r,o){return e.editor.createModel(s,r,o?Ll(e,o):void 0)}function Ll(e,s){return e.Uri.parse(s)}function Ap({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:g,originalModelPath:p,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:d="Loading...",options:c={},height:m="100%",width:x="100%",className:w,wrapperProps:_={},beforeMount:a=sr,onMount:h=sr}){let[u,f]=S.useState(!1),[y,C]=S.useState(!0),k=S.useRef(null),E=S.useRef(null),b=S.useRef(null),j=S.useRef(h),A=S.useRef(a),L=S.useRef(!1);Pl(()=>{let I=Ml.init();return I.then($=>(E.current=$)&&C(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>k.current?F():I.cancel()}),Et(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),$=Rs(E.current,e||"",o||r||"text",p||"");$!==I.getModel()&&I.setModel($)}},[p],u),Et(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),$=Rs(E.current,s||"",g||r||"text",v||"");$!==I.getModel()&&I.setModel($)}},[v],u),Et(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],u),Et(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],u),Et(()=>{let{original:I,modified:$}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage($,g||r||"text")},[r,o,g],u),Et(()=>{E.current?.editor.setTheme(l)},[l],u),Et(()=>{k.current?.updateOptions(c)},[c],u);let T=S.useCallback(()=>{if(!E.current)return;A.current(E.current);let I=Rs(E.current,e||"",o||r||"text",p||""),$=Rs(E.current,s||"",g||r||"text",v||"");k.current?.setModel({original:I,modified:$})},[r,s,g,e,o,p,v]),D=S.useCallback(()=>{!L.current&&b.current&&(k.current=E.current.editor.createDiffEditor(b.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(l),f(!0),L.current=!0)},[c,l,T]);S.useEffect(()=>{u&&j.current(k.current,E.current)},[u]),S.useEffect(()=>{!y&&!u&&D()},[y,u,D]);function F(){let I=k.current?.getModel();n||I?.original?.dispose(),i||I?.modified?.dispose(),k.current?.dispose()}return le.createElement(Dl,{width:x,height:m,isEditorReady:u,loading:d,_ref:b,className:w,wrapperProps:_})}var Tp=Ap;S.memo(Tp);function Mp(e){let s=S.useRef();return S.useEffect(()=>{s.current=e},[e]),s.current}var Dp=Mp,Dr=new Map;function Pp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:g,path:p,theme:v="light",line:n,loading:i="Loading...",options:l={},overrideServices:d={},saveViewState:c=!0,keepCurrentModel:m=!1,width:x="100%",height:w="100%",className:_,wrapperProps:a={},beforeMount:h=sr,onMount:u=sr,onChange:f,onValidate:y=sr}){let[C,k]=S.useState(!1),[E,b]=S.useState(!0),j=S.useRef(null),A=S.useRef(null),L=S.useRef(null),T=S.useRef(u),D=S.useRef(h),F=S.useRef(),I=S.useRef(o),$=Dp(p),W=S.useRef(!1),R=S.useRef(!1);Pl(()=>{let O=Ml.init();return O.then(U=>(j.current=U)&&b(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>A.current?P():O.cancel()}),Et(()=>{let O=Rs(j.current,e||o||"",s||g||"",p||r||"");O!==A.current?.getModel()&&(c&&Dr.set($,A.current?.saveViewState()),A.current?.setModel(O),c&&A.current?.restoreViewState(Dr.get(p)))},[p],C),Et(()=>{A.current?.updateOptions(l)},[l],C),Et(()=>{!A.current||o===void 0||(A.current.getOption(j.current.editor.EditorOption.readOnly)?A.current.setValue(o):o!==A.current.getValue()&&(R.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),A.current.pushUndoStop(),R.current=!1))},[o],C),Et(()=>{let O=A.current?.getModel();O&&g&&j.current?.editor.setModelLanguage(O,g)},[g],C),Et(()=>{n!==void 0&&A.current?.revealLine(n)},[n],C),Et(()=>{j.current?.editor.setTheme(v)},[v],C);let M=S.useCallback(()=>{if(!(!L.current||!j.current)&&!W.current){D.current(j.current);let O=p||r,U=Rs(j.current,o||e||"",s||g||"",O||"");A.current=j.current?.editor.create(L.current,{model:U,automaticLayout:!0,...l},d),c&&A.current.restoreViewState(Dr.get(O)),j.current.editor.setTheme(v),n!==void 0&&A.current.revealLine(n),k(!0),W.current=!0}},[e,s,r,o,g,p,l,d,c,v,n]);S.useEffect(()=>{C&&T.current(A.current,j.current)},[C]),S.useEffect(()=>{!E&&!C&&M()},[E,C,M]),I.current=o,S.useEffect(()=>{C&&f&&(F.current?.dispose(),F.current=A.current?.onDidChangeModelContent(O=>{R.current||f(A.current.getValue(),O)}))},[C,f]),S.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers(U=>{let Y=A.current.getModel()?.uri;if(Y&&U.find(B=>B.path===Y.path)){let B=j.current.editor.getModelMarkers({resource:Y});y?.(B)}});return()=>{O?.dispose()}}return()=>{}},[C,y]);function P(){F.current?.dispose(),m?c&&Dr.set(p,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return le.createElement(Dl,{width:x,height:w,isEditorReady:C,loading:i,_ref:L,className:_,wrapperProps:a})}var Lp=Pp,Ip=S.memo(Lp),Op=Ip,Tt=function(e,s){return Number(e.toFixed(s))},Bp=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Fp=function(e){return-Math.cos(e*Math.PI)/2+.5},zp=function(e){return e},Wp=function(e){return e*e},Hp=function(e){return e*(2-e)},$p=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Up=function(e){return e*e*e},qp=function(e){return--e*e*e+1},Kp=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Xp=function(e){return e*e*e*e},Yp=function(e){return 1- --e*e*e*e},Vp=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Gp=function(e){return e*e*e*e*e},Qp=function(e){return 1+--e*e*e*e*e},Zp=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Il={easeOut:Fp,linear:zp,easeInQuad:Wp,easeOutQuad:Hp,easeInOutQuad:$p,easeInCubic:Up,easeOutCubic:qp,easeInOutCubic:Kp,easeInQuart:Xp,easeOutQuart:Yp,easeInOutQuart:Vp,easeInQuint:Gp,easeOutQuint:Qp,easeInOutQuint:Zp},Ol=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Lt=function(e){e.mounted&&(Ol(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Bl(e,s,r,o){if(e.mounted){var g=new Date().getTime(),p=1;Lt(e),e.animation=function(){if(!e.mounted)return Ol(e.animation);var v=new Date().getTime()-g,n=v/r,i=Il[s],l=i(n);v>=r?(o(p),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Jp(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function ns(e,s,r,o){var g=Jp(s);if(!(!e.mounted||!g)){var p=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,d=s.scale-n,c=s.positionX-i,m=s.positionY-l;r===0?p(s.scale,s.positionX,s.positionY):Bl(e,o,r,function(x){var w=n+d*x,_=i+c*x,a=l+m*x;p(w,_,a)})}}function eg(e,s,r){var o=e.offsetWidth,g=e.offsetHeight,p=s.offsetWidth,v=s.offsetHeight,n=p*r,i=v*r,l=o-n,d=g-i;return{wrapperWidth:o,wrapperHeight:g,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:d}}var tg=function(e,s,r,o,g,p,v){var n=e>s?r*(v?1:.5):0,i=o>g?p*(v?1:.5):0,l=e-s-n,d=n,c=o-g-i,m=i;return{minPositionX:l,maxPositionX:d,minPositionY:c,maxPositionY:m}},On=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,g=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=eg(r,o,s),v=p.wrapperWidth,n=p.wrapperHeight,i=p.newContentWidth,l=p.newDiffWidth,d=p.newContentHeight,c=p.newDiffHeight,m=tg(v,i,l,n,d,c,!!g);return m},Ji=function(e,s,r,o){return o?e<s?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},ms=function(e,s){var r=On(e,s);return e.bounds=r,r};function vr(e,s,r,o,g,p,v){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,d=r.maxPositionY,c=0,m=0;v&&(c=g,m=p);var x=Ji(e,n-c,l+c,o),w=Ji(s,i-m,d+m,o);return{x,y:w}}function ui(e,s,r,o,g,p){var v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,d=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var c=i-s*d,m=l-r*d,x=vr(c,m,g,p,0,0,null);return x}function xr(e,s,r,o,g){var p=g?o:0,v=s-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var zo=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,g=e.wrapperComponent,p=s.target,v="shadowRoot"in p&&"composedPath"in s,n=v?s.composedPath().some(function(d){return d instanceof Element?g?.contains(d):!1}):g?.contains(p),i=o&&p&&n;if(!i)return!1;var l=hi(p,r);return!l},Wo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,g=o.panning.disabled,p=s&&r&&!g;return!!p},sg=function(e,s){var r=e.transformState,o=r.positionX,g=r.positionY;e.isPanning=!0;var p=s.clientX,v=s.clientY;e.startCoords={x:p-o,y:v-g}},rg=function(e,s){var r=s.touches,o=e.transformState,g=o.positionX,p=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-g,y:i-p}}};function ig(e){var s=e.transformState,r=s.positionX,o=s.positionY,g=s.scale,p=e.setup,v=p.disabled,n=p.limitToBounds,i=p.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var d=e.bounds,c=d.maxPositionX,m=d.minPositionX,x=d.maxPositionY,w=d.minPositionY,_=r>c||r<m,a=o>x||o<w,h=r>c?l.offsetWidth:e.setup.minPositionX||0,u=o>x?l.offsetHeight:e.setup.minPositionY||0,f=ui(e,h,u,g,e.bounds,n||i),y=f.x,C=f.y;return{scale:g,positionX:_?y:r,positionY:a?C:o}}}function Fl(e,s,r,o,g){var p=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,d=i.positionX,c=i.positionY;if(!(v===null||n===null||s===d&&r===c)){var m=vr(s,r,n,p,o,g,v),x=m.x,w=m.y;e.setTransformState(l,x,w)}}var ng=function(e,s,r){var o=e.startCoords,g=e.transformState,p=e.setup.panning,v=p.lockAxisX,n=p.lockAxisY,i=g.positionX,l=g.positionY;if(!o)return{x:i,y:l};var d=s-o.x,c=r-o.y,m=v?i:d,x=n?l:c;return{x:m,y:x}},is=function(e,s){var r=e.setup,o=e.transformState,g=o.scale,p=r.minScale,v=r.disablePadding;return s>0&&g>=p&&!v?s:0},og=function(e){var s=e.mounted,r=e.setup,o=r.disabled,g=r.velocityAnimation,p=e.transformState.scale,v=g.disabled,n=!v||p>1||!o||s;return!!n},ag=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,g=e.setup,p=g.disabled,v=g.velocityAnimation,n=e.transformState.scale,i=v.disabled,l=!i||n>1||!p||s;return!(!l||!r||!o)};function lg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,g=r.animationTime,p=r.sensitivity;return o?g*s*p:g}function Ho(e,s,r,o,g,p,v,n,i,l){if(g){if(s>v&&r>v){var d=v+(e-v)*l;return d>i?i:d<v?v:d}if(s<p&&r<p){var d=p+(e-p)*l;return d<n?n:d>p?p:d}}return o?s:Ji(e,p,v,g)}function cg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function dg(e,s){var r=og(e);if(r){var o=e.lastMousePosition,g=e.velocityTime,p=e.setup,v=e.wrapperComponent,n=p.velocityAnimation.equalToMove,i=Date.now();if(o&&g&&v){var l=cg(v,n),d=s.x-o.x,c=s.y-o.y,m=d/l,x=c/l,w=i-g,_=d*d+c*c,a=Math.sqrt(_)/w;e.velocity={velocityX:m,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function ug(e){var s=e.velocity,r=e.bounds,o=e.setup,g=e.wrapperComponent,p=ag(e);if(!(!p||!s||!r||!g)){var v=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,d=r.minPositionX,c=r.maxPositionY,m=r.minPositionY,x=o.limitToBounds,w=o.alignmentAnimation,_=o.zoomAnimation,a=o.panning,h=a.lockAxisY,u=a.lockAxisX,f=_.animationType,y=w.sizeX,C=w.sizeY,k=w.velocityAlignmentTime,E=k,b=lg(e,i),j=Math.max(b,E),A=is(e,y),L=is(e,C),T=A*g.offsetWidth/100,D=L*g.offsetHeight/100,F=l+T,I=d-T,$=c+D,W=m-D,R=e.transformState,M=new Date().getTime();Bl(e,f,j,function(P){var O=e.transformState,U=O.scale,Y=O.positionX,B=O.positionY,H=new Date().getTime()-M,q=H/E,N=Il[w.animationType],z=1-N(Math.min(1,q)),X=1-P,K=Y+v*X,ne=B+n*X,te=Ho(K,R.positionX,Y,u,x,d,l,I,F,z),fe=Ho(ne,R.positionY,B,h,x,m,c,W,$,z);(Y!==K||B!==ne)&&e.setTransformState(U,te,fe)})}}function $o(e,s){var r=e.transformState.scale;Lt(e),ms(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?rg(e,s):sg(e,s)}function Bn(e,s){var r=e.transformState.scale,o=e.setup,g=o.minScale,p=o.alignmentAnimation,v=p.disabled,n=p.sizeX,i=p.sizeY,l=p.animationTime,d=p.animationType,c=v||r<g||!n&&!i;if(!c){var m=ig(e);m&&ns(e,m,s??l,d)}}function Uo(e,s,r){var o=e.startCoords,g=e.setup,p=g.alignmentAnimation,v=p.sizeX,n=p.sizeY;if(o){var i=ng(e,s,r),l=i.x,d=i.y,c=is(e,v),m=is(e,n);dg(e,{x:l,y:d}),Fl(e,l,d,c,m)}}function hg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,g=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=o?.getBoundingClientRect(),v=g?.getBoundingClientRect(),n=p?.width||0,i=p?.height||0,l=v?.width||0,d=v?.height||0,c=n<l||i<d,m=!s&&r&&r?.total>.1&&c;m?ug(e):Bn(e)}}function Fn(e,s,r,o){var g=e.setup,p=g.minScale,v=g.maxScale,n=g.limitToBounds,i=xr(Tt(s,2),p,v,0,!1),l=ms(e,i),d=ui(e,r,o,i,l,n),c=d.x,m=d.y;return{scale:i,positionX:c,positionY:m}}function zl(e,s,r){var o=e.transformState.scale,g=e.wrapperComponent,p=e.setup,v=p.minScale,n=p.limitToBounds,i=p.zoomAnimation,l=i.disabled,d=i.animationTime,c=i.animationType,m=l||o>=v;if((o>=1||n)&&Bn(e),!(m||!g||!e.mounted)){var x=s||g.offsetWidth/2,w=r||g.offsetHeight/2,_=Fn(e,v,x,w);_&&ns(e,_,d,c)}}var rs=function(){return rs=Object.assign||function(s){for(var r,o=1,g=arguments.length;o<g;o++){r=arguments[o];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(s[p]=r[p])}return s},rs.apply(this,arguments)};function qo(e,s,r){for(var o=0,g=s.length,p;o<g;o++)(p||!(o in s))&&(p||(p=Array.prototype.slice.call(s,0,o)),p[o]=s[o]);return e.concat(p||Array.prototype.slice.call(s))}var Pr={scale:1,positionX:0,positionY:0},Gs={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},en={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Wl=function(e){var s,r,o,g;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Pr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Pr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Pr.positionX,positionY:(g=e.initialPositionY)!==null&&g!==void 0?g:Pr.positionY}},Ko=function(e){var s=rs({},Gs);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",g=typeof Gs[r]<"u";if(g&&o){var p=Object.prototype.toString.call(Gs[r]),v=p==="[object Object]",n=p==="[object Array]";v?s[r]=rs(rs({},Gs[r]),e[r]):n?s[r]=qo(qo([],Gs[r],!0),e[r]):s[r]=e[r]}}),s},Hl=function(e,s,r){var o=e.transformState.scale,g=e.wrapperComponent,p=e.setup,v=p.maxScale,n=p.minScale,i=p.zoomAnimation,l=p.smooth,d=i.size;if(!g)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,m=xr(Tt(c,3),n,v,d,!1);return m};function $l(e,s,r,o,g){var p=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY;if(!p)return console.error("No WrapperComponent found");var d=p.offsetWidth,c=p.offsetHeight,m=(d/2-i)/n,x=(c/2-l)/n,w=Hl(e,s,r),_=Fn(e,w,m,x);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");ns(e,_,o,g)}function Ul(e,s,r,o){var g=e.setup,p=e.wrapperComponent,v=g.limitToBounds,n=Wl(e.props),i=e.transformState,l=i.scale,d=i.positionX,c=i.positionY;if(p){var m=On(e,n.scale),x=vr(n.positionX,n.positionY,m,v,0,0,p),w={scale:n.scale,positionX:x.x,positionY:x.y};l===n.scale&&d===n.positionX&&c===n.positionY||(o?.(),ns(e,w,s,r))}}function fg(e,s,r,o){var g=e.getBoundingClientRect(),p=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=p.x*o.scale,i=p.y*o.scale;return{x:(g.x-v.x+n)/o.scale,y:(g.y-v.y+i)/o.scale}}function mg(e,s,r){var o=e.wrapperComponent,g=e.contentComponent,p=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,l=v.maxScale;if(!o||!g)return p;var d=o.getBoundingClientRect(),c=s.getBoundingClientRect(),m=fg(s,o,g,p),x=m.x,w=m.y,_=c.width/p.scale,a=c.height/p.scale,h=o.offsetWidth/_,u=o.offsetHeight/a,f=xr(r||Math.min(h,u),i,l,0,!1),y=(d.width-_*f)/2,C=(d.height-a*f)/2,k=(d.left-x)*f+y,E=(d.top-w)*f+C,b=On(e,f),j=vr(k,E,b,n,0,0,o),A=j.x,L=j.y;return{positionX:A,positionY:L,scale:f}}var pg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),$l(e,1,s,r,o)}},gg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),$l(e,-1,s,r,o)}},vg=function(e){return function(s,r,o,g,p){g===void 0&&(g=300),p===void 0&&(p="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,l=v.scale,d=e.wrapperComponent,c=e.contentComponent,m=e.setup.disabled;if(!(m||!d||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};ns(e,x,g,p)}}},xg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Ul(e,s,r)}},_g=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var g=e.transformState,p=e.wrapperComponent,v=e.contentComponent;if(p&&v){var n=ql(s||g.scale,p,v);ns(e,n,r,o)}}},bg=function(e){return function(s,r,o,g){o===void 0&&(o=600),g===void 0&&(g="easeOut"),Lt(e);var p=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(p&&v&&p.contains(v)){var n=mg(e,v,r);ns(e,n,o,g)}}},Qr=function(e){return{instance:e,zoomIn:pg(e),zoomOut:gg(e),setTransform:vg(e),resetTransform:xg(e),centerView:_g(e),zoomToElement:bg(e)}},tn=function(e){return{instance:e,state:e.transformState}},Ue=function(e){var s={};return Object.assign(s,tn(e)),Object.assign(s,Qr(e)),s},Pi=!1;function Li(){try{var e={get passive(){return Pi=!0,!1}};return e}catch{return Pi=!1,Pi}}var Lr=".".concat(en.wrapperClass),hi=function(e,s){return s.some(function(r){return e.matches("".concat(Lr," ").concat(r,", ").concat(Lr," .").concat(r,", ").concat(Lr," ").concat(r," *, ").concat(Lr," .").concat(r," *"))})},sn=function(e){e&&clearTimeout(e)},yg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},ql=function(e,s,r){var o=r.offsetWidth*e,g=r.offsetHeight*e,p=(s.offsetWidth-o)/2,v=(s.offsetHeight-g)/2;return{scale:e,positionX:p,positionY:v}};function Sg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var wg=function(e,s){var r=e.setup.wheel,o=r.disabled,g=r.wheelDisabled,p=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,l=s.target,d=n&&!i&&!o&&l;if(!d||g&&!s.ctrlKey||p&&s.ctrlKey)return!1;var c=hi(l,v);return!c},Cg=function(e){return e?e.deltaY<0?1:-1:0};function kg(e,s){var r=Cg(e),o=Bp(s,r);return o}function Kl(e,s,r){var o=s.getBoundingClientRect(),g=0,p=0;if("clientX"in e)g=(e.clientX-o.left)/r,p=(e.clientY-o.top)/r;else{var v=e.touches[0];g=(v.clientX-o.left)/r,p=(v.clientY-o.top)/r}return(Number.isNaN(g)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:g,y:p}}var Eg=function(e,s,r,o,g){var p=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,d=n.zoomAnimation,c=n.disablePadding,m=d.size,x=d.disabled;if(!v)throw new Error("Wrapper is not mounted");var w=p+s*r,_=o?!1:!x,a=xr(Tt(w,3),l,i,m,_&&!c);return a},jg=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,g=e.setup,p=g.maxScale,v=g.minScale;return r?o<p||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Ng=function(e,s){var r=e.setup.pinch,o=r.disabled,g=r.excluded,p=e.isInitialized,v=s.target,n=p&&!o&&v;if(!n)return!1;var i=hi(v,g);return!i},Rg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,g=r&&!s&&o;return!!g},Ag=function(e,s,r){var o=r.getBoundingClientRect(),g=e.touches,p=Tt(g[0].clientX-o.left,5),v=Tt(g[0].clientY-o.top,5),n=Tt(g[1].clientX-o.left,5),i=Tt(g[1].clientY-o.top,5);return{x:(p+n)/2/s,y:(v+i)/2/s}},Xl=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},Tg=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,g=e.setup,p=g.maxScale,v=g.minScale,n=g.zoomAnimation,i=g.disablePadding,l=n.size,d=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,m=c*r;return xr(Tt(m,2),v,p,l,!d&&!i)},Mg=160,Dg=100,Pg=function(e,s){var r=e.props,o=r.onWheelStart,g=r.onZoomStart;e.wheelStopEventTimer||(Lt(e),Qe(Ue(e),s,o),Qe(Ue(e),s,g))},Lg=function(e,s){var r=e.props,o=r.onWheel,g=r.onZoom,p=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,l=v.limitToBounds,d=v.centerZoomedOut,c=v.zoomAnimation,m=v.wheel,x=v.disablePadding,w=v.smooth,_=c.size,a=c.disabled,h=m.step,u=m.smoothStep;if(!p)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=kg(s,null),y=w?u*Math.abs(s.deltaY):h,C=Eg(e,f,y,!s.ctrlKey);if(i!==C){var k=ms(e,C),E=Kl(s,p,i),b=a||_===0||d||x,j=l&&b,A=ui(e,E.x,E.y,C,k,j),L=A.x,T=A.y;e.previousWheelEvent=s,e.setTransformState(C,L,T),Qe(Ue(e),s,o),Qe(Ue(e),s,g)}},Ig=function(e,s){var r=e.props,o=r.onWheelStop,g=r.onZoomStop;sn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(zl(e,s.x,s.y),e.wheelAnimationTimer=null)},Dg);var p=jg(e,s);p&&(sn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(Ue(e),s,o),Qe(Ue(e),s,g))},Mg))},Yl=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var g=s/2,p=r/2;return{x:g,y:p}},Og=function(e,s){var r=Xl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Yl(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Lt(e)},Bg=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,g=e.wrapperComponent,p=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,l=v.zoomAnimation,d=v.alignmentAnimation,c=l.disabled,m=l.size;if(!(o===null||!r)){var x=Ag(s,p,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var w=Xl(s),_=Tg(e,w),a=Yl(s),h=a.x-(e.pinchLastCenterX||0),u=a.y-(e.pinchLastCenterY||0);if(!(_===p&&h===0&&u===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ms(e,_),y=c||m===0||i,C=n&&y,k=ui(e,x.x,x.y,_,f,C),E=k.x,b=k.y;e.pinchMidpoint=x,e.lastDistance=w;var j=d.sizeX,A=d.sizeY,L=is(e,j),T=is(e,A),D=E+h,F=b+u,I=vr(D,F,f,n,L,T,g),$=I.x,W=I.y;e.setTransformState(_,$,W)}}}},Fg=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,zl(e,s?.x,s?.y)},Vl=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;sn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(Ue(e),s,r)},o)},zg=function(e,s){var r=e.props,o=r.onZoomStart,g=r.onZoom,p=e.setup.doubleClick,v=p.animationTime,n=p.animationType;Qe(Ue(e),s,o),Ul(e,v,n,function(){return Qe(Ue(e),s,g)}),Vl(e,s)};function Wg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Hg(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,g=e.transformState,p=e.contentComponent,v=g.scale,n=e.props,i=n.onZoomStart,l=n.onZoom,d=r.doubleClick,c=d.disabled,m=d.mode,x=d.step,w=d.animationTime,_=d.animationType;if(!c&&!o){if(m==="reset")return zg(e,s);if(!p)return console.error("No ContentComponent found");var a=Wg(m,e.transformState.scale),h=Hl(e,a,x);if(v!==h){Qe(Ue(e),s,i);var u=Kl(s,p,v),f=Fn(e,h,u.x,u.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Ue(e),s,l),ns(e,f,w,_),Vl(e,s)}}}var $g=function(e,s){var r=e.isInitialized,o=e.setup,g=e.wrapperComponent,p=o.doubleClick,v=p.disabled,n=p.excluded,i=s.target,l=g?.contains(i),d=r&&i&&l&&!v;if(!d)return!1;var c=hi(i,n);return!c},Ug=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,ms(r,r.transformState.scale),r.setup=Ko(o)},this.initializeWindowEvents=function(){var o,g,p=Li(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(g=r.wrapperComponent)===null||g===void 0||g.addEventListener("wheel",r.onWheelPanning,p),n?.addEventListener("mousedown",r.onPanningStart,p),n?.addEventListener("mousemove",r.onPanning,p),n?.addEventListener("mouseup",r.onPanningStop,p),v?.addEventListener("mouseleave",r.clearPanning,p),n?.addEventListener("keyup",r.setKeyUnPressed,p),n?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,g,p=Li(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,p),n?.removeEventListener("mousemove",r.onPanning,p),n?.removeEventListener("mouseup",r.onPanningStop,p),v?.removeEventListener("mouseleave",r.clearPanning,p),n?.removeEventListener("keyup",r.setKeyUnPressed,p),n?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),Lt(r),(g=r.observer)===null||g===void 0||g.disconnect()},this.handleInitializeWrapperEvents=function(o){var g=Li();o.addEventListener("wheel",r.onWheelZoom,g),o.addEventListener("dblclick",r.onDoubleClick,g),o.addEventListener("touchstart",r.onTouchPanningStart,g),o.addEventListener("touchmove",r.onTouchPanning,g),o.addEventListener("touchend",r.onTouchPanningStop,g)},this.handleInitialize=function(o,g){var p=!1,v=r.setup.centerOnInit,n=function(i,l){for(var d=0,c=i;d<c.length;d++){var m=c[d];if(m.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(Ue(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,g))if(v&&!p){var l=g.offsetWidth,d=g.offsetHeight;(l>0||d>0)&&(p=!0,r.setCenter())}else Lt(r),ms(r,r.transformState.scale),Bn(r,0)}),r.observer.observe(o),r.observer.observe(g)},this.onWheelZoom=function(o){var g=r.setup.disabled;if(!g){var p=wg(r,o);if(p){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(Pg(r,o),Lg(r,o),Ig(r,o))}}},this.onWheelPanning=function(o){var g=r.setup,p=g.disabled,v=g.wheel,n=g.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,l=i.positionX,d=i.positionY,c=l-o.deltaX,m=d-o.deltaY,x=n.lockAxisX?l:c,w=n.lockAxisY?d:m,_=r.setup.alignmentAnimation,a=_.sizeX,h=_.sizeY,u=is(r,a),f=is(r,h);x===l&&w===d||Fl(r,x,w,u,f)}},this.onPanningStart=function(o){var g=r.setup.disabled,p=r.props.onPanningStart;if(!g){var v=zo(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),Lt(r),$o(r,o),Qe(Ue(r),o,p)))}}},this.onPanning=function(o){var g=r.setup.disabled,p=r.props.onPanning;if(!g){var v=Wo(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),Uo(r,o.clientX,o.clientY),Qe(Ue(r),o,p))}}},this.onPanningStop=function(o){var g=r.props.onPanningStop;r.isPanning&&(hg(r),Qe(Ue(r),o,g))},this.onPinchStart=function(o){var g=r.setup.disabled,p=r.props,v=p.onPinchingStart,n=p.onZoomStart;if(!g){var i=Ng(r,o);i&&(Og(r,o),Lt(r),Qe(Ue(r),o,v),Qe(Ue(r),o,n))}},this.onPinch=function(o){var g=r.setup.disabled,p=r.props,v=p.onPinching,n=p.onZoom;if(!g){var i=Rg(r);i&&(o.preventDefault(),o.stopPropagation(),Bg(r,o),Qe(Ue(r),o,v),Qe(Ue(r),o,n))}},this.onPinchStop=function(o){var g=r.props,p=g.onPinchingStop,v=g.onZoomStop;r.pinchStartScale&&(Fg(r),Qe(Ue(r),o,p),Qe(Ue(r),o,v))},this.onTouchPanningStart=function(o){var g=r.setup.disabled,p=r.props.onPanningStart;if(!g){var v=zo(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,Lt(r);var i=o.touches,l=i.length===1,d=i.length===2;l&&(Lt(r),$o(r,o),Qe(Ue(r),o,p)),d&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var g=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(g)return;var v=Wo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];Uo(r,n.clientX,n.clientY),Qe(Ue(r),o,p)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var g=r.setup.disabled;if(!g){var p=$g(r,o);p&&Hg(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(g){return r.pressedKeys[g]}):!0},this.setTransformState=function(o,g,p){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(g)&&!Number.isNaN(p)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=g,r.transformState.positionY=p,r.applyTransformation();var n=Ue(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Qe(n,{scale:o,positionX:g,positionY:p},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=ql(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,g,p){return r.props.customTransform?r.props.customTransform(o,g,p):yg(o,g,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,g=o.scale,p=o.positionX,v=o.positionY,n=r.handleTransformStyles(p,v,g);r.contentComponent.style.transform=n}},this.getContext=function(){return Ue(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,g){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=g,ms(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,g),r.initializeWindowEvents(),r.isInitialized=!0;var p=Ue(r);Qe(p,void 0,r.props.onInit)},this.props=s,this.setup=Ko(this.props),this.transformState=Wl(this.props)}return e})(),fi=le.createContext(null),qg=function(e,s){return typeof e=="function"?e(s):e},Kg=le.forwardRef(function(e,s){var r=S.useRef(new Ug(e)).current,o=qg(e.children,Qr(r));return S.useImperativeHandle(s,function(){return Qr(r)},[r]),S.useEffect(function(){r.update(e)},[r,e]),le.createElement(fi.Provider,{value:r},o)});le.forwardRef(function(e,s){var r=S.useRef(null),o=S.useContext(fi);return S.useEffect(function(){return o.onChange(function(g){if(r.current){var p=0,v=0;r.current.style.transform=o.handleTransformStyles(p,v,1/g.instance.transformState.scale)}})},[o]),le.createElement("div",rs({},e,{ref:Sg([r,s])}))});function Xg(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",r==="top"&&o.firstChild?o.insertBefore(g,o.firstChild):o.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}}var Yg=`.transform-component-module_wrapper__SPB86 {
|
|
40
|
+
`},Fo=op(dp)(Tl),up={config:lp},hp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(g){return r.reduceRight(function(p,v){return v(p)},g)}};function Ml(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Ml(e[r],s[r]))}),Io(Io({},e),s)}var fp={type:"cancelation",msg:"operation is manually canceled"};function Mi(e){var s=!1,r=new Promise(function(o,g){e.then(function(p){return s?g(fp):o(p)}),e.catch(g)});return r.cancel=function(){return s=!0},r}var mp=["monaco"],pp=ip.create({config:np,isInitialized:!1,resolve:null,reject:null,monaco:null}),Dl=zm(pp,2),vr=Dl[0],ui=Dl[1];function gp(e){var s=up.config(e),r=s.monaco,o=Bm(s,mp);ui(function(g){return{config:Ml(g.config,o),monaco:r}})}function vp(){var e=vr(function(s){var r=s.monaco,o=s.isInitialized,g=s.resolve;return{monaco:r,isInitialized:o,resolve:g}});if(!e.isInitialized){if(ui({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Mi(Di);if(window.monaco&&window.monaco.editor)return Pl(window.monaco),e.resolve(window.monaco),Mi(Di);hp(xp,bp)(yp)}return Mi(Di)}function xp(e){return document.body.appendChild(e)}function _p(e){var s=document.createElement("script");return e&&(s.src=e),s}function bp(e){var s=vr(function(o){var g=o.config,p=o.reject;return{config:g,reject:p}}),r=_p("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function yp(){var e=vr(function(r){var o=r.config,g=r.resolve,p=r.reject;return{config:o,resolve:g,reject:p}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Pl(o),e.resolve(o)},function(r){e.reject(r)})}function Pl(e){vr().monaco||ui({monaco:e})}function Sp(){return vr(function(e){var s=e.monaco;return s})}var Di=new Promise(function(e,s){return ui({resolve:e,reject:s})}),Ll={config:gp,init:vp,__getMonacoInstance:Sp},wp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Pi=wp,Cp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},kp=Cp;function Ep({children:e}){return ae.createElement("div",{style:kp.container},e)}var jp=Ep,Np=jp;function Rp({width:e,height:s,isEditorReady:r,loading:o,_ref:g,className:p,wrapperProps:v}){return ae.createElement("section",{style:{...Pi.wrapper,width:e,height:s},...v},!r&&ae.createElement(Np,null,o),ae.createElement("div",{ref:g,style:{...Pi.fullWidth,...!r&&Pi.hide},className:p}))}var Ap=Rp,Il=S.memo(Ap);function Tp(e){S.useEffect(e,[])}var Ol=Tp;function Mp(e,s,r=!0){let o=S.useRef(!0);S.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var kt=Mp;function rr(){}function As(e,s,r,o){return Dp(e,o)||Pp(e,s,r,o)}function Dp(e,s){return e.editor.getModel(Bl(e,s))}function Pp(e,s,r,o){return e.editor.createModel(s,r,o?Bl(e,o):void 0)}function Bl(e,s){return e.Uri.parse(s)}function Lp({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:g,originalModelPath:p,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:d="Loading...",options:c={},height:m="100%",width:x="100%",className:w,wrapperProps:y={},beforeMount:a=rr,onMount:h=rr}){let[u,f]=S.useState(!1),[b,C]=S.useState(!0),k=S.useRef(null),E=S.useRef(null),_=S.useRef(null),j=S.useRef(h),A=S.useRef(a),P=S.useRef(!1);Ol(()=>{let I=Ll.init();return I.then(B=>(E.current=B)&&C(!1)).catch(B=>B?.type!=="cancelation"&&console.error("Monaco initialization: error:",B)),()=>k.current?W():I.cancel()}),kt(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),B=As(E.current,e||"",o||r||"text",p||"");B!==I.getModel()&&I.setModel(B)}},[p],u),kt(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),B=As(E.current,s||"",g||r||"text",v||"");B!==I.getModel()&&I.setModel(B)}},[v],u),kt(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],u),kt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],u),kt(()=>{let{original:I,modified:B}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(B,g||r||"text")},[r,o,g],u),kt(()=>{E.current?.editor.setTheme(l)},[l],u),kt(()=>{k.current?.updateOptions(c)},[c],u);let T=S.useCallback(()=>{if(!E.current)return;A.current(E.current);let I=As(E.current,e||"",o||r||"text",p||""),B=As(E.current,s||"",g||r||"text",v||"");k.current?.setModel({original:I,modified:B})},[r,s,g,e,o,p,v]),D=S.useCallback(()=>{!P.current&&_.current&&(k.current=E.current.editor.createDiffEditor(_.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(l),f(!0),P.current=!0)},[c,l,T]);S.useEffect(()=>{u&&j.current(k.current,E.current)},[u]),S.useEffect(()=>{!b&&!u&&D()},[b,u,D]);function W(){let I=k.current?.getModel();n||I?.original?.dispose(),i||I?.modified?.dispose(),k.current?.dispose()}return ae.createElement(Il,{width:x,height:m,isEditorReady:u,loading:d,_ref:_,className:w,wrapperProps:y})}var Ip=Lp;S.memo(Ip);function Op(e){let s=S.useRef();return S.useEffect(()=>{s.current=e},[e]),s.current}var Bp=Op,Pr=new Map;function Fp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:g,path:p,theme:v="light",line:n,loading:i="Loading...",options:l={},overrideServices:d={},saveViewState:c=!0,keepCurrentModel:m=!1,width:x="100%",height:w="100%",className:y,wrapperProps:a={},beforeMount:h=rr,onMount:u=rr,onChange:f,onValidate:b=rr}){let[C,k]=S.useState(!1),[E,_]=S.useState(!0),j=S.useRef(null),A=S.useRef(null),P=S.useRef(null),T=S.useRef(u),D=S.useRef(h),W=S.useRef(),I=S.useRef(o),B=Bp(p),F=S.useRef(!1),R=S.useRef(!1);Ol(()=>{let O=Ll.init();return O.then(U=>(j.current=U)&&_(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>A.current?L():O.cancel()}),kt(()=>{let O=As(j.current,e||o||"",s||g||"",p||r||"");O!==A.current?.getModel()&&(c&&Pr.set(B,A.current?.saveViewState()),A.current?.setModel(O),c&&A.current?.restoreViewState(Pr.get(p)))},[p],C),kt(()=>{A.current?.updateOptions(l)},[l],C),kt(()=>{!A.current||o===void 0||(A.current.getOption(j.current.editor.EditorOption.readOnly)?A.current.setValue(o):o!==A.current.getValue()&&(R.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),A.current.pushUndoStop(),R.current=!1))},[o],C),kt(()=>{let O=A.current?.getModel();O&&g&&j.current?.editor.setModelLanguage(O,g)},[g],C),kt(()=>{n!==void 0&&A.current?.revealLine(n)},[n],C),kt(()=>{j.current?.editor.setTheme(v)},[v],C);let M=S.useCallback(()=>{if(!(!P.current||!j.current)&&!F.current){D.current(j.current);let O=p||r,U=As(j.current,o||e||"",s||g||"",O||"");A.current=j.current?.editor.create(P.current,{model:U,automaticLayout:!0,...l},d),c&&A.current.restoreViewState(Pr.get(O)),j.current.editor.setTheme(v),n!==void 0&&A.current.revealLine(n),k(!0),F.current=!0}},[e,s,r,o,g,p,l,d,c,v,n]);S.useEffect(()=>{C&&T.current(A.current,j.current)},[C]),S.useEffect(()=>{!E&&!C&&M()},[E,C,M]),I.current=o,S.useEffect(()=>{C&&f&&(W.current?.dispose(),W.current=A.current?.onDidChangeModelContent(O=>{R.current||f(A.current.getValue(),O)}))},[C,f]),S.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers(U=>{let Y=A.current.getModel()?.uri;if(Y&&U.find(z=>z.path===Y.path)){let z=j.current.editor.getModelMarkers({resource:Y});b?.(z)}});return()=>{O?.dispose()}}return()=>{}},[C,b]);function L(){W.current?.dispose(),m?c&&Pr.set(p,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return ae.createElement(Il,{width:x,height:w,isEditorReady:C,loading:i,_ref:P,className:y,wrapperProps:a})}var zp=Fp,Wp=S.memo(zp),Hp=Wp,Tt=function(e,s){return Number(e.toFixed(s))},$p=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Up=function(e){return-Math.cos(e*Math.PI)/2+.5},qp=function(e){return e},Kp=function(e){return e*e},Xp=function(e){return e*(2-e)},Yp=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Vp=function(e){return e*e*e},Gp=function(e){return--e*e*e+1},Qp=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Zp=function(e){return e*e*e*e},Jp=function(e){return 1- --e*e*e*e},eg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},tg=function(e){return e*e*e*e*e},sg=function(e){return 1+--e*e*e*e*e},rg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Fl={easeOut:Up,linear:qp,easeInQuad:Kp,easeOutQuad:Xp,easeInOutQuad:Yp,easeInCubic:Vp,easeOutCubic:Gp,easeInOutCubic:Qp,easeInQuart:Zp,easeOutQuart:Jp,easeInOutQuart:eg,easeInQuint:tg,easeOutQuint:sg,easeInOutQuint:rg},zl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},It=function(e){e.mounted&&(zl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Wl(e,s,r,o){if(e.mounted){var g=new Date().getTime(),p=1;It(e),e.animation=function(){if(!e.mounted)return zl(e.animation);var v=new Date().getTime()-g,n=v/r,i=Fl[s],l=i(n);v>=r?(o(p),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ig(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function as(e,s,r,o){var g=ig(s);if(!(!e.mounted||!g)){var p=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,d=s.scale-n,c=s.positionX-i,m=s.positionY-l;r===0?p(s.scale,s.positionX,s.positionY):Wl(e,o,r,function(x){var w=n+d*x,y=i+c*x,a=l+m*x;p(w,y,a)})}}function ng(e,s,r){var o=e.offsetWidth,g=e.offsetHeight,p=s.offsetWidth,v=s.offsetHeight,n=p*r,i=v*r,l=o-n,d=g-i;return{wrapperWidth:o,wrapperHeight:g,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:d}}var og=function(e,s,r,o,g,p,v){var n=e>s?r*(v?1:.5):0,i=o>g?p*(v?1:.5):0,l=e-s-n,d=n,c=o-g-i,m=i;return{minPositionX:l,maxPositionX:d,minPositionY:c,maxPositionY:m}},zn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,g=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=ng(r,o,s),v=p.wrapperWidth,n=p.wrapperHeight,i=p.newContentWidth,l=p.newDiffWidth,d=p.newContentHeight,c=p.newDiffHeight,m=og(v,i,l,n,d,c,!!g);return m},en=function(e,s,r,o){return o?e<s?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},gs=function(e,s){var r=zn(e,s);return e.bounds=r,r};function xr(e,s,r,o,g,p,v){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,d=r.maxPositionY,c=0,m=0;v&&(c=g,m=p);var x=en(e,n-c,l+c,o),w=en(s,i-m,d+m,o);return{x,y:w}}function hi(e,s,r,o,g,p){var v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,d=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var c=i-s*d,m=l-r*d,x=xr(c,m,g,p,0,0,null);return x}function _r(e,s,r,o,g){var p=g?o:0,v=s-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var zo=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,g=e.wrapperComponent,p=s.target,v="shadowRoot"in p&&"composedPath"in s,n=v?s.composedPath().some(function(d){return d instanceof Element?g?.contains(d):!1}):g?.contains(p),i=o&&p&&n;if(!i)return!1;var l=fi(p,r);return!l},Wo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,g=o.panning.disabled,p=s&&r&&!g;return!!p},ag=function(e,s){var r=e.transformState,o=r.positionX,g=r.positionY;e.isPanning=!0;var p=s.clientX,v=s.clientY;e.startCoords={x:p-o,y:v-g}},lg=function(e,s){var r=s.touches,o=e.transformState,g=o.positionX,p=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-g,y:i-p}}};function cg(e){var s=e.transformState,r=s.positionX,o=s.positionY,g=s.scale,p=e.setup,v=p.disabled,n=p.limitToBounds,i=p.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var d=e.bounds,c=d.maxPositionX,m=d.minPositionX,x=d.maxPositionY,w=d.minPositionY,y=r>c||r<m,a=o>x||o<w,h=r>c?l.offsetWidth:e.setup.minPositionX||0,u=o>x?l.offsetHeight:e.setup.minPositionY||0,f=hi(e,h,u,g,e.bounds,n||i),b=f.x,C=f.y;return{scale:g,positionX:y?b:r,positionY:a?C:o}}}function Hl(e,s,r,o,g){var p=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,d=i.positionX,c=i.positionY;if(!(v===null||n===null||s===d&&r===c)){var m=xr(s,r,n,p,o,g,v),x=m.x,w=m.y;e.setTransformState(l,x,w)}}var dg=function(e,s,r){var o=e.startCoords,g=e.transformState,p=e.setup.panning,v=p.lockAxisX,n=p.lockAxisY,i=g.positionX,l=g.positionY;if(!o)return{x:i,y:l};var d=s-o.x,c=r-o.y,m=v?i:d,x=n?l:c;return{x:m,y:x}},os=function(e,s){var r=e.setup,o=e.transformState,g=o.scale,p=r.minScale,v=r.disablePadding;return s>0&&g>=p&&!v?s:0},ug=function(e){var s=e.mounted,r=e.setup,o=r.disabled,g=r.velocityAnimation,p=e.transformState.scale,v=g.disabled,n=!v||p>1||!o||s;return!!n},hg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,g=e.setup,p=g.disabled,v=g.velocityAnimation,n=e.transformState.scale,i=v.disabled,l=!i||n>1||!p||s;return!(!l||!r||!o)};function fg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,g=r.animationTime,p=r.sensitivity;return o?g*s*p:g}function Ho(e,s,r,o,g,p,v,n,i,l){if(g){if(s>v&&r>v){var d=v+(e-v)*l;return d>i?i:d<v?v:d}if(s<p&&r<p){var d=p+(e-p)*l;return d<n?n:d>p?p:d}}return o?s:en(e,p,v,g)}function mg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function pg(e,s){var r=ug(e);if(r){var o=e.lastMousePosition,g=e.velocityTime,p=e.setup,v=e.wrapperComponent,n=p.velocityAnimation.equalToMove,i=Date.now();if(o&&g&&v){var l=mg(v,n),d=s.x-o.x,c=s.y-o.y,m=d/l,x=c/l,w=i-g,y=d*d+c*c,a=Math.sqrt(y)/w;e.velocity={velocityX:m,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function gg(e){var s=e.velocity,r=e.bounds,o=e.setup,g=e.wrapperComponent,p=hg(e);if(!(!p||!s||!r||!g)){var v=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,d=r.minPositionX,c=r.maxPositionY,m=r.minPositionY,x=o.limitToBounds,w=o.alignmentAnimation,y=o.zoomAnimation,a=o.panning,h=a.lockAxisY,u=a.lockAxisX,f=y.animationType,b=w.sizeX,C=w.sizeY,k=w.velocityAlignmentTime,E=k,_=fg(e,i),j=Math.max(_,E),A=os(e,b),P=os(e,C),T=A*g.offsetWidth/100,D=P*g.offsetHeight/100,W=l+T,I=d-T,B=c+D,F=m-D,R=e.transformState,M=new Date().getTime();Wl(e,f,j,function(L){var O=e.transformState,U=O.scale,Y=O.positionX,z=O.positionY,$=new Date().getTime()-M,q=$/E,N=Fl[w.animationType],H=1-N(Math.min(1,q)),X=1-L,K=Y+v*X,ne=z+n*X,te=Ho(K,R.positionX,Y,u,x,d,l,I,W,H),he=Ho(ne,R.positionY,z,h,x,m,c,F,B,H);(Y!==K||z!==ne)&&e.setTransformState(U,te,he)})}}function $o(e,s){var r=e.transformState.scale;It(e),gs(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?lg(e,s):ag(e,s)}function Wn(e,s){var r=e.transformState.scale,o=e.setup,g=o.minScale,p=o.alignmentAnimation,v=p.disabled,n=p.sizeX,i=p.sizeY,l=p.animationTime,d=p.animationType,c=v||r<g||!n&&!i;if(!c){var m=cg(e);m&&as(e,m,s??l,d)}}function Uo(e,s,r){var o=e.startCoords,g=e.setup,p=g.alignmentAnimation,v=p.sizeX,n=p.sizeY;if(o){var i=dg(e,s,r),l=i.x,d=i.y,c=os(e,v),m=os(e,n);pg(e,{x:l,y:d}),Hl(e,l,d,c,m)}}function vg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,g=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=o?.getBoundingClientRect(),v=g?.getBoundingClientRect(),n=p?.width||0,i=p?.height||0,l=v?.width||0,d=v?.height||0,c=n<l||i<d,m=!s&&r&&r?.total>.1&&c;m?gg(e):Wn(e)}}function Hn(e,s,r,o){var g=e.setup,p=g.minScale,v=g.maxScale,n=g.limitToBounds,i=_r(Tt(s,2),p,v,0,!1),l=gs(e,i),d=hi(e,r,o,i,l,n),c=d.x,m=d.y;return{scale:i,positionX:c,positionY:m}}function $l(e,s,r){var o=e.transformState.scale,g=e.wrapperComponent,p=e.setup,v=p.minScale,n=p.limitToBounds,i=p.zoomAnimation,l=i.disabled,d=i.animationTime,c=i.animationType,m=l||o>=v;if((o>=1||n)&&Wn(e),!(m||!g||!e.mounted)){var x=s||g.offsetWidth/2,w=r||g.offsetHeight/2,y=Hn(e,v,x,w);y&&as(e,y,d,c)}}var is=function(){return is=Object.assign||function(s){for(var r,o=1,g=arguments.length;o<g;o++){r=arguments[o];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(s[p]=r[p])}return s},is.apply(this,arguments)};function qo(e,s,r){for(var o=0,g=s.length,p;o<g;o++)(p||!(o in s))&&(p||(p=Array.prototype.slice.call(s,0,o)),p[o]=s[o]);return e.concat(p||Array.prototype.slice.call(s))}var Lr={scale:1,positionX:0,positionY:0},Qs={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},tn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ul=function(e){var s,r,o,g;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Lr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Lr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Lr.positionX,positionY:(g=e.initialPositionY)!==null&&g!==void 0?g:Lr.positionY}},Ko=function(e){var s=is({},Qs);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",g=typeof Qs[r]<"u";if(g&&o){var p=Object.prototype.toString.call(Qs[r]),v=p==="[object Object]",n=p==="[object Array]";v?s[r]=is(is({},Qs[r]),e[r]):n?s[r]=qo(qo([],Qs[r],!0),e[r]):s[r]=e[r]}}),s},ql=function(e,s,r){var o=e.transformState.scale,g=e.wrapperComponent,p=e.setup,v=p.maxScale,n=p.minScale,i=p.zoomAnimation,l=p.smooth,d=i.size;if(!g)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,m=_r(Tt(c,3),n,v,d,!1);return m};function Kl(e,s,r,o,g){var p=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY;if(!p)return console.error("No WrapperComponent found");var d=p.offsetWidth,c=p.offsetHeight,m=(d/2-i)/n,x=(c/2-l)/n,w=ql(e,s,r),y=Hn(e,w,m,x);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");as(e,y,o,g)}function Xl(e,s,r,o){var g=e.setup,p=e.wrapperComponent,v=g.limitToBounds,n=Ul(e.props),i=e.transformState,l=i.scale,d=i.positionX,c=i.positionY;if(p){var m=zn(e,n.scale),x=xr(n.positionX,n.positionY,m,v,0,0,p),w={scale:n.scale,positionX:x.x,positionY:x.y};l===n.scale&&d===n.positionX&&c===n.positionY||(o?.(),as(e,w,s,r))}}function xg(e,s,r,o){var g=e.getBoundingClientRect(),p=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=p.x*o.scale,i=p.y*o.scale;return{x:(g.x-v.x+n)/o.scale,y:(g.y-v.y+i)/o.scale}}function _g(e,s,r){var o=e.wrapperComponent,g=e.contentComponent,p=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,l=v.maxScale;if(!o||!g)return p;var d=o.getBoundingClientRect(),c=s.getBoundingClientRect(),m=xg(s,o,g,p),x=m.x,w=m.y,y=c.width/p.scale,a=c.height/p.scale,h=o.offsetWidth/y,u=o.offsetHeight/a,f=_r(r||Math.min(h,u),i,l,0,!1),b=(d.width-y*f)/2,C=(d.height-a*f)/2,k=(d.left-x)*f+b,E=(d.top-w)*f+C,_=zn(e,f),j=xr(k,E,_,n,0,0,o),A=j.x,P=j.y;return{positionX:A,positionY:P,scale:f}}var bg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Kl(e,1,s,r,o)}},yg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Kl(e,-1,s,r,o)}},Sg=function(e){return function(s,r,o,g,p){g===void 0&&(g=300),p===void 0&&(p="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,l=v.scale,d=e.wrapperComponent,c=e.contentComponent,m=e.setup.disabled;if(!(m||!d||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};as(e,x,g,p)}}},wg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Xl(e,s,r)}},Cg=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var g=e.transformState,p=e.wrapperComponent,v=e.contentComponent;if(p&&v){var n=Yl(s||g.scale,p,v);as(e,n,r,o)}}},kg=function(e){return function(s,r,o,g){o===void 0&&(o=600),g===void 0&&(g="easeOut"),It(e);var p=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(p&&v&&p.contains(v)){var n=_g(e,v,r);as(e,n,o,g)}}},Zr=function(e){return{instance:e,zoomIn:bg(e),zoomOut:yg(e),setTransform:Sg(e),resetTransform:wg(e),centerView:Cg(e),zoomToElement:kg(e)}},sn=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,sn(e)),Object.assign(s,Zr(e)),s},Li=!1;function Ii(){try{var e={get passive(){return Li=!0,!1}};return e}catch{return Li=!1,Li}}var Ir=".".concat(tn.wrapperClass),fi=function(e,s){return s.some(function(r){return e.matches("".concat(Ir," ").concat(r,", ").concat(Ir," .").concat(r,", ").concat(Ir," ").concat(r," *, ").concat(Ir," .").concat(r," *"))})},rn=function(e){e&&clearTimeout(e)},Eg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Yl=function(e,s,r){var o=r.offsetWidth*e,g=r.offsetHeight*e,p=(s.offsetWidth-o)/2,v=(s.offsetHeight-g)/2;return{scale:e,positionX:p,positionY:v}};function jg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Ng=function(e,s){var r=e.setup.wheel,o=r.disabled,g=r.wheelDisabled,p=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,l=s.target,d=n&&!i&&!o&&l;if(!d||g&&!s.ctrlKey||p&&s.ctrlKey)return!1;var c=fi(l,v);return!c},Rg=function(e){return e?e.deltaY<0?1:-1:0};function Ag(e,s){var r=Rg(e),o=$p(s,r);return o}function Vl(e,s,r){var o=s.getBoundingClientRect(),g=0,p=0;if("clientX"in e)g=(e.clientX-o.left)/r,p=(e.clientY-o.top)/r;else{var v=e.touches[0];g=(v.clientX-o.left)/r,p=(v.clientY-o.top)/r}return(Number.isNaN(g)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:g,y:p}}var Tg=function(e,s,r,o,g){var p=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,d=n.zoomAnimation,c=n.disablePadding,m=d.size,x=d.disabled;if(!v)throw new Error("Wrapper is not mounted");var w=p+s*r,y=o?!1:!x,a=_r(Tt(w,3),l,i,m,y&&!c);return a},Mg=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,g=e.setup,p=g.maxScale,v=g.minScale;return r?o<p||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Dg=function(e,s){var r=e.setup.pinch,o=r.disabled,g=r.excluded,p=e.isInitialized,v=s.target,n=p&&!o&&v;if(!n)return!1;var i=fi(v,g);return!i},Pg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,g=r&&!s&&o;return!!g},Lg=function(e,s,r){var o=r.getBoundingClientRect(),g=e.touches,p=Tt(g[0].clientX-o.left,5),v=Tt(g[0].clientY-o.top,5),n=Tt(g[1].clientX-o.left,5),i=Tt(g[1].clientY-o.top,5);return{x:(p+n)/2/s,y:(v+i)/2/s}},Gl=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},Ig=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,g=e.setup,p=g.maxScale,v=g.minScale,n=g.zoomAnimation,i=g.disablePadding,l=n.size,d=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,m=c*r;return _r(Tt(m,2),v,p,l,!d&&!i)},Og=160,Bg=100,Fg=function(e,s){var r=e.props,o=r.onWheelStart,g=r.onZoomStart;e.wheelStopEventTimer||(It(e),Qe(qe(e),s,o),Qe(qe(e),s,g))},zg=function(e,s){var r=e.props,o=r.onWheel,g=r.onZoom,p=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,l=v.limitToBounds,d=v.centerZoomedOut,c=v.zoomAnimation,m=v.wheel,x=v.disablePadding,w=v.smooth,y=c.size,a=c.disabled,h=m.step,u=m.smoothStep;if(!p)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Ag(s,null),b=w?u*Math.abs(s.deltaY):h,C=Tg(e,f,b,!s.ctrlKey);if(i!==C){var k=gs(e,C),E=Vl(s,p,i),_=a||y===0||d||x,j=l&&_,A=hi(e,E.x,E.y,C,k,j),P=A.x,T=A.y;e.previousWheelEvent=s,e.setTransformState(C,P,T),Qe(qe(e),s,o),Qe(qe(e),s,g)}},Wg=function(e,s){var r=e.props,o=r.onWheelStop,g=r.onZoomStop;rn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&($l(e,s.x,s.y),e.wheelAnimationTimer=null)},Bg);var p=Mg(e,s);p&&(rn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(qe(e),s,o),Qe(qe(e),s,g))},Og))},Ql=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var g=s/2,p=r/2;return{x:g,y:p}},Hg=function(e,s){var r=Gl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Ql(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,It(e)},$g=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,g=e.wrapperComponent,p=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,l=v.zoomAnimation,d=v.alignmentAnimation,c=l.disabled,m=l.size;if(!(o===null||!r)){var x=Lg(s,p,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var w=Gl(s),y=Ig(e,w),a=Ql(s),h=a.x-(e.pinchLastCenterX||0),u=a.y-(e.pinchLastCenterY||0);if(!(y===p&&h===0&&u===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=gs(e,y),b=c||m===0||i,C=n&&b,k=hi(e,x.x,x.y,y,f,C),E=k.x,_=k.y;e.pinchMidpoint=x,e.lastDistance=w;var j=d.sizeX,A=d.sizeY,P=os(e,j),T=os(e,A),D=E+h,W=_+u,I=xr(D,W,f,n,P,T,g),B=I.x,F=I.y;e.setTransformState(y,B,F)}}}},Ug=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,$l(e,s?.x,s?.y)},Zl=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;rn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(qe(e),s,r)},o)},qg=function(e,s){var r=e.props,o=r.onZoomStart,g=r.onZoom,p=e.setup.doubleClick,v=p.animationTime,n=p.animationType;Qe(qe(e),s,o),Xl(e,v,n,function(){return Qe(qe(e),s,g)}),Zl(e,s)};function Kg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Xg(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,g=e.transformState,p=e.contentComponent,v=g.scale,n=e.props,i=n.onZoomStart,l=n.onZoom,d=r.doubleClick,c=d.disabled,m=d.mode,x=d.step,w=d.animationTime,y=d.animationType;if(!c&&!o){if(m==="reset")return qg(e,s);if(!p)return console.error("No ContentComponent found");var a=Kg(m,e.transformState.scale),h=ql(e,a,x);if(v!==h){Qe(qe(e),s,i);var u=Vl(s,p,v),f=Hn(e,h,u.x,u.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(qe(e),s,l),as(e,f,w,y),Zl(e,s)}}}var Yg=function(e,s){var r=e.isInitialized,o=e.setup,g=e.wrapperComponent,p=o.doubleClick,v=p.disabled,n=p.excluded,i=s.target,l=g?.contains(i),d=r&&i&&l&&!v;if(!d)return!1;var c=fi(i,n);return!c},Vg=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,gs(r,r.transformState.scale),r.setup=Ko(o)},this.initializeWindowEvents=function(){var o,g,p=Ii(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(g=r.wrapperComponent)===null||g===void 0||g.addEventListener("wheel",r.onWheelPanning,p),n?.addEventListener("mousedown",r.onPanningStart,p),n?.addEventListener("mousemove",r.onPanning,p),n?.addEventListener("mouseup",r.onPanningStop,p),v?.addEventListener("mouseleave",r.clearPanning,p),n?.addEventListener("keyup",r.setKeyUnPressed,p),n?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,g,p=Ii(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,p),n?.removeEventListener("mousemove",r.onPanning,p),n?.removeEventListener("mouseup",r.onPanningStop,p),v?.removeEventListener("mouseleave",r.clearPanning,p),n?.removeEventListener("keyup",r.setKeyUnPressed,p),n?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),It(r),(g=r.observer)===null||g===void 0||g.disconnect()},this.handleInitializeWrapperEvents=function(o){var g=Ii();o.addEventListener("wheel",r.onWheelZoom,g),o.addEventListener("dblclick",r.onDoubleClick,g),o.addEventListener("touchstart",r.onTouchPanningStart,g),o.addEventListener("touchmove",r.onTouchPanning,g),o.addEventListener("touchend",r.onTouchPanningStop,g)},this.handleInitialize=function(o,g){var p=!1,v=r.setup.centerOnInit,n=function(i,l){for(var d=0,c=i;d<c.length;d++){var m=c[d];if(m.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(qe(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,g))if(v&&!p){var l=g.offsetWidth,d=g.offsetHeight;(l>0||d>0)&&(p=!0,r.setCenter())}else It(r),gs(r,r.transformState.scale),Wn(r,0)}),r.observer.observe(o),r.observer.observe(g)},this.onWheelZoom=function(o){var g=r.setup.disabled;if(!g){var p=Ng(r,o);if(p){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(Fg(r,o),zg(r,o),Wg(r,o))}}},this.onWheelPanning=function(o){var g=r.setup,p=g.disabled,v=g.wheel,n=g.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,l=i.positionX,d=i.positionY,c=l-o.deltaX,m=d-o.deltaY,x=n.lockAxisX?l:c,w=n.lockAxisY?d:m,y=r.setup.alignmentAnimation,a=y.sizeX,h=y.sizeY,u=os(r,a),f=os(r,h);x===l&&w===d||Hl(r,x,w,u,f)}},this.onPanningStart=function(o){var g=r.setup.disabled,p=r.props.onPanningStart;if(!g){var v=zo(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),It(r),$o(r,o),Qe(qe(r),o,p)))}}},this.onPanning=function(o){var g=r.setup.disabled,p=r.props.onPanning;if(!g){var v=Wo(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),Uo(r,o.clientX,o.clientY),Qe(qe(r),o,p))}}},this.onPanningStop=function(o){var g=r.props.onPanningStop;r.isPanning&&(vg(r),Qe(qe(r),o,g))},this.onPinchStart=function(o){var g=r.setup.disabled,p=r.props,v=p.onPinchingStart,n=p.onZoomStart;if(!g){var i=Dg(r,o);i&&(Hg(r,o),It(r),Qe(qe(r),o,v),Qe(qe(r),o,n))}},this.onPinch=function(o){var g=r.setup.disabled,p=r.props,v=p.onPinching,n=p.onZoom;if(!g){var i=Pg(r);i&&(o.preventDefault(),o.stopPropagation(),$g(r,o),Qe(qe(r),o,v),Qe(qe(r),o,n))}},this.onPinchStop=function(o){var g=r.props,p=g.onPinchingStop,v=g.onZoomStop;r.pinchStartScale&&(Ug(r),Qe(qe(r),o,p),Qe(qe(r),o,v))},this.onTouchPanningStart=function(o){var g=r.setup.disabled,p=r.props.onPanningStart;if(!g){var v=zo(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,It(r);var i=o.touches,l=i.length===1,d=i.length===2;l&&(It(r),$o(r,o),Qe(qe(r),o,p)),d&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var g=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(g)return;var v=Wo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];Uo(r,n.clientX,n.clientY),Qe(qe(r),o,p)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var g=r.setup.disabled;if(!g){var p=Yg(r,o);p&&Xg(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(g){return r.pressedKeys[g]}):!0},this.setTransformState=function(o,g,p){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(g)&&!Number.isNaN(p)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=g,r.transformState.positionY=p,r.applyTransformation();var n=qe(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Qe(n,{scale:o,positionX:g,positionY:p},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=Yl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,g,p){return r.props.customTransform?r.props.customTransform(o,g,p):Eg(o,g,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,g=o.scale,p=o.positionX,v=o.positionY,n=r.handleTransformStyles(p,v,g);r.contentComponent.style.transform=n}},this.getContext=function(){return qe(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,g){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=g,gs(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,g),r.initializeWindowEvents(),r.isInitialized=!0;var p=qe(r);Qe(p,void 0,r.props.onInit)},this.props=s,this.setup=Ko(this.props),this.transformState=Ul(this.props)}return e})(),mi=ae.createContext(null),Gg=function(e,s){return typeof e=="function"?e(s):e},Qg=ae.forwardRef(function(e,s){var r=S.useRef(new Vg(e)).current,o=Gg(e.children,Zr(r));return S.useImperativeHandle(s,function(){return Zr(r)},[r]),S.useEffect(function(){r.update(e)},[r,e]),ae.createElement(mi.Provider,{value:r},o)});ae.forwardRef(function(e,s){var r=S.useRef(null),o=S.useContext(mi);return S.useEffect(function(){return o.onChange(function(g){if(r.current){var p=0,v=0;r.current.style.transform=o.handleTransformStyles(p,v,1/g.instance.transformState.scale)}})},[o]),ae.createElement("div",is({},e,{ref:jg([r,s])}))});function Zg(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",r==="top"&&o.firstChild?o.insertBefore(g,o.firstChild):o.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}}var Jg=`.transform-component-module_wrapper__SPB86 {
|
|
40
41
|
position: relative;
|
|
41
42
|
width: -moz-fit-content;
|
|
42
43
|
width: fit-content;
|
|
@@ -67,23 +68,23 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
67
68
|
.transform-component-module_content__FBWxo img {
|
|
68
69
|
pointer-events: none;
|
|
69
70
|
}
|
|
70
|
-
`,Xo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Xg(Yg);var Vg=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,g=e.contentClass,p=g===void 0?"":g,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,d=e.contentProps,c=d===void 0?{}:d,m=S.useContext(fi),x=m.init,w=m.cleanupWindowEvents,_=S.useRef(null),a=S.useRef(null);return S.useEffect(function(){var h=_.current,u=a.current;return h!==null&&u!==null&&x&&x?.(h,u),function(){w?.()}},[]),le.createElement("div",rs({},l,{ref:_,className:"".concat(en.wrapperClass," ").concat(Xo.wrapper," ").concat(o),style:v}),le.createElement("div",rs({},c,{ref:a,className:"".concat(en.contentClass," ").concat(Xo.content," ").concat(p),style:n}),s))},Gl=function(){var e=S.useContext(fi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Gg=function(){var e=Gl();return Qr(e)};function Qg(e){var s=Gl(),r=S.useState(e(tn(s))),o=r[0],g=r[1];return S.useEffect(function(){var p=!0,v=s.onChange(function(n){p&&g(e(tn(n.instance)))});return function(){v(),p=!1}},[e,s]),o}function Zg(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Jg(e,s){return Ot({queryKey:ae.files.tree(e||"",s),queryFn:()=>Se.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function ev(e,s){return Ot({queryKey:ae.files.content(e||"",s||""),queryFn:()=>Se.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function tv(e){const s=ht();return S.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function sv(){const e=ht();return kt({mutationFn:s=>Se.post("/files/write",s),onSuccess:(s,r)=>{const o=ae.files.content(r.workingDir,r.path),g=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:g?.language||Zg(r.path)})}})}function rv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function iv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const nv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function ov(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&nv.has(s)?ka:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?$r:s==="json"?zd:s==="md"||s==="mdx"||s==="txt"?Ca:Sd}const Yo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:g,label:p})=>t.jsxs("button",{type:"button",onClick:r,className:se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:g}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:p})]}),Ql=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:g,onFileSelect:p,selectedFilePath:v})=>{const{t:n}=de(),{data:i,isLoading:l,isError:d}=Jg(e,s),c=S.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):d?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(m=>{if(m.type==="directory"){const h=rv(s,m.name),u=o.has(h);return t.jsxs("div",{children:[t.jsx(Yo,{depth:r,onClick:()=>g(h),rightIcon:u?t.jsx(Ct,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:u?t.jsx(ri,{size:14,className:"text-amber-500"}):t.jsx(za,{size:14,className:"text-amber-500"}),label:m.name}),u&&t.jsx(Ql,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:g,onFileSelect:p,selectedFilePath:v})]},h)}const x=iv(s,m.name),w=ov(m),_=v===x,a=w===ka;return t.jsx(Yo,{depth:r,active:_,onClick:()=>p(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:w?t.jsx(w,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:m.name},x)})})},av=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:g})=>{const{t:p}=de(),[v,n]=S.useState(()=>new Set),i=tv(e),l=S.useCallback(d=>{n(c=>{const m=new Set(c);return m.has(d)?m.delete(d):m.add(d),m})},[]);return t.jsxs("div",{className:se("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:t.jsx(ur,{size:13})}),g&&t.jsx("button",{type:"button",onClick:g,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Collapse file tree"),children:t.jsx(Gd,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Ql,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},lv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function cv(e){const s=e.split(".").pop()?.toLowerCase();return s?lv.has(s):!1}function dv(e,s){const r=cr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const uv=({filePath:e})=>{const{t:s}=de(),{zoomIn:r,zoomOut:o,centerView:g}=Gg(),p=Qg(n=>n.state.scale),v=Math.round(p*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(uu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>g(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(cu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>g(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Yd,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},hv=({workingDir:e,filePath:s})=>{const{t:r}=de(),[o,g]=S.useState(!1),p=dv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Kg,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(uv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Vg,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:p,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>g(!0)})})})]})})};function fv(e){const s=e.split("/");return s[s.length-1]||e}function mv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const pv=({active:e,name:s,isDirty:r,onClick:o,onClose:g})=>{const{t:p}=de();return t.jsxs("button",{type:"button",onClick:o,className:se("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:se("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":p("Close tab"),title:p("Close"),children:t.jsx(Xt,{size:12})})]})},gv=le.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},g){const{t:p}=de(),[v,n]=S.useState([]),[i,l]=S.useState(null),[d,c]=S.useState(!1),[m,x]=S.useState(!1),[w,_]=S.useState(0),[a,h]=S.useState(null),u=S.useRef(null),f=sv();S.useEffect(()=>{let B=!1;return Jc(async()=>{const{preloadMonaco:H}=await import("./monaco-D3FVQqPj.js").then(q=>q.m);return{preloadMonaco:H}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:H})=>H()).then(()=>{B||c(!0)}).catch(()=>{B||x(!0)}),()=>{B=!0}},[]);const[y,C]=S.useState(280),[k,E]=S.useState(!1),[b,j]=S.useState(!1),A=S.useRef(280),L=S.useCallback(()=>{E(B=>(B?C(A.current):A.current=y,!B))},[y]),T=S.useCallback(B=>{B.preventDefault(),j(!0);const H=B.clientX,q=y,N=X=>{const K=X.clientX-H,ne=Math.min(480,Math.max(160,q+K));C(ne)},z=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",z)},[y]);S.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=S.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:$,error:W}=ev(s,D?.isImage?null:i);S.useEffect(()=>{!i||!F||n(B=>B.map(H=>H.path!==i||H.isDirty||H.loaded?H:{...H,language:F.language||H.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[i,F]);const R=S.useCallback((B,H,q)=>{n(N=>{if(N.find(K=>K.path===B))return N;const X=cv(B);return[...N,{path:B,name:fv(B),language:mv(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(B),h(H?{path:B,line:H,column:q}:null)},[]);le.useImperativeHandle(g,()=>({openFile:R}),[R]);const M=S.useCallback(B=>{n(H=>{const q=H.filter(N=>N.path!==B);return l(N=>N!==B?N:q.length?q[q.length-1].path:null),q})},[]),P=S.useCallback(B=>{n(H=>H.map(q=>{if(q.path!==i)return q;const N=B!==q.savedContent;return{...q,content:B,isDirty:N}}))},[i]),O=S.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(B=>B.map(H=>H.path===D.path?{...H,savedContent:H.content,isDirty:!1,loaded:!0}:H)))},[D,o,f,s]),U=S.useRef(()=>{});S.useEffect(()=>{U.current=()=>{O().catch(()=>{})}},[O]),S.useEffect(()=>{const B=H=>{o||(H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="s"&&(H.preventDefault(),U.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const Y=S.useCallback((B,H)=>{u.current=B,_(q=>q+1),B.addCommand(H.KeyMod.CtrlCmd|H.KeyCode.KeyS,()=>{U.current()})},[]);return S.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const B=u.current,H=B?.getModel();if(!B||!H)return;const q=Math.min(a.line,H.getLineCount()),N=Math.min(a.column??1,H.getLineMaxColumn(q)),z={lineNumber:q,column:N};B.setPosition(z),B.revealPositionInCenter(z),B.focus(),h(null)},[i,D?.loaded,w,a]),t.jsxs("div",{className:se("flex h-full overflow-hidden bg-white",r),style:b?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:y,transition:b?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:L,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:p("Expand file tree"),children:t.jsx(Zd,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(av,{workingDir:s,onFileSelect:R,selectedFilePath:D?.path||null,onCollapse:L},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:se("w-1 shrink-0 cursor-col-resize transition-colors",b?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:p("No open files")}):v.map(B=>t.jsx(pv,{active:B.path===i,name:B.name,isDirty:B.isDirty,onClick:()=>l(B.path),onClose:H=>{H.stopPropagation(),M(B.path)}},B.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:p("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),p("Saving")]}),D?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:p("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?D?D.isImage?t.jsx(hv,{workingDir:s,filePath:D.path}):m?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:p("Failed to load editor.")}):d?t.jsxs(t.Fragment,{children:[t.jsx(Op,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>P(B??""),onMount:Y,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),p("Loading file...")]})}),$&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[p("Failed to load file"),W instanceof Error?`: ${W.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Xe,{size:14,className:"animate-spin mr-2"}),p("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:p("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:p("No workspace selected.")})})]})]})});function mi(e,s={}){const r=xs(g=>g.visibleContext),o=hl(e,r);return Ot({queryKey:ae.git.changes(e||""),queryFn:()=>Se.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Zl(e,s,r){const o=xs(p=>p.visibleContext),g=hl(e,o);return Ot({queryKey:ae.git.diff(e||"",s||"",r),queryFn:()=>Se.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:g,refetchIntervalInBackground:!1,refetchOnWindowFocus:g?"always":!1,refetchOnReconnect:g?"always":!1})}function zn(e,s){return Ot({queryKey:ae.git.commitFiles(e||"",s||""),queryFn:()=>Se.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Wn(e,s,r){return Ot({queryKey:ae.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Se.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function Jl({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:g,isPending:p,error:v,onConfirm:n}){const{t:i}=de(),[l,d]=S.useState(""),[c,m]=S.useState(!1);S.useEffect(()=>{e&&(m(!1),d(g??""))},[e]),S.useEffect(()=>{c||!e||d(g??"")},[g,c,e]);const x=()=>{p||s()};return t.jsx(gs,{isOpen:e,onClose:x,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x,disabled:p,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:()=>n(l.trim()||void 0),disabled:p,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:p?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Hr,{size:14}),i("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(Wa,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:i("提交消息")}),t.jsx("textarea",{value:l,onChange:w=>{m(!0),d(w.target.value)},placeholder:i("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:i("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function Cs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function ec(e){if(!(e instanceof ln)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==rr.REBASE&&s.conflictOp!==rr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Cs(s,"sourceBranch"),targetBranch:Cs(s,"targetBranch"),sourceWorktreePath:Cs(s,"sourceWorktreePath"),targetWorktreePath:Cs(s,"targetWorktreePath"),sourceWorkspaceId:Cs(s,"sourceWorkspaceId"),targetWorkspaceId:Cs(s,"targetWorkspaceId")}}function Vo(e,s,r,o){const g=ec(e);if(g){r(g);return}o(e instanceof Error?e.message:s)}function tc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:g,onRefreshCommitMessage:p,onConflict:v,onResolveConflicts:n}){const{t:i}=de(),{data:l,isLoading:d}=Tn(e),c=pl(),m=ml(),x=Mn(),[w,_]=S.useState(!1),[a,h]=S.useState(null);if(S.useEffect(()=>{w&&p?.()},[w,p]),d||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const u=l.conflictedFiles.length>0,f=l.operation!=="idle",y=l.hasUncommittedChanges||l.untrackedCount>0,C=l.uncommittedCount+l.untrackedCount,k=!u&&!f&&!y,E=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!y&&!u,b=()=>{h(null),c.mutate(e,{onError:T=>{Vo(T,i("更新失败,请稍后重试"),D=>v(D),h)}})},j=()=>{h(null),_(!0)},A=T=>{h(null),m.mutate({id:e,commitMessage:T},{onSuccess:()=>_(!1),onError:D=>{Vo(D,i("提交失败,请稍后重试"),F=>{_(!1),v(F)},h)}})},L=()=>{m.isPending||(_(!1),h(null))};return E?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(ed,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),y&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx($d,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:C})})]}),u&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(dr,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),f&&!u&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Xe,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(td,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!u&&!f&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:b,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(ur,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:g??l.ahead})}),l.behind===0&&!y?t.jsxs("button",{onClick:j,disabled:m.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Hr,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(y?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Hr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(Jl,{isOpen:w,onClose:L,branchName:s,targetBranch:r,commitMessage:o,isPending:m.isPending,error:a,onConfirm:A})]})}const Ii=50,Oi=400,Go={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},Qo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function sc(e){const s=e.split("/");return s[s.length-1]||e}function vv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function xv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?vt("{count}s ago",{count:r}):r<3600?vt("{count}m ago",{count:Math.floor(r/60)}):r<86400?vt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?vt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Or(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const rn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:se("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),_v=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},rc=({diff:e})=>{const{t:s}=de(),[r,o]=S.useState(!1),g=S.useMemo(()=>e.split(`
|
|
71
|
-
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const p=!r&&g.length>Oi,v=p?g.slice(0,Oi):g;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(_v,{line:n,lineNum:i+1},i)),p&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:g.length-Oi})})]})},bv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:g}=de(),{data:p,isLoading:v,isError:n}=Zl(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Xe,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:g("差异加载失败")}):t.jsx(rc,{diff:p?.diff||""})},yv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:g}=de(),{data:p,isLoading:v,isError:n}=Wn(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Xe,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:g("差异加载失败")}):t.jsx(rc,{diff:p?.diff||""})},Bi=({entry:e,source:s,workingDir:r,flash:o,registerNode:g})=>{const[p,v]=S.useState(!1),[n,i]=S.useState(!1),l=S.useRef(null),d=Or(s,e.path);S.useEffect(()=>(g(d,l.current),()=>g(d,null)),[d,g]),S.useEffect(()=>{const x=l.current;if(!x||n)return;const w=new IntersectionObserver(_=>{_.some(a=>a.isIntersecting)&&(i(!0),w.disconnect())},{rootMargin:"300px 0px"});return w.observe(x),()=>w.disconnect()},[n]);const c=Go[e.status]||Go.M,m=vv(e.path);return t.jsxs("div",{ref:l,"data-card-key":d,className:se("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[p?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ct,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:sc(e.path)}),m&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:m}),t.jsx("span",{className:"ml-auto"}),t.jsx(rn,{additions:e.additions,deletions:e.deletions})]}),!p&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(bv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(yv,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function Sv(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let g=s;for(let p=0;p<o.length-1;p++){const v=o[p];g.dirs.has(v)||g.dirs.set(v,{name:v,path:g.path?`${g.path}/${v}`:v,dirs:new Map,files:[]}),g=g.dirs.get(v)}g.files.push(r)}return ic(s)}function ic(e){const s=new Map;for(const r of e.dirs.values()){let o=ic(r);for(;o.dirs.size===1&&o.files.length===0;){const g=[...o.dirs.values()][0];o={...g,name:`${o.name}/${g.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const wv=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[g,p]=S.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[g?t.jsx(ri,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(za,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),g&&t.jsx(nc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},nc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((g,p)=>g.name.localeCompare(p.name)).map(g=>t.jsx(wv,{dir:g,depth:s,activeKey:r,onSelect:o},g.path)),e.files.slice().sort((g,p)=>g.path.localeCompare(p.path)).map(g=>{const p=r===g.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(g),className:se("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",p?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:g.path,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full shrink-0",Qo[g.status]||Qo.M)}),t.jsx("span",{className:se("text-xs truncate",p?"text-foreground font-medium":"text-foreground/90"),children:sc(g.path)})]},g.cardKey)})]}),Cv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=de(),{data:g,isLoading:p,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=bn({queryKey:ae.git.log(e),queryFn:({pageParam:d=0})=>Se.get("/git/log",{params:{workingDir:e,limit:String(Ii),skip:String(d)}}),initialPageParam:0,getNextPageParam:(d,c)=>d.commits.length<Ii?void 0:c.length*Ii}),l=g?.pages.flatMap(d=>d.commits)||[];return p?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Xe,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(d=>{const c=s===d.hash;return t.jsxs("button",{type:"button",onClick:()=>r(d),className:se("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:d.message,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:se("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:d.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:d.shortHash})," · ",d.author," · ",xv(d.timestamp)]})]})]},d.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},kv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:g,canRunGitOperations:p,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=de(),[d,c]=S.useState({kind:"overview"}),[m,x]=S.useState(""),[w,_]=S.useState(null),[a,h]=S.useState(null),{data:u,isLoading:f,isError:y}=mi(e),C=d.kind==="commit"?d.commit.hash:null,{data:k,isLoading:E}=zn(e,C),b=S.useRef(new Map),j=S.useRef(null),A=S.useRef(null),L=S.useCallback((B,H)=>{H?b.current.set(B,H):b.current.delete(B)},[]),{uncommitted:T,committed:D,commitFiles:F}=S.useMemo(()=>{const B=N=>!m.trim()||N.path.toLowerCase().includes(m.trim().toLowerCase());if(d.kind==="commit"){const N={kind:"commit",hash:d.commit.hash},z=(k?.files||[]).filter(B).map(X=>({...X,cardKey:Or(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:z}}const H=(u?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:Or({kind:"working",diffType:"uncommitted"},N.path)})),q=(u?.committed||[]).filter(B).map(N=>({...N,cardKey:Or({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:H,committed:q,commitFiles:[]}},[d,u,k,m]),I=d.kind==="commit"?F:[...T,...D],$=S.useMemo(()=>Sv(I),[I]),W=S.useMemo(()=>{let B=0,H=0;for(const q of I)B+=q.additions??0,H+=q.deletions??0;return{additions:B,deletions:H,files:I.length}},[I]),R=S.useCallback(()=>{const B=j.current;if(!B)return;const H=B.getBoundingClientRect().top;let q=null,N=Number.NEGATIVE_INFINITY;for(const[z,X]of b.current){const K=X.getBoundingClientRect().top-H;K<=48&&K>N&&(N=K,q=z)}if(!q){let z=null,X=Number.POSITIVE_INFINITY;for(const[K,ne]of b.current){const te=ne.getBoundingClientRect().top-H;te<X&&(X=te,z=K)}q=z}_(q)},[]);S.useEffect(()=>{const B=j.current;if(!B)return;let H=0;const q=()=>{cancelAnimationFrame(H),H=requestAnimationFrame(R)};return B.addEventListener("scroll",q,{passive:!0}),()=>{B.removeEventListener("scroll",q),cancelAnimationFrame(H)}},[R]);const M=S.useCallback(B=>{const H=b.current.get(B.cardKey);H&&(H.scrollIntoView({behavior:"smooth",block:"start"}),_(B.cardKey),h(B.cardKey),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>h(null),1200))},[]),P=S.useCallback(B=>{c(H=>H.kind==="commit"&&H.commit.hash===B.hash?{kind:"overview"}:{kind:"commit",commit:B}),x(""),_(null),j.current?.scrollTo({top:0})},[]),O=S.useCallback(()=>{c({kind:"overview"}),x(""),_(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const U=p&&s&&r&&o,Y=d.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[U&&n&&i&&t.jsx(tc,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:g,committedFileCount:u?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:d.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:W.files})}),t.jsx(rn,{additions:W.additions,deletions:W.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Ps,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Ps,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:d.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:d.commit.message}),t.jsx(rn,{className:"ml-auto",additions:W.additions,deletions:W.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:Y?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(B=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},B))}):y&&d.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx($r,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:m.trim()?l("没有匹配筛选条件的文件"):d.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):d.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:F.map(B=>t.jsx(Bi,{entry:B,source:{kind:"commit",hash:d.commit.hash},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(B=>t.jsx(Bi,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))})]}),D.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map(B=>t.jsx(Bi,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(mn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:m,onChange:B=>x(B.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:m.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(nc,{node:$,depth:0,activeKey:w,onSelect:M})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Ls,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Cv,{workingDir:e,selectedHash:C,onSelectCommit:P})})]})]})]})]})},Fi=50,Zo={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Ev(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?vt("{count}s ago",{count:r}):r<3600?vt("{count}m ago",{count:Math.floor(r/60)}):r<86400?vt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?vt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function jv(e){const s=e.split("/");return s[s.length-1]||e}function Nv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const Rv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},Av=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=de(),{data:g,isLoading:p,isError:v}=Wn(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Xe,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const i=n.split(`
|
|
72
|
-
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,d)=>t.jsx(Rv,{line:l,lineNum:d+1},d))})},Tv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:g}=de(),{data:p,isLoading:v}=zn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Xe,{size:12,className:"animate-spin"}),t.jsx("span",{children:g("Loading...")})]});const n=p?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:g("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const l=Zo[i.status]||Zo.M,d=Nv(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:se("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:jv(i.path)}),d&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:d})]},i.path)})})},Mv=({workingDir:e})=>{const{t:s}=de(),r=xs(E=>E.visibleContext),o=Qh(e,r),{data:g,isLoading:p,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=bn({queryKey:ae.git.log(e||""),queryFn:({pageParam:E=0})=>Se.get("/git/log",{params:{workingDir:e||"",limit:String(Fi),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,b)=>E.commits.length<Fi?void 0:b.length*Fi,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),d=g?.pages.flatMap(E=>E.commits)||[],[c,m]=S.useState(null),[x,w]=S.useState(null),[_,a]=S.useState(280),[h,u]=S.useState(!1),f=S.useCallback(E=>{E.preventDefault(),u(!0);const b=E.clientX,j=_,A=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-b)));a(D)},L=()=>{u(!1),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",L)},[_]),y=E=>{c===E?(m(null),w(null)):(m(E),w(null))},C=S.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Xe,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(d.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Ls,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=d.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:_},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ls,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:d.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[d.map(E=>{const b=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>y(E.hash),className:se("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",b?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:se("w-2 h-2 rounded-full shrink-0 transition-colors",b?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Mt,{size:12,className:se("shrink-0 text-muted-foreground/70 transition-transform",b&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:Ev(E.timestamp)})]})]})]}),b&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(Tv,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:w})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:l,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:l?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:se("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx($r,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(Av,{workingDir:e,hash:c,filePath:x})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx($r,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Jo=cr();function Dv(e){if(!Jo)return e;try{const s=new URL(Jo);return new URL(e,s.origin).toString()}catch{return e}}function oc(e){return{...e,viewUrl:e.viewUrl?Dv(e.viewUrl):null}}function Pv(e){return Ot({queryKey:ae.previews.status(e??""),queryFn:async()=>{const s=await Se.get(`/previews/${e}/status`);return oc(s)},enabled:!!e,refetchOnWindowFocus:!1})}function Lv(e){const s=ht();return kt({mutationFn:async r=>{const o=await Se.put(`/previews/${e}/config`,{target:r});return oc(o)},onSuccess:r=>{e&&(s.setQueryData(ae.previews.status(e),r),s.invalidateQueries({queryKey:ae.workspaces.all}))}})}function Iv(){return window.location.protocol==="https:"?"remote":"local"}function Ov(e,s){const[r,o]=S.useState(null),[g,p]=S.useState(!1),[v,n]=S.useState(null),[i,l]=S.useState(0);return S.useEffect(()=>{if(!e||!s?.ready||!s.target){o(null),p(!1),n(null);return}let d=!1,c=null,m=null;o(null);const x=_=>{Se.delete(`/previews/${e}/sessions/${_}`).catch(()=>{})};return(async()=>{p(!0),n(null);try{const _={mode:Iv(),localHostname:window.location.hostname},a=await Se.post(`/previews/${e}/sessions`,_);if(d){x(a.id);return}c=a.id,o(a),m=window.setInterval(async()=>{if(c)try{const h=await Se.post(`/previews/${e}/sessions/${c}/heartbeat`);d||(o(h),n(null))}catch(h){!d&&h instanceof ln&&h.status===404?l(u=>u+1):d||n(h instanceof Error?h:new Error("Preview session heartbeat failed"))}},3e4)}catch(_){d||(o(null),n(_ instanceof Error?_:new Error("Failed to open preview session")))}finally{d||p(!1)}})(),()=>{d=!0,m!==null&&window.clearInterval(m),c&&x(c)}},[i,s?.ready,s?.target,e]),{session:r,isOpening:g,error:v,retry:()=>l(d=>d+1)}}const Bv="agent-tower-preview",Fv="agent-tower-preview-host";function zv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Wv(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Hv(e){return t.jsx($v,{...e},e.workspaceId??"no-workspace")}function $v({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:g}=de(),{data:p,isLoading:v,refetch:n,isFetching:i}=Pv(e),l=Lv(e),{session:d,isOpening:c,error:m,retry:x}=Ov(e,p),w=S.useRef(null),_=S.useRef(null),a=S.useRef(null),h=S.useRef(null),u=S.useRef(null),f=S.useRef(null),[y,C]=S.useState(0),[k,E]=S.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),b=Wv(d?.viewUrl),j=p&&k.target!==p.target?{target:p.target,address:p.target??"",iframeSrc:null,isFrameLoading:!1}:p&&!p.ready&&k.iframeSrc?{...k,iframeSrc:null,isFrameLoading:!1}:k,A=S.useCallback(W=>{E(R=>({...p&&R.target!==p.target?{target:p.target,address:p.target??"",iframeSrc:null,isFrameLoading:!1}:R,...W}))},[p]);S.useEffect(()=>{if(!d||d.target!==p?.target)return;const W=u.current!==b;u.current=b,E(R=>{const M=r&&f.current!==r.id?Rr(r.url,d.target,d.viewUrl):null;if(!W&&R.iframeSrc&&R.target===d.target&&M?.kind!=="proxy")return R;let P=R.iframeSrc;if(M?.kind==="proxy")P=M.url;else if(!P||R.target!==d.target||W){const U=a.current;if(U)P=fd(d.viewUrl,U);else{const Y=Rr(R.address||d.target,d.target,d.viewUrl);P=Y?.kind==="proxy"?Y.url:d.viewUrl}}a.current=null;const O=h.current;return O&&!O.closed&&P&&O.location.replace(P),h.current=null,{target:d.target,address:M?.kind==="proxy"?r?.url??R.address:R.address||d.target,iframeSrc:P,isFrameLoading:!!P}})},[r,d,b,p?.target]),S.useEffect(()=>()=>{h.current?.close()},[]);const L=S.useCallback(async(W,R=!1)=>{const M=Rr(W,p?.target??null,d?.viewUrl??null);if(!M||!e)return;if(M.kind==="proxy"){if(R){window.open(M.url,"_blank","noopener,noreferrer");return}E({target:p?.target??null,address:W,iframeSrc:M.url,isFrameLoading:!0});return}if(s)return;const P=R?window.open("about:blank","_blank"):null;P&&(P.opener=null);try{a.current=M.path,h.current=P;const O=await l.mutateAsync(M.target);E({target:O.target,address:W.trim(),iframeSrc:null,isFrameLoading:!!O.ready}),C(U=>U+1),ut.success(g("Preview target saved")),O.ready||(h.current?.close(),h.current=null)}catch(O){h.current?.close(),h.current=null,a.current=null;const U=O instanceof Error?O.message:g("Failed to save preview target");ut.error(U)}},[d?.viewUrl,s,p?.target,g,l,e]);S.useEffect(()=>{if(!r||v||f.current===r.id)return;const W=window.setTimeout(()=>{f.current=r.id,o?.(r.id),L(r.url)},0);return()=>window.clearTimeout(W)},[v,L,r,o]),S.useEffect(()=>{const W=R=>{if(R.source!==w.current?.contentWindow)return;const M=R.data;if(!(!M||M.source!==Bv)){if(M.type==="location"&&typeof M.href=="string"){const P=md(p?.target??null,d?.viewUrl??null,M.href,window.location.href);P&&document.activeElement!==_.current&&A({target:p?.target??j.target,address:P,isFrameLoading:!1});return}M.type==="navigate-loopback"&&typeof M.href=="string"&&L(M.href,M.newTab===!0)}};return window.addEventListener("message",W),()=>window.removeEventListener("message",W)},[j.target,L,A,d?.viewUrl,p?.target]);const T=W=>{w.current?.contentWindow?.postMessage({source:Fv,action:W},"*")},D=W=>{W.preventDefault(),L(j.address)},F=async()=>{const W=await n();if(!W.data?.ready){A({target:W.data?.target??j.target,iframeSrc:null,isFrameLoading:!1});return}if(!d||!j.iframeSrc){x();return}A({isFrameLoading:!0}),T("reload")},I=()=>{if(!d?.viewUrl)return;const W=Rr(j.address||d.target,d.target,d.viewUrl),R=W?.kind==="proxy"?W.url:d.viewUrl;window.open(R,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:g("No active workspace.")});const $=v||i||l.isPending||c;return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>T("back"),disabled:!j.iframeSrc,title:g("Back"),"aria-label":g("Back"),children:t.jsx(Ps,{})}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>T("forward"),disabled:!j.iframeSrc,title:g("Forward"),"aria-label":g("Forward"),children:t.jsx(Wa,{})}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:j.isFrameLoading?()=>{T("stop"),A({isFrameLoading:!1})}:F,disabled:!j.isFrameLoading&&i,title:j.isFrameLoading?g("Stop loading"):g("Refresh preview"),"aria-label":j.isFrameLoading?g("Stop loading"):g("Refresh preview"),children:j.isFrameLoading?t.jsx(Xt,{}):i?t.jsx(Xe,{className:"animate-spin"}):t.jsx(ur,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:D,children:[t.jsx(Od,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:_,value:j.address,onChange:W=>A({address:W.target.value}),onKeyDown:W=>{W.key==="Enter"&&W.nativeEvent.isComposing&&W.preventDefault()},disabled:s||l.isPending,placeholder:zv(),"aria-label":g("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:I,disabled:!j.iframeSrc,title:g("Open preview in new tab"),"aria-label":g("Open preview in new tab"),children:t.jsx(an,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:$?g("Checking preview target..."):m?m.message:p?.ready?`${g("Proxying")} ${p.target}`:p?.configured?`${g("Preview target is not reachable")}${p.error?`: ${p.error}`:""}`:g("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:g("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:j.iframeSrc?t.jsx("iframe",{ref:w,src:j.iframeSrc,title:g("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>A({isFrameLoading:!1})},y):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:p?.configured?p.ready&&c?g("Checking preview target..."):g("Start the preview server, then refresh."):g("Configure a local preview target to display it here.")})})]})}function Uv(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ea(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function qv(e){return e.length<=34?e:`...${e.slice(-31)}`}function ac({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:g,className:p,buttonClassName:v}){const{t:n}=de(),[i,l]=S.useState(!1),d=S.useRef(null),c=S.useMemo(()=>Ln(e,s),[e,s]),m=c.find(x=>x.workspace.id===r)??c[0];return S.useEffect(()=>{if(!i)return;const x=w=>{d.current&&!d.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:d,className:se("relative",p),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),disabled:g,className:se("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:n("Workspace"),children:[t.jsx(Ds,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(m.roleLabel)),children:n(m.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(m.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:qv(Is(m.workspace))}),t.jsx(Ct,{size:13,className:se("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(x=>{const w=x.workspace.id===m.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!1)},className:se("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",w&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:w?t.jsx(Yt,{size:13}):t.jsx(Da,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:n(x.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Uv(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Is(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const Kv=[{key:"review",label:"Changes",icon:t.jsx(Bs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(si,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Br,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ma,{size:14})}],Xv=[{key:"history",label:"History",icon:t.jsx(Ls,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(si,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Br,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ma,{size:14})}],Yv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:se("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),Vv=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:se("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),lc=le.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:g,projectId:p,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:d,teamStatus:c,gitProps:m,workspaces:x,selectedWorkspaceId:w,onSelectWorkspace:_,variant:a="tabs",expanded:h,onExpandedChange:u,minContentWidth:f=520,tabRef:y,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=de(),b=xs(G=>G.setVisibleContext),j=a==="rail",[A,L]=S.useState(!1),T=j?h??A:!0,D=S.useCallback(G=>{h===void 0&&L(G),u?.(G)},[h,u]),F=S.useMemo(()=>{const G=v?Xv:Kv,ge=n?G:G.filter(Ae=>Ae.key!=="review"&&Ae.key!=="history"),re=i?ge.filter(Ae=>Ae.key!=="terminal"):ge;return d?[{key:"team-status",label:"Team Status",icon:t.jsx(ps,{size:14})},...re]:re},[n,v,i,d]),[I,$]=S.useState(()=>C?"preview":n?v?"history":"review":"editor"),W=S.useRef(null),R=S.useRef(0),[M,P]=S.useState(),O=S.useCallback(G=>{$(G),j&&D(!0)},[j,D]);S.useImperativeHandle(y,()=>({setTab:G=>O(G),openFile:(G,ge,re)=>{O("editor"),requestAnimationFrame(()=>W.current?.openFile(G,ge,re))},openPreview:(G,ge)=>{R.current+=1,P({id:R.current,url:G,workspaceId:ge}),O("preview")}}),[O]);const U=C??M,Y=U?.workspaceId&&U.workspaceId!==o?void 0:U,B=S.useCallback(G=>{P(ge=>ge?.id===G?void 0:ge),k?.(G)},[k]),{data:H}=Cd(p??""),q=S.useMemo(()=>{if(!H?.quickCommands)return[];try{return JSON.parse(H.quickCommands)}catch{return[]}},[H?.quickCommands]),[N,z]=S.useState([]),X=S.useRef(void 0);S.useEffect(()=>{g&&g!==X.current&&(X.current=g,z(G=>G.includes(g)?G:[...G,g]))},[g]),S.useEffect(()=>{F.some(G=>G.key===I)||$(F[0]?.key??"editor")},[I,F]),S.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!g||!G){b(null);return}return b({workspaceId:o,workingDir:g,tab:G}),()=>{b(null)}},[I,T,j,b,g,o]);const K=!!_&&Ln(x,d).length>1,ne=F.find(G=>G.key===I)??F[0],te=ne?E(ne.label):"",fe=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,ce=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[K&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(ac,{workspaces:x,teamRun:d,selectedWorkspaceId:w,onSelectWorkspace:_,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&d&&c,I==="editor"&&t.jsx(gv,{ref:W,workingDir:g,readOnly:i}),N.map(G=>{const ge=I==="terminal"&&g===G;return t.jsx("div",{"aria-hidden":!ge,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:ge?"block":"none"},children:t.jsx(Nm,{cwd:G,isVisible:ge,quickCommands:q})},G)}),I==="preview"&&t.jsx(Hv,{workspaceId:o,readOnly:i,navigationRequest:Y,onNavigationRequestHandled:B}),I==="review"&&t.jsx(kv,{workingDir:g,workspaceId:o,branchName:m?.branchName,targetBranch:m?.targetBranch,commitMessage:m?.commitMessage,canRunGitOperations:m?.canRunGitOperations,onRefreshCommitMessage:m?.onRefreshCommitMessage,onConflict:m?.onConflict,onResolveConflicts:m?.onResolveConflicts}),I==="history"&&t.jsx(Mv,{workingDir:g})]})]});return j?t.jsxs("div",{className:se("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:F.map(G=>t.jsx(Vv,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[fe,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:ne?.icon}),t.jsx("span",{className:"truncate",children:te})]}),t.jsx("button",{type:"button",onClick:()=>D(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(eu,{size:15})})]}),ce]})]}):t.jsxs("div",{className:se("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&fe,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:F.map(G=>t.jsx(Yv,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),ce]})}),ta=1500,Gv=3e3;function Qv(e){const[s,r]=S.useState(null),o=S.useRef(0),g=S.useRef(null),p=S.useRef(null);return S.useEffect(()=>{if(!e)return;const v=()=>{p.current&&(clearTimeout(p.current),p.current=null)},n=Zt.connect(),i=d=>{r(d),p.current=setTimeout(()=>r(null),Gv)},l=d=>{if(d.taskId!==e)return;const c={status:d.status,currentCommand:d.currentCommand,currentIndex:d.currentIndex,totalCommands:d.totalCommands,error:d.error};if(d.status==="running"){v(),g.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const m=o.current>0?Date.now()-o.current:0,x=ta-m;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:d.totalCommands,currentIndex:d.totalCommands}),g.current=c,p.current=setTimeout(()=>i(c),ta)):x>0?(g.current=c,v(),p.current=setTimeout(()=>i(c),x)):i(c)};return n.on(ct.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(ct.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,g.current=null}},[e]),s}function Hn(){const e=ht();return kt({mutationFn:s=>Se.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.sessions.detail(r)}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function cc(){const e=ht();return kt({mutationFn:s=>Se.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.sessions.detail(r)})}})}function $n(){const e=ht();return kt({mutationFn:({id:s,message:r,providerId:o})=>Se.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function dc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:g,taskTitle:p,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:d}){const{t:c}=de(),[m,x]=S.useState(""),[w,_]=S.useState(""),[a,h]=S.useState(yt.WORKTREE),[u,f]=S.useState(null),[y,C]=S.useState("idle"),[k,E]=S.useState(null),b=ht(),j=fl(o),A=Hn(),L=kd(),{data:T,isLoading:D}=Os(),F=u?.isGitRepo??i,I=u?.worktreeReady??l,$=u?.reason??d,W=F!==!1&&I!==!1;S.useEffect(()=>{if(!e||!T)return;const N=T.find(z=>z.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),S.useEffect(()=>{if(e){const N=[p];v&&N.push(v),_(n?.trim()||N.join(`
|
|
71
|
+
`,Xo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Zg(Jg);var ev=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,g=e.contentClass,p=g===void 0?"":g,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,d=e.contentProps,c=d===void 0?{}:d,m=S.useContext(mi),x=m.init,w=m.cleanupWindowEvents,y=S.useRef(null),a=S.useRef(null);return S.useEffect(function(){var h=y.current,u=a.current;return h!==null&&u!==null&&x&&x?.(h,u),function(){w?.()}},[]),ae.createElement("div",is({},l,{ref:y,className:"".concat(tn.wrapperClass," ").concat(Xo.wrapper," ").concat(o),style:v}),ae.createElement("div",is({},c,{ref:a,className:"".concat(tn.contentClass," ").concat(Xo.content," ").concat(p),style:n}),s))},Jl=function(){var e=S.useContext(mi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},tv=function(){var e=Jl();return Zr(e)};function sv(e){var s=Jl(),r=S.useState(e(sn(s))),o=r[0],g=r[1];return S.useEffect(function(){var p=!0,v=s.onChange(function(n){p&&g(e(sn(n.instance)))});return function(){v(),p=!1}},[e,s]),o}function rv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function iv(e,s){return Bt({queryKey:de.files.tree(e||"",s),queryFn:()=>Ce.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function nv(e,s){return Bt({queryKey:de.files.content(e||"",s||""),queryFn:()=>Ce.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function ov(e){const s=bt();return S.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function av(){const e=bt();return Ft({mutationFn:s=>Ce.post("/files/write",s),onSuccess:(s,r)=>{const o=de.files.content(r.workingDir,r.path),g=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:g?.language||rv(r.path)})}})}function lv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function cv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const dv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function uv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&dv.has(s)?ka:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Ur:s==="json"?qd:s==="md"||s==="mdx"||s==="txt"?Ca:Cd}const Yo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:g,label:p})=>t.jsxs("button",{type:"button",onClick:r,className:se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:g}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:p})]}),ec=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:g,onFileSelect:p,selectedFilePath:v})=>{const{t:n}=ce(),{data:i,isLoading:l,isError:d}=iv(e,s),c=S.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):d?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(m=>{if(m.type==="directory"){const h=lv(s,m.name),u=o.has(h);return t.jsxs("div",{children:[t.jsx(Yo,{depth:r,onClick:()=>g(h),rightIcon:u?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:u?t.jsx(ii,{size:14,className:"text-amber-500"}):t.jsx($a,{size:14,className:"text-amber-500"}),label:m.name}),u&&t.jsx(ec,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:g,onFileSelect:p,selectedFilePath:v})]},h)}const x=cv(s,m.name),w=uv(m),y=v===x,a=w===ka;return t.jsx(Yo,{depth:r,active:y,onClick:()=>p(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:w?t.jsx(w,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:m.name},x)})})},hv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:g})=>{const{t:p}=ce(),[v,n]=S.useState(()=>new Set),i=ov(e),l=S.useCallback(d=>{n(c=>{const m=new Set(c);return m.has(d)?m.delete(d):m.add(d),m})},[]);return t.jsxs("div",{className:se("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:t.jsx(hr,{size:13})}),g&&t.jsx("button",{type:"button",onClick:g,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Collapse file tree"),children:t.jsx(tu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(ec,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},fv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function mv(e){const s=e.split(".").pop()?.toLowerCase();return s?fv.has(s):!1}function pv(e,s){const r=dr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const gv=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:o,centerView:g}=tv(),p=sv(n=>n.state.scale),v=Math.round(p*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(gu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>g(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(mu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>g(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Jd,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},vv=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[o,g]=S.useState(!1),p=pv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Qg,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(gv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(ev,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:p,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>g(!0)})})})]})})};function xv(e){const s=e.split("/");return s[s.length-1]||e}function _v(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const bv=({active:e,name:s,isDirty:r,onClick:o,onClose:g})=>{const{t:p}=ce();return t.jsxs("button",{type:"button",onClick:o,className:se("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:se("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":p("Close tab"),title:p("Close"),children:t.jsx(Yt,{size:12})})]})},yv=ae.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},g){const{t:p}=ce(),[v,n]=S.useState([]),[i,l]=S.useState(null),[d,c]=S.useState(!1),[m,x]=S.useState(!1),[w,y]=S.useState(0),[a,h]=S.useState(null),u=S.useRef(null),f=av();S.useEffect(()=>{let z=!1;return td(async()=>{const{preloadMonaco:$}=await import("./monaco-DX9iObLO.js").then(q=>q.m);return{preloadMonaco:$}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:$})=>$()).then(()=>{z||c(!0)}).catch(()=>{z||x(!0)}),()=>{z=!0}},[]);const[b,C]=S.useState(280),[k,E]=S.useState(!1),[_,j]=S.useState(!1),A=S.useRef(280),P=S.useCallback(()=>{E(z=>(z?C(A.current):A.current=b,!z))},[b]),T=S.useCallback(z=>{z.preventDefault(),j(!0);const $=z.clientX,q=b,N=X=>{const K=X.clientX-$,ne=Math.min(480,Math.max(160,q+K));C(ne)},H=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",H)},[b]);S.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=S.useMemo(()=>v.find(z=>z.path===i)||null,[v,i]),{data:W,isFetching:I,isError:B,error:F}=nv(s,D?.isImage?null:i);S.useEffect(()=>{!i||!W||n(z=>z.map($=>$.path!==i||$.isDirty||$.loaded?$:{...$,language:W.language||$.language,content:W.content,savedContent:W.content,isDirty:!1,loaded:!0}))},[i,W]);const R=S.useCallback((z,$,q)=>{n(N=>{if(N.find(K=>K.path===z))return N;const X=mv(z);return[...N,{path:z,name:xv(z),language:_v(z),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(z),h($?{path:z,line:$,column:q}:null)},[]);ae.useImperativeHandle(g,()=>({openFile:R}),[R]);const M=S.useCallback(z=>{n($=>{const q=$.filter(N=>N.path!==z);return l(N=>N!==z?N:q.length?q[q.length-1].path:null),q})},[]),L=S.useCallback(z=>{n($=>$.map(q=>{if(q.path!==i)return q;const N=z!==q.savedContent;return{...q,content:z,isDirty:N}}))},[i]),O=S.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(z=>z.map($=>$.path===D.path?{...$,savedContent:$.content,isDirty:!1,loaded:!0}:$)))},[D,o,f,s]),U=S.useRef(()=>{});S.useEffect(()=>{U.current=()=>{O().catch(()=>{})}},[O]),S.useEffect(()=>{const z=$=>{o||($.metaKey||$.ctrlKey)&&$.key.toLowerCase()==="s"&&($.preventDefault(),U.current())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[o]);const Y=S.useCallback((z,$)=>{u.current=z,y(q=>q+1),z.addCommand($.KeyMod.CtrlCmd|$.KeyCode.KeyS,()=>{U.current()})},[]);return S.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const z=u.current,$=z?.getModel();if(!z||!$)return;const q=Math.min(a.line,$.getLineCount()),N=Math.min(a.column??1,$.getLineMaxColumn(q)),H={lineNumber:q,column:N};z.setPosition(H),z.revealPositionInCenter(H),z.focus(),h(null)},[i,D?.loaded,w,a]),t.jsxs("div",{className:se("flex h-full overflow-hidden bg-white",r),style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:b,transition:_?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:p("Expand file tree"),children:t.jsx(ru,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(hv,{workingDir:s,onFileSelect:R,selectedFilePath:D?.path||null,onCollapse:P},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:se("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:p("No open files")}):v.map(z=>t.jsx(bv,{active:z.path===i,name:z.name,isDirty:z.isDirty,onClick:()=>l(z.path),onClose:$=>{$.stopPropagation(),M(z.path)}},z.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:p("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),p("Saving")]}),D?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:p("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?D?D.isImage?t.jsx(vv,{workingDir:s,filePath:D.path}):m?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:p("Failed to load editor.")}):d?t.jsxs(t.Fragment,{children:[t.jsx(Hp,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:z=>L(z??""),onMount:Y,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),p("Loading file...")]})}),B&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[p("Failed to load file"),F instanceof Error?`: ${F.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Ke,{size:14,className:"animate-spin mr-2"}),p("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:p("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:p("No workspace selected.")})})]})]})});function pi(e,s={}){const r=_s(g=>g.visibleContext),o=pl(e,r);return Bt({queryKey:de.git.changes(e||""),queryFn:()=>Ce.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function tc(e,s,r){const o=_s(p=>p.visibleContext),g=pl(e,o);return Bt({queryKey:de.git.diff(e||"",s||"",r),queryFn:()=>Ce.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:g,refetchIntervalInBackground:!1,refetchOnWindowFocus:g?"always":!1,refetchOnReconnect:g?"always":!1})}function $n(e,s){return Bt({queryKey:de.git.commitFiles(e||"",s||""),queryFn:()=>Ce.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Un(e,s,r){return Bt({queryKey:de.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ce.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function sc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:g,isPending:p,error:v,onConfirm:n}){const{t:i}=ce(),[l,d]=S.useState(""),[c,m]=S.useState(!1);S.useEffect(()=>{e&&(m(!1),d(g??""))},[e]),S.useEffect(()=>{c||!e||d(g??"")},[g,c,e]);const x=()=>{p||s()};return t.jsx(ns,{isOpen:e,onClose:x,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x,disabled:p,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:()=>n(l.trim()||void 0),disabled:p,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:p?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx($r,{size:14}),i("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(Ua,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:i("提交消息")}),t.jsx("textarea",{value:l,onChange:w=>{m(!0),d(w.target.value)},placeholder:i("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:i("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function Es(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function rc(e){if(!(e instanceof cn)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==ir.REBASE&&s.conflictOp!==ir.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Es(s,"sourceBranch"),targetBranch:Es(s,"targetBranch"),sourceWorktreePath:Es(s,"sourceWorktreePath"),targetWorktreePath:Es(s,"targetWorktreePath"),sourceWorkspaceId:Es(s,"sourceWorkspaceId"),targetWorkspaceId:Es(s,"targetWorkspaceId")}}function Vo(e,s,r,o){const g=rc(e);if(g){r(g);return}o(e instanceof Error?e.message:s)}function ic({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:g,onRefreshCommitMessage:p,onConflict:v,onResolveConflicts:n}){const{t:i}=ce(),{data:l,isLoading:d}=Pn(e),c=xl(),m=vl(),x=Ln(),[w,y]=S.useState(!1),[a,h]=S.useState(null);if(S.useEffect(()=>{w&&p?.()},[w,p]),d||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const u=l.conflictedFiles.length>0,f=l.operation!=="idle",b=l.hasUncommittedChanges||l.untrackedCount>0,C=l.uncommittedCount+l.untrackedCount,k=!u&&!f&&!b,E=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!b&&!u,_=()=>{h(null),c.mutate(e,{onError:T=>{Vo(T,i("更新失败,请稍后重试"),D=>v(D),h)}})},j=()=>{h(null),y(!0)},A=T=>{h(null),m.mutate({id:e,commitMessage:T},{onSuccess:()=>y(!1),onError:D=>{Vo(D,i("提交失败,请稍后重试"),W=>{y(!1),v(W)},h)}})},P=()=>{m.isPending||(y(!1),h(null))};return E?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(sd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),b&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Yd,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:C})})]}),u&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(ur,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),f&&!u&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Ke,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(rd,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!u&&!f&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:_,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(hr,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:g??l.ahead})}),l.behind===0&&!b?t.jsxs("button",{onClick:j,disabled:m.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx($r,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(b?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx($r,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(sc,{isOpen:w,onClose:P,branchName:s,targetBranch:r,commitMessage:o,isPending:m.isPending,error:a,onConfirm:A})]})}const Oi=50,Bi=400,Go={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},Qo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function nc(e){const s=e.split("/");return s[s.length-1]||e}function Sv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function wv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Br(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const nn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:se("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),Cv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},oc=({diff:e})=>{const{t:s}=ce(),[r,o]=S.useState(!1),g=S.useMemo(()=>e.split(`
|
|
72
|
+
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const p=!r&&g.length>Bi,v=p?g.slice(0,Bi):g;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(Cv,{line:n,lineNum:i+1},i)),p&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:g.length-Bi})})]})},kv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:g}=ce(),{data:p,isLoading:v,isError:n}=tc(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Ke,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:g("差异加载失败")}):t.jsx(oc,{diff:p?.diff||""})},Ev=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:g}=ce(),{data:p,isLoading:v,isError:n}=Un(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Ke,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:g("差异加载失败")}):t.jsx(oc,{diff:p?.diff||""})},Fi=({entry:e,source:s,workingDir:r,flash:o,registerNode:g})=>{const[p,v]=S.useState(!1),[n,i]=S.useState(!1),l=S.useRef(null),d=Br(s,e.path);S.useEffect(()=>(g(d,l.current),()=>g(d,null)),[d,g]),S.useEffect(()=>{const x=l.current;if(!x||n)return;const w=new IntersectionObserver(y=>{y.some(a=>a.isIntersecting)&&(i(!0),w.disconnect())},{rootMargin:"300px 0px"});return w.observe(x),()=>w.disconnect()},[n]);const c=Go[e.status]||Go.M,m=Sv(e.path);return t.jsxs("div",{ref:l,"data-card-key":d,className:se("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[p?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:nc(e.path)}),m&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:m}),t.jsx("span",{className:"ml-auto"}),t.jsx(nn,{additions:e.additions,deletions:e.deletions})]}),!p&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(kv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(Ev,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function jv(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let g=s;for(let p=0;p<o.length-1;p++){const v=o[p];g.dirs.has(v)||g.dirs.set(v,{name:v,path:g.path?`${g.path}/${v}`:v,dirs:new Map,files:[]}),g=g.dirs.get(v)}g.files.push(r)}return ac(s)}function ac(e){const s=new Map;for(const r of e.dirs.values()){let o=ac(r);for(;o.dirs.size===1&&o.files.length===0;){const g=[...o.dirs.values()][0];o={...g,name:`${o.name}/${g.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const Nv=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[g,p]=S.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[g?t.jsx(ii,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx($a,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),g&&t.jsx(lc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},lc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((g,p)=>g.name.localeCompare(p.name)).map(g=>t.jsx(Nv,{dir:g,depth:s,activeKey:r,onSelect:o},g.path)),e.files.slice().sort((g,p)=>g.path.localeCompare(p.path)).map(g=>{const p=r===g.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(g),className:se("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",p?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:g.path,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full shrink-0",Qo[g.status]||Qo.M)}),t.jsx("span",{className:se("text-xs truncate",p?"text-foreground font-medium":"text-foreground/90"),children:nc(g.path)})]},g.cardKey)})]}),Rv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ce(),{data:g,isLoading:p,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=wn({queryKey:de.git.log(e),queryFn:({pageParam:d=0})=>Ce.get("/git/log",{params:{workingDir:e,limit:String(Oi),skip:String(d)}}),initialPageParam:0,getNextPageParam:(d,c)=>d.commits.length<Oi?void 0:c.length*Oi}),l=g?.pages.flatMap(d=>d.commits)||[];return p?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Ke,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(d=>{const c=s===d.hash;return t.jsxs("button",{type:"button",onClick:()=>r(d),className:se("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:d.message,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:se("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:d.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:d.shortHash})," · ",d.author," · ",wv(d.timestamp)]})]})]},d.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Av=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:g,canRunGitOperations:p,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=ce(),[d,c]=S.useState({kind:"overview"}),[m,x]=S.useState(""),[w,y]=S.useState(null),[a,h]=S.useState(null),{data:u,isLoading:f,isError:b}=pi(e),C=d.kind==="commit"?d.commit.hash:null,{data:k,isLoading:E}=$n(e,C),_=S.useRef(new Map),j=S.useRef(null),A=S.useRef(null),P=S.useCallback((z,$)=>{$?_.current.set(z,$):_.current.delete(z)},[]),{uncommitted:T,committed:D,commitFiles:W}=S.useMemo(()=>{const z=N=>!m.trim()||N.path.toLowerCase().includes(m.trim().toLowerCase());if(d.kind==="commit"){const N={kind:"commit",hash:d.commit.hash},H=(k?.files||[]).filter(z).map(X=>({...X,cardKey:Br(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:H}}const $=(u?.uncommitted||[]).filter(z).map(N=>({...N,cardKey:Br({kind:"working",diffType:"uncommitted"},N.path)})),q=(u?.committed||[]).filter(z).map(N=>({...N,cardKey:Br({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:$,committed:q,commitFiles:[]}},[d,u,k,m]),I=d.kind==="commit"?W:[...T,...D],B=S.useMemo(()=>jv(I),[I]),F=S.useMemo(()=>{let z=0,$=0;for(const q of I)z+=q.additions??0,$+=q.deletions??0;return{additions:z,deletions:$,files:I.length}},[I]),R=S.useCallback(()=>{const z=j.current;if(!z)return;const $=z.getBoundingClientRect().top;let q=null,N=Number.NEGATIVE_INFINITY;for(const[H,X]of _.current){const K=X.getBoundingClientRect().top-$;K<=48&&K>N&&(N=K,q=H)}if(!q){let H=null,X=Number.POSITIVE_INFINITY;for(const[K,ne]of _.current){const te=ne.getBoundingClientRect().top-$;te<X&&(X=te,H=K)}q=H}y(q)},[]);S.useEffect(()=>{const z=j.current;if(!z)return;let $=0;const q=()=>{cancelAnimationFrame($),$=requestAnimationFrame(R)};return z.addEventListener("scroll",q,{passive:!0}),()=>{z.removeEventListener("scroll",q),cancelAnimationFrame($)}},[R]);const M=S.useCallback(z=>{const $=_.current.get(z.cardKey);$&&($.scrollIntoView({behavior:"smooth",block:"start"}),y(z.cardKey),h(z.cardKey),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>h(null),1200))},[]),L=S.useCallback(z=>{c($=>$.kind==="commit"&&$.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),x(""),y(null),j.current?.scrollTo({top:0})},[]),O=S.useCallback(()=>{c({kind:"overview"}),x(""),y(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const U=p&&s&&r&&o,Y=d.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[U&&n&&i&&t.jsx(ic,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:g,committedFileCount:u?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:d.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Fs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:F.files})}),t.jsx(nn,{additions:F.additions,deletions:F.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Ls,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Ls,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:d.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:d.commit.message}),t.jsx(nn,{className:"ml-auto",additions:F.additions,deletions:F.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:Y?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(z=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},z))}):b&&d.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Ur,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:m.trim()?l("没有匹配筛选条件的文件"):d.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):d.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:W.map(z=>t.jsx(Fi,{entry:z,source:{kind:"commit",hash:d.commit.hash},workingDir:e,flash:a===z.cardKey,registerNode:P},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(z=>t.jsx(Fi,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===z.cardKey,registerNode:P},z.cardKey))})]}),D.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map(z=>t.jsx(Fi,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===z.cardKey,registerNode:P},z.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(pn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:m,onChange:z=>x(z.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:m.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(lc,{node:B,depth:0,activeKey:w,onSelect:M})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Is,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Rv,{workingDir:e,selectedHash:C,onSelectCommit:L})})]})]})]})]})},zi=50,Zo={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Tv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Mv(e){const s=e.split("/");return s[s.length-1]||e}function Dv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const Pv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},Lv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ce(),{data:g,isLoading:p,isError:v}=Un(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const i=n.split(`
|
|
73
|
+
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,d)=>t.jsx(Pv,{line:l,lineNum:d+1},d))})},Iv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:g}=ce(),{data:p,isLoading:v}=$n(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Ke,{size:12,className:"animate-spin"}),t.jsx("span",{children:g("Loading...")})]});const n=p?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:g("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const l=Zo[i.status]||Zo.M,d=Dv(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:se("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:Mv(i.path)}),d&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:d})]},i.path)})})},Ov=({workingDir:e})=>{const{t:s}=ce(),r=_s(E=>E.visibleContext),o=sf(e,r),{data:g,isLoading:p,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=wn({queryKey:de.git.log(e||""),queryFn:({pageParam:E=0})=>Ce.get("/git/log",{params:{workingDir:e||"",limit:String(zi),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,_)=>E.commits.length<zi?void 0:_.length*zi,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),d=g?.pages.flatMap(E=>E.commits)||[],[c,m]=S.useState(null),[x,w]=S.useState(null),[y,a]=S.useState(280),[h,u]=S.useState(!1),f=S.useCallback(E=>{E.preventDefault(),u(!0);const _=E.clientX,j=y,A=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-_)));a(D)},P=()=>{u(!1),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",P)},[y]),b=E=>{c===E?(m(null),w(null)):(m(E),w(null))},C=S.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(d.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Is,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=d.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:y},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Is,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:d.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[d.map(E=>{const _=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>b(E.hash),className:se("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",_?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:se("w-2 h-2 rounded-full shrink-0 transition-colors",_?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Mt,{size:12,className:se("shrink-0 text-muted-foreground/70 transition-transform",_&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:Tv(E.timestamp)})]})]})]}),_&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(Iv,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:w})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:l,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:l?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:se("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Ur,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(Lv,{workingDir:e,hash:c,filePath:x})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Ur,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Jo=dr();function Bv(e){if(!Jo)return e;try{const s=new URL(Jo);return new URL(e,s.origin).toString()}catch{return e}}function cc(e){return{...e,viewUrl:e.viewUrl?Bv(e.viewUrl):null}}function Fv(e){return Bt({queryKey:de.previews.status(e??""),queryFn:async()=>{const s=await Ce.get(`/previews/${e}/status`);return cc(s)},enabled:!!e,refetchOnWindowFocus:!1})}function zv(e){const s=bt();return Ft({mutationFn:async r=>{const o=await Ce.put(`/previews/${e}/config`,{target:r});return cc(o)},onSuccess:r=>{e&&(s.setQueryData(de.previews.status(e),r),s.invalidateQueries({queryKey:de.workspaces.all}))}})}function Wv(){return window.location.protocol==="https:"?"remote":"local"}function Hv(e,s){const[r,o]=S.useState(null),[g,p]=S.useState(!1),[v,n]=S.useState(null),[i,l]=S.useState(0);return S.useEffect(()=>{if(!e||!s?.ready||!s.target){o(null),p(!1),n(null);return}let d=!1,c=null,m=null;o(null);const x=y=>{Ce.delete(`/previews/${e}/sessions/${y}`).catch(()=>{})};return(async()=>{p(!0),n(null);try{const y={mode:Wv(),localHostname:window.location.hostname},a=await Ce.post(`/previews/${e}/sessions`,y);if(d){x(a.id);return}c=a.id,o(a),m=window.setInterval(async()=>{if(c)try{const h=await Ce.post(`/previews/${e}/sessions/${c}/heartbeat`);d||(o(h),n(null))}catch(h){!d&&h instanceof cn&&h.status===404?l(u=>u+1):d||n(h instanceof Error?h:new Error("Preview session heartbeat failed"))}},3e4)}catch(y){d||(o(null),n(y instanceof Error?y:new Error("Failed to open preview session")))}finally{d||p(!1)}})(),()=>{d=!0,m!==null&&window.clearInterval(m),c&&x(c)}},[i,s?.ready,s?.target,e]),{session:r,isOpening:g,error:v,retry:()=>l(d=>d+1)}}const $v="agent-tower-preview",Uv="agent-tower-preview-host";function qv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Kv(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Xv(e){return t.jsx(Yv,{...e},e.workspaceId??"no-workspace")}function Yv({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:g}=ce(),{data:p,isLoading:v,refetch:n,isFetching:i}=Fv(e),l=zv(e),{session:d,isOpening:c,error:m,retry:x}=Hv(e,p),w=S.useRef(null),y=S.useRef(null),a=S.useRef(null),h=S.useRef(null),u=S.useRef(null),f=S.useRef(null),[b,C]=S.useState(0),[k,E]=S.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),_=Kv(d?.viewUrl),j=p&&k.target!==p.target?{target:p.target,address:p.target??"",iframeSrc:null,isFrameLoading:!1}:p&&!p.ready&&k.iframeSrc?{...k,iframeSrc:null,isFrameLoading:!1}:k,A=S.useCallback(F=>{E(R=>({...p&&R.target!==p.target?{target:p.target,address:p.target??"",iframeSrc:null,isFrameLoading:!1}:R,...F}))},[p]);S.useEffect(()=>{if(!d||d.target!==p?.target)return;const F=u.current!==_;u.current=_,E(R=>{const M=r&&f.current!==r.id?Ar(r.url,d.target,d.viewUrl):null;if(!F&&R.iframeSrc&&R.target===d.target&&M?.kind!=="proxy")return R;let L=R.iframeSrc;if(M?.kind==="proxy")L=M.url;else if(!L||R.target!==d.target||F){const U=a.current;if(U)L=pd(d.viewUrl,U);else{const Y=Ar(R.address||d.target,d.target,d.viewUrl);L=Y?.kind==="proxy"?Y.url:d.viewUrl}}a.current=null;const O=h.current;return O&&!O.closed&&L&&O.location.replace(L),h.current=null,{target:d.target,address:M?.kind==="proxy"?r?.url??R.address:R.address||d.target,iframeSrc:L,isFrameLoading:!!L}})},[r,d,_,p?.target]),S.useEffect(()=>()=>{h.current?.close()},[]);const P=S.useCallback(async(F,R=!1)=>{const M=Ar(F,p?.target??null,d?.viewUrl??null);if(!M||!e)return;if(M.kind==="proxy"){if(R){window.open(M.url,"_blank","noopener,noreferrer");return}E({target:p?.target??null,address:F,iframeSrc:M.url,isFrameLoading:!0});return}if(s)return;const L=R?window.open("about:blank","_blank"):null;L&&(L.opener=null);try{a.current=M.path,h.current=L;const O=await l.mutateAsync(M.target);E({target:O.target,address:F.trim(),iframeSrc:null,isFrameLoading:!!O.ready}),C(U=>U+1),rt.success(g("Preview target saved")),O.ready||(h.current?.close(),h.current=null)}catch(O){h.current?.close(),h.current=null,a.current=null;const U=O instanceof Error?O.message:g("Failed to save preview target");rt.error(U)}},[d?.viewUrl,s,p?.target,g,l,e]);S.useEffect(()=>{if(!r||v||f.current===r.id)return;const F=window.setTimeout(()=>{f.current=r.id,o?.(r.id),P(r.url)},0);return()=>window.clearTimeout(F)},[v,P,r,o]),S.useEffect(()=>{const F=R=>{if(R.source!==w.current?.contentWindow)return;const M=R.data;if(!(!M||M.source!==$v)){if(M.type==="location"&&typeof M.href=="string"){const L=gd(p?.target??null,d?.viewUrl??null,M.href,window.location.href);L&&document.activeElement!==y.current&&A({target:p?.target??j.target,address:L,isFrameLoading:!1});return}M.type==="navigate-loopback"&&typeof M.href=="string"&&P(M.href,M.newTab===!0)}};return window.addEventListener("message",F),()=>window.removeEventListener("message",F)},[j.target,P,A,d?.viewUrl,p?.target]);const T=F=>{w.current?.contentWindow?.postMessage({source:Uv,action:F},"*")},D=F=>{F.preventDefault(),P(j.address)},W=async()=>{const F=await n();if(!F.data?.ready){A({target:F.data?.target??j.target,iframeSrc:null,isFrameLoading:!1});return}if(!d||!j.iframeSrc){x();return}A({isFrameLoading:!0}),T("reload")},I=()=>{if(!d?.viewUrl)return;const F=Ar(j.address||d.target,d.target,d.viewUrl),R=F?.kind==="proxy"?F.url:d.viewUrl;window.open(R,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:g("No active workspace.")});const B=v||i||l.isPending||c;return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>T("back"),disabled:!j.iframeSrc,title:g("Back"),"aria-label":g("Back"),children:t.jsx(Ls,{})}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>T("forward"),disabled:!j.iframeSrc,title:g("Forward"),"aria-label":g("Forward"),children:t.jsx(Ua,{})}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:j.isFrameLoading?()=>{T("stop"),A({isFrameLoading:!1})}:W,disabled:!j.isFrameLoading&&i,title:j.isFrameLoading?g("Stop loading"):g("Refresh preview"),"aria-label":j.isFrameLoading?g("Stop loading"):g("Refresh preview"),children:j.isFrameLoading?t.jsx(Yt,{}):i?t.jsx(Ke,{className:"animate-spin"}):t.jsx(hr,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:D,children:[t.jsx(Hd,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:y,value:j.address,onChange:F=>A({address:F.target.value}),onKeyDown:F=>{F.key==="Enter"&&F.nativeEvent.isComposing&&F.preventDefault()},disabled:s||l.isPending,placeholder:qv(),"aria-label":g("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:I,disabled:!j.iframeSrc,title:g("Open preview in new tab"),"aria-label":g("Open preview in new tab"),children:t.jsx(ln,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:B?g("Checking preview target..."):m?m.message:p?.ready?`${g("Proxying")} ${p.target}`:p?.configured?`${g("Preview target is not reachable")}${p.error?`: ${p.error}`:""}`:g("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:g("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:j.iframeSrc?t.jsx("iframe",{ref:w,src:j.iframeSrc,title:g("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>A({isFrameLoading:!1})},b):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:p?.configured?p.ready&&c?g("Checking preview target..."):g("Start the preview server, then refresh."):g("Configure a local preview target to display it here.")})})]})}function Vv(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ea(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Gv(e){return e.length<=34?e:`...${e.slice(-31)}`}function dc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:g,className:p,buttonClassName:v}){const{t:n}=ce(),[i,l]=S.useState(!1),d=S.useRef(null),c=S.useMemo(()=>Bn(e,s),[e,s]),m=c.find(x=>x.workspace.id===r)??c[0];return S.useEffect(()=>{if(!i)return;const x=w=>{d.current&&!d.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:d,className:se("relative",p),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),disabled:g,className:se("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:n("Workspace"),children:[t.jsx(Ps,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(m.roleLabel)),children:n(m.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(m.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Gv(Os(m.workspace))}),t.jsx(wt,{size:13,className:se("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(x=>{const w=x.workspace.id===m.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!1)},className:se("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",w&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:w?t.jsx(Vt,{size:13}):t.jsx(Da,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:n(x.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Vv(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Os(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const Qv=[{key:"review",label:"Changes",icon:t.jsx(Fs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ri,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ma,{size:14})}],Zv=[{key:"history",label:"History",icon:t.jsx(Is,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ri,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ma,{size:14})}],Jv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:se("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),e0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:se("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),uc=ae.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:g,projectId:p,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:d,teamStatus:c,gitProps:m,workspaces:x,selectedWorkspaceId:w,onSelectWorkspace:y,variant:a="tabs",expanded:h,onExpandedChange:u,minContentWidth:f=520,tabRef:b,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ce(),_=_s(G=>G.setVisibleContext),j=a==="rail",[A,P]=S.useState(!1),T=j?h??A:!0,D=S.useCallback(G=>{h===void 0&&P(G),u?.(G)},[h,u]),W=S.useMemo(()=>{const G=v?Zv:Qv,pe=n?G:G.filter(Ae=>Ae.key!=="review"&&Ae.key!=="history"),ie=i?pe.filter(Ae=>Ae.key!=="terminal"):pe;return d?[{key:"team-status",label:"Team Status",icon:t.jsx(vs,{size:14})},...ie]:ie},[n,v,i,d]),[I,B]=S.useState(()=>C?"preview":n?v?"history":"review":"editor"),F=S.useRef(null),R=S.useRef(0),[M,L]=S.useState(),O=S.useCallback(G=>{B(G),j&&D(!0)},[j,D]);S.useImperativeHandle(b,()=>({setTab:G=>O(G),openFile:(G,pe,ie)=>{O("editor"),requestAnimationFrame(()=>F.current?.openFile(G,pe,ie))},openPreview:(G,pe)=>{R.current+=1,L({id:R.current,url:G,workspaceId:pe}),O("preview")}}),[O]);const U=C??M,Y=U?.workspaceId&&U.workspaceId!==o?void 0:U,z=S.useCallback(G=>{L(pe=>pe?.id===G?void 0:pe),k?.(G)},[k]),{data:$}=jd(p??""),q=S.useMemo(()=>{if(!$?.quickCommands)return[];try{return JSON.parse($.quickCommands)}catch{return[]}},[$?.quickCommands]),[N,H]=S.useState([]),X=S.useRef(void 0);S.useEffect(()=>{g&&g!==X.current&&(X.current=g,H(G=>G.includes(g)?G:[...G,g]))},[g]),S.useEffect(()=>{W.some(G=>G.key===I)||B(W[0]?.key??"editor")},[I,W]),S.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!g||!G){_(null);return}return _({workspaceId:o,workingDir:g,tab:G}),()=>{_(null)}},[I,T,j,_,g,o]);const K=!!y&&Bn(x,d).length>1,ne=W.find(G=>G.key===I)??W[0],te=ne?E(ne.label):"",he=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,le=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[K&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(dc,{workspaces:x,teamRun:d,selectedWorkspaceId:w,onSelectWorkspace:y,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&d&&c,I==="editor"&&t.jsx(yv,{ref:F,workingDir:g,readOnly:i}),N.map(G=>{const pe=I==="terminal"&&g===G;return t.jsx("div",{"aria-hidden":!pe,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:pe?"block":"none"},children:t.jsx(Dm,{cwd:G,isVisible:pe,quickCommands:q})},G)}),I==="preview"&&t.jsx(Xv,{workspaceId:o,readOnly:i,navigationRequest:Y,onNavigationRequestHandled:z}),I==="review"&&t.jsx(Av,{workingDir:g,workspaceId:o,branchName:m?.branchName,targetBranch:m?.targetBranch,commitMessage:m?.commitMessage,canRunGitOperations:m?.canRunGitOperations,onRefreshCommitMessage:m?.onRefreshCommitMessage,onConflict:m?.onConflict,onResolveConflicts:m?.onResolveConflicts}),I==="history"&&t.jsx(Ov,{workingDir:g})]})]});return j?t.jsxs("div",{className:se("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:W.map(G=>t.jsx(e0,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[he,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:ne?.icon}),t.jsx("span",{className:"truncate",children:te})]}),t.jsx("button",{type:"button",onClick:()=>D(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(nu,{size:15})})]}),le]})]}):t.jsxs("div",{className:se("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&he,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:W.map(G=>t.jsx(Jv,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),le]})}),ta=1500,t0=3e3;function s0(e){const[s,r]=S.useState(null),o=S.useRef(0),g=S.useRef(null),p=S.useRef(null);return S.useEffect(()=>{if(!e)return;const v=()=>{p.current&&(clearTimeout(p.current),p.current=null)},n=Jt.connect(),i=d=>{r(d),p.current=setTimeout(()=>r(null),t0)},l=d=>{if(d.taskId!==e)return;const c={status:d.status,currentCommand:d.currentCommand,currentIndex:d.currentIndex,totalCommands:d.totalCommands,error:d.error};if(d.status==="running"){v(),g.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const m=o.current>0?Date.now()-o.current:0,x=ta-m;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:d.totalCommands,currentIndex:d.totalCommands}),g.current=c,p.current=setTimeout(()=>i(c),ta)):x>0?(g.current=c,v(),p.current=setTimeout(()=>i(c),x)):i(c)};return n.on(ct.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(ct.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,g.current=null}},[e]),s}function hc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:g,taskTitle:p,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:d}){const{t:c}=ce(),[m,x]=S.useState(""),[w,y]=S.useState(""),[a,h]=S.useState(_t.WORKTREE),[u,f]=S.useState(null),[b,C]=S.useState("idle"),[k,E]=S.useState(null),_=bt(),j=gl(o),A=xn(),P=Nd(),{data:T,isLoading:D}=Bs(),W=u?.isGitRepo??i,I=u?.worktreeReady??l,B=u?.reason??d,F=W!==!1&&I!==!1;S.useEffect(()=>{if(!e||!T)return;const N=T.find(H=>H.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),S.useEffect(()=>{if(e){const N=[p];v&&N.push(v),y(n?.trim()||N.join(`
|
|
73
74
|
|
|
74
|
-
`)),f(null),h(i!==!1&&l!==!1?
|
|
75
|
-
`):"- 未获取到冲突文件列表"}function
|
|
76
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤",...
|
|
77
|
-
`)}function
|
|
78
|
-
`)}function n0(e){if(e.teamRunId)return{type:"team_room",message:i0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:r0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function pc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:g,sourceBranch:p,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:m,sourceWorktreePath:x,targetWorktreePath:w,sessions:_,currentSessionId:a,teamRunId:h}){const{t:u}=de(),[f,y]=S.useState(""),C=$n(),k=cn(h??""),E=An(),b=!!h,j=a||f,A=b?k.isPending:C.isPending,L=()=>{const $=n0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:m,sourceWorktreePath:x,targetWorktreePath:w,sourceBranch:p,targetBranch:v,conflictedFiles:g,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if($.type==="team_room"){k.mutate({content:$.message,kind:"chat"},{onSuccess:()=>{ut.success(u("已发送到 Team Room")),s(!1)}});return}$.type==="session"&&C.mutate({id:$.sessionId,message:$.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",F=!b&&!a&&_.length>0,I=b||!!j;return t.jsx(gs,{isOpen:e,onClose:()=>s(!1),title:u("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Te,{variant:"outline",onClick:T,children:u("在 IDE 中打开")}),t.jsx(Te,{onClick:L,disabled:!I||A,children:u(A?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("冲突文件({count})",{count:g.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:g.map($=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:$},$))})]}),b&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:u("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),F&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:$=>y($.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:u("选择一个 Session...")}),_.map($=>t.jsxs("option",{value:$.id,children:[$.agentType," — ",$.status]},$.id))]})]}),!b&&!j&&_.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:u("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function o0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function sa(e,s,r,o){const g=ec(e);if(g){r(g);return}o(e instanceof Error?e.message:s)}function gc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:g,gitStatus:p,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:d,className:c}){const{t:m}=de(),x=pl(),w=ml(),_=Mn(),[a,h]=S.useState(!1),[u,f]=S.useState(null),y=S.useMemo(()=>o0(g),[g]),C=y.additions+y.deletions,k=y.files>0&&C>0,E=(p?.conflictedFiles.length??0)>0,b=!!(p&&p.operation!=="idle"),j=!!(p&&(p.hasUncommittedChanges||p.untrackedCount>0)),A=(p?.uncommittedCount??0)+(p?.untrackedCount??0),L=(p?.behind??0)>0,T=(p?.ahead??0)>0,D=v||!p&&n,F=!!(n&&e&&p&&L&&!E&&!b&&!j),I=!!(n&&e&&p&&T&&!L&&!E&&!b&&!j);if(S.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const $=E?m("冲突"):p?.operation==="rebase"?m("变基中"):p?.operation==="merge"?m("合并中"):A>0?m("{count} 未提交",{count:A}):L?m("落后 {count}",{count:p?.behind??0}):m(T?"可合并":"已是最新"),W=m("{files} 个文件 · {lines} 行",{files:y.files,lines:C}),R=()=>{F&&(f(null),x.mutate(e,{onError:U=>{sa(U,m("更新失败,请稍后重试"),Y=>d(Y),f)}}))},M=()=>{I&&(f(null),h(!0))},P=U=>{f(null),w.mutate({id:e,commitMessage:U},{onSuccess:()=>h(!1),onError:Y=>{sa(Y,m("提交失败,请稍后重试"),B=>{h(!1),d(B)},f)}})},O=()=>{w.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:se("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":m("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Bs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:W}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[y.additions>0&&t.jsxs("span",{className:"text-success",children:["+",y.additions]}),y.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",y.deletions]})]}),E&&t.jsx(dr,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:$})]}),t.jsx(Mt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[b&&t.jsx("button",{type:"button",onClick:()=>_.mutate(e),disabled:_.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:_.isPending?m("正在撤销..."):m("撤销操作")}),t.jsxs("button",{type:"button",onClick:R,disabled:!F||x.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:m(L?"同步更新":"已是最新"),children:[x.isPending?t.jsx(Xe,{size:12,className:"animate-spin"}):t.jsx(ur,{size:12}),t.jsx("span",{children:x.isPending?m("正在同步..."):m("更新")})]}),t.jsxs("button",{type:"button",onClick:M,disabled:!I||w.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:I?m("合并到 {target}",{target:r}):m("提交变更"),children:[w.isPending?t.jsx(Xe,{size:12,className:"animate-spin"}):t.jsx(Hr,{size:12}),t.jsx("span",{children:w.isPending?m("正在提交..."):m("合并")})]})]})]}),u&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:u})]}),t.jsx(Jl,{isOpen:a,onClose:O,branchName:s,targetBranch:r,commitMessage:o,isPending:w.isPending,error:u,onConfirm:P})]})}function a0({agentType:e,workingDir:s}){return Ot({queryKey:ae.system.skillCatalog(e,s),queryFn:async()=>(await Se.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===js.CODEX,staleTime:3e4})}function l0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function vc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:g,minHeight:p,maxHeight:v}){const[n,i]=S.useState(0),{data:l=[]}=a0({agentType:e,workingDir:s}),c=S.useMemo(()=>e===js.CODEX?eo(r):null,[e,r])?.query??null,m=S.useMemo(()=>c===null?[]:_d(l,c),[c,l]),x=S.useCallback(()=>{const a=g.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,v))}px`)},[v,p,g]);S.useEffect(()=>{i(0)},[e,c]),S.useEffect(()=>{n<m.length||i(0)},[m.length,n]);const w=S.useCallback(a=>{const h=eo(r);if(!h)return;const u=`${r.slice(0,h.replaceStart)}${a.command} `;o(u),requestAnimationFrame(()=>{const f=g.current;f&&(x(),f.focus(),f.setSelectionRange(u.length,u.length))})},[r,x,o,g]),_=S.useCallback(a=>c===null||m.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%m.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+m.length)%m.length),!0):l0(a)?(a.preventDefault(),w(m[n]??m[0]),!0):!1,[w,m,c,n]);return{allSkills:l,query:c,filteredSkills:m,selectedIndex:n,setSelectedIndex:i,applySkill:w,handleKeyDown:_}}const c0=cr(),d0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${c0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,ks=520,zi=48,u0=4,h0=420;function f0(){const{t:e}=de();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ra=[{status:ye.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ta,{className:"w-3 h-3"})},{status:ye.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Aa,{className:"w-3 h-3"})},{status:ye.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Ra,{className:"w-3 h-3"})},{status:ye.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Na,{className:"w-3 h-3"})},{status:ye.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(ja,{className:"w-3 h-3"})}];function m0({status:e,onChangeStatus:s}){const{t:r}=de(),[o,g]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{if(!o)return;const n=i=>{p.current&&!p.current.contains(i.target)&&g(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=ra.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:p,children:[t.jsxs("button",{onClick:()=>s&&g(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ra.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),g(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function ia({state:e,onRetry:s}){const{t:r}=de(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Kt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function p0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:g,onAutoStartRecovered:p}){const{t:v}=de(),[n,i]=S.useState(""),[l,d]=S.useState(!1),[c,m]=S.useState(!1),[x,w]=S.useState(!1),[_,a]=S.useState(!1),[h,u]=S.useState(!1),[f,y]=S.useState(!1),[C,k]=S.useState(null),E=S.useRef(null),[b,j]=S.useState(!1),[A,L]=S.useState(null),[T,D]=S.useState(void 0),[F,I]=S.useState(!1),$=S.useRef(null),W=S.useRef(null),R=S.useRef(null),M=S.useRef(null),{scrollRef:P,contentRef:O,isAtBottom:U,scrollToBottom:Y,stopScroll:B}=pn({resize:"smooth",initial:"instant"}),[H,q]=S.useState(!1),[N,z]=S.useState(ks),[X,K]=S.useState(!1),ne=S.useRef(0),te=S.useRef(ks),fe=S.useRef(null),ce=S.useCallback((Q,oe,Fe)=>{E.current?.openFile(Q,oe,Fe)},[]),{data:G,isLoading:ge}=Rn(e?.id??""),re=Qv(e?.id),{data:Ae}=ya(e?.id??""),{data:nt}=Sa(Ae?.id??""),Ke=cn(Ae?.id??""),be=Ae??null,Oe=!!be,Pe=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,He=Ae===null&&Pe,Be=!!(e?.id&&Ae===null),{data:Ye,isLoading:Ze}=wa(e?.id??"",Be);S.useEffect(()=>{I(!1),L(null),D(void 0)},[e?.id]);const Me=S.useMemo(()=>yl(G,be,T),[T,be,G]);S.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const Re=S.useMemo(()=>G?.find(Q=>Q.id===Me),[Me,G]),ve=Re?.status===At.ACTIVE?Re.id:void 0,ze=Pe&&Sl(Re,be);S.useEffect(()=>{if(!F||!G)return;G.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&I(!1)},[G,F]);const xe=S.useMemo(()=>{if(F||!G)return null;const Q=pt=>{const Si=pt.createdAt,Ys=pt.endedAt??pt.startedAt??Si;if(!Ys)return 0;const Ss=Date.parse(Ys);return Number.isNaN(Ss)?0:Ss},oe=(pt,Si)=>{const Ys=pt.filter(Ss=>Si.includes(Ss.status));return Ys.length===0?null:Ys.sort((Ss,Wc)=>Q(Wc)-Q(Ss))[0]??null},Fe=G.filter(pt=>pt.status==="ACTIVE"&&Array.isArray(pt.sessions)).flatMap(pt=>pt.sessions??[]),ft=oe(Fe,[et.RUNNING])??oe(Fe,[et.PENDING])??oe(Fe,[et.COMPLETED,et.FAILED,et.CANCELLED]);if(ft)return ft;const mt=G.filter(pt=>(pt.status==="MERGED"||pt.status==="ABANDONED"||pt.status==="HIBERNATED")&&Array.isArray(pt.sessions)).flatMap(pt=>pt.sessions??[]);return oe(mt,[et.COMPLETED,et.FAILED,et.CANCELLED])},[G,F]),ot=xe?.id??"",st=Oe?A??"":ot,jt=S.useMemo(()=>{if(!A||!G)return null;for(const Q of G){const oe=Q.sessions?.find(Fe=>Fe.id===A);if(oe)return oe}return null},[A,G]),J=S.useMemo(()=>{if(!A||!be?.invocations)return null;const Q=be.invocations.filter(oe=>oe.sessionId===A);return Q.length===0?null:Q.sort((oe,Fe)=>{const ft=Date.parse(oe.updatedAt??oe.createdAt??""),mt=Date.parse(Fe.updatedAt??Fe.createdAt??"");return(Number.isNaN(mt)?0:mt)-(Number.isNaN(ft)?0:ft)})[0]??null},[A,be?.invocations]),he=S.useMemo(()=>!J?.memberId||!be?.members?null:be.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,be?.members]),V=A?jt:xe??null,Z=S.useMemo(()=>{if(V?.workspaceId)return V.workspaceId;if(!(!V||!G))return G.find(Q=>Q.sessions?.some(oe=>oe.id===V.id))?.id},[V,G]),ie=S.useCallback((Q,oe)=>{const ft=(oe&&G?.some(mt=>mt.id===oe)?oe:void 0)??Z??Me??void 0;ft&&D(ft),E.current?.openPreview(Q,ft)},[Z,Me,G]),we=S.useCallback(Q=>{ie(Q,Z)},[Z,ie]),pe=V?.status===et.RUNNING||V?.status===et.PENDING,ue=!!e?.projectArchivedAt,Le=!!e?.projectRepoDeletedAt,_e=v(Le?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Ce}=Os(),[De,ke]=S.useState(null);S.useEffect(()=>{ke(xe?.providerId??null)},[xe?.providerId]);const Ve=S.useMemo(()=>!xe||!G?!1:!G.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Fe=>Fe.id===xe.id)),[xe,G]),je=S.useMemo(()=>{if(!(!G||F)){if(Re)return ts(Re);for(const Q of G)if(Q.status==="ACTIVE"&&ts(Q))return ts(Q);return ts(G[0])}},[F,Re,G]),Ge=Pa({agentType:xe?.agentType,workingDir:je,input:n,setInput:i,textareaRef:R,minHeight:60,maxHeight:300}),tt=vc({agentType:xe?.agentType,workingDir:je,input:n,setInput:i,textareaRef:R,minHeight:60,maxHeight:300}),xt=xs(Q=>Q.setVisibleContext),_t=!!(ze&&ve&&je&&!ue),{data:at,isLoading:lt}=Tn(ve??"",{enabled:_t}),{data:bt}=mi(je,{enabled:_t});S.useEffect(()=>{if(!(H||!_t||!ve||!je))return xt({workspaceId:ve,workingDir:je,tab:"changes"}),()=>{xt(null)}},[H,ve,xt,_t,je]);const Bt=Re?.sessions??[],_s=Is(Re),Ws=Re?.commitMessage,os=S.useMemo(()=>wl(Re,G,e?.mainBranch??""),[Re,e?.mainBranch,G]),gt=S.useMemo(()=>at?.conflictOp&&at.conflictedFiles.length>0?{conflictOp:at.conflictOp,conflictedFiles:at.conflictedFiles}:C,[at?.conflictOp,at?.conflictedFiles,C]),Hs=gt?.targetWorkspaceId??ve,_r=gt?.targetWorktreePath??Re?.worktreePath,br=gt?.sourceBranch??_s,as=gt?.targetBranch??os,rt=ht(),$t=S.useCallback(async()=>e?.id?rt.fetchQuery({queryKey:ae.tasks.body(e.id),queryFn:()=>Se.get(`/tasks/${e.id}/body`)}):null,[rt,e?.id]),ls=S.useCallback(()=>e?.id?rt.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,rt]);S.useEffect(()=>{if(!b)return;const Q=oe=>{W.current&&!W.current.contains(oe.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[b]);const yr=$n(),cs=An(),Sr=rd(),$s=fl(e?.id??""),Us=Hn(),Ut=Zh(),Ft=S.useMemo(()=>!G||G.some(oe=>oe.status==="ACTIVE")?null:G.find(oe=>oe.status==="HIBERNATED")??null,[G]),qs=S.useRef(null);S.useEffect(()=>{Ft&&qs.current!==Ft.id&&(Ut.isPending||(qs.current=Ft.id,Ut.mutate(Ft.id,{onSettled:()=>{qs.current=null}})))},[Ft,Ut]);const wr=S.useCallback(async()=>{if(!e?.id)return;const Q=xe?.providerId??Ce?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),u(!0);try{const Fe=(await $t())?.prompt??e.title;await Sr.mutateAsync(e.id),I(!0);const ft=await $s.mutateAsync({workspaceKind:Pe?void 0:yt.MAIN_DIRECTORY}),mt=await Se.post(`/workspaces/${ft.id}/sessions`,{providerId:Q,prompt:Fe});await Us.mutateAsync(mt.id),await rt.invalidateQueries({queryKey:ae.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),I(!1)}finally{u(!1)}}},[e?.id,e?.title,Pe,xe?.providerId,Ce,$t,Sr,$s,Us,rt]),bs=S.useCallback(async()=>{e?.id&&(await $t(),d(!0))},[$t,e?.id]),Ks=S.useCallback(()=>{Re?.id&&cs.mutate({workspaceId:Re.id})},[cs,Re?.id]),Cr=S.useCallback(()=>{!e?.id||!s||(s(e.id),w(!1))},[e?.id,s]),kr=S.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{Y()})},[Y]),pi=S.useCallback(()=>{L(null)},[]),ds=S.useCallback(Q=>{k(Q??null),y(!0)},[]),gi=S.useCallback(Q=>Ke.mutateAsync(Q),[Ke]),Gt=S.useCallback(()=>{rt.invalidateQueries({queryKey:id.all})},[rt]),{isConnected:Xs,isLoadingSnapshot:Er,isOutputActive:jr,lastExitAt:Nr,logs:us,entries:hs,attach:ee}=Oa({sessionId:st,sessionStatus:V?.status,sessionStartedAt:V?.startedAt??V?.createdAt,sessionEndedAt:V?.endedAt??(pe?null:V?.updatedAt),onExit:S.useCallback(()=>{rt.invalidateQueries({queryKey:["workspaces"]})},[rt])});S.useEffect(()=>{if(!e?.id)return;const Q=Zt.connect();Q.emit(Es.SUBSCRIBE,{topic:"task",id:e.id});const oe=mt=>{mt.taskId===e.id&&(rt.invalidateQueries({queryKey:["tasks"]}),Gt())},Fe=mt=>{mt.taskId===e.id&&(rt.invalidateQueries({queryKey:ae.workspaces.list(e.id)}),Gt())},ft=mt=>{mt.taskId===e.id&&(rt.invalidateQueries({queryKey:ae.workspaces.list(e.id)}),Gt())};return Q.on(ct.TASK_UPDATED,oe),Q.on(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Fe),Q.on(ct.WORKSPACE_HIBERNATED,ft),()=>{Q.off(ct.TASK_UPDATED,oe),Q.off(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Fe),Q.off(ct.WORKSPACE_HIBERNATED,ft),Q.emit(Es.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,rt,Gt]),S.useEffect(()=>{if(!st)return;const Q=Zt.connect(),oe=Fe=>{Fe.sessionId===st&&(rt.invalidateQueries({queryKey:["workspaces"]}),Gt())};return Q.on(ct.SESSION_COMPLETED,oe),()=>{Q.off(ct.SESSION_COMPLETED,oe)}},[st,rt,Gt]);const{todos:me}=Ba(hs),{files:$e,addFiles:Ne,removeFile:wt,clear:Dt,buildMarkdownLinks:Ie,hasFiles:Nt,isUploading:Pt}=dn(),ys=S.useMemo(()=>uc(V),[V?.tokenUsage]),qn=La(us,ys);S.useEffect(()=>{st&&Xs&&ee()},[st,Xs,ee]);const Kn=S.useRef(e?.id);S.useEffect(()=>{if(Kn.current!==e?.id&&P.current){const Q=P.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}Kn.current=e?.id},[e?.id,P]);const vi=cc(),xi=S.useRef(!1),Xn=S.useCallback(async()=>{if(!n.trim()&&!Nt||!st||xi.current||Pt)return;xi.current=!0;const Q=Ie(),oe=[n.trim(),Q].filter(Boolean).join(`
|
|
75
|
+
`)),f(null),h(i!==!1&&l!==!1?_t.WORKTREE:_t.MAIN_DIRECTORY),C("idle"),E(null)}},[e,i,l,o,p,v,n]),S.useEffect(()=>{F||h(_t.MAIN_DIRECTORY)},[F]);const R=async()=>{if(!g||P.isPending)return;const N=await P.mutateAsync({id:g});f(N),N.worktreeReady&&h(_t.WORKTREE)},M=b!=="idle",L=async()=>{if(!(!m||!w.trim())){E(null);try{C("creating-workspace");const N=await j.mutateAsync({workspaceKind:F?a:_t.MAIN_DIRECTORY});C("creating-session");const H=await Ce.post(`/workspaces/${N.id}/sessions`,{providerId:m,prompt:w.trim()});C("starting-session"),await A.mutateAsync(H.id),await _.invalidateQueries({queryKey:de.workspaces.list(o)}),C("idle"),r?.(),s()}catch(N){C("idle"),E(N instanceof Error?N.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},U=(T??[]).map(({provider:N,availability:H})=>{const X=H.type!=="NOT_FOUND";return{value:N.id,label:X?N.name:`${N.name}${c(" (不可用)")}`,icon:t.jsx(si,{agentType:N.agentType,className:"size-4"}),disabled:!X}}),Y=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),z=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),$=c(B==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),q=[{value:_t.WORKTREE,label:c("工作树模式"),description:Y,disabled:!F},{value:_t.MAIN_DIRECTORY,label:c("本地模式"),description:z}];return t.jsx(ns,{isOpen:e,onClose:M?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{variant:"outline",onClick:s,disabled:M,children:c("取消")}),t.jsx(Te,{onClick:L,disabled:M||!m||!w.trim(),children:O[b]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("Agent")}),t.jsx(es,{value:m,onChange:x,options:U,placeholder:c(D?"加载中...":"选择 Agent"),disabled:M||D})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),F?t.jsx(es,{value:a,onChange:N=>h(N),options:q,disabled:M}):t.jsx(vd,{side:"bottom",className:"w-full",content:$,children:t.jsxs("div",{tabIndex:0,"aria-label":$,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(es,{value:a,onChange:N=>h(N),options:q,disabled:!0}),t.jsx("button",{type:"button",onClick:R,disabled:M||P.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:P.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:w,onChange:N=>y(N.target.value),rows:5,disabled:M,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function fc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function r0(e,s,r){const o=e?.providerId??r?.providerId??null,g=o?s?.find(i=>i.provider.id===o)?.provider:null,p=g?.name??o??e?.agentType??r?.agentType??null;if(!p)return null;const v=e?.agentType??g?.agentType??r?.agentType??null,n=o&&g?.name&&o!==g.name?`${g.name} (${o})`:p;return{label:p,title:n,agentType:v}}function mc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:g,agentTypeFallback:p,tokenTooltipSide:v="top"}){const{t:n}=ce(),i=r0(e,s,{providerId:g,agentType:p});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${n("Provider")}: ${i.title}`,children:[t.jsx(si,{agentType:i.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:id(i.label,o?12:18)})]}),t.jsx(_n,{usage:r,tooltipSide:v})]})}function i0({isOpen:e,onClose:s,taskId:r}){const{t:o}=ce(),[g,p]=S.useState("AUTO"),[v,n]=S.useState(null),[i,l]=S.useState([]),[d,c]=S.useState(null),m=ba();S.useEffect(()=>{e&&(p("AUTO"),n(null),l([]),c(null))},[e]);const x=m.isPending,w=!!v||i.length>0,y=async()=>{if(!x){if(!v&&i.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await m.mutateAsync({taskId:r,mode:g,...v?{teamTemplateId:v}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof cn&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!w;return t.jsxs(ns,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Te,{type:"button",onClick:y,disabled:a,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(bd,{mode:g,setMode:p,selectedTemplateId:v,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:l,disabled:x}),d&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:d})]})}function n0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ce(),g=Ln();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const p=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(ur,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[p," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>g.mutate(e),disabled:g.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Te,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function pc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
76
|
+
`):"- 未获取到冲突文件列表"}function gc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function o0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function a0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function l0(e,s,r,o,g){const p=pc(r),v=gc(g);return o===ir.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
77
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤",...o0(e,g)].join(`
|
|
78
|
+
`)}function c0(e){const s=e.conflictOp===ir.REBASE?"Rebase":"Merge",r=pc(e.conflictedFiles),o=[...gc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===ir.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":a0(e)].join(`
|
|
79
|
+
`)}function d0(e){if(e.teamRunId)return{type:"team_room",message:c0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:l0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function vc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:g,sourceBranch:p,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:m,sourceWorktreePath:x,targetWorktreePath:w,sessions:y,currentSessionId:a,teamRunId:h}){const{t:u}=ce(),[f,b]=S.useState(""),C=bn(),k=dn(h??""),E=Dn(),_=!!h,j=a||f,A=_?k.isPending:C.isPending,P=()=>{const B=d0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:m,sourceWorktreePath:x,targetWorktreePath:w,sourceBranch:p,targetBranch:v,conflictedFiles:g,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(B.type==="team_room"){k.mutate({content:B.message,kind:"chat"},{onSuccess:()=>{rt.success(u("已发送到 Team Room")),s(!1)}});return}B.type==="session"&&C.mutate({id:B.sessionId,message:B.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",W=!_&&!a&&y.length>0,I=_||!!j;return t.jsx(ns,{isOpen:e,onClose:()=>s(!1),title:u("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Te,{variant:"outline",onClick:T,children:u("在 IDE 中打开")}),t.jsx(Te,{onClick:P,disabled:!I||A,children:u(A?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("冲突文件({count})",{count:g.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:g.map(B=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:B},B))})]}),_&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:u("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),W&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:u("选择一个 Session...")}),y.map(B=>t.jsxs("option",{value:B.id,children:[B.agentType," — ",B.status]},B.id))]})]}),!_&&!j&&y.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:u("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function u0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function sa(e,s,r,o){const g=rc(e);if(g){r(g);return}o(e instanceof Error?e.message:s)}function xc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:g,gitStatus:p,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:d,className:c}){const{t:m}=ce(),x=xl(),w=vl(),y=Ln(),[a,h]=S.useState(!1),[u,f]=S.useState(null),b=S.useMemo(()=>u0(g),[g]),C=b.additions+b.deletions,k=b.files>0&&C>0,E=(p?.conflictedFiles.length??0)>0,_=!!(p&&p.operation!=="idle"),j=!!(p&&(p.hasUncommittedChanges||p.untrackedCount>0)),A=(p?.uncommittedCount??0)+(p?.untrackedCount??0),P=(p?.behind??0)>0,T=(p?.ahead??0)>0,D=v||!p&&n,W=!!(n&&e&&p&&P&&!E&&!_&&!j),I=!!(n&&e&&p&&T&&!P&&!E&&!_&&!j);if(S.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const B=E?m("冲突"):p?.operation==="rebase"?m("变基中"):p?.operation==="merge"?m("合并中"):A>0?m("{count} 未提交",{count:A}):P?m("落后 {count}",{count:p?.behind??0}):m(T?"可合并":"已是最新"),F=m("{files} 个文件 · {lines} 行",{files:b.files,lines:C}),R=()=>{W&&(f(null),x.mutate(e,{onError:U=>{sa(U,m("更新失败,请稍后重试"),Y=>d(Y),f)}}))},M=()=>{I&&(f(null),h(!0))},L=U=>{f(null),w.mutate({id:e,commitMessage:U},{onSuccess:()=>h(!1),onError:Y=>{sa(Y,m("提交失败,请稍后重试"),z=>{h(!1),d(z)},f)}})},O=()=>{w.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:se("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":m("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Fs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:F}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[b.additions>0&&t.jsxs("span",{className:"text-success",children:["+",b.additions]}),b.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",b.deletions]})]}),E&&t.jsx(ur,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:B})]}),t.jsx(Mt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[_&&t.jsx("button",{type:"button",onClick:()=>y.mutate(e),disabled:y.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:y.isPending?m("正在撤销..."):m("撤销操作")}),t.jsxs("button",{type:"button",onClick:R,disabled:!W||x.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:m(P?"同步更新":"已是最新"),children:[x.isPending?t.jsx(Ke,{size:12,className:"animate-spin"}):t.jsx(hr,{size:12}),t.jsx("span",{children:x.isPending?m("正在同步..."):m("更新")})]}),t.jsxs("button",{type:"button",onClick:M,disabled:!I||w.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:I?m("合并到 {target}",{target:r}):m("提交变更"),children:[w.isPending?t.jsx(Ke,{size:12,className:"animate-spin"}):t.jsx($r,{size:12}),t.jsx("span",{children:w.isPending?m("正在提交..."):m("合并")})]})]})]}),u&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:u})]}),t.jsx(sc,{isOpen:a,onClose:O,branchName:s,targetBranch:r,commitMessage:o,isPending:w.isPending,error:u,onConfirm:L})]})}function h0({agentType:e,workingDir:s}){return Bt({queryKey:de.system.skillCatalog(e,s),queryFn:async()=>(await Ce.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Nt.CODEX,staleTime:3e4})}function f0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function _c({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:g,minHeight:p,maxHeight:v}){const[n,i]=S.useState(0),{data:l=[]}=h0({agentType:e,workingDir:s}),c=S.useMemo(()=>e===Nt.CODEX?to(r):null,[e,r])?.query??null,m=S.useMemo(()=>c===null?[]:yd(l,c),[c,l]),x=S.useCallback(()=>{const a=g.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,v))}px`)},[v,p,g]);S.useEffect(()=>{i(0)},[e,c]),S.useEffect(()=>{n<m.length||i(0)},[m.length,n]);const w=S.useCallback(a=>{const h=to(r);if(!h)return;const u=`${r.slice(0,h.replaceStart)}${a.command} `;o(u),requestAnimationFrame(()=>{const f=g.current;f&&(x(),f.focus(),f.setSelectionRange(u.length,u.length))})},[r,x,o,g]),y=S.useCallback(a=>c===null||m.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%m.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+m.length)%m.length),!0):f0(a)?(a.preventDefault(),w(m[n]??m[0]),!0):!1,[w,m,c,n]);return{allSkills:l,query:c,filteredSkills:m,selectedIndex:n,setSelectedIndex:i,applySkill:w,handleKeyDown:y}}const m0=dr(),p0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${m0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,js=520,Wi=48,g0=4,v0=420;function x0(){const{t:e}=ce();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ra=[{status:be.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ta,{className:"w-3 h-3"})},{status:be.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Aa,{className:"w-3 h-3"})},{status:be.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Ra,{className:"w-3 h-3"})},{status:be.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Na,{className:"w-3 h-3"})},{status:be.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(ja,{className:"w-3 h-3"})}];function _0({status:e,onChangeStatus:s}){const{t:r}=ce(),[o,g]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{if(!o)return;const n=i=>{p.current&&!p.current.contains(i.target)&&g(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=ra.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:p,children:[t.jsxs("button",{onClick:()=>s&&g(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ra.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),g(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function ia({state:e,onRetry:s}){const{t:r}=ce(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function b0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:g,onAutoStartRecovered:p}){const{t:v}=ce(),[n,i]=S.useState(""),[l,d]=S.useState(!1),[c,m]=S.useState(!1),[x,w]=S.useState(!1),[y,a]=S.useState(!1),[h,u]=S.useState(!1),[f,b]=S.useState(!1),[C,k]=S.useState(null),E=S.useRef(null),[_,j]=S.useState(!1),[A,P]=S.useState(null),[T,D]=S.useState(void 0),[W,I]=S.useState(!1),B=S.useRef(null),F=S.useRef(null),R=S.useRef(null),M=S.useRef(null),{scrollRef:L,contentRef:O,isAtBottom:U,scrollToBottom:Y,stopScroll:z}=gn({resize:"smooth",initial:"instant"}),[$,q]=S.useState(!1),[N,H]=S.useState(js),[X,K]=S.useState(!1),ne=S.useRef(0),te=S.useRef(js),he=S.useRef(null),le=S.useCallback((Q,oe,Be)=>{E.current?.openFile(Q,oe,Be)},[]),{data:G,isLoading:pe}=Mn(e?.id??""),ie=s0(e?.id),{data:Ae}=ya(e?.id??""),{data:at}=Sa(Ae?.id??""),Xe=dn(Ae?.id??""),_e=Ae??null,Ie=!!_e,Pe=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,$e=Ae===null&&Pe,Oe=!!(e?.id&&Ae===null),{data:Ve,isLoading:Ze}=wa(e?.id??"",Oe);S.useEffect(()=>{I(!1),P(null),D(void 0)},[e?.id]);const Me=S.useMemo(()=>Cl(G,_e,T),[T,_e,G]);S.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const Re=S.useMemo(()=>G?.find(Q=>Q.id===Me),[Me,G]),ve=Re?.status===At.ACTIVE?Re.id:void 0,Fe=Pe&&kl(Re,_e);S.useEffect(()=>{if(!W||!G)return;G.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&I(!1)},[G,W]);const ge=S.useMemo(()=>{if(W||!G)return null;const Q=mt=>{const wi=mt.createdAt,Vs=mt.endedAt??mt.startedAt??wi;if(!Vs)return 0;const Cs=Date.parse(Vs);return Number.isNaN(Cs)?0:Cs},oe=(mt,wi)=>{const Vs=mt.filter(Cs=>wi.includes(Cs.status));return Vs.length===0?null:Vs.sort((Cs,$c)=>Q($c)-Q(Cs))[0]??null},Be=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=oe(Be,[dt.RUNNING])??oe(Be,[dt.PENDING])??oe(Be,[dt.COMPLETED,dt.FAILED,dt.CANCELLED]);if(ht)return ht;const ft=G.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return oe(ft,[dt.COMPLETED,dt.FAILED,dt.CANCELLED])},[G,W]),lt=ge?.id??"",Je=Ie?A??"":lt,Et=S.useMemo(()=>{if(!A||!G)return null;for(const Q of G){const oe=Q.sessions?.find(Be=>Be.id===A);if(oe)return oe}return null},[A,G]),J=S.useMemo(()=>{if(!A||!_e?.invocations)return null;const Q=_e.invocations.filter(oe=>oe.sessionId===A);return Q.length===0?null:Q.sort((oe,Be)=>{const ht=Date.parse(oe.updatedAt??oe.createdAt??""),ft=Date.parse(Be.updatedAt??Be.createdAt??"");return(Number.isNaN(ft)?0:ft)-(Number.isNaN(ht)?0:ht)})[0]??null},[A,_e?.invocations]),ue=S.useMemo(()=>!J?.memberId||!_e?.members?null:_e.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,_e?.members]),V=A?Et:ge??null,Z=S.useMemo(()=>{if(V?.workspaceId)return V.workspaceId;if(!(!V||!G))return G.find(Q=>Q.sessions?.some(oe=>oe.id===V.id))?.id},[V,G]),re=S.useCallback((Q,oe)=>{const ht=(oe&&G?.some(ft=>ft.id===oe)?oe:void 0)??Z??Me??void 0;ht&&D(ht),E.current?.openPreview(Q,ht)},[Z,Me,G]),ye=S.useCallback(Q=>{re(Q,Z)},[Z,re]),{isActive:me,isCancelling:Se}=Pa(V?.id??"",V?.status),we=!!e?.projectArchivedAt,xe=!!e?.projectRepoDeletedAt,ke=v(xe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:De}=Bs(),[Ee,Ye]=S.useState(null);S.useEffect(()=>{Ye(ge?.providerId??null)},[ge?.providerId]);const Ge=S.useMemo(()=>!ge||!G?!1:!G.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Be=>Be.id===ge.id)),[ge,G]),ze=S.useMemo(()=>{if(!(!G||W)){if(Re)return ss(Re);for(const Q of G)if(Q.status==="ACTIVE"&&ss(Q))return ss(Q);return ss(G[0])}},[W,Re,G]),et=La({agentType:ge?.agentType,workingDir:ze,input:n,setInput:i,textareaRef:R,minHeight:60,maxHeight:300}),it=_c({agentType:ge?.agentType,workingDir:ze,input:n,setInput:i,textareaRef:R,minHeight:60,maxHeight:300}),Dt=_s(Q=>Q.setVisibleContext),vt=!!(Fe&&ve&&ze&&!we),{data:st,isLoading:xt}=Pn(ve??"",{enabled:vt}),{data:Ct}=pi(ze,{enabled:vt});S.useEffect(()=>{if(!($||!vt||!ve||!ze))return Dt({workspaceId:ve,workingDir:ze,tab:"changes"}),()=>{Dt(null)}},[$,ve,Dt,vt,ze]);const bs=Re?.sessions??[],ys=Os(Re),Hs=Re?.commitMessage,ls=S.useMemo(()=>El(Re,G,e?.mainBranch??""),[Re,e?.mainBranch,G]),pt=S.useMemo(()=>st?.conflictOp&&st.conflictedFiles.length>0?{conflictOp:st.conflictOp,conflictedFiles:st.conflictedFiles}:C,[st?.conflictOp,st?.conflictedFiles,C]),$s=pt?.targetWorkspaceId??ve,br=pt?.targetWorktreePath??Re?.worktreePath,yr=pt?.sourceBranch??ys,cs=pt?.targetBranch??ls,nt=bt(),Ut=S.useCallback(async()=>e?.id?nt.fetchQuery({queryKey:de.tasks.body(e.id),queryFn:()=>Ce.get(`/tasks/${e.id}/body`)}):null,[nt,e?.id]),ds=S.useCallback(()=>e?.id?nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,nt]);S.useEffect(()=>{if(!_)return;const Q=oe=>{F.current&&!F.current.contains(oe.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[_]);const Sr=bn(),us=Dn(),wr=nd(),Us=gl(e?.id??""),qs=xn(),qt=rf(),zt=S.useMemo(()=>!G||G.some(oe=>oe.status==="ACTIVE")?null:G.find(oe=>oe.status==="HIBERNATED")??null,[G]),Ks=S.useRef(null);S.useEffect(()=>{zt&&Ks.current!==zt.id&&(qt.isPending||(Ks.current=zt.id,qt.mutate(zt.id,{onSettled:()=>{Ks.current=null}})))},[zt,qt]);const Cr=S.useCallback(async()=>{if(!e?.id)return;const Q=ge?.providerId??De?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),u(!0);try{const Be=(await Ut())?.prompt??e.title;await wr.mutateAsync(e.id),I(!0);const ht=await Us.mutateAsync({workspaceKind:Pe?void 0:_t.MAIN_DIRECTORY}),ft=await Ce.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Be});await qs.mutateAsync(ft.id),await nt.invalidateQueries({queryKey:de.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),I(!1)}finally{u(!1)}}},[e?.id,e?.title,Pe,ge?.providerId,De,Ut,wr,Us,qs,nt]),Ss=S.useCallback(async()=>{e?.id&&(await Ut(),d(!0))},[Ut,e?.id]),Xs=S.useCallback(()=>{Re?.id&&us.mutate({workspaceId:Re.id})},[us,Re?.id]),kr=S.useCallback(()=>{!e?.id||!s||(s(e.id),w(!1))},[e?.id,s]),Er=S.useCallback(Q=>{P(Q),requestAnimationFrame(()=>{Y()})},[Y]),gi=S.useCallback(()=>{P(null)},[]),hs=S.useCallback(Q=>{k(Q??null),b(!0)},[]),vi=S.useCallback(Q=>Xe.mutateAsync(Q),[Xe]),Qt=S.useCallback(()=>{nt.invalidateQueries({queryKey:od.all})},[nt]),{isConnected:Ys,isLoadingSnapshot:jr,isOutputActive:Nr,lastExitAt:Rr,logs:fs,entries:ms,attach:ee}=za({sessionId:Je,sessionStatus:V?.status,sessionStartedAt:V?.startedAt??V?.createdAt,sessionEndedAt:V?.endedAt??(me?null:V?.updatedAt),onExit:S.useCallback(()=>{nt.invalidateQueries({queryKey:["workspaces"]})},[nt])});S.useEffect(()=>{if(!e?.id)return;const Q=Jt.connect();Q.emit(Ns.SUBSCRIBE,{topic:"task",id:e.id});const oe=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:["tasks"]}),Qt())},Be=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Qt())},ht=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Qt())};return Q.on(ct.TASK_UPDATED,oe),Q.on(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.on(ct.WORKSPACE_HIBERNATED,ht),()=>{Q.off(ct.TASK_UPDATED,oe),Q.off(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.off(ct.WORKSPACE_HIBERNATED,ht),Q.emit(Ns.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,nt,Qt]),S.useEffect(()=>{if(!Je)return;const Q=Jt.connect(),oe=Be=>{Be.sessionId===Je&&(nt.invalidateQueries({queryKey:["workspaces"]}),Qt())};return Q.on(ct.SESSION_COMPLETED,oe),()=>{Q.off(ct.SESSION_COMPLETED,oe)}},[Je,nt,Qt]);const{todos:fe}=Wa(ms),{files:Ue,addFiles:Ne,removeFile:St,clear:Pt,buildMarkdownLinks:Le,hasFiles:jt,isUploading:Lt}=un(),ws=S.useMemo(()=>fc(V),[V?.tokenUsage]),Kn=Ia(fs,ws);S.useEffect(()=>{Je&&Ys&&ee()},[Je,Ys,ee]);const Xn=S.useRef(e?.id);S.useEffect(()=>{if(Xn.current!==e?.id&&L.current){const Q=L.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}Xn.current=e?.id},[e?.id,L]);const xi=Oa(),_i=S.useRef(!1),Yn=S.useCallback(async()=>{if(!n.trim()&&!jt||!Je||_i.current||Lt)return;_i.current=!0;const Q=Le(),oe=[n.trim(),Q].filter(Boolean).join(`
|
|
79
80
|
|
|
80
|
-
`);i(""),Dt(),R.current&&(R.current.style.height="60px"),yr.mutate({id:st,message:oe,providerId:De??void 0},{onSuccess:()=>{ee()},onSettled:()=>{xi.current=!1}})},[n,st,yr,ee,Nt,Pt,Ie,Dt,De]),Mc=S.useCallback(async()=>{st&&(await vi.mutateAsync(st),rt.invalidateQueries({queryKey:["workspaces"]}))},[st,vi,rt]),Dc=S.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Ne(Array.from(oe)),Q.target.value=""},[Ne]),Pc=S.useCallback(Q=>{const oe=Q.clipboardData.items,Fe=[];for(const ft of oe)if(ft.kind==="file"){const mt=ft.getAsFile();mt&&Fe.push(mt)}Fe.length>0&&(Q.preventDefault(),Ne(Fe))},[Ne]),[Yn,_i]=S.useState(!1),Lc=S.useCallback(Q=>{Q.preventDefault(),_i(!0)},[]),Ic=S.useCallback(Q=>{Q.preventDefault(),_i(!1)},[]),Oc=S.useCallback(Q=>{Q.preventDefault(),_i(!1);const oe=Q.dataTransfer.files;oe.length>0&&Ne(Array.from(oe))},[Ne]),qt=S.useCallback(Q=>{const oe=fe.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Fe=oe?Math.max(ks,oe-zi-u0-h0):ks;return Math.max(ks,Math.min(Math.round(Q),Fe))},[]),bi=S.useCallback(Q=>{const oe=Q.clientX-ne.current;z(qt(te.current-oe))},[qt]),yi=S.useCallback(()=>{K(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);S.useEffect(()=>{if(X)return document.addEventListener("mousemove",bi),document.addEventListener("mouseup",yi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",bi),document.removeEventListener("mouseup",yi),document.body.style.cursor="",document.body.style.userSelect=""}},[yi,bi,X]);const Bc=S.useCallback(Q=>{Q.preventDefault(),ne.current=Q.clientX,te.current=N,K(!0)},[N]);S.useEffect(()=>{!H||X||z(Q=>qt(Q))},[qt,H,X]),S.useEffect(()=>{if(!H)return;const Q=()=>{z(oe=>qt(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[qt,H]);const Fc=S.useCallback(()=>{z(Q=>qt(Q)),q(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[qt]),zc=S.useCallback(Q=>{i(Q.target.value);const oe=Q.target;oe.style.height="auto";const Fe=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Fe,300))}px`},[]),Vn=_t&&ve?t.jsx(gc,{workspaceId:ve,branchName:_s,targetBranch:os,commitMessage:Ws,changes:bt,gitStatus:at,isGitStatusLoading:lt,canRunGitOperations:ze,onOpenChanges:Fc,onRefreshCommitMessage:ls,onConflict:ds,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(m0,{status:e.status,onChangeStatus:!ue&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Ks,disabled:!je||ue,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(si,{size:16})}),(s||He)&&!ue&&t.jsxs("div",{className:"relative",ref:W,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx($a,{size:16})}),b&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[He&&t.jsxs("button",{onClick:()=>{m(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(es,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(nd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{w(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(_n,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),ze&&ve&&at&&t.jsx(e0,{workspaceId:ve,gitStatus:at,onResolve:()=>ds()}),t.jsxs("div",{ref:fe,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Oe&&be?A?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:A})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(hc,{session:V,providers:Ce,usage:qn,providerIdFallback:he?.providerId,agentTypeFallback:V?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:pi,children:[t.jsx(Ps,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:Er?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):us.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(pe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Fr,{logs:us,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:B,workingDir:je,onOpenWorkspaceFile:ce,onOpenPreviewUrl:we})})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(ir,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),me.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Wr,{todos:me})})})]}):t.jsx(bl,{teamRun:be,messages:nt??be.messages??[],readOnly:ue,readOnlyMessage:_e,onSendMessage:gi,onViewInvocationSession:kr,changeSummaryBar:Vn,centered:!0,workingDir:je,onOpenWorkspaceFile:ce,onOpenPreviewUrl:ie}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Ze||Ye?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Ze?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ye?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(hn,{urlTransform:d0,components:Ea,children:Ye.body})}):null}),re&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[re.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:re.currentIndex,total:re.totalCommands,command:re.currentCommand})})]}),re.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),re.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:re.error})})]}),!ue&&g&&(ge||ot)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ia,{state:g,onRetry:g.status==="failed"?bs:void 0})}):null,ge?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):ot?Er?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):us.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(pe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Fr,{logs:us,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:B,workingDir:je,onOpenWorkspaceFile:ce,onOpenPreviewUrl:we}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Kt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(ue?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:ue?_e:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ue&&g?t.jsx(ia,{state:g}):null,!ue&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Te,{onClick:bs,disabled:!!(g&&g.status!=="failed"),children:[t.jsx(Kt,{size:16,className:"mr-1.5"}),g?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),He&&t.jsxs(Te,{variant:"outline",onClick:()=>m(!0),children:[t.jsx(es,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(ir,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),me.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Wr,{todos:me})})}),ue?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:_e})})}):Ve?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:bs,children:[t.jsx(Kt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Lc,onDragLeave:Ic,onDrop:Oc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Vn,t.jsxs("div",{ref:$,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Yn?"border-info bg-info/5":"border-border"}`,children:[t.jsx(un,{files:$e,onRemove:wt}),t.jsx("textarea",{ref:R,value:n,onChange:zc,onPaste:Pc,onKeyDown:Q=>{tt.handleKeyDown(Q)||Ge.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),Xn())},rows:1,placeholder:v(Yn?"Drop files here...":ot&&!pe?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Dc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>M.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(xn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[xe&&Ce&&t.jsx(Ia,{providers:Ce,currentProviderId:De,agentType:xe.agentType,onSelect:ke}),t.jsx(vn,{usage:qn}),pe&&!n.trim()&&!Nt?t.jsx("button",{onClick:Mc,disabled:vi.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ms,{size:14})}):t.jsx("button",{onClick:Xn,disabled:!n.trim()&&!Nt||Pt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||Nt)&&!Pt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(gn,{size:18})})]})]})]})]}),t.jsx(zr,{open:Ge.query!==null,anchorRef:$,commands:Ge.filteredCommands,selectedIndex:Ge.selectedIndex,query:Ge.query??"",hasCatalog:Ge.allCommands.length>0,onSelect:Ge.applyCommand}),t.jsx(zr,{open:tt.query!==null,anchorRef:$,commands:tt.filteredSkills,selectedIndex:tt.selectedIndex,query:tt.query??"",hasCatalog:tt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:tt.applySkill})]})]})}),H&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Bc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:H?zi+N:zi},children:t.jsx(lc,{sessionId:ot||void 0,workspaceId:Me,workingDir:je,projectId:e.projectId,readOnly:ue,repoDeleted:Le,teamRun:be,teamStatus:be?t.jsx(El,{teamRun:be,workspaces:G,selectedWorkspaceId:Me,onSelectWorkspace:D,onViewInvocationSession:kr}):void 0,workspaces:G,selectedWorkspaceId:Me,onSelectWorkspace:D,variant:"rail",expanded:H,onExpandedChange:Q=>{Q&&z(oe=>qt(oe)),q(Q)},minContentWidth:ks,tabRef:E,gitAvailable:Pe,gitProps:ze&&ve?{branchName:_s,targetBranch:os,commitMessage:Ws,canRunGitOperations:!0,onRefreshCommitMessage:ls,onConflict:ds,onResolveConflicts:()=>ds()}:void 0})})]}),!ue&&t.jsx(dc,{isOpen:l,onClose:()=>d(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ye?.title??e.title,taskDescription:Ye?.body??"",taskPrompt:Ye?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>p?.(e.id)}),He&&!ue&&t.jsx(Jv,{isOpen:c,onClose:()=>m(!1),taskId:e.id}),ze&&Hs&>&&t.jsx(pc,{open:f,onOpenChange:Q=>{y(Q),Q||k(null)},workspaceId:Hs,conflictOp:gt.conflictOp,conflictedFiles:gt.conflictedFiles,sourceBranch:br,targetBranch:as,operation:at?.operation,worktreePath:_r,mergeAborted:gt.mergeAborted,mergeStrategy:gt.mergeStrategy,sourceWorkspaceId:gt.sourceWorkspaceId,targetWorkspaceId:gt.targetWorkspaceId,sourceWorktreePath:gt.sourceWorktreePath,targetWorktreePath:gt.targetWorktreePath,sessions:Bt,currentSessionId:Oe?void 0:ot,teamRunId:be?.id}),t.jsx(fn,{isOpen:_,onClose:()=>a(!1),onConfirm:wr,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Dn,{isOpen:x,onClose:()=>w(!1),onConfirm:Cr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(f0,{})}function Un(e){switch(e){case Wt.TODO:return ye.Pending;case Wt.IN_PROGRESS:return ye.Running;case Wt.IN_REVIEW:return ye.Review;case Wt.DONE:return ye.Done;case Wt.CANCELLED:return ye.Cancelled}}function g0(e){switch(e){case ye.Pending:return Wt.TODO;case ye.Running:return Wt.IN_PROGRESS;case ye.Review:return Wt.IN_REVIEW;case ye.Done:return Wt.DONE;case ye.Cancelled:return Wt.CANCELLED}}function v0(e){switch(e){case js.CLAUDE_CODE:return"Claude Code";case js.GEMINI_CLI:return"Gemini CLI";case js.CURSOR_AGENT:return"Cursor Agent";case js.CODEX:return"Codex"}}const Zr=["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 xc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function x0(e){return{id:e.id,name:e.name,color:e.color||Zr[xc(e.name,Zr.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function _0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===yt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:Un(e.status),agent:e.latestAgentType?v0(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function b0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===yt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Zr[xc(s.name,Zr.length)],title:e.title,status:Un(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const na={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function y0(e){const s=e.split("/");return s[s.length-1]||e}function S0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function w0({workingDir:e,filePath:s,type:r}){const{t:o}=de(),{data:g,isLoading:p,isError:v}=Zl(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
81
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,d)=>{let c="",m="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",m="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",m="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",m="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,m),children:l},d)})})}function
|
|
82
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,d)=>{let c="",m="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",m="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",m="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",m="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,m),children:l},d)})})}function A0({entry:e,workingDir:s,hash:r}){const[o,g]=S.useState(!1),p=aa[e.status]||aa.M,v=N0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:j0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(Ct,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(R0,{workingDir:s,hash:r,filePath:e.path})]})}function T0({commit:e,workingDir:s}){const{t:r}=de(),[o,g]=S.useState(!1),{data:p,isLoading:v}=zn(s,o?e.hash:null),n=p?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(i=>!i),className:se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:se("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:E0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(Ct,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(A0,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function M0({workingDir:e}){const{t:s}=de(),{data:r,isLoading:o,isError:g,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:n}=bn({queryKey:ae.git.log(e||""),queryFn:({pageParam:l=0})=>Se.get("/git/log",{params:{workingDir:e||"",limit:String(Wi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,d)=>l.commits.length<Wi?void 0:d.length*Wi,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Xe,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):g?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ls,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(l=>t.jsx(T0,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const D0=cr(),P0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${D0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function L0({status:e}){const s={[ye.Running]:"bg-blue-500",[ye.Review]:"bg-amber-500",[ye.Pending]:"bg-neutral-400",[ye.Done]:"bg-emerald-500",[ye.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const I0=[{key:"chat",label:"Chat",icon:ei},{key:"changes",label:"Changes",icon:Bs},{key:"history",label:"History",icon:Ls},{key:"workspace",label:"Workspace",icon:ri}],O0=[{key:"chat",label:"Team room",icon:ei},{key:"team-status",label:"Team Status",icon:ps},{key:"changes",label:"Changes",icon:Bs},{key:"workspace",label:"Workspace",icon:ri}];function la({state:e,onRetry:s}){const{t:r}=de(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Kt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function B0({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:g,onAutoStartRecovered:p}){const{t:v}=de(),n=xs(ee=>ee.setVisibleContext),[i,l]=S.useState("chat"),[d,c]=S.useState(""),[m,x]=S.useState(!1),[w,_]=S.useState(!1),[a,h]=S.useState(!1),[u,f]=S.useState(null),[y,C]=S.useState(void 0),k=S.useRef(0),[E,b]=S.useState(),j=S.useRef(null),A=S.useRef(null),L=S.useRef(null),T=S.useRef(null),{scrollRef:D,contentRef:F,isAtBottom:I,scrollToBottom:$,stopScroll:W}=pn({resize:"smooth",initial:"instant"}),R=ht();S.useEffect(()=>{if(!a)return;const ee=me=>{A.current&&!A.current.contains(me.target)&&h(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[a]);const{data:M,isLoading:P}=Rn(e.id),{data:O}=ya(e.id),{data:U}=Sa(O?.id??""),Y=cn(O?.id??""),B=O??null,H=e.isGitRepo!==!1&&e.worktreeReady!==!1,q=S.useMemo(()=>(B?O0:I0).filter(ee=>H||ee.key!=="changes"&&ee.key!=="history"),[H,B]),N=O===null,{data:z,isLoading:X}=wa(e.id,N),K=!!e.projectArchivedAt,ne=!!e.projectRepoDeletedAt,te=v(ne?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");S.useEffect(()=>{C(void 0),f(null),b(void 0)},[e.id]),S.useEffect(()=>{B&&i==="history"&&l("chat"),!B&&i==="team-status"&&l("chat"),q.some(ee=>ee.key===i)||l("chat")},[i,q,B]);const fe=S.useMemo(()=>yl(M,B,y),[y,B,M]);S.useEffect(()=>{y&&!M?.some(ee=>ee.id===y)&&C(void 0)},[y,M]);const ce=S.useMemo(()=>M?.find(ee=>ee.id===fe),[fe,M]),G=S.useMemo(()=>{if(M){if(ce)return ts(ce);for(const ee of M)if(ee.status==="ACTIVE"&&ts(ee))return ts(ee);return ts(M[0])}},[ce,M]),ge=ce?.status===At.ACTIVE?ce.id:void 0,re=H&&Sl(ce,B),Ae=ce?.branchName??"",nt=ce?.commitMessage,Ke=S.useMemo(()=>wl(ce,M,e?.mainBranch??""),[ce,e?.mainBranch,M]),be=!!(re&&ge&&G&&!K),{data:Oe,isLoading:Pe}=Tn(ge??"",{enabled:be}),{data:He}=mi(G,{enabled:be}),Be=He?.committed?.length,[Ye,Ze]=S.useState(!1),[Me,Re]=S.useState(null);S.useEffect(()=>{const ee=H&&(i==="changes"||i==="chat"&&be)?"changes":H&&i==="history"?"history":null;if(!ge||!G||!ee){n(null);return}return n({workspaceId:ge,workingDir:G,tab:ee}),()=>{n(null)}},[i,H,ge,n,be,G]);const ve=S.useMemo(()=>Oe?.conflictOp&&Oe.conflictedFiles.length>0?{conflictOp:Oe.conflictOp,conflictedFiles:Oe.conflictedFiles}:Me,[Oe?.conflictOp,Oe?.conflictedFiles,Me]),ze=ve?.targetWorkspaceId??ge,xe=ve?.targetWorktreePath??ce?.worktreePath,ot=ve?.sourceBranch??Ae,st=ve?.targetBranch??Ke,jt=ce?.sessions??[],J=S.useCallback(ee=>{Re(ee??null),Ze(!0)},[]),he=S.useCallback(()=>e?.id?R.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,R]),V=S.useCallback(async()=>R.fetchQuery({queryKey:ae.tasks.body(e.id),queryFn:()=>Se.get(`/tasks/${e.id}/body`)}),[R,e.id]),Z=S.useMemo(()=>{if(!M)return null;const ee=M.filter(Ie=>Ie.status==="ACTIVE"&&Array.isArray(Ie.sessions)).flatMap(Ie=>Ie.sessions??[]),me=Ie=>{const Nt=Ie.createdAt,Pt=Ie.endedAt??Ie.startedAt??Nt;if(!Pt)return 0;const ys=Date.parse(Pt);return Number.isNaN(ys)?0:ys},$e=Ie=>{const Nt=ee.filter(Pt=>Ie.includes(Pt.status));return Nt.length===0?null:Nt.sort((Pt,ys)=>me(ys)-me(Pt))[0]??null},Ne=$e([et.RUNNING])??$e([et.PENDING])??$e([et.COMPLETED,et.FAILED,et.CANCELLED]);if(Ne)return Ne;const Dt=M.filter(Ie=>(Ie.status==="ABANDONED"||Ie.status==="MERGED"||Ie.status==="HIBERNATED")&&Array.isArray(Ie.sessions)).flatMap(Ie=>Ie.sessions??[]).filter(Ie=>[et.COMPLETED,et.FAILED,et.CANCELLED].includes(Ie.status));return Dt.length===0?null:Dt.sort((Ie,Nt)=>me(Nt)-me(Ie))[0]??null},[M]),ie=Z?.id??"",we=B?u??"":ie,pe=S.useMemo(()=>{if(!u||!M)return null;for(const ee of M){const me=ee.sessions?.find($e=>$e.id===u);if(me)return me}return null},[u,M]),ue=S.useMemo(()=>{if(!u||!B?.invocations)return null;const ee=B.invocations.filter(me=>me.sessionId===u);return ee.length===0?null:ee.sort((me,$e)=>{const Ne=Date.parse(me.updatedAt??me.createdAt??""),wt=Date.parse($e.updatedAt??$e.createdAt??"");return(Number.isNaN(wt)?0:wt)-(Number.isNaN(Ne)?0:Ne)})[0]??null},[u,B?.invocations]),Le=S.useMemo(()=>!ue?.memberId||!B?.members?null:B.members.find(ee=>ee.id===ue.memberId)??null,[ue?.memberId,B?.members]),_e=u?pe:Z??null,Ce=S.useMemo(()=>{if(_e?.workspaceId)return _e.workspaceId;if(!(!_e||!M))return M.find(ee=>ee.sessions?.some(me=>me.id===_e.id))?.id},[_e,M]),De=S.useCallback((ee,me)=>{const Ne=(me&&M?.some(wt=>wt.id===me)?me:void 0)??Ce??fe??void 0;Ne&&C(Ne),k.current+=1,b({id:k.current,url:ee,workspaceId:Ne}),l("workspace")},[Ce,fe,M]),ke=S.useCallback(ee=>{De(ee,Ce)},[Ce,De]),Ve=_e?.status===et.RUNNING||_e?.status===et.PENDING,je=S.useMemo(()=>!Z||!M?!1:!M.some(me=>me.status==="ACTIVE"&&me.sessions?.some($e=>$e.id===Z.id)),[Z,M]),{data:Ge}=Os(),[tt,xt]=S.useState(null),_t=tt?.sessionId===ie?tt.providerId:Z?.providerId??null,at=S.useCallback(ee=>{xt({sessionId:ie,providerId:ee})},[ie]),lt=Pa({agentType:Z?.agentType,workingDir:G,input:d,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),bt=vc({agentType:Z?.agentType,workingDir:G,input:d,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Bt=G&&ce?ce.id:void 0,_s=$n(),Ws=An(),os=cc(),{isConnected:gt,isLoadingSnapshot:Hs,isOutputActive:_r,lastExitAt:br,logs:as,entries:rt,attach:$t}=Oa({sessionId:we,sessionStatus:_e?.status,sessionStartedAt:_e?.startedAt??_e?.createdAt,sessionEndedAt:_e?.endedAt??(Ve?null:_e?.updatedAt),onExit:S.useCallback(()=>{R.invalidateQueries({queryKey:["workspaces"]})},[R])}),{todos:ls}=Ba(rt),{files:yr,addFiles:cs,removeFile:Sr,clear:$s,buildMarkdownLinks:Us,hasFiles:Ut,isUploading:Ft}=dn(),qs=S.useMemo(()=>uc(_e),[_e?.tokenUsage]),wr=La(as,qs);S.useEffect(()=>{we&>&&$t()},[we,gt,$t]);const bs=S.useRef(null);S.useEffect(()=>{if(bs.current!==e.id&&D.current){const ee=D.current;requestAnimationFrame(()=>{ee.scrollTop=ee.scrollHeight})}bs.current=e.id},[e.id,D]);const Ks=S.useRef(!1),Cr=S.useCallback(async()=>{if(!d.trim()&&!Ut||!ie||Ks.current||Ft)return;Ks.current=!0;const ee=Us(),me=[d.trim(),ee].filter(Boolean).join(`
|
|
81
|
+
`);i(""),Pt(),R.current&&(R.current.style.height="60px"),Sr.mutate({id:Je,message:oe,providerId:Ee??void 0},{onSuccess:()=>{ee()},onSettled:()=>{_i.current=!1}})},[n,Je,Sr,ee,jt,Lt,Le,Pt,Ee]),Pc=S.useCallback(async()=>{Je&&(await xi.mutateAsync(Je),nt.invalidateQueries({queryKey:["workspaces"]}))},[Je,xi,nt]),Lc=S.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Ne(Array.from(oe)),Q.target.value=""},[Ne]),Ic=S.useCallback(Q=>{const oe=Q.clipboardData.items,Be=[];for(const ht of oe)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Be.push(ft)}Be.length>0&&(Q.preventDefault(),Ne(Be))},[Ne]),[Vn,bi]=S.useState(!1),Oc=S.useCallback(Q=>{Q.preventDefault(),bi(!0)},[]),Bc=S.useCallback(Q=>{Q.preventDefault(),bi(!1)},[]),Fc=S.useCallback(Q=>{Q.preventDefault(),bi(!1);const oe=Q.dataTransfer.files;oe.length>0&&Ne(Array.from(oe))},[Ne]),Kt=S.useCallback(Q=>{const oe=he.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Be=oe?Math.max(js,oe-Wi-g0-v0):js;return Math.max(js,Math.min(Math.round(Q),Be))},[]),yi=S.useCallback(Q=>{const oe=Q.clientX-ne.current;H(Kt(te.current-oe))},[Kt]),Si=S.useCallback(()=>{K(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);S.useEffect(()=>{if(X)return document.addEventListener("mousemove",yi),document.addEventListener("mouseup",Si),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",yi),document.removeEventListener("mouseup",Si),document.body.style.cursor="",document.body.style.userSelect=""}},[Si,yi,X]);const zc=S.useCallback(Q=>{Q.preventDefault(),ne.current=Q.clientX,te.current=N,K(!0)},[N]);S.useEffect(()=>{!$||X||H(Q=>Kt(Q))},[Kt,$,X]),S.useEffect(()=>{if(!$)return;const Q=()=>{H(oe=>Kt(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Kt,$]);const Wc=S.useCallback(()=>{H(Q=>Kt(Q)),q(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Kt]),Hc=S.useCallback(Q=>{i(Q.target.value);const oe=Q.target;oe.style.height="auto";const Be=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Be,300))}px`},[]),Gn=vt&&ve?t.jsx(xc,{workspaceId:ve,branchName:ys,targetBranch:ls,commitMessage:Hs,changes:Ct,gitStatus:st,isGitStatusLoading:xt,canRunGitOperations:Fe,onOpenChanges:Wc,onRefreshCommitMessage:ds,onConflict:hs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(_0,{status:e.status,onChangeStatus:!we&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Xs,disabled:!ze||we,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(ri,{size:16})}),(s||$e)&&!we&&t.jsxs("div",{className:"relative",ref:F,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(Ka,{size:16})}),_&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[$e&&t.jsxs("button",{onClick:()=>{m(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ts,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ad,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{w(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Sn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),Fe&&ve&&st&&t.jsx(n0,{workspaceId:ve,gitStatus:st,onResolve:()=>hs()}),t.jsxs("div",{ref:he,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ie&&_e?A?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:A})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(mc,{session:V,providers:De,usage:Kn,providerIdFallback:ue?.providerId,agentTypeFallback:V?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:gi,children:[t.jsx(Ls,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:jr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):fs.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(me?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(zr,{logs:fs,isOutputActive:Nr,lastExitAt:Rr,onUserToggleDetails:z,workingDir:ze,onOpenWorkspaceFile:le,onOpenPreviewUrl:ye})})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(nr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),fe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Hr,{todos:fe})})})]}):t.jsx(wl,{teamRun:_e,messages:at??_e.messages??[],readOnly:we,readOnlyMessage:ke,onSendMessage:vi,onViewInvocationSession:Er,changeSummaryBar:Gn,centered:!0,workingDir:ze,onOpenWorkspaceFile:le,onOpenPreviewUrl:re}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Ze||Ve?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Ze?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ve?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(fn,{urlTransform:p0,components:Ea,children:Ve.body})}):null}),ie&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[ie.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:ie.currentIndex,total:ie.totalCommands,command:ie.currentCommand})})]}),ie.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),ie.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:ie.error})})]}),!we&&g&&(pe||lt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ia,{state:g,onRetry:g.status==="failed"?Ss:void 0})}):null,pe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):lt?jr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):fs.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(me?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(zr,{logs:fs,isOutputActive:Nr,lastExitAt:Rr,onUserToggleDetails:z,workingDir:ze,onOpenWorkspaceFile:le,onOpenPreviewUrl:ye}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Xt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(we?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:we?ke:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!we&&g?t.jsx(ia,{state:g}):null,!we&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Te,{onClick:Ss,disabled:!!(g&&g.status!=="failed"),children:[t.jsx(Xt,{size:16,className:"mr-1.5"}),g?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),$e&&t.jsxs(Te,{variant:"outline",onClick:()=>m(!0),children:[t.jsx(ts,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(nr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),fe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Hr,{todos:fe})})}),we?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:ke})})}):Ge?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:Ss,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Oc,onDragLeave:Bc,onDrop:Fc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Gn,Je?t.jsx(Ba,{sessionId:Je}):null,t.jsxs("div",{ref:B,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Vn?"border-info bg-info/5":"border-border"}`,children:[t.jsx(hn,{files:Ue,onRemove:St}),t.jsx("textarea",{ref:R,value:n,onChange:Hc,onPaste:Ic,onKeyDown:Q=>{it.handleKeyDown(Q)||et.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),Yn())},rows:1,placeholder:v(Vn?"Drop files here...":lt&&!me?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Lc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>M.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(yn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[ge&&De&&t.jsx(Fa,{providers:De,currentProviderId:Ee,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Ye}),t.jsx(_n,{usage:Kn}),me&&!n.trim()&&!jt?t.jsx("button",{onClick:Pc,disabled:xi.isPending||Se,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ds,{size:14})}):t.jsx("button",{onClick:Yn,disabled:!n.trim()&&!jt||Lt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||jt)&&!Lt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(vn,{size:18})})]})]})]})]}),t.jsx(Wr,{open:et.query!==null,anchorRef:B,commands:et.filteredCommands,selectedIndex:et.selectedIndex,query:et.query??"",hasCatalog:et.allCommands.length>0,onSelect:et.applyCommand}),t.jsx(Wr,{open:it.query!==null,anchorRef:B,commands:it.filteredSkills,selectedIndex:it.selectedIndex,query:it.query??"",hasCatalog:it.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:it.applySkill})]})]})}),$&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:zc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:$?Wi+N:Wi},children:t.jsx(uc,{sessionId:lt||void 0,workspaceId:Me,workingDir:ze,projectId:e.projectId,readOnly:we,repoDeleted:xe,teamRun:_e,teamStatus:_e?t.jsx(Rl,{teamRun:_e,workspaces:G,selectedWorkspaceId:Me,onSelectWorkspace:D,onViewInvocationSession:Er}):void 0,workspaces:G,selectedWorkspaceId:Me,onSelectWorkspace:D,variant:"rail",expanded:$,onExpandedChange:Q=>{Q&&H(oe=>Kt(oe)),q(Q)},minContentWidth:js,tabRef:E,gitAvailable:Pe,gitProps:Fe&&ve?{branchName:ys,targetBranch:ls,commitMessage:Hs,canRunGitOperations:!0,onRefreshCommitMessage:ds,onConflict:hs,onResolveConflicts:()=>hs()}:void 0})})]}),!we&&t.jsx(hc,{isOpen:l,onClose:()=>d(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ve?.title??e.title,taskDescription:Ve?.body??"",taskPrompt:Ve?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>p?.(e.id)}),$e&&!we&&t.jsx(i0,{isOpen:c,onClose:()=>m(!1),taskId:e.id}),Fe&&$s&&pt&&t.jsx(vc,{open:f,onOpenChange:Q=>{b(Q),Q||k(null)},workspaceId:$s,conflictOp:pt.conflictOp,conflictedFiles:pt.conflictedFiles,sourceBranch:yr,targetBranch:cs,operation:st?.operation,worktreePath:br,mergeAborted:pt.mergeAborted,mergeStrategy:pt.mergeStrategy,sourceWorkspaceId:pt.sourceWorkspaceId,targetWorkspaceId:pt.targetWorkspaceId,sourceWorktreePath:pt.sourceWorktreePath,targetWorktreePath:pt.targetWorktreePath,sessions:bs,currentSessionId:Ie?void 0:lt,teamRunId:_e?.id}),t.jsx(mn,{isOpen:y,onClose:()=>a(!1),onConfirm:Cr,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(In,{isOpen:x,onClose:()=>w(!1),onConfirm:kr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(x0,{})}function qn(e){switch(e){case Ht.TODO:return be.Pending;case Ht.IN_PROGRESS:return be.Running;case Ht.IN_REVIEW:return be.Review;case Ht.DONE:return be.Done;case Ht.CANCELLED:return be.Cancelled}}function y0(e){switch(e){case be.Pending:return Ht.TODO;case be.Running:return Ht.IN_PROGRESS;case be.Review:return Ht.IN_REVIEW;case be.Done:return Ht.DONE;case be.Cancelled:return Ht.CANCELLED}}function S0(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex";case Nt.QWEN_CODE:return"Qwen Code";case Nt.KIRO_CLI:return"Kiro CLI";case Nt.OPENCODE:return"OpenCode";case Nt.PI_CODING_AGENT:return"Pi Coding Agent";case Nt.GROK_BUILD:return"Grok Build";case Nt.MINION_CODE:return"Minion Code"}}const Jr=["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 bc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function w0(e){return{id:e.id,name:e.name,color:e.color||Jr[bc(e.name,Jr.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function C0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:qn(e.status),agent:e.latestAgentType?S0(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function k0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Jr[bc(s.name,Jr.length)],title:e.title,status:qn(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const na={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function E0(e){const s=e.split("/");return s[s.length-1]||e}function j0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function N0({workingDir:e,filePath:s,type:r}){const{t:o}=ce(),{data:g,isLoading:p,isError:v}=tc(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
82
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,d)=>{let c="",m="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",m="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",m="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",m="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,m),children:l},d)})})}function R0({entry:e,type:s,workingDir:r}){const[o,g]=S.useState(!1),p=na[e.status]||na.M,v=j0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:E0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(N0,{workingDir:r,filePath:e.path,type:s})]})}function oa({title:e,entries:s,type:r,workingDir:o,defaultOpen:g}){const{t:p}=ce(),[v,n]=S.useState(g);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(R0,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function A0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:g}=pi(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(g)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const p=r?.uncommitted||[],v=r?.committed||[];return p.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Fs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(oa,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(oa,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Hi=50,aa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function T0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function M0(e){const s=e.split("/");return s[s.length-1]||e}function D0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function P0({workingDir:e,hash:s,filePath:r}){const{t:o}=ce(),{data:g,isLoading:p,isError:v}=Un(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
83
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,d)=>{let c="",m="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",m="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",m="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",m="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,m),children:l},d)})})}function L0({entry:e,workingDir:s,hash:r}){const[o,g]=S.useState(!1),p=aa[e.status]||aa.M,v=D0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:M0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(P0,{workingDir:s,hash:r,filePath:e.path})]})}function I0({commit:e,workingDir:s}){const{t:r}=ce(),[o,g]=S.useState(!1),{data:p,isLoading:v}=$n(s,o?e.hash:null),n=p?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(i=>!i),className:se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:se("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:T0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(L0,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function O0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:g,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:n}=wn({queryKey:de.git.log(e||""),queryFn:({pageParam:l=0})=>Ce.get("/git/log",{params:{workingDir:e||"",limit:String(Hi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,d)=>l.commits.length<Hi?void 0:d.length*Hi,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):g?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Is,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(l=>t.jsx(I0,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const B0=dr(),F0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${B0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function z0({status:e}){const s={[be.Running]:"bg-blue-500",[be.Review]:"bg-amber-500",[be.Pending]:"bg-neutral-400",[be.Done]:"bg-emerald-500",[be.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const W0=[{key:"chat",label:"Chat",icon:ti},{key:"changes",label:"Changes",icon:Fs},{key:"history",label:"History",icon:Is},{key:"workspace",label:"Workspace",icon:ii}],H0=[{key:"chat",label:"Team room",icon:ti},{key:"team-status",label:"Team Status",icon:vs},{key:"changes",label:"Changes",icon:Fs},{key:"workspace",label:"Workspace",icon:ii}];function la({state:e,onRetry:s}){const{t:r}=ce(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function $0({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:g,onAutoStartRecovered:p}){const{t:v}=ce(),n=_s(ee=>ee.setVisibleContext),[i,l]=S.useState("chat"),[d,c]=S.useState(""),[m,x]=S.useState(!1),[w,y]=S.useState(!1),[a,h]=S.useState(!1),[u,f]=S.useState(null),[b,C]=S.useState(void 0),k=S.useRef(0),[E,_]=S.useState(),j=S.useRef(null),A=S.useRef(null),P=S.useRef(null),T=S.useRef(null),{scrollRef:D,contentRef:W,isAtBottom:I,scrollToBottom:B,stopScroll:F}=gn({resize:"smooth",initial:"instant"}),R=bt();S.useEffect(()=>{if(!a)return;const ee=fe=>{A.current&&!A.current.contains(fe.target)&&h(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[a]);const{data:M,isLoading:L}=Mn(e.id),{data:O}=ya(e.id),{data:U}=Sa(O?.id??""),Y=dn(O?.id??""),z=O??null,$=e.isGitRepo!==!1&&e.worktreeReady!==!1,q=S.useMemo(()=>(z?H0:W0).filter(ee=>$||ee.key!=="changes"&&ee.key!=="history"),[$,z]),N=O===null,{data:H,isLoading:X}=wa(e.id,N),K=!!e.projectArchivedAt,ne=!!e.projectRepoDeletedAt,te=v(ne?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");S.useEffect(()=>{C(void 0),f(null),_(void 0)},[e.id]),S.useEffect(()=>{z&&i==="history"&&l("chat"),!z&&i==="team-status"&&l("chat"),q.some(ee=>ee.key===i)||l("chat")},[i,q,z]);const he=S.useMemo(()=>Cl(M,z,b),[b,z,M]);S.useEffect(()=>{b&&!M?.some(ee=>ee.id===b)&&C(void 0)},[b,M]);const le=S.useMemo(()=>M?.find(ee=>ee.id===he),[he,M]),G=S.useMemo(()=>{if(M){if(le)return ss(le);for(const ee of M)if(ee.status==="ACTIVE"&&ss(ee))return ss(ee);return ss(M[0])}},[le,M]),pe=le?.status===At.ACTIVE?le.id:void 0,ie=$&&kl(le,z),Ae=le?.branchName??"",at=le?.commitMessage,Xe=S.useMemo(()=>El(le,M,e?.mainBranch??""),[le,e?.mainBranch,M]),_e=!!(ie&&pe&&G&&!K),{data:Ie,isLoading:Pe}=Pn(pe??"",{enabled:_e}),{data:$e}=pi(G,{enabled:_e}),Oe=$e?.committed?.length,[Ve,Ze]=S.useState(!1),[Me,Re]=S.useState(null);S.useEffect(()=>{const ee=$&&(i==="changes"||i==="chat"&&_e)?"changes":$&&i==="history"?"history":null;if(!pe||!G||!ee){n(null);return}return n({workspaceId:pe,workingDir:G,tab:ee}),()=>{n(null)}},[i,$,pe,n,_e,G]);const ve=S.useMemo(()=>Ie?.conflictOp&&Ie.conflictedFiles.length>0?{conflictOp:Ie.conflictOp,conflictedFiles:Ie.conflictedFiles}:Me,[Ie?.conflictOp,Ie?.conflictedFiles,Me]),Fe=ve?.targetWorkspaceId??pe,ge=ve?.targetWorktreePath??le?.worktreePath,lt=ve?.sourceBranch??Ae,Je=ve?.targetBranch??Xe,Et=le?.sessions??[],J=S.useCallback(ee=>{Re(ee??null),Ze(!0)},[]),ue=S.useCallback(()=>e?.id?R.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,R]),V=S.useCallback(async()=>R.fetchQuery({queryKey:de.tasks.body(e.id),queryFn:()=>Ce.get(`/tasks/${e.id}/body`)}),[R,e.id]),Z=S.useMemo(()=>{if(!M)return null;const ee=M.filter(Le=>Le.status==="ACTIVE"&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]),fe=Le=>{const jt=Le.createdAt,Lt=Le.endedAt??Le.startedAt??jt;if(!Lt)return 0;const ws=Date.parse(Lt);return Number.isNaN(ws)?0:ws},Ue=Le=>{const jt=ee.filter(Lt=>Le.includes(Lt.status));return jt.length===0?null:jt.sort((Lt,ws)=>fe(ws)-fe(Lt))[0]??null},Ne=Ue([dt.RUNNING])??Ue([dt.PENDING])??Ue([dt.COMPLETED,dt.FAILED,dt.CANCELLED]);if(Ne)return Ne;const Pt=M.filter(Le=>(Le.status==="ABANDONED"||Le.status==="MERGED"||Le.status==="HIBERNATED")&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]).filter(Le=>[dt.COMPLETED,dt.FAILED,dt.CANCELLED].includes(Le.status));return Pt.length===0?null:Pt.sort((Le,jt)=>fe(jt)-fe(Le))[0]??null},[M]),re=Z?.id??"",ye=z?u??"":re,me=S.useMemo(()=>{if(!u||!M)return null;for(const ee of M){const fe=ee.sessions?.find(Ue=>Ue.id===u);if(fe)return fe}return null},[u,M]),Se=S.useMemo(()=>{if(!u||!z?.invocations)return null;const ee=z.invocations.filter(fe=>fe.sessionId===u);return ee.length===0?null:ee.sort((fe,Ue)=>{const Ne=Date.parse(fe.updatedAt??fe.createdAt??""),St=Date.parse(Ue.updatedAt??Ue.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Ne)?0:Ne)})[0]??null},[u,z?.invocations]),we=S.useMemo(()=>!Se?.memberId||!z?.members?null:z.members.find(ee=>ee.id===Se.memberId)??null,[Se?.memberId,z?.members]),xe=u?me:Z??null,ke=S.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!M))return M.find(ee=>ee.sessions?.some(fe=>fe.id===xe.id))?.id},[xe,M]),De=S.useCallback((ee,fe)=>{const Ne=(fe&&M?.some(St=>St.id===fe)?fe:void 0)??ke??he??void 0;Ne&&C(Ne),k.current+=1,_({id:k.current,url:ee,workspaceId:Ne}),l("workspace")},[ke,he,M]),Ee=S.useCallback(ee=>{De(ee,ke)},[ke,De]),{isActive:Ye,isCancelling:Ge}=Pa(xe?.id??"",xe?.status),ze=S.useMemo(()=>!Z||!M?!1:!M.some(fe=>fe.status==="ACTIVE"&&fe.sessions?.some(Ue=>Ue.id===Z.id)),[Z,M]),{data:et}=Bs(),[it,Dt]=S.useState(null),vt=it?.sessionId===re?it.providerId:Z?.providerId??null,st=S.useCallback(ee=>{Dt({sessionId:re,providerId:ee})},[re]),xt=La({agentType:Z?.agentType,workingDir:G,input:d,setInput:c,textareaRef:P,minHeight:40,maxHeight:140}),Ct=_c({agentType:Z?.agentType,workingDir:G,input:d,setInput:c,textareaRef:P,minHeight:40,maxHeight:140}),bs=G&&le?le.id:void 0,ys=bn(),Hs=Dn(),ls=Oa(),{isConnected:pt,isLoadingSnapshot:$s,isOutputActive:br,lastExitAt:yr,logs:cs,entries:nt,attach:Ut}=za({sessionId:ye,sessionStatus:xe?.status,sessionStartedAt:xe?.startedAt??xe?.createdAt,sessionEndedAt:xe?.endedAt??(Ye?null:xe?.updatedAt),onExit:S.useCallback(()=>{R.invalidateQueries({queryKey:["workspaces"]})},[R])}),{todos:ds}=Wa(nt),{files:Sr,addFiles:us,removeFile:wr,clear:Us,buildMarkdownLinks:qs,hasFiles:qt,isUploading:zt}=un(),Ks=S.useMemo(()=>fc(xe),[xe?.tokenUsage]),Cr=Ia(cs,Ks);S.useEffect(()=>{ye&&pt&&Ut()},[ye,pt,Ut]);const Ss=S.useRef(null);S.useEffect(()=>{if(Ss.current!==e.id&&D.current){const ee=D.current;requestAnimationFrame(()=>{ee.scrollTop=ee.scrollHeight})}Ss.current=e.id},[e.id,D]);const Xs=S.useRef(!1),kr=S.useCallback(async()=>{if(!d.trim()&&!qt||!re||Xs.current||zt)return;Xs.current=!0;const ee=qs(),fe=[d.trim(),ee].filter(Boolean).join(`
|
|
83
84
|
|
|
84
|
-
`);c(""),$s(),L.current&&(L.current.style.height="40px"),_s.mutate({id:ie,message:me,providerId:_t??void 0},{onSuccess:()=>$t(),onSettled:()=>{Ks.current=!1}})},[d,ie,_s,$t,Ut,Ft,Us,$s,_t]),kr=S.useCallback(async()=>{ie&&(await os.mutateAsync(ie),R.invalidateQueries({queryKey:["workspaces"]}))},[ie,os,R]),pi=S.useCallback(ee=>Y.mutateAsync(ee),[Y]),ds=S.useCallback(ee=>{f(ee),l("chat"),requestAnimationFrame(()=>{$()})},[$]),gi=S.useCallback(()=>{f(null)},[]),Gt=S.useCallback(()=>{l("changes")},[]),Xs=be&&ge?t.jsx(gc,{workspaceId:ge,branchName:Ae,targetBranch:Ke,commitMessage:nt,changes:He,gitStatus:Oe,isGitStatusLoading:Pe,canRunGitOperations:re,onOpenChanges:Gt,onRefreshCommitMessage:he,onConflict:J,className:"mb-2"}):null,Er=S.useCallback(ee=>{const me=ee.target.files;me&&me.length>0&&cs(Array.from(me)),ee.target.value=""},[cs]),jr=S.useCallback(ee=>{const me=ee.clipboardData.items,$e=[];for(const Ne of me)if(Ne.kind==="file"){const wt=Ne.getAsFile();wt&&$e.push(wt)}$e.length>0&&(ee.preventDefault(),cs($e))},[cs]),Nr=S.useCallback(ee=>{c(ee.target.value);const me=ee.target;me.style.height="auto",me.style.height=`${Math.max(40,Math.min(me.scrollHeight,140))}px`},[]),us=S.useCallback(()=>{Bt&&Ws.mutate({workspaceId:Bt})},[Ws,Bt]),hs=S.useRef(null);return S.useEffect(()=>{const ee=window.visualViewport;if(!ee)return;let me=!1;const $e=()=>{hs.current&&(hs.current.style.height=`${ee.height}px`,hs.current.style.top=`${ee.offsetTop}px`)},Ne=()=>$e(),wt=()=>{me||$e()},Dt=()=>{me=!0},Ie=()=>{me=!1,requestAnimationFrame($e)};return ee.addEventListener("resize",Ne),ee.addEventListener("scroll",wt),document.addEventListener("touchstart",Dt,{passive:!0}),document.addEventListener("touchend",Ie,{passive:!0}),document.addEventListener("touchcancel",Ie,{passive:!0}),()=>{ee.removeEventListener("resize",Ne),ee.removeEventListener("scroll",wt),document.removeEventListener("touchstart",Dt),document.removeEventListener("touchend",Ie),document.removeEventListener("touchcancel",Ie)}},[]),S.useEffect(()=>{const ee=hs.current;if(!ee)return;const me=$e=>{let Ne=$e.target;for(;Ne&&Ne!==ee;){if(Ne.tagName==="TEXTAREA"){if(Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement;continue}const Dt=window.getComputedStyle(Ne).overflowY;if((Dt==="auto"||Dt==="scroll")&&Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement}$e.preventDefault()};return ee.addEventListener("touchmove",me,{passive:!1}),()=>ee.removeEventListener("touchmove",me)},[]),t.jsxs("div",{ref:hs,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Ps,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(L0,{status:e.status}),t.jsx("button",{onClick:us,disabled:!Bt||K,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(si,{size:16})}),r&&!K&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsx("button",{onClick:()=>h(ee=>!ee),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx($a,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{_(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(_n,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:q.map(({key:ee,label:me,icon:$e})=>t.jsxs("button",{onClick:()=>l(ee),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===ee?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx($e,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(me)})]},ee))})]}),i==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:u?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:u})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(hc,{session:_e,providers:Ge,usage:wr,compact:!0,providerIdFallback:Le?.providerId,agentTypeFallback:_e?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:gi,children:[t.jsx(Ps,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:F,children:Hs?t.jsx(Hi,{label:v("Loading logs...")}):as.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(Ve?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Fr,{logs:as,isOutputActive:_r,lastExitAt:br,onUserToggleDetails:W,onOpenPreviewUrl:ke})})}),!I&&t.jsxs("button",{onClick:()=>$(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(ir,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ls.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Wr,{todos:ls,compact:!0})})]}):t.jsx(bl,{teamRun:B,messages:U??B.messages??[],readOnly:K,readOnlyMessage:te,onSendMessage:pi,onViewInvocationSession:ds,changeSummaryBar:Xs,compactComposer:!0,workingDir:G,onOpenPreviewUrl:De})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:F,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):z?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(hn,{urlTransform:P0,components:Ea,children:z.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!K&&g&&(P||ie)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(la,{state:g,onRetry:g.status==="failed"?async()=>{await V(),x(!0)}:void 0})}):null,P?t.jsx(Hi,{label:"Loading..."}):ie?Hs?t.jsx(Hi,{label:"Loading logs..."}):as.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:Ve?"Waiting for agent output...":"No logs recorded."}):t.jsx(Fr,{logs:as,isOutputActive:_r,lastExitAt:br,onUserToggleDetails:W,onOpenPreviewUrl:ke}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Kt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:K?te:v("选择一个 Agent 来执行此任务")}),!K&&g?t.jsx(la,{state:g}):null,!K&&t.jsxs(Te,{onClick:async()=>{await V(),x(!0)},disabled:!!(g&&g.status!=="failed"),children:[t.jsx(Kt,{size:16,className:"mr-1.5"}),g?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>$(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(ir,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ls.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Wr,{todos:ls,compact:!0})}),K?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:te})}):je?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:async()=>{await V(),x(!0)},children:[t.jsx(Kt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):ie&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[Xs,t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(un,{files:yr,onRemove:Sr}),t.jsx("textarea",{ref:L,value:d,onChange:Nr,onPaste:jr,onKeyDown:ee=>{bt.handleKeyDown(ee)||lt.handleKeyDown(ee)||ee.key==="Enter"&&!ee.shiftKey&&!ee.repeat&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),Cr())},rows:1,placeholder:Ve?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Er}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(xn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Z&&Ge&&t.jsx(Ia,{providers:Ge,currentProviderId:_t,agentType:Z.agentType,onSelect:at}),t.jsx(vn,{usage:wr}),Ve&&!d.trim()&&!Ut?t.jsx("button",{onClick:kr,disabled:os.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ms,{size:12})}):t.jsx("button",{onClick:Cr,disabled:!d.trim()&&!Ut||Ft,className:`p-1.5 rounded-lg transition-colors ${(d.trim()||Ut)&&!Ft?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(gn,{size:15})})]})]})]}),t.jsx(zr,{open:lt.query!==null,anchorRef:j,commands:lt.filteredCommands,selectedIndex:lt.selectedIndex,query:lt.query??"",hasCatalog:lt.allCommands.length>0,compact:!0,onSelect:lt.applyCommand}),t.jsx(zr,{open:bt.query!==null,anchorRef:j,commands:bt.filteredSkills,selectedIndex:bt.selectedIndex,query:bt.query??"",hasCatalog:bt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:bt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(El,{teamRun:B,workspaces:M,selectedWorkspaceId:fe,onSelectWorkspace:C,onViewInvocationSession:ds})}),i==="changes"&&H&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[M&&M.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(ac,{workspaces:M,teamRun:B,selectedWorkspaceId:fe,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),re&&ge&&t.jsx("div",{className:"shrink-0",children:t.jsx(tc,{workspaceId:ge,branchName:Ae,targetBranch:Ke,commitMessage:nt,committedFileCount:Be,onRefreshCommitMessage:he,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(k0,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(M0,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(lc,{sessionId:ie||void 0,workspaceId:fe,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:H,readOnly:K,repoDeleted:ne,previewRequest:E,onPreviewRequestHandled:ee=>{b(me=>me?.id===ee?void 0:me)}})}),!K&&t.jsx(dc,{isOpen:m,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:z?.title??e.title,taskDescription:z?.body??"",taskPrompt:z?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>p?.(e.id)}),t.jsx(Dn,{isOpen:w,onClose:()=>_(!1),onConfirm:()=>{r?.(e.id),_(!1)},taskId:e.id,taskTitle:e.title,workspaces:M,isLoading:o}),Ye&&ve&&ze&&t.jsx(pc,{open:Ye,onOpenChange:ee=>{Ze(ee),ee||Re(null)},workspaceId:ze,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:ot,targetBranch:st,operation:Oe?.operation,worktreePath:xe,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:jt,currentSessionId:B?void 0:ie,teamRunId:B?.id})]})}function Hi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var F0=Object.defineProperty,Jr=Object.getOwnPropertySymbols,_c=Object.prototype.hasOwnProperty,bc=Object.prototype.propertyIsEnumerable,ca=(e,s,r)=>s in e?F0(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,nn=(e,s)=>{for(var r in s||(s={}))_c.call(s,r)&&ca(e,r,s[r]);if(Jr)for(var r of Jr(s))bc.call(s,r)&&ca(e,r,s[r]);return e},on=(e,s)=>{var r={};for(var o in e)_c.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Jr)for(var o of Jr(e))s.indexOf(o)<0&&bc.call(e,o)&&(r[o]=e[o]);return r};var vs;(e=>{const s=class Ee{constructor(i,l,d,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<Ee.MIN_VERSION||i>Ee.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let m=[];for(let w=0;w<this.size;w++)m.push(!1);for(let w=0;w<this.size;w++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(d);if(this.drawCodewords(x),c==-1){let w=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const a=this.getPenaltyScore();a<w&&(c=_,w=a),this.applyMask(_)}}g(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const d=e.QrSegment.makeSegments(i);return Ee.encodeSegments(d,l)}static encodeBinary(i,l){const d=e.QrSegment.makeBytes(i);return Ee.encodeSegments([d],l)}static encodeSegments(i,l,d=1,c=40,m=-1,x=!0){if(!(Ee.MIN_VERSION<=d&&d<=c&&c<=Ee.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let w,_;for(w=d;;w++){const f=Ee.getNumDataCodewords(w,l)*8,y=v.getTotalBits(i,w);if(y<=f){_=y;break}if(w>=c)throw new RangeError("Data too long")}for(const f of[Ee.Ecc.MEDIUM,Ee.Ecc.QUARTILE,Ee.Ecc.HIGH])x&&_<=Ee.getNumDataCodewords(w,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(w),a);for(const y of f.getData())a.push(y)}g(a.length==_);const h=Ee.getNumDataCodewords(w,l)*8;g(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),g(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let u=[];for(;u.length*8<a.length;)u.push(0);return a.forEach((f,y)=>u[y>>>3]|=f<<7-(y&7)),new Ee(w,l,u,m)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let d=0;d<l;d++)for(let c=0;c<l;c++)d==0&&c==0||d==0&&c==l-1||d==l-1&&c==0||this.drawAlignmentPattern(i[d],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let d=l;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const c=(l<<10|d)^21522;g(c>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,o(c,m));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,o(c,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,o(c,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,o(c,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;g(l>>>18==0);for(let d=0;d<18;d++){const c=o(l,d),m=this.size-11+d%3,x=Math.floor(d/3);this.setFunctionModule(m,x,c),this.setFunctionModule(x,m,c)}}drawFinderPattern(i,l){for(let d=-4;d<=4;d++)for(let c=-4;c<=4;c++){const m=Math.max(Math.abs(c),Math.abs(d)),x=i+c,w=l+d;0<=x&&x<this.size&&0<=w&&w<this.size&&this.setFunctionModule(x,w,m!=2&&m!=4)}}drawAlignmentPattern(i,l){for(let d=-2;d<=2;d++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+d,Math.max(Math.abs(c),Math.abs(d))!=1)}setFunctionModule(i,l,d){this.modules[l][i]=d,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,d=this.errorCorrectionLevel;if(i.length!=Ee.getNumDataCodewords(l,d))throw new RangeError("Invalid argument");const c=Ee.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][l],m=Ee.ECC_CODEWORDS_PER_BLOCK[d.ordinal][l],x=Math.floor(Ee.getNumRawDataModules(l)/8),w=c-x%c,_=Math.floor(x/c);let a=[];const h=Ee.reedSolomonComputeDivisor(m);for(let f=0,y=0;f<c;f++){let C=i.slice(y,y+_-m+(f<w?0:1));y+=C.length;const k=Ee.reedSolomonComputeRemainder(C,h);f<w&&C.push(0),a.push(C.concat(k))}let u=[];for(let f=0;f<a[0].length;f++)a.forEach((y,C)=>{(f!=_-m||C>=w)&&u.push(y[f])});return g(u.length==x),u}drawCodewords(i){if(i.length!=Math.floor(Ee.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let c=0;c<this.size;c++)for(let m=0;m<2;m++){const x=d-m,_=(d+1&2)==0?this.size-1-c:c;!this.isFunction[_][x]&&l<i.length*8&&(this.modules[_][x]=o(i[l>>>3],7-(l&7)),l++)}}g(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let d=0;d<this.size;d++){let c;switch(i){case 0:c=(d+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=d%3==0;break;case 3:c=(d+l)%3==0;break;case 4:c=(Math.floor(d/3)+Math.floor(l/2))%2==0;break;case 5:c=d*l%2+d*l%3==0;break;case 6:c=(d*l%2+d*l%3)%2==0;break;case 7:c=((d+l)%2+d*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][d]&&c&&(this.modules[l][d]=!this.modules[l][d])}}getPenaltyScore(){let i=0;for(let m=0;m<this.size;m++){let x=!1,w=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[m][a]==x?(w++,w==5?i+=Ee.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,_),x||(i+=this.finderPenaltyCountPatterns(_)*Ee.PENALTY_N3),x=this.modules[m][a],w=1);i+=this.finderPenaltyTerminateAndCount(x,w,_)*Ee.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,w=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][m]==x?(w++,w==5?i+=Ee.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,_),x||(i+=this.finderPenaltyCountPatterns(_)*Ee.PENALTY_N3),x=this.modules[a][m],w=1);i+=this.finderPenaltyTerminateAndCount(x,w,_)*Ee.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let x=0;x<this.size-1;x++){const w=this.modules[m][x];w==this.modules[m][x+1]&&w==this.modules[m+1][x]&&w==this.modules[m+1][x+1]&&(i+=Ee.PENALTY_N2)}let l=0;for(const m of this.modules)l=m.reduce((x,w)=>x+(w?1:0),l);const d=this.size*this.size,c=Math.ceil(Math.abs(l*20-d*10)/d)-1;return g(0<=c&&c<=9),i+=c*Ee.PENALTY_N4,g(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let c=this.size-7;d.length<i;c-=l)d.splice(1,0,c);return d}}static getNumRawDataModules(i){if(i<Ee.MIN_VERSION||i>Ee.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;l-=(25*d-10)*d-55,i>=7&&(l-=36)}return g(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(Ee.getNumRawDataModules(i)/8)-Ee.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*Ee.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let d=1;for(let c=0;c<i;c++){for(let m=0;m<l.length;m++)l[m]=Ee.reedSolomonMultiply(l[m],d),m+1<l.length&&(l[m]^=l[m+1]);d=Ee.reedSolomonMultiply(d,2)}return l}static reedSolomonComputeRemainder(i,l){let d=l.map(c=>0);for(const c of i){const m=c^d.shift();d.push(0),l.forEach((x,w)=>d[w]^=Ee.reedSolomonMultiply(x,m))}return d}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let d=0;for(let c=7;c>=0;c--)d=d<<1^(d>>>7)*285,d^=(l>>>c&1)*i;return g(d>>>8==0),d}finderPenaltyCountPatterns(i){const l=i[1];g(l<=this.size*3);const d=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(d&&i[0]>=l*4&&i[6]>=l?1:0)+(d&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,d){return i&&(this.finderPenaltyAddHistory(l,d),l=0),l+=this.size,this.finderPenaltyAddHistory(l,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.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]],s.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=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)l.push(n>>>d&1)}function o(n,i){return(n>>>i&1)!=0}function g(n){if(!n)throw new Error("Assertion error")}const p=class Je{constructor(i,l,d){if(this.mode=i,this.numChars=l,this.bitData=d,l<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let l=[];for(const d of i)r(d,8,l);return new Je(Je.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!Je.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let d=0;d<i.length;){const c=Math.min(i.length-d,3);r(parseInt(i.substring(d,d+c),10),c*3+1,l),d+=c}return new Je(Je.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!Je.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],d;for(d=0;d+2<=i.length;d+=2){let c=Je.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;c+=Je.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),r(c,11,l)}return d<i.length&&r(Je.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,l),new Je(Je.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:Je.isNumeric(i)?[Je.makeNumeric(i)]:Je.isAlphanumeric(i)?[Je.makeAlphanumeric(i)]:[Je.makeBytes(Je.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new Je(Je.Mode.ECI,0,l)}static isNumeric(i){return Je.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Je.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let d=0;for(const c of i){const m=c.mode.numCharCountBits(l);if(c.numChars>=1<<m)return 1/0;d+=4+m+c.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?l.push(i.charCodeAt(d)):(l.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return l}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=p;e.QrSegment=p})(vs||(vs={}));(e=>{(s=>{const r=class{constructor(g,p){this.ordinal=g,this.formatBits=p}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(vs||(vs={}));(e=>{(s=>{const r=class{constructor(g,p){this.modeBits=g,this.numBitsCharCount=p}numCharCountBits(g){return this.numBitsCharCount[Math.floor((g+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(vs||(vs={}));var As=vs;var z0={L:As.QrCode.Ecc.LOW,M:As.QrCode.Ecc.MEDIUM,Q:As.QrCode.Ecc.QUARTILE,H:As.QrCode.Ecc.HIGH},yc=128,Sc="L",wc="#FFFFFF",Cc="#000000",kc=!1,Ec=1,W0=4,H0=0,$0=.1;function jc(e,s=0){const r=[];return e.forEach(function(o,g){let p=null;o.forEach(function(v,n){if(!v&&p!==null){r.push(`M${p+s} ${g+s}h${n-p}v1H${p+s}z`),p=null;return}if(n===o.length-1){if(!v)return;p===null?r.push(`M${n+s},${g+s} h1v1H${n+s}z`):r.push(`M${p+s},${g+s} h${n+1-p}v1H${p+s}z`);return}v&&p===null&&(p=n)})}),r.join("")}function Nc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((g,p)=>p<s.x||p>=s.x+s.w?g:!1))}function U0(e,s,r,o){if(o==null)return null;const g=e.length+r*2,p=Math.floor(s*$0),v=g/s,n=(o.width||p)*v,i=(o.height||p)*v,l=o.x==null?e.length/2-n/2:o.x*v,d=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let m=null;if(o.excavate){let w=Math.floor(l),_=Math.floor(d),a=Math.ceil(n+l-w),h=Math.ceil(i+d-_);m={x:w,y:_,w:a,h}}const x=o.crossOrigin;return{x:l,y:d,h:i,w:n,excavation:m,opacity:c,crossOrigin:x}}function q0(e,s){return s!=null?Math.max(Math.floor(s),0):e?W0:H0}function Rc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:g,imageSettings:p,size:v,boostLevel:n}){let i=le.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((_,a)=>(_.push(...As.QrSegment.makeSegments(a)),_),[]);return As.QrCode.encodeSegments(w,z0[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:d,numCells:c,calculatedImageSettings:m}=le.useMemo(()=>{let x=i.getModules();const w=q0(o,g),_=x.length+w*2,a=U0(x,v,w,p);return{cells:x,margin:w,numCells:_,calculatedImageSettings:a}},[i,v,p,o,g]);return{qrcode:i,margin:d,cells:l,numCells:c,calculatedImageSettings:m}}var K0=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),X0=le.forwardRef(function(s,r){const o=s,{value:g,size:p=yc,level:v=Sc,bgColor:n=wc,fgColor:i=Cc,includeMargin:l=kc,minVersion:d=Ec,boostLevel:c,marginSize:m,imageSettings:x}=o,_=on(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=_,h=on(_,["style"]),u=x?.src,f=le.useRef(null),y=le.useRef(null),C=le.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=le.useState(!1),{margin:b,cells:j,numCells:A,calculatedImageSettings:L}=Rc({value:g,level:v,minVersion:d,boostLevel:c,includeMargin:l,marginSize:m,imageSettings:x,size:p});le.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let $=j;const W=y.current,R=L!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;R&&L.excavation!=null&&($=Nc(j,L.excavation));const M=window.devicePixelRatio||1;F.height=F.width=p*M;const P=p/A*M;I.scale(P,P),I.fillStyle=n,I.fillRect(0,0,A,A),I.fillStyle=i,K0?I.fill(new Path2D(jc($,b))):j.forEach(function(O,U){O.forEach(function(Y,B){Y&&I.fillRect(B+b,U+b,1,1)})}),L&&(I.globalAlpha=L.opacity),R&&I.drawImage(W,L.x+b,L.y+b,L.w,L.h)}}),le.useEffect(()=>{E(!1)},[u]);const T=nn({height:p,width:p},a);let D=null;return u!=null&&(D=le.createElement("img",{src:u,key:u,style:{display:"none"},onLoad:()=>{E(!0)},ref:y,crossOrigin:L?.crossOrigin})),le.createElement(le.Fragment,null,le.createElement("canvas",nn({style:T,height:p,width:p,ref:C,role:"img"},h)),D)});X0.displayName="QRCodeCanvas";var Ac=le.forwardRef(function(s,r){const o=s,{value:g,size:p=yc,level:v=Sc,bgColor:n=wc,fgColor:i=Cc,includeMargin:l=kc,minVersion:d=Ec,boostLevel:c,title:m,marginSize:x,imageSettings:w}=o,_=on(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:u,calculatedImageSettings:f}=Rc({value:g,level:v,minVersion:d,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:w,size:p});let y=h,C=null;w!=null&&f!=null&&(f.excavation!=null&&(y=Nc(h,f.excavation)),C=le.createElement("image",{href:w.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=jc(y,a);return le.createElement("svg",nn({height:p,width:p,viewBox:`0 0 ${u} ${u}`,ref:r,role:"img"},_),!!m&&le.createElement("title",null,m),le.createElement("path",{fill:n,d:`M0,0 h${u}v${u}H0z`,shapeRendering:"crispEdges"}),le.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Ac.displayName="QRCodeSVG";function Tc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Y0(){return Ot({queryKey:ae.tunnel.status,queryFn:()=>Se.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function V0(){const e=ht();return kt({mutationFn:()=>Se.post("/tunnel/start",{port:Tc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function G0(){const e=ht();return kt({mutationFn:()=>Se.post("/tunnel/regenerate",{port:Tc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function Q0(){const e=ht();return kt({mutationFn:()=>Se.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function Z0(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function J0(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 ex(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 da(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const g=Math.round(o/60);return g<24?`${g}h ago`:`${Math.round(g/24)}d ago`}function Qs(e){const s=e?.trim();return s||null}function tx(e){if(!e)return"";const s=[Qs(e.lastLocalError),Qs(e.lastRemoteError),Qs(e.lastError)].filter(g=>g!==null),r=Qs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Qs(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
85
|
-
`)}function ua(){const{t:e}=de(),{data:s}=Y0(),r=V0(),o=Q0(),g=G0(),[p,v]=S.useState(!1),[n,i]=S.useState(null),l=S.useRef(null),[d,c]=S.useState({top:0,right:0}),[m,x]=S.useState(!1),[w,_]=S.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",u=g.isPending,f=s?.shareableUrl,y=s?.token,C=Z0(s),k=J0(s),E=tx(s);S.useEffect(()=>{if(p&&l.current){const F=l.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[p]);const b=S.useCallback(()=>{v(!0)},[a]),j=S.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),A=S.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),L=S.useCallback(()=>{y&&(navigator.clipboard.writeText(y),i("token"),setTimeout(()=>i(null),2e3))},[y]),T=S.useCallback(()=>{o.mutate(),v(!1),x(!1),_(!1)},[o]),D=S.useCallback(()=>{g.mutate(void 0,{onSuccess:()=>{_(!1),v(!0)}})},[g]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:b,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(Xe,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(dr,{size:16}):t.jsx(oo,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),p&&!a&&fs.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(oo,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",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.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Xt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Xe,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&a&&fs.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(ex(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Xt,{size:14})})]}),y&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(bd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Ac,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:F=>F.target.select()}),t.jsx("button",{onClick:A,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Yt,{size:14,className:"text-emerald-500"}):t.jsx(io,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:da(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:da(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),y&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!m),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(m?"Hide token":"Show token")}),m&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:y}),t.jsx("button",{onClick:L,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Yt,{size:14,className:"text-emerald-500"}):t.jsx(io,{size:14})})]})]}),w&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>_(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:u,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(u?"Generating...":"Regenerate link")})]})]}),!w&&t.jsxs("button",{onClick:()=>_(!0),disabled:u||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(ur,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function $i({isOpen:e,onClose:s}){const{t:r}=de(),o=Ed(),[g,p]=S.useState(""),[v,n]=S.useState(""),[i,l]=S.useState(null),[d,c]=S.useState(!1),[m,x]=S.useState(!1),w=g.trim(),_=v.trim(),a=d||o.isPending,h=S.useMemo(()=>!!(w&&_&&!a),[w,_,a]),u=S.useCallback(()=>{p(""),n(""),l(null),x(!1)},[]),f=S.useCallback(()=>{a||(u(),s())},[a,s,u]);S.useEffect(()=>{e||u()},[e,u]);const y=S.useCallback(async b=>{try{await o.mutateAsync({name:w,repoPath:_,initEmptyRepo:b}),u(),s()}catch(j){const A=j instanceof Error?j.message:r("Failed to create project");l(A),ut.error(A)}},[o,s,u,r,w,_]),C=S.useCallback(async()=>{if(!(!w||!_||a)){l(null),c(!0);try{const b=await Se.get("/filesystem/validate",{params:{path:_}});if(!b.valid){l(b.error??r("Selected path is not a valid directory"));return}if(b.isGitRepo){await y(!1);return}if(b.reason==="no_git"&&b.isEmpty){x(!0);return}if(b.reason==="no_git"){await y(!1);return}await y(!1)}catch(b){l(b instanceof Error?b.message:r("Could not check project path"))}finally{c(!1)}}},[y,a,r,w,_]),k=S.useCallback(()=>{x(!1),y(!1)},[y]),E=S.useCallback(()=>{x(!1),y(!0)},[y]);return t.jsxs(t.Fragment,{children:[t.jsx(gs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:d?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:g,onChange:b=>p(b.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(wd,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(gs,{isOpen:m,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("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.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function ha(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function sx(e){return e.map((s,r)=>({project:s,index:r,activityTime:ha(s.lastActivityAt??s.createdAt),createdTime:ha(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const g=r.createdTime-s.createdTime;return g!==0?g:s.index-r.index}).map(({project:s})=>s)}function fa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:g}){const{t:p}=de(),[v,n]=S.useState(!1),i=e.filter(d=>!d.archivedAt),l=s?e.find(d=>d.id===s)??null:null;return t.jsxs("div",{className:se("relative flex items-center min-w-0",g),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(d=>!d),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:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Ds,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:p("All Projects")}),t.jsx(Ct,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!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:[t.jsx(Ds,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:p("All Projects")}),s===null?t.jsx(Yt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(d=>{const c=s===d.id;return t.jsxs("button",{onClick:()=>{r(d.id),n(!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:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:d.name}),c?t.jsx(Yt,{size:14,className:"text-foreground shrink-0"}):null]},d.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},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:[t.jsx(es,{size:13}),t.jsx("span",{children:p("Create New Project...")})]})]})]}):null]})}function ma(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const rx=260,ix=600,pa=400,nx=100,ox=1e3;function ax(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===yt.MAIN_DIRECTORY?{workspaceKind:yt.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(g=>g.status==="RUNNING"||g.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function lx(){const{t:e,locale:s}=de(),[r,o]=S.useState(null),[g,p]=S.useState(null),[v,n]=S.useState(pa),[i,l]=S.useState(!1),[d,c]=S.useState("idle"),[m,x]=S.useState({}),w=S.useRef(!1),_=S.useRef(0),a=S.useRef(pa),h=S.useRef(null),u=ht(),{data:f,isLoading:y}=Os(),{data:C,isLoading:k}=jd({limit:nx}),E=S.useMemo(()=>C?.data??[],[C?.data]),b=g&&E.some(J=>J.id===g)?g:null,{data:j,isLoading:A}=od({...b?{projectId:b}:{},limit:ox}),L=S.useMemo(()=>j?.data??[],[j?.data]),[T,D]=S.useState([]),F=S.useMemo(()=>{if(T.length===0)return L;const J=new Set(L.map(he=>he.id));return[...T.filter(he=>!J.has(he.id)),...L]},[L,T]),[I,$]=S.useState(null),W=S.useMemo(()=>r&&F.some(J=>J.id===r)?r:I&&r===I?I:null,[r,F,I]);S.useEffect(()=>{I&&F.some(J=>J.id===I)&&$(null)},[I,F]),S.useEffect(()=>{if(T.length===0)return;const J=new Set(L.map(he=>he.id));T.some(he=>J.has(he.id))&&D(he=>he.filter(V=>!J.has(V.id)))},[L,T]);const R=S.useMemo(()=>sx(E),[E]),M=S.useMemo(()=>R.map(x0),[R]),P=S.useMemo(()=>R.filter(J=>!J.archivedAt),[R]),O=S.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),he=J?JSON.parse(J):{};return[...f].sort((V,Z)=>{const ie=V.availability.type!=="NOT_FOUND",we=Z.availability.type!=="NOT_FOUND";if(ie!==we)return ie?-1:1;const pe=he[V.provider.id]??0;return(he[Z.provider.id]??0)-pe})},[f]),U=S.useMemo(()=>F.map(J=>_0(J,E.find(he=>he.id===J.projectId))),[E,F]),Y=S.useMemo(()=>{if(!W)return null;const J=F.find(V=>V.id===W);if(!J)return null;const he=E.find(V=>V.id===J.projectId);if(!he){const V=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===yt.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:Un(J.status),branch:V,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return b0(J,he)},[W,F,E]),B=ba(),H=ad(),q=ld(),N=Hn(),z=S.useCallback(J=>{const he=ax(J);D(V=>V.some(Z=>Z.id===J.id)?V.map(Z=>Z.id===J.id?he:Z):[he,...V]),u.setQueryData(ae.tasks.detail(J.id),J),$(J.id),o(J.id)},[u]),X=S.useCallback((J,he,V)=>{const Z=J.id,ie=[J.title,J.description].filter(Boolean).join(`
|
|
85
|
+
`);c(""),Us(),P.current&&(P.current.style.height="40px"),ys.mutate({id:re,message:fe,providerId:vt??void 0},{onSuccess:()=>Ut(),onSettled:()=>{Xs.current=!1}})},[d,re,ys,Ut,qt,zt,qs,Us,vt]),Er=S.useCallback(async()=>{re&&(await ls.mutateAsync(re),R.invalidateQueries({queryKey:["workspaces"]}))},[re,ls,R]),gi=S.useCallback(ee=>Y.mutateAsync(ee),[Y]),hs=S.useCallback(ee=>{f(ee),l("chat"),requestAnimationFrame(()=>{B()})},[B]),vi=S.useCallback(()=>{f(null)},[]),Qt=S.useCallback(()=>{l("changes")},[]),Ys=_e&&pe?t.jsx(xc,{workspaceId:pe,branchName:Ae,targetBranch:Xe,commitMessage:at,changes:$e,gitStatus:Ie,isGitStatusLoading:Pe,canRunGitOperations:ie,onOpenChanges:Qt,onRefreshCommitMessage:ue,onConflict:J,className:"mb-2"}):null,jr=S.useCallback(ee=>{const fe=ee.target.files;fe&&fe.length>0&&us(Array.from(fe)),ee.target.value=""},[us]),Nr=S.useCallback(ee=>{const fe=ee.clipboardData.items,Ue=[];for(const Ne of fe)if(Ne.kind==="file"){const St=Ne.getAsFile();St&&Ue.push(St)}Ue.length>0&&(ee.preventDefault(),us(Ue))},[us]),Rr=S.useCallback(ee=>{c(ee.target.value);const fe=ee.target;fe.style.height="auto",fe.style.height=`${Math.max(40,Math.min(fe.scrollHeight,140))}px`},[]),fs=S.useCallback(()=>{bs&&Hs.mutate({workspaceId:bs})},[Hs,bs]),ms=S.useRef(null);return S.useEffect(()=>{const ee=window.visualViewport;if(!ee)return;let fe=!1;const Ue=()=>{ms.current&&(ms.current.style.height=`${ee.height}px`,ms.current.style.top=`${ee.offsetTop}px`)},Ne=()=>Ue(),St=()=>{fe||Ue()},Pt=()=>{fe=!0},Le=()=>{fe=!1,requestAnimationFrame(Ue)};return ee.addEventListener("resize",Ne),ee.addEventListener("scroll",St),document.addEventListener("touchstart",Pt,{passive:!0}),document.addEventListener("touchend",Le,{passive:!0}),document.addEventListener("touchcancel",Le,{passive:!0}),()=>{ee.removeEventListener("resize",Ne),ee.removeEventListener("scroll",St),document.removeEventListener("touchstart",Pt),document.removeEventListener("touchend",Le),document.removeEventListener("touchcancel",Le)}},[]),S.useEffect(()=>{const ee=ms.current;if(!ee)return;const fe=Ue=>{let Ne=Ue.target;for(;Ne&&Ne!==ee;){if(Ne.tagName==="TEXTAREA"){if(Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement;continue}const Pt=window.getComputedStyle(Ne).overflowY;if((Pt==="auto"||Pt==="scroll")&&Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement}Ue.preventDefault()};return ee.addEventListener("touchmove",fe,{passive:!1}),()=>ee.removeEventListener("touchmove",fe)},[]),t.jsxs("div",{ref:ms,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Ls,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(z0,{status:e.status}),t.jsx("button",{onClick:fs,disabled:!bs||K,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(ri,{size:16})}),r&&!K&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsx("button",{onClick:()=>h(ee=>!ee),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Ka,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{y(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(Sn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:q.map(({key:ee,label:fe,icon:Ue})=>t.jsxs("button",{onClick:()=>l(ee),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===ee?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Ue,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(fe)})]},ee))})]}),i==="chat"&&(z?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:u?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:u})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(mc,{session:xe,providers:et,usage:Cr,compact:!0,providerIdFallback:we?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:vi,children:[t.jsx(Ls,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:W,children:$s?t.jsx($i,{label:v("Loading logs...")}):cs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(Ye?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(zr,{logs:cs,isOutputActive:br,lastExitAt:yr,onUserToggleDetails:F,onOpenPreviewUrl:Ee})})}),!I&&t.jsxs("button",{onClick:()=>B(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(nr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ds.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Hr,{todos:ds,compact:!0})})]}):t.jsx(wl,{teamRun:z,messages:U??z.messages??[],readOnly:K,readOnlyMessage:te,onSendMessage:gi,onViewInvocationSession:hs,changeSummaryBar:Ys,compactComposer:!0,workingDir:G,onOpenPreviewUrl:De})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:W,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):H?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(fn,{urlTransform:F0,components:Ea,children:H.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!K&&g&&(L||re)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(la,{state:g,onRetry:g.status==="failed"?async()=>{await V(),x(!0)}:void 0})}):null,L?t.jsx($i,{label:"Loading..."}):re?$s?t.jsx($i,{label:"Loading logs..."}):cs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:Ye?"Waiting for agent output...":"No logs recorded."}):t.jsx(zr,{logs:cs,isOutputActive:br,lastExitAt:yr,onUserToggleDetails:F,onOpenPreviewUrl:Ee}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Xt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:K?te:v("选择一个 Agent 来执行此任务")}),!K&&g?t.jsx(la,{state:g}):null,!K&&t.jsxs(Te,{onClick:async()=>{await V(),x(!0)},disabled:!!(g&&g.status!=="failed"),children:[t.jsx(Xt,{size:16,className:"mr-1.5"}),g?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>B(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(nr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ds.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Hr,{todos:ds,compact:!0})}),K?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:te})}):ze?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:async()=>{await V(),x(!0)},children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):re&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[Ys,t.jsx(Ba,{sessionId:ye||re,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(hn,{files:Sr,onRemove:wr}),t.jsx("textarea",{ref:P,value:d,onChange:Rr,onPaste:Nr,onKeyDown:ee=>{Ct.handleKeyDown(ee)||xt.handleKeyDown(ee)||ee.key==="Enter"&&!ee.shiftKey&&!ee.repeat&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),kr())},rows:1,placeholder:Ye?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:jr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(yn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Z&&et&&t.jsx(Fa,{providers:et,currentProviderId:vt,agentType:Z.agentType,runtimeType:Z.runtimeType,onSelect:st}),t.jsx(_n,{usage:Cr}),Ye&&!d.trim()&&!qt?t.jsx("button",{onClick:Er,disabled:ls.isPending||Ge,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ds,{size:12})}):t.jsx("button",{onClick:kr,disabled:!d.trim()&&!qt||zt,className:`p-1.5 rounded-lg transition-colors ${(d.trim()||qt)&&!zt?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(vn,{size:15})})]})]})]}),t.jsx(Wr,{open:xt.query!==null,anchorRef:j,commands:xt.filteredCommands,selectedIndex:xt.selectedIndex,query:xt.query??"",hasCatalog:xt.allCommands.length>0,compact:!0,onSelect:xt.applyCommand}),t.jsx(Wr,{open:Ct.query!==null,anchorRef:j,commands:Ct.filteredSkills,selectedIndex:Ct.selectedIndex,query:Ct.query??"",hasCatalog:Ct.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Ct.applySkill})]})]})),i==="team-status"&&z&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Rl,{teamRun:z,workspaces:M,selectedWorkspaceId:he,onSelectWorkspace:C,onViewInvocationSession:hs})}),i==="changes"&&$&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[M&&M.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(dc,{workspaces:M,teamRun:z,selectedWorkspaceId:he,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),ie&&pe&&t.jsx("div",{className:"shrink-0",children:t.jsx(ic,{workspaceId:pe,branchName:Ae,targetBranch:Xe,commitMessage:at,committedFileCount:Oe,onRefreshCommitMessage:ue,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(A0,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(O0,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(uc,{sessionId:re||void 0,workspaceId:he,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:$,readOnly:K,repoDeleted:ne,previewRequest:E,onPreviewRequestHandled:ee=>{_(fe=>fe?.id===ee?void 0:fe)}})}),!K&&t.jsx(hc,{isOpen:m,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:H?.title??e.title,taskDescription:H?.body??"",taskPrompt:H?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>p?.(e.id)}),t.jsx(In,{isOpen:w,onClose:()=>y(!1),onConfirm:()=>{r?.(e.id),y(!1)},taskId:e.id,taskTitle:e.title,workspaces:M,isLoading:o}),Ve&&ve&&Fe&&t.jsx(vc,{open:Ve,onOpenChange:ee=>{Ze(ee),ee||Re(null)},workspaceId:Fe,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:lt,targetBranch:Je,operation:Ie?.operation,worktreePath:ge,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Et,currentSessionId:z?void 0:re,teamRunId:z?.id})]})}function $i({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var U0=Object.defineProperty,ei=Object.getOwnPropertySymbols,yc=Object.prototype.hasOwnProperty,Sc=Object.prototype.propertyIsEnumerable,ca=(e,s,r)=>s in e?U0(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,on=(e,s)=>{for(var r in s||(s={}))yc.call(s,r)&&ca(e,r,s[r]);if(ei)for(var r of ei(s))Sc.call(s,r)&&ca(e,r,s[r]);return e},an=(e,s)=>{var r={};for(var o in e)yc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ei)for(var o of ei(e))s.indexOf(o)<0&&Sc.call(e,o)&&(r[o]=e[o]);return r};var xs;(e=>{const s=class je{constructor(i,l,d,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<je.MIN_VERSION||i>je.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let m=[];for(let w=0;w<this.size;w++)m.push(!1);for(let w=0;w<this.size;w++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(d);if(this.drawCodewords(x),c==-1){let w=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const a=this.getPenaltyScore();a<w&&(c=y,w=a),this.applyMask(y)}}g(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const d=e.QrSegment.makeSegments(i);return je.encodeSegments(d,l)}static encodeBinary(i,l){const d=e.QrSegment.makeBytes(i);return je.encodeSegments([d],l)}static encodeSegments(i,l,d=1,c=40,m=-1,x=!0){if(!(je.MIN_VERSION<=d&&d<=c&&c<=je.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let w,y;for(w=d;;w++){const f=je.getNumDataCodewords(w,l)*8,b=v.getTotalBits(i,w);if(b<=f){y=b;break}if(w>=c)throw new RangeError("Data too long")}for(const f of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])x&&y<=je.getNumDataCodewords(w,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(w),a);for(const b of f.getData())a.push(b)}g(a.length==y);const h=je.getNumDataCodewords(w,l)*8;g(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),g(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let u=[];for(;u.length*8<a.length;)u.push(0);return a.forEach((f,b)=>u[b>>>3]|=f<<7-(b&7)),new je(w,l,u,m)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let d=0;d<l;d++)for(let c=0;c<l;c++)d==0&&c==0||d==0&&c==l-1||d==l-1&&c==0||this.drawAlignmentPattern(i[d],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let d=l;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const c=(l<<10|d)^21522;g(c>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,o(c,m));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,o(c,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,o(c,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,o(c,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;g(l>>>18==0);for(let d=0;d<18;d++){const c=o(l,d),m=this.size-11+d%3,x=Math.floor(d/3);this.setFunctionModule(m,x,c),this.setFunctionModule(x,m,c)}}drawFinderPattern(i,l){for(let d=-4;d<=4;d++)for(let c=-4;c<=4;c++){const m=Math.max(Math.abs(c),Math.abs(d)),x=i+c,w=l+d;0<=x&&x<this.size&&0<=w&&w<this.size&&this.setFunctionModule(x,w,m!=2&&m!=4)}}drawAlignmentPattern(i,l){for(let d=-2;d<=2;d++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+d,Math.max(Math.abs(c),Math.abs(d))!=1)}setFunctionModule(i,l,d){this.modules[l][i]=d,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,d=this.errorCorrectionLevel;if(i.length!=je.getNumDataCodewords(l,d))throw new RangeError("Invalid argument");const c=je.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][l],m=je.ECC_CODEWORDS_PER_BLOCK[d.ordinal][l],x=Math.floor(je.getNumRawDataModules(l)/8),w=c-x%c,y=Math.floor(x/c);let a=[];const h=je.reedSolomonComputeDivisor(m);for(let f=0,b=0;f<c;f++){let C=i.slice(b,b+y-m+(f<w?0:1));b+=C.length;const k=je.reedSolomonComputeRemainder(C,h);f<w&&C.push(0),a.push(C.concat(k))}let u=[];for(let f=0;f<a[0].length;f++)a.forEach((b,C)=>{(f!=y-m||C>=w)&&u.push(b[f])});return g(u.length==x),u}drawCodewords(i){if(i.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let c=0;c<this.size;c++)for(let m=0;m<2;m++){const x=d-m,y=(d+1&2)==0?this.size-1-c:c;!this.isFunction[y][x]&&l<i.length*8&&(this.modules[y][x]=o(i[l>>>3],7-(l&7)),l++)}}g(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let d=0;d<this.size;d++){let c;switch(i){case 0:c=(d+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=d%3==0;break;case 3:c=(d+l)%3==0;break;case 4:c=(Math.floor(d/3)+Math.floor(l/2))%2==0;break;case 5:c=d*l%2+d*l%3==0;break;case 6:c=(d*l%2+d*l%3)%2==0;break;case 7:c=((d+l)%2+d*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][d]&&c&&(this.modules[l][d]=!this.modules[l][d])}}getPenaltyScore(){let i=0;for(let m=0;m<this.size;m++){let x=!1,w=0,y=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[m][a]==x?(w++,w==5?i+=je.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,y),x||(i+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[m][a],w=1);i+=this.finderPenaltyTerminateAndCount(x,w,y)*je.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,w=0,y=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][m]==x?(w++,w==5?i+=je.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,y),x||(i+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[a][m],w=1);i+=this.finderPenaltyTerminateAndCount(x,w,y)*je.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let x=0;x<this.size-1;x++){const w=this.modules[m][x];w==this.modules[m][x+1]&&w==this.modules[m+1][x]&&w==this.modules[m+1][x+1]&&(i+=je.PENALTY_N2)}let l=0;for(const m of this.modules)l=m.reduce((x,w)=>x+(w?1:0),l);const d=this.size*this.size,c=Math.ceil(Math.abs(l*20-d*10)/d)-1;return g(0<=c&&c<=9),i+=c*je.PENALTY_N4,g(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let c=this.size-7;d.length<i;c-=l)d.splice(1,0,c);return d}}static getNumRawDataModules(i){if(i<je.MIN_VERSION||i>je.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;l-=(25*d-10)*d-55,i>=7&&(l-=36)}return g(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(je.getNumRawDataModules(i)/8)-je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let d=1;for(let c=0;c<i;c++){for(let m=0;m<l.length;m++)l[m]=je.reedSolomonMultiply(l[m],d),m+1<l.length&&(l[m]^=l[m+1]);d=je.reedSolomonMultiply(d,2)}return l}static reedSolomonComputeRemainder(i,l){let d=l.map(c=>0);for(const c of i){const m=c^d.shift();d.push(0),l.forEach((x,w)=>d[w]^=je.reedSolomonMultiply(x,m))}return d}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let d=0;for(let c=7;c>=0;c--)d=d<<1^(d>>>7)*285,d^=(l>>>c&1)*i;return g(d>>>8==0),d}finderPenaltyCountPatterns(i){const l=i[1];g(l<=this.size*3);const d=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(d&&i[0]>=l*4&&i[6]>=l?1:0)+(d&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,d){return i&&(this.finderPenaltyAddHistory(l,d),l=0),l+=this.size,this.finderPenaltyAddHistory(l,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.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]],s.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=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)l.push(n>>>d&1)}function o(n,i){return(n>>>i&1)!=0}function g(n){if(!n)throw new Error("Assertion error")}const p=class tt{constructor(i,l,d){if(this.mode=i,this.numChars=l,this.bitData=d,l<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let l=[];for(const d of i)r(d,8,l);return new tt(tt.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!tt.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let d=0;d<i.length;){const c=Math.min(i.length-d,3);r(parseInt(i.substring(d,d+c),10),c*3+1,l),d+=c}return new tt(tt.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!tt.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],d;for(d=0;d+2<=i.length;d+=2){let c=tt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;c+=tt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),r(c,11,l)}return d<i.length&&r(tt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,l),new tt(tt.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:tt.isNumeric(i)?[tt.makeNumeric(i)]:tt.isAlphanumeric(i)?[tt.makeAlphanumeric(i)]:[tt.makeBytes(tt.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new tt(tt.Mode.ECI,0,l)}static isNumeric(i){return tt.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return tt.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let d=0;for(const c of i){const m=c.mode.numCharCountBits(l);if(c.numChars>=1<<m)return 1/0;d+=4+m+c.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?l.push(i.charCodeAt(d)):(l.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return l}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=p;e.QrSegment=p})(xs||(xs={}));(e=>{(s=>{const r=class{constructor(g,p){this.ordinal=g,this.formatBits=p}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(xs||(xs={}));(e=>{(s=>{const r=class{constructor(g,p){this.modeBits=g,this.numBitsCharCount=p}numCharCountBits(g){return this.numBitsCharCount[Math.floor((g+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(xs||(xs={}));var Ts=xs;var q0={L:Ts.QrCode.Ecc.LOW,M:Ts.QrCode.Ecc.MEDIUM,Q:Ts.QrCode.Ecc.QUARTILE,H:Ts.QrCode.Ecc.HIGH},wc=128,Cc="L",kc="#FFFFFF",Ec="#000000",jc=!1,Nc=1,K0=4,X0=0,Y0=.1;function Rc(e,s=0){const r=[];return e.forEach(function(o,g){let p=null;o.forEach(function(v,n){if(!v&&p!==null){r.push(`M${p+s} ${g+s}h${n-p}v1H${p+s}z`),p=null;return}if(n===o.length-1){if(!v)return;p===null?r.push(`M${n+s},${g+s} h1v1H${n+s}z`):r.push(`M${p+s},${g+s} h${n+1-p}v1H${p+s}z`);return}v&&p===null&&(p=n)})}),r.join("")}function Ac(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((g,p)=>p<s.x||p>=s.x+s.w?g:!1))}function V0(e,s,r,o){if(o==null)return null;const g=e.length+r*2,p=Math.floor(s*Y0),v=g/s,n=(o.width||p)*v,i=(o.height||p)*v,l=o.x==null?e.length/2-n/2:o.x*v,d=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let m=null;if(o.excavate){let w=Math.floor(l),y=Math.floor(d),a=Math.ceil(n+l-w),h=Math.ceil(i+d-y);m={x:w,y,w:a,h}}const x=o.crossOrigin;return{x:l,y:d,h:i,w:n,excavation:m,opacity:c,crossOrigin:x}}function G0(e,s){return s!=null?Math.max(Math.floor(s),0):e?K0:X0}function Tc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:g,imageSettings:p,size:v,boostLevel:n}){let i=ae.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((y,a)=>(y.push(...Ts.QrSegment.makeSegments(a)),y),[]);return Ts.QrCode.encodeSegments(w,q0[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:d,numCells:c,calculatedImageSettings:m}=ae.useMemo(()=>{let x=i.getModules();const w=G0(o,g),y=x.length+w*2,a=V0(x,v,w,p);return{cells:x,margin:w,numCells:y,calculatedImageSettings:a}},[i,v,p,o,g]);return{qrcode:i,margin:d,cells:l,numCells:c,calculatedImageSettings:m}}var Q0=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Z0=ae.forwardRef(function(s,r){const o=s,{value:g,size:p=wc,level:v=Cc,bgColor:n=kc,fgColor:i=Ec,includeMargin:l=jc,minVersion:d=Nc,boostLevel:c,marginSize:m,imageSettings:x}=o,y=an(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=y,h=an(y,["style"]),u=x?.src,f=ae.useRef(null),b=ae.useRef(null),C=ae.useCallback(W=>{f.current=W,typeof r=="function"?r(W):r&&(r.current=W)},[r]),[k,E]=ae.useState(!1),{margin:_,cells:j,numCells:A,calculatedImageSettings:P}=Tc({value:g,level:v,minVersion:d,boostLevel:c,includeMargin:l,marginSize:m,imageSettings:x,size:p});ae.useEffect(()=>{if(f.current!=null){const W=f.current,I=W.getContext("2d");if(!I)return;let B=j;const F=b.current,R=P!=null&&F!==null&&F.complete&&F.naturalHeight!==0&&F.naturalWidth!==0;R&&P.excavation!=null&&(B=Ac(j,P.excavation));const M=window.devicePixelRatio||1;W.height=W.width=p*M;const L=p/A*M;I.scale(L,L),I.fillStyle=n,I.fillRect(0,0,A,A),I.fillStyle=i,Q0?I.fill(new Path2D(Rc(B,_))):j.forEach(function(O,U){O.forEach(function(Y,z){Y&&I.fillRect(z+_,U+_,1,1)})}),P&&(I.globalAlpha=P.opacity),R&&I.drawImage(F,P.x+_,P.y+_,P.w,P.h)}}),ae.useEffect(()=>{E(!1)},[u]);const T=on({height:p,width:p},a);let D=null;return u!=null&&(D=ae.createElement("img",{src:u,key:u,style:{display:"none"},onLoad:()=>{E(!0)},ref:b,crossOrigin:P?.crossOrigin})),ae.createElement(ae.Fragment,null,ae.createElement("canvas",on({style:T,height:p,width:p,ref:C,role:"img"},h)),D)});Z0.displayName="QRCodeCanvas";var Mc=ae.forwardRef(function(s,r){const o=s,{value:g,size:p=wc,level:v=Cc,bgColor:n=kc,fgColor:i=Ec,includeMargin:l=jc,minVersion:d=Nc,boostLevel:c,title:m,marginSize:x,imageSettings:w}=o,y=an(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:u,calculatedImageSettings:f}=Tc({value:g,level:v,minVersion:d,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:w,size:p});let b=h,C=null;w!=null&&f!=null&&(f.excavation!=null&&(b=Ac(h,f.excavation)),C=ae.createElement("image",{href:w.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=Rc(b,a);return ae.createElement("svg",on({height:p,width:p,viewBox:`0 0 ${u} ${u}`,ref:r,role:"img"},y),!!m&&ae.createElement("title",null,m),ae.createElement("path",{fill:n,d:`M0,0 h${u}v${u}H0z`,shapeRendering:"crispEdges"}),ae.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Mc.displayName="QRCodeSVG";function Dc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function J0(){return Bt({queryKey:de.tunnel.status,queryFn:()=>Ce.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function ex(){const e=bt();return Ft({mutationFn:()=>Ce.post("/tunnel/start",{port:Dc()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function tx(){const e=bt();return Ft({mutationFn:()=>Ce.post("/tunnel/regenerate",{port:Dc()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function sx(){const e=bt();return Ft({mutationFn:()=>Ce.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function rx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function ix(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 nx(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 da(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const g=Math.round(o/60);return g<24?`${g}h ago`:`${Math.round(g/24)}d ago`}function Zs(e){const s=e?.trim();return s||null}function ox(e){if(!e)return"";const s=[Zs(e.lastLocalError),Zs(e.lastRemoteError),Zs(e.lastError)].filter(g=>g!==null),r=Zs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Zs(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
86
|
+
`)}function ua(){const{t:e}=ce(),{data:s}=J0(),r=ex(),o=sx(),g=tx(),[p,v]=S.useState(!1),[n,i]=S.useState(null),l=S.useRef(null),[d,c]=S.useState({top:0,right:0}),[m,x]=S.useState(!1),[w,y]=S.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",u=g.isPending,f=s?.shareableUrl,b=s?.token,C=rx(s),k=ix(s),E=ox(s);S.useEffect(()=>{if(p&&l.current){const W=l.current.getBoundingClientRect();c({top:W.bottom+8,right:window.innerWidth-W.right})}},[p]);const _=S.useCallback(()=>{v(!0)},[a]),j=S.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),A=S.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),P=S.useCallback(()=>{b&&(navigator.clipboard.writeText(b),i("token"),setTimeout(()=>i(null),2e3))},[b]),T=S.useCallback(()=>{o.mutate(),v(!1),x(!1),y(!1)},[o]),D=S.useCallback(()=>{g.mutate(void 0,{onSuccess:()=>{y(!1),v(!0)}})},[g]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:_,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(Ke,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(ur,{size:16}):t.jsx(oo,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),p&&!a&&ps.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(oo,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",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.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Yt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Ke,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&a&&ps.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(nx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Yt,{size:14})})]}),b&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Sd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Mc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:W=>W.target.select()}),t.jsx("button",{onClick:A,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Vt,{size:14,className:"text-emerald-500"}):t.jsx(io,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:da(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:da(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!m),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(m?"Hide token":"Show token")}),m&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:b}),t.jsx("button",{onClick:P,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Vt,{size:14,className:"text-emerald-500"}):t.jsx(io,{size:14})})]})]}),w&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>y(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:u,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(u?"Generating...":"Regenerate link")})]})]}),!w&&t.jsxs("button",{onClick:()=>y(!0),disabled:u||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(hr,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Ui({isOpen:e,onClose:s}){const{t:r}=ce(),o=Rd(),[g,p]=S.useState(""),[v,n]=S.useState(""),[i,l]=S.useState(null),[d,c]=S.useState(!1),[m,x]=S.useState(!1),w=g.trim(),y=v.trim(),a=d||o.isPending,h=S.useMemo(()=>!!(w&&y&&!a),[w,y,a]),u=S.useCallback(()=>{p(""),n(""),l(null),x(!1)},[]),f=S.useCallback(()=>{a||(u(),s())},[a,s,u]);S.useEffect(()=>{e||u()},[e,u]);const b=S.useCallback(async _=>{try{await o.mutateAsync({name:w,repoPath:y,initEmptyRepo:_}),u(),s()}catch(j){const A=j instanceof Error?j.message:r("Failed to create project");l(A),rt.error(A)}},[o,s,u,r,w,y]),C=S.useCallback(async()=>{if(!(!w||!y||a)){l(null),c(!0);try{const _=await Ce.get("/filesystem/validate",{params:{path:y}});if(!_.valid){l(_.error??r("Selected path is not a valid directory"));return}if(_.isGitRepo){await b(!1);return}if(_.reason==="no_git"&&_.isEmpty){x(!0);return}if(_.reason==="no_git"){await b(!1);return}await b(!1)}catch(_){l(_ instanceof Error?_.message:r("Could not check project path"))}finally{c(!1)}}},[b,a,r,w,y]),k=S.useCallback(()=>{x(!1),b(!1)},[b]),E=S.useCallback(()=>{x(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(ns,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:d?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:g,onChange:_=>p(_.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(kd,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(ns,{isOpen:m,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("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.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function ha(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function ax(e){return e.map((s,r)=>({project:s,index:r,activityTime:ha(s.lastActivityAt??s.createdAt),createdTime:ha(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const g=r.createdTime-s.createdTime;return g!==0?g:s.index-r.index}).map(({project:s})=>s)}function fa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:g}){const{t:p}=ce(),[v,n]=S.useState(!1),i=e.filter(d=>!d.archivedAt),l=s?e.find(d=>d.id===s)??null:null;return t.jsxs("div",{className:se("relative flex items-center min-w-0",g),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(d=>!d),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:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Ps,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:p("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!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:[t.jsx(Ps,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:p("All Projects")}),s===null?t.jsx(Vt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(d=>{const c=s===d.id;return t.jsxs("button",{onClick:()=>{r(d.id),n(!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:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:d.name}),c?t.jsx(Vt,{size:14,className:"text-foreground shrink-0"}):null]},d.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},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:[t.jsx(ts,{size:13}),t.jsx("span",{children:p("Create New Project...")})]})]})]}):null]})}function ma(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const lx=260,cx=600,pa=400,dx=100,ux=1e3;function hx(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===_t.MAIN_DIRECTORY?{workspaceKind:_t.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(g=>g.status==="RUNNING"||g.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function fx(){const{t:e,locale:s}=ce(),[r,o]=S.useState(null),[g,p]=S.useState(null),[v,n]=S.useState(pa),[i,l]=S.useState(!1),[d,c]=S.useState("idle"),[m,x]=S.useState({}),w=S.useRef(!1),y=S.useRef(0),a=S.useRef(pa),h=S.useRef(null),u=bt(),{data:f,isLoading:b}=Bs(),{data:C,isLoading:k}=Ad({limit:dx}),E=S.useMemo(()=>C?.data??[],[C?.data]),_=g&&E.some(J=>J.id===g)?g:null,{data:j,isLoading:A}=ld({..._?{projectId:_}:{},limit:ux}),P=S.useMemo(()=>j?.data??[],[j?.data]),[T,D]=S.useState([]),W=S.useMemo(()=>{if(T.length===0)return P;const J=new Set(P.map(ue=>ue.id));return[...T.filter(ue=>!J.has(ue.id)),...P]},[P,T]),[I,B]=S.useState(null),F=S.useMemo(()=>r&&W.some(J=>J.id===r)?r:I&&r===I?I:null,[r,W,I]);S.useEffect(()=>{I&&W.some(J=>J.id===I)&&B(null)},[I,W]),S.useEffect(()=>{if(T.length===0)return;const J=new Set(P.map(ue=>ue.id));T.some(ue=>J.has(ue.id))&&D(ue=>ue.filter(V=>!J.has(V.id)))},[P,T]);const R=S.useMemo(()=>ax(E),[E]),M=S.useMemo(()=>R.map(w0),[R]),L=S.useMemo(()=>R.filter(J=>!J.archivedAt),[R]),O=S.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),ue=J?JSON.parse(J):{};return[...f].sort((V,Z)=>{const re=V.availability.type!=="NOT_FOUND",ye=Z.availability.type!=="NOT_FOUND";if(re!==ye)return re?-1:1;const me=ue[V.provider.id]??0;return(ue[Z.provider.id]??0)-me})},[f]),U=S.useMemo(()=>W.map(J=>C0(J,E.find(ue=>ue.id===J.projectId))),[E,W]),Y=S.useMemo(()=>{if(!F)return null;const J=W.find(V=>V.id===F);if(!J)return null;const ue=E.find(V=>V.id===J.projectId);if(!ue){const V=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:qn(J.status),branch:V,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return k0(J,ue)},[F,W,E]),z=ba(),$=cd(),q=dd(),N=xn(),H=S.useCallback(J=>{const ue=hx(J);D(V=>V.some(Z=>Z.id===J.id)?V.map(Z=>Z.id===J.id?ue:Z):[ue,...V]),u.setQueryData(de.tasks.detail(J.id),J),B(J.id),o(J.id)},[u]),X=S.useCallback((J,ue,V)=>{const Z=J.id,re=[J.title,J.description].filter(Boolean).join(`
|
|
86
87
|
|
|
87
|
-
`);x(
|
|
88
|
+
`);x(ye=>({...ye,[Z]:{status:"creating-workspace"}})),(async()=>{try{const ye=await Ce.post(`/tasks/${Z}/workspaces`,{workspaceKind:V});x(Se=>({...Se,[Z]:{status:"creating-session"}}));const me=await Ce.post(`/workspaces/${ye.id}/sessions`,{providerId:ue,prompt:re});x(Se=>({...Se,[Z]:{status:"starting-session"}})),await N.mutateAsync(me.id),await u.invalidateQueries({queryKey:de.workspaces.list(Z)}),await u.invalidateQueries({queryKey:de.tasks.all}),x(Se=>{const{[Z]:we,...xe}=Se;return xe})}catch(ye){const me=ye instanceof Error?ye.message:e("启动 Agent 失败");x(Se=>({...Se,[Z]:{status:"failed",error:me}})),rt.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),u.invalidateQueries({queryKey:de.workspaces.list(Z)}),u.invalidateQueries({queryKey:de.tasks.all})}})()},[u,N,e]),K=S.useCallback(J=>{x(ue=>{const{[J]:V,...Z}=ue;return Z}),u.invalidateQueries({queryKey:de.workspaces.list(J)}),u.invalidateQueries({queryKey:de.tasks.all})},[u]),ne=S.useCallback(J=>{$.mutate(J,{onSuccess:()=>{F===J&&o(null),x(ue=>{const{[J]:V,...Z}=ue;return Z}),D(ue=>ue.filter(V=>V.id!==J)),u.invalidateQueries({queryKey:de.tasks.all})},onError:()=>{rt.error(e("删除任务失败"))}})},[$,F,u,e]),te=S.useCallback((J,ue)=>{q.mutate({id:J,status:y0(ue)},{onError:()=>{rt.error(e("状态变更失败,该操作不被允许"))}})},[q,e]),he=S.useCallback(J=>{J.preventDefault(),w.current=!0,y.current=J.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);S.useEffect(()=>{const J=V=>{if(!w.current)return;const Z=V.clientX-y.current,re=Math.max(lx,Math.min(cx,a.current+Z));n(re)},ue=()=>{w.current&&(w.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",ue),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ue)}},[]);const le=S.useCallback(()=>{l(!0)},[]),G=S.useCallback(()=>{if(L.length===0){rt.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[L,e]),pe=S.useCallback(()=>{l(!1)},[]),ie=S.useCallback(async J=>{const{title:ue,description:V,projectId:Z,providerId:re,mode:ye,workspaceMode:me,teamRunMode:Se,teamTemplateId:we,memberPresetIds:xe,attachmentLinks:ke}=J,De=[V,ke].filter(Boolean).join(`
|
|
88
89
|
|
|
89
|
-
`);let
|
|
90
|
+
`);let Ee=null;try{if(c("creating-task"),Ee=await Ce.post(`/projects/${Z}/tasks`,{title:ue,description:De||void 0}),localStorage.setItem("lastSelectedProjectId",Z),ye==="SOLO"&&re){localStorage.setItem("lastSelectedProviderId",re);const Ge=localStorage.getItem("providerUsageCount"),ze=Ge?JSON.parse(Ge):{};ze[re]=(ze[re]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ze))}ye==="TEAM"?(c("creating-teamrun"),await z.mutateAsync({taskId:Ee.id,mode:Se,...we?{teamTemplateId:we}:{},...xe.length>0?{memberPresetIds:xe}:{}})):re&&X(Ee,re,me),_&&Z!==_&&p(null),H(Ee),c("idle"),u.invalidateQueries({queryKey:de.tasks.all}),u.invalidateQueries({queryKey:de.projects.all})}catch(Ye){if(c("idle"),Ee&&ye==="TEAM"){try{await $.mutateAsync(Ee.id)}catch{}throw rt.error(e("TeamRun 创建失败,请检查团队配置后重试")),Ye}else if(Ee)_&&Z!==_&&p(null),H(Ee),u.invalidateQueries({queryKey:de.tasks.all}),u.invalidateQueries({queryKey:de.projects.all});else throw rt.error(Ye instanceof Error?Ye.message:e("Failed to create task")),Ye}},[L,z,X,$,u,e,_,H]),Ae=k||A,at=S.useMemo(()=>L.map(J=>({id:J.id,name:J.name,color:M.find(ue=>ue.id===J.id)?.color,repoPath:J.repoPath,isGitRepo:J.isGitRepo,worktreeReady:J.worktreeReady,reason:J.reason})),[L,M]),Xe=S.useMemo(()=>O.map(({provider:J,availability:ue})=>({id:J.id,name:J.name,agentType:J.agentType,available:ue.type!=="NOT_FOUND"})),[O]),_e=S.useMemo(()=>{if(_&&L.find(ue=>ue.id===_))return _;const J=localStorage.getItem("lastSelectedProjectId");return J&&L.find(ue=>ue.id===J)?J:L[0]?.id??""},[L,_]),[Ie,Pe]=S.useState(_e);S.useEffect(()=>{Pe(_e)},[_e]);const $e=S.useMemo(()=>L.find(J=>J.id===Ie)?.name??L.find(J=>J.id===_e)?.name??e("Project"),[L,Ie,_e,e]),Oe=s==="zh-CN"?`你需要在 ${$e} 中做点什么?`:`What do you need to do in ${$e}?`,Ve=S.useMemo(()=>{const J=localStorage.getItem("lastSelectedProviderId");return J&&O.find(V=>V.provider.id===J&&V.availability.type!=="NOT_FOUND")?J:O.find(V=>V.availability.type!=="NOT_FOUND")?.provider.id??""},[O]),Ze=ml(),[Me,Re]=S.useState(!1),{usesIntegratedTitlebar:ve,desktopPlatform:Fe,hasMacTrafficLights:ge}=ga(),lt=ve&&Fe==="win32",Je=S.useCallback(()=>{if(L.length===0){rt.error(e("没有可用项目,请先创建或恢复项目"));return}Re(!0)},[L,e]),Et=S.useCallback(async J=>{await ie(J),Re(!1)},[ie]);return Ze?Me?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Re(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Oe}),t.jsx(so,{projects:at,providers:Xe,isProvidersLoading:b,onSubmit:Et,defaultProjectId:_e,defaultProviderId:Ve,onProjectChange:Pe,createStep:d})]})]}):F&&Y?t.jsxs(t.Fragment,{children:[t.jsx($0,{task:Y,onBack:()=>o(null),onDeleteTask:Y.projectArchivedAt?void 0:ne,isDeleting:$.isPending,autoStartState:m[Y.id]??null,onAutoStartRecovered:K}),t.jsx(Ui,{isOpen:i,onClose:pe})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(ro,{}),t.jsx(fa,{projects:M,filterProjectId:_,setFilterProjectId:p,onCreateProject:le})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ua,{}),t.jsx("button",{onClick:()=>Jn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(Zn,{size:16})})]})]}),Ae&&U.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ma,{})}):t.jsx(bo,{tasks:U,projects:M,selectedTaskId:null,onSelectTask:o,filterProjectId:_,setFilterProjectId:p,width:"100%",onCreateTask:Je,onCreateProject:le,onTaskStatusChange:te})]}),t.jsx(Ui,{isOpen:i,onClose:pe})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:se("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ve&&"app-region-drag",lt&&"pr-[150px]"),children:[t.jsxs("div",{className:se("flex items-center gap-2 min-w-0",ge&&"pl-[72px]"),children:[t.jsx(ro,{}),t.jsx(fa,{projects:M,filterProjectId:_,setFilterProjectId:p,onCreateProject:le,className:ve?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:se("flex items-center gap-1",ve&&"app-region-no-drag"),children:[t.jsx("div",{className:ve?"app-region-no-drag":void 0,children:t.jsx(ua,{})}),t.jsx("button",{onClick:()=>Jn.getState().openSettings(),className:se("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ve&&"app-region-no-drag"),children:t.jsx(Zn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ae&&U.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ma,{})}):t.jsx(bo,{tasks:U,projects:M,selectedTaskId:F,onSelectTask:o,filterProjectId:_,setFilterProjectId:p,width:v,onCreateTask:G,onCreateProject:le,isCreateActive:!F,onTaskStatusChange:te,onDeleteTask:ne}),t.jsx("div",{onMouseDown:he,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")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:F&&Y?t.jsx(b0,{task:Y,onDeleteTask:Y.projectArchivedAt?void 0:ne,isDeleting:$.isPending,onTaskStatusChange:Y.projectArchivedAt?void 0:te,autoStartState:m[Y.id]??null,onAutoStartRecovered:K}):F&&!Y?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.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:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Oe}),t.jsx(so,{projects:at,providers:Xe,isProvidersLoading:b,onSubmit:ie,defaultProjectId:_e,defaultProviderId:Ve,onProjectChange:Pe,createStep:d})]})})})]}),t.jsx(Ui,{isOpen:i,onClose:pe})]})}const zx=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:fx},Symbol.toStringTag,{value:"Module"}));export{zx as P,Ll as l};
|