@jingyi0605/codingns 0.8.1 → 0.8.5
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 +180 -0
- package/dist/public/assets/{AdaptiveButlerPage-b7s6F_sd.js → AdaptiveButlerPage-CJw8Ae62.js} +3 -3
- package/dist/public/assets/App-BOHBGFOd.js +30 -0
- package/dist/public/assets/{BootstrapPage-jFfl7KNK.js → BootstrapPage-BxHQT4nA.js} +1 -1
- package/dist/public/assets/{ConversationPage-sj_rn4q0.js → ConversationPage-DWFsF6BB.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-C5c88SOX.js → DesktopDetachPreviewPage-DOgEjYEf.js} +1 -1
- package/dist/public/assets/DesktopModal-D_A8sgQU.js +1 -0
- package/dist/public/assets/DesktopWindowPage-DK7L7osV.js +2 -0
- package/dist/public/assets/FileContextPanel-BdCoubcJ.js +1 -0
- package/dist/public/assets/GitSidebar-BeZ0hj7A.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DfLMVu8q.js +1 -0
- package/dist/public/assets/MobileSheet-5kZ-w-gU.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-_I0t7cC_.js → MobileTopHeaderFrame-lcp2GscV.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-C6JMiOq_.js +1 -0
- package/dist/public/assets/PluginAccessOverview-DGcKAMQl.js +1 -0
- package/dist/public/assets/PluginContainerPage-BlY-xJDh.js +1 -0
- package/dist/public/assets/PluginDetailPage-CAJ7LFpD.js +1 -0
- package/dist/public/assets/PluginsListPage-BxZG1NyT.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-CMtDWyGS.js → RelayConnectEntryPage-CfNO_TIl.js} +1 -1
- package/dist/public/assets/ServerSettingsModal-by36Z_5k.js +1 -0
- package/dist/public/assets/SessionIndexPage-DkBp9Mqz.js +1 -0
- package/dist/public/assets/SettingsPage-C-ASmJAG.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-NVZRxxmH.js +1 -0
- package/dist/public/assets/{TerminalPage-CBIKHI33.js → TerminalPage-C4LNoPBp.js} +3 -3
- package/dist/public/assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js +1 -0
- package/dist/public/assets/ToolFilesPage-47zbdgTW.js +1 -0
- package/dist/public/assets/ToolGitPage-Fuk_b_jg.js +1 -0
- package/dist/public/assets/ToolProcessesPage-sWSMWD-9.js +1 -0
- package/dist/public/assets/ToolsHomePage-R1mZlbZi.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CqmiFH2u.js +1 -0
- package/dist/public/assets/WorkbenchLayout-OFi6CWgH.js +244 -0
- package/dist/public/assets/WorkbenchModal-C7qoQElW.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BAQe_E0O.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-DhKa6e9y.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BPsrFffw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-KAtqZOAb.js +1 -0
- package/dist/public/assets/{client-runtime-manager-CdJP7nUp.js → client-runtime-manager-wmCJZKYd.js} +1 -1
- package/dist/public/assets/file-tree-icon-Mg1DiBRX.js +590 -0
- package/dist/public/assets/{index-VVxfF0s5.css → index-C4t-vvqk.css} +1 -1
- package/dist/public/assets/index-CL97fwWB.js +42 -0
- package/dist/public/assets/{login-direct-candidate-resolver-C-mo698r.js → login-direct-candidate-resolver-BOAgTuUf.js} +1 -1
- package/dist/public/assets/plugin-permission-copy-Cq99cnzV.js +1 -0
- package/dist/public/assets/plugins-api-BQTV5DOp.js +1 -0
- package/dist/public/assets/{preferences-service-CnaTvZq2.js → preferences-service-DJxbEEeg.js} +1 -1
- package/dist/public/assets/realtime-client-CLafKzzJ.js +1 -0
- package/dist/public/assets/{relay-entry-D7OgZZN-.js → relay-entry-D-LfvdiX.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BCtAYB0E.js → terminal-runtime-meta-BJmy8dyK.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-DQAWVdCo.js +1 -0
- package/dist/public/assets/workbench-navigation-MEzCSmsK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +4 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -1
- package/dist/server/modules/channels/wechat-claw-client.d.ts +51 -0
- package/dist/server/modules/channels/wechat-claw-client.js +245 -0
- package/dist/server/modules/channels/wechat-claw-client.js.map +1 -0
- package/dist/server/modules/file/file-access-guard.d.ts +2 -0
- package/dist/server/modules/file/file-access-guard.js +24 -2
- package/dist/server/modules/file/file-access-guard.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +153 -1
- package/dist/server/modules/file/file-controller.js +215 -1
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +2 -0
- package/dist/server/modules/file/file-preview-link-service.js +5 -1
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +911 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +126 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +471 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +42 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +304 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/plugins/plugin-controller.d.ts +131 -0
- package/dist/server/modules/plugins/plugin-controller.js +277 -0
- package/dist/server/modules/plugins/plugin-controller.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +38 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +178 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-manifest.d.ts +8 -0
- package/dist/server/modules/plugins/plugin-manifest.js +420 -0
- package/dist/server/modules/plugins/plugin-manifest.js.map +1 -0
- package/dist/server/modules/plugins/plugin-permission-service.d.ts +49 -0
- package/dist/server/modules/plugins/plugin-permission-service.js +267 -0
- package/dist/server/modules/plugins/plugin-permission-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-process-runner.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-process-runner.js +127 -0
- package/dist/server/modules/plugins/plugin-process-runner.js.map +1 -0
- package/dist/server/modules/plugins/plugin-registry-service.d.ts +41 -0
- package/dist/server/modules/plugins/plugin-registry-service.js +238 -0
- package/dist/server/modules/plugins/plugin-registry-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-service.d.ts +55 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js +252 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js +83 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.d.ts +31 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js +232 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-static-service.d.ts +11 -0
- package/dist/server/modules/plugins/plugin-static-service.js +145 -0
- package/dist/server/modules/plugins/plugin-static-service.js.map +1 -0
- package/dist/server/modules/presentation/presentation-controller.d.ts +3 -0
- package/dist/server/modules/presentation/presentation-controller.js +11 -0
- package/dist/server/modules/presentation/presentation-controller.js.map +1 -1
- package/dist/server/modules/presentation/presentation-export-task-service.d.ts +6 -0
- package/dist/server/modules/presentation/presentation-export-task-service.js +52 -8
- package/dist/server/modules/presentation/presentation-export-task-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-pptx-export-service.js +200 -14
- package/dist/server/modules/presentation/presentation-pptx-export-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-renderer.d.ts +50 -0
- package/dist/server/modules/presentation/presentation-renderer.js +450 -37
- package/dist/server/modules/presentation/presentation-renderer.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +2 -0
- package/dist/server/modules/tasks/task-types.js +2 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/routes/files.js +40 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/plugins-public.d.ts +3 -0
- package/dist/server/routes/plugins-public.js +5 -0
- package/dist/server/routes/plugins-public.js.map +1 -0
- package/dist/server/routes/plugins.d.ts +3 -0
- package/dist/server/routes/plugins.js +19 -0
- package/dist/server/routes/plugins.js.map +1 -0
- package/dist/server/routes/presentation.js +1 -0
- package/dist/server/routes/presentation.js.map +1 -1
- package/dist/server/server/create-server.d.ts +20 -0
- package/dist/server/server/create-server.js +47 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +10 -6
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/shared/runtime/better-sqlite3.d.ts +5 -0
- package/dist/server/shared/runtime/better-sqlite3.js +6 -0
- package/dist/server/shared/runtime/better-sqlite3.js.map +1 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.d.ts +8 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js +49 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-definition-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js +84 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.d.ts +9 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js +74 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.d.ts +12 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js +142 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-run-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-run-repository.js +111 -0
- package/dist/server/storage/repositories/plugin-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js +86 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.d.ts +2 -2
- package/dist/server/storage/sqlite/client.js +250 -1
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +140 -0
- package/dist/server/types/domain.d.ts +122 -0
- package/package.json +10 -3
- package/scripts/postinstall.mjs +248 -11
- package/vendor/better-sqlite3-win32-x64-node22/LICENSE +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.upstream.md +99 -0
- package/vendor/better-sqlite3-win32-x64-node22/binding.gyp +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/build/Release/better_sqlite3.node +0 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/common.gypi +68 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/copy.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/defines.gypi +41 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/download.sh +122 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/patches/1208.patch +15 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.c +265994 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.h +13968 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3ext.h +730 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3.gyp +80 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/test_extension.c +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/database.js +90 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/index.js +3 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/aggregate.js +43 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/backup.js +67 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/function.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/inspect.js +7 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/pragma.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/serialize.js +16 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/table.js +189 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/transaction.js +78 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/wrappers.js +54 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/sqlite-error.js +20 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/util.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/package.json +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/scripts/verify-runtime.cjs +42 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/addon.cpp +47 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/better_sqlite3.cpp +74 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.cpp +120 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.hpp +36 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.cpp +417 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.hpp +103 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.cpp +113 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.hpp +50 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.cpp +383 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.hpp +58 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/bind-map.cpp +73 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/binder.cpp +193 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/constants.cpp +172 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-aggregate.cpp +121 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-function.cpp +59 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-table.cpp +409 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data-converter.cpp +17 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data.cpp +194 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/helpers.cpp +109 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/macros.cpp +83 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/query-macros.cpp +71 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/row-builder.cpp +49 -0
- package/vendor/node-pty-fork/README.md +1 -0
- package/vendor/node-pty-fork/scripts/runtime-install-context.cjs +24 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.cjs +8 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +30 -0
- package/vendor-src/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/dist/public/assets/App-B0q8uDA-.js +0 -30
- package/dist/public/assets/DesktopWindowPage-BdKUZrKG.js +0 -2
- package/dist/public/assets/FileContextPanel-lM5mBcfn.js +0 -1
- package/dist/public/assets/GitSidebar-CmXAhyjo.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-CceV0-AH.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DhaM9fgx.js +0 -1
- package/dist/public/assets/ServerSettingsModal-Rkgn3jft.js +0 -1
- package/dist/public/assets/SessionIndexPage-BOumP3ij.js +0 -1
- package/dist/public/assets/SettingsPage-vx_c-00-.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-D9JHCS6d.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-W5NjqFEz.js +0 -1
- package/dist/public/assets/ToolFilesPage-DWtpaN_7.js +0 -1
- package/dist/public/assets/ToolGitPage-MpGXsw4_.js +0 -1
- package/dist/public/assets/ToolProcessesPage-B1jHQKhZ.js +0 -1
- package/dist/public/assets/ToolsHomePage-CJrn8ZFl.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CJQ1V5U-.js +0 -1
- package/dist/public/assets/WorkbenchLayout-D48i71PU.js +0 -244
- package/dist/public/assets/WorkbenchModal-BYNuMIoV.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-CGKjy4J-.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-DCAYgays.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D5v-nUIi.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-I5G1p5SR.js +0 -1
- package/dist/public/assets/file-tree-icon-BFwaPxKs.js +0 -590
- package/dist/public/assets/index-CjewzOUG.js +0 -42
- package/dist/public/assets/model-switch-api-Br0ivfe5.js +0 -1
- package/dist/public/assets/realtime-client-BlQRqVmm.js +0 -1
- package/dist/public/assets/useRegisteredDebugTemplates-CXmxu69X.js +0 -1
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-lM5mBcfn.js","assets/index-CjewzOUG.js","assets/index-VVxfF0s5.css","assets/App-B0q8uDA-.js","assets/App-CcDXqFl1.css","assets/model-switch-api-Br0ivfe5.js","assets/WorkbenchModal-BYNuMIoV.js","assets/file-tree-icon-BFwaPxKs.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-D7OgZZN-.js","assets/GitSidebar-CmXAhyjo.js","assets/TerminalManagerPanel-D9JHCS6d.js","assets/terminal-runtime-meta-BCtAYB0E.js","assets/TerminalRuntimeFallbackModal-W5NjqFEz.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var qk=Object.defineProperty;var Gk=(e,t,n)=>t in e?qk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var at=(e,t,n)=>Gk(e,typeof t!="symbol"?t+"":t,n);import{C as pe,t as l,b as f,j as s,e as ar,m as ca,H as pu,J as Of,F as Vk,K as Kk,w as fu,A as mu,g as Wf,D as Yk,p as Zo,L as Xk,M as Jk,N as Ff,i as $f,O as Tc,f as gu,h as Ic,P as Qk,l as zf,y as Zk,n as ey,z as ty,d as ny,_ as bu}from"./index-CjewzOUG.js";import{m as vt,e as $n,h as el,u as xa,f as lr,g as Fr,i as ry,j as sy,O as gd}from"./App-B0q8uDA-.js";import{e as ku,f as Mn,i as mi,j as Jt,k as $a,V as Ro,A as iy,h as Lt,v as Ss,a2 as bd,a3 as ay,a4 as oy,H as Hf,l as ly,m as cy,a5 as Uf,a6 as uy,M as dy,a7 as hy,a8 as py,n as fy,o as my,t as gy,q as by,s as qf,a as Ec,p as yu,a9 as ky,aa as yy,ab as xy,u as za,g as wy,ac as vy,ad as Sy,ae as Cy,af as Gf,ag as Ny,ah as Vf,ai as jy,aj as Ty,ak as Kf,K as Iy,S as Ey,R as kd,r as My,al as Ry}from"./model-switch-api-Br0ivfe5.js";import{t as ui,P as Po,g as Yf}from"./window-BVUB8gMK.js";import{R as Py,_ as yd,a as xd,C as Xf,i as ze}from"./event-DvH9tcej.js";import{W as St,M as Ay,D as xu}from"./WorkbenchModal-BYNuMIoV.js";import{r as Ly,b as _y}from"./relay-entry-D7OgZZN-.js";const di=new Map,Jf=48;function As(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function wd(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Dy(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function Qf(e){try{const t=JSON.parse(e);return Dy(t)?t:null}catch{return null}}function By(){if(!As())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 Zf(){if(!As())return[];const e=[];for(const t of By()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=Qf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function ua(e){if(As())try{window.sessionStorage.removeItem(e)}catch{}}function Ha(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??Jf,r=Zf().filter(a=>!t.has(a.key)),i=Math.max(0,t.size+r.length-n);for(let a=0;a<i;a+=1){const o=r[a];if(!o)break;ua(o.key)}}function Oy(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Ll(e,t){if(!As())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return Oy(n)?"quota_exceeded":"failed"}}function Wy(e,t){const n=Ll(e,t);if(n==="success"){Ha({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(ua(e),Ha({maxCount:Math.max(0,Jf-1)}),Ll(e,t)==="success"){Ha({preserveKeys:[e]});return}for(const r of Zf())if(r.key!==e&&(ua(r.key),Ll(e,t)==="success")){Ha({preserveKeys:[e]});return}}}function Ao(e,t){const n=di.get(e);if(n){if(!wd(n.savedAt,t))return n.value;di.delete(e)}if(!As())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=Qf(r);return!i||wd(i.savedAt,t)?(ua(e),di.delete(e),null):(di.set(e,i),i.value)}function ra(e,t){const n={savedAt:Date.now(),value:t};if(di.set(e,n),!!As())try{Wy(e,JSON.stringify(n))}catch{}}function XA(e){di.delete(e),As()&&ua(e)}const Fy="codingns.debug.perf",$y="codingns.debug.sessionMessageDedup",zy="codingns.debug.timelineScroll",Hy="codingns.debug.conversationTimeline";function Uy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fy)==="1"}catch{return!1}}function un(e,t){if(!Uy()||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 qy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem($y)==="1"}catch{return!1}}function os(e,t){if(!qy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,a=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];a.push(r),a.length>300&&a.splice(0,a.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=a}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 Gy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Hy)==="1"}catch{return!1}}function Vy(e,t){if(!Gy()||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 a=i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__??[];a.push(r),a.length>400&&a.splice(0,a.length-400),i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=a}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 Mc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(zy)==="1"}catch{return!1}}function Ky(e,t){if(!Mc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,a=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];a.push(r),a.length>300&&a.splice(0,a.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=a}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 em(e){return pe.request(`/api/office/artifacts/${encodeURIComponent(e)}/preview-link`)}function tm(e,t){return pe.request(`/api/office/tasks/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/preview-link`)}function JA(e,t){const n=new URLSearchParams({workspaceId:e});return t&&n.set("path",t),pe.request(`/api/files/tree?${n.toString()}`)}function QA(e,t,n,r){return pe.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function ZA(e){return pe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function eL(e){return pe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function tL(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/download?${n.toString()}`)}function Yy(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return pe.request(`/api/files/search?${i.toString()}`)}function nL(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/preview?${n.toString()}`)}function nm(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/preview-link?${n.toString()}`)}function rL(e){return pe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function sL(e){return pe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function iL(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return pe.request(`/api/git/diff?${r.toString()}`)}function aL(e,t){return pe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function oL(e,t){return pe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function lL(e,t){return pe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function cL(e,t){return pe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function uL(e,t){return pe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function dL(e){return pe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function hL(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),pe.request(`/api/git/history?${r.toString()}`)}function pL(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return pe.request(`/api/git/commit-detail?${n.toString()}`)}function Xy(e){return pe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Jy(e){return pe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function fL(e,t,n){return pe.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function mL(e,t,n,r,i){return pe.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function gL(e){return pe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var Co,No;function rm(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:rm(n));else if("action"in e&&e.action){const n=new Xf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function Si(e,t){const n=new Xf;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=ui(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=ui(t.icon)),"items"in t&&t.items)){let r=function(i){var a;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((a=i.item.About)===null||a===void 0)&&a.icon)&&(i.item.About.icon=ui(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=ui(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),rm(i))};t.items=t.items.map(r)}return ze("plugin:menu|new",{kind:e,options:t,handler:n})}class Ci extends Py{get id(){return yd(this,Co,"f")}get kind(){return yd(this,No,"f")}constructor(t,n,r){super(t),Co.set(this,void 0),No.set(this,void 0),xd(this,Co,n),xd(this,No,r)}}Co=new WeakMap,No=new WeakMap;class wu extends Ci{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return Si("MenuItem",t).then(([n,r])=>new wu(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 vu extends Ci{constructor(t,n){super(t,n,"Check")}static async new(t){return Si("Check",t).then(([n,r])=>new vu(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 vd;(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"})(vd||(vd={}));class Su extends Ci{constructor(t,n){super(t,n,"Icon")}static async new(t){return Si("Icon",t).then(([n,r])=>new Su(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:ui(t)})}}class Cu extends Ci{constructor(t,n){super(t,n,"Predefined")}static async new(t){return Si("Predefined",t).then(([n,r])=>new Cu(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 gi([e,t,n]){switch(n){case"Submenu":return new tl(e,t);case"Predefined":return new Cu(e,t);case"Check":return new vu(e,t);case"Icon":return new Su(e,t);case"MenuItem":default:return new wu(e,t)}}class tl extends Ci{constructor(t,n){super(t,n,"Submenu")}static async new(t){return Si("Submenu",t).then(([n,r])=>new tl(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(gi)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(gi))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?gi(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 Po?t:t?new Po(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:ui(t)})}}class hi extends Ci{constructor(t,n){super(t,n,"Menu")}static async new(t){return Si("Menu",t).then(([n,r])=>new hi(n,r))}static async default(){return ze("plugin:menu|create_default").then(([t,n])=>new hi(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(gi)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(gi))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?gi(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 Po?t:t?new Po(t):null})}async setAsAppMenu(){return ze("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new hi(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 hi(r[0],r[1]):null)}}async function Qy(e){if(e.length===0)return;await(await hi.new({items:await Promise.all(e.map(n=>sm(n)))})).popup(void 0,Yf())}async function sm(e){return"items"in e?tl.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>sm(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const Sd={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},Zy=2600,im="workbench.parallel.pane.palette";let ii=null;const Cd=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function ex(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function am(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function tx(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=Sd[t]??Sd["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function bL(e){const t=Lo(e.overrideColor)??nx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":Nd(t,.08),"--parallel-group-surface":Nd(t,.03)}}function kL(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=om();return Lo(n[t]??null)}function yL(e,t){if(typeof window>"u")return Lo(t);const n=e.trim();if(!n)return null;const r=om(),i=Lo(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(im,JSON.stringify(r)),i}function nx(e,t){const n=Cd.length,r=Math.abs(lx(e))%n;return Cd[(r+t*5)%n]}function xL(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function rx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function wL(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function vL(e){var n,r,i;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function sx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function ix(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function ax(e,t="create"){ii={groupId:e,createdAt:Date.now(),...ex(t)}}function ox(e){return!ii||ii.groupId!==e?null:Date.now()-ii.createdAt>Zy?(ii=null,null):ii}function om(){if(typeof window>"u")return{};const e=window.localStorage.getItem(im);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function lx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function Lo(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function Nd(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),a=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${i}, ${a}, ${n})`}function Nu(e,t){const n=new Map(e.map(a=>[t.getId(a),a])),r=new Map,i=[];for(const a of e){const o=cx(a,n,t);if(!o){i.push(a);continue}const c=r.get(o)??[];r.set(o,[...c,a])}return[...i].sort(t.compare).map(a=>um(a,0,r,t,new Set))}function Ni(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function lm(e){return e.flatMap(t=>[t.item,...lm(Ni(t))])}function Ns(e){return e.flatMap(t=>[t,...Ns(Ni(t))])}function ju(e,t){return e.some(n=>t(n.item)||ju(Ni(n),t))}function cm(e,t,n){return e?n(e.item)===t?!0:Ni(e).some(r=>cm(r,t,n)):!1}function ai(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const a=ai(Ni(r),t,n);if(cm(r,t,n)&&a.length>=0)return[i,...a]}return[]}function um(e,t,n,r,i){const a=r.getId(e),o=new Set(i);o.add(a);const c=[...n.get(a)??[]].filter(u=>!o.has(r.getId(u))).sort(r.compare).map(u=>um(u,t+1,n,r,o));return{item:e,depth:t,children:c}}function cx(e,t,n){const r=jd(n.getParentId(e));if(!r)return null;const i=t.get(r);if(!i)return null;const a=new Set([n.getId(e)]);let o=i;for(;o;){const c=n.getId(o);if(a.has(c))return null;a.add(c);const u=jd(n.getParentId(o));if(!u||(o=t.get(u),!o))return r}return r}function jd(e){const t=e==null?void 0:e.trim();return t||null}function xn(){return"/workspaces"}function Ir(e){return`/workspaces/${encodeURIComponent(e)}`}function dm(e){return`${Ir(e)}/debug`}function xi(e){return`${Ir(e)}/sessions`}function ir(e,t){return`${xi(e)}/${encodeURIComponent(t)}`}function hm(e,t){const n=`${Ir(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function pm(e){return`${Ir(e)}/tools/files`}function fm(e){return`${Ir(e)}/tools/git`}function mm(e){return`${Ir(e)}/tools/processes`}function js(e){return`${Ir(e)}/terminals`}function Ms(e,t){const n=`${Ir(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function ux(e){return km(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...bm(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function SL(e,t){return Nu(km(e),{getId:n=>n.session.sessionId,getParentId:n=>dx(n.session,t),compare:px})}function dx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:am(e)}function gm(e,t){const n=hx(),r=new URLSearchParams({provider:t});return`${ir(e,n)}?${r.toString()}`}function hx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function px(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function bm(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...bm(t.children)])}function km(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}const fx="mobile.tools.last-primary-tool";function ym(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(fx)==="git"?"git":"files"}catch{return"files"}}function Tu(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 a=vt(i.pattern,e),o=((r=a==null?void 0:a.params.workspaceId)==null?void 0:r.trim())??null;if(o)return{workspaceId:o,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(vt(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function mx(e,t){const n=Tu(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":ym()}function Iu(e,t){const n=Tu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?js(n.workspaceId):n!=null&&n.workspaceId?hm(n.workspaceId,mx(e,t)):n!=null&&n.legacy?ym()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Eu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const a=Tu(n);return a?a.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(a.routeKind==="home"||a.routeKind==="files"||a.routeKind==="git",null):null}const xm=f.createContext({composerPortalTarget:null});function Mu({composerPortalTarget:e,children:t}){return s.jsx(xm.Provider,{value:{composerPortalTarget:e},children:t})}function CL(){return f.useContext(xm)}function Ru(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const a=e.current,o=t.current;if(!n||!a||!o){i(void 0),a&&a.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=a,u=o;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 gx=3e3,Ua=10,Td=84,Id=.36;function Pu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),a=f.useRef(null),o=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{o.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function g(){xs(i),i.current=window.setTimeout(()=>{m()},gx)}function m(){d("hidden"),p(0)}function y(){d("visible"),p(1),g()}f.useEffect(()=>{if(xs(i),!e){xs(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return y(),()=>{xs(i)}},[e,r,n]),f.useEffect(()=>()=>{xs(i)},[]),f.useEffect(()=>{if(!e||n){a.current=null;return}const j=t.current;if(!j)return;function x(z){if(z.touches.length!==1){a.current=null;return}const L=z.touches[0],E=Rd(z.target);if(!L||!E){a.current=null;return}a.current={surface:E,startX:L.clientX,startY:L.clientY,pointerType:"touch",initialState:o.current==="visible"?"visible":"hidden",touchId:L.identifier,dragging:!1,latestProgress:c.current},o.current==="visible"&&xs(i)}function A(z){const L=a.current;if(!L||L.pointerType!=="touch")return;const E=_l(z.touches,L.touchId);if(!E)return;const H=E.clientX-L.startX,B=E.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(B)<=Ua||Math.abs(B)<=Math.abs(H))return;a.current=null,L.initialState==="visible"&&m();return}const oe=L.initialState==="hidden"?-B:B;oe<=Ua&&!L.dragging||(Ad(z),L.dragging=!0,L.latestProgress=Ed(L.initialState,oe),d("dragging"),p(L.latestProgress))}function T(z){const L=a.current;if(!(!L||L.pointerType!=="touch"||!_l(z.changedTouches,L.touchId))){if(a.current=null,!L.dragging){L.initialState==="visible"&&g();return}Md(L.initialState,L.latestProgress,y,d,p)}}function F(z){const L=a.current;if(!(!L||L.pointerType!=="touch"||!_l(z.changedTouches,L.touchId))){if(a.current=null,!L.dragging){L.initialState==="visible"&&g();return}if(L.initialState==="visible"){y();return}d("hidden"),p(0)}}function R(z){if(z.pointerType!=="touch")return;const L=Rd(z.target);if(!L){a.current=null;return}if(a.current={surface:L,startX:z.clientX,startY:z.clientY,pointerType:"pointer",initialState:o.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{}o.current==="visible"&&xs(i)}function I(z){const L=a.current;if(!L||L.pointerType!=="pointer")return;const E=z.clientX-L.startX,H=z.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(H)<=Ua||Math.abs(H)<=Math.abs(E))return;a.current=null,L.initialState==="visible"&&m();return}const B=L.initialState==="hidden"?-H:H;B<=Ua&&!L.dragging||(Ad(z),L.dragging=!0,L.latestProgress=Ed(L.initialState,B),d("dragging"),p(L.latestProgress))}function G(z){const L=a.current;if(!(!L||L.pointerType!=="pointer"||L.pointerId!==z.pointerId)){if(a.current=null,bx(L),!L.dragging){L.initialState==="visible"&&g();return}Md(L.initialState,L.latestProgress,y,d,p)}}return j.addEventListener("touchstart",x,{passive:!0}),j.addEventListener("pointerdown",R,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",T),window.addEventListener("touchcancel",F),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),()=>{j.removeEventListener("touchstart",x),j.removeEventListener("pointerdown",R),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",T),window.removeEventListener("touchcancel",F),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function xs(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function Ed(e,t){return Pd(e==="hidden"?t/Td:1-t/Td,0,1)}function Md(e,t,n,r,i){if(e==="hidden"){if(t>=Id){n();return}r("hidden"),i(0);return}if(t<=1-Id){r("hidden"),i(0);return}n()}function bx(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 _l(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 Rd(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 Pd(e,t,n){return Math.min(Math.max(e,t),n)}function Ad(e){e.cancelable&&e.preventDefault()}function wa({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 nl(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function wm(e){return e==="medium-navigation"||e==="expanded"}function vm(e){return e==="medium-auxiliary"||e==="expanded"}function Au({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:a,navigationPanel:o,auxiliaryPanel:c}){const u=wa({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=wm(u)&&o,h=vm(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:o}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:a}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function kx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=t==="conversation-focus",F=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),R=Pu({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),G=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.androidMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(wx,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(vx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Cx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Sx,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Nx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;Ru(S,j,T);function E(){const B=Iu(m.pathname,m.search);if(!B){o();return}y(B,{replace:!0})}const H=s.jsx("nav",{ref:j,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(Mu,{composerPortalTarget:T?x: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?R.isOpen:!0,"data-conversation-tabbar-state":T?R.state:"default",style:L,children:[G?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[G.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:E,children:s.jsx(yx,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:G.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(xx,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(Au,{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:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function yx(){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 xx(){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 wx(){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 vx(){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 Sx(){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 Cx(){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 Nx(){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 jx=120,Xi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Rc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Tx(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 Ix(){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(Rc);return e.length>0?Math.max(...e):0}function Ld(){if(typeof window>"u")return Xi;const e=window.visualViewport,t=Ix(),n=(e==null?void 0:e.height)??t,r=Rc(n)?Math.round(n):null,i=Rc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,a=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:a,keyboardOpen:Tx(typeof document<"u"?document.activeElement:null)&&a>=jx}}function Dl(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 Ex(e){const[t,n]=f.useState(()=>e?Ld():Xi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Xi),Dl(!1,Xi);return}function i(){n(Ld())}function a(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const o=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),o==null||o.addEventListener("resize",i),o==null||o.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",a),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),o==null||o.removeEventListener("resize",i),o==null||o.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",a),Dl(!1,Xi)}},[e]),f.useEffect(()=>{Dl(e,t)},[e,t]),t}function Mx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=t==="conversation-focus",F=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),R=Pu({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),G=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Ax,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Lx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Dx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(_x,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Bx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;Ru(S,j,T);function E(){const B=Iu(m.pathname,m.search);if(!B){o();return}y(B,{replace:!0})}const H=s.jsx("nav",{ref:j,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(Mu,{composerPortalTarget:T?x: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?R.isOpen:!0,"data-conversation-tabbar-state":T?R.state:"default",style:L,children:[G?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:G.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:E,children:[s.jsx(Rx,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:G.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(Px,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(Au,{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:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Rx(){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 Px(){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 Ax(){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 Lx(){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 _x(){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 Dx(){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 Bx(){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 Ox(e){const t=$n();return t.platform==="ios"?s.jsx(Mx,{...e}):t.platform==="android"?s.jsx(kx,{...e}):s.jsx(Wx,{...e})}function Wx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=Ex(p.platform==="web"),F=p.platform==="web"&&T.keyboardOpen,R=t==="conversation-focus",I=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),G=Pu({enabled:R,rootRef:S,suspended:F,resetKey:`${m.pathname}${m.search}`}),z=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),L=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),E=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(zx,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Hx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(qx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Ux,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Gx,{}),onClick:h}],H=R?{"--mobile-conversation-tabbar-progress":G.progress.toFixed(4)}:void 0;Ru(S,j,R);function B(){const K=Iu(m.pathname,m.search);if(!K){o();return}y(K,{replace:!0})}const oe=s.jsx("nav",{ref:j,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:F,children:E.map(K=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":K.key===e,"aria-current":K.key===e?"page":void 0,onClick:()=>{K.key!==e&&g.trigger("selection"),K.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:K.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:K.label})]},K.key))});return s.jsx(Mu,{composerPortalTarget:R?x: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:R?G.isOpen:!0,"data-conversation-tabbar-state":R?G.state:"default",style:H,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(Fx,{})}):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($x,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),R?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:oe})]}):oe]})})}function Fx(){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 $x(){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 zx(){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 Hx(){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 qx(){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 Gx(){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 Vx{constructor(t){at(this,"maxAttempts");at(this,"baseDelayMs");at(this,"reconnectAttempts",0);at(this,"reconnectTimer",null);at(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(!ar.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 Kx{constructor(t){at(this,"socket",null);at(this,"disposed",!1);at(this,"authRecoveryInFlight",!1);at(this,"pendingRefresh",!1);at(this,"workbenchKnownRevision");at(this,"lastWorkbenchSnapshot",null);at(this,"fileTreeSubscription",null);at(this,"gitSubscription",null);at(this,"terminalManagerSubscription",null);at(this,"workspaceManagementSubscription",null);at(this,"pendingFileTreeRefresh",null);at(this,"pendingGitRefresh",null);at(this,"pendingTerminalManagerRefresh",null);at(this,"pendingWorkspaceManagementRefresh",null);at(this,"fileTreeRevisionByPath",new Map);at(this,"gitRevisionByWorkspaceId",new Map);at(this,"terminalManagerRevisionByWorkspaceId",new Map);at(this,"workspaceManagementRevisionByWorkspaceId",new Map);at(this,"fileTreeListeners",new Set);at(this,"gitListeners",new Set);at(this,"terminalManagerListeners",new Set);at(this,"workspaceManagementListeners",new Set);at(this,"workbenchSubscribeStartedAtMs",null);at(this,"workbenchRefreshStartedAtMs",null);at(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new Vx({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!_d(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=Vn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=Vn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:Dd(n),knownRevisionByPath:Bl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Ol(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=Dd(n),a={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Ol(t,i,Bl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(a)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Bl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:Vn(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:Vn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:Vn(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:Vn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:Vn(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:Vn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:Vn(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=ca.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=pu(),i=Of(r),a=i.baseUrl,o=`${Vk("/ws",a)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:a,url:o});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:a}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Ol(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,y,S,j,x,A,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?Jx(h.snapshot):0,subscribeDurationMs:qa(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qa(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:qa(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qa(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const R=Xx(this.lastWorkbenchSnapshot,h);if(!R){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=R,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(R);return}if(h.type==="fileTree.snapshot"){const R=h.snapshot;if(R)R.revision=h.revision,this.fileTreeRevisionByPath.set(Pc(R.workspaceId,R.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(Pc(this.fileTreeSubscription.workspaceId,I),h.revision);if(!R)return;(y=(m=this.options).onFileTreeSnapshot)==null||y.call(m,R),this.fileTreeListeners.forEach(I=>I(R));return}if(h.type==="git.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.gitRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!R)return;(j=(S=this.options).onGitSnapshot)==null||j.call(S,R),this.gitListeners.forEach(I=>I(R));return}if(h.type==="terminalManager.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!R)return;(A=(x=this.options).onTerminalManagerSnapshot)==null||A.call(x,R),this.terminalManagerListeners.forEach(I=>I(R));return}if(h.type==="workspaceManagement.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!R)return;(F=(T=this.options).onWorkspaceManagementSnapshot)==null||F.call(T,R),this.workspaceManagementListeners.forEach(I=>I(R));return}h.type==="workbench.snapshot"&&h.snapshot&&Yx(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(),ca.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 _d(n)?(n.send(JSON.stringify(t)),!0):!1}}function _d(e){return e!==null&&e.readyState===1}function Yx(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Dd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Vn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Xx(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 a=n.get(i);if(!a)return null;r.push(a)}return{revision:t.revision,items:r}}function Bl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),Vn(n)]).filter(t=>t[1]!==null)):{}}function Ol(e,t,n,r){const i=t.map(a=>{const o=a.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[o,n[o]??r.get(Pc(e,o))??null]}).filter(a=>!!a[1]);if(i.length!==0)return Object.fromEntries(i)}function Pc(e,t){return`${e}::${t}`}function Jx(e){return e.items.reduce((t,n)=>t+n.sessions.length+Sm(n.childWorktrees??[]),0)}function Sm(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,a=Array.isArray(r.children)?Sm(r.children):0;return t+i+a},0)}function qa(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const Bd=6,Qx=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function Zx(e){return e instanceof HTMLElement?!e.closest(Qx):!0}function Ac(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&Zx(n)}function Cm(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Nm(e){return Cm(e)?"":void 0}function ew(e){if(!Ac(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",a),window.removeEventListener("mouseup",o),window.removeEventListener("blur",c))},a=u=>{Math.abs(u.clientX-t)<Bd&&Math.abs(u.clientY-n)<Bd||(i(),tw())},o=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",o),window.addEventListener("blur",c)}async function tw(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await Yf().startDragging()}const _o=.78,nw=1;function rw(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function jm(e,t,n,r){const i=Math.hypot(n-e,r-t),a=Math.min(1,i/120);return _o+(nw-_o)*a}function is(e){return Math.round(Number.isFinite(e)?e:0)}function sw(e){if(!rw())return null;const t=is(e.x),n=is(e.y);let r=!1,i=Promise.resolve();const a=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),o=async()=>{r||(r=!0,await a("close_detach_preview"))};return a("show_detach_preview",{title:e.title,x:t,y:n,scale:_o}),{updatePosition(c,u){if(r)return;const d=is(c),h=is(u);a("update_detach_preview_position",{x:d,y:h,scale:jm(t,n,d,h)})},complete(){return o()},cancel(){return o()}}}function iw(e){if(typeof document>"u")return null;const t=is(e.x),n=is(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",_o.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const a=document.createElement("strong");a.className="desktop-window-detach-animation-title",a.textContent=e.title;const o=document.createElement("div");o.className="desktop-window-detach-animation-body",i.append(a),r.append(i,o),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=is(d),g=is(h),m=jm(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 Od(e){return sw(e)??iw(e)}const aw={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 ow(e){return{...e,bounds:{...e.bounds}}}function lw(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function cw(e){return aw[e]}function Tm(e,t){return`${e}-${t}`}async function rl(e,t,n){const r=n.workspaceId.trim(),i=cw(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 a=Tm(t,r),o=e.windows.getDescriptor(a),c=o?ow(o):null,u=e.windows.isWindowOpen(a),d=Kk({windowId:a,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(a),{ok:!0,value:d}):(c?lw(e,c,u):e.windows.removeWindow(a),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function NL(e){return Tm("terminals",e)}function uw(e,t){return rl(e,"files",t)}function dw(e,t){return rl(e,"git",t)}function hw(e,t){return rl(e,"processes",t)}function jL(e,t){return rl(e,"terminals",t)}async function Wd(){return await pe.request("/api/skills/overview")}async function pw(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 pe.request(`/api/skills/workspace-session-mcp-status?${t.toString()}`)}async function fw(e){await pe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function mw(e){await pe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function gw(e){await pe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Fd(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 $d(e="active"){const t=new URLSearchParams({status:e});return(await pe.request(`/api/office/document-templates?${t.toString()}`)).items}async function zd(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 pe.request(`/api/office/browser/profiles${n}`)).items}async function bw(e){return await pe.request("/api/office/browser/profiles",{method:"POST",body:JSON.stringify(e)})}async function kw(e,t){return await pe.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function yw(e){return await pe.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xw(e){return await pe.request("/api/office/document-templates/import-file",{method:"POST",body:JSON.stringify(e)})}async function Ga(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 pe.request(`/api/office/tasks${n}`)).items}async function Wl(e){return await pe.request(`/api/office/tasks/${encodeURIComponent(e)}`)}async function ww(e){return await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execute`,{method:"POST"})}async function Lc(e){return(await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution`)).task}async function Hd(){return await pe.request("/api/office/browser/bridge-status")}async function vw(e){return await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution/cancel`,{method:"POST"})}async function Sw(e,t){await pe.request(`/api/office/approvals/${encodeURIComponent(e)}/reply`,{method:"POST",body:JSON.stringify(t)})}async function Ud(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 pe.request(`/api/office/ops/targets${n}`)).items}async function Cw(e){return await pe.request("/api/office/ops/targets",{method:"POST",body:JSON.stringify(e)})}async function Nw(e,t){return await pe.request(`/api/office/ops/targets/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function jw(){return await pe.request("/api/opencli/catalog")}async function qd(){return await pe.request("/api/opencli/check",{method:"POST"})}async function Tw(e){return await pe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Fl="all",$l="status";function Iw({toolbarMode:e="internal",onToolbarStateChange:t}={}){var He,Ue,je,Te;const n=fu(O=>{var q;return((q=O.session)==null?void 0:q.accessToken)??null}),[r,i]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,y]=f.useState([]),[S,j]=f.useState(null),[x,A]=f.useState(null),[T,F]=f.useState(Fl),[R,I]=f.useState(null),[G,z]=f.useState(!1),[L,E]=f.useState(""),[H,B]=f.useState($l);f.useEffect(()=>{let O=!0;if(!n){i(null),g(!1),y([]),A(null),j(null),o(!1),F(Fl),I(null),z(!1),E(""),B($l);return}return(async()=>{o(!0),A(null),j(null);try{const J=await qd();if(!O)return;N(J)}catch(J){if(!O)return;const Ce=Ka(J);try{const Ee=await jw();if(!O)return;N(Ee),A(Ce)}catch(Ee){if(!O)return;A(Ka(Ee))}}finally{O&&o(!1)}})(),()=>{O=!1}},[n]);const oe=f.useMemo(()=>new Set(m),[m]),K=f.useMemo(()=>Rw((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),X=f.useMemo(()=>_w(),[]);f.useEffect(()=>{K.some(O=>O.id===T)||F(Fl)},[T,K]);const Y=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(O=>O.commands.some(q=>Gd(q,T,oe))),[T,r==null?void 0:r.siteGroups,oe]),D=f.useMemo(()=>R?Y.find(O=>O.site===R)??null:null,[R,Y]);f.useEffect(()=>{R&&!D&&I(null)},[R,D]),f.useEffect(()=>{E(""),B($l)},[R]);const V=f.useMemo(()=>{if(!D)return[];const O=L.trim().toLowerCase();return D.commands.filter(q=>Gd(q,T,oe)&&Aw(q,O)).sort((q,J)=>Lw(q,J,{sortId:H,selectedCommandIdSet:oe}))},[T,D,L,H,oe]),le=!!(r&&(r.provider.enabled!==p||r.entries.some(O=>O.enabled!==oe.has(O.commandId)))),C=f.useMemo(()=>({draftEnabled:p,enableDisabled:a||c||d,refreshDisabled:!n||a||c||d,detailDisabled:!r||a,saveDisabled:!n||a||c||d||!r||!le,refreshing:c,saving:d,onEnabledChange:be,onRefresh:()=>{_e()},onShowDetails:()=>z(!0),onSave:()=>{Z()}}),[n,r,m,p,le,a,c,d]);f.useEffect(()=>{t==null||t(C)},[t,C]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function _e(){if(n){u(!0),A(null),j(null);try{const O=await qd();N(O),j(Hw(O.refreshState,O.runtimeAvailability))}catch(O){A(Ka(O))}finally{u(!1)}}}async function Z(){if(n){h(!0),A(null),j(null);try{const O=await Tw({enabled:p,enabledCommandIds:m});N(O),j(Uw(O))}catch(O){A(Ka(O))}finally{h(!1)}}}function N(O){i(O),g(O.provider.enabled),y(O.entries.filter(q=>q.enabled).map(q=>q.commandId).sort((q,J)=>q.localeCompare(J))),A(null)}function be(O){g(O)}function ne(O,q){const J=O.commands.map(Ce=>Ce.commandId);y(Ce=>{const Ee=new Set(Ce);for(const ve of J)q?Ee.add(ve):Ee.delete(ve);return[...Ee].sort((ve,Tt)=>ve.localeCompare(Tt))})}function fe(O,q){y(J=>{const Ce=new Set(J);return q?Ce.add(O):Ce.delete(O),[...Ce].sort((Ee,ve)=>Ee.localeCompare(ve))})}const ue=(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(Ew,{state:C,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Va,{label:l("settings.opencliSummaryInstallState"),value:Yd(ue.installState)}),s.jsx(Va,{label:l("settings.opencliSummaryCatalogCount"),value:String(ue.catalogCount)}),s.jsx(Va,{label:l("settings.opencliSummaryEnabledCount"),value:String(m.length)}),s.jsx(Va,{label:l("settings.opencliSummaryBrowserCount"),value:String(ue.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,x?s.jsx("p",{className:"settings-release-status",children:x}):null,a?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:K.map(O=>{const q=T===O.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":q,"data-active":q?"true":"false",onClick:()=>F(O.id),children:O.label},O.id)})}),Y.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:Y.map(O=>{const q=Pw(O,oe),J=Dw(O.commands),Ce=Kd(O,{maxDescriptions:2}),Ee=Kd(O),ve=Em(O.site),Tt=R===O.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:O.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(O.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:O.site}),type:"checkbox",checked:q.allSelected,disabled:c||d,ref:nt=>{nt&&(nt.indeterminate=q.partialSelected)},onChange:nt=>ne(O,nt.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:Ee,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:(J.length>0?J:["unknown"]).slice(0,2).map(nt=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Pm(nt),children:Mm(nt)},`${O.site}:${nt}`))})})})]},O.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:qw(r)}),s.jsx(St,{open:G,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>z(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Mn,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx($a,{children:Yd(r.provider.installState)}),s.jsx($a,{children:Ww(r.provider.healthState)}),s.jsx($a,{children:$w(((He=r.activeRuntimeProfile)==null?void 0:He.status)??null)})]}),children:s.jsxs(mi,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(Jt,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(Jt,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(ue.catalogCount)})}),s.jsx(Jt,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(m.length)})}),s.jsx(Jt,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(ue.browserDependentCount)})}),s.jsx(Jt,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(Jt,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Fw(r.effectiveCatalogSource??null)})}),s.jsx(Jt,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Xd(r.provider.lastCheckedAt)})}),s.jsx(Jt,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Xd(r.provider.catalogRefreshedAt)})}),s.jsx(Jt,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(Jt,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(Jt,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(je=r.activeRuntimeProfile)!=null&&je.lastErrorDetail?s.jsx(Mn,{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:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:V.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>I(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Mn,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Im(D.commands).map(O=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:O},O))})}),s.jsx(Mn,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx($a,{children:l("settings.opencliCommandResultCount",{count:V.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:O=>E(O.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(O=>{const q=H===O.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":q,"data-active":q?"true":"false",onClick:()=>B(O.id),children:O.label},O.id)})})]})]})}),V.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:V.map(O=>s.jsx(Mw,{command:O,checked:oe.has(O.commandId),disabled:c||d,onToggle:fe},O.commandId))}):s.jsx(Ro,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ew({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 Mw({command:e,checked:t,disabled:n,onToggle:r}){const i=Em(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:a=>r(e.commandId,a.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":Pm(e.strategy),children:zw(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 Va({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 Rw(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:Mm(n)})}))]}function Gd(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 Pw(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 Aw(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
|
|
3
|
-
`).toLowerCase().includes(t):!0}function Lw(e,t,n){const r=Vd(e,n)-Vd(t,n);if(r!==0)return r;const i=e.name.localeCompare(t.name);return i!==0?i:e.commandId.localeCompare(t.commandId)}function Vd(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 _w(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function Im(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function Kd(e,t={}){const n=Im(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function Dw(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 Em(e){const t=Gw[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=Jd[Math.abs(Ow(e))%Jd.length];return{label:Bw(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function Bw(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 Ow(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function Ka(e){return e instanceof mu?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function Yd(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function Ww(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 Fw(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 $w(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 zw(e){return l("settings.opencliStrategyLabel",{strategy:Rm(e)})}function Mm(e){return l("settings.opencliStrategyShortLabel",{strategy:Rm(e)})}function Rm(e){switch(Am(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 Pm(e){return Am(e)}function Am(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function Hw(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function Uw(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function qw(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function Xd(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const Jd=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],Gw={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%)"}},Vw=[{id:"skills"},{id:"office"},{id:"ops"},{id:"opencli"}];function Kw({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n,workspaceId:r=null,sessionId:i=null}){const a=fu(w=>{var U;return((U=w.session)==null?void 0:U.accessToken)??null}),o=f.useRef(null),c=f.useRef(null),[u,d]=f.useState(null),[h,p]=f.useState([]),[g,m]=f.useState([]),[y,S]=f.useState([]),[j,x]=f.useState({}),[A,T]=f.useState(null),[F,R]=f.useState([]),[I,G]=f.useState([]),[z,L]=f.useState([]),[E,H]=f.useState(null),[B,oe]=f.useState(null),[K,X]=f.useState(null),[Y,D]=f.useState(null),[V,le]=f.useState(null),[C,_e]=f.useState(!1),[Z,N]=f.useState(null),[be,ne]=f.useState(null),[fe,ue]=f.useState(null),[He,Ue]=f.useState(!1),[je,Te]=f.useState(!1),[O,q]=f.useState(!1),[J,Ce]=f.useState(!1),[Ee,ve]=f.useState(!1),[Tt,nt]=f.useState(!1),[mt,ae]=f.useState(!1),[se,ke]=f.useState(!1),[ye,Me]=f.useState(!1),[$,Q]=f.useState(!1),[ge,Ne]=f.useState(null),[Be,Ke]=f.useState(!1),Ie=(ge==null?void 0:ge.simplified)??null,[ut,Qe]=f.useState(null),[rt,st]=f.useState("file"),[qe,gt]=f.useState("workspace"),[Ht,Ye]=f.useState(""),[dt,De]=f.useState(()=>zi("workspace")),[bt,Ze]=f.useState("skills"),[_t,_]=f.useState(null),[de,Re]=f.useState("all"),[xe,Se]=f.useState("ssh_host"),[ht,Bt]=f.useState({fileName:"",fileContentBase64:""}),[ft,Ot]=f.useState({displayName:"",engine:"chrome",mode:"persistent",ownershipScope:r!=null&&r.trim()?"workspace":"user",cdpEndpoint:""}),[et,ct]=f.useState({targetId:null,displayName:"",environment:"",host:"",port:"22",username:"",privateKeyPath:"",knownHostsPath:"",jumpHost:"",workspacePath:"",credentialRef:"",strictHostKeyChecking:"accept-new",status:"active"}),Ut=f.useId(),Ur=iy(He&&!!a).items??[],kt=f.useMemo(()=>bv(Ur),[Ur]),us=f.useMemo(()=>new Map(F.map(w=>[w.id,w])),[F]),gn=f.useMemo(()=>!ye||!(r!=null&&r.trim())?g:g.filter(w=>w.workspaceId===r),[g,ye,r]),cr=f.useMemo(()=>K?y.filter(w=>w.targetRefId===K.id):[],[y,K]);f.useEffect(()=>{let w=!0;if(!He)return;if(!a){d(null),ne(null),ue(null),_e(!1);return}return(async()=>{_e(!0);try{const[Pe,Xe,Cn,Lr,Yr,Nn,kn]=await Promise.all([Wd(),$d("active"),zd(),Ga({taskType:"browser",limit:100}),bd(),Ga({workspaceId:r,taskType:"ops",limit:20}),Ud({workspaceId:r,kind:"ssh_host"})]);if(!w)return;const kr=await oh(Lr),Je=await Hd().catch(()=>null);d(Pe),p(Xe),m(Cn),S(Lr),T(Je),x(kr),R(Yr.items),G(Nn),L(kn),X(null),D(null),le(null),ne(null)}catch(Pe){if(!w)return;ne(Xt(Pe))}finally{w&&_e(!1)}})(),()=>{w=!1}},[a,He,r]);async function Qt(){const[w,U,Pe,Xe,Cn,Lr,Yr]=await Promise.all([Wd(),$d("active"),zd(),Ga({taskType:"browser",limit:100}),bd(),Ga({workspaceId:r,taskType:"ops",status:de==="all"?void 0:de,limit:20}),Ud({workspaceId:r,kind:xe==="all"?void 0:xe})]),Nn=await oh(Xe),kn=await Hd().catch(()=>null);d(w),p(U),m(Pe),S(Xe),T(kn),x(Nn),R(Cn.items),G(Lr),L(Yr),ne(null)}async function Yn(){if(a){N("refresh"),ne(null),ue(null);try{await Qt(),ue(l("settings.skillRefreshSuccess"))}catch(w){ne(Xt(w))}finally{N(null)}}}async function Zt(){if(a){N("office-template-submit"),ne(null),ue(null);try{await xw({fileName:ht.fileName,fileContentBase64:ht.fileContentBase64}),Bt(Ja()),q(!1),ue(l("settings.skillOfficeTemplateImported")),await Qt()}catch(w){ne(Xt(w))}finally{N(null)}}}async function en(){if(a){N("browser-profile-submit"),ne(null),ue(null);try{await bw({workspaceId:r,displayName:ft.displayName.trim()||null,engine:ft.engine,mode:ft.mode,ownershipScope:ft.ownershipScope,cdpEndpoint:ft.mode==="cdp_attached"&&ft.cdpEndpoint.trim()||null}),Ot(Xa(r)),Ce(!1),ue(l("settings.skillOfficeBrowserProfileCreated")),await Qt()}catch(w){ne(Xt(w))}finally{N(null)}}}async function vn(w){var Pe;if(!a)return;const U=w.ownershipScope==="user"?"workspace":"user";if(U==="workspace"&&!((Pe=w.workspaceId)!=null&&Pe.trim())){ne(l("settings.skillOfficeBrowserProfileWorkspaceRequired"));return}N(`browser-profile-scope:${w.id}`),ne(null),ue(null);try{await kw(w.id,{ownershipScope:U}),await Qt(),ue(U==="user"?l("settings.skillOfficeBrowserProfileCrossWorkspaceEnabled"):l("settings.skillOfficeBrowserProfileWorkspaceOnlyEnabled"))}catch(Xe){ne(Xt(Xe))}finally{N(null)}}function Bs(w){H(w),ve(!0),ne(null)}function Vt(w){oe(w),nt(!0),ne(null)}async function Sn(){if(!a)return;const w=B;if(w){N(`browser-profile-delete:${w.id}`),ne(null),ue(null);try{await yw(w.id),(K==null?void 0:K.id)===w.id&&(ke(!1),X(null),D(null)),(E==null?void 0:E.id)===w.id&&(ve(!1),H(null)),nt(!1),oe(null),await Qt(),ue(l("settings.skillOfficeBrowserProfileDeleted"))}catch(U){ne(Xt(U))}finally{N(null)}}}async function yt(w){if(a){N(`browser-profile-tasks:${w.id}`),ne(null);try{X(w),D(null),ke(!0)}catch(U){ne(Xt(U))}finally{N(null)}}}async function Mr(w){if(a){N(`browser-task-detail:${w}`),ne(null);try{const[U,Pe]=await Promise.all([Wl(w),Lc(w)]);D(U),x(Xe=>({...Xe,[w]:Pe}))}catch(U){ne(Xt(U))}finally{N(null)}}}async function ur(w){if(a){N(`browser-task-execute:${w}`),ne(null),ue(null);try{await ww(w),await An(w),ue(l("settings.skillOfficeBrowserInstanceStarted"))}catch(U){ne(Xt(U))}finally{N(null)}}}async function dr(w){if(a){N(`browser-task-cancel:${w}`),ne(null),ue(null);try{await vw(w),await An(w),ue(l("settings.skillOfficeBrowserInstanceCancelled"))}catch(U){ne(Xt(U))}finally{N(null)}}}async function bn(w){if(a){N(`ops-task-detail:${w}`),ne(null);try{const U=await Wl(w);le(U)}catch(U){ne(Xt(U))}finally{N(null)}}}async function qr(w,U){if(a){N(`ops-approval:${w}:${U}`),ne(null);try{if(await Sw(w,{status:U,decisionNote:U==="approved"?l("settings.skillOpsApprovalApproveNote"):l("settings.skillOpsApprovalRejectNote")}),V){const Pe=await Wl(V.task.id);le(Pe)}await Qt(),ue(U==="approved"?l("settings.skillOpsApprovalApproved"):l("settings.skillOpsApprovalRejected"))}catch(Pe){ne(Xt(Pe))}finally{N(null)}}}async function Rr(){if(a){N("ops-target-submit"),ne(null),ue(null);try{const w={workspaceId:r,kind:"ssh_host",displayName:et.displayName.trim(),environment:et.environment.trim()||null,credentialRef:et.credentialRef.trim()||null,status:et.status,config:{host:et.host.trim(),port:Number.parseInt(et.port,10)||22,username:et.username.trim(),privateKeyPath:et.privateKeyPath.trim()||void 0,knownHostsPath:et.knownHostsPath.trim()||void 0,jumpHost:et.jumpHost.trim()||void 0,workspacePath:et.workspacePath.trim()||void 0,strictHostKeyChecking:et.strictHostKeyChecking}};et.targetId?(await Nw(et.targetId,w),ue(l("settings.skillOpsTargetUpdated"))):(await Cw(w),ue(l("settings.skillOpsTargetCreated"))),ct(Ya()),ae(!1),await Qt()}catch(w){ne(Xt(w))}finally{N(null)}}}async function hr(){if(!(!a||!(r!=null&&r.trim()))){Q(!0),Ke(!0),ne(null);try{const w=await pw({workspaceId:r,sessionId:i});Ne(w)}catch(w){ne(Xt(w)),Ne(null)}finally{Ke(!1)}}}function pr(w){const U=Lm(w.configJson);ct({targetId:w.id,displayName:w.displayName,environment:w.environment??"",host:rs(U.host),port:_m(U.port,22),username:rs(U.username),privateKeyPath:rs(U.privateKeyPath),knownHostsPath:rs(U.knownHostsPath),jumpHost:rs(U.jumpHost),workspacePath:rs(U.workspacePath),credentialRef:w.credentialRef??"",strictHostKeyChecking:nv(U.strictHostKeyChecking),status:w.status}),ae(!0)}function zn(){ct(Ya())}async function ds(w){var Pe;const U=((Pe=w.target.files)==null?void 0:Pe[0])??null;if(w.target.value="",!!U){ne(null),ue(null);try{Bt({fileName:U.name,fileContentBase64:await Lv(U)})}catch(Xe){ne(Xt(Xe))}}}function Gr(){Bt(Ja()),q(!0),ne(null)}function Ii(){Ot(Xa(r)),Ce(!0),ne(null)}function Os(){ct(Ya()),ae(!0),ne(null)}async function An(w){const U=await Lc(w);x(Pe=>({...Pe,[w]:U}))}async function hs(w){if(a){N(Qd(w)),ne(null),ue(null);try{await mw({targetCli:w.targetCli,directoryPath:w.directoryPath,expectedContentHash:w.contentHash}),await Qt(),ue(l("settings.skillImportSuccess",{name:w.name,target:Wn(w.targetCli)}))}catch(U){ne(Xt(U))}finally{N(null)}}}async function rn(w){if(!a)return;const U=w.bindings.filter(Pe=>Pe.enabled).map(Pe=>Pe.targetCli).filter(Pe=>pn(Pe,kt));if(U.length===0){ne(Nv(w.bindings));return}N(Zd(w.skill.id)),ne(null),ue(null);try{await gw({skillId:w.skill.id,targetCli:U}),await Qt(),ue(l("settings.skillSyncSuccess",{name:w.skill.name}))}catch(Pe){ne(Xt(Pe))}finally{N(null)}}async function fr(w){var Pe;const U=((Pe=w.target.files)==null?void 0:Pe[0])??null;if(w.target.value="",!!U){ne(null),ue(null);try{const Xe=await Av(U),Cn=Wm(U.name,Xe);Qe(Cn),De(zi(qe,kt))}catch(Xe){ne(Xt(Xe))}}}async function Pr(){const w=ih({sourceMode:rt,fileDraft:ut,pastedMarkdown:Ht});if(!a)return;if(!w){ne(rt==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const U=w.directoryName;if(!U){ne(l("settings.skillUploadDirectoryInvalid"));return}const Pe=Do(qe).filter(Xe=>dt[Xe]).filter(Xe=>pn(Xe,kt)).map(Xe=>Xe);if(Pe.length===0){ne(jv(qe,kt));return}N("upload"),ne(null),ue(null);try{await fw({markdownContent:w.rawContent,scope:qe,fileName:w.fileName,directoryName:U,targetCli:Pe}),await Qt(),ue(l("settings.skillUploadSuccess",{name:U})),Wt(qe),Te(!1)}catch(Xe){ne(Xt(Xe))}finally{N(null)}}function mr(w){gt(w),De(zi(w,kt))}function Ar(w){st(w),Qe(null),Ye(""),De(zi(qe,kt)),ne(null)}function sn(w){pn(w,kt)&&De(U=>({...U,[w]:!U[w]}))}function Mt(){Te(!0),ne(null),Wt(qe)}function an(){Te(!1),ne(null),Wt(qe)}function Wt(w){Qe(null),Ye(""),st("file"),De(zi(w,kt))}const on=(u==null?void 0:u.summary)??{managedSkillCount:0,managedEntryCount:0},gr=Ev((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(w=>!Om(w,(u==null?void 0:u.diagnostics)??[])),br=((u==null?void 0:u.diagnostics)??[]).filter(w=>!va(w)),Kt=ih({sourceMode:rt,fileDraft:ut,pastedMarkdown:Ht}),Kr=t??l("settings.skillManageAction"),Xn=bt==="skills",Ln=bt==="office",Jn=bt==="ops",Qn=bt==="opencli";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:e,type:"button","data-open":He?"true":"false","aria-haspopup":"dialog","aria-expanded":He,onClick:()=>{Ze("skills"),Ue(!0)},children:[n,s.jsx("span",{children:Kr})]}),s.jsxs(St,{open:He,title:l("settings.skillConfigModalTitle"),hideHeader:!0,className:"settings-skill-modal",onClose:()=>{Ze("skills"),Ue(!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:Vw.map(w=>{const U=bt===w.id,Pe=`${Ut}-${w.id}-tab`,Xe=`${Ut}-${w.id}-panel`;return s.jsx("button",{id:Pe,type:"button",role:"tab",className:"settings-model-tab","aria-selected":U,"aria-controls":Xe,"data-active":U?"true":"false",onClick:()=>Ze(w.id),children:tv(w.id)},w.id)})}),Xn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Mt,children:l("settings.skillCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:()=>{Yn()},children:Z==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Ln?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsxs("div",{className:"settings-skill-toolbar-status",role:"status",title:A?l("settings.skillOfficeBrowserBridgeSummaryDetail",{provider:A.provider,status:rh(A),detail:A.detail??l("settings.skillOfficeBrowserBridgeDetailReady")}):l("settings.skillOfficeBrowserBridgeAvailabilityUnknown"),children:[s.jsx("span",{className:"settings-skill-toolbar-status-dot","data-status":uv(A),"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:rh(A)})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Gr,children:l("settings.skillOfficeTemplateOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Ii,children:l("settings.skillOfficeBrowserProfileOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:()=>{Yn()},children:Z==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Jn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Os,children:l("settings.skillOpsTargetOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:()=>{Yn()},children:Z==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Qn&&_t?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:_t.draftEnabled,disabled:_t.enableDisabled,onChange:w=>_t.onEnabledChange(w.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:_t.refreshDisabled,onClick:_t.onRefresh,children:_t.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:_t.detailDisabled,onClick:_t.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:_t.saveDisabled,onClick:_t.onSave,children:_t.saving?l("common.loading"):l("settings.opencliSaveAction")})]}):null]}),s.jsx(Ay,{onClick:()=>{Ze("skills"),Ue(!1)}})]}),Xn?s.jsxs("div",{id:`${Ut}-skills-panel`,role:"tabpanel","aria-labelledby":`${Ut}-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(on.managedSkillCount)}),s.jsx(In,{label:l("settings.skillSummaryManagedEntries"),value:String(on.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"),": ",C?l("common.loading"):Iv(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(Or,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(u==null?void 0:u.managedSkills)??[],renderItem:w=>{const U=Zd(w.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:w.skill.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:vv(w.bindings)}),s.jsx("div",{className:"settings-skill-tags",children:w.bindings.map(Pe=>s.jsx("span",{className:"settings-skill-tag","data-status":xv(Pe,kt),children:wv(Pe,kt)},`${w.skill.id}-${Pe.targetCli}`))})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!yv(w.bindings,kt),onClick:()=>{rn(w)},children:Z===U?l("common.loading"):l("settings.skillSyncAction")})})]},w.skill.id)}}),s.jsx(Or,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(u==null?void 0:u.unmanagedEntries)??[],renderItem:w=>{const U=Qd(w);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:w.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:Sv(w,kt)}),pn(w.targetCli,kt)?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:C||Z!==null||!pn(w.targetCli,kt),onClick:()=>{hs(w)},children:Z===U?l("common.loading"):l("settings.skillImportAction")})})]},`${w.targetCli}:${w.directoryPath}`)}}),s.jsx(Or,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:gr,renderItem:w=>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:w.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"),": ",Bm(w.usedByTargetCli)]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:Mv(w.usageTag)}),w.usedByTargetCli.map(U=>s.jsx("span",{className:"settings-skill-tag","data-status":pn(U,kt)?"synced":"failed",children:pn(U,kt)?Wn(U):`${Wn(U)} · ${l("settings.skillTargetDisabledTag")}`},`${w.directoryName}:${U}`))]})]}),w.directoryName==="codingns-workspace-session"?s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!(r!=null&&r.trim()),onClick:()=>{hr()},children:l("settings.skillWorkspaceSessionMcpStatusAction")})}):null]},`${w.directoryName}:${w.sourcePath}`)}),s.jsx(Or,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:Vr,renderItem:w=>{const U=Rv(w,(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:w.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:Cv(w,kt)}),U.length>0?s.jsx("div",{className:"settings-skill-tags",children:U.map(Pe=>s.jsx("span",{className:"settings-skill-tag","data-status":Pe.status,children:Pe.label},Pe.key))}):null]})},`${w.targetCli}:${w.directoryPath}`)}}),s.jsx(Or,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:br,renderItem:w=>{const U=Pv(w),Pe=Tv(w);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}),U.length>0?s.jsx("div",{className:"settings-skill-tags",children:U.map(Xe=>s.jsx("span",{className:"settings-skill-tag","data-status":Xe.status,children:Xe.label},Xe.key))}):null]})},`${w.targetCli}:${w.code}:${w.directoryPath??w.rootDir}`)}})]}):null,Ln?s.jsxs("div",{id:`${Ut}-office-panel`,role:"tabpanel","aria-labelledby":`${Ut}-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(y.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(Or,{title:l("settings.skillOfficeTemplateListTitle"),description:l("settings.skillOfficeTemplateListDescription"),emptyText:l("settings.skillOfficeTemplateEmpty"),items:h,renderItem:w=>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:w.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeTemplateListMeta",{key:w.templateKey,version:w.templateVersion})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:w.engine}),s.jsx("span",{className:"settings-skill-tag","data-status":w.status==="active"?"synced":"failed",children:w.status})]})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("span",{className:"settings-skill-entry-meta",children:w.templateSourcePath??"-"})})]},w.id)}),s.jsx(Or,{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:w=>Me(w.target.checked)}),s.jsx("span",{children:l("settings.skillOfficeBrowserProfileOnlyCurrentWorkspace")})]}),items:gn,renderItem:w=>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:w.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeBrowserProfileListMeta",{engine:eh(w.engine),mode:rv(w.mode),scope:sv(w.ownershipScope)})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:eh(w.engine)}),s.jsx("span",{className:"settings-skill-tag","data-status":av(w.status),children:iv(w.status)}),s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:l("settings.skillOfficeBrowserProfileWorkspaceTag",{workspaceName:th(w.workspaceId,us)})}),w.ownershipScope==="user"?s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.skillOfficeBrowserProfileCrossWorkspaceTag")}):null,w.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:w.userDataDir??w.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:C||Z!==null,onClick:()=>{Bs(w)},children:l("settings.skillOfficeBrowserProfileOptionAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{yt(w)},children:Z===`browser-profile-tasks:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserProfileTaskAction")}),s.jsx("button",{className:"settings-button-danger",type:"button",disabled:C||Z!==null,onClick:()=>{Vt(w)},children:l("settings.skillOfficeBrowserProfileDeleteAction")})]})]},w.id)})]}):null,Jn?s.jsxs("div",{id:`${Ut}-ops-panel`,role:"tabpanel","aria-labelledby":`${Ut}-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(Or,{title:l("settings.skillOpsTaskListTitle"),description:l("settings.skillOpsTaskListDescription"),emptyText:l("settings.skillOpsTaskEmpty"),items:I,renderItem:w=>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:w.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOpsTaskListMeta",{status:w.status,risk:w.riskLevel})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:w.connectorId}),s.jsx("span",{className:"settings-skill-tag","data-status":sh(w.status),children:w.status})]}),(V==null?void 0:V.task.id)===w.id?s.jsx("div",{className:"settings-skill-tags",children:V.approvals.map(U=>s.jsx("span",{className:"settings-skill-tag","data-status":U.status==="pending"?"pending":U.status==="approved"?"synced":"failed",children:U.status},U.id))}):null]}),s.jsxs("div",{className:"settings-skill-entry-actions",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{bn(w.id)},children:Z===`ops-task-detail:${w.id}`?l("common.loading"):l("settings.skillOpsTaskDetailAction")}),(V==null?void 0:V.task.id)===w.id?V.approvals.filter(U=>U.status==="pending").map(U=>s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{qr(U.id,"approved")},children:Z===`ops-approval:${U.id}:approved`?l("common.loading"):l("settings.skillOpsApprovalApproveAction")},U.id)):null]})]},w.id)}),s.jsx(Or,{title:l("settings.skillOpsTargetListTitle"),description:l("settings.skillOpsTargetListDescription"),emptyText:l("settings.skillOpsTargetEmpty"),items:z,renderItem:w=>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:w.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:mv(w)}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:w.kind}),s.jsx("span",{className:"settings-skill-tag","data-status":w.status==="active"?"synced":"failed",children:w.status})]})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>pr(w),children:l("settings.skillOpsTargetEditAction")})})]},w.id)})]}):null,Qn?s.jsx("div",{id:`${Ut}-opencli-panel`,role:"tabpanel","aria-labelledby":`${Ut}-opencli-tab`,className:"settings-skill-panel",children:s.jsx(Iw,{toolbarMode:"external",onToolbarStateChange:_})}):null]}),s.jsx(St,{open:O,title:l("settings.skillOfficeTemplateModalTitle"),description:l("settings.skillOfficeTemplateModalDescription"),className:"settings-skill-create-modal",onClose:()=>{q(!1),Bt(Ja())},children:s.jsxs(Mn,{heading:l("settings.skillOfficeTemplateFormTitle"),children:[s.jsx("input",{ref:c,type:"file",accept:".domt,.doct,application/octet-stream",className:"settings-skill-upload-input",onChange:w=>{ds(w)}}),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:C||Z!==null,onClick:()=>{var w;return(w=c.current)==null?void 0:w.click()},children:l("settings.skillOfficeTemplatePickAction")})})}),ht.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:ht.fileName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeTemplateAutoDetectHint")})]})}):null,s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{q(!1),Bt(Ja())},children:l("common.cancel")}),s.jsx("button",{className:"primary-button",type:"button",disabled:!ht.fileName||C||Z!==null,onClick:()=>{Zt()},children:Z==="office-template-submit"?l("common.loading"):l("settings.skillOfficeTemplateSaveAction")})]})]})}),s.jsx(St,{open:J,title:l("settings.skillOfficeBrowserProfileModalTitle"),description:l("settings.skillOfficeBrowserProfileModalDescription"),className:"settings-skill-create-modal",onClose:()=>{Ce(!1),Ot(Xa(r))},children:s.jsxs(Mn,{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:ft.displayName,onChange:w=>Ot(U=>({...U,displayName:w.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:ft.engine,onChange:w=>Ot(U=>({...U,engine:w.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:ft.mode,onChange:w=>Ot(U=>({...U,mode:w.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:ft.ownershipScope,onChange:w=>Ot(U=>({...U,ownershipScope:w.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")})]})}),ft.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:ft.cdpEndpoint,onChange:w=>Ot(U=>({...U,cdpEndpoint:w.target.value}))})}):null,s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{Ce(!1),Ot(Xa(r))},children:l("common.cancel")}),s.jsx("button",{className:"primary-button",type:"button",disabled:C||Z!==null,onClick:()=>{en()},children:Z==="browser-profile-submit"?l("common.loading"):l("settings.skillOfficeBrowserProfileSaveAction")})]})]})}),s.jsx(St,{open:se,title:l("settings.skillOfficeBrowserProfileTaskModalTitle",{profileName:(K==null?void 0:K.displayName)??"-"}),description:l("settings.skillOfficeBrowserProfileTaskModalDescription"),className:"settings-skill-detail-modal",onClose:()=>{ke(!1),X(null),D(null)},children:s.jsx(Mn,{heading:l("settings.skillOfficeBrowserProfileTaskListTitle"),description:K?l("settings.skillOfficeBrowserProfileTaskListDescription",{workspaceName:th(K.workspaceId,us)}):void 0,children:cr.length===0?s.jsx(Ro,{title:l("settings.skillOfficeBrowserProfileTaskEmpty"),compact:!0}):s.jsx(mi,{children:cr.map(w=>{const U=j[w.id]??null,Pe=(Y==null?void 0:Y.task.id)===w.id;return s.jsxs(Jt,{className:"settings-browser-task-list-item",label:w.title,description:l("settings.skillOfficeBrowserInstanceListMeta",{profileName:(K==null?void 0:K.displayName)??"-",status:nh(U,w.status),risk:w.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:fv(w.createdAt)}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{Mr(w.id)},children:Z===`browser-task-detail:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceDetailAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!hv(w.status),onClick:()=>{ur(w.id)},children:Z===`browser-task-execute:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceExecuteAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!pv(U),onClick:()=>{dr(w.id)},children:Z===`browser-task-cancel:${w.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":sh(w.status),children:w.status}),s.jsx("span",{className:"settings-skill-tag","data-status":cv(Fd(w)),children:lv(Fd(w))}),s.jsx("span",{className:"settings-skill-tag","data-status":dv(U),children:nh(U,w.status)})]}),Pe?s.jsxs("div",{className:"settings-skill-entry-meta",children:[s.jsx("p",{children:U?l("settings.skillOfficeBrowserInstanceSnapshotMeta",{status:Dm(U.status),attempt:U.attempt,startedAt:ah(U.startedAt),finishedAt:ah(U.finishedAt)}):l("settings.skillOfficeBrowserInstanceSnapshotPending")}),Y.steps.map(Xe=>s.jsxs("p",{children:[Xe.title," · ",Xe.status]},Xe.id))]}):null]},w.id)})})})}),s.jsx(St,{open:Ee,title:l("settings.skillOfficeBrowserProfileOptionsModalTitle",{profileName:(E==null?void 0:E.displayName)??"-"}),description:l("settings.skillOfficeBrowserProfileOptionsModalDescription"),className:"settings-skill-create-modal",onClose:()=>{ve(!1),H(null)},children:s.jsxs(Mn,{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:!E||C||Z!==null||!ov(E),onClick:()=>{E&&vn(E)},children:E&&Z===`browser-profile-scope:${E.id}`?l("common.loading"):(E==null?void 0:E.ownershipScope)==="user"?l("settings.skillOfficeBrowserProfileSetWorkspaceOnlyAction"):l("settings.skillOfficeBrowserProfileAllowCrossWorkspaceAction")})})}),s.jsx(Ss,{children:s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{ve(!1),H(null)},children:l("common.close")})})]})}),s.jsx(St,{open:Tt,title:l("settings.skillOfficeBrowserProfileDeleteModalTitle"),description:l("settings.skillOfficeBrowserProfileDeleteModalDescription"),className:"settings-skill-create-modal",onClose:()=>{nt(!1),oe(null)},children:s.jsxs(Mn,{heading:(B==null?void 0:B.displayName)??"-",children:[s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeBrowserProfileDeleteModalWarning")}),s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{nt(!1),oe(null)},children:l("common.cancel")}),s.jsx("button",{className:"settings-button-danger",type:"button",disabled:!B||C||Z!==null,onClick:()=>{Sn()},children:B&&Z===`browser-profile-delete:${B.id}`?l("common.loading"):l("settings.skillOfficeBrowserProfileDeleteConfirmAction")})]})]})}),s.jsx(St,{open:mt,title:l("settings.skillOpsTargetModalTitle"),description:l("settings.skillOpsTargetModalDescription"),className:"settings-skill-create-modal",onClose:()=>{ae(!1),ct(Ya())},children:s.jsxs(Mn,{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:et.displayName,onChange:w=>ct(U=>({...U,displayName:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetEnvironmentLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.environment,onChange:w=>ct(U=>({...U,environment:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetHostLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.host,onChange:w=>ct(U=>({...U,host:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetPortLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.port,onChange:w=>ct(U=>({...U,port:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetUsernameLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.username,onChange:w=>ct(U=>({...U,username:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetPrivateKeyPathLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.privateKeyPath,onChange:w=>ct(U=>({...U,privateKeyPath:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetKnownHostsPathLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.knownHostsPath,onChange:w=>ct(U=>({...U,knownHostsPath:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetJumpHostLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.jumpHost,onChange:w=>ct(U=>({...U,jumpHost:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetWorkspacePathLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.workspacePath,onChange:w=>ct(U=>({...U,workspacePath:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetCredentialRefLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.credentialRef,onChange:w=>ct(U=>({...U,credentialRef:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetHostKeyPolicyLabel"),children:s.jsxs("select",{className:"settings-select",value:et.strictHostKeyChecking,onChange:w=>ct(U=>({...U,strictHostKeyChecking:w.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(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:zn,children:l("settings.skillOpsTargetResetAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:C||Z!==null,onClick:()=>{Rr()},children:Z==="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:()=>{Q(!1),Ne(null)},children:[s.jsx(Mn,{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(mi,{children:[s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpRuntimeTitle"),description:(Ie==null?void 0:Ie.currentSessionDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi(Ie!=null&&Ie.currentSessionReady?"ready":"missing")}),s.jsx(Jt,{label:"Codex",description:(Ie==null?void 0:Ie.codexDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi((Ie==null?void 0:Ie.codexState)??"missing")}),s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpGlobalCodingnsLabel"),description:(Ie==null?void 0:Ie.globalCodingnsDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi((Ie==null?void 0:Ie.globalCodingnsState)??"missing")})]})]}):s.jsx(Ro,{title:l("settings.skillWorkspaceSessionMcpEmptyTitle"),description:be??l("settings.skillWorkspaceSessionMcpEmptyDescription"),compact:!0})}),s.jsx(Mn,{heading:l("settings.skillWorkspaceSessionMcpCommandTitle"),description:l("settings.skillWorkspaceSessionMcpCommandDescription"),children:ge?s.jsxs(mi,{children:[s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpBrowserBridgeLabel"),description:l("settings.skillWorkspaceSessionMcpBrowserBridgeDetail"),trailing:Hi("ready")}),s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpRecommendedPathLabel"),description:(Ie==null?void 0:Ie.recommendedPath)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi("ready")})]}):null}),s.jsx(Ss,{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:an,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:o,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:w=>{fr(w)}}),s.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:Qw.map(w=>{const U=rt===w;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":U,"data-active":U?"true":"false",onClick:()=>Ar(w),children:ev(w)},w)})}),s.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:Jw.map(w=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":qe===w?"true":"false",children:[s.jsx("input",{type:"radio",name:"skill-upload-scope",checked:qe===w,onChange:()=>mr(w)}),s.jsx("span",{children:Zw(w)})]},w))}),rt==="file"?s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{var w;(w=o.current)==null||w.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:Ht,onChange:w=>Ye(w.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),Kt?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:Kt.previewTitle}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",Kt.fileName]})]})}):s.jsx("div",{className:"settings-skill-empty",children:rt==="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:Do(qe).map(w=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":dt[w]?"true":"false",children:[s.jsx("input",{type:"checkbox",checked:dt[w],disabled:!pn(w,kt),onChange:()=>sn(w)}),s.jsx("span",{children:pn(w,kt)?Wn(w):`${Wn(w)} · ${l("settings.skillTargetDisabledTag")}`})]},w))})]}),Kt!=null&&Kt.notes.length?s.jsx("div",{className:"settings-skill-tags",children:Kt.notes.map((w,U)=>s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:w},`${Kt.fileName}:${U}`))}):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:C||Z!==null,onClick:()=>{Pr()},children:Z==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function Or({title:e,description:t,headerExtra:n,emptyText:r,items:i,renderItem:a}){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((o,c)=>s.jsx(f.Fragment,{children:a(o)},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 Qd(e){return`import:${e.targetCli}:${e.directoryPath}`}function Zd(e){return`sync:${e}`}const Yw=["codex","claude-code","gemini","opencode"],Xw=["codex","claude-code"],Jw=["workspace","assistant"],Qw=["file","paste"];function Xt(e){return e instanceof mu?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function Wn(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 Zw(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function ev(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function tv(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 zi(e,t={}){const r=Do(e).filter(i=>pn(i,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function Do(e){return e==="assistant"?Xw:Yw}function Ya(){return{targetId:null,displayName:"",environment:"",host:"",port:"22",username:"",privateKeyPath:"",knownHostsPath:"",jumpHost:"",workspacePath:"",credentialRef:"",strictHostKeyChecking:"accept-new",status:"active"}}function Xa(e){return{displayName:"",engine:"chrome",mode:"persistent",ownershipScope:e!=null&&e.trim()?"workspace":"user",cdpEndpoint:""}}function Ja(){return{fileName:"",fileContentBase64:""}}function Lm(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function rs(e){return typeof e=="string"?e:""}function _m(e,t){return typeof e=="number"&&Number.isFinite(e)?String(e):String(t)}function nv(e){return e==="yes"||e==="no"||e==="accept-new"?e:"accept-new"}function eh(e){return e==="edge"?l("settings.skillOfficeBrowserProfileEngineEdge"):l("settings.skillOfficeBrowserProfileEngineChrome")}function rv(e){return e==="cdp_attached"?l("settings.skillOfficeBrowserProfileModeCdpAttached"):l("settings.skillOfficeBrowserProfileModePersistent")}function sv(e){switch(e){case"workspace":return l("settings.skillOfficeBrowserProfileScopeWorkspace");case"target":return l("settings.skillOfficeBrowserProfileScopeTarget");default:return l("settings.skillOfficeBrowserProfileScopeUser")}}function iv(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 av(e){switch(e){case"locked":return"pending";case"archived":case"error":return"failed";default:return"synced"}}function th(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 ov(e){var t;return e.ownershipScope==="user"?!!((t=e.workspaceId)!=null&&t.trim()):!0}function nh(e,t){return e?Dm(e.status):t==="succeeded"?l("settings.skillOfficeBrowserInstanceExecutionSucceeded"):t==="failed"?l("settings.skillOfficeBrowserInstanceExecutionFailed"):t==="cancelled"?l("settings.skillOfficeBrowserInstanceExecutionCancelled"):l("settings.skillOfficeBrowserInstanceExecutionIdle")}function Dm(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 lv(e){return e==="opencli_bridge"?l("settings.skillOfficeBrowserExecutionBackendOpenCliBridge"):l("settings.skillOfficeBrowserExecutionBackendPlaywright")}function cv(e){return e==="opencli_bridge"?"pending":"synced"}function rh(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 uv(e){if(!e)return"conflicted";switch(e.availability){case"ready":return"synced";case"daemon_missing":case"extension_missing":return"pending";default:return"failed"}}function dv(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 hv(e){return e==="ready"||e==="failed"}function pv(e){return(e==null?void 0:e.status)==="queued"||(e==null?void 0:e.status)==="running"}function fv(e){return new Date(e).toLocaleString("zh-CN",{hour12:!1})}function sh(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 o;const t=Lm(e.configJson),n=rs(t.host),r=rs(t.username),i=_m(t.port,22);return[(o=e.environment)==null?void 0:o.trim(),`${r}@${n}:${i}`].filter(c=>c&&c.trim().length>0).join(" · ")}function Hi(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 ih({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?Wm(_v(n),n):null}function gv(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 bv(e){const t={};for(const n of e){const r=kv(n.provider);r&&(t[r]=n)}return t}function kv(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 yv(e,t){return e.some(n=>n.enabled&&pn(n.targetCli,t))}function xv(e,t){return pn(e.targetCli,t)?e.syncStatus:"failed"}function wv(e,t){return pn(e.targetCli,t)?`${Wn(e.targetCli)} · ${gv(e.syncStatus)}`:`${Wn(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function Bm(e){return e.map(Wn).join(" / ")}function vv(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:Bm(t.map(n=>n.targetCli))})}function Sv(e,t){return pn(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:Wn(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:Wn(e.targetCli)})}function Cv(e,t){return pn(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:Wn(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:Wn(e.targetCli)})}function Nv(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function jv(e,t){return Do(e).some(r=>pn(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function Tv(e){const t=Wn(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 Iv(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function ah(e){return e===null?"-":new Date(e).toLocaleString()}async function oh(e){const t=await Promise.all(e.map(async n=>[n.id,await Lc(n.id)]));return Object.fromEntries(t)}function Ev(e,t,n){if(e.length>0)return e.map(i=>({name:i.name,directoryName:i.directoryName,sourcePath:i.sourcePath,usedByTargetCli:i.usedByTargetCli,usageTag:zl(i.directoryName)}));const r=new Map;for(const i of t)Om(i,n)&&r.set(lh(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli],usageTag:zl(i.directoryName)});for(const i of n){if(!va(i))continue;const a=i.directoryPath??i.rootDir,o=lh(i.targetCli,a);r.has(o)||r.set(o,{name:i.directoryName??"codingns-assistant",directoryName:i.directoryName??"codingns-assistant",sourcePath:a,usedByTargetCli:[i.targetCli],usageTag:zl(i.directoryName??"codingns-assistant")})}return[...r.values()]}function lh(e,t){return`${e}:${t}`}function Om(e,t){return t.some(n=>va(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function va(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function zl(e){return e==="codingns-workspace-session"?"workspace-session":"assistant-only"}function Mv(e){return e==="workspace-session"?l("settings.skillTagWorkspaceSessionOnly"):l("settings.skillTagAssistantOnly")}function Rv(e,t){return t.find(r=>va(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 Pv(e){return va(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Wm(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=Fm(r),a=_c(e)??_c(i)??"";return a||n.push(l("settings.skillUploadDirectoryRequiredNote")),i||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:a,previewTitle:i||Dv(a||"skill"),notes:n}}async function Av(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 Lv(e){if(typeof e.arrayBuffer=="function"){const t=await e.arrayBuffer();return ch(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(ch(new Uint8Array(r.result)));return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsArrayBuffer(e)})}function ch(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t)}function _c(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 _v(e){const t=_c(Fm(e));return t?`${t}.md`:"pasted-skill.md"}function Fm(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function Dv(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Bv(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ov=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Fv={};function uh(e,t){return(Fv.jsx?Wv:Ov).test(e)}const $v=/[ \t\n\f\r]/g;function zv(e){return typeof e=="object"?e.type==="text"?dh(e.value):!1:dh(e)}function dh(e){return e.replace($v,"")===""}class Sa{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Sa.prototype.normal={};Sa.prototype.property={};Sa.prototype.space=void 0;function $m(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Sa(n,r,t)}function Dc(e){return e.toLowerCase()}class Pn{constructor(t,n){this.attribute=n,this.property=t}}Pn.prototype.attribute="";Pn.prototype.booleanish=!1;Pn.prototype.boolean=!1;Pn.prototype.commaOrSpaceSeparated=!1;Pn.prototype.commaSeparated=!1;Pn.prototype.defined=!1;Pn.prototype.mustUseProperty=!1;Pn.prototype.number=!1;Pn.prototype.overloadedBoolean=!1;Pn.prototype.property="";Pn.prototype.spaceSeparated=!1;Pn.prototype.space=void 0;let Hv=0;const Ge=Ls(),Gt=Ls(),Bc=Ls(),ce=Ls(),Et=Ls(),bi=Ls(),Bn=Ls();function Ls(){return 2**++Hv}const Oc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ge,booleanish:Gt,commaOrSpaceSeparated:Bn,commaSeparated:bi,number:ce,overloadedBoolean:Bc,spaceSeparated:Et},Symbol.toStringTag,{value:"Module"})),Hl=Object.keys(Oc);class Lu extends Pn{constructor(t,n,r,i){let a=-1;if(super(t,n),hh(this,"space",i),typeof r=="number")for(;++a<Hl.length;){const o=Hl[a];hh(this,Hl[a],(r&Oc[o])===Oc[o])}}}Lu.prototype.defined=!0;function hh(e,t,n){n&&(e[t]=n)}function ji(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new Lu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Dc(r)]=r,n[Dc(a.attribute)]=r}return new Sa(t,n,e.space)}const zm=ji({properties:{ariaActiveDescendant:null,ariaAtomic:Gt,ariaAutoComplete:null,ariaBusy:Gt,ariaChecked:Gt,ariaColCount:ce,ariaColIndex:ce,ariaColSpan:ce,ariaControls:Et,ariaCurrent:null,ariaDescribedBy:Et,ariaDetails:null,ariaDisabled:Gt,ariaDropEffect:Et,ariaErrorMessage:null,ariaExpanded:Gt,ariaFlowTo:Et,ariaGrabbed:Gt,ariaHasPopup:null,ariaHidden:Gt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Et,ariaLevel:ce,ariaLive:null,ariaModal:Gt,ariaMultiLine:Gt,ariaMultiSelectable:Gt,ariaOrientation:null,ariaOwns:Et,ariaPlaceholder:null,ariaPosInSet:ce,ariaPressed:Gt,ariaReadOnly:Gt,ariaRelevant:null,ariaRequired:Gt,ariaRoleDescription:Et,ariaRowCount:ce,ariaRowIndex:ce,ariaRowSpan:ce,ariaSelected:Gt,ariaSetSize:ce,ariaSort:null,ariaValueMax:ce,ariaValueMin:ce,ariaValueNow:ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Hm(e,t){return t in e?e[t]:t}function Um(e,t){return Hm(e,t.toLowerCase())}const Uv=ji({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:bi,acceptCharset:Et,accessKey:Et,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:Et,autoFocus:Ge,autoPlay:Ge,blocking:Et,capture:null,charSet:null,checked:Ge,cite:null,className:Et,cols:ce,colSpan:null,content:null,contentEditable:Gt,controls:Ge,controlsList:Et,coords:ce|bi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:Bc,draggable:Gt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:Et,height:ce,hidden:Bc,high:ce,href:null,hrefLang:null,htmlFor:Et,httpEquiv:Et,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:Et,itemRef:Et,itemScope:Ge,itemType:Et,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:ce,manifest:null,max:null,maxLength:ce,media:null,method:null,min:null,minLength:ce,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:ce,pattern:null,ping:Et,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:Et,required:Ge,reversed:Ge,rows:ce,rowSpan:ce,sandbox:Et,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:ce,sizes:null,slot:null,span:ce,spellCheck:Gt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ce,step:null,style:null,tabIndex:ce,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Gt,width:ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Et,axis:null,background:null,bgColor:null,border:ce,borderColor:null,bottomMargin:ce,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:ce,leftMargin:ce,link:null,longDesc:null,lowSrc:null,marginHeight:ce,marginWidth:ce,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:ce,rules:null,scheme:null,scrolling:Gt,standby:null,summary:null,text:null,topMargin:ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:ce,security:null,unselectable:null},space:"html",transform:Um}),qv=ji({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:Bn,accentHeight:ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ce,amplitude:ce,arabicForm:null,ascent:ce,attributeName:null,attributeType:null,azimuth:ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ce,by:null,calcMode:null,capHeight:ce,className:Et,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:ce,diffuseConstant:ce,direction:null,display:null,dur:null,divisor:ce,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:ce,enableBackground:null,end:null,event:null,exponent:ce,externalResourcesRequired:null,fill:null,fillOpacity:ce,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:bi,g2:bi,glyphName:bi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ce,horizOriginX:ce,horizOriginY:ce,id:null,ideographic:ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ce,k:ce,k1:ce,k2:ce,k3:ce,k4:ce,kernelMatrix:Bn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ce,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:ce,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:ce,overlineThickness:ce,paintOrder:null,panose1:null,path:null,pathLength:ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Et,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ce,pointsAtY:ce,pointsAtZ:ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Bn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Bn,rev:Bn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Bn,requiredFeatures:Bn,requiredFonts:Bn,requiredFormats:Bn,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:ce,specularExponent:ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ce,strikethroughThickness:ce,string:null,stroke:null,strokeDashArray:Bn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ce,strokeOpacity:ce,strokeWidth:null,style:null,surfaceScale:ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Bn,tabIndex:ce,tableValues:null,target:null,targetX:ce,targetY:ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Bn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ce,underlineThickness:ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ce,values:null,vAlphabetic:ce,vMathematical:ce,vectorEffect:null,vHanging:ce,vIdeographic:ce,version:null,vertAdvY:ce,vertOriginX:ce,vertOriginY:ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Hm}),qm=ji({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()}}),Gm=ji({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Um}),Vm=ji({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Gv={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"},Vv=/[A-Z]/g,ph=/-[a-z]/g,Kv=/^data[-\w.:]+$/i;function Yv(e,t){const n=Dc(t);let r=t,i=Pn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Kv.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(ph,Jv);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!ph.test(a)){let o=a.replace(Vv,Xv);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Lu}return new i(r,t)}function Xv(e){return"-"+e.toLowerCase()}function Jv(e){return e.charAt(1).toUpperCase()}const Qv=$m([zm,Uv,qm,Gm,Vm],"html"),_u=$m([zm,qv,qm,Gm,Vm],"svg");function Zv(e){return e.join(" ").trim()}var Qs={},Ul,fh;function eS(){if(fh)return Ul;fh=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,c=/^\s+|\s+$/g,u=`
|
|
5
|
-
`,d="/",h="*",p="",g="comment",m="declaration";function y(j,x){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];x=x||{};var A=1,T=1;function F(K){var X=K.match(t);X&&(A+=X.length);var Y=K.lastIndexOf(u);T=~Y?K.length-Y:T+K.length}function R(){var K={line:A,column:T};return function(X){return X.position=new I(K),L(),X}}function I(K){this.start=K,this.end={line:A,column:T},this.source=x.source}I.prototype.content=j;function G(K){var X=new Error(x.source+":"+A+":"+T+": "+K);if(X.reason=K,X.filename=x.source,X.line=A,X.column=T,X.source=j,!x.silent)throw X}function z(K){var X=K.exec(j);if(X){var Y=X[0];return F(Y),j=j.slice(Y.length),X}}function L(){z(n)}function E(K){var X;for(K=K||[];X=H();)X!==!1&&K.push(X);return K}function H(){var K=R();if(!(d!=j.charAt(0)||h!=j.charAt(1))){for(var X=2;p!=j.charAt(X)&&(h!=j.charAt(X)||d!=j.charAt(X+1));)++X;if(X+=2,p===j.charAt(X-1))return G("End of comment missing");var Y=j.slice(2,X-2);return T+=2,F(Y),j=j.slice(X),T+=2,K({type:g,comment:Y})}}function B(){var K=R(),X=z(r);if(X){if(H(),!z(i))return G("property missing ':'");var Y=z(a),D=K({type:m,property:S(X[0].replace(e,p)),value:Y?S(Y[0].replace(e,p)):p});return z(o),D}}function oe(){var K=[];E(K);for(var X;X=B();)X!==!1&&(K.push(X),E(K));return K}return L(),oe()}function S(j){return j?j.replace(c,p):p}return Ul=y,Ul}var mh;function tS(){if(mh)return Qs;mh=1;var e=Qs&&Qs.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.default=n;const t=e(eS());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),c=typeof i=="function";return o.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;c?i(d,h,u):h&&(a=a||{},a[d]=h)}),a}return Qs}var Ui={},gh;function nS(){if(gh)return Ui;gh=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(d){return!d||n.test(d)||e.test(d)},o=function(d,h){return h.toUpperCase()},c=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),a(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,c):d=d.replace(r,c),d.replace(t,o))};return Ui.camelCase=u,Ui}var qi,bh;function rS(){if(bh)return qi;bh=1;var e=qi&&qi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(tS()),n=nS();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(c,u){c&&u&&(o[(0,n.camelCase)(c,a)]=u)}),o}return r.default=r,qi=r,qi}var sS=rS();const iS=Wf(sS),Km=Ym("end"),Du=Ym("start");function Ym(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 aS(e){const t=Du(e),n=Km(e);if(t&&n)return{start:t,end:n}}function sa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?kh(e.position):"start"in e||"end"in e?kh(e):"line"in e||"column"in e?Wc(e):""}function Wc(e){return yh(e&&e.line)+":"+yh(e&&e.column)}function kh(e){return Wc(e&&e.start)+"-"+Wc(e&&e.end)}function yh(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="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?a.ruleId=r:(a.source=r.slice(0,u),a.ruleId=r.slice(u+1))}if(!a.place&&a.ancestors&&a.ancestors){const u=a.ancestors[a.ancestors.length-1];u&&(a.place=u.position)}const c=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.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=sa(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.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 Bu={}.hasOwnProperty,oS=new Map,lS=/[A-Z]/g,cS=new Set(["table","tbody","thead","tfoot","tr"]),uS=new Set(["td","th"]),Xm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function dS(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=kS(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"?_u:Qv,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Jm(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Jm(e,t,n){if(t.type==="element")return hS(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return pS(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return mS(e,t,n);if(t.type==="mdxjsEsm")return fS(e,t);if(t.type==="root")return gS(e,t,n);if(t.type==="text")return bS(e,t)}function hS(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=_u,e.schema=i),e.ancestors.push(t);const a=Zm(e,t.tagName,!1),o=xS(e,t);let c=Wu(e,t);return cS.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!zv(u):!0})),Qm(e,o,a,t),Ou(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function pS(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)}da(e,t.position)}function fS(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);da(e,t.position)}function mS(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=_u,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Zm(e,t.name,!0),o=wS(e,t),c=Wu(e,t);return Qm(e,o,a,t),Ou(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function gS(e,t,n){const r={};return Ou(r,Wu(e,t)),e.create(t,e.Fragment,r,n)}function bS(e,t){return t.value}function Qm(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ou(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function kS(e,t,n){return r;function r(i,a,o,c){const d=Array.isArray(o.children)?n:t;return c?d(a,o,c):d(a,o)}}function yS(e,t){return n;function n(r,i,a,o){const c=Array.isArray(a.children),u=Du(r);return t(i,a,o,c,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function xS(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Bu.call(t.properties,i)){const a=vS(e,i,t.properties[i]);if(a){const[o,c]=a;e.tableCellAlignToStyle&&o==="align"&&typeof c=="string"&&uS.has(t.tagName)?r=c:n[o]=c}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function wS(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const c=o.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else da(e,t.position);else{const i=r.name;let a;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,a=e.evaluater.evaluateExpression(c.expression)}else da(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Wu(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:oS;for(;++r<t.children.length;){const a=t.children[r];let o;if(e.passKeys){const u=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(u){const d=i.get(u)||0;o=u+"-"+d,i.set(u,d+1)}}const c=Jm(e,a,o);c!==void 0&&n.push(c)}return n}function vS(e,t,n){const r=Yv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Bv(n):Zv(n)),r.property==="style"){let i=typeof n=="object"?n:SS(e,String(n));return e.stylePropertyNameCase==="css"&&(i=CS(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Gv[r.property]||r.property:r.attribute,n]}}function SS(e,t){try{return iS(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=Xm+"#cannot-parse-style-attribute",i}}function Zm(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,o;for(;++a<i.length;){const c=uh(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};o=o?{type:"MemberExpression",object:o,property:c,computed:!!(a&&c.type==="Literal"),optional:!1}:c}r=o}else r=uh(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Bu.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);da(e)}function da(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=Xm+"#cannot-handle-mdx-estrees-without-createevaluater",n}function CS(e){const t={};let n;for(n in e)Bu.call(e,n)&&(t[NS(n)]=e[n]);return t}function NS(e){let t=e.replace(lS,jS);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function jS(e){return"-"+e.toLowerCase()}const ql={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"]},TS={};function Fu(e,t){const n=TS,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return eg(e,r,i)}function eg(e,t,n){if(IS(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 xh(e.children,t,n)}return Array.isArray(e)?xh(e,t,n):""}function xh(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=eg(e[i],t,n);return r.join("")}function IS(e){return!!(e&&typeof e=="object")}const wh=document.createElement("i");function $u(e){const t="&"+e+";";wh.innerHTML=t;const n=wh.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Fn(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Kn(e,t){return e.length>0?(Fn(e,e.length,0,t),e):t}const vh={}.hasOwnProperty;function tg(e){const t={};let n=-1;for(;++n<e.length;)ES(t,e[n]);return t}function ES(e,t){let n;for(n in t){const i=(vh.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){vh.call(i,o)||(i[o]=[]);const c=a[o];MS(i[o],Array.isArray(c)?c:c?[c]:[])}}}function MS(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Fn(e,0,0,r)}function ng(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 wn=cs(/[A-Za-z]/),fn=cs(/[\dA-Za-z]/),RS=cs(/[#-'*+\--9=?A-Z^-~]/);function Bo(e){return e!==null&&(e<32||e===127)}const Fc=cs(/\d/),PS=cs(/[\dA-Fa-f]/),AS=cs(/[!-/:-@[-`{-~]/);function Le(e){return e!==null&&e<-2}function jt(e){return e!==null&&(e<0||e===32)}function tt(e){return e===-2||e===-1||e===32}const sl=cs(new RegExp("\\p{P}|\\p{S}","u")),Rs=cs(/\s/);function cs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ti(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o="";if(a===37&&fn(e.charCodeAt(n+1))&&fn(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const c=e.charCodeAt(n+1);a<56320&&c>56319&&c<57344?(o=String.fromCharCode(a,c),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ot(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return tt(u)?(e.enter(n),c(u)):t(u)}function c(u){return tt(u)&&a++<i?(e.consume(u),c):(e.exit(n),t(u))}}const LS={tokenize:_S};function _S(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"),ot(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),a(c)}function a(c){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,o(c)}function o(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Le(c)?(e.consume(c),e.exit("chunkText"),a):(e.consume(c),o)}}const DS={tokenize:BS},Sh={tokenize:OS};function BS(e){const t=this,n=[];let r=0,i,a,o;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&&A();const F=t.events.length;let R=F,I;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){I=t.events[R][1].end;break}x(r);let G=F;for(;G<t.events.length;)t.events[G][1].end={...I},G++;return Fn(t.events,R+1,0,t.events.slice(F)),t.events.length=G,d(T)}return c(T)}function d(T){if(r===n.length){if(!i)return g(T);if(i.currentConstruct&&i.currentConstruct.concrete)return y(T);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sh,h,p)(T)}function h(T){return i&&A(),x(r),g(T)}function p(T){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,y(T)}function g(T){return t.containerState={},e.attempt(Sh,m,y)(T)}function m(T){return r++,n.push([t.currentConstruct,t.containerState]),g(T)}function y(T){if(T===null){i&&A(),x(0),e.consume(T);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),S(T)}function S(T){if(T===null){j(e.exit("chunkFlow"),!0),x(0),e.consume(T);return}return Le(T)?(e.consume(T),j(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(T),S)}function j(T,F){const R=t.sliceStream(T);if(F&&R.push(null),T.previous=a,a&&(a.next=T),a=T,i.defineSkip(T.start),i.write(R),t.parser.lazy[T.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<o&&(!i.events[I][1].end||i.events[I][1].end.offset>o))return;const G=t.events.length;let z=G,L,E;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(L){E=t.events[z][1].end;break}L=!0}for(x(r),I=G;I<t.events.length;)t.events[I][1].end={...E},I++;Fn(t.events,z+1,0,t.events.slice(G)),t.events.length=I}}function x(T){let F=n.length;for(;F-- >T;){const R=n[F];t.containerState=R[1],R[0].exit.call(t,e)}n.length=T}function A(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function OS(e,t,n){return ot(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function wi(e){if(e===null||jt(e)||Rs(e))return 1;if(sl(e))return 2}function il(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const $c={name:"attention",resolveAll:WS,tokenize:FS};function WS(e,t){let n=-1,r,i,a,o,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};Ch(p,-u),Ch(g,u),o={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},a={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...o.start},end:{...c.end}},e[r][1].end={...o.start},e[n][1].start={...c.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Kn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Kn(d,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),d=Kn(d,il(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Kn(d,[["exit",a,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=Kn(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Fn(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 FS(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wi(r);let a;return o;function o(u){return a=u,e.enter("attentionSequence"),c(u)}function c(u){if(u===a)return e.consume(u),c;const d=e.exit("attentionSequence"),h=wi(u),p=!h||h===2&&i||n.includes(u),g=!i||i===2&&h||n.includes(r);return d._open=!!(a===42?p:p&&(i||!g)),d._close=!!(a===42?g:g&&(h||!p)),t(u)}}function Ch(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const $S={name:"autolink",tokenize:zS};function zS(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"),a}function a(m){return wn(m)?(e.consume(m),o):m===64?n(m):d(m)}function o(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||Bo(m)?n(m):(e.consume(m),u)}function d(m){return m===64?(e.consume(m),h):RS(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 y=m===45?g:p;return e.consume(m),y}return n(m)}}const Ca={partial:!0,tokenize:HS};function HS(e,t,n){return r;function r(a){return tt(a)?ot(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||Le(a)?t(a):n(a)}}const rg={continuation:{tokenize:qS},exit:GS,name:"blockQuote",tokenize:US};function US(e,t,n){const r=this;return i;function i(o){if(o===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),a}return n(o)}function a(o){return tt(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function qS(e,t,n){const r=this;return i;function i(o){return tt(o)?ot(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):a(o)}function a(o){return e.attempt(rg,t,n)(o)}}function GS(e){e.exit("blockQuote")}const sg={name:"characterEscape",tokenize:VS};function VS(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return AS(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const ig={name:"characterReference",tokenize:KS};function KS(e,t,n){const r=this;let i=0,a,o;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"),a=31,o=fn,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=PS,h):(e.enter("characterReferenceValue"),a=7,o=Fc,h(p))}function h(p){if(p===59&&i){const g=e.exit("characterReferenceValue");return o===fn&&!$u(r.sliceSerialize(g))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&i++<a?(e.consume(p),h):n(p)}}const Nh={partial:!0,tokenize:XS},jh={concrete:!0,name:"codeFenced",tokenize:YS};function YS(e,t,n){const r=this,i={partial:!0,tokenize:R};let a=0,o=0,c;return u;function u(I){return d(I)}function d(I){const G=r.events[r.events.length-1];return a=G&&G[1].type==="linePrefix"?G[2].sliceSerialize(G[1],!0).length:0,c=I,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(I)}function h(I){return I===c?(o++,e.consume(I),h):o<3?n(I):(e.exit("codeFencedFenceSequence"),tt(I)?ot(e,p,"whitespace")(I):p(I))}function p(I){return I===null||Le(I)?(e.exit("codeFencedFence"),r.interrupt?t(I):e.check(Nh,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)):tt(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ot(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"}),y(I))}function y(I){return I===null||Le(I)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(I)):I===96&&I===c?n(I):(e.consume(I),y)}function S(I){return e.attempt(i,F,j)(I)}function j(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),x}function x(I){return a>0&&tt(I)?ot(e,A,"linePrefix",a+1)(I):A(I)}function A(I){return I===null||Le(I)?e.check(Nh,S,F)(I):(e.enter("codeFlowValue"),T(I))}function T(I){return I===null||Le(I)?(e.exit("codeFlowValue"),A(I)):(e.consume(I),T)}function F(I){return e.exit("codeFenced"),t(I)}function R(I,G,z){let L=0;return E;function E(X){return I.enter("lineEnding"),I.consume(X),I.exit("lineEnding"),H}function H(X){return I.enter("codeFencedFence"),tt(X)?ot(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"),oe(X)):z(X)}function oe(X){return X===c?(L++,I.consume(X),oe):L>=o?(I.exit("codeFencedFenceSequence"),tt(X)?ot(I,K,"whitespace")(X):K(X)):z(X)}function K(X){return X===null||Le(X)?(I.exit("codeFencedFence"),G(X)):z(X)}}}function XS(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Gl={name:"codeIndented",tokenize:QS},JS={partial:!0,tokenize:ZS};function QS(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),ot(e,a,"linePrefix",5)(d)}function a(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?o(d):n(d)}function o(d){return d===null?u(d):Le(d)?e.attempt(JS,o,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Le(d)?(e.exit("codeFlowValue"),o(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function ZS(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ot(e,a,"linePrefix",5)(o)}function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):Le(o)?i(o):n(o)}}const eC={name:"codeText",previous:nC,resolve:tC,tokenize:rC};function tC(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 nC(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function rC(e,t,n){let r=0,i,a;return o;function o(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?(a=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)):(a.type="codeTextData",d(p))}}class sC{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 a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Gi(this.left,r),a.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),Gi(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Gi(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);Gi(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Gi(this.left,n.reverse())}}}function Gi(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 ag(e){const t={};let n=-1,r,i,a,o,c,u,d;const h=new sC(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,a=0,a<u.length&&u[a][1].type==="lineEndingBlank"&&(a+=2),a<u.length&&u[a][1].type==="content"))for(;++a<u.length&&u[a][1].type!=="content";)u[a][1].type==="chunkText"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,iC(h,n)),n=t[n],d=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=h.get(a),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=a);else if(!(o[1].type==="linePrefix"||o[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 Fn(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function iC(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const c=o.events,u=[],d={};let h,p,g=-1,m=n,y=0,S=0;const j=[S];for(;m;){for(;e.get(++i)[1]!==m;);a.push(i),m._tokenizer||(h=r.sliceStream(m),m.next||h.push(null),p&&o.defineSkip(m.start),m._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(h),m._isInFirstContentOfListItem&&(o._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,j.push(S),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(o.events=[],m?(m._tokenizer=void 0,m.previous=void 0):j.pop(),g=j.length;g--;){const x=c.slice(j[g],j[g+1]),A=a.pop();u.push([A,A+x.length-1]),e.splice(A,2,x)}for(u.reverse(),g=-1;++g<u.length;)d[y+u[g][0]]=y+u[g][1],y+=u[g][1]-u[g][0]-1;return d}const aC={resolve:lC,tokenize:cC},oC={partial:!0,tokenize:uC};function lC(e){return ag(e),e}function cC(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?a(c):Le(c)?e.check(oC,o,a)(c):(e.consume(c),i)}function a(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function o(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function uC(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ot(e,a,"linePrefix")}function a(o){if(o===null||Le(o))return n(o);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(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function og(e,t,n,r,i,a,o,c,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(x){return x===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(x),e.exit(a),g):x===null||x===32||x===41||Bo(x)?n(x):(e.enter(r),e.enter(o),e.enter(c),e.enter("chunkString",{contentType:"string"}),S(x))}function g(x){return x===62?(e.enter(a),e.consume(x),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===62?(e.exit("chunkString"),e.exit(c),g(x)):x===null||x===60||Le(x)?n(x):(e.consume(x),x===92?y:m)}function y(x){return x===60||x===62||x===92?(e.consume(x),m):m(x)}function S(x){return!h&&(x===null||x===41||jt(x))?(e.exit("chunkString"),e.exit(c),e.exit(o),e.exit(r),t(x)):h<d&&x===40?(e.consume(x),h++,S):x===41?(e.consume(x),h--,S):x===null||x===32||x===40||Bo(x)?n(x):(e.consume(x),x===92?j:S)}function j(x){return x===40||x===41||x===92?(e.consume(x),S):S(x)}}function lg(e,t,n,r,i,a){const o=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(a),h}function h(m){return c>999||m===null||m===91||m===93&&!u||m===94&&!c&&"_hiddenFootnoteSupport"in o.parser.constructs?n(m):m===93?(e.exit(a),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=!tt(m)),m===92?g:p)}function g(m){return m===91||m===92||m===93?(e.consume(m),c++,p):p(m)}}function cg(e,t,n,r,i,a){let o;return c;function c(g){return g===34||g===39||g===40?(e.enter(r),e.enter(i),e.consume(g),e.exit(i),o=g===40?41:g,u):n(g)}function u(g){return g===o?(e.enter(i),e.consume(g),e.exit(i),e.exit(r),t):(e.enter(a),d(g))}function d(g){return g===o?(e.exit(a),u(o)):g===null?n(g):Le(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),ot(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===o||g===null||Le(g)?(e.exit("chunkString"),d(g)):(e.consume(g),g===92?p:h)}function p(g){return g===o||g===92?(e.consume(g),h):h(g)}}function ia(e,t){let n;return r;function r(i){return Le(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):tt(i)?ot(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const dC={name:"definition",tokenize:pC},hC={partial:!0,tokenize:fC};function pC(e,t,n){const r=this;let i;return a;function a(m){return e.enter("definition"),o(m)}function o(m){return lg.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)?ia(e,d)(m):d(m)}function d(m){return og(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function h(m){return e.attempt(hC,p,p)(m)}function p(m){return tt(m)?ot(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 fC(e,t,n){return r;function r(c){return jt(c)?ia(e,i)(c):n(c)}function i(c){return cg(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function a(c){return tt(c)?ot(e,o,"whitespace")(c):o(c)}function o(c){return c===null||Le(c)?t(c):n(c)}}const mC={name:"hardBreakEscape",tokenize:gC};function gC(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return Le(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const bC={name:"headingAtx",resolve:kC,tokenize:yC};function kC(e,t){let n=e.length-2,r=3,i,a;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},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Fn(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function yC(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),a(h)}function a(h){return e.enter("atxHeadingSequence"),o(h)}function o(h){return h===35&&r++<6?(e.consume(h),o):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)):tt(h)?ot(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 xC=["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"],Th=["pre","script","style","textarea"],wC={concrete:!0,name:"htmlFlow",resolveTo:CC,tokenize:NC},vC={partial:!0,tokenize:TC},SC={partial:!0,tokenize:jC};function CC(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 NC(e,t,n){const r=this;let i,a,o,c,u;return d;function d(N){return h(N)}function h(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),p}function p(N){return N===33?(e.consume(N),g):N===47?(e.consume(N),a=!0,S):N===63?(e.consume(N),i=3,r.interrupt?t:C):wn(N)?(e.consume(N),o=String.fromCharCode(N),j):n(N)}function g(N){return N===45?(e.consume(N),i=2,m):N===91?(e.consume(N),i=5,c=0,y):wn(N)?(e.consume(N),i=4,r.interrupt?t:C):n(N)}function m(N){return N===45?(e.consume(N),r.interrupt?t:C):n(N)}function y(N){const be="CDATA[";return N===be.charCodeAt(c++)?(e.consume(N),c===be.length?r.interrupt?t:B:y):n(N)}function S(N){return wn(N)?(e.consume(N),o=String.fromCharCode(N),j):n(N)}function j(N){if(N===null||N===47||N===62||jt(N)){const be=N===47,ne=o.toLowerCase();return!be&&!a&&Th.includes(ne)?(i=1,r.interrupt?t(N):B(N)):xC.includes(o.toLowerCase())?(i=6,be?(e.consume(N),x):r.interrupt?t(N):B(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):a?A(N):T(N))}return N===45||fn(N)?(e.consume(N),o+=String.fromCharCode(N),j):n(N)}function x(N){return N===62?(e.consume(N),r.interrupt?t:B):n(N)}function A(N){return tt(N)?(e.consume(N),A):E(N)}function T(N){return N===47?(e.consume(N),E):N===58||N===95||wn(N)?(e.consume(N),F):tt(N)?(e.consume(N),T):E(N)}function F(N){return N===45||N===46||N===58||N===95||fn(N)?(e.consume(N),F):R(N)}function R(N){return N===61?(e.consume(N),I):tt(N)?(e.consume(N),R):T(N)}function I(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,G):tt(N)?(e.consume(N),I):z(N)}function G(N){return N===u?(e.consume(N),u=null,L):N===null||Le(N)?n(N):(e.consume(N),G)}function z(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||jt(N)?R(N):(e.consume(N),z)}function L(N){return N===47||N===62||tt(N)?T(N):n(N)}function E(N){return N===62?(e.consume(N),H):n(N)}function H(N){return N===null||Le(N)?B(N):tt(N)?(e.consume(N),H):n(N)}function B(N){return N===45&&i===2?(e.consume(N),Y):N===60&&i===1?(e.consume(N),D):N===62&&i===4?(e.consume(N),_e):N===63&&i===3?(e.consume(N),C):N===93&&i===5?(e.consume(N),le):Le(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(vC,Z,oe)(N)):N===null||Le(N)?(e.exit("htmlFlowData"),oe(N)):(e.consume(N),B)}function oe(N){return e.check(SC,K,Z)(N)}function K(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),X}function X(N){return N===null||Le(N)?oe(N):(e.enter("htmlFlowData"),B(N))}function Y(N){return N===45?(e.consume(N),C):B(N)}function D(N){return N===47?(e.consume(N),o="",V):B(N)}function V(N){if(N===62){const be=o.toLowerCase();return Th.includes(be)?(e.consume(N),_e):B(N)}return wn(N)&&o.length<8?(e.consume(N),o+=String.fromCharCode(N),V):B(N)}function le(N){return N===93?(e.consume(N),C):B(N)}function C(N){return N===62?(e.consume(N),_e):N===45&&i===2?(e.consume(N),C):B(N)}function _e(N){return N===null||Le(N)?(e.exit("htmlFlowData"),Z(N)):(e.consume(N),_e)}function Z(N){return e.exit("htmlFlow"),t(N)}}function jC(e,t,n){const r=this;return i;function i(o){return Le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function TC(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ca,t,n)}}const IC={name:"htmlText",tokenize:EC};function EC(e,t,n){const r=this;let i,a,o;return c;function c(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),u}function u(C){return C===33?(e.consume(C),d):C===47?(e.consume(C),R):C===63?(e.consume(C),T):wn(C)?(e.consume(C),z):n(C)}function d(C){return C===45?(e.consume(C),h):C===91?(e.consume(C),a=0,y):wn(C)?(e.consume(C),A):n(C)}function h(C){return C===45?(e.consume(C),m):n(C)}function p(C){return C===null?n(C):C===45?(e.consume(C),g):Le(C)?(o=p,D(C)):(e.consume(C),p)}function g(C){return C===45?(e.consume(C),m):p(C)}function m(C){return C===62?Y(C):C===45?g(C):p(C)}function y(C){const _e="CDATA[";return C===_e.charCodeAt(a++)?(e.consume(C),a===_e.length?S:y):n(C)}function S(C){return C===null?n(C):C===93?(e.consume(C),j):Le(C)?(o=S,D(C)):(e.consume(C),S)}function j(C){return C===93?(e.consume(C),x):S(C)}function x(C){return C===62?Y(C):C===93?(e.consume(C),x):S(C)}function A(C){return C===null||C===62?Y(C):Le(C)?(o=A,D(C)):(e.consume(C),A)}function T(C){return C===null?n(C):C===63?(e.consume(C),F):Le(C)?(o=T,D(C)):(e.consume(C),T)}function F(C){return C===62?Y(C):T(C)}function R(C){return wn(C)?(e.consume(C),I):n(C)}function I(C){return C===45||fn(C)?(e.consume(C),I):G(C)}function G(C){return Le(C)?(o=G,D(C)):tt(C)?(e.consume(C),G):Y(C)}function z(C){return C===45||fn(C)?(e.consume(C),z):C===47||C===62||jt(C)?L(C):n(C)}function L(C){return C===47?(e.consume(C),Y):C===58||C===95||wn(C)?(e.consume(C),E):Le(C)?(o=L,D(C)):tt(C)?(e.consume(C),L):Y(C)}function E(C){return C===45||C===46||C===58||C===95||fn(C)?(e.consume(C),E):H(C)}function H(C){return C===61?(e.consume(C),B):Le(C)?(o=H,D(C)):tt(C)?(e.consume(C),H):L(C)}function B(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),i=C,oe):Le(C)?(o=B,D(C)):tt(C)?(e.consume(C),B):(e.consume(C),K)}function oe(C){return C===i?(e.consume(C),i=void 0,X):C===null?n(C):Le(C)?(o=oe,D(C)):(e.consume(C),oe)}function K(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||jt(C)?L(C):(e.consume(C),K)}function X(C){return C===47||C===62||jt(C)?L(C):n(C)}function Y(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function D(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),V}function V(C){return tt(C)?ot(e,le,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):le(C)}function le(C){return e.enter("htmlTextData"),o(C)}}const zu={name:"labelEnd",resolveAll:AC,resolveTo:LC,tokenize:_C},MC={tokenize:DC},RC={tokenize:BC},PC={tokenize:OC};function AC(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&&Fn(e,0,e.length,n),e}function LC(e,t){let n=e.length,r=0,i,a,o,c;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const u={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[a][1].start},end:{...e[o][1].end}},h={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return c=[["enter",u,t],["enter",d,t]],c=Kn(c,e.slice(a+1,a+r+3)),c=Kn(c,[["enter",h,t]]),c=Kn(c,il(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),c=Kn(c,[["exit",h,t],e[o-2],e[o-1],["exit",d,t]]),c=Kn(c,e.slice(o+1)),c=Kn(c,[["exit",u,t]]),Fn(e,a,e.length,c),e}function _C(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return c;function c(g){return a?a._inactive?p(g):(o=r.parser.defined.includes(or(r.sliceSerialize({start:a.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(MC,h,o?h:p)(g):g===91?e.attempt(RC,h,o?d:p)(g):o?h(g):p(g)}function d(g){return e.attempt(PC,h,p)(g)}function h(g){return t(g)}function p(g){return a._balanced=!0,n(g)}}function DC(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)?ia(e,a)(p):a(p)}function a(p){return p===41?h(p):og(e,o,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return jt(p)?ia(e,u)(p):h(p)}function c(p){return n(p)}function u(p){return p===34||p===39||p===40?cg(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return jt(p)?ia(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 BC(e,t,n){const r=this;return i;function i(c){return lg.call(r,e,a,o,"reference","referenceMarker","referenceString")(c)}function a(c){return r.parser.defined.includes(or(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function o(c){return n(c)}}function OC(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const WC={name:"labelStartImage",resolveAll:zu.resolveAll,tokenize:FC};function FC(e,t,n){const r=this;return i;function i(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),a}function a(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),o):n(c)}function o(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const $C={name:"labelStartLink",resolveAll:zu.resolveAll,tokenize:zC};function zC(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),a}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Vl={name:"lineEnding",tokenize:HC};function HC(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ot(e,t,"linePrefix")}}const jo={name:"thematicBreak",tokenize:UC};function UC(e,t,n){let r=0,i;return a;function a(d){return e.enter("thematicBreak"),o(d)}function o(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"),tt(d)?ot(e,c,"whitespace")(d):c(d))}}const En={continuation:{tokenize:KC},exit:XC,name:"list",tokenize:VC},qC={partial:!0,tokenize:JC},GC={partial:!0,tokenize:YC};function VC(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return c;function c(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:Fc(m)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(jo,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 Fc(m)&&++o<10?(e.consume(m),u):(!r.interrupt||o<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(Ca,r.interrupt?n:h,e.attempt(qC,g,p))}function h(m){return r.containerState.initialBlankLine=!0,a++,g(m)}function p(m){return tt(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),g):n(m)}function g(m){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function KC(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ca,i,a);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ot(e,t,"listItemIndent",r.containerState.size+1)(c)}function a(c){return r.containerState.furtherBlankLines||!tt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(GC,t,o)(c))}function o(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,ot(e,e.attempt(En,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function YC(e,t,n){const r=this;return ot(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function XC(e){e.exit(this.containerState.type)}function JC(e,t,n){const r=this;return ot(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!tt(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const Ih={name:"setextUnderline",resolveTo:QC,tokenize:ZC};function QC(e,t){let n=e.length,r,i,a;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),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function ZC(e,t,n){const r=this;let i;return a;function a(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,o(d)):n(d)}function o(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===i?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),tt(d)?ot(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Le(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const e0={tokenize:t0};function t0(e){const t=this,n=e.attempt(Ca,r,e.attempt(this.parser.constructs.flowInitial,i,ot(e,e.attempt(this.parser.constructs.flow,i,e.attempt(aC,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const n0={resolveAll:dg()},r0=ug("string"),s0=ug("text");function ug(e){return{resolveAll:dg(e==="text"?i0:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,c);return o;function o(h){return d(h)?a(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"),a(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 dg(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function i0(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 a=i.length,o=-1,c=0,u;for(;a--;){const d=i[a];if(typeof d=="string"){for(o=d.length;d.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(d===-2)u=!0,c++;else if(d!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const d={type:n===e.length||u||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,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 a0={42:En,43:En,45:En,48:En,49:En,50:En,51:En,52:En,53:En,54:En,55:En,56:En,57:En,62:rg},o0={91:dC},l0={[-2]:Gl,[-1]:Gl,32:Gl},c0={35:bC,42:jo,45:[Ih,jo],60:wC,61:Ih,95:jo,96:jh,126:jh},u0={38:ig,92:sg},d0={[-5]:Vl,[-4]:Vl,[-3]:Vl,33:WC,38:ig,42:$c,60:[$S,IC],91:$C,92:[mC,sg],93:zu,95:$c,96:eC},h0={null:[$c,n0]},p0={null:[42,95]},f0={null:[]},m0=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:p0,contentInitial:o0,disable:f0,document:a0,flow:c0,flowInitial:l0,insideSpan:h0,string:u0,text:d0},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={},a=[];let o=[],c=[];const u={attempt:G(R),check:G(I),consume:A,enter:T,exit:F,interrupt:G(I,{interrupt:!0})},d={code:null,containerState:{},defineSkip:S,events:[],now:y,parser:e,previous:null,sliceSerialize:g,sliceStream:m,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&a.push(t),d;function p(H){return o=Kn(o,H),j(),o[o.length-1]!==null?[]:(z(t,0),d.events=il(a,d.events,d),d.events)}function g(H,B){return k0(m(H),B)}function m(H){return b0(o,H)}function y(){const{_bufferIndex:H,_index:B,line:oe,column:K,offset:X}=r;return{_bufferIndex:H,_index:B,line:oe,column:K,offset:X}}function S(H){i[H.line]=H.column,E()}function j(){let H;for(;r._index<o.length;){const B=o[r._index];if(typeof B=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<B.length;)x(B.charCodeAt(r._bufferIndex));else x(B)}}function x(H){h=h(H)}function A(H){Le(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,E()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=H}function T(H,B){const oe=B||{};return oe.type=H,oe.start=y(),d.events.push(["enter",oe,d]),c.push(oe),oe}function F(H){const B=c.pop();return B.end=y(),d.events.push(["exit",B,d]),B}function R(H,B){z(H,B.from)}function I(H,B){B.restore()}function G(H,B){return oe;function oe(K,X,Y){let D,V,le,C;return Array.isArray(K)?Z(K):"tokenize"in K?Z([K]):_e(K);function _e(fe){return ue;function ue(He){const Ue=He!==null&&fe[He],je=He!==null&&fe.null,Te=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(je)?je:je?[je]:[]];return Z(Te)(He)}}function Z(fe){return D=fe,V=0,fe.length===0?Y:N(fe[V])}function N(fe){return ue;function ue(He){return C=L(),le=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?ne():fe.tokenize.call(B?Object.assign(Object.create(d),B):d,u,be,ne)(He)}}function be(fe){return H(le,C),X}function ne(fe){return C.restore(),++V<D.length?N(D[V]):Y}}}function z(H,B){H.resolveAll&&!a.includes(H)&&a.push(H),H.resolve&&Fn(d.events,B,d.events.length-B,H.resolve(d.events.slice(B),d)),H.resolveTo&&(d.events=H.resolveTo(d.events,d))}function L(){const H=y(),B=d.previous,oe=d.currentConstruct,K=d.events.length,X=Array.from(c);return{from:K,restore:Y};function Y(){r=H,d.previous=B,d.currentConstruct=oe,d.events.length=K,c=X,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function b0(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const c=o[0];typeof c=="string"?o[0]=c.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function k0(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
|
|
6
|
-
`;break}case-3:{o=`\r
|
|
7
|
-
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join("")}function y0(e){const r={constructs:tg([m0,...(e||{}).extensions||[]]),content:i(LS),defined:[],document:i(DS),flow:i(e0),lazy:{},string:i(r0),text:i(s0)};return r;function i(a){return o;function o(c){return g0(r,a,c)}}}function x0(e){for(;!ag(e););return e}const Eh=/[\0\t\n\r]/g;function w0(){let e=1,t="",n=!0,r;return i;function i(a,o,c){const u=[];let d,h,p,g,m;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(o||void 0).decode(a)),p=0,t="",n&&(a.charCodeAt(0)===65279&&p++,n=void 0);p<a.length;){if(Eh.lastIndex=p,d=Eh.exec(a),g=d&&d.index!==void 0?d.index:a.length,m=a.charCodeAt(g),!d){t=a.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(a.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 v0=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function S0(e){return e.replace(v0,C0)}function C0(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return ng(n.slice(a?2:1),a?16:10)}return $u(n)||e}const hg={}.hasOwnProperty;function N0(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),j0(n)(x0(y0(n).document().write(w0()(e,t,!0))))}function j0(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(nt),autolinkProtocol:L,autolinkEmail:L,atxHeading:a(Ce),blockQuote:a(je),characterEscape:L,characterReference:L,codeFenced:a(Te),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(Te,o),codeText:a(O,o),codeTextData:L,data:L,codeFlowValue:L,definition:a(q),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(J),hardBreakEscape:a(Ee),hardBreakTrailing:a(Ee),htmlFlow:a(ve,o),htmlFlowData:L,htmlText:a(ve,o),htmlTextData:L,image:a(Tt),label:o,link:a(nt),listItem:a(ae),listItemValue:g,listOrdered:a(mt,p),listUnordered:a(mt),paragraph:a(se),reference:N,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(Ce),strong:a(ke),thematicBreak:a(Me)},exit:{atxHeading:u(),atxHeadingSequence:R,autolink:u(),autolinkEmail:Ue,autolinkProtocol:He,blockQuote:u(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:fe,characterReference:ue,codeFenced:u(j),codeFencedFence:S,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:u(x),codeText:u(X),codeTextData:E,data:E,definition:u(),definitionDestinationString:F,definitionLabelString:A,definitionTitleString:T,emphasis:u(),hardBreakEscape:u(B),hardBreakTrailing:u(B),htmlFlow:u(oe),htmlFlowData:E,htmlText:u(K),htmlTextData:E,image:u(D),label:le,labelText:V,lineEnding:H,link:u(Y),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:be,resourceDestinationString:C,resourceTitleString:_e,resource:Z,setextHeading:u(z),setextHeadingLineSequence:G,setextHeadingText:I,strong:u(),thematicBreak:u()}};pg(t,(e||{}).mdastExtensions||[]);const n={};return r;function r($){let Q={type:"root",children:[]};const ge={stack:[Q],tokenStack:[],config:t,enter:c,exit:d,buffer:o,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 Ke=Ne.pop();Be=i($,Ke,Be)}for(Be=-1;++Be<$.length;){const Ke=t[$[Be][0]];hg.call(Ke,$[Be][1].type)&&Ke[$[Be][1].type].call(Object.assign({sliceSerialize:$[Be][2].sliceSerialize},ge),$[Be][1])}if(ge.tokenStack.length>0){const Ke=ge.tokenStack[ge.tokenStack.length-1];(Ke[1]||Mh).call(ge,void 0,Ke[0])}for(Q.position={start:Zr($.length>0?$[0][1].start:{line:1,column:1,offset:0}),end:Zr($.length>0?$[$.length-2][1].end:{line:1,column:1,offset:0})},Be=-1;++Be<t.transforms.length;)Q=t.transforms[Be](Q)||Q;return Q}function i($,Q,ge){let Ne=Q-1,Be=-1,Ke=!1,Ie,ut,Qe,rt;for(;++Ne<=ge;){const st=$[Ne];switch(st[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{st[0]==="enter"?Be++:Be--,rt=void 0;break}case"lineEndingBlank":{st[0]==="enter"&&(Ie&&!rt&&!Be&&!Qe&&(Qe=Ne),rt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:rt=void 0}if(!Be&&st[0]==="enter"&&st[1].type==="listItemPrefix"||Be===-1&&st[0]==="exit"&&(st[1].type==="listUnordered"||st[1].type==="listOrdered")){if(Ie){let qe=Ne;for(ut=void 0;qe--;){const gt=$[qe];if(gt[1].type==="lineEnding"||gt[1].type==="lineEndingBlank"){if(gt[0]==="exit")continue;ut&&($[ut][1].type="lineEndingBlank",Ke=!0),gt[1].type="lineEnding",ut=qe}else if(!(gt[1].type==="linePrefix"||gt[1].type==="blockQuotePrefix"||gt[1].type==="blockQuotePrefixWhitespace"||gt[1].type==="blockQuoteMarker"||gt[1].type==="listItemIndent"))break}Qe&&(!ut||Qe<ut)&&(Ie._spread=!0),Ie.end=Object.assign({},ut?$[ut][1].start:st[1].end),$.splice(ut||Ne,0,["exit",Ie,st[2]]),Ne++,ge++}if(st[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},st[1].start),end:void 0};Ie=qe,$.splice(Ne,0,["enter",qe,st[2]]),Ne++,ge++,Qe=void 0,rt=!0}}}return $[Q][1]._spread=Ke,ge}function a($,Q){return ge;function ge(Ne){c.call(this,$(Ne),Ne),Q&&Q.call(this,Ne)}}function o(){this.stack.push({type:"fragment",children:[]})}function c($,Q,ge){this.stack[this.stack.length-1].children.push($),this.stack.push($),this.tokenStack.push([Q,ge||void 0]),$.position={start:Zr(Q.start),end:void 0}}function u($){return Q;function Q(ge){$&&$.call(this,ge),d.call(this,ge)}}function d($,Q){const ge=this.stack.pop(),Ne=this.tokenStack.pop();if(Ne)Ne[0].type!==$.type&&(Q?Q.call(this,$,Ne[0]):(Ne[1]||Mh).call(this,$,Ne[0]));else throw new Error("Cannot close `"+$.type+"` ("+sa({start:$.start,end:$.end})+"): it’s not open");ge.position.end=Zr($.end)}function h(){return Fu(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g($){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize($),10),this.data.expectingFirstListItemValue=void 0}}function m(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=$}function y(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=$}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.value=$.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.value=$.replace(/(\r?\n|\r)$/g,"")}function A($){const Q=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Q,ge.identifier=or(this.sliceSerialize($)).toLowerCase()}function T(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.title=$}function F(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.url=$}function R($){const Q=this.stack[this.stack.length-1];if(!Q.depth){const ge=this.sliceSerialize($).length;Q.depth=ge}}function I(){this.data.setextHeadingSlurpLineEnding=!0}function G($){const Q=this.stack[this.stack.length-1];Q.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:Zr($.start),end:void 0},ge.push(Ne)),this.stack.push(Ne)}function E($){const Q=this.stack.pop();Q.value+=this.sliceSerialize($),Q.position.end=Zr($.end)}function H($){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=Q.children[Q.children.length-1];ge.position.end=Zr($.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(L.call(this,$),E.call(this,$))}function B(){this.data.atHardBreak=!0}function oe(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.value=$}function K(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.value=$}function X(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.value=$}function Y(){const $=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";$.type+="Reference",$.referenceType=Q,delete $.url,delete $.title}else delete $.identifier,delete $.label;this.data.referenceType=void 0}function D(){const $=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";$.type+="Reference",$.referenceType=Q,delete $.url,delete $.title}else delete $.identifier,delete $.label;this.data.referenceType=void 0}function V($){const Q=this.sliceSerialize($),ge=this.stack[this.stack.length-2];ge.label=S0(Q),ge.identifier=or(Q).toLowerCase()}function le(){const $=this.stack[this.stack.length-1],Q=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=Q}function C(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.url=$}function _e(){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.title=$}function Z(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function be($){const Q=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Q,ge.identifier=or(this.sliceSerialize($)).toLowerCase(),this.data.referenceType="full"}function ne($){this.data.characterReferenceType=$.type}function fe($){const Q=this.sliceSerialize($),ge=this.data.characterReferenceType;let Ne;ge?(Ne=ng(Q,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ne=$u(Q);const Be=this.stack[this.stack.length-1];Be.value+=Ne}function ue($){const Q=this.stack.pop();Q.position.end=Zr($.end)}function He($){E.call(this,$);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize($)}function Ue($){E.call(this,$);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize($)}function je(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function O(){return{type:"inlineCode",value:""}}function q(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function Ee(){return{type:"break"}}function ve(){return{type:"html",value:""}}function Tt(){return{type:"image",title:null,url:"",alt:null}}function nt(){return{type:"link",title:null,url:"",children:[]}}function mt($){return{type:"list",ordered:$.type==="listOrdered",start:null,spread:$._spread,children:[]}}function ae($){return{type:"listItem",spread:$._spread,checked:null,children:[]}}function se(){return{type:"paragraph",children:[]}}function ke(){return{type:"strong",children:[]}}function ye(){return{type:"text",value:""}}function Me(){return{type:"thematicBreak"}}}function Zr(e){return{line:e.line,column:e.column,offset:e.offset}}function pg(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?pg(e,r):T0(e,r)}}function T0(e,t){let n;for(n in t)if(hg.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 Mh(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+sa({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+sa({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+sa({start:t.start,end:t.end})+") is still open")}function I0(e){const t=this;t.parser=n;function n(r){return N0(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function E0(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 M0(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
8
|
-
`}]}function R0(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 a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function P0(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function A0(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function L0(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Ti(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let o,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+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(o)}]};e.patch(t,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function _0(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 D0(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function fg(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),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function B0(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return fg(e,t);const i={src:Ti(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function O0(e,t){const n={src:Ti(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 W0(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 F0(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return fg(e,t);const i={href:Ti(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function $0(e,t){const n={href:Ti(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 z0(e,t,n){const r=e.all(t),i=n?H0(n):mg(t),a={},o=[];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:[]}),a.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const h=r[c];(i||c!==0||h.type!=="element"||h.tagName!=="p")&&o.push({type:"text",value:`
|
|
10
|
-
`}),h.type==="element"&&h.tagName==="p"&&!i?o.push(...h.children):o.push(h)}const u=r[r.length-1];u&&(i||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
|
|
11
|
-
`});const d={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,d),e.applyData(t,d)}function H0(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 U0(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 o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function q0(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function G0(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function V0(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function K0(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=Du(t.children[1]),u=Km(t.children[t.children.length-1]);c&&u&&(o.position={start:c,end:u}),i.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Y0(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,c=o?o.length:t.children.length;let u=-1;const d=[];for(;++u<c;){const p=t.children[u],g={},m=o?o[u]:void 0;m&&(g.align=m);let y={type:"element",tagName:a,properties:g,children:[]};p&&(y.children=e.all(p),e.patch(p,y),y=e.applyData(p,y)),d.push(y)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,h),e.applyData(t,h)}function X0(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Rh=9,Ph=32;function J0(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const a=[];for(;r;)a.push(Ah(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Ah(t.slice(i),i>0,!1)),a.join("")}function Ah(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===Rh||a===Ph;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===Rh||a===Ph;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Q0(e,t){const n={type:"text",value:J0(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Z0(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const e1={blockquote:E0,break:M0,code:R0,delete:P0,emphasis:A0,footnoteReference:L0,heading:_0,html:D0,imageReference:B0,image:O0,inlineCode:W0,linkReference:F0,link:$0,listItem:z0,list:U0,paragraph:q0,root:G0,strong:V0,table:K0,tableCell:X0,tableRow:Y0,text:Q0,thematicBreak:Z0,toml:Qa,yaml:Qa,definition:Qa,footnoteDefinition:Qa};function Qa(){}const gg=-1,al=0,aa=1,Oo=2,Hu=3,Uu=4,qu=5,Gu=6,bg=7,kg=8,Lh=typeof self=="object"?self:globalThis,t1=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,o]=t[i];switch(a){case al:case gg:return n(o,i);case aa:{const c=n([],i);for(const u of o)c.push(r(u));return c}case Oo:{const c=n({},i);for(const[u,d]of o)c[r(u)]=r(d);return c}case Hu:return n(new Date(o),i);case Uu:{const{source:c,flags:u}=o;return n(new RegExp(c,u),i)}case qu:{const c=n(new Map,i);for(const[u,d]of o)c.set(r(u),r(d));return c}case Gu:{const c=n(new Set,i);for(const u of o)c.add(r(u));return c}case bg:{const{name:c,message:u}=o;return n(new Lh[c](u),i)}case kg:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:c}=new Uint8Array(o);return n(new DataView(c),o)}}return n(new Lh[a](o),i)};return r},_h=e=>t1(new Map,e)(0),Zs="",{toString:n1}={},{keys:r1}=Object,Vi=e=>{const t=typeof e;if(t!=="object"||!e)return[al,t];const n=n1.call(e).slice(8,-1);switch(n){case"Array":return[aa,Zs];case"Object":return[Oo,Zs];case"Date":return[Hu,Zs];case"RegExp":return[Uu,Zs];case"Map":return[qu,Zs];case"Set":return[Gu,Zs];case"DataView":return[aa,n]}return n.includes("Array")?[aa,n]:n.includes("Error")?[bg,n]:[Oo,n]},Za=([e,t])=>e===al&&(t==="function"||t==="symbol"),s1=(e,t,n,r)=>{const i=(o,c)=>{const u=r.push(o)-1;return n.set(c,u),u},a=o=>{if(n.has(o))return n.get(o);let[c,u]=Vi(o);switch(c){case al:{let h=o;switch(u){case"bigint":c=kg,h=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);h=null;break;case"undefined":return i([gg],o)}return i([c,h],o)}case aa:{if(u){let g=o;return u==="DataView"?g=new Uint8Array(o.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(o)),i([u,[...g]],o)}const h=[],p=i([c,h],o);for(const g of o)h.push(a(g));return p}case Oo:{if(u)switch(u){case"BigInt":return i([u,o.toString()],o);case"Boolean":case"Number":case"String":return i([u,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const h=[],p=i([c,h],o);for(const g of r1(o))(e||!Za(Vi(o[g])))&&h.push([a(g),a(o[g])]);return p}case Hu:return i([c,o.toISOString()],o);case Uu:{const{source:h,flags:p}=o;return i([c,{source:h,flags:p}],o)}case qu:{const h=[],p=i([c,h],o);for(const[g,m]of o)(e||!(Za(Vi(g))||Za(Vi(m))))&&h.push([a(g),a(m)]);return p}case Gu:{const h=[],p=i([c,h],o);for(const g of o)(e||!Za(Vi(g)))&&h.push(a(g));return p}}const{message:d}=o;return i([c,{name:u,message:d}],o)};return a},Dh=(e,{json:t,lossy:n}={})=>{const r=[];return s1(!(t||n),!!t,new Map,r)(e),r},Wo=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_h(Dh(e,t)):structuredClone(e):(e,t)=>_h(Dh(e,t));function i1(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 a1(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function o1(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||i1,r=e.options.footnoteBackLabel||a1,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=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=Ti(p.toLowerCase());let m=0;const y=[],S=e.footnoteCounts.get(p);for(;S!==void 0&&++m<=S;){y.length>0&&y.push({type:"text",value:" "});let A=typeof n=="string"?n:n(u,m);typeof A=="string"&&(A={type:"text",value:A}),y.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(A)?A:[A]})}const j=h[h.length-1];if(j&&j.type==="element"&&j.tagName==="p"){const A=j.children[j.children.length-1];A&&A.type==="text"?A.value+=" ":j.children.push({type:"text",value:" "}),j.children.push(...y)}else h.push(...y);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(h,!0)};e.patch(d,x),c.push(x)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...Wo(o),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 ol=(function(e){if(e==null)return d1;if(typeof e=="function")return ll(e);if(typeof e=="object")return Array.isArray(e)?l1(e):c1(e);if(typeof e=="string")return u1(e);throw new Error("Expected function, string, or object as test")});function l1(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ol(e[n]);return ll(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function c1(e){const t=e;return ll(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function u1(e){return ll(t);function t(n){return n&&n.type===e}}function ll(e){return t;function t(n,r,i){return!!(h1(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function d1(){return!0}function h1(e){return e!==null&&typeof e=="object"&&"type"in e}const yg=[],p1=!0,zc=!1,f1="skip";function xg(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=ol(i),o=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=yg,y,S,j;if((!t||a(u,d,h[h.length-1]||void 0))&&(m=m1(n(u,h)),m[0]===zc))return m;if("children"in u&&u.children){const x=u;if(x.children&&m[0]!==f1)for(S=(r?x.children.length:-1)+o,j=h.concat(x);S>-1&&S<x.children.length;){const A=x.children[S];if(y=c(A,S,j)(),y[0]===zc)return y;S=typeof y[1]=="number"?y[1]:S+o}}return m}}}function m1(e){return Array.isArray(e)?e:typeof e=="number"?[p1,e]:e==null?yg:[e]}function Vu(e,t,n,r){let i,a,o;typeof t=="function"&&typeof n!="function"?(a=void 0,o=t,i=n):(a=t,o=n,i=r),xg(e,a,c,i);function c(u,d){const h=d[d.length-1],p=h?h.children.indexOf(u):void 0;return o(u,p,h)}}const Hc={}.hasOwnProperty,g1={};function b1(e,t){const n=t||g1,r=new Map,i=new Map,a=new Map,o={...e1,...n.handlers},c={all:d,applyData:y1,definitionById:r,footnoteById:i,footnoteCounts:a,footnoteOrder:[],handlers:o,one:u,options:n,patch:k1,wrap:w1};return Vu(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(Hc.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,...j}=h,x=Wo(j);return x.children=c.all(h),x}return Wo(h)}return(c.options.unknownHandler||x1)(c,h,p)}function d(h){const p=[];if("children"in h){const g=h.children;let m=-1;for(;++m<g.length;){const y=c.one(g[m],h);if(y){if(m&&g[m-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=Bh(y.value)),!Array.isArray(y)&&y.type==="element")){const S=y.children[0];S&&S.type==="text"&&(S.value=Bh(S.value))}Array.isArray(y)?p.push(...y):p.push(y)}}}return p}}function k1(e,t){e.position&&(t.position=aS(e))}function y1(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,a=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&a&&Object.assign(n.properties,Wo(a)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function x1(e,t){const n=t.data||{},r="value"in t&&!(Hc.call(n,"hProperties")||Hc.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 w1(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 Bh(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Oh(e,t){const n=b1(e,t),r=n.one(e,void 0),i=o1(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:`
|
|
17
|
-
`},i),a}function v1(e,t){return e&&"run"in e?async function(n,r){const i=Oh(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Oh(n,{file:r,...e||t})}}function Wh(e){if(e)throw e}var Kl,Fh;function S1(){if(Fh)return Kl;Fh=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]"},a=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)},o=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 Kl=function u(){var d,h,p,g,m,y,S=arguments[0],j=1,x=arguments.length,A=!1;for(typeof S=="boolean"&&(A=S,S=arguments[1]||{},j=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});j<x;++j)if(d=arguments[j],d!=null)for(h in d)p=c(S,h),g=c(d,h),S!==g&&(A&&g&&(a(g)||(m=i(g)))?(m?(m=!1,y=p&&i(p)?p:[]):y=p&&a(p)?p:{},o(S,{name:h,newValue:u(A,y,g)})):typeof g<"u"&&o(S,{name:h,newValue:g}));return S},Kl}var C1=S1();const Yl=Wf(C1);function Uc(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 N1(){const e=[],t={run:n,use:r};return t;function n(...i){let a=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);c(null,...i);function c(u,...d){const h=e[++a];let p=-1;if(u){o(u);return}for(;++p<i.length;)(d[p]===null||d[p]===void 0)&&(d[p]=i[p]);i=d,h?j1(h,c)(...d):o(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 j1(e,t){let n;return r;function r(...o){const c=e.length>o.length;let u;c&&o.push(i);try{u=e.apply(this,o)}catch(d){const h=d;if(c&&n)throw h;return i(h)}c||(u&&u.then&&typeof u.then=="function"?u.then(a,i):u instanceof Error?i(u):a(u))}function i(o,...c){n||(n=!0,t(o,...c))}function a(o){i(null,o)}}const Nr={basename:T1,dirname:I1,extname:E1,join:M1,sep:"/"};function T1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Na(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,c=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),c>-1&&(e.codePointAt(i)===t.codePointAt(c--)?c<0&&(r=i):(c=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function I1(e){if(Na(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 E1(e){Na(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const c=e.codePointAt(t);if(c===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),c===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function M1(...e){let t=-1,n;for(;++t<e.length;)Na(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":R1(n)}function R1(e){Na(e);const t=e.codePointAt(0)===47;let n=P1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function P1(e,t){let n="",r=0,i=-1,a=0,o=-1,c,u;for(;++o<=e.length;){if(o<e.length)c=e.codePointAt(o);else{if(c===47)break;c=47}if(c===47){if(!(i===o-1||a===1))if(i!==o-1&&a===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=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else c===46&&a>-1?a++:a=-1}return n}function Na(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const A1={cwd:L1};function L1(){return"/"}function qc(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function _1(e){if(typeof e=="string")e=new URL(e);else if(!qc(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 D1(e)}function D1(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 Xl=["history","path","basename","stem","extname","dirname"];class wg{constructor(t){let n;t?qc(t)?n={path:t}:typeof t=="string"||B1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":A1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Xl.length;){const a=Xl[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let i;for(i in n)Xl.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Nr.basename(this.path):void 0}set basename(t){Ql(t,"basename"),Jl(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){$h(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(Jl(t,"extname"),$h(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){qc(t)&&(t=_1(t)),Ql(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){Ql(t,"stem"),Jl(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 Jl(e,t){if(e&&e.includes(Nr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Nr.sep+"`")}function Ql(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function $h(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function B1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const O1=(function(e){const r=this.constructor.prototype,i=r[e],a=function(){return i.apply(a,arguments)};return Object.setPrototypeOf(a,r),a}),W1={}.hasOwnProperty;class Ku extends O1{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=N1()}copy(){const t=new Ku;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Yl(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(tc("data",this.frozen),this.namespace[t]=n,this):W1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(tc("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=eo(t),r=this.parser||this.Parser;return Zl("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Zl("process",this.parser||this.Parser),ec("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(a,o){const c=eo(t),u=r.parse(c);r.run(u,c,function(h,p,g){if(h||!p||!g)return d(h);const m=p,y=r.stringify(m,g);z1(y)?g.value=y:g.result=y,d(h,g)});function d(h,p){h||!p?o(h):a?a(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),Zl("processSync",this.parser||this.Parser),ec("processSync",this.compiler||this.Compiler),this.process(t,i),Hh("processSync","process",n),r;function i(a,o){n=!0,Wh(a),r=o}}run(t,n,r){zh(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(o,c){const u=eo(n);i.run(t,u,d);function d(h,p,g){const m=p||t;h?c(h):o?o(m):r(void 0,m,g)}}}runSync(t,n){let r=!1,i;return this.run(t,n,a),Hh("runSync","run",r),i;function a(o,c){Wh(o),i=c,r=!0}}stringify(t,n){this.freeze();const r=eo(n),i=this.compiler||this.Compiler;return ec("stringify",i),zh(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(tc("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[h,...p]=d;u(h,p)}else o(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function o(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=Yl(!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];a(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,...y]=h;const S=r[g][1];Uc(S)&&Uc(m)&&(m=Yl(!0,S,m)),r[g]=[d,m,...y]}}}}const F1=new Ku().freeze();function Zl(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ec(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function tc(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 zh(e){if(!Uc(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Hh(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function eo(e){return $1(e)?e:new wg(e)}function $1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function z1(e){return typeof e=="string"||H1(e)}function H1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const U1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Uh=[],qh={allowDangerousHtml:!0},q1=/^(https?|ircs?|mailto|xmpp)$/i,G1=[{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 V1(e){const t=K1(e),n=Y1(e);return X1(t.runSync(t.parse(n),n),e)}function K1(e){const t=e.rehypePlugins||Uh,n=e.remarkPlugins||Uh,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qh}:qh;return F1().use(I0).use(n).use(v1,r).use(t)}function Y1(e){const t=e.children||"",n=new wg;return typeof t=="string"&&(n.value=t),n}function X1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,c=t.unwrapDisallowed,u=t.urlTransform||J1;for(const h of G1)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+U1+h.id,void 0);return Vu(e,d),dS(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 o?g.children.splice(p,1):g.children[p]={type:"text",value:h.value},p;if(h.type==="element"){let m;for(m in ql)if(Object.hasOwn(ql,m)&&Object.hasOwn(h.properties,m)){const y=h.properties[m],S=ql[m];(S===null||S.includes(h.tagName))&&(h.properties[m]=u(String(y||""),m,h))}}if(h.type==="element"){let m=n?!n.includes(h.tagName):a?a.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 J1(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||q1.test(e.slice(0,t))?e:""}function Gh(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 Q1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Z1(e,t,n){const i=ol((n||{}).ignore||[]),a=eN(t);let o=-1;for(;++o<a.length;)xg(e,"text",c);function c(d,h){let p=-1,g;for(;++p<h.length;){const m=h[p],y=g?g.children:void 0;if(i(m,y?y.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=a[o][0],m=a[o][1];let y=0;const j=p.children.indexOf(d);let x=!1,A=[];g.lastIndex=0;let T=g.exec(d.value);for(;T;){const F=T.index,R={index:T.index,input:T.input,stack:[...h,d]};let I=m(...T,R);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=F+1:(y!==F&&A.push({type:"text",value:d.value.slice(y,F)}),Array.isArray(I)?A.push(...I):I&&A.push(I),y=F+T[0].length,x=!0),!g.global)break;T=g.exec(d.value)}return x?(y<d.value.length&&A.push({type:"text",value:d.value.slice(y)}),p.children.splice(j,1,...A)):A=[d],j+A.length}}function eN(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([tN(i[0]),nN(i[1])])}return t}function tN(e){return typeof e=="string"?new RegExp(Q1(e),"g"):e}function nN(e){return typeof e=="function"?e:function(){return e}}const nc="phrasing",rc=["autolink","link","image","label"];function rN(){return{transforms:[uN],enter:{literalAutolink:iN,literalAutolinkEmail:sc,literalAutolinkHttp:sc,literalAutolinkWww:sc},exit:{literalAutolink:cN,literalAutolinkEmail:lN,literalAutolinkHttp:aN,literalAutolinkWww:oN}}}function sN(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:nc,notInConstruct:rc},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:nc,notInConstruct:rc},{character:":",before:"[ps]",after:"\\/",inConstruct:nc,notInConstruct:rc}]}}function iN(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function sc(e){this.config.enter.autolinkProtocol.call(this,e)}function aN(e){this.config.exit.autolinkProtocol.call(this,e)}function oN(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 lN(e){this.config.exit.autolinkEmail.call(this,e)}function cN(e){this.exit(e)}function uN(e){Z1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,dN],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),hN]],{ignore:["link","linkReference"]})}function dN(e,t,n,r,i){let a="";if(!vg(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!pN(n)))return!1;const o=fN(n+r);if(!o[0])return!1;const c={type:"link",title:null,url:a+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[c,{type:"text",value:o[1]}]:c}function hN(e,t,n,r){return!vg(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function pN(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 fN(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=Gh(e,"(");let a=Gh(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function vg(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Rs(n)||sl(n))&&(!t||n!==47)}Sg.peek=SN;function mN(){this.buffer()}function gN(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function bN(){this.buffer()}function kN(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function yN(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 xN(e){this.exit(e)}function wN(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 vN(e){this.exit(e)}function SN(){return"["}function Sg(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const o=n.enter("footnoteReference"),c=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{after:"]",before:a})),c(),o(),a+=i.move("]"),a}function CN(){return{enter:{gfmFootnoteCallString:mN,gfmFootnoteCall:gN,gfmFootnoteDefinitionLabelString:bN,gfmFootnoteDefinition:kN},exit:{gfmFootnoteCallString:yN,gfmFootnoteCall:xN,gfmFootnoteDefinitionLabelString:wN,gfmFootnoteDefinition:vN}}}function NN(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Sg},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,a,o){const c=a.createTracker(o);let u=c.move("[^");const d=a.enter("footnoteDefinition"),h=a.enter("label");return u+=c.move(a.safe(a.associationId(r),{before:u,after:"]"})),h(),u+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),u+=c.move((t?`
|
|
18
|
-
`:" ")+a.indentLines(a.containerFlow(r,c.current()),t?Cg:jN))),d(),u}}function jN(e,t,n){return t===0?e:Cg(e,t,n)}function Cg(e,t,n){return(n?"":" ")+e}const TN=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ng.peek=PN;function IN(){return{canContainEols:["delete"],enter:{strikethrough:MN},exit:{strikethrough:RN}}}function EN(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:TN}],handlers:{delete:Ng}}}function MN(e){this.enter({type:"delete",children:[]},e)}function RN(e){this.exit(e)}function Ng(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),a(),o}function PN(){return"~"}function AN(e){return e.length}function LN(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||AN,a=[],o=[],c=[],u=[];let d=0,h=-1;for(;++h<e.length;){const S=[],j=[];let x=-1;for(e[h].length>d&&(d=e[h].length);++x<e[h].length;){const A=_N(e[h][x]);if(n.alignDelimiters!==!1){const T=i(A);j[x]=T,(u[x]===void 0||T>u[x])&&(u[x]=T)}S.push(A)}o[h]=S,c[h]=j}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)a[p]=Vh(r[p]);else{const S=Vh(r);for(;++p<d;)a[p]=S}p=-1;const g=[],m=[];for(;++p<d;){const S=a[p];let j="",x="";S===99?(j=":",x=":"):S===108?j=":":S===114&&(x=":");let A=n.alignDelimiters===!1?1:Math.max(1,u[p]-j.length-x.length);const T=j+"-".repeat(A)+x;n.alignDelimiters!==!1&&(A=j.length+A+x.length,A>u[p]&&(u[p]=A),m[p]=A),g[p]=T}o.splice(1,0,g),c.splice(1,0,m),h=-1;const y=[];for(;++h<o.length;){const S=o[h],j=c[h];p=-1;const x=[];for(;++p<d;){const A=S[p]||"";let T="",F="";if(n.alignDelimiters!==!1){const R=u[p]-(j[p]||0),I=a[p];I===114?T=" ".repeat(R):I===99?R%2?(T=" ".repeat(R/2+.5),F=" ".repeat(R/2-.5)):(T=" ".repeat(R/2),F=T):F=" ".repeat(R)}n.delimiterStart!==!1&&!p&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||p)&&x.push(" "),n.alignDelimiters!==!1&&x.push(T),x.push(A),n.alignDelimiters!==!1&&x.push(F),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||p!==d-1)&&x.push("|")}y.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return y.join(`
|
|
19
|
-
`)}function _N(e){return e==null?"":String(e)}function Vh(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 DN(e,t,n,r){const i=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const o=n.indentLines(n.containerFlow(e,a.current()),BN);return i(),o}function BN(e,t,n){return">"+(n?"":" ")+e}function ON(e,t){return Kh(e,t.inConstruct,!0)&&!Kh(e,t.notInConstruct,!1)}function Kh(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 Yh(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
20
|
-
`&&ON(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
21
|
-
`}function WN(e,t){const n=String(e);let r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function FN(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 $N(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 zN(e,t,n,r){const i=$N(n),a=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(FN(e,n)){const p=n.enter("codeIndented"),g=n.indentLines(a,HN);return p(),g}const c=n.createTracker(r),u=i.repeat(Math.max(WN(a,i)+1,3)),d=n.enter("codeFenced");let h=c.move(u);if(e.lang){const p=n.enter(`codeFencedLang${o}`);h+=c.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${o}`);h+=c.move(" "),h+=c.move(n.safe(e.meta,{before:h,after:`
|
|
22
|
-
`,encode:["`"],...c.current()})),p()}return h+=c.move(`
|
|
23
|
-
`),a&&(h+=c.move(a+`
|
|
24
|
-
`)),h+=c.move(u),d(),h}function HN(e,t,n){return(n?"":" ")+e}function Yu(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 UN(e,t,n,r){const i=Yu(n),a=i==='"'?"Quote":"Apostrophe",o=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${a}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),c()),o(),d}function qN(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 ha(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Fo(e,t,n){const r=wi(e),i=wi(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}}jg.peek=GN;function jg(e,t,n,r){const i=qN(n),a=n.enter("emphasis"),o=n.createTracker(r),c=o.move(i);let u=o.move(n.containerPhrasing(e,{after:i,before:c,...o.current()}));const d=u.charCodeAt(0),h=Fo(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=ha(d)+u.slice(1));const p=u.charCodeAt(u.length-1),g=Fo(r.after.charCodeAt(0),p,i);g.inside&&(u=u.slice(0,-1)+ha(p));const m=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:g.outside,before:h.outside},c+u+m}function GN(e,t,n){return n.options.emphasis||"*"}function VN(e,t){let n=!1;return Vu(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,zc}),!!((!e.depth||e.depth<3)&&Fu(e)&&(t.options.setext||n))}function KN(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(VN(e,n)){const h=n.enter("headingSetext"),p=n.enter("phrasing"),g=n.containerPhrasing(e,{...a.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 o="#".repeat(i),c=n.enter("headingAtx"),u=n.enter("phrasing");a.move(o+" ");let d=n.containerPhrasing(e,{before:"# ",after:`
|
|
30
|
-
`,...a.current()});return/^[\t ]/.test(d)&&(d=ha(d.charCodeAt(0))+d.slice(1)),d=d?o+" "+d:o,n.options.closeAtx&&(d+=" "+o),u(),c(),d}Tg.peek=YN;function Tg(e){return e.value||""}function YN(){return"<"}Ig.peek=XN;function Ig(e,t,n,r){const i=Yu(n),a=i==='"'?"Quote":"Apostrophe",o=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${a}`),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(")"),o(),d}function XN(){return"!"}Eg.peek=JN;function Eg(e,t,n,r){const i=e.referenceType,a=n.enter("imageReference");let o=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+"]["),o();const h=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return o(),n.stack=h,a(),i==="full"||!d||d!==p?u+=c.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function JN(){return"!"}Mg.peek=QN;function Mg(e,t,n){let r=e.value||"",i="`",a=-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+" ");++a<n.unsafe.length;){const o=n.unsafe[a],c=n.compilePattern(o);let u;if(o.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 QN(){return"`"}function Rg(e,t){const n=Fu(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))}Pg.peek=ZN;function Pg(e,t,n,r){const i=Yu(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let c,u;if(Rg(e,n)){const h=n.stack;n.stack=[],c=n.enter("autolink");let p=o.move("<");return p+=o.move(n.containerPhrasing(e,{before:p,after:">",...o.current()})),p+=o.move(">"),c(),n.stack=h,p}c=n.enter("link"),u=n.enter("label");let d=o.move("[");return d+=o.move(n.containerPhrasing(e,{before:d,after:"](",...o.current()})),d+=o.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),d+=o.move("<"),d+=o.move(n.safe(e.url,{before:d,after:">",...o.current()})),d+=o.move(">")):(u=n.enter("destinationRaw"),d+=o.move(n.safe(e.url,{before:d,after:e.title?" ":")",...o.current()}))),u(),e.title&&(u=n.enter(`title${a}`),d+=o.move(" "+i),d+=o.move(n.safe(e.title,{before:d,after:i,...o.current()})),d+=o.move(i),u()),d+=o.move(")"),c(),d}function ZN(e,t,n){return Rg(e,n)?"<":"["}Ag.peek=ej;function Ag(e,t,n,r){const i=e.referenceType,a=n.enter("linkReference");let o=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+"]["),o();const h=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return o(),n.stack=h,a(),i==="full"||!d||d!==p?u+=c.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function ej(){return"["}function Xu(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 tj(e){const t=Xu(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 nj(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 Lg(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 rj(e,t,n,r){const i=n.enter("list"),a=n.bulletCurrent;let o=e.ordered?nj(n):Xu(n);const c=e.ordered?o==="."?")":".":tj(n);let u=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&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),Lg(n)===o&&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&&(o=c),n.bulletCurrent=o;const d=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),d}function sj(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 ij(e,t,n,r){const i=sj(n);let a=n.bulletCurrent||Xu(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const c=n.createTracker(r);c.move(a+" ".repeat(o-a.length)),c.shift(o);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(o))+p:(m?a:a+" ".repeat(o-a.length))+p}}function aj(e,t,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(e,r);return a(),i(),o}const oj=ol(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function lj(e,t,n,r){return(e.children.some(function(o){return oj(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function cj(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}_g.peek=uj;function _g(e,t,n,r){const i=cj(n),a=n.enter("strong"),o=n.createTracker(r),c=o.move(i+i);let u=o.move(n.containerPhrasing(e,{after:i,before:c,...o.current()}));const d=u.charCodeAt(0),h=Fo(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=ha(d)+u.slice(1));const p=u.charCodeAt(u.length-1),g=Fo(r.after.charCodeAt(0),p,i);g.inside&&(u=u.slice(0,-1)+ha(p));const m=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:g.outside,before:h.outside},c+u+m}function uj(e,t,n){return n.options.strong||"*"}function dj(e,t,n,r){return n.safe(e.value,r)}function hj(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 pj(e,t,n){const r=(Lg(n)+(n.options.ruleSpaces?" ":"")).repeat(hj(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Dg={blockquote:DN,break:Yh,code:zN,definition:UN,emphasis:jg,hardBreak:Yh,heading:KN,html:Tg,image:Ig,imageReference:Eg,inlineCode:Mg,link:Pg,linkReference:Ag,list:rj,listItem:ij,paragraph:aj,root:lj,strong:_g,text:dj,thematicBreak:pj};function fj(){return{enter:{table:mj,tableData:Xh,tableHeader:Xh,tableRow:bj},exit:{codeText:kj,table:gj,tableData:ic,tableHeader:ic,tableRow:ic}}}function mj(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 bj(e){this.enter({type:"tableRow",children:[]},e)}function ic(e){this.exit(e)}function Xh(e){this.enter({type:"tableCell",children:[]},e)}function kj(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 xj(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=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:o,tableCell:u,tableRow:c}};function o(m,y,S,j){return d(h(m,S,j),m.align)}function c(m,y,S,j){const x=p(m,S,j),A=d([x]);return A.slice(0,A.indexOf(`
|
|
32
|
-
`))}function u(m,y,S,j){const x=S.enter("tableCell"),A=S.enter("phrasing"),T=S.containerPhrasing(m,{...j,before:a,after:a});return A(),x(),T}function d(m,y){return LN(m,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function h(m,y,S){const j=m.children;let x=-1;const A=[],T=y.enter("table");for(;++x<j.length;)A[x]=p(j[x],y,S);return T(),A}function p(m,y,S){const j=m.children;let x=-1;const A=[],T=y.enter("tableRow");for(;++x<j.length;)A[x]=u(j[x],m,y,S);return T(),A}function g(m,y,S){let j=Dg.inlineCode(m,y,S);return S.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function wj(){return{exit:{taskListCheckValueChecked:Jh,taskListCheckValueUnchecked:Jh,paragraph:Sj}}}function vj(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Cj}}}function Jh(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Sj(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 a=-1,o;for(;++a<i.length;){const c=i[a];if(c.type==="paragraph"){o=c;break}}o===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 Cj(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);a&&c.move(o);let u=Dg.listItem(e,t,n,{...r,...c.current()});return a&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(h){return h+o}}function Nj(){return[rN(),CN(),IN(),fj(),wj()]}function jj(e){return{extensions:[sN(),NN(e),EN(),xj(e),vj()]}}const Tj={tokenize:Aj,partial:!0},Bg={tokenize:Lj,partial:!0},Og={tokenize:_j,partial:!0},Wg={tokenize:Dj,partial:!0},Ij={tokenize:Bj,partial:!0},Fg={name:"wwwAutolink",tokenize:Rj,previous:zg},$g={name:"protocolAutolink",tokenize:Pj,previous:Hg},zr={name:"emailAutolink",tokenize:Mj,previous:Ug},Er={};function Ej(){return{text:Er}}let ws=48;for(;ws<123;)Er[ws]=zr,ws++,ws===58?ws=65:ws===91&&(ws=97);Er[43]=zr;Er[45]=zr;Er[46]=zr;Er[95]=zr;Er[72]=[zr,$g];Er[104]=[zr,$g];Er[87]=[zr,Fg];Er[119]=[zr,Fg];function Mj(e,t,n){const r=this;let i,a;return o;function o(p){return!Gc(p)||!Ug.call(r,r.previous)||Ju(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(p))}function c(p){return Gc(p)?(e.consume(p),c):p===64?(e.consume(p),u):n(p)}function u(p){return p===46?e.check(Ij,h,d)(p):p===45||p===95||fn(p)?(a=!0,e.consume(p),u):h(p)}function d(p){return e.consume(p),i=!0,u}function h(p){return a&&i&&wn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function Rj(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!zg.call(r,r.previous)||Ju(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Tj,e.attempt(Bg,e.attempt(Og,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Pj(e,t,n){const r=this;let i="",a=!1;return o;function o(p){return(p===72||p===104)&&Hg.call(r,r.previous)&&!Ju(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),c):n(p)}function c(p){if(wn(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),a?d:(a=!0,u)):n(p)}function d(p){return p===null||Bo(p)||jt(p)||Rs(p)||sl(p)?n(p):e.attempt(Bg,e.attempt(Og,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function Aj(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function Lj(e,t,n){let r,i,a;return o;function o(d){return d===46||d===95?e.check(Wg,u,c)(d):d===null||jt(d)||Rs(d)||d!==45&&sl(d)?u(d):(a=!0,e.consume(d),o)}function c(d){return d===95?r=!0:(i=r,r=void 0),e.consume(d),o}function u(d){return i||r||!a?n(d):t(d)}}function _j(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Wg,t,a)(o):o===null||jt(o)||Rs(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&r++,e.consume(o),i}}function Dj(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),a):c===93?(e.consume(c),i):c===60||c===null||jt(c)||Rs(c)?t(c):n(c)}function i(c){return c===null||c===40||c===91||jt(c)||Rs(c)?t(c):r(c)}function a(c){return wn(c)?o(c):n(c)}function o(c){return c===59?(e.consume(c),r):wn(c)?(e.consume(c),o):n(c)}}function Bj(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return fn(a)?n(a):t(a)}}function zg(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||jt(e)}function Hg(e){return!wn(e)}function Ug(e){return!(e===47||Gc(e))}function Gc(e){return e===43||e===45||e===46||e===95||fn(e)}function Ju(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 Oj={tokenize:Gj,partial:!0};function Wj(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Hj,continuation:{tokenize:Uj},exit:qj}},text:{91:{name:"gfmFootnoteCall",tokenize:zj},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Fj,resolveTo:$j}}}}function Fj(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){o=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(!o||!o._balanced)return n(u);const d=or(r.sliceSerialize({start:o.end,end:r.now()}));return d.codePointAt(0)!==94||!a.includes(d.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function $j(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 a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function zj(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;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(a>999||p===93&&!o||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)||(o=!0),a++,e.consume(p),p===92?h:d}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Hj(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,c;return u;function u(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(y)}function h(y){if(o>999||y===93&&!c||y===null||y===91||jt(y))return n(y);if(y===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return a=or(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return jt(y)||(c=!0),o++,e.consume(y),y===92?p:h}function p(y){return y===91||y===92||y===93?(e.consume(y),o++,h):h(y)}function g(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),i.includes(a)||i.push(a),ot(e,m,"gfmFootnoteDefinitionWhitespace")):n(y)}function m(y){return t(y)}}function Uj(e,t,n){return e.check(Ca,t,e.attempt(Oj,t,n))}function qj(e){e.exit("gfmFootnoteDefinition")}function Gj(e,t,n){const r=this;return ot(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function Vj(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,c){let u=-1;for(;++u<o.length;)if(o[u][0]==="enter"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._close){let d=u;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[u][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[u][1].end)},p={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[u][1].start)},g=[["enter",h,c],["enter",o[d][1],c],["exit",o[d][1],c],["enter",p,c]],m=c.parser.constructs.insideSpan.null;m&&Fn(g,g.length,0,il(m,o.slice(d+1,u),c)),Fn(g,g.length,0,[["exit",p,c],["enter",o[u][1],c],["exit",o[u][1],c],["exit",h,c]]),Fn(o,d-1,u-d+3,g),u=d+g.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type==="strikethroughSequenceTemporary"&&(o[u][1].type="data");return o}function a(o,c,u){const d=this.previous,h=this.events;let p=0;return g;function g(y){return d===126&&h[h.length-1][1].type!=="characterEscape"?u(y):(o.enter("strikethroughSequenceTemporary"),m(y))}function m(y){const S=wi(d);if(y===126)return p>1?u(y):(o.consume(y),p++,m);if(p<2&&!n)return u(y);const j=o.exit("strikethroughSequenceTemporary"),x=wi(y);return j._open=!x||x===2&&!!S,j._close=!S||S===2&&!!x,c(y)}}}class Kj{constructor(){this.map=[]}add(t,n,r){Yj(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[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 a of i)t.push(a);i=r.pop()}this.map.length=0}}function Yj(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 Xj(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 a=r.length-1;r[a]=r[a]==="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 Jj(){return{flow:{null:{name:"table",tokenize:Qj,resolveAll:Zj}}}}function Qj(e,t,n){const r=this;let i=0,a=0,o;return c;function c(E){let H=r.events.length-1;for(;H>-1;){const K=r.events[H][1].type;if(K==="lineEnding"||K==="linePrefix")H--;else break}const B=H>-1?r.events[H][1].type:null,oe=B==="tableHead"||B==="tableRow"?I:u;return oe===I&&r.parser.lazy[r.now().line]?n(E):oe(E)}function u(E){return e.enter("tableHead"),e.enter("tableRow"),d(E)}function d(E){return E===124||(o=!0,a+=1),h(E)}function h(E){return E===null?n(E):Le(E)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),m):n(E):tt(E)?ot(e,h,"whitespace")(E):(a+=1,o&&(o=!1,i+=1),E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),o=!0,h):(e.enter("data"),p(E)))}function p(E){return E===null||E===124||jt(E)?(e.exit("data"),h(E)):(e.consume(E),E===92?g:p)}function g(E){return E===92||E===124?(e.consume(E),p):p(E)}function m(E){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(E):(e.enter("tableDelimiterRow"),o=!1,tt(E)?ot(e,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):y(E))}function y(E){return E===45||E===58?j(E):E===124?(o=!0,e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),S):R(E)}function S(E){return tt(E)?ot(e,j,"whitespace")(E):j(E)}function j(E){return E===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),x):E===45?(a+=1,x(E)):E===null||Le(E)?F(E):R(E)}function x(E){return E===45?(e.enter("tableDelimiterFiller"),A(E)):R(E)}function A(E){return E===45?(e.consume(E),A):E===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(E))}function T(E){return tt(E)?ot(e,F,"whitespace")(E):F(E)}function F(E){return E===124?y(E):E===null||Le(E)?!o||i!==a?R(E):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(E)):R(E)}function R(E){return n(E)}function I(E){return e.enter("tableRow"),G(E)}function G(E){return E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),G):E===null||Le(E)?(e.exit("tableRow"),t(E)):tt(E)?ot(e,G,"whitespace")(E):(e.enter("data"),z(E))}function z(E){return E===null||E===124||jt(E)?(e.exit("data"),G(E)):(e.consume(E),E===92?L:z)}function L(E){return E===92||E===124?(e.consume(E),z):z(E)}}function Zj(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],c=!1,u=0,d,h,p;const g=new Kj;for(;++n<e.length;){const m=e[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(c=!1,u!==0&&(Qh(g,t,u,d,h),h=void 0,u=0),d={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},g.add(n,0,[["enter",d,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,p=void 0,a=[0,0,0,0],o=[0,n+1,0,0],c&&(c=!1,h={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},g.add(n,0,[["enter",h,t]])),i=y.type==="tableDelimiterRow"?2:h?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],p=to(g,t,a,i,void 0,p),a=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],p=to(g,t,a,i,void 0,p)),a=o,o=[a[1],n,0,0])):y.type==="tableHead"?(c=!0,u=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(u=n,a[1]!==0?(o[0]=o[1],p=to(g,t,a,i,n,p)):o[1]!==0&&(p=to(g,t,o,i,n,p)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(u!==0&&Qh(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=Xj(t.events,n))}return e}function to(e,t,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(a.end=Object.assign({},oi(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const u=oi(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const d=oi(t.events,n[2]),h=oi(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 y=n[2]+1,S=n[3]-n[2]-1;e.add(y,S,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(a.end=Object.assign({},oi(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function Qh(e,t,n,r,i){const a=[],o=oi(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function oi(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const eT={name:"tasklistCheck",tokenize:nT};function tT(){return{text:{91:eT}}}function nT(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"),a)}function a(u){return jt(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),o):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),o):n(u)}function o(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):tt(u)?e.check({tokenize:rT},t,n)(u):n(u)}}function rT(e,t,n){return ot(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function sT(e){return tg([Ej(),Wj(),Vj(e),Jj(),tT()])}const iT={};function aT(e){const t=this,n=e||iT,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(sT(n)),a.push(Nj()),o.push(jj(n))}const oT="X-CodingNS-Assistant-Source",lT="butler-ui",ac=new Map;async function Hr(e,t={},n={}){const r=new Headers(t.headers);r.set(oT,lT);const i=cT();if(ac.get(i)===!1){if(n.unsupportedFallback!==void 0)return Zh(n.unsupportedFallback);throw ep()}try{const o=await pe.request(e,{...t,headers:r});return ac.set(i,!0),o}catch(o){if(!uT(o))throw o;if(ac.set(i,!1),n.unsupportedFallback!==void 0)return Zh(n.unsupportedFallback);throw ep()}}function cT(){return pu()}function Zh(e){return typeof e=="function"?e():e}function uT(e){return e instanceof mu&&(e.status===404||e.status===405||e.status===501)}function ep(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function dT(){return pe.request("/api/butler/profile")}function TL(e){return pe.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function IL(e){return pe.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function EL(){return pe.request("/api/butler/control-session")}function ML(){return pe.request("/api/butler/control-sessions")}function RL(e){return pe.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function PL(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 pe.request(r)}function AL(){return pe.request("/api/butler/control-session/reset",{method:"POST"})}function LL(e={}){return pe.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function _L(e){return pe.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function DL(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 BL(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 OL(e){return Hr(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function WL(e,t){return Hr(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function FL(e){return Hr(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function $L(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 zL(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 HL(e){return Hr(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function UL(e){return Hr(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function qL(e){return pe.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function GL(){return pe.request("/api/butler/control-session/events")}function hT(){return pe.request("/api/butler/overview")}function pT(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 pe.request(r)}function VL(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 pe.request(i)}function qg(e={}){var i,a;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),(a=e.projectId)!=null&&a.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 pe.request(r)}function fT(e){return pe.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function mT(e={}){var i,a;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.projectId)!=null&&i.trim()&&t.set("projectId",e.projectId.trim()),(a=e.sessionId)!=null&&a.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 pe.request(r)}function KL(e){return pe.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function gT(e){return pe.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function YL(e){return pe.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function XL(e,t){return pe.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function tp(e,t){return pe.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 JL(e){return pe.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function QL(e){return pe.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function bT(e){return pe.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function kT(){return pe.request("/api/butler/notifications/archives")}function yT(e,t){return pe.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function xT(e){const t=new URLSearchParams;return t.set("sessionId",e),pe.request(`/api/butler/session-target?${t.toString()}`)}function ZL(e){const t=new URLSearchParams;return t.set("sessionId",e),pe.request(`/api/butler/session-action-context?${t.toString()}`)}function e2(e){return pe.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}const $o="*** Begin Patch",zo="*** End Patch";function np(e){const t=e.replace(/\r\n/g,`
|
|
33
|
-
`);if(!t.includes($o)||!t.includes(zo))return null;const n=t.split(`
|
|
34
|
-
`),r=[];let i=null,a=null;for(const o of n){if(o===$o||o===zo)continue;if(o.startsWith("*** Update File: ")){i=oc("update",o.slice(17)),r.push(i),a=null;continue}if(o.startsWith("*** Add File: ")){i=oc("add",o.slice(14)),r.push(i),a={oldLineNumber:0,newLineNumber:1};continue}if(o.startsWith("*** Delete File: ")){i=oc("delete",o.slice(17)),r.push(i),a=null;continue}if(!i)continue;if(o.startsWith("*** Move to: ")){i.nextPath=o.slice(13),i.lines.push({kind:"meta",text:o,oldLineNumber:null,newLineNumber:null});continue}if(o.startsWith("@@")){a=ST(o)??{oldLineNumber:0,newLineNumber:0},i.lines.push({kind:"hunk",text:o,oldLineNumber:null,newLineNumber:null});continue}if(o==="*** End of File"){i.lines.push({kind:"meta",text:o,oldLineNumber:null,newLineNumber:null});continue}if(i.action==="add"&&o.startsWith("+")){i.additions+=1,i.statsKnown=!0,i.lines.push({kind:"add",text:o,oldLineNumber:null,newLineNumber:(a==null?void 0:a.newLineNumber)??i.additions}),a&&(a.newLineNumber+=1);continue}if(!a){i.lines.push({kind:"meta",text:o,oldLineNumber:null,newLineNumber:null});continue}if(o.startsWith("+")){i.additions+=1,i.statsKnown=!0,i.lines.push({kind:"add",text:o,oldLineNumber:null,newLineNumber:a.newLineNumber}),a.newLineNumber+=1;continue}if(o.startsWith("-")){i.deletions+=1,i.statsKnown=!0,i.lines.push({kind:"remove",text:o,oldLineNumber:a.oldLineNumber,newLineNumber:null}),a.oldLineNumber+=1;continue}if(o.startsWith(" ")||o.length===0){i.lines.push({kind:"context",text:o,oldLineNumber:a.oldLineNumber,newLineNumber:a.newLineNumber}),a.oldLineNumber+=1,a.newLineNumber+=1;continue}i.lines.push({kind:"meta",text:o,oldLineNumber:null,newLineNumber:null})}return r.length===0?null:{files:r,totalAdditions:r.reduce((o,c)=>o+c.additions,0),totalDeletions:r.reduce((o,c)=>o+c.deletions,0)}}function wT(e,t=[]){const n=e.replace(/\r\n/g,`
|
|
35
|
-
`).trim();if(!n)return null;if(n.includes($o)&&n.includes(zo))return n;const r=[...new Set(t.map(i=>i.trim()).filter(i=>i.length>0))];return r.length!==1||!CT(n)?null:[$o,`*** Update File: ${r[0]}`,n,zo].join(`
|
|
36
|
-
`)}function vT(e){const t=NT(e);if(!t)return[];const n=t.replace(/\r\n/g,`
|
|
37
|
-
`).split(`
|
|
38
|
-
`),r=[];let i=!1;for(const a of n){const o=a.trim();if(!i){/^Success\.\s+Updated the following files:/i.test(o)&&(i=!0);continue}if(!o){if(r.length>0)break;continue}const c=o.match(/^[A-Z?]\s+(.+)$/),u=((c==null?void 0:c[1])??o).trim();if(!u)break;r.push(u)}return[...new Set(r)]}function rp(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function oc(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,statsKnown:!1,lines:[]}}function ST(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function CT(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
|
|
39
|
-
@@`)||e.startsWith("+")||e.startsWith("-")}function NT(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 jT=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,TT=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,IT=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,ET=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,MT=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,sp=/```question\s*([\s\S]*?)```/i;function pa(e){const t=PT(e),n=RT(t);if(n)return n;const r=AT(t);return r||{...Vg(t),structuredQuestions:null}}function RT(e){var r;const t=e.match(sp);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";if(!n)return null;try{const i=JSON.parse(n),a=Gg(i);return a?{text:Qu(e.replace(sp,"").trim()),inlineImages:[],structuredQuestions:a}:null}catch{return null}}function PT(e){return e.replace(MT,"")}function AT(e){const t=e.trim();if(!_T(t))return null;try{const n=JSON.parse(t),r=Gg(n),i=DT(r?LT(n):n);return i.text||i.inlineImages.length>0||r?{...i,structuredQuestions:r}:null}catch{return null}}function LT(e){const t=ja(e);if(!t||!("questions"in t))return e;const{questions:n,...r}=t;return r}function _T(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function DT(e){const t=[],n=[];return To(e,t,n),{text:Qu(t.join(`
|
|
40
|
-
|
|
41
|
-
`)),inlineImages:Kg(n),structuredQuestions:null}}function Gg(e){const t=ja(e);if(!t)return null;const n=BT(t.questions);return n.length===0?null:{questions:n}}function BT(e){return Array.isArray(e)?e.map((t,n)=>OT(t,n)).filter(t=>t!==null):[]}function OT(e,t){const n=ja(e);if(!n)return null;const r=jr(dn(n.question));if(!r)return null;const i=WT(n.options);return i.length===0?null:{id:jr(dn(n.id))??`structured-question-${t+1}`,header:jr(dn(n.header))??"问题",question:r,allowOther:!!(n.allowOther??n.isOther),secret:!!(n.secret??n.isSecret),options:i}}function WT(e){return Array.isArray(e)?e.map(t=>{const n=ja(t);if(!n)return null;const r=jr(dn(n.label));return r?{label:r,description:jr(dn(n.description))}:null}).filter(t=>t!==null):[]}function To(e,t,n){if(typeof e=="string"){const o=Vg(e);o.text&&t.push(o.text),n.push(...o.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(o=>To(o,t,n));return}if(typeof e!="object")return;const r=e,i=new Set,a=FT(r);a&&(n.push(a),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(o=>{o in r&&i.add(o)}));for(const o of["image_url","url","src","source"]){const c=r[o];typeof c!="string"||!Yg(c)||(n.push(Is(c,dn(r.alt))),i.add(o))}for(const o of["text","message","content","output","result","summary","caption"])o in r&&(i.add(o),To(r[o],t,n));i.size>0||Object.values(r).forEach(o=>{To(o,t,n)})}function Vg(e){const t=[];let n=e;return n=n.replace(ET,(r,i,a)=>{const o=UT(i,"name"),c=HT(a);return c!=null&&c.url&&t.push(Is(c.url,c.altText||o)),""}),n=n.replace(TT,(r,i,a)=>(t.push(Is(a,i)),"")),n=n.replace(IT,(r,i)=>(t.push(Is(i,null)),"")),n=n.replace(jT,(r,i,a)=>(t.push(Is(r,null,`image/${i}`,Ho(a))),"")),{text:Qu(n),inlineImages:Kg(t),structuredQuestions:null}}function Is(e,t,n,r){const i=n??$T(e)??"image/png";return{url:e,mimeType:i,altText:jr(t),estimatedBytes:r??zT(e)}}function FT(e){const t=ja(e.source);if(t){const i=dn(t.type).trim().toLowerCase(),a=ap(t.media_type??t.mime_type??t.mimeType),o=ip(t.data);if(i==="base64"&&a&&o)return Is(`data:${a};base64,${o}`,jr(dn(t.alt)||dn(t.name)||dn(e.alt)||dn(e.name)),a,Ho(o))}const n=ap(e.media_type??e.mime_type??e.mimeType),r=ip(e.data);return n&&r?Is(`data:${n};base64,${r}`,jr(dn(e.alt)||dn(e.name)),n,Ho(r)):null}function Kg(e){const t=new Map;return e.forEach(n=>{t.has(n.url)||t.set(n.url,n)}),[...t.values()]}function Qu(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 Yg(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function $T(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 zT(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?Ho(t[1]):null}function Ho(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 jr(e){const t=dn(e).trim();return t.length>0?t:null}function ip(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function ap(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 ja(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function HT(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=jr(dn(n.name)||dn(n.alt));return{url:Yg(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 UT(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return jr((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 qT=new Set(["updateplan"]),Xg=new Set(["todowrite"]),Vc=new Set(["todoread"]),Jg=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function t2(e,t){const n=KT(e,t);return n||YT(e,t)}function GT(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function VT(e,t,n){if(!e)return null;if(Kc(e.name)){const o=ki(e);if(!o||!ul(o.value))return null;const c=Qg(o.value,n);return!c||c.items.length===0?null:{provider:t,source:"plan",explanation:c.explanation,items:c.items,updatedAt:n}}const r=cl(e.name);if(!Xg.has(r)&&!Vc.has(r)&&!Jg.has(r))return null;const i=ki(e,(Vc.has(r),"prefer-output"));if(!i)return null;if(r==="taskdelete"||r==="taskremove"){const o=Zg(i.value);return o.length>0?{provider:t,source:"todo",explanation:null,items:o.map((c,u)=>({id:c,title:`Task ${u+1}`,status:"cancelled",detail:c,updatedAt:n})),updatedAt:n}:null}const a=Ji(i.value,n);return a.length===0?null:{provider:t,source:Kc(e.name)?"plan":"todo",explanation:null,items:a,updatedAt:n}}function KT(e,t){let n=null;for(const r of e){const i=r.toolCall;if(!i||cl(i.name)===""||!Kc(i.name))continue;const a=ki(i);if(!a||typeof a.value!="object"||a.value===null)continue;const o=Qg(a.value,r.timestamp);!o||o.items.length===0||(n={provider:t,source:"plan",explanation:o.explanation,items:o.items,updatedAt:r.timestamp})}return n}function YT(e,t){const n=new Map;let r=null;for(const a of e){const o=a.toolCall;if(!o)continue;const c=cl(o.name);if(Xg.has(c)){const h=ki(o),p=h?Ji(h.value,a.timestamp):[];p.length>0&&(lc(n,p),r=a.timestamp);continue}if(Vc.has(c)){const h=ki(o,"prefer-output"),p=h?Ji(h.value,a.timestamp):[];p.length>0&&(lc(n,p),r=a.timestamp);continue}if(!Jg.has(c))continue;const u=ki(o,"prefer-output");if(!u)continue;if(c==="tasklist"||c==="taskget"){const h=Ji(u.value,a.timestamp);h.length>0&&(lc(n,h),r=a.timestamp);continue}if(c==="taskdelete"||c==="taskremove"){const h=Zg(u.value);if(h.length>0){for(const p of h)n.delete(p);r=a.timestamp}continue}const d=Ji(u.value,a.timestamp);if(d.length!==0){for(const h of d)JT(n,h);r=a.timestamp}}const i=Array.from(n.values()).sort((a,o)=>a.updatedAt.localeCompare(o.updatedAt)).map(a=>({...a}));return i.length===0||!r?null:{provider:t,source:"todo",explanation:null,items:i,updatedAt:r}}function Kc(e){return qT.has(cl(e))}function Qg(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((i,a)=>eb(i,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${a+1}`,fallbackStatus:"pending",updatedAt:t})).filter(i=>i!==null);return r.length===0?null:{items:r,explanation:Dt(e.explanation)}}function ki(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=XT(r.text);if(i!==null)return{value:i,source:r.source}}return null}function XT(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=no(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const u=no(r[1].trim());if(u!==null)return u}const i=t.indexOf("{"),a=t.lastIndexOf("}");if(i>=0&&a>i){const u=no(t.slice(i,a+1));if(u!==null)return u}const o=t.indexOf("["),c=t.lastIndexOf("]");return o>=0&&c>o?no(t.slice(o,c+1)):null}function no(e){try{return JSON.parse(e)}catch{return null}}function Ji(e,t){return oa(e).map((r,i)=>eb(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${i+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function oa(e){if(Array.isArray(e))return e.flatMap(n=>oa(n));if(!ul(e))return[];if(tI(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=oa(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>oa(n))}function Zg(e){const n=oa(e).map(i=>Yc(i)).filter(i=>i!==null);if(n.length>0)return n;if(!ul(e))return[];const r=Yc(e);return r?[r]:[]}function eb(e,t){if(!ul(e))return null;const n=Dt(e.step)??Dt(e.title)??Dt(e.content)??Dt(e.task)??Dt(e.text)??Dt(e.name)??Dt(e.subject)??Dt(e.description)??t.fallbackTitle,r=Yc(e)??eI(t.fallbackIdPrefix,n),i=ZT(e,n);return{id:r,title:n,status:QT(e.status,t.fallbackStatus),detail:i,updatedAt:t.updatedAt}}function JT(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 lc(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function QT(e,t){var r;const n=(r=Dt(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 ZT(e,t){const n=[Dt(e.detail),Dt(e.details),Dt(e.description),Dt(e.reason),Dt(e.summary),Dt(e.note),Dt(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function Yc(e){return Dt(e.id)??Dt(e.taskId)??Dt(e.task_id)??Dt(e.uuid)??Dt(e.key)}function eI(e,t){return`${e}:${t.trim().toLowerCase()}`}function tI(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>Dt(t)!==null)}function cl(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function ul(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Dt(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function nI({snapshot:e,toolName:t="",expanded:n=!1,exportMode:r=!1,className:i,children:a,onToggleExpanded:o}){const c=GT(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:rI(e,t)}),s.jsx("span",{className:"task-tool-summary-text",children:sI(e.items,c)})]})]}),!r&&o?s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,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:iI(h.status)})]},h.id))}),a]})}function rI(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 sI(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 iI(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 aI(){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 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("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 n2(){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 r2(){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 s2(){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 i2(){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 tb="codingns.user-app.conversation-scroll",ei=1,lI=200,cI=1e7;function nb(){return typeof window<"u"&&typeof window.localStorage<"u"}function rb(e){return e.trim()}function sb(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),cI)}function ib(e){return!e||typeof e!="object"?null:{scrollTop:sb(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function ab(){if(!nb())return{schemaVersion:ei,bySessionId:{}};const e=window.localStorage.getItem(tb);if(!e)return{schemaVersion:ei,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==ei||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:ei,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,i])=>{const a=ib(i);return a?[r,a]:null}).filter(r=>!!r));return{schemaVersion:ei,bySessionId:n}}catch{return{schemaVersion:ei,bySessionId:{}}}}function uI(e){if(nb())try{window.localStorage.setItem(tb,JSON.stringify(e))}catch{}}function ro(e){const t=rb(e);if(!t)return null;const n=ab().bySessionId[t],r=ib(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function op(e,t){const n=rb(e);if(!n)return;const r=ab();r.bySessionId[n]={scrollTop:sb(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const i=Object.entries(r.bySessionId).sort((a,o)=>o[1].updatedAt-a[1].updatedAt).slice(0,lI);r.bySessionId=Object.fromEntries(i),uI(r)}const dI=5e3;let ti=null;function hI(){var t;if(ti!==null)return ti;if(typeof document>"u")return ti=0,ti;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),ti=Math.max(0,e.offsetWidth-e.clientWidth),e.remove(),ti}function pI(e){if(hI()>0){e.dataset.scrollbarLayout="stable";return}e.removeAttribute("data-scrollbar-layout")}function Zu(e){const t=f.useRef(null),n=e??t;return f.useEffect(()=>{const r=n.current;if(!r||typeof globalThis.window>"u")return;pI(r);let i=null;const a=()=>{i!==null&&(window.clearTimeout(i),i=null)},o=()=>{a(),r.removeAttribute("data-scrolling")},c=()=>{r.setAttribute("data-scrolling","true"),a(),i=window.setTimeout(()=>{r.removeAttribute("data-scrolling"),i=null},dI)},u=()=>{c()};return r.addEventListener("scroll",u,{passive:!0}),()=>{r.removeEventListener("scroll",u),o()}},[n]),n}function ed(e){var t,n;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((n=e.lastErrorDetail)!=null&&n.trim())}function fI(e,t,n){return`${e} is-${ob(t,n)}`}function ob(e,t){t==null||t.isActive;const n=bI(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 mI(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 a2(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function bI(e){return ed(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?kI(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function kI(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function yI(e){return ed(e)||e.syncStatus==="error"}function xI(e){if(!yI(e))return null;const t=vI(e.lastErrorCode),n=SI(e.lastErrorDetail),r=wI(t,n,e.syncStatus);return{title:e.syncStatus==="error"&&!ed(e)?l("conversation.syncStatusError"):l("conversation.runtimeErrorTitle"),summary:r,code:t,detail:n}}function wI(e,t,n){return t||(n==="error"?l("conversation.syncStatusError"):e?l("conversation.runtimeErrorFallbackDetail"):l("conversation.runtimeErrorFallbackDetail"))}function vI(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}function SI(e){const t=(e==null?void 0:e.replace(/\s+/g," ").trim())??"";return t.length>0?t:null}function CI(e){const t=e.messages.map(i=>({type:"message",key:i.id,message:i})),n=e.runtimeThinkingPlaceholder??null,r=xI({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 NI(e){return e.flatMap(t=>t.type==="message"?[t.message]:[])}function jI(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 o2(e,t){const n=e.filter(a=>a.type!=="runtime_thinking");if(!t)return n;const r={type:"runtime_thinking",key:`runtime-thinking:${t}`,label:t},i=n.findIndex(a=>a.type==="session_error");return i<0?[...n,r]:[...n.slice(0,i),r,...n.slice(i)]}function TI(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function II(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 a of t.matchAll(n)){const o=a.index??0,c=a[0];o>i&&r.push({type:"text",text:t.slice(i,o)}),r.push({type:/^request id:/i.test(c)?"request_id":"status_code",text:c}),i=o+c.length}return i<t.length&&r.push({type:"text",text:t.slice(i)}),r.filter(a=>a.text.length>0)}function lb(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 EI(e){return e==="user"?l("conversation.turnAbortedUser"):e==="runtime"?l("conversation.turnAbortedUnexpected"):l("conversation.turnAbortedGeneric")}const MI=480,lp=80,cp=240,RI=120,PI=18,AI=50,LI=3500,Xc=f.createContext(!1);function vi(e){return e.replace(/\\/g,"/")}function Uo(e){return/^[a-zA-Z]:\//.test(e)}function _I(e){return e.startsWith("/")||e.startsWith("//")||Uo(e)}function cb(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Uo(e)}function Jc(e){return e.replace(/\/+$/,"")}function td(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 ub(e){const t=[];for(const n of vi(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function dl(e){try{return decodeURIComponent(e)}catch{return e}}function Qc(e,t){const n=dl(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(cb(r))return null;if(r=vi(td(r.trim())),!r)return null;const i=Jc(vi(t.trim()));if(!i)return null;if(_I(r)){const a=Jc(r),o=Uo(i)?i.toLowerCase():i,c=Uo(a)?a.toLowerCase():a;if(c===o)return null;const u=`${o}/`;return c.startsWith(u)?a.slice(i.length+1):null}return ub(r)}function db(e){const t=dl(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(cb(n))return null;const r=vi(td(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 a=r.match(/(?:^|\/)office-artifacts\/([^/]+)\/([^/]+)$/i);return!(a!=null&&a[1])||!(a!=null&&a[2])?null:{kind:"task_file",taskId:a[1],fileName:a[2]}}return{kind:"artifact",artifactId:i[1]}}function DI(e){if(e.name.trim()!=="view_image")return null;const t=hl(e.input);return(t?pb(t,"path").trim():"")||null}function up(e){return vi(e).split("/").filter(Boolean).at(-1)??e}function BI(e,t){const n=DI(e);if(!n)return null;const r=db(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:up(n)};const i=t?Qc(n,t):ub(td(n));return{previewTarget:i?{kind:"workspace_file",relativePath:i}:null,displayPath:i??n,fileName:up(n)}}function Zc(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=Of(pu()).baseUrl;return Yk(e,i)}catch{return t}return t}function nd(e){return e.kind==="tool_call"||e.kind==="tool_result"}function hb(e){return e.toolCall?e.toolCall:nd(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 OI(e){return e==="shell_command"||e==="tool"?l("conversation.roleTool"):e}function hl(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 pb(e,t){const n=e[t];return typeof n=="string"?n:""}function ni(e,t){for(const n of t){const r=pb(e,n);if(r)return r}return""}function fa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function tn(e,t){if(!e)return null;const n=e[t];return fa(n)?n:null}function cc(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function wt(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 WI(e){const t=[e.output,e.input];for(const n of t){const r=fb(n,0);if(r)return r}return null}function fb(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(!fa(e))return null;if(FI(e))return{ok:!0,capability:wt(e,"capability")??"",auditId:wt(e,"auditId")??"",timestamp:wt(e,"timestamp")??"",targetRef:{kind:wt(tn(e,"targetRef"),"kind")??"none",id:wt(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 a=fb(i,t+1);if(a)return a}if(fa(i)){const a=mb(i,t+1);if(a)return a}}return null}function FI(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&fa(e.targetRef)&&fa(e.payload)}function $I(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(a=>{const o=typeof a.title=="string"&&a.title.trim()?a.title.trim():a.sessionId;n.set(a.sessionId,o),r.set(a.sessionId,i.workspace.id)})}),{workspaceNamesById:t,sessionNamesById:n,sessionWorkspaceIdsById:r}}function zI(e,t){const n=WI(e);return n?{...bb(n.capability),rows:QI(n,t)}:null}function HI(e,t){const n=UI(e);if(!n)return null;const r=qI(n);return r?{...KI(r),rows:JI(r,t)}:null}function UI(e){const t=hl(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 qI(e){const t=GI(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,a=r[1],o=a&&!a.startsWith("-")?a:null,c=r.slice(o?2:1),{options:u,positionals:d}=VI(c);return!o&&u["--help"]?{group:i,action:null,mode:"help",options:u,positionals:d}:{group:i,action:o,mode:"execute",options:u,positionals:d}}function GI(e){const t=[],n=/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`|\S+/g;for(const r of e.matchAll(n)){const i=r[0]??"";if(!i)continue;const a=i[0];if((a==='"'||a==="'"||a==="`")&&i[i.length-1]===a){t.push(i.slice(1,-1));continue}t.push(i)}return t}function VI(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 a=e[r+1];if(!a||a.startsWith("--")){t[i]=!0;continue}t[i]=a,r+=1}return{options:t,positionals:n}}function KI(e){if(e.mode==="help")return YI(e.group,e.action);const t=XI(e.group,e.action);return t?bb(t):{kind:rd(e.group),badge:gb(e.group),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCliSummaryCommand")}}function YI(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:rd(e),badge:gb(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 XI(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 rd(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 gb(e){switch(rd(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 JI(e,t){const n=[],r=ri(e,"--session-id")??e.positionals[0]??null,i=ri(e,"--project")??ri(e,"--project-id");return e.mode==="help"?(Ve(n,l("conversation.assistantCliLabelScope"),e.group??l("conversation.assistantCliScopeRoot")),Ve(n,l("conversation.assistantCliLabelAction"),e.action),n):(e.group==="sessions"&&Ve(n,l("conversation.assistantCapabilityLabelSession"),Es(r,null,t)),e.group==="timers"&&(Ve(n,l("conversation.assistantCapabilityLabelSession"),Es(r,null,t)),Ve(n,l("conversation.assistantCliLabelDelay"),ri(e,"--after-seconds"))),e.group==="terminals"&&Ve(n,l("conversation.assistantCapabilityLabelTerminal"),e.positionals[0]??null),(e.group==="workspaces"||e.group==="worktrees")&&Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),ss(e.positionals[0]??null,null,t)),Ve(n,l("conversation.assistantCliLabelProject"),i),Ve(n,l("conversation.assistantCliLabelMessage"),ri(e,"--message")),Ve(n,l("conversation.assistantCliLabelInput"),ri(e,"--input")),n.slice(0,4))}function ri(e,t){const n=e.options[t];return typeof n=="string"?n:null}function bb(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 QI(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const i=tn(r,"session");Ve(n,l("conversation.assistantCapabilityLabelSession"),Es(wt(i,"sessionId"),wt(i,"title"),t)),Ve(n,l("conversation.assistantCapabilityLabelProvider"),wt(i,"provider"));break}case"sessions.message.send":{const i=tn(r,"result");Ve(n,l("conversation.assistantCapabilityLabelSession"),Es(e.targetRef.id,null,t)),Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),kb(e.targetRef.id,t)),Ve(n,l("conversation.assistantCapabilityLabelStatus"),l("conversation.assistantCapabilityStatusCompleted")),Ve(n,l("conversation.assistantCapabilityLabelDueAt"),dp(wt(i,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const i=tn(r,"session");Ve(n,l("conversation.assistantCapabilityLabelSession"),Es(wt(i,"sessionId"),wt(i,"title"),t)),Ve(n,l("conversation.assistantCapabilityLabelProvider"),wt(i,"provider"));break}case"timers.create":case"timers.cancel":{const i=tn(r,"timer"),a=tn(i,"controlSession"),o=tn(a,"session");Ve(n,l("conversation.assistantCapabilityLabelTimer"),wt(i,"title")),Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),ss(wt(o,"workspaceId"),null,t)),Ve(n,l("conversation.assistantCapabilityLabelSession"),Es(wt(i,"targetSessionId"),null,t)),Ve(n,l("conversation.assistantCapabilityLabelDueAt"),dp(wt(i,"dueAt"))),Ve(n,l("conversation.assistantCapabilityLabelStatus"),tE(wt(i,"status")));break}case"terminals.input.send":case"terminals.close":Ve(n,l("conversation.assistantCapabilityLabelTerminal"),e.targetRef.id);break;case"workspaces.directory.create":{const i=tn(r,"result");Ve(n,l("conversation.assistantCapabilityLabelPath"),wt(i,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const i=tn(r,"workspace");Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),ss(wt(i,"id")??e.targetRef.id,wt(i,"name"),t)),Ve(n,l("conversation.assistantCapabilityLabelPath"),wt(i,"path"));break}case"workspaces.navigation-state.update":{const i=tn(r,"state");Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),ss(wt(i,"workspaceId")??e.targetRef.id,null,t)),Ve(n,l("conversation.assistantCapabilityLabelStatus"),wt(i,"collapsed")==="true"?l("conversation.assistantCapabilityNavigationCollapsed"):l("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const i=tn(r,"result"),a=tn(i,"workspace");Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),ss(wt(a,"id")??e.targetRef.id,wt(a,"name"),t)),Ve(n,l("conversation.assistantCapabilityLabelBranch"),wt(i,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const i=tn(r,"result");Ve(n,l("conversation.assistantCapabilityLabelWorkspace"),ss(e.targetRef.id,null,t)),Ve(n,l("conversation.assistantCapabilityLabelStatus"),wt(i,"status"));break}case"debug-targets.run":{const i=tn(r,"result");Ve(n,l("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),Ve(n,l("conversation.assistantCapabilityLabelRuntime"),wt(i,"runtimeId"));break}}return ZI(n,e,t),n.slice(0,4)}function ZI(e,t,n){t.targetRef.kind==="session"&&(Ve(e,l("conversation.assistantCapabilityLabelSession"),Es(t.targetRef.id,null,n)),Ve(e,l("conversation.assistantCapabilityLabelWorkspace"),kb(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&Ve(e,l("conversation.assistantCapabilityLabelWorkspace"),ss(t.targetRef.id,null,n)),t.targetRef.kind==="terminal"&&Ve(e,l("conversation.assistantCapabilityLabelTerminal"),t.targetRef.id),t.targetRef.kind==="timer"&&Ve(e,l("conversation.assistantCapabilityLabelTimer"),t.targetRef.id);const r=eE(t.payload);r!==null&&Ve(e,l("conversation.assistantCapabilityLabelCount"),String(r))}function Ve(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 Es(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 ss(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 kb(e,t){const n=e==null?void 0:e.trim();return n?ss(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function eE(e){const t=cc(e,"items");if(t)return t.length;const n=tn(e,"page"),r=cc(n,"items");if(r)return r.length;const i=tn(e,"history"),a=cc(i,"items");return a?a.length:null}function dp(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 tE(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 nE({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 rE(e){if(e.name==="apply_patch"){const c=np(e.input);if(c)return c;const u=vT(e.output||e.error||""),d=wT(e.input,u);return d?np(d):null}const t=e.name.trim().toLowerCase(),n=sE(t);if(!n)return null;const r=hl(e.input);if(!r)return null;const i=ni(r,["file_path","filePath","path"]);if(!i)return null;if(n==="write"){const c=ni(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=ni(r,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),u=ni(r,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/);return hp(i,[{oldLines:c,newLines:u}])}const o=(Array.isArray(r.edits)?r.edits:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;const u=c;return{oldLines:ni(u,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),newLines:ni(u,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/)}}).filter(c=>!!c);return o.length>0?hp(i,o):null}function sE(e){return e==="write"||e==="overwrite"?"write":e==="edit"?"edit":e==="multiedit"||e==="multi_edit"?"multiedit":null}function hp(e,t){const n=[];let r=0,i=0;return t.forEach((a,o)=>{n.push({kind:"hunk",text:`@@ -1,${a.oldLines.length} +1,${a.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),a.oldLines.forEach((c,u)=>{c.length===0&&a.oldLines.length===1&&a.newLines.length>0||(i+=1,n.push({kind:"remove",text:`-${c}`,oldLineNumber:u+1,newLineNumber:null}))}),a.newLines.forEach((c,u)=>{c.length===0&&a.newLines.length===1&&a.oldLines.length>0||(r+=1,n.push({kind:"add",text:`+${c}`,oldLineNumber:null,newLineNumber:u+1}))}),o<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 iE(e){const t=hl(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 pp(e){var a;const t=e.map(o=>({message:o,tool:hb(o)})).filter(o=>!!o.tool);if(t.length===0)return null;const n={...t[0].tool};let r=!1,i=!1;for(const{message:o,tool:c}of t)o.kind==="tool_call"&&(r=!0,!n.input&&c.input&&(n.input=c.input)),o.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:o})=>o.id).join(":"),messageIds:t.map(({message:o})=>o.id),tool:n,hasRequest:r,hasResult:i,updatedAt:((a=t.at(-1))==null?void 0:a.message.timestamp)??t[0].message.timestamp}}function aE(e){const t=[];let n=[],r=null;function i(){if(n.length===0)return;const a=pp(n);a&&t.push(a),n=[],r=null}for(const a of e){const o=hb(a),c=(o==null?void 0:o.callId.trim())??"";if(!o||c.length===0){i();const u=pp([a]);u&&t.push(u);continue}if(n.length===0){n=[a],r=c;continue}if(r===c){n.push(a);continue}i(),n=[a],r=c}return i(),t}function oE(e,t){const n=[],r=[];let i=0;function a(){if(r.length===0)return;const o=aE(r);if(o.length===0){const c=r[0];c&&n.push({type:"message",key:c.id,message:c}),r.length=0;return}o.forEach(c=>{n.push({type:"tool_group",key:c.key,group:c})}),r.length=0}for(const o of e){if(o.type!=="message"){a(),n.push(o);continue}const c=o.message,u=i;if(i+=1,!xb(t,u)){if(!nd(c)){a(),n.push({type:"message",key:c.id,message:c});continue}r.push(c)}}return a(),n}function lE(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=[],a=[],o=[];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),a.push(d);continue}o.push(d.id)}return{visibleItems:i,visibleMessages:a,hiddenMessageIds:o}}function yb(e){const t=lE(e.sessionSummary,e.items),n=oE(t.visibleItems,t.visibleMessages),r=fE(t.visibleMessages,e.provider),i=_E(t.visibleMessages);return{visibleMessages:t.visibleMessages,renderItems:n,leadingSystemPromptMessageIds:r,actionStateByMessageId:i,hiddenMessageIds:t.hiddenMessageIds,validationIssues:cE(t.visibleMessages,n)}}function cE(e,t){const n=[],r=t.map(u=>u.key),i=uE(r);i.length>0&&n.push(`duplicate_render_keys:${i.join(",")}`);const a=[];for(const u of t){if(u.type==="message"){a.push(u.message.id);continue}u.type==="tool_group"&&a.push(...u.group.messageIds)}const o=new Set(a);for(const u of e)fp(e,u.id)&&!o.has(u.id)&&n.push(`missing_render_message:${u.id}`);const c=e.filter(u=>fp(e,u.id)).map(u=>u.id);return a.join(",")!==c.join(",")&&n.push("render_order_mismatch"),n}function fp(e,t){const n=e.findIndex(r=>r.id===t);return n<0?!1:!xb(e,n)}function uE(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 xb(e,t){const n=e[t];if(!n||lb(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const i=e[r];if(!(!i||nd(i)))return i.role==="user"}return!1}function dE(e,t){if(!ay(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 hE(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 pE(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 fE(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 mE(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 gE(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])),a=new Map(t.map((u,d)=>[u,d])),o=new Map(n.map(u=>[u.id,u])),c=[];for(const u of r){const d=i.get(u)??null,h=a.get(u)??null;if(d===h)continue;const p=o.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 ma(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>ma(n)).join(""):e&&typeof e=="object"&&"props"in e?ma(((t=e.props)==null?void 0:t.children)??""):""}function bE(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:ma(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(i==null?void 0:i[1])??null}}function kE(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 sd(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(!kE(e))throw new Error(l("conversation.copyContentFailed"))}}function yE({className:e,children:t,onCopy:n,exportMode:r=!1}){const i=f.useContext(Xc),a=ma(t).trim();if(r||i||!a)return s.jsx("code",{className:e||void 0,children:t});function o(c){c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),n(a))}return s.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":l("conversation.copyAction"),onClick:()=>n(a),onKeyDown:o,children:t})}function xE({href:e,children:t,className:n,onInteract:r,exportMode:i=!1}){if(i)return s.jsx(Xc.Provider,{value:!0,children:s.jsx("a",{href:e,className:n,children:t})});const a=ma(t).trim()||(e?dl(e).trim():"");return s.jsx(Xc.Provider,{value:!0,children:s.jsx("a",{href:e,className:[n,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:o=>{o.preventDefault(),r(e,a)},children:t})})}function wb({language:e,codeClassName:t,content:n,exportMode:r=!1}){const{showToast:i}=lr(),a=$n(),o=(e==null?void 0:e.trim().toLowerCase())??null,c=o==="text",u=o||"code";async function d(){try{await sd(n,a),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 Qi({content:e,className:t,exportMode:n=!1}){const{showToast:r}=lr(),i=$n(),{navigationGroups:a,currentWorkspaceId:o,revealWorkspaceFile:c}=Lk(),[u,d]=f.useState({}),h=f.useMemo(()=>{var y;return((y=a.find(S=>S.workspace.id===o))==null?void 0:y.workspace)??null},[o,a]),p=h!=null&&h.path?Jc(vi(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 j=Array.from(new Map(S.map(F=>{const R=F.replace(/^<|>$/g,"").replace(/\s+"[^"]*"$/,"");if(!R||R.startsWith("#"))return null;const I=db(R);return I?[R,I]:null}).filter(F=>F!==null))),x=new Set(j.map(([F])=>F)),A=Array.from(new Map(S.map(F=>{const R=F.replace(/^<|>$/g,"").replace(/\s+"[^"]*"$/,"");if(!R||R.startsWith("#")||x.has(R)||/^data:image\//i.test(R)||/^https?:\/\//i.test(R)||!o||!p)return null;const I=Qc(R,p);return I?[R,I]:null}).filter(F=>F!==null)).entries()).map(([F,R])=>({sourceUrl:F,relativePath:R}));let T=!1;return Promise.all([...j.map(async([F,R])=>{try{const I=R.kind==="artifact"?await em(R.artifactId):await tm(R.taskId,R.fileName),G=Zc(I.previewPath,I.previewUrl,i.isDesktop);return G?[F,G]:null}catch{return null}}),...A.map(async F=>{try{if(!o)return null;const R=await nm(o,F.relativePath),I=Zc(R.previewPath,R.previewUrl,i.isDesktop);return I?[F.sourceUrl,I]:null}catch{return null}})]).then(F=>{T||d(Object.fromEntries([...F.filter(R=>R!==null)]))}),()=>{T=!0}},[e,o,p,i.isDesktop]);async function g(y){if(y.trim())try{await sd(y,i),r({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(S){r({title:S instanceof Error?S.message:l("conversation.copyContentFailed"),tone:"error"})}}function m(y,S){const j=y&&(h!=null&&h.path)?Qc(y,h.path):null;j&&c({workspaceId:(h==null?void 0:h.id)??o,filePath:j,openViewer:!1})||g(S||(y?dl(y).trim():""))}return s.jsx("div",{className:t,children:s.jsx(V1,{remarkPlugins:[aT],components:{p:({node:y,...S})=>s.jsx("p",{...S}),a(y){return s.jsx(xE,{href:typeof y.href=="string"?y.href:void 0,className:typeof y.className=="string"?y.className:void 0,onInteract:m,exportMode:n,children:y.children})},img(y){const S=typeof y.src=="string"?y.src.trim():"",j=u[S]??S,x=typeof y.alt=="string"?y.alt:"";return j?s.jsx("img",{src:j,alt:x,className:"message-markdown-image",loading:"lazy",decoding:"async"}):null},pre(y){const S=bE(y.children);return S?s.jsx(wb,{language:S.language,codeClassName:S.codeClassName,content:S.content,exportMode:n}):s.jsx("pre",{children:y.children})},code(y){const S=typeof y.className=="string"?y.className:"";return s.jsx(yE,{className:S||void 0,exportMode:n,onCopy:j=>{g(j)},children:y.children})}},children:e})})}function mp(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function wE(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 so({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return s.jsx(vE,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function vE({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){const[i,a]=f.useState({}),[o,c]=f.useState(null),u=f.useMemo(()=>n.map((g,m)=>{const y=mp(g,t==null?void 0:t[m]);if(y)return{id:g.id,kind:g.kind,fileName:g.fileName,fileSize:g.fileSize,url:y,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===o)??null;return f.useEffect(()=>{if(!o)return;function g(m){m.key==="Escape"&&c(null)}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[o]),f.useEffect(()=>{const g=n.filter((S,j)=>!mp(S,t==null?void 0:t[j]));if(!e||g.length===0){a({});return}let m=!1;const y=[];return a(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 j=await oy(e,S.id),x=URL.createObjectURL(j);return y.push(x),{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:x,status:"ready"}}catch{return{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"error"}}})).then(S=>{if(m){y.forEach(j=>URL.revokeObjectURL(j));return}a(Object.fromEntries(S.map(j=>[j.id,j])))}),()=>{m=!0,y.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",y=g.status==="loading"?l("conversation.attachmentPreviewLoading"):g.status==="error"?l("conversation.attachmentPreviewUnavailable"):m?l("conversation.attachmentPreviewOpen"):l("conversation.attachmentDownload"),S=wE(g.fileSize),j=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} - ${y}`,title:y,children:j},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} - ${y}`,title:y,children:j},g.id)})}),s.jsx(xu,{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 SE(){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 CE({tool:e,preview:t,exportMode:n=!1}){const[r,i]=f.useState(null),a=r===null?null:t.files[r]??null;return f.useEffect(()=>{if(r===null)return;function o(c){c.key==="Escape"&&i(null)}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((o,c)=>n?s.jsxs("div",{className:"apply-patch-summary-row",children:[s.jsx("span",{className:"apply-patch-summary-label",children:uc(o.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:io(o),children:rp(o.nextPath??o.path)}),hc(o)]},dc(o,c)):s.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>i(c),children:[s.jsx("span",{className:"apply-patch-summary-label",children:uc(o.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:io(o),children:rp(o.nextPath??o.path)}),hc(o)]},dc(o,c)))}),s.jsx(xu,{open:a!==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:a?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"apply-patch-modal-totals",children:TE(a)}),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:uc(a.action)}),s.jsx("strong",{children:io(a)})]}),hc(a)]}),s.jsx("div",{className:"apply-patch-diff-view",children:s.jsx("div",{className:"apply-patch-diff-scroll",children:a.lines.map((o,c)=>s.jsxs("div",{className:`apply-patch-diff-line ${IE(o.kind)}`,children:[s.jsx("span",{className:"apply-patch-line-number",children:bp(o.oldLineNumber)}),s.jsx("span",{className:"apply-patch-line-number",children:bp(o.newLineNumber)}),s.jsx("span",{className:"apply-patch-line-content",children:o.text||" "})]},`${io(a)}:${c}`))})})]},dc(a,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 NE({tool:e,snapshot:t,workspaceId:n,exportMode:r=!1}){const i=$n(),[a,o]=f.useState({status:"idle",url:null});return f.useEffect(()=>{if(r||!t.previewTarget){o({status:"idle",url:null});return}let c=!1;return o({status:"loading",url:null}),(t.previewTarget.kind==="workspace_file"?n?nm(n,t.previewTarget.relativePath):Promise.reject(new Error("workspace preview requires workspaceId")):t.previewTarget.kind==="office_artifact"?em(t.previewTarget.artifactId):tm(t.previewTarget.taskId,t.previewTarget.fileName)).then(d=>{if(c)return;const h=Zc(d.previewPath,d.previewUrl,i.isDesktop);o(h?{status:"ready",url:h}:{status:"error",url:null})}).catch(()=>{c||o({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:a.status==="ready"?s.jsx("img",{src:a.url,alt:t.fileName||l("conversation.attachmentPreviewAlt")}):s.jsx("div",{className:"view-image-tool-placeholder",children:a.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")})})]})}function vb({group:e,workspaceId:t,workspacePath:n,exportMode:r=!1}){const[i,a]=f.useState(!1),{navigationGroups:o}=Lk(),{tool:c,hasRequest:u,hasResult:d}=e,h=OI(c.name),p=f.useMemo(()=>BI(c,n),[c,n]),g=f.useMemo(()=>$I(o),[o]),m=f.useMemo(()=>zI(c,g),[g,c]),y=f.useMemo(()=>HI(c,g),[g,c]),S=f.useMemo(()=>VT(c,null,e.updatedAt),[e.updatedAt,c]),j=f.useMemo(()=>rE(c),[c.input,c.name]);if(p)return s.jsx(NE,{tool:c,snapshot:p,workspaceId:t,exportMode:r});if(j)return s.jsx(CE,{tool:c,preview:j,exportMode:r});if(m)return s.jsx(gp,{tool:c,snapshot:m,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{a(R=>!R)}});if(y)return s.jsx(gp,{tool:c,snapshot:y,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{a(R=>!R)}});if(S)return s.jsx(jE,{tool:c,snapshot:S,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{a(R=>!R)}});const x=iE(c),A=!!(c.input||c.output||c.error),T=A&&!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:x})]}),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:()=>A&&a(R=>!R),children:F}),i&&A&&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 gp({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:a,exportMode:o=!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(nE,{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})]})]}),o?null:s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:a,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,!o&&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 jE({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:a,exportMode:o=!1}){return s.jsx(nI,{snapshot:t,toolName:e.name,expanded:n,exportMode:o,onToggleExpanded:o?void 0:a,children:!o&&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 uc(e){return e==="add"?l("conversation.applyPatchAddedLabel"):e==="delete"?l("conversation.applyPatchDeletedLabel"):l("conversation.applyPatchEditedLabel")}function io(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function dc(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function hc(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 TE(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 IE(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function bp(e){return e===null||e<=0?"":String(e)}function EE(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Sb({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:EE(e)}),n]})]})}function Ts({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:i}){const{showToast:a}=lr(),o=$n(),[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 sd(e,o),a({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(S){a({title:S instanceof Error?S.message:l("conversation.copyContentFailed"),tone:"error"})}finally{u(!1)}}}async function y(){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(aI,{})}):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:()=>{y()},disabled:d,children:s.jsx(oI,{})}):null]})}function ME({message:e,kind:t,tone:n,actionState:r,onRetry:i,onForkMessage:a,forceExpanded:o=!1,exportMode:c=!1}){const[u,d]=f.useState(!1),h=pE(t,e.content),p=n==="user-message",g=o||u,m=t==="system_prompt"?l("conversation.systemPromptTitle"):t==="skill_context"?l("conversation.skillContextTitle"):l("conversation.rulesMessageTitle"),y=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:[o?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(j=>!j),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:y}),g&&s.jsx("div",{className:"rules-message-body",children:s.jsx(Qi,{content:e.content,className:"message-text message-content markdown-content",exportMode:c})}),p?s.jsx(Sb,{timestamp:e.timestamp,children:s.jsx(Ts,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(a&&e.deliveryState==="sent"),compact:!0,onFork:a?()=>a(e):null})}):s.jsx(Ts,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>i(e.clientRequestId),children:l("conversation.resendButton")})]})})}function Cb({message:e,provider:t,interruptedSource:n=null,foldedPromptKind:r=null,actionState:i,onRetry:a,onForkMessage:o,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"?lb(e.content):null,y=r??(dE(t,e.content)?"rules":hE(t,e.content)?"skill_context":null),S=f.useMemo(()=>pa(e.content),[e.content]),j=S.text,x=S.inlineImages,A=S.structuredQuestions,[T,F]=f.useState(!1),[R,I]=f.useState(!1),[G,z]=f.useState(null),[L,E]=f.useState(null);if(y){const H=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return s.jsx(ME,{message:e,kind:y,tone:H,actionState:i,onRetry:a,onForkMessage:o,forceExpanded:u,exportMode:u})}if(m){const H=EI(n),B=m.detail?`${H}
|
|
46
|
-
|
|
47
|
-
${m.detail}`:H;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(pc,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Qi,{content:B,className:"message-text message-content markdown-content",exportMode:u}),s.jsx(Ts,{text:B,canCopy:i.canCopy,canFork:!1,onFork:null})]})]})}if(h){const H=e.origin==="butler_proxy"||AE(e.clientRequestId),B=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function oe(){if(!B)return;const X=!T;if(F(X),!(!X||L||R)){I(!0),z(null);try{const Y=await gT(e.originRef);E(Y.task)}catch(Y){z(Y instanceof Error?Y.message:l("conversation.butlerOriginDetailLoadFailed"))}finally{I(!1)}}}const K=H?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:()=>{oe()},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")}),R?s.jsx("p",{children:l("conversation.butlerOriginDetailLoading")}):G?s.jsx("p",{children:G}):L?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:[l("conversation.butlerOriginDetailObjectiveLabel"),":",L.objective]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailStatusLabel"),":",LE(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(so,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),j?s.jsx(Qi,{content:j,className:"message-text message-content markdown-content",exportMode:u}):null,e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>a(e.clientRequestId),children:l("conversation.resendButton")}),s.jsx(Sb,{timestamp:e.timestamp,leading:K,children:s.jsx(Ts,{text:j,canCopy:i.canCopy,canFork:i.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(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(pc,{})}),s.jsxs("div",{className:"thinking-message-content",children:[s.jsx("div",{className:"thinking-message-label",children:l("conversation.thinkingLabel")}),s.jsx(so,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),j&&s.jsx(Qi,{content:j,className:"message-text message-content markdown-content thinking-message-text",exportMode:u}),s.jsx(Ts,{text:j,canCopy:i.canCopy,canFork:i.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(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(pc,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(so,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),j&&s.jsx(Qi,{content:j,className:"message-text message-content markdown-content",exportMode:u}),A&&d?s.jsx(RE,{messageId:e.id,prompt:A,onSubmit:d}):null,s.jsx(Ts,{text:j,canCopy:i.canCopy,canFork:i.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(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(so,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),j?s.jsx("div",{className:"message-text message-content",children:s.jsx(wb,{language:"text",content:j,exportMode:u})}):null,s.jsx(Ts,{text:j,canCopy:i.canCopy,canFork:i.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(e):null})]})})}function RE({messageId:e,prompt:t,onSubmit:n}){const[r,i]=f.useState({}),[a,o]=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:a||c,onClick:async()=>{o(!0);try{await n({messageId:e,answers:r})}finally{o(!1)}},children:a?l("conversation.permissionRequestSubmitting"):l("common.confirm")})})]})}function Nb(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:TI(e.label)||e.label}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})},e.key)}function jb(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:II(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 PE({sessionId:e,sessionSummary:t=null,workspaceId:n=null,workspacePath:r=null,items:i,provider:a,interruptedSource:o=null,assistantAvatar:c}){const u=f.useMemo(()=>yb({sessionSummary:t,items:i,provider:a}),[i,a,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(vb,{group:p.group,workspaceId:n,workspacePath:r,exportMode:!0})},p.key):p.type==="runtime_thinking"?Nb(p):p.type==="session_error"?jb(p):s.jsx(Cb,{message:p.message,provider:a,foldedPromptKind:h.has(p.message.id)?"system_prompt":null,actionState:{canCopy:!1,canFork:!1},onRetry:()=>{},onForkMessage:null,interruptedSource:o,assistantAvatar:c,exportMode:!0},p.key))]})})}function pc(){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 AE(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function LE(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 l2({sessionId:e="session",sessionSummary:t=null,workspaceId:n=null,workspacePath:r=null,items:i,historyState:a,loadingOlderMessages:o=!1,hasOlderMessages:c=!1,onLoadOlderMessages:u=()=>{},onRetryMessage:d,onForkMessage:h,provider:p,interruptedSource:g=null,assistantAvatar:m,followTailUpdates:y=!1,onSubmitStructuredQuestion:S}){var _t;const{showToast:j}=lr(),x=$n(),A=!y,T=f.useRef(null);Zu(T);const F=f.useRef(e),R=f.useRef(0),I=f.useRef(null),G=f.useRef(!0),z=f.useRef(null),L=f.useRef(null),E=f.useRef(!1),H=f.useRef(y?null:ro(e)),B=f.useRef(y?null:((_t=ro(e))==null?void 0:_t.lastMessageSignature)??null),oe=f.useRef(y?null:ro(e)),K=f.useRef(null),X=f.useRef(null),Y=f.useRef(null),D=f.useRef(0),V=f.useRef(!1),le=f.useRef(null),C=f.useRef(null),_e=f.useRef(null),[Z,N]=f.useState(!1),[be,ne]=f.useState(!1),fe=f.useRef(!1),ue=f.useRef(null),He=x.isMobile?0:LI,Ue=f.useMemo(()=>NI(i),[i]),je=f.useMemo(()=>jI(i),[i]),Te=f.useMemo(()=>yb({sessionSummary:t,items:i,provider:p}),[i,p,t]),O=Te.visibleMessages,q=Te.renderItems,J=Te.leadingSystemPromptMessageIds,Ce=Te.actionStateByMessageId,Ee=a==="loading"&&Ue.length===0;function ve(_){var de,Re,xe;if(!_)return null;try{const Se=JSON.parse(_);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((de=Se.toolCall)==null?void 0:de.status)=="string"?Se.toolCall.status:null,hasToolOutput:typeof((Re=Se.toolCall)==null?void 0:Re.output)=="string"?Se.toolCall.output.length>0:!1,hasToolError:typeof((xe=Se.toolCall)==null?void 0:xe.error)=="string"?Se.toolCall.error.length>0:!1}}catch{return{parseError:!0,length:_.length}}}function Tt(_){var de;return{id:_.id,rawRef:_.rawRef,role:_.role,kind:_.kind,deliveryState:_.deliveryState,timestamp:_.timestamp,sequence:_.sequence,attachmentCount:((de=_.attachments)==null?void 0:de.length)??0,contentPreview:pa(_.content).text.replace(/\r\n/g,`
|
|
48
|
-
`).trimEnd().slice(0,120)}}function nt(_){return _.type==="message"?{type:_.type,key:_.key,message:Tt(_.message)}:_.type==="runtime_thinking"?{type:_.type,key:_.key,labelPreview:_.label.slice(0,80)}:_.type==="session_error"?{type:_.type,key:_.key,code:_.error.code,summary:_.error.summary}:{type:_.type,key:_.key,callId:_.group.tool.callId,name:_.group.tool.name,hasRequest:_.group.hasRequest,hasResult:_.group.hasResult,updatedAt:_.group.updatedAt}}function mt(_,de){const Re=_.getBoundingClientRect(),xe=de.getBoundingClientRect(),Se=Math.max(xe.top,Re.top),ht=Math.min(xe.bottom,Re.bottom),Bt=Math.max(0,ht-Se);return{top:Math.round(xe.top),bottom:Math.round(xe.bottom),height:Math.round(xe.height),relativeTop:Math.round(xe.top-Re.top),relativeBottom:Math.round(xe.bottom-Re.top),bottomGap:Math.round(Re.bottom-xe.bottom),visibleHeight:Math.round(Bt),fullyVisible:xe.top>=Re.top&&xe.bottom<=Re.bottom}}function ae(_,de){var Se;const Re=de.dataset.messageId??null,xe=Re?O.find(ht=>ht.id===Re)??null:null;return{messageId:Re,role:(xe==null?void 0:xe.role)??null,kind:(xe==null?void 0:xe.kind)??null,className:de.className,textLength:((Se=de.textContent)==null?void 0:Se.length)??0,rect:mt(_,de)}}function se(_){var Se;if(!_)return null;const de=_.getBoundingClientRect(),Re=Array.from(_.children).filter(ht=>ht instanceof HTMLElement&&ht.classList.contains("message-item")),xe=_.querySelector("[data-runtime-thinking-placeholder='true']");return{listRect:{top:Math.round(de.top),bottom:Math.round(de.bottom),height:Math.round(de.height)},messageElementCount:Re.length,tailDomItems:Re.slice(-5).map(ht=>ae(_,ht)),runtimeThinkingPlaceholderDom:xe?{textLength:((Se=xe.textContent)==null?void 0:Se.length)??0,rect:mt(_,xe)}:null}}function ke(_,de={}){const Re=O[0]??null,xe=O.at(-1)??null,Se=q.at(-1)??null,ht=H.current,Bt=oe.current,ft=_?_.scrollHeight-_.clientHeight-_.scrollTop:null;return{sessionId:e,historyState:a,followTailUpdates:y,messagesLength:O.length,rawMessagesLength:Ue.length,renderItemsLength:q.length,firstMessageId:(Re==null?void 0:Re.id)??null,firstMessageRole:(Re==null?void 0:Re.role)??null,lastMessageId:(xe==null?void 0:xe.id)??null,lastMessageRole:(xe==null?void 0:xe.role)??null,lastMessageKind:(xe==null?void 0:xe.kind)??null,lastMessageTimestamp:(xe==null?void 0:xe.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:(_==null?void 0:_.scrollTop)??null,scrollHeight:(_==null?void 0:_.scrollHeight)??null,clientHeight:(_==null?void 0:_.clientHeight)??null,distanceToBottom:ft,stickToBottomRef:G.current,hasNewMessagesBelow:fe.current,previousMessageCount:R.current,previousLastMessage:ve(I.current),hiddenMessageIds:Te.hiddenMessageIds,validationIssues:Te.validationIssues,tailMessages:O.slice(-5).map(Tt),tailRenderItems:q.slice(-5).map(nt),dom:se(_),pendingRestoreState:ht===null?null:{scrollTop:ht.scrollTop,stickToBottom:ht.stickToBottom,lastMessage:ve(ht.lastMessageSignature)},currentScrollState:Bt===null?null:{scrollTop:Bt.scrollTop,stickToBottom:Bt.stickToBottom,lastMessage:ve(Bt.lastMessageSignature)},restoredTailMessage:ve(B.current),...de}}function ye(_,de,Re={}){Mc()&&Ky(_,ke(de,Re))}function Me(_){const Re=_.scrollHeight-_.clientHeight-_.scrollTop<=lp;return{scrollTop:_.scrollTop,stickToBottom:Re,lastMessageSignature:fe.current&&!Re?B.current:Cs(q.at(-1)??null)}}function $(_){return oe.current=Me(_),oe.current}function Q(_){const de=_.scrollHeight-_.clientHeight-_.scrollTop,Re=de<=lp;G.current=Re,Re&&fe.current&&(Qe(),fe.current=!1,B.current=Cs(q.at(-1)??null),ne(!1)),N(q.length>0&&(de>cp||fe.current)),$(_),ye("affordance.sync",_,{distanceToBottom:de,nextStickToBottom:Re})}function ge(_=T.current){A&&(_&&$(_),oe.current&&op(e,oe.current))}function Ne(_){A&&oe.current&&op(_,oe.current)}function Be(){K.current!==null&&(window.clearTimeout(K.current),K.current=null)}function Ke(){A&&(Be(),K.current=window.setTimeout(()=>{K.current=null,ge()},RI))}function Ie(_,de,Re={}){ye("jump_to_bottom.before",_,{reason:de,...Re}),_.scrollTop=_.scrollHeight,ye("jump_to_bottom.after",_,{reason:de,...Re})}function ut(){X.current!==null&&(window.clearTimeout(X.current),X.current=null)}function Qe(){ut(),V.current=!1,Y.current=null,D.current=0,le.current=null}function rt(_,de){const Re=Math.max(0,_.scrollHeight-_.clientHeight),xe=Math.max(0,Math.min(de,Re));le.current=xe,_.scrollTop=xe,G.current=!1,ye("manual_restore.apply",_,{targetScrollTop:de,maxScrollableTop:Re,nextScrollTop:xe}),N(q.length>0&&(Re-xe>cp||fe.current))}function st(){ut(),V.current&&(X.current=window.setTimeout(()=>{X.current=null;const _=T.current,de=Y.current;if(!_||de===null){Qe();return}if(rt(_,de),Date.now()<D.current){st();return}Qe(),Q(_)},AI))}function qe(_,de){if(He<=0){rt(de,_),Qe();return}V.current=!0,Y.current=_,D.current=Date.now()+He,rt(de,_),st()}function gt(){V.current&&(ye("manual_restore.interrupt",T.current),Qe())}function Ht(_){return E.current||!c||o||a!=="ready"||_.scrollTop>MI?!1:(E.current=!0,z.current=_.scrollHeight-_.scrollTop,L.current=Cs(q[0]??null),ye("older_history.prefetch",_,{pendingOlderLoadOffset:z.current,pendingOlderLoadHeadMessage:ve(L.current)}),u(),!0)}f.useEffect(()=>{a==="error"&&j({title:l("conversation.historyLoadFailed"),tone:"error"})},[a,j]),f.useLayoutEffect(()=>{var _,de;if(F.current!==e){const Re=F.current;Ne(Re),F.current=e,R.current=0,I.current=null,H.current=y?null:ro(e),B.current=((_=H.current)==null?void 0:_.lastMessageSignature)??null,oe.current=H.current,G.current=y?!0:((de=H.current)==null?void 0:de.stickToBottom)??!0,z.current=null,L.current=null,Qe(),fe.current=!1,ne(!1),N(!1),ye("session.switch",T.current,{previousSessionId:Re,nextSessionId:e})}},[y,A,e]),f.useLayoutEffect(()=>()=>{Be(),Qe(),Ne(F.current)},[A,e]),f.useLayoutEffect(()=>{const _=T.current,de=Cs(q.at(-1)??null);if(!_){R.current=q.length,I.current=de;return}const Re=R.current,xe=I.current,Se=H.current,ht=Re===0||q.length!==Re||de!==xe;if(ye("messages.effect.start",_,{previousCount:Re,previousLastMessage:ve(xe),currentLastMessage:ve(de),hasTailUpdate:ht}),Se&&a==="ready"){const Ut=!Se.stickToBottom&&Se.lastMessageSignature!==null&&de!==null&&Se.lastMessageSignature!==de;Se.stickToBottom?(Qe(),Ie(_,"restore_ready_stick_to_bottom",{hasTailUpdates:Ut})):(qe(Se.scrollTop,_),ye("restore_ready.manual",_,{hasTailUpdates:Ut,targetScrollTop:Se.scrollTop})),fe.current=Ut,B.current=Se.lastMessageSignature,ne(Ut),H.current=null,Q(_),R.current=q.length,I.current=de,$(_);return}if(Se&&a==="error"){Se.stickToBottom?(Qe(),Ie(_,"restore_error_stick_to_bottom")):(qe(Se.scrollTop,_),ye("restore_error.manual",_,{targetScrollTop:Se.scrollTop})),H.current=null,Q(_),R.current=q.length,I.current=de,$(_);return}if(V.current){rt(_,Y.current??_.scrollTop),R.current=q.length,I.current=de,$(_);return}const Bt=Cs(q[0]??null),ft=z.current,Ot=L.current,et=ft!==null&&!o&&Ot!==null&&Ot!==Bt&&q.length>=Re,ct=ht&&(y||G.current);ye("messages.effect.decision",_,{currentHeadMessage:ve(Bt),pendingOlderLoadOffset:ft,pendingOlderLoadHeadMessage:ve(Ot),shouldRestoreOlderLoadOffset:et,shouldFollowTailUpdate:ct,loadingOlderMessages:o}),et?(_.scrollTop=Math.max(0,_.scrollHeight-ft),z.current=null,L.current=null):z.current!==null&&!o?(z.current=null,L.current=null,ct&&Ie(_,"older_load_offset_cleared_follow_tail",{pendingOlderLoadOffset:ft})):ct&&Ie(_,"tail_update_follow"),Q(_),R.current=q.length,I.current=de},[a,o,q,e]),f.useEffect(()=>{if(!c){E.current=!1;return}!o&&z.current===null&&(E.current=!1)},[c,o,O.length]),f.useLayoutEffect(()=>{const _=_e.current;_!==je&&(ye("runtime_thinking.placeholder_change",T.current,{previousVisible:!!_,nextVisible:!!je,previousLength:(_==null?void 0:_.length)??0,nextLength:(je==null?void 0:je.length)??0,note:"Codex 思考中占位符已经并入统一 timeline source item 列表;调试时直接看 renderItems 尾部即可。"}),_e.current=je)},[je,e]),f.useEffect(()=>{const _=T.current;if(!Mc()||!_||typeof ResizeObserver>"u")return;const de=new ResizeObserver(()=>{ye("list.resize",_)});return de.observe(_),()=>{de.disconnect()}},[e,O.length]),f.useEffect(()=>{const _=mE(q),de=gE(ue.current,_,O);(Te.hiddenMessageIds.length>0||Te.validationIssues.length>0||de.length>0)&&Vy("timeline.render",{sessionId:e,hiddenMessageIds:Te.hiddenMessageIds,validationIssues:Te.validationIssues,assistantRenderMoves:de,rawTailMessages:Ue.slice(-6).map(Tt),visibleTailMessages:O.slice(-6).map(Tt),renderTailItems:q.slice(-6).map(nt)}),ue.current=_},[Ue,q,e,Te.hiddenMessageIds,Te.validationIssues,O]);function Ye(){const _=T.current;if(_){if(V.current){const de=le.current;de!==null&&Math.abs(_.scrollTop-de)<=1?le.current=null:gt()}Q(_),Ke(),ye("scroll",_),Ht(_)}}function dt(_){if(_.deltaY!==0&>(),_.deltaY>=0)return;const de=T.current;de&&Ht(de)}function De(_){var de;gt(),C.current=((de=_.touches[0])==null?void 0:de.clientY)??null}function bt(_){var Se;const de=C.current,Re=((Se=_.touches[0])==null?void 0:Se.clientY)??null;if(de===null||Re===null||Re-de<PI)return;gt();const xe=T.current;xe&&Ht(xe)}function Ze(){C.current=null}return s.jsxs("section",{className:"message-timeline",children:[a==="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:gt,onWheel:dt,onTouchStart:De,onTouchMove:bt,onTouchEnd:Ze,onTouchCancel:Ze,children:[Ee?s.jsx(SE,{}):null,o?s.jsx("div",{className:"timeline-status timeline-status-inline",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoadingOlder")})}):null,q.length===0&&a==="ready"&&s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}),q.map(_=>_.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(vb,{group:_.group,workspaceId:n,workspacePath:r})},_.key):_.type==="runtime_thinking"?Nb(_):_.type==="session_error"?jb(_):s.jsx(Cb,{message:_.message,provider:p,foldedPromptKind:J.has(_.message.id)?"system_prompt":null,actionState:Ce.get(_.message.id)??{canCopy:_.message.role==="user",canFork:!1},onRetry:d,onForkMessage:h,interruptedSource:g,assistantAvatar:m,onSubmitStructuredQuestion:S},_.key))]}),Z?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 _=T.current;_&&(Qe(),Ie(_,"scroll_button_click"),fe.current=!1,B.current=Cs(q.at(-1)??null),ne(!1),Q(_),ge(_))},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 Cs(e){return e?"type"in e?e.type==="message"?Cs(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 _E(e){const t=new Map;let n=0;function r(i){let a=null;for(let o=i-1;o>=n;o-=1){const c=e[o];if(!(!c||!DE(c))){a=c.id;break}}for(let o=n;o<i;o+=1){const c=e[o];if(c){if(c.role==="user"){t.set(c.id,{canCopy:!0,canFork:!1});continue}t.set(c.id,{canCopy:c.id===a,canFork:c.id===a})}}}for(let i=0;i<e.length;i+=1){const a=e[i];a&&a.role==="user"&&i>n&&(r(i),n=i)}return r(e.length),t}function DE(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function BE(e){return id(e)!==null}function OE(e){return e.isSubagent===!0&&!BE(e)}function id(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 WE(e){const t=id(e);return t==="reconstructed"?l("shell.sessionForkReconstructed"):t==="message"?l("shell.sessionForkMessage"):t==="session"?l("shell.sessionForkSession"):null}function FE(e){return e.sessionKind==="annotation"?"annotation":null}function c2(e){return FE(e)==="annotation"?l("conversation.actionSessionBadge"):null}const kp=120*1e3,$E=8,zE=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,HE=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/;function u2(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 Tb(e,t,n="sent",r=null){const i=t.kind??(t.role==="tool"?"tool_result":"text"),a=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:gM(t.provider,t.role,i,t.content),toolCall:a,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 d2(e,t,n,r=[],i=[],a=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:a,rawRef:`pending://${n}`,deliveryState:"sending",clientRequestId:n}}function h2(e,t){return Ib([...e,t])}function p2(e,t,n){const r=new Map,i=new Set,a=[];for(const o of e)r.set(o.id,o),i.add(o.id);for(const o of n){const c=Tb(t,o);a.push(c);const u=wM(r,c,t);if(u&&u!==c.id)continue;const d=xM(r,c,t),h=d&&d!==c.id?r.get(d)??null:null;d&&d!==c.id&&r.delete(d);const p=vM(r,i,c);if(p&&p!==c.id){const S=r.get(p)??null;if(S){const j=eu(S,c);os("session.messages.codex_equivalent_replace",{sessionId:t,previous:nn(S),incoming:nn(c),merged:nn(j)}),r.delete(p),r.set(o.messageId,j);continue}}const g=CM(r,c);if(g&&g!==c.id){const S=r.get(g)??null;if(S){const j=iM(S,c);os("session.messages.opencode_equivalent_replace",{sessionId:t,previous:nn(S),incoming:nn(c),merged:nn(j)}),r.set(g,j);continue}}const m=r.get(o.messageId)??null,y=h===null?c:sM(c,h);r.set(o.messageId,m?eu(m,y):y)}return Ib(NM(Array.from(r.values()),a))}function f2(e,t){const n=new Map;for(const r of e)n.set(vp(r),r);for(const r of t){const i=vp(r),a=n.get(i)??null;if(a){os("session.messages.runtime_overlay_merge",{overlayKey:i,mode:"update",previous:nn(a),incoming:nn(r)}),n.set(i,aM(a,r));continue}os("session.messages.runtime_overlay_merge",{overlayKey:i,mode:"insert",incoming:nn(r)}),n.set(i,r)}return Eb(Array.from(n.values()))}function m2(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function UE(e){const t=[];let n=null,r=!1;for(const i of e)if(!lM(n,i,r)){if(t.push(i),ka(i)){n=i,r=!1;continue}n&&cM(i)&&(r=!0)}return t}function qE(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Ab(r,n)){t.push(n);continue}t[t.length-1]=Lb(r,n)}return t}function GE(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],a=t[t.length-2],o=t[t.length-1];uM(r,i,a,o)&&t.splice(t.length-3,3,Lb(i,o))}return t}function VE(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!dM(r,n)){t.push(n);continue}t[t.length-1]=pM(r,n)}return t}function KE(e){const t=[];for(const n of e){const r=t.findIndex(i=>hM(i,n));if(r===-1){t.push(n);continue}t[r]=fM(t[r],n)}return t}function Ib(e){const t=Eb(e);return KE(VE(UE(GE(qE(t)))))}function Eb(e){return[...e].sort((t,n)=>Mb(t,n))}function Mb(e,t){const n=YE(e.rawRef,t.rawRef);if(n!==null&&n!==0)return n;if(e.sequence!==t.sequence)return e.sequence-t.sequence;const r=XE(e.rawRef,t.rawRef);if(r!==0)return r;const i=e.timestamp.localeCompare(t.timestamp);if(i!==0)return i;const a=JE(e.rawRef,t.rawRef);if(a!==0)return a;const o=rM(e.role,t.role);if(o!==0)return o;const c=e.rawRef.localeCompare(t.rawRef);return c!==0?c:e.id.localeCompare(t.id)}function YE(e,t){if(!e.startsWith("codex://")||!t.startsWith("codex://"))return null;const n=ga(e),r=ga(t);if(!n||!r||n!==r)return null;const i=ba(e),a=ba(t);if(i===null||a===null)return null;if(i!==a)return i-a;const o=Ps(e,"part")??0,c=Ps(t,"part")??0;return o-c}function ga(e){const t=e.match(/^codex:\/\/(.+?)(?:#|$)/);return(t==null?void 0:t[1])??null}function XE(e,t){const n=nM(e,t);if(n!==null&&n!==0)return n;const r=QE(e,t);if(r!==null&&r!==0)return r;const i=xp(e),a=xp(t);if(!i&&!a||!i||!a)return 0;const o=Math.max(i.length,a.length);for(let c=0;c<o;c+=1){const u=i[c],d=a[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 JE(e,t){const n=ba(e),r=ba(t);return n===null&&r===null?0:n===null?1:r===null?-1:n-r}function ba(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 QE(e,t){const n=yp(e),r=yp(t);if(!n||!r||n!==r)return null;const i=Ps(e,"part"),a=Ps(t,"part");return i===null||a===null?null:i-a}function yp(e){const t=e.match(/^(.+\/message\/[^/?#]+)\/part\/[^/?#]+(?:[?#].*)?$/i);return(t==null?void 0:t[1])??null}function xp(e){const t=ba(e);if(t!==null){const i=Ps(e,"part");return i===null?[t]:[t,i]}const n=ZE(e);if(n)return n;const r=eM(e);return r||null}function ZE(e){const t=Ps(e,"index");if(t===null)return null;const n=Ps(e,"part");return n===null?[t]:[t,n]}function Ps(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 eM(e){const t=e.match(/\/message\/(user|assistant|tool)-(\d+)\/part\/([a-z_]+)-(\d+)/i);if(!t)return null;const n=tM(t[1]??""),r=Number.parseInt(t[2]??"",10),i=Zi(t[3]??""),a=Number.parseInt(t[4]??"",10);return!Number.isFinite(r)||!Number.isFinite(a)?null:[r,n,i,a]}function tM(e){switch(e.toLowerCase()){case"user":return 0;case"assistant":return 1;case"tool":return 2;default:return 3}}function Zi(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 nM(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 a=r.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i),o=i.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i);if(a&&o){const j=a[1]??"",x=o[1]??"",A=a[2]??"",T=o[2]??"";return j!==x||A!==T?0:Zi(a[3]??"")-Zi(o[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),y=Number.parseInt(u[3]??"",10);if(!Number.isFinite(m)||!Number.isFinite(y))return null;const S=m-y;return S!==0?S:Zi(c[4]??"")-Zi(u[4]??"")}function rM(e,t){return wp(e)-wp(t)}function wp(e){switch(e){case"user":return 0;case"assistant":return 1;case"tool":return 2;case"system":default:return 3}}function sM(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function eu(e,t){if(e.id!==t.id)return t;if(Rb(e,t)){const o=qo(e.toolCall,t.toolCall),c=Pb(e,t,o,Go),u=Vo(e.attachments,t.attachments),d=Ko(e,t);return{...$r(e,t),kind:(o==null?void 0:o.status)==="running"?"tool_call":"tool_result",content:c,toolCall:o,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 $r(e,t);const n=qo(e.toolCall,t.toolCall),r=Go(e.content,t.content,e.timestamp,t.timestamp),i=Vo(e.attachments,t.attachments),a=Ko(e,t);return{...$r(e,t),content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:a.rawRef,timestamp:a.timestamp,sequence:a.sequence}}function iM(e,t){if(Rb(e,t)){const o=qo(e.toolCall,t.toolCall),c=Pb(e,t,o,Go),u=Vo(e.attachments,t.attachments),d=Ko(e,t);return{...$r(e,t),id:e.id,kind:(o==null?void 0:o.status)==="running"?"tool_call":"tool_result",content:c,toolCall:o,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{...$r(e,t),id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId};const n=qo(e.toolCall,t.toolCall),r=Go(e.content,t.content,e.timestamp,t.timestamp),i=Vo(e.attachments,t.attachments),a=Ko(e,t);return{...$r(e,t),id:e.id,content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:a.rawRef,timestamp:a.timestamp,sequence:a.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function Rb(e,t){return Ob(e,t)||ad(e,t)}function Pb(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 aM(e,t){return{...eu(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 vp(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=ga(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 oM(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=pa(e.content),i=pa(t.content);return _s(e.timestamp,t.timestamp,n)&&Pt(r.text)===Pt(i.text)&&yM(r.inlineImages,i.inlineImages)}function lM(e,t,n){return!e||n||!ka(e)||!ka(t)?!1:_s(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function ka(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function tu(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")}function cM(e){return tu(e)&&e.kind==="text"}function Ab(e,t){return tu(e)&&tu(t)&&e.kind===t.kind&&_s(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function uM(e,t,n,r){return!e||!t||!n||!r||!ka(e)||!ka(n)?!1:Ab(t,r)&&_s(e.timestamp,n.timestamp,120*1e3)&&Pt(e.content)===Pt(n.content)}function Lb(e,t){var o,c;const n=((o=e.attachments)==null?void 0:o.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,a=Pt(t.content).length;return i!==a?i>a?e:t:$r(e,t)}function dM(e,t){return!Sp(e)||!Sp(t)?!1:e.role===t.role&&_s(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function hM(e,t){return!Cp(e)||!Cp(t)?!1:e.role===t.role&&_s(e.timestamp,t.timestamp,120*1e3)&&Pt(e.content)===Pt(t.content)}function Sp(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Cp(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function pM(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,a=Pt(t.content).length;if(i!==a)return i>a?e:t;const o=e.rawRef.includes("#file="),c=t.rawRef.includes("#file=");return o!==c?o?e:t:$r(e,t)}function fM(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,a=Pt(t.content).length;if(i!==a)return i>a?e:t;const o=e.rawRef.includes("/context#"),c=t.rawRef.includes("/context#");return o!==c?o?e:t:$r(e,t)}function qo(e,t){return e?t?{...mM(e,t),input:_b(e.input,t.input),output:jp(e.output,t.output),error:jp(e.error,t.error)}:e:t}function mM(e,t){const n=Np(e.status),r=Np(t.status);return r!==n?r>n?t:e:t}function Np(e){return e==="running"?0:1}function Go(e,t,n,r){const i=Pt(e),a=Pt(t);if(i===a){const o=kM(e,t);return o!==null?o:e.length>=t.length?e:t}return i.length>a.length&&i.includes(a)?e:a.length>i.length&&a.includes(i)||r.localeCompare(n)>=0?t:e}function Vo(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 _b(e,t){return t.length>e.length?t:e}function jp(e,t){return e===null?t:t===null?e:_b(e,t)}function $r(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 Ko(e,t){return Mb(e,t)<=0?e:t}function Pt(e){return bM(e).replace(/\r\n/g,`
|
|
49
|
-
`).trimEnd()}function nu(e){return Pt(e).replace(/[ \t]+\n/g,`
|
|
50
|
-
`).replace(/\n{2,}/g,`
|
|
51
|
-
`).trim()}function gM(e,t,n,r){return e!=="claude-code"&&e!=="codex"||t!=="user"&&t!=="assistant"||n!=="text"&&n!=="thinking"?r:Db(r)}function bM(e){return Db(e).replace(/\r\n/g,`
|
|
52
|
-
`).trimEnd()}function ru(e){return HE.test(e)}function Db(e){return ru(e)?e.replace(zE,"").replace(/[ \t]+\n/g,`
|
|
53
|
-
`).replace(/\n{3,}/g,`
|
|
54
|
-
|
|
55
|
-
`).trimEnd():e}function kM(e,t){const n=ru(e),r=ru(t);return n===r?null:n?t:e}function yM(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 xM(e,t,n){return Wb(t)?Bb(e,t,"optimistic",n):null}function wM(e,t,n){return pl(t)?Bb(e,t,"authoritative",n):null}function vM(e,t,n){if(!Yo(n))return null;for(const[r,i]of e.entries())if(!(r===n.id||!t.has(r)||!SM(i,n)))return os("session.messages.codex_identity_bridge_match",{previous:nn(i),incoming:nn(n)}),r;return null}function SM(e,t){if(!jM(e,t))return!1;if(e.rawRef===t.rawRef)return!0;if(e.kind==="tool_call"||e.kind==="tool_result")return ad(e,t);const n=ga(e.rawRef),r=ga(t.rawRef);if(!n||!r||n!==r)return!1;const i=Math.abs(e.sequence-t.sequence);return i>1?(os("session.messages.codex_identity_bridge_rejected",{reason:"sequence_distance",sequenceDistance:i,previous:nn(e),incoming:nn(t)}),!1):!0}function CM(e,t){if(!Tp(t))return null;const n=Xo(t.rawRef);if(n===null)return null;const r=ls(t.timestamp);let i=null,a=Number.POSITIVE_INFINITY;for(const[o,c]of e.entries()){if(o===t.id||!Tp(c)||c.role!==t.role)continue;if(Ob(c,t))return o;if(c.kind!==t.kind||Xo(c.rawRef)!==n)continue;const d=ls(c.timestamp),h=Math.abs(d-r),g=Math.abs(c.sequence-t.sequence)*6e4+h;g<a&&(i=o,a=g)}return i}function Bb(e,t,n,r){const i=ls(t.timestamp),a=Pt(t.content),o=nu(t.content),c=su(t.attachments);let u=null,d=Number.POSITIVE_INFINITY;const h=[];for(const[p,g]of e.entries()){if(!(n==="optimistic"?pl(g):Wb(g)))continue;const y=Pt(g.content),S=nu(g.content),j=y===a,x=S===o;if(!j&&!x)continue;const A=ls(g.timestamp),T=Math.abs(A-i);if(T>300*1e3)continue;const F=Math.abs(g.sequence-t.sequence),R=su(g.attachments),I=IM(R,c);if(I==="conflict"&&(j||a.length===0)){h.push(Ep(g,{strictTextMatches:j,relaxedTextMatches:x,attachmentCompatibility:I,distanceMs:T,sequenceDistance:F}));continue}const G=T+F*15e3+(j?0:500)+EM(I);h.push(Ep(g,{strictTextMatches:j,relaxedTextMatches:x,attachmentCompatibility:I,distanceMs:T,sequenceDistance:F})),G<d&&(u=p,d=G)}return h.length>0&&os("session.messages.user_match",{sessionId:r,target:n,matchedId:u,matchedScore:Number.isFinite(d)?d:null,incoming:MM(t,{relaxedContent:o,attachmentSignature:c}),candidates:h.slice(0,5)}),u}function Yo(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.role==="assistant"||e.role==="tool")}function NM(e,t){const n=t.filter(Yo);return n.length===0?e:e.map(r=>{if(!TM(r))return r;const i=ls(r.timestamp),a=n.reduce((c,u)=>ls(u.timestamp)<i?c:Math.min(c,u.sequence),Number.POSITIVE_INFINITY);if(!Number.isFinite(a)||a>=r.sequence)return r;const o={...r,sequence:a};return os("session.messages.synthetic_user_rebased",{syntheticMessage:nn(r),rebasedMessage:nn(o),incomingAnchors:n.slice(0,5).map(nn)}),o})}function Tp(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&!pl(e)&&(e.role==="user"||e.role==="assistant"||e.role==="tool")}function Ip(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")&&e.toolCall!==null}function Ob(e,t){var i,a;if(!Ip(e)||!Ip(t))return!1;const n=((i=e.toolCall)==null?void 0:i.callId.trim())??"",r=((a=t.toolCall)==null?void 0:a.callId.trim())??"";return n&&r?n===r:Xo(e.rawRef)===Xo(t.rawRef)}function Xo(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 a=r.slice(0,i),o=new URLSearchParams(r.slice(i+1));if(!o.has("part"))return e;o.delete("part");const c=o.toString();return`${a}${c?`?${c}`:""}${n}`}function jM(e,t){if(!Yo(e)||!Yo(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?ad(e,t):Math.abs(e.sequence-t.sequence)>$E||!_s(e.timestamp,t.timestamp,kp)?!1:t.kind==="text"||t.kind==="thinking"?oM(e,t,kp):!1}function ad(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 pl(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 TM(e){return e.deliveryState==="sent"&&e.role==="user"&&e.kind==="text"&&e.rawRef.startsWith("synthetic://codex/")}function Wb(e){return e.role==="user"&&e.kind==="text"&&!pl(e)}function ls(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(pa(e.content).text).slice(0,160):Pt(e.content).slice(0,160)}}function su(e){return(e??[]).map(t=>[t.kind,t.fileName.trim().toLowerCase(),t.mimeType.trim().toLowerCase(),String(t.fileSize)].join(":")).sort().join("|")}function IM(e,t){return!e&&!t?"same":!e||!t?"one_side_missing":e===t?"same":"conflict"}function EM(e){switch(e){case"same":return 0;case"one_side_missing":return 2500;case"conflict":default:return 12e4}}function Ep(e,t){return{...nn(e),comparableContent:nu(e.content).slice(0,160),attachmentSignature:su(e.attachments),strictTextMatches:t.strictTextMatches,relaxedTextMatches:t.relaxedTextMatches,attachmentCompatibility:t.attachmentCompatibility,distanceMs:t.distanceMs,sequenceDistance:t.sequenceDistance}}function MM(e,t){return{...nn(e),comparableContent:t.relaxedContent.slice(0,160),attachmentSignature:t.attachmentSignature}}function g2(e){return e.reduce((n,r)=>Number.isFinite(r.sequence)&&r.sequence>n?r.sequence:n,0)+1}function _s(e,t,n){return Math.abs(ls(e)-ls(t))<=n}const RM=200;async function PM(e){const t=[],n=new Set;let r=null;for(;!(r&&n.has(r));){r&&n.add(r);const i=await Hf(e,r,RM,"forward"),a=i.messages.map(o=>Tb(e,o));if(t.push(...a),!i.nextCursor||i.nextCursor===r||a.length===0)break;r=i.nextCursor}return{messages:t}}function fc(e,t,n=new Date){return`${FM(e.title||l("conversation.titleFallback"))}-${WM(n)}.${t}`}function AM(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")}:${yi(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${yi(n.toISOString())}`,""];return t.forEach((a,o)=>{var c,u,d;i.push(`## ${o+1}. ${Fb(a)}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownTimeLabel")}:${yi(a.timestamp)}`),i.push(`- ${l("conversation.exportMarkdownTypeLabel")}:${OM(a)}`),(((c=a.attachments)==null?void 0:c.length)??0)>0&&i.push(`- ${l("conversation.exportMarkdownAttachmentsLabel")}:${a.attachments.length}`),i.push(""),a.content.trim()&&(i.push(a.content),i.push("")),a.toolCall&&(i.push(`### ${l("conversation.exportMarkdownToolSectionTitle")}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownToolNameLabel")}:${a.toolCall.name}`),i.push(`- ${l("conversation.exportMarkdownToolStatusLabel")}:${a.toolCall.status}`),i.push(""),a.toolCall.input.trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolInputLabel")}`),i.push(""),i.push("```text"),i.push(a.toolCall.input),i.push("```"),i.push("")),(a.toolCall.output??"").trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolOutputLabel")}`),i.push(""),i.push("```text"),i.push(a.toolCall.output??""),i.push("```"),i.push("")),(a.toolCall.error??"").trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolErrorLabel")}`),i.push(""),i.push("```text"),i.push(a.toolCall.error??""),i.push("```"),i.push(""))),(((u=a.attachments)==null?void 0:u.length)??0)>0&&(i.push(`### ${l("conversation.exportMarkdownAttachmentsSectionTitle")}`),i.push(""),(d=a.attachments)==null||d.forEach(h=>{i.push(`- ${h.fileName} (${h.kind}, ${h.mimeType}, ${$b(h.fileSize)})`)}),i.push(""))}),`${i.join(`
|
|
56
|
-
`).trimEnd()}
|
|
57
|
-
`}function Mp(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),a=document.createElement("a");a.href=i,a.download=e,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function LM(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}),a=URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=e,document.body.append(o),o.click(),o.remove(),URL.revokeObjectURL(a)}function _M(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")}:${yi(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${yi(n.toISOString())}`],a=new UM;return a.renderDocumentHeader(r,i),t.forEach((o,c)=>{a.renderMessageCard(c,o)}),eR(a.finish())}function DM(e){const t=Rp(e.htmlAttributes,e.htmlStyle),n=Rp(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>${zb(e.title)}</title>`,`<style>${e.styleText}</style>`,"</head>",`<body${n}>`,e.bodyHtml,"</body>","</html>"].join("")}function Fb(e){return`${BM(e)} · ${yi(e.timestamp)}`}function BM(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 OM(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 yi(e){const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function WM(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"),a=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0");return`${t}${n}${r}-${i}${a}${o}`}function $b(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 FM(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-")||"session"}function Rp(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}="${$M(i)}"`).join(" ")}`}function zb(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function $M(e){return zb(e).replaceAll('"',""")}const Hb=595.28,ea=841.89,Pp=40,Ap=40,li=36,Ub=Hb-li*2,zM=14,iu=12,ao=12,HM=72,oo=11,pi=9,Ki=12,Lp=20;class UM{constructor(){at(this,"pages",[[]]);at(this,"cursorTop",Pp)}renderDocumentHeader(t,n){this.drawRichText(t,li,this.cursorTop,Lp,[15,23,42],"sans"),this.cursorTop+=Lp+8,n.forEach(r=>{this.drawRichText(r,li,this.cursorTop,pi,[71,85,105],"sans"),this.cursorTop+=ts(pi)}),this.cursorTop+=18}renderMessageCard(t,n){const r=qM(t,n);let i=0,a=0;for(;i<r.lines.length||a===0;){this.ensureVerticalSpace(HM);const o=this.pickSegmentLines(r.lines,i);o.count===0&&r.lines.length>0&&(o.lines.push(r.lines[i]),o.count=1,o.height=ts(r.lines[i].fontSize));const c=a===0?r.header:`${r.header} · 续`,u=ao*2+ts(Ki)+8+Math.max(o.height,0);if(this.ensureVerticalSpace(u),this.drawCardSegment(r,c,o.lines,o.height),this.cursorTop+=u+zM,i+=o.count,a+=1,r.lines.length===0)break}}finish(){return this.pages.map(t=>t.join(`
|
|
58
|
-
`))}drawCardSegment(t,n,r,i){const a=ao*2+ts(Ki)+8+Math.max(i,0),o=this.cursorTop,c=ea-o-a;this.pushCommand(`${lo(t.backgroundColor)} rg ${lo(t.borderColor)} RG 1 w ${On(li)} ${On(c)} ${On(Ub)} ${On(a)} re B`);let u=o+ao;this.drawRichText(n,li+iu,u,Ki,t.headerColor,"sans"),u+=ts(Ki)+8,r.forEach(d=>{u+=d.gapBefore,this.drawRichText(d.text,li+iu,u,d.fontSize,d.color,d.fontKind),u+=ts(d.fontSize)})}pickSegmentLines(t,n){const r={lines:[],count:0,height:0},i=ea-this.cursorTop-Ap-ao*2-ts(Ki)-8;if(i<=0)return r;let a=0;for(let o=n;o<t.length;o+=1){const c=t[o],u=a+c.gapBefore+ts(c.fontSize);if(r.count>0&&u>i)break;r.lines.push(c),r.count+=1,a=u}return r.height=a,r}ensureVerticalSpace(t){this.cursorTop+t<=ea-Ap||(this.pages.push([]),this.cursorTop=Pp)}drawRichText(t,n,r,i,a,o){const c=ea-r-i;let u=n;YM(t).forEach(h=>{if(h.text){if(h.fontRef==="F1"){u=this.drawPdfUnicodeRun(h.text,u,c,i,a);return}this.pushCommand(`BT /${h.fontRef} ${On(i)} Tf ${lo(a)} rg 1 0 0 1 ${On(u)} ${On(c)} Tm (${ZM(h.text)}) Tj ET`),u+=JM(h.text,i,h.fontRef)}})}drawPdfUnicodeRun(t,n,r,i,a){let o=n;for(const c of Array.from(t))this.pushCommand(`BT /F1 ${On(i)} Tf ${lo(a)} rg 1 0 0 1 ${On(o)} ${On(r)} Tm <${KM(c)}> Tj ET`),o+=od(c,i,"F1");return o}pushCommand(t){var n;(n=this.pages[this.pages.length-1])==null||n.push(t)}}function qM(e,t){var o,c;const n=GM(t.role),r=Ub-iu*2,i=[],a=`${e+1}. ${Fb(t)}`;if(t.content.trim()&&es(i,t.content,r,oo,[15,23,42],0,"sans"),t.toolCall){const u=`${l("conversation.exportMarkdownToolSectionTitle")} · ${t.toolCall.name} · ${t.toolCall.status}`;es(i,u,r,oo,[30,41,59],10,"sans"),t.toolCall.input.trim()&&es(i,`${l("conversation.exportMarkdownToolInputLabel")}:${t.toolCall.input}`,r,pi,[71,85,105],6,"mono"),(t.toolCall.output??"").trim()&&es(i,`${l("conversation.exportMarkdownToolOutputLabel")}:${t.toolCall.output??""}`,r,pi,[71,85,105],6,"mono"),(t.toolCall.error??"").trim()&&es(i,`${l("conversation.exportMarkdownToolErrorLabel")}:${t.toolCall.error??""}`,r,pi,[185,28,28],6,"mono")}return(((o=t.attachments)==null?void 0:o.length)??0)>0&&(es(i,l("conversation.exportMarkdownAttachmentsSectionTitle"),r,oo,[30,41,59],10,"sans"),(c=t.attachments)==null||c.forEach(u=>{es(i,`- ${u.fileName} (${u.kind}, ${u.mimeType}, ${$b(u.fileSize)})`,r,pi,[71,85,105],4,"sans")})),i.length===0&&es(i,l("conversation.exportMarkdownTextType"),r,oo,[100,116,139],0,"sans"),{header:a,headerColor:n.headerColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,lines:i}}function GM(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 es(e,t,n,r,i,a=0,o="sans"){t.replace(/\r\n/g,`
|
|
59
|
-
`).split(`
|
|
60
|
-
`).forEach((d,h)=>{const p=VM(d,n,r);if(p.length===0){e.push({text:" ",fontSize:r,color:i,gapBefore:h===0?a:4,fontKind:o});return}p.forEach((g,m)=>{e.push({text:g,fontSize:r,color:i,gapBefore:h===0&&m===0?a:m===0?4:0,fontKind:o})})})}function VM(e,t,n,r){if(!e.trim())return[];const i=[];let a="",o=0;const c=qb();for(const u of Array.from(e)){const d=od(u,n,c);if(a&&o+d>t){i.push(a.trimEnd()),a=u,o=d;continue}a+=u,o+=d}return a.trim().length>0&&i.push(a.trimEnd()),i}function od(e,t,n){if(n==="F1")return t*(QM(e)/1e3);const r=n==="F3"?600:Gb[e]??556;return t*(r/1e3)}function ts(e){return e*1.5}function lo(e){return e.map(t=>On(t/255)).join(" ")}function On(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/u,"").replace(/\.$/u,"")}function KM(e){return[254,255,...Array.from(e).flatMap(r=>{const i=r.codePointAt(0)??32;if(i<=65535)return[i];const a=i-65536,o=55296+(a>>10&1023),c=56320+(a&1023);return[o,c]}).flatMap(r=>[r>>8&255,r&255])].map(r=>r.toString(16).padStart(2,"0").toUpperCase()).join("")}function YM(e,t){if(!e)return[];const n=qb();return[{text:e,fontRef:n}]}function qb(e,t){return"F1"}function XM(e){const t=e.codePointAt(0)??0;return t>=32&&t<=126}function JM(e,t,n){return Array.from(e).reduce((r,i)=>r+od(i,t,n),0)}function QM(e){return XM(e)?Gb[e]??556:e===" "?278:1e3}function ZM(e){return e.replace(/\\/gu,"\\\\").replace(/\(/gu,"\\(").replace(/\)/gu,"\\)")}const Gb={" ":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 eR(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(y=>{const S=c,j=c+1;n.push(S),c+=2;const x=new TextEncoder().encode(y);t[j]=`<< /Length ${x.length} >>
|
|
61
|
-
stream
|
|
62
|
-
${y}
|
|
63
|
-
endstream`,t[S]=["<< /Type /Page","/Parent 2 0 R",`/MediaBox [0 0 ${On(Hb)} ${On(ea)}]`,"/Resources << /Font << /F1 3 0 R /F2 5 0 R /F3 6 0 R >> >>",`/Contents ${j} 0 R`,">>"].join(" ")}),t[2]=`<< /Type /Pages /Kids [${n.map(y=>`${y} 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 y=1;y<t.length;y+=1){const S=t[y];if(!S)continue;h[y]=p;const j=`${y} 0 obj
|
|
66
|
-
${S}
|
|
67
|
-
endobj
|
|
68
|
-
`;d.push(j),p+=new TextEncoder().encode(j).length}const g=p,m=["xref",`0 ${u+1}`,"0000000000 65535 f "];for(let y=1;y<h.length;y+=1){const S=h[y];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 _p=48;function tR(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function ld(e,t){const n=tR(e)||t,r=n.length>_p?n.slice(0,_p).trimEnd():n;return{fullTitle:n,displayTitle:r}}function co(e,t){return(t??"").localeCompare(e??"")}function Dp(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function uo(e){return(e==null?void 0:e.trim())??""}function ya(e,t,n){if(n==="updatedAt"){const o=co(e.updatedAt,t.updatedAt);if(o!==0)return o}if(n==="title"){const o=Dp(uo(e.title),uo(t.title));if(o!==0)return o}else{const o=co(e.createdAt,t.createdAt);if(o!==0)return o}const r=co(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=co(e.createdAt,t.createdAt);if(i!==0)return i;const a=Dp(uo(e.title),uo(t.title));return a!==0?a:e.sessionId.localeCompare(t.sessionId)}function Ta(e,t){return[...e].sort((n,r)=>ya(n,r,t))}function cd(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:Ta(n.sessions,t),children:cd(n.children,t)})):[]}const mc=5,gc=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function nR(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function rR(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,mc).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:gc[u]??gc[0]})),a=e.slice(mc);if(a.length===0)return i;const o=a.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:o,ratio:o/n,color:gc[mc]}),i}function sR(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 a=t,o=i===e.length-1?1:Math.min(1,t+r.ratio);return t=o,`${r.color} ${Bp(a)} ${Bp(o)}`}).join(", ")})`}function iR(e){return{"--workbench-manage-chart-background":sR(e)}}function Bp(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const aR=8,oR=12,lR=160,Op=96;function cR(e,t,n,r={}){const i=r.gapPx??aR,a=r.viewportMarginPx??oR,o=r.defaultWidthPx??lR,c=r.estimatedHeightPx??Op,u=r.minHeightPx??Op,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-a*2),g=Math.max(0,d-a*2),m=ho(Math.max(t.width||o,o),0,g),y=Math.max(t.height||c,c),S=Math.max(0,d-e.x-a),j=Math.max(0,e.x-a),x=S<m&&j>S,A=Math.max(0,h-e.y-i-a),T=Math.max(0,e.y-i-a),F=A<y&&T>A,I=ho(Math.max(F?T:A,u),0,p),G=Math.min(y,I),z=x?e.x-m:e.x,L=Math.max(a,d-a-m),E=F?e.y-i-G:e.y+i,H=Math.max(a,h-a-G),B=ho(z,a,L),oe=ho(E,a,H),K=x||B<e.x?"right":"left";return{top:oe,left:B,width:m,maxHeight:Math.max(0,I),transformOrigin:`${F?"bottom":"top"} ${K}`}}function ho(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const Vb="workbench.navigation.snapshot",Kb=1800*1e3,uR="workbench.navigation.snapshot.host.";function Yb(e){return`${uR}${e}`}function dR(e=Kb,t=Zo(ar.getState())){if(t){const n=Ao(Yb(t),e);if(n)return n}return Ao(Vb,e)}function po(e,t=Zo(ar.getState())){ra(Vb,e),t&&ra(Yb(t),e)}function Wp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:Ta(n.sessions,t),childWorktrees:hR(n.childWorktrees,t)}))}function hR(e,t){return cd(e,t)}function Jo(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 pR(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Jo(n.workspace)),Xb(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 Xb(e,t,n,r,i=r.name){var a;for(const o of t){const c=((a=o.meta.displayName)==null?void 0:a.trim())||o.workspace.name;e.set(o.workspace.id,{workspaceId:o.workspace.id,tone:"worktree",backgroundColor:o.workspace.backgroundColor??null,displayName:c,workspaceName:o.workspace.name,branchName:o.meta.branchName||null,depth:o.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:o.meta.parentWorkspaceId||r.id,parentDisplayName:i}),Xb(e,o.children,n,o.workspace,c)}}class au extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class fR{constructor(){at(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=ar.getState();if(Zo(n)===t)return;const r=Xk(n,t);if(!r)throw new au("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await Jk(r.baseUrl)).reachable)throw new au("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const a=Ff(r.id);if(a)try{await ca.loginForHost(r,{username:a.username,password:a.password})}catch{}const o=ar.getState(),c=new Date().toISOString();if($f(r)){ar.updateRuntime({discoveredHosts:o.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}Tc.setActiveDiscoveredHost(null),await ar.update({hosts:o.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const mR=new fR,gR=1700;function bR({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:a,popoverRef:o,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 y=0;const S=()=>{const x=a.current;if(!x)return;const A=x.getBoundingClientRect(),T=Math.max(180,Math.min(u,window.innerWidth-h*2)),F=Math.min(Math.max(h,A.right-T),Math.max(h,window.innerWidth-h-T)),R=A.top>=Math.min(240,window.innerHeight*.42),I=Math.round(R?A.top-d:A.bottom+d);g({top:I,left:Math.round(F),width:T,placeAbove:R})},j=()=>{window.cancelAnimationFrame(y),y=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.cancelAnimationFrame(y),window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[a,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:gR,transform:p.placeAbove?"translateY(-100%)":void 0};return Fr.createPortal(s.jsx("div",{id:t,ref:o,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:m,children:c}),document.body)}const bc={status:"idle",latencyMs:null};function Jb({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[a,o]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,g]=f.useState(""),[m,y]=f.useState(null),[S,j]=f.useState(null),[x,A]=f.useState(null),[T,F]=f.useState(!1),[R,I]=f.useState(!1),[G,z]=f.useState(bc),[L,E]=f.useState(null),H=f.useRef(null),B=f.useRef(null),oe=f.useRef(null),K=f.useRef(null),X=gu(O=>O),Y=fu(O=>O.session),{showToast:D}=lr(),V=Ic(X),le=Zo(X),C=ly(),_e=Qk(le),Z=f.useMemo(()=>Fp(X.hosts,le),[le,X.hosts]),N=f.useMemo(()=>Fp(zf(X),le),[le,X]),be=f.useCallback(()=>{if(typeof window>"u")return;const O=H.current;if(!O)return;const q=O.getBoundingClientRect(),J=window.innerWidth,Ce=window.innerHeight,Ee=16,ve=8,nt=Math.min(320,Math.max(240,J-Ee*2)),mt=Math.min(e?Math.max(Ee,q.right+ve):Math.max(Ee,q.left),Math.max(Ee,J-nt-Ee)),ae=r?440:240,se=e?q.top:q.bottom+ve,ke=Math.min(Math.max(Ee,se),Math.max(Ee,Ce-ae-Ee));E({position:"fixed",top:ke,left:mt,width:nt,maxWidth:J-Ee*2})},[e,r]);f.useEffect(()=>{if(!t){E(null),F(!1),z(bc);return}Tc.refresh();function O(J){var Ce,Ee,ve;J.target instanceof Node&&!((Ce=H.current)!=null&&Ce.contains(J.target))&&!((Ee=B.current)!=null&&Ee.contains(J.target))&&!((ve=K.current)!=null&&ve.contains(J.target))&&(n(!1),i(!1),F(!1),A(null))}function q(J){J.key==="Escape"&&(n(!1),i(!1),F(!1),A(null))}return window.addEventListener("pointerdown",O),window.addEventListener("keydown",q),window.addEventListener("resize",be),window.addEventListener("scroll",be,!0),be(),()=>{window.removeEventListener("pointerdown",O),window.removeEventListener("keydown",q),window.removeEventListener("resize",be),window.removeEventListener("scroll",be,!0)}},[t,be]),f.useEffect(()=>{if(!T||!t||(C==null?void 0:C.kind)!=="relay"){z(bc);return}let O=!1;const q=performance.now();return z({status:"probing",latencyMs:null}),pe.request("/api/client/runtime-config").then(()=>{O||z({status:"ready",latencyMs:performance.now()-q})}).catch(()=>{O||z({status:"error",latencyMs:null})}),()=>{O=!0}},[C==null?void 0:C.kind,T,t]);async function ne(O){if(m||S||O.id===le){n(!1);return}y(O.id);try{await mR.switchHost(O.id),n(!1),i(!1),F(!1),A(null)}catch(q){D({title:vR(q,O.name),tone:"error"})}finally{y(null)}}async function fe(O){if(!(O.id===le||m||S)){if(x!==O.id){A(O.id);return}j(O.id);try{await ar.update({hosts:X.hosts.filter(q=>q.id!==O.id)}),Zk(O.id),ca.clearHostSession(O.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:O.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:O.name}),tone:"error"})}finally{j(null)}}}async function ue(){if(R)return;const O=a.trim(),q=d.trim();if((q.length>0||p.length>0)&&(!q||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Ce;try{Ce=ey(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const Ee=await Ly(Ce),ve=ar.getState(),Tt=Ic(ve);if(Ee?ve.hosts.find(ke=>{var ye;return ke.baseUrl===Ce||!!Ee.bindingId&&((ye=ke.relayTunnel)==null?void 0:ye.bindingId)===Ee.bindingId}):ve.hosts.find(ke=>ke.baseUrl===Ce)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const mt=$f(Tt)&&Tt.baseUrl===Ce;mt&&Tc.setActiveDiscoveredHost(null);let ae,se;if(Ee){const ye=(await ar.update(_y(ve,Ee,{activate:mt,displayName:O}))).hosts.find(Me=>xR(Me,Ce,Ee.bindingId??null));if(!ye)throw new Error("relay entry host missing after save");ae=ye.id,se=ye.name}else{const ke=new Date().toISOString(),ye={id:wR(),name:O||kR(Ce),baseUrl:Ce,kind:yR(Ce),createdAt:ke,updatedAt:ke,lastConnectedAt:null,lastUserId:null,lastUsername:null};await ar.update({hosts:[...ve.hosts,ye],activeHostId:mt?ye.id:ve.activeHostId}),ae=ye.id,se=ye.name}q&&p&&ty({hostId:ae,username:q,password:p}),He(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:se})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function He(){o(""),u(""),h(""),g("")}if(!V)return null;const Ue=Y!=null&&Y.user.username?`${V.baseUrl} · ${Y.user.username}`:V.baseUrl,je=(C==null?void 0:C.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),Te=C?l(cy(C.kind)):l("common.unknown");return s.jsxs("div",{ref:H,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:Ue,"aria-expanded":t,onClick:()=>{n(O=>!O),i(!1)},children:s.jsx(NR,{})}),t&&L&&typeof document<"u"?Fr.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")}),Z.map(O=>{const q=O.id===le,J=q?(Y==null?void 0:Y.user.username)??O.lastUsername??O.baseUrl:O.lastUsername??O.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":q,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{ne(O)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[O.name,q?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:J})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===O.id?l("shell.hostSwitcherSwitching"):q?s.jsx(zp,{}):s.jsx($p,{})})]}),q?s.jsx("button",{ref:oe,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:O.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ce=>!Ce),A(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:O.name}),title:x===O.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":x===O.id,disabled:m!==null||S!==null,onClick:()=>{fe(O)},children:S===O.id?l("shell.hostDeleteBusy"):x===O.id?l("shell.hostDeleteConfirmAction"):s.jsx(TR,{})})]},O.id)}),N.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(O=>{const q=O.id===le,J=Ff(O.id),Ce=q?(Y==null?void 0:Y.user.username)??(J==null?void 0:J.username)??O.baseUrl:(J==null?void 0:J.username)??O.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":q,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{ne(O)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[O.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),q?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===O.id?l("shell.hostSwitcherSwitching"):q?s.jsx(zp,{}):s.jsx($p,{})})]}),q?s.jsx("button",{ref:oe,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:O.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ee=>!Ee),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},O.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:a,disabled:R,onChange:O=>o(O.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:R,onChange:O=>u(O.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:R,onChange:O=>h(O.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:R,onChange:O=>g(O.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:R,onClick:()=>{i(!1),He()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:R,onClick:()=>{ue()},children:R?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(jR,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(bR,{open:T&&C!==null&&oe.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:oe,popoverRef:K,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:(C==null?void 0:C.url)??V.baseUrl})]}),(C==null?void 0:C.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:SR(G)})]}),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:CR(_e.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function Fp(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 kR(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function yR(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 xR(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function wR(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function vR(e,t){return e instanceof au?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function SR(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 CR(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 NR(){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 $p(){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 zp(){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 jR(){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 TR(){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 fo={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function IR({open:e,onClose:t,onCloned:n}){const{showToast:r}=lr(),[i,a]=f.useState(!1),[o,c]=f.useState(fo),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[g,m]=f.useState(null),[y,S]=f.useState(""),[j,x]=f.useState(""),[A,T]=f.useState(null),[F,R]=f.useState([]),[I,G]=f.useState([]),z=i||h;f.useEffect(()=>{!e&&!i&&(c(fo),d(!1),m(null))},[i,e]);const L=f.useCallback(async Y=>{p(!0),m(null);try{const D=await Uf(Y);S(D.currentPath),x(D.currentPath),T(D.parentPath),R(D.roots),G(D.items),c(V=>({...V,parentPath:D.currentPath}))}catch(D){S(""),T(null),G([]),m(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function E(){i||(d(!1),m(null),c(fo),t())}function H(){d(!0),L(o.parentPath||void 0)}function B(){i||(d(!1),m(null))}async function oe(Y){Y.preventDefault(),await L(j)}function K(){c(Y=>({...Y,parentPath:y})),d(!1),m(null)}async function X(Y){Y.preventDefault();const D=o.repositoryUrl.trim(),V=o.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!V){r({title:l("shell.clonePathRequired"),tone:"error"});return}a(!0);try{const le=await uy({repositoryUrl:D,parentPath:V,directoryName:o.directoryName.trim()||void 0,name:o.name.trim()||void 0,auth:o.authMode==="none"?{mode:"none"}:o.authMode==="basic"?{mode:"basic",username:o.username.trim(),password:o.password}:{mode:"token",username:o.username.trim()||void 0,token:o.token}});await(n==null?void 0:n(le)),c(fo),d(!1),r({title:l("shell.cloneSuccess"),description:le.path,tone:"success"}),t()}catch(le){r({title:le instanceof Error?le.message:l("shell.cloneFailed"),tone:"error"})}finally{a(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(St,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:E,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:Y=>void X(Y),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:o.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:Y=>c(D=>({...D,repositoryUrl:Y.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:o.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:Y=>c(D=>({...D,parentPath:Y.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:H,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:o.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:Y=>c(D=>({...D,directoryName:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:o.name,placeholder:l("shell.importNamePlaceholder"),onChange:Y=>c(D=>({...D,name:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:o.authMode,onChange:Y=>c(D=>({...D,authMode:Y.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")})]})]}),o.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:o.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:Y=>c(D=>({...D,username:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:o.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:Y=>c(D=>({...D,password:Y.target.value}))})]})]}):null,o.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:o.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:Y=>c(D=>({...D,username:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:o.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:Y=>c(D=>({...D,token:Y.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:E,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:oe,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:j,placeholder:l("shell.importPathPlaceholder"),onChange:Y=>x(Y.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:z||!A,onClick:()=>{A&&L(A)},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(Y=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:z,onClick:()=>{L(Y.path)},children:Y.name},Y.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:y}),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(Y=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:z,onClick:()=>{L(Y.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:Y.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:Y.path})]},Y.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||!y,onClick:K,children:l("shell.cloneBrowserSubmit")})]})]})]})}const ER="butler:inbox-updated";function kc(){typeof window>"u"||window.dispatchEvent(new Event(ER))}const Hp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function Qb({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:a=!1,composerOpen:o=!0,onComposerOpenChange:c}){const{showToast:u}=lr(),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,y]=f.useState([]),[S,j]=f.useState([]),[x,A]=f.useState(null),[T,F]=f.useState(null),[R,I]=f.useState(Hp),[G,z]=f.useState(!1),L=f.useMemo(()=>qp(m,t,T),[T,t,m]),E=f.useMemo(()=>G?S:S.filter(D=>D.status!=="closed"),[S,G]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||x||I(D=>{const V=Vp({projects:L,currentProjectId:D.projectId,preferredProjectId:T,preferredWorkspaceId:t});return V===D.projectId?D:{...D,projectId:V}})},[e,x,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 H(){h(!0);try{const[D,V,le]=await Promise.all([pT(),qg(),n?xT(n).catch(()=>null):Promise.resolve(null)]),C=(le==null?void 0:le.target.project.id)??null;F(C),y(D.items),j(V.items),x||B(D.items,t,r>0?i:null,C)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{h(!1)}}function B(D=m,V=t,le=i,C=T){var Z,N;const _e=qp(D,V,C);A(null),I({...Hp,projectId:Vp({projects:_e,preferredProjectId:C,preferredWorkspaceId:V}),title:((Z=le==null?void 0:le.title)==null?void 0:Z.trim())??"",content:((N=le==null?void 0:le.content)==null?void 0:N.trim())??""})}function oe(D){A(D.id),I({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),a&&(c==null||c(!0))}async function K(D){D.preventDefault(),g(!0);try{x?(await tp(x,{projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await fT({projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),kc(),await H(),B(),a&&(c==null||c(!1))}catch(V){u({title:l("shell.butlerInboxSaveFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{g(!1)}}async function X(D){g(!0);try{await bT(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),kc(),await H(),x===D&&B()}catch(V){u({title:l("shell.butlerInboxDeleteFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{g(!1)}}async function Y(D,V){if(D.status!==V){g(!0);try{await tp(D.id,{status:V}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),kc(),await H(),x===D.id&&I(le=>({...le,status:V}))}catch(le){u({title:l("shell.butlerInboxSaveFailed"),description:le instanceof Error?le.message:void 0,tone:"error"})}finally{g(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[a?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(Up,{selectableProjects:L,formState:R,saving:p,editingItemId:x,useMobilePicker:!1,onProjectChange:D=>{I(V=>({...V,projectId:D}))},onItemTypeChange:D=>{I(V=>({...V,itemType:D}))},onStatusChange:D=>{I(V=>({...V,status:D}))},onTitleChange:D=>{I(V=>({...V,title:D}))},onContentChange:D=>{I(V=>({...V,content:D}))},onCancel:()=>B(),onSubmit:K})}),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:G,onChange:D=>z(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&E.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&E.length>0?s.jsx("div",{className:"workspace-inbox-list",children:E.map(D=>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:D.title}),s.jsx("p",{children:D.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:Kp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:LR(D.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:_R(D.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(V=>{const le=D.status===V;return s.jsx("button",{type:"button",className:"secondary-button","data-active":le,disabled:p,onClick:()=>{Y(D,V)},children:Kp(V)},`${D.id}:${V}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>oe(D),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{X(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),a?s.jsx(St,{open:e&&o,title:x?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(Up,{selectableProjects:L,formState:R,saving:p,editingItemId:x,useMobilePicker:!0,onProjectChange:D=>{I(V=>({...V,projectId:D}))},onItemTypeChange:D=>{I(V=>({...V,itemType:D}))},onStatusChange:D=>{I(V=>({...V,status:D}))},onTitleChange:D=>{I(V=>({...V,title:D}))},onContentChange:D=>{I(V=>({...V,content:D}))},onCancel:()=>{c==null||c(!1),B()},onSubmit:K})})}):null]})}function Up(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(yc,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(yc,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(yc,{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 yc({label:e,value:t,options:n,disabled:r,onChange:i}){const[a,o]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!a)return;function u(d){d.key==="Escape"&&o(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[a]),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":a,disabled:r||n.length===0,onClick:()=>o(!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(PR,{expanded:a})})]})]}),s.jsx(MR,{open:a,title:e,options:n,selectedValue:t,onClose:()=>o(!1),onSelect:u=>{i(u),o(!1)}})]})}function MR({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:a}){return e?s.jsx(dy,{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(mi,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(o=>{const c=o.value===r;return s.jsx(Jt,{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(AR,{}):null}),onClick:()=>a(o.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:o.label}),o.description?s.jsx("span",{children:o.description}):null]})},o.value)})})}):null}function b2({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:a,compactComposer:o=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!o);return f.useEffect(()=>{e||h(!o)},[o,e]),s.jsx(St,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!o,headerActions:o?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(RR,{})}):void 0,onClose:a,children:s.jsx(Qb,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:o,composerOpen:d,onComposerOpenChange:h})})}function qp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const a=Gp(r,t,n),o=Gp(i,t,n);return a!==o?o-a:r.name.localeCompare(i.name,"zh-Hans-CN")})}function Gp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function Vp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var a;if(t&&e.some(o=>o.id===t))return t;if(n&&e.some(o=>o.id===n))return n;const i=r?e.find(o=>o.workspaceId===r):null;return(i==null?void 0:i.id)||((a=e[0])==null?void 0:a.id)||""}function RR(){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 PR({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 AR(){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 LR(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 Kp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function _R(e){return new Date(e).toLocaleString()}function DR({open:e,onClose:t,onImported:n}){const{showToast:r}=lr(),[i,a]=f.useState(!1),[o,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[g,m]=f.useState(""),[y,S]=f.useState(""),[j,x]=f.useState(null),[A,T]=f.useState([]),[F,R]=f.useState([]),[I,G]=f.useState(!1),[z,L]=f.useState(""),E=i||o||u,H=f.useCallback(async V=>{a(!0),p(null);try{const le=await Uf(V);m(le.currentPath),S(le.currentPath),x(le.parentPath),T(le.roots),R(le.items)}catch(le){m(""),x(null),R([]),p(le instanceof Error?le.message:l("shell.importBrowserBrowseFailed"))}finally{a(!1)}},[]);f.useEffect(()=>{if(!e){G(!1),L(""),p(null);return}H(g||void 0)},[H,e]);function B(){E||(G(!1),L(""),t())}async function oe(V){V.preventDefault(),await H(y)}function K(){!g||E||(L(""),G(!0))}function X(){o||(G(!1),L(""))}async function Y(V){V==null||V.preventDefault();const le=z.trim();if(!(!g||!le||E)){c(!0),p(null);try{const C=await py({parentPath:g,directoryName:le});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:C.path,tone:"success"}),G(!1),L(""),await H(C.path)}catch(C){const _e=C instanceof Error?C.message:l("shell.importBrowserCreateDirectoryFailed");p(_e),r({title:_e,tone:"error"})}finally{c(!1)}}}async function D(){const V=g.trim();if(!(!V||E)){d(!0),p(null);try{const le=await hy({path:V});r({title:l("shell.importSuccess"),description:le.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(le)).catch(C=>{r({title:C instanceof Error?C.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(le){r({title:le instanceof Error?le.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:oe,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:y,placeholder:l("shell.importPathPlaceholder"),onChange:V=>S(V.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:E||!j,onClick:()=>{j&&H(j)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:E,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:E||!g,onClick:K,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:A.map(V=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:E,onClick:()=>{H(V.path)},children:V.name},V.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(V=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:E,onClick:()=>{H(V.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:V.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:V.path})]},V.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:E,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:E||!g,onClick:()=>{D()},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:V=>void Y(V),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:V=>L(V.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:X,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:o||!z.trim(),children:o?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function BR({onOpenSoftwareUpdate:e}){var r;const t=gu(i=>i.platform),n=ry(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 OR(){const e=ny.getState().profile.defaultPermissionMode;return e==="default"?null:e}const ta="provider-default",Io="__global_default__";function WR(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function mo(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 FR(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:Io,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 $R(e){return e.usesProviderDefault===!0||e.id===ta}function zR(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function HR({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:a,onSelectPreset:o,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:g=!1,showPresetColumn:m=!0,modelEmptyText:y}){const[S,j]=f.useState(!1),x=f.useRef(null),A=f.useRef(null),T=f.useRef(null),[F,R]=f.useState(null),I=f.useId(),G=f.useCallback(()=>{const z=A.current;if(!z||typeof window>"u")return;const L=z.getBoundingClientRect(),E=z.closest(".workbench-modal-card"),H=E instanceof HTMLElement?E.getBoundingClientRect():null,B=window.innerWidth,oe=window.innerHeight,K=12,X=8,Y=320,D=Math.min(560,Math.max(320,B-K*2)),V=Math.min(D,420),le=Math.max(Math.min(D,Math.max(V,Math.round(L.width*1.9))),Math.min(320,D)),C=Math.min(Math.max(K,L.left),Math.max(K,B-le-K)),_e=H?Math.max(K,H.top+8):K,Z=H?Math.min(oe-K,H.bottom-8):oe-K,N=Math.max(0,L.top-_e-X),be=Math.max(0,Z-L.bottom-X),ne=H?!(be>=Y||be>N+40):N>=240||N>=be;R({position:"fixed",left:C,width:le,maxWidth:D,zIndex:1905,top:ne?void 0:L.bottom+X,bottom:ne?oe-L.top+X:void 0})},[]);return f.useEffect(()=>{if(!S)return;function z(E){var B,oe;const H=E.target;!((B=x.current)!=null&&B.contains(H))&&!((oe=T.current)!=null&&oe.contains(H))&&j(!1)}function L(E){E.key==="Escape"&&j(!1)}return window.addEventListener("pointerdown",z),window.addEventListener("keydown",L),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),G(),()=>{window.removeEventListener("pointerdown",z),window.removeEventListener("keydown",L),window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[S,G]),s.jsxs("div",{ref:x,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":I,onClick:()=>j(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"?Fr.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:()=>o(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&&a?s.jsx("div",{className:"composer-deployment-select-column-hint",children:a}):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),j(!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:y})})]})]})}),document.body):null]})}const Zb=144,UR=196,qR=124,GR=72;let Yp=null;function VR(e,t){if(typeof document>"u")return t.length*8;Yp??(Yp=document.createElement("canvas"));const n=Yp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",a=r.fontWeight||"600",o=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${a} ${o} ${c}`,n.measureText(t).width}function KR({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const a=e.reduce((o,c)=>Math.max(o,Math.ceil(i(c)+GR)),0);return Math.min(n,Math.max(t,Zb,r,a))}function Xp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:a=!1,compact:o=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),g=f.useRef(null),[m,y]=f.useState(null),S=f.useId(),j=r.find(T=>T.value===n)??r[0]??null,x=f.useMemo(()=>r.map(T=>T.label),[r]),A=f.useCallback(()=>{const T=p.current;if(!T||typeof window>"u")return;const F=T.getBoundingClientRect(),R=window.innerWidth,I=window.innerHeight,G=12,z=10,L=Math.max(Zb,R-G*2),E=o?qR:UR,H=KR({labels:x,triggerWidth:F.width,maxWidth:L,preferredWidth:E,measureText:Y=>VR(T,Y)}),B=Math.min(Math.max(G,F.left),Math.max(G,R-H-G)),oe=F.top-G,K=I-F.bottom-G,X=oe>=180||oe>=K;y({position:"fixed",left:B,width:H,maxWidth:L,zIndex:1905,top:X?void 0:F.bottom+z,bottom:X?I-F.top+z:void 0})},[o,x]);return f.useEffect(()=>{if(!u)return;function T(R){var G,z;const I=R.target;!((G=h.current)!=null&&G.contains(I))&&!((z=g.current)!=null&&z.contains(I))&&d(!1)}function F(R){R.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",F),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",F),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),j?s.jsxs("div",{ref:h,className:`composer-mac-select ${o?"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:a,onClick:()=>d(T=>!T),children:[s.jsx("span",{className:"composer-mac-select-label",children:j.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"?Fr.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 go=["codex","claude-code","gemini"];function ek(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function Jp(e,t){return Array.from({length:t},()=>ek(e))}function xc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:yu(t).modelOptions??[]}function Qp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function Zp(e,t){return Math.max(0,e-t.length)}function YR({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),a=(t==null?void 0:t.defaultProvider)??"codex",o=(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,se)=>se+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}=fy(my,e),[g,m]=f.useState(h),[y,S]=f.useState(d),[j,x]=f.useState(()=>Jp(a,d)),[A,T]=f.useState({}),[F,R]=f.useState({}),[I,G]=f.useState({}),[z,L]=f.useState({}),[E,H]=f.useState({}),[B,oe]=f.useState(!1),[K,X]=f.useState(!1),[Y,D]=f.useState(null),[V,le]=f.useState(null),[C,_e]=f.useState({}),Z=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const ae=(t==null?void 0:t.defaultProvider)??"codex",se=(t==null?void 0:t.kind)==="group"?1:2;m((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S(se),x(Jp(ae,se)),T({}),R({}),G({}),L({}),H({}),oe(!1),X(!1),D(null),le(null),_e({}),Z.current=!1,Object.keys(N.current).forEach(ke=>{delete N.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(()=>{x(ae=>{var ye;if(ae.length===y)return ae;if(ae.length>y)return ae.slice(0,y);const se=ae.slice(),ke=((ye=ae[0])==null?void 0:ye.provider)??a;for(;se.length<y;)se.push(ek(ke));return se})},[a,y]),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 oe(!0),gy(p,t.workspaceId).then(se=>{ae||T(se)}).finally(()=>{ae||oe(!1)}),()=>{ae=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(Z.current||(Z.current=!0,G(ae=>({...ae,...Object.fromEntries(go.map(se=>[se,!0]))})),by().then(ae=>{const se=Object.fromEntries(ae.items.map(ke=>[ke.app,ke]));R(Object.fromEntries(go.map(ke=>[ke,se[ke]??null])))}).catch(()=>{R(Object.fromEntries(go.map(ae=>[ae,null])))}).finally(()=>{G(ae=>({...ae,...Object.fromEntries(go.map(se=>[se,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const ae=Array.from(new Set(j.map(se=>{const ke=mo(se.providerConfigMode,se.providerPresetId);return Qp(se.provider,ke.providerConfigMode,ke.providerPresetId)}).filter(se=>se!==null))).filter(se=>z[se]===void 0&&!N.current[se]);if(ae.length!==0)for(const se of ae){const[ke,ye]=se.split("::");N.current[se]=!0,H(Me=>({...Me,[se]:!0})),qf(ke,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ye}).then(Me=>{L($=>({...$,[se]:Me}))}).catch(()=>{L(Me=>({...Me,[se]:null}))}).finally(()=>{delete N.current[se],H(Me=>({...Me,[se]:!1}))})}},[z,j,e,t]);const be=f.useMemo(()=>p.filter(ae=>{const se=A[ae];return se?se.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!be.length)return;const ae=be.includes(a)?a:be[0];x(se=>{let ke=!1;const ye=se.map(Me=>be.includes(Me.provider)?Me:(ke=!0,{...Me,provider:ae,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ke?ye:se})},[be,a]);const ne=f.useMemo(()=>j.map((ae,se)=>{var Ye;const ke=mo(ae.providerConfigMode,ae.providerPresetId),ye=WR(ae.provider),Me=ye?F[ye]??null:null,$=FR(Me),Q=ke.providerConfigMode==="cc-switch-preset"?ke.providerPresetId??Io:Io,ge=$.find(dt=>dt.value===Q)??$[0]??null,Ne=Qp(ae.provider,ke.providerConfigMode,ke.providerPresetId),Be=A[ae.provider]??null,Ke=Ne?z[Ne]??null:null,ut=(ke.providerConfigMode==="cc-switch-preset"?Ke?xc(Ke,ae.provider):[{id:ta,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:xc(Be,ae.provider)).map(dt=>({value:dt.id,label:$R(dt)?l("conversation.modelUseCliDefault"):dt.name})),Qe=ae.model.trim()||ta,rt=((Ye=ut.find(dt=>dt.value===Qe))==null?void 0:Ye.label)??l("conversation.modelUseCliDefault"),st=zR(Me),qe=ye!==null,gt=Ne?E[Ne]===!0:!1,Ht=!!(Ne&>&&Ke===null);return{index:se,draft:ae,supportsDeploymentPicker:qe,showPresetColumn:st,deploymentPresetOptions:$,selectedPresetValue:Q,selectedPresetOption:ge,triggerLabel:st?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${rt}`:rt,selectedModelValue:Qe,modelOptions:ut,loadingPresets:ye?I[ye]===!0:!1,loadingModels:gt,modelColumnDisabled:Ht}}),[z,F,I,E,j,A]);if(f.useEffect(()=>{e&&x(ae=>{let se=!1;const ke=ae.map((ye,Me)=>{const $=ne[Me];if(!$)return ye;let Q=ye;const ge=mo(ye.providerConfigMode,ye.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!$.loadingPresets&&!$.deploymentPresetOptions.some(Ke=>Ke.value===ge.providerPresetId)&&(Q={...Q,providerConfigMode:"global-default",providerPresetId:null,model:""},se=!0);const Ne=new Set($.modelOptions.map(Ke=>Ke.value)),Be=Q.model.trim()||ta;return Ne.has(Be)||(Q={...Q,model:""},se=!0),Q});return se?ke:ae})},[ne,e]),!e||!t)return null;const fe=t,ue=V?Zp(j.length,V.memberFailures):0,He=new Set(V?j.map((ae,se)=>se).filter(ae=>!(ae in C)):[]),Ue=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"),O=fe.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),q=fe.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),J=fe.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Ce=Y??(fe.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!B&&be.length===0?l("shell.parallelCreateNoAvailableProviders"):null),Ee={"--parallel-member-columns":String(Math.max(1,Math.min(y,4)))};function ve(ae){D(null),le(null),_e(se=>{if(!(ae in se))return se;const ke={...se};return delete ke[ae],ke})}function Tt(){D(null),le(null),_e({})}function nt(ae,se){ve(ae);const ke=se?"temporary_worktree":"none";x(ye=>ye.map((Me,$)=>$===ae?{...Me,workspaceIsolationMode:ke}:Me))}async function mt(){const ae=g.trim();if(!o&&!ae){D(l("shell.parallelCreatePromptRequired"));return}if(fe.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!be.length){D(l("shell.parallelCreateNoAvailableProviders"));return}X(!0),D(null),le(null),_e({});try{const se=OR(),ke=j.map(Me=>{const $=mo(Me.providerConfigMode,Me.providerPresetId);return{provider:Me.provider,model:Me.model.trim()||null,providerConfigMode:$.providerConfigMode,providerPresetId:$.providerConfigMode==="cc-switch-preset"?$.providerPresetId:null,memberPrompt:Me.memberPrompt.trim()||null,workspaceIsolationMode:Me.workspaceIsolationMode}}),ye=fe.kind==="group"?await ky(fe.groupId,{permissionMode:se,members:ke}):fe.kind==="session"?await yy(fe.sessionId,{sharedPrompt:ae,permissionMode:se,members:ke}):await xy(fe.workspaceId,{sharedPrompt:ae,permissionMode:se,members:ke});if(ye.memberFailures.length>0){const Me=Zp(j.length,ye.memberFailures);le(ye),_e(Object.fromEntries(ye.memberFailures.map($=>[$.ordinal,$]))),D(Me>0?l("shell.parallelCreatePartialFailure",{successCount:Me,failureCount:ye.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ye.memberFailures.length}));return}await r(ye)}catch(se){D(se instanceof Error?se.message:l("shell.parallelGroupLoadFailed"))}finally{X(!1)}}return s.jsx(xu,{open:e,title:Ue,description:je,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!K,onClose:n,footer:s.jsxs(Ss,{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:[V&&ue>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:()=>{r(V)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:K||B||be.length===0||fe.kind==="group"&&c===0,onClick:()=>{mt()},children:K?J:q})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Mn,{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:o,"aria-readonly":o,"data-readonly":o?"true":void 0,onChange:ae=>{o||(Tt(),m(ae.target.value))}})}),s.jsx(Lt,{className:"parallel-create-count-field",label:O,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":O,children:u.map(ae=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":y===ae,onClick:()=>{Tt(),S(ae)},children:ae},ae))})})]})}),s.jsx(Mn,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:Ee,children:ne.map(({draft:ae,index:se,supportsDeploymentPicker:ke,showPresetColumn:ye,deploymentPresetOptions:Me,selectedPresetValue:$,selectedPresetOption:Q,triggerLabel:ge,selectedModelValue:Ne,modelOptions:Be,loadingPresets:Ke,loadingModels:Ie,modelColumnDisabled:ut})=>{var Ht;const Qe=be,rt=Qe.includes(ae.provider)?ae.provider:"",st=Qe.length>0?Qe.map(Ye=>({value:Ye,label:Ec(Ye,"full")})):[{value:"",label:B?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],qe=xc(A[ae.provider]??null,ae.provider),gt=qe.length>0?[{value:"",label:((Ht=qe.find(Ye=>Ye.usesProviderDefault===!0))==null?void 0:Ht.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":C[se]?"error":He.has(se)?"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:se+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:Ec(ae.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:ae.workspaceIsolationMode==="temporary_worktree",onChange:Ye=>{nt(se,Ye.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),C[se]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):He.has(se)?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-${se}-provider`,children:s.jsx(Xp,{triggerId:`${i}-member-${se}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:rt,options:st,disabled:!Qe.length,onChange:Ye=>{ve(se);const dt=Ye;x(De=>De.map((bt,Ze)=>Ze===se?{...bt,provider:dt,providerConfigMode:"global-default",providerPresetId:null,model:""}:bt))}})}),s.jsx(Lt,{label:l("shell.parallelCreateModelLabel"),htmlFor:ke?void 0:`${i}-member-${se}-model`,children:ke?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(HR,{triggerId:`${i}-member-${se}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:Me,selectedPresetValue:$,selectedPresetSummary:(Q==null?void 0:Q.summary)??null,onSelectPreset:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt!==se?De:Ye===Io?{...De,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...De,providerConfigMode:"cc-switch-preset",providerPresetId:Ye,model:""}))},modelOptions:Be,selectedModelValue:Ne,onSelectModel:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt===se?{...De,model:Ye===ta?"":Ye}:De))},loadingPresets:Ke,loadingModels:Ie,modelColumnDisabled:ut,showPresetColumn:ye,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(Xp,{triggerId:`${i}-member-${se}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:ae.model,options:gt,disabled:!Qe.length||qe.length===0,onChange:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt===se?{...De,model:Ye}:De))}})})]}),s.jsx(Lt,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${se}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${se}-prompt`,className:"parallel-create-textarea member",rows:2,value:ae.memberPrompt,onChange:Ye=>{ve(se);const dt=Ye.target.value;x(De=>De.map((bt,Ze)=>Ze===se?{...bt,memberPrompt:dt}:bt))}})}),C[se]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:C[se].detail})]}):null]},`parallel-member-${se}`)})})})]})})}const XR=12,JR=180,ef=72;function QR(e,t){const[n,r]=f.useState(!1),[i,a]=f.useState(""),[o,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[g,m]=f.useState(null);f.useEffect(()=>{e||(r(!1),a(""),m(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const j=t.filter(A=>u[A.sessionId]!==!0);if(j.length===0)return;let x=!1;return p(!0),m(null),Promise.allSettled(j.map(async A=>{const T=await Hf(A.sessionId,null,XR,"backward");return{sessionId:A.sessionId,summary:ZR(T.messages)}})).then(A=>{if(x)return;const T={},F={};let R=0;j.forEach(I=>{T[I.sessionId]=!0});for(const I of A){if(I.status==="fulfilled"){F[I.value.sessionId]=I.value.summary;continue}R+=1}d(I=>({...I,...T})),Object.keys(F).length>0&&c(I=>({...I,...F})),m(R>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{x||p(!1)}),()=>{x=!0}},[u,e,n,t]);const y=f.useMemo(()=>{const j=wc(i);return j?t.filter(x=>wc(x.title).includes(j)?!0:wc(o[x.sessionId]??"").includes(j)):t},[i,t,o]);function S(){r(j=>{const x=!j;return x||(a(""),m(null)),x})}return{searchOpen:n,searchKeyword:i,filteredSessions:y,summaryLoading:h,summaryError:g,summaryBySessionId:o,setSearchKeyword:a,toggleSearch:S}}function ZR(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(eP).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return ou(n,JR)}function eP(e){var n,r;const t=tk(e.content);return t.length>0?ou(t,ef):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?ou(e.toolCall.name.trim(),ef):""}function wc(e){return tk(e).toLocaleLowerCase()}function tk(e){return e.replace(/\s+/g," ").trim()}function ou(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const tf="workbench.left.width",nf="workbench.right.width",rf="workbench.left.collapsed",sf="workbench.right.collapsed",bo="workbench.last.session.path",vc="workbench.workspace.selected.id",af="workbench.notifications.seen_at",tP=280,nP=320,of=240,lf=280,cf=520,uf=560,rP=200,Sc=20,Yi=40,ko=5,sP=3e4,iP=12,df=60*1e3,aP=4e3,hf=220,pf=18,oP=6,si="data-workbench-panel-resizing",yo="data-workbench-window-resizing",lP=180,cP="workbench:focus-composer",uP=new Set(["starting","running","reconnecting","stale","unknown"]),dP=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],hP=["--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"],Rt={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 nk(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function pP(e){return Math.round(e*100)/100}function fP(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 ns(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(a=>fP(n,a)).filter(a=>a!==null);return i.length===0?null:i.reduce((a,o)=>a+o,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=`${pP(n)}px`;r!==i&&e.style.setProperty(t,i)}function Cr(e,t,n,r){return r===null?null:(nk(e,t)??0)+(n-r)}function ff(e){if(e)for(const t of hP)e.style.removeProperty(t)}function mP(e){return uP.has(e.runningState??"idle")||e.activityState==="running"}function gP(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 bP(e){var i,a;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((a=e.lastErrorDetail)==null?void 0:a.trim())??"",r=[t,n].filter(o=>o.length>0).join(" · ");return r?r.length<=hf?r:`${r.slice(0,hf-3)}...`:null}function kP(e,t,n){var a,o,c,u,d,h,p,g,m,y,S,j;const r=new Map(e.projects.map(x=>[x.id,x.workspaceId])),i=[];for(const x of n){const A=x.title.trim()||x.projectName;if(x.assistantState.lifecycleStage==="analyzed"&&!((a=x.assistantState.linkedSessionId)!=null&&a.trim())&&x.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${x.id}:${x.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((o=x.assistantState.analysisSummary)==null?void 0:o.trim())||((c=x.assistantState.generatedPrompt)==null?void 0:c.trim())||x.content,routePath:Ms(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.assistantState.lastAnalyzedAt});continue}x.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${x.id}:${x.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=x.assistantState.lastError)==null?void 0:u.trim())||x.content,routePath:Ms(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.updatedAt})}for(const x of t){const A=((d=x.sessionTitle)==null?void 0:d.trim())||x.projectName,T=x.updatedAt||x.lastAutomationAt||x.createdAt;if(x.status==="waiting_user"){i.push({id:`follow-up-waiting:${x.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((h=x.waitingReason)==null?void 0:h.trim())||((p=x.lastAutomationSummary)==null?void 0:p.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T});continue}if(x.status==="completed"){i.push({id:`follow-up-completed:${x.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((g=x.lastAutomationSummary)==null?void 0:g.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T});continue}x.status==="failed"&&i.push({id:`follow-up-failed:${x.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((m=x.lastAutomationSummary)==null?void 0:m.trim())||((y=x.waitingReason)==null?void 0:y.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T})}for(const x of e.verifications){if(x.status!=="failed")continue;const A=x.projectId?r.get(x.projectId)??null:null,T=((S=x.targetRef)==null?void 0:S.trim())||x.verificationType;i.push({id:`verification-failed:${x.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:T}),body:((j=x.summary)==null?void 0:j.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?Ms(A):null,workspaceId:A,createdAt:x.finishedAt||x.startedAt||x.createdAt})}return i.sort((x,A)=>{const T=mf(x.kind)-mf(A.kind);return T!==0?T:as(A.createdAt)-as(x.createdAt)}).slice(0,iP)}function mf(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 yP(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 as(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function xP(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function wP(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function vP(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)),a=((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)),o=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:a,tags:o}}function SP(e){return e.getBoundingClientRect()}function CP(e,t){return t?as(e.createdAt)>as(t):!0}function NP(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 gf(e,t){var o,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/butler"];for(const u of n){const d=vt(u,e),h=(o=d==null?void 0:d.params.workspaceId)==null?void 0:o.trim();if(h)return h}const r=la(e),i=(r==null?void 0:r.sessionId)??null;return!i||!_k(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function jP(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function Cc(e){return e==="mobile"?xn():"/landing"}function la(e){var a,o,c;const t=vt("/workspaces/:workspaceId/sessions/:sessionId",e),n=(a=t==null?void 0:t.params.sessionId)==null?void 0:a.trim();if(n)return{sessionId:n,workspaceId:((o=t==null?void 0:t.params.workspaceId)==null?void 0:o.trim())??null};const r=vt("/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 TP(e){return!!(vt("/sessions",e)||vt("/workspaces/:workspaceId/sessions",e))}function bf(e){return!!la(e)}function IP(e){return!!(vt("/tools",e)||vt("/tools/files",e)||vt("/tools/git",e)||vt("/tools/processes",e)||vt("/workspaces/:workspaceId/tools",e)||vt("/workspaces/:workspaceId/tools/files",e)||vt("/workspaces/:workspaceId/tools/git",e)||vt("/workspaces/:workspaceId/tools/processes",e))}function Eo(e){return!!(vt("/terminals",e)||vt("/workspaces/:workspaceId/terminals",e))}function Mo(e){return!!vt("/workspaces/:workspaceId/butler",e)}function EP(e,t){return vt("/workspaces/:workspaceId/debug",e)?dm(t):vt("/workspaces/:workspaceId",e)?Ir(t):vt("/workspaces/:workspaceId/tools/files",e)||vt("/tools/files",e)?pm(t):vt("/workspaces/:workspaceId/tools/git",e)||vt("/tools/git",e)?fm(t):vt("/workspaces/:workspaceId/tools/processes",e)||vt("/tools/processes",e)?mm(t):vt("/workspaces/:workspaceId/tools",e)||vt("/tools",e)?hm(t):Eo(e)?js(t):Mo(e)?Ms(t):xi(t)}function MP(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const RP=f.lazy(async()=>({default:(await bu(()=>import("./FileContextPanel-lM5mBcfn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),PP=f.lazy(async()=>({default:(await bu(()=>import("./GitSidebar-CmXAhyjo.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),AP=f.lazy(async()=>({default:(await bu(()=>import("./TerminalManagerPanel-D9JHCS6d.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function LP(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Rn(e){return Ni(e)}function _P(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function ci(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(LP):[]}async function rk(e,t){const n=await qf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const sk=f.createContext(null);function Qo(e){return OE(e)}function Tr(e){return e.isArchived===!0}function Ia(e){return am(e)}function ik(e,t){return Nu(e,{getId:n=>n.sessionId,getParentId:Ia,compare:(n,r)=>ya(n,r,t)})}function DP(e,t){const n=BP(e);return ak(n,t)}function ak(e,t){const n=OP(e);return Nu(n,{getId:r=>r.session.sessionId,getParentId:r=>Ia(r.session),compare:(r,i)=>ya(r.session,i.session,t)}).map(r=>lk(r))}function BP(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...ok(t.childWorktrees)])}function ok(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...ok(t.children)])}function OP(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 lk(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>lk(n,t+1))}}function lu(e,t){return{...e,depth:e.depth+t,children:Rn(e).map(n=>lu(n,t))}}function kf(e){return`${e}::parallel-anchor-member`}function yf(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function cu(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=cu(Rn(n),t);if(r)return r}return null}function WP(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=ck(r,n,null);if(i)return i}return null}function ck(e,t,n){var i,a;const r=((a=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:a.trim())||n;if(e.item.sessionId===t)return r;for(const o of Rn(e)){const c=ck(o,t,r);if(c)return c}return null}function uk(e){return e.filter(t=>{if(Tr(t))return!1;const n=Ia(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&Tr(r)?!Qo(t):!0})}function FP(e){return e.flatMap(t=>{const n=_P(t);return n?[n,...lm(Rn(t))]:[]})}function $P(e,t,n){var g;const r=Rn(e),i=Ns(r).sort((m,y)=>ya(m.item,y.item,n));if(!(((g=e.item.parallelGroup)==null?void 0:g.role)==="anchor"&&r.some(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const m=new Set(i.slice(0,Math.max(0,t)).map(y=>y.item.sessionId));return{...e,children:uu(r,m)}}const o=r.slice().sort((m,y)=>ya(m.item,y.item,n)),c=o.filter(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),u=o.filter(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.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:uu(r,p)}}function uu(e,t){return e.flatMap(n=>{const r=uu(Rn(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function xo(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 xf(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 zP(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function fl(e,t="compact"){return Ec(e,t)}const HP={position:"relative",zIndex:0},UP={zIndex:1};function dk(e,t,n,r){const i=[],a=(r==null?void 0:r.trim())||t.name;n&&i.push(a);const o=zP(e);return o&&i.push(o),i.join(" · ")||a}function wf(e,t){return fI("session-state-indicator",e,t)}function qP(e,t){return ob(e,t)}function vf(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 Sf(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Cf(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function vs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function GP(e){try{window.localStorage.removeItem(e)}catch{}}function wo(e,t,n){return Math.max(t,Math.min(n,e))}function vo(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function VP(e){const t=window.getComputedStyle(e),n=vo(t.getPropertyValue("--desktop-macos-titlebar-height")),r=vo(t.getPropertyValue("--workbench-header-min-height")),i=vo(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),a=vo(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+a+8}function Nf(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+VP(t)}function KP(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function YP(){typeof window>"u"||window.dispatchEvent(new CustomEvent(cP))}function hk(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=hk(r.children,n);if(i)return i}return null}function jf(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=hk(r.childWorktrees,n);if(i)return i}return null}function pk(e){return e.flatMap(t=>[t.workspace.id,...pk(t.children)])}function fk(e){return new Set(e.flatMap(t=>[t.workspace.id,...pk(t.childWorktrees)]))}function Tf(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 Nc(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 mk(e,t,n,r=new Set){return e.map(i=>{const a=i.sessions.filter(c=>!r.has(c.sessionId)),o=uk(a);return{workspace:i.workspace,meta:i.meta,visibleSessions:o,archivedSessions:a.filter(c=>Tr(c)&&!Ia(c)),visibleSessionTree:ik(o,n).filter(c=>!t.has(c.item.sessionId)&&!ju(Rn(c),u=>t.has(u.sessionId))),children:mk(i.children,t,n,r)}})}function du(e){return e.flatMap(t=>[t.workspace.id,...du(t.children)])}function na(e){return e.flatMap(t=>[...t.visibleSessionTree,...na(t.children)])}function gk(e){return e.flatMap(t=>[t,...gk(t.children)])}function XP(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:ci(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 JP(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=kk(n.childWorktrees,t);if(r)return r}return null}function jc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=yk(n.childWorktrees,t);if(r)return r}return null}function kk(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=kk(n.children,t);if(r)return r}return null}function yk(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=yk(n.children,t);if(r)return r}return null}function xk(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=xk(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function If(e){return e.flatMap(t=>[t.workspace.id,...wk(t.childWorktrees)])}function wk(e){return e.flatMap(t=>[t.workspace.id,...wk(t.children)])}function QP(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 ZP(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),a=e.findIndex(d=>d.workspace.id===n);if(i<0||a<0)return e;const o=[...e],[c]=o.splice(i,1);if(!c)return e;const u=o.findIndex(d=>d.workspace.id===n);return u<0?e:(o.splice(r==="before"?u:u+1,0,c),o.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:o)}function eA(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let a=!1;const o=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||Tr(u)===d?u:(n=!0,a=!0,{...u,isArchived:d})}),c=Sk(i.childWorktrees??[],t,u=>{u&&(n=!0,a=!0)});return a?{...i,sessions:o,childWorktrees:c}:i});return n?{...e,items:r}:e}function tA(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&&Tr(r)===i&&e.delete(r.sessionId)}Ck(e,n.childWorktrees??[])}}function nA(e,t,n){let r=!1;const i=e.map(a=>{if(a.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Nk(a.childWorktrees,t,n);return d?(r=!0,{...a,childWorktrees:u}):a}const o=a.sessions.findIndex(u=>u.sessionId===t.sessionId),c=o>=0?a.sessions.map((u,d)=>d===o?t:u):[t,...a.sessions];return r=!0,{...a,sessions:Ta(c,n)}});return r?i:e}function rA(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t?d:(r=!0,o=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=ml(a.childWorktrees,d=>d.sessionId!==t?d:(r=!0,o=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function Ef(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,o=!0,{...d,isArchived:n})),u=ml(a.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,o=!0,{...d,isArchived:n}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function Mf(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,o=!0,{...d,isFavorite:n})),u=ml(a.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,o=!0,{...d,isFavorite:n}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function sA(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function iA(e){return e?e.slice(0,8):"--"}function Rf(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function vk(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Sk(e,t,n){return e.map(r=>{let i=!1;const a=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||Tr(c)===u?c:(i=!0,{...c,isArchived:u})}),o=Sk(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:a,children:o}:r})}function Ck(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Tr(r)===i&&e.delete(r.sessionId)}Ck(e,n.children)}}function Nk(e,t,n){let r=!1;const i=e.map(a=>{if(a.workspace.id===t.workspaceId){const c=a.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?a.sessions.map((d,h)=>h===c?t:d):[t,...a.sessions];return r=!0,{...a,sessions:Ta(u,n)}}const o=Nk(a.children,t,n);return o.changed?(r=!0,{...a,children:o.nodes}):a});return{nodes:r?i:[...e],changed:r}}function aA(e,t){return e.map(n=>({...n,sessions:Ta(n.sessions,t),childWorktrees:cd(n.childWorktrees,t)}))}function ml(e,t){let n=!1;const r=e.map(i=>{let a=!1;const o=i.sessions.map(u=>{const d=t(u);return d!==u&&(a=!0,n=!0),d}),c=ml(i.children,t);return c!==i.children&&(a=!0,n=!0),a?{...i,sessions:o,children:c}:i});return n?r:[...e]}function hu(e){return`workspace-management.summary.${e}`}function jk(e){return`git-sidebar.snapshot.${e}`}function Tk(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 Ik(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 Ek(e,t){var a,o,c,u;const n=((a=t.status)==null?void 0:a.snapshot.enabled)!==!1,r=n?((o=t.status)==null?void 0:o.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 Mk({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 oA(){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(Mk,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function So(){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(Mk,{count:3})]},t))})}function lA({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 Pf({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(lA,{side:t,collapsed:n})})}function fi({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 cA(){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 uA(){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 dA(){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 Rk(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(dA,{}),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 hA(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 a=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":a,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:yP(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:NP(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(a){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:a?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(Qb,{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 pA(){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 fA(){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 mA(){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 gA(){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 bA(){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 kA(){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 Pk(){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 yA(){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 xA(){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 wA(){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 vA(){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 SA({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 Ak({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 CA(){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 NA(){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 jA(){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 TA(){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 IA(){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 EA(){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 MA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:a,codeError:o,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:g,onCodeSearch:m,onOpenSession:y}){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:j=>p(j.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(j=>{const x=ld(j.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>y(j.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:x.fullTitle,children:x.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[j.workspace.name," · ",fl(j.session.provider,"full")]})]},j.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:j=>g(j.target.value),children:c.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:j=>{j.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:j=>p(j.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||a,children:a?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[o?s.jsx("p",{className:"status-text","data-tone":"error",children:o}):null,!o&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!o&&n.trim().length>0&&!a&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(j=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:j.name}),s.jsx("span",{className:"workbench-search-result-meta",children:j.path})]},`${j.path}-${j.kind}`))]})]})]})})}const RA=`
|
|
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 PA({menuKey:e,session:t,workspace:n,workspaceContext:r,isActive:i,isFavorite:a,menuOpen:o,menuAnchorPoint:c,showWorkspaceName:u,depth:d=0,showActions:h=!0,exportDisabled:p=!1,hasSubagents:g=!1,subagentListExpanded:m=!1,showParallelBadge:y=!0,selectionMode:S=!1,selected:j=!1,onToggleSelect:x,onToggleSubagents:A,onOpen:T,onRename:F,onOpenContextMenu:R,onExport:I,onToggleFavorite:G,onArchive:z,onDelete:L,onCloseMenu:E}){var Ue,je,Te,O;const H=$n(),B=yu(t.provider).supportsSessionDelete===!0,oe=!H.isDesktop&&!H.isMobile,K=Qo(t)?((Ue=t.subagentLabel)==null?void 0:Ue.trim())||l("shell.subagentBadge"):null,X=ld(t.title,l("common.unknown")),Y=mI(t),D=Y?gI("session-activity-badge",t):null,V=id(t),le=WE(t),C=y&&((je=t.parallelGroup)==null?void 0:je.role)==="anchor"?rx(t.parallelGroup):null,_e=tx(t.parallelGroup),Z=f.useRef(null),[N,be]=f.useState(null),[ne,fe]=f.useState(!1);f.useEffect(()=>{o||fe(!1)},[o]),f.useLayoutEffect(()=>{if(H.isDesktop||!o||!c||typeof window>"u"){be(null);return}const q=()=>{var Ce,Ee;const J=cR(c,{width:((Ce=Z.current)==null?void 0:Ce.offsetWidth)??0,height:((Ee=Z.current)==null?void 0:Ee.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:B&&L?216:168});be({position:"fixed",top:`${Math.round(J.top)}px`,left:`${Math.round(J.left)}px`,width:`${Math.round(J.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(J.maxHeight)}px`,transformOrigin:J.transformOrigin})};return q(),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[c,o,H.isDesktop]);async function ue(){await Qy([{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:a?l("shell.unfavoriteAction"):l("shell.favoriteAction"),onSelect:G},{id:`archive:${t.sessionId}`,label:l("shell.archiveAction"),onSelect:z},...B&&L?[{id:`delete:${t.sessionId}`,label:l("shell.deleteSessionAction"),onSelect:L}]:[]])}const He=!H.isDesktop&&o&&typeof document<"u"?Fr.createPortal(s.jsxs("div",{ref:Z,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":l("shell.sessionMoreAction"),onClick:q=>q.stopPropagation(),style:N??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{F(),E()},children:[s.jsx(NA,{}),s.jsx("span",{children:l("shell.renameAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{G(),E()},children:[s.jsx(Ak,{active:a}),s.jsx("span",{children:a?l("shell.unfavoriteAction"):l("shell.favoriteAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{z(),E()},children:[s.jsx(CA,{}),s.jsx("span",{children:l("shell.archiveAction")})]}),oe?s.jsxs("div",{className:"workbench-session-submenu","data-open":ne,children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item","aria-haspopup":"menu","aria-expanded":ne,onClick:()=>{fe(q=>!q)},children:[s.jsx(jA,{}),s.jsx("span",{children:l("conversation.exportAction")}),s.jsx("span",{className:"workbench-session-submenu-caret","aria-hidden":"true",children:s.jsx(fi,{expanded:ne})})]}),ne?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"),E()},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"),E()},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"),E()},children:s.jsx("span",{children:l("conversation.exportHtmlAction")})})]}):null]}):null,B&&L?s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{L(),E()},children:[s.jsx(TA,{}),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":Qo(t),"data-workspace-tone":r.tone,"data-worktree-depth":r.depth,"data-has-subagents":g,"data-selecting":S,"data-selected":j,"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":((O=t.parallelGroup)==null?void 0:O.colorToken)??void 0,style:{...Wr(r)??{},..._e??{}},onContextMenu:q=>{if(!(S||!h||!R)){if(q.preventDefault(),q.stopPropagation(),H.isDesktop){ue();return}R({x:q.clientX,y:q.clientY})}},children:[s.jsxs("div",{className:"workbench-session-main",children:[S?s.jsx("span",{className:"workbench-session-selection-indicator","data-selected":j,"aria-hidden":"true",children:s.jsx(SA,{selected:j})}):g?s.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:UP,"data-indicator-variant":qP(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:q=>{q.stopPropagation(),A==null||A()},children:[s.jsx("span",{className:wf(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(fi,{expanded:m})})]}):s.jsx("span",{className:wf(t,{isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),s.jsx("button",{type:"button",className:"workbench-session-link",style:g?HP:void 0,"data-active":i,"aria-pressed":S?j:void 0,onClick:S?x:T,onKeyDown:q=>{if(S||!h||!R||q.key!=="ContextMenu"&&!(q.shiftKey&&q.key==="F10"))return;if(q.preventDefault(),q.stopPropagation(),H.isDesktop){ue();return}const J=q.currentTarget.getBoundingClientRect();R({x:J.right,y:J.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}),K?s.jsx("span",{className:"session-subagent-badge",children:K}):null,C?s.jsx("span",{className:"session-parallel-badge",children:C}):null,!C&&le&&V?s.jsx("span",{className:`session-fork-badge ${V}`,children:le}):null]}),s.jsxs("div",{className:"session-meta-row",children:[s.jsx("span",{className:"session-meta",children:dk(t,n,u,r.displayName)}),Y&&D?s.jsx("span",{className:D,children:Y}):null,s.jsx("span",{className:`session-provider-badge ${t.provider}`,children:fl(t.provider)})]})]})})]}),He]})}async function AA(e,t=document){await Lf(),await Lf(),await ud(420),await _A(t,1800),e&&await DA(e,1800)}function LA(){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 Af(e){const t={};for(const n of Array.from(e.attributes))n.name!=="style"&&(t[n.name]=n.value);return t}function Lf(){return new Promise(e=>{window.requestAnimationFrame(()=>e())})}function ud(e){return new Promise(t=>{window.setTimeout(t,e)})}async function _A(e,t){const n=e.fonts;!n||typeof n.ready>"u"||await Promise.race([n.ready.catch(()=>{}),ud(t)])}async function DA(e,t){const n=Array.from(e.querySelectorAll("img"));n.length!==0&&await Promise.race([Promise.all(n.map(r=>OA(r))),ud(t)])}function BA(){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 OA(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 _f({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:n,favoriteSessions:r,favoriteSessionIds:i,activeWorkspaceId:a,isConversationActive:o,isTerminalActive:c,isButlerActive:u,isSearchOpen:d,navigationLoading:h,navigationError:p,activeSessionId:g,onRefreshNavigation:m,onSessionUpdated:y,onNavigateConversation:S,onNavigateTerminals:j,onNavigateButler:x,onOpenSearch:A,onOpenSettings:T,onSelectWorkspace:F,onToggleWorkspaceCollapse:R,onStartWorkspaceReorder:I,onPreviewWorkspaceReorder:G,onCommitWorkspaceReorder:z,allowWorkspaceReorder:L,subscribeGitSnapshot:E,requestGitRefresh:H,subscribeWorkspaceManagementSnapshot:B,requestWorkspaceManagementRefresh:oe,onToggleFavoriteSession:K,onArchiveSession:X,onUnarchiveSession:Y,workspaceManagementStateById:D,setWorkspaceManagementStateById:V,unreadNotificationCount:le,notificationPanelOpen:C,onToggleNotificationPanel:_e,onClose:Z,onToggleCollapse:N}){var Fi;const be=xa(),ne=$n(),fe=Nm(ne),{showToast:ue}=lr(),He=Zu(),Ue=gu(k=>k),je=((Fi=Ic(Ue))==null?void 0:Fi.name)??"",Te=Ue.hosts.length+zf(Ue).length>1&&je.length>0,[O,q]=f.useState(!1),[J,Ce]=f.useState(!1),[Ee,ve]=f.useState(!1),[Tt,nt]=f.useState([]),[mt,ae]=f.useState(null),[se,ke]=f.useState(null),[ye,Me]=f.useState(null),[$,Q]=f.useState(null),[ge,Ne]=f.useState(null),[Be,Ke]=f.useState(null),[Ie,ut]=f.useState(null),[Qe,rt]=f.useState(!1),[st,qe]=f.useState(!1),[gt,Ht]=f.useState(""),[Ye,dt]=f.useState(""),[De,bt]=f.useState(""),[Ze,_t]=f.useState({localBranches:[],remoteBranches:[],tags:[]}),[_,de]=f.useState(!1),[Re,xe]=f.useState(-1),[Se,ht]=f.useState(!1),[Bt,ft]=f.useState(!1),[Ot,et]=f.useState(null),[ct,Ut]=f.useState(null),[Ds,Ur]=f.useState(null),[kt,us]=f.useState(null),[gn,cr]=f.useState(null),[Qt,Yn]=f.useState(null),[Zt,en]=f.useState(null),[vn,Bs]=f.useState(!1),[Vt,Sn]=f.useState(null),[yt,Mr]=f.useState(null),[ur,dr]=f.useState(null),[bn,qr]=f.useState(null),[Rr,hr]=f.useState(Sc),[pr,zn]=f.useState({}),[ds,Gr]=f.useState({}),[Ii,Os]=f.useState([]),[An,hs]=f.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[rn,fr]=f.useState(null),[Pr,mr]=f.useState(""),[Ar,sn]=f.useState(null),[Mt,an]=f.useState(null),[Wt,on]=f.useState([]),[gr,Vr]=f.useState(!1),[br,Kt]=f.useState({}),[Kr,Xn]=f.useState(null),Ln=f.useRef(null),Jn=f.useRef(null),Qn=f.useRef(null),w=f.useRef(null),U=f.useRef(new Map),Pe=f.useRef(null),Xe=f.useRef(null),Cn=f.useRef(null),Lr=f.useMemo(()=>new Set(An.expandedWorkspaceIds),[An.expandedWorkspaceIds]),Yr=f.useMemo(()=>new Set(An.collapsedWorkspaceIds),[An.collapsedWorkspaceIds]),Nn=Kr!==null,kn=L&&ne.isDesktop&&ne.ui.osFamily==="macos",kr=f.useMemo(()=>DP(e,n),[e,n]),Je=f.useMemo(()=>{const k=new Map;for(const M of e){k.set(M.workspace.id,ci(M).map(W=>cu(kr,W.item.sessionId)??W));for(const W of gk(M.childWorktrees)){const te=W.visibleSessionTree.map(ie=>cu(kr,ie.item.sessionId)??ie).filter(ie=>ie.item.workspaceId===W.workspace.id&&ie.depth===0);k.set(W.workspace.id,te)}}return k},[kr,e]),Ct=f.useCallback(()=>{Sn(null),Mr(null)},[]),Nt=f.useCallback((k,M)=>{Sn(k),Mr(M)},[]),xt=jc(e,ge)??((Ie==null?void 0:Ie.id)===ge?Ie:null),_r=De.trim().toLowerCase(),yr=f.useMemo(()=>[{key:"localBranches",label:l("shell.createWorktreeBaseRefLocalGroup"),items:Ze.localBranches},{key:"remoteBranches",label:l("shell.createWorktreeBaseRefRemoteGroup"),items:Ze.remoteBranches},{key:"tags",label:l("shell.createWorktreeBaseRefTagGroup"),items:Ze.tags}].map(M=>({...M,items:M.items.filter(W=>_r?W.value.toLowerCase().includes(_r):!0)})).filter(M=>M.items.length>0),[_r,Ze]),yn=f.useMemo(()=>yr.flatMap(k=>k.items),[yr]),Zn=xt?`create-worktree-base-ref-listbox-${xt.id}`:"create-worktree-base-ref-listbox",hn=JP(e,kt),er=hn?vr(hn.workspace):null,Ws=(hn==null?void 0:hn.archivedSessions)??[],{searchOpen:Fs,searchKeyword:Ei,filteredSessions:ln,summaryLoading:qt,summaryError:tr,summaryBySessionId:$s,setSearchKeyword:Mi,toggleSearch:Ri}=QR(hn!==null,Ws),We=f.useId(),xr=f.useMemo(()=>XP(e,Mt),[Mt,e]),ps=f.useMemo(()=>xr?FP(xr.visibleSessionTree):[],[xr]),jn=f.useMemo(()=>ps.map(k=>k.sessionId),[ps]),Xr=f.useMemo(()=>new Set(jn),[jn]),gl=f.useMemo(()=>new Set(Wt),[Wt]),fs=jn.length>0&&Wt.length===jn.length;f.useEffect(()=>{V(k=>{const M=If(e),W=new Set(M),te={};Object.entries(k).forEach(([me,it])=>{W.has(me)&&(te[me]=it)}),M.forEach(me=>{const it=jc(e,me);if(!it)return;const At=Ao(hu(me),df),It=Ao(jk(me),df),Yt=te[me];let qn=Ik((Yt==null?void 0:Yt.detail)??At??Tk(it),it);(It!=null&&It.status||It!=null&&It.branches)&&(qn=Ek(qn,{status:It.status??null,branches:It.branches??null})),te[me]={detail:qn,loading:!1,error:null}});const ie=Object.keys(k),Fe=Object.keys(te);return ie.length===Fe.length&&Fe.every(me=>k[me]===te[me])?k:te})},[e]);const _n=f.useCallback(async k=>{await m(),await ne.bridge.showNotification(l("shell.importSuccess"),k.path)},[m,ne.bridge]),Ft=f.useCallback(async k=>{await m(),await ne.bridge.showNotification(l("shell.cloneSuccess"),k.path)},[m,ne.bridge]);function ms(k){if(Tt.includes(k)){nt(W=>W.filter(te=>te!==k));return}nt(W=>[...W,k]),E(k),H(k),B(k),oe(k)}async function Pi(k,M){if(br[k])return;const W=(M==null?void 0:M.trim().toUpperCase())??null;Kt(te=>({...te,[k]:!0}));try{await Vf(k,{backgroundColor:W}),await m()}catch(te){ue({title:te instanceof Error?te.message:l("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{Kt(te=>({...te,[k]:!1}))}}async function zs(){if(!(!mt||se)){ke(mt.id);try{await My(mt.id),nt(k=>k.filter(M=>M!==mt.id)),V(k=>{const M={...k};return delete M[mt.id],M}),ae(null),await m(),ue({title:l("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(k){ue({title:k instanceof Error?k.message:l("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{ke(null)}}}f.useEffect(()=>{if(!Vt)return;function k(M){const W=M.target;W instanceof HTMLElement&&W.closest(".workbench-session-menu")||Ct()}return window.addEventListener("pointerdown",k),()=>{window.removeEventListener("pointerdown",k)}},[Ct,Vt]),f.useEffect(()=>{if(!Mt){Wt.length>0&&on([]),Zt&&en(null);return}if(!xr){an(null),on([]),en(null);return}on(k=>vk(k,Xr))},[xr,Zt,Xr,Mt,Wt.length]),f.useEffect(()=>{Mt&&jn.length===0&&(an(null),on([]),en(null))},[jn.length,Mt]),f.useEffect(()=>{const k=new Set(If(e)),M=new Set(e.flatMap(W=>du(W.childWorktrees)));nt(W=>W.filter(te=>k.has(te))),hs(W=>({expandedWorkspaceIds:W.expandedWorkspaceIds.filter(te=>M.has(te)),collapsedWorkspaceIds:W.collapsedWorkspaceIds.filter(te=>M.has(te))})),ae(W=>W&&k.has(W.id)?W:null),Kt(W=>Object.fromEntries(Object.entries(W).filter(([te,ie])=>ie&&k.has(te))))},[e]),f.useEffect(()=>{const k=r.findIndex(M=>M.session.sessionId===g);hr(M=>{const W=xo(r.length,Sc,M,k);return W===M?M:W})},[g,r]),f.useEffect(()=>{zn(k=>{const M={};for(const W of e){const te=ci(W),ie=te.findIndex(Fe=>Fe.item.sessionId===g||ai([Fe],g??"",me=>me.sessionId).length>0);M[W.workspace.id]=xo(te.length,Yi,k[W.workspace.id],ie);for(const Fe of na(W.childWorktrees)){Fe.item.sessionId===g||ai([Fe],g??"",It=>It.sessionId).length>0;const me=Fe.item.workspaceId;if(M[me]!==void 0)continue;const it=na(W.childWorktrees).filter(It=>It.item.workspaceId===me&&It.depth===0),At=it.findIndex(It=>It.item.sessionId===g||ai([It],g??"",Yt=>Yt.sessionId).length>0);M[me]=xo(it.length,Yi,k[me],At)}}return xf(k,M)?k:M})},[g,e]),f.useEffect(()=>{Gr(k=>{const M={};for(const W of e)for(const te of[...ci(W),...na(W.childWorktrees)])for(const ie of Ns(Rn(te))){const Fe=Rn(ie);if(Fe.length===0)continue;const me=Ns(Fe),it=me.findIndex(At=>At.item.sessionId===g);M[ie.item.sessionId]=xo(me.length,ko,k[ie.item.sessionId],it)}return xf(k,M)?k:M})},[g,e]),f.useEffect(()=>{if(!g)return;const k=e.flatMap(M=>[...ai(ci(M),g,W=>W.sessionId),...na(M.childWorktrees).flatMap(W=>ai([W],g,te=>te.sessionId))]);k.length!==0&&Os(M=>{const W=new Set(M);let te=!1;for(const ie of k)W.has(ie)||(W.add(ie),te=!0);return te?Array.from(W):M})},[g,e]),f.useEffect(()=>{if(!a)return;const k=[];for(const M of e){const W=xk(M.childWorktrees,a);W.length!==0&&k.push(...W)}k.length>0&&hs(M=>{const W=new Set(M.expandedWorkspaceIds);let te=!1;for(const ie of k)W.has(ie)||(W.add(ie),te=!0);return te?{expandedWorkspaceIds:Array.from(W),collapsedWorkspaceIds:M.collapsedWorkspaceIds}:M})},[a,e]),f.useEffect(()=>{if(!ge){ut(null),rt(!1),qe(!1),Ht(""),dt(""),bt(""),de(!1),xe(-1),ht(!1),_t({localBranches:[],remoteBranches:[],tags:[]}),ft(!1),et(null);return}rt(!1),Ht(""),dt(""),bt(""),de(!1),xe(-1),ht(!1),_t({localBranches:[],remoteBranches:[],tags:[]}),ft(!1),et(null)},[ge]),f.useEffect(()=>{const k=xt;if(!Qe||!k)return;let M=!1;const W=k.id;return ft(!0),et(null),Promise.all([Xy(W),Jy(W)]).then(([te,ie])=>{M||_t(vP(te,ie))}).catch(()=>{M||(_t({localBranches:[],remoteBranches:[],tags:[]}),et(l("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{M||ft(!1)}),()=>{M=!0}},[xt==null?void 0:xt.id,Qe]),f.useLayoutEffect(()=>{if(!_||!Ln.current){Ut(null),Ur(null);return}const k=()=>{const W=Ln.current;if(!W)return;const te=SP(W);Ut({top:te.bottom+8,left:te.left,width:te.width})};k();const M=W=>{var ie,Fe;const te=W.target;te instanceof Node&&((ie=Ln.current)!=null&&ie.contains(te)||(Fe=Jn.current)!=null&&Fe.contains(te)||(de(!1),xe(-1)))};return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),window.addEventListener("pointerdown",M),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),window.removeEventListener("pointerdown",M)}},[yn.length,_]),f.useLayoutEffect(()=>{if(!_||!Jn.current){Ur(null);return}const k=Jn.current,M=()=>{const te=Math.ceil(k.getBoundingClientRect().height);Ur(ie=>ie===te?ie:te)};if(M(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{M()});return W.observe(k),()=>{W.disconnect()}},[_,yr,Bt,Ot]);function gs(){q(!0)}function bl(){Ce(!0)}function nr(k){Hn(),Ne(null),Ke({kind:"workspace",workspaceId:k.id,workspaceName:k.name})}function Hn(){rt(!1),Ht(""),dt(""),bt(""),de(!1),xe(-1),ht(!1)}function Ai(k,M){const W=k.getBoundingClientRect();return M<=W.top+W.height/2?"before":"after"}function Li(){w.current!==null&&(cancelAnimationFrame(w.current),w.current=null),Xn(null)}function Jr(k){const M=(k==null?void 0:k.commit)??!1,W=(k==null?void 0:k.preserveClickSuppression)??!1,te=Pe.current,ie=Xe.current;Pe.current=null,Xe.current=null,ie==null||ie(),te!=null&&te.dragging&&(Li(),M&&z(),!W&&Cn.current===te.workspaceId&&(Cn.current=null))}function kl(k){if(Cn.current===k){Cn.current=null;return}R(k)}function rr(k,M){if(M){U.current.set(k,M);return}U.current.delete(k)}function Ea(k,M){for(const[W,te]of U.current){const ie=te.getBoundingClientRect();if(k>=ie.left&&k<=ie.right&&M>=ie.top&&M<=ie.bottom)return{workspaceId:W,element:te}}return null}function Hs(k,M){var it;if(!kn||k.button!==0)return;Jr();const W=k.currentTarget,te={pointerId:k.pointerId,workspaceId:M,startX:k.clientX,startY:k.clientY,pointerTarget:W,dragging:!1};Pe.current=te,(it=W.setPointerCapture)==null||it.call(W,k.pointerId);const ie=At=>{cn(At)},Fe=At=>{Dr(At.pointerId,{commit:!0,preserveClickSuppression:!0})},me=At=>{Dr(At.pointerId,{commit:!1,preserveClickSuppression:!1})};Xe.current=()=>{W.removeEventListener("pointermove",ie),W.removeEventListener("pointerup",Fe),W.removeEventListener("pointercancel",me),window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",me)},W.addEventListener("pointermove",ie),W.addEventListener("pointerup",Fe),W.addEventListener("pointercancel",me),window.addEventListener("pointermove",ie,{passive:!1}),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",me)}function cn(k){const M=Pe.current;if(!M||M.pointerId!==k.pointerId)return;if(!M.dragging){if(Math.hypot(k.clientX-M.startX,k.clientY-M.startY)<oP)return;M.dragging=!0,Cn.current=M.workspaceId,I(),Xn(M.workspaceId)}k.preventDefault();const W=Ea(k.clientX,k.clientY);!W||W.workspaceId===M.workspaceId||G(M.workspaceId,W.workspaceId,Ai(W.element,k.clientY))}function Dr(k,M){var te,ie;const W=Pe.current;!W||W.pointerId!==k||((ie=(te=W.pointerTarget).releasePointerCapture)==null||ie.call(te,k),Jr(M))}function _i(k){cn(k)}function yl(k){Dr(k.pointerId,{commit:!0,preserveClickSuppression:!0})}function xl(k){Dr(k.pointerId,{commit:!1,preserveClickSuppression:!1})}function Ma(k,M){k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",M),I(),w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,Xn(M)})}function wl(k,M){const W=Kr||k.dataTransfer.getData("text/plain");!W||W===M||(k.preventDefault(),k.dataTransfer.dropEffect="move",G(W,M,Ai(k.currentTarget,k.clientY)))}function vl(k){k.preventDefault()}function Sl(){Li(),z()}f.useEffect(()=>()=>{Jr()},[]);function Cl(k){return ds[k]??ko}function Nl(k){return Ii.includes(k)}function Us(k){return pr[k]??Yi}function jl(){hr(k=>Math.min(r.length,k+Sc))}function Ra(k,M){zn(W=>({...W,[k]:Math.min(M,(W[k]??Yi)+Yi)}))}function Br(k){Gr(M=>({...M,[k]:(M[k]??ko)+ko}))}function qs(k){Os(M=>M.includes(k)?M.filter(W=>W!==k):[...M,k])}function bs(k,M){return Yr.has(k)?!1:M||Lr.has(k)}function Pa(k,M){const W=!bs(k,M);hs(te=>{const ie=te.expandedWorkspaceIds.filter(me=>me!==k),Fe=te.collapsedWorkspaceIds.filter(me=>me!==k);return W?{expandedWorkspaceIds:[...ie,k],collapsedWorkspaceIds:Fe}:{expandedWorkspaceIds:ie,collapsedWorkspaceIds:[...Fe,k]}})}function Aa(k){const M=Ns(kr).find(W=>W.item.sessionId===k)??null;return M?Rn(M):[]}function Di(k,M){const W=vr(k);return s.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":W.tone,style:Wr(W),onClick:()=>us(k.id),children:[s.jsxs("span",{className:"workbench-archive-folder-main",children:[s.jsx(IA,{}),s.jsx("span",{children:l("shell.archiveFolderLabel")})]}),s.jsx("span",{className:"workbench-section-counter",children:M.length})]})}function Gs(){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:Il,children:fs?l("shell.clearSelectedSessions"):l("shell.selectAllSessions")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Wt.length===0||gr||vn,onClick:()=>{Ys()},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:Da,children:vn?l("shell.batchDeleting"):l("shell.batchDeleteAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:_a,children:l("common.cancel")})]})}function Bi(k,M="workbench-workspace-actions"){return s.jsxs("div",{className:M,children:[s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.switchWorkspace"),title:l("shell.switchWorkspace"),"aria-pressed":a===k,onClick:()=>{F(k),Z==null||Z()},children:s.jsx(vA,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.batchSelectSessions"),title:l("shell.batchSelectSessions"),onClick:()=>Tl(k),children:s.jsx(wA,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":l("shell.createSession"),title:l("shell.createSession"),onClick:()=>Ne(k),children:s.jsx(pA,{})})]})}function La(k){const M=Je.get(k.workspace.id)??k.visibleSessionTree,te=new Set(du(k.children)).has(a??""),ie=k.workspace.id===a||te,Fe=Nn||!bs(k.workspace.id,ie),me=vr(k.workspace);return s.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":Mt===k.workspace.id,"data-worktree-depth":k.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:()=>Pa(k.workspace.id,ie),children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(fi,{expanded:!Fe})}),s.jsxs("span",{children:[s.jsx("strong",{children:k.meta.displayName||k.workspace.name}),s.jsx("span",{className:"session-meta",children:k.meta.branchName})]})]}),Mt===k.workspace.id?Gs():Bi(k.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:[M.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,Us(k.workspace.id)).map(it=>ks({node:it,workspace:k.workspace,workspaceContext:me,menuKeyPrefix:`worktree:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:Mt===k.workspace.id,favoriteEnabled:!0})),M.length>Us(k.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Ra(k.workspace.id,M.length),children:l("shell.sessionExpandMore")}):null]}),k.children.length>0?s.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:k.children.map(it=>La(it))}):null,Di(k.workspace,k.archivedSessions)]})]},k.workspace.id)}function ks(k){var hd,pd,fd,md;const{node:M,fullNode:W=M,branchKey:te,subagentStateKey:ie,workspace:Fe,workspaceContext:me,menuKeyPrefix:it,showWorkspaceName:At,selectionMode:It,favoriteEnabled:Yt,showParallelBadge:qn=!0,forceInactive:Gn=!1,ancestorExpanded:Qr=!1,allowToggle:b=M.depth===0,ancestorHasNextSiblings:v=[],hasNextSibling:P=!1,isFirstSibling:ee=!1}=k,re=M.item,he=jc(e,re.workspaceId)??Fe,Ae=vr(he),Oe=Rn(W),$e=ie??re.sessionId,we=Nl($e),lt=Qr&&Rn(M).length>0,Tn=we,Dn=lt||Tn,$t=we&&b,sr=lt?M:$t?$P(M,Cl($e),n):W,Xs=Dn?Rn(sr):[],Dk=Ns(Oe).length,Bk=Ns(Xs).length,Ok=$t&&Bk<Dk,Wk=M.depth>0?[...v,P]:[...v],Js=((pd=(hd=re.parallelGroup)==null?void 0:hd.groupId)==null?void 0:pd.trim())||null,Pl=((fd=re.parallelGroup)==null?void 0:fd.role)==="anchor"&&Js?Xs.filter(pt=>{var zt;return((zt=pt.item.parallelGroup)==null?void 0:zt.groupId)===Js}):[],Fk=Xs.filter(pt=>{var zt;return((zt=pt.item.parallelGroup)==null?void 0:zt.groupId)!==Js}),$k=((md=re.parallelGroup)==null?void 0:md.role)==="anchor"&&Js?Oe.filter(pt=>{var zt;return((zt=pt.item.parallelGroup)==null?void 0:zt.groupId)===Js}):[],zk=Oe.filter(pt=>{var zt;return((zt=pt.item.parallelGroup)==null?void 0:zt.groupId)!==Js}),Hk=Pl.length>0?Fk:[],dd=Pl.length>0?[yf({session:re,depth:M.depth+1,children:Hk.map(pt=>lu(pt,1))}),...Pl].map((pt,zt)=>{const $i=zt===0,Uk=yf({session:re,depth:M.depth+1,children:zk.map(Al=>lu(Al,1))});return{node:pt,fullNode:$i?Uk:$k.find(Al=>Al.item.sessionId===pt.item.sessionId)??pt,branchKey:$i?kf(re.sessionId):void 0,subagentStateKey:$i?kf(re.sessionId):void 0,showParallelBadge:!$i,forceInactive:$i}}):Xs.map(pt=>({node:pt,fullNode:Oe.find(zt=>zt.item.sessionId===pt.item.sessionId)??pt}));return s.jsxs("div",{className:"workbench-session-tree-node",children:[s.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":M.depth},children:[M.depth>0?s.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[v.map((pt,zt)=>pt?s.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":zt+1}},`${re.sessionId}:ancestor:${zt}`):null),s.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":P,"data-first":ee,style:{"--workbench-session-tree-level":M.depth},children:s.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,s.jsx(PA,{menuKey:`${it}:${te??re.sessionId}`,session:re,workspace:he,workspaceContext:Ae,isActive:!Gn&&re.sessionId===g,isFavorite:Yt&&i.has(re.sessionId),menuOpen:Vt===`${it}:${te??re.sessionId}`,showWorkspaceName:At,depth:M.depth,showActions:Yt,exportDisabled:ur!==null,hasSubagents:b&&Oe.length>0,subagentListExpanded:Tn,showParallelBadge:qn,selectionMode:It,selected:gl.has(re.sessionId),onToggleSelect:()=>Vs(re.sessionId),onToggleSubagents:()=>qs($e),onOpen:()=>{be(ir(he.id,re.sessionId)),Z==null||Z()},onRename:()=>Oa(re,he),menuAnchorPoint:Vt===`${it}:${te??re.sessionId}`?yt:null,onOpenContextMenu:pt=>Nt(`${it}:${te??re.sessionId}`,pt),onExport:pt=>wr(re,pt),onToggleFavorite:()=>Ba(re.sessionId),onArchive:()=>Un(re.sessionId),onDelete:yu(re.provider).supportsSessionDelete===!0?()=>{Ct(),cr({session:re,workspace:he})}:void 0,onCloseMenu:Ct})]}),Oe.length>0&&Dn?s.jsxs("div",{className:"workbench-subsession-list",children:[dd.map((pt,zt)=>ks({node:pt.node,fullNode:pt.fullNode,branchKey:pt.branchKey,subagentStateKey:pt.subagentStateKey,workspace:Fe,workspaceContext:me,menuKeyPrefix:it,showWorkspaceName:At,selectionMode:It,favoriteEnabled:Yt,showParallelBadge:pt.showParallelBadge,forceInactive:pt.forceInactive,allowToggle:!0,ancestorHasNextSiblings:Wk,hasNextSibling:zt<dd.length-1,isFirstSibling:zt===0})),Ok?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Br($e),children:l("shell.subagentExpandMore")}):null]}):null]},te??re.sessionId)}function Tl(k){Ct(),an(k),on([]),en(null)}function _a(){an(null),on([]),en(null)}function Vs(k){on(M=>sA(M,k))}function Il(){on(k=>k.length===jn.length?[]:jn)}function Da(){if(!xr||Wt.length===0||gr||vn)return;const k=new Map(ps.map(W=>[W.sessionId,W])),M=Wt.flatMap(W=>{const te=k.get(W);return te?[te]:[]});M.length!==0&&(Ct(),en({workspace:xr.workspace,sessions:M}))}async function El(k,M){Me(k),Q(M);try{await rk(k,M),Ne(null),be(gm(k,M)),Z==null||Z()}catch(W){ue({title:W instanceof Error?W.message:l("shell.startSessionFailed"),tone:"error"})}finally{Me(null),Q(null)}}async function Ml(k){if(k.preventDefault(),!xt||st)return;const M=gt.trim(),W=Ye.trim(),te=De.trim();if(!M){ue({title:l("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!xP(M)){ue({title:l("shell.createWorktreeBranchInvalid"),tone:"error"});return}qe(!0);try{const ie=await Ry({sourceWorkspaceId:xt.id,branchName:M,displayName:W||void 0,baseRef:te||void 0});ut(ie.workspace),F(ie.workspace.id),await m(),Ne(ie.workspace.id),Hn(),ue({title:l("shell.createWorktreeSucceeded",{name:ie.meta.displayName||ie.workspace.name}),tone:"success"})}catch(ie){ue({title:ie instanceof Error?ie.message:l("shell.createWorktreeFailed"),tone:"error"})}finally{qe(!1)}}async function Ba(k){const M=i.has(k);Ct();try{await K(k),ue({title:M?l("shell.favoriteRemoved"):l("shell.favoriteAdded"),tone:"success"})}catch(W){ue({title:W instanceof Error?W.message:l("shell.favoriteToggleFailed"),tone:"error"})}}async function Un(k){Ct();try{await X(k),ue({title:l("shell.archiveAdded"),tone:"success"})}catch(M){ue({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}async function wr(k,M){var W,te;if(!ur){Ct(),dr(k.sessionId);try{const ie=await PM(k.sessionId),Fe=BA();if(M==="md"){const v=fc(k,"md"),P=AM(k,ie.messages);Mp(v,P,"text/markdown;charset=utf-8"),ue({title:l("conversation.exportMarkdownSuccess"),tone:"success"});return}Fr.flushSync(()=>{qr({session:k,items:CI({messages:ie.messages}),shellWidthPx:Fe.shellWidthPx})}),await AA(Qn.current);const me=((W=Qn.current)==null?void 0:W.innerHTML.trim())??"";if(!me)throw new Error(l("conversation.exportLoadFailed"));const it=Af(document.documentElement),At=document.body?Af(document.body):{},It=document.documentElement.getAttribute("style"),Yt=((te=document.body)==null?void 0:te.getAttribute("style"))??null,qn=`${LA()}
|
|
244
|
-
${RA}`,Gn=DM({title:k.title||l("conversation.titleFallback"),bodyHtml:`<div class="session-export-document-root">${me}</div>`,styleText:qn,htmlAttributes:it,bodyAttributes:At,htmlStyle:It,bodyStyle:Yt});if(M==="html"){const v=fc(k,"html");Mp(v,Gn,"text/html;charset=utf-8"),ue({title:l("conversation.exportHtmlSuccess"),tone:"success"});return}const Qr=fc(k,"pdf"),b=_M(k,ie.messages);LM(Qr,b,"application/pdf"),ue({title:l("conversation.exportPdfPreparing"),tone:"success"})}catch(ie){ue({title:ie instanceof Error?ie.message:l("conversation.exportLoadFailed"),tone:"error"})}finally{Fr.flushSync(()=>{qr(null)}),dr(null)}}}async function Ks(){if(!gn||Qt)return;const{session:k,workspace:M}=gn;Yn(k.sessionId),Ct();try{await kd(k.sessionId),on(W=>W.filter(te=>te!==k.sessionId)),cr(null),g===k.sessionId&&be(M.id?xi(M.id):xn()),await m(),ue({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(W){ue({title:W instanceof Error?W.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{Yn(null)}}async function Ys(){if(!(Wt.length===0||gr||vn)){Ct(),Vr(!0);try{const k=[...Wt],M=await Promise.allSettled(k.map(async ie=>({sessionId:ie,session:await Gf(ie,!0)}))),W=[];let te=0;for(const ie of M){if(ie.status==="fulfilled"){W.push(ie.value.sessionId),y(ie.value.session);continue}te+=1}W.length>0&&(await m(),on(ie=>ie.filter(Fe=>!W.includes(Fe)))),te>0?ue({title:W.length>0?l("shell.batchArchivePartialFailed"):l("shell.batchArchiveFailed"),tone:"error"}):ue({title:l("shell.batchArchiveSuccess"),tone:"success"})}catch(k){ue({title:k instanceof Error?k.message:l("shell.batchArchiveFailed"),tone:"error"})}finally{Vr(!1)}}}async function ys(){if(!Zt||vn)return;const{workspace:k,sessions:M}=Zt,W=M.map(te=>te.sessionId);if(W.length===0){en(null);return}Bs(!0),Ct();try{const te=await Promise.allSettled(W.map(async me=>(await kd(me),me))),ie=[];let Fe=0;for(const me of te){if(me.status==="fulfilled"){ie.push(me.value);continue}Fe+=1}if(ie.length>0&&(g&&ie.includes(g)&&be(k.id?xi(k.id):xn()),on(me=>me.filter(it=>!ie.includes(it))),await m()),Fe>0){en(me=>{if(!me)return me;const it=me.sessions.filter(At=>!ie.includes(At.sessionId));return it.length>0?{...me,sessions:it}:null}),ue({title:ie.length>0?l("shell.batchDeletePartialFailed"):l("shell.batchDeleteFailed"),tone:"error"});return}en(null),ue({title:l("shell.batchDeleteSuccess"),tone:"success"})}catch(te){ue({title:te instanceof Error?te.message:l("shell.batchDeleteFailed"),tone:"error"})}finally{Bs(!1)}}async function Rl(k){Ct();try{await Y(k),ue({title:l("shell.archiveRestored"),tone:"success"})}catch(M){ue({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}function Oa(k,M){Ct(),fr({session:k,workspace:M}),mr(k.title)}async function Wa(k){if(k.preventDefault(),!rn)return;const M=Pr.trim();if(M){sn(rn.session.sessionId);try{const W=await Kf(rn.session.sessionId,M);y(W),fr(null),mr(""),ue({title:l("shell.renameSuccess"),tone:"success"})}catch(W){ue({title:W instanceof Error?W.message:l("shell.renameFailed"),tone:"error"})}finally{sn(null)}}}const Oi=r.slice(0,Rr),Fa=Oi.length<r.length;function vr(k){return t[k.id]??Jo(k)}function Wi(k,M,W,te,ie=[]){var v;const Fe=Tt.includes(k.id),me=D[k.id]??{detail:null,loading:!1,error:null},it=se===k.id,At=br[k.id]===!0,It=(v=me.detail)!=null&&v.git.remotes.length?me.detail.git.remotes.map(P=>`${P.name}: ${P.url}`).join(" · "):l("shell.manageWorkspaceNoRemote"),Yt=me.detail?rR(me.detail.codeComposition.items,l("shell.manageWorkspaceCodeCompositionOther")):[],qn=Yt.length>0?iR(Yt):void 0,Gn=vr(k),Qr=QP(Gn,ie),b=[...ie,Gn.displayName];return s.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":Gn.tone,"data-worktree-node":te,style:Wr(Gn),children:[s.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":Fe,onClick:()=>ms(k.id),children:[s.jsxs("span",{className:"workbench-manage-item-heading",children:[s.jsx(fi,{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:Qr})]})]}),s.jsx("span",{className:"workbench-section-counter",children:M})]}),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:k.path})]}),te?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:dP.map(P=>s.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":l("shell.manageWorkspaceColorSelectSwatch",{color:P}),"aria-pressed":k.backgroundColor===P,disabled:At,"data-selected":k.backgroundColor===P,style:{backgroundColor:P},onClick:()=>{Pi(k.id,P)}},P))}),s.jsx("button",{type:"button",className:"ghost-button",disabled:At||!k.backgroundColor,onClick:()=>{Pi(k.id,null)},children:l("shell.manageWorkspaceColorClearAction")})]})]}),s.jsx("p",{className:"workbench-manage-hint",children:k.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(P=>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:P.color},"aria-hidden":"true"}),s.jsx("span",{className:"workbench-manage-type-name",children:P.type})]}),s.jsxs("span",{children:[P.count," · ",nR(P)]})]},P.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(dm(k.id))},children:l("shell.workspaceDetailDebugOpenPageAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!se,onClick:()=>ae(k),children:it?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveAction")})]})]}):null,W.length>0?s.jsx("div",{className:"workbench-manage-children",children:W.map(P=>Wi(P.workspace,P.visibleSessions.length+P.archivedSessions.length,P.children,!0,b))}):null]},k.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:[N?s.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideSessionSidebar"),title:l("shell.hideSessionSidebar"),onClick:N,children:s.jsx(Pk,{})}):null,s.jsx(Jb,{}),s.jsx(Rk,{unreadCount:le,open:C,onToggle:_e})]})}),s.jsxs("div",{ref:He,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:o?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":o,onClick:S,children:[s.jsx(mA,{}),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:x,children:[s.jsx(bA,{}),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:j,children:[s.jsx(gA,{}),s.jsx("span",{children:l("shell.terminalsEntry")})]})]}),s.jsx(Kw,{triggerClassName:"workbench-nav-segment-button",triggerLabel:l("shell.skillsEntry"),triggerLeading:s.jsx(kA,{}),workspaceId:a,sessionId:g}),s.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":d,"aria-haspopup":"dialog","aria-expanded":d,onClick:A,children:[s.jsx(fA,{}),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(Ak,{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:[Oi.map(k=>{const M=Aa(k.session.sessionId);return s.jsx("div",{children:ks({node:{item:k.session,depth:0,children:M},workspace:k.workspace,workspaceContext:vr(k.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},k.session.sessionId)}),Fa?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:jl,children:l("shell.favoriteExpandMore")}):null]})]}):null,h&&e.length===0?s.jsx(oA,{}):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(uA,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.importWorkspaceTitle"),title:l("shell.importWorkspaceTitle"),onClick:gs,children:s.jsx(cA,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.cloneWorkspaceTitle"),title:l("shell.cloneWorkspaceTitle"),onClick:bl,children:s.jsx(yA,{})})]})]}),e.map(k=>{const M=Je.get(k.workspace.id)??ci(k),W=Kr===k.workspace.id,te=k.isCollapsed||Nn;return s.jsxs("section",{className:"workbench-workspace-group",ref:ie=>rr(k.workspace.id,ie),"data-workspace-group-id":k.workspace.id,"data-batch-active":Mt===k.workspace.id,"data-dragging":W,onDragOver:ie=>wl(ie,k.workspace.id),onDrop:vl,children:[s.jsxs("div",{className:"workbench-workspace-header minimal",children:[s.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":te?l("shell.workspaceExpand"):l("shell.workspaceCollapse"),draggable:L&&!kn,onClick:()=>kl(k.workspace.id),onPointerDown:kn?ie=>Hs(ie,k.workspace.id):void 0,onPointerMove:kn?_i:void 0,onPointerUp:kn?yl:void 0,onPointerCancel:kn?xl:void 0,onDragStart:L&&!kn?ie=>Ma(ie,k.workspace.id):void 0,onDragEnd:L&&!kn?Sl:void 0,"data-reorder-enabled":L?"true":void 0,children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(fi,{expanded:!te})}),s.jsx("strong",{children:k.workspace.name})]}),Mt===k.workspace.id?Gs():Bi(k.workspace.id)]}),te?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-session-list",children:[M.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,Us(k.workspace.id)).map(ie=>ks({node:ie,workspace:k.workspace,workspaceContext:vr(k.workspace),menuKeyPrefix:`workspace:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:Mt===k.workspace.id,favoriteEnabled:!0})),M.length>Us(k.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Ra(k.workspace.id,M.length),children:l("shell.sessionExpandMore")}):null]}),k.childWorktrees.length>0?s.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:k.childWorktrees.map(ie=>La(ie))}):null,Di(k.workspace,k.archivedSessions)]})]},k.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(xA,{}),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(BR,{onOpenSoftwareUpdate:()=>be("/settings/software-update")})]})}),s.jsx(St,{open:Ee,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:gs,children:l("shell.manageWorkspaceImportAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:bl,children:l("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{se||ve(!1)},children:e.length>0?s.jsx("div",{className:"workbench-manage-list",children:e.map(k=>Wi(k.workspace,k.visibleSessions.length+k.archivedSessions.length,k.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:()=>{Ks()},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:()=>{ys()},children:vn?l("shell.batchDeleting"):l("shell.batchDeleteAction")})]})]}),s.jsxs(St,{open:mt!==null,title:l("shell.manageWorkspaceRemoveConfirmTitle"),description:l("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{se||ae(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:mt?l("shell.manageWorkspaceRemoveConfirmTarget",{name:mt.name}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!se,onClick:()=>ae(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!se,onClick:()=>{zs()},children:se?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveConfirmAction")})]})]}),s.jsx(IR,{open:J,onClose:()=>Ce(!1),onCloned:Ft}),s.jsx(DR,{open:O,onClose:()=>q(!1),onImported:_n}),s.jsx(YR,{open:Be!==null,source:Be,onClose:()=>Ke(null),onCreated:async k=>{k.members.forEach(W=>{y(W.session)}),ax(k.group.id),await m();const M=k.members.find(W=>W.session.sessionId===k.group.anchorSessionId)??k.members[0]??null;M&&be(ir(sx(M.session,M.sessionIsolatedWorkspace),M.session.sessionId)),Ke(null),ue({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:st||!!ye||!xt,onClick:()=>{xt&&nr(xt)},children:l("shell.parallelCreateAction")}),s.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:st||!!ye,onClick:()=>rt(!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(Ey,{disabled:!!ye||st,workspaceId:(xt==null?void 0:xt.id)??null,pendingProvider:ye===(xt==null?void 0:xt.id)?$??null:null,onSelect:k=>{xt&&El(xt.id,k)}})]})}),s.jsx(St,{open:xt!==null&&Qe,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:()=>ht(k=>!k),children:s.jsx(EA,{})}),description:xt?`${l("shell.createWorktreeSectionDescription")} ${l("shell.createSessionTarget")} · ${xt.name}`:l("shell.createWorktreeSectionDescription"),onClose:Hn,children:s.jsxs("form",{className:"create-session-worktree-form",onSubmit:Ml,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:gt,placeholder:l("shell.createWorktreeBranchPlaceholder"),onChange:k=>{const M=k.target.value;wP(M)&&Ht(M)}})]}),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:k=>dt(k.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:Ln,onBlurCapture:k=>{var W,te;const M=k.relatedTarget;M instanceof Node&&((W=Ln.current)!=null&&W.contains(M)||(te=Jn.current)!=null&&te.contains(M))||(de(!1),xe(-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":_,"aria-controls":Zn,value:De,placeholder:l("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{de(!0),xe(yn.length>0?0:-1)},onChange:k=>{bt(k.target.value),de(!0),xe(yn.length>0?0:-1)},onKeyDown:k=>{if(k.key==="ArrowDown"){if(k.preventDefault(),!_){de(!0);return}yn.length>0&&xe(M=>M>=yn.length-1?0:M+1);return}if(k.key==="ArrowUp"){if(k.preventDefault(),!_){de(!0);return}yn.length>0&&xe(M=>M<=0?yn.length-1:M-1);return}if(k.key==="Enter"&&_&&Re>=0){k.preventDefault();const M=yn[Re];M&&(bt(M.value),de(!1),xe(-1));return}k.key==="Escape"&&de(!1)}}),s.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":l("shell.createWorktreeBaseRefToggle"),"aria-expanded":_,onClick:()=>{de(k=>!k),xe(!_&&yn.length>0?0:-1)},children:s.jsx(fi,{expanded:_})})]})}),s.jsx("span",{className:"create-session-worktree-field-hint",children:Bt?l("shell.createWorktreeBaseRefLoading"):Ot||l("shell.createWorktreeBaseRefHint",{localCount:Ze.localBranches.length,remoteCount:Ze.remoteBranches.length,tagCount:Ze.tags.length})})]}),_&&ct&&typeof document<"u"?Fr.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":`${Ds??0}px`}}),s.jsx("div",{ref:Jn,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")}):Ot?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:Ot}):yr.length>0?s.jsx("div",{id:Zn,className:"create-session-worktree-combobox-list",role:"listbox",children:yr.map(k=>s.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":k.label,children:[s.jsx("header",{className:"create-session-worktree-combobox-group-title",children:k.label}),s.jsx("div",{className:"create-session-worktree-combobox-group-options",children:k.items.map(M=>{const W=yn.findIndex(Fe=>Fe.value===M.value),te=De===M.value,ie=Re===W;return s.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":te,"data-highlighted":ie,onMouseDown:Fe=>Fe.preventDefault(),onMouseEnter:()=>xe(W),onClick:()=>{bt(M.value),de(!1),xe(-1)},children:[s.jsx("span",{className:"create-session-worktree-combobox-option-label",children:M.value}),s.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[M.current?s.jsx("span",{className:"create-session-worktree-combobox-badge",children:l("shell.createWorktreeBaseRefCurrentBadge")}):null,M.recommended?s.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:l("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${k.key}:${M.value}`)})})]},k.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:st,onClick:Hn,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:st,children:st?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:Ws.length>0?s.jsx("button",{type:"button",className:"secondary-button","aria-pressed":Fs,onClick:Ri,children:l("shell.archiveSearchAction")}):void 0,onClose:()=>us(null),children:[Fs?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:Ei,placeholder:l("shell.archiveSearchPlaceholder"),autoFocus:!0,onChange:k=>Mi(k.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(mi,{className:"workbench-archive-list","data-workspace-tone":(er==null?void 0:er.tone)??"root",style:Wr(er),children:ln.map(k=>{var te;const M=ld(k.title,l("common.unknown")),W=((te=$s[k.sessionId])==null?void 0:te.trim())??"";return s.jsx(Jt,{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:()=>Rl(k.sessionId),children:l("shell.unarchiveAction")}),children:s.jsxs("div",{className:"workbench-archive-item-main",children:[s.jsx("strong",{title:M.fullTitle,children:M.displayTitle}),s.jsxs("p",{children:[dk(k,hn.workspace,!1)," ·"," ",fl(k.provider)]}),Fs&&W?s.jsx("p",{className:"workbench-archive-item-summary",children:W}):null]})},k.sessionId)})}):s.jsx(Ro,{title:Ws.length>0&&Ei.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:()=>{Ar||(fr(null),mr(""))},children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:Wa,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:k=>mr(k.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!Ar,onClick:()=>{fr(null),mr("")},children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!Pr.trim()||Ar===(rn==null?void 0:rn.session.sessionId),children:Ar===(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(PE,{sessionId:bn.session.sessionId,items:bn.items,provider:bn.session.provider})]})}):null]})}function Df({panelReady:e,activeTab:t,fileRevealRequest:n,onTabChange:r,onToggleCollapse:i,currentSessionId:a,activeWorkspaceId:o,navigationGroups:c,workspaceContext:u,worktreeMeta:d,worktreeMergeState:h,onRefreshWorktreeMergePreview:p,onApplyWorktreeMerge:g,onCleanupWorktree:m}){var _e;const y=o??((_e=c[0])==null?void 0:_e.workspace.id)??null,S=(o==null?void 0:o.trim())||null,j=f.useMemo(()=>fk(c),[c]),[x,A]=f.useState(()=>S),T=$n(),F=Nm(T),{showToast:R}=lr(),I=Zu(),G=f.useRef(null),z=f.useRef(null),L=T.isDesktop&&T.bridge.supported,E=L&&!!o,H=L&&!!y,B=L&&!!y,oe=typeof globalThis<"u"&&"PointerEvent"in globalThis,K=S??x,X=K&&K===S?a:null,Y=K&&K===S?n:null;f.useEffect(()=>{if(S){A(Z=>Z===S?Z:S);return}j.size!==0&&A(Z=>Z&&j.has(Z)?Z:null)},[j,S]);const D=f.useCallback(async(Z,N,be)=>{if(Z==="files"){const fe=await uw(T,{workspaceId:N,sessionId:be,focusOwner:"file-context-panel"});fe.ok||R({title:fe.detail??l("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(Z==="git"){const fe=await dw(T,{workspaceId:N,focusOwner:"git-sidebar"});fe.ok||R({title:fe.detail??l("git.openExternalFailed"),tone:"error"});return}const ne=await hw(T,{workspaceId:N,focusOwner:"terminal-manager-panel"});ne.ok||R({title:ne.detail??l("terminalManager.openExternalFailed"),tone:"error"})},[T,R]),V=f.useCallback((Z,N)=>{if(Z.button!==0||!L)return;const be=N==="files"?o:N==="git"||N==="terminals"?y:null;if(!be)return;const ne=N==="files"?a:null;G.current={tab:N,startX:Z.clientX,startY:Z.clientY,workspaceId:be,sessionId:ne,detached:!1,preview:null};const fe=je=>{var J;const Te=G.current;if(!Te)return;const O=Math.abs(je.clientX-Te.startX),q=Math.abs(je.clientY-Te.startY);!Te.detached&&Math.max(O,q)<pf||(Te.detached||(Te.detached=!0,z.current=Te.tab,Te.preview=Od({title:Te.tab==="files"?l("shell.filesEntry"):Te.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:je.clientX,y:je.clientY})),(J=Te.preview)==null||J.updatePosition(je.clientX,je.clientY))},ue=je=>{var O;const Te=(O=G.current)==null?void 0:O.preview;je&&(Te==null||Te.cancel()),window.removeEventListener("mousemove",fe),window.removeEventListener("mouseup",He),window.removeEventListener("blur",Ue),G.current=null},He=async()=>{var Te;const je=G.current;ue(!1),je!=null&&je.detached&&(await((Te=je.preview)==null?void 0:Te.complete()),await D(je.tab,je.workspaceId,je.sessionId))},Ue=()=>{ue(!0)};window.addEventListener("mousemove",fe),window.addEventListener("mouseup",He),window.addEventListener("blur",Ue)},[o,L,a,y,D]),le=f.useCallback((Z,N)=>{if(Z.button!==0||!L)return;const be=N==="files"?o:N==="git"||N==="terminals"?y:null;if(!be)return;const ne=Z.currentTarget,fe=Z.pointerId;ne.setPointerCapture(fe);const ue=N==="files"?a:null;G.current={tab:N,startX:Z.clientX,startY:Z.clientY,workspaceId:be,sessionId:ue,detached:!1,preview:null};const He=q=>{var ve;if(q.pointerId!==fe)return;const J=G.current;if(!J)return;const Ce=Math.abs(q.clientX-J.startX),Ee=Math.abs(q.clientY-J.startY);!J.detached&&Math.max(Ce,Ee)<pf||(J.detached||(J.detached=!0,z.current=J.tab,J.preview=Od({title:J.tab==="files"?l("shell.filesEntry"):J.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:q.clientX,y:q.clientY})),(ve=J.preview)==null||ve.updatePosition(q.clientX,q.clientY))},Ue=q=>{var Ce;const J=(Ce=G.current)==null?void 0:Ce.preview;q&&(J==null||J.cancel()),ne.removeEventListener("pointermove",He),ne.removeEventListener("pointerup",je),ne.removeEventListener("pointercancel",Te),ne.removeEventListener("lostpointercapture",Te),window.removeEventListener("blur",O),G.current=null,ne.hasPointerCapture(fe)&&ne.releasePointerCapture(fe)},je=async q=>{var Ce;if(q.pointerId!==fe)return;const J=G.current;Ue(!1),J!=null&&J.detached&&(await((Ce=J.preview)==null?void 0:Ce.complete()),await D(J.tab,J.workspaceId,J.sessionId))},Te=q=>{q.pointerId===fe&&Ue(!0)},O=()=>{Ue(!0)};ne.addEventListener("pointermove",He),ne.addEventListener("pointerup",je),ne.addEventListener("pointercancel",Te),ne.addEventListener("lostpointercapture",Te),window.addEventListener("blur",O)},[o,L,a,y,D]),C=f.useCallback(Z=>{if(z.current===Z){z.current=null;return}r(Z)},[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(Pk,{})}):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:E?"拖拽标签到独立窗口":void 0,onPointerDown:Z=>le(Z,"files"),onMouseDown:oe?void 0:Z=>V(Z,"files"),onClick:()=>C("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:H?"拖拽标签到独立窗口":void 0,onPointerDown:Z=>le(Z,"git"),onMouseDown:oe?void 0:Z=>V(Z,"git"),onClick:()=>C("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:Z=>le(Z,"terminals"),onMouseDown:oe?void 0:Z=>V(Z,"terminals"),onClick:()=>C("terminals"),children:l("shell.terminalManagerEntry")})]})]}),s.jsxs("div",{ref:I,className:"workbench-auxiliary-body","data-scrollbar-autohide":"true",children:[e?null:s.jsx(So,{}),e&&t==="git"&&d?s.jsx(WA,{meta:d,state:h,onRefresh:()=>p(d.workspaceId,!0),onApply:()=>g(d.workspaceId),onCleanup:()=>m(d)}):null,e&&t==="files"?K?s.jsx(f.Suspense,{fallback:s.jsx(So,{}),children:s.jsx(RP,{sessionId:X,workspaceId:K,externalRevealRequest:Y})}):s.jsx("section",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.filesPanelEmpty")})}):null,e&&t==="git"?y?s.jsx(f.Suspense,{fallback:s.jsx(So,{}),children:s.jsx(PP,{workspaceId:y})}):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(So,{}),children:s.jsx(AP,{currentWorkspaceId:o,navigationGroups:c})}):null]})]})}function WA({meta:e,state:t,onRefresh:n,onApply:r,onCleanup:i}){const[a,o]=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))??[]),y=m.size>0||!!(t!=null&&t.error),S=g&&!y,j=(c==null?void 0:c.canMerge)===!0&&!u&&!d&&!h&&!S,x=S&&!u&&!d&&!h&&!m.has("SOURCE_DIRTY")&&!m.has("HAS_ACTIVE_CHILDREN"),A=u||d||h?"loading":y?"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,R=(c==null?void 0:c.targetBranchName)??e.baseRef??l("common.unknown"),I=$A({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}),G=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:R}),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:iA(c.mergeBaseCommit)}):null].filter(B=>!!B),L=`worktree-merge-panel-details-${e.workspaceId}`,E=a?l("shell.worktreeMergeCollapseDetails"):l("shell.worktreeMergeExpandDetails"),H=FA({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(()=>{o(!1)},[e.workspaceId]),s.jsxs("section",{className:"worktree-merge-panel","data-state":A,children:[s.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":E,"aria-expanded":a,"aria-controls":L,onClick:()=>{o(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:H.map(B=>s.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":A,children:B},B))})}),s.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:E})]}),a?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":A,children:G})}),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:!j,onClick:r,children:d?l("shell.worktreeMergeApplying"):l("shell.worktreeMergeApplyAction")}),s.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!x,onClick:i,children:h?l("shell.worktreeCleanupRunning"):l("shell.worktreeCleanupAction")})]})]}):null]})}function FA(e){const{t,loading:n,applying:r,cleaning:i,hasPreview:a,canMerge:o,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:o?[t("shell.worktreeMergeCompactReady")]:c?[t("shell.worktreeMergeCompactMerged")]:a?u.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function $A(e){const{t,hasPreview:n,showMergedState:r,isMerged:i,canMerge:a,ahead:o,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")||o<=0),y=r?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:a?{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"},y]}function k2({shellMode:e="desktop"}){var vr,Wi,Fi,k,M,W,te,ie,Fe,me,it,At,It,Yt,qn,Gn,Qr;const t=el(),n=xa(),r=$n(),{showToast:i}=lr(),a=za(b=>b.sessionDisplaySortMode),o=za(b=>b.notificationPreferences.notifyOnPermissionRequest),c=za(b=>b.notificationPreferences.notifyOnSessionCompleted),u=za(b=>b.notificationPreferences.notifyOnSessionFailed),d=f.useRef(dR(Kb)),h=f.useRef(0),p=f.useRef((((Wi=(vr=d.current)==null?void 0:vr.items)==null?void 0:Wi.length)??0)>0),g=f.useRef(new Map),m=f.useRef(!1),y=f.useRef(null),S=f.useRef(0),j=f.useRef(null),x=f.useRef(null),A=f.useRef(new Set),T=f.useRef(new Set),F=f.useRef(new Set),R=f.useRef(new Set),I=f.useRef(null),G=f.useRef(null),z=f.useRef(null),L=f.useRef(null),E=f.useRef(null),H=f.useRef(null),B=f.useRef(null),oe=f.useRef(null),K=f.useRef(0),X=f.useRef(0),Y=f.useRef(i),D=f.useRef(r.bridge),V=f.useRef(null),le=f.useRef(0),C=f.useRef(0),_e=f.useRef(null),Z=f.useRef(null),N=f.useRef(null),be=f.useRef(!1),ne=f.useRef(!1),fe=f.useRef(!1),ue=f.useRef(new Map),He=f.useRef(!1),Ue=f.useRef(new Map),je=f.useRef(""),Te=f.useRef([]),O=f.useRef(a),q=f.useRef(null),[J,Ce]=f.useState(()=>Wp(d.current,a)),Ee=f.useRef(J),[ve,Tt]=f.useState(()=>{var b,v;return(((v=(b=d.current)==null?void 0:b.items)==null?void 0:v.length)??0)===0}),[nt,mt]=f.useState(null),[ae,se]=f.useState(()=>wo(vf(tf,tP),of,cf)),[ke,ye]=f.useState(()=>wo(vf(nf,nP),lf,uf)),[Me,$]=f.useState(()=>Sf(rf,!1)),[Q,ge]=f.useState(()=>Sf(sf,!1)),[Ne,Be]=f.useState(null),[Ke,Ie]=f.useState(null),[ut,Qe]=f.useState(()=>Tf(d.current)),[rt,st]=f.useState(()=>Cf(vc)),[qe,gt]=f.useState(!1),[Ht,Ye]=f.useState("files"),[dt,De]=f.useState(!1),[bt,Ze]=f.useState(!1),[_t,_]=f.useState(null),[de,Re]=f.useState({}),[xe,Se]=f.useState(!1),[ht,Bt]=f.useState("sessions"),[ft,Ot]=f.useState(""),[et,ct]=f.useState(""),[Ut,Ds]=f.useState(!1),[Ur,kt]=f.useState(null),[us,gn]=f.useState([]),[cr,Qt]=f.useState(null),[Yn,Zt]=f.useState({}),en=Cm(r),vn=f.useCallback(b=>{if(en)return;const v=V.current;v&&(!Ac(r,b.button,b.target)||!Nf(b.clientY,v)||ew({platform:r,button:b.button,target:b.target,clientX:b.clientX,clientY:b.clientY}))},[r,en]),Bs=f.useCallback(b=>{if(en)return;const v=V.current;v&&(!Ac(r,b.button,b.target)||!Nf(b.clientY,v)||r.bridge.setWindowState("toggle-zoom"))},[r,en]),[Vt,Sn]=f.useState({}),[yt,Mr]=f.useState(null),[ur,dr]=f.useState(!1),[bn,qr]=f.useState([]),[Rr,hr]=f.useState(()=>new Set),[pr,zn]=f.useState(!1),[ds,Gr]=f.useState(!1),[Ii,Os]=f.useState(0),[An,hs]=f.useState(()=>Cf(af)),rn=e==="desktop"&&r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar,{theme:fr}=sy();f.useEffect(()=>{Y.current=i},[i]),f.useEffect(()=>{if(typeof document>"u")return;const{documentElement:b,body:v}=document,P=document.getElementById("root");if(!rn){b.removeAttribute("data-workbench-macos-vibrancy"),v==null||v.removeAttribute("data-workbench-macos-vibrancy");return}const ee=b.style.background,re=(v==null?void 0:v.style.background)??"",he=(P==null?void 0:P.style.background)??"";return b.setAttribute("data-workbench-macos-vibrancy","true"),v==null||v.setAttribute("data-workbench-macos-vibrancy","true"),b.style.background="transparent",v==null||v.style.setProperty("background","transparent"),P==null||P.style.setProperty("background","transparent"),()=>{b.removeAttribute("data-workbench-macos-vibrancy"),v==null||v.removeAttribute("data-workbench-macos-vibrancy"),b.style.background=ee,v&&(v.style.background=re),P instanceof HTMLElement&&(P.style.background=he)}},[rn]),f.useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current)},[]),f.useEffect(()=>{var re;if(typeof document>"u")return;const{documentElement:b,body:v}=document;if(!Ke){b.removeAttribute(si),v==null||v.removeAttribute(si);return}const P=b.style.cursor,ee=(v==null?void 0:v.style.cursor)??"";return b.setAttribute(si,Ke),v==null||v.setAttribute(si,Ke),b.style.cursor="col-resize",v==null||v.style.setProperty("cursor","col-resize"),(re=window.getSelection())==null||re.removeAllRanges(),()=>{b.removeAttribute(si),v==null||v.removeAttribute(si),b.style.cursor=P,v&&(v.style.cursor=ee)}},[Ke]),f.useEffect(()=>{O.current=a,Ce(b=>aA(b,a))},[a]),f.useEffect(()=>{Ee.current=J},[J]),f.useEffect(()=>{D.current=r.bridge},[r.bridge]),f.useEffect(()=>{le.current=ae},[ae]),f.useEffect(()=>{C.current=ke},[ke]),f.useEffect(()=>()=>{_e.current!==null&&window.cancelAnimationFrame(_e.current)},[]);const Pr=f.useCallback(async()=>{const b=K.current+1;K.current=b;try{const v=await dT();if(b!==K.current)return;if(!v.initialized){qr([]),hr(new Set);return}const[P,ee,re,he]=await Promise.all([hT(),mT(),qg(),kT()]);if(b!==K.current)return;qr(kP(P.overview,ee.items,re.items)),hr(new Set(he.items.map(Ae=>Ae.notificationId)))}catch{if(b!==K.current)return;qr([]),hr(new Set)}},[]),mr=f.useCallback(b=>{const v=b.map(P=>P.createdAt).sort((P,ee)=>as(ee)-as(P))[0]??null;v&&hs(P=>P&&as(P)>=as(v)?P:v)},[]);f.useEffect(()=>{An&&vs(af,An)},[An]),f.useEffect(()=>{Pr();const b=window.setInterval(()=>{Pr()},sP);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,v;un("workbench.cached_snapshot_loaded",{cached:!!d.current,workspaceCount:((b=d.current)==null?void 0:b.items.length)??0,sessionCount:((v=d.current)==null?void 0:v.items.reduce((P,ee)=>P+ee.sessions.length,0))??0})},[]);function Ar(b){var ee;if(!b||!Array.isArray(b.items))return;tA(g.current,b);const v=eA(b,g.current);un("workbench.apply_snapshot",{workspaceCount:v.items.length,sessionCount:v.items.reduce((re,he)=>re+he.sessions.length,0),currentSessionId:((ee=la(t.pathname))==null?void 0:ee.sessionId)??null});const P=Wp(v,O.current);d.current=v,po(v),Ee.current=P,Ce(P),Qe(Tf(v)),mt(null)}const sn=f.useCallback(async()=>{const b=h.current+1;h.current=b,Tt(v=>v||!p.current),un("workbench.refresh_navigation.start",{requestId:b,hasNavigationData:p.current});try{const v=await wy();if(b!==h.current){un("workbench.refresh_navigation.stale",{requestId:b});return}Ar(v)}catch(v){if(b!==h.current)return;mt(v instanceof Error?v.message:l("shell.navigationLoadFailed")),Y.current({title:v instanceof Error?v.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{un("workbench.refresh_navigation.end",{requestId:b,success:b===h.current}),b===h.current&&Tt(!1)}},[]),Mt=f.useCallback(b=>{Ce(v=>{const P=nA(v,b,O.current);return Ee.current=P,P})},[]),an=f.useCallback(()=>{var b;(b=x.current)==null||b.requestRefresh()},[]),Wt=f.useCallback((b,v)=>{n(ir(b,v))},[n]),on=f.useCallback((b,v,P)=>{var ee;I.current={workspaceId:b,paths:v,knownRevisionByPath:P==null?void 0:P.knownRevisionByPath},(ee=x.current)==null||ee.subscribeFileTree(b,v,P)},[]),gr=f.useCallback((b,v,P)=>{var ee;G.current={workspaceId:b,paths:v,knownRevisionByPath:P==null?void 0:P.knownRevisionByPath},(ee=x.current)==null||ee.requestFileTreeRefresh(b,v,P)},[]),Vr=f.useCallback(b=>(A.current.add(b),()=>{A.current.delete(b)}),[]),br=f.useCallback((b,v)=>{var P;z.current={workspaceId:b,knownRevision:v==null?void 0:v.knownRevision},(P=x.current)==null||P.subscribeGit(b,v)},[]),Kt=f.useCallback((b,v)=>{var P;L.current={workspaceId:b,knownRevision:v==null?void 0:v.knownRevision},(P=x.current)==null||P.requestGitRefresh(b,v)},[]),Kr=f.useCallback(b=>(T.current.add(b),()=>{T.current.delete(b)}),[]),Xn=f.useCallback((b,v)=>{var P;E.current={workspaceId:b,knownRevision:v==null?void 0:v.knownRevision},(P=x.current)==null||P.subscribeWorkspaceManagement(b,v)},[]),Ln=f.useCallback((b,v)=>{var P;H.current={workspaceId:b,knownRevision:v==null?void 0:v.knownRevision},Zt(ee=>{var re;return{...ee,[b]:{detail:((re=ee[b])==null?void 0:re.detail)??null,loading:!0,error:null}}}),(P=x.current)==null||P.requestWorkspaceManagementRefresh(b,v)},[]),Jn=f.useCallback(b=>(F.current.add(b),()=>{F.current.delete(b)}),[]),Qn=f.useCallback(async(b,v=!1)=>{const P=b.trim();if(!P)return;let ee=!0;if(Sn(re=>{const he=re[P];return!v&&(he!=null&&he.loading)?(ee=!1,re):{...re,[P]:{preview:(he==null?void 0:he.preview)??null,loading:!0,applying:(he==null?void 0:he.applying)??!1,cleaning:(he==null?void 0:he.cleaning)??!1,error:null}}}),!!ee)try{const re=await vy(P);Sn(he=>{var Ae,Oe;return{...he,[P]:{preview:re,loading:!1,applying:((Ae=he[P])==null?void 0:Ae.applying)??!1,cleaning:((Oe=he[P])==null?void 0:Oe.cleaning)??!1,error:null}}})}catch(re){Sn(he=>{var Ae,Oe,$e;return{...he,[P]:{preview:((Ae=he[P])==null?void 0:Ae.preview)??null,loading:!1,applying:((Oe=he[P])==null?void 0:Oe.applying)??!1,cleaning:(($e=he[P])==null?void 0:$e.cleaning)??!1,error:re instanceof Error?re.message:l("shell.worktreeMergePreviewFailed")}}})}},[]),w=f.useCallback(async b=>{const v=b.trim();if(v){Sn(P=>{var ee,re;return{...P,[v]:{preview:((ee=P[v])==null?void 0:ee.preview)??null,loading:!1,applying:!0,cleaning:((re=P[v])==null?void 0:re.cleaning)??!1,error:null}}});try{const P=await Sy(v);Sn(ee=>{var re;return{...ee,[v]:{preview:P.preview,loading:!1,applying:!1,cleaning:((re=ee[v])==null?void 0:re.cleaning)??!1,error:null}}}),an(),sn(),Qn(v,!0),Kt(P.preview.targetWorkspace.id),Y.current({title:P.applied?l("shell.worktreeMergeApplySuccess"):l("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(P){Sn(ee=>{var re,he;return{...ee,[v]:{preview:((re=ee[v])==null?void 0:re.preview)??null,loading:!1,applying:!1,cleaning:((he=ee[v])==null?void 0:he.cleaning)??!1,error:P instanceof Error?P.message:l("shell.worktreeMergeApplyFailed")}}}),Y.current({title:P instanceof Error?P.message:l("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[Qn,sn,Kt,an]),U=f.useCallback(async b=>{var ee,re;const v=b.workspaceId,P=ur&&((re=(ee=Vt[v])==null?void 0:ee.preview)==null?void 0:re.alreadyMerged)===!0;Sn(he=>{var Ae;return{...he,[v]:{preview:((Ae=he[v])==null?void 0:Ae.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const he=await Cy(v,{deleteBranch:P});if(Sn(Ae=>{var Oe;return{...Ae,[v]:{preview:((Oe=Ae[v])==null?void 0:Oe.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),dr(!1),Mr(Ae=>(Ae==null?void 0:Ae.workspaceId)===v?null:Ae),an(),await sn(),n(Ir(b.parentWorkspaceId),{replace:!0}),he.branchDeleted){Y.current({title:l("shell.worktreeCleanupDeleteBranchSuccess",{branch:he.deletedBranchName||b.branchName}),tone:"success"});return}if(he.branchDeleteRequested){Y.current({title:l("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:b.branchName}),description:he.branchDeleteError||void 0,tone:"warning"});return}Y.current({title:l("shell.worktreeCleanupSuccess"),tone:"success"})}catch(he){Sn(Ae=>{var Oe;return{...Ae,[v]:{preview:((Oe=Ae[v])==null?void 0:Oe.preview)??null,loading:!1,applying:!1,cleaning:!1,error:he instanceof Error?he.message:l("shell.worktreeCleanupFailed")}}}),Y.current({title:he instanceof Error?he.message:l("shell.worktreeCleanupFailed"),tone:"error"})}},[ur,n,sn,an,Vt]),Pe=f.useCallback(b=>{dr(!1),Mr(b)},[]),Xe=f.useCallback((b,v)=>{var P;B.current={workspaceId:b,knownRevision:v==null?void 0:v.knownRevision},(P=x.current)==null||P.subscribeTerminalManager(b,v)},[]),Cn=f.useCallback((b,v)=>{var P;oe.current={workspaceId:b,knownRevision:v==null?void 0:v.knownRevision},(P=x.current)==null||P.requestTerminalManagerRefresh(b,v)},[]),Lr=f.useCallback(b=>(R.current.add(b),()=>{R.current.delete(b)}),[]),Yr=f.useCallback((b,v)=>{Ce(P=>rA(P,b,v??new Date().toISOString()))},[]),Nn=f.useCallback(async(b,v)=>{g.current.set(b,v),Ce(P=>Ef(P,b,v));try{const P=await Gf(b,v),ee=Tr(P);ee===v?g.current.set(b,ee):g.current.delete(b),Mt(P),an(),sn()}catch(P){throw g.current.delete(b),Ce(ee=>Ef(ee,b,!v)),P}},[sn,an,Mt]),kn=f.useCallback((b,v)=>{un("workbench.set_session_workspace",{sessionId:b,workspaceId:v}),Re(P=>{if(!v){if(!(b in P))return P;const ee={...P};return delete ee[b],ee}return P[b]===v?P:{...P,[b]:v}})},[]);f.useEffect(()=>{p.current=J.length>0},[J]),f.useEffect(()=>{un("workbench.navigation_state",{navigationLoading:ve,workspaceCount:J.length,sessionCount:J.reduce((b,v)=>b+v.sessions.length,0)})},[J,ve]),f.useEffect(()=>{j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{var we;j.current=null,!(m.current||p.current)&&(un("workbench.refresh_navigation.ws_fallback_triggered"),(we=x.current)==null||we.requestRefresh())},1200);const b=new Kx({onConnectionChange:we=>{we==="connected"&&Ny(),we==="reconnect_failed"&&!p.current&&(mt(l("shell.navigationLoadFailed")),Y.current({id:"workbench-navigation-connection",title:l("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:we=>{m.current=!0,un("workbench.ws_snapshot_received",{workspaceCount:we.items.length,sessionCount:we.items.reduce((lt,Tn)=>lt+Tn.sessions.length,0)}),j.current!==null&&(window.clearTimeout(j.current),j.current=null),Ar(we),Tt(!1)},onFileTreeSnapshot:we=>{A.current.forEach(lt=>lt(we))},onGitSnapshot:we=>{ra(jk(we.workspaceId),{revision:we.revision??null,status:we.status,history:we.history,historyTotalCount:we.historyTotalCount,historyNextCursor:we.historyNextCursor,branches:we.branches}),Zt(lt=>{var sr;const Tn=((sr=J.find(Xs=>Xs.workspace.id===we.workspaceId))==null?void 0:sr.workspace)??null;if(!Tn)return lt;const Dn=lt[we.workspaceId],$t=Ek(Ik((Dn==null?void 0:Dn.detail)??Tk(Tn),Tn),we);return ra(hu(we.workspaceId),$t),{...lt,[we.workspaceId]:{detail:$t,loading:!1,error:null}}}),T.current.forEach(lt=>lt(we))},onWorkspaceManagementSnapshot:we=>{ra(hu(we.workspaceId),we),Zt(lt=>({...lt,[we.workspaceId]:{detail:we,loading:!1,error:null}})),F.current.forEach(lt=>lt(we))},onTerminalManagerSnapshot:we=>{R.current.forEach(lt=>lt(we))},onUnauthorized:()=>{ca.clear(),n("/login",{replace:!0})}});b.primeWorkbenchSnapshot(d.current),x.current=b;const v=I.current,P=G.current,ee=z.current,re=L.current,he=E.current,Ae=H.current,Oe=B.current,$e=oe.current;return v&&b.subscribeFileTree(v.workspaceId,v.paths,{knownRevisionByPath:v.knownRevisionByPath}),ee&&b.subscribeGit(ee.workspaceId,{knownRevision:ee.knownRevision}),he&&b.subscribeWorkspaceManagement(he.workspaceId,{knownRevision:he.knownRevision}),Oe&&b.subscribeTerminalManager(Oe.workspaceId,{knownRevision:Oe.knownRevision}),P&&b.requestFileTreeRefresh(P.workspaceId,P.paths,{knownRevisionByPath:P.knownRevisionByPath}),re&&b.requestGitRefresh(re.workspaceId,{knownRevision:re.knownRevision}),Ae&&b.requestWorkspaceManagementRefresh(Ae.workspaceId,{knownRevision:Ae.knownRevision}),$e&&b.requestTerminalManagerRefresh($e.workspaceId,{knownRevision:$e.knownRevision}),b.start(),()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null),x.current===b&&(x.current=null),b.close()}},[n]),f.useEffect(()=>{vs(tf,String(ae))},[ae]),f.useEffect(()=>{vs(nf,String(ke))},[ke]),f.useEffect(()=>{vs(rf,String(Me))},[Me]),f.useEffect(()=>{vs(sf,String(Q))},[Q]),f.useEffect(()=>{if(!rt){GP(vc);return}vs(vc,rt)},[rt]),f.useEffect(()=>{if(qe||Q)return;const b=window.setTimeout(()=>{gt(!0)},rP);return()=>{window.clearTimeout(b)}},[qe,Q]);const kr=la(t.pathname),Je=(kr==null?void 0:kr.sessionId)??null,Ct=Je?_k(Je):!1,Nt=f.useMemo(()=>ux(J),[J]),xt=f.useMemo(()=>ak(Nt,a),[Nt,a]),_r=f.useMemo(()=>fk(J),[J]),yr=f.useMemo(()=>new Set(ut),[ut]),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 v=Nc(b,ut);d.current=v,po(v),Ee.current=b,Ce(b)},[ut]),er=f.useCallback(b=>{const v=!yr.has(b),P=Rf(ut,b,v),ee=Nc(J,P);d.current=ee,po(ee),Qe(P),Vf(b,{collapsed:v}).catch(re=>{const he=Rf(P,b,!v),Ae=Nc(J,he);d.current=Ae,po(Ae),Qe(he),Y.current({title:re instanceof Error?re.message:l("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[yr,ut,J]),Ws=f.useCallback(()=>{q.current={originalGroups:Ee.current}},[]),Fs=f.useCallback((b,v,P)=>{const ee=Ee.current,re=ZP(ee,b,v,P);re!==ee&&hn(re)},[hn]),Ei=f.useCallback(()=>{const b=q.current;q.current=null;const v=Ee.current;b&&(b.originalGroups.length===v.length&&b.originalGroups.every((P,ee)=>{var re;return P.workspace.id===((re=v[ee])==null?void 0:re.workspace.id)})||jy({workspaceIds:v.map(P=>P.workspace.id)}).catch(P=>{hn(b.originalGroups),Y.current({title:P instanceof Error?P.message:l("shell.workspaceReorderFailed"),tone:"error"})}))},[hn]);f.useEffect(()=>{const b=new Map;if(Nt.forEach(({session:v})=>{b.set(v.sessionId,{activityState:v.activityState,completedAt:v.completedAt??null,runningState:v.runningState??null})}),!fe.current){fe.current=!0,ue.current=b;return}Nt.forEach(({session:v})=>{var Ae;if(v.sessionId===Je)return;const P=ue.current.get(v.sessionId);if(!P)return;const ee=P.activityState!=="completed_unread"&&v.activityState==="completed_unread",re=((Ae=v.title)==null?void 0:Ae.trim())||l("common.unknown");if(c&&ee){const Oe=l("conversation.backgroundCompletionToastDescription",{title:re});Y.current({id:`workbench-session-completed-${v.sessionId}-${v.completedAt??"unknown"}`,title:l("conversation.backgroundCompletionToastTitle"),description:Oe,tone:"success",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Wt(v.workspaceId,v.sessionId)}}),D.current.showNotification(l("conversation.backgroundCompletionToastTitle"),Oe)}const he=P.runningState!=="failed"&&(v.runningState??null)==="failed";if(u&&he){const Oe=bP(v)??l("conversation.runtimeFailed"),$e=l("conversation.backgroundFailureToastDescription",{title:re,detail:Oe});Y.current({id:`workbench-session-failed-${v.sessionId}-${v.updatedAt}`,title:l("conversation.backgroundFailureToastTitle"),description:$e,tone:"error",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Wt(v.workspaceId,v.sessionId)}}),D.current.showNotification(l("conversation.backgroundFailureToastTitle"),$e)}}),ue.current=b},[Je,Nt,c,u,Wt]),f.useEffect(()=>{Te.current=Nt.map(b=>b.session).filter(b=>b.sessionId!==Je&&mP(b)).map(b=>{var v;return{sessionId:b.sessionId,workspaceId:b.workspaceId,title:((v=b.title)==null?void 0:v.trim())||l("common.unknown")}})},[Je,Nt]),f.useEffect(()=>{let b=!1,v=null;const P=()=>{v=window.setTimeout(()=>{ee().finally(()=>{b||P()})},aP)},ee=async()=>{var $e;const re=Te.current;if(re.length===0){He.current||(He.current=!0),je.current="";return}const he=new Set(re.map(we=>we.sessionId)),Ae=await Promise.all(re.map(async we=>{try{const lt=await Iy(we.sessionId);return{session:we,items:lt.items}}catch{return{session:we,items:null}}}));if(b)return;for(const we of Ae){if(!we.items)continue;const lt=we.items.filter($t=>$t.status==="pending"),Tn=new Set(lt.map($t=>$t.id)),Dn=Ue.current.get(we.session.sessionId)??new Set;He.current&<.forEach($t=>{if(Dn.has($t.id)||!o)return;const sr=l("conversation.backgroundPermissionToastDescription",{title:we.session.title,requestTitle:$t.title});Y.current({id:`workbench-permission-request-${$t.id}`,title:l("conversation.permissionRequestToastTitle"),description:sr,tone:"warning",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Wt(we.session.workspaceId,we.session.sessionId)}}),D.current.showNotification(l("conversation.permissionRequestToastTitle"),sr)}),Ue.current.set(we.session.sessionId,Tn)}for(const[we,lt]of Ue.current.entries())!he.has(we)&<.size===0&&Ue.current.delete(we);const Oe=gP(Ue.current,he);He.current&&Oe!==je.current&&(($e=x.current)==null||$e.requestRefresh()),je.current=Oe,He.current=!0};return ee().finally(()=>{b||P()}),()=>{b=!0,v!==null&&window.clearTimeout(v)}},[o,Wt]),f.useEffect(()=>{ve&&J.length===0||(Qe(b=>vk(b,_r)),st(b=>b&&_r.has(b)?b:null))},[_r,ve]);const ln=Nt.find(b=>b.session.sessionId===Je)??null,qt=(ln==null?void 0:ln.workspace.id)??(Je?de[Je]??null:null),tr=gf(t.pathname,t.search),$s=tr&&_r.has(tr)?tr:null,Mi=rt&&_r.has(rt)?rt:null,Ri=qt??$s??Mi??null,We=Ri??((Fi=J[0])==null?void 0:Fi.workspace.id)??null,xr=f.useCallback(b=>{if(b){const v=Nt.find(P=>P.workspace.id===b)??null;if(v)return v}return Nt[0]??null},[Nt]),ps=f.useCallback(b=>{const v=typeof window>"u"?null:window.localStorage.getItem(bo);if(!v)return null;const P=v.split("?")[0]??v,ee=la(P);if(!ee)return window.localStorage.removeItem(bo),null;const re=ee.sessionId,he=Nt.find(Oe=>Oe.session.sessionId===re)??null,Ae=ee.workspaceId??(he==null?void 0:he.workspace.id)??null;return he&&(!b||Ae===b)?ir(he.workspace.id,he.session.sessionId):(window.localStorage.removeItem(bo),null)},[Nt]),jn=f.useMemo(()=>bn.filter(b=>!Rr.has(b.id)),[Rr,bn]),Xr=f.useMemo(()=>jn.filter(b=>CP(b,An)).length,[jn,An]);f.useEffect(()=>{pr&&mr(jn)},[jn,mr,pr]);const gl=f.useCallback(b=>{zn(!1),b.routePath&&n(b.routePath)},[n]),fs=f.useCallback(async(b,v)=>{const P=X.current+1;X.current=P;try{const ee=await yT(b,v);if(P!==X.current)return;hr(re=>{const he=new Set(re);return ee.item?he.add(ee.item.notificationId):he.delete(b),he})}catch(ee){if(P!==X.current)return;Y.current({title:l("shell.globalNotificationsArchiveFailed"),description:ee instanceof Error?ee.message:void 0,tone:"error"})}},[]);f.useEffect(()=>{qt&&st(b=>b===qt?b:qt)},[qt]),f.useEffect(()=>{var he;if(ve)return;const b=((he=J[0])==null?void 0:he.workspace.id)??null,v=$s??b??Mi,P=Je&&!Ct?xr(v):null,ee=Je&&!Ct?ps(v):null,re=P?ir(P.workspace.id,P.session.sessionId):null;if(tr&&!$s){n(ee??re??(b?EP(t.pathname,b):Cc(e)),{replace:!0});return}if(Je&&!Ct&&!qt){n(ee??re??(b?xi(b):Cc(e)),{replace:!0});return}},[Je,xr,Ct,t.pathname,n,J,ve,ps,tr,qt,e,Mi,$s]),f.useEffect(()=>{un("workbench.current_workspace_resolved",{currentSessionId:Je,sessionWorkspaceId:qt,routeWorkspaceId:tr,currentWorkspaceId:We,source:qt?ln?"navigation":"sessionWorkspaceMap":tr?"route":rt?"workspaceSelection":"navigationFallback"})},[ln,Je,We,tr,rt,qt]);const _n=Eo(t.pathname)?"terminals":Mo(t.pathname)?"butler":"conversation",Ft=e==="mobile",ms=Cc(e),Pi=f.useMemo(()=>J.map(b=>{const v=uk(b.sessions),P=new Set(b.sessions.map(ee=>ee.sessionId));return{workspace:b.workspace,visibleSessions:v,archivedSessions:b.sessions.filter(ee=>Tr(ee)&&!Ia(ee)),visibleSessionTree:ik(v,a).filter(ee=>!Zn.has(ee.item.sessionId)&&!ju(Rn(ee),re=>Zn.has(re.sessionId))),childWorktrees:mk(b.childWorktrees,Zn,a,P),isCollapsed:yr.has(b.workspace.id)}}),[yr,Zn,J,a]),zs=f.useMemo(()=>pR(J),[J]),gs=f.useMemo(()=>jf(J,We),[We,J]),nr=(ln?ix(ln.session,ln.session.sessionIsolatedWorkspace):We)??We,Hn=f.useMemo(()=>jf(J,nr),[nr,J]),Ai=f.useMemo(()=>We?(gs==null?void 0:gs.workspace)??J.map(b=>b.workspace).find(b=>b.id===We)??null:null,[We,gs,J]),Li=f.useMemo(()=>nr?(Hn==null?void 0:Hn.workspace)??J.map(b=>b.workspace).find(b=>b.id===nr)??null:null,[nr,Hn,J]),Jr=(Hn==null?void 0:Hn.meta)??null,kl=(We?zs[We]??null:null)??(Ai?Jo(Ai):null),rr=(nr?zs[nr]??null:null)??(Li?Jo(Li):kl),Ea=Jr?Vt[Jr.workspaceId]??null:null,Hs=f.useMemo(()=>{var v,P,ee;if(!Je)return null;const b=((ee=(P=(v=ln==null?void 0:ln.session)==null?void 0:v.parallelGroup)==null?void 0:P.groupId)==null?void 0:ee.trim())||null;return b||WP(xt,Je)},[(M=(k=ln==null?void 0:ln.session)==null?void 0:k.parallelGroup)==null?void 0:M.groupId,Je,xt]),cn=_n==="conversation"&&!!Hs;f.useEffect(()=>{if(typeof window>"u"||!cn||!Hs){Be(null);return}const b=ox(Hs);if(!b||b.sidebarCollapseDurationMs<=0){Be(null);return}Be(b);const v=Date.now()-b.createdAt,P=b.totalDurationMs-v;if(P<=0){Be(null);return}const ee=window.setTimeout(()=>{Be(null)},P);return()=>{window.clearTimeout(ee)}},[Hs,cn]),f.useEffect(()=>{un("workbench.info_panel_state",{infoPanelReady:qe,rightCollapsed:Q||cn,currentWorkspaceId:We,sessionWorkspaceId:qt,currentSessionId:Je})},[Je,We,qe,cn,Q,qt]);const Dr=f.useMemo(()=>Nt.filter(b=>Zn.has(b.session.sessionId)&&!Tr(b.session)&&!Qo(b.session)),[Zn,Nt]),_i=t.pathname.startsWith("/settings")?"settings":Mo(t.pathname)?"terminals":Eo(t.pathname)?"butler":IP(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":TP(t.pathname)||bf(t.pathname)?"sessions":"workspaces",yl=Ft&&(_i==="sessions"&&bf(t.pathname)||Mo(t.pathname)),xl=nl({isNativeMobile:r.isNativeMobile,viewportClass:r.viewportClass}),Ma=wa({viewportClass:r.viewportClass,activeEntry:_i,hasNavigationPanel:Ft,hasAuxiliaryPanel:Ft,preferCompactLayout:xl}),wl=Ft&&wm(Ma),vl=Ft&&vm(Ma),Sl=f.useMemo(()=>J.map(b=>b.workspace),[J]),Cl=f.useMemo(()=>{const b=ft.trim().toLowerCase();return b?Nt.filter(v=>{const P=(v.session.title||"").toLowerCase(),ee=v.workspace.name.toLowerCase(),re=fl(v.session.provider,"full").toLowerCase();return P.includes(b)||ee.includes(b)||re.includes(b)}):[]},[Nt,ft]);f.useEffect(()=>{var v;const b=We??((v=J[0])==null?void 0:v.workspace.id)??"";b&&ct(P=>P&&J.some(re=>re.workspace.id===P)?P:b)},[We,J]),f.useEffect(()=>{Je&&!Ct&&qt&&vs(bo,`${t.pathname}${t.search}`)},[Je,Ct,t.pathname,t.search,qt]),f.useEffect(()=>{if(Je&&Ct){y.current=`${t.pathname}${t.search}`;return}Je&&!Ct&&(y.current=null)},[Je,Ct,t.pathname,t.search]),f.useEffect(()=>{Ft||(De(!1),Ze(!1))},[Ft]),f.useEffect(()=>{!Ft||ve||!jP(t.pathname)||Ri||(De(!1),Ze(!1),n(ms,{replace:!0}))},[Ri,Ft,t.pathname,n,ve,ms]);function Nl(){if(Ft){De(!0);return}$(!1)}function Us(){if(!cn){if(Br(),Ft){Ze(!0);return}ge(!1)}}function jl(){if(Ft){De(b=>!b);return}$(b=>!b)}function Ra(){if(!cn){if(Br(),Ft){Ze(b=>!b);return}ge(b=>!b)}}function Br(){gt(!0)}function qs(b){if(st(b),Br(),Eo(t.pathname)){const v=js(b);t.pathname!==v&&n(v);return}Je&&qt!==b&&n(ms)}const bs=f.useCallback(async b=>{var ee;const v=((ee=Nt.find(re=>re.session.sessionId===b))==null?void 0:ee.session)??null,P=(v==null?void 0:v.isFavorite)!==!0;Ce(re=>Mf(re,b,P));try{const re=await Ty(b,P);Mt(re),an()}catch(re){throw Ce(he=>Mf(he,b,!P)),re}},[Nt,an,Mt]),Pa=f.useCallback((b,v)=>{rk(b,v).then(()=>{n(gm(b,v))}).catch(P=>{i({title:P instanceof Error?P.message:l("shell.startSessionFailed"),tone:"error"})})},[n,i]),Aa=f.useCallback(b=>{var ee;const v=((ee=b.workspaceId)==null?void 0:ee.trim())||We,P=MP(b.filePath);return!v||!P?!1:(Br(),Ye("files"),Ft?(De(!1),Ze(!0)):ge(!1),Qt({requestId:S.current+1,workspaceId:v,filePath:P,openViewer:b.openViewer===!0}),S.current+=1,!0)},[We,Ft]),Di=f.useCallback(async(b,v)=>{const P=await Kf(b,v.trim());return Mt(P),P},[Mt]);function Gs(b){Se(!0)}function Bi(){Se(!1),Bt("sessions"),Ot(""),kt(null),gn([]),Ds(!1)}async function La(){const b=ft.trim();if(!b||!et.trim()){gn([]),kt(null);return}Ds(!0),kt(null);try{const v=await Yy(et,b);gn(v.items)}catch(v){gn([]),kt(v instanceof Error?v.message:l("shell.searchCodeFailed"))}finally{Ds(!1)}}function ks(b,v){const P=V.current;P&&(P.style.setProperty("--workbench-left-width",`${b}px`),P.style.setProperty("--workbench-left-current-width",Me?"0px":`${b}px`),P.style.setProperty("--workbench-right-width",`${v}px`),P.style.setProperty("--workbench-right-current-width",Q?"0px":`${v}px`))}function Tl(b={}){return{leftWidth:b.leftWidth??(Me?0:le.current),rightWidth:b.rightWidth??(Un&&!Q?C.current:0),leftCollapsed:b.leftCollapsed??Me,rightCollapsed:b.rightCollapsed??(!Un||Q),prefersDarkAppearance:b.prefersDarkAppearance??fr!=="light",isResizing:b.isResizing??Ke!==null}}function _a(b,v){var Oe;v.preventDefault(),v.stopPropagation(),(Oe=window.getSelection())==null||Oe.removeAllRanges();const P=v.clientX,ee=b==="left"?ae:ke;Ie(b);const re=()=>{const $e=Z.current;if(Z.current=null,$e!==null){if(b==="left"){le.current=$e,se(we=>we===$e?we:$e),ks($e,C.current);return}C.current=$e,ye(we=>we===$e?we:$e),ks(le.current,$e)}};function he($e){var Dn;$e.preventDefault(),(Dn=window.getSelection())==null||Dn.removeAllRanges();const we=$e.clientX-P,lt=b==="left"?wo(ee+we,of,cf):wo(ee-we,lf,uf),Tn=b==="left"?le.current:C.current;lt===Tn&&Z.current===null||(Z.current=lt,_e.current===null&&(_e.current=window.requestAnimationFrame(()=>{_e.current=null,re()})))}function Ae(){document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Ae),_e.current!==null&&(window.cancelAnimationFrame(_e.current),_e.current=null),re(),Ie(we=>we===b?null:we);const $e=Tl({isResizing:!1});Wa.current=$e,r.bridge.syncNativeSidebarLayout($e)}document.addEventListener("mousemove",he,{passive:!1}),document.addEventListener("mouseup",Ae)}function Vs(){if(Da())return;if(Nt.length===0){n(ms);return}const b=ir(Nt[0].workspace.id,Nt[0].session.sessionId);n(b)}function Il(){if(!Da(We)){if(We){n(xi(We));return}n(ms)}}function Da(b){if(Je&&qt)return b&&qt&&qt!==b?!1:(n(`${t.pathname}${t.search}`),!0);if(y.current){if(b){const[P,ee=""]=y.current.split("?"),re=gf(P??y.current,ee?`?${ee}`:"");if(re&&re!==b)return!1}return n(y.current),!0}const v=ps(b);return v?(n(v),!0):!1}f.useEffect(()=>{if(typeof window>"u")return;function b(v){if(!(v.metaKey||v.ctrlKey)){v.key==="Escape"&&(De(!1),Ze(!1));return}if(KP(v.target))return;const ee=v.key.toLowerCase();if(!v.shiftKey&&ee==="b"){v.preventDefault(),jl();return}if(v.shiftKey&&ee==="i"){v.preventDefault(),Ra();return}if(!v.shiftKey&&ee===","){v.preventDefault(),n("/settings");return}if(!v.shiftKey&&ee==="1"){v.preventDefault(),Vs();return}if(!v.shiftKey&&ee==="2"){v.preventDefault(),n(We?js(We):xn());return}if(!v.shiftKey&&ee==="k"){v.preventDefault(),YP();return}v.shiftKey&&ee==="r"&&(v.preventDefault(),sn())}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[n,sn,Ft,Vs]);const El=f.useMemo(()=>({shellMode:e,navigationGroups:J,navigationLoading:ve,navigationError:nt,currentWorkspaceId:We,currentSessionId:Je,favoriteSessionIds:yn,favoriteSessions:Dr,globalNotifications:bn,archivedNotificationIds:Array.from(Rr),showArchivedNotifications:ds,unreadNotificationCount:Xr,refreshNavigation:sn,requestNavigationRefresh:an,openNotificationPanel:()=>{zn(!0)},closeNotificationPanel:()=>{zn(!1)},setShowArchivedNotifications:Gr,archiveNotification:b=>{fs(b,!0)},unarchiveNotification:b=>{fs(b,!1)},setAuxiliaryPanel:_,subscribeFileTree:on,requestFileTreeRefresh:gr,addFileTreeSnapshotListener:Vr,subscribeGitSnapshot:br,requestGitRefresh:Kt,addGitSnapshotListener:Kr,subscribeWorkspaceManagementSnapshot:Xn,requestWorkspaceManagementRefresh:Ln,addWorkspaceManagementSnapshotListener:Jn,workspaceManagementStateById:Yn,subscribeTerminalManagerSnapshot:Xe,requestTerminalManagerRefresh:Cn,addTerminalManagerSnapshotListener:Lr,selectWorkspace:qs,toggleFavoriteSession:bs,archiveSession:b=>Nn(b,!0),unarchiveSession:b=>Nn(b,!1),renameSession:Di,startDraftSession:Pa,markNavigationSessionSeen:Yr,upsertNavigationSession:Mt,setSessionWorkspace:kn,revealWorkspaceFile:Aa}),[Vr,Kr,Jn,Lr,Nn,Je,We,bn,yn,Dr,qs,Rr,Yr,nt,J,ve,Xr,gr,Kt,Ln,sn,an,Gr,_,Cn,Di,ds,Yn,e,Pa,kn,on,br,Xn,Xe,fs,bs,Mt,Aa]),Ml={"--workbench-left-width":`${ae}px`,"--workbench-left-current-width":Me?"0px":`${ae}px`,"--workbench-right-width":`${ke}px`,"--workbench-right-current-width":Q||cn?"0px":`${ke}px`,"--workbench-right-sidebar-duration":Ne&&!Q?`${Ne.sidebarCollapseDurationMs}ms`:void 0,"--workbench-right-sidebar-content-duration":Ne&&!Q?`${Math.max(320,Ne.sidebarCollapseDurationMs-120)}ms`:void 0},Ba=_n==="butler"?_t:s.jsx(Df,{panelReady:qe,activeTab:Ht,fileRevealRequest:cr,onTabChange:b=>{Br(),Ye(b)},currentSessionId:Ct?null:Je,activeWorkspaceId:nr,navigationGroups:J,workspaceContext:rr,worktreeMeta:Jr,worktreeMergeState:Ea,onRefreshWorktreeMergePreview:Qn,onApplyWorktreeMerge:w,onCleanupWorktree:U}),Un=Ba!==null,wr=Q||cn,Ks=cn&&Ne!==null&&!Q,Ys=r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar;f.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:b,body:v}=document,P=()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null);const re=be.current;be.current=!1,b.removeAttribute(yo),v==null||v.removeAttribute(yo),re&&ne.current&&(ne.current=!1,Os(he=>he+1))};if(!Ys){P();return}const ee=()=>{be.current=!0,b.setAttribute(yo,"true"),v==null||v.setAttribute(yo,"true"),N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{P()},lP)};return window.addEventListener("resize",ee),()=>{window.removeEventListener("resize",ee),P()}},[Ys]);const ys=f.useMemo(()=>({leftWidth:Me?0:ae,rightWidth:Un&&!wr?ke:0,leftCollapsed:Me,rightCollapsed:!Un||wr,prefersDarkAppearance:fr!=="light",isResizing:Ke!==null}),[Ke,wr,Me,ae,ke,Un,fr]),Rl=f.useDeferredValue(ys),Oa=Ke===null?Rl:ys,Wa=f.useRef(ys);f.useEffect(()=>{Wa.current=ys},[ys]),f.useEffect(()=>{if(typeof window>"u")return;let b=null;const v=()=>{b=null,r.bridge.syncNativeSidebarLayout(Oa)},P=()=>{b!==null&&window.cancelAnimationFrame(b),b=window.requestAnimationFrame(v)};return rn?(P(),()=>{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)})},[Oa,r.bridge,rn]),f.useLayoutEffect(()=>{const b=V.current;if(!b||!Ys||typeof window>"u"){ff(b);return}let v=null,P=null;const ee=new Set([b]),re=()=>{ne.current=!1;const Ae=window.getComputedStyle(b),Oe=nk(Ae,"--desktop-macos-traffic-light-center-y");if(Oe===null){ff(b);return}const $e={navToolbar:ns(b,Rt.navToolbar.selector),infoTabs:ns(b,Rt.infoTabs.selector),auxiliaryToolbarButton:ns(b,Rt.auxiliaryToolbarButton.selector),conversationHeaderMain:ns(b,Rt.conversationHeaderMain.selector),conversationHeaderActions:ns(b,Rt.conversationHeaderActions.selector),terminalTabbarMain:ns(b,Rt.terminalTabbarMain.selector),collapsedLeftControls:ns(b,Rt.collapsedLeftControls.selector),collapsedRightControls:ns(b,Rt.collapsedRightControls.selector)},we=[$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(Ae,"--workbench-collapsed-controls-live-shift-y",Oe,lt.reduce(($t,sr)=>$t+sr,0)/lt.length):null,Dn=we.length>0?Cr(Ae,"--workbench-titlebar-live-content-shift-y",Oe,we.reduce(($t,sr)=>$t+sr,0)/we.length):null;Sr(b,"--workbench-titlebar-live-content-shift-y",Dn),Sr(b,"--workbench-collapsed-controls-live-shift-y",Tn),Sr(b,Rt.navToolbar.variableName,Cr(Ae,Rt.navToolbar.variableName,Oe,$e.navToolbar)),Sr(b,Rt.infoTabs.variableName,Cr(Ae,Rt.infoTabs.variableName,Oe,$e.infoTabs)),Sr(b,Rt.auxiliaryToolbarButton.variableName,Cr(Ae,Rt.auxiliaryToolbarButton.variableName,Oe,$e.auxiliaryToolbarButton)),Sr(b,Rt.conversationHeaderMain.variableName,Cr(Ae,Rt.conversationHeaderMain.variableName,Oe,$e.conversationHeaderMain)),Sr(b,Rt.conversationHeaderActions.variableName,Cr(Ae,Rt.conversationHeaderActions.variableName,Oe,$e.conversationHeaderActions)),Sr(b,Rt.terminalTabbarMain.variableName,Cr(Ae,Rt.terminalTabbarMain.variableName,Oe,$e.terminalTabbarMain)),Sr(b,Rt.collapsedLeftControls.variableName,Cr(Ae,Rt.collapsedLeftControls.variableName,Oe,$e.collapsedLeftControls)),Sr(b,Rt.collapsedRightControls.variableName,Cr(Ae,Rt.collapsedRightControls.variableName,Oe,$e.collapsedRightControls))},he=()=>{if(be.current){ne.current=!0;return}v!==null&&window.cancelAnimationFrame(v),v=window.requestAnimationFrame(()=>{v=null,re()})};if(he(),typeof ResizeObserver<"u"){P=new ResizeObserver(()=>{he()});for(const Ae of Object.values(Rt))for(const Oe of b.querySelectorAll(Ae.selector))ee.add(Oe);for(const Ae of ee)P.observe(Ae)}return window.addEventListener("resize",he),()=>{v!==null&&window.cancelAnimationFrame(v),window.removeEventListener("resize",he),P==null||P.disconnect()}},[_n,qe,Me,t.pathname,t.search,Q,Un,Ys,Ii]);const Oi=Ft?s.jsx(_f,{workspaceGroups:Pi,workspaceVisualContextMap:zs,sessionDisplaySortMode:a,favoriteSessions:Dr,favoriteSessionIds:Zn,activeWorkspaceId:We,isConversationActive:_n==="conversation",isTerminalActive:_n==="terminals",isButlerActive:_n==="butler",isSearchOpen:xe,navigationLoading:ve,navigationError:nt,activeSessionId:Je,onRefreshNavigation:sn,onSessionUpdated:Mt,onNavigateConversation:Vs,onNavigateTerminals:()=>{De(!1),n(We?js(We):xn())},onNavigateButler:()=>{De(!1),n(We?Ms(We):xn())},onOpenSearch:()=>{De(!1),Gs()},onOpenSettings:()=>{De(!1),n("/settings")},onSelectWorkspace:qs,onToggleWorkspaceCollapse:er,onStartWorkspaceReorder:Ws,onPreviewWorkspaceReorder:Fs,onCommitWorkspaceReorder:Ei,allowWorkspaceReorder:!1,subscribeGitSnapshot:br,requestGitRefresh:Kt,subscribeWorkspaceManagementSnapshot:Xn,requestWorkspaceManagementRefresh:Ln,onToggleFavoriteSession:bs,onArchiveSession:b=>Nn(b,!0),onUnarchiveSession:b=>Nn(b,!1),workspaceManagementStateById:Yn,setWorkspaceManagementStateById:Zt,unreadNotificationCount:Xr,notificationPanelOpen:pr,onToggleNotificationPanel:()=>{zn(b=>!b)},onClose:()=>De(!1)}):null,Fa=Ft&&Un?Ba:null;return s.jsxs(sk.Provider,{value:El,children:[Ft?s.jsx(s.Fragment,{children:s.jsx(Ox,{activeEntry:_i,presentation:yl?"conversation-focus":"default",navigationPanel:Oi,auxiliaryPanel:Fa,onOpenNavigation:()=>{Ze(!1),De(!0)},onOpenSearch:()=>{De(!1),Ze(!1),Gs()},onOpenAuxiliary:()=>{Un&&(Br(),De(!1),Ze(!0))},onNavigateWorkspaces:()=>{De(!1),Ze(!1),n(xn())},onNavigateTerminals:()=>{De(!1),Ze(!1),n(We?js(We):xn())},onNavigateButler:()=>{De(!1),Ze(!1),n(We?Ms(We):xn())},onNavigateSessions:()=>{De(!1),Ze(!1),Il()},onNavigateToolFiles:()=>{De(!1),Ze(!1),n(We?pm(We):xn())},onNavigateToolGit:()=>{De(!1),Ze(!1),n(We?fm(We):xn())},onNavigateToolProcesses:()=>{De(!1),Ze(!1),n(We?mm(We):xn())},onNavigateSettings:()=>{De(!1),Ze(!1),n("/settings")},children:s.jsx(gd,{})})}):s.jsx("div",{className:"workbench-shell",ref:V,style:Ml,onMouseDownCapture:vn,onDoubleClickCapture:Bs,"data-nav-loading":ve,"data-left-collapsed":Me,"data-right-collapsed":wr,"data-info-ready":qe,"data-parallel-conversation-active":cn?"true":void 0,"data-parallel-sidebar-transition":Ks?"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":Me,children:s.jsx(_f,{workspaceGroups:Pi,workspaceVisualContextMap:zs,sessionDisplaySortMode:a,favoriteSessions:Dr,favoriteSessionIds:Zn,activeWorkspaceId:We,isConversationActive:_n==="conversation",isTerminalActive:_n==="terminals",isButlerActive:_n==="butler",isSearchOpen:xe,navigationLoading:ve,navigationError:nt,activeSessionId:Je,onRefreshNavigation:sn,onSessionUpdated:Mt,onNavigateConversation:Vs,onNavigateTerminals:()=>n(We?js(We):xn()),onNavigateButler:()=>n(We?Ms(We):xn()),onOpenSearch:()=>Gs(),onOpenSettings:()=>n("/settings"),onSelectWorkspace:qs,onToggleWorkspaceCollapse:er,onStartWorkspaceReorder:Ws,onPreviewWorkspaceReorder:Fs,onCommitWorkspaceReorder:Ei,allowWorkspaceReorder:!0,subscribeGitSnapshot:br,requestGitRefresh:Kt,subscribeWorkspaceManagementSnapshot:Xn,requestWorkspaceManagementRefresh:Ln,onToggleFavoriteSession:bs,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":Me,role:"separator","aria-label":l("shell.leftResizerLabel"),onMouseDown:Me?void 0:b=>_a("left",b)}),s.jsxs("div",{className:"workbench-main-shell",children:[s.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!Me&&!Q,children:[s.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":Me,children:[s.jsx(Pf,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:Nl}),s.jsx(Jb,{collapsed:!0}),s.jsx(Rk,{unreadCount:Xr,open:pr,onToggle:()=>{zn(b=>!b)},collapsed:!0})]}),Un&&!cn?s.jsx("div",{className:"workbench-collapsed-controls right","data-visible":Q,children:s.jsx(Pf,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:Us})}):null]}),s.jsx(gd,{})]}),Un?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":wr,"data-auto-hidden":cn?"true":void 0,role:"separator","aria-label":l("shell.rightResizerLabel"),onMouseDown:wr?void 0:b=>_a("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":wr,"data-auto-hidden":cn?"true":void 0,"data-custom-panel":_n==="butler","data-parallel-transition":Ks?"true":void 0,"aria-hidden":wr&&!Ks,style:Wr(rr),children:cn&&!Ks?null:_n==="butler"?s.jsx("div",{className:"workbench-auxiliary-custom-panel",children:_t}):s.jsx(Df,{panelReady:qe,activeTab:Ht,fileRevealRequest:cr,onTabChange:b=>{Br(),Ye(b)},onToggleCollapse:()=>ge(!0),currentSessionId:Ct?null:Je,activeWorkspaceId:nr,navigationGroups:J,workspaceContext:rr,worktreeMeta:Jr,worktreeMergeState:Ea,onRefreshWorktreeMergePreview:Qn,onApplyWorktreeMerge:w,onCleanupWorktree:Pe})})]}):null]})}),s.jsx(hA,{open:pr,notifications:bn,archivedNotificationIds:Rr,showArchivedNotifications:ds,onClose:()=>zn(!1),onToggleShowArchivedNotifications:Gr,onArchiveNotification:b=>{fs(b,!0)},onUnarchiveNotification:b=>{fs(b,!1)},onSelectNotification:gl,preferredWorkspaceId:We,preferredSessionId:Ct?null:Je}),s.jsx(MA,{open:xe,mode:ht,keyword:ft,codeWorkspaceId:et,codeResults:us,codeLoading:Ut,codeError:Ur,workspaceOptions:Sl,sessionResults:Cl,onClose:Bi,onModeChange:b=>{Bt(b),kt(null),gn([])},onKeywordChange:b=>{Ot(b),ht==="code"&&!b.trim()&&(gn([]),kt(null))},onCodeWorkspaceChange:b=>ct(b),onCodeSearch:()=>{La()},onOpenSession:b=>{Bi();const v=Nt.find(P=>P.session.sessionId===b)??null;n(v?ir(v.workspace.id,b):xn())}}),s.jsxs(St,{open:yt!==null,title:l("shell.worktreeCleanupModalTitle"),description:l("shell.worktreeCleanupModalDescription"),onClose:()=>{var b;yt&&((b=Vt[yt.workspaceId])!=null&&b.cleaning)||(dr(!1),Mr(null))},children:[s.jsx("p",{className:"workbench-section-empty",children:yt?l("shell.worktreeCleanupConfirm",{name:yt.displayName||yt.branchName}):""}),yt?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=Vt[yt.workspaceId])!=null&&W.cleaning)||((ie=(te=Vt[yt.workspaceId])==null?void 0:te.preview)==null?void 0:ie.alreadyMerged)!==!0,onChange:b=>dr(b.target.checked)}),s.jsx("span",{children:l("shell.worktreeCleanupDeleteBranchLabel",{branch:yt.branchName})})]}),((me=(Fe=Vt[yt.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:!!(yt&&((it=Vt[yt.workspaceId])!=null&&it.cleaning)),onClick:()=>{dr(!1),Mr(null)},children:l("common.cancel")}),s.jsx("button",{type:"button",className:ur&&yt&&((It=(At=Vt[yt.workspaceId])==null?void 0:At.preview)==null?void 0:It.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!yt||!!(yt&&((Yt=Vt[yt.workspaceId])!=null&&Yt.cleaning)),onClick:()=>{yt&&U(yt)},children:yt&&((qn=Vt[yt.workspaceId])!=null&&qn.cleaning)?l("shell.worktreeCleanupRunning"):ur&&yt&&((Qr=(Gn=Vt[yt.workspaceId])==null?void 0:Gn.preview)==null?void 0:Qr.alreadyMerged)===!0?l("shell.worktreeCleanupDeleteBranchAction"):l("shell.worktreeCleanupAction")})]})]}),Ft?s.jsxs(s.Fragment,{children:[wl?null:s.jsx(Bf,{isOpen:dt,side:"left",onClose:()=>De(!1),children:Oi}),vl?null:s.jsx(Bf,{isOpen:bt,side:"right",onClose:()=>Ze(!1),children:Fa})]}):null]})}function Bf({isOpen:e,side:t,onClose:n,children:r,className:i,overlayClassName:a}){if(!e)return null;const o=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:["mobile-nav-overlay","open",a].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"?o:Fr.createPortal(o,document.body)}function Lk(){return f.useContext(sk)??{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 _k(e){return e.startsWith("draft-")}export{n2 as $,nR as A,ER as B,ld as C,mI as D,gI as E,rx as F,xL as G,tx as H,cR as I,fI as J,pR as K,dx as L,SL as M,Ns as N,Ni as O,ai as P,mo as Q,ta as R,WR as S,zR as T,FR as U,Io as V,Kx as W,$R as X,HR as Y,OR as Z,ZL as _,k2 as a,JL as a$,YL as a0,XL as a1,e2 as a2,KL as a3,s2 as a4,u2 as a5,d2 as a6,un as a7,Vy as a8,Tb as a9,dw as aA,hw as aB,jL as aC,id as aD,WE as aE,FE as aF,c2 as aG,CL as aH,ju as aI,QR as aJ,xn as aK,vL as aL,ax as aM,r2 as aN,Vx as aO,NL as aP,TL as aQ,IL as aR,LL as aS,_L as aT,AL as aU,RL as aV,EL as aW,GL as aX,ML as aY,$L as aZ,gT as a_,os as aa,p2 as ab,m2 as ac,h2 as ad,f2 as ae,CI as af,g2 as ag,vp as ah,pa as ai,Mb as aj,o2 as ak,ux as al,sx as am,Jo as an,YR as ao,ex as ap,ox as aq,kL as ar,bL as as,wL as at,ix as au,Wr as av,Cd as aw,yL as ax,l2 as ay,uw as az,Ao as b,QL as b0,qL as b1,OL as b2,WL as b3,FL as b4,zL as b5,HL as b6,UL as b7,bR as b8,PL as b9,uL as bA,oL as bB,dL as bC,lL as bD,mL as bE,gL as bF,fL as bG,pL as bH,nL as bI,QA as bJ,V1 as bK,aT as bL,dm as bM,DL as ba,BL as bb,VL as bc,t2 as bd,GT as be,nI as bf,i2 as bg,Xp as bh,dR as bi,mR as bj,au as bk,rL as bl,Zu as bm,aL as bn,iL as bo,ZA as bp,Yy as bq,eL as br,tL as bs,JA as bt,Qy as bu,XA as bv,sL as bw,cL as bx,hL as by,Xy as bz,ir as c,DR as d,IR as e,b2 as f,OE as g,dT as h,a2 as i,hT as j,qg as k,mT as l,Wp as m,xi as n,js as o,hm as p,Ms as q,Nm as r,mm as s,Ir as t,Lk as u,rR as v,ra as w,iR as x,pm as y,fm as z};
|