@jingyi0605/codingns 0.8.5 → 0.9.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/bin/codingns.mjs +7 -156
- package/dist/public/assets/AdaptiveButlerPage-B17QiMyT.js +2 -0
- package/dist/public/assets/{App-BOHBGFOd.js → App-CFBwDUNA.js} +6 -6
- package/dist/public/assets/{BootstrapPage-BxHQT4nA.js → BootstrapPage-W5wU3BPh.js} +1 -1
- package/dist/public/assets/{ConversationPage-DWFsF6BB.js → ConversationPage-DQLX1bUh.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-DOgEjYEf.js → DesktopDetachPreviewPage-DTPeuAW-.js} +1 -1
- package/dist/public/assets/DesktopModal-6ii53_Y9.js +1 -0
- package/dist/public/assets/DesktopWindowPage-D0blSuKd.js +2 -0
- package/dist/public/assets/FileContextPanel-BrKO8Xt6.js +1 -0
- package/dist/public/assets/GitSidebar-BdwiDtOr.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-Cx_dBiBb.js +1 -0
- package/dist/public/assets/MobileSheet-opTWyRe1.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-lcp2GscV.js → MobileTopHeaderFrame-BbNON3Y4.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-BZEzPeMj.js +1 -0
- package/dist/public/assets/{PluginAccessOverview-DGcKAMQl.js → PluginAccessOverview-mQDmAljp.js} +1 -1
- package/dist/public/assets/PluginContainerPage-CcxUJpM4.js +1 -0
- package/dist/public/assets/{PluginDetailPage-CAJ7LFpD.js → PluginDetailPage-D5--ACIt.js} +1 -1
- package/dist/public/assets/{PluginsListPage-BxZG1NyT.js → PluginsListPage-D_oJxYXT.js} +1 -1
- package/dist/public/assets/{RelayConnectEntryPage-CfNO_TIl.js → RelayConnectEntryPage-DROxpnkv.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-by36Z_5k.js → ServerSettingsModal-CUUOPqSe.js} +1 -1
- package/dist/public/assets/SessionIndexPage-C2Jxh6Gp.js +1 -0
- package/dist/public/assets/SettingsPage-BlAZCHsy.js +2 -0
- package/dist/public/assets/{TerminalManagerPanel-NVZRxxmH.js → TerminalManagerPanel-CjzbiWjl.js} +1 -1
- package/dist/public/assets/{TerminalPage-C4LNoPBp.js → TerminalPage-CwWyFDj8.js} +2 -2
- package/dist/public/assets/TerminalRuntimeFallbackModal-CSVVbO8r.js +1 -0
- package/dist/public/assets/{ToolFilesPage-47zbdgTW.js → ToolFilesPage-QBEY8oCf.js} +1 -1
- package/dist/public/assets/{ToolGitPage-Fuk_b_jg.js → ToolGitPage-BKoZ2l9v.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-sWSMWD-9.js → ToolProcessesPage-BOH0ib4G.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-R1mZlbZi.js → ToolsHomePage-BcMZ3BCQ.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-CqmiFH2u.js → WorkbenchLandingPage-B5zoppEl.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-BksVkkFF.css +1 -0
- package/dist/public/assets/WorkbenchLayout-CikJBS62.js +1019 -0
- package/dist/public/assets/{WorkbenchModal-C7qoQElW.js → WorkbenchModal-NGmPgqaE.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-BbbSOiZw.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DT3VMjWD.css +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-CVivdPx5.js +1 -0
- package/dist/public/assets/{WorkspaceDetailPage-BPsrFffw.js → WorkspaceDetailPage-DgOSjscR.js} +1 -1
- package/dist/public/assets/{WorkspaceHomePage-KAtqZOAb.js → WorkspaceHomePage-HPa7M_Vh.js} +1 -1
- package/dist/public/assets/{client-runtime-manager-wmCJZKYd.js → client-runtime-manager-DXbI9K1K.js} +1 -1
- package/dist/public/assets/index-BxJPQpFM.css +1 -0
- package/dist/public/assets/index-CeXGOT_T.js +50 -0
- package/dist/public/assets/{login-direct-candidate-resolver-BOAgTuUf.js → login-direct-candidate-resolver-DkKyFtQJ.js} +1 -1
- package/dist/public/assets/{plugin-permission-copy-Cq99cnzV.js → plugin-permission-copy-CzN269Bk.js} +1 -1
- package/dist/public/assets/{plugins-api-BQTV5DOp.js → plugins-api-Bv9DHpLF.js} +1 -1
- package/dist/public/assets/{preferences-service-DJxbEEeg.js → preferences-service-D2ISL2Zz.js} +1 -1
- package/dist/public/assets/{relay-entry-D-LfvdiX.js → relay-entry-Bg0OisQy.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BJmy8dyK.js → terminal-runtime-meta-C8t-CIDF.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-DQAWVdCo.js → useRegisteredDebugTemplates-Bol3NVfN.js} +1 -1
- package/dist/public/assets/{workbench-navigation-MEzCSmsK.js → workbench-navigation-B7IjRQd8.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/middlewares/auth-guard.js +10 -5
- package/dist/server/middlewares/auth-guard.js.map +1 -1
- package/dist/server/modules/affairs-indexer/contracts/src/errors/app-error.d.ts +11 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/app-error.js +22 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/app-error.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/error-codes.d.ts +23 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/error-codes.js +23 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/error-codes.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/index.d.ts +4 -0
- package/dist/server/modules/affairs-indexer/contracts/src/index.js +5 -0
- package/dist/server/modules/affairs-indexer/contracts/src/index.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/cli-command-context.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/cli-command-context.js +2 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/cli-command-context.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/runtime-config.d.ts +16 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/runtime-config.js +2 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/runtime-config.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/config/load-runtime-config.d.ts +10 -0
- package/dist/server/modules/affairs-indexer/core/src/config/load-runtime-config.js +215 -0
- package/dist/server/modules/affairs-indexer/core/src/config/load-runtime-config.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/index.d.ts +31 -0
- package/dist/server/modules/affairs-indexer/core/src/index.js +32 -0
- package/dist/server/modules/affairs-indexer/core/src/index.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/logging/structured-logger.d.ts +20 -0
- package/dist/server/modules/affairs-indexer/core/src/logging/structured-logger.js +47 -0
- package/dist/server/modules/affairs-indexer/core/src/logging/structured-logger.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/base-complex-parser-adapter.d.ts +17 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/base-complex-parser-adapter.js +63 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/base-complex-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/complex-document-skip-adapter.d.ts +12 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/complex-document-skip-adapter.js +42 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/complex-document-skip-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/csv-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/csv-parser-adapter.js +107 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/csv-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/document-parser.d.ts +19 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/document-parser.js +37 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/document-parser.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/docx-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/docx-parser-adapter.js +123 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/docx-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/openxml-utils.d.ts +8 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/openxml-utils.js +111 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/openxml-utils.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-adapter.d.ts +42 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-adapter.js +2 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-capability-registry.d.ts +18 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-capability-registry.js +91 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-capability-registry.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-router.d.ts +18 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-router.js +59 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-router.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.d.ts +48 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.js +193 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pdf-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pdf-parser-adapter.js +371 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pdf-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser-adapter.d.ts +10 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser-adapter.js +55 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser.d.ts +9 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser.js +2 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pptx-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pptx-parser-adapter.js +130 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pptx-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/xlsx-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/xlsx-parser-adapter.js +228 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/xlsx-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.d.ts +205 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js +1471 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.d.ts +161 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.js +1350 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/scanner/file-scanner.d.ts +32 -0
- package/dist/server/modules/affairs-indexer/core/src/scanner/file-scanner.js +208 -0
- package/dist/server/modules/affairs-indexer/core/src/scanner/file-scanner.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.d.ts +30 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js +66 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.d.ts +33 -0
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js +705 -0
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/allowed-extensions-diff-service.d.ts +80 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/allowed-extensions-diff-service.js +193 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/allowed-extensions-diff-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/text-indexer.d.ts +77 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/text-indexer.js +467 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/text-indexer.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/mcp/mcp-stdio-server.d.ts +17 -0
- package/dist/server/modules/affairs-indexer/core/src/services/mcp/mcp-stdio-server.js +264 -0
- package/dist/server/modules/affairs-indexer/core/src/services/mcp/mcp-stdio-server.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/offline-search-service.d.ts +11 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/offline-search-service.js +76 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/offline-search-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.d.ts +26 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js +305 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/tagging/tag-recompute-service.d.ts +53 -0
- package/dist/server/modules/affairs-indexer/core/src/services/tagging/tag-recompute-service.js +566 -0
- package/dist/server/modules/affairs-indexer/core/src/services/tagging/tag-recompute-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/watch/watch-service.d.ts +47 -0
- package/dist/server/modules/affairs-indexer/core/src/services/watch/watch-service.js +227 -0
- package/dist/server/modules/affairs-indexer/core/src/services/watch/watch-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/catalog-schema.d.ts +5 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/catalog-schema.js +245 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/catalog-schema.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.d.ts +14 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js +87 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/init-catalog.d.ts +13 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/init-catalog.js +16 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/init-catalog.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/migration-runner.d.ts +22 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/migration-runner.js +430 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/migration-runner.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.d.ts +9 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js +19 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/tagging/simple-tag-inference.d.ts +21 -0
- package/dist/server/modules/affairs-indexer/core/src/tagging/simple-tag-inference.js +94 -0
- package/dist/server/modules/affairs-indexer/core/src/tagging/simple-tag-inference.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/abort.d.ts +2 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/abort.js +13 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/abort.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/file-streaming.d.ts +9 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/file-streaming.js +64 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/file-streaming.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/root-command-lock.d.ts +10 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/root-command-lock.js +230 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/root-command-lock.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/rss-log.d.ts +2 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/rss-log.js +19 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/rss-log.js.map +1 -0
- package/dist/server/modules/affairs-indexer/internal-command-runner.d.ts +31 -0
- package/dist/server/modules/affairs-indexer/internal-command-runner.js +643 -0
- package/dist/server/modules/affairs-indexer/internal-command-runner.js.map +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +0 -49
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +10 -56
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +2 -46
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +15 -158
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/browser-runtime/opencli-bridge-browser-executor.d.ts +4 -2
- package/dist/server/modules/browser-runtime/opencli-bridge-browser-executor.js +62 -21
- package/dist/server/modules/browser-runtime/opencli-bridge-browser-executor.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +3 -4
- package/dist/server/modules/butler/butler-control-session-service.js +39 -62
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-controller.d.ts +11 -3
- package/dist/server/modules/butler/butler-controller.js +19 -4
- package/dist/server/modules/butler/butler-controller.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
- package/dist/server/modules/butler/butler-profile-service.d.ts +1 -1
- package/dist/server/modules/butler/butler-profile-service.js +34 -63
- package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
- package/dist/server/modules/butler/butler-project-service.d.ts +1 -3
- package/dist/server/modules/butler/butler-project-service.js +1 -7
- package/dist/server/modules/butler/butler-project-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-service.d.ts +1 -0
- package/dist/server/modules/butler/butler-session-service.js +109 -0
- package/dist/server/modules/butler/butler-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-summary-service.js +0 -2
- package/dist/server/modules/butler/butler-session-summary-service.js.map +1 -1
- package/dist/server/modules/butler/butler-workspace-context.d.ts +5 -1
- package/dist/server/modules/butler/butler-workspace-context.js +21 -12
- package/dist/server/modules/butler/butler-workspace-context.js.map +1 -1
- package/dist/server/modules/file/file-content-service.d.ts +11 -0
- package/dist/server/modules/file/file-content-service.js +55 -0
- package/dist/server/modules/file/file-content-service.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +26 -1
- package/dist/server/modules/file/file-controller.js +59 -4
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +1 -0
- package/dist/server/modules/file/file-preview-link-service.js +25 -0
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/file-preview-service.js +15 -4
- package/dist/server/modules/file/file-preview-service.js.map +1 -1
- package/dist/server/modules/file/file-preview-types.d.ts +9 -1
- package/dist/server/modules/file/file-preview-types.js +8 -1
- package/dist/server/modules/file/file-preview-types.js.map +1 -1
- package/dist/server/modules/file/recent-modified-file-service.d.ts +15 -0
- package/dist/server/modules/file/recent-modified-file-service.js +102 -0
- package/dist/server/modules/file/recent-modified-file-service.js.map +1 -0
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +6 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +11 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +19 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -1
- package/dist/server/modules/file/workspace-index-apply-service.d.ts +25 -0
- package/dist/server/modules/file/workspace-index-apply-service.js +42 -0
- package/dist/server/modules/file/workspace-index-apply-service.js.map +1 -0
- package/dist/server/modules/office/office-controller.d.ts +15 -1
- package/dist/server/modules/office/office-controller.js +26 -1
- package/dist/server/modules/office/office-controller.js.map +1 -1
- package/dist/server/modules/office/onlyoffice-integration-service.d.ts +78 -0
- package/dist/server/modules/office/onlyoffice-integration-service.js +610 -0
- package/dist/server/modules/office/onlyoffice-integration-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +12 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +13 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -1
- package/dist/server/modules/preferences/profile-service.d.ts +1 -0
- package/dist/server/modules/preferences/profile-service.js +27 -3
- package/dist/server/modules/preferences/profile-service.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +0 -8
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/session-controller.d.ts +1 -0
- package/dist/server/modules/sessions/session-controller.js +3 -0
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +2 -0
- package/dist/server/modules/sessions/session-history-service.js +78 -3
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +1 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +4 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-permission-request-service.js +0 -4
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/sessions/workspace-session-instruction-watch-service.d.ts +23 -0
- package/dist/server/modules/sessions/workspace-session-instruction-watch-service.js +122 -0
- package/dist/server/modules/sessions/workspace-session-instruction-watch-service.js.map +1 -0
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.d.ts +15 -0
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +93 -10
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/SKILL.md +6 -7
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/references/cli-workflow.md +2 -3
- package/dist/server/modules/system/host-resource-controller.d.ts +7 -0
- package/dist/server/modules/system/host-resource-controller.js +12 -0
- package/dist/server/modules/system/host-resource-controller.js.map +1 -0
- package/dist/server/modules/system/host-resource-service.d.ts +54 -0
- package/dist/server/modules/system/host-resource-service.js +162 -0
- package/dist/server/modules/system/host-resource-service.js.map +1 -0
- package/dist/server/modules/tasks/observability-service.d.ts +12 -2
- package/dist/server/modules/tasks/observability-service.js +13 -1
- package/dist/server/modules/tasks/observability-service.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-client.d.ts +36 -2
- package/dist/server/modules/tasks/task-helper-client.js +201 -19
- package/dist/server/modules/tasks/task-helper-client.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-pool.d.ts +37 -0
- package/dist/server/modules/tasks/task-helper-pool.js +173 -0
- package/dist/server/modules/tasks/task-helper-pool.js.map +1 -0
- package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +27 -0
- package/dist/server/modules/tasks/task-helper-process-handlers.js +25 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process.js +75 -26
- package/dist/server/modules/tasks/task-helper-process.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-scheduling.d.ts +11 -0
- package/dist/server/modules/tasks/task-helper-scheduling.js +43 -0
- package/dist/server/modules/tasks/task-helper-scheduling.js.map +1 -0
- package/dist/server/modules/tasks/task-lane-executors.js +19 -3
- package/dist/server/modules/tasks/task-lane-executors.js.map +1 -1
- package/dist/server/modules/tasks/task-manager.d.ts +1 -0
- package/dist/server/modules/tasks/task-manager.js +3 -0
- package/dist/server/modules/tasks/task-manager.js.map +1 -1
- package/dist/server/modules/tasks/task-registry.d.ts +1 -0
- package/dist/server/modules/tasks/task-registry.js +3 -0
- package/dist/server/modules/tasks/task-registry.js.map +1 -1
- package/dist/server/modules/tasks/task-scheduler.d.ts +6 -0
- package/dist/server/modules/tasks/task-scheduler.js +162 -7
- package/dist/server/modules/tasks/task-scheduler.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +28 -3
- package/dist/server/modules/tasks/task-types.js +14 -2
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.d.ts +68 -0
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js +286 -0
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js.map +1 -0
- package/dist/server/modules/workbench/workbench-controller.js +11 -1
- package/dist/server/modules/workbench/workbench-controller.js.map +1 -1
- package/dist/server/modules/workbench/workbench-service.d.ts +9 -2
- package/dist/server/modules/workbench/workbench-service.js +58 -18
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workspace/affairs-library-controller.d.ts +117 -0
- package/dist/server/modules/workspace/affairs-library-controller.js +164 -0
- package/dist/server/modules/workspace/affairs-library-controller.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-debug-log.d.ts +23 -0
- package/dist/server/modules/workspace/affairs-library-debug-log.js +107 -0
- package/dist/server/modules/workspace/affairs-library-debug-log.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-dirty-watch-service.d.ts +52 -0
- package/dist/server/modules/workspace/affairs-library-dirty-watch-service.js +555 -0
- package/dist/server/modules/workspace/affairs-library-dirty-watch-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.d.ts +24 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.js +157 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-refresh-contract.d.ts +56 -0
- package/dist/server/modules/workspace/affairs-library-refresh-contract.js +48 -0
- package/dist/server/modules/workspace/affairs-library-refresh-contract.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-service.d.ts +344 -0
- package/dist/server/modules/workspace/affairs-library-service.js +3755 -0
- package/dist/server/modules/workspace/affairs-library-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.d.ts +78 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.js +146 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.js.map +1 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.d.ts +133 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js +1447 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-tag-controller.d.ts +107 -0
- package/dist/server/modules/workspace/affairs-tag-controller.js +97 -0
- package/dist/server/modules/workspace/affairs-tag-controller.js.map +1 -0
- package/dist/server/modules/workspace/affairs-tag-service.d.ts +153 -0
- package/dist/server/modules/workspace/affairs-tag-service.js +680 -0
- package/dist/server/modules/workspace/affairs-tag-service.js.map +1 -0
- package/dist/server/modules/workspace/workspace-controller.d.ts +2 -1
- package/dist/server/modules/workspace/workspace-controller.js +8 -2
- package/dist/server/modules/workspace/workspace-controller.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.js +60 -9
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/routes/affairs.d.ts +3 -0
- package/dist/server/routes/affairs.js +7 -0
- package/dist/server/routes/affairs.js.map +1 -0
- package/dist/server/routes/assistant.js +0 -5
- package/dist/server/routes/assistant.js.map +1 -1
- package/dist/server/routes/files.js +5 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/office.js +4 -0
- package/dist/server/routes/office.js.map +1 -1
- package/dist/server/routes/system.d.ts +2 -1
- package/dist/server/routes/system.js +2 -1
- package/dist/server/routes/system.js.map +1 -1
- package/dist/server/routes/workspaces.d.ts +4 -1
- package/dist/server/routes/workspaces.js +46 -1
- package/dist/server/routes/workspaces.js.map +1 -1
- package/dist/server/server/create-server.d.ts +6 -2
- package/dist/server/server/create-server.js +113 -32
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +10 -0
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/storage/repositories/affairs-assistant-session-snapshot-repository.d.ts +10 -0
- package/dist/server/storage/repositories/affairs-assistant-session-snapshot-repository.js +47 -0
- package/dist/server/storage/repositories/affairs-assistant-session-snapshot-repository.js.map +1 -0
- package/dist/server/storage/repositories/butler-profile-repository.js +7 -3
- package/dist/server/storage/repositories/butler-profile-repository.js.map +1 -1
- package/dist/server/storage/repositories/office-onlyoffice-setting-repository.d.ts +19 -0
- package/dist/server/storage/repositories/office-onlyoffice-setting-repository.js +55 -0
- package/dist/server/storage/repositories/office-onlyoffice-setting-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-index-repository.js +9 -2
- package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.d.ts +10 -0
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.js +69 -0
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-preference-profile-repository.js +6 -3
- package/dist/server/storage/repositories/user-preference-profile-repository.js.map +1 -1
- package/dist/server/storage/repositories/workspace-navigation-state-repository.d.ts +3 -0
- package/dist/server/storage/repositories/workspace-navigation-state-repository.js +47 -4
- package/dist/server/storage/repositories/workspace-navigation-state-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.js +230 -123
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +48 -25
- package/dist/server/types/domain.d.ts +27 -20
- package/dist/server/ws/workbench-ws-hub.js +2 -2
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +0 -2
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +0 -6
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/AdaptiveButlerPage-B153lk5H.css +0 -1
- package/dist/public/assets/AdaptiveButlerPage-CJw8Ae62.js +0 -3
- package/dist/public/assets/DesktopModal-D_A8sgQU.js +0 -1
- package/dist/public/assets/DesktopWindowPage-DK7L7osV.js +0 -2
- package/dist/public/assets/FileContextPanel-BdCoubcJ.js +0 -1
- package/dist/public/assets/GitSidebar-BeZ0hj7A.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-DfLMVu8q.js +0 -1
- package/dist/public/assets/MobileSheet-5kZ-w-gU.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-C6JMiOq_.js +0 -1
- package/dist/public/assets/PluginContainerPage-BlY-xJDh.js +0 -1
- package/dist/public/assets/SessionIndexPage-DkBp9Mqz.js +0 -1
- package/dist/public/assets/SettingsPage-C-ASmJAG.js +0 -2
- package/dist/public/assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js +0 -1
- package/dist/public/assets/WorkbenchLayout-OFi6CWgH.js +0 -244
- package/dist/public/assets/WorkbenchShellRoute-B4XB8SwG.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-BAQe_E0O.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-DhKa6e9y.js +0 -1
- package/dist/public/assets/file-tree-icon-Mg1DiBRX.js +0 -590
- package/dist/public/assets/index-C4t-vvqk.css +0 -1
- package/dist/public/assets/index-CL97fwWB.js +0 -42
- package/dist/public/assets/realtime-client-CLafKzzJ.js +0 -1
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.d.ts +0 -32
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js +0 -93
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js.map +0 -1
- package/dist/server/modules/butler/assistant-sandbox-service.d.ts +0 -69
- package/dist/server/modules/butler/assistant-sandbox-service.js +0 -399
- package/dist/server/modules/butler/assistant-sandbox-service.js.map +0 -1
- package/dist/server/modules/channels/wechat-claw-client.d.ts +0 -51
- package/dist/server/modules/channels/wechat-claw-client.js +0 -245
- package/dist/server/modules/channels/wechat-claw-client.js.map +0 -1
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.d.ts +0 -18
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js +0 -191
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js.map +0 -1
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-BdCoubcJ.js","assets/index-CL97fwWB.js","assets/index-C4t-vvqk.css","assets/App-BOHBGFOd.js","assets/App-CcDXqFl1.css","assets/workbench-navigation-MEzCSmsK.js","assets/WorkbenchModal-C7qoQElW.js","assets/DesktopModal-D_A8sgQU.js","assets/file-tree-icon-Mg1DiBRX.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-D-LfvdiX.js","assets/MobileSheet-5kZ-w-gU.js","assets/GitSidebar-BeZ0hj7A.js","assets/TerminalManagerPanel-NVZRxxmH.js","assets/terminal-runtime-meta-BJmy8dyK.js","assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var dy=Object.defineProperty;var hy=(e,t,n)=>t in e?dy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Qe=(e,t,n)=>hy(e,typeof t!="symbol"?t+"":t,n);import{C as Y,A as il,b as f,T as Qf,t as l,j as s,e as ir,m as ho,J as Su,K as Zf,F as py,w as Cu,g as em,D as fy,p as ol,U as my,V as gy,W as tm,i as nm,X as Bc,f as al,Y as by,h as Oa,Z as ky,l as rm,y as yy,n as wy,z as xy,d as vy,_ as Nu}from"./index-CL97fwWB.js";import{e as Pn,t as ut,h as ll,u as Co,f as ar,g as $r,j as Sy,p as Cy,O as Nd}from"./App-BOHBGFOd.js";import{c as Ts,d as sm,M as Rn,s as bi,t as Xt,u as qo,G as Ba,q as Lt,v as Ns,b as jr,g as im,w as Ny,a as po,F as om,D as jy,O as am,f as lm,H as wn,i as cm,h as um,e as Es,Q as dm,R as hm,L as Ty,o as Iy,S as Ay,z as Ry,p as Ui,n as li,J as Ey,x as Py,T as My,r as Ly,k as Dy}from"./workbench-navigation-MEzCSmsK.js";import{t as hi,P as _a,g as pm}from"./window-BVUB8gMK.js";import{R as Oy,_ as jd,a as Td,C as fm,i as ze}from"./event-DvH9tcej.js";import{M as By,D as ju}from"./DesktopModal-D_A8sgQU.js";import{W as St}from"./WorkbenchModal-C7qoQElW.js";import{r as _y,b as Wy}from"./relay-entry-D-LfvdiX.js";import{M as Fy}from"./MobileSheet-5kZ-w-gU.js";function _c(){return Y.request("/api/workspaces")}async function $y(){try{return await Y.request("/api/workbench")}catch(e){if(!(e instanceof il)||e.status!==404)throw e;const t=await _c();return{items:await Promise.all(t.items.map(async r=>({workspace:r,sessions:(await Ky(r.id)).items})))}}}function zy(e){return Y.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function Uy(e){return Y.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function Hy(e){return Y.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function HL(e){return Y.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function qL(e,t){return Y.request(`/api/debug-targets/${encodeURIComponent(e)}/launch-plan`,{method:"POST",body:JSON.stringify({})})}function GL(){return Y.request("/api/framework-compatibility-matrix")}function qy(e){return Y.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function mm(e,t){return Y.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(t)})}function gm(e){const t=new URLSearchParams;return e!=null&&e.trim()&&t.set("path",e.trim()),Y.request(`/api/workspaces/browse${t.size>0?`?${t.toString()}`:""}`)}function Gy(e){return Y.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function Ky(e){return Y.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function KL(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}`)}function VL(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function YL(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function bm(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:t})})}function km(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:t})})}function Vy(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:t})})}function Id(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Yy(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/parallel-groups`,{method:"POST",body:JSON.stringify(t)})}function Jy(e,t){return Y.request(`/api/workspaces/${encodeURIComponent(e)}/parallel-groups`,{method:"POST",body:JSON.stringify(t)})}function JL(e){return Y.request(`/api/parallel-groups/${encodeURIComponent(e)}`)}function Xy(e,t){return Y.request(`/api/parallel-groups/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)})}function XL(e){return Y.request(`/api/session-isolated-workspaces/${encodeURIComponent(e)}/promote`,{method:"POST"})}function Qy(e){return Y.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function Zy(e){return Y.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function ew(e){return Y.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function tw(e,t){return Y.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(t??{})})}function QL(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function nw(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function ZL(){return Y.request("/api/preferences/quick-phrases")}function eD(e){return Y.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function Tu(e,t,n){var i;const r=new URLSearchParams;return t!=null&&t.trim()&&r.set("workspaceId",t.trim()),(n==null?void 0:n.providerConfigMode)==="cc-switch-preset"&&((i=n.providerPresetId)!=null&&i.trim())&&(r.set("providerConfigMode","cc-switch-preset"),r.set("providerPresetId",n.providerPresetId.trim())),Y.request(`/api/providers/${encodeURIComponent(e)}/capabilities${r.size>0?`?${r.toString()}`:""}`)}async function rw(){return(await Y.request("/api/providers/catalog")).items}async function sw(){return(await Y.request("/api/providers/catalog/refresh",{method:"POST"})).items}async function iw(e,t){return(await Y.request(`/api/providers/catalog/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({enabled:t})})).item}async function ym(e,t){const n=await Promise.allSettled(e.map(async i=>[i,await Tu(i,t)])),r=[];for(const i of n){if(i.status!=="fulfilled")continue;const[o,a]=i.value;r.push([o,a])}return Object.fromEntries(r)}function wm(e,t,n,r="forward"){const i=new URLSearchParams;return t&&i.set("cursor",t),i.set("limit",String(n)),i.set("direction",r),Y.request(`/api/sessions/${encodeURIComponent(e)}/messages?${i.toString()}`)}function ow(e,t){return Y.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content`)}function tD(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})}function nD(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(t)})}function rD(e){return Y.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function sD(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(t)})}function iD(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function oD(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(t)})}function aD(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(t)}`,{method:"DELETE"})}function lD(e,t){return Y.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(t)}/steer`,{method:"POST"})}function cD(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function uD(e){return Y.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function dD(e,t,n){return Y.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(t)}/reply`,{method:"POST",body:JSON.stringify(n)})}const Ta="codingns.workspace.session-display-sort-mode",Ia="codingns.file-panel.show-system-files",Iu="codingns.notification.preferences",ei={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function vi(){return typeof window<"u"&&typeof window.localStorage<"u"}function aw(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function Ad(){if(!vi())return"createdAt";const e=window.localStorage.getItem(Ta);return aw(e)?e:"createdAt"}function Rd(){return vi()?window.localStorage.getItem(Ia)==="1":!1}function Ul(e){return typeof e=="boolean"}function Ed(){if(!vi())return ei;const e=window.localStorage.getItem(Iu);if(!e)return ei;try{const t=JSON.parse(e);return{notifyOnPermissionRequest:Ul(t.notifyOnPermissionRequest)?t.notifyOnPermissionRequest:ei.notifyOnPermissionRequest,notifyOnSessionCompleted:Ul(t.notifyOnSessionCompleted)?t.notifyOnSessionCompleted:ei.notifyOnSessionCompleted,notifyOnSessionFailed:Ul(t.notifyOnSessionFailed)?t.notifyOnSessionFailed:ei.notifyOnSessionFailed}}catch{return ei}}function Pd(e,t){return e.notifyOnPermissionRequest===t.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===t.notifyOnSessionCompleted&&e.notifyOnSessionFailed===t.notifyOnSessionFailed}function lw(e){vi()&&window.localStorage.setItem(Iu,JSON.stringify(e))}class cw{constructor(){Qe(this,"state",{sessionDisplaySortMode:Ad(),showSystemFiles:Rd(),notificationPreferences:Ed()});Qe(this,"listeners",new Set);Qe(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));Qe(this,"getState",()=>this.state);Qe(this,"handleStorage",t=>{if(t.key!==null&&t.key!==Ta&&t.key!==Ia&&t.key!==Iu)return;const n=Ad(),r=Rd(),i=Ed(),o=this.state.sessionDisplaySortMode===n,a=this.state.showSystemFiles===r,c=Pd(this.state.notificationPreferences,i);o&&a&&c||(this.state={sessionDisplaySortMode:n,showSystemFiles:r,notificationPreferences:i},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(t){vi()&&(t==="createdAt"?window.localStorage.removeItem(Ta):window.localStorage.setItem(Ta,t)),this.state.sessionDisplaySortMode!==t&&(this.state={...this.state,sessionDisplaySortMode:t},this.emit())}setShowSystemFiles(t){vi()&&(t?window.localStorage.setItem(Ia,"1"):window.localStorage.removeItem(Ia)),this.state.showSystemFiles!==t&&(this.state={...this.state,showSystemFiles:t},this.emit())}setNotificationPreferences(t){const n={...this.state.notificationPreferences,...t};Pd(this.state.notificationPreferences,n)||(lw(n),this.state={...this.state,notificationPreferences:n},this.emit())}emit(){for(const t of this.listeners)t()}}const Md=new cw;function Go(e){return f.useSyncExternalStore(Md.subscribe,()=>e(Md.getState()))}const pi=new Map,xm=48;function Ds(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function Ld(e,t){return!Number.isFinite(e)||Date.now()-e>t}function uw(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function vm(e){try{const t=JSON.parse(e);return uw(t)?t:null}catch{return null}}function dw(){if(!Ds())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Sm(){if(!Ds())return[];const e=[];for(const t of dw()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=vm(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function fo(e){if(Ds())try{window.sessionStorage.removeItem(e)}catch{}}function Ko(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??xm,r=Sm().filter(o=>!t.has(o.key)),i=Math.max(0,t.size+r.length-n);for(let o=0;o<i;o+=1){const a=r[o];if(!a)break;fo(a.key)}}function hw(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Hl(e,t){if(!Ds())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return hw(n)?"quota_exceeded":"failed"}}function pw(e,t){const n=Hl(e,t);if(n==="success"){Ko({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(fo(e),Ko({maxCount:Math.max(0,xm-1)}),Hl(e,t)==="success"){Ko({preserveKeys:[e]});return}for(const r of Sm())if(r.key!==e&&(fo(r.key),Hl(e,t)==="success")){Ko({preserveKeys:[e]});return}}}function Wa(e,t){const n=pi.get(e);if(n){if(!Ld(n.savedAt,t))return n.value;pi.delete(e)}if(!Ds())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=vm(r);return!i||Ld(i.savedAt,t)?(fo(e),pi.delete(e),null):(pi.set(e,i),i.value)}function io(e,t){const n={savedAt:Date.now(),value:t};if(pi.set(e,n),!!Ds())try{pw(e,JSON.stringify(n))}catch{}}function hD(e){pi.delete(e),Ds()&&fo(e)}const fw="codingns.debug.perf",mw="codingns.debug.sessionMessageDedup",gw="codingns.debug.timelineScroll",bw="codingns.debug.conversationTimeline";function kw(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(fw)==="1"}catch{return!1}}function un(e,t){if(!kw()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function yw(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(mw)==="1"}catch{return!1}}function cs(e,t){if(!yw()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function ww(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(bw)==="1"}catch{return!1}}function xw(e,t){if(!ww()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window;i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__!==!0&&(i.__CODINGNS_OPENCODE_ORDER_DEBUG__=[],i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=[],i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=[],i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=[],i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__=!0);const o=i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__??[];o.push(r),o.length>400&&o.splice(0,o.length-400),i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[conversation-timeline] ${e} ${n}ms`,t);return}console.info(`[conversation-timeline] ${e} ${n}ms`)}function Wc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(gw)==="1"}catch{return!1}}function vw(e,t){if(!Wc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function Cm(e){return Y.request(`/api/office/artifacts/${encodeURIComponent(e)}/preview-link`)}function Nm(e,t){return Y.request(`/api/office/tasks/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/preview-link`)}function pD(e,t){const n=new URLSearchParams({workspaceId:e});return t&&n.set("path",t),Y.request(`/api/files/tree?${n.toString()}`)}function fD(e,t,n,r){return Y.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function mD(e){return Y.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function gD(e){return Y.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function bD(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return Y.request(`/api/files/download?${n.toString()}`)}function Sw(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return Y.request(`/api/files/search?${i.toString()}`)}function kD(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return Y.request(`/api/files/preview?${n.toString()}`)}function jm(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return Y.request(`/api/files/preview-link?${n.toString()}`)}function yD(e){return Y.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function wD(e){return Y.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function xD(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return Y.request(`/api/git/diff?${r.toString()}`)}function vD(e,t){return Y.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function SD(e,t){return Y.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function CD(e,t){return Y.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function ND(e,t){return Y.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function jD(e,t){return Y.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function TD(e){return Y.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function ID(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),Y.request(`/api/git/history?${r.toString()}`)}function AD(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return Y.request(`/api/git/commit-detail?${n.toString()}`)}function Cw(e){return Y.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Nw(e){return Y.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function RD(e,t,n){return Y.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function ED(e,t,n,r,i){return Y.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function PD(e){return Y.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}const jw={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function Tm(e){return{...e,bounds:{...e.bounds},payload:{...e.payload}}}function Im(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function Tw(e){return jw[e]}function Am(e,t){return`${e}-${t}`}function Rm(e){return e.trim().replace(/\\/g,"/")}function Dd(e){return encodeURIComponent(e).replace(/%/g,"_").replace(/\./g,"_")}function Iw(e,t){const n=e.trim(),r=Rm(t);return`file-preview-${Dd(n)}-${Dd(r)}`}async function cl(e,t,n){const r=n.workspaceId.trim(),i=Tw(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const o=Am(t,r),a=e.windows.getDescriptor(o),c=a?Tm(a):null,u=e.windows.isWindowOpen(o),d=Qf({windowId:o,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(o),{ok:!0,value:d}):(c?Im(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:h.errorCode,detail:h.detail})}async function Aw(e,t,n){const r=n.workspaceId.trim(),i=Rm(n.filePath);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:"文件预览外部窗口必须绑定工作区。"};if(!i)return{ok:!1,errorCode:"WINDOW_FILE_REQUIRED",detail:"文件预览外部窗口必须指定文件。"};const o=Iw(r,i),a=e.windows.getDescriptor(o),c=a?Tm(a):null,u=e.windows.isWindowOpen(o),d=Qf({windowId:o,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:n.bounds??(c==null?void 0:c.bounds)??{width:1120,height:760,minWidth:720,minHeight:480},focusOwner:n.focusOwner??"file-preview-window",payload:{filePath:i}});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(o),{ok:!0,value:d}):(c?Im(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function MD(e){return Am("terminals",e)}function Rw(e,t){return cl(e,"files",t)}function Ew(e,t){return cl(e,"git",t)}function Pw(e,t){return cl(e,"processes",t)}function LD(e,t){return cl(e,"terminals",t)}function DD(e,t){return Aw(e,"file-preview",t)}var Aa,Ra;function Em(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:Em(n));else if("action"in e&&e.action){const n=new fm;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function Ni(e,t){const n=new fm;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=hi(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=hi(t.icon)),"items"in t&&t.items)){let r=function(i){var o;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((o=i.item.About)===null||o===void 0)&&o.icon)&&(i.item.About.icon=hi(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=hi(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),Em(i))};t.items=t.items.map(r)}return ze("plugin:menu|new",{kind:e,options:t,handler:n})}class ji extends Oy{get id(){return jd(this,Aa,"f")}get kind(){return jd(this,Ra,"f")}constructor(t,n,r){super(t),Aa.set(this,void 0),Ra.set(this,void 0),Td(this,Aa,n),Td(this,Ra,r)}}Aa=new WeakMap,Ra=new WeakMap;class Au extends ji{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return Ni("MenuItem",t).then(([n,r])=>new Au(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class Ru extends ji{constructor(t,n){super(t,n,"Check")}static async new(t){return Ni("Check",t).then(([n,r])=>new Ru(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return ze("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return ze("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var Od;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(Od||(Od={}));class Eu extends ji{constructor(t,n){super(t,n,"Icon")}static async new(t){return Ni("Icon",t).then(([n,r])=>new Eu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return ze("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:hi(t)})}}class Pu extends ji{constructor(t,n){super(t,n,"Predefined")}static async new(t){return Ni("Predefined",t).then(([n,r])=>new Pu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function ki([e,t,n]){switch(n){case"Submenu":return new ul(e,t);case"Predefined":return new Pu(e,t);case"Check":return new Ru(e,t);case"Icon":return new Eu(e,t);case"MenuItem":default:return new Au(e,t)}}class ul extends ji{constructor(t,n){super(t,n,"Submenu")}static async new(t){return Ni("Submenu",t).then(([n,r])=>new ul(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return ze("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return ze("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return ze("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return ze("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ze("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ki)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ki))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ki(n):null)}async popup(t,n){var r;return ze("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof _a?t:t?new _a(t):null})}async setAsWindowsMenuForNSApp(){return ze("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return ze("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return ze("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:hi(t)})}}class fi extends ji{constructor(t,n){super(t,n,"Menu")}static async new(t){return Ni("Menu",t).then(([n,r])=>new fi(n,r))}static async default(){return ze("plugin:menu|create_default").then(([t,n])=>new fi(t,n))}async append(t){return ze("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return ze("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return ze("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return ze("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ze("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ki)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ki))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ki(n):null)}async popup(t,n){var r;return ze("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof _a?t:t?new _a(t):null})}async setAsAppMenu(){return ze("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new fi(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return ze("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new fi(r[0],r[1]):null)}}async function Mw(e){if(e.length===0)return;await(await fi.new({items:await Promise.all(e.map(n=>Pm(n)))})).popup(void 0,pm())}async function Pm(e){return"items"in e?ul.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>Pm(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}function dl(){return Pn().haptics}const Lw="mobile.tools.last-primary-tool";function Mm(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Lw)==="git"?"git":"files"}catch{return"files"}}function Mu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const o=ut(i.pattern,e),a=((r=o==null?void 0:o.params.workspaceId)==null?void 0:r.trim())??null;if(a)return{workspaceId:a,routeKind:i.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of n)if(ut(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function Dw(e,t){const n=Mu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":Mm()}function Lu(e,t){const n=Mu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?Ts(n.workspaceId):n!=null&&n.workspaceId?sm(n.workspaceId,Dw(e,t)):n!=null&&n.legacy?Mm()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Du({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const o=Mu(n);return o?o.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(o.routeKind==="home"||o.routeKind==="files"||o.routeKind==="git",null):null}const Lm=f.createContext({composerPortalTarget:null});function Ou({composerPortalTarget:e,children:t}){return s.jsx(Lm.Provider,{value:{composerPortalTarget:e},children:t})}function OD(){return f.useContext(Lm)}function Bu(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const o=e.current,a=t.current;if(!n||!o||!a){i(void 0),o&&o.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=o,u=a;function d(){if(!e.current||!u.isConnected)return;const p=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",p),i(p)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const Ow=3e3,Vo=10,Bd=84,_d=.36;function _u({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),o=f.useRef(null),a=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{a.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function g(){vs(i),i.current=window.setTimeout(()=>{m()},Ow)}function m(){d("hidden"),p(0)}function k(){d("visible"),p(1),g()}f.useEffect(()=>{if(vs(i),!e){vs(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return k(),()=>{vs(i)}},[e,r,n]),f.useEffect(()=>()=>{vs(i)},[]),f.useEffect(()=>{if(!e||n){o.current=null;return}const v=t.current;if(!v)return;function w(z){if(z.touches.length!==1){o.current=null;return}const L=z.touches[0],A=$d(z.target);if(!L||!A){o.current=null;return}o.current={surface:A,startX:L.clientX,startY:L.clientY,pointerType:"touch",initialState:a.current==="visible"?"visible":"hidden",touchId:L.identifier,dragging:!1,latestProgress:c.current},a.current==="visible"&&vs(i)}function R(z){const L=o.current;if(!L||L.pointerType!=="touch")return;const A=ql(z.touches,L.touchId);if(!A)return;const U=A.clientX-L.startX,B=A.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(B)<=Vo||Math.abs(B)<=Math.abs(U))return;o.current=null,L.initialState==="visible"&&m();return}const le=L.initialState==="hidden"?-B:B;le<=Vo&&!L.dragging||(Ud(z),L.dragging=!0,L.latestProgress=Wd(L.initialState,le),d("dragging"),p(L.latestProgress))}function T(z){const L=o.current;if(!(!L||L.pointerType!=="touch"||!ql(z.changedTouches,L.touchId))){if(o.current=null,!L.dragging){L.initialState==="visible"&&g();return}Fd(L.initialState,L.latestProgress,k,d,p)}}function F(z){const L=o.current;if(!(!L||L.pointerType!=="touch"||!ql(z.changedTouches,L.touchId))){if(o.current=null,!L.dragging){L.initialState==="visible"&&g();return}if(L.initialState==="visible"){k();return}d("hidden"),p(0)}}function E(z){if(z.pointerType!=="touch")return;const L=$d(z.target);if(!L){o.current=null;return}if(o.current={surface:L,startX:z.clientX,startY:z.clientY,pointerType:"pointer",initialState:a.current==="visible"?"visible":"hidden",pointerId:z.pointerId,captureTarget:z.target instanceof Element?z.target:null,dragging:!1,latestProgress:c.current},z.target instanceof Element)try{z.target.setPointerCapture(z.pointerId)}catch{}a.current==="visible"&&vs(i)}function I(z){const L=o.current;if(!L||L.pointerType!=="pointer")return;const A=z.clientX-L.startX,U=z.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(U)<=Vo||Math.abs(U)<=Math.abs(A))return;o.current=null,L.initialState==="visible"&&m();return}const B=L.initialState==="hidden"?-U:U;B<=Vo&&!L.dragging||(Ud(z),L.dragging=!0,L.latestProgress=Wd(L.initialState,B),d("dragging"),p(L.latestProgress))}function q(z){const L=o.current;if(!(!L||L.pointerType!=="pointer"||L.pointerId!==z.pointerId)){if(o.current=null,Bw(L),!L.dragging){L.initialState==="visible"&&g();return}Fd(L.initialState,L.latestProgress,k,d,p)}}return v.addEventListener("touchstart",w,{passive:!0}),v.addEventListener("pointerdown",E,{passive:!0}),window.addEventListener("touchmove",R,{passive:!1}),window.addEventListener("touchend",T),window.addEventListener("touchcancel",F),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",q),window.addEventListener("pointercancel",q),()=>{v.removeEventListener("touchstart",w),v.removeEventListener("pointerdown",E),window.removeEventListener("touchmove",R),window.removeEventListener("touchend",T),window.removeEventListener("touchcancel",F),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",q),window.removeEventListener("pointercancel",q)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function vs(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function Wd(e,t){return zd(e==="hidden"?t/Bd:1-t/Bd,0,1)}function Fd(e,t,n,r,i){if(e==="hidden"){if(t>=_d){n();return}r("hidden"),i(0);return}if(t<=1-_d){r("hidden"),i(0);return}n()}function Bw(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function ql(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function $d(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function zd(e,t,n){return Math.min(Math.max(e,t),n)}function Ud(e){e.cancelable&&e.preventDefault()}function No({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function hl(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function Dm(e){return e==="medium-navigation"||e==="expanded"}function Om(e){return e==="medium-auxiliary"||e==="expanded"}function Wu({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:o,navigationPanel:a,auxiliaryPanel:c}){const u=No({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=Dm(u)&&a,h=Om(u)&&c;return s.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?s.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:a}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:o}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function _w({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=Pn(),g=dl(),m=ll(),k=Co(),S=f.useRef(null),v=f.useRef(null),[w,R]=f.useState(null),T=t==="conversation-focus",F=hl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),E=_u({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=No({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),q=Du({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.androidMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx($w,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(zw,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Hw,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Uw,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(qw,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":E.progress.toFixed(4)}:void 0;Bu(S,v,T);function A(){const B=Lu(m.pathname,m.search);if(!B){a();return}k(B,{replace:!0})}const U=s.jsx("nav",{ref:v,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:z.map(B=>s.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&g.trigger("selection"),B.onClick()},children:[s.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:B.icon}),s.jsx("span",{className:"android-workbench-bottom-nav-label",children:B.label})]},B.key))});return s.jsx(Ou,{composerPortalTarget:T?w:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":T?E.isOpen:!0,"data-conversation-tabbar-state":T?E.state:"default",style:L,children:[q?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[q.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:A,children:s.jsx(Ww,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:q.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:q.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":q.moreButtonLabel,onClick:d,children:s.jsx(Fw,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(Wu,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:R,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:U})]}):U]})})}function Ww(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function Fw(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function $w(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function zw(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Uw(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Hw(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function qw(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const Gw=120,Qi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Fc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Kw(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function Vw(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(Fc);return e.length>0?Math.max(...e):0}function Hd(){if(typeof window>"u")return Qi;const e=window.visualViewport,t=Vw(),n=(e==null?void 0:e.height)??t,r=Fc(n)?Math.round(n):null,i=Fc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,o=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:o,keyboardOpen:Kw(typeof document<"u"?document.activeElement:null)&&o>=Gw}}function Gl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function Yw(e){const[t,n]=f.useState(()=>e?Hd():Qi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Qi),Gl(!1,Qi);return}function i(){n(Hd())}function o(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const a=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),a==null||a.addEventListener("resize",i),a==null||a.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",o),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),a==null||a.removeEventListener("resize",i),a==null||a.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",o),Gl(!1,Qi)}},[e]),f.useEffect(()=>{Gl(e,t)},[e,t]),t}function Jw({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=Pn(),g=dl(),m=ll(),k=Co(),S=f.useRef(null),v=f.useRef(null),[w,R]=f.useState(null),T=t==="conversation-focus",F=hl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),E=_u({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=No({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),q=Du({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Zw,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(ex,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(nx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(tx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(rx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":E.progress.toFixed(4)}:void 0;Bu(S,v,T);function A(){const B=Lu(m.pathname,m.search);if(!B){a();return}k(B,{replace:!0})}const U=s.jsx("nav",{ref:v,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:z.map(B=>s.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&g.trigger("selection"),B.onClick()},children:[s.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:B.icon}),s.jsx("span",{className:"ios-workbench-tabbar-label",children:B.label})]},B.key))});return s.jsx(Ou,{composerPortalTarget:T?w:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":T?E.isOpen:!0,"data-conversation-tabbar-state":T?E.state:"default",style:L,children:[q?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:q.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:A,children:[s.jsx(Xw,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:q.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:q.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":q.moreButtonLabel,onClick:d,children:s.jsx(Qw,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(Wu,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:R,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:U})]}):U]})})}function Xw(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function Qw(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Zw(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function ex(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function tx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function nx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function rx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function sx(e){const t=Pn();return t.platform==="ios"?s.jsx(Jw,{...e}):t.platform==="android"?s.jsx(_w,{...e}):s.jsx(ix,{...e})}function ix({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=Pn(),g=dl(),m=ll(),k=Co(),S=f.useRef(null),v=f.useRef(null),[w,R]=f.useState(null),T=Yw(p.platform==="web"),F=p.platform==="web"&&T.keyboardOpen,E=t==="conversation-focus",I=hl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),q=_u({enabled:E,rootRef:S,suspended:F,resetKey:`${m.pathname}${m.search}`}),z=No({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),L=Du({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),A=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(lx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(cx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(dx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(ux,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(hx,{}),onClick:h}],U=E?{"--mobile-conversation-tabbar-progress":q.progress.toFixed(4)}:void 0;Bu(S,v,E);function B(){const V=Lu(m.pathname,m.search);if(!V){a();return}k(V,{replace:!0})}const le=s.jsx("nav",{ref:v,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:F,children:A.map(V=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":V.key===e,"aria-current":V.key===e?"page":void 0,onClick:()=>{V.key!==e&&g.trigger("selection"),V.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:V.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:V.label})]},V.key))});return s.jsx(Ou,{composerPortalTarget:E?w:null,children:s.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":p.platform,"data-mobile-keyboard-open":F,"data-pane-layout":z,"data-tabbar-open":F?!1:E?q.isOpen:!0,"data-conversation-tabbar-state":E?q.state:"default",style:U,children:[L?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[L.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:B,children:s.jsx(ox,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:L.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:L.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":L.moreButtonLabel,onClick:d,children:s.jsx(ax,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(Wu,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),E?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:R,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:le})]}):le]})})}function ox(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function ax(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function lx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function cx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ux(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function dx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function hx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class px{constructor(t){Qe(this,"maxAttempts");Qe(this,"baseDelayMs");Qe(this,"reconnectAttempts",0);Qe(this,"reconnectTimer",null);Qe(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!ir.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class fx{constructor(t){Qe(this,"socket",null);Qe(this,"disposed",!1);Qe(this,"authRecoveryInFlight",!1);Qe(this,"pendingRefresh",!1);Qe(this,"workbenchKnownRevision");Qe(this,"lastWorkbenchSnapshot",null);Qe(this,"fileTreeSubscription",null);Qe(this,"gitSubscription",null);Qe(this,"terminalManagerSubscription",null);Qe(this,"workspaceManagementSubscription",null);Qe(this,"pendingFileTreeRefresh",null);Qe(this,"pendingGitRefresh",null);Qe(this,"pendingTerminalManagerRefresh",null);Qe(this,"pendingWorkspaceManagementRefresh",null);Qe(this,"fileTreeRevisionByPath",new Map);Qe(this,"gitRevisionByWorkspaceId",new Map);Qe(this,"terminalManagerRevisionByWorkspaceId",new Map);Qe(this,"workspaceManagementRevisionByWorkspaceId",new Map);Qe(this,"fileTreeListeners",new Set);Qe(this,"gitListeners",new Set);Qe(this,"terminalManagerListeners",new Set);Qe(this,"workspaceManagementListeners",new Set);Qe(this,"workbenchSubscribeStartedAtMs",null);Qe(this,"workbenchRefreshStartedAtMs",null);Qe(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new px({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!qd(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),un("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=Kn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=Kn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:Gd(n),knownRevisionByPath:Kl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Vl(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=Gd(n),o={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Vl(t,i,Kl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(o)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Kl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:Kn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=ho.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=Su(),i=Zf(r),o=i.baseUrl,a=`${py("/ws",o)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:o,url:a});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),un("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:o}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Vl(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var p,g,m,k,S,v,w,R,T,F;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const h=JSON.parse(d.data);if(h.type==="system.connected"){this.connectionManager.markConnected();return}if(h.type==="session.error"){h.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(h.type==="workbench.snapshot"&&(un("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?bx(h.snapshot):0,subscribeDurationMs:Yo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Yo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){un("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:Yo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Yo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const E=gx(this.lastWorkbenchSnapshot,h);if(!E){un("workbench.delta.mismatch",{currentRevision:((g=this.lastWorkbenchSnapshot)==null?void 0:g.revision)??null,baseRevision:h.baseRevision,revision:h.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=E,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(E);return}if(h.type==="fileTree.snapshot"){const E=h.snapshot;if(E)E.revision=h.revision,this.fileTreeRevisionByPath.set($c(E.workspaceId,E.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set($c(this.fileTreeSubscription.workspaceId,I),h.revision);if(!E)return;(k=(m=this.options).onFileTreeSnapshot)==null||k.call(m,E),this.fileTreeListeners.forEach(I=>I(E));return}if(h.type==="git.snapshot"){const E=h.snapshot;if(E?(E.revision=h.revision,this.gitRevisionByWorkspaceId.set(E.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!E)return;(v=(S=this.options).onGitSnapshot)==null||v.call(S,E),this.gitListeners.forEach(I=>I(E));return}if(h.type==="terminalManager.snapshot"){const E=h.snapshot;if(E?(E.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(E.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!E)return;(R=(w=this.options).onTerminalManagerSnapshot)==null||R.call(w,E),this.terminalManagerListeners.forEach(I=>I(E));return}if(h.type==="workspaceManagement.snapshot"){const E=h.snapshot;if(E?(E.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(E.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!E)return;(F=(T=this.options).onWorkspaceManagementSnapshot)==null||F.call(T,E),this.workspaceManagementListeners.forEach(I=>I(E));return}h.type==="workbench.snapshot"&&h.snapshot&&mx(h.snapshot)?(h.snapshot.revision=h.revision,this.lastWorkbenchSnapshot=h.snapshot,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(h.snapshot)):h.type==="workbench.snapshot"&&h.unchanged&&(this.workbenchKnownRevision=h.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:h.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),ho.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return qd(n)?(n.send(JSON.stringify(t)),!0):!1}}function qd(e){return e!==null&&e.readyState===1}function mx(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Gd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Kn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function gx(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)n.delete(i);for(const i of t.changedItems)n.set(i.workspace.id,i);const r=[];for(const i of t.orderedWorkspaceIds){const o=n.get(i);if(!o)return null;r.push(o)}return{revision:t.revision,items:r}}function Kl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),Kn(n)]).filter(t=>t[1]!==null)):{}}function Vl(e,t,n,r){const i=t.map(o=>{const a=o.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[a,n[a]??r.get($c(e,a))??null]}).filter(o=>!!o[1]);if(i.length!==0)return Object.fromEntries(i)}function $c(e,t){return`${e}::${t}`}function bx(e){return e.items.reduce((t,n)=>t+n.sessions.length+Bm(n.childWorktrees??[]),0)}function Bm(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,i=Array.isArray(r.sessions)?r.sessions.length:0,o=Array.isArray(r.children)?Bm(r.children):0;return t+i+o},0)}function Yo(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const Kd=6,kx=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function yx(e){return e instanceof HTMLElement?!e.closest(kx):!0}function zc(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&yx(n)}function _m(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Wm(e){return _m(e)?"":void 0}function wx(e){if(!zc(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const i=()=>{r&&(r=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),window.removeEventListener("blur",c))},o=u=>{Math.abs(u.clientX-t)<Kd&&Math.abs(u.clientY-n)<Kd||(i(),xx())},a=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),window.addEventListener("blur",c)}async function xx(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await pm().startDragging()}const Fa=.78,vx=1;function Sx(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function Fm(e,t,n,r){const i=Math.hypot(n-e,r-t),o=Math.min(1,i/120);return Fa+(vx-Fa)*o}function as(e){return Math.round(Number.isFinite(e)?e:0)}function Cx(e){if(!Sx())return null;const t=as(e.x),n=as(e.y);let r=!1,i=Promise.resolve();const o=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),a=async()=>{r||(r=!0,await o("close_detach_preview"))};return o("show_detach_preview",{title:e.title,x:t,y:n,scale:Fa}),{updatePosition(c,u){if(r)return;const d=as(c),h=as(u);o("update_detach_preview_position",{x:d,y:h,scale:Fm(t,n,d,h)})},complete(){return a()},cancel(){return a()}}}function Nx(e){if(typeof document>"u")return null;const t=as(e.x),n=as(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",Fa.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const o=document.createElement("strong");o.className="desktop-window-detach-animation-title",o.textContent=e.title;const a=document.createElement("div");a.className="desktop-window-detach-animation-body",i.append(o),r.append(i,a),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=as(d),g=as(h),m=Fm(t,n,p,g);r.style.left=`${p}px`,r.style.top=`${g}px`,r.style.setProperty("--detach-preview-scale",m.toFixed(3))},async complete(){u()},async cancel(){u()}}}function Vd(e){return Cx(e)??Nx(e)}async function Yd(){return await Y.request("/api/skills/overview")}async function jx(e){var n;const t=new URLSearchParams;return t.set("workspaceId",e.workspaceId),(n=e.sessionId)!=null&&n.trim()&&t.set("sessionId",e.sessionId.trim()),await Y.request(`/api/skills/workspace-session-mcp-status?${t.toString()}`)}async function Tx(e){await Y.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Ix(e){await Y.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Ax(e){await Y.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Jd(e){if(e.executionBackend==="opencli_bridge"||e.executionBackend==="playwright")return e.executionBackend;try{return JSON.parse(e.inputJson).executionBackend==="opencli_bridge"?"opencli_bridge":"playwright"}catch{return"playwright"}}async function Xd(e="active"){const t=new URLSearchParams({status:e});return(await Y.request(`/api/office/document-templates?${t.toString()}`)).items}async function Qd(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim());const n=t.size>0?`?${t.toString()}`:"";return(await Y.request(`/api/office/browser/profiles${n}`)).items}async function Rx(e){return await Y.request("/api/office/browser/profiles",{method:"POST",body:JSON.stringify(e)})}async function Ex(e,t){return await Y.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function Px(e){return await Y.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Mx(e){return await Y.request("/api/office/document-templates/import-file",{method:"POST",body:JSON.stringify(e)})}async function Jo(e){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.taskType&&t.set("taskType",e.taskType),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel),typeof e.limit=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(Math.trunc(e.limit)));const n=t.size>0?`?${t.toString()}`:"";return(await Y.request(`/api/office/tasks${n}`)).items}async function Yl(e){return await Y.request(`/api/office/tasks/${encodeURIComponent(e)}`)}async function Lx(e){return await Y.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execute`,{method:"POST"})}async function Uc(e){return(await Y.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution`)).task}async function Zd(){return await Y.request("/api/office/browser/bridge-status")}async function Dx(e){return await Y.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution/cancel`,{method:"POST"})}async function Ox(e,t){await Y.request(`/api/office/approvals/${encodeURIComponent(e)}/reply`,{method:"POST",body:JSON.stringify(t)})}async function eh(e){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.kind&&t.set("kind",e.kind),e.status&&t.set("status",e.status);const n=t.size>0?`?${t.toString()}`:"";return(await Y.request(`/api/office/ops/targets${n}`)).items}async function Bx(e){return await Y.request("/api/office/ops/targets",{method:"POST",body:JSON.stringify(e)})}async function _x(e,t){return await Y.request(`/api/office/ops/targets/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}const Hc=new Set;let Fr={items:null,loading:!1,requested:!1},is=null;function Wx(){Hc.forEach(e=>e())}function Ps(e){Fr=e,Wx()}function Fx(e){return Hc.add(e),()=>{Hc.delete(e)}}function th(){return Fr}function $x(e=!1){if(!e){if(Fr.items)return Promise.resolve(Fr.items);if(is)return is}return Ps({...Fr,loading:!0,requested:!0}),is=rw().then(t=>(Ps({items:t,loading:!1,requested:!0}),t)).catch(()=>(Ps({...Fr,items:null,loading:!1,requested:!0}),null)).finally(()=>{is=null}),is}function BD(){return Ps({...Fr,loading:!0,requested:!0}),is=sw().then(e=>(Ps({items:e,loading:!1,requested:!0}),e)).catch(()=>(Ps({...Fr,loading:!1,requested:!0}),null)).finally(()=>{is=null}),is}function zx(e){const t=Fr.items??[],n=Ux(t,e);Ps({items:n,loading:!1,requested:!0})}async function _D(e,t){const n=await iw(e,t);return zx(n),n}function $m(e=!0){const t=f.useSyncExternalStore(Fx,th,th);return f.useEffect(()=>{e&&$x()},[e]),t}function Ux(e,t){const n=e.slice(),r=n.findIndex(i=>i.provider===t.provider);return r>=0?(n[r]=t,n):(n.push(t),n)}async function Hx(){return await Y.request("/api/opencli/catalog")}async function nh(){return await Y.request("/api/opencli/check",{method:"POST"})}async function qx(e){return await Y.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Jl="all",Xl="status";function Gx({toolbarMode:e="internal",onToolbarStateChange:t}={}){var Ue,He,je,Te;const n=Cu(_=>{var G;return((G=_.session)==null?void 0:G.accessToken)??null}),[r,i]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,k]=f.useState([]),[S,v]=f.useState(null),[w,R]=f.useState(null),[T,F]=f.useState(Jl),[E,I]=f.useState(null),[q,z]=f.useState(!1),[L,A]=f.useState(""),[U,B]=f.useState(Xl);f.useEffect(()=>{let _=!0;if(!n){i(null),g(!1),k([]),R(null),v(null),a(!1),F(Jl),I(null),z(!1),A(""),B(Xl);return}return(async()=>{a(!0),R(null),v(null);try{const Q=await nh();if(!_)return;j(Q)}catch(Q){if(!_)return;const Ce=Qo(Q);try{const Ae=await Hx();if(!_)return;j(Ae),R(Ce)}catch(Ae){if(!_)return;R(Qo(Ae))}}finally{_&&a(!1)}})(),()=>{_=!1}},[n]);const le=f.useMemo(()=>new Set(m),[m]),V=f.useMemo(()=>Yx((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),X=f.useMemo(()=>Zx(),[]);f.useEffect(()=>{V.some(_=>_.id===T)||F(Jl)},[T,V]);const J=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(_=>_.commands.some(G=>rh(G,T,le))),[T,r==null?void 0:r.siteGroups,le]),O=f.useMemo(()=>E?J.find(_=>_.site===E)??null:null,[E,J]);f.useEffect(()=>{E&&!O&&I(null)},[E,O]),f.useEffect(()=>{A(""),B(Xl)},[E]);const K=f.useMemo(()=>{if(!O)return[];const _=L.trim().toLowerCase();return O.commands.filter(G=>rh(G,T,le)&&Xx(G,_)).sort((G,Q)=>Qx(G,Q,{sortId:U,selectedCommandIdSet:le}))},[T,O,L,U,le]),ce=!!(r&&(r.provider.enabled!==p||r.entries.some(_=>_.enabled!==le.has(_.commandId)))),N=f.useMemo(()=>({draftEnabled:p,enableDisabled:o||c||d,refreshDisabled:!n||o||c||d,detailDisabled:!r||o,saveDisabled:!n||o||c||d||!r||!ce,refreshing:c,saving:d,onEnabledChange:be,onRefresh:()=>{De()},onShowDetails:()=>z(!0),onSave:()=>{ee()}}),[n,r,m,p,ce,o,c,d]);f.useEffect(()=>{t==null||t(N)},[t,N]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function De(){if(n){u(!0),R(null),v(null);try{const _=await nh();j(_),v(av(_.refreshState,_.runtimeAvailability))}catch(_){R(Qo(_))}finally{u(!1)}}}async function ee(){if(n){h(!0),R(null),v(null);try{const _=await qx({enabled:p,enabledCommandIds:m});j(_),v(lv(_))}catch(_){R(Qo(_))}finally{h(!1)}}}function j(_){i(_),g(_.provider.enabled),k(_.entries.filter(G=>G.enabled).map(G=>G.commandId).sort((G,Q)=>G.localeCompare(Q))),R(null)}function be(_){g(_)}function re(_,G){const Q=_.commands.map(Ce=>Ce.commandId);k(Ce=>{const Ae=new Set(Ce);for(const ve of Q)G?Ae.add(ve):Ae.delete(ve);return[...Ae].sort((ve,Tt)=>ve.localeCompare(Tt))})}function fe(_,G){k(Q=>{const Ce=new Set(Q);return G?Ce.add(_):Ce.delete(_),[...Ce].sort((Ae,ve)=>Ae.localeCompare(ve))})}const de=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return s.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?s.jsx(Kx,{state:N,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Xo,{label:l("settings.opencliSummaryInstallState"),value:oh(de.installState)}),s.jsx(Xo,{label:l("settings.opencliSummaryCatalogCount"),value:String(de.catalogCount)}),s.jsx(Xo,{label:l("settings.opencliSummaryEnabledCount"),value:String(m.length)}),s.jsx(Xo,{label:l("settings.opencliSummaryBrowserCount"),value:String(de.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,w?s.jsx("p",{className:"settings-release-status",children:w}):null,o?s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?s.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[s.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:V.map(_=>{const G=T===_.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":G,"data-active":G?"true":"false",onClick:()=>F(_.id),children:_.label},_.id)})}),J.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:J.map(_=>{const G=Jx(_,le),Q=ev(_.commands),Ce=ih(_,{maxDescriptions:2}),Ae=ih(_),ve=Um(_.site),Tt=E===_.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":Tt?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:ve.style,children:s.jsx("span",{children:ve.label})}),s.jsxs("div",{className:"settings-opencli-site-card-body",children:[s.jsxs("div",{className:"settings-opencli-site-card-topline",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:_.site}),s.jsxs("div",{className:"settings-opencli-site-card-actions",children:[s.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>I(_.site),children:l("settings.opencliSiteViewAction")}),s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:_.site}),type:"checkbox",checked:G.allSelected,disabled:c||d,ref:rt=>{rt&&(rt.indeterminate=G.partialSelected)},onChange:rt=>re(_,rt.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:Ae,children:Ce})]})]}),s.jsx("div",{className:"settings-opencli-site-card-summary",children:s.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:s.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(Q.length>0?Q:["unknown"]).slice(0,2).map(rt=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Gm(rt),children:Hm(rt)},`${_.site}:${rt}`))})})})]},_.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:cv(r)}),s.jsx(St,{open:q,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>z(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Rn,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx(qo,{children:oh(r.provider.installState)}),s.jsx(qo,{children:rv(r.provider.healthState)}),s.jsx(qo,{children:iv(((Ue=r.activeRuntimeProfile)==null?void 0:Ue.status)??null)})]}),children:s.jsxs(bi,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(Xt,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(Xt,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(de.catalogCount)})}),s.jsx(Xt,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(m.length)})}),s.jsx(Xt,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(de.browserDependentCount)})}),s.jsx(Xt,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(Xt,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:sv(r.effectiveCatalogSource??null)})}),s.jsx(Xt,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:ah(r.provider.lastCheckedAt)})}),s.jsx(Xt,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:ah(r.provider.catalogRefreshedAt)})}),s.jsx(Xt,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(Xt,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(Xt,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((He=r.activeRuntimeProfile)==null?void 0:He.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(je=r.activeRuntimeProfile)!=null&&je.lastErrorDetail?s.jsx(Rn,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:s.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(Te=r.activeRuntimeProfile)!=null&&Te.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(St,{open:O!==null,title:O?l("settings.opencliSiteDetailTitle",{site:O.site}):l("settings.opencliCommandModalFallbackTitle"),description:O?l("settings.opencliSiteDetailDescription",{count:K.length,total:O.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>I(null),children:O?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Rn,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:zm(O.commands).map(_=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:_},_))})}),s.jsx(Rn,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx(qo,{children:l("settings.opencliCommandResultCount",{count:K.length})}),children:s.jsxs("div",{className:"settings-opencli-command-tools",children:[s.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),s.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:L,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:_=>A(_.target.value)})]}),s.jsxs("div",{className:"settings-opencli-command-sort",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),s.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:X.map(_=>{const G=U===_.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":G,"data-active":G?"true":"false",onClick:()=>B(_.id),children:_.label},_.id)})})]})]})}),K.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:K.map(_=>s.jsx(Vx,{command:_,checked:le.has(_.commandId),disabled:c||d,onToggle:fe},_.commandId))}):s.jsx(Ba,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Kx({state:e,className:t}){return s.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function Vx({command:e,checked:t,disabled:n,onToggle:r}){const i=Um(e.commandId);return s.jsxs("div",{className:"settings-opencli-command-card",children:[s.jsxs("div",{className:"settings-opencli-command-card-head",children:[s.jsx("div",{className:"settings-opencli-command-badge",style:i.style,children:s.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),s.jsxs("div",{className:"settings-opencli-command-card-main",children:[s.jsxs("label",{className:"settings-opencli-checkbox",children:[s.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:o=>r(e.commandId,o.target.checked)}),s.jsx("span",{children:e.commandId})]}),s.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Gm(e.strategy),children:ov(e.strategy)}),e.browser?s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Xo({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Yx(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Hm(n)})}))]}function rh(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Jx(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function Xx(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
|
|
3
|
-
`).toLowerCase().includes(t):!0}function Qx(e,t,n){const r=sh(e,n)-sh(t,n);if(r!==0)return r;const i=e.name.localeCompare(t.name);return i!==0?i:e.commandId.localeCompare(t.commandId)}function sh(e,t){const n=t.selectedCommandIdSet.has(e.commandId)?0:1,r=e.browser?1:0;switch(t.sortId){case"browser":return(e.browser?0:2)+n;case"name":return 0;case"status":default:return n*2+r}}function Zx(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function zm(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function ih(e,t={}){const n=zm(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function ev(e){return Array.from(new Set(e.map(t=>t.strategy.trim()).filter(t=>t.length>0&&t!=="unknown"))).sort((t,n)=>t.localeCompare(n))}function Um(e){const t=uv[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=lh[Math.abs(nv(e))%lh.length];return{label:tv(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function tv(e){const t=e.split(/[^a-z0-9]+/i).map(r=>r.trim()).filter(r=>r.length>0);if(t.length>=2)return`${t[0][0]??""}${t[1][0]??""}`.toUpperCase();const n=t[0]??e;return n.slice(0,Math.min(2,n.length)).toUpperCase()}function nv(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function Qo(e){return e instanceof il?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function oh(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function rv(e){switch(e){case"ready":return l("settings.opencliHealthReady");case"bridge_missing":return l("settings.opencliHealthBridgeMissing");case"binary_ready":return l("settings.opencliHealthBinaryReady");case"runtime_build_failed":return l("settings.opencliHealthRuntimeBuildFailed");default:return l("settings.opencliHealthUnknown")}}function sv(e){switch(e){case"manifest":return l("settings.opencliCatalogSourceManifest");case"cli_list":return l("settings.opencliCatalogSourceCliList");case"local_manifest":return l("settings.opencliCatalogSourceLocalManifest");case"cache":return l("settings.opencliCatalogSourceCache");default:return"-"}}function iv(e){switch(e){case"ready":return l("settings.opencliRuntimeReady");case"failed":return l("settings.opencliRuntimeFailed");case"pending":return l("settings.opencliRuntimePending");case"stale":return l("settings.opencliRuntimeStale");default:return l("settings.opencliRuntimeIdle")}}function ov(e){return l("settings.opencliStrategyLabel",{strategy:qm(e)})}function Hm(e){return l("settings.opencliStrategyShortLabel",{strategy:qm(e)})}function qm(e){switch(Km(e)){case"cookie":return l("settings.opencliStrategyCookie");case"header":return l("settings.opencliStrategyHeader");case"intercept":return l("settings.opencliStrategyIntercept");case"local":return l("settings.opencliStrategyLocal");case"public":return l("settings.opencliStrategyPublic");case"ui":return l("settings.opencliStrategyUi");default:return l("settings.opencliStrategyUnknown")}}function Gm(e){return Km(e)}function Km(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function av(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function lv(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function cv(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function ah(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const lh=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],uv={github:{label:"GH",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"},hackernews:{label:"HN",background:"linear-gradient(135deg, #f97316 0%, #fb923c 100%)"},twitter:{label:"TW",background:"linear-gradient(135deg, #2563eb 0%, #38bdf8 100%)"},x:{label:"X",background:"linear-gradient(135deg, #111827 0%, #6b7280 100%)"},reddit:{label:"RD",background:"linear-gradient(135deg, #f97316 0%, #ef4444 100%)"}},dv=[{id:"skills"},{id:"office"},{id:"ops"},{id:"opencli"}];function hv({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n,workspaceId:r=null,sessionId:i=null}){const o=Cu(x=>{var H;return((H=x.session)==null?void 0:H.accessToken)??null}),a=f.useRef(null),c=f.useRef(null),[u,d]=f.useState(null),[h,p]=f.useState([]),[g,m]=f.useState([]),[k,S]=f.useState([]),[v,w]=f.useState({}),[R,T]=f.useState(null),[F,E]=f.useState([]),[I,q]=f.useState([]),[z,L]=f.useState([]),[A,U]=f.useState(null),[B,le]=f.useState(null),[V,X]=f.useState(null),[J,O]=f.useState(null),[K,ce]=f.useState(null),[N,De]=f.useState(!1),[ee,j]=f.useState(null),[be,re]=f.useState(null),[fe,de]=f.useState(null),[Ue,He]=f.useState(!1),[je,Te]=f.useState(!1),[_,G]=f.useState(!1),[Q,Ce]=f.useState(!1),[Ae,ve]=f.useState(!1),[Tt,rt]=f.useState(!1),[gt,ae]=f.useState(!1),[ie,ke]=f.useState(!1),[ye,Re]=f.useState(!1),[$,Z]=f.useState(!1),[ge,Ne]=f.useState(null),[Be,Ve]=f.useState(!1),Ie=(ge==null?void 0:ge.simplified)??null,[dt,Ze]=f.useState(null),[st,it]=f.useState("file"),[qe,bt]=f.useState("workspace"),[Ut,Ye]=f.useState(""),[ht,Oe]=f.useState(()=>Hi("workspace")),[kt,et]=f.useState("skills"),[Dt,D]=f.useState(null),[he,Ee]=f.useState("all"),[we,Se]=f.useState("ssh_host"),[pt,Bt]=f.useState({fileName:"",fileContentBase64:""}),[mt,_t]=f.useState({displayName:"",engine:"chrome",mode:"persistent",ownershipScope:r!=null&&r.trim()?"workspace":"user",cdpEndpoint:""}),[tt,ct]=f.useState({targetId:null,displayName:"",environment:"",host:"",port:"22",username:"",privateKeyPath:"",knownHostsPath:"",jumpHost:"",workspacePath:"",credentialRef:"",strictHostKeyChecking:"accept-new",status:"active"}),Ht=f.useId(),qr=$m(Ue&&!!o).items??[],yt=f.useMemo(()=>Dv(qr),[qr]),hs=f.useMemo(()=>new Map(F.map(x=>[x.id,x])),[F]),gn=f.useMemo(()=>!ye||!(r!=null&&r.trim())?g:g.filter(x=>x.workspaceId===r),[g,ye,r]),cr=f.useMemo(()=>V?k.filter(x=>x.targetRefId===V.id):[],[k,V]);f.useEffect(()=>{let x=!0;if(!Ue)return;if(!o){d(null),re(null),de(null),De(!1);return}return(async()=>{De(!0);try{const[Pe,Je,Cn,Lr,Jr,Nn,kn]=await Promise.all([Yd(),Xd("active"),Qd(),Jo({taskType:"browser",limit:100}),_c(),Jo({workspaceId:r,taskType:"ops",limit:20}),eh({workspaceId:r,kind:"ssh_host"})]);if(!x)return;const kr=await kh(Lr),Xe=await Zd().catch(()=>null);d(Pe),p(Je),m(Cn),S(Lr),T(Xe),w(kr),E(Jr.items),q(Nn),L(kn),X(null),O(null),ce(null),re(null)}catch(Pe){if(!x)return;re(Jt(Pe))}finally{x&&De(!1)}})(),()=>{x=!1}},[o,Ue,r]);async function Qt(){const[x,H,Pe,Je,Cn,Lr,Jr]=await Promise.all([Yd(),Xd("active"),Qd(),Jo({taskType:"browser",limit:100}),_c(),Jo({workspaceId:r,taskType:"ops",status:he==="all"?void 0:he,limit:20}),eh({workspaceId:r,kind:we==="all"?void 0:we})]),Nn=await kh(Je),kn=await Zd().catch(()=>null);d(x),p(H),m(Pe),S(Je),T(kn),w(Nn),E(Cn.items),q(Lr),L(Jr),re(null)}async function Yn(){if(o){j("refresh"),re(null),de(null);try{await Qt(),de(l("settings.skillRefreshSuccess"))}catch(x){re(Jt(x))}finally{j(null)}}}async function Zt(){if(o){j("office-template-submit"),re(null),de(null);try{await Mx({fileName:pt.fileName,fileContentBase64:pt.fileContentBase64}),Bt(ta()),G(!1),de(l("settings.skillOfficeTemplateImported")),await Qt()}catch(x){re(Jt(x))}finally{j(null)}}}async function en(){if(o){j("browser-profile-submit"),re(null),de(null);try{await Rx({workspaceId:r,displayName:mt.displayName.trim()||null,engine:mt.engine,mode:mt.mode,ownershipScope:mt.ownershipScope,cdpEndpoint:mt.mode==="cdp_attached"&&mt.cdpEndpoint.trim()||null}),_t(ea(r)),Ce(!1),de(l("settings.skillOfficeBrowserProfileCreated")),await Qt()}catch(x){re(Jt(x))}finally{j(null)}}}async function vn(x){var Pe;if(!o)return;const H=x.ownershipScope==="user"?"workspace":"user";if(H==="workspace"&&!((Pe=x.workspaceId)!=null&&Pe.trim())){re(l("settings.skillOfficeBrowserProfileWorkspaceRequired"));return}j(`browser-profile-scope:${x.id}`),re(null),de(null);try{await Ex(x.id,{ownershipScope:H}),await Qt(),de(H==="user"?l("settings.skillOfficeBrowserProfileCrossWorkspaceEnabled"):l("settings.skillOfficeBrowserProfileWorkspaceOnlyEnabled"))}catch(Je){re(Jt(Je))}finally{j(null)}}function Ws(x){U(x),ve(!0),re(null)}function Kt(x){le(x),rt(!0),re(null)}async function Sn(){if(!o)return;const x=B;if(x){j(`browser-profile-delete:${x.id}`),re(null),de(null);try{await Px(x.id),(V==null?void 0:V.id)===x.id&&(ke(!1),X(null),O(null)),(A==null?void 0:A.id)===x.id&&(ve(!1),U(null)),rt(!1),le(null),await Qt(),de(l("settings.skillOfficeBrowserProfileDeleted"))}catch(H){re(Jt(H))}finally{j(null)}}}async function wt(x){if(o){j(`browser-profile-tasks:${x.id}`),re(null);try{X(x),O(null),ke(!0)}catch(H){re(Jt(H))}finally{j(null)}}}async function Rr(x){if(o){j(`browser-task-detail:${x}`),re(null);try{const[H,Pe]=await Promise.all([Yl(x),Uc(x)]);O(H),w(Je=>({...Je,[x]:Pe}))}catch(H){re(Jt(H))}finally{j(null)}}}async function ur(x){if(o){j(`browser-task-execute:${x}`),re(null),de(null);try{await Lx(x),await Ln(x),de(l("settings.skillOfficeBrowserInstanceStarted"))}catch(H){re(Jt(H))}finally{j(null)}}}async function dr(x){if(o){j(`browser-task-cancel:${x}`),re(null),de(null);try{await Dx(x),await Ln(x),de(l("settings.skillOfficeBrowserInstanceCancelled"))}catch(H){re(Jt(H))}finally{j(null)}}}async function bn(x){if(o){j(`ops-task-detail:${x}`),re(null);try{const H=await Yl(x);ce(H)}catch(H){re(Jt(H))}finally{j(null)}}}async function Gr(x,H){if(o){j(`ops-approval:${x}:${H}`),re(null);try{if(await Ox(x,{status:H,decisionNote:H==="approved"?l("settings.skillOpsApprovalApproveNote"):l("settings.skillOpsApprovalRejectNote")}),K){const Pe=await Yl(K.task.id);ce(Pe)}await Qt(),de(H==="approved"?l("settings.skillOpsApprovalApproved"):l("settings.skillOpsApprovalRejected"))}catch(Pe){re(Jt(Pe))}finally{j(null)}}}async function Er(){if(o){j("ops-target-submit"),re(null),de(null);try{const x={workspaceId:r,kind:"ssh_host",displayName:tt.displayName.trim(),environment:tt.environment.trim()||null,credentialRef:tt.credentialRef.trim()||null,status:tt.status,config:{host:tt.host.trim(),port:Number.parseInt(tt.port,10)||22,username:tt.username.trim(),privateKeyPath:tt.privateKeyPath.trim()||void 0,knownHostsPath:tt.knownHostsPath.trim()||void 0,jumpHost:tt.jumpHost.trim()||void 0,workspacePath:tt.workspacePath.trim()||void 0,strictHostKeyChecking:tt.strictHostKeyChecking}};tt.targetId?(await _x(tt.targetId,x),de(l("settings.skillOpsTargetUpdated"))):(await Bx(x),de(l("settings.skillOpsTargetCreated"))),ct(Zo()),ae(!1),await Qt()}catch(x){re(Jt(x))}finally{j(null)}}}async function hr(){if(!(!o||!(r!=null&&r.trim()))){Z(!0),Ve(!0),re(null);try{const x=await jx({workspaceId:r,sessionId:i});Ne(x)}catch(x){re(Jt(x)),Ne(null)}finally{Ve(!1)}}}function pr(x){const H=Vm(x.configJson);ct({targetId:x.id,displayName:x.displayName,environment:x.environment??"",host:ss(H.host),port:Ym(H.port,22),username:ss(H.username),privateKeyPath:ss(H.privateKeyPath),knownHostsPath:ss(H.knownHostsPath),jumpHost:ss(H.jumpHost),workspacePath:ss(H.workspacePath),credentialRef:x.credentialRef??"",strictHostKeyChecking:wv(H.strictHostKeyChecking),status:x.status}),ae(!0)}function zn(){ct(Zo())}async function ps(x){var Pe;const H=((Pe=x.target.files)==null?void 0:Pe[0])??null;if(x.target.value="",!!H){re(null),de(null);try{Bt({fileName:H.name,fileContentBase64:await Qv(H)})}catch(Je){re(Jt(Je))}}}function Kr(){Bt(ta()),G(!0),re(null)}function Ai(){_t(ea(r)),Ce(!0),re(null)}function Fs(){ct(Zo()),ae(!0),re(null)}async function Ln(x){const H=await Uc(x);w(Pe=>({...Pe,[x]:H}))}async function fs(x){if(o){j(ch(x)),re(null),de(null);try{await Ix({targetCli:x.targetCli,directoryPath:x.directoryPath,expectedContentHash:x.contentHash}),await Qt(),de(l("settings.skillImportSuccess",{name:x.name,target:Fn(x.targetCli)}))}catch(H){re(Jt(H))}finally{j(null)}}}async function rn(x){if(!o)return;const H=x.bindings.filter(Pe=>Pe.enabled).map(Pe=>Pe.targetCli).filter(Pe=>pn(Pe,yt));if(H.length===0){re(Uv(x.bindings));return}j(uh(x.skill.id)),re(null),de(null);try{await Ax({skillId:x.skill.id,targetCli:H}),await Qt(),de(l("settings.skillSyncSuccess",{name:x.skill.name}))}catch(Pe){re(Jt(Pe))}finally{j(null)}}async function fr(x){var Pe;const H=((Pe=x.target.files)==null?void 0:Pe[0])??null;if(x.target.value="",!!H){re(null),de(null);try{const Je=await Xv(H),Cn=Zm(H.name,Je);Ze(Cn),Oe(Hi(qe,yt))}catch(Je){re(Jt(Je))}}}async function Pr(){const x=gh({sourceMode:st,fileDraft:dt,pastedMarkdown:Ut});if(!o)return;if(!x){re(st==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const H=x.directoryName;if(!H){re(l("settings.skillUploadDirectoryInvalid"));return}const Pe=$a(qe).filter(Je=>ht[Je]).filter(Je=>pn(Je,yt)).map(Je=>Je);if(Pe.length===0){re(Hv(qe,yt));return}j("upload"),re(null),de(null);try{await Tx({markdownContent:x.rawContent,scope:qe,fileName:x.fileName,directoryName:H,targetCli:Pe}),await Qt(),de(l("settings.skillUploadSuccess",{name:H})),Wt(qe),Te(!1)}catch(Je){re(Jt(Je))}finally{j(null)}}function mr(x){bt(x),Oe(Hi(x,yt))}function Mr(x){it(x),Ze(null),Ye(""),Oe(Hi(qe,yt)),re(null)}function sn(x){pn(x,yt)&&Oe(H=>({...H,[x]:!H[x]}))}function Rt(){Te(!0),re(null),Wt(qe)}function on(){Te(!1),re(null),Wt(qe)}function Wt(x){Ze(null),Ye(""),it("file"),Oe(Hi(x,yt))}const an=(u==null?void 0:u.summary)??{managedSkillCount:0,managedEntryCount:0},gr=Kv((u==null?void 0:u.assistantRuntimeSkills)??[],(u==null?void 0:u.conflictedEntries)??[],(u==null?void 0:u.diagnostics)??[]),Vr=((u==null?void 0:u.conflictedEntries)??[]).filter(x=>!Qm(x,(u==null?void 0:u.diagnostics)??[])),br=((u==null?void 0:u.diagnostics)??[]).filter(x=>!jo(x)),Vt=gh({sourceMode:st,fileDraft:dt,pastedMarkdown:Ut}),Yr=t??l("settings.skillManageAction"),Jn=kt==="skills",Dn=kt==="office",Xn=kt==="ops",Qn=kt==="opencli";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:e,type:"button","data-open":Ue?"true":"false","aria-haspopup":"dialog","aria-expanded":Ue,onClick:()=>{et("skills"),He(!0)},children:[n,s.jsx("span",{children:Yr})]}),s.jsxs(St,{open:Ue,title:l("settings.skillConfigModalTitle"),hideHeader:!0,className:"settings-skill-modal",onClose:()=>{et("skills"),He(!1)},children:[s.jsxs("div",{className:"settings-skill-modal-topbar",children:[s.jsxs("div",{className:"settings-skill-modal-topbar-main",children:[s.jsx("div",{className:"settings-model-tabs settings-skill-tabs",role:"tablist","aria-label":l("settings.skillConfigTabsLabel"),children:dv.map(x=>{const H=kt===x.id,Pe=`${Ht}-${x.id}-tab`,Je=`${Ht}-${x.id}-panel`;return s.jsx("button",{id:Pe,type:"button",role:"tab",className:"settings-model-tab","aria-selected":H,"aria-controls":Je,"data-active":H?"true":"false",onClick:()=>et(x.id),children:yv(x.id)},x.id)})}),Jn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:Rt,children:l("settings.skillCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:()=>{Yn()},children:ee==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Dn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsxs("div",{className:"settings-skill-toolbar-status",role:"status",title:R?l("settings.skillOfficeBrowserBridgeSummaryDetail",{provider:R.provider,status:fh(R),detail:R.detail??l("settings.skillOfficeBrowserBridgeDetailReady")}):l("settings.skillOfficeBrowserBridgeAvailabilityUnknown"),children:[s.jsx("span",{className:"settings-skill-toolbar-status-dot","data-status":Iv(R),"aria-hidden":"true"}),s.jsx("span",{className:"settings-skill-toolbar-status-label",children:l("settings.skillOfficeBrowserBridgeSummaryLabel")}),s.jsx("strong",{className:"settings-skill-toolbar-status-value",children:fh(R)})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:Kr,children:l("settings.skillOfficeTemplateOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:Ai,children:l("settings.skillOfficeBrowserProfileOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:()=>{Yn()},children:ee==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Xn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:Fs,children:l("settings.skillOpsTargetOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!o||N||ee!==null,onClick:()=>{Yn()},children:ee==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Qn&&Dt?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar settings-opencli-toolbar",children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:Dt.draftEnabled,disabled:Dt.enableDisabled,onChange:x=>Dt.onEnabledChange(x.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:Dt.refreshDisabled,onClick:Dt.onRefresh,children:Dt.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:Dt.detailDisabled,onClick:Dt.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:Dt.saveDisabled,onClick:Dt.onSave,children:Dt.saving?l("common.loading"):l("settings.opencliSaveAction")})]}):null]}),s.jsx(By,{onClick:()=>{et("skills"),He(!1)}})]}),Jn?s.jsxs("div",{id:`${Ht}-skills-panel`,role:"tabpanel","aria-labelledby":`${Ht}-skills-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillSummaryManagedSkills"),value:String(an.managedSkillCount)}),s.jsx(In,{label:l("settings.skillSummaryManagedEntries"),value:String(an.managedEntryCount)}),s.jsx(In,{label:l("settings.skillSummaryConflictedEntries"),value:String(Vr.length)}),s.jsx(In,{label:l("settings.skillSummaryDiagnostics"),value:String(br.length)})]}),s.jsx("div",{className:"settings-release-meta",children:s.jsxs("span",{children:[l("settings.skillScannedAt"),": ",N?l("common.loading"):Gv(u==null?void 0:u.scannedAt)]})}),fe?s.jsx("p",{className:"settings-release-status",children:fe}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null]}),s.jsx(_r,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(u==null?void 0:u.managedSkills)??[],renderItem:x=>{const H=uh(x.skill.id);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.skill.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:Fv(x.bindings)}),s.jsx("div",{className:"settings-skill-tags",children:x.bindings.map(Pe=>s.jsx("span",{className:"settings-skill-tag","data-status":_v(Pe,yt),children:Wv(Pe,yt)},`${x.skill.id}-${Pe.targetCli}`))})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null||!Bv(x.bindings,yt),onClick:()=>{rn(x)},children:ee===H?l("common.loading"):l("settings.skillSyncAction")})})]},x.skill.id)}}),s.jsx(_r,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(u==null?void 0:u.unmanagedEntries)??[],renderItem:x=>{const H=ch(x);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:$v(x,yt)}),pn(x.targetCli,yt)?null:s.jsx("div",{className:"settings-skill-tags",children:s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.skillTargetDisabledTag")})})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null||!pn(x.targetCli,yt),onClick:()=>{fs(x)},children:ee===H?l("common.loading"):l("settings.skillImportAction")})})]},`${x.targetCli}:${x.directoryPath}`)}}),s.jsx(_r,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:gr,renderItem:x=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillAssistantRuntimeItemDescription")}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillAssistantRuntimeUsedBy"),": ",Xm(x.usedByTargetCli)]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:Vv(x.usageTag)}),x.usedByTargetCli.map(H=>s.jsx("span",{className:"settings-skill-tag","data-status":pn(H,yt)?"synced":"failed",children:pn(H,yt)?Fn(H):`${Fn(H)} · ${l("settings.skillTargetDisabledTag")}`},`${x.directoryName}:${H}`))]})]}),x.directoryName==="codingns-workspace-session"?s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null||!(r!=null&&r.trim()),onClick:()=>{hr()},children:l("settings.skillWorkspaceSessionMcpStatusAction")})}):null]},`${x.directoryName}:${x.sourcePath}`)}),s.jsx(_r,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:Vr,renderItem:x=>{const H=Yv(x,(u==null?void 0:u.diagnostics)??[]);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:zv(x,yt)}),H.length>0?s.jsx("div",{className:"settings-skill-tags",children:H.map(Pe=>s.jsx("span",{className:"settings-skill-tag","data-status":Pe.status,children:Pe.label},Pe.key))}):null]})},`${x.targetCli}:${x.directoryPath}`)}}),s.jsx(_r,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:br,renderItem:x=>{const H=Jv(x),Pe=qv(x);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:Pe.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:Pe.detail}),H.length>0?s.jsx("div",{className:"settings-skill-tags",children:H.map(Je=>s.jsx("span",{className:"settings-skill-tag","data-status":Je.status,children:Je.label},Je.key))}):null]})},`${x.targetCli}:${x.code}:${x.directoryPath??x.rootDir}`)}})]}):null,Dn?s.jsxs("div",{id:`${Ht}-office-panel`,role:"tabpanel","aria-labelledby":`${Ht}-office-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillOfficeTemplateCount"),value:String(h.length)}),s.jsx(In,{label:l("settings.skillOfficeBrowserProfileCount"),value:String(gn.length)}),s.jsx(In,{label:l("settings.skillOfficeBrowserTaskCount"),value:String(k.length)}),s.jsx(In,{label:l("settings.skillOfficeWorkspaceScope"),value:r!=null&&r.trim()?l("settings.skillOfficeScoped"):l("settings.skillOfficeGlobal")})]}),fe?s.jsx("p",{className:"settings-release-status",children:fe}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null]}),s.jsx(_r,{title:l("settings.skillOfficeTemplateListTitle"),description:l("settings.skillOfficeTemplateListDescription"),emptyText:l("settings.skillOfficeTemplateEmpty"),items:h,renderItem:x=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeTemplateListMeta",{key:x.templateKey,version:x.templateVersion})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:x.engine}),s.jsx("span",{className:"settings-skill-tag","data-status":x.status==="active"?"synced":"failed",children:x.status})]})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("span",{className:"settings-skill-entry-meta",children:x.templateSourcePath??"-"})})]},x.id)}),s.jsx(_r,{title:l("settings.skillOfficeBrowserProfileListTitle"),description:l("settings.skillOfficeBrowserProfileListDescription"),emptyText:l("settings.skillOfficeBrowserProfileEmpty"),headerExtra:s.jsxs("label",{className:"settings-skill-inline-toggle",children:[s.jsx("input",{type:"checkbox",checked:ye,disabled:!(r!=null&&r.trim()),onChange:x=>Re(x.target.checked)}),s.jsx("span",{children:l("settings.skillOfficeBrowserProfileOnlyCurrentWorkspace")})]}),items:gn,renderItem:x=>s.jsxs("div",{className:"settings-skill-entry settings-browser-profile-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeBrowserProfileListMeta",{engine:dh(x.engine),mode:xv(x.mode),scope:vv(x.ownershipScope)})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:dh(x.engine)}),s.jsx("span",{className:"settings-skill-tag","data-status":Cv(x.status),children:Sv(x.status)}),s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:l("settings.skillOfficeBrowserProfileWorkspaceTag",{workspaceName:hh(x.workspaceId,hs)})}),x.ownershipScope==="user"?s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.skillOfficeBrowserProfileCrossWorkspaceTag")}):null,x.cdpEndpoint?s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:l("settings.skillOfficeBrowserProfileCdpEndpointTag")}):null]}),s.jsx("p",{className:"settings-skill-entry-meta settings-skill-path",children:x.userDataDir??x.cdpEndpoint??l("settings.skillOfficeBrowserProfileUserDataDirLabel")})]}),s.jsxs("div",{className:"settings-skill-entry-actions settings-browser-profile-entry-actions",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{Ws(x)},children:l("settings.skillOfficeBrowserProfileOptionAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{wt(x)},children:ee===`browser-profile-tasks:${x.id}`?l("common.loading"):l("settings.skillOfficeBrowserProfileTaskAction")}),s.jsx("button",{className:"settings-button-danger",type:"button",disabled:N||ee!==null,onClick:()=>{Kt(x)},children:l("settings.skillOfficeBrowserProfileDeleteAction")})]})]},x.id)})]}):null,Xn?s.jsxs("div",{id:`${Ht}-ops-panel`,role:"tabpanel","aria-labelledby":`${Ht}-ops-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillOpsTaskCount"),value:String(I.length)}),s.jsx(In,{label:l("settings.skillOpsTargetCount"),value:String(z.length)}),s.jsx(In,{label:l("settings.skillOpsWorkspaceScope"),value:r!=null&&r.trim()?l("settings.skillOfficeScoped"):l("settings.skillOfficeGlobal")})]}),fe?s.jsx("p",{className:"settings-release-status",children:fe}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null]}),s.jsx(_r,{title:l("settings.skillOpsTaskListTitle"),description:l("settings.skillOpsTaskListDescription"),emptyText:l("settings.skillOpsTaskEmpty"),items:I,renderItem:x=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOpsTaskListMeta",{status:x.status,risk:x.riskLevel})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:x.connectorId}),s.jsx("span",{className:"settings-skill-tag","data-status":mh(x.status),children:x.status})]}),(K==null?void 0:K.task.id)===x.id?s.jsx("div",{className:"settings-skill-tags",children:K.approvals.map(H=>s.jsx("span",{className:"settings-skill-tag","data-status":H.status==="pending"?"pending":H.status==="approved"?"synced":"failed",children:H.status},H.id))}):null]}),s.jsxs("div",{className:"settings-skill-entry-actions",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{bn(x.id)},children:ee===`ops-task-detail:${x.id}`?l("common.loading"):l("settings.skillOpsTaskDetailAction")}),(K==null?void 0:K.task.id)===x.id?K.approvals.filter(H=>H.status==="pending").map(H=>s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{Gr(H.id,"approved")},children:ee===`ops-approval:${H.id}:approved`?l("common.loading"):l("settings.skillOpsApprovalApproveAction")},H.id)):null]})]},x.id)}),s.jsx(_r,{title:l("settings.skillOpsTargetListTitle"),description:l("settings.skillOpsTargetListDescription"),emptyText:l("settings.skillOpsTargetEmpty"),items:z,renderItem:x=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:x.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:Mv(x)}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:x.kind}),s.jsx("span",{className:"settings-skill-tag","data-status":x.status==="active"?"synced":"failed",children:x.status})]})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>pr(x),children:l("settings.skillOpsTargetEditAction")})})]},x.id)})]}):null,Qn?s.jsx("div",{id:`${Ht}-opencli-panel`,role:"tabpanel","aria-labelledby":`${Ht}-opencli-tab`,className:"settings-skill-panel",children:s.jsx(Gx,{toolbarMode:"external",onToolbarStateChange:D})}):null]}),s.jsx(St,{open:_,title:l("settings.skillOfficeTemplateModalTitle"),description:l("settings.skillOfficeTemplateModalDescription"),className:"settings-skill-create-modal",onClose:()=>{G(!1),Bt(ta())},children:s.jsxs(Rn,{heading:l("settings.skillOfficeTemplateFormTitle"),children:[s.jsx("input",{ref:c,type:"file",accept:".domt,.doct,application/octet-stream",className:"settings-skill-upload-input",onChange:x=>{ps(x)}}),s.jsx(Lt,{label:l("settings.skillOfficeTemplateUploadLabel"),description:l("settings.skillOfficeTemplateUploadDescription"),children:s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{var x;return(x=c.current)==null?void 0:x.click()},children:l("settings.skillOfficeTemplatePickAction")})})}),pt.fileName?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:pt.fileName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeTemplateAutoDetectHint")})]})}):null,s.jsxs(Ns,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{G(!1),Bt(ta())},children:l("common.cancel")}),s.jsx("button",{className:"primary-button",type:"button",disabled:!pt.fileName||N||ee!==null,onClick:()=>{Zt()},children:ee==="office-template-submit"?l("common.loading"):l("settings.skillOfficeTemplateSaveAction")})]})]})}),s.jsx(St,{open:Q,title:l("settings.skillOfficeBrowserProfileModalTitle"),description:l("settings.skillOfficeBrowserProfileModalDescription"),className:"settings-skill-create-modal",onClose:()=>{Ce(!1),_t(ea(r))},children:s.jsxs(Rn,{heading:l("settings.skillOfficeBrowserProfileFormTitle"),children:[s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileNameLabel"),htmlFor:"browser-profile-name",children:s.jsx("input",{id:"browser-profile-name",className:"settings-text-input",value:mt.displayName,onChange:x=>_t(H=>({...H,displayName:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileEngineLabel"),htmlFor:"browser-profile-engine",children:s.jsxs("select",{id:"browser-profile-engine",className:"settings-select",value:mt.engine,onChange:x=>_t(H=>({...H,engine:x.target.value})),children:[s.jsx("option",{value:"chrome",children:l("settings.skillOfficeBrowserProfileEngineChrome")}),s.jsx("option",{value:"edge",children:l("settings.skillOfficeBrowserProfileEngineEdge")})]})}),s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileModeLabel"),htmlFor:"browser-profile-mode",children:s.jsxs("select",{id:"browser-profile-mode",className:"settings-select",value:mt.mode,onChange:x=>_t(H=>({...H,mode:x.target.value})),children:[s.jsx("option",{value:"persistent",children:l("settings.skillOfficeBrowserProfileModePersistent")}),s.jsx("option",{value:"cdp_attached",children:l("settings.skillOfficeBrowserProfileModeCdpAttached")})]})}),s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileScopeLabel"),htmlFor:"browser-profile-scope",children:s.jsxs("select",{id:"browser-profile-scope",className:"settings-select",value:mt.ownershipScope,onChange:x=>_t(H=>({...H,ownershipScope:x.target.value})),children:[s.jsx("option",{value:"user",children:l("settings.skillOfficeBrowserProfileScopeUser")}),s.jsx("option",{value:"workspace",children:l("settings.skillOfficeBrowserProfileScopeWorkspace")}),s.jsx("option",{value:"target",children:l("settings.skillOfficeBrowserProfileScopeTarget")})]})}),mt.mode==="cdp_attached"?s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileCdpEndpointLabel"),description:l("settings.skillOfficeBrowserProfileCdpEndpointDescription"),htmlFor:"browser-profile-cdp-endpoint",children:s.jsx("input",{id:"browser-profile-cdp-endpoint",className:"settings-text-input",value:mt.cdpEndpoint,onChange:x=>_t(H=>({...H,cdpEndpoint:x.target.value}))})}):null,s.jsxs(Ns,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{Ce(!1),_t(ea(r))},children:l("common.cancel")}),s.jsx("button",{className:"primary-button",type:"button",disabled:N||ee!==null,onClick:()=>{en()},children:ee==="browser-profile-submit"?l("common.loading"):l("settings.skillOfficeBrowserProfileSaveAction")})]})]})}),s.jsx(St,{open:ie,title:l("settings.skillOfficeBrowserProfileTaskModalTitle",{profileName:(V==null?void 0:V.displayName)??"-"}),description:l("settings.skillOfficeBrowserProfileTaskModalDescription"),className:"settings-skill-detail-modal",onClose:()=>{ke(!1),X(null),O(null)},children:s.jsx(Rn,{heading:l("settings.skillOfficeBrowserProfileTaskListTitle"),description:V?l("settings.skillOfficeBrowserProfileTaskListDescription",{workspaceName:hh(V.workspaceId,hs)}):void 0,children:cr.length===0?s.jsx(Ba,{title:l("settings.skillOfficeBrowserProfileTaskEmpty"),compact:!0}):s.jsx(bi,{children:cr.map(x=>{const H=v[x.id]??null,Pe=(J==null?void 0:J.task.id)===x.id;return s.jsxs(Xt,{className:"settings-browser-task-list-item",label:x.title,description:l("settings.skillOfficeBrowserInstanceListMeta",{profileName:(V==null?void 0:V.displayName)??"-",status:ph(H,x.status),risk:x.riskLevel}),trailing:s.jsxs("div",{className:"settings-skill-entry-actions settings-browser-task-list-item-actions",children:[s.jsx("span",{className:"settings-skill-entry-meta",children:Pv(x.createdAt)}),s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{Rr(x.id)},children:ee===`browser-task-detail:${x.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceDetailAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null||!Rv(x.status),onClick:()=>{ur(x.id)},children:ee===`browser-task-execute:${x.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceExecuteAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null||!Ev(H),onClick:()=>{dr(x.id)},children:ee===`browser-task-cancel:${x.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceCancelAction")})]}),children:[s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":mh(x.status),children:x.status}),s.jsx("span",{className:"settings-skill-tag","data-status":Tv(Jd(x)),children:jv(Jd(x))}),s.jsx("span",{className:"settings-skill-tag","data-status":Av(H),children:ph(H,x.status)})]}),Pe?s.jsxs("div",{className:"settings-skill-entry-meta",children:[s.jsx("p",{children:H?l("settings.skillOfficeBrowserInstanceSnapshotMeta",{status:Jm(H.status),attempt:H.attempt,startedAt:bh(H.startedAt),finishedAt:bh(H.finishedAt)}):l("settings.skillOfficeBrowserInstanceSnapshotPending")}),J.steps.map(Je=>s.jsxs("p",{children:[Je.title," · ",Je.status]},Je.id))]}):null]},x.id)})})})}),s.jsx(St,{open:Ae,title:l("settings.skillOfficeBrowserProfileOptionsModalTitle",{profileName:(A==null?void 0:A.displayName)??"-"}),description:l("settings.skillOfficeBrowserProfileOptionsModalDescription"),className:"settings-skill-create-modal",onClose:()=>{ve(!1),U(null)},children:s.jsxs(Rn,{heading:l("settings.skillOfficeBrowserProfileOptionsSectionTitle"),children:[s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileCrossWorkspaceFieldLabel"),description:l("settings.skillOfficeBrowserProfileCrossWorkspaceFieldDescription"),children:s.jsx("div",{className:"settings-skill-entry-actions settings-browser-profile-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:!A||N||ee!==null||!Nv(A),onClick:()=>{A&&vn(A)},children:A&&ee===`browser-profile-scope:${A.id}`?l("common.loading"):(A==null?void 0:A.ownershipScope)==="user"?l("settings.skillOfficeBrowserProfileSetWorkspaceOnlyAction"):l("settings.skillOfficeBrowserProfileAllowCrossWorkspaceAction")})})}),s.jsx(Ns,{children:s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{ve(!1),U(null)},children:l("common.close")})})]})}),s.jsx(St,{open:Tt,title:l("settings.skillOfficeBrowserProfileDeleteModalTitle"),description:l("settings.skillOfficeBrowserProfileDeleteModalDescription"),className:"settings-skill-create-modal",onClose:()=>{rt(!1),le(null)},children:s.jsxs(Rn,{heading:(B==null?void 0:B.displayName)??"-",children:[s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeBrowserProfileDeleteModalWarning")}),s.jsxs(Ns,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{rt(!1),le(null)},children:l("common.cancel")}),s.jsx("button",{className:"settings-button-danger",type:"button",disabled:!B||N||ee!==null,onClick:()=>{Sn()},children:B&&ee===`browser-profile-delete:${B.id}`?l("common.loading"):l("settings.skillOfficeBrowserProfileDeleteConfirmAction")})]})]})}),s.jsx(St,{open:gt,title:l("settings.skillOpsTargetModalTitle"),description:l("settings.skillOpsTargetModalDescription"),className:"settings-skill-create-modal",onClose:()=>{ae(!1),ct(Zo())},children:s.jsxs(Rn,{heading:l("settings.skillOpsTargetFormTitle"),description:l("settings.skillOpsTargetFormDescription"),children:[s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOpsPasswordNotice")}),s.jsx(Lt,{label:l("settings.skillOpsTargetNameLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.displayName,onChange:x=>ct(H=>({...H,displayName:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetEnvironmentLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.environment,onChange:x=>ct(H=>({...H,environment:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetHostLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.host,onChange:x=>ct(H=>({...H,host:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetPortLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.port,onChange:x=>ct(H=>({...H,port:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetUsernameLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.username,onChange:x=>ct(H=>({...H,username:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetPrivateKeyPathLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.privateKeyPath,onChange:x=>ct(H=>({...H,privateKeyPath:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetKnownHostsPathLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.knownHostsPath,onChange:x=>ct(H=>({...H,knownHostsPath:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetJumpHostLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.jumpHost,onChange:x=>ct(H=>({...H,jumpHost:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetWorkspacePathLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.workspacePath,onChange:x=>ct(H=>({...H,workspacePath:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetCredentialRefLabel"),children:s.jsx("input",{className:"settings-text-input",value:tt.credentialRef,onChange:x=>ct(H=>({...H,credentialRef:x.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetHostKeyPolicyLabel"),children:s.jsxs("select",{className:"settings-select",value:tt.strictHostKeyChecking,onChange:x=>ct(H=>({...H,strictHostKeyChecking:x.target.value})),children:[s.jsx("option",{value:"accept-new",children:"accept-new"}),s.jsx("option",{value:"yes",children:"yes"}),s.jsx("option",{value:"no",children:"no"})]})}),s.jsxs(Ns,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:zn,children:l("settings.skillOpsTargetResetAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:N||ee!==null,onClick:()=>{Er()},children:ee==="ops-target-submit"?l("common.loading"):l("settings.skillOpsTargetSaveAction")})]})]})}),s.jsxs(St,{open:$,title:l("settings.skillWorkspaceSessionMcpModalTitle"),description:l("settings.skillWorkspaceSessionMcpModalDescription"),className:"settings-skill-create-modal",onClose:()=>{Z(!1),Ne(null)},children:[s.jsx(Rn,{heading:l("settings.skillWorkspaceSessionMcpRuntimeTitle"),description:l("settings.skillWorkspaceSessionMcpRuntimeDescription"),children:Be?s.jsx("div",{className:"settings-skill-empty",children:l("settings.skillWorkspaceSessionMcpLoading")}):ge?s.jsxs("div",{className:"settings-skill-entry-list",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillWorkspaceSessionMcpOverallLabel"),value:(Ie==null?void 0:Ie.overallState)==="ready"?l("settings.skillWorkspaceSessionMcpStateReady"):(Ie==null?void 0:Ie.overallState)==="partial"?l("settings.skillWorkspaceSessionMcpStatePartial"):l("settings.skillWorkspaceSessionMcpStateMissing")}),s.jsx(In,{label:l("settings.skillWorkspaceSessionMcpCurrentSessionLabel"),value:Ie!=null&&Ie.currentSessionReady?l("settings.skillWorkspaceSessionMcpStateReady"):l("settings.skillWorkspaceSessionMcpStateMissing")}),s.jsx(In,{label:l("settings.skillWorkspaceSessionMcpCodexLabel"),value:(Ie==null?void 0:Ie.codexState)==="ready"?l("settings.skillWorkspaceSessionMcpStateReady"):(Ie==null?void 0:Ie.codexState)==="partial"?l("settings.skillWorkspaceSessionMcpStatePartial"):l("settings.skillWorkspaceSessionMcpStateMissing")})]}),s.jsxs(bi,{children:[s.jsx(Xt,{label:l("settings.skillWorkspaceSessionMcpRuntimeTitle"),description:(Ie==null?void 0:Ie.currentSessionDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:qi(Ie!=null&&Ie.currentSessionReady?"ready":"missing")}),s.jsx(Xt,{label:"Codex",description:(Ie==null?void 0:Ie.codexDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:qi((Ie==null?void 0:Ie.codexState)??"missing")}),s.jsx(Xt,{label:l("settings.skillWorkspaceSessionMcpGlobalCodingnsLabel"),description:(Ie==null?void 0:Ie.globalCodingnsDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:qi((Ie==null?void 0:Ie.globalCodingnsState)??"missing")})]})]}):s.jsx(Ba,{title:l("settings.skillWorkspaceSessionMcpEmptyTitle"),description:be??l("settings.skillWorkspaceSessionMcpEmptyDescription"),compact:!0})}),s.jsx(Rn,{heading:l("settings.skillWorkspaceSessionMcpCommandTitle"),description:l("settings.skillWorkspaceSessionMcpCommandDescription"),children:ge?s.jsxs(bi,{children:[s.jsx(Xt,{label:l("settings.skillWorkspaceSessionMcpBrowserBridgeLabel"),description:l("settings.skillWorkspaceSessionMcpBrowserBridgeDetail"),trailing:qi("ready")}),s.jsx(Xt,{label:l("settings.skillWorkspaceSessionMcpRecommendedPathLabel"),description:(Ie==null?void 0:Ie.recommendedPath)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:qi("ready")})]}):null}),s.jsx(Ns,{children:s.jsx("button",{className:"secondary-button",type:"button",disabled:!(r!=null&&r.trim())||Be,onClick:()=>{hr()},children:Be?l("common.loading"):l("settings.skillWorkspaceSessionMcpRefreshAction")})})]}),s.jsx(St,{open:je,title:l("settings.skillCreateModalTitle"),description:l("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:on,children:s.jsxs("section",{className:"settings-skill-section",children:[s.jsx("h3",{className:"settings-skill-section-title",children:l("settings.skillUploadSectionTitle")}),s.jsx("p",{className:"settings-skill-section-description",children:l("settings.skillUploadSectionDescription")}),s.jsxs("div",{className:"settings-skill-create-panel",children:[s.jsx("input",{ref:a,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:x=>{fr(x)}}),s.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:gv.map(x=>{const H=st===x;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":H,"data-active":H?"true":"false",onClick:()=>Mr(x),children:kv(x)},x)})}),s.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:mv.map(x=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":qe===x?"true":"false",children:[s.jsx("input",{type:"radio",name:"skill-upload-scope",checked:qe===x,onChange:()=>mr(x)}),s.jsx("span",{children:bv(x)})]},x))}),st==="file"?s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:N||ee!==null,onClick:()=>{var x;(x=a.current)==null||x.click()},children:l("settings.skillUploadPickAction")})}):s.jsxs("label",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillPasteLabel")}),s.jsx("textarea",{className:"settings-skill-create-textarea",value:Ut,onChange:x=>Ye(x.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),Vt?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:Vt.previewTitle}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",Vt.fileName]})]})}):s.jsx("div",{className:"settings-skill-empty",children:st==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty")}),s.jsxs("div",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillUploadTargetsLabel")}),s.jsx("div",{className:"settings-skill-upload-targets",children:$a(qe).map(x=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":ht[x]?"true":"false",children:[s.jsx("input",{type:"checkbox",checked:ht[x],disabled:!pn(x,yt),onChange:()=>sn(x)}),s.jsx("span",{children:pn(x,yt)?Fn(x):`${Fn(x)} · ${l("settings.skillTargetDisabledTag")}`})]},x))})]}),Vt!=null&&Vt.notes.length?s.jsx("div",{className:"settings-skill-tags",children:Vt.notes.map((x,H)=>s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:x},`${Vt.fileName}:${H}`))}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null,s.jsx("div",{className:"settings-skill-create-actions",children:s.jsx("button",{className:"primary-button",type:"button",disabled:N||ee!==null,onClick:()=>{Pr()},children:ee==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function _r({title:e,description:t,headerExtra:n,emptyText:r,items:i,renderItem:o}){return s.jsxs("section",{className:"settings-skill-section",children:[s.jsxs("div",{className:"settings-skill-section-header",children:[s.jsx("h3",{className:"settings-skill-section-title",children:e}),n?s.jsx("div",{className:"settings-skill-section-extra",children:n}):null]}),t?s.jsx("p",{className:"settings-skill-section-description",children:t}):null,i.length>0?s.jsx("div",{className:"settings-skill-entry-list",children:i.map((a,c)=>s.jsx(f.Fragment,{children:o(a)},c))}):s.jsx("div",{className:"settings-skill-empty",children:r})]})}function In({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function ch(e){return`import:${e.targetCli}:${e.directoryPath}`}function uh(e){return`sync:${e}`}const pv=["codex","claude-code","gemini","opencode"],fv=["codex","claude-code"],mv=["workspace","assistant"],gv=["file","paste"];function Jt(e){return e instanceof il?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function Fn(e){switch(e){case"claude-code":return l("settings.skillTargetClaudeCode");case"gemini":return l("settings.skillTargetGemini");case"opencode":return l("settings.skillTargetOpenCode");default:return l("settings.skillTargetCodex")}}function bv(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function kv(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function yv(e){switch(e){case"office":return l("settings.skillConfigTabOffice");case"ops":return l("settings.skillConfigTabOps");case"opencli":return l("settings.skillConfigTabOpenCli");default:return l("settings.skillConfigTabSkills")}}function Hi(e,t={}){const r=$a(e).filter(i=>pn(i,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function $a(e){return e==="assistant"?fv:pv}function Zo(){return{targetId:null,displayName:"",environment:"",host:"",port:"22",username:"",privateKeyPath:"",knownHostsPath:"",jumpHost:"",workspacePath:"",credentialRef:"",strictHostKeyChecking:"accept-new",status:"active"}}function ea(e){return{displayName:"",engine:"chrome",mode:"persistent",ownershipScope:e!=null&&e.trim()?"workspace":"user",cdpEndpoint:""}}function ta(){return{fileName:"",fileContentBase64:""}}function Vm(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function ss(e){return typeof e=="string"?e:""}function Ym(e,t){return typeof e=="number"&&Number.isFinite(e)?String(e):String(t)}function wv(e){return e==="yes"||e==="no"||e==="accept-new"?e:"accept-new"}function dh(e){return e==="edge"?l("settings.skillOfficeBrowserProfileEngineEdge"):l("settings.skillOfficeBrowserProfileEngineChrome")}function xv(e){return e==="cdp_attached"?l("settings.skillOfficeBrowserProfileModeCdpAttached"):l("settings.skillOfficeBrowserProfileModePersistent")}function vv(e){switch(e){case"workspace":return l("settings.skillOfficeBrowserProfileScopeWorkspace");case"target":return l("settings.skillOfficeBrowserProfileScopeTarget");default:return l("settings.skillOfficeBrowserProfileScopeUser")}}function Sv(e){switch(e){case"locked":return l("settings.skillOfficeBrowserProfileStatusLocked");case"archived":return l("settings.skillOfficeBrowserProfileStatusArchived");case"error":return l("settings.skillOfficeBrowserProfileStatusError");default:return l("settings.skillOfficeBrowserProfileStatusActive")}}function Cv(e){switch(e){case"locked":return"pending";case"archived":case"error":return"failed";default:return"synced"}}function hh(e,t){var n;return e!=null&&e.trim()?((n=t.get(e))==null?void 0:n.name)??l("settings.skillOfficeBrowserProfileWorkspaceUnknown"):l("settings.skillOfficeBrowserProfileWorkspaceUnbound")}function Nv(e){var t;return e.ownershipScope==="user"?!!((t=e.workspaceId)!=null&&t.trim()):!0}function ph(e,t){return e?Jm(e.status):t==="succeeded"?l("settings.skillOfficeBrowserInstanceExecutionSucceeded"):t==="failed"?l("settings.skillOfficeBrowserInstanceExecutionFailed"):t==="cancelled"?l("settings.skillOfficeBrowserInstanceExecutionCancelled"):l("settings.skillOfficeBrowserInstanceExecutionIdle")}function Jm(e){switch(e){case"queued":return l("settings.skillOfficeBrowserInstanceExecutionQueued");case"running":return l("settings.skillOfficeBrowserInstanceExecutionRunning");case"succeeded":return l("settings.skillOfficeBrowserInstanceExecutionSucceeded");case"failed":return l("settings.skillOfficeBrowserInstanceExecutionFailed");case"cancelled":return l("settings.skillOfficeBrowserInstanceExecutionCancelled");default:return l("settings.skillOfficeBrowserInstanceExecutionTimeout")}}function jv(e){return e==="opencli_bridge"?l("settings.skillOfficeBrowserExecutionBackendOpenCliBridge"):l("settings.skillOfficeBrowserExecutionBackendPlaywright")}function Tv(e){return e==="opencli_bridge"?"pending":"synced"}function fh(e){if(!e)return l("settings.skillOfficeBrowserBridgeAvailabilityUnknown");switch(e.availability){case"ready":return l("settings.skillOfficeBrowserBridgeAvailabilityReady");case"daemon_missing":return l("settings.skillOfficeBrowserBridgeAvailabilityDaemonMissing");case"extension_missing":return l("settings.skillOfficeBrowserBridgeAvailabilityExtensionMissing");default:return l("settings.skillOfficeBrowserBridgeAvailabilityUnavailable")}}function Iv(e){if(!e)return"conflicted";switch(e.availability){case"ready":return"synced";case"daemon_missing":case"extension_missing":return"pending";default:return"failed"}}function Av(e){if(!e)return"conflicted";switch(e.status){case"queued":case"running":return"pending";case"succeeded":return"synced";case"failed":case"cancelled":case"timeout":return"failed";default:return"conflicted"}}function Rv(e){return e==="ready"||e==="failed"}function Ev(e){return(e==null?void 0:e.status)==="queued"||(e==null?void 0:e.status)==="running"}function Pv(e){return new Date(e).toLocaleString("zh-CN",{hour12:!1})}function mh(e){return e==="ready"||e==="running"||e==="succeeded"?"synced":e==="pending_approval"||e==="waiting_external"||e==="paused"?"pending":e==="failed"||e==="cancelled"||e==="rolled_back"?"failed":"conflicted"}function Mv(e){var a;const t=Vm(e.configJson),n=ss(t.host),r=ss(t.username),i=Ym(t.port,22);return[(a=e.environment)==null?void 0:a.trim(),`${r}@${n}:${i}`].filter(c=>c&&c.trim().length>0).join(" · ")}function qi(e){const t=e==="ready"?"synced":e==="partial"?"pending":"failed",n=e==="ready"?l("settings.skillWorkspaceSessionMcpStateReady"):e==="partial"?l("settings.skillWorkspaceSessionMcpStatePartial"):l("settings.skillWorkspaceSessionMcpStateMissing");return s.jsx("span",{className:"settings-skill-tag","data-status":t,children:n})}function gh({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?Zm(Zv(n),n):null}function Lv(e){switch(e){case"conflicted":return l("settings.skillBindingConflicted");case"failed":return l("settings.skillBindingFailed");case"pending":return l("settings.skillBindingPending");default:return l("settings.skillBindingSynced")}}function Dv(e){const t={};for(const n of e){const r=Ov(n.provider);r&&(t[r]=n)}return t}function Ov(e){switch(e){case"claude-code":return"claude-code";case"codex":return"codex";case"gemini":return"gemini";case"opencode":return"opencode";default:return null}}function pn(e,t){var n;return((n=t[e])==null?void 0:n.enabled)!==!1}function Bv(e,t){return e.some(n=>n.enabled&&pn(n.targetCli,t))}function _v(e,t){return pn(e.targetCli,t)?e.syncStatus:"failed"}function Wv(e,t){return pn(e.targetCli,t)?`${Fn(e.targetCli)} · ${Lv(e.syncStatus)}`:`${Fn(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function Xm(e){return e.map(Fn).join(" / ")}function Fv(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:Xm(t.map(n=>n.targetCli))})}function $v(e,t){return pn(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:Fn(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:Fn(e.targetCli)})}function zv(e,t){return pn(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:Fn(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:Fn(e.targetCli)})}function Uv(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function Hv(e,t){return $a(e).some(r=>pn(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function qv(e){const t=Fn(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:l("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:l("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:l("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:l("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:l("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:l("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:l("settings.skillDiagnosticGenericTitle",{target:t}),detail:l("settings.skillDiagnosticGenericDetail",{target:t})}}}function Gv(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function bh(e){return e===null?"-":new Date(e).toLocaleString()}async function kh(e){const t=await Promise.all(e.map(async n=>[n.id,await Uc(n.id)]));return Object.fromEntries(t)}function Kv(e,t,n){if(e.length>0)return e.map(i=>({name:i.name,directoryName:i.directoryName,sourcePath:i.sourcePath,usedByTargetCli:i.usedByTargetCli,usageTag:Ql(i.directoryName)}));const r=new Map;for(const i of t)Qm(i,n)&&r.set(yh(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli],usageTag:Ql(i.directoryName)});for(const i of n){if(!jo(i))continue;const o=i.directoryPath??i.rootDir,a=yh(i.targetCli,o);r.has(a)||r.set(a,{name:i.directoryName??"codingns-assistant",directoryName:i.directoryName??"codingns-assistant",sourcePath:o,usedByTargetCli:[i.targetCli],usageTag:Ql(i.directoryName??"codingns-assistant")})}return[...r.values()]}function yh(e,t){return`${e}:${t}`}function Qm(e,t){return t.some(n=>jo(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function jo(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function Ql(e){return e==="codingns-workspace-session"?"workspace-session":"assistant-only"}function Vv(e){return e==="workspace-session"?l("settings.skillTagWorkspaceSessionOnly"):l("settings.skillTagAssistantOnly")}function Yv(e,t){return t.find(r=>jo(r)&&r.targetCli===e.targetCli&&r.directoryName===e.directoryName&&r.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Jv(e){return jo(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Zm(e,t){const n=[],r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
4
|
-
`).trim();if(!r)throw new Error(l("settings.skillUploadContentEmpty"));r!==t.trim()&&n.push(l("settings.skillUploadNormalizedNote"));const i=eg(r),o=qc(e)??qc(i)??"";return o||n.push(l("settings.skillUploadDirectoryRequiredNote")),i||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:o,previewTitle:i||eS(o||"skill"),notes:n}}async function Xv(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(typeof r.result=="string"){t(r.result);return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsText(e)})}async function Qv(e){if(typeof e.arrayBuffer=="function"){const t=await e.arrayBuffer();return wh(new Uint8Array(t))}if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(r.result instanceof ArrayBuffer){t(wh(new Uint8Array(r.result)));return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsArrayBuffer(e)})}function wh(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t)}function qc(e){const r=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return r.length>0?r:null}function Zv(e){const t=qc(eg(e));return t?`${t}.md`:"pasted-skill.md"}function eg(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function eS(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}const tS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",nS="/assets/legna-code-6TqgZ4Ls.png",tg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbGSURBVHgBzZo/bBtVHMd/ZzuJA0gYCYlsOFO7xRFDy1R3olucqd0SJtiSjiCknBckpjZjBxRn7BR3owOqs5Wp7tZKoDgSQysh4UqUOCG2eZ/3/Oznv/fObqJ+pfPZd+/ufn++vz/vnQN5FwjbGZFGQSRYUb+yIu2c2tSxIOOMqpktqKpzz9X3ioSLNZkRgUwLhA4aW9KWvPqVl6mgldmVGZSJr0BX8Pb2gIVnRUltxbiKxFOgeLJzAYL3I5BQdhaL/sN9EJ5k1dADw+1LQU1tN328kYgaIMWzDSX4s0sUHmSVwZ5JeFqIGjhZgeKpokyzdKGUGQuyWOtA03YCxlNIC98K5X3AhLgYrYB2ndLeE5l0IFvXklK4mpRsxvyuvmqrrSX71aZUjlsyM4LkpuzM7w8dHhqoAxbO+9Fm63pSwhspLTSo1dt6n830bl1SStx9fK6/Z9LmWL3B1hZ/BHUl1+pgYI9S4Eh0EEVjJ5/SwiPI7m9Nuf+02SfUZi4pO+o8ynDcKmlRqRkPlZ43xQ+q8IXpVfdIsu88vJd2ZOSD/OcJKRXmtMW//PlMyi9a0jjvH5NZCDStEDydCjSlfvm9pa/hd24poc+zf/zH8PUjsCT57wOp/FjpqtQ9pakjR+KJo60Fbdnl3dMubSw4vrc2J/msSXLlF4ZCg+M4zzjGEzM39888aAWVFpYlZN+fRnfEE1iMh8JtVygsDWWefTOvhYMiCLX+8L8h4QHnVx+cas/klgLZvpb0eDrp9d/trjr609P6brbhgesPDXXA5kpS7t0ywYwVi4fERD8noJ1WfIDzBDYeRRw8GscL1gP5iCv0g7FsqAIX4UH9pHeegEb44uG5EuKsT3iuPbg9J08252VPxQ3CoowFGYlgRhEMEY2eFzp3CbbEQ3j28BnXjwI0CSvnXQu6lMJrnOd67qOV6fAf2HuuLPn2l4kbRgGT9yf2OU825o11lXDw+bgenb8LV5JdjwE8s/rAxMPXj0xMkGbxBkpWX8epCRp5WvuERNAHl9qADQ+j8xz0QuGDOz3rIizXW8/wHa7bzISSKAveNCQGGoVElPU3coaTcDQKhmoL3QxEkLMna2FplzKAOCFLGf6b4x+nJQbauURnHjsWWJQg8+1nsChCsZGh2LuUwTvb11J94zfVeVtPGOOej4CuNNlJI2xa9BUeQQaD3FKG83iAdItHClcSQ4rzLJvRohGsRCowqoexyCxKbNiUqVPrnf5MhBL0VKRTv6IWZCJnZJR4bujm7eprY+GD2/M6g/hZyypgKENGspThHha2fqxdjZ4sUg8iRz16aYLXBrN5SLPLa5tBMrGCT3T7wD0GgYcM1XwU0IWsXZ80wPY7WMpVguM2g0ABvMDmZhkXZox4w3dswvQV44FFSIe4vqT46rrbzSAEru1pXF6j1L2vTND6Us10p15Zr5Ywq2OTQRwUO0UMyiCM27PYDDKYLomRoy2VNq+n9HGfbGbvyzM9FWgd+4zMfWY4iaV1v6+assHCZNOl7XcKnUC0bUQ9osrq3qnTevgUTtZYUz4ecGEDDwtjaTYER8jsx0YAO5Gxc2EfyyP83lqq27b4Fc6gqhRolEXSe1FDrRBUZioslrYpkD3WthzHSyg0WNCIkVFeoNWw3S7UsQsAHqiobvQTgrgSNbL80gizdmU4EyEswsNzPMQxV3hqiO1oR3kDoyD87tOm57QStKusUNiUcigRXSlZQRchZW2qpc0Sdg5AbQDuw3XboDIQcwGAUm7uh3LWEPvPx88zRiNgWd5OaBr3o+oBrmeaCJhdDeZ7BB83kbETdjZ3bmzryii6eaDCR8c0PzUk/wOdTX7SFU//bEmg5EYoUiOCvv5H5NXbnuDffpHUGYoxLJN892uvarsgXXIPa/14SJTU+pBepXOWVf5W88yFI58VOWqBW9DAYNM3KQMRE0x4gO2JYmLZrtD1ItLTC3ooK2rKasdvzAIVwNp2PfTqpwmdWZY+CswMKzDeYZp579acNgDjodSLv+IK31JvcT4o218jlhYbM78LcJcUR8EG8xSWrynLL7sHZl7cnQQUoYKvLJn0eVwnHTenCVgxSSbwWNwF4cmm+owsbpeLxLqEC+WhoyPHhosl4Y3hewN4Pyw8mNzfhiehxFgzvRgg/IfhuLPRDXr4ljfwe5f/nkxz/m6HDWMR4zWrPBHPFx+zQ7/BX/d5zRrvRfeFU0pbfVcJHvpeMcVfDfAGby8TG/LO0BFc0vftiwtfzPBnD02rvFnZnrrwVUR3wvEFt5heARddZVDE/uXGjRdt4bru4UWODcfT5WmFdvE/Jeqz44iuBr4AAAAASUVORK5CYII=",rS="/assets/gemini-D4G1NbrE.png",sS="/assets/kimi-BWNNSh7e.png",iS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",oS=new Set(["low","medium","high","xhigh"]),ng=["claude-code","codex","opencode","gemini","kimi","legna-code"],Fu=["codex","claude-code","opencode","gemini","kimi","legna-code"];function xh(e){const t=new Set,n=[],r=[...Fu,...ng];for(const i of r)e.includes(i)&&(t.has(i)||(t.add(i),n.push(i)));for(const i of e)t.has(i)||(t.add(i),n.push(i));return n}const rg={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:tS,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,supportsRunSteeringByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},"legna-code":{displayNameKey:"conversation.providerLegna",fullDisplayNameKey:"shell.providerLegnaCode",draftTitleKey:"conversation.draftTitleLegna",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:nS,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,supportsRunSteeringByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},codex:{displayNameKey:"conversation.providerCodex",draftTitleKey:"conversation.draftTitleCodex",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:tg,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!0,defaultReasoningLevel:null,supportsSlashMenuByDefault:!1,supportsRunSteeringByDefault:!0,supportsQueueWhileRunningByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0},opencode:{displayNameKey:"conversation.providerOpenCode",draftTitleKey:"conversation.draftTitleOpenCode",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:iS,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:rS,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},kimi:{displayNameKey:"conversation.providerKimi",draftTitleKey:"conversation.draftTitleKimi",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:sS,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0}},aS=Array.from(new Set(Object.values(rg).map(e=>e.icon)));let vh=!1;function lS(e){return ng.includes(e)}function lr(e){return!e||!lS(e)?null:rg[e]}function cS(e){return[{id:"provider-default",name:l(e),usesProviderDefault:!0}]}function uS(e){const t=lr(e);return cS((t==null?void 0:t.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function WD(e){return!!(e&&lr(e))}function FD(e){const t=lr(e);return l((t==null?void 0:t.draftTitleKey)??"conversation.draftTitleCodex")}function za(e,t="compact"){const n=lr(e);return n?t==="full"&&n.fullDisplayNameKey?l(n.fullDisplayNameKey):l(n.displayNameKey):(e==null?void 0:e.trim())||l("conversation.providerCodex")}function dS(e){const t=lr(e);return(t==null?void 0:t.icon)??tg}function sg(){vh||typeof window>"u"||(vh=!0,aS.forEach(e=>{const t=new window.Image;t.decoding="async",t.src=e,typeof t.decode=="function"&&t.decode().catch(()=>{})}))}function $u(e){const t=lr(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(t==null?void 0:t.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(t==null?void 0:t.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(t==null?void 0:t.supportsAttachments)??!0,supportsPermissionPrompt:(t==null?void 0:t.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,supportsSessionDelete:(t==null?void 0:t.supportsSessionDeleteByDefault)??!1,modelOptions:uS(e),defaultReasoningLevel:t==null?void 0:t.defaultReasoningLevel,supportsRunSteering:t==null?void 0:t.supportsRunSteeringByDefault,supportsQueueWhileRunning:t==null?void 0:t.supportsQueueWhileRunningByDefault,limitations:[]}}function $D(e){return(e==null?void 0:e.provider)??"claude-code"}function zD(e){var n;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const t=(e==null?void 0:e.provider)??null;return((n=lr(t))==null?void 0:n.supportsSlashMenuByDefault)??!1}function UD(e){var t;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((t=e==null?void 0:e.modelOptions)!=null&&t.some(n=>{var r;return((r=n.supportedReasoningEfforts)==null?void 0:r.some(i=>oS.has(i)))??!1}))}function HD(e,t){var o;if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const n=(e==null?void 0:e.provider)??null,r=(o=lr(n))==null?void 0:o.supportsQueueWhileRunningByDefault;if(r!==void 0)return r;const i=(e==null?void 0:e.inRunInputMode)??"none";return i==="queued_guidance"||i==="none"||i==="streaming_guidance"&&t===!1}function qD(e){var n;if((e==null?void 0:e.supportsRunSteering)!==void 0)return e.supportsRunSteering;const t=(e==null?void 0:e.provider)??null;return((n=lr(t))==null?void 0:n.supportsRunSteeringByDefault)??(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function GD(e){const t=lr(e);return(t==null?void 0:t.reasoningLevelPersists)??!1}function hS(e,t){var r;return((r=lr(t??null))==null?void 0:r.foldRulesMessagesByDefault)??!1}typeof window<"u"&&sg();function pS(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fS=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mS=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gS={};function Sh(e,t){return(gS.jsx?mS:fS).test(e)}const bS=/[ \t\n\f\r]/g;function kS(e){return typeof e=="object"?e.type==="text"?Ch(e.value):!1:Ch(e)}function Ch(e){return e.replace(bS,"")===""}class To{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}To.prototype.normal={};To.prototype.property={};To.prototype.space=void 0;function ig(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new To(n,r,t)}function Gc(e){return e.toLowerCase()}class Mn{constructor(t,n){this.attribute=n,this.property=t}}Mn.prototype.attribute="";Mn.prototype.booleanish=!1;Mn.prototype.boolean=!1;Mn.prototype.commaOrSpaceSeparated=!1;Mn.prototype.commaSeparated=!1;Mn.prototype.defined=!1;Mn.prototype.mustUseProperty=!1;Mn.prototype.number=!1;Mn.prototype.overloadedBoolean=!1;Mn.prototype.property="";Mn.prototype.spaceSeparated=!1;Mn.prototype.space=void 0;let yS=0;const Ge=Os(),Gt=Os(),Kc=Os(),ue=Os(),At=Os(),yi=Os(),_n=Os();function Os(){return 2**++yS}const Vc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ge,booleanish:Gt,commaOrSpaceSeparated:_n,commaSeparated:yi,number:ue,overloadedBoolean:Kc,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),Zl=Object.keys(Vc);class zu extends Mn{constructor(t,n,r,i){let o=-1;if(super(t,n),Nh(this,"space",i),typeof r=="number")for(;++o<Zl.length;){const a=Zl[o];Nh(this,Zl[o],(r&Vc[a])===Vc[a])}}}zu.prototype.defined=!0;function Nh(e,t,n){n&&(e[t]=n)}function Ti(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new zu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Gc(r)]=r,n[Gc(o.attribute)]=r}return new To(t,n,e.space)}const og=Ti({properties:{ariaActiveDescendant:null,ariaAtomic:Gt,ariaAutoComplete:null,ariaBusy:Gt,ariaChecked:Gt,ariaColCount:ue,ariaColIndex:ue,ariaColSpan:ue,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:Gt,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:Gt,ariaFlowTo:At,ariaGrabbed:Gt,ariaHasPopup:null,ariaHidden:Gt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:ue,ariaLive:null,ariaModal:Gt,ariaMultiLine:Gt,ariaMultiSelectable:Gt,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:ue,ariaPressed:Gt,ariaReadOnly:Gt,ariaRelevant:null,ariaRequired:Gt,ariaRoleDescription:At,ariaRowCount:ue,ariaRowIndex:ue,ariaRowSpan:ue,ariaSelected:Gt,ariaSetSize:ue,ariaSort:null,ariaValueMax:ue,ariaValueMin:ue,ariaValueNow:ue,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ag(e,t){return t in e?e[t]:t}function lg(e,t){return ag(e,t.toLowerCase())}const wS=Ti({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:yi,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:At,autoFocus:Ge,autoPlay:Ge,blocking:At,capture:null,charSet:null,checked:Ge,cite:null,className:At,cols:ue,colSpan:null,content:null,contentEditable:Gt,controls:Ge,controlsList:At,coords:ue|yi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:Kc,draggable:Gt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:At,height:ue,hidden:Kc,high:ue,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:At,itemRef:At,itemScope:Ge,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:ue,manifest:null,max:null,maxLength:ue,media:null,method:null,min:null,minLength:ue,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ge,optimum:ue,pattern:null,ping:At,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:At,required:Ge,reversed:Ge,rows:ue,rowSpan:ue,sandbox:At,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:ue,sizes:null,slot:null,span:ue,spellCheck:Gt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ue,step:null,style:null,tabIndex:ue,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Gt,width:ue,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,axis:null,background:null,bgColor:null,border:ue,borderColor:null,bottomMargin:ue,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:ue,leftMargin:ue,link:null,longDesc:null,lowSrc:null,marginHeight:ue,marginWidth:ue,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:ue,rules:null,scheme:null,scrolling:Gt,standby:null,summary:null,text:null,topMargin:ue,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ue,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:ue,security:null,unselectable:null},space:"html",transform:lg}),xS=Ti({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:_n,accentHeight:ue,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ue,amplitude:ue,arabicForm:null,ascent:ue,attributeName:null,attributeType:null,azimuth:ue,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ue,by:null,calcMode:null,capHeight:ue,className:At,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ue,diffuseConstant:ue,direction:null,display:null,dur:null,divisor:ue,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:ue,enableBackground:null,end:null,event:null,exponent:ue,externalResourcesRequired:null,fill:null,fillOpacity:ue,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:yi,g2:yi,glyphName:yi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ue,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ue,horizOriginX:ue,horizOriginY:ue,id:null,ideographic:ue,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ue,k:ue,k1:ue,k2:ue,k3:ue,k4:ue,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ue,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ue,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ue,overlineThickness:ue,paintOrder:null,panose1:null,path:null,pathLength:ue,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ue,pointsAtY:ue,pointsAtZ:ue,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ue,specularExponent:ue,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ue,strikethroughThickness:ue,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ue,strokeOpacity:ue,strokeWidth:null,style:null,surfaceScale:ue,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:ue,tableValues:null,target:null,targetX:ue,targetY:ue,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ue,underlineThickness:ue,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ue,values:null,vAlphabetic:ue,vMathematical:ue,vectorEffect:null,vHanging:ue,vIdeographic:ue,version:null,vertAdvY:ue,vertOriginX:ue,vertOriginY:ue,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ue,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ag}),cg=Ti({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),ug=Ti({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:lg}),dg=Ti({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),vS={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},SS=/[A-Z]/g,jh=/-[a-z]/g,CS=/^data[-\w.:]+$/i;function NS(e,t){const n=Gc(t);let r=t,i=Mn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&CS.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(jh,TS);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!jh.test(o)){let a=o.replace(SS,jS);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=zu}return new i(r,t)}function jS(e){return"-"+e.toLowerCase()}function TS(e){return e.charAt(1).toUpperCase()}const IS=ig([og,wS,cg,ug,dg],"html"),Uu=ig([og,xS,cg,ug,dg],"svg");function AS(e){return e.join(" ").trim()}var ti={},ec,Th;function RS(){if(Th)return ec;Th=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,u=`
|
|
5
|
-
`,d="/",h="*",p="",g="comment",m="declaration";function k(v,w){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];w=w||{};var R=1,T=1;function F(V){var X=V.match(t);X&&(R+=X.length);var J=V.lastIndexOf(u);T=~J?V.length-J:T+V.length}function E(){var V={line:R,column:T};return function(X){return X.position=new I(V),L(),X}}function I(V){this.start=V,this.end={line:R,column:T},this.source=w.source}I.prototype.content=v;function q(V){var X=new Error(w.source+":"+R+":"+T+": "+V);if(X.reason=V,X.filename=w.source,X.line=R,X.column=T,X.source=v,!w.silent)throw X}function z(V){var X=V.exec(v);if(X){var J=X[0];return F(J),v=v.slice(J.length),X}}function L(){z(n)}function A(V){var X;for(V=V||[];X=U();)X!==!1&&V.push(X);return V}function U(){var V=E();if(!(d!=v.charAt(0)||h!=v.charAt(1))){for(var X=2;p!=v.charAt(X)&&(h!=v.charAt(X)||d!=v.charAt(X+1));)++X;if(X+=2,p===v.charAt(X-1))return q("End of comment missing");var J=v.slice(2,X-2);return T+=2,F(J),v=v.slice(X),T+=2,V({type:g,comment:J})}}function B(){var V=E(),X=z(r);if(X){if(U(),!z(i))return q("property missing ':'");var J=z(o),O=V({type:m,property:S(X[0].replace(e,p)),value:J?S(J[0].replace(e,p)):p});return z(a),O}}function le(){var V=[];A(V);for(var X;X=B();)X!==!1&&(V.push(X),A(V));return V}return L(),le()}function S(v){return v?v.replace(c,p):p}return ec=k,ec}var Ih;function ES(){if(Ih)return ti;Ih=1;var e=ti&&ti.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ti,"__esModule",{value:!0}),ti.default=n;const t=e(RS());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),c=typeof i=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;c?i(d,h,u):h&&(o=o||{},o[d]=h)}),o}return ti}var Gi={},Ah;function PS(){if(Ah)return Gi;Ah=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(d){return!d||n.test(d)||e.test(d)},a=function(d,h){return h.toUpperCase()},c=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),o(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,c):d=d.replace(r,c),d.replace(t,a))};return Gi.camelCase=u,Gi}var Ki,Rh;function MS(){if(Rh)return Ki;Rh=1;var e=Ki&&Ki.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(ES()),n=PS();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(c,u){c&&u&&(a[(0,n.camelCase)(c,o)]=u)}),a}return r.default=r,Ki=r,Ki}var LS=MS();const DS=em(LS),hg=pg("end"),Hu=pg("start");function pg(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function OS(e){const t=Hu(e),n=hg(e);if(t&&n)return{start:t,end:n}}function oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Eh(e.position):"start"in e||"end"in e?Eh(e):"line"in e||"column"in e?Yc(e):""}function Yc(e){return Ph(e&&e.line)+":"+Ph(e&&e.column)}function Eh(e){return Yc(e&&e.start)+"-"+Yc(e&&e.end)}function Ph(e){return e&&typeof e=="number"?e:1}class mn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=oo(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}mn.prototype.file="";mn.prototype.name="";mn.prototype.reason="";mn.prototype.message="";mn.prototype.stack="";mn.prototype.column=void 0;mn.prototype.line=void 0;mn.prototype.ancestors=void 0;mn.prototype.cause=void 0;mn.prototype.fatal=void 0;mn.prototype.place=void 0;mn.prototype.ruleId=void 0;mn.prototype.source=void 0;const qu={}.hasOwnProperty,BS=new Map,_S=/[A-Z]/g,WS=new Set(["table","tbody","thead","tfoot","tr"]),FS=new Set(["td","th"]),fg="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function $S(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=YS(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=VS(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Uu:IS,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=mg(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function mg(e,t,n){if(t.type==="element")return zS(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return US(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return qS(e,t,n);if(t.type==="mdxjsEsm")return HS(e,t);if(t.type==="root")return GS(e,t,n);if(t.type==="text")return KS(e,t)}function zS(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Uu,e.schema=i),e.ancestors.push(t);const o=bg(e,t.tagName,!1),a=JS(e,t);let c=Ku(e,t);return WS.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!kS(u):!0})),gg(e,a,o,t),Gu(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function US(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}mo(e,t.position)}function HS(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);mo(e,t.position)}function qS(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Uu,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:bg(e,t.name,!0),a=XS(e,t),c=Ku(e,t);return gg(e,a,o,t),Gu(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function GS(e,t,n){const r={};return Gu(r,Ku(e,t)),e.create(t,e.Fragment,r,n)}function KS(e,t){return t.value}function gg(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Gu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function VS(e,t,n){return r;function r(i,o,a,c){const d=Array.isArray(a.children)?n:t;return c?d(o,a,c):d(o,a)}}function YS(e,t){return n;function n(r,i,o,a){const c=Array.isArray(o.children),u=Hu(r);return t(i,o,a,c,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function JS(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&qu.call(t.properties,i)){const o=QS(e,i,t.properties[i]);if(o){const[a,c]=o;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&FS.has(t.tagName)?r=c:n[a]=c}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function XS(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else mo(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else mo(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Ku(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:BS;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const d=i.get(u)||0;a=u+"-"+d,i.set(u,d+1)}}const c=mg(e,o,a);c!==void 0&&n.push(c)}return n}function QS(e,t,n){const r=NS(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?pS(n):AS(n)),r.property==="style"){let i=typeof n=="object"?n:ZS(e,String(n));return e.stylePropertyNameCase==="css"&&(i=eC(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?vS[r.property]||r.property:r.attribute,n]}}function ZS(e,t){try{return DS(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new mn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=fg+"#cannot-parse-style-attribute",i}}function bg(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,a;for(;++o<i.length;){const c=Sh(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(o&&c.type==="Literal"),optional:!1}:c}r=a}else r=Sh(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return qu.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);mo(e)}function mo(e,t){const n=new mn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=fg+"#cannot-handle-mdx-estrees-without-createevaluater",n}function eC(e){const t={};let n;for(n in e)qu.call(e,n)&&(t[tC(n)]=e[n]);return t}function tC(e){let t=e.replace(_S,nC);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function nC(e){return"-"+e.toLowerCase()}const tc={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},rC={};function Vu(e,t){const n=rC,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return kg(e,r,i)}function kg(e,t,n){if(sC(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Mh(e.children,t,n)}return Array.isArray(e)?Mh(e,t,n):""}function Mh(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=kg(e[i],t,n);return r.join("")}function sC(e){return!!(e&&typeof e=="object")}const Lh=document.createElement("i");function Yu(e){const t="&"+e+";";Lh.innerHTML=t;const n=Lh.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $n(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function Vn(e,t){return e.length>0?($n(e,e.length,0,t),e):t}const Dh={}.hasOwnProperty;function yg(e){const t={};let n=-1;for(;++n<e.length;)iC(t,e[n]);return t}function iC(e,t){let n;for(n in t){const i=(Dh.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Dh.call(i,a)||(i[a]=[]);const c=o[a];oC(i[a],Array.isArray(c)?c:c?[c]:[])}}}function oC(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$n(e,0,0,r)}function wg(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function or(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const xn=ds(/[A-Za-z]/),fn=ds(/[\dA-Za-z]/),aC=ds(/[#-'*+\--9=?A-Z^-~]/);function Ua(e){return e!==null&&(e<32||e===127)}const Jc=ds(/\d/),lC=ds(/[\dA-Fa-f]/),cC=ds(/[!-/:-@[-`{-~]/);function Le(e){return e!==null&&e<-2}function jt(e){return e!==null&&(e<0||e===32)}function nt(e){return e===-2||e===-1||e===32}const pl=ds(new RegExp("\\p{P}|\\p{S}","u")),Ms=ds(/\s/);function ds(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ii(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&fn(e.charCodeAt(n+1))&&fn(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const c=e.charCodeAt(n+1);o<56320&&c>56319&&c<57344?(a=String.fromCharCode(o,c),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function at(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return nt(u)?(e.enter(n),c(u)):t(u)}function c(u){return nt(u)&&o++<i?(e.consume(u),c):(e.exit(n),t(u))}}const uC={tokenize:dC};function dC(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),at(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),o(c)}function o(c){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(c)}function a(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Le(c)?(e.consume(c),e.exit("chunkText"),o):(e.consume(c),a)}}const hC={tokenize:pC},Oh={tokenize:fC};function pC(e){const t=this,n=[];let r=0,i,o,a;return c;function c(T){if(r<n.length){const F=n[r];return t.containerState=F[1],e.attempt(F[0].continuation,u,d)(T)}return d(T)}function u(T){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&R();const F=t.events.length;let E=F,I;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){I=t.events[E][1].end;break}w(r);let q=F;for(;q<t.events.length;)t.events[q][1].end={...I},q++;return $n(t.events,E+1,0,t.events.slice(F)),t.events.length=q,d(T)}return c(T)}function d(T){if(r===n.length){if(!i)return g(T);if(i.currentConstruct&&i.currentConstruct.concrete)return k(T);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Oh,h,p)(T)}function h(T){return i&&R(),w(r),g(T)}function p(T){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,k(T)}function g(T){return t.containerState={},e.attempt(Oh,m,k)(T)}function m(T){return r++,n.push([t.currentConstruct,t.containerState]),g(T)}function k(T){if(T===null){i&&R(),w(0),e.consume(T);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),S(T)}function S(T){if(T===null){v(e.exit("chunkFlow"),!0),w(0),e.consume(T);return}return Le(T)?(e.consume(T),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(T),S)}function v(T,F){const E=t.sliceStream(T);if(F&&E.push(null),T.previous=o,o&&(o.next=T),o=T,i.defineSkip(T.start),i.write(E),t.parser.lazy[T.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<a&&(!i.events[I][1].end||i.events[I][1].end.offset>a))return;const q=t.events.length;let z=q,L,A;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(L){A=t.events[z][1].end;break}L=!0}for(w(r),I=q;I<t.events.length;)t.events[I][1].end={...A},I++;$n(t.events,z+1,0,t.events.slice(q)),t.events.length=I}}function w(T){let F=n.length;for(;F-- >T;){const E=n[F];t.containerState=E[1],E[0].exit.call(t,e)}n.length=T}function R(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fC(e,t,n){return at(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Si(e){if(e===null||jt(e)||Ms(e))return 1;if(pl(e))return 2}function fl(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Xc={name:"attention",resolveAll:mC,tokenize:gC};function mC(e,t){let n=-1,r,i,o,a,c,u,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},g={...e[n][1].start};Bh(p,-u),Bh(g,u),a={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},c={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...a.start},end:{...c.end}},e[r][1].end={...a.start},e[n][1].start={...c.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Vn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Vn(d,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=Vn(d,fl(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Vn(d,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=Vn(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,$n(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function gC(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Si(r);let o;return a;function a(u){return o=u,e.enter("attentionSequence"),c(u)}function c(u){if(u===o)return e.consume(u),c;const d=e.exit("attentionSequence"),h=Si(u),p=!h||h===2&&i||n.includes(u),g=!i||i===2&&h||n.includes(r);return d._open=!!(o===42?p:p&&(i||!g)),d._close=!!(o===42?g:g&&(h||!p)),t(u)}}function Bh(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const bC={name:"autolink",tokenize:kC};function kC(e,t,n){let r=0;return i;function i(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(m){return xn(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||fn(m)?(r=1,c(m)):d(m)}function c(m){return m===58?(e.consume(m),r=0,u):(m===43||m===45||m===46||fn(m))&&r++<32?(e.consume(m),c):(r=0,d(m))}function u(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||Ua(m)?n(m):(e.consume(m),u)}function d(m){return m===64?(e.consume(m),h):aC(m)?(e.consume(m),d):n(m)}function h(m){return fn(m)?p(m):n(m)}function p(m){return m===46?(e.consume(m),r=0,h):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):g(m)}function g(m){if((m===45||fn(m))&&r++<63){const k=m===45?g:p;return e.consume(m),k}return n(m)}}const Io={partial:!0,tokenize:yC};function yC(e,t,n){return r;function r(o){return nt(o)?at(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||Le(o)?t(o):n(o)}}const xg={continuation:{tokenize:xC},exit:vC,name:"blockQuote",tokenize:wC};function wC(e,t,n){const r=this;return i;function i(a){if(a===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return nt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function xC(e,t,n){const r=this;return i;function i(a){return nt(a)?at(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(xg,t,n)(a)}}function vC(e){e.exit("blockQuote")}const vg={name:"characterEscape",tokenize:SC};function SC(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return cC(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Sg={name:"characterReference",tokenize:CC};function CC(e,t,n){const r=this;let i=0,o,a;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,a=fn,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=lC,h):(e.enter("characterReferenceValue"),o=7,a=Jc,h(p))}function h(p){if(p===59&&i){const g=e.exit("characterReferenceValue");return a===fn&&!Yu(r.sliceSerialize(g))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&i++<o?(e.consume(p),h):n(p)}}const _h={partial:!0,tokenize:jC},Wh={concrete:!0,name:"codeFenced",tokenize:NC};function NC(e,t,n){const r=this,i={partial:!0,tokenize:E};let o=0,a=0,c;return u;function u(I){return d(I)}function d(I){const q=r.events[r.events.length-1];return o=q&&q[1].type==="linePrefix"?q[2].sliceSerialize(q[1],!0).length:0,c=I,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(I)}function h(I){return I===c?(a++,e.consume(I),h):a<3?n(I):(e.exit("codeFencedFenceSequence"),nt(I)?at(e,p,"whitespace")(I):p(I))}function p(I){return I===null||Le(I)?(e.exit("codeFencedFence"),r.interrupt?t(I):e.check(_h,S,F)(I)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(I))}function g(I){return I===null||Le(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(I)):nt(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),at(e,m,"whitespace")(I)):I===96&&I===c?n(I):(e.consume(I),g)}function m(I){return I===null||Le(I)?p(I):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(I))}function k(I){return I===null||Le(I)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(I)):I===96&&I===c?n(I):(e.consume(I),k)}function S(I){return e.attempt(i,F,v)(I)}function v(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),w}function w(I){return o>0&&nt(I)?at(e,R,"linePrefix",o+1)(I):R(I)}function R(I){return I===null||Le(I)?e.check(_h,S,F)(I):(e.enter("codeFlowValue"),T(I))}function T(I){return I===null||Le(I)?(e.exit("codeFlowValue"),R(I)):(e.consume(I),T)}function F(I){return e.exit("codeFenced"),t(I)}function E(I,q,z){let L=0;return A;function A(X){return I.enter("lineEnding"),I.consume(X),I.exit("lineEnding"),U}function U(X){return I.enter("codeFencedFence"),nt(X)?at(I,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(X):B(X)}function B(X){return X===c?(I.enter("codeFencedFenceSequence"),le(X)):z(X)}function le(X){return X===c?(L++,I.consume(X),le):L>=a?(I.exit("codeFencedFenceSequence"),nt(X)?at(I,V,"whitespace")(X):V(X)):z(X)}function V(X){return X===null||Le(X)?(I.exit("codeFencedFence"),q(X)):z(X)}}}function jC(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const nc={name:"codeIndented",tokenize:IC},TC={partial:!0,tokenize:AC};function IC(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),at(e,o,"linePrefix",5)(d)}function o(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?u(d):Le(d)?e.attempt(TC,a,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Le(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function AC(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):Le(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):at(e,o,"linePrefix",5)(a)}function o(a){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):Le(a)?i(a):n(a)}}const RC={name:"codeText",previous:PC,resolve:EC,tokenize:MC};function EC(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function PC(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function MC(e,t,n){let r=0,i,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),r++,c):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(o=e.enter("codeTextSequence"),i=0,h(p)):Le(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||Le(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),d)}function h(p){return p===96?(e.consume(p),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",d(p))}}class LC{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Vi(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Vi(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Vi(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Vi(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Vi(this.left,n.reverse())}}}function Vi(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Cg(e){const t={};let n=-1,r,i,o,a,c,u,d;const h=new LC(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,DC(h,n)),n=t[n],d=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=h.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},c=h.slice(i,n),c.unshift(r),h.splice(i,n-i+1,c))}}return $n(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function DC(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const c=a.events,u=[],d={};let h,p,g=-1,m=n,k=0,S=0;const v=[S];for(;m;){for(;e.get(++i)[1]!==m;);o.push(i),m._tokenizer||(h=r.sliceStream(m),m.next||h.push(null),p&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=m,m=m.next}for(m=n;++g<c.length;)c[g][0]==="exit"&&c[g-1][0]==="enter"&&c[g][1].type===c[g-1][1].type&&c[g][1].start.line!==c[g][1].end.line&&(S=g+1,v.push(S),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):v.pop(),g=v.length;g--;){const w=c.slice(v[g],v[g+1]),R=o.pop();u.push([R,R+w.length-1]),e.splice(R,2,w)}for(u.reverse(),g=-1;++g<u.length;)d[k+u[g][0]]=k+u[g][1],k+=u[g][1]-u[g][0]-1;return d}const OC={resolve:_C,tokenize:WC},BC={partial:!0,tokenize:FC};function _C(e){return Cg(e),e}function WC(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(c)}function i(c){return c===null?o(c):Le(c)?e.check(BC,a,o)(c):(e.consume(c),i)}function o(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function a(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function FC(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),at(e,o,"linePrefix")}function o(a){if(a===null||Le(a))return n(a);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Ng(e,t,n,r,i,o,a,c,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(w){return w===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(w),e.exit(o),g):w===null||w===32||w===41||Ua(w)?n(w):(e.enter(r),e.enter(a),e.enter(c),e.enter("chunkString",{contentType:"string"}),S(w))}function g(w){return w===62?(e.enter(o),e.consume(w),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===62?(e.exit("chunkString"),e.exit(c),g(w)):w===null||w===60||Le(w)?n(w):(e.consume(w),w===92?k:m)}function k(w){return w===60||w===62||w===92?(e.consume(w),m):m(w)}function S(w){return!h&&(w===null||w===41||jt(w))?(e.exit("chunkString"),e.exit(c),e.exit(a),e.exit(r),t(w)):h<d&&w===40?(e.consume(w),h++,S):w===41?(e.consume(w),h--,S):w===null||w===32||w===40||Ua(w)?n(w):(e.consume(w),w===92?v:S)}function v(w){return w===40||w===41||w===92?(e.consume(w),S):S(w)}}function jg(e,t,n,r,i,o){const a=this;let c=0,u;return d;function d(m){return e.enter(r),e.enter(i),e.consume(m),e.exit(i),e.enter(o),h}function h(m){return c>999||m===null||m===91||m===93&&!u||m===94&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(o),e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):Le(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(m))}function p(m){return m===null||m===91||m===93||Le(m)||c++>999?(e.exit("chunkString"),h(m)):(e.consume(m),u||(u=!nt(m)),m===92?g:p)}function g(m){return m===91||m===92||m===93?(e.consume(m),c++,p):p(m)}}function Tg(e,t,n,r,i,o){let a;return c;function c(g){return g===34||g===39||g===40?(e.enter(r),e.enter(i),e.consume(g),e.exit(i),a=g===40?41:g,u):n(g)}function u(g){return g===a?(e.enter(i),e.consume(g),e.exit(i),e.exit(r),t):(e.enter(o),d(g))}function d(g){return g===a?(e.exit(o),u(a)):g===null?n(g):Le(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),at(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===a||g===null||Le(g)?(e.exit("chunkString"),d(g)):(e.consume(g),g===92?p:h)}function p(g){return g===a||g===92?(e.consume(g),h):h(g)}}function ao(e,t){let n;return r;function r(i){return Le(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):nt(i)?at(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const $C={name:"definition",tokenize:UC},zC={partial:!0,tokenize:HC};function UC(e,t,n){const r=this;let i;return o;function o(m){return e.enter("definition"),a(m)}function a(m){return jg.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function c(m){return i=or(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),u):n(m)}function u(m){return jt(m)?ao(e,d)(m):d(m)}function d(m){return Ng(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function h(m){return e.attempt(zC,p,p)(m)}function p(m){return nt(m)?at(e,g,"whitespace")(m):g(m)}function g(m){return m===null||Le(m)?(e.exit("definition"),r.parser.defined.push(i),t(m)):n(m)}}function HC(e,t,n){return r;function r(c){return jt(c)?ao(e,i)(c):n(c)}function i(c){return Tg(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return nt(c)?at(e,a,"whitespace")(c):a(c)}function a(c){return c===null||Le(c)?t(c):n(c)}}const qC={name:"hardBreakEscape",tokenize:GC};function GC(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return Le(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const KC={name:"headingAtx",resolve:VC,tokenize:YC};function VC(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$n(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function YC(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),o(h)}function o(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||jt(h)?(e.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Le(h)?(e.exit("atxHeading"),t(h)):nt(h)?at(e,c,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function u(h){return h===35?(e.consume(h),u):(e.exit("atxHeadingSequence"),c(h))}function d(h){return h===null||h===35||jt(h)?(e.exit("atxHeadingText"),c(h)):(e.consume(h),d)}}const JC=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Fh=["pre","script","style","textarea"],XC={concrete:!0,name:"htmlFlow",resolveTo:e0,tokenize:t0},QC={partial:!0,tokenize:r0},ZC={partial:!0,tokenize:n0};function e0(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function t0(e,t,n){const r=this;let i,o,a,c,u;return d;function d(j){return h(j)}function h(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),p}function p(j){return j===33?(e.consume(j),g):j===47?(e.consume(j),o=!0,S):j===63?(e.consume(j),i=3,r.interrupt?t:N):xn(j)?(e.consume(j),a=String.fromCharCode(j),v):n(j)}function g(j){return j===45?(e.consume(j),i=2,m):j===91?(e.consume(j),i=5,c=0,k):xn(j)?(e.consume(j),i=4,r.interrupt?t:N):n(j)}function m(j){return j===45?(e.consume(j),r.interrupt?t:N):n(j)}function k(j){const be="CDATA[";return j===be.charCodeAt(c++)?(e.consume(j),c===be.length?r.interrupt?t:B:k):n(j)}function S(j){return xn(j)?(e.consume(j),a=String.fromCharCode(j),v):n(j)}function v(j){if(j===null||j===47||j===62||jt(j)){const be=j===47,re=a.toLowerCase();return!be&&!o&&Fh.includes(re)?(i=1,r.interrupt?t(j):B(j)):JC.includes(a.toLowerCase())?(i=6,be?(e.consume(j),w):r.interrupt?t(j):B(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):o?R(j):T(j))}return j===45||fn(j)?(e.consume(j),a+=String.fromCharCode(j),v):n(j)}function w(j){return j===62?(e.consume(j),r.interrupt?t:B):n(j)}function R(j){return nt(j)?(e.consume(j),R):A(j)}function T(j){return j===47?(e.consume(j),A):j===58||j===95||xn(j)?(e.consume(j),F):nt(j)?(e.consume(j),T):A(j)}function F(j){return j===45||j===46||j===58||j===95||fn(j)?(e.consume(j),F):E(j)}function E(j){return j===61?(e.consume(j),I):nt(j)?(e.consume(j),E):T(j)}function I(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),u=j,q):nt(j)?(e.consume(j),I):z(j)}function q(j){return j===u?(e.consume(j),u=null,L):j===null||Le(j)?n(j):(e.consume(j),q)}function z(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||jt(j)?E(j):(e.consume(j),z)}function L(j){return j===47||j===62||nt(j)?T(j):n(j)}function A(j){return j===62?(e.consume(j),U):n(j)}function U(j){return j===null||Le(j)?B(j):nt(j)?(e.consume(j),U):n(j)}function B(j){return j===45&&i===2?(e.consume(j),J):j===60&&i===1?(e.consume(j),O):j===62&&i===4?(e.consume(j),De):j===63&&i===3?(e.consume(j),N):j===93&&i===5?(e.consume(j),ce):Le(j)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(QC,ee,le)(j)):j===null||Le(j)?(e.exit("htmlFlowData"),le(j)):(e.consume(j),B)}function le(j){return e.check(ZC,V,ee)(j)}function V(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),X}function X(j){return j===null||Le(j)?le(j):(e.enter("htmlFlowData"),B(j))}function J(j){return j===45?(e.consume(j),N):B(j)}function O(j){return j===47?(e.consume(j),a="",K):B(j)}function K(j){if(j===62){const be=a.toLowerCase();return Fh.includes(be)?(e.consume(j),De):B(j)}return xn(j)&&a.length<8?(e.consume(j),a+=String.fromCharCode(j),K):B(j)}function ce(j){return j===93?(e.consume(j),N):B(j)}function N(j){return j===62?(e.consume(j),De):j===45&&i===2?(e.consume(j),N):B(j)}function De(j){return j===null||Le(j)?(e.exit("htmlFlowData"),ee(j)):(e.consume(j),De)}function ee(j){return e.exit("htmlFlow"),t(j)}}function n0(e,t,n){const r=this;return i;function i(a){return Le(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function r0(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Io,t,n)}}const s0={name:"htmlText",tokenize:i0};function i0(e,t,n){const r=this;let i,o,a;return c;function c(N){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(N),u}function u(N){return N===33?(e.consume(N),d):N===47?(e.consume(N),E):N===63?(e.consume(N),T):xn(N)?(e.consume(N),z):n(N)}function d(N){return N===45?(e.consume(N),h):N===91?(e.consume(N),o=0,k):xn(N)?(e.consume(N),R):n(N)}function h(N){return N===45?(e.consume(N),m):n(N)}function p(N){return N===null?n(N):N===45?(e.consume(N),g):Le(N)?(a=p,O(N)):(e.consume(N),p)}function g(N){return N===45?(e.consume(N),m):p(N)}function m(N){return N===62?J(N):N===45?g(N):p(N)}function k(N){const De="CDATA[";return N===De.charCodeAt(o++)?(e.consume(N),o===De.length?S:k):n(N)}function S(N){return N===null?n(N):N===93?(e.consume(N),v):Le(N)?(a=S,O(N)):(e.consume(N),S)}function v(N){return N===93?(e.consume(N),w):S(N)}function w(N){return N===62?J(N):N===93?(e.consume(N),w):S(N)}function R(N){return N===null||N===62?J(N):Le(N)?(a=R,O(N)):(e.consume(N),R)}function T(N){return N===null?n(N):N===63?(e.consume(N),F):Le(N)?(a=T,O(N)):(e.consume(N),T)}function F(N){return N===62?J(N):T(N)}function E(N){return xn(N)?(e.consume(N),I):n(N)}function I(N){return N===45||fn(N)?(e.consume(N),I):q(N)}function q(N){return Le(N)?(a=q,O(N)):nt(N)?(e.consume(N),q):J(N)}function z(N){return N===45||fn(N)?(e.consume(N),z):N===47||N===62||jt(N)?L(N):n(N)}function L(N){return N===47?(e.consume(N),J):N===58||N===95||xn(N)?(e.consume(N),A):Le(N)?(a=L,O(N)):nt(N)?(e.consume(N),L):J(N)}function A(N){return N===45||N===46||N===58||N===95||fn(N)?(e.consume(N),A):U(N)}function U(N){return N===61?(e.consume(N),B):Le(N)?(a=U,O(N)):nt(N)?(e.consume(N),U):L(N)}function B(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),i=N,le):Le(N)?(a=B,O(N)):nt(N)?(e.consume(N),B):(e.consume(N),V)}function le(N){return N===i?(e.consume(N),i=void 0,X):N===null?n(N):Le(N)?(a=le,O(N)):(e.consume(N),le)}function V(N){return N===null||N===34||N===39||N===60||N===61||N===96?n(N):N===47||N===62||jt(N)?L(N):(e.consume(N),V)}function X(N){return N===47||N===62||jt(N)?L(N):n(N)}function J(N){return N===62?(e.consume(N),e.exit("htmlTextData"),e.exit("htmlText"),t):n(N)}function O(N){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),K}function K(N){return nt(N)?at(e,ce,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):ce(N)}function ce(N){return e.enter("htmlTextData"),a(N)}}const Ju={name:"labelEnd",resolveAll:c0,resolveTo:u0,tokenize:d0},o0={tokenize:h0},a0={tokenize:p0},l0={tokenize:f0};function c0(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&$n(e,0,e.length,n),e}function u0(e,t){let n=e.length,r=0,i,o,a,c;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return c=[["enter",u,t],["enter",d,t]],c=Vn(c,e.slice(o+1,o+r+3)),c=Vn(c,[["enter",h,t]]),c=Vn(c,fl(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),c=Vn(c,[["exit",h,t],e[a-2],e[a-1],["exit",d,t]]),c=Vn(c,e.slice(a+1)),c=Vn(c,[["exit",u,t]]),$n(e,o,e.length,c),e}function d0(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return c;function c(g){return o?o._inactive?p(g):(a=r.parser.defined.includes(or(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(o0,h,a?h:p)(g):g===91?e.attempt(a0,h,a?d:p)(g):a?h(g):p(g)}function d(g){return e.attempt(l0,h,p)(g)}function h(g){return t(g)}function p(g){return o._balanced=!0,n(g)}}function h0(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return jt(p)?ao(e,o)(p):o(p)}function o(p){return p===41?h(p):Ng(e,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return jt(p)?ao(e,u)(p):h(p)}function c(p){return n(p)}function u(p){return p===34||p===39||p===40?Tg(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return jt(p)?ao(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function p0(e,t,n){const r=this;return i;function i(c){return jg.call(r,e,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return r.parser.defined.includes(or(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function a(c){return n(c)}}function f0(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const m0={name:"labelStartImage",resolveAll:Ju.resolveAll,tokenize:g0};function g0(e,t,n){const r=this;return i;function i(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),o}function o(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),a):n(c)}function a(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const b0={name:"labelStartLink",resolveAll:Ju.resolveAll,tokenize:k0};function k0(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const rc={name:"lineEnding",tokenize:y0};function y0(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),at(e,t,"linePrefix")}}const Ea={name:"thematicBreak",tokenize:w0};function w0(e,t,n){let r=0,i;return o;function o(d){return e.enter("thematicBreak"),a(d)}function a(d){return i=d,c(d)}function c(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Le(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),nt(d)?at(e,c,"whitespace")(d):c(d))}}const An={continuation:{tokenize:C0},exit:j0,name:"list",tokenize:S0},x0={partial:!0,tokenize:T0},v0={partial:!0,tokenize:N0};function S0(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return c;function c(m){const k=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:Jc(m)){if(r.containerState.type||(r.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(Ea,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(m)}return n(m)}function u(m){return Jc(m)&&++a<10?(e.consume(m),u):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(Io,r.interrupt?n:h,e.attempt(x0,g,p))}function h(m){return r.containerState.initialBlankLine=!0,o++,g(m)}function p(m){return nt(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),g):n(m)}function g(m){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function C0(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Io,i,o);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,at(e,t,"listItemIndent",r.containerState.size+1)(c)}function o(c){return r.containerState.furtherBlankLines||!nt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(v0,t,a)(c))}function a(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,at(e,e.attempt(An,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function N0(e,t,n){const r=this;return at(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function j0(e){e.exit(this.containerState.type)}function T0(e,t,n){const r=this;return at(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!nt(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const $h={name:"setextUnderline",resolveTo:I0,tokenize:A0};function I0(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function A0(e,t,n){const r=this;let i;return o;function o(d){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===i?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),nt(d)?at(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Le(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const R0={tokenize:E0};function E0(e){const t=this,n=e.attempt(Io,r,e.attempt(this.parser.constructs.flowInitial,i,at(e,e.attempt(this.parser.constructs.flow,i,e.attempt(OC,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const P0={resolveAll:Ag()},M0=Ig("string"),L0=Ig("text");function Ig(e){return{resolveAll:Ag(e==="text"?D0:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,c);return a;function a(h){return d(h)?o(h):c(h)}function c(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),u}function u(h){return d(h)?(n.exit("data"),o(h)):(n.consume(h),u)}function d(h){if(h===null)return!0;const p=i[h];let g=-1;if(p)for(;++g<p.length;){const m=p[g];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function Ag(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function D0(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let o=i.length,a=-1,c=0,u;for(;o--;){const d=i[o];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)c++,a--;if(a)break;a=-1}else if(d===-2)u=!0,c++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const d={type:n===e.length||u||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const O0={42:An,43:An,45:An,48:An,49:An,50:An,51:An,52:An,53:An,54:An,55:An,56:An,57:An,62:xg},B0={91:$C},_0={[-2]:nc,[-1]:nc,32:nc},W0={35:KC,42:Ea,45:[$h,Ea],60:XC,61:$h,95:Ea,96:Wh,126:Wh},F0={38:Sg,92:vg},$0={[-5]:rc,[-4]:rc,[-3]:rc,33:m0,38:Sg,42:Xc,60:[bC,s0],91:b0,92:[qC,vg],93:Ju,95:Xc,96:RC},z0={null:[Xc,P0]},U0={null:[42,95]},H0={null:[]},q0=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:U0,contentInitial:B0,disable:H0,document:O0,flow:W0,flowInitial:_0,insideSpan:z0,string:F0,text:$0},Symbol.toStringTag,{value:"Module"}));function G0(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let a=[],c=[];const u={attempt:q(E),check:q(I),consume:R,enter:T,exit:F,interrupt:q(I,{interrupt:!0})},d={code:null,containerState:{},defineSkip:S,events:[],now:k,parser:e,previous:null,sliceSerialize:g,sliceStream:m,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&o.push(t),d;function p(U){return a=Vn(a,U),v(),a[a.length-1]!==null?[]:(z(t,0),d.events=fl(o,d.events,d),d.events)}function g(U,B){return V0(m(U),B)}function m(U){return K0(a,U)}function k(){const{_bufferIndex:U,_index:B,line:le,column:V,offset:X}=r;return{_bufferIndex:U,_index:B,line:le,column:V,offset:X}}function S(U){i[U.line]=U.column,A()}function v(){let U;for(;r._index<a.length;){const B=a[r._index];if(typeof B=="string")for(U=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===U&&r._bufferIndex<B.length;)w(B.charCodeAt(r._bufferIndex));else w(B)}}function w(U){h=h(U)}function R(U){Le(U)?(r.line++,r.column=1,r.offset+=U===-3?2:1,A()):U!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=U}function T(U,B){const le=B||{};return le.type=U,le.start=k(),d.events.push(["enter",le,d]),c.push(le),le}function F(U){const B=c.pop();return B.end=k(),d.events.push(["exit",B,d]),B}function E(U,B){z(U,B.from)}function I(U,B){B.restore()}function q(U,B){return le;function le(V,X,J){let O,K,ce,N;return Array.isArray(V)?ee(V):"tokenize"in V?ee([V]):De(V);function De(fe){return de;function de(Ue){const He=Ue!==null&&fe[Ue],je=Ue!==null&&fe.null,Te=[...Array.isArray(He)?He:He?[He]:[],...Array.isArray(je)?je:je?[je]:[]];return ee(Te)(Ue)}}function ee(fe){return O=fe,K=0,fe.length===0?J:j(fe[K])}function j(fe){return de;function de(Ue){return N=L(),ce=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?re():fe.tokenize.call(B?Object.assign(Object.create(d),B):d,u,be,re)(Ue)}}function be(fe){return U(ce,N),X}function re(fe){return N.restore(),++K<O.length?j(O[K]):J}}}function z(U,B){U.resolveAll&&!o.includes(U)&&o.push(U),U.resolve&&$n(d.events,B,d.events.length-B,U.resolve(d.events.slice(B),d)),U.resolveTo&&(d.events=U.resolveTo(d.events,d))}function L(){const U=k(),B=d.previous,le=d.currentConstruct,V=d.events.length,X=Array.from(c);return{from:V,restore:J};function J(){r=U,d.previous=B,d.currentConstruct=le,d.events.length=V,c=X,A()}}function A(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function K0(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const c=a[0];typeof c=="string"?a[0]=c.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function V0(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
6
|
-
`;break}case-3:{a=`\r
|
|
7
|
-
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function Y0(e){const r={constructs:yg([q0,...(e||{}).extensions||[]]),content:i(uC),defined:[],document:i(hC),flow:i(R0),lazy:{},string:i(M0),text:i(L0)};return r;function i(o){return a;function a(c){return G0(r,o,c)}}}function J0(e){for(;!Cg(e););return e}const zh=/[\0\t\n\r]/g;function X0(){let e=1,t="",n=!0,r;return i;function i(o,a,c){const u=[];let d,h,p,g,m;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(zh.lastIndex=p,d=zh.exec(o),g=d&&d.index!==void 0?d.index:o.length,m=o.charCodeAt(g),!d){t=o.slice(p);break}if(m===10&&p===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<g&&(u.push(o.slice(p,g)),e+=g-p),m){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}p=g+1}return c&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const Q0=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Z0(e){return e.replace(Q0,eN)}function eN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return wg(n.slice(o?2:1),o?16:10)}return Yu(n)||e}const Rg={}.hasOwnProperty;function tN(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),nN(n)(J0(Y0(n).document().write(X0()(e,t,!0))))}function nN(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(rt),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(Ce),blockQuote:o(je),characterEscape:L,characterReference:L,codeFenced:o(Te),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Te,a),codeText:o(_,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(G),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Q),hardBreakEscape:o(Ae),hardBreakTrailing:o(Ae),htmlFlow:o(ve,a),htmlFlowData:L,htmlText:o(ve,a),htmlTextData:L,image:o(Tt),label:a,link:o(rt),listItem:o(ae),listItemValue:g,listOrdered:o(gt,p),listUnordered:o(gt),paragraph:o(ie),reference:j,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ce),strong:o(ke),thematicBreak:o(Re)},exit:{atxHeading:u(),atxHeadingSequence:E,autolink:u(),autolinkEmail:He,autolinkProtocol:Ue,blockQuote:u(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:fe,characterReference:de,codeFenced:u(v),codeFencedFence:S,codeFencedFenceInfo:m,codeFencedFenceMeta:k,codeFlowValue:A,codeIndented:u(w),codeText:u(X),codeTextData:A,data:A,definition:u(),definitionDestinationString:F,definitionLabelString:R,definitionTitleString:T,emphasis:u(),hardBreakEscape:u(B),hardBreakTrailing:u(B),htmlFlow:u(le),htmlFlowData:A,htmlText:u(V),htmlTextData:A,image:u(O),label:ce,labelText:K,lineEnding:U,link:u(J),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:be,resourceDestinationString:N,resourceTitleString:De,resource:ee,setextHeading:u(z),setextHeadingLineSequence:q,setextHeadingText:I,strong:u(),thematicBreak:u()}};Eg(t,(e||{}).mdastExtensions||[]);const n={};return r;function r($){let Z={type:"root",children:[]};const ge={stack:[Z],tokenStack:[],config:t,enter:c,exit:d,buffer:a,resume:h,data:n},Ne=[];let Be=-1;for(;++Be<$.length;)if($[Be][1].type==="listOrdered"||$[Be][1].type==="listUnordered")if($[Be][0]==="enter")Ne.push(Be);else{const Ve=Ne.pop();Be=i($,Ve,Be)}for(Be=-1;++Be<$.length;){const Ve=t[$[Be][0]];Rg.call(Ve,$[Be][1].type)&&Ve[$[Be][1].type].call(Object.assign({sliceSerialize:$[Be][2].sliceSerialize},ge),$[Be][1])}if(ge.tokenStack.length>0){const Ve=ge.tokenStack[ge.tokenStack.length-1];(Ve[1]||Uh).call(ge,void 0,Ve[0])}for(Z.position={start:es($.length>0?$[0][1].start:{line:1,column:1,offset:0}),end:es($.length>0?$[$.length-2][1].end:{line:1,column:1,offset:0})},Be=-1;++Be<t.transforms.length;)Z=t.transforms[Be](Z)||Z;return Z}function i($,Z,ge){let Ne=Z-1,Be=-1,Ve=!1,Ie,dt,Ze,st;for(;++Ne<=ge;){const it=$[Ne];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?Be++:Be--,st=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(Ie&&!st&&!Be&&!Ze&&(Ze=Ne),st=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:st=void 0}if(!Be&&it[0]==="enter"&&it[1].type==="listItemPrefix"||Be===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(Ie){let qe=Ne;for(dt=void 0;qe--;){const bt=$[qe];if(bt[1].type==="lineEnding"||bt[1].type==="lineEndingBlank"){if(bt[0]==="exit")continue;dt&&($[dt][1].type="lineEndingBlank",Ve=!0),bt[1].type="lineEnding",dt=qe}else if(!(bt[1].type==="linePrefix"||bt[1].type==="blockQuotePrefix"||bt[1].type==="blockQuotePrefixWhitespace"||bt[1].type==="blockQuoteMarker"||bt[1].type==="listItemIndent"))break}Ze&&(!dt||Ze<dt)&&(Ie._spread=!0),Ie.end=Object.assign({},dt?$[dt][1].start:it[1].end),$.splice(dt||Ne,0,["exit",Ie,it[2]]),Ne++,ge++}if(it[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};Ie=qe,$.splice(Ne,0,["enter",qe,it[2]]),Ne++,ge++,Ze=void 0,st=!0}}}return $[Z][1]._spread=Ve,ge}function o($,Z){return ge;function ge(Ne){c.call(this,$(Ne),Ne),Z&&Z.call(this,Ne)}}function a(){this.stack.push({type:"fragment",children:[]})}function c($,Z,ge){this.stack[this.stack.length-1].children.push($),this.stack.push($),this.tokenStack.push([Z,ge||void 0]),$.position={start:es(Z.start),end:void 0}}function u($){return Z;function Z(ge){$&&$.call(this,ge),d.call(this,ge)}}function d($,Z){const ge=this.stack.pop(),Ne=this.tokenStack.pop();if(Ne)Ne[0].type!==$.type&&(Z?Z.call(this,$,Ne[0]):(Ne[1]||Uh).call(this,$,Ne[0]));else throw new Error("Cannot close `"+$.type+"` ("+oo({start:$.start,end:$.end})+"): it’s not open");ge.position.end=es($.end)}function h(){return Vu(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g($){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize($),10),this.data.expectingFirstListItemValue=void 0}}function m(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=$}function k(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=$}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.value=$.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function w(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.value=$.replace(/(\r?\n|\r)$/g,"")}function R($){const Z=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Z,ge.identifier=or(this.sliceSerialize($)).toLowerCase()}function T(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.title=$}function F(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.url=$}function E($){const Z=this.stack[this.stack.length-1];if(!Z.depth){const ge=this.sliceSerialize($).length;Z.depth=ge}}function I(){this.data.setextHeadingSlurpLineEnding=!0}function q($){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize($).codePointAt(0)===61?1:2}function z(){this.data.setextHeadingSlurpLineEnding=void 0}function L($){const ge=this.stack[this.stack.length-1].children;let Ne=ge[ge.length-1];(!Ne||Ne.type!=="text")&&(Ne=ye(),Ne.position={start:es($.start),end:void 0},ge.push(Ne)),this.stack.push(Ne)}function A($){const Z=this.stack.pop();Z.value+=this.sliceSerialize($),Z.position.end=es($.end)}function U($){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=Z.children[Z.children.length-1];ge.position.end=es($.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(L.call(this,$),A.call(this,$))}function B(){this.data.atHardBreak=!0}function le(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.value=$}function V(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.value=$}function X(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.value=$}function J(){const $=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";$.type+="Reference",$.referenceType=Z,delete $.url,delete $.title}else delete $.identifier,delete $.label;this.data.referenceType=void 0}function O(){const $=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";$.type+="Reference",$.referenceType=Z,delete $.url,delete $.title}else delete $.identifier,delete $.label;this.data.referenceType=void 0}function K($){const Z=this.sliceSerialize($),ge=this.stack[this.stack.length-2];ge.label=Z0(Z),ge.identifier=or(Z).toLowerCase()}function ce(){const $=this.stack[this.stack.length-1],Z=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const Ne=$.children;ge.children=Ne}else ge.alt=Z}function N(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.url=$}function De(){const $=this.resume(),Z=this.stack[this.stack.length-1];Z.title=$}function ee(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function be($){const Z=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Z,ge.identifier=or(this.sliceSerialize($)).toLowerCase(),this.data.referenceType="full"}function re($){this.data.characterReferenceType=$.type}function fe($){const Z=this.sliceSerialize($),ge=this.data.characterReferenceType;let Ne;ge?(Ne=wg(Z,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ne=Yu(Z);const Be=this.stack[this.stack.length-1];Be.value+=Ne}function de($){const Z=this.stack.pop();Z.position.end=es($.end)}function Ue($){A.call(this,$);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize($)}function He($){A.call(this,$);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize($)}function je(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function _(){return{type:"inlineCode",value:""}}function G(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Q(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function Ae(){return{type:"break"}}function ve(){return{type:"html",value:""}}function Tt(){return{type:"image",title:null,url:"",alt:null}}function rt(){return{type:"link",title:null,url:"",children:[]}}function gt($){return{type:"list",ordered:$.type==="listOrdered",start:null,spread:$._spread,children:[]}}function ae($){return{type:"listItem",spread:$._spread,checked:null,children:[]}}function ie(){return{type:"paragraph",children:[]}}function ke(){return{type:"strong",children:[]}}function ye(){return{type:"text",value:""}}function Re(){return{type:"thematicBreak"}}}function es(e){return{line:e.line,column:e.column,offset:e.offset}}function Eg(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Eg(e,r):rN(e,r)}}function rN(e,t){let n;for(n in t)if(Rg.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Uh(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+oo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+oo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+oo({start:t.start,end:t.end})+") is still open")}function sN(e){const t=this;t.parser=n;function n(r){return tN(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function iN(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function oN(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
8
|
-
`}]}function aN(e,t){const n=t.value?t.value+`
|
|
9
|
-
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function lN(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cN(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uN(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Ii(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,c+=1,e.footnoteCounts.set(r,c);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function dN(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hN(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Pg(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function pN(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pg(e,t);const i={src:Ii(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function fN(e,t){const n={src:Ii(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function mN(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function gN(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pg(e,t);const i={href:Ii(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function bN(e,t){const n={href:Ii(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function kN(e,t,n){const r=e.all(t),i=n?yN(n):Mg(t),o={},a=[];if(typeof t.checked=="boolean"){const h=r[0];let p;h&&h.type==="element"&&h.tagName==="p"?p=h:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const h=r[c];(i||c!==0||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
|
|
10
|
-
`}),h.type==="element"&&h.tagName==="p"&&!i?a.push(...h.children):a.push(h)}const u=r[r.length-1];u&&(i||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
|
|
11
|
-
`});const d={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,d),e.applyData(t,d)}function yN(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Mg(n[r])}return t}function Mg(e){const t=e.spread;return t??e.children.length>1}function wN(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function xN(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vN(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function SN(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function CN(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=Hu(t.children[1]),u=hg(t.children[t.children.length-1]);c&&u&&(a.position={start:c,end:u}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function NN(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,c=a?a.length:t.children.length;let u=-1;const d=[];for(;++u<c;){const p=t.children[u],g={},m=a?a[u]:void 0;m&&(g.align=m);let k={type:"element",tagName:o,properties:g,children:[]};p&&(k.children=e.all(p),e.patch(p,k),k=e.applyData(p,k)),d.push(k)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,h),e.applyData(t,h)}function jN(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Hh=9,qh=32;function TN(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(Gh(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(Gh(t.slice(i),i>0,!1)),o.join("")}function Gh(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===Hh||o===qh;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===Hh||o===qh;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function IN(e,t){const n={type:"text",value:TN(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function AN(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const RN={blockquote:iN,break:oN,code:aN,delete:lN,emphasis:cN,footnoteReference:uN,heading:dN,html:hN,imageReference:pN,image:fN,inlineCode:mN,linkReference:gN,link:bN,listItem:kN,list:wN,paragraph:xN,root:vN,strong:SN,table:CN,tableCell:jN,tableRow:NN,text:IN,thematicBreak:AN,toml:na,yaml:na,definition:na,footnoteDefinition:na};function na(){}const Lg=-1,ml=0,lo=1,Ha=2,Xu=3,Qu=4,Zu=5,ed=6,Dg=7,Og=8,Kh=typeof self=="object"?self:globalThis,EN=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case ml:case Lg:return n(a,i);case lo:{const c=n([],i);for(const u of a)c.push(r(u));return c}case Ha:{const c=n({},i);for(const[u,d]of a)c[r(u)]=r(d);return c}case Xu:return n(new Date(a),i);case Qu:{const{source:c,flags:u}=a;return n(new RegExp(c,u),i)}case Zu:{const c=n(new Map,i);for(const[u,d]of a)c.set(r(u),r(d));return c}case ed:{const c=n(new Set,i);for(const u of a)c.add(r(u));return c}case Dg:{const{name:c,message:u}=a;return n(new Kh[c](u),i)}case Og:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:c}=new Uint8Array(a);return n(new DataView(c),a)}}return n(new Kh[o](a),i)};return r},Vh=e=>EN(new Map,e)(0),ni="",{toString:PN}={},{keys:MN}=Object,Yi=e=>{const t=typeof e;if(t!=="object"||!e)return[ml,t];const n=PN.call(e).slice(8,-1);switch(n){case"Array":return[lo,ni];case"Object":return[Ha,ni];case"Date":return[Xu,ni];case"RegExp":return[Qu,ni];case"Map":return[Zu,ni];case"Set":return[ed,ni];case"DataView":return[lo,n]}return n.includes("Array")?[lo,n]:n.includes("Error")?[Dg,n]:[Ha,n]},ra=([e,t])=>e===ml&&(t==="function"||t==="symbol"),LN=(e,t,n,r)=>{const i=(a,c)=>{const u=r.push(a)-1;return n.set(c,u),u},o=a=>{if(n.has(a))return n.get(a);let[c,u]=Yi(a);switch(c){case ml:{let h=a;switch(u){case"bigint":c=Og,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);h=null;break;case"undefined":return i([Lg],a)}return i([c,h],a)}case lo:{if(u){let g=a;return u==="DataView"?g=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(a)),i([u,[...g]],a)}const h=[],p=i([c,h],a);for(const g of a)h.push(o(g));return p}case Ha:{if(u)switch(u){case"BigInt":return i([u,a.toString()],a);case"Boolean":case"Number":case"String":return i([u,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const h=[],p=i([c,h],a);for(const g of MN(a))(e||!ra(Yi(a[g])))&&h.push([o(g),o(a[g])]);return p}case Xu:return i([c,a.toISOString()],a);case Qu:{const{source:h,flags:p}=a;return i([c,{source:h,flags:p}],a)}case Zu:{const h=[],p=i([c,h],a);for(const[g,m]of a)(e||!(ra(Yi(g))||ra(Yi(m))))&&h.push([o(g),o(m)]);return p}case ed:{const h=[],p=i([c,h],a);for(const g of a)(e||!ra(Yi(g)))&&h.push(o(g));return p}}const{message:d}=a;return i([c,{name:u,message:d}],a)};return o},Yh=(e,{json:t,lossy:n}={})=>{const r=[];return LN(!(t||n),!!t,new Map,r)(e),r},qa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Vh(Yh(e,t)):structuredClone(e):(e,t)=>Vh(Yh(e,t));function DN(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function ON(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function BN(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||DN,r=e.options.footnoteBackLabel||ON,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const h=e.all(d),p=String(d.identifier).toUpperCase(),g=Ii(p.toLowerCase());let m=0;const k=[],S=e.footnoteCounts.get(p);for(;S!==void 0&&++m<=S;){k.length>0&&k.push({type:"text",value:" "});let R=typeof n=="string"?n:n(u,m);typeof R=="string"&&(R={type:"text",value:R}),k.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,m),className:["data-footnote-backref"]},children:Array.isArray(R)?R:[R]})}const v=h[h.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const R=v.children[v.children.length-1];R&&R.type==="text"?R.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...k)}else h.push(...k);const w={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(h,!0)};e.patch(d,w),c.push(w)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...qa(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
12
|
-
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
13
|
-
`}]}}const gl=(function(e){if(e==null)return $N;if(typeof e=="function")return bl(e);if(typeof e=="object")return Array.isArray(e)?_N(e):WN(e);if(typeof e=="string")return FN(e);throw new Error("Expected function, string, or object as test")});function _N(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=gl(e[n]);return bl(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function WN(e){const t=e;return bl(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function FN(e){return bl(t);function t(n){return n&&n.type===e}}function bl(e){return t;function t(n,r,i){return!!(zN(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function $N(){return!0}function zN(e){return e!==null&&typeof e=="object"&&"type"in e}const Bg=[],UN=!0,Qc=!1,HN="skip";function _g(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=gl(i),a=r?-1:1;c(e,void 0,[])();function c(u,d,h){const p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){const m=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(m?"<"+m+">":""))+")"})}return g;function g(){let m=Bg,k,S,v;if((!t||o(u,d,h[h.length-1]||void 0))&&(m=qN(n(u,h)),m[0]===Qc))return m;if("children"in u&&u.children){const w=u;if(w.children&&m[0]!==HN)for(S=(r?w.children.length:-1)+a,v=h.concat(w);S>-1&&S<w.children.length;){const R=w.children[S];if(k=c(R,S,v)(),k[0]===Qc)return k;S=typeof k[1]=="number"?k[1]:S+a}}return m}}}function qN(e){return Array.isArray(e)?e:typeof e=="number"?[UN,e]:e==null?Bg:[e]}function td(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),_g(e,o,c,i);function c(u,d){const h=d[d.length-1],p=h?h.children.indexOf(u):void 0;return a(u,p,h)}}const Zc={}.hasOwnProperty,GN={};function KN(e,t){const n=t||GN,r=new Map,i=new Map,o=new Map,a={...RN,...n.handlers},c={all:d,applyData:YN,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:u,options:n,patch:VN,wrap:XN};return td(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const p=h.type==="definition"?r:i,g=String(h.identifier).toUpperCase();p.has(g)||p.set(g,h)}}),c;function u(h,p){const g=h.type,m=c.handlers[g];if(Zc.call(c.handlers,g)&&m)return m(c,h,p);if(c.options.passThrough&&c.options.passThrough.includes(g)){if("children"in h){const{children:S,...v}=h,w=qa(v);return w.children=c.all(h),w}return qa(h)}return(c.options.unknownHandler||JN)(c,h,p)}function d(h){const p=[];if("children"in h){const g=h.children;let m=-1;for(;++m<g.length;){const k=c.one(g[m],h);if(k){if(m&&g[m-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=Jh(k.value)),!Array.isArray(k)&&k.type==="element")){const S=k.children[0];S&&S.type==="text"&&(S.value=Jh(S.value))}Array.isArray(k)?p.push(...k):p.push(k)}}}return p}}function VN(e,t){e.position&&(t.position=OS(e))}function YN(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,qa(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function JN(e,t){const n=t.data||{},r="value"in t&&!(Zc.call(n,"hProperties")||Zc.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function XN(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
14
|
-
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
15
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
16
|
-
`}),n}function Jh(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Xh(e,t){const n=KN(e,t),r=n.one(e,void 0),i=BN(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
|
|
17
|
-
`},i),o}function QN(e,t){return e&&"run"in e?async function(n,r){const i=Xh(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Xh(n,{file:r,...e||t})}}function Qh(e){if(e)throw e}var sc,Zh;function ZN(){if(Zh)return sc;Zh=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var h=e.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!h&&!p)return!1;var g;for(g in d);return typeof g>"u"||e.call(d,g)},a=function(d,h){n&&h.name==="__proto__"?n(d,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):d[h.name]=h.newValue},c=function(d,h){if(h==="__proto__")if(e.call(d,h)){if(r)return r(d,h).value}else return;return d[h]};return sc=function u(){var d,h,p,g,m,k,S=arguments[0],v=1,w=arguments.length,R=!1;for(typeof S=="boolean"&&(R=S,S=arguments[1]||{},v=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});v<w;++v)if(d=arguments[v],d!=null)for(h in d)p=c(S,h),g=c(d,h),S!==g&&(R&&g&&(o(g)||(m=i(g)))?(m?(m=!1,k=p&&i(p)?p:[]):k=p&&o(p)?p:{},a(S,{name:h,newValue:u(R,k,g)})):typeof g<"u"&&a(S,{name:h,newValue:g}));return S},sc}var e1=ZN();const ic=em(e1);function eu(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function t1(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...i);function c(u,...d){const h=e[++o];let p=-1;if(u){a(u);return}for(;++p<i.length;)(d[p]===null||d[p]===void 0)&&(d[p]=i[p]);i=d,h?n1(h,c)(...d):a(null,...d)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function n1(e,t){let n;return r;function r(...a){const c=e.length>a.length;let u;c&&a.push(i);try{u=e.apply(this,a)}catch(d){const h=d;if(c&&n)throw h;return i(h)}c||(u&&u.then&&typeof u.then=="function"?u.then(o,i):u instanceof Error?i(u):o(u))}function i(a,...c){n||(n=!0,t(a,...c))}function o(a){i(null,a)}}const Nr={basename:r1,dirname:s1,extname:i1,join:o1,sep:"/"};function r1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ao(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,c=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),c>-1&&(e.codePointAt(i)===t.codePointAt(c--)?c<0&&(r=i):(c=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function s1(e){if(Ao(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function i1(e){Ao(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function o1(...e){let t=-1,n;for(;++t<e.length;)Ao(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":a1(n)}function a1(e){Ao(e);const t=e.codePointAt(0)===47;let n=l1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function l1(e,t){let n="",r=0,i=-1,o=0,a=-1,c,u;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else c===46&&o>-1?o++:o=-1}return n}function Ao(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const c1={cwd:u1};function u1(){return"/"}function tu(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function d1(e){if(typeof e=="string")e=new URL(e);else if(!tu(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return h1(e)}function h1(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const oc=["history","path","basename","stem","extname","dirname"];class Wg{constructor(t){let n;t?tu(t)?n={path:t}:typeof t=="string"||p1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":c1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<oc.length;){const o=oc[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)oc.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Nr.basename(this.path):void 0}set basename(t){lc(t,"basename"),ac(t,"basename"),this.path=Nr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Nr.dirname(this.path):void 0}set dirname(t){ep(this.basename,"dirname"),this.path=Nr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Nr.extname(this.path):void 0}set extname(t){if(ac(t,"extname"),ep(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Nr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){tu(t)&&(t=d1(t)),lc(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Nr.basename(this.path,this.extname):void 0}set stem(t){lc(t,"stem"),ac(t,"stem"),this.path=Nr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new mn(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function ac(e,t){if(e&&e.includes(Nr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Nr.sep+"`")}function lc(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ep(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function p1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const f1=(function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),m1={}.hasOwnProperty;class nd extends f1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=t1()}copy(){const t=new nd;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ic(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(dc("data",this.frozen),this.namespace[t]=n,this):m1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(dc("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=sa(t),r=this.parser||this.Parser;return cc("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),cc("process",this.parser||this.Parser),uc("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,a){const c=sa(t),u=r.parse(c);r.run(u,c,function(h,p,g){if(h||!p||!g)return d(h);const m=p,k=r.stringify(m,g);k1(k)?g.value=k:g.result=k,d(h,g)});function d(h,p){h||!p?a(h):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),cc("processSync",this.parser||this.Parser),uc("processSync",this.compiler||this.Compiler),this.process(t,i),np("processSync","process",n),r;function i(o,a){n=!0,Qh(o),r=a}}run(t,n,r){tp(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,c){const u=sa(n);i.run(t,u,d);function d(h,p,g){const m=p||t;h?c(h):a?a(m):r(void 0,m,g)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),np("runSync","run",r),i;function o(a,c){Qh(a),i=c,r=!0}}stringify(t,n){this.freeze();const r=sa(n),i=this.compiler||this.Compiler;return uc("stringify",i),tp(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(dc("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[h,...p]=d;u(h,p)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(d.plugins),d.settings&&(i.settings=ic(!0,i.settings,d.settings))}function c(d){let h=-1;if(d!=null)if(Array.isArray(d))for(;++h<d.length;){const p=d[h];o(p)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,h){let p=-1,g=-1;for(;++p<r.length;)if(r[p][0]===d){g=p;break}if(g===-1)r.push([d,...h]);else if(h.length>0){let[m,...k]=h;const S=r[g][1];eu(S)&&eu(m)&&(m=ic(!0,S,m)),r[g]=[d,m,...k]}}}}const g1=new nd().freeze();function cc(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function uc(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function dc(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function tp(e){if(!eu(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function np(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function sa(e){return b1(e)?e:new Wg(e)}function b1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function k1(e){return typeof e=="string"||y1(e)}function y1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const w1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",rp=[],sp={allowDangerousHtml:!0},x1=/^(https?|ircs?|mailto|xmpp)$/i,v1=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function S1(e){const t=C1(e),n=N1(e);return j1(t.runSync(t.parse(n),n),e)}function C1(e){const t=e.rehypePlugins||rp,n=e.remarkPlugins||rp,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sp}:sp;return g1().use(sN).use(n).use(QN,r).use(t)}function N1(e){const t=e.children||"",n=new Wg;return typeof t=="string"&&(n.value=t),n}function j1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,u=t.urlTransform||T1;for(const h of v1)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+w1+h.id,void 0);return td(e,d),$S(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function d(h,p,g){if(h.type==="raw"&&g&&typeof p=="number")return a?g.children.splice(p,1):g.children[p]={type:"text",value:h.value},p;if(h.type==="element"){let m;for(m in tc)if(Object.hasOwn(tc,m)&&Object.hasOwn(h.properties,m)){const k=h.properties[m],S=tc[m];(S===null||S.includes(h.tagName))&&(h.properties[m]=u(String(k||""),m,h))}}if(h.type==="element"){let m=n?!n.includes(h.tagName):o?o.includes(h.tagName):!1;if(!m&&r&&typeof p=="number"&&(m=!r(h,p,g)),m&&g&&typeof p=="number")return c&&h.children?g.children.splice(p,1,...h.children):g.children.splice(p,1),p}}}function T1(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||x1.test(e.slice(0,t))?e:""}function ip(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function I1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function A1(e,t,n){const i=gl((n||{}).ignore||[]),o=R1(t);let a=-1;for(;++a<o.length;)_g(e,"text",c);function c(d,h){let p=-1,g;for(;++p<h.length;){const m=h[p],k=g?g.children:void 0;if(i(m,k?k.indexOf(m):void 0,g))return;g=m}if(g)return u(d,h)}function u(d,h){const p=h[h.length-1],g=o[a][0],m=o[a][1];let k=0;const v=p.children.indexOf(d);let w=!1,R=[];g.lastIndex=0;let T=g.exec(d.value);for(;T;){const F=T.index,E={index:T.index,input:T.input,stack:[...h,d]};let I=m(...T,E);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=F+1:(k!==F&&R.push({type:"text",value:d.value.slice(k,F)}),Array.isArray(I)?R.push(...I):I&&R.push(I),k=F+T[0].length,w=!0),!g.global)break;T=g.exec(d.value)}return w?(k<d.value.length&&R.push({type:"text",value:d.value.slice(k)}),p.children.splice(v,1,...R)):R=[d],v+R.length}}function R1(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([E1(i[0]),P1(i[1])])}return t}function E1(e){return typeof e=="string"?new RegExp(I1(e),"g"):e}function P1(e){return typeof e=="function"?e:function(){return e}}const hc="phrasing",pc=["autolink","link","image","label"];function M1(){return{transforms:[F1],enter:{literalAutolink:D1,literalAutolinkEmail:fc,literalAutolinkHttp:fc,literalAutolinkWww:fc},exit:{literalAutolink:W1,literalAutolinkEmail:_1,literalAutolinkHttp:O1,literalAutolinkWww:B1}}}function L1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:hc,notInConstruct:pc},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:hc,notInConstruct:pc},{character:":",before:"[ps]",after:"\\/",inConstruct:hc,notInConstruct:pc}]}}function D1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function fc(e){this.config.enter.autolinkProtocol.call(this,e)}function O1(e){this.config.exit.autolinkProtocol.call(this,e)}function B1(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function _1(e){this.config.exit.autolinkEmail.call(this,e)}function W1(e){this.exit(e)}function F1(e){A1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,$1],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),z1]],{ignore:["link","linkReference"]})}function $1(e,t,n,r,i){let o="";if(!Fg(i)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!U1(n)))return!1;const a=H1(n+r);if(!a[0])return!1;const c={type:"link",title:null,url:o+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[c,{type:"text",value:a[1]}]:c}function z1(e,t,n,r){return!Fg(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function U1(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function H1(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=ip(e,"(");let o=ip(e,")");for(;r!==-1&&i>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function Fg(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ms(n)||pl(n))&&(!t||n!==47)}$g.peek=Z1;function q1(){this.buffer()}function G1(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function K1(){this.buffer()}function V1(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Y1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=or(this.sliceSerialize(e)).toLowerCase(),n.label=t}function J1(e){this.exit(e)}function X1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=or(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Q1(e){this.exit(e)}function Z1(){return"["}function $g(e,t,n,r){const i=n.createTracker(r);let o=i.move("[^");const a=n.enter("footnoteReference"),c=n.enter("reference");return o+=i.move(n.safe(n.associationId(e),{after:"]",before:o})),c(),a(),o+=i.move("]"),o}function ej(){return{enter:{gfmFootnoteCallString:q1,gfmFootnoteCall:G1,gfmFootnoteDefinitionLabelString:K1,gfmFootnoteDefinition:V1},exit:{gfmFootnoteCallString:Y1,gfmFootnoteCall:J1,gfmFootnoteDefinitionLabelString:X1,gfmFootnoteDefinition:Q1}}}function tj(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:$g},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,o,a){const c=o.createTracker(a);let u=c.move("[^");const d=o.enter("footnoteDefinition"),h=o.enter("label");return u+=c.move(o.safe(o.associationId(r),{before:u,after:"]"})),h(),u+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),u+=c.move((t?`
|
|
18
|
-
`:" ")+o.indentLines(o.containerFlow(r,c.current()),t?zg:nj))),d(),u}}function nj(e,t,n){return t===0?e:zg(e,t,n)}function zg(e,t,n){return(n?"":" ")+e}const rj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ug.peek=lj;function sj(){return{canContainEols:["delete"],enter:{strikethrough:oj},exit:{strikethrough:aj}}}function ij(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:rj}],handlers:{delete:Ug}}}function oj(e){this.enter({type:"delete",children:[]},e)}function aj(e){this.exit(e)}function Ug(e,t,n,r){const i=n.createTracker(r),o=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),o(),a}function lj(){return"~"}function cj(e){return e.length}function uj(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||cj,o=[],a=[],c=[],u=[];let d=0,h=-1;for(;++h<e.length;){const S=[],v=[];let w=-1;for(e[h].length>d&&(d=e[h].length);++w<e[h].length;){const R=dj(e[h][w]);if(n.alignDelimiters!==!1){const T=i(R);v[w]=T,(u[w]===void 0||T>u[w])&&(u[w]=T)}S.push(R)}a[h]=S,c[h]=v}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)o[p]=op(r[p]);else{const S=op(r);for(;++p<d;)o[p]=S}p=-1;const g=[],m=[];for(;++p<d;){const S=o[p];let v="",w="";S===99?(v=":",w=":"):S===108?v=":":S===114&&(w=":");let R=n.alignDelimiters===!1?1:Math.max(1,u[p]-v.length-w.length);const T=v+"-".repeat(R)+w;n.alignDelimiters!==!1&&(R=v.length+R+w.length,R>u[p]&&(u[p]=R),m[p]=R),g[p]=T}a.splice(1,0,g),c.splice(1,0,m),h=-1;const k=[];for(;++h<a.length;){const S=a[h],v=c[h];p=-1;const w=[];for(;++p<d;){const R=S[p]||"";let T="",F="";if(n.alignDelimiters!==!1){const E=u[p]-(v[p]||0),I=o[p];I===114?T=" ".repeat(E):I===99?E%2?(T=" ".repeat(E/2+.5),F=" ".repeat(E/2-.5)):(T=" ".repeat(E/2),F=T):F=" ".repeat(E)}n.delimiterStart!==!1&&!p&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&R==="")&&(n.delimiterStart!==!1||p)&&w.push(" "),n.alignDelimiters!==!1&&w.push(T),w.push(R),n.alignDelimiters!==!1&&w.push(F),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||p!==d-1)&&w.push("|")}k.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return k.join(`
|
|
19
|
-
`)}function dj(e){return e==null?"":String(e)}function op(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function hj(e,t,n,r){const i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),pj);return i(),a}function pj(e,t,n){return">"+(n?"":" ")+e}function fj(e,t){return ap(e,t.inConstruct,!0)&&!ap(e,t.notInConstruct,!1)}function ap(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function lp(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
20
|
-
`&&fj(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
21
|
-
`}function mj(e,t){const n=String(e);let r=n.indexOf(t),i=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>a&&(a=o):o=1,i=r+t.length,r=n.indexOf(t,i);return a}function gj(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function bj(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function kj(e,t,n,r){const i=bj(n),o=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(gj(e,n)){const p=n.enter("codeIndented"),g=n.indentLines(o,yj);return p(),g}const c=n.createTracker(r),u=i.repeat(Math.max(mj(o,i)+1,3)),d=n.enter("codeFenced");let h=c.move(u);if(e.lang){const p=n.enter(`codeFencedLang${a}`);h+=c.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${a}`);h+=c.move(" "),h+=c.move(n.safe(e.meta,{before:h,after:`
|
|
22
|
-
`,encode:["`"],...c.current()})),p()}return h+=c.move(`
|
|
23
|
-
`),o&&(h+=c.move(o+`
|
|
24
|
-
`)),h+=c.move(u),d(),h}function yj(e,t,n){return(n?"":" ")+e}function rd(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function wj(e,t,n,r){const i=rd(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("[");return d+=u.move(n.safe(n.associationId(e),{before:d,after:"]",...u.current()})),d+=u.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(c=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":`
|
|
25
|
-
`,...u.current()}))),c(),e.title&&(c=n.enter(`title${o}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),c()),a(),d}function xj(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function go(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ga(e,t,n){const r=Si(e),i=Si(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Hg.peek=vj;function Hg(e,t,n,r){const i=xj(n),o=n.enter("emphasis"),a=n.createTracker(r),c=a.move(i);let u=a.move(n.containerPhrasing(e,{after:i,before:c,...a.current()}));const d=u.charCodeAt(0),h=Ga(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=go(d)+u.slice(1));const p=u.charCodeAt(u.length-1),g=Ga(r.after.charCodeAt(0),p,i);g.inside&&(u=u.slice(0,-1)+go(p));const m=a.move(i);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:h.outside},c+u+m}function vj(e,t,n){return n.options.emphasis||"*"}function Sj(e,t){let n=!1;return td(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Qc}),!!((!e.depth||e.depth<3)&&Vu(e)&&(t.options.setext||n))}function Cj(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(Sj(e,n)){const h=n.enter("headingSetext"),p=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
|
|
26
|
-
`,after:`
|
|
27
|
-
`});return p(),h(),g+`
|
|
28
|
-
`+(i===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
|
|
29
|
-
`))+1))}const a="#".repeat(i),c=n.enter("headingAtx"),u=n.enter("phrasing");o.move(a+" ");let d=n.containerPhrasing(e,{before:"# ",after:`
|
|
30
|
-
`,...o.current()});return/^[\t ]/.test(d)&&(d=go(d.charCodeAt(0))+d.slice(1)),d=d?a+" "+d:a,n.options.closeAtx&&(d+=" "+a),u(),c(),d}qg.peek=Nj;function qg(e){return e.value||""}function Nj(){return"<"}Gg.peek=jj;function Gg(e,t,n,r){const i=rd(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("![");return d+=u.move(n.safe(e.alt,{before:d,after:"]",...u.current()})),d+=u.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(c=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":")",...u.current()}))),c(),e.title&&(c=n.enter(`title${o}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),c()),d+=u.move(")"),a(),d}function jj(){return"!"}Kg.peek=Tj;function Kg(e,t,n,r){const i=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("![");const d=n.safe(e.alt,{before:u,after:"]",...c.current()});u+=c.move(d+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return a(),n.stack=h,o(),i==="full"||!d||d!==p?u+=c.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function Tj(){return"!"}Vg.peek=Ij;function Vg(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],c=n.compilePattern(a);let u;if(a.atBreak)for(;u=c.exec(r);){let d=u.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(u.index+1)}}return i+r+i}function Ij(){return"`"}function Yg(e,t){const n=Vu(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Jg.peek=Aj;function Jg(e,t,n,r){const i=rd(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let c,u;if(Yg(e,n)){const h=n.stack;n.stack=[],c=n.enter("autolink");let p=a.move("<");return p+=a.move(n.containerPhrasing(e,{before:p,after:">",...a.current()})),p+=a.move(">"),c(),n.stack=h,p}c=n.enter("link"),u=n.enter("label");let d=a.move("[");return d+=a.move(n.containerPhrasing(e,{before:d,after:"](",...a.current()})),d+=a.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),d+=a.move("<"),d+=a.move(n.safe(e.url,{before:d,after:">",...a.current()})),d+=a.move(">")):(u=n.enter("destinationRaw"),d+=a.move(n.safe(e.url,{before:d,after:e.title?" ":")",...a.current()}))),u(),e.title&&(u=n.enter(`title${o}`),d+=a.move(" "+i),d+=a.move(n.safe(e.title,{before:d,after:i,...a.current()})),d+=a.move(i),u()),d+=a.move(")"),c(),d}function Aj(e,t,n){return Yg(e,n)?"<":"["}Xg.peek=Rj;function Xg(e,t,n,r){const i=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("[");const d=n.containerPhrasing(e,{before:u,after:"]",...c.current()});u+=c.move(d+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return a(),n.stack=h,o(),i==="full"||!d||d!==p?u+=c.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function Rj(){return"["}function sd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Ej(e){const t=sd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Pj(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Qg(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Mj(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?Pj(n):sd(n);const c=e.ordered?a==="."?")":".":Ej(n);let u=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),Qg(n)===a&&h){let p=-1;for(;++p<e.children.length;){const g=e.children[p];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(a=c),n.bulletCurrent=a;const d=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,i(),d}function Lj(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Dj(e,t,n,r){const i=Lj(n);let o=n.bulletCurrent||sd(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const c=n.createTracker(r);c.move(o+" ".repeat(a-o.length)),c.shift(a);const u=n.enter("listItem"),d=n.indentLines(n.containerFlow(e,c.current()),h);return u(),d;function h(p,g,m){return g?(m?"":" ".repeat(a))+p:(m?o:o+" ".repeat(a-o.length))+p}}function Oj(e,t,n,r){const i=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),i(),a}const Bj=gl(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function _j(e,t,n,r){return(e.children.some(function(a){return Bj(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Wj(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Zg.peek=Fj;function Zg(e,t,n,r){const i=Wj(n),o=n.enter("strong"),a=n.createTracker(r),c=a.move(i+i);let u=a.move(n.containerPhrasing(e,{after:i,before:c,...a.current()}));const d=u.charCodeAt(0),h=Ga(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=go(d)+u.slice(1));const p=u.charCodeAt(u.length-1),g=Ga(r.after.charCodeAt(0),p,i);g.inside&&(u=u.slice(0,-1)+go(p));const m=a.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:h.outside},c+u+m}function Fj(e,t,n){return n.options.strong||"*"}function $j(e,t,n,r){return n.safe(e.value,r)}function zj(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Uj(e,t,n){const r=(Qg(n)+(n.options.ruleSpaces?" ":"")).repeat(zj(n));return n.options.ruleSpaces?r.slice(0,-1):r}const eb={blockquote:hj,break:lp,code:kj,definition:wj,emphasis:Hg,hardBreak:lp,heading:Cj,html:qg,image:Gg,imageReference:Kg,inlineCode:Vg,link:Jg,linkReference:Xg,list:Mj,listItem:Dj,paragraph:Oj,root:_j,strong:Zg,text:$j,thematicBreak:Uj};function Hj(){return{enter:{table:qj,tableData:cp,tableHeader:cp,tableRow:Kj},exit:{codeText:Vj,table:Gj,tableData:mc,tableHeader:mc,tableRow:mc}}}function qj(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Gj(e){this.exit(e),this.data.inTable=void 0}function Kj(e){this.enter({type:"tableRow",children:[]},e)}function mc(e){this.exit(e)}function cp(e){this.enter({type:"tableCell",children:[]},e)}function Vj(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Yj));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Yj(e,t){return t==="|"?t:e}function Jj(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
31
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:u,tableRow:c}};function a(m,k,S,v){return d(h(m,S,v),m.align)}function c(m,k,S,v){const w=p(m,S,v),R=d([w]);return R.slice(0,R.indexOf(`
|
|
32
|
-
`))}function u(m,k,S,v){const w=S.enter("tableCell"),R=S.enter("phrasing"),T=S.containerPhrasing(m,{...v,before:o,after:o});return R(),w(),T}function d(m,k){return uj(m,{align:k,alignDelimiters:r,padding:n,stringLength:i})}function h(m,k,S){const v=m.children;let w=-1;const R=[],T=k.enter("table");for(;++w<v.length;)R[w]=p(v[w],k,S);return T(),R}function p(m,k,S){const v=m.children;let w=-1;const R=[],T=k.enter("tableRow");for(;++w<v.length;)R[w]=u(v[w],m,k,S);return T(),R}function g(m,k,S){let v=eb.inlineCode(m,k,S);return S.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function Xj(){return{exit:{taskListCheckValueChecked:up,taskListCheckValueUnchecked:up,paragraph:Zj}}}function Qj(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:eT}}}function up(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Zj(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,a;for(;++o<i.length;){const c=i[o];if(c.type==="paragraph"){a=c;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function eT(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);o&&c.move(a);let u=eb.listItem(e,t,n,{...r,...c.current()});return o&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(h){return h+a}}function tT(){return[M1(),ej(),sj(),Hj(),Xj()]}function nT(e){return{extensions:[L1(),tj(e),ij(),Jj(e),Qj()]}}const rT={tokenize:cT,partial:!0},tb={tokenize:uT,partial:!0},nb={tokenize:dT,partial:!0},rb={tokenize:hT,partial:!0},sT={tokenize:pT,partial:!0},sb={name:"wwwAutolink",tokenize:aT,previous:ob},ib={name:"protocolAutolink",tokenize:lT,previous:ab},Ur={name:"emailAutolink",tokenize:oT,previous:lb},Ar={};function iT(){return{text:Ar}}let Ss=48;for(;Ss<123;)Ar[Ss]=Ur,Ss++,Ss===58?Ss=65:Ss===91&&(Ss=97);Ar[43]=Ur;Ar[45]=Ur;Ar[46]=Ur;Ar[95]=Ur;Ar[72]=[Ur,ib];Ar[104]=[Ur,ib];Ar[87]=[Ur,sb];Ar[119]=[Ur,sb];function oT(e,t,n){const r=this;let i,o;return a;function a(p){return!nu(p)||!lb.call(r,r.previous)||id(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(p))}function c(p){return nu(p)?(e.consume(p),c):p===64?(e.consume(p),u):n(p)}function u(p){return p===46?e.check(sT,h,d)(p):p===45||p===95||fn(p)?(o=!0,e.consume(p),u):h(p)}function d(p){return e.consume(p),i=!0,u}function h(p){return o&&i&&xn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function aT(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!ob.call(r,r.previous)||id(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(rT,e.attempt(tb,e.attempt(nb,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function lT(e,t,n){const r=this;let i="",o=!1;return a;function a(p){return(p===72||p===104)&&ab.call(r,r.previous)&&!id(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),c):n(p)}function c(p){if(xn(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),c;if(p===58){const g=i.toLowerCase();if(g==="http"||g==="https")return e.consume(p),u}return n(p)}function u(p){return p===47?(e.consume(p),o?d:(o=!0,u)):n(p)}function d(p){return p===null||Ua(p)||jt(p)||Ms(p)||pl(p)?n(p):e.attempt(tb,e.attempt(nb,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function cT(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function uT(e,t,n){let r,i,o;return a;function a(d){return d===46||d===95?e.check(rb,u,c)(d):d===null||jt(d)||Ms(d)||d!==45&&pl(d)?u(d):(o=!0,e.consume(d),a)}function c(d){return d===95?r=!0:(i=r,r=void 0),e.consume(d),a}function u(d){return i||r||!o?n(d):t(d)}}function dT(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(rb,t,o)(a):a===null||jt(a)||Ms(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function hT(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),o):c===93?(e.consume(c),i):c===60||c===null||jt(c)||Ms(c)?t(c):n(c)}function i(c){return c===null||c===40||c===91||jt(c)||Ms(c)?t(c):r(c)}function o(c){return xn(c)?a(c):n(c)}function a(c){return c===59?(e.consume(c),r):xn(c)?(e.consume(c),a):n(c)}}function pT(e,t,n){return r;function r(o){return e.consume(o),i}function i(o){return fn(o)?n(o):t(o)}}function ob(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||jt(e)}function ab(e){return!xn(e)}function lb(e){return!(e===47||nu(e))}function nu(e){return e===43||e===45||e===46||e===95||fn(e)}function id(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const fT={tokenize:vT,partial:!0};function mT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:yT,continuation:{tokenize:wT},exit:xT}},text:{91:{name:"gfmFootnoteCall",tokenize:kT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:gT,resolveTo:bT}}}}function gT(e,t,n){const r=this;let i=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){a=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return c;function c(u){if(!a||!a._balanced)return n(u);const d=or(r.sliceSerialize({start:a.end,end:r.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function bT(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function kT(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),u}function u(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(o>999||p===93&&!a||p===null||p===91||jt(p))return n(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return i.includes(or(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return jt(p)||(a=!0),o++,e.consume(p),p===92?h:d}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function yT(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,c;return u;function u(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(k)}function h(k){if(a>999||k===93&&!c||k===null||k===91||jt(k))return n(k);if(k===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return o=or(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return jt(k)||(c=!0),a++,e.consume(k),k===92?p:h}function p(k){return k===91||k===92||k===93?(e.consume(k),a++,h):h(k)}function g(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),i.includes(o)||i.push(o),at(e,m,"gfmFootnoteDefinitionWhitespace")):n(k)}function m(k){return t(k)}}function wT(e,t,n){return e.check(Io,t,e.attempt(fT,t,n))}function xT(e){e.exit("gfmFootnoteDefinition")}function vT(e,t,n){const r=this;return at(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function ST(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,c){let u=-1;for(;++u<a.length;)if(a[u][0]==="enter"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._close){let d=u;for(;d--;)if(a[d][0]==="exit"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[d][1].end.offset-a[d][1].start.offset){a[u][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[u][1].end)},p={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[u][1].start)},g=[["enter",h,c],["enter",a[d][1],c],["exit",a[d][1],c],["enter",p,c]],m=c.parser.constructs.insideSpan.null;m&&$n(g,g.length,0,fl(m,a.slice(d+1,u),c)),$n(g,g.length,0,[["exit",p,c],["enter",a[u][1],c],["exit",a[u][1],c],["exit",h,c]]),$n(a,d-1,u-d+3,g),u=d+g.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type==="strikethroughSequenceTemporary"&&(a[u][1].type="data");return a}function o(a,c,u){const d=this.previous,h=this.events;let p=0;return g;function g(k){return d===126&&h[h.length-1][1].type!=="characterEscape"?u(k):(a.enter("strikethroughSequenceTemporary"),m(k))}function m(k){const S=Si(d);if(k===126)return p>1?u(k):(a.consume(k),p++,m);if(p<2&&!n)return u(k);const v=a.exit("strikethroughSequenceTemporary"),w=Si(k);return v._open=!w||w===2&&!!S,v._close=!S||S===2&&!!w,c(k)}}}class CT{constructor(){this.map=[]}add(t,n,r){NT(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const o of i)t.push(o);i=r.pop()}this.map.length=0}}function NT(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function jT(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function TT(){return{flow:{null:{name:"table",tokenize:IT,resolveAll:AT}}}}function IT(e,t,n){const r=this;let i=0,o=0,a;return c;function c(A){let U=r.events.length-1;for(;U>-1;){const V=r.events[U][1].type;if(V==="lineEnding"||V==="linePrefix")U--;else break}const B=U>-1?r.events[U][1].type:null,le=B==="tableHead"||B==="tableRow"?I:u;return le===I&&r.parser.lazy[r.now().line]?n(A):le(A)}function u(A){return e.enter("tableHead"),e.enter("tableRow"),d(A)}function d(A){return A===124||(a=!0,o+=1),h(A)}function h(A){return A===null?n(A):Le(A)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),m):n(A):nt(A)?at(e,h,"whitespace")(A):(o+=1,a&&(a=!1,i+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),p(A)))}function p(A){return A===null||A===124||jt(A)?(e.exit("data"),h(A)):(e.consume(A),A===92?g:p)}function g(A){return A===92||A===124?(e.consume(A),p):p(A)}function m(A){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(A):(e.enter("tableDelimiterRow"),a=!1,nt(A)?at(e,k,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):k(A))}function k(A){return A===45||A===58?v(A):A===124?(a=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),S):E(A)}function S(A){return nt(A)?at(e,v,"whitespace")(A):v(A)}function v(A){return A===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),w):A===45?(o+=1,w(A)):A===null||Le(A)?F(A):E(A)}function w(A){return A===45?(e.enter("tableDelimiterFiller"),R(A)):E(A)}function R(A){return A===45?(e.consume(A),R):A===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(A))}function T(A){return nt(A)?at(e,F,"whitespace")(A):F(A)}function F(A){return A===124?k(A):A===null||Le(A)?!a||i!==o?E(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(A)):E(A)}function E(A){return n(A)}function I(A){return e.enter("tableRow"),q(A)}function q(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),q):A===null||Le(A)?(e.exit("tableRow"),t(A)):nt(A)?at(e,q,"whitespace")(A):(e.enter("data"),z(A))}function z(A){return A===null||A===124||jt(A)?(e.exit("data"),q(A)):(e.consume(A),A===92?L:z)}function L(A){return A===92||A===124?(e.consume(A),z):z(A)}}function AT(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],a=[0,0,0,0],c=!1,u=0,d,h,p;const g=new CT;for(;++n<e.length;){const m=e[n],k=m[1];m[0]==="enter"?k.type==="tableHead"?(c=!1,u!==0&&(dp(g,t,u,d,h),h=void 0,u=0),d={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},g.add(n,0,[["enter",d,t]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(r=!0,p=void 0,o=[0,0,0,0],a=[0,n+1,0,0],c&&(c=!1,h={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},g.add(n,0,[["enter",h,t]])),i=k.type==="tableDelimiterRow"?2:h?3:1):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],p=ia(g,t,o,i,void 0,p),o=[0,0,0,0]),a[2]=n)):k.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],p=ia(g,t,o,i,void 0,p)),o=a,a=[o[1],n,0,0])):k.type==="tableHead"?(c=!0,u=n):k.type==="tableRow"||k.type==="tableDelimiterRow"?(u=n,o[1]!==0?(a[0]=a[1],p=ia(g,t,o,i,n,p)):a[1]!==0&&(p=ia(g,t,a,i,n,p)),i=0):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&dp(g,t,u,d,h),g.consume(t.events),n=-1;++n<t.events.length;){const m=t.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=jT(t.events,n))}return e}function ia(e,t,n,r,i,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},ci(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const u=ci(t.events,n[1]);if(o={type:a,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const d=ci(t.events,n[2]),h=ci(t.events,n[3]),p={type:c,start:Object.assign({},d),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const g=t.events[n[2]],m=t.events[n[3]];if(g[1].end=Object.assign({},m[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const k=n[2]+1,S=n[3]-n[2]-1;e.add(k,S,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(o.end=Object.assign({},ci(t.events,i)),e.add(i,0,[["exit",o,t]]),o=void 0),o}function dp(e,t,n,r,i){const o=[],a=ci(t.events,n);i&&(i.end=Object.assign({},a),o.push(["exit",i,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function ci(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const RT={name:"tasklistCheck",tokenize:PT};function ET(){return{text:{91:RT}}}function PT(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),o)}function o(u){return jt(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),a):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),a):n(u)}function a(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(u)}function c(u){return Le(u)?t(u):nt(u)?e.check({tokenize:MT},t,n)(u):n(u)}}function MT(e,t,n){return at(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function LT(e){return yg([iT(),mT(),ST(e),TT(),ET()])}const DT={};function OT(e){const t=this,n=e||DT,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(LT(n)),o.push(tT()),a.push(nT(n))}const BT="X-CodingNS-Assistant-Source",_T="butler-ui",gc=new Map;async function Hr(e,t={},n={}){const r=new Headers(t.headers);r.set(BT,_T);const i=WT();if(gc.get(i)===!1){if(n.unsupportedFallback!==void 0)return hp(n.unsupportedFallback);throw pp()}try{const a=await Y.request(e,{...t,headers:r});return gc.set(i,!0),a}catch(a){if(!FT(a))throw a;if(gc.set(i,!1),n.unsupportedFallback!==void 0)return hp(n.unsupportedFallback);throw pp()}}function WT(){return Su()}function hp(e){return typeof e=="function"?e():e}function FT(e){return e instanceof il&&(e.status===404||e.status===405||e.status===501)}function pp(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function $T(){return Y.request("/api/butler/profile")}function KD(e){return Y.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function VD(e){return Y.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function YD(){return Y.request("/api/butler/control-session")}function JD(){return Y.request("/api/butler/control-sessions")}function XD(e){return Y.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function QD(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/butler/control-timers?${n}`:"/api/butler/control-timers";return Y.request(r)}function ZD(){return Y.request("/api/butler/control-session/reset",{method:"POST"})}function eO(e={}){return Y.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function tO(e){return Y.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function nO(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations?${n}`:"/api/assistant/automations";return Hr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function rO(e={}){var i;const t=new URLSearchParams;(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations/runs/recent?${n}`:"/api/assistant/automations/runs/recent";return Hr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function sO(e){return Hr(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function iO(e,t){return Hr(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function oO(e){return Hr(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function aO(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim());const n=t.toString(),r=n?`/api/assistant/sandboxes?${n}`:"/api/assistant/sandboxes";return Hr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function lO(e){return Hr(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function cO(e){return Hr(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function uO(e){return Hr(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function dO(e){return Y.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function hO(){return Y.request("/api/butler/control-session/events")}function zT(){return Y.request("/api/butler/overview")}function UT(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel);const n=t.toString(),r=n?`/api/butler/projects?${n}`:"/api/butler/projects";return Y.request(r)}function pO(e,t={}){const n=new URLSearchParams;t.enabled!==null&&t.enabled!==void 0&&n.set("enabled",String(t.enabled)),t.executionMode&&n.set("executionMode",t.executionMode);const r=n.toString(),i=r?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${r}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return Y.request(i)}function cb(e={}){var i,o;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),(o=e.projectId)!=null&&o.trim()&&t.set("projectId",e.projectId.trim()),e.status&&t.set("status",e.status),e.itemType&&t.set("itemType",e.itemType);const n=t.toString(),r=n?`/api/butler/inbox?${n}`:"/api/butler/inbox";return Y.request(r)}function HT(e){return Y.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function qT(e={}){var i,o;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.projectId)!=null&&i.trim()&&t.set("projectId",e.projectId.trim()),(o=e.sessionId)!=null&&o.trim()&&t.set("sessionId",e.sessionId.trim());const n=t.toString(),r=n?`/api/butler/follow-up-tasks?${n}`:"/api/butler/follow-up-tasks";return Y.request(r)}function fO(e){return Y.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function GT(e){return Y.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function mO(e){return Y.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function gO(e,t){return Y.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function fp(e,t){return Y.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:t.projectId,itemType:t.itemType,title:t.title,content:t.content,priority:t.priority,status:t.status})})}function bO(e){return Y.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function kO(e){return Y.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function KT(e){return Y.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function VT(){return Y.request("/api/butler/notifications/archives")}function YT(e,t){return Y.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function JT(e){const t=new URLSearchParams;return t.set("sessionId",e),Y.request(`/api/butler/session-target?${t.toString()}`)}function yO(e){const t=new URLSearchParams;return t.set("sessionId",e),Y.request(`/api/butler/session-action-context?${t.toString()}`)}function wO(e){return Y.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}const Ka="*** Begin Patch",Va="*** End Patch";function mp(e){const t=e.replace(/\r\n/g,`
|
|
33
|
-
`);if(!t.includes(Ka)||!t.includes(Va))return null;const n=t.split(`
|
|
34
|
-
`),r=[];let i=null,o=null;for(const a of n){if(a===Ka||a===Va)continue;if(a.startsWith("*** Update File: ")){i=bc("update",a.slice(17)),r.push(i),o=null;continue}if(a.startsWith("*** Add File: ")){i=bc("add",a.slice(14)),r.push(i),o={oldLineNumber:0,newLineNumber:1};continue}if(a.startsWith("*** Delete File: ")){i=bc("delete",a.slice(17)),r.push(i),o=null;continue}if(!i)continue;if(a.startsWith("*** Move to: ")){i.nextPath=a.slice(13),i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a.startsWith("@@")){o=ZT(a)??{oldLineNumber:0,newLineNumber:0},i.lines.push({kind:"hunk",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a==="*** End of File"){i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(i.action==="add"&&a.startsWith("+")){i.additions+=1,i.statsKnown=!0,i.lines.push({kind:"add",text:a,oldLineNumber:null,newLineNumber:(o==null?void 0:o.newLineNumber)??i.additions}),o&&(o.newLineNumber+=1);continue}if(!o){i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a.startsWith("+")){i.additions+=1,i.statsKnown=!0,i.lines.push({kind:"add",text:a,oldLineNumber:null,newLineNumber:o.newLineNumber}),o.newLineNumber+=1;continue}if(a.startsWith("-")){i.deletions+=1,i.statsKnown=!0,i.lines.push({kind:"remove",text:a,oldLineNumber:o.oldLineNumber,newLineNumber:null}),o.oldLineNumber+=1;continue}if(a.startsWith(" ")||a.length===0){i.lines.push({kind:"context",text:a,oldLineNumber:o.oldLineNumber,newLineNumber:o.newLineNumber}),o.oldLineNumber+=1,o.newLineNumber+=1;continue}i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null})}return r.length===0?null:{files:r,totalAdditions:r.reduce((a,c)=>a+c.additions,0),totalDeletions:r.reduce((a,c)=>a+c.deletions,0)}}function XT(e,t=[]){const n=e.replace(/\r\n/g,`
|
|
35
|
-
`).trim();if(!n)return null;if(n.includes(Ka)&&n.includes(Va))return n;const r=[...new Set(t.map(i=>i.trim()).filter(i=>i.length>0))];return r.length!==1||!eI(n)?null:[Ka,`*** Update File: ${r[0]}`,n,Va].join(`
|
|
36
|
-
`)}function QT(e){const t=tI(e);if(!t)return[];const n=t.replace(/\r\n/g,`
|
|
37
|
-
`).split(`
|
|
38
|
-
`),r=[];let i=!1;for(const o of n){const a=o.trim();if(!i){/^Success\.\s+Updated the following files:/i.test(a)&&(i=!0);continue}if(!a){if(r.length>0)break;continue}const c=a.match(/^[A-Z?]\s+(.+)$/),u=((c==null?void 0:c[1])??a).trim();if(!u)break;r.push(u)}return[...new Set(r)]}function gp(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function bc(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,statsKnown:!1,lines:[]}}function ZT(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function eI(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
|
|
39
|
-
@@`)||e.startsWith("+")||e.startsWith("-")}function tI(e){const t=e.trim();if(!t)return"";if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;if(typeof r.output=="string"&&r.output.trim().length>0)return r.output;if(typeof r.result=="string"&&r.result.trim().length>0)return r.result;if(typeof r.message=="string"&&r.message.trim().length>0)return r.message}catch{return t}return t}const nI=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,rI=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,sI=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,iI=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,oI=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,bp=/```question\s*([\s\S]*?)```/i;function bo(e){const t=lI(e),n=aI(t);if(n)return n;const r=cI(t);return r||{...db(t),structuredQuestions:null}}function aI(e){var r;const t=e.match(bp);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";if(!n)return null;try{const i=JSON.parse(n),o=ub(i);return o?{text:od(e.replace(bp,"").trim()),inlineImages:[],structuredQuestions:o}:null}catch{return null}}function lI(e){return e.replace(oI,"")}function cI(e){const t=e.trim();if(!dI(t))return null;try{const n=JSON.parse(t),r=ub(n),i=hI(r?uI(n):n);return i.text||i.inlineImages.length>0||r?{...i,structuredQuestions:r}:null}catch{return null}}function uI(e){const t=Ro(e);if(!t||!("questions"in t))return e;const{questions:n,...r}=t;return r}function dI(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function hI(e){const t=[],n=[];return Pa(e,t,n),{text:od(t.join(`
|
|
40
|
-
|
|
41
|
-
`)),inlineImages:hb(n),structuredQuestions:null}}function ub(e){const t=Ro(e);if(!t)return null;const n=pI(t.questions);return n.length===0?null:{questions:n}}function pI(e){return Array.isArray(e)?e.map((t,n)=>fI(t,n)).filter(t=>t!==null):[]}function fI(e,t){const n=Ro(e);if(!n)return null;const r=Tr(dn(n.question));if(!r)return null;const i=mI(n.options);return i.length===0?null:{id:Tr(dn(n.id))??`structured-question-${t+1}`,header:Tr(dn(n.header))??"问题",question:r,allowOther:!!(n.allowOther??n.isOther),secret:!!(n.secret??n.isSecret),options:i}}function mI(e){return Array.isArray(e)?e.map(t=>{const n=Ro(t);if(!n)return null;const r=Tr(dn(n.label));return r?{label:r,description:Tr(dn(n.description))}:null}).filter(t=>t!==null):[]}function Pa(e,t,n){if(typeof e=="string"){const a=db(e);a.text&&t.push(a.text),n.push(...a.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(a=>Pa(a,t,n));return}if(typeof e!="object")return;const r=e,i=new Set,o=gI(r);o&&(n.push(o),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(a=>{a in r&&i.add(a)}));for(const a of["image_url","url","src","source"]){const c=r[a];typeof c!="string"||!pb(c)||(n.push(As(c,dn(r.alt))),i.add(a))}for(const a of["text","message","content","output","result","summary","caption"])a in r&&(i.add(a),Pa(r[a],t,n));i.size>0||Object.values(r).forEach(a=>{Pa(a,t,n)})}function db(e){const t=[];let n=e;return n=n.replace(iI,(r,i,o)=>{const a=wI(i,"name"),c=yI(o);return c!=null&&c.url&&t.push(As(c.url,c.altText||a)),""}),n=n.replace(rI,(r,i,o)=>(t.push(As(o,i)),"")),n=n.replace(sI,(r,i)=>(t.push(As(i,null)),"")),n=n.replace(nI,(r,i,o)=>(t.push(As(r,null,`image/${i}`,Ya(o))),"")),{text:od(n),inlineImages:hb(t),structuredQuestions:null}}function As(e,t,n,r){const i=n??bI(e)??"image/png";return{url:e,mimeType:i,altText:Tr(t),estimatedBytes:r??kI(e)}}function gI(e){const t=Ro(e.source);if(t){const i=dn(t.type).trim().toLowerCase(),o=yp(t.media_type??t.mime_type??t.mimeType),a=kp(t.data);if(i==="base64"&&o&&a)return As(`data:${o};base64,${a}`,Tr(dn(t.alt)||dn(t.name)||dn(e.alt)||dn(e.name)),o,Ya(a))}const n=yp(e.media_type??e.mime_type??e.mimeType),r=kp(e.data);return n&&r?As(`data:${n};base64,${r}`,Tr(dn(e.alt)||dn(e.name)),n,Ya(r)):null}function hb(e){const t=new Map;return e.forEach(n=>{t.has(n.url)||t.set(n.url,n)}),[...t.values()]}function od(e){return e.replace(/\r\n/g,`
|
|
42
|
-
`).replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
|
|
43
|
-
`).replace(/\n{3,}/g,`
|
|
44
|
-
|
|
45
|
-
`).trim()}function pb(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function bI(e){var n;const t=e.match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,/i);return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())??null}function kI(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?Ya(t[1]):null}function Ya(e){const t=e.trim(),n=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-n)}function Tr(e){const t=dn(e).trim();return t.length>0?t:null}function kp(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function yp(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function dn(e){return typeof e=="string"?e:""}function Ro(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function yI(e){const t=e.trim();if(t.length===0)return null;try{const n=JSON.parse(t),r=dn(n.image_url??n.imageUrl).trim(),i=Tr(dn(n.name)||dn(n.alt));return{url:pb(r)?r:null,altText:i}}catch{const n=t.match(/(data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)/i);return n?{url:n[1],altText:null}:null}}function wI(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return Tr((r==null?void 0:r[1])??(r==null?void 0:r[2])??(r==null?void 0:r[3])??(r==null?void 0:r[4])??"")}const xI=new Set(["updateplan"]),fb=new Set(["todowrite"]),ru=new Set(["todoread"]),mb=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function xO(e,t){const n=CI(e,t);return n||NI(e,t)}function vI(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function SI(e,t,n){if(!e)return null;if(su(e.name)){const a=wi(e);if(!a||!yl(a.value))return null;const c=gb(a.value,n);return!c||c.items.length===0?null:{provider:t,source:"plan",explanation:c.explanation,items:c.items,updatedAt:n}}const r=kl(e.name);if(!fb.has(r)&&!ru.has(r)&&!mb.has(r))return null;const i=wi(e,(ru.has(r),"prefer-output"));if(!i)return null;if(r==="taskdelete"||r==="taskremove"){const a=bb(i.value);return a.length>0?{provider:t,source:"todo",explanation:null,items:a.map((c,u)=>({id:c,title:`Task ${u+1}`,status:"cancelled",detail:c,updatedAt:n})),updatedAt:n}:null}const o=Zi(i.value,n);return o.length===0?null:{provider:t,source:su(e.name)?"plan":"todo",explanation:null,items:o,updatedAt:n}}function CI(e,t){let n=null;for(const r of e){const i=r.toolCall;if(!i||kl(i.name)===""||!su(i.name))continue;const o=wi(i);if(!o||typeof o.value!="object"||o.value===null)continue;const a=gb(o.value,r.timestamp);!a||a.items.length===0||(n={provider:t,source:"plan",explanation:a.explanation,items:a.items,updatedAt:r.timestamp})}return n}function NI(e,t){const n=new Map;let r=null;for(const o of e){const a=o.toolCall;if(!a)continue;const c=kl(a.name);if(fb.has(c)){const h=wi(a),p=h?Zi(h.value,o.timestamp):[];p.length>0&&(kc(n,p),r=o.timestamp);continue}if(ru.has(c)){const h=wi(a,"prefer-output"),p=h?Zi(h.value,o.timestamp):[];p.length>0&&(kc(n,p),r=o.timestamp);continue}if(!mb.has(c))continue;const u=wi(a,"prefer-output");if(!u)continue;if(c==="tasklist"||c==="taskget"){const h=Zi(u.value,o.timestamp);h.length>0&&(kc(n,h),r=o.timestamp);continue}if(c==="taskdelete"||c==="taskremove"){const h=bb(u.value);if(h.length>0){for(const p of h)n.delete(p);r=o.timestamp}continue}const d=Zi(u.value,o.timestamp);if(d.length!==0){for(const h of d)TI(n,h);r=o.timestamp}}const i=Array.from(n.values()).sort((o,a)=>o.updatedAt.localeCompare(a.updatedAt)).map(o=>({...o}));return i.length===0||!r?null:{provider:t,source:"todo",explanation:null,items:i,updatedAt:r}}function su(e){return xI.has(kl(e))}function gb(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((i,o)=>kb(i,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${o+1}`,fallbackStatus:"pending",updatedAt:t})).filter(i=>i!==null);return r.length===0?null:{items:r,explanation:Ot(e.explanation)}}function wi(e,t="prefer-input"){const n=t==="prefer-output"?[{text:e.output,source:"output"},{text:e.input,source:"input"}]:[{text:e.input,source:"input"},{text:e.output,source:"output"}];for(const r of n){const i=jI(r.text);if(i!==null)return{value:i,source:r.source}}return null}function jI(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=oa(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const u=oa(r[1].trim());if(u!==null)return u}const i=t.indexOf("{"),o=t.lastIndexOf("}");if(i>=0&&o>i){const u=oa(t.slice(i,o+1));if(u!==null)return u}const a=t.indexOf("["),c=t.lastIndexOf("]");return a>=0&&c>a?oa(t.slice(a,c+1)):null}function oa(e){try{return JSON.parse(e)}catch{return null}}function Zi(e,t){return co(e).map((r,i)=>kb(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${i+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function co(e){if(Array.isArray(e))return e.flatMap(n=>co(n));if(!yl(e))return[];if(EI(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=co(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>co(n))}function bb(e){const n=co(e).map(i=>iu(i)).filter(i=>i!==null);if(n.length>0)return n;if(!yl(e))return[];const r=iu(e);return r?[r]:[]}function kb(e,t){if(!yl(e))return null;const n=Ot(e.step)??Ot(e.title)??Ot(e.content)??Ot(e.task)??Ot(e.text)??Ot(e.name)??Ot(e.subject)??Ot(e.description)??t.fallbackTitle,r=iu(e)??RI(t.fallbackIdPrefix,n),i=AI(e,n);return{id:r,title:n,status:II(e.status,t.fallbackStatus),detail:i,updatedAt:t.updatedAt}}function TI(e,t){const n=e.get(t.id);if(!n){e.set(t.id,{...t});return}e.set(t.id,{id:n.id,title:t.title||n.title,status:t.status,detail:t.detail??n.detail,updatedAt:t.updatedAt})}function kc(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function II(e,t){var r;const n=(r=Ot(e))==null?void 0:r.toLowerCase().replace(/[\s-]+/g,"_");return n?["pending","todo","open","queued","not_started","created"].includes(n)?"pending":["in_progress","progress","active","doing","running","started"].includes(n)?"in_progress":["completed","complete","done","success","succeeded","finished","closed"].includes(n)?"completed":["failed","error","errored"].includes(n)?"failed":["cancelled","canceled","aborted","skipped"].includes(n)?"cancelled":t:t}function AI(e,t){const n=[Ot(e.detail),Ot(e.details),Ot(e.description),Ot(e.reason),Ot(e.summary),Ot(e.note),Ot(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function iu(e){return Ot(e.id)??Ot(e.taskId)??Ot(e.task_id)??Ot(e.uuid)??Ot(e.key)}function RI(e,t){return`${e}:${t.trim().toLowerCase()}`}function EI(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>Ot(t)!==null)}function kl(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function yl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ot(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function PI({snapshot:e,toolName:t="",expanded:n=!1,exportMode:r=!1,className:i,children:o,onToggleExpanded:a}){const c=vI(e.items),u=n?l("conversation.taskCardRawCollapse"):l("conversation.taskCardRawExpand"),d=i?`tool-call-item task-tool-item ${i}`:"tool-call-item task-tool-item";return s.jsxs("div",{className:d,children:[s.jsxs("div",{className:"task-tool-header",children:[s.jsxs("div",{className:"task-tool-heading",children:[s.jsx("span",{className:"task-tool-badge",children:e.source==="plan"?l("conversation.taskCardPlanTitle"):l("conversation.taskCardTodoTitle")}),s.jsxs("div",{className:"task-tool-heading-main",children:[s.jsx("strong",{children:MI(e,t)}),s.jsx("span",{className:"task-tool-summary-text",children:LI(e.items,c)})]})]}),!r&&a?s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:a,children:u}):null]}),s.jsx("ol",{className:"task-tool-list",children:e.items.map(h=>s.jsxs("li",{className:"task-tool-list-item","data-status":h.status,children:[s.jsx("span",{className:"task-tool-item-indicator","data-status":h.status,"aria-hidden":"true"}),s.jsx("strong",{className:"task-tool-item-title",children:h.title}),h.detail?s.jsx("span",{className:"task-tool-item-detail",children:h.detail}):null,s.jsx("span",{className:"task-tool-item-status",children:DI(h.status)})]},h.id))}),o]})}function MI(e,t){if(e.source==="plan")return l("conversation.taskCardPlanUpdated");const n=t.trim().toLowerCase();return n==="taskcreate"||n==="todowrite"||n==="todoread"?l("conversation.taskCardTodoUpdated"):n.startsWith("task")?l("conversation.taskCardTodoUpdated"):l("conversation.taskCardTodoUpdated")}function LI(e,t){const n=[l("conversation.taskCardSummaryTotal",{count:e.length})];return t.in_progress>0&&n.push(l("conversation.taskCardSummaryInProgress",{count:t.in_progress})),t.pending>0&&n.push(l("conversation.taskCardSummaryPending",{count:t.pending})),t.completed>0&&n.push(l("conversation.taskCardSummaryCompleted",{count:t.completed})),t.failed>0&&n.push(l("conversation.taskCardSummaryFailed",{count:t.failed})),n.join(" / ")}function DI(e){switch(e){case"in_progress":return l("conversation.taskProgressStatusInProgress");case"completed":return l("conversation.taskProgressStatusCompleted");case"failed":return l("conversation.taskProgressStatusFailed");case"cancelled":return l("conversation.taskProgressStatusCancelled");case"pending":default:return l("conversation.taskProgressStatusPending")}}function OI(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("rect",{x:"7",y:"5",width:"9",height:"11",rx:"2.5"}),s.jsx("path",{d:"M5.5 12.5H5A2 2 0 0 1 3 10.5V5a2 2 0 0 1 2-2h5.5"})]})}function BI(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"6",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"14",r:"2.25"}),s.jsx("path",{d:"M8.4 5.7h2.2a2.7 2.7 0 0 1 2.7 2.7v1.2"}),s.jsx("path",{d:"M8.1 5.9l4.1 6.2"})]})}function vO(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M10 2.8l1.6 3.4 3.8.5-2.8 2.6.7 3.9-3.3-1.8-3.3 1.8.7-3.9-2.8-2.6 3.8-.5L10 2.8z"}),s.jsx("path",{d:"M15.8 13.3l.7 1.5 1.7.2-1.2 1.1.3 1.8-1.5-.8-1.5.8.3-1.8-1.2-1.1 1.7-.2.7-1.5z"})]})}function SO(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"14",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"10",cy:"14",r:"2.2"}),s.jsx("path",{d:"M8.2 5h3.6"}),s.jsx("path",{d:"M10 7.2v4.6"}),s.jsx("path",{d:"M7.3 6.8l1.7 4"}),s.jsx("path",{d:"M12.7 6.8l-1.7 4"})]})}function CO(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"4.5",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"10",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"15.5",cy:"10",r:"1.5"})]})}function NO(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M4.5 5.5h1.2"}),s.jsx("path",{d:"M8 5.5h7.5"}),s.jsx("path",{d:"M4.5 10h1.2"}),s.jsx("path",{d:"M8 10h7.5"}),s.jsx("path",{d:"M4.5 14.5h1.2"}),s.jsx("path",{d:"M8 14.5h7.5"}),s.jsx("path",{d:"M5.1 5.5l.5.5 1-1"}),s.jsx("circle",{cx:"5.1",cy:"10",r:".8",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M5.1 14.5l.5.5 1-1"})]})}const yb="codingns.user-app.conversation-scroll",ri=1,_I=200,WI=1e7;function wb(){return typeof window<"u"&&typeof window.localStorage<"u"}function xb(e){return e.trim()}function vb(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),WI)}function Sb(e){return!e||typeof e!="object"?null:{scrollTop:vb(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function Cb(){if(!wb())return{schemaVersion:ri,bySessionId:{}};const e=window.localStorage.getItem(yb);if(!e)return{schemaVersion:ri,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==ri||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:ri,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,i])=>{const o=Sb(i);return o?[r,o]:null}).filter(r=>!!r));return{schemaVersion:ri,bySessionId:n}}catch{return{schemaVersion:ri,bySessionId:{}}}}function FI(e){if(wb())try{window.localStorage.setItem(yb,JSON.stringify(e))}catch{}}function aa(e){const t=xb(e);if(!t)return null;const n=Cb().bySessionId[t],r=Sb(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function wp(e,t){const n=xb(e);if(!n)return;const r=Cb();r.bySessionId[n]={scrollTop:vb(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const i=Object.entries(r.bySessionId).sort((o,a)=>a[1].updatedAt-o[1].updatedAt).slice(0,_I);r.bySessionId=Object.fromEntries(i),FI(r)}const $I=5e3;let si=null;function zI(){var t;if(si!==null)return si;if(typeof document>"u")return si=0,si;const e=document.createElement("div");return e.dataset.scrollbarProbe="true",e.style.position="absolute",e.style.top="-9999px",e.style.width="120px",e.style.height="120px",e.style.overflow="scroll",e.style.visibility="hidden",e.style.pointerEvents="none",(t=document.body)==null||t.appendChild(e),si=Math.max(0,e.offsetWidth-e.clientWidth),e.remove(),si}function UI(e){if(zI()>0){e.dataset.scrollbarLayout="stable";return}e.removeAttribute("data-scrollbar-layout")}function ad(e){const t=f.useRef(null),n=e??t;return f.useEffect(()=>{const r=n.current;if(!r||typeof globalThis.window>"u")return;UI(r);let i=null;const o=()=>{i!==null&&(window.clearTimeout(i),i=null)},a=()=>{o(),r.removeAttribute("data-scrolling")},c=()=>{r.setAttribute("data-scrolling","true"),o(),i=window.setTimeout(()=>{r.removeAttribute("data-scrolling"),i=null},$I)},u=()=>{c()};return r.addEventListener("scroll",u,{passive:!0}),()=>{r.removeEventListener("scroll",u),a()}},[n]),n}function ld(e){var t,n;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((n=e.lastErrorDetail)!=null&&n.trim())}function HI(e,t,n){return`${e} is-${Nb(t,n)}`}function Nb(e,t){t==null||t.isActive;const n=KI(e);return t!=null&&t.hasSubagents?n==="error"?"error":n==="unread"?"subagent-unread":n==="running"||n==="running_inferred"?"subagent-running":"subagent":n==="running_inferred"?"running-inferred":n.replace("_","-")}function qI(e){return e.runningState==="stale"?l("conversation.runtimeStale"):e.runningState==="unknown"?l("conversation.runtimeUnknown"):null}function GI(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function jO(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function KI(e){return ld(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?VI(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function VI(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function YI(e){return ld(e)||e.syncStatus==="error"}function JI(e){if(!YI(e))return null;const t=QI(e.lastErrorCode),n=ZI(e.lastErrorDetail),r=XI(t,n,e.syncStatus);return{title:e.syncStatus==="error"&&!ld(e)?l("conversation.syncStatusError"):l("conversation.runtimeErrorTitle"),summary:r,code:t,detail:n}}function XI(e,t,n){return t||(n==="error"?l("conversation.syncStatusError"):e?l("conversation.runtimeErrorFallbackDetail"):l("conversation.runtimeErrorFallbackDetail"))}function QI(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}function ZI(e){const t=(e==null?void 0:e.replace(/\s+/g," ").trim())??"";return t.length>0?t:null}function eA(e){const t=e.messages.map(i=>({type:"message",key:i.id,message:i})),n=e.runtimeThinkingPlaceholder??null,r=JI({runningState:e.sessionRunningState??null,syncStatus:e.sessionSyncStatus??null,lastErrorCode:e.sessionLastErrorCode??null,lastErrorDetail:e.sessionLastErrorDetail??null});return n&&t.push({type:"runtime_thinking",key:`runtime-thinking:${n}`,label:n}),r&&t.push({type:"session_error",key:`session-error:${r.code??"none"}:${r.summary??"none"}`,error:r}),t}function tA(e){return e.flatMap(t=>t.type==="message"?[t.message]:[])}function nA(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if((n==null?void 0:n.type)==="runtime_thinking")return n.label}return null}function TO(e,t){const n=e.filter(o=>o.type!=="runtime_thinking");if(!t)return n;const r={type:"runtime_thinking",key:`runtime-thinking:${t}`,label:t},i=n.findIndex(o=>o.type==="session_error");return i<0?[...n,r]:[...n.slice(0,i),r,...n.slice(i)]}function rA(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function sA(e){const t=e.trim();if(!t)return[];const n=/\b(?:last status:\s*\d{3}\s+[A-Za-z][A-Za-z ]*|\d{3}\s+(?:Too Many Requests|Bad Gateway|Gateway Timeout|Service Unavailable|Unauthorized|Forbidden|Not Found|Internal Server Error))\b|\brequest id:\s*[A-Za-z0-9-]+\b/gi,r=[];let i=0;for(const o of t.matchAll(n)){const a=o.index??0,c=o[0];a>i&&r.push({type:"text",text:t.slice(i,a)}),r.push({type:/^request id:/i.test(c)?"request_id":"status_code",text:c}),i=a+c.length}return i<t.length&&r.push({type:"text",text:t.slice(i)}),r.filter(o=>o.text.length>0)}function jb(e){var r;const t=e.match(/^\s*<turn_aborted>([\s\S]*?)<\/turn_aborted>\s*$/i);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";return!n||/^previous turn aborted$/i.test(n)?{detail:null}:{detail:n}}function iA(e){return e==="user"?l("conversation.turnAbortedUser"):e==="runtime"?l("conversation.turnAbortedUnexpected"):l("conversation.turnAbortedGeneric")}const oA=480,xp=80,vp=240,aA=120,lA=18,cA=50,uA=3500,ou=f.createContext(!1);function Ci(e){return e.replace(/\\/g,"/")}function Ja(e){return/^[a-zA-Z]:\//.test(e)}function dA(e){return e.startsWith("/")||e.startsWith("//")||Ja(e)}function Tb(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Ja(e)}function au(e){return e.replace(/\/+$/,"")}function cd(e){const t=e.indexOf("#"),n=t>=0?e.slice(0,t):e,r=n.indexOf("?");return(r>=0?n.slice(0,r):n).replace(/:(\d+)(?::(\d+))?$/,"")}function Ib(e){const t=[];for(const n of Ci(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function wl(e){try{return decodeURIComponent(e)}catch{return e}}function lu(e,t){const n=wl(e).trim();if(!n||n.startsWith("#"))return null;let r=n;if(/^file:\/\//i.test(r))try{r=decodeURIComponent(new URL(r).pathname),/^\/[a-zA-Z]:\//.test(r)&&(r=r.slice(1))}catch{return null}else if(Tb(r))return null;if(r=Ci(cd(r.trim())),!r)return null;const i=au(Ci(t.trim()));if(!i)return null;if(dA(r)){const o=au(r),a=Ja(i)?i.toLowerCase():i,c=Ja(o)?o.toLowerCase():o;if(c===a)return null;const u=`${a}/`;return c.startsWith(u)?o.slice(i.length+1):null}return Ib(r)}function Ab(e){const t=wl(e).trim();if(!t||t.startsWith("#"))return null;let n=t;if(/^file:\/\//i.test(n))try{n=decodeURIComponent(new URL(n).pathname),/^\/[a-zA-Z]:\//.test(n)&&(n=n.slice(1))}catch{return null}else if(/^https?:\/\//i.test(n))try{n=decodeURIComponent(new URL(n).pathname)}catch{return null}else if(Tb(n))return null;const r=Ci(cd(n)),i=r.match(/(?:^|\/)office-artifacts\/[^/]+\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})-[^/]+$/i);if(!(i!=null&&i[1])){const o=r.match(/(?:^|\/)office-artifacts\/([^/]+)\/([^/]+)$/i);return!(o!=null&&o[1])||!(o!=null&&o[2])?null:{kind:"task_file",taskId:o[1],fileName:o[2]}}return{kind:"artifact",artifactId:i[1]}}function hA(e){if(e.name.trim()!=="view_image")return null;const t=xl(e.input);return(t?Eb(t,"path").trim():"")||null}function Sp(e){return Ci(e).split("/").filter(Boolean).at(-1)??e}function pA(e,t){const n=hA(e);if(!n)return null;const r=Ab(n);if(r)return{previewTarget:r.kind==="artifact"?{kind:"office_artifact",artifactId:r.artifactId}:{kind:"office_task_file",taskId:r.taskId,fileName:r.fileName},displayPath:n,fileName:Sp(n)};const i=t?lu(n,t):Ib(cd(n));return{previewTarget:i?{kind:"workspace_file",relativePath:i}:null,displayPath:i??n,fileName:Sp(n)}}function cu(e,t,n){var r;if(e&&!n&&typeof window<"u"&&((r=window.location)!=null&&r.origin))return new URL(e,window.location.origin).toString();if(e&&n)try{const i=Zf(Su()).baseUrl;return fy(e,i)}catch{return t}return t}function ud(e){return e.kind==="tool_call"||e.kind==="tool_result"}function Rb(e){return e.toolCall?e.toolCall:ud(e)?{callId:e.rawRef||e.id,name:"tool",input:e.kind==="tool_call"?e.content:"",output:e.kind==="tool_result"&&e.content?e.content:null,error:null,status:e.kind==="tool_call"?"running":"completed"}:null}function fA(e){return e==="shell_command"||e==="tool"?l("conversation.roleTool"):e}function xl(e){if(!e.trim())return null;try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function Eb(e,t){const n=e[t];return typeof n=="string"?n:""}function ii(e,t){for(const n of t){const r=Eb(e,n);if(r)return r}return""}function ko(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function tn(e,t){if(!e)return null;const n=e[t];return ko(n)?n:null}function yc(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function vt(e,t){if(!e)return null;const n=e[t];if(typeof n=="string"){const r=n.trim();return r||null}return typeof n=="number"||typeof n=="boolean"?String(n):null}function mA(e){const t=[e.output,e.input];for(const n of t){const r=Pb(n,0);if(r)return r}return null}function Pb(e,t){if(!(e!=null&&e.trim())||t>2)return null;try{return Mb(JSON.parse(e),t)}catch{return null}}function Mb(e,t){if(!ko(e))return null;if(gA(e))return{ok:!0,capability:vt(e,"capability")??"",auditId:vt(e,"auditId")??"",timestamp:vt(e,"timestamp")??"",targetRef:{kind:vt(tn(e,"targetRef"),"kind")??"none",id:vt(tn(e,"targetRef"),"id")},payload:tn(e,"payload")??{}};const n=["output","result","data","payload"];for(const r of n){const i=e[r];if(typeof i=="string"){const o=Pb(i,t+1);if(o)return o}if(ko(i)){const o=Mb(i,t+1);if(o)return o}}return null}function gA(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&ko(e.targetRef)&&ko(e.payload)}function bA(e){const t=new Map,n=new Map,r=new Map;return e.forEach(i=>{t.set(i.workspace.id,i.workspace.name),i.sessions.forEach(o=>{const a=typeof o.title=="string"&&o.title.trim()?o.title.trim():o.sessionId;n.set(o.sessionId,a),r.set(o.sessionId,i.workspace.id)})}),{workspaceNamesById:t,sessionNamesById:n,sessionWorkspaceIdsById:r}}function kA(e,t){const n=mA(e);return n?{...Db(n.capability),rows:IA(n,t)}:null}function yA(e,t){const n=wA(e);if(!n)return null;const r=xA(n);return r?{...CA(r),rows:TA(r,t)}:null}function wA(e){const t=xl(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(!n)return null;const r=n.indexOf("codingns assistant");return r<0?null:n.slice(r).trim()}function xA(e){const t=vA(e),n=t.findIndex((h,p)=>h==="codingns"&&t[p+1]==="assistant");if(n<0)return null;const r=t.slice(n+2);if(r.length===0||r[0]==="--help"||r[0]==="-h")return{group:null,action:null,mode:"help",options:{},positionals:[]};if(r[0]==="help")return{group:r[1]??null,action:r[2]??null,mode:"help",options:{},positionals:[]};const i=r[0]??null,o=r[1],a=o&&!o.startsWith("-")?o:null,c=r.slice(a?2:1),{options:u,positionals:d}=SA(c);return!a&&u["--help"]?{group:i,action:null,mode:"help",options:u,positionals:d}:{group:i,action:a,mode:"execute",options:u,positionals:d}}function vA(e){const t=[],n=/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`|\S+/g;for(const r of e.matchAll(n)){const i=r[0]??"";if(!i)continue;const o=i[0];if((o==='"'||o==="'"||o==="`")&&i[i.length-1]===o){t.push(i.slice(1,-1));continue}t.push(i)}return t}function SA(e){const t={},n=[];for(let r=0;r<e.length;r+=1){const i=e[r]??"";if(!i.startsWith("--")){n.push(i);continue}const o=e[r+1];if(!o||o.startsWith("--")){t[i]=!0;continue}t[i]=o,r+=1}return{options:t,positionals:n}}function CA(e){if(e.mode==="help")return NA(e.group,e.action);const t=jA(e.group,e.action);return t?Db(t):{kind:dd(e.group),badge:Lb(e.group),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCliSummaryCommand")}}function NA(e,t){return e?e==="sessions"?{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:t?l("conversation.assistantCliHelpSessionActionTitle",{action:t}):l("conversation.assistantCliHelpSessionsTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="timers"?{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCliHelpTimersTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="terminals"?{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCliHelpTerminalsTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="workspaces"||e==="worktrees"?{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCliHelpWorkspacesTitle"),summary:l("conversation.assistantCliSummaryHelp")}:{kind:dd(e),badge:Lb(e),title:l("conversation.assistantCliHelpGenericTitle",{group:e}),summary:l("conversation.assistantCliSummaryHelp")}:{kind:"query",badge:l("conversation.assistantCapabilityBadgeQuery"),title:l("conversation.assistantCliHelpRootTitle"),summary:l("conversation.assistantCliSummaryHelp")}}function jA(e,t){const n=e==null?void 0:e.trim(),r=t==null?void 0:t.trim();return n?n==="capabilities"&&r==="list"?"capabilities.list":n==="projects"&&r==="list"?"projects.list":n==="projects"&&r==="get"?"projects.get":n==="sessions"&&r==="list"?"projects.sessions.list":n==="sessions"&&r==="get"?"sessions.get":n==="sessions"&&r==="messages"?"sessions.messages.list":n==="sessions"&&r==="runtime"?"sessions.runtime.get":n==="sessions"&&r==="start"?"projects.sessions.start":n==="sessions"&&r==="send"?"sessions.message.send":n==="sessions"&&r==="fork"?"sessions.fork":n==="timers"&&r==="create"?"timers.create":n==="timers"&&r==="cancel"?"timers.cancel":n==="timers"&&r==="list"?"timers.list":n==="terminals"&&r==="send"?"terminals.input.send":n==="terminals"&&r==="close"?"terminals.close":n==="terminals"&&r==="history"?"terminals.history.read":n==="terminals"&&r==="list"?"terminals.list":n==="workspaces"&&r==="list"?"workspaces.list":n==="workspaces"&&r==="clone"?"workspaces.clone":n==="workspaces"&&r==="import"?"workspaces.import":n==="workspaces"&&r==="management"?"workspaces.management.get":n==="worktrees"&&r==="tree"?"worktrees.tree":n==="worktrees"&&r==="create"?"worktrees.create":null:null}function dd(e){switch(e){case"sessions":case"projects":return"session";case"timers":return"automation";case"terminals":return"terminal";case"workspaces":case"worktrees":return"workspace";case"debug-targets":case"debug-runtimes":return"debug";default:return"query"}}function Lb(e){switch(dd(e)){case"session":return l("conversation.assistantCapabilityBadgeSession");case"automation":return l("conversation.assistantCapabilityBadgeAutomation");case"terminal":return l("conversation.assistantCapabilityBadgeTerminal");case"workspace":return l("conversation.assistantCapabilityBadgeWorkspace");case"debug":return l("conversation.assistantCapabilityBadgeDebug");case"query":default:return l("conversation.assistantCapabilityBadgeQuery")}}function TA(e,t){const n=[],r=oi(e,"--session-id")??e.positionals[0]??null,i=oi(e,"--project")??oi(e,"--project-id");return e.mode==="help"?(Ke(n,l("conversation.assistantCliLabelScope"),e.group??l("conversation.assistantCliScopeRoot")),Ke(n,l("conversation.assistantCliLabelAction"),e.action),n):(e.group==="sessions"&&Ke(n,l("conversation.assistantCapabilityLabelSession"),Rs(r,null,t)),e.group==="timers"&&(Ke(n,l("conversation.assistantCapabilityLabelSession"),Rs(r,null,t)),Ke(n,l("conversation.assistantCliLabelDelay"),oi(e,"--after-seconds"))),e.group==="terminals"&&Ke(n,l("conversation.assistantCapabilityLabelTerminal"),e.positionals[0]??null),(e.group==="workspaces"||e.group==="worktrees")&&Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),os(e.positionals[0]??null,null,t)),Ke(n,l("conversation.assistantCliLabelProject"),i),Ke(n,l("conversation.assistantCliLabelMessage"),oi(e,"--message")),Ke(n,l("conversation.assistantCliLabelInput"),oi(e,"--input")),n.slice(0,4))}function oi(e,t){const n=e.options[t];return typeof n=="string"?n:null}function Db(e){switch(e){case"projects.sessions.start":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilityProjectSessionStartTitle"),summary:l("conversation.assistantCapabilitySummarySessionStart")};case"sessions.message.send":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionSendTitle"),summary:l("conversation.assistantCapabilitySummarySessionSend")};case"sessions.fork":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionForkTitle"),summary:l("conversation.assistantCapabilitySummarySessionFork")};case"timers.create":return{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityTimerCreateTitle"),summary:l("conversation.assistantCapabilitySummaryTimerCreate")};case"timers.cancel":return{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityTimerCancelTitle"),summary:l("conversation.assistantCapabilitySummaryTimerCancel")};case"terminals.input.send":return{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalInputTitle"),summary:l("conversation.assistantCapabilitySummaryTerminalInput")};case"terminals.close":return{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalCloseTitle"),summary:l("conversation.assistantCapabilitySummaryTerminalClose")};case"workspaces.directory.create":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceDirectoryCreateTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.import":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceImportTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.clone":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceCloneTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.navigation-state.update":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceNavigationUpdateTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.remove":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceRemoveTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"worktrees.create":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeCreateTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.merge-into-parent":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeMergeTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.cleanup":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeCleanupTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"debug-targets.run":return{kind:"debug",badge:l("conversation.assistantCapabilityBadgeDebug"),title:l("conversation.assistantCapabilityDebugRunTitle"),summary:l("conversation.assistantCapabilitySummaryDebug")};default:return e.startsWith("sessions.")||e.startsWith("projects.")?{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("timers.")?{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityAutomationReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("terminals.")?{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("workspaces.")||e.startsWith("worktrees.")?{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("debug-targets.")||e.startsWith("debug-runtimes.")?{kind:"debug",badge:l("conversation.assistantCapabilityBadgeDebug"),title:l("conversation.assistantCapabilityDebugReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:{kind:"query",badge:l("conversation.assistantCapabilityBadgeQuery"),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}}}function IA(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const i=tn(r,"session");Ke(n,l("conversation.assistantCapabilityLabelSession"),Rs(vt(i,"sessionId"),vt(i,"title"),t)),Ke(n,l("conversation.assistantCapabilityLabelProvider"),vt(i,"provider"));break}case"sessions.message.send":{const i=tn(r,"result");Ke(n,l("conversation.assistantCapabilityLabelSession"),Rs(e.targetRef.id,null,t)),Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),Ob(e.targetRef.id,t)),Ke(n,l("conversation.assistantCapabilityLabelStatus"),l("conversation.assistantCapabilityStatusCompleted")),Ke(n,l("conversation.assistantCapabilityLabelDueAt"),Cp(vt(i,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const i=tn(r,"session");Ke(n,l("conversation.assistantCapabilityLabelSession"),Rs(vt(i,"sessionId"),vt(i,"title"),t)),Ke(n,l("conversation.assistantCapabilityLabelProvider"),vt(i,"provider"));break}case"timers.create":case"timers.cancel":{const i=tn(r,"timer"),o=tn(i,"controlSession"),a=tn(o,"session");Ke(n,l("conversation.assistantCapabilityLabelTimer"),vt(i,"title")),Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),os(vt(a,"workspaceId"),null,t)),Ke(n,l("conversation.assistantCapabilityLabelSession"),Rs(vt(i,"targetSessionId"),null,t)),Ke(n,l("conversation.assistantCapabilityLabelDueAt"),Cp(vt(i,"dueAt"))),Ke(n,l("conversation.assistantCapabilityLabelStatus"),EA(vt(i,"status")));break}case"terminals.input.send":case"terminals.close":Ke(n,l("conversation.assistantCapabilityLabelTerminal"),e.targetRef.id);break;case"workspaces.directory.create":{const i=tn(r,"result");Ke(n,l("conversation.assistantCapabilityLabelPath"),vt(i,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const i=tn(r,"workspace");Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),os(vt(i,"id")??e.targetRef.id,vt(i,"name"),t)),Ke(n,l("conversation.assistantCapabilityLabelPath"),vt(i,"path"));break}case"workspaces.navigation-state.update":{const i=tn(r,"state");Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),os(vt(i,"workspaceId")??e.targetRef.id,null,t)),Ke(n,l("conversation.assistantCapabilityLabelStatus"),vt(i,"collapsed")==="true"?l("conversation.assistantCapabilityNavigationCollapsed"):l("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const i=tn(r,"result"),o=tn(i,"workspace");Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),os(vt(o,"id")??e.targetRef.id,vt(o,"name"),t)),Ke(n,l("conversation.assistantCapabilityLabelBranch"),vt(i,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const i=tn(r,"result");Ke(n,l("conversation.assistantCapabilityLabelWorkspace"),os(e.targetRef.id,null,t)),Ke(n,l("conversation.assistantCapabilityLabelStatus"),vt(i,"status"));break}case"debug-targets.run":{const i=tn(r,"result");Ke(n,l("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),Ke(n,l("conversation.assistantCapabilityLabelRuntime"),vt(i,"runtimeId"));break}}return AA(n,e,t),n.slice(0,4)}function AA(e,t,n){t.targetRef.kind==="session"&&(Ke(e,l("conversation.assistantCapabilityLabelSession"),Rs(t.targetRef.id,null,n)),Ke(e,l("conversation.assistantCapabilityLabelWorkspace"),Ob(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&Ke(e,l("conversation.assistantCapabilityLabelWorkspace"),os(t.targetRef.id,null,n)),t.targetRef.kind==="terminal"&&Ke(e,l("conversation.assistantCapabilityLabelTerminal"),t.targetRef.id),t.targetRef.kind==="timer"&&Ke(e,l("conversation.assistantCapabilityLabelTimer"),t.targetRef.id);const r=RA(t.payload);r!==null&&Ke(e,l("conversation.assistantCapabilityLabelCount"),String(r))}function Ke(e,t,n){const r=n==null?void 0:n.trim();r&&(e.some(i=>i.label===t)||e.push({label:t,value:r}))}function Rs(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const i=e==null?void 0:e.trim();return i?n.sessionNamesById.get(i)??i:null}function os(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const i=e==null?void 0:e.trim();return i?n.workspaceNamesById.get(i)??i:null}function Ob(e,t){const n=e==null?void 0:e.trim();return n?os(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function RA(e){const t=yc(e,"items");if(t)return t.length;const n=tn(e,"page"),r=yc(n,"items");if(r)return r.length;const i=tn(e,"history"),o=yc(i,"items");return o?o.length:null}function Cp(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n)):t}function EA(e){switch(e){case"active":return l("conversation.assistantCapabilityStatusActive");case"completed":return l("conversation.assistantCapabilityStatusCompleted");case"cancelled":return l("conversation.assistantCapabilityStatusCancelled");case"failed":return l("conversation.assistantCapabilityStatusFailed");default:return e}}function PA({kind:e}){switch(e){case"session":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M5 7.5A2.5 2.5 0 0 1 7.5 5h9A2.5 2.5 0 0 1 19 7.5v5A2.5 2.5 0 0 1 16.5 15H11l-4 4v-4H7.5A2.5 2.5 0 0 1 5 12.5z"})});case"automation":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"7.5"}),s.jsx("path",{d:"M12 8.5v4.2l2.8 1.8"})]});case"terminal":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"m7 8 3.5 3.5L7 15"}),s.jsx("path",{d:"M13 15h4"}),s.jsx("rect",{x:"4.5",y:"5.5",width:"15",height:"13",rx:"2.5"})]});case"workspace":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M4.5 8.5A2.5 2.5 0 0 1 7 6h3l1.5 1.5H17A2.5 2.5 0 0 1 19.5 10v6A2.5 2.5 0 0 1 17 18.5H7A2.5 2.5 0 0 1 4.5 16z"})});case"debug":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M9 4.5h6"}),s.jsx("path",{d:"M10 8h4a4 4 0 0 1 4 4v1a6 6 0 0 1-12 0v-1a4 4 0 0 1 4-4Z"}),s.jsx("path",{d:"M4.5 11h3M16.5 11h3M5.5 7.5l2 1.5M18.5 7.5l-2 1.5"})]});case"query":default:return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"11",cy:"11",r:"5.5"}),s.jsx("path",{d:"m16 16 3.5 3.5"})]})}}function MA(e){if(e.name==="apply_patch"){const c=mp(e.input);if(c)return c;const u=QT(e.output||e.error||""),d=XT(e.input,u);return d?mp(d):null}const t=e.name.trim().toLowerCase(),n=LA(t);if(!n)return null;const r=xl(e.input);if(!r)return null;const i=ii(r,["file_path","filePath","path"]);if(!i)return null;if(n==="write"){const c=ii(r,["content","new_content","newContent"]),u=c.length>0?c.split(/\r?\n/):[];return{files:[{path:i,nextPath:null,action:"add",additions:u.length,deletions:0,statsKnown:!0,lines:u.map((d,h)=>({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:h+1}))}],totalAdditions:u.length,totalDeletions:0}}if(n==="edit"){const c=ii(r,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),u=ii(r,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/);return Np(i,[{oldLines:c,newLines:u}])}const a=(Array.isArray(r.edits)?r.edits:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;const u=c;return{oldLines:ii(u,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),newLines:ii(u,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/)}}).filter(c=>!!c);return a.length>0?Np(i,a):null}function LA(e){return e==="write"||e==="overwrite"?"write":e==="edit"?"edit":e==="multiedit"||e==="multi_edit"?"multiedit":null}function Np(e,t){const n=[];let r=0,i=0;return t.forEach((o,a)=>{n.push({kind:"hunk",text:`@@ -1,${o.oldLines.length} +1,${o.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),o.oldLines.forEach((c,u)=>{c.length===0&&o.oldLines.length===1&&o.newLines.length>0||(i+=1,n.push({kind:"remove",text:`-${c}`,oldLineNumber:u+1,newLineNumber:null}))}),o.newLines.forEach((c,u)=>{c.length===0&&o.newLines.length===1&&o.oldLines.length>0||(r+=1,n.push({kind:"add",text:`+${c}`,oldLineNumber:null,newLineNumber:u+1}))}),a<t.length-1&&n.push({kind:"meta",text:"***",oldLineNumber:null,newLineNumber:null})}),{files:[{path:e,nextPath:null,action:"update",additions:r,deletions:i,statsKnown:!0,lines:n}],totalAdditions:r,totalDeletions:i}}function DA(e){const t=xl(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(n)return`${l("conversation.toolPreviewCommand")}:${n}`;if(e.name==="read_thread_terminal")return l("conversation.toolPreviewTerminal");const r=e.input||e.error||e.output||l("conversation.toolResultEmpty");return r.length>60?`${r.slice(0,60)}...`:r}function jp(e){var o;const t=e.map(a=>({message:a,tool:Rb(a)})).filter(a=>!!a.tool);if(t.length===0)return null;const n={...t[0].tool};let r=!1,i=!1;for(const{message:a,tool:c}of t)a.kind==="tool_call"&&(r=!0,!n.input&&c.input&&(n.input=c.input)),a.kind==="tool_result"&&(i=!0,n.output=c.output,n.error=c.error,n.status=c.status,!n.input&&c.input&&(n.input=c.input)),!n.name&&c.name&&(n.name=c.name);return{key:t.map(({message:a})=>a.id).join(":"),messageIds:t.map(({message:a})=>a.id),tool:n,hasRequest:r,hasResult:i,updatedAt:((o=t.at(-1))==null?void 0:o.message.timestamp)??t[0].message.timestamp}}function OA(e){const t=[];let n=[],r=null;function i(){if(n.length===0)return;const o=jp(n);o&&t.push(o),n=[],r=null}for(const o of e){const a=Rb(o),c=(a==null?void 0:a.callId.trim())??"";if(!a||c.length===0){i();const u=jp([o]);u&&t.push(u);continue}if(n.length===0){n=[o],r=c;continue}if(r===c){n.push(o);continue}i(),n=[o],r=c}return i(),t}function BA(e,t){const n=[],r=[];let i=0;function o(){if(r.length===0)return;const a=OA(r);if(a.length===0){const c=r[0];c&&n.push({type:"message",key:c.id,message:c}),r.length=0;return}a.forEach(c=>{n.push({type:"tool_group",key:c.key,group:c})}),r.length=0}for(const a of e){if(a.type!=="message"){o(),n.push(a);continue}const c=a.message,u=i;if(i+=1,!_b(t,u)){if(!ud(c)){o(),n.push({type:"message",key:c.id,message:c});continue}r.push(c)}}return o(),n}function _A(e,t){var c;if(!e||e.forkSourceType!=="message"||typeof e.inheritedPrefixMessageCount!="number"||e.inheritedPrefixMessageCount<0)return{visibleItems:t,visibleMessages:t.flatMap(u=>u.type==="message"?[u.message]:[]),hiddenMessageIds:[]};const n=((c=e.createdAt)==null?void 0:c.trim())||"";if(n.length===0)return{visibleItems:t,visibleMessages:t.flatMap(u=>u.type==="message"?[u.message]:[]),hiddenMessageIds:[]};const r=Math.max(0,e.inheritedPrefixMessageCount),i=[],o=[],a=[];for(const u of t){if(u.type!=="message"){i.push(u);continue}const d=u.message;if(d.sequence<=r||d.timestamp>=n){i.push(u),o.push(d);continue}a.push(d.id)}return{visibleItems:i,visibleMessages:o,hiddenMessageIds:a}}function Bb(e){const t=_A(e.sessionSummary,e.items),n=BA(t.visibleItems,t.visibleMessages),r=HA(t.visibleMessages,e.provider),i=dR(t.visibleMessages);return{visibleMessages:t.visibleMessages,renderItems:n,leadingSystemPromptMessageIds:r,actionStateByMessageId:i,hiddenMessageIds:t.hiddenMessageIds,validationIssues:WA(t.visibleMessages,n)}}function WA(e,t){const n=[],r=t.map(u=>u.key),i=FA(r);i.length>0&&n.push(`duplicate_render_keys:${i.join(",")}`);const o=[];for(const u of t){if(u.type==="message"){o.push(u.message.id);continue}u.type==="tool_group"&&o.push(...u.group.messageIds)}const a=new Set(o);for(const u of e)Tp(e,u.id)&&!a.has(u.id)&&n.push(`missing_render_message:${u.id}`);const c=e.filter(u=>Tp(e,u.id)).map(u=>u.id);return o.join(",")!==c.join(",")&&n.push("render_order_mismatch"),n}function Tp(e,t){const n=e.findIndex(r=>r.id===t);return n<0?!1:!_b(e,n)}function FA(e){const t=new Map;for(const n of e)t.set(n,(t.get(n)??0)+1);return Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n)}function _b(e,t){const n=e[t];if(!n||jb(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const i=e[r];if(!(!i||ud(i)))return i.role==="user"}return!1}function $A(e,t){if(!hS(null,e))return!1;const n=t.trim();return/AGENTS\.md instructions for/i.test(n)&&/<INSTRUCTIONS>/i.test(n)&&/<\/INSTRUCTIONS>/i.test(n)}function zA(e,t){if(e!=="claude-code")return!1;const n=t.trim();return/Base directory for this skill:/i.test(n)&&/^#\s+.+/im.test(n)&&/\bARGUMENTS:/i.test(n)}function UA(e,t){if(e==="skill_context"){const r=t.split(/\r?\n/).map(i=>i.trim()).find(i=>/^#\s+/.test(i));if(r)return r.replace(/^#+\s*/,"")}const n=t.split(/\r?\n/).map(r=>r.trim()).find(Boolean);return n?n.replace(/^#+\s*/,""):l("conversation.rulesMessageTitle")}function HA(e,t){const n=new Set;if(t!=="kimi")return n;for(const r of e){if(r.role==="system"&&r.kind==="text"){n.add(r.id);continue}break}return n}function qA(e){const t=[];for(const n of e){if(n.type==="message"){t.push(n.message.id);continue}n.type==="tool_group"&&t.push(...n.group.messageIds)}return t}function GA(e,t,n){if(!e)return[];const r=new Set(n.filter(u=>u.role==="assistant").map(u=>u.id));if(r.size===0)return[];const i=new Map(e.map((u,d)=>[u,d])),o=new Map(t.map((u,d)=>[u,d])),a=new Map(n.map(u=>[u.id,u])),c=[];for(const u of r){const d=i.get(u)??null,h=o.get(u)??null;if(d===h)continue;const p=a.get(u)??null;c.push({messageId:u,fromIndex:d,toIndex:h,sequence:(p==null?void 0:p.sequence)??null,rawRef:(p==null?void 0:p.rawRef)??null,timestamp:(p==null?void 0:p.timestamp)??null})}return c.slice(0,8)}function yo(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>yo(n)).join(""):e&&typeof e=="object"&&"props"in e?yo(((t=e.props)==null?void 0:t.children)??""):""}function KA(e){const t=Array.isArray(e)?e[0]:e;if(!f.isValidElement(t))return null;const n=t.props,r=typeof n.className=="string"?n.className:"",i=/language-([^\s]+)/.exec(r);return{content:yo(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(i==null?void 0:i[1])??null}}function VA(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function hd(e,t){var n;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!VA(e))throw new Error(l("conversation.copyContentFailed"))}}function YA({className:e,children:t,onCopy:n,exportMode:r=!1}){const i=f.useContext(ou),o=yo(t).trim();if(r||i||!o)return s.jsx("code",{className:e||void 0,children:t});function a(c){c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),n(o))}return s.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":l("conversation.copyAction"),onClick:()=>n(o),onKeyDown:a,children:t})}function JA({href:e,children:t,className:n,onInteract:r,exportMode:i=!1}){if(i)return s.jsx(ou.Provider,{value:!0,children:s.jsx("a",{href:e,className:n,children:t})});const o=yo(t).trim()||(e?wl(e).trim():"");return s.jsx(ou.Provider,{value:!0,children:s.jsx("a",{href:e,className:[n,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:a=>{a.preventDefault(),r(e,o)},children:t})})}function Wb({language:e,codeClassName:t,content:n,exportMode:r=!1}){const{showToast:i}=ar(),o=Pn(),a=(e==null?void 0:e.trim().toLowerCase())??null,c=a==="text",u=a||"code";async function d(){try{await hd(n,o),i({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(h){i({title:h instanceof Error?h.message:l("conversation.copyContentFailed"),tone:"error"})}}return s.jsxs("div",{className:`code-block${c?" text-code-block":""}`,children:[s.jsxs("div",{className:"code-header",children:[s.jsx("span",{className:"code-header-label",children:u}),r?null:s.jsx("button",{className:"code-copy-button",type:"button",onClick:()=>void d(),children:l("conversation.copyAction")})]}),s.jsx("pre",{className:t,children:s.jsx("code",{children:n})})]})}function eo({content:e,className:t,exportMode:n=!1}){const{showToast:r}=ar(),i=Pn(),{navigationGroups:o,currentWorkspaceId:a,revealWorkspaceFile:c}=ey(),[u,d]=f.useState({}),h=f.useMemo(()=>{var k;return((k=o.find(S=>S.workspace.id===a))==null?void 0:k.workspace)??null},[a,o]),p=h!=null&&h.path?au(Ci(h.path.trim())):null;f.useEffect(()=>{const S=Array.from(e.matchAll(/!\[[^\]]*]\(([^)\s]+(?:\s+"[^"]*")?)\)|<img\b[^>]*src=["']([^"']+)["'][^>]*>/gi)).map(F=>(F[1]??F[2]??"").trim()).filter(F=>F.length>0);if(S.length===0){d({});return}const v=Array.from(new Map(S.map(F=>{const E=F.replace(/^<|>$/g,"").replace(/\s+"[^"]*"$/,"");if(!E||E.startsWith("#"))return null;const I=Ab(E);return I?[E,I]:null}).filter(F=>F!==null))),w=new Set(v.map(([F])=>F)),R=Array.from(new Map(S.map(F=>{const E=F.replace(/^<|>$/g,"").replace(/\s+"[^"]*"$/,"");if(!E||E.startsWith("#")||w.has(E)||/^data:image\//i.test(E)||/^https?:\/\//i.test(E)||!a||!p)return null;const I=lu(E,p);return I?[E,I]:null}).filter(F=>F!==null)).entries()).map(([F,E])=>({sourceUrl:F,relativePath:E}));let T=!1;return Promise.all([...v.map(async([F,E])=>{try{const I=E.kind==="artifact"?await Cm(E.artifactId):await Nm(E.taskId,E.fileName),q=cu(I.previewPath,I.previewUrl,i.isDesktop);return q?[F,q]:null}catch{return null}}),...R.map(async F=>{try{if(!a)return null;const E=await jm(a,F.relativePath),I=cu(E.previewPath,E.previewUrl,i.isDesktop);return I?[F.sourceUrl,I]:null}catch{return null}})]).then(F=>{T||d(Object.fromEntries([...F.filter(E=>E!==null)]))}),()=>{T=!0}},[e,a,p,i.isDesktop]);async function g(k){if(k.trim())try{await hd(k,i),r({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(S){r({title:S instanceof Error?S.message:l("conversation.copyContentFailed"),tone:"error"})}}function m(k,S){const v=k&&(h!=null&&h.path)?lu(k,h.path):null;v&&c({workspaceId:(h==null?void 0:h.id)??a,filePath:v,openViewer:!1})||g(S||(k?wl(k).trim():""))}return s.jsx("div",{className:t,children:s.jsx(S1,{remarkPlugins:[OT],components:{p:({node:k,...S})=>s.jsx("p",{...S}),a(k){return s.jsx(JA,{href:typeof k.href=="string"?k.href:void 0,className:typeof k.className=="string"?k.className:void 0,onInteract:m,exportMode:n,children:k.children})},img(k){const S=typeof k.src=="string"?k.src.trim():"",v=u[S]??S,w=typeof k.alt=="string"?k.alt:"";return v?s.jsx("img",{src:v,alt:w,className:"message-markdown-image",loading:"lazy",decoding:"async"}):null},pre(k){const S=KA(k.children);return S?s.jsx(Wb,{language:S.language,codeClassName:S.codeClassName,content:S.content,exportMode:n}):s.jsx("pre",{children:k.children})},code(k){const S=typeof k.className=="string"?k.className:"";return s.jsx(YA,{className:S||void 0,exportMode:n,onCopy:v=>{g(v)},children:k.children})}},children:e})})}function Ip(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function XA(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function la({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return s.jsx(QA,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function QA({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){const[i,o]=f.useState({}),[a,c]=f.useState(null),u=f.useMemo(()=>n.map((g,m)=>{const k=Ip(g,t==null?void 0:t[m]);if(k)return{id:g.id,kind:g.kind,fileName:g.fileName,fileSize:g.fileSize,url:k,status:"ready"};const S=i[g.id];return{id:g.id,kind:g.kind,fileName:g.fileName,fileSize:g.fileSize,url:(S==null?void 0:S.url)??null,status:(S==null?void 0:S.status)??(e?"loading":"error")}}),[t,n,i,e]),d=f.useMemo(()=>r.map((g,m)=>({id:`inline-image-${m}`,kind:"image",fileName:g.altText||`${l("conversation.imageAttachmentLabel")} ${m+1}`,fileSize:g.estimatedBytes,url:g.url,status:"ready"})),[r]),h=f.useMemo(()=>[...d,...u],[u,d]),p=h.find(g=>g.id===a)??null;return f.useEffect(()=>{if(!a)return;function g(m){m.key==="Escape"&&c(null)}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[a]),f.useEffect(()=>{const g=n.filter((S,v)=>!Ip(S,t==null?void 0:t[v]));if(!e||g.length===0){o({});return}let m=!1;const k=[];return o(Object.fromEntries(g.map(S=>[S.id,{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"loading"}]))),Promise.all(g.map(async S=>{try{const v=await ow(e,S.id),w=URL.createObjectURL(v);return k.push(w),{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:w,status:"ready"}}catch{return{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"error"}}})).then(S=>{if(m){k.forEach(v=>URL.revokeObjectURL(v));return}o(Object.fromEntries(S.map(v=>[v.id,v])))}),()=>{m=!0,k.forEach(S=>URL.revokeObjectURL(S))}},[t,n,e]),h.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-attachments",children:h.map(g=>{const m=g.kind==="image",k=g.status==="loading"?l("conversation.attachmentPreviewLoading"):g.status==="error"?l("conversation.attachmentPreviewUnavailable"):m?l("conversation.attachmentPreviewOpen"):l("conversation.attachmentDownload"),S=XA(g.fileSize),v=s.jsx("div",{className:"message-attachment-card",children:m?g.url?s.jsx("img",{className:"message-attachment-thumbnail",src:g.url,alt:g.fileName||l("conversation.attachmentPreviewAlt"),loading:"lazy"}):s.jsx("div",{className:"message-attachment-placeholder","aria-hidden":"true",children:g.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")}):s.jsxs("div",{className:"message-attachment-file-card",children:[s.jsx("div",{className:"message-attachment-file-icon","aria-hidden":"true",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),s.jsx("path",{d:"M14 2v5h5"}),s.jsx("path",{d:"M9 13h6"}),s.jsx("path",{d:"M9 17h6"})]})}),s.jsxs("div",{className:"message-attachment-file-meta",children:[s.jsx("strong",{title:g.fileName,children:g.fileName}),s.jsx("span",{children:S??l("conversation.fileAttachmentLabel")})]})]})});return!m&&g.url?s.jsx("a",{className:"message-attachment-button",href:g.url,download:g.fileName,"aria-label":`${g.fileName} - ${k}`,title:k,children:v},g.id):s.jsx("button",{type:"button",className:"message-attachment-button",onClick:()=>m&&g.url&&c(g.id),disabled:!g.url,"aria-label":`${g.fileName} - ${k}`,title:k,children:v},g.id)})}),s.jsx(ju,{open:!!(p!=null&&p.url),title:l("conversation.imagePreviewTitle"),description:p==null?void 0:p.fileName,size:"xwide",layout:"viewer",className:"message-image-modal",bodyClassName:"message-image-modal-body",onClose:()=>c(null),children:p!=null&&p.url?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-image-modal-stage",children:s.jsx("img",{className:"message-image-modal-image",src:p.url,alt:p.fileName||l("conversation.attachmentPreviewAlt")})}),s.jsx("p",{className:"message-image-modal-hint",children:l("conversation.imagePreviewHint")})]}):null})]})}function ZA(){return s.jsx("div",{className:"timeline-skeleton","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("article",{className:`timeline-skeleton-item ${t%2===0?"assistant":"user"}`,children:[s.jsx("div",{className:"timeline-skeleton-avatar"}),s.jsxs("div",{className:"timeline-skeleton-bubble",children:[s.jsx("span",{className:"timeline-skeleton-line long"}),s.jsx("span",{className:"timeline-skeleton-line medium"}),s.jsx("span",{className:"timeline-skeleton-line short"})]})]},t))})}function eR({tool:e,preview:t,exportMode:n=!1}){const[r,i]=f.useState(null),o=r===null?null:t.files[r]??null;return f.useEffect(()=>{if(r===null)return;function a(c){c.key==="Escape"&&i(null)}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((a,c)=>n?s.jsxs("div",{className:"apply-patch-summary-row",children:[s.jsx("span",{className:"apply-patch-summary-label",children:wc(a.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:ca(a),children:gp(a.nextPath??a.path)}),vc(a)]},xc(a,c)):s.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>i(c),children:[s.jsx("span",{className:"apply-patch-summary-label",children:wc(a.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:ca(a),children:gp(a.nextPath??a.path)}),vc(a)]},xc(a,c)))}),s.jsx(ju,{open:o!==null,title:l("conversation.applyPatchDialogTitle"),description:l("conversation.applyPatchDialogDescription"),size:"full",layout:"viewer",className:"apply-patch-modal",bodyClassName:"apply-patch-modal-body",onClose:()=>i(null),children:o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"apply-patch-modal-totals",children:rR(o)}),s.jsxs("section",{className:"apply-patch-file-panel",children:[s.jsxs("div",{className:"apply-patch-file-panel-header",children:[s.jsxs("div",{className:"apply-patch-file-panel-title",children:[s.jsx("span",{className:"apply-patch-summary-label",children:wc(o.action)}),s.jsx("strong",{children:ca(o)})]}),vc(o)]}),s.jsx("div",{className:"apply-patch-diff-view",children:s.jsx("div",{className:"apply-patch-diff-scroll",children:o.lines.map((a,c)=>s.jsxs("div",{className:`apply-patch-diff-line ${sR(a.kind)}`,children:[s.jsx("span",{className:"apply-patch-line-number",children:Rp(a.oldLineNumber)}),s.jsx("span",{className:"apply-patch-line-number",children:Rp(a.newLineNumber)}),s.jsx("span",{className:"apply-patch-line-content",children:a.text||" "})]},`${ca(o)}:${c}`))})})]},xc(o,r??0)),e.error?s.jsxs("section",{className:"apply-patch-error-panel",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:"tool-call-error",children:e.error})]}):null]}):null})]})}function tR({tool:e,snapshot:t,workspaceId:n,exportMode:r=!1}){const i=Pn(),[o,a]=f.useState({status:"idle",url:null});return f.useEffect(()=>{if(r||!t.previewTarget){a({status:"idle",url:null});return}let c=!1;return a({status:"loading",url:null}),(t.previewTarget.kind==="workspace_file"?n?jm(n,t.previewTarget.relativePath):Promise.reject(new Error("workspace preview requires workspaceId")):t.previewTarget.kind==="office_artifact"?Cm(t.previewTarget.artifactId):Nm(t.previewTarget.taskId,t.previewTarget.fileName)).then(d=>{if(c)return;const h=cu(d.previewPath,d.previewUrl,i.isDesktop);a(h?{status:"ready",url:h}:{status:"error",url:null})}).catch(()=>{c||a({status:"error",url:null})}),()=>{c=!0}},[r,i.isDesktop,t.previewTarget,n]),s.jsxs("div",{className:`tool-call-item view-image-tool-item ${e.status==="completed"?"tool-result":""}`,children:[s.jsx("div",{className:"tool-call-header view-image-tool-header",children:s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:l("conversation.toolViewImageActiveLabel")}),s.jsx("span",{className:"tool-call-input-preview",children:t.displayPath})]})}),r?null:s.jsx("div",{className:"view-image-tool-preview",children:o.status==="ready"?s.jsx("img",{src:o.url,alt:t.fileName||l("conversation.attachmentPreviewAlt")}):s.jsx("div",{className:"view-image-tool-placeholder",children:o.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")})})]})}function Fb({group:e,workspaceId:t,workspacePath:n,exportMode:r=!1}){const[i,o]=f.useState(!1),{navigationGroups:a}=ey(),{tool:c,hasRequest:u,hasResult:d}=e,h=fA(c.name),p=f.useMemo(()=>pA(c,n),[c,n]),g=f.useMemo(()=>bA(a),[a]),m=f.useMemo(()=>kA(c,g),[g,c]),k=f.useMemo(()=>yA(c,g),[g,c]),S=f.useMemo(()=>SI(c,null,e.updatedAt),[e.updatedAt,c]),v=f.useMemo(()=>MA(c),[c.input,c.name]);if(p)return s.jsx(tR,{tool:c,snapshot:p,workspaceId:t,exportMode:r});if(v)return s.jsx(eR,{tool:c,preview:v,exportMode:r});if(m)return s.jsx(Ap,{tool:c,snapshot:m,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(E=>!E)}});if(k)return s.jsx(Ap,{tool:c,snapshot:k,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(E=>!E)}});if(S)return s.jsx(nR,{tool:c,snapshot:S,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(E=>!E)}});const w=DA(c),R=!!(c.input||c.output||c.error),T=R&&!r,F=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:h}),s.jsx("span",{className:"tool-call-input-preview",children:w})]}),s.jsx("div",{className:"tool-call-meta",children:T&&s.jsx("span",{className:`tool-call-toggle ${i?"expanded":""}`,children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]});return s.jsxs("div",{className:`tool-call-item ${d?"tool-result":""}`,children:[r?s.jsx("div",{className:"tool-call-header",children:F}):s.jsx("button",{type:"button",className:"tool-call-header",onClick:()=>R&&o(E=>!E),children:F}),i&&R&&s.jsxs("div",{className:"tool-call-output",children:[u&&c.input&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:c.input})]}),(d||c.error||c.output)&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:c.error?"tool-call-error":void 0,children:c.error||c.output||l("conversation.toolResultEmpty")})]})]})]})}function Ap({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:o,exportMode:a=!1}){const c=n?l("conversation.assistantCapabilityRawCollapse"):l("conversation.assistantCapabilityRawExpand");return s.jsxs("div",{className:"tool-call-item assistant-capability-item","data-kind":t.kind,children:[s.jsxs("div",{className:"assistant-capability-header",children:[s.jsxs("div",{className:"assistant-capability-heading",children:[s.jsx("span",{className:"assistant-capability-icon",children:s.jsx(PA,{kind:t.kind})}),s.jsxs("div",{className:"assistant-capability-heading-main",children:[s.jsx("span",{className:"assistant-capability-badge",children:t.badge}),s.jsx("strong",{children:t.title}),s.jsx("span",{className:"assistant-capability-summary",children:t.summary})]})]}),a?null:s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:c})]}),t.rows.length>0?s.jsx("div",{className:"assistant-capability-list",children:t.rows.map(u=>s.jsxs("div",{className:"assistant-capability-row",children:[s.jsx("span",{className:"assistant-capability-row-label",children:u.label}),s.jsx("span",{className:"assistant-capability-row-value",children:u.value})]},u.label))}):null,!a&&n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,i||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null]})}function nR({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:o,exportMode:a=!1}){return s.jsx(PI,{snapshot:t,toolName:e.name,expanded:n,exportMode:a,onToggleExpanded:a?void 0:o,children:!a&&n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,i||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null})}function wc(e){return e==="add"?l("conversation.applyPatchAddedLabel"):e==="delete"?l("conversation.applyPatchDeletedLabel"):l("conversation.applyPatchEditedLabel")}function ca(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function xc(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function vc(e){return e.statsKnown?s.jsxs("span",{className:"apply-patch-summary-stats",children:[s.jsxs("span",{className:"apply-patch-summary-added",children:["+",e.additions]}),s.jsxs("span",{className:"apply-patch-summary-removed",children:["-",e.deletions]})]}):s.jsx("span",{className:"apply-patch-summary-stats",children:s.jsx("span",{className:"apply-patch-summary-edited",children:l("conversation.applyPatchEditedStat")})})}function rR(e){return e.statsKnown?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"apply-patch-stat-pill positive",children:[l("conversation.applyPatchAddedStat")," +",e.additions]}),s.jsxs("span",{className:"apply-patch-stat-pill negative",children:[l("conversation.applyPatchRemovedStat")," -",e.deletions]})]}):s.jsx("span",{className:"apply-patch-stat-pill neutral",children:l("conversation.applyPatchEditedStat")})}function sR(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function Rp(e){return e===null||e<=0?"":String(e)}function iR(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function $b({timestamp:e,leading:t,children:n}){return s.jsxs("div",{className:"user-message-footer",children:[s.jsx("div",{className:"user-message-footer-leading",children:t}),s.jsxs("div",{className:"user-message-footer-trailing",children:[s.jsx("time",{className:"message-time",dateTime:e,children:iR(e)}),n]})]})}function Is({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:i}){const{showToast:o}=ar(),a=Pn(),[c,u]=f.useState(!1),[d,h]=f.useState(!1),p=e.trim().length>0,g=t&&p;async function m(){if(!(!g||c)){u(!0);try{await hd(e,a),o({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(S){o({title:S instanceof Error?S.message:l("conversation.copyContentFailed"),tone:"error"})}finally{u(!1)}}}async function k(){if(!(!i||d)){h(!0);try{await i()}finally{h(!1)}}}return!g&&!n?null:s.jsxs("div",{className:r?"message-metadata-bar compact":"message-metadata-bar",children:[g?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":l("conversation.copyAction"),title:l("conversation.copyAction"),onClick:()=>{m()},disabled:c,children:s.jsx(OI,{})}):null,n?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":d?l("conversation.forkingAction"):l("conversation.forkFromHereAction"),title:d?l("conversation.forkingAction"):l("conversation.forkFromHereAction"),onClick:()=>{k()},disabled:d,children:s.jsx(BI,{})}):null]})}function oR({message:e,kind:t,tone:n,actionState:r,onRetry:i,onForkMessage:o,forceExpanded:a=!1,exportMode:c=!1}){const[u,d]=f.useState(!1),h=UA(t,e.content),p=n==="user-message",g=a||u,m=t==="system_prompt"?l("conversation.systemPromptTitle"):t==="skill_context"?l("conversation.skillContextTitle"):l("conversation.rulesMessageTitle"),k=t==="system_prompt"?l("conversation.systemPromptHint"):t==="skill_context"?l("conversation.skillContextHint"):l("conversation.rulesMessageHint"),S=g?t==="system_prompt"?l("conversation.systemPromptCollapse"):t==="skill_context"?l("conversation.skillContextCollapse"):l("conversation.rulesMessageCollapse"):t==="system_prompt"?l("conversation.systemPromptExpand"):t==="skill_context"?l("conversation.skillContextExpand"):l("conversation.rulesMessageExpand");return s.jsx("article",{className:`message-item ${n} rules-message-row`,"data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsxs("div",{className:"rules-message-card",children:[a?s.jsx("div",{className:"rules-message-toggle","aria-expanded":g,children:s.jsxs("div",{className:"rules-message-heading",children:[s.jsx("span",{className:"rules-message-badge",children:m}),s.jsx("span",{className:"rules-message-summary",children:h})]})}):s.jsxs("button",{type:"button",className:"rules-message-toggle","aria-expanded":g,onClick:()=>d(v=>!v),children:[s.jsxs("div",{className:"rules-message-heading",children:[s.jsx("span",{className:"rules-message-badge",children:m}),s.jsx("span",{className:"rules-message-summary",children:h})]}),s.jsx("span",{className:"rules-message-action",children:S})]}),s.jsx("p",{className:"rules-message-hint",children:k}),g&&s.jsx("div",{className:"rules-message-body",children:s.jsx(eo,{content:e.content,className:"message-text message-content markdown-content",exportMode:c})}),p?s.jsx($b,{timestamp:e.timestamp,children:s.jsx(Is,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(e):null})}):s.jsx(Is,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>i(e.clientRequestId),children:l("conversation.resendButton")})]})})}function zb({message:e,provider:t,interruptedSource:n=null,foldedPromptKind:r=null,actionState:i,onRetry:o,onForkMessage:a,assistantAvatar:c,exportMode:u=!1,onSubmitStructuredQuestion:d}){const h=e.role==="user",p=e.kind==="thinking",g=e.role==="assistant"&&e.kind==="text",m=t==="codex"&&e.kind==="text"?jb(e.content):null,k=r??($A(t,e.content)?"rules":zA(t,e.content)?"skill_context":null),S=f.useMemo(()=>bo(e.content),[e.content]),v=S.text,w=S.inlineImages,R=S.structuredQuestions,[T,F]=f.useState(!1),[E,I]=f.useState(!1),[q,z]=f.useState(null),[L,A]=f.useState(null);if(k){const U=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return s.jsx(oR,{message:e,kind:k,tone:U,actionState:i,onRetry:o,onForkMessage:a,forceExpanded:u,exportMode:u})}if(m){const U=iA(n),B=m.detail?`${U}
|
|
46
|
-
|
|
47
|
-
${m.detail}`:U;return s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:c??s.jsx(Sc,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(eo,{content:B,className:"message-text message-content markdown-content",exportMode:u}),s.jsx(Is,{text:B,canCopy:i.canCopy,canFork:!1,onFork:null})]})]})}if(h){const U=e.origin==="butler_proxy"||cR(e.clientRequestId),B=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function le(){if(!B)return;const X=!T;if(F(X),!(!X||L||E)){I(!0),z(null);try{const J=await GT(e.originRef);A(J.task)}catch(J){z(J instanceof Error?J.message:l("conversation.butlerOriginDetailLoadFailed"))}finally{I(!1)}}}const V=U?B?s.jsxs("div",{className:"message-origin-detail-anchor",children:[s.jsx("button",{type:"button",className:"message-origin-badge message-origin-badge-button","aria-expanded":T,onClick:()=>{le()},children:l("conversation.butlerProxyMessageBadge")}),T?s.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[s.jsx("strong",{children:l("conversation.butlerOriginDetailTitle")}),E?s.jsx("p",{children:l("conversation.butlerOriginDetailLoading")}):q?s.jsx("p",{children:q}):L?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:[l("conversation.butlerOriginDetailObjectiveLabel"),":",L.objective]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailStatusLabel"),":",uR(L.status)]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailSummaryLabel"),":",L.lastAutomationSummary||l("conversation.butlerAnalysisEmpty")]}),L.waitingReason?s.jsxs("p",{children:[l("conversation.butlerOriginDetailWaitingReasonLabel"),":",L.waitingReason]}):null]}):s.jsx("p",{children:l("conversation.butlerAnalysisEmpty")})]}):null]}):s.jsx("span",{className:"message-origin-badge",children:l("conversation.butlerProxyMessageBadge")}):null;return s.jsx("article",{className:"message-item user-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(la,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:w}),v?s.jsx(eo,{content:v,className:"message-text message-content markdown-content",exportMode:u}):null,e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>o(e.clientRequestId),children:l("conversation.resendButton")}),s.jsx($b,{timestamp:e.timestamp,leading:V,children:s.jsx(Is,{text:v,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),compact:!0,onFork:a?()=>a(e):null})})]})})}return p?s.jsxs("article",{className:"message-item assistant-message thinking-message-row","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:c??s.jsx(Sc,{})}),s.jsxs("div",{className:"thinking-message-content",children:[s.jsx("div",{className:"thinking-message-label",children:l("conversation.thinkingLabel")}),s.jsx(la,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:w}),v&&s.jsx(eo,{content:v,className:"message-text message-content markdown-content thinking-message-text",exportMode:u}),s.jsx(Is,{text:v,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})]}):g?s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:c??s.jsx(Sc,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(la,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:w}),v&&s.jsx(eo,{content:v,className:"message-text message-content markdown-content",exportMode:u}),R&&d?s.jsx(aR,{messageId:e.id,prompt:R,onSubmit:d}):null,s.jsx(Is,{text:v,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})]}):s.jsx("article",{className:"message-item system-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(la,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:w}),v?s.jsx("div",{className:"message-text message-content",children:s.jsx(Wb,{language:"text",content:v,exportMode:u})}):null,s.jsx(Is,{text:v,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})})}function aR({messageId:e,prompt:t,onSubmit:n}){const[r,i]=f.useState({}),[o,a]=f.useState(!1),c=t.questions.some(u=>{var d;return(((d=r[u.id])==null?void 0:d.filter(Boolean).length)??0)===0});return s.jsxs("section",{className:"permission-request-card permission-request-card-inline",children:[s.jsxs("header",{className:"permission-request-card-header",children:[s.jsx("div",{className:"permission-request-provider",children:s.jsxs("div",{className:"permission-request-provider-copy",children:[s.jsx("strong",{children:l("conversation.permissionRequestQuestionsLabel")}),s.jsx("span",{children:l("conversation.permissionRequestSectionDescription")})]})}),s.jsx("span",{className:"permission-request-kind",children:l("conversation.permissionRequestKindUserInput")})]}),s.jsx("div",{className:"permission-request-card-body",children:s.jsxs("div",{className:"permission-request-block",children:[s.jsx("div",{className:"permission-request-block-label",children:l("conversation.permissionRequestQuestionsLabel")}),s.jsx("div",{className:"permission-request-question-list",children:t.questions.map(u=>s.jsxs("div",{className:"permission-request-question",children:[s.jsx("div",{className:"permission-request-question-header",children:u.header}),s.jsx("p",{children:u.question}),s.jsx("div",{className:"permission-request-question-options",children:u.options.map(d=>{var p;const h=((p=r[u.id])==null?void 0:p.includes(d.label))??!1;return s.jsxs("label",{className:"permission-request-question-option",children:[s.jsx("input",{type:"radio",name:`${e}:${u.id}`,checked:h,onChange:()=>{i(g=>({...g,[u.id]:[d.label]}))}}),s.jsxs("span",{children:[s.jsx("strong",{children:d.label}),d.description?s.jsx("small",{children:d.description}):null]})]},`${u.id}:${d.label}`)})})]},`${e}:${u.id}`))})]})}),s.jsx("footer",{className:"permission-request-card-footer",children:s.jsx("button",{type:"button",className:"primary-button permission-request-action",disabled:o||c,onClick:async()=>{a(!0);try{await n({messageId:e,answers:r})}finally{a(!1)}},children:o?l("conversation.permissionRequestSubmitting"):l("common.confirm")})})]})}function Ub(e){return s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline","data-runtime-thinking-placeholder":"true",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":e.label,children:[s.jsx("span",{children:rA(e.label)||e.label}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})},e.key)}function Hb(e){return s.jsxs("article",{className:"message-item assistant-message session-runtime-error-row",children:[s.jsx("div",{className:"session-runtime-error-row__spacer","aria-hidden":"true"}),s.jsxs("section",{className:"message-content-wrapper session-runtime-error-panel",role:"status","aria-label":e.error.title,children:[s.jsxs("div",{className:"session-runtime-error-panel__header",children:[s.jsxs("div",{className:"session-runtime-error-panel__title-group",children:[s.jsx("span",{className:"session-runtime-error-panel__dot","aria-hidden":"true"}),s.jsx("strong",{children:e.error.title})]}),e.error.code?s.jsx("code",{className:"session-runtime-error-panel__code",children:e.error.code}):null]}),e.error.summary?s.jsx("p",{className:"session-runtime-error-panel__summary",children:sA(e.error.summary).map((t,n)=>t.type==="text"?s.jsx("span",{children:t.text},`${e.key}:text:${n}`):s.jsx("mark",{className:`session-runtime-error-panel__summary-token session-runtime-error-panel__summary-token--${t.type}`,children:t.text},`${e.key}:${t.type}:${n}`))}):null]})]},e.key)}function lR({sessionId:e,sessionSummary:t=null,workspaceId:n=null,workspacePath:r=null,items:i,provider:o,interruptedSource:a=null,assistantAvatar:c}){const u=f.useMemo(()=>Bb({sessionSummary:t,items:i,provider:o}),[i,o,t]),d=u.renderItems,h=u.leadingSystemPromptMessageIds;return s.jsx("section",{className:"message-timeline message-timeline-export","aria-label":l("conversation.exportPrintContainerTitle"),children:s.jsxs("div",{className:"message-list message-list-export","data-export-mode":"true",children:[d.length===0?s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}):null,d.map(p=>p.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(Fb,{group:p.group,workspaceId:n,workspacePath:r,exportMode:!0})},p.key):p.type==="runtime_thinking"?Ub(p):p.type==="session_error"?Hb(p):s.jsx(zb,{message:p.message,provider:o,foldedPromptKind:h.has(p.message.id)?"system_prompt":null,actionState:{canCopy:!1,canFork:!1},onRetry:()=>{},onForkMessage:null,interruptedSource:a,assistantAvatar:c,exportMode:!0},p.key))]})})}function Sc(){return s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4M12 8h.01"})]})}function cR(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function uR(e){switch(e){case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"active":default:return l("shell.butlerAutomationStatusActive")}}function IO({sessionId:e="session",sessionSummary:t=null,workspaceId:n=null,workspacePath:r=null,items:i,historyState:o,loadingOlderMessages:a=!1,hasOlderMessages:c=!1,onLoadOlderMessages:u=()=>{},onRetryMessage:d,onForkMessage:h,provider:p,interruptedSource:g=null,assistantAvatar:m,followTailUpdates:k=!1,onSubmitStructuredQuestion:S}){var Dt;const{showToast:v}=ar(),w=Pn(),R=!k,T=f.useRef(null);ad(T);const F=f.useRef(e),E=f.useRef(0),I=f.useRef(null),q=f.useRef(!0),z=f.useRef(null),L=f.useRef(null),A=f.useRef(!1),U=f.useRef(k?null:aa(e)),B=f.useRef(k?null:((Dt=aa(e))==null?void 0:Dt.lastMessageSignature)??null),le=f.useRef(k?null:aa(e)),V=f.useRef(null),X=f.useRef(null),J=f.useRef(null),O=f.useRef(0),K=f.useRef(!1),ce=f.useRef(null),N=f.useRef(null),De=f.useRef(null),[ee,j]=f.useState(!1),[be,re]=f.useState(!1),fe=f.useRef(!1),de=f.useRef(null),Ue=w.isMobile?0:uA,He=f.useMemo(()=>tA(i),[i]),je=f.useMemo(()=>nA(i),[i]),Te=f.useMemo(()=>Bb({sessionSummary:t,items:i,provider:p}),[i,p,t]),_=Te.visibleMessages,G=Te.renderItems,Q=Te.leadingSystemPromptMessageIds,Ce=Te.actionStateByMessageId,Ae=o==="loading"&&He.length===0;function ve(D){var he,Ee,we;if(!D)return null;try{const Se=JSON.parse(D);return{type:typeof Se.type=="string"?Se.type:"message",key:typeof Se.key=="string"?Se.key:null,id:typeof Se.id=="string"?Se.id:null,timestamp:typeof Se.timestamp=="string"?Se.timestamp:null,deliveryState:typeof Se.deliveryState=="string"?Se.deliveryState:null,contentLength:typeof Se.content=="string"?Se.content.length:0,labelLength:typeof Se.label=="string"?Se.label.length:0,summaryLength:typeof Se.summary=="string"?Se.summary.length:0,messageIdCount:Array.isArray(Se.messageIds)?Se.messageIds.length:0,attachmentCount:Array.isArray(Se.attachments)?Se.attachments.length:0,toolStatus:typeof((he=Se.toolCall)==null?void 0:he.status)=="string"?Se.toolCall.status:null,hasToolOutput:typeof((Ee=Se.toolCall)==null?void 0:Ee.output)=="string"?Se.toolCall.output.length>0:!1,hasToolError:typeof((we=Se.toolCall)==null?void 0:we.error)=="string"?Se.toolCall.error.length>0:!1}}catch{return{parseError:!0,length:D.length}}}function Tt(D){var he;return{id:D.id,rawRef:D.rawRef,role:D.role,kind:D.kind,deliveryState:D.deliveryState,timestamp:D.timestamp,sequence:D.sequence,attachmentCount:((he=D.attachments)==null?void 0:he.length)??0,contentPreview:bo(D.content).text.replace(/\r\n/g,`
|
|
48
|
-
`).trimEnd().slice(0,120)}}function rt(D){return D.type==="message"?{type:D.type,key:D.key,message:Tt(D.message)}:D.type==="runtime_thinking"?{type:D.type,key:D.key,labelPreview:D.label.slice(0,80)}:D.type==="session_error"?{type:D.type,key:D.key,code:D.error.code,summary:D.error.summary}:{type:D.type,key:D.key,callId:D.group.tool.callId,name:D.group.tool.name,hasRequest:D.group.hasRequest,hasResult:D.group.hasResult,updatedAt:D.group.updatedAt}}function gt(D,he){const Ee=D.getBoundingClientRect(),we=he.getBoundingClientRect(),Se=Math.max(we.top,Ee.top),pt=Math.min(we.bottom,Ee.bottom),Bt=Math.max(0,pt-Se);return{top:Math.round(we.top),bottom:Math.round(we.bottom),height:Math.round(we.height),relativeTop:Math.round(we.top-Ee.top),relativeBottom:Math.round(we.bottom-Ee.top),bottomGap:Math.round(Ee.bottom-we.bottom),visibleHeight:Math.round(Bt),fullyVisible:we.top>=Ee.top&&we.bottom<=Ee.bottom}}function ae(D,he){var Se;const Ee=he.dataset.messageId??null,we=Ee?_.find(pt=>pt.id===Ee)??null:null;return{messageId:Ee,role:(we==null?void 0:we.role)??null,kind:(we==null?void 0:we.kind)??null,className:he.className,textLength:((Se=he.textContent)==null?void 0:Se.length)??0,rect:gt(D,he)}}function ie(D){var Se;if(!D)return null;const he=D.getBoundingClientRect(),Ee=Array.from(D.children).filter(pt=>pt instanceof HTMLElement&&pt.classList.contains("message-item")),we=D.querySelector("[data-runtime-thinking-placeholder='true']");return{listRect:{top:Math.round(he.top),bottom:Math.round(he.bottom),height:Math.round(he.height)},messageElementCount:Ee.length,tailDomItems:Ee.slice(-5).map(pt=>ae(D,pt)),runtimeThinkingPlaceholderDom:we?{textLength:((Se=we.textContent)==null?void 0:Se.length)??0,rect:gt(D,we)}:null}}function ke(D,he={}){const Ee=_[0]??null,we=_.at(-1)??null,Se=G.at(-1)??null,pt=U.current,Bt=le.current,mt=D?D.scrollHeight-D.clientHeight-D.scrollTop:null;return{sessionId:e,historyState:o,followTailUpdates:k,messagesLength:_.length,rawMessagesLength:He.length,renderItemsLength:G.length,firstMessageId:(Ee==null?void 0:Ee.id)??null,firstMessageRole:(Ee==null?void 0:Ee.role)??null,lastMessageId:(we==null?void 0:we.id)??null,lastMessageRole:(we==null?void 0:we.role)??null,lastMessageKind:(we==null?void 0:we.kind)??null,lastMessageTimestamp:(we==null?void 0:we.timestamp)??null,runtimeThinkingPlaceholderVisible:!!je,runtimeThinkingPlaceholderLength:(je==null?void 0:je.length)??0,runtimeThinkingPlaceholderPreview:(je==null?void 0:je.slice(0,80))??null,tailItemType:(Se==null?void 0:Se.type)??null,tailItemKey:(Se==null?void 0:Se.key)??null,tailToolCallId:Se&&Se.type==="tool_group"?Se.group.tool.callId:null,scrollTop:(D==null?void 0:D.scrollTop)??null,scrollHeight:(D==null?void 0:D.scrollHeight)??null,clientHeight:(D==null?void 0:D.clientHeight)??null,distanceToBottom:mt,stickToBottomRef:q.current,hasNewMessagesBelow:fe.current,previousMessageCount:E.current,previousLastMessage:ve(I.current),hiddenMessageIds:Te.hiddenMessageIds,validationIssues:Te.validationIssues,tailMessages:_.slice(-5).map(Tt),tailRenderItems:G.slice(-5).map(rt),dom:ie(D),pendingRestoreState:pt===null?null:{scrollTop:pt.scrollTop,stickToBottom:pt.stickToBottom,lastMessage:ve(pt.lastMessageSignature)},currentScrollState:Bt===null?null:{scrollTop:Bt.scrollTop,stickToBottom:Bt.stickToBottom,lastMessage:ve(Bt.lastMessageSignature)},restoredTailMessage:ve(B.current),...he}}function ye(D,he,Ee={}){Wc()&&vw(D,ke(he,Ee))}function Re(D){const Ee=D.scrollHeight-D.clientHeight-D.scrollTop<=xp;return{scrollTop:D.scrollTop,stickToBottom:Ee,lastMessageSignature:fe.current&&!Ee?B.current:js(G.at(-1)??null)}}function $(D){return le.current=Re(D),le.current}function Z(D){const he=D.scrollHeight-D.clientHeight-D.scrollTop,Ee=he<=xp;q.current=Ee,Ee&&fe.current&&(Ze(),fe.current=!1,B.current=js(G.at(-1)??null),re(!1)),j(G.length>0&&(he>vp||fe.current)),$(D),ye("affordance.sync",D,{distanceToBottom:he,nextStickToBottom:Ee})}function ge(D=T.current){R&&(D&&$(D),le.current&&wp(e,le.current))}function Ne(D){R&&le.current&&wp(D,le.current)}function Be(){V.current!==null&&(window.clearTimeout(V.current),V.current=null)}function Ve(){R&&(Be(),V.current=window.setTimeout(()=>{V.current=null,ge()},aA))}function Ie(D,he,Ee={}){ye("jump_to_bottom.before",D,{reason:he,...Ee}),D.scrollTop=D.scrollHeight,ye("jump_to_bottom.after",D,{reason:he,...Ee})}function dt(){X.current!==null&&(window.clearTimeout(X.current),X.current=null)}function Ze(){dt(),K.current=!1,J.current=null,O.current=0,ce.current=null}function st(D,he){const Ee=Math.max(0,D.scrollHeight-D.clientHeight),we=Math.max(0,Math.min(he,Ee));ce.current=we,D.scrollTop=we,q.current=!1,ye("manual_restore.apply",D,{targetScrollTop:he,maxScrollableTop:Ee,nextScrollTop:we}),j(G.length>0&&(Ee-we>vp||fe.current))}function it(){dt(),K.current&&(X.current=window.setTimeout(()=>{X.current=null;const D=T.current,he=J.current;if(!D||he===null){Ze();return}if(st(D,he),Date.now()<O.current){it();return}Ze(),Z(D)},cA))}function qe(D,he){if(Ue<=0){st(he,D),Ze();return}K.current=!0,J.current=D,O.current=Date.now()+Ue,st(he,D),it()}function bt(){K.current&&(ye("manual_restore.interrupt",T.current),Ze())}function Ut(D){return A.current||!c||a||o!=="ready"||D.scrollTop>oA?!1:(A.current=!0,z.current=D.scrollHeight-D.scrollTop,L.current=js(G[0]??null),ye("older_history.prefetch",D,{pendingOlderLoadOffset:z.current,pendingOlderLoadHeadMessage:ve(L.current)}),u(),!0)}f.useEffect(()=>{o==="error"&&v({title:l("conversation.historyLoadFailed"),tone:"error"})},[o,v]),f.useLayoutEffect(()=>{var D,he;if(F.current!==e){const Ee=F.current;Ne(Ee),F.current=e,E.current=0,I.current=null,U.current=k?null:aa(e),B.current=((D=U.current)==null?void 0:D.lastMessageSignature)??null,le.current=U.current,q.current=k?!0:((he=U.current)==null?void 0:he.stickToBottom)??!0,z.current=null,L.current=null,Ze(),fe.current=!1,re(!1),j(!1),ye("session.switch",T.current,{previousSessionId:Ee,nextSessionId:e})}},[k,R,e]),f.useLayoutEffect(()=>()=>{Be(),Ze(),Ne(F.current)},[R,e]),f.useLayoutEffect(()=>{const D=T.current,he=js(G.at(-1)??null);if(!D){E.current=G.length,I.current=he;return}const Ee=E.current,we=I.current,Se=U.current,pt=Ee===0||G.length!==Ee||he!==we;if(ye("messages.effect.start",D,{previousCount:Ee,previousLastMessage:ve(we),currentLastMessage:ve(he),hasTailUpdate:pt}),Se&&o==="ready"){const Ht=!Se.stickToBottom&&Se.lastMessageSignature!==null&&he!==null&&Se.lastMessageSignature!==he;Se.stickToBottom?(Ze(),Ie(D,"restore_ready_stick_to_bottom",{hasTailUpdates:Ht})):(qe(Se.scrollTop,D),ye("restore_ready.manual",D,{hasTailUpdates:Ht,targetScrollTop:Se.scrollTop})),fe.current=Ht,B.current=Se.lastMessageSignature,re(Ht),U.current=null,Z(D),E.current=G.length,I.current=he,$(D);return}if(Se&&o==="error"){Se.stickToBottom?(Ze(),Ie(D,"restore_error_stick_to_bottom")):(qe(Se.scrollTop,D),ye("restore_error.manual",D,{targetScrollTop:Se.scrollTop})),U.current=null,Z(D),E.current=G.length,I.current=he,$(D);return}if(K.current){st(D,J.current??D.scrollTop),E.current=G.length,I.current=he,$(D);return}const Bt=js(G[0]??null),mt=z.current,_t=L.current,tt=mt!==null&&!a&&_t!==null&&_t!==Bt&&G.length>=Ee,ct=pt&&(k||q.current);ye("messages.effect.decision",D,{currentHeadMessage:ve(Bt),pendingOlderLoadOffset:mt,pendingOlderLoadHeadMessage:ve(_t),shouldRestoreOlderLoadOffset:tt,shouldFollowTailUpdate:ct,loadingOlderMessages:a}),tt?(D.scrollTop=Math.max(0,D.scrollHeight-mt),z.current=null,L.current=null):z.current!==null&&!a?(z.current=null,L.current=null,ct&&Ie(D,"older_load_offset_cleared_follow_tail",{pendingOlderLoadOffset:mt})):ct&&Ie(D,"tail_update_follow"),Z(D),E.current=G.length,I.current=he},[o,a,G,e]),f.useEffect(()=>{if(!c){A.current=!1;return}!a&&z.current===null&&(A.current=!1)},[c,a,_.length]),f.useLayoutEffect(()=>{const D=De.current;D!==je&&(ye("runtime_thinking.placeholder_change",T.current,{previousVisible:!!D,nextVisible:!!je,previousLength:(D==null?void 0:D.length)??0,nextLength:(je==null?void 0:je.length)??0,note:"Codex 思考中占位符已经并入统一 timeline source item 列表;调试时直接看 renderItems 尾部即可。"}),De.current=je)},[je,e]),f.useEffect(()=>{const D=T.current;if(!Wc()||!D||typeof ResizeObserver>"u")return;const he=new ResizeObserver(()=>{ye("list.resize",D)});return he.observe(D),()=>{he.disconnect()}},[e,_.length]),f.useEffect(()=>{const D=qA(G),he=GA(de.current,D,_);(Te.hiddenMessageIds.length>0||Te.validationIssues.length>0||he.length>0)&&xw("timeline.render",{sessionId:e,hiddenMessageIds:Te.hiddenMessageIds,validationIssues:Te.validationIssues,assistantRenderMoves:he,rawTailMessages:He.slice(-6).map(Tt),visibleTailMessages:_.slice(-6).map(Tt),renderTailItems:G.slice(-6).map(rt)}),de.current=D},[He,G,e,Te.hiddenMessageIds,Te.validationIssues,_]);function Ye(){const D=T.current;if(D){if(K.current){const he=ce.current;he!==null&&Math.abs(D.scrollTop-he)<=1?ce.current=null:bt()}Z(D),Ve(),ye("scroll",D),Ut(D)}}function ht(D){if(D.deltaY!==0&&bt(),D.deltaY>=0)return;const he=T.current;he&&Ut(he)}function Oe(D){var he;bt(),N.current=((he=D.touches[0])==null?void 0:he.clientY)??null}function kt(D){var Se;const he=N.current,Ee=((Se=D.touches[0])==null?void 0:Se.clientY)??null;if(he===null||Ee===null||Ee-he<lA)return;bt();const we=T.current;we&&Ut(we)}function et(){N.current=null}return s.jsxs("section",{className:"message-timeline",children:[o==="loading"&&s.jsx("div",{className:"timeline-status",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoading")})}),s.jsxs("div",{ref:T,className:"message-list","data-scrollbar-autohide":"true",onScroll:Ye,onPointerDown:bt,onWheel:ht,onTouchStart:Oe,onTouchMove:kt,onTouchEnd:et,onTouchCancel:et,children:[Ae?s.jsx(ZA,{}):null,a?s.jsx("div",{className:"timeline-status timeline-status-inline",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoadingOlder")})}):null,G.length===0&&o==="ready"&&s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}),G.map(D=>D.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(Fb,{group:D.group,workspaceId:n,workspacePath:r})},D.key):D.type==="runtime_thinking"?Ub(D):D.type==="session_error"?Hb(D):s.jsx(zb,{message:D.message,provider:p,foldedPromptKind:Q.has(D.message.id)?"system_prompt":null,actionState:Ce.get(D.message.id)??{canCopy:D.message.role==="user",canFork:!1},onRetry:d,onForkMessage:h,interruptedSource:g,assistantAvatar:m,onSubmitStructuredQuestion:S},D.key))]}),ee?s.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":be?"true":"false","aria-label":l("conversation.scrollToBottomAction"),title:l("conversation.scrollToBottomAction"),onClick:()=>{const D=T.current;D&&(Ze(),Ie(D,"scroll_button_click"),fe.current=!1,B.current=js(G.at(-1)??null),re(!1),Z(D),ge(D))},children:[be?s.jsx("span",{className:"conversation-scroll-to-bottom-button-badge",children:"NEW"}):null,s.jsx("svg",{className:"conversation-scroll-to-bottom-button-icon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M10 4.25a.75.75 0 0 1 .75.75v7.19l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V5a.75.75 0 0 1 .75-.75Zm-4 11a.75.75 0 0 1 0-1.5h8a.75.75 0 0 1 0 1.5H6Z",fill:"currentColor"})})]}):null]})}function js(e){return e?"type"in e?e.type==="message"?js(e.message):e.type==="tool_group"?JSON.stringify({type:e.type,key:e.key,messageIds:e.group.messageIds,timestamp:e.group.updatedAt,toolCall:{status:e.group.tool.status,output:e.group.tool.output,error:e.group.tool.error}}):e.type==="runtime_thinking"?JSON.stringify({type:e.type,key:e.key,label:e.label}):JSON.stringify({type:e.type,key:e.key,summary:e.error.summary,code:e.error.code}):JSON.stringify({type:"message",id:e.id,content:e.content,attachments:e.attachments,timestamp:e.timestamp,deliveryState:e.deliveryState,toolCall:e.toolCall?{status:e.toolCall.status,output:e.toolCall.output,error:e.toolCall.error}:null}):null}function dR(e){const t=new Map;let n=0;function r(i){let o=null;for(let a=i-1;a>=n;a-=1){const c=e[a];if(!(!c||!hR(c))){o=c.id;break}}for(let a=n;a<i;a+=1){const c=e[a];if(c){if(c.role==="user"){t.set(c.id,{canCopy:!0,canFork:!1});continue}t.set(c.id,{canCopy:c.id===o,canFork:c.id===o})}}}for(let i=0;i<e.length;i+=1){const o=e[i];o&&o.role==="user"&&i>n&&(r(i),n=i)}return r(e.length),t}function hR(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function pR(e){return pd(e)!==null}function fR(e){return e.isSubagent===!0&&!pR(e)}function pd(e){return e.forkMethod==="reconstructed_message_fork"||e.forkMethod==="reconstructed_session_fork"?"reconstructed":e.forkMethod==="native_message_fork"||e.forkSourceType==="message"?"message":e.forkMethod==="native_session_fork"||e.forkSourceType==="session"?"session":null}function mR(e){const t=pd(e);return t==="reconstructed"?l("shell.sessionForkReconstructed"):t==="message"?l("shell.sessionForkMessage"):t==="session"?l("shell.sessionForkSession"):null}function gR(e){return e.sessionKind==="annotation"?"annotation":null}function AO(e){return gR(e)==="annotation"?l("conversation.actionSessionBadge"):null}const Ep=120*1e3,bR=8,kR=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,yR=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/;function RO(e){return{session:(e==null?void 0:e.session)??null,capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:(e==null?void 0:e.messages)??[],timelineItems:(e==null?void 0:e.timelineItems)??[],permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],historyState:"idle",loadingOlderMessages:!1,olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,connectionState:"closed",lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0,interruptSource:(e==null?void 0:e.interruptSource)??null,errorCode:null,errorDetail:null}}function qb(e,t,n="sent",r=null){const i=t.kind??(t.role==="tool"?"tool_result":"text"),o=t.toolCall??(i==="tool_call"||i==="tool_result"?{callId:t.rawRef||t.messageId,name:"tool",input:i==="tool_call"?t.content:"",output:i==="tool_result"&&t.content?t.content:null,error:null,status:i==="tool_call"?"running":"completed"}:null);return{id:t.messageId,sessionId:e,role:t.role,kind:i,content:GR(t.provider,t.role,i,t.content),toolCall:o,attachments:t.attachments??[],attachmentPayloads:null,origin:t.origin??null,originRef:t.originRef??null,timestamp:t.timestamp,sequence:t.sequence,rawRef:t.rawRef,deliveryState:n,clientRequestId:r}}function EO(e,t,n,r=[],i=[],o=Number.MAX_SAFE_INTEGER){return{id:`pending-${n}`,sessionId:e,role:"user",kind:"text",content:t,toolCall:null,attachments:r,attachmentPayloads:i,origin:null,originRef:null,timestamp:new Date().toISOString(),sequence:o,rawRef:`pending://${n}`,deliveryState:"sending",clientRequestId:n}}function PO(e,t){return Gb([...e,t])}function MO(e,t,n){const r=new Map,i=new Set,o=[];for(const a of e)r.set(a.id,a),i.add(a.id);for(const a of n){const c=qb(t,a);o.push(c);const u=XR(r,c,t);if(u&&u!==c.id)continue;const d=JR(r,c,t),h=d&&d!==c.id?r.get(d)??null:null;d&&d!==c.id&&r.delete(d);const p=QR(r,i,c);if(p&&p!==c.id){const S=r.get(p)??null;if(S){const v=uu(S,c);cs("session.messages.codex_equivalent_replace",{sessionId:t,previous:nn(S),incoming:nn(c),merged:nn(v)}),r.delete(p),r.set(a.messageId,v);continue}}const g=eE(r,c);if(g&&g!==c.id){const S=r.get(g)??null;if(S){const v=DR(S,c);cs("session.messages.opencode_equivalent_replace",{sessionId:t,previous:nn(S),incoming:nn(c),merged:nn(v)}),r.set(g,v);continue}}const m=r.get(a.messageId)??null,k=h===null?c:LR(c,h);r.set(a.messageId,m?uu(m,k):k)}return Gb(tE(Array.from(r.values()),o))}function LO(e,t){const n=new Map;for(const r of e)n.set(Dp(r),r);for(const r of t){const i=Dp(r),o=n.get(i)??null;if(o){cs("session.messages.runtime_overlay_merge",{overlayKey:i,mode:"update",previous:nn(o),incoming:nn(r)}),n.set(i,OR(o,r));continue}cs("session.messages.runtime_overlay_merge",{overlayKey:i,mode:"insert",incoming:nn(r)}),n.set(i,r)}return Kb(Array.from(n.values()))}function DO(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function wR(e){const t=[];let n=null,r=!1;for(const i of e)if(!_R(n,i,r)){if(t.push(i),vo(i)){n=i,r=!1;continue}n&&WR(i)&&(r=!0)}return t}function xR(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Xb(r,n)){t.push(n);continue}t[t.length-1]=Qb(r,n)}return t}function vR(e){const t=[];for(const n of e){if(t.push(n),t.length<4)continue;const r=t[t.length-4],i=t[t.length-3],o=t[t.length-2],a=t[t.length-1];FR(r,i,o,a)&&t.splice(t.length-3,3,Qb(i,a))}return t}function SR(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!$R(r,n)){t.push(n);continue}t[t.length-1]=UR(r,n)}return t}function CR(e){const t=[];for(const n of e){const r=t.findIndex(i=>zR(i,n));if(r===-1){t.push(n);continue}t[r]=HR(t[r],n)}return t}function Gb(e){const t=Kb(e);return CR(SR(wR(vR(xR(t)))))}function Kb(e){return[...e].sort((t,n)=>Vb(t,n))}function Vb(e,t){const n=NR(e.rawRef,t.rawRef);if(n!==null&&n!==0)return n;if(e.sequence!==t.sequence)return e.sequence-t.sequence;const r=jR(e.rawRef,t.rawRef);if(r!==0)return r;const i=e.timestamp.localeCompare(t.timestamp);if(i!==0)return i;const o=TR(e.rawRef,t.rawRef);if(o!==0)return o;const a=MR(e.role,t.role);if(a!==0)return a;const c=e.rawRef.localeCompare(t.rawRef);return c!==0?c:e.id.localeCompare(t.id)}function NR(e,t){if(!e.startsWith("codex://")||!t.startsWith("codex://"))return null;const n=wo(e),r=wo(t);if(!n||!r||n!==r)return null;const i=xo(e),o=xo(t);if(i===null||o===null)return null;if(i!==o)return i-o;const a=Ls(e,"part")??0,c=Ls(t,"part")??0;return a-c}function wo(e){const t=e.match(/^codex:\/\/(.+?)(?:#|$)/);return(t==null?void 0:t[1])??null}function jR(e,t){const n=PR(e,t);if(n!==null&&n!==0)return n;const r=IR(e,t);if(r!==null&&r!==0)return r;const i=Mp(e),o=Mp(t);if(!i&&!o||!i||!o)return 0;const a=Math.max(i.length,o.length);for(let c=0;c<a;c+=1){const u=i[c],d=o[c];if(u===void 0&&d===void 0)return 0;if(u===void 0)return-1;if(d===void 0)return 1;if(u!==d)return u-d}return 0}function TR(e,t){const n=xo(e),r=xo(t);return n===null&&r===null?0:n===null?1:r===null?-1:n-r}function xo(e){const t=e.match(/(?:^|[?#&])line=(\d+)(?:$|[&#])/);if(!t)return null;const n=Number.parseInt(t[1]??"",10);return Number.isFinite(n)?n:null}function IR(e,t){const n=Pp(e),r=Pp(t);if(!n||!r||n!==r)return null;const i=Ls(e,"part"),o=Ls(t,"part");return i===null||o===null?null:i-o}function Pp(e){const t=e.match(/^(.+\/message\/[^/?#]+)\/part\/[^/?#]+(?:[?#].*)?$/i);return(t==null?void 0:t[1])??null}function Mp(e){const t=xo(e);if(t!==null){const i=Ls(e,"part");return i===null?[t]:[t,i]}const n=AR(e);if(n)return n;const r=RR(e);return r||null}function AR(e){const t=Ls(e,"index");if(t===null)return null;const n=Ls(e,"part");return n===null?[t]:[t,n]}function Ls(e,t){const n=e.match(new RegExp(`(?:^|[?#&])${t}=(\\d+)(?:$|[&#])`));if(!n)return null;const r=Number.parseInt(n[1]??"",10);return Number.isFinite(r)?r:null}function RR(e){const t=e.match(/\/message\/(user|assistant|tool)-(\d+)\/part\/([a-z_]+)-(\d+)/i);if(!t)return null;const n=ER(t[1]??""),r=Number.parseInt(t[2]??"",10),i=to(t[3]??""),o=Number.parseInt(t[4]??"",10);return!Number.isFinite(r)||!Number.isFinite(o)?null:[r,n,i,o]}function ER(e){switch(e.toLowerCase()){case"user":return 0;case"assistant":return 1;case"tool":return 2;default:return 3}}function to(e){switch(e.toLowerCase()){case"reasoning":case"thinking":return 0;case"text":return 1;case"tool":case"tool_call":case"tool_result":return 2;default:return 3}}function PR(e,t){const n="claude-code://message/";if(!e.startsWith(n)||!t.startsWith(n))return null;let r="",i="";try{r=decodeURIComponent(e.slice(n.length)),i=decodeURIComponent(t.slice(n.length))}catch{return null}const o=r.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i),a=i.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i);if(o&&a){const v=o[1]??"",w=a[1]??"",R=o[2]??"",T=a[2]??"";return v!==w||R!==T?0:to(o[3]??"")-to(a[3]??"")}const c=r.match(/^message:(assistant|user):([^:]+):part:(\d+):type:([a-z_]+)$/i),u=i.match(/^message:(assistant|user):([^:]+):part:(\d+):type:([a-z_]+)$/i);if(!c||!u)return null;const d=c[1]??"",h=u[1]??"",p=c[2]??"",g=u[2]??"";if(d!==h||p!==g)return 0;const m=Number.parseInt(c[3]??"",10),k=Number.parseInt(u[3]??"",10);if(!Number.isFinite(m)||!Number.isFinite(k))return null;const S=m-k;return S!==0?S:to(c[4]??"")-to(u[4]??"")}function MR(e,t){return Lp(e)-Lp(t)}function Lp(e){switch(e){case"user":return 0;case"assistant":return 1;case"tool":return 2;case"system":default:return 3}}function LR(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function uu(e,t){if(e.id!==t.id)return t;if(Yb(e,t)){const a=Xa(e.toolCall,t.toolCall),c=Jb(e,t,a,Qa),u=Za(e.attachments,t.attachments),d=el(e,t);return{...zr(e,t),kind:(a==null?void 0:a.status)==="running"?"tool_call":"tool_result",content:c,toolCall:a,attachments:u,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:d.rawRef,timestamp:d.timestamp,sequence:d.sequence}}if(e.role!==t.role||e.kind!==t.kind)return zr(e,t);const n=Xa(e.toolCall,t.toolCall),r=Qa(e.content,t.content,e.timestamp,t.timestamp),i=Za(e.attachments,t.attachments),o=el(e,t);return{...zr(e,t),content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence}}function DR(e,t){if(Yb(e,t)){const a=Xa(e.toolCall,t.toolCall),c=Jb(e,t,a,Qa),u=Za(e.attachments,t.attachments),d=el(e,t);return{...zr(e,t),id:e.id,kind:(a==null?void 0:a.status)==="running"?"tool_call":"tool_result",content:c,toolCall:a,attachments:u,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:d.rawRef,timestamp:d.timestamp,sequence:d.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}if(e.role!==t.role||e.kind!==t.kind)return{...zr(e,t),id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId};const n=Xa(e.toolCall,t.toolCall),r=Qa(e.content,t.content,e.timestamp,t.timestamp),i=Za(e.attachments,t.attachments),o=el(e,t);return{...zr(e,t),id:e.id,content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function Yb(e,t){return nk(e,t)||fd(e,t)}function Jb(e,t,n,r){if((n==null?void 0:n.status)==="running"){if(t.kind==="tool_call"&&t.content)return t.content;if(e.kind==="tool_call"&&e.content)return e.content}else{if(t.kind==="tool_result"&&t.content)return t.content;if(e.kind==="tool_result"&&e.content)return e.content;if(n!=null&&n.output)return n.output}return r(e.content,t.content,e.timestamp,t.timestamp)}function OR(e,t){return{...uu(e,{...t,id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId}),id:e.id,rawRef:e.rawRef,timestamp:e.timestamp,sequence:e.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function Dp(e){var t;if(e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")){const n=((t=e.toolCall)==null?void 0:t.callId.trim())??"";if(n)return`toolCall:${n}`}if(e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")&&e.rawRef.startsWith("codex://")){const n=wo(e.rawRef);if(n)return`codexAssistantStream:${n}:${e.kind}:${e.sequence}`}return e.id?`id:${e.id}`:e.rawRef?`rawRef:${e.rawRef}`:`fallback:${e.role}:${e.kind}:${e.timestamp}:${e.sequence}`}function BR(e,t,n){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const r=bo(e.content),i=bo(t.content);return Bs(e.timestamp,t.timestamp,n)&&Pt(r.text)===Pt(i.text)&&YR(r.inlineImages,i.inlineImages)}function _R(e,t,n){return!e||n||!vo(e)||!vo(t)?!1:Bs(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function vo(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function du(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")}function WR(e){return du(e)&&e.kind==="text"}function Xb(e,t){return du(e)&&du(t)&&e.kind===t.kind&&Bs(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function FR(e,t,n,r){return!e||!t||!n||!r||!vo(e)||!vo(n)?!1:Xb(t,r)&&Bs(e.timestamp,n.timestamp,120*1e3)&&Pt(e.content)===Pt(n.content)}function Qb(e,t){var a,c;const n=((a=e.attachments)==null?void 0:a.length)??0,r=((c=t.attachments)==null?void 0:c.length)??0;if(n!==r)return n>r?e:t;const i=Pt(e.content).length,o=Pt(t.content).length;return i!==o?i>o?e:t:zr(e,t)}function $R(e,t){return!Op(e)||!Op(t)?!1:e.role===t.role&&Bs(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function zR(e,t){return!Bp(e)||!Bp(t)?!1:e.role===t.role&&Bs(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function Op(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Bp(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function UR(e,t){var u,d;const n=((u=e.attachments)==null?void 0:u.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const i=Pt(e.content).length,o=Pt(t.content).length;if(i!==o)return i>o?e:t;const a=e.rawRef.includes("#file="),c=t.rawRef.includes("#file=");return a!==c?a?e:t:zr(e,t)}function HR(e,t){var u,d;const n=((u=e.attachments)==null?void 0:u.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const i=Pt(e.content).length,o=Pt(t.content).length;if(i!==o)return i>o?e:t;const a=e.rawRef.includes("/context#"),c=t.rawRef.includes("/context#");return a!==c?a?e:t:zr(e,t)}function Xa(e,t){return e?t?{...qR(e,t),input:Zb(e.input,t.input),output:Wp(e.output,t.output),error:Wp(e.error,t.error)}:e:t}function qR(e,t){const n=_p(e.status),r=_p(t.status);return r!==n?r>n?t:e:t}function _p(e){return e==="running"?0:1}function Qa(e,t,n,r){const i=Pt(e),o=Pt(t);if(i===o){const a=VR(e,t);return a!==null?a:e.length>=t.length?e:t}return i.length>o.length&&i.includes(o)?e:o.length>i.length&&o.includes(i)||r.localeCompare(n)>=0?t:e}function Za(e,t){const n=(e==null?void 0:e.length)??0,r=(t==null?void 0:t.length)??0;return r!==n?r>n?t:e:t??e}function Zb(e,t){return t.length>e.length?t:e}function Wp(e,t){return e===null?t:t===null?e:Zb(e,t)}function zr(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function el(e,t){return Vb(e,t)<=0?e:t}function Pt(e){return KR(e).replace(/\r\n/g,`
|
|
49
|
-
`).trimEnd()}function hu(e){return Pt(e).replace(/[ \t]+\n/g,`
|
|
50
|
-
`).replace(/\n{2,}/g,`
|
|
51
|
-
`).trim()}function GR(e,t,n,r){return e!=="claude-code"&&e!=="codex"||t!=="user"&&t!=="assistant"||n!=="text"&&n!=="thinking"?r:ek(r)}function KR(e){return ek(e).replace(/\r\n/g,`
|
|
52
|
-
`).trimEnd()}function pu(e){return yR.test(e)}function ek(e){return pu(e)?e.replace(kR,"").replace(/[ \t]+\n/g,`
|
|
53
|
-
`).replace(/\n{3,}/g,`
|
|
54
|
-
|
|
55
|
-
`).trimEnd():e}function VR(e,t){const n=pu(e),r=pu(t);return n===r?null:n?t:e}function YR(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((n,r)=>{var i;return n.url===((i=t[r])==null?void 0:i.url)})}function JR(e,t,n){return rk(t)?tk(e,t,"optimistic",n):null}function XR(e,t,n){return vl(t)?tk(e,t,"authoritative",n):null}function QR(e,t,n){if(!tl(n))return null;for(const[r,i]of e.entries())if(!(r===n.id||!t.has(r)||!ZR(i,n)))return cs("session.messages.codex_identity_bridge_match",{previous:nn(i),incoming:nn(n)}),r;return null}function ZR(e,t){if(!nE(e,t))return!1;if(e.rawRef===t.rawRef)return!0;if(e.kind==="tool_call"||e.kind==="tool_result")return fd(e,t);const n=wo(e.rawRef),r=wo(t.rawRef);if(!n||!r||n!==r)return!1;const i=Math.abs(e.sequence-t.sequence);return i>1?(cs("session.messages.codex_identity_bridge_rejected",{reason:"sequence_distance",sequenceDistance:i,previous:nn(e),incoming:nn(t)}),!1):!0}function eE(e,t){if(!Fp(t))return null;const n=nl(t.rawRef);if(n===null)return null;const r=us(t.timestamp);let i=null,o=Number.POSITIVE_INFINITY;for(const[a,c]of e.entries()){if(a===t.id||!Fp(c)||c.role!==t.role)continue;if(nk(c,t))return a;if(c.kind!==t.kind||nl(c.rawRef)!==n)continue;const d=us(c.timestamp),h=Math.abs(d-r),g=Math.abs(c.sequence-t.sequence)*6e4+h;g<o&&(i=a,o=g)}return i}function tk(e,t,n,r){const i=us(t.timestamp),o=Pt(t.content),a=hu(t.content),c=fu(t.attachments);let u=null,d=Number.POSITIVE_INFINITY;const h=[];for(const[p,g]of e.entries()){if(!(n==="optimistic"?vl(g):rk(g)))continue;const k=Pt(g.content),S=hu(g.content),v=k===o,w=S===a;if(!v&&!w)continue;const R=us(g.timestamp),T=Math.abs(R-i);if(T>300*1e3)continue;const F=Math.abs(g.sequence-t.sequence),E=fu(g.attachments),I=sE(E,c);if(I==="conflict"&&(v||o.length===0)){h.push(zp(g,{strictTextMatches:v,relaxedTextMatches:w,attachmentCompatibility:I,distanceMs:T,sequenceDistance:F}));continue}const q=T+F*15e3+(v?0:500)+iE(I);h.push(zp(g,{strictTextMatches:v,relaxedTextMatches:w,attachmentCompatibility:I,distanceMs:T,sequenceDistance:F})),q<d&&(u=p,d=q)}return h.length>0&&cs("session.messages.user_match",{sessionId:r,target:n,matchedId:u,matchedScore:Number.isFinite(d)?d:null,incoming:oE(t,{relaxedContent:a,attachmentSignature:c}),candidates:h.slice(0,5)}),u}function tl(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.role==="assistant"||e.role==="tool")}function tE(e,t){const n=t.filter(tl);return n.length===0?e:e.map(r=>{if(!rE(r))return r;const i=us(r.timestamp),o=n.reduce((c,u)=>us(u.timestamp)<i?c:Math.min(c,u.sequence),Number.POSITIVE_INFINITY);if(!Number.isFinite(o)||o>=r.sequence)return r;const a={...r,sequence:o};return cs("session.messages.synthetic_user_rebased",{syntheticMessage:nn(r),rebasedMessage:nn(a),incomingAnchors:n.slice(0,5).map(nn)}),a})}function Fp(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&!vl(e)&&(e.role==="user"||e.role==="assistant"||e.role==="tool")}function $p(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")&&e.toolCall!==null}function nk(e,t){var i,o;if(!$p(e)||!$p(t))return!1;const n=((i=e.toolCall)==null?void 0:i.callId.trim())??"",r=((o=t.toolCall)==null?void 0:o.callId.trim())??"";return n&&r?n===r:nl(e.rawRef)===nl(t.rawRef)}function nl(e){if(!e.startsWith("opencode://"))return null;const t=e.indexOf("#"),n=t>=0?e.slice(t):"",r=t>=0?e.slice(0,t):e,i=r.indexOf("?");if(i<0)return e;const o=r.slice(0,i),a=new URLSearchParams(r.slice(i+1));if(!a.has("part"))return e;a.delete("part");const c=a.toString();return`${o}${c?`?${c}`:""}${n}`}function nE(e,t){if(!tl(e)||!tl(t)||e.role!==t.role)return!1;const n=(e.kind==="tool_call"||e.kind==="tool_result")&&(t.kind==="tool_call"||t.kind==="tool_result");return!n&&e.kind!==t.kind?!1:n?fd(e,t):Math.abs(e.sequence-t.sequence)>bR||!Bs(e.timestamp,t.timestamp,Ep)?!1:t.kind==="text"||t.kind==="thinking"?BR(e,t,Ep):!1}function fd(e,t){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!=="tool"||t.role!=="tool"||e.kind!=="tool_call"&&e.kind!=="tool_result"||t.kind!=="tool_call"&&t.kind!=="tool_result"||e.toolCall===null||t.toolCall===null)return!1;const n=e.toolCall.callId.trim(),r=t.toolCall.callId.trim();return n.length>0&&n===r}function vl(e){return e.role!=="user"||e.kind!=="text"||e.deliveryState==="failed"?!1:e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic")}function rE(e){return e.deliveryState==="sent"&&e.role==="user"&&e.kind==="text"&&e.rawRef.startsWith("synthetic://codex/")}function rk(e){return e.role==="user"&&e.kind==="text"&&!vl(e)}function us(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function nn(e){var t;return{id:e.id,rawRef:e.rawRef,role:e.role,kind:e.kind,sequence:e.sequence,timestamp:e.timestamp,callId:((t=e.toolCall)==null?void 0:t.callId)??null,contentPreview:e.kind==="text"||e.kind==="thinking"?Pt(bo(e.content).text).slice(0,160):Pt(e.content).slice(0,160)}}function fu(e){return(e??[]).map(t=>[t.kind,t.fileName.trim().toLowerCase(),t.mimeType.trim().toLowerCase(),String(t.fileSize)].join(":")).sort().join("|")}function sE(e,t){return!e&&!t?"same":!e||!t?"one_side_missing":e===t?"same":"conflict"}function iE(e){switch(e){case"same":return 0;case"one_side_missing":return 2500;case"conflict":default:return 12e4}}function zp(e,t){return{...nn(e),comparableContent:hu(e.content).slice(0,160),attachmentSignature:fu(e.attachments),strictTextMatches:t.strictTextMatches,relaxedTextMatches:t.relaxedTextMatches,attachmentCompatibility:t.attachmentCompatibility,distanceMs:t.distanceMs,sequenceDistance:t.sequenceDistance}}function oE(e,t){return{...nn(e),comparableContent:t.relaxedContent.slice(0,160),attachmentSignature:t.attachmentSignature}}function OO(e){return e.reduce((n,r)=>Number.isFinite(r.sequence)&&r.sequence>n?r.sequence:n,0)+1}function Bs(e,t,n){return Math.abs(us(e)-us(t))<=n}const aE=200;async function lE(e){const t=[],n=new Set;let r=null;for(;!(r&&n.has(r));){r&&n.add(r);const i=await wm(e,r,aE,"forward"),o=i.messages.map(a=>qb(e,a));if(t.push(...o),!i.nextCursor||i.nextCursor===r||o.length===0)break;r=i.nextCursor}return{messages:t}}function Cc(e,t,n=new Date){return`${gE(e.title||l("conversation.titleFallback"))}-${mE(n)}.${t}`}function cE(e,t,n=new Date){const i=[`# ${(e.title||l("conversation.titleFallback")).trim()||l("conversation.titleFallback")}`,"",`${l("conversation.exportMarkdownSessionIdLabel")}:\`${e.sessionId}\``,`${l("conversation.exportMarkdownProviderLabel")}:${e.provider}`,`${l("conversation.exportMarkdownWorkspaceLabel")}:\`${e.workspaceId}\``,`${l("conversation.exportMarkdownCreatedAtLabel")}:${xi(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${xi(n.toISOString())}`,""];return t.forEach((o,a)=>{var c,u,d;i.push(`## ${a+1}. ${sk(o)}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownTimeLabel")}:${xi(o.timestamp)}`),i.push(`- ${l("conversation.exportMarkdownTypeLabel")}:${fE(o)}`),(((c=o.attachments)==null?void 0:c.length)??0)>0&&i.push(`- ${l("conversation.exportMarkdownAttachmentsLabel")}:${o.attachments.length}`),i.push(""),o.content.trim()&&(i.push(o.content),i.push("")),o.toolCall&&(i.push(`### ${l("conversation.exportMarkdownToolSectionTitle")}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownToolNameLabel")}:${o.toolCall.name}`),i.push(`- ${l("conversation.exportMarkdownToolStatusLabel")}:${o.toolCall.status}`),i.push(""),o.toolCall.input.trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolInputLabel")}`),i.push(""),i.push("```text"),i.push(o.toolCall.input),i.push("```"),i.push("")),(o.toolCall.output??"").trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolOutputLabel")}`),i.push(""),i.push("```text"),i.push(o.toolCall.output??""),i.push("```"),i.push("")),(o.toolCall.error??"").trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolErrorLabel")}`),i.push(""),i.push("```text"),i.push(o.toolCall.error??""),i.push("```"),i.push(""))),(((u=o.attachments)==null?void 0:u.length)??0)>0&&(i.push(`### ${l("conversation.exportMarkdownAttachmentsSectionTitle")}`),i.push(""),(d=o.attachments)==null||d.forEach(h=>{i.push(`- ${h.fileName} (${h.kind}, ${h.mimeType}, ${ik(h.fileSize)})`)}),i.push(""))}),`${i.join(`
|
|
56
|
-
`).trimEnd()}
|
|
57
|
-
`}function Up(e,t,n="text/plain;charset=utf-8"){if(typeof document>"u")throw new Error(l("conversation.exportDownloadFailed"));const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.append(o),o.click(),o.remove(),URL.revokeObjectURL(i)}function uE(e,t,n="application/octet-stream"){if(typeof document>"u")throw new Error(l("conversation.exportDownloadFailed"));const r=new Uint8Array(t.byteLength);r.set(t);const i=new Blob([r],{type:n}),o=URL.createObjectURL(i),a=document.createElement("a");a.href=o,a.download=e,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(o)}function dE(e,t,n=new Date){const r=(e.title||l("conversation.titleFallback")).trim()||l("conversation.titleFallback"),i=[`${l("conversation.exportMarkdownSessionIdLabel")}:${e.sessionId}`,`${l("conversation.exportMarkdownProviderLabel")}:${e.provider}`,`${l("conversation.exportMarkdownWorkspaceLabel")}:${e.workspaceId}`,`${l("conversation.exportMarkdownCreatedAtLabel")}:${xi(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${xi(n.toISOString())}`],o=new wE;return o.renderDocumentHeader(r,i),t.forEach((a,c)=>{o.renderMessageCard(c,a)}),RE(o.finish())}function hE(e){const t=Hp(e.htmlAttributes,e.htmlStyle),n=Hp(e.bodyAttributes,e.bodyStyle);return["<!DOCTYPE html>",`<html${t}>`,"<head>",'<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${ok(e.title)}</title>`,`<style>${e.styleText}</style>`,"</head>",`<body${n}>`,e.bodyHtml,"</body>","</html>"].join("")}function sk(e){return`${pE(e)} · ${xi(e.timestamp)}`}function pE(e){switch(e.role){case"user":return l("conversation.roleUser");case"assistant":return l("conversation.roleAssistant");case"tool":return l("conversation.roleTool");case"system":default:return l("conversation.roleSystem")}}function fE(e){return e.kind==="thinking"?l("conversation.thinkingLabel"):e.kind==="tool_call"?l("conversation.exportMarkdownToolCallType"):e.kind==="tool_result"?l("conversation.exportMarkdownToolResultType"):l("conversation.exportMarkdownTextType")}function xi(e){const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function mE(e){const t=String(e.getFullYear()),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`${t}${n}${r}-${i}${o}${a}`}function ik(e){return!Number.isFinite(e)||e<0?l("conversation.exportMarkdownUnknownSize"):e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function gE(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-")||"session"}function Hp(e,t){const n=Object.entries(e??{}).filter(([,r])=>r.trim().length>0);return t!=null&&t.trim()&&n.push(["style",t.trim()]),n.length===0?"":` ${n.map(([r,i])=>`${r}="${bE(i)}"`).join(" ")}`}function ok(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function bE(e){return ok(e).replaceAll('"',""")}const ak=595.28,no=841.89,qp=40,Gp=40,ui=36,lk=ak-ui*2,kE=14,mu=12,ua=12,yE=72,da=11,mi=9,Ji=12,Kp=20;class wE{constructor(){Qe(this,"pages",[[]]);Qe(this,"cursorTop",qp)}renderDocumentHeader(t,n){this.drawRichText(t,ui,this.cursorTop,Kp,[15,23,42],"sans"),this.cursorTop+=Kp+8,n.forEach(r=>{this.drawRichText(r,ui,this.cursorTop,mi,[71,85,105],"sans"),this.cursorTop+=ns(mi)}),this.cursorTop+=18}renderMessageCard(t,n){const r=xE(t,n);let i=0,o=0;for(;i<r.lines.length||o===0;){this.ensureVerticalSpace(yE);const a=this.pickSegmentLines(r.lines,i);a.count===0&&r.lines.length>0&&(a.lines.push(r.lines[i]),a.count=1,a.height=ns(r.lines[i].fontSize));const c=o===0?r.header:`${r.header} · 续`,u=ua*2+ns(Ji)+8+Math.max(a.height,0);if(this.ensureVerticalSpace(u),this.drawCardSegment(r,c,a.lines,a.height),this.cursorTop+=u+kE,i+=a.count,o+=1,r.lines.length===0)break}}finish(){return this.pages.map(t=>t.join(`
|
|
58
|
-
`))}drawCardSegment(t,n,r,i){const o=ua*2+ns(Ji)+8+Math.max(i,0),a=this.cursorTop,c=no-a-o;this.pushCommand(`${ha(t.backgroundColor)} rg ${ha(t.borderColor)} RG 1 w ${Wn(ui)} ${Wn(c)} ${Wn(lk)} ${Wn(o)} re B`);let u=a+ua;this.drawRichText(n,ui+mu,u,Ji,t.headerColor,"sans"),u+=ns(Ji)+8,r.forEach(d=>{u+=d.gapBefore,this.drawRichText(d.text,ui+mu,u,d.fontSize,d.color,d.fontKind),u+=ns(d.fontSize)})}pickSegmentLines(t,n){const r={lines:[],count:0,height:0},i=no-this.cursorTop-Gp-ua*2-ns(Ji)-8;if(i<=0)return r;let o=0;for(let a=n;a<t.length;a+=1){const c=t[a],u=o+c.gapBefore+ns(c.fontSize);if(r.count>0&&u>i)break;r.lines.push(c),r.count+=1,o=u}return r.height=o,r}ensureVerticalSpace(t){this.cursorTop+t<=no-Gp||(this.pages.push([]),this.cursorTop=qp)}drawRichText(t,n,r,i,o,a){const c=no-r-i;let u=n;NE(t).forEach(h=>{if(h.text){if(h.fontRef==="F1"){u=this.drawPdfUnicodeRun(h.text,u,c,i,o);return}this.pushCommand(`BT /${h.fontRef} ${Wn(i)} Tf ${ha(o)} rg 1 0 0 1 ${Wn(u)} ${Wn(c)} Tm (${AE(h.text)}) Tj ET`),u+=TE(h.text,i,h.fontRef)}})}drawPdfUnicodeRun(t,n,r,i,o){let a=n;for(const c of Array.from(t))this.pushCommand(`BT /F1 ${Wn(i)} Tf ${ha(o)} rg 1 0 0 1 ${Wn(a)} ${Wn(r)} Tm <${CE(c)}> Tj ET`),a+=md(c,i,"F1");return a}pushCommand(t){var n;(n=this.pages[this.pages.length-1])==null||n.push(t)}}function xE(e,t){var a,c;const n=vE(t.role),r=lk-mu*2,i=[],o=`${e+1}. ${sk(t)}`;if(t.content.trim()&&ts(i,t.content,r,da,[15,23,42],0,"sans"),t.toolCall){const u=`${l("conversation.exportMarkdownToolSectionTitle")} · ${t.toolCall.name} · ${t.toolCall.status}`;ts(i,u,r,da,[30,41,59],10,"sans"),t.toolCall.input.trim()&&ts(i,`${l("conversation.exportMarkdownToolInputLabel")}:${t.toolCall.input}`,r,mi,[71,85,105],6,"mono"),(t.toolCall.output??"").trim()&&ts(i,`${l("conversation.exportMarkdownToolOutputLabel")}:${t.toolCall.output??""}`,r,mi,[71,85,105],6,"mono"),(t.toolCall.error??"").trim()&&ts(i,`${l("conversation.exportMarkdownToolErrorLabel")}:${t.toolCall.error??""}`,r,mi,[185,28,28],6,"mono")}return(((a=t.attachments)==null?void 0:a.length)??0)>0&&(ts(i,l("conversation.exportMarkdownAttachmentsSectionTitle"),r,da,[30,41,59],10,"sans"),(c=t.attachments)==null||c.forEach(u=>{ts(i,`- ${u.fileName} (${u.kind}, ${u.mimeType}, ${ik(u.fileSize)})`,r,mi,[71,85,105],4,"sans")})),i.length===0&&ts(i,l("conversation.exportMarkdownTextType"),r,da,[100,116,139],0,"sans"),{header:o,headerColor:n.headerColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,lines:i}}function vE(e){switch(e){case"user":return{headerColor:[30,64,175],backgroundColor:[239,246,255],borderColor:[191,219,254]};case"tool":return{headerColor:[6,95,70],backgroundColor:[236,253,245],borderColor:[167,243,208]};case"system":return{headerColor:[71,85,105],backgroundColor:[248,250,252],borderColor:[226,232,240]};case"assistant":default:return{headerColor:[15,23,42],backgroundColor:[255,255,255],borderColor:[226,232,240]}}}function ts(e,t,n,r,i,o=0,a="sans"){t.replace(/\r\n/g,`
|
|
59
|
-
`).split(`
|
|
60
|
-
`).forEach((d,h)=>{const p=SE(d,n,r);if(p.length===0){e.push({text:" ",fontSize:r,color:i,gapBefore:h===0?o:4,fontKind:a});return}p.forEach((g,m)=>{e.push({text:g,fontSize:r,color:i,gapBefore:h===0&&m===0?o:m===0?4:0,fontKind:a})})})}function SE(e,t,n,r){if(!e.trim())return[];const i=[];let o="",a=0;const c=ck();for(const u of Array.from(e)){const d=md(u,n,c);if(o&&a+d>t){i.push(o.trimEnd()),o=u,a=d;continue}o+=u,a+=d}return o.trim().length>0&&i.push(o.trimEnd()),i}function md(e,t,n){if(n==="F1")return t*(IE(e)/1e3);const r=n==="F3"?600:uk[e]??556;return t*(r/1e3)}function ns(e){return e*1.5}function ha(e){return e.map(t=>Wn(t/255)).join(" ")}function Wn(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/u,"").replace(/\.$/u,"")}function CE(e){return[254,255,...Array.from(e).flatMap(r=>{const i=r.codePointAt(0)??32;if(i<=65535)return[i];const o=i-65536,a=55296+(o>>10&1023),c=56320+(o&1023);return[a,c]}).flatMap(r=>[r>>8&255,r&255])].map(r=>r.toString(16).padStart(2,"0").toUpperCase()).join("")}function NE(e,t){if(!e)return[];const n=ck();return[{text:e,fontRef:n}]}function ck(e,t){return"F1"}function jE(e){const t=e.codePointAt(0)??0;return t>=32&&t<=126}function TE(e,t,n){return Array.from(e).reduce((r,i)=>r+md(i,t,n),0)}function IE(e){return jE(e)?uk[e]??556:e===" "?278:1e3}function AE(e){return e.replace(/\\/gu,"\\\\").replace(/\(/gu,"\\(").replace(/\)/gu,"\\)")}const uk={" ":278,"!":278,'"':355,"#":556,$:556,"%":889,"&":667,"'":191,"(":333,")":333,"*":389,"+":584,",":278,"-":333,".":278,"/":278,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,":":278,";":278,"<":584,"=":584,">":584,"?":556,"@":1015,A:667,B:667,C:722,D:722,E:667,F:611,G:778,H:722,I:278,J:500,K:667,L:556,M:833,N:722,O:778,P:667,Q:778,R:722,S:667,T:611,U:722,V:667,W:944,X:667,Y:667,Z:611,"[":278,"\\":278,"]":278,"^":469,_:556,"`":333,a:556,b:556,c:500,d:556,e:556,f:278,g:556,h:556,i:222,j:222,k:500,l:222,m:833,n:556,o:556,p:556,q:556,r:333,s:500,t:278,u:556,v:500,w:722,x:500,y:500,z:500,"{":334,"|":260,"}":334,"~":584};function RE(e){const t=[],n=[];t[1]="<< /Type /Catalog /Pages 2 0 R >>",t[3]="<< /Type /Font /Subtype /Type0 /BaseFont /STSong-Light /Encoding /UniGB-UCS2-H /DescendantFonts [4 0 R] >>",t[4]="<< /Type /Font /Subtype /CIDFontType0 /BaseFont /STSong-Light /CIDSystemInfo << /Registry (Adobe) /Ordering (GB1) /Supplement 4 >> /DW 1000 >>",t[5]="<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",t[6]="<< /Type /Font /Subtype /Type1 /BaseFont /Courier >>";let c=7;e.forEach(k=>{const S=c,v=c+1;n.push(S),c+=2;const w=new TextEncoder().encode(k);t[v]=`<< /Length ${w.length} >>
|
|
61
|
-
stream
|
|
62
|
-
${k}
|
|
63
|
-
endstream`,t[S]=["<< /Type /Page","/Parent 2 0 R",`/MediaBox [0 0 ${Wn(ak)} ${Wn(no)}]`,"/Resources << /Font << /F1 3 0 R /F2 5 0 R /F3 6 0 R >> >>",`/Contents ${v} 0 R`,">>"].join(" ")}),t[2]=`<< /Type /Pages /Kids [${n.map(k=>`${k} 0 R`).join(" ")}] /Count ${n.length} >>`;const u=t.filter(Boolean).length,d=[`%PDF-1.4
|
|
64
|
-
%----
|
|
65
|
-
`],h=[0];let p=new TextEncoder().encode(d[0]).length;for(let k=1;k<t.length;k+=1){const S=t[k];if(!S)continue;h[k]=p;const v=`${k} 0 obj
|
|
66
|
-
${S}
|
|
67
|
-
endobj
|
|
68
|
-
`;d.push(v),p+=new TextEncoder().encode(v).length}const g=p,m=["xref",`0 ${u+1}`,"0000000000 65535 f "];for(let k=1;k<h.length;k+=1){const S=h[k];typeof S=="number"&&m.push(`${String(S).padStart(10,"0")} 00000 n `)}return d.push(`${m.join(`
|
|
69
|
-
`)}
|
|
70
|
-
`),d.push(["trailer",`<< /Size ${u+1} /Root 1 0 R >>`,"startxref",String(g),"%%EOF"].join(`
|
|
71
|
-
`)),new TextEncoder().encode(d.join(""))}const Vp=48;function EE(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function gd(e,t){const n=EE(e)||t,r=n.length>Vp?n.slice(0,Vp).trimEnd():n;return{fullTitle:n,displayTitle:r}}function pa(e,t){return(t??"").localeCompare(e??"")}function Yp(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function fa(e){return(e==null?void 0:e.trim())??""}function So(e,t,n){if(n==="updatedAt"){const a=pa(e.updatedAt,t.updatedAt);if(a!==0)return a}if(n==="title"){const a=Yp(fa(e.title),fa(t.title));if(a!==0)return a}else{const a=pa(e.createdAt,t.createdAt);if(a!==0)return a}const r=pa(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=pa(e.createdAt,t.createdAt);if(i!==0)return i;const o=Yp(fa(e.title),fa(t.title));return o!==0?o:e.sessionId.localeCompare(t.sessionId)}function Eo(e,t){return[...e].sort((n,r)=>So(n,r,t))}function bd(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:Eo(n.sessions,t),children:bd(n.children,t)})):[]}const Nc=5,jc=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function PE(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function ME(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,Nc).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:jc[u]??jc[0]})),o=e.slice(Nc);if(o.length===0)return i;const a=o.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:a,ratio:a/n,color:jc[Nc]}),i}function LE(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,i)=>{const o=t,a=i===e.length-1?1:Math.min(1,t+r.ratio);return t=a,`${r.color} ${Jp(o)} ${Jp(a)}`}).join(", ")})`}function DE(e){return{"--workbench-manage-chart-background":LE(e)}}function Jp(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const OE=8,BE=12,_E=160,Xp=96;function WE(e,t,n,r={}){const i=r.gapPx??OE,o=r.viewportMarginPx??BE,a=r.defaultWidthPx??_E,c=r.estimatedHeightPx??Xp,u=r.minHeightPx??Xp,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-o*2),g=Math.max(0,d-o*2),m=ma(Math.max(t.width||a,a),0,g),k=Math.max(t.height||c,c),S=Math.max(0,d-e.x-o),v=Math.max(0,e.x-o),w=S<m&&v>S,R=Math.max(0,h-e.y-i-o),T=Math.max(0,e.y-i-o),F=R<k&&T>R,I=ma(Math.max(F?T:R,u),0,p),q=Math.min(k,I),z=w?e.x-m:e.x,L=Math.max(o,d-o-m),A=F?e.y-i-q:e.y+i,U=Math.max(o,h-o-q),B=ma(z,o,L),le=ma(A,o,U),V=w||B<e.x?"right":"left";return{top:le,left:B,width:m,maxHeight:Math.max(0,I),transformOrigin:`${F?"bottom":"top"} ${V}`}}function ma(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const dk="workbench.navigation.snapshot",hk=1800*1e3,FE="workbench.navigation.snapshot.host.";function pk(e){return`${FE}${e}`}function $E(e=hk,t=ol(ir.getState())){if(t){const n=Wa(pk(t),e);if(n)return n}return Wa(dk,e)}function ga(e,t=ol(ir.getState())){io(dk,e),t&&io(pk(t),e)}function Qp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:Eo(n.sessions,t),childWorktrees:zE(n.childWorktrees,t)}))}function zE(e,t){return bd(e,t)}function rl(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function UE(e){const t=new Map;for(const n of e)t.set(n.workspace.id,rl(n.workspace)),fk(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function Wr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function fk(e,t,n,r,i=r.name){var o;for(const a of t){const c=((o=a.meta.displayName)==null?void 0:o.trim())||a.workspace.name;e.set(a.workspace.id,{workspaceId:a.workspace.id,tone:"worktree",backgroundColor:a.workspace.backgroundColor??null,displayName:c,workspaceName:a.workspace.name,branchName:a.meta.branchName||null,depth:a.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:a.meta.parentWorkspaceId||r.id,parentDisplayName:i}),fk(e,a.children,n,a.workspace,c)}}function mk(e,t=!0){const n=f.useMemo(()=>xh(e),[e]),{items:r,loading:i,requested:o}=$m(t),a=f.useMemo(()=>{if(!r)return o&&!i?n:[];const c=new Set(n),u=r.filter(d=>d.enabled&&c.has(d.provider)).map(d=>d.provider);return xh(u)},[n,r]);return{providerCatalog:r,visibleProviders:a,loading:i,ready:r!==null||o&&!i}}const kd=new Map;function HE(){kd.clear()}function qE({disabled:e=!1,workspaceId:t=null,pendingProvider:n=null,selectedProvider:r=null,providers:i=Fu,className:o,disabledReasons:a,statusHintByProvider:c,onSelect:u}){const d=dl(),{visibleProviders:h,ready:p}=mk(i),g=!!t,[m,k]=f.useState(()=>Zp(h,t)),S=h.map(v=>({provider:v}));return f.useEffect(()=>{sg()},[]),f.useEffect(()=>{if(!p){k({});return}if(!t){k({});return}const v=Zp(h,t);k(v);const w=h.filter(T=>!v[T]);if(w.length===0)return;let R=!1;return ym(w,t).then(T=>{KE(t,T),R||k(F=>({...F,...T}))}),()=>{R=!0}},[p,h,t]),p?s.jsx("div",{className:`session-provider-grid${o?` ${o}`:""}`,children:S.map(v=>{const w=za(v.provider,"full"),R=n===v.provider,T=r===v.provider,F=!!m[v.provider],E=GE(m[v.provider]??null),I=(a==null?void 0:a[v.provider])??E,q=R?l("shell.startingSession"):I||((c==null?void 0:c[v.provider])??(g&&!F&&!R?l("shell.providerChecking"):null));return s.jsxs("button",{type:"button",className:"session-provider-card","data-provider":v.provider,"data-pending":R?"true":"false","data-selected":T?"true":"false","aria-label":w,disabled:e||!!I,onClick:()=>{d.trigger("action"),u(v.provider)},children:[s.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:s.jsx("img",{src:dS(v.provider),alt:"",loading:"eager",decoding:"async"})}),s.jsxs("span",{className:"session-provider-card-copy",children:[s.jsx("strong",{children:w}),q?s.jsx("span",{className:"session-provider-card-status",children:q}):null]})]},v.provider)})}):s.jsx("div",{className:`session-provider-grid${o?` ${o}`:""}`,children:s.jsx("div",{className:"session-provider-card","aria-hidden":"true","data-placeholder":"true",children:s.jsx("span",{className:"session-provider-card-copy",children:s.jsx("strong",{children:l("shell.providerChecking")})})})})}function GE(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??l("conversation.capabilityDenied")}function Zp(e,t){const n=(t==null?void 0:t.trim())??"";if(!n)return{};const r=[];for(const i of e){const o=kd.get(gk(n,i));o&&r.push([i,o])}return Object.fromEntries(r)}function KE(e,t){const n=e.trim();if(n)for(const[r,i]of Object.entries(t))i&&kd.set(gk(n,r),i)}function gk(e,t){return`${e}::${t}`}class gu extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class VE{constructor(){Qe(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=ir.getState();if(ol(n)===t)return;const r=my(n,t);if(!r)throw new gu("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await gy(r.baseUrl)).reachable)throw new gu("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const o=tm(r.id);if(o)try{await ho.loginForHost(r,{username:o.username,password:o.password})}catch{}const a=ir.getState(),c=new Date().toISOString();if(nm(r)){ir.updateRuntime({discoveredHosts:a.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}Bc.setActiveDiscoveredHost(null),await ir.update({hosts:a.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const YE=new VE;function JE(){const e=al(n=>n),t=by(n=>n);return XE(e,t)}function XE(e,t){var a;const n=Oa(e);if(!n)return null;const r=!!((a=n.relayTunnel)!=null&&a.enabled),o=!(e.platform==="web"&&r)&&t.activeHostId===n.id&&t.candidateProbePhase==="ready"?ZE(t):null;if(o){const c=eP(o.kind);return{kind:c,url:o.url,endpointId:o.endpointId,autoDirect:r&&c!=="relay",probeInProgress:!1}}return{kind:tP(n),url:n.baseUrl,endpointId:null,autoDirect:!1,probeInProgress:r&&t.activeHostId===n.id&&t.candidateProbePhase==="probing"}}function QE(e){switch(e){case"relay":return"common.connectionRouteRelay";case"lan":return"common.connectionRouteLan";case"loopback":return"common.connectionRouteLoopback";case"tailscale":return"common.connectionRouteTailscale";default:return"common.connectionRouteDirect"}}function ZE(e){const t=e.preferredDirectCandidateEndpointId??e.preferredCandidateEndpointId;return t?e.candidateEndpoints.find(n=>n.endpointId===t&&n.status==="verified")??null:null}function eP(e){return e==="custom"?"direct":e}function tP(e){var t;if((t=e.relayTunnel)!=null&&t.enabled&&nP(e.baseUrl,e.relayTunnel.tunnelDomain))return"relay";try{const n=new URL(e.baseUrl).hostname.toLowerCase();if(rP(n))return"loopback";if(sP(n))return"tailscale";if(iP(n))return"lan"}catch{return"direct"}return e.kind==="local"?"loopback":e.kind==="lan"?"lan":"direct"}function nP(e,t){try{return new URL(e).hostname.toLowerCase()===t.trim().toLowerCase()}catch{return!1}}function rP(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function sP(e){if(e.endsWith(".ts.net"))return!0;const t=e.split(".").map(i=>Number(i));if(t.length!==4||t.some(i=>Number.isNaN(i)))return!1;const[n,r]=t;return n===100&&r>=64&&r<=127}function iP(e){const t=e.split(".").map(i=>Number(i));if(t.length!==4||t.some(i=>Number.isNaN(i)))return!1;const[n,r]=t;return n===10||n===192&&r===168||n===172&&r>=16&&r<=31}const oP=1700;function aP({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:o,popoverRef:a,children:c,maxWidth:u=360,gap:d=10,viewportPadding:h=16}){const[p,g]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){g(null);return}let k=0;const S=()=>{const w=o.current;if(!w)return;const R=w.getBoundingClientRect(),T=Math.max(180,Math.min(u,window.innerWidth-h*2)),F=Math.min(Math.max(h,R.right-T),Math.max(h,window.innerWidth-h-T)),E=R.top>=Math.min(240,window.innerHeight*.42),I=Math.round(E?R.top-d:R.bottom+d);g({top:I,left:Math.round(F),width:T,placeAbove:E})},v=()=>{window.cancelAnimationFrame(k),k=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),()=>{window.cancelAnimationFrame(k),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}},[o,d,u,e,h]),!e||!p||typeof document>"u")return null;const m={position:"fixed",top:p.top,left:p.left,width:p.width,maxWidth:`calc(100vw - ${h*2}px)`,zIndex:oP,transform:p.placeAbove?"translateY(-100%)":void 0};return $r.createPortal(s.jsx("div",{id:t,ref:a,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:m,children:c}),document.body)}const Tc={status:"idle",latencyMs:null};function bk({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[o,a]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,g]=f.useState(""),[m,k]=f.useState(null),[S,v]=f.useState(null),[w,R]=f.useState(null),[T,F]=f.useState(!1),[E,I]=f.useState(!1),[q,z]=f.useState(Tc),[L,A]=f.useState(null),U=f.useRef(null),B=f.useRef(null),le=f.useRef(null),V=f.useRef(null),X=al(_=>_),J=Cu(_=>_.session),{showToast:O}=ar(),K=Oa(X),ce=ol(X),N=JE(),De=ky(ce),ee=f.useMemo(()=>ef(X.hosts,ce),[ce,X.hosts]),j=f.useMemo(()=>ef(rm(X),ce),[ce,X]),be=f.useCallback(()=>{if(typeof window>"u")return;const _=U.current;if(!_)return;const G=_.getBoundingClientRect(),Q=window.innerWidth,Ce=window.innerHeight,Ae=16,ve=8,rt=Math.min(320,Math.max(240,Q-Ae*2)),gt=Math.min(e?Math.max(Ae,G.right+ve):Math.max(Ae,G.left),Math.max(Ae,Q-rt-Ae)),ae=r?440:240,ie=e?G.top:G.bottom+ve,ke=Math.min(Math.max(Ae,ie),Math.max(Ae,Ce-ae-Ae));A({position:"fixed",top:ke,left:gt,width:rt,maxWidth:Q-Ae*2})},[e,r]);f.useEffect(()=>{if(!t){A(null),F(!1),z(Tc);return}Bc.refresh();function _(Q){var Ce,Ae,ve;Q.target instanceof Node&&!((Ce=U.current)!=null&&Ce.contains(Q.target))&&!((Ae=B.current)!=null&&Ae.contains(Q.target))&&!((ve=V.current)!=null&&ve.contains(Q.target))&&(n(!1),i(!1),F(!1),R(null))}function G(Q){Q.key==="Escape"&&(n(!1),i(!1),F(!1),R(null))}return window.addEventListener("pointerdown",_),window.addEventListener("keydown",G),window.addEventListener("resize",be),window.addEventListener("scroll",be,!0),be(),()=>{window.removeEventListener("pointerdown",_),window.removeEventListener("keydown",G),window.removeEventListener("resize",be),window.removeEventListener("scroll",be,!0)}},[t,be]),f.useEffect(()=>{if(!T||!t||(N==null?void 0:N.kind)!=="relay"){z(Tc);return}let _=!1;const G=performance.now();return z({status:"probing",latencyMs:null}),Y.request("/api/client/runtime-config").then(()=>{_||z({status:"ready",latencyMs:performance.now()-G})}).catch(()=>{_||z({status:"error",latencyMs:null})}),()=>{_=!0}},[N==null?void 0:N.kind,T,t]);async function re(_){if(m||S||_.id===ce){n(!1);return}k(_.id);try{await YE.switchHost(_.id),n(!1),i(!1),F(!1),R(null)}catch(G){O({title:hP(G,_.name),tone:"error"})}finally{k(null)}}async function fe(_){if(!(_.id===ce||m||S)){if(w!==_.id){R(_.id);return}v(_.id);try{await ir.update({hosts:X.hosts.filter(G=>G.id!==_.id)}),yy(_.id),ho.clearHostSession(_.id),R(null),O({title:l("shell.hostDeleteSuccess",{name:_.name})})}catch{O({title:l("shell.hostDeleteFailed",{name:_.name}),tone:"error"})}finally{v(null)}}}async function de(){if(E)return;const _=o.trim(),G=d.trim();if((G.length>0||p.length>0)&&(!G||!p)){O({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Ce;try{Ce=wy(c)}catch{O({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const Ae=await _y(Ce),ve=ir.getState(),Tt=Oa(ve);if(Ae?ve.hosts.find(ke=>{var ye;return ke.baseUrl===Ce||!!Ae.bindingId&&((ye=ke.relayTunnel)==null?void 0:ye.bindingId)===Ae.bindingId}):ve.hosts.find(ke=>ke.baseUrl===Ce)){O({title:l("shell.hostAddDuplicate"),tone:"error"});return}const gt=nm(Tt)&&Tt.baseUrl===Ce;gt&&Bc.setActiveDiscoveredHost(null);let ae,ie;if(Ae){const ye=(await ir.update(Wy(ve,Ae,{activate:gt,displayName:_}))).hosts.find(Re=>uP(Re,Ce,Ae.bindingId??null));if(!ye)throw new Error("relay entry host missing after save");ae=ye.id,ie=ye.name}else{const ke=new Date().toISOString(),ye={id:dP(),name:_||lP(Ce),baseUrl:Ce,kind:cP(Ce),createdAt:ke,updatedAt:ke,lastConnectedAt:null,lastUserId:null,lastUsername:null};await ir.update({hosts:[...ve.hosts,ye],activeHostId:gt?ye.id:ve.activeHostId}),ae=ye.id,ie=ye.name}G&&p&&xy({hostId:ae,username:G,password:p}),Ue(),i(!1),R(null),O({title:l("shell.hostAddSuccess",{name:ie})})}catch{O({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function Ue(){a(""),u(""),h(""),g("")}if(!K)return null;const He=J!=null&&J.user.username?`${K.baseUrl} · ${J.user.username}`:K.baseUrl,je=(N==null?void 0:N.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),Te=N?l(QE(N.kind)):l("common.unknown");return s.jsxs("div",{ref:U,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[s.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:He,"aria-expanded":t,onClick:()=>{n(_=>!_),i(!1)},children:s.jsx(mP,{})}),t&&L&&typeof document<"u"?$r.createPortal(s.jsxs("div",{ref:B,className:"workbench-host-switcher-menu",style:L,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[s.jsx("div",{className:"workbench-host-switcher-menu-header",children:s.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-list",children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),ee.map(_=>{const G=_.id===ce,Q=G?(J==null?void 0:J.user.username)??_.lastUsername??_.baseUrl:_.lastUsername??_.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":G,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{re(_)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[_.name,G?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Q})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===_.id?l("shell.hostSwitcherSwitching"):G?s.jsx(nf,{}):s.jsx(tf,{})})]}),G?s.jsx("button",{ref:le,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:_.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ce=>!Ce),R(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:_.name}),title:w===_.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":w===_.id,disabled:m!==null||S!==null,onClick:()=>{fe(_)},children:S===_.id?l("shell.hostDeleteBusy"):w===_.id?l("shell.hostDeleteConfirmAction"):s.jsx(bP,{})})]},_.id)}),j.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),j.map(_=>{const G=_.id===ce,Q=tm(_.id),Ce=G?(J==null?void 0:J.user.username)??(Q==null?void 0:Q.username)??_.baseUrl:(Q==null?void 0:Q.username)??_.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":G,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{re(_)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[_.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),G?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Ce})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===_.id?l("shell.hostSwitcherSwitching"):G?s.jsx(nf,{}):s.jsx(tf,{})})]}),G?s.jsx("button",{ref:le,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:_.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ae=>!Ae),R(null)},children:l("shell.hostSwitcherDetailAction")}):null]},_.id)})]}):null,X.localHostDiscovery.status==="refreshing"?s.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,X.localHostDiscovery.status==="failed"?s.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?s.jsxs("div",{className:"workbench-host-switcher-form",children:[s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),s.jsx("input",{value:o,disabled:E,onChange:_=>a(_.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),s.jsx("input",{value:c,disabled:E,onChange:_=>u(_.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.username")}),s.jsx("input",{value:d,disabled:E,onChange:_=>h(_.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.password")}),s.jsx("input",{type:"password",value:p,disabled:E,onChange:_=>g(_.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:E,onClick:()=>{i(!1),Ue()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:E,onClick:()=>{de()},children:E?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),R(null)},children:[s.jsx(gP,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(aP,{open:T&&N!==null&&le.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:le,popoverRef:V,labelledBy:"workbench-host-switcher-detail-title",children:[s.jsx("div",{className:"workbench-host-switcher-detail-header",children:s.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:je})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:Te})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(N==null?void 0:N.url)??K.baseUrl})]}),(N==null?void 0:N.kind)==="relay"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:pP(q)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:fP(De.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function ef(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const i=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(i)})}function lP(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function cP(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function uP(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function dP(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function hP(e,t){return e instanceof gu?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function pP(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function fP(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function mP(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function tf(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function nf(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function gP(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function bP(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const ba={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function kP({open:e,onClose:t,onCloned:n}){const{showToast:r}=ar(),[i,o]=f.useState(!1),[a,c]=f.useState(ba),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[g,m]=f.useState(null),[k,S]=f.useState(""),[v,w]=f.useState(""),[R,T]=f.useState(null),[F,E]=f.useState([]),[I,q]=f.useState([]),z=i||h;f.useEffect(()=>{!e&&!i&&(c(ba),d(!1),m(null))},[i,e]);const L=f.useCallback(async J=>{p(!0),m(null);try{const O=await gm(J);S(O.currentPath),w(O.currentPath),T(O.parentPath),E(O.roots),q(O.items),c(K=>({...K,parentPath:O.currentPath}))}catch(O){S(""),T(null),q([]),m(O instanceof Error?O.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function A(){i||(d(!1),m(null),c(ba),t())}function U(){d(!0),L(a.parentPath||void 0)}function B(){i||(d(!1),m(null))}async function le(J){J.preventDefault(),await L(v)}function V(){c(J=>({...J,parentPath:k})),d(!1),m(null)}async function X(J){J.preventDefault();const O=a.repositoryUrl.trim(),K=a.parentPath.trim();if(!O){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!K){r({title:l("shell.clonePathRequired"),tone:"error"});return}o(!0);try{const ce=await Uy({repositoryUrl:O,parentPath:K,directoryName:a.directoryName.trim()||void 0,name:a.name.trim()||void 0,auth:a.authMode==="none"?{mode:"none"}:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}});await(n==null?void 0:n(ce)),c(ba),d(!1),r({title:l("shell.cloneSuccess"),description:ce.path,tone:"success"}),t()}catch(ce){r({title:ce instanceof Error?ce.message:l("shell.cloneFailed"),tone:"error"})}finally{o(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(St,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:A,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:J=>void X(J),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:a.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:J=>c(O=>({...O,repositoryUrl:J.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneParentPathLabel")}),s.jsxs("div",{className:"workbench-modal-inline-field",children:[s.jsx("input",{type:"text",value:a.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:J=>c(O=>({...O,parentPath:J.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:U,children:l("shell.clonePickDirectory")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),s.jsx("input",{type:"text",value:a.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:J=>c(O=>({...O,directoryName:J.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:a.name,placeholder:l("shell.importNamePlaceholder"),onChange:J=>c(O=>({...O,name:J.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:a.authMode,onChange:J=>c(O=>({...O,authMode:J.target.value})),children:[s.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),s.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),s.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),a.authMode==="basic"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:J=>c(O=>({...O,username:J.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:a.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:J=>c(O=>({...O,password:J.target.value}))})]})]}):null,a.authMode==="token"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:J=>c(O=>({...O,username:J.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:a.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:J=>c(O=>({...O,token:J.target.value}))})]})]}):null,s.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:A,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(St,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:B,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:le,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:v,placeholder:l("shell.importPathPlaceholder"),onChange:J=>w(J.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:z||!R,onClick:()=>{R&&L(R)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:z,children:l("shell.importBrowserOpenPath")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:F.map(J=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:z,onClick:()=>{L(J.path)},children:J.name},J.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:k}),g?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:g}):null,h?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):I.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:I.map(J=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:z,onClick:()=>{L(J.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:J.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:J.path})]},J.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:z||!k,onClick:V,children:l("shell.cloneBrowserSubmit")})]})]})]})}const yP="butler:inbox-updated";function Ic(){typeof window>"u"||window.dispatchEvent(new Event(yP))}const rf={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function kk({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:o=!1,composerOpen:a=!0,onComposerOpenChange:c}){const{showToast:u}=ar(),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,k]=f.useState([]),[S,v]=f.useState([]),[w,R]=f.useState(null),[T,F]=f.useState(null),[E,I]=f.useState(rf),[q,z]=f.useState(!1),L=f.useMemo(()=>of(m,t,T),[T,t,m]),A=f.useMemo(()=>q?S:S.filter(O=>O.status!=="closed"),[S,q]);f.useEffect(()=>{e&&U()},[e,n]),f.useEffect(()=>{!e||w||I(O=>{const K=lf({projects:L,currentProjectId:O.projectId,preferredProjectId:T,preferredWorkspaceId:t});return K===O.projectId?O:{...O,projectId:K}})},[e,w,T,t,L]),f.useEffect(()=>{!e||r<=0||(B(void 0,t,i,T),c==null||c(!0))},[e,r,i,c,T,t]);async function U(){h(!0);try{const[O,K,ce]=await Promise.all([UT(),cb(),n?JT(n).catch(()=>null):Promise.resolve(null)]),N=(ce==null?void 0:ce.target.project.id)??null;F(N),k(O.items),v(K.items),w||B(O.items,t,r>0?i:null,N)}catch(O){u({title:l("shell.butlerInboxLoadFailed"),description:O instanceof Error?O.message:void 0,tone:"error"})}finally{h(!1)}}function B(O=m,K=t,ce=i,N=T){var ee,j;const De=of(O,K,N);R(null),I({...rf,projectId:lf({projects:De,preferredProjectId:N,preferredWorkspaceId:K}),title:((ee=ce==null?void 0:ce.title)==null?void 0:ee.trim())??"",content:((j=ce==null?void 0:ce.content)==null?void 0:j.trim())??""})}function le(O){R(O.id),I({projectId:O.projectId,itemType:O.itemType,title:O.title,content:O.content,status:O.status}),o&&(c==null||c(!0))}async function V(O){O.preventDefault(),g(!0);try{w?(await fp(w,{projectId:E.projectId,itemType:E.itemType,title:E.title,content:E.content,status:E.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await HT({projectId:E.projectId,itemType:E.itemType,title:E.title,content:E.content,status:E.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),Ic(),await U(),B(),o&&(c==null||c(!1))}catch(K){u({title:l("shell.butlerInboxSaveFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{g(!1)}}async function X(O){g(!0);try{await KT(O),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),Ic(),await U(),w===O&&B()}catch(K){u({title:l("shell.butlerInboxDeleteFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{g(!1)}}async function J(O,K){if(O.status!==K){g(!0);try{await fp(O.id,{status:K}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),Ic(),await U(),w===O.id&&I(ce=>({...ce,status:K}))}catch(ce){u({title:l("shell.butlerInboxSaveFailed"),description:ce instanceof Error?ce.message:void 0,tone:"error"})}finally{g(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[o?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(sf,{selectableProjects:L,formState:E,saving:p,editingItemId:w,useMobilePicker:!1,onProjectChange:O=>{I(K=>({...K,projectId:O}))},onItemTypeChange:O=>{I(K=>({...K,itemType:O}))},onStatusChange:O=>{I(K=>({...K,status:O}))},onTitleChange:O=>{I(K=>({...K,title:O}))},onContentChange:O=>{I(K=>({...K,content:O}))},onCancel:()=>B(),onSubmit:V})}),s.jsxs("section",{className:"workspace-inbox-panel",children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:l("shell.butlerInboxListTitle")}),s.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),s.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[s.jsx("input",{type:"checkbox",checked:q,onChange:O=>z(O.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&A.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&A.length>0?s.jsx("div",{className:"workspace-inbox-list",children:A.map(O=>s.jsxs("article",{className:"workspace-inbox-item",children:[s.jsxs("div",{className:"workspace-inbox-item-header",children:[s.jsxs("div",{children:[s.jsx("strong",{children:O.title}),s.jsx("p",{children:O.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:cf(O.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:CP(O.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:O.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:NP(O.updatedAt)}),s.jsxs("div",{className:"workspace-inbox-item-actions",children:[s.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(K=>{const ce=O.status===K;return s.jsx("button",{type:"button",className:"secondary-button","data-active":ce,disabled:p,onClick:()=>{J(O,K)},children:cf(K)},`${O.id}:${K}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>le(O),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{X(O.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},O.id))}):null]}),o?s.jsx(St,{open:e&&a,title:w?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),B()},children:s.jsx("div",{className:"workspace-inbox-composer-modal-body",children:s.jsx(sf,{selectableProjects:L,formState:E,saving:p,editingItemId:w,useMobilePicker:!0,onProjectChange:O=>{I(K=>({...K,projectId:O}))},onItemTypeChange:O=>{I(K=>({...K,itemType:O}))},onStatusChange:O=>{I(K=>({...K,status:O}))},onTitleChange:O=>{I(K=>({...K,title:O}))},onContentChange:O=>{I(K=>({...K,content:O}))},onCancel:()=>{c==null||c(!1),B()},onSubmit:V})})}):null]})}function sf(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),s.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):s.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[s.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?s.jsxs(s.Fragment,{children:[s.jsx(Ac,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(Ac,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(Ac,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),s.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),s.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[s.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),s.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),s.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),s.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),s.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[s.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),s.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),s.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),s.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxContentLabel")}),s.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function Ac({label:e,value:t,options:n,disabled:r,onChange:i}){const[o,a]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!o)return;function u(d){d.key==="Escape"&&a(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[o]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":o,disabled:r||n.length===0,onClick:()=>a(!0),children:[s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:s.jsx(vP,{expanded:o})})]})]}),s.jsx(wP,{open:o,title:e,options:n,selectedValue:t,onClose:()=>a(!1),onSelect:u=>{i(u),a(!1)}})]})}function wP({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:o}){return e?s.jsx(Fy,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:s.jsx(bi,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(a=>{const c=a.value===r;return s.jsx(Xt,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:s.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?s.jsx(SP,{}):null}),onClick:()=>o(a.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:a.label}),a.description?s.jsx("span",{children:a.description}):null]})},a.value)})})}):null}function BO({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:o,compactComposer:a=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!a);return f.useEffect(()=>{e||h(!a)},[a,e]),s.jsx(St,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!a,headerActions:a?s.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(p=>p+1),h(!0)},children:s.jsx(xP,{})}):void 0,onClose:o,children:s.jsx(kk,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:a,composerOpen:d,onComposerOpenChange:h})})}function of(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const o=af(r,t,n),a=af(i,t,n);return o!==a?a-o:r.name.localeCompare(i.name,"zh-Hans-CN")})}function af(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function lf({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var o;if(t&&e.some(a=>a.id===t))return t;if(n&&e.some(a=>a.id===n))return n;const i=r?e.find(a=>a.workspaceId===r):null;return(i==null?void 0:i.id)||((o=e[0])==null?void 0:o.id)||""}function xP(){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]})}function vP({expanded:e}){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:s.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function SP(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function CP(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function cf(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function NP(e){return new Date(e).toLocaleString()}function jP({open:e,onClose:t,onImported:n}){const{showToast:r}=ar(),[i,o]=f.useState(!1),[a,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[g,m]=f.useState(""),[k,S]=f.useState(""),[v,w]=f.useState(null),[R,T]=f.useState([]),[F,E]=f.useState([]),[I,q]=f.useState(!1),[z,L]=f.useState(""),A=i||a||u,U=f.useCallback(async K=>{o(!0),p(null);try{const ce=await gm(K);m(ce.currentPath),S(ce.currentPath),w(ce.parentPath),T(ce.roots),E(ce.items)}catch(ce){m(""),w(null),E([]),p(ce instanceof Error?ce.message:l("shell.importBrowserBrowseFailed"))}finally{o(!1)}},[]);f.useEffect(()=>{if(!e){q(!1),L(""),p(null);return}U(g||void 0)},[U,e]);function B(){A||(q(!1),L(""),t())}async function le(K){K.preventDefault(),await U(k)}function V(){!g||A||(L(""),q(!0))}function X(){a||(q(!1),L(""))}async function J(K){K==null||K.preventDefault();const ce=z.trim();if(!(!g||!ce||A)){c(!0),p(null);try{const N=await Gy({parentPath:g,directoryName:ce});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:N.path,tone:"success"}),q(!1),L(""),await U(N.path)}catch(N){const De=N instanceof Error?N.message:l("shell.importBrowserCreateDirectoryFailed");p(De),r({title:De,tone:"error"})}finally{c(!1)}}}async function O(){const K=g.trim();if(!(!K||A)){d(!0),p(null);try{const ce=await zy({path:K});r({title:l("shell.importSuccess"),description:ce.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(ce)).catch(N=>{r({title:N instanceof Error?N.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(ce){r({title:ce instanceof Error?ce.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return s.jsxs(s.Fragment,{children:[s.jsxs(St,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:B,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:le,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:k,placeholder:l("shell.importPathPlaceholder"),onChange:K=>S(K.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:A||!v,onClick:()=>{v&&U(v)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:A,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:A||!g,onClick:V,children:l("shell.importBrowserCreateDirectory")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:R.map(K=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:A,onClick:()=>{U(K.path)},children:K.name},K.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:g}),h?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:h}):null,i?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):F.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:F.map(K=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:A,onClick:()=>{U(K.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:K.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:K.path})]},K.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:A,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:A||!g,onClick:()=>{O()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(St,{open:e&&I,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:X,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:K=>void J(K),children:[s.jsx("div",{className:"workbench-directory-browser-current-path",children:g}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),s.jsx("input",{type:"text",value:z,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:K=>L(K.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:X,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:a||!z.trim(),children:a?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function TP({onOpenSoftwareUpdate:e}){var r;const t=al(i=>i.platform),n=Sy(i=>i.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:s.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:s.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function IP(){const e=vy.getState().profile.defaultPermissionMode;return e==="default"?null:e}async function AP(){return await Y.request("/api/system/model-switch")}async function _O(e){return await Y.request("/api/system/model-switch",{method:"POST",body:JSON.stringify(e)})}const ro="provider-default",Ma="__global_default__";function RP(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function ka(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function EP(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:Ma,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function PP(e){return e.usesProviderDefault===!0||e.id===ro}function MP(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function LP({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:o,onSelectPreset:a,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:g=!1,showPresetColumn:m=!0,modelEmptyText:k}){const[S,v]=f.useState(!1),w=f.useRef(null),R=f.useRef(null),T=f.useRef(null),[F,E]=f.useState(null),I=f.useId(),q=f.useCallback(()=>{const z=R.current;if(!z||typeof window>"u")return;const L=z.getBoundingClientRect(),A=z.closest(".workbench-modal-card"),U=A instanceof HTMLElement?A.getBoundingClientRect():null,B=window.innerWidth,le=window.innerHeight,V=12,X=8,J=320,O=Math.min(560,Math.max(320,B-V*2)),K=Math.min(O,420),ce=Math.max(Math.min(O,Math.max(K,Math.round(L.width*1.9))),Math.min(320,O)),N=Math.min(Math.max(V,L.left),Math.max(V,B-ce-V)),De=U?Math.max(V,U.top+8):V,ee=U?Math.min(le-V,U.bottom-8):le-V,j=Math.max(0,L.top-De-X),be=Math.max(0,ee-L.bottom-X),re=U?!(be>=J||be>j+40):j>=240||j>=be;E({position:"fixed",left:N,width:ce,maxWidth:O,zIndex:1905,top:re?void 0:L.bottom+X,bottom:re?le-L.top+X:void 0})},[]);return f.useEffect(()=>{if(!S)return;function z(A){var B,le;const U=A.target;!((B=w.current)!=null&&B.contains(U))&&!((le=T.current)!=null&&le.contains(U))&&v(!1)}function L(A){A.key==="Escape"&&v(!1)}return window.addEventListener("pointerdown",z),window.addEventListener("keydown",L),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),q(),()=>{window.removeEventListener("pointerdown",z),window.removeEventListener("keydown",L),window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[S,q]),s.jsxs("div",{ref:w,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:R,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":I,onClick:()=>v(z=>!z),children:[s.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&F&&typeof document<"u"?$r.createPortal(s.jsx("div",{ref:T,className:"composer-mac-select-popover composer-deployment-select-popover",style:F,role:"presentation",children:s.jsxs("div",{id:I,className:`composer-deployment-select-panel${m?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[m?s.jsxs("div",{className:"composer-deployment-select-column",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),s.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(z=>{const L=z.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,onClick:()=>a(z.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:z.label}),z.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:z.summary}):null]})]},z.value)}),h?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,s.jsxs("div",{className:"composer-deployment-select-column","data-disabled":g?"true":"false",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),m&&o?s.jsx("div",{className:"composer-deployment-select-column-hint",children:o}):null,s.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:p&&g?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(z=>{const L=z.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,disabled:g,onClick:()=>{d(z.value),v(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:z.label})})]},z.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:k})})]})]})}),document.body):null]})}const yk=144,DP=196,OP=124,BP=72;let uf=null;function _P(e,t){if(typeof document>"u")return t.length*8;uf??(uf=document.createElement("canvas"));const n=uf.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",o=r.fontWeight||"600",a=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${o} ${a} ${c}`,n.measureText(t).width}function WP({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const o=e.reduce((a,c)=>Math.max(a,Math.ceil(i(c)+BP)),0);return Math.min(n,Math.max(t,yk,r,o))}function df({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:o=!1,compact:a=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),g=f.useRef(null),[m,k]=f.useState(null),S=f.useId(),v=r.find(T=>T.value===n)??r[0]??null,w=f.useMemo(()=>r.map(T=>T.label),[r]),R=f.useCallback(()=>{const T=p.current;if(!T||typeof window>"u")return;const F=T.getBoundingClientRect(),E=window.innerWidth,I=window.innerHeight,q=12,z=10,L=Math.max(yk,E-q*2),A=a?OP:DP,U=WP({labels:w,triggerWidth:F.width,maxWidth:L,preferredWidth:A,measureText:J=>_P(T,J)}),B=Math.min(Math.max(q,F.left),Math.max(q,E-U-q)),le=F.top-q,V=I-F.bottom-q,X=le>=180||le>=V;k({position:"fixed",left:B,width:U,maxWidth:L,zIndex:1905,top:X?void 0:F.bottom+z,bottom:X?I-F.top+z:void 0})},[a,w]);return f.useEffect(()=>{if(!u)return;function T(E){var q,z;const I=E.target;!((q=h.current)!=null&&q.contains(I))&&!((z=g.current)!=null&&z.contains(I))&&d(!1)}function F(E){E.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",F),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),R(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",F),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[u,R]),v?s.jsxs("div",{ref:h,className:`composer-mac-select ${a?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[s.jsxs("button",{id:e,ref:p,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:o,onClick:()=>d(T=>!T),children:[s.jsx("span",{className:"composer-mac-select-label",children:v.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&m&&typeof document<"u"?$r.createPortal(s.jsx("div",{ref:g,className:"composer-mac-select-popover",style:m,role:"presentation",children:s.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(T=>{const F=T.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":F,className:`composer-mac-select-option ${F?"is-selected":""}`,onClick:()=>{i(T.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:F?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:T.label})]},T.value)})})}),document.body):null]}):null}const ya=["codex","claude-code","gemini"];function wk(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function hf(e,t){return Array.from({length:t},()=>wk(e))}function Rc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:$u(t).modelOptions??[]}function pf(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function ff(e,t){return Math.max(0,e-t.length)}function FP({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),o=(t==null?void 0:t.defaultProvider)??"codex",a=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(ae,ie)=>ie+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,h=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:p}=mk(Fu,e),[g,m]=f.useState(h),[k,S]=f.useState(d),[v,w]=f.useState(()=>hf(o,d)),[R,T]=f.useState({}),[F,E]=f.useState({}),[I,q]=f.useState({}),[z,L]=f.useState({}),[A,U]=f.useState({}),[B,le]=f.useState(!1),[V,X]=f.useState(!1),[J,O]=f.useState(null),[K,ce]=f.useState(null),[N,De]=f.useState({}),ee=f.useRef(!1),j=f.useRef({});f.useEffect(()=>{if(!e)return;const ae=(t==null?void 0:t.defaultProvider)??"codex",ie=(t==null?void 0:t.kind)==="group"?1:2;m((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S(ie),w(hf(ae,ie)),T({}),E({}),q({}),L({}),U({}),le(!1),X(!1),O(null),ce(null),De({}),ee.current=!1,Object.keys(j.current).forEach(ke=>{delete j.current[ke]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),f.useEffect(()=>{w(ae=>{var ye;if(ae.length===k)return ae;if(ae.length>k)return ae.slice(0,k);const ie=ae.slice(),ke=((ye=ae[0])==null?void 0:ye.provider)??o;for(;ie.length<k;)ie.push(wk(ke));return ie})},[o,k]),f.useEffect(()=>{u.length!==0&&S(ae=>u.includes(ae)?ae:u[0]??ae)},[u]),f.useEffect(()=>{if(!e||!t)return;let ae=!1;return le(!0),ym(p,t.workspaceId).then(ie=>{ae||T(ie)}).finally(()=>{ae||le(!1)}),()=>{ae=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(ee.current||(ee.current=!0,q(ae=>({...ae,...Object.fromEntries(ya.map(ie=>[ie,!0]))})),AP().then(ae=>{const ie=Object.fromEntries(ae.items.map(ke=>[ke.app,ke]));E(Object.fromEntries(ya.map(ke=>[ke,ie[ke]??null])))}).catch(()=>{E(Object.fromEntries(ya.map(ae=>[ae,null])))}).finally(()=>{q(ae=>({...ae,...Object.fromEntries(ya.map(ie=>[ie,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const ae=Array.from(new Set(v.map(ie=>{const ke=ka(ie.providerConfigMode,ie.providerPresetId);return pf(ie.provider,ke.providerConfigMode,ke.providerPresetId)}).filter(ie=>ie!==null))).filter(ie=>z[ie]===void 0&&!j.current[ie]);if(ae.length!==0)for(const ie of ae){const[ke,ye]=ie.split("::");j.current[ie]=!0,U(Re=>({...Re,[ie]:!0})),Tu(ke,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ye}).then(Re=>{L($=>({...$,[ie]:Re}))}).catch(()=>{L(Re=>({...Re,[ie]:null}))}).finally(()=>{delete j.current[ie],U(Re=>({...Re,[ie]:!1}))})}},[z,v,e,t]);const be=f.useMemo(()=>p.filter(ae=>{const ie=R[ae];return ie?ie.canStartSession!==!1:!1}),[R,p]);f.useEffect(()=>{if(!be.length)return;const ae=be.includes(o)?o:be[0];w(ie=>{let ke=!1;const ye=ie.map(Re=>be.includes(Re.provider)?Re:(ke=!0,{...Re,provider:ae,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ke?ye:ie})},[be,o]);const re=f.useMemo(()=>v.map((ae,ie)=>{var Ye;const ke=ka(ae.providerConfigMode,ae.providerPresetId),ye=RP(ae.provider),Re=ye?F[ye]??null:null,$=EP(Re),Z=ke.providerConfigMode==="cc-switch-preset"?ke.providerPresetId??Ma:Ma,ge=$.find(ht=>ht.value===Z)??$[0]??null,Ne=pf(ae.provider,ke.providerConfigMode,ke.providerPresetId),Be=R[ae.provider]??null,Ve=Ne?z[Ne]??null:null,dt=(ke.providerConfigMode==="cc-switch-preset"?Ve?Rc(Ve,ae.provider):[{id:ro,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:Rc(Be,ae.provider)).map(ht=>({value:ht.id,label:PP(ht)?l("conversation.modelUseCliDefault"):ht.name})),Ze=ae.model.trim()||ro,st=((Ye=dt.find(ht=>ht.value===Ze))==null?void 0:Ye.label)??l("conversation.modelUseCliDefault"),it=MP(Re),qe=ye!==null,bt=Ne?A[Ne]===!0:!1,Ut=!!(Ne&&bt&&Ve===null);return{index:ie,draft:ae,supportsDeploymentPicker:qe,showPresetColumn:it,deploymentPresetOptions:$,selectedPresetValue:Z,selectedPresetOption:ge,triggerLabel:it?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${st}`:st,selectedModelValue:Ze,modelOptions:dt,loadingPresets:ye?I[ye]===!0:!1,loadingModels:bt,modelColumnDisabled:Ut}}),[z,F,I,A,v,R]);if(f.useEffect(()=>{e&&w(ae=>{let ie=!1;const ke=ae.map((ye,Re)=>{const $=re[Re];if(!$)return ye;let Z=ye;const ge=ka(ye.providerConfigMode,ye.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!$.loadingPresets&&!$.deploymentPresetOptions.some(Ve=>Ve.value===ge.providerPresetId)&&(Z={...Z,providerConfigMode:"global-default",providerPresetId:null,model:""},ie=!0);const Ne=new Set($.modelOptions.map(Ve=>Ve.value)),Be=Z.model.trim()||ro;return Ne.has(Be)||(Z={...Z,model:""},ie=!0),Z});return ie?ke:ae})},[re,e]),!e||!t)return null;const fe=t,de=K?ff(v.length,K.memberFailures):0,Ue=new Set(K?v.map((ae,ie)=>ie).filter(ae=>!(ae in N)):[]),He=fe.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),je=fe.kind==="session"?`${fe.workspaceName} · ${fe.sessionTitle}`:fe.workspaceName,Te=fe.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),_=fe.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),G=fe.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),Q=fe.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Ce=J??(fe.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!B&&be.length===0?l("shell.parallelCreateNoAvailableProviders"):null),Ae={"--parallel-member-columns":String(Math.max(1,Math.min(k,4)))};function ve(ae){O(null),ce(null),De(ie=>{if(!(ae in ie))return ie;const ke={...ie};return delete ke[ae],ke})}function Tt(){O(null),ce(null),De({})}function rt(ae,ie){ve(ae);const ke=ie?"temporary_worktree":"none";w(ye=>ye.map((Re,$)=>$===ae?{...Re,workspaceIsolationMode:ke}:Re))}async function gt(){const ae=g.trim();if(!a&&!ae){O(l("shell.parallelCreatePromptRequired"));return}if(fe.kind==="group"&&c===0){O(l("shell.parallelAppendNoRemainingSlots"));return}if(!be.length){O(l("shell.parallelCreateNoAvailableProviders"));return}X(!0),O(null),ce(null),De({});try{const ie=IP(),ke=v.map(Re=>{const $=ka(Re.providerConfigMode,Re.providerPresetId);return{provider:Re.provider,model:Re.model.trim()||null,providerConfigMode:$.providerConfigMode,providerPresetId:$.providerConfigMode==="cc-switch-preset"?$.providerPresetId:null,memberPrompt:Re.memberPrompt.trim()||null,workspaceIsolationMode:Re.workspaceIsolationMode}}),ye=fe.kind==="group"?await Xy(fe.groupId,{permissionMode:ie,members:ke}):fe.kind==="session"?await Yy(fe.sessionId,{sharedPrompt:ae,permissionMode:ie,members:ke}):await Jy(fe.workspaceId,{sharedPrompt:ae,permissionMode:ie,members:ke});if(ye.memberFailures.length>0){const Re=ff(v.length,ye.memberFailures);ce(ye),De(Object.fromEntries(ye.memberFailures.map($=>[$.ordinal,$]))),O(Re>0?l("shell.parallelCreatePartialFailure",{successCount:Re,failureCount:ye.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ye.memberFailures.length}));return}await r(ye)}catch(ie){O(ie instanceof Error?ie.message:l("shell.parallelGroupLoadFailed"))}finally{X(!1)}}return s.jsx(ju,{open:e,title:He,description:je,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!V,onClose:n,footer:s.jsxs(Ns,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Ce?s.jsx("span",{className:"parallel-create-modal-error",children:Ce}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[K&&de>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:V,onClick:()=>{r(K)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:V,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:V||B||be.length===0||fe.kind==="group"&&c===0,onClick:()=>{gt()},children:V?Q:G})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Rn,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx(Lt,{className:"parallel-create-target-field",label:Te,htmlFor:`${i}-shared-prompt`,children:s.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:g,readOnly:a,"aria-readonly":a,"data-readonly":a?"true":void 0,onChange:ae=>{a||(Tt(),m(ae.target.value))}})}),s.jsx(Lt,{className:"parallel-create-count-field",label:_,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":_,children:u.map(ae=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":k===ae,onClick:()=>{Tt(),S(ae)},children:ae},ae))})})]})}),s.jsx(Rn,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:Ae,children:re.map(({draft:ae,index:ie,supportsDeploymentPicker:ke,showPresetColumn:ye,deploymentPresetOptions:Re,selectedPresetValue:$,selectedPresetOption:Z,triggerLabel:ge,selectedModelValue:Ne,modelOptions:Be,loadingPresets:Ve,loadingModels:Ie,modelColumnDisabled:dt})=>{var Ut;const Ze=be,st=Ze.includes(ae.provider)?ae.provider:"",it=Ze.length>0?Ze.map(Ye=>({value:Ye,label:za(Ye,"full")})):[{value:"",label:B?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],qe=Rc(R[ae.provider]??null,ae.provider),bt=qe.length>0?[{value:"",label:((Ut=qe.find(Ye=>Ye.usesProviderDefault===!0))==null?void 0:Ut.name)??l("shell.parallelPaneModelFallback")},...qe.filter(Ye=>Ye.usesProviderDefault!==!0).map(Ye=>({value:Ye.id,label:Ye.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":N[ie]?"error":Ue.has(ie)?"success":void 0,children:[s.jsxs("header",{className:"parallel-create-member-header",children:[s.jsxs("div",{className:"parallel-create-member-title-block",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:ie+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:za(ae.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:ae.workspaceIsolationMode==="temporary_worktree",onChange:Ye=>{rt(ie,Ye.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),N[ie]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):Ue.has(ie)?s.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),s.jsxs("div",{className:"parallel-create-member-grid",children:[s.jsx(Lt,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${ie}-provider`,children:s.jsx(df,{triggerId:`${i}-member-${ie}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:st,options:it,disabled:!Ze.length,onChange:Ye=>{ve(ie);const ht=Ye;w(Oe=>Oe.map((kt,et)=>et===ie?{...kt,provider:ht,providerConfigMode:"global-default",providerPresetId:null,model:""}:kt))}})}),s.jsx(Lt,{label:l("shell.parallelCreateModelLabel"),htmlFor:ke?void 0:`${i}-member-${ie}-model`,children:ke?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(LP,{triggerId:`${i}-member-${ie}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:Re,selectedPresetValue:$,selectedPresetSummary:(Z==null?void 0:Z.summary)??null,onSelectPreset:Ye=>{ve(ie),w(ht=>ht.map((Oe,kt)=>kt!==ie?Oe:Ye===Ma?{...Oe,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...Oe,providerConfigMode:"cc-switch-preset",providerPresetId:Ye,model:""}))},modelOptions:Be,selectedModelValue:Ne,onSelectModel:Ye=>{ve(ie),w(ht=>ht.map((Oe,kt)=>kt===ie?{...Oe,model:Ye===ro?"":Ye}:Oe))},loadingPresets:Ve,loadingModels:Ie,modelColumnDisabled:dt,showPresetColumn:ye,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(df,{triggerId:`${i}-member-${ie}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:ae.model,options:bt,disabled:!Ze.length||qe.length===0,onChange:Ye=>{ve(ie),w(ht=>ht.map((Oe,kt)=>kt===ie?{...Oe,model:Ye}:Oe))}})})]}),s.jsx(Lt,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${ie}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${ie}-prompt`,className:"parallel-create-textarea member",rows:2,value:ae.memberPrompt,onChange:Ye=>{ve(ie);const ht=Ye.target.value;w(Oe=>Oe.map((kt,et)=>et===ie?{...kt,memberPrompt:ht}:kt))}})}),N[ie]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:N[ie].detail})]}):null]},`parallel-member-${ie}`)})})})]})})}const $P=12,zP=180,mf=72;function UP(e,t){const[n,r]=f.useState(!1),[i,o]=f.useState(""),[a,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[g,m]=f.useState(null);f.useEffect(()=>{e||(r(!1),o(""),m(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const v=t.filter(R=>u[R.sessionId]!==!0);if(v.length===0)return;let w=!1;return p(!0),m(null),Promise.allSettled(v.map(async R=>{const T=await wm(R.sessionId,null,$P,"backward");return{sessionId:R.sessionId,summary:HP(T.messages)}})).then(R=>{if(w)return;const T={},F={};let E=0;v.forEach(I=>{T[I.sessionId]=!0});for(const I of R){if(I.status==="fulfilled"){F[I.value.sessionId]=I.value.summary;continue}E+=1}d(I=>({...I,...T})),Object.keys(F).length>0&&c(I=>({...I,...F})),m(E>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{w||p(!1)}),()=>{w=!0}},[u,e,n,t]);const k=f.useMemo(()=>{const v=Ec(i);return v?t.filter(w=>Ec(w.title).includes(v)?!0:Ec(a[w.sessionId]??"").includes(v)):t},[i,t,a]);function S(){r(v=>{const w=!v;return w||(o(""),m(null)),w})}return{searchOpen:n,searchKeyword:i,filteredSessions:k,summaryLoading:h,summaryError:g,summaryBySessionId:a,setSearchKeyword:o,toggleSearch:S}}function HP(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(qP).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return bu(n,zP)}function qP(e){var n,r;const t=xk(e.content);return t.length>0?bu(t,mf):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?bu(e.toolCall.name.trim(),mf):""}function Ec(e){return xk(e).toLocaleLowerCase()}function xk(e){return e.replace(/\s+/g," ").trim()}function bu(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const gf="workbench.left.width",bf="workbench.right.width",kf="workbench.left.collapsed",yf="workbench.right.collapsed",wa="workbench.last.session.path",Pc="workbench.workspace.selected.id",wf="workbench.notifications.seen_at",GP=280,KP=320,xf=240,vf=280,Sf=520,Cf=560,VP=200,Mc=20,Xi=40,xa=5,YP=3e4,JP=12,Nf=60*1e3,XP=4e3,jf=220,Tf=18,QP=6,ai="data-workbench-panel-resizing",va="data-workbench-window-resizing",ZP=180,eM="workbench:focus-composer",tM=new Set(["starting","running","reconnecting","stale","unknown"]),nM=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],rM=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],Et={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function vk(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function sM(e){return Math.round(e*100)/100}function iM(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function rs(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(o=>iM(n,o)).filter(o=>o!==null);return i.length===0?null:i.reduce((o,a)=>o+a,0)/i.length}function Sr(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${sM(n)}px`;r!==i&&e.style.setProperty(t,i)}function Cr(e,t,n,r){return r===null?null:(vk(e,t)??0)+(n-r)}function If(e){if(e)for(const t of rM)e.style.removeProperty(t)}function oM(e){return tM.has(e.runningState??"idle")||e.activityState==="running"}function aM(e,t){const n=[];for(const r of[...t].sort()){const i=e.get(r);!i||i.size===0||n.push(`${r}:${[...i].sort().join(",")}`)}return n.join("|")}function lM(e){var i,o;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((o=e.lastErrorDetail)==null?void 0:o.trim())??"",r=[t,n].filter(a=>a.length>0).join(" · ");return r?r.length<=jf?r:`${r.slice(0,jf-3)}...`:null}function cM(e,t,n){var o,a,c,u,d,h,p,g,m,k,S,v;const r=new Map(e.projects.map(w=>[w.id,w.workspaceId])),i=[];for(const w of n){const R=w.title.trim()||w.projectName;if(w.assistantState.lifecycleStage==="analyzed"&&!((o=w.assistantState.linkedSessionId)!=null&&o.trim())&&w.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${w.id}:${w.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:R}),body:((a=w.assistantState.analysisSummary)==null?void 0:a.trim())||((c=w.assistantState.generatedPrompt)==null?void 0:c.trim())||w.content,routePath:Es(w.workspaceId),workspaceId:w.workspaceId,createdAt:w.assistantState.lastAnalyzedAt});continue}w.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${w.id}:${w.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:R}),body:((u=w.assistantState.lastError)==null?void 0:u.trim())||w.content,routePath:Es(w.workspaceId),workspaceId:w.workspaceId,createdAt:w.updatedAt})}for(const w of t){const R=((d=w.sessionTitle)==null?void 0:d.trim())||w.projectName,T=w.updatedAt||w.lastAutomationAt||w.createdAt;if(w.status==="waiting_user"){i.push({id:`follow-up-waiting:${w.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:R}),body:((h=w.waitingReason)==null?void 0:h.trim())||((p=w.lastAutomationSummary)==null?void 0:p.trim())||w.objective,routePath:jr(w.workspaceId,w.sessionId),workspaceId:w.workspaceId,createdAt:T});continue}if(w.status==="completed"){i.push({id:`follow-up-completed:${w.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:R}),body:((g=w.lastAutomationSummary)==null?void 0:g.trim())||w.objective,routePath:jr(w.workspaceId,w.sessionId),workspaceId:w.workspaceId,createdAt:T});continue}w.status==="failed"&&i.push({id:`follow-up-failed:${w.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:R}),body:((m=w.lastAutomationSummary)==null?void 0:m.trim())||((k=w.waitingReason)==null?void 0:k.trim())||w.objective,routePath:jr(w.workspaceId,w.sessionId),workspaceId:w.workspaceId,createdAt:T})}for(const w of e.verifications){if(w.status!=="failed")continue;const R=w.projectId?r.get(w.projectId)??null:null,T=((S=w.targetRef)==null?void 0:S.trim())||w.verificationType;i.push({id:`verification-failed:${w.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:T}),body:((v=w.summary)==null?void 0:v.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:R?Es(R):null,workspaceId:R,createdAt:w.finishedAt||w.startedAt||w.createdAt})}return i.sort((w,R)=>{const T=Af(w.kind)-Af(R.kind);return T!==0?T:ls(R.createdAt)-ls(w.createdAt)}).slice(0,JP)}function Af(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function uM(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function ls(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function dM(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function hM(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function pM(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:o,tags:a}}function fM(e){return e.getBoundingClientRect()}function mM(e,t){return t?ls(e.createdAt)>ls(t):!0}function gM(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Rf(e,t){var a,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/plugins","/workspaces/:workspaceId/plugins/:pluginId","/workspaces/:workspaceId/plugins/:pluginId/run","/workspaces/:workspaceId/butler"];for(const u of n){const d=ut(u,e),h=(a=d==null?void 0:d.params.workspaceId)==null?void 0:a.trim();if(h)return h}const r=uo(e),i=(r==null?void 0:r.sessionId)??null;return!i||!ty(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function bM(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function Lc(e){return e==="mobile"?wn():"/landing"}function uo(e){var o,a,c;const t=ut("/workspaces/:workspaceId/sessions/:sessionId",e),n=(o=t==null?void 0:t.params.sessionId)==null?void 0:o.trim();if(n)return{sessionId:n,workspaceId:((a=t==null?void 0:t.params.workspaceId)==null?void 0:a.trim())??null};const r=ut("/sessions/:sessionId",e),i=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return i?{sessionId:i,workspaceId:null}:null}function kM(e){return!!(ut("/sessions",e)||ut("/workspaces/:workspaceId/sessions",e))}function Ef(e){return!!uo(e)}function yM(e){return!!(ut("/tools",e)||ut("/tools/files",e)||ut("/tools/git",e)||ut("/tools/processes",e)||ut("/workspaces/:workspaceId/tools",e)||ut("/workspaces/:workspaceId/tools/files",e)||ut("/workspaces/:workspaceId/tools/git",e)||ut("/workspaces/:workspaceId/tools/processes",e))}function La(e){return!!(ut("/terminals",e)||ut("/workspaces/:workspaceId/terminals",e))}function Da(e){return!!ut("/workspaces/:workspaceId/butler",e)}function wM(e){return!!(ut("/workspaces/:workspaceId/plugins",e)||ut("/workspaces/:workspaceId/plugins/:pluginId",e)||ut("/workspaces/:workspaceId/plugins/:pluginId/run",e))}function xM(e,t){return ut("/workspaces/:workspaceId/debug",e)?hm(t):ut("/workspaces/:workspaceId",e)?im(t):ut("/workspaces/:workspaceId/tools/files",e)||ut("/tools/files",e)?um(t):ut("/workspaces/:workspaceId/tools/git",e)||ut("/tools/git",e)?cm(t):ut("/workspaces/:workspaceId/tools/processes",e)||ut("/tools/processes",e)?lm(t):ut("/workspaces/:workspaceId/tools",e)||ut("/tools",e)?sm(t):La(e)?Ts(t):Da(e)?Es(t):wM(e)?Ty(t):po(t)}function vM(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const SM=f.lazy(async()=>({default:(await Nu(()=>import("./FileContextPanel-BdCoubcJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))).FileContextPanel})),CM=f.lazy(async()=>({default:(await Nu(()=>import("./GitSidebar-BeZ0hj7A.js"),__vite__mapDeps([13,1,2,3,4,8,7,6,5,9,10,11,12]))).GitSidebar})),NM=f.lazy(async()=>({default:(await Nu(()=>import("./TerminalManagerPanel-NVZRxxmH.js"),__vite__mapDeps([14,1,2,7,3,4,5,12,15,16,9,10,6,11]))).TerminalManagerPanel}));function jM(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function En(e){return Iy(e)}function TM(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function di(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(jM):[]}async function Sk(e,t){const n=await Tu(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const Ck=f.createContext(null);function sl(e){return fR(e)}function Ir(e){return e.isArchived===!0}function Po(e){return Ay(e)}function Nk(e,t){return dm(e,{getId:n=>n.sessionId,getParentId:Po,compare:(n,r)=>So(n,r,t)})}function IM(e,t){const n=AM(e);return jk(n,t)}function jk(e,t){const n=RM(e);return dm(n,{getId:r=>r.session.sessionId,getParentId:r=>Po(r.session),compare:(r,i)=>So(r.session,i.session,t)}).map(r=>Ik(r))}function AM(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...Tk(t.childWorktrees)])}function Tk(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...Tk(t.children)])}function RM(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}function Ik(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>Ik(n,t+1))}}function ku(e,t){return{...e,depth:e.depth+t,children:En(e).map(n=>ku(n,t))}}function Pf(e){return`${e}::parallel-anchor-member`}function Mf(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function yu(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=yu(En(n),t);if(r)return r}return null}function EM(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=Ak(r,n,null);if(i)return i}return null}function Ak(e,t,n){var i,o;const r=((o=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:o.trim())||n;if(e.item.sessionId===t)return r;for(const a of En(e)){const c=Ak(a,t,r);if(c)return c}return null}function Rk(e){return e.filter(t=>{if(Ir(t))return!1;const n=Po(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&Ir(r)?!sl(t):!0})}function PM(e){return e.flatMap(t=>{const n=TM(t);return n?[n,...My(En(t))]:[]})}function MM(e,t,n){var g;const r=En(e),i=li(r).sort((m,k)=>So(m.item,k.item,n));if(!(((g=e.item.parallelGroup)==null?void 0:g.role)==="anchor"&&r.some(m=>{var k,S;return((k=m.item.parallelGroup)==null?void 0:k.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const m=new Set(i.slice(0,Math.max(0,t)).map(k=>k.item.sessionId));return{...e,children:wu(r,m)}}const a=r.slice().sort((m,k)=>So(m.item,k.item,n)),c=a.filter(m=>{var k,S;return((k=m.item.parallelGroup)==null?void 0:k.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),u=a.filter(m=>{var k,S;return((k=m.item.parallelGroup)==null?void 0:k.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),d=[...c,...u],h=Math.max(0,t-d.length),p=new Set(d);for(const m of i){if(p.size>=d.length+h)break;p.add(m.item.sessionId)}return{...e,children:wu(r,p)}}function wu(e,t){return e.flatMap(n=>{const r=wu(En(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function Sa(e,t,n,r=-1){if(e<=0)return 0;const i=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,i))}function Lf(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>e[i]===t[i])}function LM(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function Sl(e,t="compact"){return za(e,t)}const DM={position:"relative",zIndex:0},OM={zIndex:1};function Ek(e,t,n,r){const i=[],o=(r==null?void 0:r.trim())||t.name;n&&i.push(o);const a=LM(e);return a&&i.push(a),i.join(" · ")||o}function Df(e,t){return HI("session-state-indicator",e,t)}function BM(e,t){return Nb(e,t)}function Of(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function Bf(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function _f(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function Cs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function _M(e){try{window.localStorage.removeItem(e)}catch{}}function Ca(e,t,n){return Math.max(t,Math.min(n,e))}function Na(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function WM(e){const t=window.getComputedStyle(e),n=Na(t.getPropertyValue("--desktop-macos-titlebar-height")),r=Na(t.getPropertyValue("--workbench-header-min-height")),i=Na(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),o=Na(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+o+8}function Wf(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+WM(t)}function FM(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function $M(){typeof window>"u"||window.dispatchEvent(new CustomEvent(eM))}function Pk(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const i=Pk(r.children,n);if(i)return i}return null}function Ff(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=Pk(r.childWorktrees,n);if(i)return i}return null}function Mk(e){return e.flatMap(t=>[t.workspace.id,...Mk(t.children)])}function Lk(e){return new Set(e.flatMap(t=>[t.workspace.id,...Mk(t.childWorktrees)]))}function $f(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function Dc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function Dk(e,t,n,r=new Set){return e.map(i=>{const o=i.sessions.filter(c=>!r.has(c.sessionId)),a=Rk(o);return{workspace:i.workspace,meta:i.meta,visibleSessions:a,archivedSessions:o.filter(c=>Ir(c)&&!Po(c)),visibleSessionTree:Nk(a,n).filter(c=>!t.has(c.item.sessionId)&&!om(En(c),u=>t.has(u.sessionId))),children:Dk(i.children,t,n,r)}})}function xu(e){return e.flatMap(t=>[t.workspace.id,...xu(t.children)])}function so(e){return e.flatMap(t=>[...t.visibleSessionTree,...so(t.children)])}function Ok(e){return e.flatMap(t=>[t,...Ok(t.children)])}function zM(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:di(n)};const r=Bk(n.childWorktrees,t);if(r)return r}return null}function Bk(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=Bk(n.children,t);if(r)return r}return null}function UM(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=_k(n.childWorktrees,t);if(r)return r}return null}function Oc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Wk(n.childWorktrees,t);if(r)return r}return null}function _k(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=_k(n.children,t);if(r)return r}return null}function Wk(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Wk(n.children,t);if(r)return r}return null}function Fk(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=Fk(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function zf(e){return e.flatMap(t=>[t.workspace.id,...$k(t.childWorktrees)])}function $k(e){return e.flatMap(t=>[t.workspace.id,...$k(t.children)])}function HM(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function qM(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),o=e.findIndex(d=>d.workspace.id===n);if(i<0||o<0)return e;const a=[...e],[c]=a.splice(i,1);if(!c)return e;const u=a.findIndex(d=>d.workspace.id===n);return u<0?e:(a.splice(r==="before"?u:u+1,0,c),a.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:a)}function GM(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||Ir(u)===d?u:(n=!0,o=!0,{...u,isArchived:d})}),c=Uk(i.childWorktrees??[],t,u=>{u&&(n=!0,o=!0)});return o?{...i,sessions:a,childWorktrees:c}:i});return n?{...e,items:r}:e}function KM(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Ir(r)===i&&e.delete(r.sessionId)}Hk(e,n.childWorktrees??[])}}function VM(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=qk(o.childWorktrees,t,n);return d?(r=!0,{...o,childWorktrees:u}):o}const a=o.sessions.findIndex(u=>u.sessionId===t.sessionId),c=a>=0?o.sessions.map((u,d)=>d===a?t:u):[t,...o.sessions];return r=!0,{...o,sessions:Eo(c,n)}});return r?i:e}function YM(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=Cl(o.childWorktrees,d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Uf(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n})),u=Cl(o.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Hf(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n})),u=Cl(o.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function JM(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function XM(e){return e?e.slice(0,8):"--"}function qf(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function zk(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Uk(e,t,n){return e.map(r=>{let i=!1;const o=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||Ir(c)===u?c:(i=!0,{...c,isArchived:u})}),a=Uk(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:o,children:a}:r})}function Hk(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Ir(r)===i&&e.delete(r.sessionId)}Hk(e,n.children)}}function qk(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id===t.workspaceId){const c=o.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?o.sessions.map((d,h)=>h===c?t:d):[t,...o.sessions];return r=!0,{...o,sessions:Eo(u,n)}}const a=qk(o.children,t,n);return a.changed?(r=!0,{...o,children:a.nodes}):o});return{nodes:r?i:[...e],changed:r}}function QM(e,t){return e.map(n=>({...n,sessions:Eo(n.sessions,t),childWorktrees:bd(n.childWorktrees,t)}))}function Cl(e,t){let n=!1;const r=e.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t(u);return d!==u&&(o=!0,n=!0),d}),c=Cl(i.children,t);return c!==i.children&&(o=!0,n=!0),o?{...i,sessions:a,children:c}:i});return n?r:[...e]}function vu(e){return`workspace-management.summary.${e}`}function Gk(e){return`git-sidebar.snapshot.${e}`}function Kk(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Vk(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function Yk(e,t){var o,a,c,u;const n=((o=t.status)==null?void 0:o.snapshot.enabled)!==!1,r=n?((a=t.status)==null?void 0:a.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:i,error:null}}}function Jk({count:e,className:t="workbench-skeleton-lines"}){return s.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>s.jsx("span",{className:"skeleton-line"},r))})}function ZM(){return s.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("section",{className:"workbench-skeleton-card",children:[s.jsxs("div",{className:"workbench-skeleton-heading",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx("span",{className:"skeleton-line tiny"})]}),s.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>s.jsxs("div",{className:"workbench-skeleton-session",children:[s.jsx("span",{className:"workbench-skeleton-dot"}),s.jsx(Jk,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function ja(){return s.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>s.jsxs("article",{className:"workbench-info-skeleton-card",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx(Jk,{count:3})]},t))})}function eL({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),s.jsx("polyline",{points:r})]})}function Gf({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:i}){return s.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:i,children:s.jsx(eL,{side:t,collapsed:n})})}function gi({expanded:e}){return s.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})}function tL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function nL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),s.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function rL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Xk(e){return s.jsx("div",{className:"workbench-notification-anchor",children:s.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[s.jsx(rL,{}),e.unreadCount>0?s.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function sL(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return s.jsxs(St,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[s.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[s.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),s.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),s.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?s.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[s.jsx("div",{className:"workbench-notification-toolbar",children:s.jsxs("label",{className:"workbench-notification-filter",children:[s.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),s.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?s.jsx("div",{className:"workbench-notification-list",children:r.map(i=>{const o=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":o,children:[s.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[s.jsx("span",{className:"workbench-notification-item-kind",children:uM(i.kind)}),s.jsx("strong",{children:i.title}),s.jsx("p",{children:i.body})]}),s.jsxs("div",{className:"workbench-notification-item-side",children:[s.jsx("time",{children:gM(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(o){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:o?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):s.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):s.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:s.jsx(kk,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),s.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:s.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function iL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function oL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function aL(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function lL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M13 15h4"})]})}function cL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"11",r:"1"}),s.jsx("circle",{cx:"15",cy:"11",r:"1"}),s.jsx("path",{d:"M8 15h8"}),s.jsx("path",{d:"M12 5V3"})]})}function uL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),s.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Qk(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),s.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function dL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),s.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function hL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function pL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),s.jsx("path",{d:"M14 16l2 2 4-4"})]})}function fL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),s.jsx("path",{d:"M10 12h8"}),s.jsx("path",{d:"M15 8l4 4-4 4"})]})}function mL({selected:e}){return e?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),s.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Zk({active:e,className:t}){return e?s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function gL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7h18"}),s.jsx("path",{d:"M5 7l1 12h12l1-12"}),s.jsx("path",{d:"M9 11h6"}),s.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function bL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function kL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 4v10"}),s.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),s.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function yL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 14h10l1-14"}),s.jsx("path",{d:"M10 11v5"}),s.jsx("path",{d:"M14 11v5"})]})}function wL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M9 13h6"})]})}function xL(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function vL({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:o,codeError:a,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:g,onCodeSearch:m,onOpenSession:k}){const S=n.trim().length>0&&r.trim().length>0;return s.jsx(St,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:s.jsxs("div",{className:"workbench-search-modal",children:[s.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[s.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>h("sessions"),children:l("shell.searchModeSessions")}),s.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>h("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:v=>p(v.target.value)})]}),s.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(v=>{const w=gd(v.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>k(v.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:w.fullTitle,children:w.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[v.workspace.name," · ",Sl(v.session.provider,"full")]})]},v.session.sessionId)}):s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchWorkspaceLabel")}),s.jsx("select",{value:r,onChange:v=>g(v.target.value),children:c.map(v=>s.jsx("option",{value:v.id,children:v.name},v.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:v=>{v.preventDefault(),m()},children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:v=>p(v.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||o,children:o?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[a?s.jsx("p",{className:"status-text","data-tone":"error",children:a}):null,!a&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!a&&n.trim().length>0&&!o&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(v=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:v.name}),s.jsx("span",{className:"workbench-search-result-meta",children:v.path})]},`${v.path}-${v.kind}`))]})]})]})})}const SL=`
|
|
72
|
-
html,
|
|
73
|
-
body {
|
|
74
|
-
width: 100% !important;
|
|
75
|
-
height: auto !important;
|
|
76
|
-
min-height: auto !important;
|
|
77
|
-
overflow: visible !important;
|
|
78
|
-
overflow-x: visible !important;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
body {
|
|
82
|
-
margin: 0 !important;
|
|
83
|
-
padding: 0 !important;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.session-export-document-root {
|
|
87
|
-
position: static !important;
|
|
88
|
-
inset: auto !important;
|
|
89
|
-
z-index: auto !important;
|
|
90
|
-
opacity: 1 !important;
|
|
91
|
-
pointer-events: auto !important;
|
|
92
|
-
overflow: visible !important;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.session-export-document-root,
|
|
96
|
-
.session-export-document-root * {
|
|
97
|
-
font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif);
|
|
98
|
-
letter-spacing: normal !important;
|
|
99
|
-
word-spacing: normal !important;
|
|
100
|
-
text-align: left !important;
|
|
101
|
-
-webkit-text-fill-color: currentColor !important;
|
|
102
|
-
text-fill-color: currentColor !important;
|
|
103
|
-
-webkit-background-clip: border-box !important;
|
|
104
|
-
background-clip: border-box !important;
|
|
105
|
-
text-shadow: none !important;
|
|
106
|
-
mix-blend-mode: normal !important;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.session-export-document-root .markdown-content p,
|
|
110
|
-
.session-export-document-root .markdown-content blockquote,
|
|
111
|
-
.session-export-document-root .markdown-content td {
|
|
112
|
-
display: block !important;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.session-export-document-root .markdown-content li {
|
|
116
|
-
display: list-item !important;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.session-export-document-root .markdown-content code,
|
|
120
|
-
.session-export-document-root .markdown-content pre,
|
|
121
|
-
.session-export-document-root .code-block pre,
|
|
122
|
-
.session-export-document-root .tool-call-section pre,
|
|
123
|
-
.session-export-document-root .tool-call-input-preview,
|
|
124
|
-
.session-export-document-root .apply-patch-line-content,
|
|
125
|
-
.session-export-document-root .apply-patch-summary-file {
|
|
126
|
-
font-family:
|
|
127
|
-
var(--font-mono, "SF Mono", "Consolas", "Cascadia Code", "Courier New", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", monospace) !important;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.session-export-document-root .thinking-message-label,
|
|
131
|
-
.session-export-document-root .thinking-status-text {
|
|
132
|
-
background: none !important;
|
|
133
|
-
color: var(--text-secondary, #475569) !important;
|
|
134
|
-
-webkit-text-fill-color: currentColor !important;
|
|
135
|
-
animation: none !important;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@media print {
|
|
139
|
-
body * {
|
|
140
|
-
visibility: hidden;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.session-export-document-root,
|
|
144
|
-
.session-export-document-root * {
|
|
145
|
-
visibility: visible;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.session-export-document-root {
|
|
149
|
-
position: static !important;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.session-export-document-root .session-export-print-shell {
|
|
153
|
-
width: 100%;
|
|
154
|
-
max-width: none;
|
|
155
|
-
margin: 0;
|
|
156
|
-
padding: 0;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.session-export-document-root .message-timeline-export,
|
|
160
|
-
.session-export-document-root .message-timeline-export .message-list-export {
|
|
161
|
-
overflow: visible;
|
|
162
|
-
height: auto;
|
|
163
|
-
max-height: none;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.session-export-document-root .tool-call-header,
|
|
167
|
-
.session-export-document-root .tool-call-info,
|
|
168
|
-
.session-export-document-root .task-tool-header,
|
|
169
|
-
.session-export-document-root .task-tool-heading,
|
|
170
|
-
.session-export-document-root .task-tool-heading-main,
|
|
171
|
-
.session-export-document-root .task-tool-list-item,
|
|
172
|
-
.session-export-document-root .assistant-capability-header,
|
|
173
|
-
.session-export-document-root .assistant-capability-heading,
|
|
174
|
-
.session-export-document-root .assistant-capability-heading-main,
|
|
175
|
-
.session-export-document-root .assistant-capability-row,
|
|
176
|
-
.session-export-document-root .apply-patch-summary-row,
|
|
177
|
-
.session-export-document-root .rules-message-toggle {
|
|
178
|
-
display: flex !important;
|
|
179
|
-
flex-wrap: wrap !important;
|
|
180
|
-
align-items: flex-start !important;
|
|
181
|
-
justify-content: flex-start !important;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.session-export-document-root .task-tool-list-item,
|
|
185
|
-
.session-export-document-root .assistant-capability-row,
|
|
186
|
-
.session-export-document-root .apply-patch-summary-row {
|
|
187
|
-
row-gap: 4px !important;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.session-export-document-root .tool-call-input-preview,
|
|
191
|
-
.session-export-document-root .rules-message-summary,
|
|
192
|
-
.session-export-document-root .task-tool-summary-text,
|
|
193
|
-
.session-export-document-root .task-tool-item-title,
|
|
194
|
-
.session-export-document-root .task-tool-item-detail,
|
|
195
|
-
.session-export-document-root .task-tool-item-status,
|
|
196
|
-
.session-export-document-root .assistant-capability-heading-main strong,
|
|
197
|
-
.session-export-document-root .assistant-capability-summary,
|
|
198
|
-
.session-export-document-root .assistant-capability-row-label,
|
|
199
|
-
.session-export-document-root .assistant-capability-row-value,
|
|
200
|
-
.session-export-document-root .apply-patch-summary-file,
|
|
201
|
-
.session-export-document-root .apply-patch-summary-stats,
|
|
202
|
-
.session-export-document-root .session-title,
|
|
203
|
-
.session-export-document-root .message-text,
|
|
204
|
-
.session-export-document-root .markdown-content,
|
|
205
|
-
.session-export-document-root .thinking-message-text,
|
|
206
|
-
.session-export-document-root .thinking-message-text :where(p, li, blockquote, strong, em, a, span),
|
|
207
|
-
.session-export-document-root .thinking-message-label,
|
|
208
|
-
.session-export-document-root .thinking-status-text {
|
|
209
|
-
white-space: normal !important;
|
|
210
|
-
overflow: visible !important;
|
|
211
|
-
text-overflow: clip !important;
|
|
212
|
-
word-break: break-word !important;
|
|
213
|
-
overflow-wrap: anywhere !important;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.session-export-document-root .assistant-capability-summary {
|
|
217
|
-
display: inline !important;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.session-export-document-root .task-tool-list {
|
|
221
|
-
list-style: decimal !important;
|
|
222
|
-
padding-left: 24px !important;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.session-export-document-root .message-timeline-export .conversation-scroll-to-bottom-button,
|
|
226
|
-
.session-export-document-root .message-timeline-export .message-metadata-bar,
|
|
227
|
-
.session-export-document-root .message-timeline-export .retry-button,
|
|
228
|
-
.session-export-document-root .message-timeline-export .code-copy-button,
|
|
229
|
-
.session-export-document-root .message-timeline-export .rules-message-action,
|
|
230
|
-
.session-export-document-root .message-timeline-export .message-origin-detail-popover {
|
|
231
|
-
display: none !important;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.session-export-document-root .message-item,
|
|
235
|
-
.session-export-document-root .tool-message-row,
|
|
236
|
-
.session-export-document-root .rules-message-row {
|
|
237
|
-
break-inside: avoid;
|
|
238
|
-
page-break-inside: avoid;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
`;function CL({menuKey:e,session:t,workspace:n,workspaceContext:r,isActive:i,isFavorite:o,menuOpen:a,menuAnchorPoint:c,showWorkspaceName:u,depth:d=0,showActions:h=!0,exportDisabled:p=!1,hasSubagents:g=!1,subagentListExpanded:m=!1,showParallelBadge:k=!0,selectionMode:S=!1,selected:v=!1,onToggleSelect:w,onToggleSubagents:R,onOpen:T,onRename:F,onOpenContextMenu:E,onExport:I,onToggleFavorite:q,onArchive:z,onDelete:L,onCloseMenu:A}){var He,je,Te,_;const U=Pn(),B=$u(t.provider).supportsSessionDelete===!0,le=!U.isDesktop&&!U.isMobile,V=sl(t)?((He=t.subagentLabel)==null?void 0:He.trim())||l("shell.subagentBadge"):null,X=gd(t.title,l("common.unknown")),J=qI(t),O=J?GI("session-activity-badge",t):null,K=pd(t),ce=mR(t),N=k&&((je=t.parallelGroup)==null?void 0:je.role)==="anchor"?Ly(t.parallelGroup):null,De=Dy(t.parallelGroup),ee=f.useRef(null),[j,be]=f.useState(null),[re,fe]=f.useState(!1);f.useEffect(()=>{a||fe(!1)},[a]),f.useLayoutEffect(()=>{if(U.isDesktop||!a||!c||typeof window>"u"){be(null);return}const G=()=>{var Ce,Ae;const Q=WE(c,{width:((Ce=ee.current)==null?void 0:Ce.offsetWidth)??0,height:((Ae=ee.current)==null?void 0:Ae.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:B&&L?216:168});be({position:"fixed",top:`${Math.round(Q.top)}px`,left:`${Math.round(Q.left)}px`,width:`${Math.round(Q.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(Q.maxHeight)}px`,transformOrigin:Q.transformOrigin})};return G(),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),()=>{window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[c,a,U.isDesktop]);async function de(){await Mw([{id:`rename:${t.sessionId}`,label:l("shell.renameAction"),onSelect:F},{id:`export:${t.sessionId}`,label:l("conversation.exportAction"),disabled:p,items:[{id:`export-markdown:${t.sessionId}`,label:l("conversation.exportMarkdownAction"),onSelect:()=>I("md")},{id:`export-pdf:${t.sessionId}`,label:l("conversation.exportPdfAction"),onSelect:()=>I("pdf")},{id:`export-html:${t.sessionId}`,label:l("conversation.exportHtmlAction"),onSelect:()=>I("html")}]},{id:`favorite:${t.sessionId}`,label:o?l("shell.unfavoriteAction"):l("shell.favoriteAction"),onSelect:q},{id:`archive:${t.sessionId}`,label:l("shell.archiveAction"),onSelect:z},...B&&L?[{id:`delete:${t.sessionId}`,label:l("shell.deleteSessionAction"),onSelect:L}]:[]])}const Ue=!U.isDesktop&&a&&typeof document<"u"?$r.createPortal(s.jsxs("div",{ref:ee,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":l("shell.sessionMoreAction"),onClick:G=>G.stopPropagation(),style:j??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{F(),A()},children:[s.jsx(bL,{}),s.jsx("span",{children:l("shell.renameAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{q(),A()},children:[s.jsx(Zk,{active:o}),s.jsx("span",{children:o?l("shell.unfavoriteAction"):l("shell.favoriteAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{z(),A()},children:[s.jsx(gL,{}),s.jsx("span",{children:l("shell.archiveAction")})]}),le?s.jsxs("div",{className:"workbench-session-submenu","data-open":re,children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item","aria-haspopup":"menu","aria-expanded":re,onClick:()=>{fe(G=>!G)},children:[s.jsx(kL,{}),s.jsx("span",{children:l("conversation.exportAction")}),s.jsx("span",{className:"workbench-session-submenu-caret","aria-hidden":"true",children:s.jsx(gi,{expanded:re})})]}),re?s.jsxs("div",{className:"workbench-session-submenu-panel",role:"menu","aria-label":l("conversation.exportAction"),children:[s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{I("md"),A()},children:s.jsx("span",{children:l("conversation.exportMarkdownAction")})}),s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{I("pdf"),A()},children:s.jsx("span",{children:l("conversation.exportPdfAction")})}),s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{I("html"),A()},children:s.jsx("span",{children:l("conversation.exportHtmlAction")})})]}):null]}):null,B&&L?s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{L(),A()},children:[s.jsx(yL,{}),s.jsx("span",{children:l("shell.deleteSessionAction")})]}):null]}),document.body):null;return s.jsxs("article",{className:"workbench-session-card","data-active":i,"data-depth":d,"data-subagent":sl(t),"data-workspace-tone":r.tone,"data-worktree-depth":r.depth,"data-has-subagents":g,"data-selecting":S,"data-selected":v,"data-parallel-group":t.parallelGroup?"true":void 0,"data-parallel-role":((Te=t.parallelGroup)==null?void 0:Te.role)??void 0,"data-parallel-color-token":((_=t.parallelGroup)==null?void 0:_.colorToken)??void 0,style:{...Wr(r)??{},...De??{}},onContextMenu:G=>{if(!(S||!h||!E)){if(G.preventDefault(),G.stopPropagation(),U.isDesktop){de();return}E({x:G.clientX,y:G.clientY})}},children:[s.jsxs("div",{className:"workbench-session-main",children:[S?s.jsx("span",{className:"workbench-session-selection-indicator","data-selected":v,"aria-hidden":"true",children:s.jsx(mL,{selected:v})}):g?s.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:OM,"data-indicator-variant":BM(t,{hasSubagents:!0,isActive:i}),"aria-label":m?l("shell.subagentCollapse"):l("shell.subagentExpand"),title:m?l("shell.subagentCollapse"):l("shell.subagentExpand"),"aria-expanded":m,onClick:G=>{G.stopPropagation(),R==null||R()},children:[s.jsx("span",{className:Df(t,{hasSubagents:!0,isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),s.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:s.jsx(gi,{expanded:m})})]}):s.jsx("span",{className:Df(t,{isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),s.jsx("button",{type:"button",className:"workbench-session-link",style:g?DM:void 0,"data-active":i,"aria-pressed":S?v:void 0,onClick:S?w:T,onKeyDown:G=>{if(S||!h||!E||G.key!=="ContextMenu"&&!(G.shiftKey&&G.key==="F10"))return;if(G.preventDefault(),G.stopPropagation(),U.isDesktop){de();return}const Q=G.currentTarget.getBoundingClientRect();E({x:Q.right,y:Q.bottom})},children:s.jsxs("div",{className:"workbench-session-link-copy",children:[s.jsxs("div",{className:"session-title-row",children:[s.jsx("span",{className:"session-title",title:X.fullTitle,children:X.displayTitle}),V?s.jsx("span",{className:"session-subagent-badge",children:V}):null,N?s.jsx("span",{className:"session-parallel-badge",children:N}):null,!N&&ce&&K?s.jsx("span",{className:`session-fork-badge ${K}`,children:ce}):null]}),s.jsxs("div",{className:"session-meta-row",children:[s.jsx("span",{className:"session-meta",children:Ek(t,n,u,r.displayName)}),J&&O?s.jsx("span",{className:O,children:J}):null,s.jsx("span",{className:`session-provider-badge ${t.provider}`,children:Sl(t.provider)})]})]})})]}),Ue]})}async function NL(e,t=document){await Vf(),await Vf(),await yd(420),await TL(t,1800),e&&await IL(e,1800)}function jL(){if(typeof document>"u")return"";const e=[];for(const t of Array.from(document.styleSheets))try{const n=t.cssRules;if(!n||n.length===0)continue;e.push(Array.from(n).map(r=>r.cssText).join(`
|
|
242
|
-
`))}catch{continue}return e.join(`
|
|
243
|
-
`)}function Kf(e){const t={};for(const n of Array.from(e.attributes))n.name!=="style"&&(t[n.name]=n.value);return t}function Vf(){return new Promise(e=>{window.requestAnimationFrame(()=>e())})}function yd(e){return new Promise(t=>{window.setTimeout(t,e)})}async function TL(e,t){const n=e.fonts;!n||typeof n.ready>"u"||await Promise.race([n.ready.catch(()=>{}),yd(t)])}async function IL(e,t){const n=Array.from(e.querySelectorAll("img"));n.length!==0&&await Promise.race([Promise.all(n.map(r=>RL(r))),yd(t)])}function AL(){if(typeof document>"u")return{shellWidthPx:null};const e=[".conversation-timeline-shell",".conversation-main",".conversation-panel"];for(const t of e){const n=document.querySelector(t);if(!(n instanceof HTMLElement))continue;const r=n.getBoundingClientRect();if(!(!Number.isFinite(r.width)||r.width<=0))return{shellWidthPx:Math.round(r.width)}}return{shellWidthPx:null}}function RL(e){return e.complete?Promise.resolve():new Promise(t=>{const n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),t()};e.addEventListener("load",n),e.addEventListener("error",n)})}function Yf({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:n,favoriteSessions:r,favoriteSessionIds:i,activeWorkspaceId:o,isConversationActive:a,isTerminalActive:c,isButlerActive:u,isSearchOpen:d,navigationLoading:h,navigationError:p,activeSessionId:g,onRefreshNavigation:m,onSessionUpdated:k,onNavigateConversation:S,onNavigateTerminals:v,onNavigateButler:w,onOpenSearch:R,onOpenSettings:T,onSelectWorkspace:F,onToggleWorkspaceCollapse:E,onStartWorkspaceReorder:I,onPreviewWorkspaceReorder:q,onCommitWorkspaceReorder:z,allowWorkspaceReorder:L,subscribeGitSnapshot:A,requestGitRefresh:U,subscribeWorkspaceManagementSnapshot:B,requestWorkspaceManagementRefresh:le,onToggleFavoriteSession:V,onArchiveSession:X,onUnarchiveSession:J,workspaceManagementStateById:O,setWorkspaceManagementStateById:K,unreadNotificationCount:ce,notificationPanelOpen:N,onToggleNotificationPanel:De,onClose:ee,onToggleCollapse:j}){var $i;const be=Co(),re=Pn(),fe=Wm(re),{showToast:de}=ar(),Ue=ad(),He=al(y=>y),je=(($i=Oa(He))==null?void 0:$i.name)??"",Te=He.hosts.length+rm(He).length>1&&je.length>0,[_,G]=f.useState(!1),[Q,Ce]=f.useState(!1),[Ae,ve]=f.useState(!1),[Tt,rt]=f.useState([]),[gt,ae]=f.useState(null),[ie,ke]=f.useState(null),[ye,Re]=f.useState(null),[$,Z]=f.useState(null),[ge,Ne]=f.useState(null),[Be,Ve]=f.useState(null),[Ie,dt]=f.useState(null),[Ze,st]=f.useState(!1),[it,qe]=f.useState(!1),[bt,Ut]=f.useState(""),[Ye,ht]=f.useState(""),[Oe,kt]=f.useState(""),[et,Dt]=f.useState({localBranches:[],remoteBranches:[],tags:[]}),[D,he]=f.useState(!1),[Ee,we]=f.useState(-1),[Se,pt]=f.useState(!1),[Bt,mt]=f.useState(!1),[_t,tt]=f.useState(null),[ct,Ht]=f.useState(null),[_s,qr]=f.useState(null),[yt,hs]=f.useState(null),[gn,cr]=f.useState(null),[Qt,Yn]=f.useState(null),[Zt,en]=f.useState(null),[vn,Ws]=f.useState(!1),[Kt,Sn]=f.useState(null),[wt,Rr]=f.useState(null),[ur,dr]=f.useState(null),[bn,Gr]=f.useState(null),[Er,hr]=f.useState(Mc),[pr,zn]=f.useState({}),[ps,Kr]=f.useState({}),[Ai,Fs]=f.useState([]),[Ln,fs]=f.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[rn,fr]=f.useState(null),[Pr,mr]=f.useState(""),[Mr,sn]=f.useState(null),[Rt,on]=f.useState(null),[Wt,an]=f.useState([]),[gr,Vr]=f.useState(!1),[br,Vt]=f.useState({}),[Yr,Jn]=f.useState(null),Dn=f.useRef(null),Xn=f.useRef(null),Qn=f.useRef(null),x=f.useRef(null),H=f.useRef(new Map),Pe=f.useRef(null),Je=f.useRef(null),Cn=f.useRef(null),Lr=f.useMemo(()=>new Set(Ln.expandedWorkspaceIds),[Ln.expandedWorkspaceIds]),Jr=f.useMemo(()=>new Set(Ln.collapsedWorkspaceIds),[Ln.collapsedWorkspaceIds]),Nn=Yr!==null,kn=L&&re.isDesktop&&re.ui.osFamily==="macos",kr=f.useMemo(()=>IM(e,n),[e,n]),Xe=f.useMemo(()=>{const y=new Map;for(const P of e){y.set(P.workspace.id,di(P).map(W=>yu(kr,W.item.sessionId)??W));for(const W of Ok(P.childWorktrees)){const ne=W.visibleSessionTree.map(oe=>yu(kr,oe.item.sessionId)??oe).filter(oe=>oe.item.workspaceId===W.workspace.id&&oe.depth===0);y.set(W.workspace.id,ne)}}return y},[kr,e]),Ct=f.useCallback(()=>{Sn(null),Rr(null)},[]),Nt=f.useCallback((y,P)=>{Sn(y),Rr(P)},[]),xt=Oc(e,ge)??((Ie==null?void 0:Ie.id)===ge?Ie:null),Dr=Oe.trim().toLowerCase(),yr=f.useMemo(()=>[{key:"localBranches",label:l("shell.createWorktreeBaseRefLocalGroup"),items:et.localBranches},{key:"remoteBranches",label:l("shell.createWorktreeBaseRefRemoteGroup"),items:et.remoteBranches},{key:"tags",label:l("shell.createWorktreeBaseRefTagGroup"),items:et.tags}].map(P=>({...P,items:P.items.filter(W=>Dr?W.value.toLowerCase().includes(Dr):!0)})).filter(P=>P.items.length>0),[Dr,et]),yn=f.useMemo(()=>yr.flatMap(y=>y.items),[yr]),Zn=xt?`create-worktree-base-ref-listbox-${xt.id}`:"create-worktree-base-ref-listbox",hn=UM(e,yt),er=hn?vr(hn.workspace):null,$s=(hn==null?void 0:hn.archivedSessions)??[],{searchOpen:zs,searchKeyword:Ri,filteredSessions:ln,summaryLoading:qt,summaryError:tr,summaryBySessionId:Us,setSearchKeyword:Ei,toggleSearch:Pi}=UP(hn!==null,$s),We=f.useId(),wr=f.useMemo(()=>zM(e,Rt),[Rt,e]),ms=f.useMemo(()=>wr?PM(wr.visibleSessionTree):[],[wr]),jn=f.useMemo(()=>ms.map(y=>y.sessionId),[ms]),Xr=f.useMemo(()=>new Set(jn),[jn]),Nl=f.useMemo(()=>new Set(Wt),[Wt]),gs=jn.length>0&&Wt.length===jn.length;f.useEffect(()=>{K(y=>{const P=zf(e),W=new Set(P),ne={};Object.entries(y).forEach(([me,ot])=>{W.has(me)&&(ne[me]=ot)}),P.forEach(me=>{const ot=Oc(e,me);if(!ot)return;const Mt=Wa(vu(me),Nf),It=Wa(Gk(me),Nf),Yt=ne[me];let qn=Vk((Yt==null?void 0:Yt.detail)??Mt??Kk(ot),ot);(It!=null&&It.status||It!=null&&It.branches)&&(qn=Yk(qn,{status:It.status??null,branches:It.branches??null})),ne[me]={detail:qn,loading:!1,error:null}});const oe=Object.keys(y),Fe=Object.keys(ne);return oe.length===Fe.length&&Fe.every(me=>y[me]===ne[me])?y:ne})},[e]);const On=f.useCallback(async y=>{await m(),await re.bridge.showNotification(l("shell.importSuccess"),y.path)},[m,re.bridge]),Ft=f.useCallback(async y=>{await m(),await re.bridge.showNotification(l("shell.cloneSuccess"),y.path)},[m,re.bridge]);function bs(y){if(Tt.includes(y)){rt(W=>W.filter(ne=>ne!==y));return}rt(W=>[...W,y]),A(y),U(y),B(y),le(y)}async function Mi(y,P){if(br[y])return;const W=(P==null?void 0:P.trim().toUpperCase())??null;Vt(ne=>({...ne,[y]:!0}));try{await mm(y,{backgroundColor:W}),await m()}catch(ne){de({title:ne instanceof Error?ne.message:l("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{Vt(ne=>({...ne,[y]:!1}))}}async function Hs(){if(!(!gt||ie)){ke(gt.id);try{await Hy(gt.id),rt(y=>y.filter(P=>P!==gt.id)),K(y=>{const P={...y};return delete P[gt.id],P}),ae(null),await m(),de({title:l("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(y){de({title:y instanceof Error?y.message:l("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{ke(null)}}}f.useEffect(()=>{if(!Kt)return;function y(P){const W=P.target;W instanceof HTMLElement&&W.closest(".workbench-session-menu")||Ct()}return window.addEventListener("pointerdown",y),()=>{window.removeEventListener("pointerdown",y)}},[Ct,Kt]),f.useEffect(()=>{if(!Rt){Wt.length>0&&an([]),Zt&&en(null);return}if(!wr){on(null),an([]),en(null);return}an(y=>zk(y,Xr))},[wr,Zt,Xr,Rt,Wt.length]),f.useEffect(()=>{Rt&&jn.length===0&&(on(null),an([]),en(null))},[jn.length,Rt]),f.useEffect(()=>{const y=new Set(zf(e)),P=new Set(e.flatMap(W=>xu(W.childWorktrees)));rt(W=>W.filter(ne=>y.has(ne))),fs(W=>({expandedWorkspaceIds:W.expandedWorkspaceIds.filter(ne=>P.has(ne)),collapsedWorkspaceIds:W.collapsedWorkspaceIds.filter(ne=>P.has(ne))})),ae(W=>W&&y.has(W.id)?W:null),Vt(W=>Object.fromEntries(Object.entries(W).filter(([ne,oe])=>oe&&y.has(ne))))},[e]),f.useEffect(()=>{const y=r.findIndex(P=>P.session.sessionId===g);hr(P=>{const W=Sa(r.length,Mc,P,y);return W===P?P:W})},[g,r]),f.useEffect(()=>{zn(y=>{const P={};for(const W of e){const ne=di(W),oe=ne.findIndex(Fe=>Fe.item.sessionId===g||Ui([Fe],g??"",me=>me.sessionId).length>0);P[W.workspace.id]=Sa(ne.length,Xi,y[W.workspace.id],oe);for(const Fe of so(W.childWorktrees)){Fe.item.sessionId===g||Ui([Fe],g??"",It=>It.sessionId).length>0;const me=Fe.item.workspaceId;if(P[me]!==void 0)continue;const ot=so(W.childWorktrees).filter(It=>It.item.workspaceId===me&&It.depth===0),Mt=ot.findIndex(It=>It.item.sessionId===g||Ui([It],g??"",Yt=>Yt.sessionId).length>0);P[me]=Sa(ot.length,Xi,y[me],Mt)}}return Lf(y,P)?y:P})},[g,e]),f.useEffect(()=>{Kr(y=>{const P={};for(const W of e)for(const ne of[...di(W),...so(W.childWorktrees)])for(const oe of li(En(ne))){const Fe=En(oe);if(Fe.length===0)continue;const me=li(Fe),ot=me.findIndex(Mt=>Mt.item.sessionId===g);P[oe.item.sessionId]=Sa(me.length,xa,y[oe.item.sessionId],ot)}return Lf(y,P)?y:P})},[g,e]),f.useEffect(()=>{if(!g)return;const y=e.flatMap(P=>[...Ui(di(P),g,W=>W.sessionId),...so(P.childWorktrees).flatMap(W=>Ui([W],g,ne=>ne.sessionId))]);y.length!==0&&Fs(P=>{const W=new Set(P);let ne=!1;for(const oe of y)W.has(oe)||(W.add(oe),ne=!0);return ne?Array.from(W):P})},[g,e]),f.useEffect(()=>{if(!o)return;const y=[];for(const P of e){const W=Fk(P.childWorktrees,o);W.length!==0&&y.push(...W)}y.length>0&&fs(P=>{const W=new Set(P.expandedWorkspaceIds);let ne=!1;for(const oe of y)W.has(oe)||(W.add(oe),ne=!0);return ne?{expandedWorkspaceIds:Array.from(W),collapsedWorkspaceIds:P.collapsedWorkspaceIds}:P})},[o,e]),f.useEffect(()=>{if(!ge){dt(null),st(!1),qe(!1),Ut(""),ht(""),kt(""),he(!1),we(-1),pt(!1),Dt({localBranches:[],remoteBranches:[],tags:[]}),mt(!1),tt(null);return}st(!1),Ut(""),ht(""),kt(""),he(!1),we(-1),pt(!1),Dt({localBranches:[],remoteBranches:[],tags:[]}),mt(!1),tt(null)},[ge]),f.useEffect(()=>{const y=xt;if(!Ze||!y)return;let P=!1;const W=y.id;return mt(!0),tt(null),Promise.all([Cw(W),Nw(W)]).then(([ne,oe])=>{P||Dt(pM(ne,oe))}).catch(()=>{P||(Dt({localBranches:[],remoteBranches:[],tags:[]}),tt(l("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{P||mt(!1)}),()=>{P=!0}},[xt==null?void 0:xt.id,Ze]),f.useLayoutEffect(()=>{if(!D||!Dn.current){Ht(null),qr(null);return}const y=()=>{const W=Dn.current;if(!W)return;const ne=fM(W);Ht({top:ne.bottom+8,left:ne.left,width:ne.width})};y();const P=W=>{var oe,Fe;const ne=W.target;ne instanceof Node&&((oe=Dn.current)!=null&&oe.contains(ne)||(Fe=Xn.current)!=null&&Fe.contains(ne)||(he(!1),we(-1)))};return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),window.addEventListener("pointerdown",P),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0),window.removeEventListener("pointerdown",P)}},[yn.length,D]),f.useLayoutEffect(()=>{if(!D||!Xn.current){qr(null);return}const y=Xn.current,P=()=>{const ne=Math.ceil(y.getBoundingClientRect().height);qr(oe=>oe===ne?oe:ne)};if(P(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{P()});return W.observe(y),()=>{W.disconnect()}},[D,yr,Bt,_t]);function ks(){G(!0)}function jl(){Ce(!0)}function nr(y){Un(),Ne(null),Ve({kind:"workspace",workspaceId:y.id,workspaceName:y.name})}function Un(){st(!1),Ut(""),ht(""),kt(""),he(!1),we(-1),pt(!1)}function Li(y,P){const W=y.getBoundingClientRect();return P<=W.top+W.height/2?"before":"after"}function Di(){x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),Jn(null)}function Qr(y){const P=(y==null?void 0:y.commit)??!1,W=(y==null?void 0:y.preserveClickSuppression)??!1,ne=Pe.current,oe=Je.current;Pe.current=null,Je.current=null,oe==null||oe(),ne!=null&&ne.dragging&&(Di(),P&&z(),!W&&Cn.current===ne.workspaceId&&(Cn.current=null))}function Tl(y){if(Cn.current===y){Cn.current=null;return}E(y)}function rr(y,P){if(P){H.current.set(y,P);return}H.current.delete(y)}function Mo(y,P){for(const[W,ne]of H.current){const oe=ne.getBoundingClientRect();if(y>=oe.left&&y<=oe.right&&P>=oe.top&&P<=oe.bottom)return{workspaceId:W,element:ne}}return null}function qs(y,P){var ot;if(!kn||y.button!==0)return;Qr();const W=y.currentTarget,ne={pointerId:y.pointerId,workspaceId:P,startX:y.clientX,startY:y.clientY,pointerTarget:W,dragging:!1};Pe.current=ne,(ot=W.setPointerCapture)==null||ot.call(W,y.pointerId);const oe=Mt=>{cn(Mt)},Fe=Mt=>{Or(Mt.pointerId,{commit:!0,preserveClickSuppression:!0})},me=Mt=>{Or(Mt.pointerId,{commit:!1,preserveClickSuppression:!1})};Je.current=()=>{W.removeEventListener("pointermove",oe),W.removeEventListener("pointerup",Fe),W.removeEventListener("pointercancel",me),window.removeEventListener("pointermove",oe),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",me)},W.addEventListener("pointermove",oe),W.addEventListener("pointerup",Fe),W.addEventListener("pointercancel",me),window.addEventListener("pointermove",oe,{passive:!1}),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",me)}function cn(y){const P=Pe.current;if(!P||P.pointerId!==y.pointerId)return;if(!P.dragging){if(Math.hypot(y.clientX-P.startX,y.clientY-P.startY)<QP)return;P.dragging=!0,Cn.current=P.workspaceId,I(),Jn(P.workspaceId)}y.preventDefault();const W=Mo(y.clientX,y.clientY);!W||W.workspaceId===P.workspaceId||q(P.workspaceId,W.workspaceId,Li(W.element,y.clientY))}function Or(y,P){var ne,oe;const W=Pe.current;!W||W.pointerId!==y||((oe=(ne=W.pointerTarget).releasePointerCapture)==null||oe.call(ne,y),Qr(P))}function Oi(y){cn(y)}function Il(y){Or(y.pointerId,{commit:!0,preserveClickSuppression:!0})}function Al(y){Or(y.pointerId,{commit:!1,preserveClickSuppression:!1})}function Lo(y,P){y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("text/plain",P),I(),x.current!==null&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{x.current=null,Jn(P)})}function Rl(y,P){const W=Yr||y.dataTransfer.getData("text/plain");!W||W===P||(y.preventDefault(),y.dataTransfer.dropEffect="move",q(W,P,Li(y.currentTarget,y.clientY)))}function El(y){y.preventDefault()}function Pl(){Di(),z()}f.useEffect(()=>()=>{Qr()},[]);function Ml(y){return ps[y]??xa}function Ll(y){return Ai.includes(y)}function Gs(y){return pr[y]??Xi}function Dl(){hr(y=>Math.min(r.length,y+Mc))}function Do(y,P){zn(W=>({...W,[y]:Math.min(P,(W[y]??Xi)+Xi)}))}function Br(y){Kr(P=>({...P,[y]:(P[y]??xa)+xa}))}function Ks(y){Fs(P=>P.includes(y)?P.filter(W=>W!==y):[...P,y])}function ys(y,P){return Jr.has(y)?!1:P||Lr.has(y)}function Oo(y,P){const W=!ys(y,P);fs(ne=>{const oe=ne.expandedWorkspaceIds.filter(me=>me!==y),Fe=ne.collapsedWorkspaceIds.filter(me=>me!==y);return W?{expandedWorkspaceIds:[...oe,y],collapsedWorkspaceIds:Fe}:{expandedWorkspaceIds:oe,collapsedWorkspaceIds:[...Fe,y]}})}function Bo(y){const P=li(kr).find(W=>W.item.sessionId===y)??null;return P?En(P):[]}function Bi(y,P){const W=vr(y);return s.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":W.tone,style:Wr(W),onClick:()=>hs(y.id),children:[s.jsxs("span",{className:"workbench-archive-folder-main",children:[s.jsx(wL,{}),s.jsx("span",{children:l("shell.archiveFolderLabel")})]}),s.jsx("span",{className:"workbench-section-counter",children:P.length})]})}function Vs(){return s.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[s.jsx("span",{className:"workbench-workspace-batch-label",children:l("shell.batchSelectionMode")}),s.jsxs("span",{className:"workbench-workspace-batch-counter",children:[Wt.length,"/",jn.length]}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Bl,children:gs?l("shell.clearSelectedSessions"):l("shell.selectAllSessions")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Wt.length===0||gr||vn,onClick:()=>{Xs()},children:gr?l("shell.batchArchiving"):l("shell.batchArchiveAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action danger",disabled:Wt.length===0||gr||vn,onClick:Fo,children:vn?l("shell.batchDeleting"):l("shell.batchDeleteAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Wo,children:l("common.cancel")})]})}function _i(y,P="workbench-workspace-actions"){return s.jsxs("div",{className:P,children:[s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.switchWorkspace"),title:l("shell.switchWorkspace"),"aria-pressed":o===y,onClick:()=>{F(y),ee==null||ee()},children:s.jsx(fL,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.batchSelectSessions"),title:l("shell.batchSelectSessions"),onClick:()=>Ol(y),children:s.jsx(pL,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":l("shell.createSession"),title:l("shell.createSession"),onClick:()=>Ne(y),children:s.jsx(iL,{})})]})}function _o(y){const P=Xe.get(y.workspace.id)??y.visibleSessionTree,ne=new Set(xu(y.children)).has(o??""),oe=y.workspace.id===o||ne,Fe=Nn||!ys(y.workspace.id,oe),me=vr(y.workspace);return s.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":Rt===y.workspace.id,"data-worktree-depth":y.meta.depth,"data-workspace-tone":"worktree",style:Wr(me),children:[s.jsxs("div",{className:"workbench-workspace-header minimal",children:[s.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":Fe?l("shell.worktreeExpand"):l("shell.worktreeCollapse"),onClick:()=>Oo(y.workspace.id,oe),children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(gi,{expanded:!Fe})}),s.jsxs("span",{children:[s.jsx("strong",{children:y.meta.displayName||y.workspace.name}),s.jsx("span",{className:"session-meta",children:y.meta.branchName})]})]}),Rt===y.workspace.id?Vs():_i(y.workspace.id)]}),Fe?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-session-list","data-workspace-tone":me.tone,style:Wr(me),children:[P.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):P.slice(0,Gs(y.workspace.id)).map(ot=>ws({node:ot,workspace:y.workspace,workspaceContext:me,menuKeyPrefix:`worktree:${y.workspace.id}`,showWorkspaceName:!1,selectionMode:Rt===y.workspace.id,favoriteEnabled:!0})),P.length>Gs(y.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Do(y.workspace.id,P.length),children:l("shell.sessionExpandMore")}):null]}),y.children.length>0?s.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:y.children.map(ot=>_o(ot))}):null,Bi(y.workspace,y.archivedSessions)]})]},y.workspace.id)}function ws(y){var xd,vd,Sd,Cd;const{node:P,fullNode:W=P,branchKey:ne,subagentStateKey:oe,workspace:Fe,workspaceContext:me,menuKeyPrefix:ot,showWorkspaceName:Mt,selectionMode:It,favoriteEnabled:Yt,showParallelBadge:qn=!0,forceInactive:Gn=!1,ancestorExpanded:Zr=!1,allowToggle:b=P.depth===0,ancestorHasNextSiblings:C=[],hasNextSibling:M=!1,isFirstSibling:te=!1}=y,se=P.item,pe=Oc(e,se.workspaceId)??Fe,Me=vr(pe),_e=En(W),$e=oe??se.sessionId,xe=Ll($e),lt=Zr&&En(P).length>0,Tn=xe,Bn=lt||Tn,$t=xe&&b,sr=lt?P:$t?MM(P,Ml($e),n):W,Qs=Bn?En(sr):[],ny=li(_e).length,ry=li(Qs).length,sy=$t&&ry<ny,iy=P.depth>0?[...C,M]:[...C],Zs=((vd=(xd=se.parallelGroup)==null?void 0:xd.groupId)==null?void 0:vd.trim())||null,$l=((Sd=se.parallelGroup)==null?void 0:Sd.role)==="anchor"&&Zs?Qs.filter(ft=>{var zt;return((zt=ft.item.parallelGroup)==null?void 0:zt.groupId)===Zs}):[],oy=Qs.filter(ft=>{var zt;return((zt=ft.item.parallelGroup)==null?void 0:zt.groupId)!==Zs}),ay=((Cd=se.parallelGroup)==null?void 0:Cd.role)==="anchor"&&Zs?_e.filter(ft=>{var zt;return((zt=ft.item.parallelGroup)==null?void 0:zt.groupId)===Zs}):[],ly=_e.filter(ft=>{var zt;return((zt=ft.item.parallelGroup)==null?void 0:zt.groupId)!==Zs}),cy=$l.length>0?oy:[],wd=$l.length>0?[Mf({session:se,depth:P.depth+1,children:cy.map(ft=>ku(ft,1))}),...$l].map((ft,zt)=>{const zi=zt===0,uy=Mf({session:se,depth:P.depth+1,children:ly.map(zl=>ku(zl,1))});return{node:ft,fullNode:zi?uy:ay.find(zl=>zl.item.sessionId===ft.item.sessionId)??ft,branchKey:zi?Pf(se.sessionId):void 0,subagentStateKey:zi?Pf(se.sessionId):void 0,showParallelBadge:!zi,forceInactive:zi}}):Qs.map(ft=>({node:ft,fullNode:_e.find(zt=>zt.item.sessionId===ft.item.sessionId)??ft}));return s.jsxs("div",{className:"workbench-session-tree-node",children:[s.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":P.depth},children:[P.depth>0?s.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[C.map((ft,zt)=>ft?s.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":zt+1}},`${se.sessionId}:ancestor:${zt}`):null),s.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":M,"data-first":te,style:{"--workbench-session-tree-level":P.depth},children:s.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,s.jsx(CL,{menuKey:`${ot}:${ne??se.sessionId}`,session:se,workspace:pe,workspaceContext:Me,isActive:!Gn&&se.sessionId===g,isFavorite:Yt&&i.has(se.sessionId),menuOpen:Kt===`${ot}:${ne??se.sessionId}`,showWorkspaceName:Mt,depth:P.depth,showActions:Yt,exportDisabled:ur!==null,hasSubagents:b&&_e.length>0,subagentListExpanded:Tn,showParallelBadge:qn,selectionMode:It,selected:Nl.has(se.sessionId),onToggleSelect:()=>Ys(se.sessionId),onToggleSubagents:()=>Ks($e),onOpen:()=>{be(jr(pe.id,se.sessionId)),ee==null||ee()},onRename:()=>zo(se,pe),menuAnchorPoint:Kt===`${ot}:${ne??se.sessionId}`?wt:null,onOpenContextMenu:ft=>Nt(`${ot}:${ne??se.sessionId}`,ft),onExport:ft=>xr(se,ft),onToggleFavorite:()=>$o(se.sessionId),onArchive:()=>Hn(se.sessionId),onDelete:$u(se.provider).supportsSessionDelete===!0?()=>{Ct(),cr({session:se,workspace:pe})}:void 0,onCloseMenu:Ct})]}),_e.length>0&&Bn?s.jsxs("div",{className:"workbench-subsession-list",children:[wd.map((ft,zt)=>ws({node:ft.node,fullNode:ft.fullNode,branchKey:ft.branchKey,subagentStateKey:ft.subagentStateKey,workspace:Fe,workspaceContext:me,menuKeyPrefix:ot,showWorkspaceName:Mt,selectionMode:It,favoriteEnabled:Yt,showParallelBadge:ft.showParallelBadge,forceInactive:ft.forceInactive,allowToggle:!0,ancestorHasNextSiblings:iy,hasNextSibling:zt<wd.length-1,isFirstSibling:zt===0})),sy?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Br($e),children:l("shell.subagentExpandMore")}):null]}):null]},ne??se.sessionId)}function Ol(y){Ct(),on(y),an([]),en(null)}function Wo(){on(null),an([]),en(null)}function Ys(y){an(P=>JM(P,y))}function Bl(){an(y=>y.length===jn.length?[]:jn)}function Fo(){if(!wr||Wt.length===0||gr||vn)return;const y=new Map(ms.map(W=>[W.sessionId,W])),P=Wt.flatMap(W=>{const ne=y.get(W);return ne?[ne]:[]});P.length!==0&&(Ct(),en({workspace:wr.workspace,sessions:P}))}async function _l(y,P){Re(y),Z(P);try{await Sk(y,P),Ne(null),be(am(y,P)),ee==null||ee()}catch(W){de({title:W instanceof Error?W.message:l("shell.startSessionFailed"),tone:"error"})}finally{Re(null),Z(null)}}async function Wl(y){if(y.preventDefault(),!xt||it)return;const P=bt.trim(),W=Ye.trim(),ne=Oe.trim();if(!P){de({title:l("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!dM(P)){de({title:l("shell.createWorktreeBranchInvalid"),tone:"error"});return}qe(!0);try{const oe=await Qy({sourceWorkspaceId:xt.id,branchName:P,displayName:W||void 0,baseRef:ne||void 0});dt(oe.workspace),F(oe.workspace.id),await m(),Ne(oe.workspace.id),Un(),de({title:l("shell.createWorktreeSucceeded",{name:oe.meta.displayName||oe.workspace.name}),tone:"success"})}catch(oe){de({title:oe instanceof Error?oe.message:l("shell.createWorktreeFailed"),tone:"error"})}finally{qe(!1)}}async function $o(y){const P=i.has(y);Ct();try{await V(y),de({title:P?l("shell.favoriteRemoved"):l("shell.favoriteAdded"),tone:"success"})}catch(W){de({title:W instanceof Error?W.message:l("shell.favoriteToggleFailed"),tone:"error"})}}async function Hn(y){Ct();try{await X(y),de({title:l("shell.archiveAdded"),tone:"success"})}catch(P){de({title:P instanceof Error?P.message:l("shell.navigationLoadFailed"),tone:"error"})}}async function xr(y,P){var W,ne;if(!ur){Ct(),dr(y.sessionId);try{const oe=await lE(y.sessionId),Fe=AL();if(P==="md"){const C=Cc(y,"md"),M=cE(y,oe.messages);Up(C,M,"text/markdown;charset=utf-8"),de({title:l("conversation.exportMarkdownSuccess"),tone:"success"});return}$r.flushSync(()=>{Gr({session:y,items:eA({messages:oe.messages}),shellWidthPx:Fe.shellWidthPx})}),await NL(Qn.current);const me=((W=Qn.current)==null?void 0:W.innerHTML.trim())??"";if(!me)throw new Error(l("conversation.exportLoadFailed"));const ot=Kf(document.documentElement),Mt=document.body?Kf(document.body):{},It=document.documentElement.getAttribute("style"),Yt=((ne=document.body)==null?void 0:ne.getAttribute("style"))??null,qn=`${jL()}
|
|
244
|
-
${SL}`,Gn=hE({title:y.title||l("conversation.titleFallback"),bodyHtml:`<div class="session-export-document-root">${me}</div>`,styleText:qn,htmlAttributes:ot,bodyAttributes:Mt,htmlStyle:It,bodyStyle:Yt});if(P==="html"){const C=Cc(y,"html");Up(C,Gn,"text/html;charset=utf-8"),de({title:l("conversation.exportHtmlSuccess"),tone:"success"});return}const Zr=Cc(y,"pdf"),b=dE(y,oe.messages);uE(Zr,b,"application/pdf"),de({title:l("conversation.exportPdfPreparing"),tone:"success"})}catch(oe){de({title:oe instanceof Error?oe.message:l("conversation.exportLoadFailed"),tone:"error"})}finally{$r.flushSync(()=>{Gr(null)}),dr(null)}}}async function Js(){if(!gn||Qt)return;const{session:y,workspace:P}=gn;Yn(y.sessionId),Ct();try{await Id(y.sessionId),an(W=>W.filter(ne=>ne!==y.sessionId)),cr(null),g===y.sessionId&&be(P.id?po(P.id):wn()),await m(),de({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(W){de({title:W instanceof Error?W.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{Yn(null)}}async function Xs(){if(!(Wt.length===0||gr||vn)){Ct(),Vr(!0);try{const y=[...Wt],P=await Promise.allSettled(y.map(async oe=>({sessionId:oe,session:await km(oe,!0)}))),W=[];let ne=0;for(const oe of P){if(oe.status==="fulfilled"){W.push(oe.value.sessionId),k(oe.value.session);continue}ne+=1}W.length>0&&(await m(),an(oe=>oe.filter(Fe=>!W.includes(Fe)))),ne>0?de({title:W.length>0?l("shell.batchArchivePartialFailed"):l("shell.batchArchiveFailed"),tone:"error"}):de({title:l("shell.batchArchiveSuccess"),tone:"success"})}catch(y){de({title:y instanceof Error?y.message:l("shell.batchArchiveFailed"),tone:"error"})}finally{Vr(!1)}}}async function xs(){if(!Zt||vn)return;const{workspace:y,sessions:P}=Zt,W=P.map(ne=>ne.sessionId);if(W.length===0){en(null);return}Ws(!0),Ct();try{const ne=await Promise.allSettled(W.map(async me=>(await Id(me),me))),oe=[];let Fe=0;for(const me of ne){if(me.status==="fulfilled"){oe.push(me.value);continue}Fe+=1}if(oe.length>0&&(g&&oe.includes(g)&&be(y.id?po(y.id):wn()),an(me=>me.filter(ot=>!oe.includes(ot))),await m()),Fe>0){en(me=>{if(!me)return me;const ot=me.sessions.filter(Mt=>!oe.includes(Mt.sessionId));return ot.length>0?{...me,sessions:ot}:null}),de({title:oe.length>0?l("shell.batchDeletePartialFailed"):l("shell.batchDeleteFailed"),tone:"error"});return}en(null),de({title:l("shell.batchDeleteSuccess"),tone:"success"})}catch(ne){de({title:ne instanceof Error?ne.message:l("shell.batchDeleteFailed"),tone:"error"})}finally{Ws(!1)}}async function Fl(y){Ct();try{await J(y),de({title:l("shell.archiveRestored"),tone:"success"})}catch(P){de({title:P instanceof Error?P.message:l("shell.navigationLoadFailed"),tone:"error"})}}function zo(y,P){Ct(),fr({session:y,workspace:P}),mr(y.title)}async function Uo(y){if(y.preventDefault(),!rn)return;const P=Pr.trim();if(P){sn(rn.session.sessionId);try{const W=await bm(rn.session.sessionId,P);k(W),fr(null),mr(""),de({title:l("shell.renameSuccess"),tone:"success"})}catch(W){de({title:W instanceof Error?W.message:l("shell.renameFailed"),tone:"error"})}finally{sn(null)}}}const Wi=r.slice(0,Er),Ho=Wi.length<r.length;function vr(y){return t[y.id]??rl(y)}function Fi(y,P,W,ne,oe=[]){var C;const Fe=Tt.includes(y.id),me=O[y.id]??{detail:null,loading:!1,error:null},ot=ie===y.id,Mt=br[y.id]===!0,It=(C=me.detail)!=null&&C.git.remotes.length?me.detail.git.remotes.map(M=>`${M.name}: ${M.url}`).join(" · "):l("shell.manageWorkspaceNoRemote"),Yt=me.detail?ME(me.detail.codeComposition.items,l("shell.manageWorkspaceCodeCompositionOther")):[],qn=Yt.length>0?DE(Yt):void 0,Gn=vr(y),Zr=HM(Gn,oe),b=[...oe,Gn.displayName];return s.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":Gn.tone,"data-worktree-node":ne,style:Wr(Gn),children:[s.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":Fe,onClick:()=>bs(y.id),children:[s.jsxs("span",{className:"workbench-manage-item-heading",children:[s.jsx(gi,{expanded:Fe}),s.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[s.jsx("strong",{children:Gn.displayName}),s.jsx("span",{className:"workbench-manage-item-tree-path",children:Zr})]})]}),s.jsx("span",{className:"workbench-section-counter",children:P})]}),Fe?s.jsxs("div",{className:"workbench-manage-item-body",children:[s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspacePathLabel")}),s.jsx("p",{className:"workbench-manage-detail-value",children:y.path})]}),ne?s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsxs("div",{className:"workbench-manage-detail-header",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceColorLabel")}),s.jsxs("div",{className:"workbench-manage-color-actions",children:[s.jsx("div",{className:"workbench-manage-color-palette","aria-label":l("shell.manageWorkspaceColorLabel"),children:nM.map(M=>s.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":l("shell.manageWorkspaceColorSelectSwatch",{color:M}),"aria-pressed":y.backgroundColor===M,disabled:Mt,"data-selected":y.backgroundColor===M,style:{backgroundColor:M},onClick:()=>{Mi(y.id,M)}},M))}),s.jsx("button",{type:"button",className:"ghost-button",disabled:Mt||!y.backgroundColor,onClick:()=>{Mi(y.id,null)},children:l("shell.manageWorkspaceColorClearAction")})]})]}),s.jsx("p",{className:"workbench-manage-hint",children:y.backgroundColor??l("shell.manageWorkspaceColorUnset")})]}):null,me.loading&&me.detail===null?s.jsx("p",{className:"workbench-manage-status status-text",children:l("shell.manageWorkspaceLoading")}):null,me.error?s.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:me.error}):null,me.detail?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-manage-detail-block",children:s.jsxs("div",{className:"workbench-manage-detail-header",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitCommitCount")}),s.jsx("strong",{className:"workbench-manage-detail-accent",children:me.detail.git.commitCount??"--"})]})}),s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitInfoLabel")}),me.detail.git.isRepository?s.jsxs("div",{className:"workbench-manage-kv-list",children:[s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceRepoRoot")}),s.jsx("span",{children:me.detail.git.repoRoot??"--"})]}),s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceCurrentBranch")}),s.jsx("span",{children:me.detail.git.currentBranch??"--"})]}),s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceRemoteLabel")}),s.jsx("span",{children:It})]})]}):s.jsx("p",{className:"workbench-section-empty",children:me.detail.git.error??l("shell.manageWorkspaceNotGit")})]}),s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceCodeCompositionLabel")}),Yt.length>0?s.jsxs("div",{className:"workbench-manage-type-chart",children:[s.jsxs("div",{className:"workbench-manage-type-chart-ring",style:qn,"aria-hidden":"true",children:[s.jsx("strong",{className:"workbench-manage-type-chart-total",children:me.detail.codeComposition.scannedFileCount}),s.jsx("span",{className:"workbench-manage-type-chart-caption",children:l("shell.manageWorkspaceCodeCompositionFiles")})]}),s.jsx("div",{className:"workbench-manage-type-list",children:Yt.map(M=>s.jsxs("div",{className:"workbench-manage-type-item",children:[s.jsxs("span",{className:"workbench-manage-type-meta",children:[s.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:M.color},"aria-hidden":"true"}),s.jsx("span",{className:"workbench-manage-type-name",children:M.type})]}),s.jsxs("span",{children:[M.count," · ",PE(M)]})]},M.key))})]}):s.jsx("p",{className:"workbench-section-empty",children:me.detail.codeComposition.error??l("shell.manageWorkspaceNoCodeComposition")}),me.detail.codeComposition.truncated?s.jsx("p",{className:"workbench-manage-hint",children:l("shell.manageWorkspaceCodeTruncated",{count:me.detail.codeComposition.scannedFileCount})}):null]})]}):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(!1),be(hm(y.id))},children:l("shell.workspaceDetailDebugOpenPageAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!ie,onClick:()=>ae(y),children:ot?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveAction")})]})]}):null,W.length>0?s.jsx("div",{className:"workbench-manage-children",children:W.map(M=>Fi(M.workspace,M.visibleSessions.length+M.archivedSessions.length,M.children,!0,b))}):null]},y.id)}return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":fe,children:s.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":fe,children:[j?s.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideSessionSidebar"),title:l("shell.hideSessionSidebar"),onClick:j,children:s.jsx(Qk,{})}):null,s.jsx(bk,{}),s.jsx(Xk,{unreadCount:ce,open:N,onToggle:De})]})}),s.jsxs("div",{ref:Ue,className:"workbench-nav-body","data-scrollbar-autohide":"true",children:[s.jsxs("div",{className:"workbench-nav-segment",children:[s.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":l("shell.centerTabsLabel"),children:[s.jsxs("div",{className:"workbench-nav-segment-pair",children:[s.jsxs("button",{type:"button",className:a?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":a,onClick:S,children:[s.jsx(aL,{}),s.jsx("span",{children:l("shell.conversationEntry")})]}),s.jsxs("button",{type:"button",className:u?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":u,onClick:w,children:[s.jsx(cL,{}),s.jsx("span",{children:l("shell.butlerEntry")})]})]}),s.jsxs("button",{type:"button",className:c?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":c,onClick:v,children:[s.jsx(lL,{}),s.jsx("span",{children:l("shell.terminalsEntry")})]})]}),s.jsx(hv,{triggerClassName:"workbench-nav-segment-button",triggerLabel:l("shell.skillsEntry"),triggerLeading:s.jsx(uL,{}),workspaceId:o,sessionId:g}),s.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":d,"aria-haspopup":"dialog","aria-expanded":d,onClick:R,children:[s.jsx(oL,{}),s.jsx("span",{children:l("shell.searchEntry")})]})]}),p?s.jsx("div",{className:"workbench-status-row",children:s.jsx("p",{className:"status-text","data-tone":"error",children:p})}):null,r.length>0?s.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[s.jsxs("div",{className:"workbench-section-heading",children:[s.jsxs("div",{className:"workbench-section-heading-main",children:[s.jsx(Zk,{active:!0,className:"workbench-favorite-heading-icon"}),s.jsx("span",{children:l("shell.favoriteSectionTitle")})]}),s.jsx("span",{className:"workbench-section-counter",children:r.length})]}),s.jsxs("div",{className:"workbench-session-list",children:[Wi.map(y=>{const P=Bo(y.session.sessionId);return s.jsx("div",{children:ws({node:{item:y.session,depth:0,children:P},workspace:y.workspace,workspaceContext:vr(y.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},y.session.sessionId)}),Ho?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:Dl,children:l("shell.favoriteExpandMore")}):null]})]}):null,h&&e.length===0?s.jsx(ZM,{}):null,!h&&!p&&e.length===0?s.jsx("div",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.emptyNavigationBody")})}):null,s.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[s.jsxs("div",{className:"workbench-section-heading",children:[s.jsx("div",{className:"workbench-section-heading-main",children:s.jsx("span",{children:l("shell.workspaceSectionTitle")})}),s.jsxs("div",{className:"workbench-section-actions",children:[s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.manageWorkspaceAction"),title:l("shell.manageWorkspaceAction"),onClick:()=>ve(!0),children:s.jsx(nL,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.importWorkspaceTitle"),title:l("shell.importWorkspaceTitle"),onClick:ks,children:s.jsx(tL,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.cloneWorkspaceTitle"),title:l("shell.cloneWorkspaceTitle"),onClick:jl,children:s.jsx(dL,{})})]})]}),e.map(y=>{const P=Xe.get(y.workspace.id)??di(y),W=Yr===y.workspace.id,ne=y.isCollapsed||Nn;return s.jsxs("section",{className:"workbench-workspace-group",ref:oe=>rr(y.workspace.id,oe),"data-workspace-group-id":y.workspace.id,"data-batch-active":Rt===y.workspace.id,"data-dragging":W,onDragOver:oe=>Rl(oe,y.workspace.id),onDrop:El,children:[s.jsxs("div",{className:"workbench-workspace-header minimal",children:[s.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":ne?l("shell.workspaceExpand"):l("shell.workspaceCollapse"),draggable:L&&!kn,onClick:()=>Tl(y.workspace.id),onPointerDown:kn?oe=>qs(oe,y.workspace.id):void 0,onPointerMove:kn?Oi:void 0,onPointerUp:kn?Il:void 0,onPointerCancel:kn?Al:void 0,onDragStart:L&&!kn?oe=>Lo(oe,y.workspace.id):void 0,onDragEnd:L&&!kn?Pl:void 0,"data-reorder-enabled":L?"true":void 0,children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(gi,{expanded:!ne})}),s.jsx("strong",{children:y.workspace.name})]}),Rt===y.workspace.id?Vs():_i(y.workspace.id)]}),ne?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-session-list",children:[P.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):P.slice(0,Gs(y.workspace.id)).map(oe=>ws({node:oe,workspace:y.workspace,workspaceContext:vr(y.workspace),menuKeyPrefix:`workspace:${y.workspace.id}`,showWorkspaceName:!1,selectionMode:Rt===y.workspace.id,favoriteEnabled:!0})),P.length>Gs(y.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Do(y.workspace.id,P.length),children:l("shell.sessionExpandMore")}):null]}),y.childWorktrees.length>0?s.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:y.childWorktrees.map(oe=>_o(oe))}):null,Bi(y.workspace,y.archivedSessions)]})]},y.workspace.id)})]})]}),s.jsx("div",{className:"workbench-nav-footer minimal",children:s.jsxs("div",{className:"workbench-nav-footer-actions",children:[s.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:T,title:Te?`${l("settings.title")} · ${je}`:l("settings.title"),children:[s.jsx(hL,{}),s.jsx("span",{className:"settings-entry-label",children:l("settings.title")}),Te?s.jsx("span",{className:"workbench-nav-settings-host-badge",title:je,children:je}):null]}),s.jsx(TP,{onOpenSoftwareUpdate:()=>be("/settings/software-update")})]})}),s.jsx(St,{open:Ae,title:l("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:l("shell.manageWorkspaceDescription"),headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:ks,children:l("shell.manageWorkspaceImportAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:jl,children:l("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{ie||ve(!1)},children:e.length>0?s.jsx("div",{className:"workbench-manage-list",children:e.map(y=>Fi(y.workspace,y.visibleSessions.length+y.archivedSessions.length,y.childWorktrees,!1))}):s.jsx("p",{className:"workbench-section-empty",children:l("shell.manageWorkspaceEmpty")})}),s.jsxs(St,{open:gn!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),onClose:()=>{Qt||cr(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:gn?gn.session.title:""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!Qt,onClick:()=>cr(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Qt,onClick:()=>{Js()},children:Qt?l("common.loading"):l("shell.deleteSessionAction")})]})]}),s.jsxs(St,{open:Zt!==null,title:l("shell.batchDeleteConfirmTitle"),description:l("shell.batchDeleteConfirmDescription",{count:`${(Zt==null?void 0:Zt.sessions.length)??0}`}),onClose:()=>{vn||en(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:Zt?l("shell.batchDeleteSelectionSummary",{count:`${Zt.sessions.length}`}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:vn,onClick:()=>en(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:vn,onClick:()=>{xs()},children:vn?l("shell.batchDeleting"):l("shell.batchDeleteAction")})]})]}),s.jsxs(St,{open:gt!==null,title:l("shell.manageWorkspaceRemoveConfirmTitle"),description:l("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{ie||ae(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:gt?l("shell.manageWorkspaceRemoveConfirmTarget",{name:gt.name}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!ie,onClick:()=>ae(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!ie,onClick:()=>{Hs()},children:ie?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveConfirmAction")})]})]}),s.jsx(kP,{open:Q,onClose:()=>Ce(!1),onCloned:Ft}),s.jsx(jP,{open:_,onClose:()=>G(!1),onImported:On}),s.jsx(FP,{open:Be!==null,source:Be,onClose:()=>Ve(null),onCreated:async y=>{y.members.forEach(W=>{k(W.session)}),Ey(y.group.id),await m();const P=y.members.find(W=>W.session.sessionId===y.group.anchorSessionId)??y.members[0]??null;P&&be(jr(Py(P.session,P.sessionIsolatedWorkspace),P.session.sessionId)),Ve(null),de({title:l("shell.parallelCreateSucceeded"),tone:"success"})}}),s.jsx(St,{open:xt!==null,title:l("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:xt?`${l("shell.createSessionTarget")} · ${xt.name}`:l("shell.createSessionModalDescription"),headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"primary-button create-session-parallel-trigger",disabled:it||!!ye||!xt,onClick:()=>{xt&&nr(xt)},children:l("shell.parallelCreateAction")}),s.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:it||!!ye,onClick:()=>st(!0),children:l("shell.createWorktreeAction")})]}),onClose:()=>Ne(null),children:s.jsxs("section",{className:"create-session-modal-section",children:[s.jsx("div",{className:"create-session-modal-section-header",children:s.jsx("strong",{children:l("shell.createSessionProviderLabel")})}),s.jsx(qE,{disabled:!!ye||it,workspaceId:(xt==null?void 0:xt.id)??null,pendingProvider:ye===(xt==null?void 0:xt.id)?$??null:null,onSelect:y=>{xt&&_l(xt.id,y)}})]})}),s.jsx(St,{open:xt!==null&&Ze,title:l("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:s.jsx("button",{type:"button",className:Se?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":l("shell.createWorktreeHelpAction"),title:l("shell.createWorktreeHelpAction"),"aria-pressed":Se,onClick:()=>pt(y=>!y),children:s.jsx(xL,{})}),description:xt?`${l("shell.createWorktreeSectionDescription")} ${l("shell.createSessionTarget")} · ${xt.name}`:l("shell.createWorktreeSectionDescription"),onClose:Un,children:s.jsxs("form",{className:"create-session-worktree-form",onSubmit:Wl,children:[Se?s.jsxs("section",{className:"create-session-worktree-help-card","aria-label":l("shell.createWorktreeHelpTitle"),children:[s.jsx("strong",{children:l("shell.createWorktreeHelpTitle")}),s.jsxs("div",{className:"create-session-worktree-help-grid",children:[s.jsxs("article",{children:[s.jsx("h3",{children:l("shell.createWorktreeHelpBranchTitle")}),s.jsx("p",{children:l("shell.createWorktreeHelpBranchBody")})]}),s.jsxs("article",{children:[s.jsx("h3",{children:l("shell.createWorktreeHelpDisplayNameTitle")}),s.jsx("p",{children:l("shell.createWorktreeHelpDisplayNameBody")})]}),s.jsxs("article",{children:[s.jsx("h3",{children:l("shell.createWorktreeHelpBaseRefTitle")}),s.jsx("p",{children:l("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,s.jsxs("label",{className:"create-session-worktree-field",children:[s.jsx("span",{children:l("shell.createWorktreeBranchLabel")}),s.jsx("input",{className:"settings-text-input",value:bt,placeholder:l("shell.createWorktreeBranchPlaceholder"),onChange:y=>{const P=y.target.value;hM(P)&&Ut(P)}})]}),s.jsxs("label",{className:"create-session-worktree-field",children:[s.jsx("span",{children:l("shell.createWorktreeDisplayNameLabel")}),s.jsx("input",{className:"settings-text-input",value:Ye,placeholder:l("shell.createWorktreeDisplayNamePlaceholder"),onChange:y=>ht(y.target.value)})]}),s.jsxs("label",{className:"create-session-worktree-field",children:[s.jsx("span",{children:l("shell.createWorktreeBaseRefLabel")}),s.jsx("div",{className:"create-session-worktree-combobox",ref:Dn,onBlurCapture:y=>{var W,ne;const P=y.relatedTarget;P instanceof Node&&((W=Dn.current)!=null&&W.contains(P)||(ne=Xn.current)!=null&&ne.contains(P))||(he(!1),we(-1))},children:s.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[s.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":D,"aria-controls":Zn,value:Oe,placeholder:l("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{he(!0),we(yn.length>0?0:-1)},onChange:y=>{kt(y.target.value),he(!0),we(yn.length>0?0:-1)},onKeyDown:y=>{if(y.key==="ArrowDown"){if(y.preventDefault(),!D){he(!0);return}yn.length>0&&we(P=>P>=yn.length-1?0:P+1);return}if(y.key==="ArrowUp"){if(y.preventDefault(),!D){he(!0);return}yn.length>0&&we(P=>P<=0?yn.length-1:P-1);return}if(y.key==="Enter"&&D&&Ee>=0){y.preventDefault();const P=yn[Ee];P&&(kt(P.value),he(!1),we(-1));return}y.key==="Escape"&&he(!1)}}),s.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":l("shell.createWorktreeBaseRefToggle"),"aria-expanded":D,onClick:()=>{he(y=>!y),we(!D&&yn.length>0?0:-1)},children:s.jsx(gi,{expanded:D})})]})}),s.jsx("span",{className:"create-session-worktree-field-hint",children:Bt?l("shell.createWorktreeBaseRefLoading"):_t||l("shell.createWorktreeBaseRefHint",{localCount:et.localBranches.length,remoteCount:et.remoteBranches.length,tagCount:et.tags.length})})]}),D&&ct&&typeof document<"u"?$r.createPortal(s.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[s.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${ct.top}px`,"--create-worktree-combobox-left":`${ct.left}px`,"--create-worktree-combobox-width":`${ct.width}px`,"--create-worktree-combobox-height":`${_s??0}px`}}),s.jsx("div",{ref:Xn,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${ct.top}px`,"--create-worktree-combobox-left":`${ct.left}px`,"--create-worktree-combobox-width":`${ct.width}px`},children:Bt?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefLoading")}):_t?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:_t}):yr.length>0?s.jsx("div",{id:Zn,className:"create-session-worktree-combobox-list",role:"listbox",children:yr.map(y=>s.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":y.label,children:[s.jsx("header",{className:"create-session-worktree-combobox-group-title",children:y.label}),s.jsx("div",{className:"create-session-worktree-combobox-group-options",children:y.items.map(P=>{const W=yn.findIndex(Fe=>Fe.value===P.value),ne=Oe===P.value,oe=Ee===W;return s.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":ne,"data-highlighted":oe,onMouseDown:Fe=>Fe.preventDefault(),onMouseEnter:()=>we(W),onClick:()=>{kt(P.value),he(!1),we(-1)},children:[s.jsx("span",{className:"create-session-worktree-combobox-option-label",children:P.value}),s.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[P.current?s.jsx("span",{className:"create-session-worktree-combobox-badge",children:l("shell.createWorktreeBaseRefCurrentBadge")}):null,P.recommended?s.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:l("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${y.key}:${P.value}`)})})]},y.key))}):s.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:it,onClick:Un,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:it,children:it?l("shell.createWorktreeSubmitting"):l("shell.createWorktreeSubmit")})]})]})}),s.jsxs(St,{open:hn!==null,title:l("shell.archiveModalTitle"),description:hn?`${hn.workspace.name} · ${l("shell.archiveModalDescription")}`:l("shell.archiveModalDescription"),headerActions:$s.length>0?s.jsx("button",{type:"button",className:"secondary-button","aria-pressed":zs,onClick:Pi,children:l("shell.archiveSearchAction")}):void 0,onClose:()=>hs(null),children:[zs?s.jsxs("div",{className:"workbench-archive-search-panel",children:[s.jsx(Lt,{label:l("shell.archiveSearchLabel"),htmlFor:We,children:s.jsx("input",{id:We,type:"text",value:Ri,placeholder:l("shell.archiveSearchPlaceholder"),autoFocus:!0,onChange:y=>Ei(y.target.value)})}),qt?s.jsx("p",{className:"workbench-archive-search-status",children:l("shell.archiveSearchSummaryLoading")}):null,tr?s.jsx("p",{className:"workbench-archive-search-status status-text","data-tone":"warning",children:tr}):null]}):null,hn&&ln.length>0?s.jsx(bi,{className:"workbench-archive-list","data-workspace-tone":(er==null?void 0:er.tone)??"root",style:Wr(er),children:ln.map(y=>{var ne;const P=gd(y.title,l("common.unknown")),W=((ne=Us[y.sessionId])==null?void 0:ne.trim())??"";return s.jsx(Xt,{className:"workbench-archive-item","data-workspace-tone":(er==null?void 0:er.tone)??"root",style:Wr(er),trailing:s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>Fl(y.sessionId),children:l("shell.unarchiveAction")}),children:s.jsxs("div",{className:"workbench-archive-item-main",children:[s.jsx("strong",{title:P.fullTitle,children:P.displayTitle}),s.jsxs("p",{children:[Ek(y,hn.workspace,!1)," ·"," ",Sl(y.provider)]}),zs&&W?s.jsx("p",{className:"workbench-archive-item-summary",children:W}):null]})},y.sessionId)})}):s.jsx(Ba,{title:$s.length>0&&Ri.trim().length>0?l("shell.archiveSearchEmpty"):l("shell.archiveEmpty"),compact:!0,className:"workbench-section-empty"})]}),s.jsx(St,{open:rn!==null,title:l("shell.renameModalTitle"),description:l("shell.renameModalDescription"),onClose:()=>{Mr||(fr(null),mr(""))},children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:Uo,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.renameInputLabel")}),s.jsx("input",{type:"text",value:Pr,placeholder:l("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:y=>mr(y.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!Mr,onClick:()=>{fr(null),mr("")},children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!Pr.trim()||Mr===(rn==null?void 0:rn.session.sessionId),children:Mr===(rn==null?void 0:rn.session.sessionId)?l("shell.renamingSession"):l("common.save")})]})]})}),bn?s.jsx("div",{ref:Qn,className:"session-export-print-root","aria-hidden":"true",children:s.jsxs("div",{className:"session-export-print-shell",style:bn.shellWidthPx?{width:`${bn.shellWidthPx}px`,maxWidth:"100%"}:void 0,children:[s.jsxs("header",{className:"session-export-print-header",children:[s.jsx("h1",{children:bn.session.title||l("conversation.titleFallback")}),s.jsx("p",{children:l("conversation.exportAction")})]}),s.jsx(lR,{sessionId:bn.session.sessionId,items:bn.items,provider:bn.session.provider})]})}):null]})}function Jf({panelReady:e,activeTab:t,fileRevealRequest:n,onTabChange:r,onToggleCollapse:i,currentSessionId:o,activeWorkspaceId:a,navigationGroups:c,workspaceContext:u,worktreeMeta:d,worktreeMergeState:h,onRefreshWorktreeMergePreview:p,onApplyWorktreeMerge:g,onCleanupWorktree:m}){var De;const k=a??((De=c[0])==null?void 0:De.workspace.id)??null,S=(a==null?void 0:a.trim())||null,v=f.useMemo(()=>Lk(c),[c]),[w,R]=f.useState(()=>S),T=Pn(),F=Wm(T),{showToast:E}=ar(),I=ad(),q=f.useRef(null),z=f.useRef(null),L=T.isDesktop&&T.bridge.supported,A=L&&!!a,U=L&&!!k,B=L&&!!k,le=typeof globalThis<"u"&&"PointerEvent"in globalThis,V=S??w,X=V&&V===S?o:null,J=V&&V===S?n:null;f.useEffect(()=>{if(S){R(ee=>ee===S?ee:S);return}v.size!==0&&R(ee=>ee&&v.has(ee)?ee:null)},[v,S]);const O=f.useCallback(async(ee,j,be)=>{if(ee==="files"){const fe=await Rw(T,{workspaceId:j,sessionId:be,focusOwner:"file-context-panel"});fe.ok||E({title:fe.detail??l("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(ee==="git"){const fe=await Ew(T,{workspaceId:j,focusOwner:"git-sidebar"});fe.ok||E({title:fe.detail??l("git.openExternalFailed"),tone:"error"});return}const re=await Pw(T,{workspaceId:j,focusOwner:"terminal-manager-panel"});re.ok||E({title:re.detail??l("terminalManager.openExternalFailed"),tone:"error"})},[T,E]),K=f.useCallback((ee,j)=>{if(ee.button!==0||!L)return;const be=j==="files"?a:j==="git"||j==="terminals"?k:null;if(!be)return;const re=j==="files"?o:null;q.current={tab:j,startX:ee.clientX,startY:ee.clientY,workspaceId:be,sessionId:re,detached:!1,preview:null};const fe=je=>{var Q;const Te=q.current;if(!Te)return;const _=Math.abs(je.clientX-Te.startX),G=Math.abs(je.clientY-Te.startY);!Te.detached&&Math.max(_,G)<Tf||(Te.detached||(Te.detached=!0,z.current=Te.tab,Te.preview=Vd({title:Te.tab==="files"?l("shell.filesEntry"):Te.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:je.clientX,y:je.clientY})),(Q=Te.preview)==null||Q.updatePosition(je.clientX,je.clientY))},de=je=>{var _;const Te=(_=q.current)==null?void 0:_.preview;je&&(Te==null||Te.cancel()),window.removeEventListener("mousemove",fe),window.removeEventListener("mouseup",Ue),window.removeEventListener("blur",He),q.current=null},Ue=async()=>{var Te;const je=q.current;de(!1),je!=null&&je.detached&&(await((Te=je.preview)==null?void 0:Te.complete()),await O(je.tab,je.workspaceId,je.sessionId))},He=()=>{de(!0)};window.addEventListener("mousemove",fe),window.addEventListener("mouseup",Ue),window.addEventListener("blur",He)},[a,L,o,k,O]),ce=f.useCallback((ee,j)=>{if(ee.button!==0||!L)return;const be=j==="files"?a:j==="git"||j==="terminals"?k:null;if(!be)return;const re=ee.currentTarget,fe=ee.pointerId;re.setPointerCapture(fe);const de=j==="files"?o:null;q.current={tab:j,startX:ee.clientX,startY:ee.clientY,workspaceId:be,sessionId:de,detached:!1,preview:null};const Ue=G=>{var ve;if(G.pointerId!==fe)return;const Q=q.current;if(!Q)return;const Ce=Math.abs(G.clientX-Q.startX),Ae=Math.abs(G.clientY-Q.startY);!Q.detached&&Math.max(Ce,Ae)<Tf||(Q.detached||(Q.detached=!0,z.current=Q.tab,Q.preview=Vd({title:Q.tab==="files"?l("shell.filesEntry"):Q.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:G.clientX,y:G.clientY})),(ve=Q.preview)==null||ve.updatePosition(G.clientX,G.clientY))},He=G=>{var Ce;const Q=(Ce=q.current)==null?void 0:Ce.preview;G&&(Q==null||Q.cancel()),re.removeEventListener("pointermove",Ue),re.removeEventListener("pointerup",je),re.removeEventListener("pointercancel",Te),re.removeEventListener("lostpointercapture",Te),window.removeEventListener("blur",_),q.current=null,re.hasPointerCapture(fe)&&re.releasePointerCapture(fe)},je=async G=>{var Ce;if(G.pointerId!==fe)return;const Q=q.current;He(!1),Q!=null&&Q.detached&&(await((Ce=Q.preview)==null?void 0:Ce.complete()),await O(Q.tab,Q.workspaceId,Q.sessionId))},Te=G=>{G.pointerId===fe&&He(!0)},_=()=>{He(!0)};re.addEventListener("pointermove",Ue),re.addEventListener("pointerup",je),re.addEventListener("pointercancel",Te),re.addEventListener("lostpointercapture",Te),window.addEventListener("blur",_)},[a,L,o,k,O]),N=f.useCallback(ee=>{if(z.current===ee){z.current=null;return}r(ee)},[r]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(u==null?void 0:u.tone)??"root",style:Wr(u),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":F,children:[i?s.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideInfoSidebar"),title:l("shell.hideInfoSidebar"),onClick:i,children:s.jsx(Qk,{})}):null,s.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":l("shell.infoTabsLabel"),"data-tauri-drag-region":F,children:[s.jsx("button",{className:t==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="files",title:A?"拖拽标签到独立窗口":void 0,onPointerDown:ee=>ce(ee,"files"),onMouseDown:le?void 0:ee=>K(ee,"files"),onClick:()=>N("files"),children:l("shell.filesEntry")}),s.jsx("button",{className:t==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="git",title:U?"拖拽标签到独立窗口":void 0,onPointerDown:ee=>ce(ee,"git"),onMouseDown:le?void 0:ee=>K(ee,"git"),onClick:()=>N("git"),children:l("shell.gitEntry")}),s.jsx("button",{className:t==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="terminals",title:B?"拖拽标签到独立窗口":void 0,onPointerDown:ee=>ce(ee,"terminals"),onMouseDown:le?void 0:ee=>K(ee,"terminals"),onClick:()=>N("terminals"),children:l("shell.terminalManagerEntry")})]})]}),s.jsxs("div",{ref:I,className:"workbench-auxiliary-body","data-scrollbar-autohide":"true",children:[e?null:s.jsx(ja,{}),e&&t==="git"&&d?s.jsx(EL,{meta:d,state:h,onRefresh:()=>p(d.workspaceId,!0),onApply:()=>g(d.workspaceId),onCleanup:()=>m(d)}):null,e&&t==="files"?V?s.jsx(f.Suspense,{fallback:s.jsx(ja,{}),children:s.jsx(SM,{sessionId:X,workspaceId:V,externalRevealRequest:J})}):s.jsx("section",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.filesPanelEmpty")})}):null,e&&t==="git"?k?s.jsx(f.Suspense,{fallback:s.jsx(ja,{}),children:s.jsx(CM,{workspaceId:k})}):s.jsx("section",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.gitPanelEmpty")})}):null,e&&t==="terminals"?s.jsx(f.Suspense,{fallback:s.jsx(ja,{}),children:s.jsx(NM,{currentWorkspaceId:a,navigationGroups:c})}):null]})]})}function EL({meta:e,state:t,onRefresh:n,onApply:r,onCleanup:i}){const[o,a]=f.useState(!1),c=(t==null?void 0:t.preview)??null,u=(t==null?void 0:t.loading)??!1,d=(t==null?void 0:t.applying)??!1,h=(t==null?void 0:t.cleaning)??!1,p=c!==null,g=(c==null?void 0:c.alreadyMerged)===!0,m=new Set((c==null?void 0:c.blockers.map(B=>B.code))??[]),k=m.size>0||!!(t!=null&&t.error),S=g&&!k,v=(c==null?void 0:c.canMerge)===!0&&!u&&!d&&!h&&!S,w=S&&!u&&!d&&!h&&!m.has("SOURCE_DIRTY")&&!m.has("HAS_ACTIVE_CHILDREN"),R=u||d||h?"loading":k?"blocked":S?"merged":c!=null&&c.canMerge?"ready":p?"blocked":"idle",T=(c==null?void 0:c.targetWorkspace.name)??l("common.unknown"),F=(c==null?void 0:c.sourceBranchName)??e.branchName,E=(c==null?void 0:c.targetBranchName)??e.baseRef??l("common.unknown"),I=ML({t:l,hasPreview:p,showMergedState:S,isMerged:g,canMerge:(c==null?void 0:c.canMerge)===!0,ahead:(c==null?void 0:c.ahead)??0,blockerCodeSet:m}),q=u?l("shell.worktreeMergePreviewLoading"):d?l("shell.worktreeMergeApplying"):h?l("shell.worktreeCleanupRunning"):S?l("shell.worktreeMergeAlreadyMerged"):c!=null&&c.canMerge?l("shell.worktreeMergeReady"):p?l("shell.worktreeMergeBlocked"):l("shell.worktreeMergePreviewIdle"),z=[l("shell.worktreeMergeCurrentBranch",{branch:F}),l("shell.worktreeMergeParentBranch",{branch:E}),l("shell.worktreeMergeTargetWorkspace",{name:T}),c?l("shell.worktreeMergeAheadBehind",{ahead:c.ahead,behind:c.behind}):l("shell.worktreeMergeAheadBehindPending"),c!=null&&c.mergeBaseCommit?l("shell.worktreeMergeBaseCommit",{commit:XM(c.mergeBaseCommit)}):null].filter(B=>!!B),L=`worktree-merge-panel-details-${e.workspaceId}`,A=o?l("shell.worktreeMergeCollapseDetails"):l("shell.worktreeMergeExpandDetails"),U=PL({t:l,loading:u,applying:d,cleaning:h,hasPreview:p,canMerge:(c==null?void 0:c.canMerge)===!0,showMergedState:S,blockerCodeSet:m});return f.useEffect(()=>{a(!1)},[e.workspaceId]),s.jsxs("section",{className:"worktree-merge-panel","data-state":R,children:[s.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":A,"aria-expanded":o,"aria-controls":L,onClick:()=>{a(B=>!B)},children:[s.jsx("span",{className:"worktree-merge-panel-summary-label",children:l("shell.worktreeMergePanelLabel")}),s.jsx("span",{className:"worktree-merge-panel-summary-main",children:s.jsx("span",{className:"worktree-merge-panel-summary-tags",children:U.map(B=>s.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":R,children:B},B))})}),s.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:A})]}),o?s.jsxs("div",{id:L,className:"worktree-merge-panel-details",children:[s.jsx("div",{className:"worktree-merge-panel-detail-head",children:s.jsx("span",{className:"worktree-merge-panel-status","data-state":R,children:q})}),s.jsx("div",{className:"worktree-merge-panel-meta",children:z.map(B=>s.jsx("span",{children:B},B))}),p?s.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":l("shell.worktreeMergeChecklistTitle"),children:I.map(B=>s.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":B.state,children:[s.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:B.state==="done"?"✓":B.state==="blocked"?"!":"·"}),s.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[s.jsx("strong",{children:B.label}),B.detail?s.jsx("span",{children:B.detail}):null]})]},B.key))}):null,t!=null&&t.error?s.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:t.error}):null,c!=null&&c.conflictPaths.length?s.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[s.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:l("shell.worktreeMergeConflictLabel")}),s.jsx("div",{className:"worktree-merge-panel-conflict-list",children:c.conflictPaths.map(B=>s.jsx("code",{children:B},B))})]}):null,s.jsxs("div",{className:"worktree-merge-panel-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:u||d||h,onClick:n,children:p?l("shell.worktreeMergePreviewRefresh"):l("shell.worktreeMergePreviewAction")}),s.jsx("button",{type:"button",className:"primary-button",disabled:!v,onClick:r,children:d?l("shell.worktreeMergeApplying"):l("shell.worktreeMergeApplyAction")}),s.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!w,onClick:i,children:h?l("shell.worktreeCleanupRunning"):l("shell.worktreeCleanupAction")})]})]}):null]})}function PL(e){const{t,loading:n,applying:r,cleaning:i,hasPreview:o,canMerge:a,showMergedState:c,blockerCodeSet:u}=e;if(n)return[t("shell.worktreeMergeCompactChecking")];if(r)return[t("shell.worktreeMergeCompactMerging")];if(i)return[t("shell.worktreeMergeCompactCleaning")];const d=[];return u.has("SOURCE_NOT_ACTIVE")&&d.push(t("shell.worktreeMergeCompactInactive")),u.has("SOURCE_DIRTY")&&d.push(t("shell.worktreeMergeCompactDirty")),u.has("TARGET_DIRTY")&&d.push(t("shell.worktreeMergeCompactTargetDirty")),u.has("HAS_CONFLICTS")&&d.push(t("shell.worktreeMergeCompactConflict")),u.has("HAS_ACTIVE_CHILDREN")&&d.push(t("shell.worktreeMergeCompactChildren")),d.length>0?d:a?[t("shell.worktreeMergeCompactReady")]:c?[t("shell.worktreeMergeCompactMerged")]:o?u.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function ML(e){const{t,hasPreview:n,showMergedState:r,isMerged:i,canMerge:o,ahead:a,blockerCodeSet:c}=e,u=c.has("SOURCE_NOT_ACTIVE"),d=c.has("SOURCE_DIRTY"),h=c.has("TARGET_DIRTY"),p=c.has("HAS_ACTIVE_CHILDREN"),g=c.has("HAS_CONFLICTS"),m=n&&!i&&(c.has("NO_COMMITS_TO_MERGE")||a<=0),k=r?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:o?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultReady"),detail:t("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:n?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultBlocked"),detail:t("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:t("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:t("shell.worktreeMergeChecklistSourceState"),detail:n&&u?t("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:n?u?"blocked":"done":"pending"},{key:"clean-source",label:t("shell.worktreeMergeChecklistSourceClean"),detail:n&&d?t("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:n?d?"blocked":"done":"pending"},{key:"clean-target",label:t("shell.worktreeMergeChecklistTargetClean"),detail:n&&h?t("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:n?h?"blocked":"done":"pending"},{key:"children",label:t("shell.worktreeMergeChecklistChildren"),detail:n&&p?t("shell.worktreeMergeChecklistChildrenBlocked"):null,state:n?p?"blocked":"done":"pending"},{key:"commits",label:t("shell.worktreeMergeChecklistCommits"),detail:m?t(i?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:m?i?"done":"blocked":n?"done":"pending"},{key:"conflicts",label:t("shell.worktreeMergeChecklistConflicts"),detail:g?t("shell.worktreeMergeChecklistConflictsBlocked"):null,state:g?"blocked":n?"done":"pending"},k]}function WO({shellMode:e="desktop"}){var vr,Fi,$i,y,P,W,ne,oe,Fe,me,ot,Mt,It,Yt,qn,Gn,Zr;const t=ll(),n=Co(),r=Pn(),{showToast:i}=ar(),o=Go(b=>b.sessionDisplaySortMode),a=Go(b=>b.notificationPreferences.notifyOnPermissionRequest),c=Go(b=>b.notificationPreferences.notifyOnSessionCompleted),u=Go(b=>b.notificationPreferences.notifyOnSessionFailed),d=f.useRef($E(hk)),h=f.useRef(0),p=f.useRef((((Fi=(vr=d.current)==null?void 0:vr.items)==null?void 0:Fi.length)??0)>0),g=f.useRef(new Map),m=f.useRef(!1),k=f.useRef(null),S=f.useRef(0),v=f.useRef(null),w=f.useRef(null),R=f.useRef(new Set),T=f.useRef(new Set),F=f.useRef(new Set),E=f.useRef(new Set),I=f.useRef(null),q=f.useRef(null),z=f.useRef(null),L=f.useRef(null),A=f.useRef(null),U=f.useRef(null),B=f.useRef(null),le=f.useRef(null),V=f.useRef(0),X=f.useRef(0),J=f.useRef(i),O=f.useRef(r.bridge),K=f.useRef(null),ce=f.useRef(0),N=f.useRef(0),De=f.useRef(null),ee=f.useRef(null),j=f.useRef(null),be=f.useRef(!1),re=f.useRef(!1),fe=f.useRef(!1),de=f.useRef(new Map),Ue=f.useRef(!1),He=f.useRef(new Map),je=f.useRef(""),Te=f.useRef([]),_=f.useRef(o),G=f.useRef(null),[Q,Ce]=f.useState(()=>Qp(d.current,o)),Ae=f.useRef(Q),[ve,Tt]=f.useState(()=>{var b,C;return(((C=(b=d.current)==null?void 0:b.items)==null?void 0:C.length)??0)===0}),[rt,gt]=f.useState(null),[ae,ie]=f.useState(()=>Ca(Of(gf,GP),xf,Sf)),[ke,ye]=f.useState(()=>Ca(Of(bf,KP),vf,Cf)),[Re,$]=f.useState(()=>Bf(kf,!1)),[Z,ge]=f.useState(()=>Bf(yf,!1)),[Ne,Be]=f.useState(null),[Ve,Ie]=f.useState(null),[dt,Ze]=f.useState(()=>$f(d.current)),[st,it]=f.useState(()=>_f(Pc)),[qe,bt]=f.useState(!1),[Ut,Ye]=f.useState("files"),[ht,Oe]=f.useState(!1),[kt,et]=f.useState(!1),[Dt,D]=f.useState(null),[he,Ee]=f.useState({}),[we,Se]=f.useState(!1),[pt,Bt]=f.useState("sessions"),[mt,_t]=f.useState(""),[tt,ct]=f.useState(""),[Ht,_s]=f.useState(!1),[qr,yt]=f.useState(null),[hs,gn]=f.useState([]),[cr,Qt]=f.useState(null),[Yn,Zt]=f.useState({}),en=_m(r),vn=f.useCallback(b=>{if(en)return;const C=K.current;C&&(!zc(r,b.button,b.target)||!Wf(b.clientY,C)||wx({platform:r,button:b.button,target:b.target,clientX:b.clientX,clientY:b.clientY}))},[r,en]),Ws=f.useCallback(b=>{if(en)return;const C=K.current;C&&(!zc(r,b.button,b.target)||!Wf(b.clientY,C)||r.bridge.setWindowState("toggle-zoom"))},[r,en]),[Kt,Sn]=f.useState({}),[wt,Rr]=f.useState(null),[ur,dr]=f.useState(!1),[bn,Gr]=f.useState([]),[Er,hr]=f.useState(()=>new Set),[pr,zn]=f.useState(!1),[ps,Kr]=f.useState(!1),[Ai,Fs]=f.useState(0),[Ln,fs]=f.useState(()=>_f(wf)),rn=e==="desktop"&&r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar,{theme:fr}=Cy();f.useEffect(()=>{J.current=i},[i]),f.useEffect(()=>{if(typeof document>"u")return;const{documentElement:b,body:C}=document,M=document.getElementById("root");if(!rn){b.removeAttribute("data-workbench-macos-vibrancy"),C==null||C.removeAttribute("data-workbench-macos-vibrancy");return}const te=b.style.background,se=(C==null?void 0:C.style.background)??"",pe=(M==null?void 0:M.style.background)??"";return b.setAttribute("data-workbench-macos-vibrancy","true"),C==null||C.setAttribute("data-workbench-macos-vibrancy","true"),b.style.background="transparent",C==null||C.style.setProperty("background","transparent"),M==null||M.style.setProperty("background","transparent"),()=>{b.removeAttribute("data-workbench-macos-vibrancy"),C==null||C.removeAttribute("data-workbench-macos-vibrancy"),b.style.background=te,C&&(C.style.background=se),M instanceof HTMLElement&&(M.style.background=pe)}},[rn]),f.useEffect(()=>()=>{j.current!==null&&window.clearTimeout(j.current)},[]),f.useEffect(()=>{var se;if(typeof document>"u")return;const{documentElement:b,body:C}=document;if(!Ve){b.removeAttribute(ai),C==null||C.removeAttribute(ai);return}const M=b.style.cursor,te=(C==null?void 0:C.style.cursor)??"";return b.setAttribute(ai,Ve),C==null||C.setAttribute(ai,Ve),b.style.cursor="col-resize",C==null||C.style.setProperty("cursor","col-resize"),(se=window.getSelection())==null||se.removeAllRanges(),()=>{b.removeAttribute(ai),C==null||C.removeAttribute(ai),b.style.cursor=M,C&&(C.style.cursor=te)}},[Ve]),f.useEffect(()=>{_.current=o,Ce(b=>QM(b,o))},[o]),f.useEffect(()=>{Ae.current=Q},[Q]),f.useEffect(()=>{O.current=r.bridge},[r.bridge]),f.useEffect(()=>{ce.current=ae},[ae]),f.useEffect(()=>{N.current=ke},[ke]),f.useEffect(()=>()=>{De.current!==null&&window.cancelAnimationFrame(De.current)},[]);const Pr=f.useCallback(async()=>{const b=V.current+1;V.current=b;try{const C=await $T();if(b!==V.current)return;if(!C.initialized){Gr([]),hr(new Set);return}const[M,te,se,pe]=await Promise.all([zT(),qT(),cb(),VT()]);if(b!==V.current)return;Gr(cM(M.overview,te.items,se.items)),hr(new Set(pe.items.map(Me=>Me.notificationId)))}catch{if(b!==V.current)return;Gr([]),hr(new Set)}},[]),mr=f.useCallback(b=>{const C=b.map(M=>M.createdAt).sort((M,te)=>ls(te)-ls(M))[0]??null;C&&fs(M=>M&&ls(M)>=ls(C)?M:C)},[]);f.useEffect(()=>{Ln&&Cs(wf,Ln)},[Ln]),f.useEffect(()=>{Pr();const b=window.setInterval(()=>{Pr()},YP);return()=>{window.clearInterval(b)}},[Pr]),f.useEffect(()=>{un("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),f.useEffect(()=>{var b,C;un("workbench.cached_snapshot_loaded",{cached:!!d.current,workspaceCount:((b=d.current)==null?void 0:b.items.length)??0,sessionCount:((C=d.current)==null?void 0:C.items.reduce((M,te)=>M+te.sessions.length,0))??0})},[]);function Mr(b){var te;if(!b||!Array.isArray(b.items))return;KM(g.current,b);const C=GM(b,g.current);un("workbench.apply_snapshot",{workspaceCount:C.items.length,sessionCount:C.items.reduce((se,pe)=>se+pe.sessions.length,0),currentSessionId:((te=uo(t.pathname))==null?void 0:te.sessionId)??null});const M=Qp(C,_.current);d.current=C,ga(C),Ae.current=M,Ce(M),Ze($f(C)),gt(null)}const sn=f.useCallback(async()=>{const b=h.current+1;h.current=b,Tt(C=>C||!p.current),un("workbench.refresh_navigation.start",{requestId:b,hasNavigationData:p.current});try{const C=await $y();if(b!==h.current){un("workbench.refresh_navigation.stale",{requestId:b});return}Mr(C)}catch(C){if(b!==h.current)return;gt(C instanceof Error?C.message:l("shell.navigationLoadFailed")),J.current({title:C instanceof Error?C.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{un("workbench.refresh_navigation.end",{requestId:b,success:b===h.current}),b===h.current&&Tt(!1)}},[]),Rt=f.useCallback(b=>{Ce(C=>{const M=VM(C,b,_.current);return Ae.current=M,M})},[]),on=f.useCallback(()=>{var b;(b=w.current)==null||b.requestRefresh()},[]),Wt=f.useCallback((b,C)=>{n(jr(b,C))},[n]),an=f.useCallback((b,C,M)=>{var te;I.current={workspaceId:b,paths:C,knownRevisionByPath:M==null?void 0:M.knownRevisionByPath},(te=w.current)==null||te.subscribeFileTree(b,C,M)},[]),gr=f.useCallback((b,C,M)=>{var te;q.current={workspaceId:b,paths:C,knownRevisionByPath:M==null?void 0:M.knownRevisionByPath},(te=w.current)==null||te.requestFileTreeRefresh(b,C,M)},[]),Vr=f.useCallback(b=>(R.current.add(b),()=>{R.current.delete(b)}),[]),br=f.useCallback((b,C)=>{var M;z.current={workspaceId:b,knownRevision:C==null?void 0:C.knownRevision},(M=w.current)==null||M.subscribeGit(b,C)},[]),Vt=f.useCallback((b,C)=>{var M;L.current={workspaceId:b,knownRevision:C==null?void 0:C.knownRevision},(M=w.current)==null||M.requestGitRefresh(b,C)},[]),Yr=f.useCallback(b=>(T.current.add(b),()=>{T.current.delete(b)}),[]),Jn=f.useCallback((b,C)=>{var M;A.current={workspaceId:b,knownRevision:C==null?void 0:C.knownRevision},(M=w.current)==null||M.subscribeWorkspaceManagement(b,C)},[]),Dn=f.useCallback((b,C)=>{var M;U.current={workspaceId:b,knownRevision:C==null?void 0:C.knownRevision},Zt(te=>{var se;return{...te,[b]:{detail:((se=te[b])==null?void 0:se.detail)??null,loading:!0,error:null}}}),(M=w.current)==null||M.requestWorkspaceManagementRefresh(b,C)},[]),Xn=f.useCallback(b=>(F.current.add(b),()=>{F.current.delete(b)}),[]),Qn=f.useCallback(async(b,C=!1)=>{const M=b.trim();if(!M)return;let te=!0;if(Sn(se=>{const pe=se[M];return!C&&(pe!=null&&pe.loading)?(te=!1,se):{...se,[M]:{preview:(pe==null?void 0:pe.preview)??null,loading:!0,applying:(pe==null?void 0:pe.applying)??!1,cleaning:(pe==null?void 0:pe.cleaning)??!1,error:null}}}),!!te)try{const se=await Zy(M);Sn(pe=>{var Me,_e;return{...pe,[M]:{preview:se,loading:!1,applying:((Me=pe[M])==null?void 0:Me.applying)??!1,cleaning:((_e=pe[M])==null?void 0:_e.cleaning)??!1,error:null}}})}catch(se){Sn(pe=>{var Me,_e,$e;return{...pe,[M]:{preview:((Me=pe[M])==null?void 0:Me.preview)??null,loading:!1,applying:((_e=pe[M])==null?void 0:_e.applying)??!1,cleaning:(($e=pe[M])==null?void 0:$e.cleaning)??!1,error:se instanceof Error?se.message:l("shell.worktreeMergePreviewFailed")}}})}},[]),x=f.useCallback(async b=>{const C=b.trim();if(C){Sn(M=>{var te,se;return{...M,[C]:{preview:((te=M[C])==null?void 0:te.preview)??null,loading:!1,applying:!0,cleaning:((se=M[C])==null?void 0:se.cleaning)??!1,error:null}}});try{const M=await ew(C);Sn(te=>{var se;return{...te,[C]:{preview:M.preview,loading:!1,applying:!1,cleaning:((se=te[C])==null?void 0:se.cleaning)??!1,error:null}}}),on(),sn(),Qn(C,!0),Vt(M.preview.targetWorkspace.id),J.current({title:M.applied?l("shell.worktreeMergeApplySuccess"):l("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(M){Sn(te=>{var se,pe;return{...te,[C]:{preview:((se=te[C])==null?void 0:se.preview)??null,loading:!1,applying:!1,cleaning:((pe=te[C])==null?void 0:pe.cleaning)??!1,error:M instanceof Error?M.message:l("shell.worktreeMergeApplyFailed")}}}),J.current({title:M instanceof Error?M.message:l("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[Qn,sn,Vt,on]),H=f.useCallback(async b=>{var te,se;const C=b.workspaceId,M=ur&&((se=(te=Kt[C])==null?void 0:te.preview)==null?void 0:se.alreadyMerged)===!0;Sn(pe=>{var Me;return{...pe,[C]:{preview:((Me=pe[C])==null?void 0:Me.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const pe=await tw(C,{deleteBranch:M});if(Sn(Me=>{var _e;return{...Me,[C]:{preview:((_e=Me[C])==null?void 0:_e.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),dr(!1),Rr(Me=>(Me==null?void 0:Me.workspaceId)===C?null:Me),on(),await sn(),n(im(b.parentWorkspaceId),{replace:!0}),pe.branchDeleted){J.current({title:l("shell.worktreeCleanupDeleteBranchSuccess",{branch:pe.deletedBranchName||b.branchName}),tone:"success"});return}if(pe.branchDeleteRequested){J.current({title:l("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:b.branchName}),description:pe.branchDeleteError||void 0,tone:"warning"});return}J.current({title:l("shell.worktreeCleanupSuccess"),tone:"success"})}catch(pe){Sn(Me=>{var _e;return{...Me,[C]:{preview:((_e=Me[C])==null?void 0:_e.preview)??null,loading:!1,applying:!1,cleaning:!1,error:pe instanceof Error?pe.message:l("shell.worktreeCleanupFailed")}}}),J.current({title:pe instanceof Error?pe.message:l("shell.worktreeCleanupFailed"),tone:"error"})}},[ur,n,sn,on,Kt]),Pe=f.useCallback(b=>{dr(!1),Rr(b)},[]),Je=f.useCallback((b,C)=>{var M;B.current={workspaceId:b,knownRevision:C==null?void 0:C.knownRevision},(M=w.current)==null||M.subscribeTerminalManager(b,C)},[]),Cn=f.useCallback((b,C)=>{var M;le.current={workspaceId:b,knownRevision:C==null?void 0:C.knownRevision},(M=w.current)==null||M.requestTerminalManagerRefresh(b,C)},[]),Lr=f.useCallback(b=>(E.current.add(b),()=>{E.current.delete(b)}),[]),Jr=f.useCallback((b,C)=>{Ce(M=>YM(M,b,C??new Date().toISOString()))},[]),Nn=f.useCallback(async(b,C)=>{g.current.set(b,C),Ce(M=>Uf(M,b,C));try{const M=await km(b,C),te=Ir(M);te===C?g.current.set(b,te):g.current.delete(b),Rt(M),on(),sn()}catch(M){throw g.current.delete(b),Ce(te=>Uf(te,b,!C)),M}},[sn,on,Rt]),kn=f.useCallback((b,C)=>{un("workbench.set_session_workspace",{sessionId:b,workspaceId:C}),Ee(M=>{if(!C){if(!(b in M))return M;const te={...M};return delete te[b],te}return M[b]===C?M:{...M,[b]:C}})},[]);f.useEffect(()=>{p.current=Q.length>0},[Q]),f.useEffect(()=>{un("workbench.navigation_state",{navigationLoading:ve,workspaceCount:Q.length,sessionCount:Q.reduce((b,C)=>b+C.sessions.length,0)})},[Q,ve]),f.useEffect(()=>{v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{var xe;v.current=null,!(m.current||p.current)&&(un("workbench.refresh_navigation.ws_fallback_triggered"),(xe=w.current)==null||xe.requestRefresh())},1200);const b=new fx({onConnectionChange:xe=>{xe==="connected"&&HE(),xe==="reconnect_failed"&&!p.current&&(gt(l("shell.navigationLoadFailed")),J.current({id:"workbench-navigation-connection",title:l("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:xe=>{m.current=!0,un("workbench.ws_snapshot_received",{workspaceCount:xe.items.length,sessionCount:xe.items.reduce((lt,Tn)=>lt+Tn.sessions.length,0)}),v.current!==null&&(window.clearTimeout(v.current),v.current=null),Mr(xe),Tt(!1)},onFileTreeSnapshot:xe=>{R.current.forEach(lt=>lt(xe))},onGitSnapshot:xe=>{io(Gk(xe.workspaceId),{revision:xe.revision??null,status:xe.status,history:xe.history,historyTotalCount:xe.historyTotalCount,historyNextCursor:xe.historyNextCursor,branches:xe.branches}),Zt(lt=>{var sr;const Tn=((sr=Q.find(Qs=>Qs.workspace.id===xe.workspaceId))==null?void 0:sr.workspace)??null;if(!Tn)return lt;const Bn=lt[xe.workspaceId],$t=Yk(Vk((Bn==null?void 0:Bn.detail)??Kk(Tn),Tn),xe);return io(vu(xe.workspaceId),$t),{...lt,[xe.workspaceId]:{detail:$t,loading:!1,error:null}}}),T.current.forEach(lt=>lt(xe))},onWorkspaceManagementSnapshot:xe=>{io(vu(xe.workspaceId),xe),Zt(lt=>({...lt,[xe.workspaceId]:{detail:xe,loading:!1,error:null}})),F.current.forEach(lt=>lt(xe))},onTerminalManagerSnapshot:xe=>{E.current.forEach(lt=>lt(xe))},onUnauthorized:()=>{ho.clear(),n("/login",{replace:!0})}});b.primeWorkbenchSnapshot(d.current),w.current=b;const C=I.current,M=q.current,te=z.current,se=L.current,pe=A.current,Me=U.current,_e=B.current,$e=le.current;return C&&b.subscribeFileTree(C.workspaceId,C.paths,{knownRevisionByPath:C.knownRevisionByPath}),te&&b.subscribeGit(te.workspaceId,{knownRevision:te.knownRevision}),pe&&b.subscribeWorkspaceManagement(pe.workspaceId,{knownRevision:pe.knownRevision}),_e&&b.subscribeTerminalManager(_e.workspaceId,{knownRevision:_e.knownRevision}),M&&b.requestFileTreeRefresh(M.workspaceId,M.paths,{knownRevisionByPath:M.knownRevisionByPath}),se&&b.requestGitRefresh(se.workspaceId,{knownRevision:se.knownRevision}),Me&&b.requestWorkspaceManagementRefresh(Me.workspaceId,{knownRevision:Me.knownRevision}),$e&&b.requestTerminalManagerRefresh($e.workspaceId,{knownRevision:$e.knownRevision}),b.start(),()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null),w.current===b&&(w.current=null),b.close()}},[n]),f.useEffect(()=>{Cs(gf,String(ae))},[ae]),f.useEffect(()=>{Cs(bf,String(ke))},[ke]),f.useEffect(()=>{Cs(kf,String(Re))},[Re]),f.useEffect(()=>{Cs(yf,String(Z))},[Z]),f.useEffect(()=>{if(!st){_M(Pc);return}Cs(Pc,st)},[st]),f.useEffect(()=>{if(qe||Z)return;const b=window.setTimeout(()=>{bt(!0)},VP);return()=>{window.clearTimeout(b)}},[qe,Z]);const kr=uo(t.pathname),Xe=(kr==null?void 0:kr.sessionId)??null,Ct=Xe?ty(Xe):!1,Nt=f.useMemo(()=>Ny(Q),[Q]),xt=f.useMemo(()=>jk(Nt,o),[Nt,o]),Dr=f.useMemo(()=>Lk(Q),[Q]),yr=f.useMemo(()=>new Set(dt),[dt]),yn=f.useMemo(()=>Nt.filter(b=>b.session.isFavorite===!0).map(b=>b.session.sessionId),[Nt]),Zn=f.useMemo(()=>new Set(yn),[yn]),hn=f.useCallback(b=>{const C=Dc(b,dt);d.current=C,ga(C),Ae.current=b,Ce(b)},[dt]),er=f.useCallback(b=>{const C=!yr.has(b),M=qf(dt,b,C),te=Dc(Q,M);d.current=te,ga(te),Ze(M),mm(b,{collapsed:C}).catch(se=>{const pe=qf(M,b,!C),Me=Dc(Q,pe);d.current=Me,ga(Me),Ze(pe),J.current({title:se instanceof Error?se.message:l("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[yr,dt,Q]),$s=f.useCallback(()=>{G.current={originalGroups:Ae.current}},[]),zs=f.useCallback((b,C,M)=>{const te=Ae.current,se=qM(te,b,C,M);se!==te&&hn(se)},[hn]),Ri=f.useCallback(()=>{const b=G.current;G.current=null;const C=Ae.current;b&&(b.originalGroups.length===C.length&&b.originalGroups.every((M,te)=>{var se;return M.workspace.id===((se=C[te])==null?void 0:se.workspace.id)})||qy({workspaceIds:C.map(M=>M.workspace.id)}).catch(M=>{hn(b.originalGroups),J.current({title:M instanceof Error?M.message:l("shell.workspaceReorderFailed"),tone:"error"})}))},[hn]);f.useEffect(()=>{const b=new Map;if(Nt.forEach(({session:C})=>{b.set(C.sessionId,{activityState:C.activityState,completedAt:C.completedAt??null,runningState:C.runningState??null})}),!fe.current){fe.current=!0,de.current=b;return}Nt.forEach(({session:C})=>{var Me;if(C.sessionId===Xe)return;const M=de.current.get(C.sessionId);if(!M)return;const te=M.activityState!=="completed_unread"&&C.activityState==="completed_unread",se=((Me=C.title)==null?void 0:Me.trim())||l("common.unknown");if(c&&te){const _e=l("conversation.backgroundCompletionToastDescription",{title:se});J.current({id:`workbench-session-completed-${C.sessionId}-${C.completedAt??"unknown"}`,title:l("conversation.backgroundCompletionToastTitle"),description:_e,tone:"success",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Wt(C.workspaceId,C.sessionId)}}),O.current.showNotification(l("conversation.backgroundCompletionToastTitle"),_e)}const pe=M.runningState!=="failed"&&(C.runningState??null)==="failed";if(u&&pe){const _e=lM(C)??l("conversation.runtimeFailed"),$e=l("conversation.backgroundFailureToastDescription",{title:se,detail:_e});J.current({id:`workbench-session-failed-${C.sessionId}-${C.updatedAt}`,title:l("conversation.backgroundFailureToastTitle"),description:$e,tone:"error",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Wt(C.workspaceId,C.sessionId)}}),O.current.showNotification(l("conversation.backgroundFailureToastTitle"),$e)}}),de.current=b},[Xe,Nt,c,u,Wt]),f.useEffect(()=>{Te.current=Nt.map(b=>b.session).filter(b=>b.sessionId!==Xe&&oM(b)).map(b=>{var C;return{sessionId:b.sessionId,workspaceId:b.workspaceId,title:((C=b.title)==null?void 0:C.trim())||l("common.unknown")}})},[Xe,Nt]),f.useEffect(()=>{let b=!1,C=null;const M=()=>{C=window.setTimeout(()=>{te().finally(()=>{b||M()})},XP)},te=async()=>{var $e;const se=Te.current;if(se.length===0){Ue.current||(Ue.current=!0),je.current="";return}const pe=new Set(se.map(xe=>xe.sessionId)),Me=await Promise.all(se.map(async xe=>{try{const lt=await nw(xe.sessionId);return{session:xe,items:lt.items}}catch{return{session:xe,items:null}}}));if(b)return;for(const xe of Me){if(!xe.items)continue;const lt=xe.items.filter($t=>$t.status==="pending"),Tn=new Set(lt.map($t=>$t.id)),Bn=He.current.get(xe.session.sessionId)??new Set;Ue.current&<.forEach($t=>{if(Bn.has($t.id)||!a)return;const sr=l("conversation.backgroundPermissionToastDescription",{title:xe.session.title,requestTitle:$t.title});J.current({id:`workbench-permission-request-${$t.id}`,title:l("conversation.permissionRequestToastTitle"),description:sr,tone:"warning",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Wt(xe.session.workspaceId,xe.session.sessionId)}}),O.current.showNotification(l("conversation.permissionRequestToastTitle"),sr)}),He.current.set(xe.session.sessionId,Tn)}for(const[xe,lt]of He.current.entries())!pe.has(xe)&<.size===0&&He.current.delete(xe);const _e=aM(He.current,pe);Ue.current&&_e!==je.current&&(($e=w.current)==null||$e.requestRefresh()),je.current=_e,Ue.current=!0};return te().finally(()=>{b||M()}),()=>{b=!0,C!==null&&window.clearTimeout(C)}},[a,Wt]),f.useEffect(()=>{ve&&Q.length===0||(Ze(b=>zk(b,Dr)),it(b=>b&&Dr.has(b)?b:null))},[Dr,ve]);const ln=Nt.find(b=>b.session.sessionId===Xe)??null,qt=(ln==null?void 0:ln.workspace.id)??(Xe?he[Xe]??null:null),tr=Rf(t.pathname,t.search),Us=tr&&Dr.has(tr)?tr:null,Ei=st&&Dr.has(st)?st:null,Pi=qt??Us??Ei??null,We=Pi??(($i=Q[0])==null?void 0:$i.workspace.id)??null,wr=f.useCallback(b=>{if(b){const C=Nt.find(M=>M.workspace.id===b)??null;if(C)return C}return Nt[0]??null},[Nt]),ms=f.useCallback(b=>{const C=typeof window>"u"?null:window.localStorage.getItem(wa);if(!C)return null;const M=C.split("?")[0]??C,te=uo(M);if(!te)return window.localStorage.removeItem(wa),null;const se=te.sessionId,pe=Nt.find(_e=>_e.session.sessionId===se)??null,Me=te.workspaceId??(pe==null?void 0:pe.workspace.id)??null;return pe&&(!b||Me===b)?jr(pe.workspace.id,pe.session.sessionId):(window.localStorage.removeItem(wa),null)},[Nt]),jn=f.useMemo(()=>bn.filter(b=>!Er.has(b.id)),[Er,bn]),Xr=f.useMemo(()=>jn.filter(b=>mM(b,Ln)).length,[jn,Ln]);f.useEffect(()=>{pr&&mr(jn)},[jn,mr,pr]);const Nl=f.useCallback(b=>{zn(!1),b.routePath&&n(b.routePath)},[n]),gs=f.useCallback(async(b,C)=>{const M=X.current+1;X.current=M;try{const te=await YT(b,C);if(M!==X.current)return;hr(se=>{const pe=new Set(se);return te.item?pe.add(te.item.notificationId):pe.delete(b),pe})}catch(te){if(M!==X.current)return;J.current({title:l("shell.globalNotificationsArchiveFailed"),description:te instanceof Error?te.message:void 0,tone:"error"})}},[]);f.useEffect(()=>{qt&&it(b=>b===qt?b:qt)},[qt]),f.useEffect(()=>{var pe;if(ve)return;const b=((pe=Q[0])==null?void 0:pe.workspace.id)??null,C=Us??b??Ei,M=Xe&&!Ct?wr(C):null,te=Xe&&!Ct?ms(C):null,se=M?jr(M.workspace.id,M.session.sessionId):null;if(tr&&!Us){n(te??se??(b?xM(t.pathname,b):Lc(e)),{replace:!0});return}if(Xe&&!Ct&&!qt){n(te??se??(b?po(b):Lc(e)),{replace:!0});return}},[Xe,wr,Ct,t.pathname,n,Q,ve,ms,tr,qt,e,Ei,Us]),f.useEffect(()=>{un("workbench.current_workspace_resolved",{currentSessionId:Xe,sessionWorkspaceId:qt,routeWorkspaceId:tr,currentWorkspaceId:We,source:qt?ln?"navigation":"sessionWorkspaceMap":tr?"route":st?"workspaceSelection":"navigationFallback"})},[ln,Xe,We,tr,st,qt]);const On=La(t.pathname)?"terminals":Da(t.pathname)?"butler":"conversation",Ft=e==="mobile",bs=Lc(e),Mi=f.useMemo(()=>Q.map(b=>{const C=Rk(b.sessions),M=new Set(b.sessions.map(te=>te.sessionId));return{workspace:b.workspace,visibleSessions:C,archivedSessions:b.sessions.filter(te=>Ir(te)&&!Po(te)),visibleSessionTree:Nk(C,o).filter(te=>!Zn.has(te.item.sessionId)&&!om(En(te),se=>Zn.has(se.sessionId))),childWorktrees:Dk(b.childWorktrees,Zn,o,M),isCollapsed:yr.has(b.workspace.id)}}),[yr,Zn,Q,o]),Hs=f.useMemo(()=>UE(Q),[Q]),ks=f.useMemo(()=>Ff(Q,We),[We,Q]),nr=(ln?jy(ln.session,ln.session.sessionIsolatedWorkspace):We)??We,Un=f.useMemo(()=>Ff(Q,nr),[nr,Q]),Li=f.useMemo(()=>We?(ks==null?void 0:ks.workspace)??Q.map(b=>b.workspace).find(b=>b.id===We)??null:null,[We,ks,Q]),Di=f.useMemo(()=>nr?(Un==null?void 0:Un.workspace)??Q.map(b=>b.workspace).find(b=>b.id===nr)??null:null,[nr,Un,Q]),Qr=(Un==null?void 0:Un.meta)??null,Tl=(We?Hs[We]??null:null)??(Li?rl(Li):null),rr=(nr?Hs[nr]??null:null)??(Di?rl(Di):Tl),Mo=Qr?Kt[Qr.workspaceId]??null:null,qs=f.useMemo(()=>{var C,M,te;if(!Xe)return null;const b=((te=(M=(C=ln==null?void 0:ln.session)==null?void 0:C.parallelGroup)==null?void 0:M.groupId)==null?void 0:te.trim())||null;return b||EM(xt,Xe)},[(P=(y=ln==null?void 0:ln.session)==null?void 0:y.parallelGroup)==null?void 0:P.groupId,Xe,xt]),cn=On==="conversation"&&!!qs;f.useEffect(()=>{if(typeof window>"u"||!cn||!qs){Be(null);return}const b=Ry(qs);if(!b||b.sidebarCollapseDurationMs<=0){Be(null);return}Be(b);const C=Date.now()-b.createdAt,M=b.totalDurationMs-C;if(M<=0){Be(null);return}const te=window.setTimeout(()=>{Be(null)},M);return()=>{window.clearTimeout(te)}},[qs,cn]),f.useEffect(()=>{un("workbench.info_panel_state",{infoPanelReady:qe,rightCollapsed:Z||cn,currentWorkspaceId:We,sessionWorkspaceId:qt,currentSessionId:Xe})},[Xe,We,qe,cn,Z,qt]);const Or=f.useMemo(()=>Nt.filter(b=>Zn.has(b.session.sessionId)&&!Ir(b.session)&&!sl(b.session)),[Zn,Nt]),Oi=t.pathname.startsWith("/settings")?"settings":Da(t.pathname)?"terminals":La(t.pathname)?"butler":yM(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":kM(t.pathname)||Ef(t.pathname)?"sessions":"workspaces",Il=Ft&&(Oi==="sessions"&&Ef(t.pathname)||Da(t.pathname)),Al=hl({isNativeMobile:r.isNativeMobile,viewportClass:r.viewportClass}),Lo=No({viewportClass:r.viewportClass,activeEntry:Oi,hasNavigationPanel:Ft,hasAuxiliaryPanel:Ft,preferCompactLayout:Al}),Rl=Ft&&Dm(Lo),El=Ft&&Om(Lo),Pl=f.useMemo(()=>Q.map(b=>b.workspace),[Q]),Ml=f.useMemo(()=>{const b=mt.trim().toLowerCase();return b?Nt.filter(C=>{const M=(C.session.title||"").toLowerCase(),te=C.workspace.name.toLowerCase(),se=Sl(C.session.provider,"full").toLowerCase();return M.includes(b)||te.includes(b)||se.includes(b)}):[]},[Nt,mt]);f.useEffect(()=>{var C;const b=We??((C=Q[0])==null?void 0:C.workspace.id)??"";b&&ct(M=>M&&Q.some(se=>se.workspace.id===M)?M:b)},[We,Q]),f.useEffect(()=>{Xe&&!Ct&&qt&&Cs(wa,`${t.pathname}${t.search}`)},[Xe,Ct,t.pathname,t.search,qt]),f.useEffect(()=>{if(Xe&&Ct){k.current=`${t.pathname}${t.search}`;return}Xe&&!Ct&&(k.current=null)},[Xe,Ct,t.pathname,t.search]),f.useEffect(()=>{Ft||(Oe(!1),et(!1))},[Ft]),f.useEffect(()=>{!Ft||ve||!bM(t.pathname)||Pi||(Oe(!1),et(!1),n(bs,{replace:!0}))},[Pi,Ft,t.pathname,n,ve,bs]);function Ll(){if(Ft){Oe(!0);return}$(!1)}function Gs(){if(!cn){if(Br(),Ft){et(!0);return}ge(!1)}}function Dl(){if(Ft){Oe(b=>!b);return}$(b=>!b)}function Do(){if(!cn){if(Br(),Ft){et(b=>!b);return}ge(b=>!b)}}function Br(){bt(!0)}function Ks(b){if(it(b),Br(),La(t.pathname)){const C=Ts(b);t.pathname!==C&&n(C);return}Xe&&qt!==b&&n(bs)}const ys=f.useCallback(async b=>{var te;const C=((te=Nt.find(se=>se.session.sessionId===b))==null?void 0:te.session)??null,M=(C==null?void 0:C.isFavorite)!==!0;Ce(se=>Hf(se,b,M));try{const se=await Vy(b,M);Rt(se),on()}catch(se){throw Ce(pe=>Hf(pe,b,!M)),se}},[Nt,on,Rt]),Oo=f.useCallback((b,C)=>{Sk(b,C).then(()=>{n(am(b,C))}).catch(M=>{i({title:M instanceof Error?M.message:l("shell.startSessionFailed"),tone:"error"})})},[n,i]),Bo=f.useCallback(b=>{var te;const C=((te=b.workspaceId)==null?void 0:te.trim())||We,M=vM(b.filePath);return!C||!M?!1:(Br(),Ye("files"),Ft?(Oe(!1),et(!0)):ge(!1),Qt({requestId:S.current+1,workspaceId:C,filePath:M,openViewer:b.openViewer===!0}),S.current+=1,!0)},[We,Ft]),Bi=f.useCallback(async(b,C)=>{const M=await bm(b,C.trim());return Rt(M),M},[Rt]);function Vs(b){Se(!0)}function _i(){Se(!1),Bt("sessions"),_t(""),yt(null),gn([]),_s(!1)}async function _o(){const b=mt.trim();if(!b||!tt.trim()){gn([]),yt(null);return}_s(!0),yt(null);try{const C=await Sw(tt,b);gn(C.items)}catch(C){gn([]),yt(C instanceof Error?C.message:l("shell.searchCodeFailed"))}finally{_s(!1)}}function ws(b,C){const M=K.current;M&&(M.style.setProperty("--workbench-left-width",`${b}px`),M.style.setProperty("--workbench-left-current-width",Re?"0px":`${b}px`),M.style.setProperty("--workbench-right-width",`${C}px`),M.style.setProperty("--workbench-right-current-width",Z?"0px":`${C}px`))}function Ol(b={}){return{leftWidth:b.leftWidth??(Re?0:ce.current),rightWidth:b.rightWidth??(Hn&&!Z?N.current:0),leftCollapsed:b.leftCollapsed??Re,rightCollapsed:b.rightCollapsed??(!Hn||Z),prefersDarkAppearance:b.prefersDarkAppearance??fr!=="light",isResizing:b.isResizing??Ve!==null}}function Wo(b,C){var _e;C.preventDefault(),C.stopPropagation(),(_e=window.getSelection())==null||_e.removeAllRanges();const M=C.clientX,te=b==="left"?ae:ke;Ie(b);const se=()=>{const $e=ee.current;if(ee.current=null,$e!==null){if(b==="left"){ce.current=$e,ie(xe=>xe===$e?xe:$e),ws($e,N.current);return}N.current=$e,ye(xe=>xe===$e?xe:$e),ws(ce.current,$e)}};function pe($e){var Bn;$e.preventDefault(),(Bn=window.getSelection())==null||Bn.removeAllRanges();const xe=$e.clientX-M,lt=b==="left"?Ca(te+xe,xf,Sf):Ca(te-xe,vf,Cf),Tn=b==="left"?ce.current:N.current;lt===Tn&&ee.current===null||(ee.current=lt,De.current===null&&(De.current=window.requestAnimationFrame(()=>{De.current=null,se()})))}function Me(){document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",Me),De.current!==null&&(window.cancelAnimationFrame(De.current),De.current=null),se(),Ie(xe=>xe===b?null:xe);const $e=Ol({isResizing:!1});Uo.current=$e,r.bridge.syncNativeSidebarLayout($e)}document.addEventListener("mousemove",pe,{passive:!1}),document.addEventListener("mouseup",Me)}function Ys(){if(Fo())return;if(Nt.length===0){n(bs);return}const b=jr(Nt[0].workspace.id,Nt[0].session.sessionId);n(b)}function Bl(){if(!Fo(We)){if(We){n(po(We));return}n(bs)}}function Fo(b){if(Xe&&qt)return b&&qt&&qt!==b?!1:(n(`${t.pathname}${t.search}`),!0);if(k.current){if(b){const[M,te=""]=k.current.split("?"),se=Rf(M??k.current,te?`?${te}`:"");if(se&&se!==b)return!1}return n(k.current),!0}const C=ms(b);return C?(n(C),!0):!1}f.useEffect(()=>{if(typeof window>"u")return;function b(C){if(!(C.metaKey||C.ctrlKey)){C.key==="Escape"&&(Oe(!1),et(!1));return}if(FM(C.target))return;const te=C.key.toLowerCase();if(!C.shiftKey&&te==="b"){C.preventDefault(),Dl();return}if(C.shiftKey&&te==="i"){C.preventDefault(),Do();return}if(!C.shiftKey&&te===","){C.preventDefault(),n("/settings");return}if(!C.shiftKey&&te==="1"){C.preventDefault(),Ys();return}if(!C.shiftKey&&te==="2"){C.preventDefault(),n(We?Ts(We):wn());return}if(!C.shiftKey&&te==="k"){C.preventDefault(),$M();return}C.shiftKey&&te==="r"&&(C.preventDefault(),sn())}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[n,sn,Ft,Ys]);const _l=f.useMemo(()=>({shellMode:e,navigationGroups:Q,navigationLoading:ve,navigationError:rt,currentWorkspaceId:We,currentSessionId:Xe,favoriteSessionIds:yn,favoriteSessions:Or,globalNotifications:bn,archivedNotificationIds:Array.from(Er),showArchivedNotifications:ps,unreadNotificationCount:Xr,refreshNavigation:sn,requestNavigationRefresh:on,openNotificationPanel:()=>{zn(!0)},closeNotificationPanel:()=>{zn(!1)},setShowArchivedNotifications:Kr,archiveNotification:b=>{gs(b,!0)},unarchiveNotification:b=>{gs(b,!1)},setAuxiliaryPanel:D,subscribeFileTree:an,requestFileTreeRefresh:gr,addFileTreeSnapshotListener:Vr,subscribeGitSnapshot:br,requestGitRefresh:Vt,addGitSnapshotListener:Yr,subscribeWorkspaceManagementSnapshot:Jn,requestWorkspaceManagementRefresh:Dn,addWorkspaceManagementSnapshotListener:Xn,workspaceManagementStateById:Yn,subscribeTerminalManagerSnapshot:Je,requestTerminalManagerRefresh:Cn,addTerminalManagerSnapshotListener:Lr,selectWorkspace:Ks,toggleFavoriteSession:ys,archiveSession:b=>Nn(b,!0),unarchiveSession:b=>Nn(b,!1),renameSession:Bi,startDraftSession:Oo,markNavigationSessionSeen:Jr,upsertNavigationSession:Rt,setSessionWorkspace:kn,revealWorkspaceFile:Bo}),[Vr,Yr,Xn,Lr,Nn,Xe,We,bn,yn,Or,Ks,Er,Jr,rt,Q,ve,Xr,gr,Vt,Dn,sn,on,Kr,D,Cn,Bi,ps,Yn,e,Oo,kn,an,br,Jn,Je,gs,ys,Rt,Bo]),Wl={"--workbench-left-width":`${ae}px`,"--workbench-left-current-width":Re?"0px":`${ae}px`,"--workbench-right-width":`${ke}px`,"--workbench-right-current-width":Z||cn?"0px":`${ke}px`,"--workbench-right-sidebar-duration":Ne&&!Z?`${Ne.sidebarCollapseDurationMs}ms`:void 0,"--workbench-right-sidebar-content-duration":Ne&&!Z?`${Math.max(320,Ne.sidebarCollapseDurationMs-120)}ms`:void 0},$o=On==="butler"?Dt:s.jsx(Jf,{panelReady:qe,activeTab:Ut,fileRevealRequest:cr,onTabChange:b=>{Br(),Ye(b)},currentSessionId:Ct?null:Xe,activeWorkspaceId:nr,navigationGroups:Q,workspaceContext:rr,worktreeMeta:Qr,worktreeMergeState:Mo,onRefreshWorktreeMergePreview:Qn,onApplyWorktreeMerge:x,onCleanupWorktree:H}),Hn=$o!==null,xr=Z||cn,Js=cn&&Ne!==null&&!Z,Xs=r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar;f.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:b,body:C}=document,M=()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null);const se=be.current;be.current=!1,b.removeAttribute(va),C==null||C.removeAttribute(va),se&&re.current&&(re.current=!1,Fs(pe=>pe+1))};if(!Xs){M();return}const te=()=>{be.current=!0,b.setAttribute(va,"true"),C==null||C.setAttribute(va,"true"),j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{M()},ZP)};return window.addEventListener("resize",te),()=>{window.removeEventListener("resize",te),M()}},[Xs]);const xs=f.useMemo(()=>({leftWidth:Re?0:ae,rightWidth:Hn&&!xr?ke:0,leftCollapsed:Re,rightCollapsed:!Hn||xr,prefersDarkAppearance:fr!=="light",isResizing:Ve!==null}),[Ve,xr,Re,ae,ke,Hn,fr]),Fl=f.useDeferredValue(xs),zo=Ve===null?Fl:xs,Uo=f.useRef(xs);f.useEffect(()=>{Uo.current=xs},[xs]),f.useEffect(()=>{if(typeof window>"u")return;let b=null;const C=()=>{b=null,r.bridge.syncNativeSidebarLayout(zo)},M=()=>{b!==null&&window.cancelAnimationFrame(b),b=window.requestAnimationFrame(C)};return rn?(M(),()=>{b!==null&&window.cancelAnimationFrame(b)}):(r.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{b!==null&&window.cancelAnimationFrame(b)})},[zo,r.bridge,rn]),f.useLayoutEffect(()=>{const b=K.current;if(!b||!Xs||typeof window>"u"){If(b);return}let C=null,M=null;const te=new Set([b]),se=()=>{re.current=!1;const Me=window.getComputedStyle(b),_e=vk(Me,"--desktop-macos-traffic-light-center-y");if(_e===null){If(b);return}const $e={navToolbar:rs(b,Et.navToolbar.selector),infoTabs:rs(b,Et.infoTabs.selector),auxiliaryToolbarButton:rs(b,Et.auxiliaryToolbarButton.selector),conversationHeaderMain:rs(b,Et.conversationHeaderMain.selector),conversationHeaderActions:rs(b,Et.conversationHeaderActions.selector),terminalTabbarMain:rs(b,Et.terminalTabbarMain.selector),collapsedLeftControls:rs(b,Et.collapsedLeftControls.selector),collapsedRightControls:rs(b,Et.collapsedRightControls.selector)},xe=[$e.infoTabs,$e.conversationHeaderMain,$e.conversationHeaderActions,$e.terminalTabbarMain].filter($t=>$t!==null),lt=[$e.collapsedLeftControls,$e.collapsedRightControls].filter($t=>$t!==null),Tn=lt.length>0?Cr(Me,"--workbench-collapsed-controls-live-shift-y",_e,lt.reduce(($t,sr)=>$t+sr,0)/lt.length):null,Bn=xe.length>0?Cr(Me,"--workbench-titlebar-live-content-shift-y",_e,xe.reduce(($t,sr)=>$t+sr,0)/xe.length):null;Sr(b,"--workbench-titlebar-live-content-shift-y",Bn),Sr(b,"--workbench-collapsed-controls-live-shift-y",Tn),Sr(b,Et.navToolbar.variableName,Cr(Me,Et.navToolbar.variableName,_e,$e.navToolbar)),Sr(b,Et.infoTabs.variableName,Cr(Me,Et.infoTabs.variableName,_e,$e.infoTabs)),Sr(b,Et.auxiliaryToolbarButton.variableName,Cr(Me,Et.auxiliaryToolbarButton.variableName,_e,$e.auxiliaryToolbarButton)),Sr(b,Et.conversationHeaderMain.variableName,Cr(Me,Et.conversationHeaderMain.variableName,_e,$e.conversationHeaderMain)),Sr(b,Et.conversationHeaderActions.variableName,Cr(Me,Et.conversationHeaderActions.variableName,_e,$e.conversationHeaderActions)),Sr(b,Et.terminalTabbarMain.variableName,Cr(Me,Et.terminalTabbarMain.variableName,_e,$e.terminalTabbarMain)),Sr(b,Et.collapsedLeftControls.variableName,Cr(Me,Et.collapsedLeftControls.variableName,_e,$e.collapsedLeftControls)),Sr(b,Et.collapsedRightControls.variableName,Cr(Me,Et.collapsedRightControls.variableName,_e,$e.collapsedRightControls))},pe=()=>{if(be.current){re.current=!0;return}C!==null&&window.cancelAnimationFrame(C),C=window.requestAnimationFrame(()=>{C=null,se()})};if(pe(),typeof ResizeObserver<"u"){M=new ResizeObserver(()=>{pe()});for(const Me of Object.values(Et))for(const _e of b.querySelectorAll(Me.selector))te.add(_e);for(const Me of te)M.observe(Me)}return window.addEventListener("resize",pe),()=>{C!==null&&window.cancelAnimationFrame(C),window.removeEventListener("resize",pe),M==null||M.disconnect()}},[On,qe,Re,t.pathname,t.search,Z,Hn,Xs,Ai]);const Wi=Ft?s.jsx(Yf,{workspaceGroups:Mi,workspaceVisualContextMap:Hs,sessionDisplaySortMode:o,favoriteSessions:Or,favoriteSessionIds:Zn,activeWorkspaceId:We,isConversationActive:On==="conversation",isTerminalActive:On==="terminals",isButlerActive:On==="butler",isSearchOpen:we,navigationLoading:ve,navigationError:rt,activeSessionId:Xe,onRefreshNavigation:sn,onSessionUpdated:Rt,onNavigateConversation:Ys,onNavigateTerminals:()=>{Oe(!1),n(We?Ts(We):wn())},onNavigateButler:()=>{Oe(!1),n(We?Es(We):wn())},onOpenSearch:()=>{Oe(!1),Vs()},onOpenSettings:()=>{Oe(!1),n("/settings")},onSelectWorkspace:Ks,onToggleWorkspaceCollapse:er,onStartWorkspaceReorder:$s,onPreviewWorkspaceReorder:zs,onCommitWorkspaceReorder:Ri,allowWorkspaceReorder:!1,subscribeGitSnapshot:br,requestGitRefresh:Vt,subscribeWorkspaceManagementSnapshot:Jn,requestWorkspaceManagementRefresh:Dn,onToggleFavoriteSession:ys,onArchiveSession:b=>Nn(b,!0),onUnarchiveSession:b=>Nn(b,!1),workspaceManagementStateById:Yn,setWorkspaceManagementStateById:Zt,unreadNotificationCount:Xr,notificationPanelOpen:pr,onToggleNotificationPanel:()=>{zn(b=>!b)},onClose:()=>Oe(!1)}):null,Ho=Ft&&Hn?$o:null;return s.jsxs(Ck.Provider,{value:_l,children:[Ft?s.jsx(s.Fragment,{children:s.jsx(sx,{activeEntry:Oi,presentation:Il?"conversation-focus":"default",navigationPanel:Wi,auxiliaryPanel:Ho,onOpenNavigation:()=>{et(!1),Oe(!0)},onOpenSearch:()=>{Oe(!1),et(!1),Vs()},onOpenAuxiliary:()=>{Hn&&(Br(),Oe(!1),et(!0))},onNavigateWorkspaces:()=>{Oe(!1),et(!1),n(wn())},onNavigateTerminals:()=>{Oe(!1),et(!1),n(We?Ts(We):wn())},onNavigateButler:()=>{Oe(!1),et(!1),n(We?Es(We):wn())},onNavigateSessions:()=>{Oe(!1),et(!1),Bl()},onNavigateToolFiles:()=>{Oe(!1),et(!1),n(We?um(We):wn())},onNavigateToolGit:()=>{Oe(!1),et(!1),n(We?cm(We):wn())},onNavigateToolProcesses:()=>{Oe(!1),et(!1),n(We?lm(We):wn())},onNavigateSettings:()=>{Oe(!1),et(!1),n("/settings")},children:s.jsx(Nd,{})})}):s.jsx("div",{className:"workbench-shell",ref:K,style:Wl,onMouseDownCapture:vn,onDoubleClickCapture:Ws,"data-nav-loading":ve,"data-left-collapsed":Re,"data-right-collapsed":xr,"data-info-ready":qe,"data-parallel-conversation-active":cn?"true":void 0,"data-parallel-sidebar-transition":Js?"true":void 0,"data-runtime-platform":r.platform,"data-os-family":r.ui.osFamily,"data-overlay-titlebar":r.ui.prefersOverlayTitlebar,children:s.jsxs("div",{className:"workbench-body-shell",children:[s.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":Re,children:s.jsx(Yf,{workspaceGroups:Mi,workspaceVisualContextMap:Hs,sessionDisplaySortMode:o,favoriteSessions:Or,favoriteSessionIds:Zn,activeWorkspaceId:We,isConversationActive:On==="conversation",isTerminalActive:On==="terminals",isButlerActive:On==="butler",isSearchOpen:we,navigationLoading:ve,navigationError:rt,activeSessionId:Xe,onRefreshNavigation:sn,onSessionUpdated:Rt,onNavigateConversation:Ys,onNavigateTerminals:()=>n(We?Ts(We):wn()),onNavigateButler:()=>n(We?Es(We):wn()),onOpenSearch:()=>Vs(),onOpenSettings:()=>n("/settings"),onSelectWorkspace:Ks,onToggleWorkspaceCollapse:er,onStartWorkspaceReorder:$s,onPreviewWorkspaceReorder:zs,onCommitWorkspaceReorder:Ri,allowWorkspaceReorder:!0,subscribeGitSnapshot:br,requestGitRefresh:Vt,subscribeWorkspaceManagementSnapshot:Jn,requestWorkspaceManagementRefresh:Dn,onToggleFavoriteSession:ys,onArchiveSession:b=>Nn(b,!0),onUnarchiveSession:b=>Nn(b,!1),workspaceManagementStateById:Yn,setWorkspaceManagementStateById:Zt,unreadNotificationCount:Xr,notificationPanelOpen:pr,onToggleNotificationPanel:()=>{zn(b=>!b)},onToggleCollapse:()=>$(!0)})}),s.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":Re,role:"separator","aria-label":l("shell.leftResizerLabel"),onMouseDown:Re?void 0:b=>Wo("left",b)}),s.jsxs("div",{className:"workbench-main-shell",children:[s.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!Re&&!Z,children:[s.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":Re,children:[s.jsx(Gf,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:Ll}),s.jsx(bk,{collapsed:!0}),s.jsx(Xk,{unreadCount:Xr,open:pr,onToggle:()=>{zn(b=>!b)},collapsed:!0})]}),Hn&&!cn?s.jsx("div",{className:"workbench-collapsed-controls right","data-visible":Z,children:s.jsx(Gf,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:Gs})}):null]}),s.jsx(Nd,{})]}),Hn?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":xr,"data-auto-hidden":cn?"true":void 0,role:"separator","aria-label":l("shell.rightResizerLabel"),onMouseDown:xr?void 0:b=>Wo("right",b)}),s.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(rr==null?void 0:rr.tone)??"root","data-worktree-depth":(rr==null?void 0:rr.depth)??0,"data-collapsed":xr,"data-auto-hidden":cn?"true":void 0,"data-custom-panel":On==="butler","data-parallel-transition":Js?"true":void 0,"aria-hidden":xr&&!Js,style:Wr(rr),children:cn&&!Js?null:On==="butler"?s.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Dt}):s.jsx(Jf,{panelReady:qe,activeTab:Ut,fileRevealRequest:cr,onTabChange:b=>{Br(),Ye(b)},onToggleCollapse:()=>ge(!0),currentSessionId:Ct?null:Xe,activeWorkspaceId:nr,navigationGroups:Q,workspaceContext:rr,worktreeMeta:Qr,worktreeMergeState:Mo,onRefreshWorktreeMergePreview:Qn,onApplyWorktreeMerge:x,onCleanupWorktree:Pe})})]}):null]})}),s.jsx(sL,{open:pr,notifications:bn,archivedNotificationIds:Er,showArchivedNotifications:ps,onClose:()=>zn(!1),onToggleShowArchivedNotifications:Kr,onArchiveNotification:b=>{gs(b,!0)},onUnarchiveNotification:b=>{gs(b,!1)},onSelectNotification:Nl,preferredWorkspaceId:We,preferredSessionId:Ct?null:Xe}),s.jsx(vL,{open:we,mode:pt,keyword:mt,codeWorkspaceId:tt,codeResults:hs,codeLoading:Ht,codeError:qr,workspaceOptions:Pl,sessionResults:Ml,onClose:_i,onModeChange:b=>{Bt(b),yt(null),gn([])},onKeywordChange:b=>{_t(b),pt==="code"&&!b.trim()&&(gn([]),yt(null))},onCodeWorkspaceChange:b=>ct(b),onCodeSearch:()=>{_o()},onOpenSession:b=>{_i();const C=Nt.find(M=>M.session.sessionId===b)??null;n(C?jr(C.workspace.id,b):wn())}}),s.jsxs(St,{open:wt!==null,title:l("shell.worktreeCleanupModalTitle"),description:l("shell.worktreeCleanupModalDescription"),onClose:()=>{var b;wt&&((b=Kt[wt.workspaceId])!=null&&b.cleaning)||(dr(!1),Rr(null))},children:[s.jsx("p",{className:"workbench-section-empty",children:wt?l("shell.worktreeCleanupConfirm",{name:wt.displayName||wt.branchName}):""}),wt?s.jsxs("div",{className:"worktree-cleanup-modal-options",children:[s.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[s.jsx("input",{type:"checkbox",checked:ur,disabled:!!((W=Kt[wt.workspaceId])!=null&&W.cleaning)||((oe=(ne=Kt[wt.workspaceId])==null?void 0:ne.preview)==null?void 0:oe.alreadyMerged)!==!0,onChange:b=>dr(b.target.checked)}),s.jsx("span",{children:l("shell.worktreeCleanupDeleteBranchLabel",{branch:wt.branchName})})]}),((me=(Fe=Kt[wt.workspaceId])==null?void 0:Fe.preview)==null?void 0:me.alreadyMerged)!==!0?s.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:l("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!(wt&&((ot=Kt[wt.workspaceId])!=null&&ot.cleaning)),onClick:()=>{dr(!1),Rr(null)},children:l("common.cancel")}),s.jsx("button",{type:"button",className:ur&&wt&&((It=(Mt=Kt[wt.workspaceId])==null?void 0:Mt.preview)==null?void 0:It.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!wt||!!(wt&&((Yt=Kt[wt.workspaceId])!=null&&Yt.cleaning)),onClick:()=>{wt&&H(wt)},children:wt&&((qn=Kt[wt.workspaceId])!=null&&qn.cleaning)?l("shell.worktreeCleanupRunning"):ur&&wt&&((Zr=(Gn=Kt[wt.workspaceId])==null?void 0:Gn.preview)==null?void 0:Zr.alreadyMerged)===!0?l("shell.worktreeCleanupDeleteBranchAction"):l("shell.worktreeCleanupAction")})]})]}),Ft?s.jsxs(s.Fragment,{children:[Rl?null:s.jsx(Xf,{isOpen:ht,side:"left",onClose:()=>Oe(!1),children:Wi}),El?null:s.jsx(Xf,{isOpen:kt,side:"right",onClose:()=>et(!1),children:Ho})]}):null]})}function Xf({isOpen:e,side:t,onClose:n,children:r,className:i,overlayClassName:o}){if(!e)return null;const a=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:["mobile-nav-overlay","open",o].filter(Boolean).join(" "),onClick:n,role:"button",tabIndex:0,"aria-label":l("common.back"),onKeyDown:c=>{c.key==="Escape"&&n()}}),s.jsx("div",{className:["mobile-nav-drawer",t,"open",i].filter(Boolean).join(" "),children:r})]});return typeof document>"u"?a:$r.createPortal(a,document.body)}function ey(){return f.useContext(Ck)??{navigationGroups:[],navigationLoading:!1,navigationError:null,shellMode:"desktop",currentWorkspaceId:null,currentSessionId:null,favoriteSessionIds:[],favoriteSessions:[],globalNotifications:[],archivedNotificationIds:[],showArchivedNotifications:!1,unreadNotificationCount:0,refreshNavigation:async()=>{},requestNavigationRefresh:()=>{},openNotificationPanel:()=>{},closeNotificationPanel:()=>{},setShowArchivedNotifications:()=>{},archiveNotification:()=>{},unarchiveNotification:()=>{},setAuxiliaryPanel:()=>{},subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{},subscribeWorkspaceManagementSnapshot:()=>{},requestWorkspaceManagementRefresh:()=>{},addWorkspaceManagementSnapshotListener:()=>()=>{},workspaceManagementStateById:{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{},selectWorkspace:()=>{},toggleFavoriteSession:async()=>{},archiveSession:async()=>{},unarchiveSession:async()=>{},renameSession:async()=>{throw new Error("workbench shell unavailable")},startDraftSession:()=>{},setSessionWorkspace:()=>{},upsertNavigationSession:()=>{},markNavigationSessionSeen:()=>{},revealWorkspaceFile:()=>!1}}function ty(e){return e.startsWith("draft-")}export{IP as $,dl as A,yP as B,qI as C,GI as D,WE as E,HI as F,UE as G,JE as H,QE as I,ka as J,mk as K,Fu as L,RP as M,MP as N,EP as O,ro as P,Ma as Q,$u as R,qE as S,PP as T,AP as U,Tu as V,fx as W,ym as X,LP as Y,nD as Z,sD as _,WO as a,eO as a$,rD as a0,KL as a1,$m as a2,yO as a3,vO as a4,mO as a5,gO as a6,wO as a7,fO as a8,CO as a9,bo as aA,Vb as aB,qD as aC,TO as aD,rl as aE,FP as aF,JL as aG,Wr as aH,IO as aI,Id as aJ,XL as aK,Rw as aL,Ew as aM,Pw as aN,LD as aO,pd as aP,mR as aQ,gR as aR,AO as aS,OD as aT,FD as aU,UP as aV,SO as aW,px as aX,MD as aY,KD as aZ,VD as a_,RO as aa,EO as ab,oD as ac,aD as ad,lD as ae,uD as af,dD as ag,un as ah,xw as ai,YL as aj,wm as ak,cD as al,QL as am,nw as an,iD as ao,tD as ap,qb as aq,cs as ar,MO as as,DO as at,PO as au,LO as av,eA as aw,OO as ax,WD as ay,Dp as az,ey as b,ID as b$,tO as b0,ZD as b1,XD as b2,YD as b3,hO as b4,JD as b5,aO as b6,GT as b7,bO as b8,kO as b9,YE as bA,gu as bB,_O as bC,HE as bD,BD as bE,_D as bF,$x as bG,Md as bH,yD as bI,VL as bJ,ad as bK,vD as bL,xD as bM,mD as bN,Sw as bO,DD as bP,gD as bQ,bD as bR,pD as bS,Mw as bT,kD as bU,fD as bV,S1 as bW,OT as bX,hD as bY,wD as bZ,ND as b_,dO as ba,sO as bb,iO as bc,oO as bd,lO as be,cO as bf,uO as bg,aP as bh,QD as bi,nO as bj,rO as bk,pO as bl,xO as bm,vI as bn,PI as bo,NO as bp,$D as bq,UD as br,zD as bs,HD as bt,eD as bu,GD as bv,ZL as bw,df as bx,dS as by,$E as bz,Wa as c,Cw as c0,jD as c1,SD as c2,TD as c3,CD as c4,ED as c5,PD as c6,RD as c7,AD as c8,za as d,jP as e,kP as f,$y as g,BO as h,jO as i,fR as j,$T as k,zT as l,Qp as m,qT as n,cb as o,ME as p,DE as q,Wm as r,PE as s,gd as t,Go as u,Hy as v,io as w,qL as x,HL as y,GL as z};
|