@jingyi0605/codingns 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codingns.mjs +425 -1
- package/dist/public/assets/AdaptiveButlerPage-B153lk5H.css +1 -0
- package/dist/public/assets/AdaptiveButlerPage-R-XZw7pd.js +3 -0
- package/dist/public/assets/App-DUAg5urj.css +1 -0
- package/dist/public/assets/App-DkvE5EyM.js +30 -0
- package/dist/public/assets/BootstrapPage-Vu5oEJ8z.js +1 -0
- package/dist/public/assets/ConversationPage-Cjpg6g0J.js +2 -0
- package/dist/public/assets/DesktopDetachPreviewPage-BgeEqbc5.js +1 -0
- package/dist/public/assets/DesktopWindowPage-1WelvxdH.js +2 -0
- package/dist/public/assets/FileContextPanel-D_ghXJuW.js +1 -0
- package/dist/public/assets/GitSidebar-D9f9Jxwr.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DLq5qPkx.js +1 -0
- package/dist/public/assets/MobileSheet-DLg-gX1t.js +1 -0
- package/dist/public/assets/MobileTopHeaderFrame-DArgZI7L.js +1 -0
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-0ywJKfBQ.js +1 -0
- package/dist/public/assets/ServerSettingsModal-izoYMx9U.js +1 -0
- package/dist/public/assets/SessionIndexPage-C5aG8FIv.js +1 -0
- package/dist/public/assets/SettingsPage-HJIC-P-4.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-DpyUTo9k.js +1 -0
- package/dist/public/assets/{TerminalPage-6jHZV9Mh.js → TerminalPage-CtKXIU0h.js} +19 -19
- package/dist/public/assets/TerminalRuntimeFallbackModal-CRhOQOsT.js +1 -0
- package/dist/public/assets/ToolFilesPage-DcYPsS-e.js +1 -0
- package/dist/public/assets/ToolGitPage-CsPl89ty.js +1 -0
- package/dist/public/assets/ToolProcessesPage-D0dvR8xK.js +1 -0
- package/dist/public/assets/ToolsHomePage-4fP-KRiv.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-kvlfyxRo.js +1 -0
- package/dist/public/assets/WorkbenchLayout-ByFw4eeu.js +3 -0
- package/dist/public/assets/WorkbenchModal-Ctob14VR.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BUITtdAg.css +1 -0
- package/dist/public/assets/WorkbenchShellRoute-Kw7JEZI3.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-Com5kEXJ.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-D0Lrx4Uz.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-wR8d3aP9.js +1 -0
- package/dist/public/assets/butler-records-events-DgWCG364.js +1 -0
- package/dist/public/assets/default-session-permission-mode-CcGwR4Kk.js +1 -0
- package/dist/public/assets/event-DvH9tcej.js +1 -0
- package/dist/public/assets/file-tree-icon-UFVoVzhM.js +31 -0
- package/dist/public/assets/index-Byp9hJ0c.js +42 -0
- package/dist/public/assets/index-_52jxu4a.css +1 -0
- package/dist/public/assets/preferences-service-KIYeE2gk.js +1 -0
- package/dist/public/assets/session-runtime-machine-0KNSSPp5.js +17 -0
- package/dist/public/assets/styles-BWPBZvze.css +1 -0
- package/dist/public/assets/styles-CSUx5LGe.js +1 -0
- package/dist/public/assets/terminal-runtime-meta-AWXJpN4r.js +1 -0
- package/dist/public/assets/useRegisteredDebugTemplates-DBDRdptr.js +1 -0
- package/dist/public/assets/window-BWqRixxq.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/middlewares/auth-guard.d.ts +4 -0
- package/dist/server/middlewares/auth-guard.js +42 -4
- package/dist/server/middlewares/auth-guard.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +62 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +58 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +66 -3
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +173 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/auth/auth-controller.d.ts +11 -1
- package/dist/server/modules/auth/auth-controller.js +61 -2
- package/dist/server/modules/auth/auth-controller.js.map +1 -1
- package/dist/server/modules/auth/auth-device-display-name.d.ts +10 -0
- package/dist/server/modules/auth/auth-device-display-name.js +190 -0
- package/dist/server/modules/auth/auth-device-display-name.js.map +1 -0
- package/dist/server/modules/auth/auth-service.d.ts +80 -5
- package/dist/server/modules/auth/auth-service.js +333 -23
- package/dist/server/modules/auth/auth-service.js.map +1 -1
- package/dist/server/modules/butler/assistant-automation-service.d.ts +2 -0
- package/dist/server/modules/butler/assistant-automation-service.js +46 -0
- package/dist/server/modules/butler/assistant-automation-service.js.map +1 -1
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.d.ts +32 -0
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js +93 -0
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js.map +1 -0
- package/dist/server/modules/butler/assistant-sandbox-service.d.ts +16 -2
- package/dist/server/modules/butler/assistant-sandbox-service.js +137 -4
- package/dist/server/modules/butler/assistant-sandbox-service.js.map +1 -1
- package/dist/server/modules/butler/butler-auth-service.js +7 -2
- package/dist/server/modules/butler/butler-auth-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +4 -1
- package/dist/server/modules/butler/butler-control-session-service.js +20 -1
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-evaluation-instruction-adapter.d.ts +2 -1
- package/dist/server/modules/butler/butler-follow-up-evaluation-instruction-adapter.js +27 -25
- package/dist/server/modules/butler/butler-follow-up-evaluation-instruction-adapter.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-service.d.ts +32 -4
- package/dist/server/modules/butler/butler-follow-up-service.js +436 -331
- package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
- package/dist/server/modules/butler/butler-inbox-analysis-service.d.ts +1 -1
- package/dist/server/modules/butler/butler-inbox-analysis-service.js.map +1 -1
- package/dist/server/modules/butler/butler-inbox-service.js +1 -0
- package/dist/server/modules/butler/butler-inbox-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-service.d.ts +3 -1
- package/dist/server/modules/butler/butler-session-service.js +15 -1
- package/dist/server/modules/butler/butler-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-workspace-context.d.ts +1 -1
- package/dist/server/modules/butler/butler-workspace-context.js +54 -28
- package/dist/server/modules/butler/butler-workspace-context.js.map +1 -1
- package/dist/server/modules/provider/provider-controller.d.ts +1 -1
- package/dist/server/modules/provider/provider-controller.js.map +1 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-identity-service.d.ts +10 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-identity-service.js +48 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-identity-service.js.map +1 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.d.ts +48 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.js +11 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.js.map +1 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.d.ts +74 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js +302 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-controller.d.ts +33 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-controller.js +57 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-controller.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-edge-proof.d.ts +9 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-edge-proof.js +25 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-edge-proof.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.d.ts +18 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js +230 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.d.ts +41 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +443 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +111 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +771 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +2 -1
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +78 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +84 -2
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/provider-session-delete-cli.d.ts +15 -0
- package/dist/server/modules/sessions/provider-session-delete-cli.js +148 -0
- package/dist/server/modules/sessions/provider-session-delete-cli.js.map +1 -0
- package/dist/server/modules/sessions/session-controller.d.ts +4 -1
- package/dist/server/modules/sessions/session-controller.js +4 -0
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +17 -0
- package/dist/server/modules/sessions/session-history-service.js +150 -1
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-router-service.d.ts +25 -0
- package/dist/server/modules/sessions/session-live-runtime-router-service.js +42 -0
- package/dist/server/modules/sessions/session-live-runtime-router-service.js.map +1 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +34 -18
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-message-attachment-service.d.ts +1 -0
- package/dist/server/modules/sessions/session-message-attachment-service.js +22 -0
- package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -1
- package/dist/server/modules/sessions/session-permission-request-service.d.ts +1 -0
- package/dist/server/modules/sessions/session-permission-request-service.js +200 -5
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-error-mapper.js +32 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-usage-guard-service.d.ts +37 -0
- package/dist/server/modules/sessions/session-provider-usage-guard-service.js +179 -0
- package/dist/server/modules/sessions/session-provider-usage-guard-service.js.map +1 -0
- package/dist/server/modules/sessions/session-provider-usage-limit.d.ts +17 -0
- package/dist/server/modules/sessions/session-provider-usage-limit.js +465 -0
- package/dist/server/modules/sessions/session-provider-usage-limit.js.map +1 -0
- package/dist/server/modules/skills/assistant-runtime-skill-catalog.d.ts +8 -0
- package/dist/server/modules/skills/assistant-runtime-skill-catalog.js +26 -0
- package/dist/server/modules/skills/assistant-runtime-skill-catalog.js.map +1 -0
- package/dist/server/modules/skills/assistant-runtime-skill-cleanup.d.ts +9 -0
- package/dist/server/modules/skills/assistant-runtime-skill-cleanup.js +55 -0
- package/dist/server/modules/skills/assistant-runtime-skill-cleanup.js.map +1 -0
- package/dist/server/modules/skills/builtin-skill-service.js +1 -6
- package/dist/server/modules/skills/builtin-skill-service.js.map +1 -1
- package/dist/server/modules/skills/skill-controller.d.ts +2 -2
- package/dist/server/modules/skills/skill-controller.js +9 -1
- package/dist/server/modules/skills/skill-controller.js.map +1 -1
- package/dist/server/modules/skills/skill-manager-service.d.ts +26 -1
- package/dist/server/modules/skills/skill-manager-service.js +346 -90
- package/dist/server/modules/skills/skill-manager-service.js.map +1 -1
- package/dist/server/modules/skills/skill-name-policy.d.ts +2 -0
- package/dist/server/modules/skills/skill-name-policy.js +10 -0
- package/dist/server/modules/skills/skill-name-policy.js.map +1 -0
- package/dist/server/modules/tailscale/tailscale-service.d.ts +2 -0
- package/dist/server/modules/tailscale/tailscale-service.js +21 -8
- package/dist/server/modules/tailscale/tailscale-service.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +3 -0
- package/dist/server/modules/tasks/task-types.js +3 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/template-reverse-proxy-service.js +71 -3
- package/dist/server/modules/terminal/template-reverse-proxy-service.js.map +1 -1
- package/dist/server/routes/assistant.js +30 -0
- package/dist/server/routes/assistant.js.map +1 -1
- package/dist/server/routes/auth.js +4 -0
- package/dist/server/routes/auth.js.map +1 -1
- package/dist/server/routes/sessions.js +1 -0
- package/dist/server/routes/sessions.js.map +1 -1
- package/dist/server/routes/system.d.ts +2 -1
- package/dist/server/routes/system.js +13 -1
- package/dist/server/routes/system.js.map +1 -1
- package/dist/server/server/create-server.d.ts +10 -0
- package/dist/server/server/create-server.js +82 -12
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/utils/tokens.d.ts +3 -1
- package/dist/server/shared/utils/tokens.js +9 -2
- package/dist/server/shared/utils/tokens.js.map +1 -1
- package/dist/server/storage/repositories/assistant-automation-task-repository.d.ts +2 -0
- package/dist/server/storage/repositories/assistant-automation-task-repository.js +8 -2
- package/dist/server/storage/repositories/assistant-automation-task-repository.js.map +1 -1
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.d.ts +1 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js +27 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js.map +1 -1
- package/dist/server/storage/repositories/auth-device-repository.d.ts +22 -0
- package/dist/server/storage/repositories/auth-device-repository.js +97 -0
- package/dist/server/storage/repositories/auth-device-repository.js.map +1 -0
- package/dist/server/storage/repositories/auth-device-session-repository.d.ts +17 -0
- package/dist/server/storage/repositories/auth-device-session-repository.js +82 -0
- package/dist/server/storage/repositories/auth-device-session-repository.js.map +1 -0
- package/dist/server/storage/repositories/auth-login-event-repository.d.ts +9 -0
- package/dist/server/storage/repositories/auth-login-event-repository.js +53 -0
- package/dist/server/storage/repositories/auth-login-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/auth-token-repository.d.ts +4 -0
- package/dist/server/storage/repositories/auth-token-repository.js +58 -5
- package/dist/server/storage/repositories/auth-token-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-follow-up-task-repository.js +21 -3
- package/dist/server/storage/repositories/butler-follow-up-task-repository.js.map +1 -1
- package/dist/server/storage/repositories/instance-relay-tunnel-identity-repository.d.ts +8 -0
- package/dist/server/storage/repositories/instance-relay-tunnel-identity-repository.js +52 -0
- package/dist/server/storage/repositories/instance-relay-tunnel-identity-repository.js.map +1 -0
- package/dist/server/storage/repositories/instance-relay-tunnel-repository.d.ts +10 -0
- package/dist/server/storage/repositories/instance-relay-tunnel-repository.js +153 -0
- package/dist/server/storage/repositories/instance-relay-tunnel-repository.js.map +1 -0
- package/dist/server/storage/repositories/instance-tailscale-repository.js +6 -3
- package/dist/server/storage/repositories/instance-tailscale-repository.js.map +1 -1
- package/dist/server/storage/repositories/managed-skill-repository.d.ts +2 -1
- package/dist/server/storage/repositories/managed-skill-repository.js +14 -4
- package/dist/server/storage/repositories/managed-skill-repository.js.map +1 -1
- package/dist/server/storage/repositories/session-message-attachment-repository.d.ts +2 -0
- package/dist/server/storage/repositories/session-message-attachment-repository.js +24 -0
- package/dist/server/storage/repositories/session-message-attachment-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.js +297 -2
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +122 -4
- package/dist/server/types/domain.d.ts +82 -1
- package/dist/server/ws/workbench-ws-hub.js +99 -75
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/dist/server/ws/ws-auth-guard.js +1 -4
- package/dist/server/ws/ws-auth-guard.js.map +1 -1
- package/dist/server/ws/ws-server.d.ts +1 -1
- package/dist/server/ws/ws-server.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js +80 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +11 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +132 -21
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.d.ts +2 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +53 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js +10 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +30 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +5 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +145 -58
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/services.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js +7 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/scripts/postinstall.mjs +0 -33
- package/dist/public/assets/index-CSVhg7I8.js +0 -123
- package/dist/public/assets/index-Ce1VX19m.css +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-D_ghXJuW.js","assets/index-Byp9hJ0c.js","assets/index-_52jxu4a.css","assets/App-DkvE5EyM.js","assets/App-DUAg5urj.css","assets/MobileSheet-DLg-gX1t.js","assets/WorkbenchModal-Ctob14VR.js","assets/file-tree-icon-UFVoVzhM.js","assets/window-BWqRixxq.js","assets/event-DvH9tcej.js","assets/GitSidebar-D9f9Jxwr.js","assets/default-session-permission-mode-CcGwR4Kk.js","assets/TerminalManagerPanel-DpyUTo9k.js","assets/terminal-runtime-meta-AWXJpN4r.js","assets/TerminalRuntimeFallbackModal-CRhOQOsT.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var zl=Object.defineProperty;var Kl=(e,n,s)=>n in e?zl(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var Ee=(e,n,s)=>Kl(e,typeof n!="symbol"?n+"":n,s);import{z as Z,t as r,b as l,j as t,e as en,m as Js,D as Ci,B as Vl,E as Xl,F as Yl,v as Ii,A as Ti,h as Yr,G as Jl,H as Zl,J as Mi,k as Ri,K as Co,f as Bo,i as Ei,l as Wi,x as Ql,n as ec,y as tc,_ as Do}from"./index-Byp9hJ0c.js";import{m as ye,d as Cn,g as Jr,u as Qs,e as Vn,f as Zr,h as nc,i as sc,O as la}from"./App-DkvE5EyM.js";import{e as _o,Z as Pi,_ as rc,M as oc,i as ac,j as ic,$ as lc,a0 as cc,u as Mr,g as dc,a1 as uc,a2 as hc,a3 as fc,a4 as Ai,a5 as pc,a6 as Li,a7 as mc,a8 as bc,a9 as Bi,F as gc,a as kc,m as wc,S as xc,l as Di,N as yc,r as vc,aa as Sc}from"./MobileSheet-DLg-gX1t.js";import{t as gs,P as Kr,g as _i}from"./window-BWqRixxq.js";import{R as jc,_ as ca,a as da,C as Fi,i as le}from"./event-DvH9tcej.js";import{W as Fe}from"./WorkbenchModal-Ctob14VR.js";const qs=new Map;function Oi(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function ua(e,n){return!Number.isFinite(e)||Date.now()-e>n}function Vr(e,n){const s=qs.get(e);if(s&&!ua(s.savedAt,n))return s.value;if(!Oi())return null;const o=window.sessionStorage.getItem(e);if(!o)return null;try{const a=JSON.parse(o);return!a||ua(a.savedAt,n)?(window.sessionStorage.removeItem(e),qs.delete(e),null):(qs.set(e,a),a.value)}catch{return window.sessionStorage.removeItem(e),qs.delete(e),null}}function Xs(e,n){const s={savedAt:Date.now(),value:n};if(qs.set(e,s),!!Oi())try{window.sessionStorage.setItem(e,JSON.stringify(s))}catch{}}const Nc="codingns.debug.perf";function Cc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Nc)==="1"}catch{return!1}}function pt(e,n){if(!Cc()||typeof performance>"u")return;const s=Math.round(performance.now());if(n&&Object.keys(n).length>0){console.info(`[perf-ui] ${e} ${s}ms`,n);return}console.info(`[perf-ui] ${e} ${s}ms`)}function Uf(e,n,s,o){return Z.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:n,content:s,expectedVersion:o??void 0})})}function $f(e){return Z.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function qf(e){return Z.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function Gf(e,n){const s=new URLSearchParams({workspaceId:e,path:n});return Z.request(`/api/files/download?${s.toString()}`)}function Ic(e,n,s=1,o=20){const a=new URLSearchParams({workspaceId:e,keyword:n,page:String(s),pageSize:String(o)});return Z.request(`/api/files/search?${a.toString()}`)}function zf(e,n){const s=new URLSearchParams({workspaceId:e,path:n});return Z.request(`/api/files/preview?${s.toString()}`)}function Kf(e){return Z.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function Vf(e,n,s){const o=new URLSearchParams({workspaceId:e,path:n,staged:String(s)});return Z.request(`/api/git/diff?${o.toString()}`)}function Xf(e,n){return Z.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:n})})}function Yf(e,n){return Z.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:n})})}function Jf(e,n){return Z.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:n})})}function Zf(e,n){return Z.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:n})})}function Qf(e,n){return Z.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:n})})}function ep(e){return Z.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function tp(e,n=5,s=null){const o=new URLSearchParams({workspaceId:e,limit:String(n)});return s&&o.set("cursor",s),Z.request(`/api/git/history?${o.toString()}`)}function np(e,n){const s=new URLSearchParams({workspaceId:e,commitHash:n});return Z.request(`/api/git/commit-detail?${s.toString()}`)}function Tc(e){return Z.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Mc(e){return Z.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function sp(e,n,s){return Z.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:n,create:s})})}function rp(e,n,s,o,a){return Z.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:n,...s?{remote:s}:{},...o?{auth:o}:{},...a?{remember:a}:{}})})}function op(e){return Z.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var qr,Gr;function Hi(e){var n;if("items"in e)e.items=(n=e.items)===null||n===void 0?void 0:n.map(s=>"rid"in s?s:Hi(s));else if("action"in e&&e.action){const s=new Fi;return s.onmessage=e.action,delete e.action,{...e,handler:s}}return e}async function ys(e,n){const s=new Fi;if(n&&typeof n=="object"&&("action"in n&&n.action&&(s.onmessage=n.action,delete n.action),"item"in n&&n.item&&typeof n.item=="object"&&"About"in n.item&&n.item.About&&typeof n.item.About=="object"&&"icon"in n.item.About&&n.item.About.icon&&(n.item.About.icon=gs(n.item.About.icon)),"icon"in n&&n.icon&&(n.icon=gs(n.icon)),"items"in n&&n.items)){let o=function(a){var c;return"rid"in a?[a.rid,a.kind]:("item"in a&&typeof a.item=="object"&&(!((c=a.item.About)===null||c===void 0)&&c.icon)&&(a.item.About.icon=gs(a.item.About.icon)),"icon"in a&&a.icon&&(a.icon=gs(a.icon)),"items"in a&&a.items&&(a.items=a.items.map(o)),Hi(a))};n.items=n.items.map(o)}return le("plugin:menu|new",{kind:e,options:n,handler:s})}class vs extends jc{get id(){return ca(this,qr,"f")}get kind(){return ca(this,Gr,"f")}constructor(n,s,o){super(n),qr.set(this,void 0),Gr.set(this,void 0),da(this,qr,s),da(this,Gr,o)}}qr=new WeakMap,Gr=new WeakMap;class Fo extends vs{constructor(n,s){super(n,s,"MenuItem")}static async new(n){return ys("MenuItem",n).then(([s,o])=>new Fo(s,o))}async text(){return le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async setAccelerator(n){return le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:n})}}class Oo extends vs{constructor(n,s){super(n,s,"Check")}static async new(n){return ys("Check",n).then(([s,o])=>new Oo(s,o))}async text(){return le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async setAccelerator(n){return le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:n})}async isChecked(){return le("plugin:menu|is_checked",{rid:this.rid})}async setChecked(n){return le("plugin:menu|set_checked",{rid:this.rid,checked:n})}}var ha;(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"})(ha||(ha={}));class Ho extends vs{constructor(n,s){super(n,s,"Icon")}static async new(n){return ys("Icon",n).then(([s,o])=>new Ho(s,o))}async text(){return le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async setAccelerator(n){return le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:n})}async setIcon(n){return le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:gs(n)})}}class Uo extends vs{constructor(n,s){super(n,s,"Predefined")}static async new(n){return ys("Predefined",n).then(([s,o])=>new Uo(s,o))}async text(){return le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}}function xs([e,n,s]){switch(s){case"Submenu":return new $o(e,n);case"Predefined":return new Uo(e,n);case"Check":return new Oo(e,n);case"Icon":return new Ho(e,n);case"MenuItem":default:return new Fo(e,n)}}class $o extends vs{constructor(n,s){super(n,s,"Submenu")}static async new(n){return ys("Submenu",n).then(([s,o])=>new $o(s,o))}async text(){return le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async append(n){return le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(n){return le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(n,s){return le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(o=>"rid"in o?[o.rid,o.kind]:o),position:s})}async remove(n){return le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[n.rid,n.kind]})}async removeAt(n){return le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:n}).then(xs)}async items(){return le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(n=>n.map(xs))}async get(n){return le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:n}).then(s=>s?xs(s):null)}async popup(n,s){var o;return le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(o=s==null?void 0:s.label)!==null&&o!==void 0?o:null,at:n instanceof Kr?n:n?new Kr(n):null})}async setAsWindowsMenuForNSApp(){return le("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return le("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(n){return le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:gs(n)})}}class ks extends vs{constructor(n,s){super(n,s,"Menu")}static async new(n){return ys("Menu",n).then(([s,o])=>new ks(s,o))}static async default(){return le("plugin:menu|create_default").then(([n,s])=>new ks(n,s))}async append(n){return le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(n){return le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(n,s){return le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(o=>"rid"in o?[o.rid,o.kind]:o),position:s})}async remove(n){return le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[n.rid,n.kind]})}async removeAt(n){return le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:n}).then(xs)}async items(){return le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(n=>n.map(xs))}async get(n){return le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:n}).then(s=>s?xs(s):null)}async popup(n,s){var o;return le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(o=s==null?void 0:s.label)!==null&&o!==void 0?o:null,at:n instanceof Kr?n:n?new Kr(n):null})}async setAsAppMenu(){return le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(n=>n?new ks(n[0],n[1]):null)}async setAsWindowMenu(n){var s;return le("plugin:menu|set_as_window_menu",{rid:this.rid,window:(s=n==null?void 0:n.label)!==null&&s!==void 0?s:null}).then(o=>o?new ks(o[0],o[1]):null)}}async function Rc(e){if(e.length===0)return;await(await ks.new({items:e.map(s=>({id:s.id,text:s.label,enabled:!s.disabled,accelerator:s.accelerator,action:()=>{s.onSelect()}}))})).popup(void 0,_i())}function Ui(e,n){const s=new Map(e.map(c=>[n.getId(c),c])),o=new Map,a=[];for(const c of e){const h=Ec(c,s,n);if(!h){a.push(c);continue}const f=o.get(h)??[];o.set(h,[...f,c])}return[...a].sort(n.compare).map(c=>Gi(c,0,o,n,new Set))}function Ss(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function $i(e){return e.flatMap(n=>[n.item,...$i(Ss(n))])}function vn(e){return e.flatMap(n=>[n,...vn(Ss(n))])}function qo(e,n){return e.some(s=>n(s.item)||qo(Ss(s),n))}function qi(e,n,s){return e?s(e.item)===n?!0:Ss(e).some(o=>qi(o,n,s)):!1}function bs(e,n,s){for(const o of e){const a=s(o.item);if(a===n)return[];const c=bs(Ss(o),n,s);if(qi(o,n,s)&&c.length>=0)return[a,...c]}return[]}function Gi(e,n,s,o,a){const c=o.getId(e),h=new Set(a);h.add(c);const f=[...s.get(c)??[]].filter(b=>!h.has(o.getId(b))).sort(o.compare).map(b=>Gi(b,n+1,s,o,h));return{item:e,depth:n,children:f}}function Ec(e,n,s){const o=fa(s.getParentId(e));if(!o)return null;const a=n.get(o);if(!a)return null;const c=new Set([s.getId(e)]);let h=a;for(;h;){const f=s.getId(h);if(c.has(f))return null;c.add(f);const b=fa(s.getParentId(h));if(!b||(h=n.get(b),!h))return o}return o}function fa(e){const n=e==null?void 0:e.trim();return n||null}function st(){return"/workspaces"}function Ut(e){return`/workspaces/${encodeURIComponent(e)}`}function zi(e){return`${Ut(e)}/debug`}function Zs(e){return`${Ut(e)}/sessions`}function Ot(e,n){return`${Zs(e)}/${encodeURIComponent(n)}`}function Ki(e,n){const s=`${Ut(e)}/tools`;if(!n)return s;const o=new URLSearchParams({tab:n});return`${s}?${o.toString()}`}function Vi(e){return`${Ut(e)}/tools/files`}function Xi(e){return`${Ut(e)}/tools/git`}function Yi(e){return`${Ut(e)}/tools/processes`}function ws(e){return`${Ut(e)}/terminals`}function Kn(e,n){const s=`${Ut(e)}/butler`;if(!n)return s;const o=new URLSearchParams({tab:n});return`${s}?${o.toString()}`}function Wc(e){return e.flatMap(n=>[...n.sessions.map(s=>({session:s,workspace:n.workspace})),...Zi(n.childWorktrees??[])]).sort((n,s)=>(s.session.lastMessageAt??s.session.updatedAt).localeCompare(n.session.lastMessageAt??n.session.updatedAt))}function ap(e){return Ui(e,{getId:n=>n.session.sessionId,getParentId:n=>{var s;return((s=n.session.parentSessionId)==null?void 0:s.trim())||null},compare:Ac})}function Ji(e,n){const s=Pc(),o=new URLSearchParams({provider:n});return`${Ot(e,s)}?${o.toString()}`}function Pc(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ac(e,n){return(n.session.lastMessageAt??n.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Zi(e){return e.flatMap(n=>[...n.sessions.map(s=>({session:s,workspace:n.workspace})),...Zi(n.children)])}const Lc="mobile.tools.last-primary-tool";function Qi(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Lc)==="git"?"git":"files"}catch{return"files"}}function Go(e){var o;const n=[{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 a of n){const c=ye(a.pattern,e),h=((o=c==null?void 0:c.params.workspaceId)==null?void 0:o.trim())??null;if(h)return{workspaceId:h,routeKind:a.routeKind,legacy:!1}}const s=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const a of s)if(ye(a.pattern,e))return{workspaceId:null,routeKind:a.routeKind,legacy:!0};return null}function Bc(e,n){const s=Go(e);if((s==null?void 0:s.routeKind)==="git")return"git";if((s==null?void 0:s.routeKind)==="files")return"files";const o=new URLSearchParams(n).get("tab");return o==="git"?"git":o==="files"?"files":Qi()}function zo(e,n){const s=Go(e);return(s==null?void 0:s.routeKind)==="processes"&&s.workspaceId?ws(s.workspaceId):s!=null&&s.workspaceId?Ki(s.workspaceId,Bc(e,n)):s!=null&&s.legacy?Qi()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Ko({activeEntry:e,presentation:n,pathname:s,search:o,moreButtonLabel:a}){if(n==="conversation-focus"||e!=="butler")return null;const c=Go(s);return c?c.routeKind==="processes"?{title:r("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:a}:(c.routeKind==="home"||c.routeKind==="files"||c.routeKind==="git",null):null}const el=l.createContext({composerPortalTarget:null});function Vo({composerPortalTarget:e,children:n}){return t.jsx(el.Provider,{value:{composerPortalTarget:e},children:n})}function ip(){return l.useContext(el)}function Xo(e,n,s){const[o,a]=l.useState(void 0);return l.useEffect(()=>{const c=e.current,h=n.current;if(!s||!c||!h){a(void 0),c&&c.style.removeProperty("--mobile-conversation-tabbar-height");return}const f=c,b=h;function m(){if(!e.current||!b.isConnected)return;const N=`${Math.round(b.getBoundingClientRect().height)}px`;f.style.setProperty("--mobile-conversation-tabbar-height",N),a(N)}m();const I=typeof ResizeObserver<"u"?new ResizeObserver(m):null;return I==null||I.observe(b),window.addEventListener("resize",m),()=>{I==null||I.disconnect(),window.removeEventListener("resize",m),f.style.removeProperty("--mobile-conversation-tabbar-height")}},[s,e,n]),o}const Dc=3e3,Rr=10,pa=84,ma=.36;function Yo({enabled:e,rootRef:n,suspended:s=!1,resetKey:o}){const a=l.useRef(null),c=l.useRef(null),h=l.useRef("visible"),f=l.useRef(1),[b,m]=l.useState("visible"),[I,N]=l.useState(1);l.useEffect(()=>{h.current=b},[b]),l.useEffect(()=>{f.current=I},[I]);function j(){Gn(a),a.current=window.setTimeout(()=>{M()},Dc)}function M(){m("hidden"),N(0)}function F(){m("visible"),N(1),j()}l.useEffect(()=>{if(Gn(a),!e){Gn(a),m("visible"),N(1);return}if(s){m("hidden"),N(0);return}return F(),()=>{Gn(a)}},[e,o,s]),l.useEffect(()=>()=>{Gn(a)},[]),l.useEffect(()=>{if(!e||s){c.current=null;return}const P=n.current;if(!P)return;function w(L){if(L.touches.length!==1){c.current=null;return}const y=L.touches[0],K=ka(L.target);if(!y||!K){c.current=null;return}c.current={surface:K,startX:y.clientX,startY:y.clientY,pointerType:"touch",initialState:h.current==="visible"?"visible":"hidden",touchId:y.identifier,dragging:!1,latestProgress:f.current},h.current==="visible"&&Gn(a)}function O(L){const y=c.current;if(!y||y.pointerType!=="touch")return;const K=mo(L.touches,y.touchId);if(!K)return;const J=K.clientX-y.startX,E=K.clientY-y.startY;if(y.surface==="conversation"){if(Math.abs(E)<=Rr||Math.abs(E)<=Math.abs(J))return;c.current=null,y.initialState==="visible"&&M();return}const ge=y.initialState==="hidden"?-E:E;ge<=Rr&&!y.dragging||(xa(L),y.dragging=!0,y.latestProgress=ba(y.initialState,ge),m("dragging"),N(y.latestProgress))}function U(L){const y=c.current;if(!(!y||y.pointerType!=="touch"||!mo(L.changedTouches,y.touchId))){if(c.current=null,!y.dragging){y.initialState==="visible"&&j();return}ga(y.initialState,y.latestProgress,F,m,N)}}function se(L){const y=c.current;if(!(!y||y.pointerType!=="touch"||!mo(L.changedTouches,y.touchId))){if(c.current=null,!y.dragging){y.initialState==="visible"&&j();return}if(y.initialState==="visible"){F();return}m("hidden"),N(0)}}function X(L){if(L.pointerType!=="touch")return;const y=ka(L.target);if(!y){c.current=null;return}if(c.current={surface:y,startX:L.clientX,startY:L.clientY,pointerType:"pointer",initialState:h.current==="visible"?"visible":"hidden",pointerId:L.pointerId,captureTarget:L.target instanceof Element?L.target:null,dragging:!1,latestProgress:f.current},L.target instanceof Element)try{L.target.setPointerCapture(L.pointerId)}catch{}h.current==="visible"&&Gn(a)}function ee(L){const y=c.current;if(!y||y.pointerType!=="pointer")return;const K=L.clientX-y.startX,J=L.clientY-y.startY;if(y.surface==="conversation"){if(Math.abs(J)<=Rr||Math.abs(J)<=Math.abs(K))return;c.current=null,y.initialState==="visible"&&M();return}const E=y.initialState==="hidden"?-J:J;E<=Rr&&!y.dragging||(xa(L),y.dragging=!0,y.latestProgress=ba(y.initialState,E),m("dragging"),N(y.latestProgress))}function _(L){const y=c.current;if(!(!y||y.pointerType!=="pointer"||y.pointerId!==L.pointerId)){if(c.current=null,_c(y),!y.dragging){y.initialState==="visible"&&j();return}ga(y.initialState,y.latestProgress,F,m,N)}}return P.addEventListener("touchstart",w,{passive:!0}),P.addEventListener("pointerdown",X,{passive:!0}),window.addEventListener("touchmove",O,{passive:!1}),window.addEventListener("touchend",U),window.addEventListener("touchcancel",se),window.addEventListener("pointermove",ee,{passive:!1}),window.addEventListener("pointerup",_),window.addEventListener("pointercancel",_),()=>{P.removeEventListener("touchstart",w),P.removeEventListener("pointerdown",X),window.removeEventListener("touchmove",O),window.removeEventListener("touchend",U),window.removeEventListener("touchcancel",se),window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_)}},[e,n,s]);const H=e&&!s?I:e?0:1;return{state:s&&e?"hidden":b,progress:H,isOpen:H>.01}}function Gn(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function ba(e,n){return wa(e==="hidden"?n/pa:1-n/pa,0,1)}function ga(e,n,s,o,a){if(e==="hidden"){if(n>=ma){s();return}o("hidden"),a(0);return}if(n<=1-ma){o("hidden"),a(0);return}s()}function _c(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 mo(e,n){if(typeof n!="number")return e[0]??null;for(let s=0;s<e.length;s+=1){const o=e[s];if((o==null?void 0:o.identifier)===n)return o}return null}function ka(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 wa(e,n,s){return Math.min(Math.max(e,n),s)}function xa(e){e.cancelable&&e.preventDefault()}function er({viewportClass:e,activeEntry:n,hasNavigationPanel:s,hasAuxiliaryPanel:o,preferCompactLayout:a=!1}){return a||e==="compact"?"compact":e==="expanded"&&s&&o?"expanded":n==="butler"&&o?"medium-auxiliary":s?"medium-navigation":o?"medium-auxiliary":"compact"}function Qr(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function tl(e){return e==="medium-navigation"||e==="expanded"}function nl(e){return e==="medium-auxiliary"||e==="expanded"}function Jo({viewportClass:e,activeEntry:n,hasNavigationPanel:s,hasAuxiliaryPanel:o,preferCompactLayout:a=!1,children:c,navigationPanel:h,auxiliaryPanel:f}){const b=er({viewportClass:e,activeEntry:n,hasNavigationPanel:s,hasAuxiliaryPanel:o,preferCompactLayout:a}),m=tl(b)&&h,I=nl(b)&&f;return t.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":b,children:[m?t.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:h}):null,t.jsx("div",{className:"mobile-adaptive-pane-main",children:c}),I?t.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:f}):null]})}function Fc({activeEntry:e,presentation:n="default",children:s,navigationPanel:o,auxiliaryPanel:a,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:f,onNavigateButler:b,onNavigateToolProcesses:m,onNavigateSettings:I}){const N=Cn(),j=_o(),M=Jr(),F=Qs(),H=l.useRef(null),P=l.useRef(null),[w,O]=l.useState(null),U=n==="conversation-focus",se=Qr({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),X=Yo({enabled:U,rootRef:H,resetKey:`${M.pathname}${M.search}`}),ee=er({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!o,hasAuxiliaryPanel:!!a,preferCompactLayout:se}),_=Ko({activeEntry:e,presentation:n,pathname:M.pathname,search:M.search,moreButtonLabel:r("shell.androidMoreAction")}),L=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:t.jsx(Uc,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:t.jsx($c,{}),onClick:f},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:t.jsx(Gc,{}),onClick:b},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:t.jsx(qc,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:t.jsx(zc,{}),onClick:I}],y=U?{"--mobile-conversation-tabbar-progress":X.progress.toFixed(4)}:void 0;Xo(H,P,U);function K(){const E=zo(M.pathname,M.search);if(!E){h();return}F(E,{replace:!0})}const J=t.jsx("nav",{ref:P,className:"android-workbench-bottom-nav","aria-label":r("shell.title"),children:L.map(E=>t.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":E.key===e,"aria-current":E.key===e?"page":void 0,onClick:()=>{E.key!==e&&j.trigger("selection"),E.onClick()},children:[t.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:E.icon}),t.jsx("span",{className:"android-workbench-bottom-nav-label",children:E.label})]},E.key))});return t.jsx(Vo,{composerPortalTarget:U?w:null,children:t.jsxs("div",{ref:H,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":n,"data-pane-layout":ee,"data-tabbar-open":U?X.isOpen:!0,"data-conversation-tabbar-state":U?X.state:"default",style:y,children:[_?t.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[t.jsxs("div",{className:"android-workbench-topbar-leading",children:[_.showBackButton?t.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":r("common.back"),onClick:K,children:t.jsx(Oc,{})}):null,t.jsx("div",{className:"android-workbench-topbar-copy",children:t.jsx("h1",{children:_.title})})]}),t.jsx("div",{className:"android-workbench-topbar-actions",children:_.showMoreButton?t.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":_.moreButtonLabel,onClick:m,children:t.jsx(Hc,{})}):null})]}):null,t.jsx("div",{className:"android-workbench-content",children:t.jsx(Jo,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!o,hasAuxiliaryPanel:!!a,preferCompactLayout:se,navigationPanel:o,auxiliaryPanel:a,children:s})}),U?t.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[t.jsx("div",{ref:O,className:"mobile-conversation-bottom-layer-composer-slot"}),t.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:J})]}):J]})})}function Oc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"m15 18-6-6 6-6"}),t.jsx("path",{d:"M21 12H9"})]})}function Hc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Uc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.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"}),t.jsx("path",{d:"M8 13h8"})]})}function $c(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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 qc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),t.jsx("path",{d:"m7.5 9 3 3-3 3"}),t.jsx("path",{d:"M12.5 15H17"})]})}function Gc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),t.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),t.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function zc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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 Kc=120,Gs={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Io(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Vc(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 n=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(n)}return!1}function Xc(){var n;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(n=document.documentElement)==null?void 0:n.clientHeight:0].filter(Io);return e.length>0?Math.max(...e):0}function ya(){if(typeof window>"u")return Gs;const e=window.visualViewport,n=Xc(),s=(e==null?void 0:e.height)??n,o=Io(s)?Math.round(s):null,a=Io(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,c=o===null?0:Math.max(0,Math.round(n-o-a));return{viewportHeight:o,keyboardInset:c,keyboardOpen:Vc(typeof document<"u"?document.activeElement:null)&&c>=Kc}}function bo(e,n){if(typeof document>"u")return;[document.documentElement,document.body].filter(o=>o instanceof HTMLElement).forEach(o=>{if(!e){delete o.dataset.mobileKeyboardOpen,delete o.dataset.mobileViewportBound,o.style.removeProperty("--mobile-shell-viewport-height"),o.style.removeProperty("--mobile-shell-keyboard-inset");return}o.dataset.mobileKeyboardOpen=String(n.keyboardOpen),o.dataset.mobileViewportBound="true",n.viewportHeight===null?o.style.removeProperty("--mobile-shell-viewport-height"):o.style.setProperty("--mobile-shell-viewport-height",`${n.viewportHeight}px`),o.style.setProperty("--mobile-shell-keyboard-inset",`${n.keyboardInset}px`)})}function Yc(e){const[n,s]=l.useState(()=>e?ya():Gs),o=l.useRef(null);return l.useEffect(()=>{if(!e){s(Gs),bo(!1,Gs);return}function a(){s(ya())}function c(){o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,a()},0)}a();const h=window.visualViewport;return window.addEventListener("resize",a),window.addEventListener("orientationchange",a),h==null||h.addEventListener("resize",a),h==null||h.addEventListener("scroll",a),document.addEventListener("focusin",a),document.addEventListener("focusout",c),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null),window.removeEventListener("resize",a),window.removeEventListener("orientationchange",a),h==null||h.removeEventListener("resize",a),h==null||h.removeEventListener("scroll",a),document.removeEventListener("focusin",a),document.removeEventListener("focusout",c),bo(!1,Gs)}},[e]),l.useEffect(()=>{bo(e,n)},[e,n]),n}function Jc({activeEntry:e,presentation:n="default",children:s,navigationPanel:o,auxiliaryPanel:a,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:f,onNavigateButler:b,onNavigateToolProcesses:m,onNavigateSettings:I}){const N=Cn(),j=_o(),M=Jr(),F=Qs(),H=l.useRef(null),P=l.useRef(null),[w,O]=l.useState(null),U=n==="conversation-focus",se=Qr({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),X=Yo({enabled:U,rootRef:H,resetKey:`${M.pathname}${M.search}`}),ee=er({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!o,hasAuxiliaryPanel:!!a,preferCompactLayout:se}),_=Ko({activeEntry:e,presentation:n,pathname:M.pathname,search:M.search,moreButtonLabel:r("shell.iosMoreAction")}),L=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:t.jsx(ed,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:t.jsx(td,{}),onClick:f},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:t.jsx(sd,{}),onClick:b},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:t.jsx(nd,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:t.jsx(rd,{}),onClick:I}],y=U?{"--mobile-conversation-tabbar-progress":X.progress.toFixed(4)}:void 0;Xo(H,P,U);function K(){const E=zo(M.pathname,M.search);if(!E){h();return}F(E,{replace:!0})}const J=t.jsx("nav",{ref:P,className:"ios-workbench-tabbar","aria-label":r("shell.title"),children:L.map(E=>t.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":E.key===e,"aria-current":E.key===e?"page":void 0,onClick:()=>{E.key!==e&&j.trigger("selection"),E.onClick()},children:[t.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:E.icon}),t.jsx("span",{className:"ios-workbench-tabbar-label",children:E.label})]},E.key))});return t.jsx(Vo,{composerPortalTarget:U?w:null,children:t.jsxs("div",{ref:H,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":n,"data-pane-layout":ee,"data-tabbar-open":U?X.isOpen:!0,"data-conversation-tabbar-state":U?X.state:"default",style:y,children:[_?t.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[t.jsx("div",{className:"ios-workbench-nav-leading",children:_.showBackButton?t.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":r("common.back"),onClick:K,children:[t.jsx(Zc,{}),t.jsx("span",{children:r("common.back")})]}):null}),t.jsx("div",{className:"ios-workbench-nav-copy",children:t.jsx("h1",{children:_.title})}),t.jsx("div",{className:"ios-workbench-nav-actions",children:_.showMoreButton?t.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":_.moreButtonLabel,onClick:m,children:t.jsx(Qc,{})}):null})]}):null,t.jsx("div",{className:"ios-workbench-content",children:t.jsx(Jo,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!o,hasAuxiliaryPanel:!!a,preferCompactLayout:se,navigationPanel:o,auxiliaryPanel:a,children:s})}),U?t.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[t.jsx("div",{ref:O,className:"mobile-conversation-bottom-layer-composer-slot"}),t.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:J})]}):J]})})}function Zc(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:t.jsx("path",{d:"m15 18-6-6 6-6"})})}function Qc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function ed(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[t.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"}),t.jsx("path",{d:"M8 13h8"})]})}function td(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:t.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 nd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),t.jsx("path",{d:"m7.5 9 3 3-3 3"}),t.jsx("path",{d:"M12.5 15H17"})]})}function sd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[t.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),t.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),t.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function rd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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 od(e){const n=Cn();return n.platform==="ios"?t.jsx(Jc,{...e}):n.platform==="android"?t.jsx(Fc,{...e}):t.jsx(ad,{...e})}function ad({activeEntry:e,presentation:n="default",children:s,navigationPanel:o,auxiliaryPanel:a,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:f,onNavigateButler:b,onNavigateToolProcesses:m,onNavigateSettings:I}){const N=Cn(),j=_o(),M=Jr(),F=Qs(),H=l.useRef(null),P=l.useRef(null),[w,O]=l.useState(null),U=Yc(N.platform==="web"),se=N.platform==="web"&&U.keyboardOpen,X=n==="conversation-focus",ee=Qr({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),_=Yo({enabled:X,rootRef:H,suspended:se,resetKey:`${M.pathname}${M.search}`}),L=er({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!o,hasAuxiliaryPanel:!!a,preferCompactLayout:ee}),y=Ko({activeEntry:e,presentation:n,pathname:M.pathname,search:M.search,moreButtonLabel:r("shell.iosMoreAction")}),K=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:t.jsx(cd,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:t.jsx(dd,{}),onClick:f},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:t.jsx(hd,{}),onClick:b},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:t.jsx(ud,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:t.jsx(fd,{}),onClick:I}],J=X?{"--mobile-conversation-tabbar-progress":_.progress.toFixed(4)}:void 0;Xo(H,P,X);function E(){const $=zo(M.pathname,M.search);if(!$){h();return}F($,{replace:!0})}const ge=t.jsx("nav",{ref:P,className:"mobile-workbench-tabbar","aria-label":r("shell.title"),hidden:se,children:K.map($=>t.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":$.key===e,"aria-current":$.key===e?"page":void 0,onClick:()=>{$.key!==e&&j.trigger("selection"),$.onClick()},children:[t.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:$.icon}),t.jsx("span",{className:"mobile-workbench-tabbar-label",children:$.label})]},$.key))});return t.jsx(Vo,{composerPortalTarget:X?w:null,children:t.jsxs("div",{ref:H,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":n,"data-mobile-runtime":N.platform,"data-mobile-keyboard-open":se,"data-pane-layout":L,"data-tabbar-open":se?!1:X?_.isOpen:!0,"data-conversation-tabbar-state":X?_.state:"default",style:J,children:[y?t.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[t.jsxs("div",{className:"mobile-workbench-header-leading",children:[y.showBackButton?t.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":r("common.back"),onClick:E,children:t.jsx(id,{})}):null,t.jsx("div",{className:"mobile-workbench-header-copy",children:t.jsx("h1",{children:y.title})})]}),t.jsx("div",{className:"mobile-workbench-header-actions",children:y.showMoreButton?t.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":y.moreButtonLabel,onClick:m,children:t.jsx(ld,{})}):null})]}):null,t.jsx("div",{className:"mobile-workbench-content",children:t.jsx(Jo,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!o,hasAuxiliaryPanel:!!a,preferCompactLayout:ee,navigationPanel:o,auxiliaryPanel:a,children:s})}),X?t.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[t.jsx("div",{ref:O,className:"mobile-conversation-bottom-layer-composer-slot"}),t.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ge})]}):ge]})})}function id(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("path",{d:"m15 18-6-6 6-6"}),t.jsx("path",{d:"M21 12H9"})]})}function ld(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function cd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.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"}),t.jsx("path",{d:"M8 13h8"})]})}function dd(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:t.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 ud(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),t.jsx("path",{d:"m7.5 9 3 3-3 3"}),t.jsx("path",{d:"M12.5 15H17"})]})}function hd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),t.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),t.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function fd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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 pd{constructor(n){Ee(this,"maxAttempts");Ee(this,"baseDelayMs");Ee(this,"reconnectAttempts",0);Ee(this,"reconnectTimer",null);Ee(this,"disposed",!1);this.options=n,this.maxAttempts=n.maxAttempts??4,this.baseDelayMs=n.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(!en.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 n=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},n)}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 md{constructor(n){Ee(this,"socket",null);Ee(this,"disposed",!1);Ee(this,"authRecoveryInFlight",!1);Ee(this,"pendingRefresh",!1);Ee(this,"fileTreeSubscription",null);Ee(this,"gitWorkspaceId",null);Ee(this,"terminalManagerWorkspaceId",null);Ee(this,"workspaceManagementWorkspaceId",null);Ee(this,"pendingFileTreeRefresh",null);Ee(this,"pendingGitRefreshWorkspaceId",null);Ee(this,"pendingTerminalManagerRefreshWorkspaceId",null);Ee(this,"pendingWorkspaceManagementRefreshWorkspaceId",null);Ee(this,"fileTreeListeners",new Set);Ee(this,"gitListeners",new Set);Ee(this,"terminalManagerListeners",new Set);Ee(this,"workspaceManagementListeners",new Set);Ee(this,"connectionManager");this.options=n,this.connectionManager=new pd({onReconnect:s=>{this.connect(s)},onStateChange:n.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const n=this.socket;if(!va(n)){this.pendingRefresh=!0;return}n.send(JSON.stringify({type:"workbench.refresh"})),this.pendingRefresh=!1}subscribeFileTree(n,s){this.fileTreeSubscription={workspaceId:n,paths:Sa(s)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:n,paths:this.fileTreeSubscription.paths})}requestFileTreeRefresh(n,s){const o=Sa(s),a={type:"fileTree.refresh",workspaceId:n,paths:o};this.sendWhenReady(a)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:n,paths:o}}subscribeGit(n){this.gitWorkspaceId=n,this.sendWhenReady({type:"git.subscribe",workspaceId:n})}requestGitRefresh(n){this.sendWhenReady({type:"git.refresh",workspaceId:n})?this.pendingGitRefreshWorkspaceId=null:this.pendingGitRefreshWorkspaceId=n}subscribeTerminalManager(n){this.terminalManagerWorkspaceId=n,this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:n})}requestTerminalManagerRefresh(n){this.sendWhenReady({type:"terminalManager.refresh",workspaceId:n})?this.pendingTerminalManagerRefreshWorkspaceId=null:this.pendingTerminalManagerRefreshWorkspaceId=n}subscribeWorkspaceManagement(n){this.workspaceManagementWorkspaceId=n,this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:n})}requestWorkspaceManagementRefresh(n){this.sendWhenReady({type:"workspaceManagement.refresh",workspaceId:n})?this.pendingWorkspaceManagementRefreshWorkspaceId=null:this.pendingWorkspaceManagementRefreshWorkspaceId=n}addFileTreeSnapshotListener(n){return this.fileTreeListeners.add(n),()=>{this.fileTreeListeners.delete(n)}}addGitSnapshotListener(n){return this.gitListeners.add(n),()=>{this.gitListeners.delete(n)}}addTerminalManagerSnapshotListener(n){return this.terminalManagerListeners.add(n),()=>{this.terminalManagerListeners.delete(n)}}addWorkspaceManagementSnapshotListener(n){return this.workspaceManagementListeners.add(n),()=>{this.workspaceManagementListeners.delete(n)}}close(){var n;this.disposed=!0,this.connectionManager.close(),(n=this.socket)==null||n.close(),this.socket=null}connect(n){var h;if(this.disposed)return;n&&this.socket&&(this.socket.close(),this.socket=null);const s=(h=Js.getState().session)==null?void 0:h.accessToken;if(!s){this.options.onUnauthorized();return}const o=Ci(),a=`${Vl("/ws",o)}?access_token=${encodeURIComponent(s)}`,c=Xl(o).createWebSocket({path:"/ws",baseUrl:o,url:a});this.socket=c,c.addEventListener("open",()=>{c.send(JSON.stringify({type:"workbench.subscribe"})),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths),this.gitWorkspaceId&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitWorkspaceId})),this.pendingGitRefreshWorkspaceId&&this.requestGitRefresh(this.pendingGitRefreshWorkspaceId),this.terminalManagerWorkspaceId&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerWorkspaceId})),this.pendingTerminalManagerRefreshWorkspaceId&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefreshWorkspaceId),this.workspaceManagementWorkspaceId&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementWorkspaceId})),this.pendingWorkspaceManagementRefreshWorkspaceId&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefreshWorkspaceId)}),c.addEventListener("message",f=>{var m,I,N,j,M,F,H,P;if(!(f instanceof MessageEvent)||typeof f.data!="string")return;const b=JSON.parse(f.data);if(b.type==="system.connected"){this.connectionManager.markConnected();return}if(b.type==="session.error"){b.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(b.type==="fileTree.snapshot"){(I=(m=this.options).onFileTreeSnapshot)==null||I.call(m,b.snapshot),this.fileTreeListeners.forEach(w=>w(b.snapshot));return}if(b.type==="git.snapshot"){(j=(N=this.options).onGitSnapshot)==null||j.call(N,b.snapshot),this.gitListeners.forEach(w=>w(b.snapshot));return}if(b.type==="terminalManager.snapshot"){(F=(M=this.options).onTerminalManagerSnapshot)==null||F.call(M,b.snapshot),this.terminalManagerListeners.forEach(w=>w(b.snapshot));return}if(b.type==="workspaceManagement.snapshot"){(P=(H=this.options).onWorkspaceManagementSnapshot)==null||P.call(H,b.snapshot),this.workspaceManagementListeners.forEach(w=>w(b.snapshot));return}b.type==="workbench.snapshot"&&bd(b.snapshot)&&this.options.onSnapshot(b.snapshot)}),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 n=this.socket;this.socket=null,n==null||n.close(),Js.refresh().then(s=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(s.status==="refreshed"){this.connectionManager.reconnectNow();return}if(s.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(n){const s=this.socket;return va(s)?(s.send(JSON.stringify(n)),!0):!1}}function va(e){return e!==null&&e.readyState===1}function bd(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Sa(e){const n=new Set;for(const s of e??[""])n.add(s.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...n]}const ja=6,gd=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function kd(e){return e instanceof HTMLElement?!e.closest(gd):!0}function To(e,n,s){return e.isDesktop&&e.ui.osFamily==="macos"&&n===0&&kd(s)}function sl(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function rl(e){return sl(e)?"":void 0}function wd(e){if(!To(e.platform,e.button,e.target)||typeof window>"u")return;const n=e.clientX,s=e.clientY;let o=!0;const a=()=>{o&&(o=!1,window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",h),window.removeEventListener("blur",f))},c=b=>{Math.abs(b.clientX-n)<ja&&Math.abs(b.clientY-s)<ja||(a(),xd())},h=()=>{a()},f=()=>{a()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",h),window.addEventListener("blur",f)}async function xd(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await _i().startDragging()}const Xr=.78,yd=1;function vd(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function ol(e,n,s,o){const a=Math.hypot(s-e,o-n),c=Math.min(1,a/120);return Xr+(yd-Xr)*c}function Sn(e){return Math.round(Number.isFinite(e)?e:0)}function Sd(e){if(!vd())return null;const n=Sn(e.x),s=Sn(e.y);let o=!1,a=Promise.resolve();const c=(f,b)=>(a=a.then(async()=>{await window.__TAURI_INTERNALS__.invoke(f,b)}).catch(()=>{}),a),h=async()=>{o||(o=!0,await c("close_detach_preview"))};return c("show_detach_preview",{title:e.title,x:n,y:s,scale:Xr}),{updatePosition(f,b){if(o)return;const m=Sn(f),I=Sn(b);c("update_detach_preview_position",{x:m,y:I,scale:ol(n,s,m,I)})},complete(){return h()},cancel(){return h()}}}function jd(e){if(typeof document>"u")return null;const n=Sn(e.x),s=Sn(e.y),o=document.createElement("div");o.className="desktop-window-detach-animation",o.setAttribute("aria-hidden","true"),o.dataset.state="preview",o.style.left=`${n}px`,o.style.top=`${s}px`,o.style.setProperty("--detach-preview-scale",Xr.toFixed(3));const a=document.createElement("div");a.className="desktop-window-detach-animation-bar";const c=document.createElement("strong");c.className="desktop-window-detach-animation-title",c.textContent=e.title;const h=document.createElement("div");h.className="desktop-window-detach-animation-body",a.append(c),o.append(a,h),document.body.append(o);let f=!1;const b=()=>{f||(f=!0,o.remove())};return{updatePosition(m,I){if(f)return;const N=Sn(m),j=Sn(I),M=ol(n,s,N,j);o.style.left=`${N}px`,o.style.top=`${j}px`,o.style.setProperty("--detach-preview-scale",M.toFixed(3))},async complete(){b()},async cancel(){b()}}}function Na(e){return Sd(e)??jd(e)}const Nd={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 Cd(e){return{...e,bounds:{...e.bounds}}}function Id(e,n,s){n&&(e.windows.registerDescriptor(n),s?e.windows.markWindowOpen(n.windowId):e.windows.markWindowClosed(n.windowId))}function Td(e){return Nd[e]}function Md(e,n){return`${e}-${n}`}async function eo(e,n,s){const o=s.workspaceId.trim(),a=Td(n);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!o)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${a.label}外部窗口必须绑定工作区。`};const c=Md(n,o),h=e.windows.getDescriptor(c),f=h?Cd(h):null,b=e.windows.isWindowOpen(c),m=Yl({windowId:c,kind:n,workspaceId:o,sessionId:s.sessionId??(f==null?void 0:f.sessionId)??null,mode:"external",bounds:f==null?void 0:f.bounds,focusOwner:s.focusOwner??a.defaultFocusOwner});e.windows.registerDescriptor(m);const I=await e.bridge.createWindow(m);return I.ok?(e.windows.markWindowOpen(c),{ok:!0,value:m}):(f?Id(e,f,b):e.windows.removeWindow(c),{ok:!1,errorCode:I.errorCode,detail:I.detail})}function Rd(e,n){return eo(e,"files",n)}function Ed(e,n){return eo(e,"git",n)}function Wd(e,n){return eo(e,"processes",n)}function lp(e,n){return eo(e,"terminals",n)}async function Ca(){return await Z.request("/api/skills/overview")}async function Pd(e){await Z.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Ad(e){await Z.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Ld(e){await Z.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Bd({triggerClassName:e="secondary-button",triggerLabel:n,triggerLeading:s}){const o=Ii(v=>{var ce;return((ce=v.session)==null?void 0:ce.accessToken)??null}),a=l.useRef(null),[c,h]=l.useState(null),[f,b]=l.useState(!1),[m,I]=l.useState(null),[N,j]=l.useState(null),[M,F]=l.useState(null),[H,P]=l.useState(!1),[w,O]=l.useState(!1),[U,se]=l.useState(null),[X,ee]=l.useState("file"),[_,L]=l.useState("workspace"),[y,K]=l.useState(""),[J,E]=l.useState(()=>Us("workspace"));l.useEffect(()=>{let v=!0;if(!H)return;if(!o){h(null),j(null),F(null),b(!1);return}return(async()=>{b(!0);try{const be=await Ca();if(!v)return;h(be),j(null)}catch(be){if(!v)return;j(ps(be))}finally{v&&b(!1)}})(),()=>{v=!1}},[o,H]);async function ge(){const v=await Ca();h(v),j(null)}async function $(){if(o){I("refresh"),j(null),F(null);try{await ge(),F(r("settings.skillRefreshSuccess"))}catch(v){j(ps(v))}finally{I(null)}}}async function me(v){if(o){I(Ia(v)),j(null),F(null);try{await Ad({targetCli:v.targetCli,directoryPath:v.directoryPath,expectedContentHash:v.contentHash}),await ge(),F(r("settings.skillImportSuccess",{name:v.name,target:jn(v.targetCli)}))}catch(ce){j(ps(ce))}finally{I(null)}}}async function D(v){if(!o)return;const ce=v.bindings.filter(be=>be.enabled).map(be=>be.targetCli);if(ce.length===0){j(r("settings.skillSyncTargetMissing"));return}I(Ta(v.skill.id)),j(null),F(null);try{await Ld({skillId:v.skill.id,targetCli:ce}),await ge(),F(r("settings.skillSyncSuccess",{name:v.skill.name}))}catch(be){j(ps(be))}finally{I(null)}}async function x(v){var be;const ce=((be=v.target.files)==null?void 0:be[0])??null;if(v.target.value="",!!ce){j(null),F(null);try{const Q=await Zd(ce),rt=ll(ce.name,Q);se(rt),E(Us(_))}catch(Q){j(ps(Q))}}}async function S(){const v=Ma({sourceMode:X,fileDraft:U,pastedMarkdown:y});if(!o)return;if(!v){j(X==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty"));return}const ce=v.directoryName;if(!ce){j(r("settings.skillUploadDirectoryInvalid"));return}const be=Mo(_).filter(Q=>J[Q]).map(Q=>Q);if(be.length===0){j(r("settings.skillUploadTargetRequired"));return}I("upload"),j(null),F(null);try{await Pd({markdownContent:v.rawContent,scope:_,fileName:v.fileName,directoryName:ce,targetCli:be}),await ge(),F(r("settings.skillUploadSuccess",{name:ce})),z(_),O(!1)}catch(Q){j(ps(Q))}finally{I(null)}}function Y(v){L(v),E(Us(v))}function T(v){ee(v),se(null),K(""),E(Us(_)),j(null)}function re(v){E(ce=>({...ce,[v]:!ce[v]}))}function q(){O(!0),j(null)}function te(){O(!1),j(null),z(_)}function z(v){se(null),K(""),ee("file"),E(Us(v))}const ae=(c==null?void 0:c.summary)??{managedSkillCount:0,managedEntryCount:0},pe=Xd((c==null?void 0:c.assistantRuntimeSkills)??[],(c==null?void 0:c.conflictedEntries)??[],(c==null?void 0:c.diagnostics)??[]),de=((c==null?void 0:c.conflictedEntries)??[]).filter(v=>!il(v,(c==null?void 0:c.diagnostics)??[])),He=((c==null?void 0:c.diagnostics)??[]).filter(v=>!tr(v)),Me=Ma({sourceMode:X,fileDraft:U,pastedMarkdown:y}),Mt=n??r("settings.skillManageAction");return t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:e,type:"button","data-open":H?"true":"false","aria-haspopup":"dialog","aria-expanded":H,onClick:()=>{P(!0)},children:[s,t.jsx("span",{children:Mt})]}),t.jsxs(Fe,{open:H,title:r("settings.skillConfigModalTitle"),description:r("settings.skillConfigModalDescription"),className:"settings-skill-modal",headerActions:t.jsxs("div",{className:"settings-skill-modal-actions",children:[t.jsx("button",{className:"secondary-button",type:"button",disabled:!o||f||m!==null,onClick:q,children:r("settings.skillCreateAction")}),t.jsx("button",{className:"secondary-button",type:"button",disabled:!o||f||m!==null,onClick:()=>{$()},children:m==="refresh"?r("common.loading"):r("settings.skillRefresh")})]}),onClose:()=>P(!1),children:[t.jsxs("section",{className:"settings-skill-summary-block",children:[t.jsxs("div",{className:"settings-skill-summary-grid",children:[t.jsx(Er,{label:r("settings.skillSummaryManagedSkills"),value:String(ae.managedSkillCount)}),t.jsx(Er,{label:r("settings.skillSummaryManagedEntries"),value:String(ae.managedEntryCount)}),t.jsx(Er,{label:r("settings.skillSummaryConflictedEntries"),value:String(de.length)}),t.jsx(Er,{label:r("settings.skillSummaryDiagnostics"),value:String(He.length)})]}),t.jsx("div",{className:"settings-release-meta",children:t.jsxs("span",{children:[r("settings.skillScannedAt"),": ",f?r("common.loading"):Vd(c==null?void 0:c.scannedAt)]})}),M?t.jsx("p",{className:"settings-release-status",children:M}):null,N?t.jsx("p",{className:"settings-release-status",children:N}):null]}),t.jsx(Hs,{title:r("settings.skillManagedListTitle"),emptyText:r("settings.skillManagedEmpty"),items:(c==null?void 0:c.managedSkills)??[],renderItem:v=>{const ce=Ta(v.skill.id);return t.jsxs("div",{className:"settings-skill-entry",children:[t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:v.skill.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:qd(v.bindings)}),t.jsx("div",{className:"settings-skill-tags",children:v.bindings.map(be=>t.jsxs("span",{className:"settings-skill-tag","data-status":be.syncStatus,children:[jn(be.targetCli)," · ",$d(be.syncStatus)]},`${v.skill.id}-${be.targetCli}`))})]}),t.jsx("div",{className:"settings-skill-entry-actions",children:t.jsx("button",{className:"secondary-button",type:"button",disabled:f||m!==null,onClick:()=>{D(v)},children:m===ce?r("common.loading"):r("settings.skillSyncAction")})})]},v.skill.id)}}),t.jsx(Hs,{title:r("settings.skillUnmanagedListTitle"),emptyText:r("settings.skillUnmanagedEmpty"),items:(c==null?void 0:c.unmanagedEntries)??[],renderItem:v=>{const ce=Ia(v);return t.jsxs("div",{className:"settings-skill-entry",children:[t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:v.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:Gd(v)})]}),t.jsx("div",{className:"settings-skill-entry-actions",children:t.jsx("button",{className:"secondary-button",type:"button",disabled:f||m!==null,onClick:()=>{me(v)},children:m===ce?r("common.loading"):r("settings.skillImportAction")})})]},`${v.targetCli}:${v.directoryPath}`)}}),t.jsx(Hs,{title:r("settings.skillAssistantRuntimeListTitle"),description:r("settings.skillAssistantRuntimeListDescription"),emptyText:r("settings.skillAssistantRuntimeEmpty"),items:pe,renderItem:v=>t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:v.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:r("settings.skillAssistantRuntimeItemDescription")}),t.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillAssistantRuntimeUsedBy"),": ",al(v.usedByTargetCli)]}),t.jsxs("div",{className:"settings-skill-tags",children:[t.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:r("settings.skillTagAssistantOnly")}),v.usedByTargetCli.map(ce=>t.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:jn(ce)},`${v.directoryName}:${ce}`))]})]})},`${v.directoryName}:${v.sourcePath}`)}),t.jsx(Hs,{title:r("settings.skillConflictedListTitle"),emptyText:r("settings.skillConflictedEmpty"),items:de,renderItem:v=>{const ce=Yd(v,(c==null?void 0:c.diagnostics)??[]);return t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:v.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:zd(v)}),ce.length>0?t.jsx("div",{className:"settings-skill-tags",children:ce.map(be=>t.jsx("span",{className:"settings-skill-tag","data-status":be.status,children:be.label},be.key))}):null]})},`${v.targetCli}:${v.directoryPath}`)}}),t.jsx(Hs,{title:r("settings.skillDiagnosticsTitle"),emptyText:r("settings.skillDiagnosticsEmpty"),items:He,renderItem:v=>{const ce=Jd(v),be=Kd(v);return t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:be.title}),t.jsx("p",{className:"settings-skill-entry-meta",children:be.detail}),ce.length>0?t.jsx("div",{className:"settings-skill-tags",children:ce.map(Q=>t.jsx("span",{className:"settings-skill-tag","data-status":Q.status,children:Q.label},Q.key))}):null]})},`${v.targetCli}:${v.code}:${v.directoryPath??v.rootDir}`)}})]}),t.jsx(Fe,{open:w,title:r("settings.skillCreateModalTitle"),description:r("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:te,children:t.jsxs("section",{className:"settings-skill-section",children:[t.jsx("h3",{className:"settings-skill-section-title",children:r("settings.skillUploadSectionTitle")}),t.jsx("p",{className:"settings-skill-section-description",children:r("settings.skillUploadSectionDescription")}),t.jsxs("div",{className:"settings-skill-create-panel",children:[t.jsx("input",{ref:a,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:v=>{x(v)}}),t.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":r("settings.skillCreateSourceTabsLabel"),children:Od.map(v=>{const ce=X===v;return t.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":ce,"data-active":ce?"true":"false",onClick:()=>T(v),children:Ud(v)},v)})}),t.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":r("settings.skillUploadScopeLabel"),children:Fd.map(v=>t.jsxs("label",{className:"settings-skill-upload-target","data-selected":_===v?"true":"false",children:[t.jsx("input",{type:"radio",name:"skill-upload-scope",checked:_===v,onChange:()=>Y(v)}),t.jsx("span",{children:Hd(v)})]},v))}),X==="file"?t.jsx("div",{className:"settings-skill-create-toolbar",children:t.jsx("button",{className:"secondary-button",type:"button",disabled:f||m!==null,onClick:()=>{var v;(v=a.current)==null||v.click()},children:r("settings.skillUploadPickAction")})}):t.jsxs("label",{className:"settings-skill-upload-field",children:[t.jsx("span",{children:r("settings.skillPasteLabel")}),t.jsx("textarea",{className:"settings-skill-create-textarea",value:y,onChange:v=>K(v.target.value),placeholder:r("settings.skillPastePlaceholder")})]}),Me?t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:Me.previewTitle}),t.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillUploadPickedFile"),": ",Me.fileName]})]})}):t.jsx("div",{className:"settings-skill-empty",children:X==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty")}),t.jsxs("div",{className:"settings-skill-upload-field",children:[t.jsx("span",{children:r("settings.skillUploadTargetsLabel")}),t.jsx("div",{className:"settings-skill-upload-targets",children:Mo(_).map(v=>t.jsxs("label",{className:"settings-skill-upload-target","data-selected":J[v]?"true":"false",children:[t.jsx("input",{type:"checkbox",checked:J[v],onChange:()=>re(v)}),t.jsx("span",{children:jn(v)})]},v))})]}),Me!=null&&Me.notes.length?t.jsx("div",{className:"settings-skill-tags",children:Me.notes.map((v,ce)=>t.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:v},`${Me.fileName}:${ce}`))}):null,N?t.jsx("p",{className:"settings-release-status",children:N}):null,t.jsx("div",{className:"settings-skill-create-actions",children:t.jsx("button",{className:"primary-button",type:"button",disabled:f||m!==null,onClick:()=>{S()},children:m==="upload"?r("common.loading"):r("settings.skillCreateSubmitAction")})})]})]})})]})}function Hs({title:e,description:n,emptyText:s,items:o,renderItem:a}){return t.jsxs("section",{className:"settings-skill-section",children:[t.jsx("h3",{className:"settings-skill-section-title",children:e}),n?t.jsx("p",{className:"settings-skill-section-description",children:n}):null,o.length>0?t.jsx("div",{className:"settings-skill-entry-list",children:o.map(c=>a(c))}):t.jsx("div",{className:"settings-skill-empty",children:s})]})}function Er({label:e,value:n}){return t.jsxs("div",{className:"settings-skill-summary-card",children:[t.jsx("span",{children:e}),t.jsx("strong",{children:n})]})}function Ia(e){return`import:${e.targetCli}:${e.directoryPath}`}function Ta(e){return`sync:${e}`}const Dd=["codex","claude-code","gemini","opencode"],_d=["codex","claude-code"],Fd=["workspace","assistant"],Od=["file","paste"];function ps(e){return e instanceof Ti?e.message||r("settings.skillLoadFailed"):e instanceof Error?e.message:r("settings.skillLoadFailed")}function jn(e){switch(e){case"claude-code":return r("settings.skillTargetClaudeCode");case"gemini":return r("settings.skillTargetGemini");case"opencode":return r("settings.skillTargetOpenCode");default:return r("settings.skillTargetCodex")}}function Hd(e){return e==="assistant"?r("settings.skillUploadScopeAssistant"):r("settings.skillUploadScopeWorkspace")}function Ud(e){return e==="paste"?r("settings.skillCreateSourcePaste"):r("settings.skillCreateSourceFile")}function Us(e){return{codex:new Set(Mo(e)).has("codex"),"claude-code":!1,gemini:!1,opencode:!1}}function Mo(e){return e==="assistant"?_d:Dd}function Ma({sourceMode:e,fileDraft:n,pastedMarkdown:s}){return e==="file"?n:s.trim()?ll(Qd(s),s):null}function $d(e){switch(e){case"conflicted":return r("settings.skillBindingConflicted");case"failed":return r("settings.skillBindingFailed");case"pending":return r("settings.skillBindingPending");default:return r("settings.skillBindingSynced")}}function al(e){return e.map(jn).join(" / ")}function qd(e){const n=e.filter(s=>s.enabled);return n.length===0?r("settings.skillManagedItemNoTarget"):r("settings.skillManagedItemDescription",{targets:al(n.map(s=>s.targetCli))})}function Gd(e){return r("settings.skillUnmanagedItemDescription",{target:jn(e.targetCli)})}function zd(e){return r("settings.skillConflictedItemDescription",{target:jn(e.targetCli)})}function Kd(e){const n=jn(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:r("settings.skillDiagnosticTargetMissingTitle",{target:n}),detail:r("settings.skillDiagnosticTargetMissingDetail",{target:n})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:r("settings.skillDiagnosticReadFailedTitle",{target:n}),detail:r("settings.skillDiagnosticReadFailedDetail",{target:n})};case"SKILL_TARGET_SKILL_MISSING":return{title:r("settings.skillDiagnosticSyncMissingTitle",{target:n}),detail:r("settings.skillDiagnosticSyncMissingDetail",{target:n})};default:return{title:r("settings.skillDiagnosticGenericTitle",{target:n}),detail:r("settings.skillDiagnosticGenericDetail",{target:n})}}}function Vd(e){if(!e)return"-";const n=Date.parse(e);return Number.isNaN(n)?e:new Date(n).toLocaleString()}function Xd(e,n,s){if(e.length>0)return e.map(a=>({name:a.name,directoryName:a.directoryName,sourcePath:a.sourcePath,usedByTargetCli:a.usedByTargetCli}));const o=new Map;for(const a of n)il(a,s)&&o.set(Ra(a.targetCli,a.directoryPath),{name:a.name,directoryName:a.directoryName,sourcePath:a.directoryPath,usedByTargetCli:[a.targetCli]});for(const a of s){if(!tr(a))continue;const c=a.directoryPath??a.rootDir,h=Ra(a.targetCli,c);o.has(h)||o.set(h,{name:a.directoryName??"codingns-assistant",directoryName:a.directoryName??"codingns-assistant",sourcePath:c,usedByTargetCli:[a.targetCli]})}return[...o.values()]}function Ra(e,n){return`${e}:${n}`}function il(e,n){return n.some(s=>tr(s)&&s.targetCli===e.targetCli&&s.directoryPath===e.directoryPath&&s.directoryName===e.directoryName)}function tr(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function Yd(e,n){return n.find(o=>tr(o)&&o.targetCli===e.targetCli&&o.directoryName===e.directoryName&&o.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Jd(e){return tr(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function ll(e,n){const s=[],o=n.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
3
|
+
`).trim();if(!o)throw new Error(r("settings.skillUploadContentEmpty"));o!==n.trim()&&s.push(r("settings.skillUploadNormalizedNote"));const a=cl(o),c=Ro(e)??Ro(a)??"";return c||s.push(r("settings.skillUploadDirectoryRequiredNote")),a||s.push(r("settings.skillUploadHeadingNote")),{fileName:e,rawContent:o,directoryName:c,previewTitle:a||eu(c||"skill"),notes:s}}async function Zd(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(r("settings.skillUploadReadFailed"));return await new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(o.error??new Error(r("settings.skillUploadReadFailed")))},o.onload=()=>{if(typeof o.result=="string"){n(o.result);return}s(new Error(r("settings.skillUploadReadFailed")))},o.readAsText(e)})}function Ro(e){const o=(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 o.length>0?o:null}function Qd(e){const n=Ro(cl(e));return n?`${n}.md`:"pasted-skill.md"}function cl(e){var n,s;return((s=(n=e.match(/^#\s+(.+)$/m))==null?void 0:n[1])==null?void 0:s.trim())??""}function eu(e){return e.split(/[._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")||e}function Zo(e){var n,s;return e.runningState==="failed"||!!((n=e.lastErrorCode)!=null&&n.trim())||!!((s=e.lastErrorDetail)!=null&&s.trim())}function tu(e,n,s){return`${e} is-${dl(n,s)}`}function dl(e,n){n==null||n.isActive;const s=ru(e);return n!=null&&n.hasSubagents?s==="error"?"error":s==="unread"?"subagent-unread":s==="running"||s==="running_inferred"?"subagent-running":"subagent":s==="running_inferred"?"running-inferred":s.replace("_","-")}function nu(e){return e.runningState==="stale"?r("conversation.runtimeStale"):e.runningState==="unknown"?r("conversation.runtimeUnknown"):null}function su(e,n){return n.runningState==="stale"?`${e} is-stale`:n.runningState==="unknown"?`${e} is-unknown`:null}function ru(e){return Zo(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?ou(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function ou(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function au(e){return Qo(e)!==null}function iu(e){return e.isSubagent===!0&&!au(e)}function Qo(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 lu(e){const n=Qo(e);return n==="reconstructed"?r("shell.sessionForkReconstructed"):n==="message"?r("shell.sessionForkMessage"):n==="session"?r("shell.sessionForkSession"):null}function cu(e){return e.sessionKind==="annotation"?"annotation":null}function cp(e){return cu(e)==="annotation"?r("conversation.actionSessionBadge"):null}const Ea=48;function du(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function ea(e,n){const s=du(e)||n,o=s.length>Ea?s.slice(0,Ea).trimEnd():s;return{fullTitle:s,displayTitle:o}}function Wr(e,n){return(n??"").localeCompare(e??"")}function Wa(e,n){return e.localeCompare(n,void 0,{numeric:!0,sensitivity:"base"})}function Pr(e){return(e==null?void 0:e.trim())??""}function ta(e,n,s){if(s==="updatedAt"){const h=Wr(e.updatedAt,n.updatedAt);if(h!==0)return h}if(s==="title"){const h=Wa(Pr(e.title),Pr(n.title));if(h!==0)return h}else{const h=Wr(e.createdAt,n.createdAt);if(h!==0)return h}const o=Wr(e.updatedAt,n.updatedAt);if(o!==0)return o;const a=Wr(e.createdAt,n.createdAt);if(a!==0)return a;const c=Wa(Pr(e.title),Pr(n.title));return c!==0?c:e.sessionId.localeCompare(n.sessionId)}function nr(e,n){return[...e].sort((s,o)=>ta(s,o,n))}function na(e,n){return Array.isArray(e)?e.map(s=>({...s,sessions:nr(s.sessions,n),children:na(s.children,n)})):[]}const go=5,ko=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function uu(e){const n=Math.round(e.ratio*1e3)/10;return`${n.toFixed(n%1===0?0:1)}%`}function hu(e,n){const s=e.reduce((f,b)=>f+b.count,0);if(s<=0)return[];const a=e.slice(0,go).map((f,b)=>({...f,key:f.type,ratio:f.count/s,color:ko[b]??ko[0]})),c=e.slice(go);if(c.length===0)return a;const h=c.reduce((f,b)=>f+b.count,0);return a.push({key:"other",type:n,count:h,ratio:h/s,color:ko[go]}),a}function fu(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let n=0;return`conic-gradient(${e.map((o,a)=>{const c=n,h=a===e.length-1?1:Math.min(1,n+o.ratio);return n=h,`${o.color} ${Pa(c)} ${Pa(h)}`}).join(", ")})`}function pu(e){return{"--workbench-manage-chart-background":fu(e)}}function Pa(e){const n=Math.round(e*1e3)/10;return`${n.toFixed(n%1===0?0:1)}%`}const mu=8,bu=12,gu=160,Aa=96;function ku(e,n,s,o={}){const a=o.gapPx??mu,c=o.viewportMarginPx??bu,h=o.defaultWidthPx??gu,f=o.estimatedHeightPx??Aa,b=o.minHeightPx??Aa,m=Math.max(0,s.width),I=Math.max(0,s.height),N=Math.max(0,I-c*2),j=Math.max(0,m-c*2),M=Ar(Math.max(n.width||h,h),0,j),F=Math.max(n.height||f,f),H=Math.max(0,m-e.x-c),P=Math.max(0,e.x-c),w=H<M&&P>H,O=Math.max(0,I-e.y-a-c),U=Math.max(0,e.y-a-c),se=O<F&&U>O,ee=Ar(Math.max(se?U:O,b),0,N),_=Math.min(F,ee),L=w?e.x-M:e.x,y=Math.max(c,m-c-M),K=se?e.y-a-_:e.y+a,J=Math.max(c,I-c-_),E=Ar(L,c,y),ge=Ar(K,c,J),$=w||E<e.x?"right":"left";return{top:ge,left:E,width:M,maxHeight:Math.max(0,ee),transformOrigin:`${se?"bottom":"top"} ${$}`}}function Ar(e,n,s){return!Number.isFinite(e)||s<n?n:Math.min(Math.max(e,n),s)}const ul="workbench.navigation.snapshot",hl=1800*1e3,wu="workbench.navigation.snapshot.host.";function fl(e){return`${wu}${e}`}function xu(e=hl,n=Yr(en.getState())){if(n){const s=Vr(fl(n),e);if(s)return s}return Vr(ul,e)}function Lr(e,n=Yr(en.getState())){Xs(ul,e),n&&Xs(fl(n),e)}function La(e,n="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(s=>({workspace:s.workspace,sessions:nr(s.sessions,n),childWorktrees:yu(s.childWorktrees,n)}))}function yu(e,n){return na(e,n)}function sa(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 vu(e){const n=new Map;for(const s of e)n.set(s.workspace.id,sa(s.workspace)),pl(n,s.childWorktrees??[],s.workspace,s.workspace);return Object.fromEntries(n)}function Qt(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function pl(e,n,s,o,a=o.name){var c;for(const h of n){const f=((c=h.meta.displayName)==null?void 0:c.trim())||h.workspace.name;e.set(h.workspace.id,{workspaceId:h.workspace.id,tone:"worktree",backgroundColor:h.workspace.backgroundColor??null,displayName:f,workspaceName:h.workspace.name,branchName:h.meta.branchName||null,depth:h.meta.depth,rootWorkspaceId:s.id,rootDisplayName:s.name,parentWorkspaceId:h.meta.parentWorkspaceId||o.id,parentDisplayName:a}),pl(e,h.children,s,h.workspace,f)}}const Su="X-CodingNS-Assistant-Source",ju="butler-ui",wo=new Map;async function tn(e,n={},s={}){const o=new Headers(n.headers);o.set(Su,ju);const a=Nu();if(wo.get(a)===!1){if(s.unsupportedFallback!==void 0)return Ba(s.unsupportedFallback);throw Da()}try{const h=await Z.request(e,{...n,headers:o});return wo.set(a,!0),h}catch(h){if(!Cu(h))throw h;if(wo.set(a,!1),s.unsupportedFallback!==void 0)return Ba(s.unsupportedFallback);throw Da()}}function Nu(){return Ci()}function Ba(e){return typeof e=="function"?e():e}function Cu(e){return e instanceof Ti&&(e.status===404||e.status===405||e.status===501)}function Da(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function Iu(){return Z.request("/api/butler/profile")}function dp(e){return Z.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function up(e){return Z.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function hp(){return Z.request("/api/butler/control-session")}function fp(){return Z.request("/api/butler/control-sessions")}function pp(e){return Z.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function mp(e={}){var a;const n=new URLSearchParams;e.status&&n.set("status",e.status),(a=e.controlSessionId)!=null&&a.trim()&&n.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&n.set("limit",String(e.limit));const s=n.toString(),o=s?`/api/butler/control-timers?${s}`:"/api/butler/control-timers";return Z.request(o)}function bp(){return Z.request("/api/butler/control-session/reset",{method:"POST"})}function gp(e={}){return Z.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function kp(e){return Z.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function wp(e={}){var a;const n=new URLSearchParams;e.status&&n.set("status",e.status),(a=e.controlSessionId)!=null&&a.trim()&&n.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&n.set("limit",String(e.limit));const s=n.toString(),o=s?`/api/assistant/automations?${s}`:"/api/assistant/automations";return tn(o,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function xp(e={}){var a;const n=new URLSearchParams;(a=e.controlSessionId)!=null&&a.trim()&&n.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&n.set("limit",String(e.limit));const s=n.toString(),o=s?`/api/assistant/automations/runs/recent?${s}`:"/api/assistant/automations/runs/recent";return tn(o,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function yp(e){return tn(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function vp(e,n){return tn(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(n)})}function Sp(e){return tn(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function jp(e={}){var a;const n=new URLSearchParams;e.status&&n.set("status",e.status),(a=e.controlSessionId)!=null&&a.trim()&&n.set("controlSessionId",e.controlSessionId.trim());const s=n.toString(),o=s?`/api/assistant/sandboxes?${s}`:"/api/assistant/sandboxes";return tn(o,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function Np(e){return tn(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function Cp(e){return tn(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function Ip(e){return tn(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function Tp(e){return Z.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function Mp(){return Z.request("/api/butler/control-session/events")}function Tu(){return Z.request("/api/butler/overview")}function Mu(e={}){var a;const n=new URLSearchParams;(a=e.workspaceId)!=null&&a.trim()&&n.set("workspaceId",e.workspaceId.trim()),e.status&&n.set("status",e.status),e.riskLevel&&n.set("riskLevel",e.riskLevel);const s=n.toString(),o=s?`/api/butler/projects?${s}`:"/api/butler/projects";return Z.request(o)}function Rp(e,n={}){const s=new URLSearchParams;n.enabled!==null&&n.enabled!==void 0&&s.set("enabled",String(n.enabled)),n.executionMode&&s.set("executionMode",n.executionMode);const o=s.toString(),a=o?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${o}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return Z.request(a)}function ml(e={}){var a,c;const n=new URLSearchParams;(a=e.workspaceId)!=null&&a.trim()&&n.set("workspaceId",e.workspaceId.trim()),(c=e.projectId)!=null&&c.trim()&&n.set("projectId",e.projectId.trim()),e.status&&n.set("status",e.status),e.itemType&&n.set("itemType",e.itemType);const s=n.toString(),o=s?`/api/butler/inbox?${s}`:"/api/butler/inbox";return Z.request(o)}function Ru(e){return Z.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function Eu(e={}){var a,c;const n=new URLSearchParams;e.status&&n.set("status",e.status),(a=e.projectId)!=null&&a.trim()&&n.set("projectId",e.projectId.trim()),(c=e.sessionId)!=null&&c.trim()&&n.set("sessionId",e.sessionId.trim());const s=n.toString(),o=s?`/api/butler/follow-up-tasks?${s}`:"/api/butler/follow-up-tasks";return Z.request(o)}function Ep(e){return Z.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function Wp(e){return Z.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function Pp(e){return Z.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function Ap(e,n){return Z.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(n)}/cancel`,{method:"POST"})}function _a(e,n){return Z.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:n.projectId,itemType:n.itemType,title:n.title,content:n.content,priority:n.priority,status:n.status})})}function Lp(e){return Z.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function Bp(e){return Z.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function Wu(e){return Z.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function Pu(){return Z.request("/api/butler/notifications/archives")}function Au(e,n){return Z.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:n})})}function Lu(e){const n=new URLSearchParams;return n.set("sessionId",e),Z.request(`/api/butler/session-target?${n.toString()}`)}function Dp(e){const n=new URLSearchParams;return n.set("sessionId",e),Z.request(`/api/butler/session-action-context?${n.toString()}`)}function _p(e){return Z.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}class Eo extends Error{constructor(n,s){super(s),this.code=n,this.name="HostSwitchError"}}class Bu{constructor(){Ee(this,"inFlight",null)}async switchHost(n){this.inFlight&&await this.inFlight;const s=this.performSwitch(n).finally(()=>{this.inFlight===s&&(this.inFlight=null)});this.inFlight=s,await s}async performSwitch(n){const s=en.getState();if(Yr(s)===n)return;const o=Jl(s,n);if(!o)throw new Eo("HOST_NOT_FOUND",`找不到 HOST:${n}`);if(!(await Zl(o.baseUrl)).reachable)throw new Eo("HOST_UNREACHABLE",`目标 HOST 不可达:${o.baseUrl}`);const c=Mi(o.id);if(c)try{await Js.loginForHost(o,{username:c.username,password:c.password})}catch{}const h=en.getState(),f=new Date().toISOString();if(Ri(o)){en.updateRuntime({discoveredHosts:h.discoveredHosts.map(b=>b.id===n?{...b,lastConnectedAt:f,updatedAt:f}:b),activeDiscoveredHostId:n});return}Co.setActiveDiscoveredHost(null),await en.update({hosts:h.hosts.map(b=>b.id===n?{...b,lastConnectedAt:f,updatedAt:f}:b),activeHostId:n})}}const Du=new Bu;function bl({collapsed:e=!1}){const[n,s]=l.useState(!1),[o,a]=l.useState(!1),[c,h]=l.useState(""),[f,b]=l.useState(""),[m,I]=l.useState(""),[N,j]=l.useState(""),[M,F]=l.useState(null),[H,P]=l.useState(null),[w,O]=l.useState(null),[U,se]=l.useState(null),X=l.useRef(null),ee=l.useRef(null),_=Bo(T=>T),L=Ii(T=>T.session),{showToast:y}=Vn(),K=Ei(_),J=Yr(_),E=l.useMemo(()=>Fa(_.hosts,J),[J,_.hosts]),ge=l.useMemo(()=>Fa(Wi(_),J),[J,_]),$=l.useCallback(()=>{if(typeof window>"u")return;const T=X.current;if(!T)return;const re=T.getBoundingClientRect(),q=window.innerWidth,te=window.innerHeight,z=16,ae=8,de=Math.min(320,Math.max(240,q-z*2)),He=Math.min(e?Math.max(z,re.right+ae):Math.max(z,re.left),Math.max(z,q-de-z)),Me=o?440:240,Mt=e?re.top:re.bottom+ae,v=Math.min(Math.max(z,Mt),Math.max(z,te-Me-z));se({position:"fixed",top:v,left:He,width:de,maxWidth:q-z*2})},[e,o]);l.useEffect(()=>{if(!n){se(null);return}Co.refresh();function T(q){var te,z;q.target instanceof Node&&!((te=X.current)!=null&&te.contains(q.target))&&!((z=ee.current)!=null&&z.contains(q.target))&&(s(!1),a(!1),O(null))}function re(q){q.key==="Escape"&&(s(!1),a(!1),O(null))}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",re),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),$(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",re),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[n,$]);async function me(T){if(M||H||T.id===J){s(!1);return}F(T.id);try{await Du.switchHost(T.id),s(!1),a(!1),O(null)}catch(re){y({title:Hu(re,T.name),tone:"error"})}finally{F(null)}}async function D(T){if(!(T.id===J||M||H)){if(w!==T.id){O(T.id);return}P(T.id);try{await en.update({hosts:_.hosts.filter(re=>re.id!==T.id)}),Ql(T.id),Js.clearHostSession(T.id),O(null),y({title:r("shell.hostDeleteSuccess",{name:T.name})})}catch{y({title:r("shell.hostDeleteFailed",{name:T.name}),tone:"error"})}finally{P(null)}}}async function x(){const T=m.trim();if((T.length>0||N.length>0)&&(!T||!N)){y({title:r("shell.hostAddIncompleteCredentials"),tone:"error"});return}let q;try{q=ec(f)}catch{y({title:r("shell.hostAddInvalidUrl"),tone:"error"});return}if(_.hosts.some(ae=>ae.baseUrl===q)){y({title:r("shell.hostAddDuplicate"),tone:"error"});return}const te=new Date().toISOString(),z={id:Ou(),name:c.trim()||_u(q),baseUrl:q,kind:Fu(q),createdAt:te,updatedAt:te,lastConnectedAt:null,lastUserId:null,lastUsername:null};try{const ae=Ri(K)&&K.baseUrl===q;ae&&Co.setActiveDiscoveredHost(null),await en.update({hosts:[..._.hosts,z],activeHostId:ae?z.id:_.activeHostId}),T&&N&&tc({hostId:z.id,username:T,password:N}),S(),a(!1),O(null),y({title:r("shell.hostAddSuccess",{name:z.name})})}catch{y({title:r("shell.hostAddFailed"),tone:"error"})}}function S(){h(""),b(""),I(""),j("")}if(!K)return null;const Y=L!=null&&L.user.username?`${K.baseUrl} · ${L.user.username}`:K.baseUrl;return t.jsxs("div",{ref:X,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[t.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.hostSwitcherAriaLabel"),title:Y,"aria-expanded":n,onClick:()=>{s(T=>!T),a(!1)},children:t.jsx(Uu,{})}),n&&U&&typeof document<"u"?Zr.createPortal(t.jsxs("div",{ref:ee,className:"workbench-host-switcher-menu",style:U,role:"menu","aria-label":r("shell.hostSwitcherTitle"),children:[t.jsx("div",{className:"workbench-host-switcher-menu-header",children:t.jsx("strong",{children:r("shell.hostSwitcherTitle")})}),t.jsxs("div",{className:"workbench-host-switcher-list",children:[t.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherSavedSection")}),E.map(T=>{const re=T.id===J,q=re?(L==null?void 0:L.user.username)??T.lastUsername??T.baseUrl:T.lastUsername??T.baseUrl;return t.jsxs("div",{className:"workbench-host-switcher-item","data-active":re,children:[t.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:M!==null||H!==null,onClick:()=>{me(T)},children:[t.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[t.jsxs("span",{className:"workbench-host-switcher-item-title",children:[T.name,re?t.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),t.jsx("span",{className:"workbench-host-switcher-item-meta",children:q})]}),t.jsx("span",{className:"workbench-host-switcher-item-trailing",children:M===T.id?r("shell.hostSwitcherSwitching"):re?t.jsx(Ha,{}):t.jsx(Oa,{})})]}),re?null:t.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostDeleteAriaLabel",{name:T.name}),title:w===T.id?r("shell.hostDeleteConfirmAction"):r("shell.hostDeleteAction"),"data-confirming":w===T.id,disabled:M!==null||H!==null,onClick:()=>{D(T)},children:H===T.id?r("shell.hostDeleteBusy"):w===T.id?r("shell.hostDeleteConfirmAction"):t.jsx(qu,{})})]},T.id)}),ge.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherDiscoveredSection")}),ge.map(T=>{const re=T.id===J,q=Mi(T.id),te=re?(L==null?void 0:L.user.username)??(q==null?void 0:q.username)??T.baseUrl:(q==null?void 0:q.username)??T.baseUrl;return t.jsx("div",{className:"workbench-host-switcher-item","data-active":re,"data-discovered":"true",children:t.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:M!==null||H!==null,onClick:()=>{me(T)},children:[t.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[t.jsxs("span",{className:"workbench-host-switcher-item-title",children:[T.name,t.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:r("shell.hostSwitcherDiscoveredBadge")}),re?t.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),t.jsx("span",{className:"workbench-host-switcher-item-meta",children:te})]}),t.jsx("span",{className:"workbench-host-switcher-item-trailing",children:M===T.id?r("shell.hostSwitcherSwitching"):re?t.jsx(Ha,{}):t.jsx(Oa,{})})]})},T.id)})]}):null,_.localHostDiscovery.status==="refreshing"?t.jsx("div",{className:"workbench-host-switcher-state-row",children:r("shell.hostDiscoveryRefreshing")}):null,_.localHostDiscovery.status==="failed"?t.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:r("shell.hostDiscoveryFailed")}):null]}),o?t.jsxs("div",{className:"workbench-host-switcher-form",children:[t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("shell.hostSwitcherNameLabel")}),t.jsx("input",{value:c,onChange:T=>h(T.target.value),placeholder:r("shell.hostSwitcherNamePlaceholder")})]}),t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("shell.hostSwitcherUrlLabel")}),t.jsx("input",{value:f,onChange:T=>b(T.target.value),placeholder:r("shell.hostSwitcherUrlPlaceholder")})]}),t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("auth.username")}),t.jsx("input",{value:m,onChange:T=>I(T.target.value),autoComplete:"username"})]}),t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("auth.password")}),t.jsx("input",{type:"password",value:N,onChange:T=>j(T.target.value),autoComplete:"current-password"})]}),t.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{a(!1),S()},children:r("common.cancel")}),t.jsx("button",{type:"button",className:"primary-button",onClick:()=>{x()},children:r("shell.hostSwitcherSaveAction")})]})]}):t.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{a(!0),O(null)},children:[t.jsx($u,{}),r("shell.hostSwitcherAddAction")]})]}),document.body):null]})}function Fa(e,n){return[...e].sort((s,o)=>{if(s.id===n)return-1;if(o.id===n)return 1;const a=s.lastConnectedAt??s.updatedAt??s.createdAt;return(o.lastConnectedAt??o.updatedAt??o.createdAt).localeCompare(a)})}function _u(e){try{const n=new URL(e),s=n.pathname==="/"?"":n.pathname.replace(/\/+$/,"");return`${n.host}${s}`}catch{return e}}function Fu(e){try{const n=new URL(e).hostname.toLowerCase();return n==="localhost"||n==="127.0.0.1"||n==="::1"||n==="[::1]"?"local":/^10\./.test(n)||/^192\.168\./.test(n)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(n)?"lan":"remote"}catch{return"custom"}}function Ou(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Hu(e,n){return e instanceof Eo?e.code==="HOST_UNREACHABLE"?r("shell.hostSwitchUnreachable",{name:n}):r("shell.hostSwitchMissing"):r("shell.hostSwitchFailed")}function Uu(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function Oa(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Ha(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.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 $u(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function qu(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.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 Br={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function Gu({open:e,onClose:n,onCloned:s}){const{showToast:o}=Vn(),[a,c]=l.useState(!1),[h,f]=l.useState(Br),[b,m]=l.useState(!1),[I,N]=l.useState(!1),[j,M]=l.useState(null),[F,H]=l.useState(""),[P,w]=l.useState(""),[O,U]=l.useState(null),[se,X]=l.useState([]),[ee,_]=l.useState([]),L=a||I;l.useEffect(()=>{!e&&!a&&(f(Br),m(!1),M(null))},[a,e]);const y=l.useCallback(async D=>{N(!0),M(null);try{const x=await Pi(D);H(x.currentPath),w(x.currentPath),U(x.parentPath),X(x.roots),_(x.items),f(S=>({...S,parentPath:x.currentPath}))}catch(x){H(""),U(null),_([]),M(x instanceof Error?x.message:r("shell.importBrowserBrowseFailed"))}finally{N(!1)}},[]);function K(){a||(m(!1),M(null),f(Br),n())}function J(){m(!0),y(h.parentPath||void 0)}function E(){a||(m(!1),M(null))}async function ge(D){D.preventDefault(),await y(P)}function $(){f(D=>({...D,parentPath:F})),m(!1),M(null)}async function me(D){D.preventDefault();const x=h.repositoryUrl.trim(),S=h.parentPath.trim();if(!x){o({title:r("shell.cloneRepoRequired"),tone:"error"});return}if(!S){o({title:r("shell.clonePathRequired"),tone:"error"});return}c(!0);try{const Y=await rc({repositoryUrl:x,parentPath:S,directoryName:h.directoryName.trim()||void 0,name:h.name.trim()||void 0,auth:h.authMode==="none"?{mode:"none"}:h.authMode==="basic"?{mode:"basic",username:h.username.trim(),password:h.password}:{mode:"token",username:h.username.trim()||void 0,token:h.token}});await(s==null?void 0:s(Y)),f(Br),m(!1),o({title:r("shell.cloneSuccess"),description:Y.path,tone:"success"}),n()}catch(Y){o({title:Y instanceof Error?Y.message:r("shell.cloneFailed"),tone:"error"})}finally{c(!1)}}return t.jsxs(t.Fragment,{children:[t.jsx(Fe,{open:e,title:r("shell.cloneWorkspaceTitle"),description:r("shell.cloneWorkspaceHint"),onClose:K,children:t.jsxs("form",{className:"workbench-clone-form",onSubmit:D=>void me(D),children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneRepositoryLabel")}),t.jsx("input",{type:"text",value:h.repositoryUrl,placeholder:r("shell.cloneRepositoryPlaceholder"),onChange:D=>f(x=>({...x,repositoryUrl:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneParentPathLabel")}),t.jsxs("div",{className:"workbench-modal-inline-field",children:[t.jsx("input",{type:"text",value:h.parentPath,placeholder:r("shell.cloneParentPathPlaceholder"),onChange:D=>f(x=>({...x,parentPath:D.target.value}))}),t.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:J,children:r("shell.clonePickDirectory")})]})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneDirectoryNameLabel")}),t.jsx("input",{type:"text",value:h.directoryName,placeholder:r("shell.cloneDirectoryNamePlaceholder"),onChange:D=>f(x=>({...x,directoryName:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importNameLabel")}),t.jsx("input",{type:"text",value:h.name,placeholder:r("shell.importNamePlaceholder"),onChange:D=>f(x=>({...x,name:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneAuthModeLabel")}),t.jsxs("select",{value:h.authMode,onChange:D=>f(x=>({...x,authMode:D.target.value})),children:[t.jsx("option",{value:"none",children:r("shell.cloneAuthModeNone")}),t.jsx("option",{value:"basic",children:r("shell.cloneAuthModeBasic")}),t.jsx("option",{value:"token",children:r("shell.cloneAuthModeToken")})]})]}),h.authMode==="basic"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneUsernameLabel")}),t.jsx("input",{type:"text",value:h.username,placeholder:r("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:D=>f(x=>({...x,username:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.clonePasswordLabel")}),t.jsx("input",{type:"password",value:h.password,placeholder:r("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:D=>f(x=>({...x,password:D.target.value}))})]})]}):null,h.authMode==="token"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneUsernameLabel")}),t.jsx("input",{type:"text",value:h.username,placeholder:r("shell.cloneTokenUsernamePlaceholder"),onChange:D=>f(x=>({...x,username:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneTokenLabel")}),t.jsx("input",{type:"password",value:h.token,placeholder:r("shell.cloneTokenPlaceholder"),onChange:D=>f(x=>({...x,token:D.target.value}))})]})]}):null,t.jsx("p",{className:"workbench-import-hint",children:r("shell.cloneHint")}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:K,children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:a,children:a?r("shell.cloneSubmitting"):r("shell.cloneSubmit")})]})]})}),t.jsxs(Fe,{open:e&&b,title:r("shell.cloneBrowserTitle"),description:r("shell.cloneBrowserDescription"),onClose:E,children:[t.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ge,children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importBrowserCurrentPath")}),t.jsx("input",{type:"text",value:P,placeholder:r("shell.importPathPlaceholder"),onChange:D=>w(D.target.value)})]}),t.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:L||!O,onClick:()=>{O&&y(O)},children:r("shell.importBrowserOpenParent")}),t.jsx("button",{type:"submit",className:"secondary-button",disabled:L,children:r("shell.importBrowserOpenPath")})]})]}),t.jsxs("section",{className:"workbench-directory-browser-panel",children:[t.jsxs("div",{className:"workbench-directory-browser-section",children:[t.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),t.jsx("div",{className:"workbench-directory-browser-root-list",children:se.map(D=>t.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:L,onClick:()=>{y(D.path)},children:D.name},D.path))})]}),t.jsx("div",{className:"workbench-directory-browser-current-path",children:F}),j?t.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:j}):null,I?t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):ee.length>0?t.jsx("div",{className:"workbench-directory-browser-list",children:ee.map(D=>t.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:L,onClick:()=>{y(D.path)},children:[t.jsx("span",{className:"workbench-directory-browser-item-name",children:D.name}),t.jsx("span",{className:"workbench-directory-browser-item-path",children:D.path})]},D.path))}):t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:E,children:r("common.cancel")}),t.jsx("button",{type:"button",className:"primary-button",disabled:L||!F,onClick:$,children:r("shell.cloneBrowserSubmit")})]})]})]})}const zu="butler:inbox-updated";function xo(){typeof window>"u"||window.dispatchEvent(new Event(zu))}const Ua={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function gl({active:e,preferredWorkspaceId:n,preferredSessionId:s,creationRequestId:o=0,initialDraft:a=null,compactComposer:c=!1,composerOpen:h=!0,onComposerOpenChange:f}){const{showToast:b}=Vn(),[m,I]=l.useState(!1),[N,j]=l.useState(!1),[M,F]=l.useState([]),[H,P]=l.useState([]),[w,O]=l.useState(null),[U,se]=l.useState(null),[X,ee]=l.useState(Ua),[_,L]=l.useState(!1),y=l.useMemo(()=>qa(M,n,U),[U,n,M]),K=l.useMemo(()=>_?H:H.filter(x=>x.status!=="closed"),[H,_]);l.useEffect(()=>{e&&J()},[e,s]),l.useEffect(()=>{!e||w||ee(x=>{const S=za({projects:y,currentProjectId:x.projectId,preferredProjectId:U,preferredWorkspaceId:n});return S===x.projectId?x:{...x,projectId:S}})},[e,w,U,n,y]),l.useEffect(()=>{!e||o<=0||(E(void 0,n,a,U),f==null||f(!0))},[e,o,a,f,U,n]);async function J(){I(!0);try{const[x,S,Y]=await Promise.all([Mu(),ml(),s?Lu(s).catch(()=>null):Promise.resolve(null)]),T=(Y==null?void 0:Y.target.project.id)??null;se(T),F(x.items),P(S.items),w||E(x.items,n,o>0?a:null,T)}catch(x){b({title:r("shell.butlerInboxLoadFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{I(!1)}}function E(x=M,S=n,Y=a,T=U){var q,te;const re=qa(x,S,T);O(null),ee({...Ua,projectId:za({projects:re,preferredProjectId:T,preferredWorkspaceId:S}),title:((q=Y==null?void 0:Y.title)==null?void 0:q.trim())??"",content:((te=Y==null?void 0:Y.content)==null?void 0:te.trim())??""})}function ge(x){O(x.id),ee({projectId:x.projectId,itemType:x.itemType,title:x.title,content:x.content,status:x.status}),c&&(f==null||f(!0))}async function $(x){x.preventDefault(),j(!0);try{w?(await _a(w,{projectId:X.projectId,itemType:X.itemType,title:X.title,content:X.content,status:X.status,priority:"medium"}),b({title:r("shell.butlerInboxUpdated"),tone:"success"})):(await Ru({projectId:X.projectId,itemType:X.itemType,title:X.title,content:X.content,status:X.status,priority:"medium"}),b({title:r("shell.butlerInboxCreated"),tone:"success"})),xo(),await J(),E(),c&&(f==null||f(!1))}catch(S){b({title:r("shell.butlerInboxSaveFailed"),description:S instanceof Error?S.message:void 0,tone:"error"})}finally{j(!1)}}async function me(x){j(!0);try{await Wu(x),b({title:r("shell.butlerInboxDeleted"),tone:"success"}),xo(),await J(),w===x&&E()}catch(S){b({title:r("shell.butlerInboxDeleteFailed"),description:S instanceof Error?S.message:void 0,tone:"error"})}finally{j(!1)}}async function D(x,S){if(x.status!==S){j(!0);try{await _a(x.id,{status:S}),b({title:r("shell.butlerInboxUpdated"),tone:"success"}),xo(),await J(),w===x.id&&ee(Y=>({...Y,status:S}))}catch(Y){b({title:r("shell.butlerInboxSaveFailed"),description:Y instanceof Error?Y.message:void 0,tone:"error"})}finally{j(!1)}}}return t.jsxs("div",{className:"workspace-inbox-modal",children:[c?null:t.jsx("section",{className:"workspace-inbox-panel",children:t.jsx($a,{selectableProjects:y,formState:X,saving:N,editingItemId:w,useMobilePicker:!1,onProjectChange:x=>{ee(S=>({...S,projectId:x}))},onItemTypeChange:x=>{ee(S=>({...S,itemType:x}))},onStatusChange:x=>{ee(S=>({...S,status:x}))},onTitleChange:x=>{ee(S=>({...S,title:x}))},onContentChange:x=>{ee(S=>({...S,content:x}))},onCancel:()=>E(),onSubmit:$})}),t.jsxs("section",{className:"workspace-inbox-panel",children:[t.jsxs("header",{className:"workspace-inbox-panel-header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:r("shell.butlerInboxListTitle")}),t.jsx("p",{children:r("shell.butlerInboxListDescription")})]}),t.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[t.jsx("input",{type:"checkbox",checked:_,onChange:x=>L(x.target.checked)}),t.jsx("span",{children:r("shell.butlerInboxShowClosedAction")})]})]}),m?t.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxLoading")}):null,!m&&K.length===0?t.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxEmpty")}):null,!m&&K.length>0?t.jsx("div",{className:"workspace-inbox-list",children:K.map(x=>t.jsxs("article",{className:"workspace-inbox-item",children:[t.jsxs("div",{className:"workspace-inbox-item-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:x.title}),t.jsx("p",{children:x.projectName})]}),t.jsxs("div",{className:"workspace-inbox-item-badges",children:[t.jsx("span",{className:"workspace-inbox-badge",children:Ka(x.status)}),t.jsx("span",{className:"workspace-inbox-badge",children:Ju(x.itemType)})]})]}),t.jsx("p",{className:"workspace-inbox-item-content",children:x.content}),t.jsxs("div",{className:"workspace-inbox-item-footer",children:[t.jsx("span",{children:Zu(x.updatedAt)}),t.jsxs("div",{className:"workspace-inbox-item-actions",children:[t.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":r("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(S=>{const Y=x.status===S;return t.jsx("button",{type:"button",className:"secondary-button","data-active":Y,disabled:N,onClick:()=>{D(x,S)},children:Ka(S)},`${x.id}:${S}`)})}),t.jsx("button",{type:"button",className:"secondary-button",disabled:N,onClick:()=>ge(x),children:r("shell.butlerInboxEditAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:N,onClick:()=>{me(x.id)},children:r("shell.butlerInboxDeleteAction")})]})]})]},x.id))}):null]}),c?t.jsx(Fe,{open:e&&h,title:w?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle"),description:r("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{f==null||f(!1),E()},children:t.jsx("div",{className:"workspace-inbox-composer-modal-body",children:t.jsx($a,{selectableProjects:y,formState:X,saving:N,editingItemId:w,useMobilePicker:!0,onProjectChange:x=>{ee(S=>({...S,projectId:x}))},onItemTypeChange:x=>{ee(S=>({...S,itemType:x}))},onStatusChange:x=>{ee(S=>({...S,status:x}))},onTitleChange:x=>{ee(S=>({...S,title:x}))},onContentChange:x=>{ee(S=>({...S,content:x}))},onCancel:()=>{f==null||f(!1),E()},onSubmit:$})})}):null]})}function $a(e){const n=e.selectableProjects.map(a=>({value:a.id,label:a.name})),s=[{value:"task",label:r("shell.butlerInboxTypeTask")},{value:"bug",label:r("shell.butlerInboxTypeBug")},{value:"feature",label:r("shell.butlerInboxTypeFeature")},{value:"change",label:r("shell.butlerInboxTypeChange")}],o=[{value:"pending",label:r("shell.butlerInboxStatusPending")},{value:"in_progress",label:r("shell.butlerInboxStatusInProgress")},{value:"closed",label:r("shell.butlerInboxStatusClosed")}];return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"workspace-inbox-panel-header",children:[t.jsx("h3",{children:e.editingItemId?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle")}),t.jsx("p",{children:r("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?t.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxProjectsEmpty")}):t.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[t.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?t.jsxs(t.Fragment,{children:[t.jsx(yo,{label:r("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:n,disabled:e.saving,onChange:e.onProjectChange}),t.jsx(yo,{label:r("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:s,disabled:e.saving,onChange:e.onItemTypeChange}),t.jsx(yo,{label:r("shell.butlerInboxStatusLabel"),value:e.formState.status,options:o,disabled:e.saving,onChange:e.onStatusChange})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxProjectLabel")}),t.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:a=>e.onProjectChange(a.target.value),children:e.selectableProjects.map(a=>t.jsx("option",{value:a.id,children:a.name},a.id))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxTypeLabel")}),t.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:a=>e.onItemTypeChange(a.target.value),children:[t.jsx("option",{value:"task",children:r("shell.butlerInboxTypeTask")}),t.jsx("option",{value:"bug",children:r("shell.butlerInboxTypeBug")}),t.jsx("option",{value:"feature",children:r("shell.butlerInboxTypeFeature")}),t.jsx("option",{value:"change",children:r("shell.butlerInboxTypeChange")})]})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxStatusLabel")}),t.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:a=>e.onStatusChange(a.target.value),children:[t.jsx("option",{value:"pending",children:r("shell.butlerInboxStatusPending")}),t.jsx("option",{value:"in_progress",children:r("shell.butlerInboxStatusInProgress")}),t.jsx("option",{value:"closed",children:r("shell.butlerInboxStatusClosed")})]})]})]})}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxTitleLabel")}),t.jsx("input",{value:e.formState.title,placeholder:r("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:a=>e.onTitleChange(a.target.value)})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxContentLabel")}),t.jsx("textarea",{rows:4,value:e.formState.content,placeholder:r("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:a=>e.onContentChange(a.target.value)})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?r("shell.butlerInboxCancelEditAction"):r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?r("shell.butlerInboxUpdateAction"):r("shell.butlerInboxCreateAction")})]})]})]})}function yo({label:e,value:n,options:s,disabled:o,onChange:a}){const[c,h]=l.useState(!1),f=s.find(b=>b.value===n)??s[0]??null;return l.useEffect(()=>{if(!c)return;function b(m){m.key==="Escape"&&h(!1)}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[c]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[t.jsx("span",{children:e}),t.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":c,disabled:o||s.length===0,onClick:()=>h(!0),children:[t.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(f==null?void 0:f.label)??""}),t.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:t.jsx(Xu,{expanded:c})})]})]}),t.jsx(Ku,{open:c,title:e,options:s,selectedValue:n,onClose:()=>h(!1),onSelect:b=>{a(b),h(!1)}})]})}function Ku({open:e,title:n,options:s,selectedValue:o,onClose:a,onSelect:c}){return e?t.jsx(oc,{open:e,title:n,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:a,children:t.jsx(ac,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":n,children:s.map(h=>{const f=h.value===o;return t.jsx(ic,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":f,selected:f,trailing:t.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:f?t.jsx(Yu,{}):null}),onClick:()=>c(h.value),children:t.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[t.jsx("strong",{children:h.label}),h.description?t.jsx("span",{children:h.description}):null]})},h.value)})})}):null}function Fp({open:e,preferredWorkspaceId:n,preferredSessionId:s,creationRequestId:o=0,initialDraft:a=null,onClose:c,compactComposer:h=!1}){const[f,b]=l.useState(0),[m,I]=l.useState(!h);return l.useEffect(()=>{e||I(!h)},[h,e]),t.jsx(Fe,{open:e,title:r("shell.butlerInboxModalTitle"),description:r("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!h,headerActions:h?t.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":r("shell.butlerInboxCreateAction"),title:r("shell.butlerInboxCreateAction"),onClick:()=>{b(N=>N+1),I(!0)},children:t.jsx(Vu,{})}):void 0,onClose:c,children:t.jsx(gl,{active:e,preferredWorkspaceId:n,preferredSessionId:s,creationRequestId:Math.max(o,f),initialDraft:a,compactComposer:h,composerOpen:m,onComposerOpenChange:I})})}function qa(e,n,s){return[...e].filter(o=>o.lifecycleStatus!=="archived").sort((o,a)=>{const c=Ga(o,n,s),h=Ga(a,n,s);return c!==h?h-c:o.name.localeCompare(a.name,"zh-Hans-CN")})}function Ga(e,n,s){return s&&e.id===s?2:n&&e.workspaceId===n?1:0}function za({projects:e,currentProjectId:n,preferredProjectId:s,preferredWorkspaceId:o}){var c;if(n&&e.some(h=>h.id===n))return n;if(s&&e.some(h=>h.id===s))return s;const a=o?e.find(h=>h.workspaceId===o):null;return(a==null?void 0:a.id)||((c=e[0])==null?void 0:c.id)||""}function Vu(){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[t.jsx("path",{d:"M12 5v14"}),t.jsx("path",{d:"M5 12h14"})]})}function Xu({expanded:e}){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:t.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Yu(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.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 Ju(e){switch(e){case"bug":return r("shell.butlerInboxTypeBug");case"feature":return r("shell.butlerInboxTypeFeature");case"change":return r("shell.butlerInboxTypeChange");case"task":default:return r("shell.butlerInboxTypeTask")}}function Ka(e){switch(e){case"in_progress":return r("shell.butlerInboxStatusInProgress");case"closed":return r("shell.butlerInboxStatusClosed");case"pending":default:return r("shell.butlerInboxStatusPending")}}function Zu(e){return new Date(e).toLocaleString()}function Qu({open:e,onClose:n,onImported:s}){const{showToast:o}=Vn(),[a,c]=l.useState(!1),[h,f]=l.useState(!1),[b,m]=l.useState(!1),[I,N]=l.useState(null),[j,M]=l.useState(""),[F,H]=l.useState(""),[P,w]=l.useState(null),[O,U]=l.useState([]),[se,X]=l.useState([]),[ee,_]=l.useState(!1),[L,y]=l.useState(""),K=a||h||b,J=l.useCallback(async S=>{c(!0),N(null);try{const Y=await Pi(S);M(Y.currentPath),H(Y.currentPath),w(Y.parentPath),U(Y.roots),X(Y.items)}catch(Y){M(""),w(null),X([]),N(Y instanceof Error?Y.message:r("shell.importBrowserBrowseFailed"))}finally{c(!1)}},[]);l.useEffect(()=>{if(!e){_(!1),y(""),N(null);return}J(j||void 0)},[J,e]);function E(){K||(_(!1),y(""),n())}async function ge(S){S.preventDefault(),await J(F)}function $(){!j||K||(y(""),_(!0))}function me(){h||(_(!1),y(""))}async function D(S){S==null||S.preventDefault();const Y=L.trim();if(!(!j||!Y||K)){f(!0),N(null);try{const T=await cc({parentPath:j,directoryName:Y});o({title:r("shell.importBrowserCreateDirectorySuccess"),description:T.path,tone:"success"}),_(!1),y(""),await J(T.path)}catch(T){const re=T instanceof Error?T.message:r("shell.importBrowserCreateDirectoryFailed");N(re),o({title:re,tone:"error"})}finally{f(!1)}}}async function x(){const S=j.trim();if(!(!S||K)){m(!0),N(null);try{const Y=await lc({path:S});o({title:r("shell.importSuccess"),description:Y.path,tone:"success"}),n(),Promise.resolve().then(()=>s==null?void 0:s(Y)).catch(T=>{o({title:T instanceof Error?T.message:r("shell.navigationLoadFailed"),tone:"error"})})}catch(Y){o({title:Y instanceof Error?Y.message:r("shell.importFailed"),tone:"error"})}finally{m(!1)}}}return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{open:e,title:r("shell.importBrowserTitle"),description:r("shell.importBrowserDescription"),onClose:E,children:[t.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ge,children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importBrowserCurrentPath")}),t.jsx("input",{type:"text",value:F,placeholder:r("shell.importPathPlaceholder"),onChange:S=>H(S.target.value)})]}),t.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:K||!P,onClick:()=>{P&&J(P)},children:r("shell.importBrowserOpenParent")}),t.jsx("button",{type:"submit",className:"secondary-button",disabled:K,children:r("shell.importBrowserOpenPath")}),t.jsx("button",{type:"button",className:"secondary-button",disabled:K||!j,onClick:$,children:r("shell.importBrowserCreateDirectory")})]})]}),t.jsxs("section",{className:"workbench-directory-browser-panel",children:[t.jsxs("div",{className:"workbench-directory-browser-section",children:[t.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),t.jsx("div",{className:"workbench-directory-browser-root-list",children:O.map(S=>t.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:K,onClick:()=>{J(S.path)},children:S.name},S.path))})]}),t.jsx("div",{className:"workbench-directory-browser-current-path",children:j}),I?t.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:I}):null,a?t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):se.length>0?t.jsx("div",{className:"workbench-directory-browser-list",children:se.map(S=>t.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:K,onClick:()=>{J(S.path)},children:[t.jsx("span",{className:"workbench-directory-browser-item-name",children:S.name}),t.jsx("span",{className:"workbench-directory-browser-item-path",children:S.path})]},S.path))}):t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:E,children:r("common.cancel")}),t.jsx("button",{type:"button",className:"primary-button",disabled:K||!j,onClick:()=>{x()},children:b?r("shell.importSubmitting"):r("shell.importBrowserSubmit")})]})]}),t.jsx(Fe,{open:e&&ee,title:r("shell.importBrowserCreateDirectoryTitle"),description:r("shell.importBrowserCreateDirectoryDescription"),onClose:me,children:t.jsxs("form",{className:"workbench-rename-form",onSubmit:S=>void D(S),children:[t.jsx("div",{className:"workbench-directory-browser-current-path",children:j}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importBrowserCreateDirectoryLabel")}),t.jsx("input",{type:"text",value:L,placeholder:r("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:S=>y(S.target.value)})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:h,onClick:me,children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:h||!L.trim(),children:h?r("shell.importBrowserCreatingDirectory"):r("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function eh({onOpenSoftwareUpdate:e}){var o;const n=Bo(a=>a.platform),s=nc(a=>a.latestState);return n!=="desktop"||!(s!=null&&s.hasUpdate)?null:t.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((o=s.manifest)==null?void 0:o.version)??r("settings.releaseUpdateReady"),onClick:e,children:t.jsx("span",{className:"workbench-nav-update-badge-label",children:r("settings.releaseUpdateBadge")})})}const Va="workbench.left.width",Xa="workbench.right.width",Ya="workbench.left.collapsed",Ja="workbench.right.collapsed",Dr="workbench.last.session.path",vo="workbench.workspace.selected.id",Za="workbench.notifications.seen_at",th=280,nh=320,Qa=240,ei=280,ti=520,ni=560,sh=200,So=20,$s=40,_r=5,rh=3e4,oh=12,si=60*1e3,ah=4e3,ri=220,oi=18,ih=6,ms="data-workbench-panel-resizing",Fr="data-workbench-window-resizing",lh=180,ch="workbench:focus-composer",dh=new Set(["starting","running","reconnecting","stale","unknown"]),uh=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],hh=["--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"],Te={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 kl(e,n){const s=e.getPropertyValue(n).trim();if(!s)return null;const o=Number.parseFloat(s);return Number.isFinite(o)?o:null}function fh(e){return Math.round(e*100)/100}function ph(e,n){const s=n.getBoundingClientRect();if(s.width<=0||s.height<=0)return null;const o=window.getComputedStyle(n);return o.display==="none"||o.visibility==="hidden"?null:s.top-e.top+s.height/2}function yn(e,n){const s=e.getBoundingClientRect(),a=Array.from(e.querySelectorAll(n)).map(c=>ph(s,c)).filter(c=>c!==null);return a.length===0?null:a.reduce((c,h)=>c+h,0)/a.length}function _t(e,n,s){const o=e.style.getPropertyValue(n).trim();if(s===null||!Number.isFinite(s)){o&&e.style.removeProperty(n);return}const a=`${fh(s)}px`;o!==a&&e.style.setProperty(n,a)}function Ft(e,n,s,o){return o===null?null:(kl(e,n)??0)+(s-o)}function ai(e){if(e)for(const n of hh)e.style.removeProperty(n)}function mh(e){return dh.has(e.runningState??"idle")||e.activityState==="running"}function bh(e,n){const s=[];for(const o of[...n].sort()){const a=e.get(o);!a||a.size===0||s.push(`${o}:${[...a].sort().join(",")}`)}return s.join("|")}function gh(e){var a,c;const n=((a=e.lastErrorCode)==null?void 0:a.trim())??"",s=((c=e.lastErrorDetail)==null?void 0:c.trim())??"",o=[n,s].filter(h=>h.length>0).join(" · ");return o?o.length<=ri?o:`${o.slice(0,ri-3)}...`:null}function kh(e,n,s){var c,h,f,b,m,I,N,j,M,F,H,P;const o=new Map(e.projects.map(w=>[w.id,w.workspaceId])),a=[];for(const w of s){const O=w.title.trim()||w.projectName;if(w.assistantState.lifecycleStage==="analyzed"&&!((c=w.assistantState.linkedSessionId)!=null&&c.trim())&&w.assistantState.lastAnalyzedAt){a.push({id:`todo-analysis-completed:${w.id}:${w.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:r("shell.globalNotificationTodoAnalyzedTitle",{title:O}),body:((h=w.assistantState.analysisSummary)==null?void 0:h.trim())||((f=w.assistantState.generatedPrompt)==null?void 0:f.trim())||w.content,routePath:Kn(w.workspaceId),workspaceId:w.workspaceId,createdAt:w.assistantState.lastAnalyzedAt});continue}w.assistantState.lifecycleStage==="failed"&&a.push({id:`todo-analysis-failed:${w.id}:${w.updatedAt}`,kind:"todo_analyze_failed",title:r("shell.globalNotificationTodoAnalyzeFailedTitle",{title:O}),body:((b=w.assistantState.lastError)==null?void 0:b.trim())||w.content,routePath:Kn(w.workspaceId),workspaceId:w.workspaceId,createdAt:w.updatedAt})}for(const w of n){const O=((m=w.sessionTitle)==null?void 0:m.trim())||w.projectName,U=w.updatedAt||w.lastAutomationAt||w.createdAt;if(w.status==="waiting_user"){a.push({id:`follow-up-waiting:${w.id}`,kind:"follow_up_waiting_user",title:r("shell.globalNotificationFollowUpWaitingTitle",{title:O}),body:((I=w.waitingReason)==null?void 0:I.trim())||((N=w.lastAutomationSummary)==null?void 0:N.trim())||w.objective,routePath:Ot(w.workspaceId,w.sessionId),workspaceId:w.workspaceId,createdAt:U});continue}if(w.status==="completed"){a.push({id:`follow-up-completed:${w.id}`,kind:"follow_up_completed",title:r("shell.globalNotificationFollowUpCompletedTitle",{title:O}),body:((j=w.lastAutomationSummary)==null?void 0:j.trim())||w.objective,routePath:Ot(w.workspaceId,w.sessionId),workspaceId:w.workspaceId,createdAt:U});continue}w.status==="failed"&&a.push({id:`follow-up-failed:${w.id}`,kind:"follow_up_failed",title:r("shell.globalNotificationFollowUpFailedTitle",{title:O}),body:((M=w.lastAutomationSummary)==null?void 0:M.trim())||((F=w.waitingReason)==null?void 0:F.trim())||w.objective,routePath:Ot(w.workspaceId,w.sessionId),workspaceId:w.workspaceId,createdAt:U})}for(const w of e.verifications){if(w.status!=="failed")continue;const O=w.projectId?o.get(w.projectId)??null:null,U=((H=w.targetRef)==null?void 0:H.trim())||w.verificationType;a.push({id:`verification-failed:${w.id}`,kind:"verification_failed",title:r("shell.globalNotificationVerificationFailedTitle",{title:U}),body:((P=w.summary)==null?void 0:P.trim())||r("shell.globalNotificationVerificationFailedFallback"),routePath:O?Kn(O):null,workspaceId:O,createdAt:w.finishedAt||w.startedAt||w.createdAt})}return a.sort((w,O)=>{const U=ii(w.kind)-ii(O.kind);return U!==0?U:Nn(O.createdAt)-Nn(w.createdAt)}).slice(0,oh)}function ii(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 wh(e){switch(e){case"follow_up_waiting_user":return r("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return r("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return r("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return r("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return r("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return r("shell.globalNotificationKindVerificationFailed");default:return r("shell.globalNotificationsPanelTitle")}}function Nn(e){if(!e)return 0;const n=new Date(e).getTime();return Number.isNaN(n)?0:n}function xh(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function yh(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function vh(e,n){const s=new Set,o=(e==null?void 0:e.currentBranch)??"",a=((e==null?void 0:e.local)??[]).slice().sort((f,b)=>Number(b.current)-Number(f.current)||f.name.localeCompare(b.name)).map(f=>({value:f.name,current:f.current,recommended:f.name===o})).filter(f=>!f.value||s.has(f.value)?!1:(s.add(f.value),!0)),c=((e==null?void 0:e.remote)??[]).map(f=>({value:f.name})).filter(f=>!f.value||s.has(f.value)?!1:(s.add(f.value),!0)),h=n.map(f=>({value:f.name})).filter(f=>!f.value||s.has(f.value)?!1:(s.add(f.value),!0));return{localBranches:a,remoteBranches:c,tags:h}}function Sh(e){return e.getBoundingClientRect()}function jh(e,n){return n?Nn(e.createdAt)>Nn(n):!0}function Nh(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function li(e,n){var h,f;const s=["/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 b of s){const m=ye(b,e),I=(h=m==null?void 0:m.params.workspaceId)==null?void 0:h.trim();if(I)return I}const o=Ys(e),a=(o==null?void 0:o.sessionId)??null;return!a||!ql(a)?null:((f=new URLSearchParams(n).get("workspaceId"))==null?void 0:f.trim())||null}function Ch(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function jo(e){return e==="mobile"?st():"/landing"}function Ys(e){var c,h,f;const n=ye("/workspaces/:workspaceId/sessions/:sessionId",e),s=(c=n==null?void 0:n.params.sessionId)==null?void 0:c.trim();if(s)return{sessionId:s,workspaceId:((h=n==null?void 0:n.params.workspaceId)==null?void 0:h.trim())??null};const o=ye("/sessions/:sessionId",e),a=(f=o==null?void 0:o.params.sessionId)==null?void 0:f.trim();return a?{sessionId:a,workspaceId:null}:null}function Ih(e){return!!(ye("/sessions",e)||ye("/workspaces/:workspaceId/sessions",e))}function ci(e){return!!Ys(e)}function Th(e){return!!(ye("/tools",e)||ye("/tools/files",e)||ye("/tools/git",e)||ye("/tools/processes",e)||ye("/workspaces/:workspaceId/tools",e)||ye("/workspaces/:workspaceId/tools/files",e)||ye("/workspaces/:workspaceId/tools/git",e)||ye("/workspaces/:workspaceId/tools/processes",e))}function Wo(e){return!!(ye("/terminals",e)||ye("/workspaces/:workspaceId/terminals",e))}function zr(e){return!!ye("/workspaces/:workspaceId/butler",e)}function Mh(e,n){return ye("/workspaces/:workspaceId/debug",e)?zi(n):ye("/workspaces/:workspaceId",e)?Ut(n):ye("/workspaces/:workspaceId/tools/files",e)||ye("/tools/files",e)?Vi(n):ye("/workspaces/:workspaceId/tools/git",e)||ye("/tools/git",e)?Xi(n):ye("/workspaces/:workspaceId/tools/processes",e)||ye("/tools/processes",e)?Yi(n):ye("/workspaces/:workspaceId/tools",e)||ye("/tools",e)?Ki(n):Wo(e)?ws(n):zr(e)?Kn(n):Zs(n)}function Rh(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const Eh=l.lazy(async()=>({default:(await Do(()=>import("./FileContextPanel-D_ghXJuW.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).FileContextPanel})),Wh=l.lazy(async()=>({default:(await Do(()=>import("./GitSidebar-D9f9Jxwr.js"),__vite__mapDeps([10,1,2,3,4,11,5,7,6,8,9]))).GitSidebar})),Ph=l.lazy(async()=>({default:(await Do(()=>import("./TerminalManagerPanel-DpyUTo9k.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9]))).TerminalManagerPanel}));function Ah(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Tt(e){return Ss(e)}function Lh(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function zs(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(Ah):[]}async function wl(e,n){const s=await wc(n,e);if(s.canStartSession===!1)throw new Error(s.limitations[0]??r("conversation.capabilityDenied"))}const xl=l.createContext(null);function Po(e){return iu(e)}function Ht(e){return e.isArchived===!0}function to(e){var n;return((n=e.parentSessionId)==null?void 0:n.trim())||null}function ra(e,n){return Ui(e,{getId:s=>s.sessionId,getParentId:to,compare:(s,o)=>ta(s,o,n)})}function yl(e){return e.filter(n=>{if(Ht(n))return!1;const s=to(n);if(!s)return!0;const o=e.find(a=>a.sessionId===s);return!o||!Ht(o)})}function Bh(e){return e.flatMap(n=>{const s=Lh(n);return s?[s,...$i(Tt(n))]:[]})}function Dh(e,n,s){const o=new Set(vn(Tt(e)).sort((a,c)=>ta(a.item,c.item,s)).slice(0,n).map(a=>a.item.sessionId));return{...e,children:vl(Tt(e),o)}}function vl(e,n){return e.flatMap(s=>{const o=vl(Tt(s),n);return!n.has(s.item.sessionId)&&o.length===0?[]:[{...s,children:o}]})}function Or(e,n,s,o=-1){if(e<=0)return 0;const a=o>=0?Math.max(n,o+1):n;return Math.min(e,Math.max(s??0,a))}function di(e,n){const s=Object.keys(e),o=Object.keys(n);return s.length!==o.length?!1:s.every(a=>e[a]===n[a])}function _h(e){const n=e.lastMessageAt??e.updatedAt;return n?new Date(n).toLocaleDateString():""}function Fh(e){return Zo(e)||e.syncStatus==="error"}function Oh(e){var o,a;if(!Fh(e))return null;const n=((o=e.lastErrorCode)==null?void 0:o.trim())??"",s=((a=e.lastErrorDetail)==null?void 0:a.replace(/\s+/g," ").trim())??"";return n&&s&&!s.includes(n)?`${n} · ${s}`:s||n||(e.syncStatus==="error"&&!Zo(e)?r("conversation.syncStatusError"):r("conversation.runtimeErrorTitle"))}function Hh(e,n=110){return e.length<=n?e:`${e.slice(0,Math.max(0,n-1)).trimEnd()}…`}function no(e,n="compact"){return kc(e,n)}const Uh={position:"relative",zIndex:0},$h={zIndex:1};function Sl(e,n,s,o){const a=[],c=(o==null?void 0:o.trim())||n.name;s&&a.push(c);const h=_h(e);return h&&a.push(h),a.join(" · ")||c}function ui(e,n){return tu("session-state-indicator",e,n)}function qh(e,n){return dl(e,n)}function hi(e,n){try{const s=window.localStorage.getItem(e),o=s?Number(s):Number.NaN;return Number.isFinite(o)?o:n}catch{return n}}function fi(e,n){try{const s=window.localStorage.getItem(e);return s===null?n:s==="true"}catch{return n}}function pi(e){var n;try{const s=(n=window.localStorage.getItem(e))==null?void 0:n.trim();return s||null}catch{return null}}function zn(e,n){try{window.localStorage.setItem(e,n)}catch{}}function Gh(e){try{window.localStorage.removeItem(e)}catch{}}function Hr(e,n,s){return Math.max(n,Math.min(s,e))}function Ur(e){const n=Number.parseFloat(e);return Number.isFinite(n)?n:0}function zh(e){const n=window.getComputedStyle(e),s=Ur(n.getPropertyValue("--desktop-macos-titlebar-height")),o=Ur(n.getPropertyValue("--workbench-header-min-height")),a=Ur(n.getPropertyValue("--workbench-macos-titlebar-padding-top")),c=Ur(n.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(s,o,40)+a+c+8}function mi(e,n){const s=n.getBoundingClientRect();return e>=s.top&&e<=s.top+zh(n)}function Kh(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function Vh(){typeof window>"u"||window.dispatchEvent(new CustomEvent(ch))}function jl(e,n){const s=n==null?void 0:n.trim();if(!s)return null;for(const o of e){if(o.workspace.id===s)return o;const a=jl(o.children,s);if(a)return a}return null}function Xh(e,n){const s=n==null?void 0:n.trim();if(!s)return null;for(const o of e){const a=jl(o.childWorktrees,s);if(a)return a}return null}function bi(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(n=>{var s;return n.collapsed===!0&&((s=n.workspace)==null?void 0:s.id)}).map(n=>n.workspace.id)}function No(e,n){const s=new Set(n);return{items:e.map(o=>({workspace:o.workspace,sessions:o.sessions,childWorktrees:o.childWorktrees,collapsed:s.has(o.workspace.id)}))}}function Nl(e,n,s){return e.map(o=>{const a=yl(o.sessions);return{workspace:o.workspace,meta:o.meta,visibleSessions:a,archivedSessions:o.sessions.filter(c=>Ht(c)&&!to(c)),visibleSessionTree:ra(a,s).filter(c=>!n.has(c.item.sessionId)&&!qo(Tt(c),h=>n.has(h.sessionId))),children:Nl(o.children,n,s)}})}function Ao(e){return e.flatMap(n=>[n.workspace.id,...Ao(n.children)])}function Ks(e){return e.flatMap(n=>[...n.visibleSessionTree,...Ks(n.children)])}function Yh(e,n){if(!n)return null;for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,visibleSessionTree:zs(s)};const o=Il(s.childWorktrees,n);if(o)return o}return null}function Cl(e,n){for(const s of e){const o=vn(s.visibleSessionTree).find(c=>c.item.sessionId===n);if(o)return o;const a=Cl(s.children,n);if(a)return a}return null}function Il(e,n){for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,visibleSessionTree:s.visibleSessionTree};const o=Il(s.children,n);if(o)return o}return null}function Jh(e,n){if(!n)return null;for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const o=Tl(s.childWorktrees,n);if(o)return o}return null}function gi(e,n){if(!n)return null;for(const s of e){if(s.workspace.id===n)return s.workspace;const o=Ml(s.childWorktrees,n);if(o)return o}return null}function Tl(e,n){for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const o=Tl(s.children,n);if(o)return o}return null}function Ml(e,n){for(const s of e){if(s.workspace.id===n)return s.workspace;const o=Ml(s.children,n);if(o)return o}return null}function Rl(e,n){for(const s of e){if(s.workspace.id===n)return[s.workspace.id];const o=Rl(s.children,n);if(o.length>0)return[s.workspace.id,...o]}return[]}function ki(e){return e.flatMap(n=>[n.workspace.id,...El(n.childWorktrees)])}function El(e){return e.flatMap(n=>[n.workspace.id,...El(n.children)])}function Zh(e,n=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(n.length>0)return n.join(" / ");const s=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&s.push(e.parentDisplayName),s.join(" / ")}function Qh(e,n,s,o){if(n===s)return e;const a=e.findIndex(m=>m.workspace.id===n),c=e.findIndex(m=>m.workspace.id===s);if(a<0||c<0)return e;const h=[...e],[f]=h.splice(a,1);if(!f)return e;const b=h.findIndex(m=>m.workspace.id===s);return b<0?e:(h.splice(o==="before"?b:b+1,0,f),h.every((m,I)=>{var N;return m.workspace.id===((N=e[I])==null?void 0:N.workspace.id)})?e:h)}function ef(e,n){if(!Array.isArray(e.items)||n.size===0)return e;let s=!1;const o=e.items.map(a=>{let c=!1;const h=a.sessions.map(b=>{const m=n.get(b.sessionId);return m===void 0||Ht(b)===m?b:(s=!0,c=!0,{...b,isArchived:m})}),f=Pl(a.childWorktrees??[],n,b=>{b&&(s=!0,c=!0)});return c?{...a,sessions:h,childWorktrees:f}:a});return s?{...e,items:o}:e}function tf(e,n){if(!(!Array.isArray(n.items)||e.size===0))for(const s of n.items){for(const o of s.sessions){const a=e.get(o.sessionId);a!==void 0&&Ht(o)===a&&e.delete(o.sessionId)}Al(e,s.childWorktrees??[])}}function nf(e,n,s){let o=!1;const a=e.map(c=>{if(c.workspace.id!==n.workspaceId){const{nodes:b,changed:m}=Ll(c.childWorktrees,n,s);return m?(o=!0,{...c,childWorktrees:b}):c}const h=c.sessions.findIndex(b=>b.sessionId===n.sessionId),f=h>=0?c.sessions.map((b,m)=>m===h?n:b):[n,...c.sessions];return o=!0,{...c,sessions:nr(f,s)}});return o?a:e}function sf(e,n,s){let o=!1;const a=e.map(c=>{let h=!1;const f=c.sessions.map(m=>m.sessionId!==n?m:(o=!0,h=!0,{...m,lastSeenAt:m.lastSeenAt&&m.lastSeenAt>s?m.lastSeenAt:s,activityState:m.activityState==="completed_unread"?"idle":m.activityState})),b=so(c.childWorktrees,m=>m.sessionId!==n?m:(o=!0,h=!0,{...m,lastSeenAt:m.lastSeenAt&&m.lastSeenAt>s?m.lastSeenAt:s,activityState:m.activityState==="completed_unread"?"idle":m.activityState}));return h?{...c,sessions:f,childWorktrees:b}:c});return o?a:e}function wi(e,n,s){let o=!1;const a=e.map(c=>{let h=!1;const f=c.sessions.map(m=>m.sessionId!==n||m.isArchived===s?m:(o=!0,h=!0,{...m,isArchived:s})),b=so(c.childWorktrees,m=>m.sessionId!==n||m.isArchived===s?m:(o=!0,h=!0,{...m,isArchived:s}));return h?{...c,sessions:f,childWorktrees:b}:c});return o?a:e}function xi(e,n,s){let o=!1;const a=e.map(c=>{let h=!1;const f=c.sessions.map(m=>m.sessionId!==n||m.isFavorite===!0===s?m:(o=!0,h=!0,{...m,isFavorite:s})),b=so(c.childWorktrees,m=>m.sessionId!==n||m.isFavorite===!0===s?m:(o=!0,h=!0,{...m,isFavorite:s}));return h?{...c,sessions:f,childWorktrees:b}:c});return o?a:e}function rf(e,n){return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function of(e){return e?e.slice(0,8):"--"}function yi(e,n,s){return s?e.includes(n)?e:[...e,n]:e.includes(n)?e.filter(o=>o!==n):e}function Wl(e,n){const s=e.filter(o=>n.has(o));return s.length===e.length?e:s}function Pl(e,n,s){return e.map(o=>{let a=!1;const c=o.sessions.map(f=>{const b=n.get(f.sessionId);return b===void 0||Ht(f)===b?f:(a=!0,{...f,isArchived:b})}),h=Pl(o.children,n,f=>{f&&(a=!0)});return s(a),a?{...o,sessions:c,children:h}:o})}function Al(e,n){for(const s of n){for(const o of s.sessions){const a=e.get(o.sessionId);a!==void 0&&Ht(o)===a&&e.delete(o.sessionId)}Al(e,s.children)}}function Ll(e,n,s){let o=!1;const a=e.map(c=>{if(c.workspace.id===n.workspaceId){const f=c.sessions.findIndex(m=>m.sessionId===n.sessionId),b=f>=0?c.sessions.map((m,I)=>I===f?n:m):[n,...c.sessions];return o=!0,{...c,sessions:nr(b,s)}}const h=Ll(c.children,n,s);return h.changed?(o=!0,{...c,children:h.nodes}):c});return{nodes:o?a:[...e],changed:o}}function af(e,n){return e.map(s=>({...s,sessions:nr(s.sessions,n),childWorktrees:na(s.childWorktrees,n)}))}function so(e,n){let s=!1;const o=e.map(a=>{let c=!1;const h=a.sessions.map(b=>{const m=n(b);return m!==b&&(c=!0,s=!0),m}),f=so(a.children,n);return f!==a.children&&(c=!0,s=!0),c?{...a,sessions:h,children:f}:a});return s?o:[...e]}function Lo(e){return`workspace-management.summary.${e}`}function Bl(e){return`git-sidebar.snapshot.${e}`}function Dl(e,n){const s=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!s,repoRoot:s,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function _l(e,n){const s=e.git.repoRoot??n.repoRoot??null;return{...e,workspaceId:n.id,name:n.name,path:n.path,git:{...e.git,isRepository:e.git.isRepository||!!s,repoRoot:s}}}function Fl(e,n){var a,c,h;const s=((a=n.status)==null?void 0:a.snapshot.repoRoot)??e.git.repoRoot,o=((c=n.status)==null?void 0:c.snapshot.branch)??((h=n.branches)==null?void 0:h.currentBranch)??e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:e.git.isRepository||!!s,repoRoot:s,currentBranch:o,error:null}}}function Ol({count:e,className:n="workbench-skeleton-lines"}){return t.jsx("div",{className:n,"aria-hidden":"true",children:Array.from({length:e},(s,o)=>t.jsx("span",{className:"skeleton-line"},o))})}function lf(){return t.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,n)=>t.jsxs("section",{className:"workbench-skeleton-card",children:[t.jsxs("div",{className:"workbench-skeleton-heading",children:[t.jsx("span",{className:"skeleton-line short"}),t.jsx("span",{className:"skeleton-line tiny"})]}),t.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(s,o)=>t.jsxs("div",{className:"workbench-skeleton-session",children:[t.jsx("span",{className:"workbench-skeleton-dot"}),t.jsx(Ol,{count:2,className:"workbench-skeleton-lines compact"})]},o))})]},n))})}function $r(){return t.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,n)=>t.jsxs("article",{className:"workbench-info-skeleton-card",children:[t.jsx("span",{className:"skeleton-line short"}),t.jsx(Ol,{count:3})]},n))})}function cf({side:e,collapsed:n}){const s=e==="left"?8.5:15.5,o=e==="left"?n?"12 9 15 12 12 15":"15 9 12 12 15 15":n?"12 9 9 12 12 15":"9 9 12 12 9 15";return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("line",{x1:s,y1:"4",x2:s,y2:"20"}),t.jsx("polyline",{points:o})]})}function vi({ariaLabel:e,side:n,collapsed:s,className:o="panel-icon-button",onClick:a}){return t.jsx("button",{className:o,type:"button","aria-label":e,title:e,onClick:a,children:t.jsx(cf,{side:n,collapsed:s})})}function Vs({expanded:e}){return t.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:t.jsx("polyline",{points:"6 9 12 15 18 9"})})}function df(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),t.jsx("polyline",{points:"7 10 12 15 17 10"}),t.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function uf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),t.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),t.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),t.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function hf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.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"}),t.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Hl(e){return t.jsx("div",{className:"workbench-notification-anchor",children:t.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.globalNotificationsAction"),title:r("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[t.jsx(hf,{}),e.unreadCount>0?t.jsx("span",{className:"workbench-notification-badge","aria-label":r("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function ff(e){const[n,s]=l.useState("notifications");l.useEffect(()=>{e.open&&s("notifications")},[e.open]);const o=l.useMemo(()=>e.notifications.filter(a=>e.showArchivedNotifications||!e.archivedNotificationIds.has(a.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return t.jsxs(Fe,{open:e.open,title:r("shell.globalNotificationsPanelTitle"),description:r("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[t.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":r("shell.globalNotificationsPanelTitle"),children:[t.jsx("button",{type:"button",className:n==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":n==="notifications",onClick:()=>s("notifications"),children:r("shell.globalNotificationsAction")}),t.jsx("button",{type:"button",className:n==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":n==="inbox",onClick:()=>s("inbox"),children:r("shell.butlerInboxAction")})]}),t.jsx("div",{className:"workbench-notification-content","data-tab":n,children:n==="notifications"?t.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.globalNotificationsAction"),children:[t.jsx("div",{className:"workbench-notification-toolbar",children:t.jsxs("label",{className:"workbench-notification-filter",children:[t.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:a=>e.onToggleShowArchivedNotifications(a.target.checked)}),t.jsx("span",{children:r("shell.globalNotificationsShowArchived")})]})}),o.length>0?t.jsx("div",{className:"workbench-notification-list",children:o.map(a=>{const c=e.archivedNotificationIds.has(a.id);return t.jsxs("article",{className:"workbench-notification-item","data-archived":c,children:[t.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(a)},children:[t.jsx("span",{className:"workbench-notification-item-kind",children:wh(a.kind)}),t.jsx("strong",{children:a.title}),t.jsx("p",{children:a.body})]}),t.jsxs("div",{className:"workbench-notification-item-side",children:[t.jsx("time",{children:Nh(a.createdAt)}),t.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(c){e.onUnarchiveNotification(a.id);return}e.onArchiveNotification(a.id)},children:c?r("shell.globalNotificationsRemoveArchiveAction"):r("shell.globalNotificationsArchiveAction")})]})]},a.id)})}):t.jsx("p",{className:"workbench-notification-empty",children:r("shell.globalNotificationsEmpty")})]}):t.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.butlerInboxAction"),children:t.jsx(gl,{active:e.open&&n==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),t.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:t.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:r("common.close")})})]})}function pf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function mf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"7"}),t.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function bf(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:t.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 gf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("path",{d:"M7 9l3 3-3 3"}),t.jsx("path",{d:"M13 15h4"})]})}function kf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),t.jsx("circle",{cx:"9",cy:"11",r:"1"}),t.jsx("circle",{cx:"15",cy:"11",r:"1"}),t.jsx("path",{d:"M8 15h8"}),t.jsx("path",{d:"M12 5V3"})]})}function wf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.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"}),t.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 Ul(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),t.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function xf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"18",cy:"6",r:"3"}),t.jsx("circle",{cx:"6",cy:"6",r:"3"}),t.jsx("circle",{cx:"18",cy:"18",r:"3"}),t.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),t.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function yf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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 vf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),t.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),t.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),t.jsx("path",{d:"M14 16l2 2 4-4"})]})}function Sf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),t.jsx("path",{d:"M10 12h8"}),t.jsx("path",{d:"M15 8l4 4-4 4"})]})}function jf({selected:e}){return e?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),t.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function $l({active:e,className:n}){return e?t.jsx("svg",{className:n,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:t.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):t.jsx("svg",{className:n,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:t.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function Nf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M3 7h18"}),t.jsx("path",{d:"M5 7l1 12h12l1-12"}),t.jsx("path",{d:"M9 11h6"}),t.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function Cf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M12 20h9"}),t.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 If(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M8 6V4h8v2"}),t.jsx("path",{d:"M6 6l1 14h10l1-14"}),t.jsx("path",{d:"M10 11v5"}),t.jsx("path",{d:"M14 11v5"})]})}function Tf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.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"}),t.jsx("path",{d:"M9 13h6"})]})}function Mf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.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"}),t.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function Rf({open:e,mode:n,keyword:s,codeWorkspaceId:o,codeResults:a,codeLoading:c,codeError:h,workspaceOptions:f,sessionResults:b,onClose:m,onModeChange:I,onKeywordChange:N,onCodeWorkspaceChange:j,onCodeSearch:M,onOpenSession:F}){const H=s.trim().length>0&&o.trim().length>0;return t.jsx(Fe,{open:e,title:r("shell.searchModalTitle"),description:r("shell.searchModalDescription"),onClose:m,children:t.jsxs("div",{className:"workbench-search-modal",children:[t.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":r("shell.searchModeLabel"),children:[t.jsx("button",{type:"button",className:n==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":n==="sessions",onClick:()=>I("sessions"),children:r("shell.searchModeSessions")}),t.jsx("button",{type:"button",className:n==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":n==="code",onClick:()=>I("code"),children:r("shell.searchModeCode")})]}),n==="sessions"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.searchKeywordLabel")}),t.jsx("input",{type:"text",value:s,placeholder:r("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:P=>N(P.target.value)})]}),t.jsx("div",{className:"workbench-search-results",children:s.trim().length===0?t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionHint")}):b.length>0?b.map(P=>{const w=ea(P.session.title,r("common.unknown"));return t.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>F(P.session.sessionId),children:[t.jsx("span",{className:"workbench-search-result-title",title:w.fullTitle,children:w.displayTitle}),t.jsxs("span",{className:"workbench-search-result-meta",children:[P.workspace.name," · ",no(P.session.provider,"full")]})]},P.session.sessionId)}):t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionEmpty")})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.searchWorkspaceLabel")}),t.jsx("select",{value:o,onChange:P=>j(P.target.value),children:f.map(P=>t.jsx("option",{value:P.id,children:P.name},P.id))})]}),t.jsxs("form",{className:"workbench-search-code-form",onSubmit:P=>{P.preventDefault(),M()},children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.searchKeywordLabel")}),t.jsx("input",{type:"text",value:s,placeholder:r("shell.searchCodePlaceholder"),autoFocus:!0,onChange:P=>N(P.target.value)})]}),t.jsx("button",{type:"submit",className:"primary-button",disabled:!H||c,children:c?r("common.loading"):r("shell.searchSubmit")})]}),t.jsxs("div",{className:"workbench-search-results",children:[h?t.jsx("p",{className:"status-text","data-tone":"error",children:h}):null,!h&&s.trim().length===0?t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeHint")}):null,!h&&s.trim().length>0&&!c&&a.length===0?t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeEmpty")}):null,a.map(P=>t.jsxs("div",{className:"workbench-search-result-item static",children:[t.jsx("span",{className:"workbench-search-result-title",children:P.name}),t.jsx("span",{className:"workbench-search-result-meta",children:P.path})]},`${P.path}-${P.kind}`))]})]})]})})}function Ef({menuKey:e,session:n,workspace:s,workspaceContext:o,isActive:a,isFavorite:c,menuOpen:h,menuAnchorPoint:f,showWorkspaceName:b,depth:m=0,showActions:I=!0,hasSubagents:N=!1,subagentListExpanded:j=!1,selectionMode:M=!1,selected:F=!1,onToggleSelect:H,onToggleSubagents:P,onOpen:w,onRename:O,onOpenContextMenu:U,onToggleFavorite:se,onArchive:X,onDelete:ee,onCloseMenu:_}){var te;const L=Cn(),y=Di(n.provider).supportsSessionDelete===!0,K=Po(n)?((te=n.subagentLabel)==null?void 0:te.trim())||r("shell.subagentBadge"):null,J=ea(n.title,r("common.unknown")),E=Oh(n),ge=E?Hh(E):null,$=nu(n),me=$?su("session-activity-badge",n):null,D=Qo(n),x=lu(n),S=l.useRef(null),[Y,T]=l.useState(null);l.useLayoutEffect(()=>{if(L.isDesktop||!h||!f||typeof window>"u"){T(null);return}const z=()=>{var pe,de;const ae=ku(f,{width:((pe=S.current)==null?void 0:pe.offsetWidth)??0,height:((de=S.current)==null?void 0:de.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:y&&ee?216:168});T({position:"fixed",top:`${Math.round(ae.top)}px`,left:`${Math.round(ae.left)}px`,width:`${Math.round(ae.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(ae.maxHeight)}px`,transformOrigin:ae.transformOrigin})};return z(),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0),()=>{window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}},[f,h,L.isDesktop]);async function re(){await Rc([{id:`rename:${n.sessionId}`,label:r("shell.renameAction"),onSelect:O},{id:`favorite:${n.sessionId}`,label:c?r("shell.unfavoriteAction"):r("shell.favoriteAction"),onSelect:se},{id:`archive:${n.sessionId}`,label:r("shell.archiveAction"),onSelect:X},...y&&ee?[{id:`delete:${n.sessionId}`,label:r("shell.deleteSessionAction"),onSelect:ee}]:[]])}const q=!L.isDesktop&&h&&typeof document<"u"?Zr.createPortal(t.jsxs("div",{ref:S,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":r("shell.sessionMoreAction"),onClick:z=>z.stopPropagation(),style:Y??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{O(),_()},children:[t.jsx(Cf,{}),t.jsx("span",{children:r("shell.renameAction")})]}),t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{se(),_()},children:[t.jsx($l,{active:c}),t.jsx("span",{children:c?r("shell.unfavoriteAction"):r("shell.favoriteAction")})]}),t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{X(),_()},children:[t.jsx(Nf,{}),t.jsx("span",{children:r("shell.archiveAction")})]}),y&&ee?t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{ee(),_()},children:[t.jsx(If,{}),t.jsx("span",{children:r("shell.deleteSessionAction")})]}):null]}),document.body):null;return t.jsxs("article",{className:"workbench-session-card","data-active":a,"data-depth":m,"data-subagent":Po(n),"data-workspace-tone":o.tone,"data-worktree-depth":o.depth,"data-has-subagents":N,"data-selecting":M,"data-selected":F,style:Qt(o),onContextMenu:z=>{if(!(M||!I||!U)){if(z.preventDefault(),z.stopPropagation(),L.isDesktop){re();return}U({x:z.clientX,y:z.clientY})}},children:[t.jsxs("div",{className:"workbench-session-main",children:[M?t.jsx("span",{className:"workbench-session-selection-indicator","data-selected":F,"aria-hidden":"true",children:t.jsx(jf,{selected:F})}):N?t.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:$h,"data-indicator-variant":qh(n,{hasSubagents:!0,isActive:a}),"aria-label":j?r("shell.subagentCollapse"):r("shell.subagentExpand"),title:j?r("shell.subagentCollapse"):r("shell.subagentExpand"),"aria-expanded":j,onClick:z=>{z.stopPropagation(),P==null||P()},children:[t.jsx("span",{className:ui(n,{hasSubagents:!0,isActive:a}),"data-activity-source":n.activitySource,"aria-hidden":"true"}),t.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:t.jsx(Vs,{expanded:j})})]}):t.jsx("span",{className:ui(n,{isActive:a}),"data-activity-source":n.activitySource,"aria-hidden":"true"}),t.jsx("button",{type:"button",className:"workbench-session-link",style:N?Uh:void 0,"data-active":a,"aria-pressed":M?F:void 0,onClick:M?H:w,onKeyDown:z=>{if(M||!I||!U||z.key!=="ContextMenu"&&!(z.shiftKey&&z.key==="F10"))return;if(z.preventDefault(),z.stopPropagation(),L.isDesktop){re();return}const ae=z.currentTarget.getBoundingClientRect();U({x:ae.right,y:ae.bottom})},children:t.jsxs("div",{className:"workbench-session-link-copy",children:[t.jsxs("div",{className:"session-title-row",children:[t.jsx("span",{className:"session-title",title:J.fullTitle,children:J.displayTitle}),K?t.jsx("span",{className:"session-subagent-badge",children:K}):null,x&&D?t.jsx("span",{className:`session-fork-badge ${D}`,children:x}):null]}),t.jsxs("div",{className:"session-meta-row",children:[t.jsx("span",{className:"session-meta",children:Sl(n,s,b,o.displayName)}),$&&me?t.jsx("span",{className:me,children:$}):null,t.jsx("span",{className:`session-provider-badge ${n.provider}`,children:no(n.provider)})]}),ge?t.jsx("div",{className:"session-error-row",title:E??void 0,children:t.jsx("span",{className:"session-error-text",children:ge})}):null]})})]}),q]})}function Si({workspaceGroups:e,workspaceVisualContextMap:n,sessionDisplaySortMode:s,favoriteSessions:o,favoriteSessionIds:a,activeWorkspaceId:c,isConversationActive:h,isTerminalActive:f,isButlerActive:b,isSearchOpen:m,navigationLoading:I,navigationError:N,activeSessionId:j,onRefreshNavigation:M,onSessionUpdated:F,onNavigateConversation:H,onNavigateTerminals:P,onNavigateButler:w,onOpenSearch:O,onOpenSettings:U,onSelectWorkspace:se,onToggleWorkspaceCollapse:X,onStartWorkspaceReorder:ee,onPreviewWorkspaceReorder:_,onCommitWorkspaceReorder:L,allowWorkspaceReorder:y,subscribeGitSnapshot:K,requestGitRefresh:J,subscribeWorkspaceManagementSnapshot:E,requestWorkspaceManagementRefresh:ge,onToggleFavoriteSession:$,onArchiveSession:me,onUnarchiveSession:D,workspaceManagementStateById:x,setWorkspaceManagementStateById:S,unreadNotificationCount:Y,notificationPanelOpen:T,onToggleNotificationPanel:re,onClose:q,onToggleCollapse:te}){var qn;const z=Qs(),ae=Cn(),pe=rl(ae),{showToast:de}=Vn(),He=Bo(d=>d),Me=((qn=Ei(He))==null?void 0:qn.name)??"",Mt=He.hosts.length+Wi(He).length>1&&Me.length>0,[v,ce]=l.useState(!1),[be,Q]=l.useState(!1),[rt,mt]=l.useState(!1),[Ue,nn]=l.useState([]),[ot,$t]=l.useState(null),[Le,sr]=l.useState(null),[at,rr]=l.useState(null),[Be,Xn]=l.useState(null),[Ne,qt]=l.useState(null),[it,js]=l.useState(null),[Rt,Gt]=l.useState(!1),[Ve,In]=l.useState(!1),[bt,Tn]=l.useState(""),[Ns,sn]=l.useState(""),[Yn,ke]=l.useState(""),[zt,We]=l.useState({localBranches:[],remoteBranches:[],tags:[]}),[Xe,$e]=l.useState(!1),[Cs,Ye]=l.useState(-1),[Mn,Rn]=l.useState(!1),[Jn,En]=l.useState(!1),[Et,Wn]=l.useState(null),[gt,Is]=l.useState(null),[ro,Pn]=l.useState(null),[oo,Kt]=l.useState(null),[An,kt]=l.useState(null),[rn,or]=l.useState(null),[Vt,on]=l.useState(null),[Zn,ar]=l.useState(null),[ao,Je]=l.useState(So),[wt,ve]=l.useState({}),[Qn,an]=l.useState({}),[Ln,ln]=l.useState([]),[cn,Xt]=l.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[Ze,xt]=l.useState(null),[yt,Yt]=l.useState(""),[dn,ir]=l.useState(null),[tt,Wt]=l.useState(null),[vt,Qe]=l.useState([]),[Bn,es]=l.useState(!1),[Ts,ts]=l.useState({}),[qe,nt]=l.useState(null),Ge=l.useRef(null),St=l.useRef(null),Pt=l.useRef(null),ns=l.useRef(new Map),un=l.useRef(null),hn=l.useRef(null),ct=l.useRef(null),lr=l.useMemo(()=>new Set(cn.expandedWorkspaceIds),[cn.expandedWorkspaceIds]),ss=l.useMemo(()=>new Set(cn.collapsedWorkspaceIds),[cn.collapsedWorkspaceIds]),Dn=qe!==null,jt=y&&ae.isDesktop&&ae.ui.osFamily==="macos",ze=l.useCallback(()=>{on(null),ar(null)},[]),cr=l.useCallback((d,p)=>{on(d),ar(p)},[]),Ce=gi(e,Ne)??((it==null?void 0:it.id)===Ne?it:null),Ms=Yn.trim().toLowerCase(),fn=l.useMemo(()=>[{key:"localBranches",label:r("shell.createWorktreeBaseRefLocalGroup"),items:zt.localBranches},{key:"remoteBranches",label:r("shell.createWorktreeBaseRefRemoteGroup"),items:zt.remoteBranches},{key:"tags",label:r("shell.createWorktreeBaseRefTagGroup"),items:zt.tags}].map(p=>({...p,items:p.items.filter(k=>Ms?k.value.toLowerCase().includes(Ms):!0)})).filter(p=>p.items.length>0),[Ms,zt]),lt=l.useMemo(()=>fn.flatMap(d=>d.items),[fn]),Rs=Ce?`create-worktree-base-ref-listbox-${Ce.id}`:"create-worktree-base-ref-listbox",dt=Jh(e,oo),Ke=dt?gn(dt.workspace):null,pn=l.useMemo(()=>Yh(e,tt),[tt,e]),rs=l.useMemo(()=>pn?Bh(pn.visibleSessionTree):[],[pn]),he=l.useMemo(()=>rs.map(d=>d.sessionId),[rs]),et=l.useMemo(()=>new Set(he),[he]),Ie=l.useMemo(()=>new Set(vt),[vt]),dr=he.length>0&&vt.length===he.length;l.useEffect(()=>{S(d=>{const p=ki(e),k=new Set(p),R={};Object.entries(d).forEach(([V,we])=>{k.has(V)&&(R[V]=we)}),p.forEach(V=>{const we=gi(e,V);if(!we)return;const De=Vr(Lo(V),si),Re=Vr(Bl(V),si),Oe=R[V];let Ct=_l((Oe==null?void 0:Oe.detail)??De??Dl(we),we);(Re!=null&&Re.status||Re!=null&&Re.branches)&&(Ct=Fl(Ct,{status:Re.status??null,branches:Re.branches??null})),R[V]={detail:Ct,loading:!1,error:null}});const W=Object.keys(d),oe=Object.keys(R);return W.length===oe.length&&oe.every(V=>d[V]===R[V])?d:R})},[e]);const os=l.useCallback(async d=>{await M(),await ae.bridge.showNotification(r("shell.importSuccess"),d.path)},[M,ae.bridge]),as=l.useCallback(async d=>{await M(),await ae.bridge.showNotification(r("shell.cloneSuccess"),d.path)},[M,ae.bridge]);function At(d){if(Ue.includes(d)){nn(k=>k.filter(R=>R!==d));return}nn(k=>[...k,d]),K(d),J(d),E(d),ge(d)}async function _n(d,p){if(Ts[d])return;const k=(p==null?void 0:p.trim().toUpperCase())??null;ts(R=>({...R,[d]:!0}));try{await Li(d,{backgroundColor:k}),await M()}catch(R){de({title:R instanceof Error?R.message:r("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{ts(R=>({...R,[d]:!1}))}}async function ur(){if(!(!ot||Le)){sr(ot.id);try{await vc(ot.id),nn(d=>d.filter(p=>p!==ot.id)),S(d=>{const p={...d};return delete p[ot.id],p}),$t(null),await M(),de({title:r("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(d){de({title:d instanceof Error?d.message:r("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{sr(null)}}}l.useEffect(()=>{if(!Vt)return;function d(p){const k=p.target;k instanceof HTMLElement&&k.closest(".workbench-session-menu")||ze()}return window.addEventListener("pointerdown",d),()=>{window.removeEventListener("pointerdown",d)}},[ze,Vt]),l.useEffect(()=>{if(!tt){vt.length>0&&Qe([]);return}if(!pn){Wt(null),Qe([]);return}Qe(d=>Wl(d,et))},[pn,et,tt,vt.length]),l.useEffect(()=>{tt&&he.length===0&&(Wt(null),Qe([]))},[he.length,tt]),l.useEffect(()=>{const d=new Set(ki(e)),p=new Set(e.flatMap(k=>Ao(k.childWorktrees)));nn(k=>k.filter(R=>d.has(R))),Xt(k=>({expandedWorkspaceIds:k.expandedWorkspaceIds.filter(R=>p.has(R)),collapsedWorkspaceIds:k.collapsedWorkspaceIds.filter(R=>p.has(R))})),$t(k=>k&&d.has(k.id)?k:null),ts(k=>Object.fromEntries(Object.entries(k).filter(([R,W])=>W&&d.has(R))))},[e]),l.useEffect(()=>{const d=o.findIndex(p=>p.session.sessionId===j);Je(p=>{const k=Or(o.length,So,p,d);return k===p?p:k})},[j,o]),l.useEffect(()=>{ve(d=>{const p={};for(const k of e){const R=zs(k),W=R.findIndex(oe=>oe.item.sessionId===j||bs([oe],j??"",V=>V.sessionId).length>0);p[k.workspace.id]=Or(R.length,$s,d[k.workspace.id],W);for(const oe of Ks(k.childWorktrees)){oe.item.sessionId===j||bs([oe],j??"",Re=>Re.sessionId).length>0;const V=oe.item.workspaceId;if(p[V]!==void 0)continue;const we=Ks(k.childWorktrees).filter(Re=>Re.item.workspaceId===V&&Re.depth===0),De=we.findIndex(Re=>Re.item.sessionId===j||bs([Re],j??"",Oe=>Oe.sessionId).length>0);p[V]=Or(we.length,$s,d[V],De)}}return di(d,p)?d:p})},[j,e]),l.useEffect(()=>{an(d=>{const p={};for(const k of e)for(const R of[...zs(k),...Ks(k.childWorktrees)])for(const W of vn(Tt(R))){const oe=Tt(W);if(oe.length===0)continue;const V=vn(oe),we=V.findIndex(De=>De.item.sessionId===j);p[W.item.sessionId]=Or(V.length,_r,d[W.item.sessionId],we)}return di(d,p)?d:p})},[j,e]),l.useEffect(()=>{if(!j)return;const d=e.flatMap(p=>[...bs(zs(p),j,k=>k.sessionId),...Ks(p.childWorktrees).flatMap(k=>bs([k],j,R=>R.sessionId))]);d.length!==0&&ln(p=>{const k=new Set(p);let R=!1;for(const W of d)k.has(W)||(k.add(W),R=!0);return R?Array.from(k):p})},[j,e]),l.useEffect(()=>{if(!c)return;const d=[];for(const p of e){const k=Rl(p.childWorktrees,c);k.length!==0&&d.push(...k)}d.length>0&&Xt(p=>{const k=new Set(p.expandedWorkspaceIds);let R=!1;for(const W of d)k.has(W)||(k.add(W),R=!0);return R?{expandedWorkspaceIds:Array.from(k),collapsedWorkspaceIds:p.collapsedWorkspaceIds}:p})},[c,e]),l.useEffect(()=>{if(!Ne){js(null),Gt(!1),In(!1),Tn(""),sn(""),ke(""),$e(!1),Ye(-1),Rn(!1),We({localBranches:[],remoteBranches:[],tags:[]}),En(!1),Wn(null);return}Gt(!1),Tn(""),sn(""),ke(""),$e(!1),Ye(-1),Rn(!1),We({localBranches:[],remoteBranches:[],tags:[]}),En(!1),Wn(null)},[Ne]),l.useEffect(()=>{const d=Ce;if(!Rt||!d)return;let p=!1;const k=d.id;return En(!0),Wn(null),Promise.all([Tc(k),Mc(k)]).then(([R,W])=>{p||We(vh(R,W))}).catch(()=>{p||(We({localBranches:[],remoteBranches:[],tags:[]}),Wn(r("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{p||En(!1)}),()=>{p=!0}},[Ce==null?void 0:Ce.id,Rt]),l.useLayoutEffect(()=>{if(!Xe||!Ge.current){Is(null),Pn(null);return}const d=()=>{const k=Ge.current;if(!k)return;const R=Sh(k);Is({top:R.bottom+8,left:R.left,width:R.width})};d();const p=k=>{var W,oe;const R=k.target;R instanceof Node&&((W=Ge.current)!=null&&W.contains(R)||(oe=St.current)!=null&&oe.contains(R)||($e(!1),Ye(-1)))};return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),window.addEventListener("pointerdown",p),()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),window.removeEventListener("pointerdown",p)}},[lt.length,Xe]),l.useLayoutEffect(()=>{if(!Xe||!St.current){Pn(null);return}const d=St.current,p=()=>{const R=Math.ceil(d.getBoundingClientRect().height);Pn(W=>W===R?W:R)};if(p(),typeof ResizeObserver>"u")return;const k=new ResizeObserver(()=>{p()});return k.observe(d),()=>{k.disconnect()}},[Xe,fn,Jn,Et]);function Es(){ce(!0)}function Ws(){Q(!0)}function is(){Gt(!1),Tn(""),sn(""),ke(""),$e(!1),Ye(-1),Rn(!1)}function mn(d,p){const k=d.getBoundingClientRect();return p<=k.top+k.height/2?"before":"after"}function Ae(){Pt.current!==null&&(cancelAnimationFrame(Pt.current),Pt.current=null),nt(null)}function ut(d){const p=(d==null?void 0:d.commit)??!1,k=(d==null?void 0:d.preserveClickSuppression)??!1,R=un.current,W=hn.current;un.current=null,hn.current=null,W==null||W(),R!=null&&R.dragging&&(Ae(),p&&L(),!k&&ct.current===R.workspaceId&&(ct.current=null))}function ls(d){if(ct.current===d){ct.current=null;return}X(d)}function Ps(d,p){if(p){ns.current.set(d,p);return}ns.current.delete(d)}function As(d,p){for(const[k,R]of ns.current){const W=R.getBoundingClientRect();if(d>=W.left&&d<=W.right&&p>=W.top&&p<=W.bottom)return{workspaceId:k,element:R}}return null}function ie(d,p){var we;if(!jt||d.button!==0)return;ut();const k=d.currentTarget,R={pointerId:d.pointerId,workspaceId:p,startX:d.clientX,startY:d.clientY,pointerTarget:k,dragging:!1};un.current=R,(we=k.setPointerCapture)==null||we.call(k,d.pointerId);const W=De=>{Ls(De)},oe=De=>{bn(De.pointerId,{commit:!0,preserveClickSuppression:!0})},V=De=>{bn(De.pointerId,{commit:!1,preserveClickSuppression:!1})};hn.current=()=>{k.removeEventListener("pointermove",W),k.removeEventListener("pointerup",oe),k.removeEventListener("pointercancel",V),window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",oe),window.removeEventListener("pointercancel",V)},k.addEventListener("pointermove",W),k.addEventListener("pointerup",oe),k.addEventListener("pointercancel",V),window.addEventListener("pointermove",W,{passive:!1}),window.addEventListener("pointerup",oe),window.addEventListener("pointercancel",V)}function Ls(d){const p=un.current;if(!p||p.pointerId!==d.pointerId)return;if(!p.dragging){if(Math.hypot(d.clientX-p.startX,d.clientY-p.startY)<ih)return;p.dragging=!0,ct.current=p.workspaceId,ee(),nt(p.workspaceId)}d.preventDefault();const k=As(d.clientX,d.clientY);!k||k.workspaceId===p.workspaceId||_(p.workspaceId,k.workspaceId,mn(k.element,d.clientY))}function bn(d,p){var R,W;const k=un.current;!k||k.pointerId!==d||((W=(R=k.pointerTarget).releasePointerCapture)==null||W.call(R,d),ut(p))}function cs(d){Ls(d)}function Fn(d){bn(d.pointerId,{commit:!0,preserveClickSuppression:!0})}function io(d){bn(d.pointerId,{commit:!1,preserveClickSuppression:!1})}function On(d,p){d.dataTransfer.effectAllowed="move",d.dataTransfer.setData("text/plain",p),ee(),Pt.current!==null&&cancelAnimationFrame(Pt.current),Pt.current=requestAnimationFrame(()=>{Pt.current=null,nt(p)})}function ht(d,p){const k=qe||d.dataTransfer.getData("text/plain");!k||k===p||(d.preventDefault(),d.dataTransfer.dropEffect="move",_(k,p,mn(d.currentTarget,d.clientY)))}function Pe(d){d.preventDefault()}function Hn(){Ae(),L()}l.useEffect(()=>()=>{ut()},[]);function hr(d){return Qn[d]??_r}function Bs(d){return Ln.includes(d)}function ft(d){return wt[d]??$s}function fr(){Je(d=>Math.min(o.length,d+So))}function Un(d,p){ve(k=>({...k,[d]:Math.min(p,(k[d]??$s)+$s)}))}function Nt(d){an(p=>({...p,[d]:(p[d]??_r)+_r}))}function pr(d){ln(p=>p.includes(d)?p.filter(k=>k!==d):[...p,d])}function $n(d,p){return ss.has(d)?!1:p||lr.has(d)}function Ds(d,p){const k=!$n(d,p);Xt(R=>{const W=R.expandedWorkspaceIds.filter(V=>V!==d),oe=R.collapsedWorkspaceIds.filter(V=>V!==d);return k?{expandedWorkspaceIds:[...W,d],collapsedWorkspaceIds:oe}:{expandedWorkspaceIds:W,collapsedWorkspaceIds:[...oe,d]}})}function lo(d){for(const p of e){const k=vn(ra(p.visibleSessions,s)).find(R=>R.item.sessionId===d)??Cl(p.childWorktrees,d);if(k)return Tt(k)}return[]}function mr(d,p){const k=gn(d);return t.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":k.tone,style:Qt(k),onClick:()=>Kt(d.id),children:[t.jsxs("span",{className:"workbench-archive-folder-main",children:[t.jsx(Tf,{}),t.jsx("span",{children:r("shell.archiveFolderLabel")})]}),t.jsx("span",{className:"workbench-section-counter",children:p.length})]})}function _s(){return t.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[t.jsx("span",{className:"workbench-workspace-batch-label",children:r("shell.batchSelectionMode")}),t.jsxs("span",{className:"workbench-workspace-batch-counter",children:[vt.length,"/",he.length]}),t.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:fo,children:dr?r("shell.clearSelectedSessions"):r("shell.selectAllSessions")}),t.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:vt.length===0||Bn,onClick:()=>{wr()},children:Bn?r("shell.batchArchiving"):r("shell.batchArchiveAction")}),t.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:uo,children:r("common.cancel")})]})}function br(d,p="workbench-workspace-actions"){return t.jsxs("div",{className:p,children:[t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.switchWorkspace"),title:r("shell.switchWorkspace"),"aria-pressed":c===d,onClick:()=>{se(d),q==null||q()},children:t.jsx(Sf,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.batchSelectSessions"),title:r("shell.batchSelectSessions"),onClick:()=>co(d),children:t.jsx(vf,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":r("shell.createSession"),title:r("shell.createSession"),onClick:()=>qt(d),children:t.jsx(pf,{})})]})}function gr(d){const p=d.visibleSessionTree,R=new Set(Ao(d.children)).has(c??""),W=d.workspace.id===c||R,oe=Dn||!$n(d.workspace.id,W),V=gn(d.workspace);return t.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":tt===d.workspace.id,"data-worktree-depth":d.meta.depth,"data-workspace-tone":"worktree",style:Qt(V),children:[t.jsxs("div",{className:"workbench-workspace-header minimal",children:[t.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":oe?r("shell.worktreeExpand"):r("shell.worktreeCollapse"),onClick:()=>Ds(d.workspace.id,W),children:[t.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:t.jsx(Vs,{expanded:!oe})}),t.jsxs("span",{children:[t.jsx("strong",{children:d.meta.displayName||d.workspace.name}),t.jsx("span",{className:"session-meta",children:d.meta.branchName})]})]}),tt===d.workspace.id?_s():br(d.workspace.id)]}),oe?null:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-session-list","data-workspace-tone":V.tone,style:Qt(V),children:[p.length===0?t.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):p.slice(0,ft(d.workspace.id)).map(we=>ds({node:we,workspace:d.workspace,workspaceContext:V,menuKeyPrefix:`worktree:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:tt===d.workspace.id,favoriteEnabled:!0})),p.length>ft(d.workspace.id)?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Un(d.workspace.id,p.length),children:r("shell.sessionExpandMore")}):null]}),d.children.length>0?t.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.children.map(we=>gr(we))}):null,mr(d.workspace,d.archivedSessions)]})]},d.workspace.id)}function ds(d){const{node:p,workspace:k,workspaceContext:R,menuKeyPrefix:W,showWorkspaceName:oe,selectionMode:V,favoriteEnabled:we,ancestorExpanded:De=!1,allowToggle:Re=p.depth===0,ancestorHasNextSiblings:Oe=[],hasNextSibling:Ct=!1,isFirstSibling:Lt=!1}=d,Se=p.item,kn=Tt(p),Bt=De||Bs(Se.sessionId),je=Bt&&Re,jr=je?Dh(p,hr(Se.sessionId),s):p,fs=Bt?Tt(jr):[],Nr=vn(kn).length,Cr=vn(fs).length,Ir=je&&Cr<Nr,Tr=p.depth>0?[...Oe,Ct]:[...Oe];return t.jsxs("div",{className:"workbench-session-tree-node",children:[t.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":p.depth},children:[p.depth>0?t.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[Oe.map((wn,xn)=>wn?t.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":xn+1}},`${Se.sessionId}:ancestor:${xn}`):null),t.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":Ct,"data-first":Lt,style:{"--workbench-session-tree-level":p.depth},children:t.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,t.jsx(Ef,{menuKey:`${W}:${Se.sessionId}`,session:Se,workspace:k,workspaceContext:R,isActive:Se.sessionId===j,isFavorite:we&&a.has(Se.sessionId),menuOpen:Vt===`${W}:${Se.sessionId}`,showWorkspaceName:oe,depth:p.depth,showActions:we,hasSubagents:Re&&kn.length>0,subagentListExpanded:Bt,selectionMode:V,selected:Ie.has(Se.sessionId),onToggleSelect:()=>ho(Se.sessionId),onToggleSubagents:()=>pr(Se.sessionId),onOpen:()=>{z(Ot(k.id,Se.sessionId)),q==null||q()},onRename:()=>Fs(Se,k),menuAnchorPoint:Vt===`${W}:${Se.sessionId}`?Zn:null,onOpenContextMenu:wn=>cr(`${W}:${Se.sessionId}`,wn),onToggleFavorite:()=>us(Se.sessionId),onArchive:()=>hs(Se.sessionId),onDelete:Di(Se.provider).supportsSessionDelete===!0?()=>{ze(),kt({session:Se,workspace:k})}:void 0,onCloseMenu:ze})]}),kn.length>0&&Bt?t.jsxs("div",{className:"workbench-subsession-list",children:[fs.map((wn,xn)=>ds({node:wn,workspace:k,workspaceContext:R,menuKeyPrefix:W,showWorkspaceName:oe,selectionMode:V,favoriteEnabled:we,ancestorExpanded:!0,allowToggle:!1,ancestorHasNextSiblings:Tr,hasNextSibling:xn<fs.length-1,isFirstSibling:xn===0})),Ir?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Nt(Se.sessionId),children:r("shell.subagentExpandMore")}):null]}):null]},Se.sessionId)}function co(d){ze(),Wt(d),Qe([])}function uo(){Wt(null),Qe([])}function ho(d){Qe(p=>rf(p,d))}function fo(){Qe(d=>d.length===he.length?[]:he)}async function po(d,p){rr(d),Xn(p);try{await wl(d,p),qt(null),z(Ji(d,p)),q==null||q()}catch(k){de({title:k instanceof Error?k.message:r("shell.startSessionFailed"),tone:"error"})}finally{rr(null),Xn(null)}}async function Jt(d){if(d.preventDefault(),!Ce||Ve)return;const p=bt.trim(),k=Ns.trim(),R=Yn.trim();if(!p){de({title:r("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!xh(p)){de({title:r("shell.createWorktreeBranchInvalid"),tone:"error"});return}In(!0);try{const W=await Sc({sourceWorkspaceId:Ce.id,branchName:p,displayName:k||void 0,baseRef:R||void 0});js(W.workspace),se(W.workspace.id),await M(),qt(W.workspace.id),is(),de({title:r("shell.createWorktreeSucceeded",{name:W.meta.displayName||W.workspace.name}),tone:"success"})}catch(W){de({title:W instanceof Error?W.message:r("shell.createWorktreeFailed"),tone:"error"})}finally{In(!1)}}async function us(d){const p=a.has(d);ze();try{await $(d),de({title:p?r("shell.favoriteRemoved"):r("shell.favoriteAdded"),tone:"success"})}catch(k){de({title:k instanceof Error?k.message:r("shell.favoriteToggleFailed"),tone:"error"})}}async function hs(d){ze();try{await me(d),de({title:r("shell.archiveAdded"),tone:"success"})}catch(p){de({title:p instanceof Error?p.message:r("shell.navigationLoadFailed"),tone:"error"})}}async function kr(){if(!An||rn)return;const{session:d,workspace:p}=An;or(d.sessionId),ze();try{await yc(d.sessionId),Qe(k=>k.filter(R=>R!==d.sessionId)),kt(null),j===d.sessionId&&z(p.id?Zs(p.id):st()),await M(),de({title:r("shell.deleteSessionSuccess"),tone:"success"})}catch(k){de({title:k instanceof Error?k.message:r("shell.deleteSessionFailed"),tone:"error"})}finally{or(null)}}async function wr(){if(!(vt.length===0||Bn)){ze(),es(!0);try{const d=[...vt],p=await Promise.allSettled(d.map(async W=>({sessionId:W,session:await Ai(W,!0)}))),k=[];let R=0;for(const W of p){if(W.status==="fulfilled"){k.push(W.value.sessionId),F(W.value.session);continue}R+=1}k.length>0&&(await M(),Qe(W=>W.filter(oe=>!k.includes(oe)))),R>0?de({title:k.length>0?r("shell.batchArchivePartialFailed"):r("shell.batchArchiveFailed"),tone:"error"}):de({title:r("shell.batchArchiveSuccess"),tone:"success"})}catch(d){de({title:d instanceof Error?d.message:r("shell.batchArchiveFailed"),tone:"error"})}finally{es(!1)}}}async function xr(d){ze();try{await D(d),de({title:r("shell.archiveRestored"),tone:"success"})}catch(p){de({title:p instanceof Error?p.message:r("shell.navigationLoadFailed"),tone:"error"})}}function Fs(d,p){ze(),xt({session:d,workspace:p}),Yt(d.title)}async function yr(d){if(d.preventDefault(),!Ze)return;const p=yt.trim();if(p){ir(Ze.session.sessionId);try{const k=await Bi(Ze.session.sessionId,p);F(k),xt(null),Yt(""),de({title:r("shell.renameSuccess"),tone:"success"})}catch(k){de({title:k instanceof Error?k.message:r("shell.renameFailed"),tone:"error"})}finally{ir(null)}}}const vr=o.slice(0,ao),Sr=vr.length<o.length;function gn(d){return n[d.id]??sa(d)}function Os(d,p,k,R,W=[]){var Bt;const oe=Ue.includes(d.id),V=x[d.id]??{detail:null,loading:!1,error:null},we=Le===d.id,De=Ts[d.id]===!0,Re=(Bt=V.detail)!=null&&Bt.git.remotes.length?V.detail.git.remotes.map(je=>`${je.name}: ${je.url}`).join(" · "):r("shell.manageWorkspaceNoRemote"),Oe=V.detail?hu(V.detail.codeComposition.items,r("shell.manageWorkspaceCodeCompositionOther")):[],Ct=Oe.length>0?pu(Oe):void 0,Lt=gn(d),Se=Zh(Lt,W),kn=[...W,Lt.displayName];return t.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":Lt.tone,"data-worktree-node":R,style:Qt(Lt),children:[t.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":oe,onClick:()=>At(d.id),children:[t.jsxs("span",{className:"workbench-manage-item-heading",children:[t.jsx(Vs,{expanded:oe}),t.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[t.jsx("strong",{children:Lt.displayName}),t.jsx("span",{className:"workbench-manage-item-tree-path",children:Se})]})]}),t.jsx("span",{className:"workbench-section-counter",children:p})]}),oe?t.jsxs("div",{className:"workbench-manage-item-body",children:[t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspacePathLabel")}),t.jsx("p",{className:"workbench-manage-detail-value",children:d.path})]}),R?t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsxs("div",{className:"workbench-manage-detail-header",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceColorLabel")}),t.jsxs("div",{className:"workbench-manage-color-actions",children:[t.jsx("div",{className:"workbench-manage-color-palette","aria-label":r("shell.manageWorkspaceColorLabel"),children:uh.map(je=>t.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":r("shell.manageWorkspaceColorSelectSwatch",{color:je}),"aria-pressed":d.backgroundColor===je,disabled:De,"data-selected":d.backgroundColor===je,style:{backgroundColor:je},onClick:()=>{_n(d.id,je)}},je))}),t.jsx("button",{type:"button",className:"ghost-button",disabled:De||!d.backgroundColor,onClick:()=>{_n(d.id,null)},children:r("shell.manageWorkspaceColorClearAction")})]})]}),t.jsx("p",{className:"workbench-manage-hint",children:d.backgroundColor??r("shell.manageWorkspaceColorUnset")})]}):null,V.loading&&V.detail===null?t.jsx("p",{className:"workbench-manage-status status-text",children:r("shell.manageWorkspaceLoading")}):null,V.error?t.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:V.error}):null,V.detail?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-manage-detail-block",children:t.jsxs("div",{className:"workbench-manage-detail-header",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitCommitCount")}),t.jsx("strong",{className:"workbench-manage-detail-accent",children:V.detail.git.commitCount??"--"})]})}),t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitInfoLabel")}),V.detail.git.isRepository?t.jsxs("div",{className:"workbench-manage-kv-list",children:[t.jsxs("div",{className:"workbench-manage-kv-item",children:[t.jsx("span",{children:r("shell.manageWorkspaceRepoRoot")}),t.jsx("span",{children:V.detail.git.repoRoot??"--"})]}),t.jsxs("div",{className:"workbench-manage-kv-item",children:[t.jsx("span",{children:r("shell.manageWorkspaceCurrentBranch")}),t.jsx("span",{children:V.detail.git.currentBranch??"--"})]}),t.jsxs("div",{className:"workbench-manage-kv-item",children:[t.jsx("span",{children:r("shell.manageWorkspaceRemoteLabel")}),t.jsx("span",{children:Re})]})]}):t.jsx("p",{className:"workbench-section-empty",children:V.detail.git.error??r("shell.manageWorkspaceNotGit")})]}),t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceCodeCompositionLabel")}),Oe.length>0?t.jsxs("div",{className:"workbench-manage-type-chart",children:[t.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Ct,"aria-hidden":"true",children:[t.jsx("strong",{className:"workbench-manage-type-chart-total",children:V.detail.codeComposition.scannedFileCount}),t.jsx("span",{className:"workbench-manage-type-chart-caption",children:r("shell.manageWorkspaceCodeCompositionFiles")})]}),t.jsx("div",{className:"workbench-manage-type-list",children:Oe.map(je=>t.jsxs("div",{className:"workbench-manage-type-item",children:[t.jsxs("span",{className:"workbench-manage-type-meta",children:[t.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:je.color},"aria-hidden":"true"}),t.jsx("span",{className:"workbench-manage-type-name",children:je.type})]}),t.jsxs("span",{children:[je.count," · ",uu(je)]})]},je.key))})]}):t.jsx("p",{className:"workbench-section-empty",children:V.detail.codeComposition.error??r("shell.manageWorkspaceNoCodeComposition")}),V.detail.codeComposition.truncated?t.jsx("p",{className:"workbench-manage-hint",children:r("shell.manageWorkspaceCodeTruncated",{count:V.detail.codeComposition.scannedFileCount})}):null]})]}):null,t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{mt(!1),z(zi(d.id))},children:r("shell.workspaceDetailDebugOpenPageAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Le,onClick:()=>$t(d),children:we?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveAction")})]})]}):null,k.length>0?t.jsx("div",{className:"workbench-manage-children",children:k.map(je=>Os(je.workspace,je.visibleSessions.length+je.archivedSessions.length,je.children,!0,kn))}):null]},d.id)}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":pe,children:t.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":pe,children:[te?t.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideSessionSidebar"),title:r("shell.hideSessionSidebar"),onClick:te,children:t.jsx(Ul,{})}):null,t.jsx(bl,{}),t.jsx(Hl,{unreadCount:Y,open:T,onToggle:re})]})}),t.jsxs("div",{className:"workbench-nav-body",children:[t.jsxs("div",{className:"workbench-nav-segment",children:[t.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":r("shell.centerTabsLabel"),children:[t.jsxs("div",{className:"workbench-nav-segment-pair",children:[t.jsxs("button",{type:"button",className:h?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":h,onClick:H,children:[t.jsx(bf,{}),t.jsx("span",{children:r("shell.conversationEntry")})]}),t.jsxs("button",{type:"button",className:b?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":b,onClick:w,children:[t.jsx(kf,{}),t.jsx("span",{children:r("shell.butlerEntry")})]})]}),t.jsxs("button",{type:"button",className:f?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":f,onClick:P,children:[t.jsx(gf,{}),t.jsx("span",{children:r("shell.terminalsEntry")})]})]}),t.jsx(Bd,{triggerClassName:"workbench-nav-segment-button",triggerLabel:r("shell.skillsEntry"),triggerLeading:t.jsx(wf,{})}),t.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":m,"aria-haspopup":"dialog","aria-expanded":m,onClick:O,children:[t.jsx(mf,{}),t.jsx("span",{children:r("shell.searchEntry")})]})]}),N?t.jsx("div",{className:"workbench-status-row",children:t.jsx("p",{className:"status-text","data-tone":"error",children:N})}):null,o.length>0?t.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[t.jsxs("div",{className:"workbench-section-heading",children:[t.jsxs("div",{className:"workbench-section-heading-main",children:[t.jsx($l,{active:!0,className:"workbench-favorite-heading-icon"}),t.jsx("span",{children:r("shell.favoriteSectionTitle")})]}),t.jsx("span",{className:"workbench-section-counter",children:o.length})]}),t.jsxs("div",{className:"workbench-session-list",children:[vr.map(d=>{const p=lo(d.session.sessionId);return t.jsx("div",{children:ds({node:{item:d.session,depth:0,children:p},workspace:d.workspace,workspaceContext:gn(d.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},d.session.sessionId)}),Sr?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:fr,children:r("shell.favoriteExpandMore")}):null]})]}):null,I&&e.length===0?t.jsx(lf,{}):null,!I&&!N&&e.length===0?t.jsx("div",{className:"workbench-empty-state minimal",children:t.jsx("p",{children:r("shell.emptyNavigationBody")})}):null,t.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[t.jsxs("div",{className:"workbench-section-heading",children:[t.jsx("div",{className:"workbench-section-heading-main",children:t.jsx("span",{children:r("shell.workspaceSectionTitle")})}),t.jsxs("div",{className:"workbench-section-actions",children:[t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.manageWorkspaceAction"),title:r("shell.manageWorkspaceAction"),onClick:()=>mt(!0),children:t.jsx(uf,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.importWorkspaceTitle"),title:r("shell.importWorkspaceTitle"),onClick:Es,children:t.jsx(df,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.cloneWorkspaceTitle"),title:r("shell.cloneWorkspaceTitle"),onClick:Ws,children:t.jsx(xf,{})})]})]}),e.map(d=>{const p=zs(d),k=qe===d.workspace.id,R=d.isCollapsed||Dn;return t.jsxs("section",{className:"workbench-workspace-group",ref:W=>Ps(d.workspace.id,W),"data-workspace-group-id":d.workspace.id,"data-batch-active":tt===d.workspace.id,"data-dragging":k,onDragOver:W=>ht(W,d.workspace.id),onDrop:Pe,children:[t.jsxs("div",{className:"workbench-workspace-header minimal",children:[t.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":R?r("shell.workspaceExpand"):r("shell.workspaceCollapse"),draggable:y&&!jt,onClick:()=>ls(d.workspace.id),onPointerDown:jt?W=>ie(W,d.workspace.id):void 0,onPointerMove:jt?cs:void 0,onPointerUp:jt?Fn:void 0,onPointerCancel:jt?io:void 0,onDragStart:y&&!jt?W=>On(W,d.workspace.id):void 0,onDragEnd:y&&!jt?Hn:void 0,"data-reorder-enabled":y?"true":void 0,children:[t.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:t.jsx(Vs,{expanded:!R})}),t.jsx("strong",{children:d.workspace.name})]}),tt===d.workspace.id?_s():br(d.workspace.id)]}),R?null:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-session-list",children:[p.length===0?t.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):p.slice(0,ft(d.workspace.id)).map(W=>ds({node:W,workspace:d.workspace,workspaceContext:gn(d.workspace),menuKeyPrefix:`workspace:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:tt===d.workspace.id,favoriteEnabled:!0})),p.length>ft(d.workspace.id)?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Un(d.workspace.id,p.length),children:r("shell.sessionExpandMore")}):null]}),d.childWorktrees.length>0?t.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.childWorktrees.map(W=>gr(W))}):null,mr(d.workspace,d.archivedSessions)]})]},d.workspace.id)})]})]}),t.jsx("div",{className:"workbench-nav-footer minimal",children:t.jsxs("div",{className:"workbench-nav-footer-actions",children:[t.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:U,title:Mt?`${r("settings.title")} · ${Me}`:r("settings.title"),children:[t.jsx(yf,{}),t.jsx("span",{className:"settings-entry-label",children:r("settings.title")}),Mt?t.jsx("span",{className:"workbench-nav-settings-host-badge",title:Me,children:Me}):null]}),t.jsx(eh,{onOpenSoftwareUpdate:()=>z("/settings/software-update")})]})}),t.jsx(Fe,{open:rt,title:r("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:r("shell.manageWorkspaceDescription"),headerActions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:Es,children:r("shell.manageWorkspaceImportAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:Ws,children:r("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{Le||mt(!1)},children:e.length>0?t.jsx("div",{className:"workbench-manage-list",children:e.map(d=>Os(d.workspace,d.visibleSessions.length+d.archivedSessions.length,d.childWorktrees,!1))}):t.jsx("p",{className:"workbench-section-empty",children:r("shell.manageWorkspaceEmpty")})}),t.jsxs(Fe,{open:An!==null,title:r("shell.deleteSessionConfirmTitle"),description:r("shell.deleteSessionConfirmDescription"),onClose:()=>{rn||kt(null)},children:[t.jsx("p",{className:"workbench-section-empty",children:An?An.session.title:""}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!rn,onClick:()=>kt(null),children:r("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!rn,onClick:()=>{kr()},children:rn?r("common.loading"):r("shell.deleteSessionAction")})]})]}),t.jsxs(Fe,{open:ot!==null,title:r("shell.manageWorkspaceRemoveConfirmTitle"),description:r("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{Le||$t(null)},children:[t.jsx("p",{className:"workbench-section-empty",children:ot?r("shell.manageWorkspaceRemoveConfirmTarget",{name:ot.name}):""}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!Le,onClick:()=>$t(null),children:r("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Le,onClick:()=>{ur()},children:Le?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveConfirmAction")})]})]}),t.jsx(Gu,{open:be,onClose:()=>Q(!1),onCloned:as}),t.jsx(Qu,{open:v,onClose:()=>ce(!1),onImported:os}),t.jsx(Fe,{open:Ce!==null,title:r("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:Ce?`${r("shell.createSessionTarget")} · ${Ce.name}`:r("shell.createSessionModalDescription"),headerActions:t.jsx("button",{type:"button",className:"secondary-button create-session-worktree-trigger",disabled:Ve||!!at,onClick:()=>Gt(!0),children:r("shell.createWorktreeAction")}),onClose:()=>qt(null),children:t.jsxs("section",{className:"create-session-modal-section",children:[t.jsxs("div",{className:"create-session-modal-section-header",children:[t.jsx("strong",{children:r("shell.createSessionProviderLabel")}),t.jsx("span",{children:r("shell.providerOptionHint")})]}),t.jsx(xc,{disabled:!!at||Ve,workspaceId:(Ce==null?void 0:Ce.id)??null,pendingProvider:at===(Ce==null?void 0:Ce.id)?Be??null:null,onSelect:d=>{Ce&&po(Ce.id,d)}})]})}),t.jsx(Fe,{open:Ce!==null&&Rt,title:r("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:t.jsx("button",{type:"button",className:Mn?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":r("shell.createWorktreeHelpAction"),title:r("shell.createWorktreeHelpAction"),"aria-pressed":Mn,onClick:()=>Rn(d=>!d),children:t.jsx(Mf,{})}),description:Ce?`${r("shell.createWorktreeSectionDescription")} ${r("shell.createSessionTarget")} · ${Ce.name}`:r("shell.createWorktreeSectionDescription"),onClose:is,children:t.jsxs("form",{className:"create-session-worktree-form",onSubmit:Jt,children:[Mn?t.jsxs("section",{className:"create-session-worktree-help-card","aria-label":r("shell.createWorktreeHelpTitle"),children:[t.jsx("strong",{children:r("shell.createWorktreeHelpTitle")}),t.jsxs("div",{className:"create-session-worktree-help-grid",children:[t.jsxs("article",{children:[t.jsx("h3",{children:r("shell.createWorktreeHelpBranchTitle")}),t.jsx("p",{children:r("shell.createWorktreeHelpBranchBody")})]}),t.jsxs("article",{children:[t.jsx("h3",{children:r("shell.createWorktreeHelpDisplayNameTitle")}),t.jsx("p",{children:r("shell.createWorktreeHelpDisplayNameBody")})]}),t.jsxs("article",{children:[t.jsx("h3",{children:r("shell.createWorktreeHelpBaseRefTitle")}),t.jsx("p",{children:r("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,t.jsxs("label",{className:"create-session-worktree-field",children:[t.jsx("span",{children:r("shell.createWorktreeBranchLabel")}),t.jsx("input",{className:"settings-text-input",value:bt,placeholder:r("shell.createWorktreeBranchPlaceholder"),onChange:d=>{const p=d.target.value;yh(p)&&Tn(p)}})]}),t.jsxs("label",{className:"create-session-worktree-field",children:[t.jsx("span",{children:r("shell.createWorktreeDisplayNameLabel")}),t.jsx("input",{className:"settings-text-input",value:Ns,placeholder:r("shell.createWorktreeDisplayNamePlaceholder"),onChange:d=>sn(d.target.value)})]}),t.jsxs("label",{className:"create-session-worktree-field",children:[t.jsx("span",{children:r("shell.createWorktreeBaseRefLabel")}),t.jsx("div",{className:"create-session-worktree-combobox",ref:Ge,onBlurCapture:d=>{var k,R;const p=d.relatedTarget;p instanceof Node&&((k=Ge.current)!=null&&k.contains(p)||(R=St.current)!=null&&R.contains(p))||($e(!1),Ye(-1))},children:t.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[t.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":Xe,"aria-controls":Rs,value:Yn,placeholder:r("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{$e(!0),Ye(lt.length>0?0:-1)},onChange:d=>{ke(d.target.value),$e(!0),Ye(lt.length>0?0:-1)},onKeyDown:d=>{if(d.key==="ArrowDown"){if(d.preventDefault(),!Xe){$e(!0);return}lt.length>0&&Ye(p=>p>=lt.length-1?0:p+1);return}if(d.key==="ArrowUp"){if(d.preventDefault(),!Xe){$e(!0);return}lt.length>0&&Ye(p=>p<=0?lt.length-1:p-1);return}if(d.key==="Enter"&&Xe&&Cs>=0){d.preventDefault();const p=lt[Cs];p&&(ke(p.value),$e(!1),Ye(-1));return}d.key==="Escape"&&$e(!1)}}),t.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":r("shell.createWorktreeBaseRefToggle"),"aria-expanded":Xe,onClick:()=>{$e(d=>!d),Ye(!Xe&<.length>0?0:-1)},children:t.jsx(Vs,{expanded:Xe})})]})}),t.jsx("span",{className:"create-session-worktree-field-hint",children:Jn?r("shell.createWorktreeBaseRefLoading"):Et||r("shell.createWorktreeBaseRefHint",{localCount:zt.localBranches.length,remoteCount:zt.remoteBranches.length,tagCount:zt.tags.length})})]}),Xe&>&&typeof document<"u"?Zr.createPortal(t.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[t.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${gt.top}px`,"--create-worktree-combobox-left":`${gt.left}px`,"--create-worktree-combobox-width":`${gt.width}px`,"--create-worktree-combobox-height":`${ro??0}px`}}),t.jsx("div",{ref:St,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${gt.top}px`,"--create-worktree-combobox-left":`${gt.left}px`,"--create-worktree-combobox-width":`${gt.width}px`},children:Jn?t.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefLoading")}):Et?t.jsx("p",{className:"create-session-worktree-combobox-empty",children:Et}):fn.length>0?t.jsx("div",{id:Rs,className:"create-session-worktree-combobox-list",role:"listbox",children:fn.map(d=>t.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":d.label,children:[t.jsx("header",{className:"create-session-worktree-combobox-group-title",children:d.label}),t.jsx("div",{className:"create-session-worktree-combobox-group-options",children:d.items.map(p=>{const k=lt.findIndex(oe=>oe.value===p.value),R=Yn===p.value,W=Cs===k;return t.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":R,"data-highlighted":W,onMouseDown:oe=>oe.preventDefault(),onMouseEnter:()=>Ye(k),onClick:()=>{ke(p.value),$e(!1),Ye(-1)},children:[t.jsx("span",{className:"create-session-worktree-combobox-option-label",children:p.value}),t.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[p.current?t.jsx("span",{className:"create-session-worktree-combobox-badge",children:r("shell.createWorktreeBaseRefCurrentBadge")}):null,p.recommended?t.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:r("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${d.key}:${p.value}`)})})]},d.key))}):t.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:Ve,onClick:is,children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:Ve,children:Ve?r("shell.createWorktreeSubmitting"):r("shell.createWorktreeSubmit")})]})]})}),t.jsx(Fe,{open:dt!==null,title:r("shell.archiveModalTitle"),description:dt?`${dt.workspace.name} · ${r("shell.archiveModalDescription")}`:r("shell.archiveModalDescription"),onClose:()=>Kt(null),children:dt&&dt.archivedSessions.length>0?t.jsx("div",{className:"workbench-archive-list","data-workspace-tone":(Ke==null?void 0:Ke.tone)??"root",style:Qt(Ke),children:dt.archivedSessions.map(d=>{const p=ea(d.title,r("common.unknown"));return t.jsxs("article",{className:"workbench-archive-item","data-workspace-tone":(Ke==null?void 0:Ke.tone)??"root",style:Qt(Ke),children:[t.jsxs("div",{className:"workbench-archive-item-main",children:[t.jsx("strong",{title:p.fullTitle,children:p.displayTitle}),t.jsxs("p",{children:[Sl(d,dt.workspace,!1)," ·"," ",no(d.provider)]})]}),t.jsx("button",{type:"button",className:"secondary-button",onClick:()=>xr(d.sessionId),children:r("shell.unarchiveAction")})]},d.sessionId)})}):t.jsx("p",{className:"workbench-section-empty",children:r("shell.archiveEmpty")})}),t.jsx(Fe,{open:Ze!==null,title:r("shell.renameModalTitle"),description:r("shell.renameModalDescription"),onClose:()=>{dn||(xt(null),Yt(""))},children:t.jsxs("form",{className:"workbench-rename-form",onSubmit:yr,children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.renameInputLabel")}),t.jsx("input",{type:"text",value:yt,placeholder:r("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:d=>Yt(d.target.value)})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!dn,onClick:()=>{xt(null),Yt("")},children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:!yt.trim()||dn===(Ze==null?void 0:Ze.session.sessionId),children:dn===(Ze==null?void 0:Ze.session.sessionId)?r("shell.renamingSession"):r("common.save")})]})]})})]})}function ji({panelReady:e,activeTab:n,fileRevealRequest:s,onTabChange:o,onToggleCollapse:a,currentSessionId:c,activeWorkspaceId:h,navigationGroups:f,workspaceContext:b,worktreeMeta:m,worktreeMergeState:I,onRefreshWorktreeMergePreview:N,onApplyWorktreeMerge:j,onCleanupWorktree:M}){var ge;const F=h??((ge=f[0])==null?void 0:ge.workspace.id)??null,H=Cn(),P=rl(H),{showToast:w}=Vn(),O=l.useRef(null),U=l.useRef(null),se=H.isDesktop&&H.bridge.supported,X=se&&!!h,ee=se&&!!F,_=se&&!!F,L=typeof globalThis<"u"&&"PointerEvent"in globalThis,y=l.useCallback(async($,me,D)=>{if($==="files"){const S=await Rd(H,{workspaceId:me,sessionId:D,focusOwner:"file-context-panel"});S.ok||w({title:S.detail??r("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if($==="git"){const S=await Ed(H,{workspaceId:me,focusOwner:"git-sidebar"});S.ok||w({title:S.detail??r("git.openExternalFailed"),tone:"error"});return}const x=await Wd(H,{workspaceId:me,focusOwner:"terminal-manager-panel"});x.ok||w({title:x.detail??r("terminalManager.openExternalFailed"),tone:"error"})},[H,w]),K=l.useCallback(($,me)=>{if($.button!==0||!se)return;const D=me==="files"?h:me==="git"||me==="terminals"?F:null;if(!D)return;const x=me==="files"?c:null;O.current={tab:me,startX:$.clientX,startY:$.clientY,workspaceId:D,sessionId:x,detached:!1,preview:null};const S=q=>{var pe;const te=O.current;if(!te)return;const z=Math.abs(q.clientX-te.startX),ae=Math.abs(q.clientY-te.startY);!te.detached&&Math.max(z,ae)<oi||(te.detached||(te.detached=!0,U.current=te.tab,te.preview=Na({title:te.tab==="files"?r("shell.filesEntry"):te.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:q.clientX,y:q.clientY})),(pe=te.preview)==null||pe.updatePosition(q.clientX,q.clientY))},Y=q=>{var z;const te=(z=O.current)==null?void 0:z.preview;q&&(te==null||te.cancel()),window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",T),window.removeEventListener("blur",re),O.current=null},T=async()=>{var te;const q=O.current;Y(!1),q!=null&&q.detached&&(await((te=q.preview)==null?void 0:te.complete()),await y(q.tab,q.workspaceId,q.sessionId))},re=()=>{Y(!0)};window.addEventListener("mousemove",S),window.addEventListener("mouseup",T),window.addEventListener("blur",re)},[h,se,c,F,y]),J=l.useCallback(($,me)=>{if($.button!==0||!se)return;const D=me==="files"?h:me==="git"||me==="terminals"?F:null;if(!D)return;const x=$.currentTarget,S=$.pointerId;x.setPointerCapture(S);const Y=me==="files"?c:null;O.current={tab:me,startX:$.clientX,startY:$.clientY,workspaceId:D,sessionId:Y,detached:!1,preview:null};const T=ae=>{var Me;if(ae.pointerId!==S)return;const pe=O.current;if(!pe)return;const de=Math.abs(ae.clientX-pe.startX),He=Math.abs(ae.clientY-pe.startY);!pe.detached&&Math.max(de,He)<oi||(pe.detached||(pe.detached=!0,U.current=pe.tab,pe.preview=Na({title:pe.tab==="files"?r("shell.filesEntry"):pe.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:ae.clientX,y:ae.clientY})),(Me=pe.preview)==null||Me.updatePosition(ae.clientX,ae.clientY))},re=ae=>{var de;const pe=(de=O.current)==null?void 0:de.preview;ae&&(pe==null||pe.cancel()),x.removeEventListener("pointermove",T),x.removeEventListener("pointerup",q),x.removeEventListener("pointercancel",te),x.removeEventListener("lostpointercapture",te),window.removeEventListener("blur",z),O.current=null,x.hasPointerCapture(S)&&x.releasePointerCapture(S)},q=async ae=>{var de;if(ae.pointerId!==S)return;const pe=O.current;re(!1),pe!=null&&pe.detached&&(await((de=pe.preview)==null?void 0:de.complete()),await y(pe.tab,pe.workspaceId,pe.sessionId))},te=ae=>{ae.pointerId===S&&re(!0)},z=()=>{re(!0)};x.addEventListener("pointermove",T),x.addEventListener("pointerup",q),x.addEventListener("pointercancel",te),x.addEventListener("lostpointercapture",te),window.addEventListener("blur",z)},[h,se,c,F,y]),E=l.useCallback($=>{if(U.current===$){U.current=null;return}o($)},[o]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(b==null?void 0:b.tone)??"root",style:Qt(b),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":P,children:[a?t.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideInfoSidebar"),title:r("shell.hideInfoSidebar"),onClick:a,children:t.jsx(Ul,{})}):null,t.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":r("shell.infoTabsLabel"),"data-tauri-drag-region":P,children:[t.jsx("button",{className:n==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":n==="files",title:X?"拖拽标签到独立窗口":void 0,onPointerDown:$=>J($,"files"),onMouseDown:L?void 0:$=>K($,"files"),onClick:()=>E("files"),children:r("shell.filesEntry")}),t.jsx("button",{className:n==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":n==="git",title:ee?"拖拽标签到独立窗口":void 0,onPointerDown:$=>J($,"git"),onMouseDown:L?void 0:$=>K($,"git"),onClick:()=>E("git"),children:r("shell.gitEntry")}),t.jsx("button",{className:n==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":n==="terminals",title:_?"拖拽标签到独立窗口":void 0,onPointerDown:$=>J($,"terminals"),onMouseDown:L?void 0:$=>K($,"terminals"),onClick:()=>E("terminals"),children:r("shell.terminalManagerEntry")})]})]}),t.jsxs("div",{className:"workbench-auxiliary-body",children:[e?null:t.jsx($r,{}),e&&n==="git"&&m?t.jsx(Wf,{meta:m,state:I,onRefresh:()=>N(m.workspaceId,!0),onApply:()=>j(m.workspaceId),onCleanup:()=>M(m)}):null,e&&n==="files"?h?t.jsx(l.Suspense,{fallback:t.jsx($r,{}),children:t.jsx(Eh,{sessionId:c,workspaceId:h,externalRevealRequest:s})}):t.jsx("section",{className:"workbench-empty-state minimal",children:t.jsx("p",{children:r("shell.filesPanelEmpty")})}):null,e&&n==="git"?F?t.jsx(l.Suspense,{fallback:t.jsx($r,{}),children:t.jsx(Wh,{workspaceId:F})}):t.jsx("section",{className:"workbench-empty-state minimal",children:t.jsx("p",{children:r("shell.gitPanelEmpty")})}):null,e&&n==="terminals"?t.jsx(l.Suspense,{fallback:t.jsx($r,{}),children:t.jsx(Ph,{currentWorkspaceId:h,navigationGroups:f})}):null]})]})}function Wf({meta:e,state:n,onRefresh:s,onApply:o,onCleanup:a}){const[c,h]=l.useState(!1),f=(n==null?void 0:n.preview)??null,b=(n==null?void 0:n.loading)??!1,m=(n==null?void 0:n.applying)??!1,I=(n==null?void 0:n.cleaning)??!1,N=f!==null,j=(f==null?void 0:f.alreadyMerged)===!0,M=new Set((f==null?void 0:f.blockers.map(E=>E.code))??[]),F=M.size>0||!!(n!=null&&n.error),H=j&&!F,P=(f==null?void 0:f.canMerge)===!0&&!b&&!m&&!I&&!H,w=H&&!b&&!m&&!I&&!M.has("SOURCE_DIRTY")&&!M.has("HAS_ACTIVE_CHILDREN"),O=b||m||I?"loading":F?"blocked":H?"merged":f!=null&&f.canMerge?"ready":N?"blocked":"idle",U=(f==null?void 0:f.targetWorkspace.name)??r("common.unknown"),se=(f==null?void 0:f.sourceBranchName)??e.branchName,X=(f==null?void 0:f.targetBranchName)??e.baseRef??r("common.unknown"),ee=Af({t:r,hasPreview:N,showMergedState:H,isMerged:j,canMerge:(f==null?void 0:f.canMerge)===!0,ahead:(f==null?void 0:f.ahead)??0,blockerCodeSet:M}),_=b?r("shell.worktreeMergePreviewLoading"):m?r("shell.worktreeMergeApplying"):I?r("shell.worktreeCleanupRunning"):H?r("shell.worktreeMergeAlreadyMerged"):f!=null&&f.canMerge?r("shell.worktreeMergeReady"):N?r("shell.worktreeMergeBlocked"):r("shell.worktreeMergePreviewIdle"),L=[r("shell.worktreeMergeCurrentBranch",{branch:se}),r("shell.worktreeMergeParentBranch",{branch:X}),r("shell.worktreeMergeTargetWorkspace",{name:U}),f?r("shell.worktreeMergeAheadBehind",{ahead:f.ahead,behind:f.behind}):r("shell.worktreeMergeAheadBehindPending"),f!=null&&f.mergeBaseCommit?r("shell.worktreeMergeBaseCommit",{commit:of(f.mergeBaseCommit)}):null].filter(E=>!!E),y=`worktree-merge-panel-details-${e.workspaceId}`,K=c?r("shell.worktreeMergeCollapseDetails"):r("shell.worktreeMergeExpandDetails"),J=Pf({t:r,loading:b,applying:m,cleaning:I,hasPreview:N,canMerge:(f==null?void 0:f.canMerge)===!0,showMergedState:H,blockerCodeSet:M});return l.useEffect(()=>{h(!1)},[e.workspaceId]),t.jsxs("section",{className:"worktree-merge-panel","data-state":O,children:[t.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":K,"aria-expanded":c,"aria-controls":y,onClick:()=>{h(E=>!E)},children:[t.jsx("span",{className:"worktree-merge-panel-summary-label",children:r("shell.worktreeMergePanelLabel")}),t.jsx("span",{className:"worktree-merge-panel-summary-main",children:t.jsx("span",{className:"worktree-merge-panel-summary-tags",children:J.map(E=>t.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":O,children:E},E))})}),t.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:K})]}),c?t.jsxs("div",{id:y,className:"worktree-merge-panel-details",children:[t.jsx("div",{className:"worktree-merge-panel-detail-head",children:t.jsx("span",{className:"worktree-merge-panel-status","data-state":O,children:_})}),t.jsx("div",{className:"worktree-merge-panel-meta",children:L.map(E=>t.jsx("span",{children:E},E))}),N?t.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":r("shell.worktreeMergeChecklistTitle"),children:ee.map(E=>t.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":E.state,children:[t.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:E.state==="done"?"✓":E.state==="blocked"?"!":"·"}),t.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[t.jsx("strong",{children:E.label}),E.detail?t.jsx("span",{children:E.detail}):null]})]},E.key))}):null,n!=null&&n.error?t.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:n.error}):null,f!=null&&f.conflictPaths.length?t.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[t.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:r("shell.worktreeMergeConflictLabel")}),t.jsx("div",{className:"worktree-merge-panel-conflict-list",children:f.conflictPaths.map(E=>t.jsx("code",{children:E},E))})]}):null,t.jsxs("div",{className:"worktree-merge-panel-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:b||m||I,onClick:s,children:N?r("shell.worktreeMergePreviewRefresh"):r("shell.worktreeMergePreviewAction")}),t.jsx("button",{type:"button",className:"primary-button",disabled:!P,onClick:o,children:m?r("shell.worktreeMergeApplying"):r("shell.worktreeMergeApplyAction")}),t.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!w,onClick:a,children:I?r("shell.worktreeCleanupRunning"):r("shell.worktreeCleanupAction")})]})]}):null]})}function Pf(e){const{t:n,loading:s,applying:o,cleaning:a,hasPreview:c,canMerge:h,showMergedState:f,blockerCodeSet:b}=e;if(s)return[n("shell.worktreeMergeCompactChecking")];if(o)return[n("shell.worktreeMergeCompactMerging")];if(a)return[n("shell.worktreeMergeCompactCleaning")];const m=[];return b.has("SOURCE_NOT_ACTIVE")&&m.push(n("shell.worktreeMergeCompactInactive")),b.has("SOURCE_DIRTY")&&m.push(n("shell.worktreeMergeCompactDirty")),b.has("TARGET_DIRTY")&&m.push(n("shell.worktreeMergeCompactTargetDirty")),b.has("HAS_CONFLICTS")&&m.push(n("shell.worktreeMergeCompactConflict")),b.has("HAS_ACTIVE_CHILDREN")&&m.push(n("shell.worktreeMergeCompactChildren")),m.length>0?m:h?[n("shell.worktreeMergeCompactReady")]:f?[n("shell.worktreeMergeCompactMerged")]:c?b.has("NO_COMMITS_TO_MERGE")?[n("shell.worktreeMergeCompactNoCommits")]:[n("shell.worktreeMergeCompactBlocked")]:[n("shell.worktreeMergeCompactPending")]}function Af(e){const{t:n,hasPreview:s,showMergedState:o,isMerged:a,canMerge:c,ahead:h,blockerCodeSet:f}=e,b=f.has("SOURCE_NOT_ACTIVE"),m=f.has("SOURCE_DIRTY"),I=f.has("TARGET_DIRTY"),N=f.has("HAS_ACTIVE_CHILDREN"),j=f.has("HAS_CONFLICTS"),M=s&&!a&&(f.has("NO_COMMITS_TO_MERGE")||h<=0),F=o?{key:"merge-result",label:n("shell.worktreeMergeChecklistResultMerged"),detail:n("shell.worktreeMergeMergedHint"),state:"done"}:c?{key:"merge-result",label:n("shell.worktreeMergeChecklistResultReady"),detail:n("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:s?{key:"merge-result",label:n("shell.worktreeMergeChecklistResultBlocked"),detail:n("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:n("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:n("shell.worktreeMergeChecklistSourceState"),detail:s&&b?n("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:s?b?"blocked":"done":"pending"},{key:"clean-source",label:n("shell.worktreeMergeChecklistSourceClean"),detail:s&&m?n("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:s?m?"blocked":"done":"pending"},{key:"clean-target",label:n("shell.worktreeMergeChecklistTargetClean"),detail:s&&I?n("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:s?I?"blocked":"done":"pending"},{key:"children",label:n("shell.worktreeMergeChecklistChildren"),detail:s&&N?n("shell.worktreeMergeChecklistChildrenBlocked"):null,state:s?N?"blocked":"done":"pending"},{key:"commits",label:n("shell.worktreeMergeChecklistCommits"),detail:M?n(a?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:M?a?"done":"blocked":s?"done":"pending"},{key:"conflicts",label:n("shell.worktreeMergeChecklistConflicts"),detail:j?n("shell.worktreeMergeChecklistConflictsBlocked"):null,state:j?"blocked":s?"done":"pending"},F]}function Op({shellMode:e="desktop"}){var Se,kn,Bt,je,jr,fs,Nr,Cr,Ir,Tr,wn,xn,oa,aa,ia;const n=Jr(),s=Qs(),o=Cn(),{showToast:a}=Vn(),c=Mr(i=>i.sessionDisplaySortMode),h=Mr(i=>i.notificationPreferences.notifyOnPermissionRequest),f=Mr(i=>i.notificationPreferences.notifyOnSessionCompleted),b=Mr(i=>i.notificationPreferences.notifyOnSessionFailed),m=l.useRef(xu(hl)),I=l.useRef(0),N=l.useRef((((kn=(Se=m.current)==null?void 0:Se.items)==null?void 0:kn.length)??0)>0),j=l.useRef(new Map),M=l.useRef(!1),F=l.useRef(null),H=l.useRef(0),P=l.useRef(null),w=l.useRef(null),O=l.useRef(new Set),U=l.useRef(new Set),se=l.useRef(new Set),X=l.useRef(new Set),ee=l.useRef(null),_=l.useRef(null),L=l.useRef(null),y=l.useRef(null),K=l.useRef(null),J=l.useRef(null),E=l.useRef(null),ge=l.useRef(null),$=l.useRef(0),me=l.useRef(0),D=l.useRef(a),x=l.useRef(o.bridge),S=l.useRef(null),Y=l.useRef(0),T=l.useRef(0),re=l.useRef(null),q=l.useRef(null),te=l.useRef(null),z=l.useRef(!1),ae=l.useRef(!1),pe=l.useRef(!1),de=l.useRef(new Map),He=l.useRef(!1),Me=l.useRef(new Map),Mt=l.useRef(""),v=l.useRef([]),ce=l.useRef(c),be=l.useRef(null),[Q,rt]=l.useState(()=>La(m.current,c)),mt=l.useRef(Q),[Ue,nn]=l.useState(()=>{var i,u;return(((u=(i=m.current)==null?void 0:i.items)==null?void 0:u.length)??0)===0}),[ot,$t]=l.useState(null),[Le,sr]=l.useState(()=>Hr(hi(Va,th),Qa,ti)),[at,rr]=l.useState(()=>Hr(hi(Xa,nh),ei,ni)),[Be,Xn]=l.useState(()=>fi(Ya,!1)),[Ne,qt]=l.useState(()=>fi(Ja,!1)),[it,js]=l.useState(null),[Rt,Gt]=l.useState(()=>bi(m.current)),[Ve,In]=l.useState(()=>pi(vo)),[bt,Tn]=l.useState(!1),[Ns,sn]=l.useState("files"),[Yn,ke]=l.useState(!1),[zt,We]=l.useState(!1),[Xe,$e]=l.useState(null),[Cs,Ye]=l.useState({}),[Mn,Rn]=l.useState(!1),[Jn,En]=l.useState("sessions"),[Et,Wn]=l.useState(""),[gt,Is]=l.useState(""),[ro,Pn]=l.useState(!1),[oo,Kt]=l.useState(null),[An,kt]=l.useState([]),[rn,or]=l.useState(null),[Vt,on]=l.useState({}),Zn=sl(o),ar=l.useCallback(i=>{if(Zn)return;const u=S.current;u&&(!To(o,i.button,i.target)||!mi(i.clientY,u)||wd({platform:o,button:i.button,target:i.target,clientX:i.clientX,clientY:i.clientY}))},[o,Zn]),ao=l.useCallback(i=>{if(Zn)return;const u=S.current;u&&(!To(o,i.button,i.target)||!mi(i.clientY,u)||o.bridge.setWindowState("toggle-zoom"))},[o,Zn]),[Je,wt]=l.useState({}),[ve,Qn]=l.useState(null),[an,Ln]=l.useState(!1),[ln,cn]=l.useState([]),[Xt,Ze]=l.useState(()=>new Set),[xt,yt]=l.useState(!1),[Yt,dn]=l.useState(!1),[ir,tt]=l.useState(0),[Wt,vt]=l.useState(()=>pi(Za)),Qe=e==="desktop"&&o.isDesktop&&o.ui.osFamily==="macos"&&o.ui.prefersOverlayTitlebar,{theme:Bn}=sc();l.useEffect(()=>{D.current=a},[a]),l.useEffect(()=>{if(typeof document>"u")return;const{documentElement:i,body:u}=document,g=document.getElementById("root");if(!Qe){i.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy");return}const C=i.style.background,B=(u==null?void 0:u.style.background)??"",A=(g==null?void 0:g.style.background)??"";return i.setAttribute("data-workbench-macos-vibrancy","true"),u==null||u.setAttribute("data-workbench-macos-vibrancy","true"),i.style.background="transparent",u==null||u.style.setProperty("background","transparent"),g==null||g.style.setProperty("background","transparent"),()=>{i.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy"),i.style.background=C,u&&(u.style.background=B),g instanceof HTMLElement&&(g.style.background=A)}},[Qe]),l.useEffect(()=>()=>{te.current!==null&&window.clearTimeout(te.current)},[]),l.useEffect(()=>{var B;if(typeof document>"u")return;const{documentElement:i,body:u}=document;if(!it){i.removeAttribute(ms),u==null||u.removeAttribute(ms);return}const g=i.style.cursor,C=(u==null?void 0:u.style.cursor)??"";return i.setAttribute(ms,it),u==null||u.setAttribute(ms,it),i.style.cursor="col-resize",u==null||u.style.setProperty("cursor","col-resize"),(B=window.getSelection())==null||B.removeAllRanges(),()=>{i.removeAttribute(ms),u==null||u.removeAttribute(ms),i.style.cursor=g,u&&(u.style.cursor=C)}},[it]),l.useEffect(()=>{ce.current=c,rt(i=>af(i,c))},[c]),l.useEffect(()=>{mt.current=Q},[Q]),l.useEffect(()=>{x.current=o.bridge},[o.bridge]),l.useEffect(()=>{Y.current=Le},[Le]),l.useEffect(()=>{T.current=at},[at]),l.useEffect(()=>()=>{re.current!==null&&window.cancelAnimationFrame(re.current)},[]);const es=l.useCallback(async()=>{const i=$.current+1;$.current=i;try{const u=await Iu();if(i!==$.current)return;if(!u.initialized){cn([]),Ze(new Set);return}const[g,C,B,A]=await Promise.all([Tu(),Eu(),ml(),Pu()]);if(i!==$.current)return;cn(kh(g.overview,C.items,B.items)),Ze(new Set(A.items.map(ne=>ne.notificationId)))}catch{if(i!==$.current)return;cn([]),Ze(new Set)}},[]),Ts=l.useCallback(i=>{const u=i.map(g=>g.createdAt).sort((g,C)=>Nn(C)-Nn(g))[0]??null;u&&vt(g=>g&&Nn(g)>=Nn(u)?g:u)},[]);l.useEffect(()=>{Wt&&zn(Za,Wt)},[Wt]),l.useEffect(()=>{es();const i=window.setInterval(()=>{es()},rh);return()=>{window.clearInterval(i)}},[es]),l.useEffect(()=>{pt("workbench.layout_mounted",{path:n.pathname,search:n.search})},[n.pathname,n.search]),l.useEffect(()=>{var i,u;pt("workbench.cached_snapshot_loaded",{cached:!!m.current,workspaceCount:((i=m.current)==null?void 0:i.items.length)??0,sessionCount:((u=m.current)==null?void 0:u.items.reduce((g,C)=>g+C.sessions.length,0))??0})},[]);function ts(i){var C;if(!i||!Array.isArray(i.items))return;tf(j.current,i);const u=ef(i,j.current);pt("workbench.apply_snapshot",{workspaceCount:u.items.length,sessionCount:u.items.reduce((B,A)=>B+A.sessions.length,0),currentSessionId:((C=Ys(n.pathname))==null?void 0:C.sessionId)??null});const g=La(u,ce.current);m.current=u,Lr(u),mt.current=g,rt(g),Gt(bi(u)),$t(null)}const qe=l.useCallback(async()=>{const i=I.current+1;I.current=i,nn(u=>u||!N.current),pt("workbench.refresh_navigation.start",{requestId:i,hasNavigationData:N.current});try{const u=await dc();if(i!==I.current){pt("workbench.refresh_navigation.stale",{requestId:i});return}ts(u)}catch(u){if(i!==I.current)return;$t(u instanceof Error?u.message:r("shell.navigationLoadFailed")),D.current({title:u instanceof Error?u.message:r("shell.navigationLoadFailed"),tone:"error"})}finally{pt("workbench.refresh_navigation.end",{requestId:i,success:i===I.current}),i===I.current&&nn(!1)}},[]),nt=l.useCallback(i=>{rt(u=>{const g=nf(u,i,ce.current);return mt.current=g,g})},[]),Ge=l.useCallback(()=>{var i;(i=w.current)==null||i.requestRefresh()},[]),St=l.useCallback((i,u)=>{s(Ot(i,u))},[s]),Pt=l.useCallback((i,u)=>{var g;ee.current={workspaceId:i,paths:u},(g=w.current)==null||g.subscribeFileTree(i,u)},[]),ns=l.useCallback((i,u)=>{var g;_.current={workspaceId:i,paths:u},(g=w.current)==null||g.requestFileTreeRefresh(i,u)},[]),un=l.useCallback(i=>(O.current.add(i),()=>{O.current.delete(i)}),[]),hn=l.useCallback(i=>{var u;L.current=i,(u=w.current)==null||u.subscribeGit(i)},[]),ct=l.useCallback(i=>{var u;y.current=i,(u=w.current)==null||u.requestGitRefresh(i)},[]),lr=l.useCallback(i=>(U.current.add(i),()=>{U.current.delete(i)}),[]),ss=l.useCallback(i=>{var u;K.current=i,(u=w.current)==null||u.subscribeWorkspaceManagement(i)},[]),Dn=l.useCallback(i=>{var u;J.current=i,on(g=>{var C;return{...g,[i]:{detail:((C=g[i])==null?void 0:C.detail)??null,loading:!0,error:null}}}),(u=w.current)==null||u.requestWorkspaceManagementRefresh(i)},[]),jt=l.useCallback(i=>(se.current.add(i),()=>{se.current.delete(i)}),[]),ze=l.useCallback(async(i,u=!1)=>{const g=i.trim();if(!g)return;let C=!0;if(wt(B=>{const A=B[g];return!u&&(A!=null&&A.loading)?(C=!1,B):{...B,[g]:{preview:(A==null?void 0:A.preview)??null,loading:!0,applying:(A==null?void 0:A.applying)??!1,cleaning:(A==null?void 0:A.cleaning)??!1,error:null}}}),!!C)try{const B=await uc(g);wt(A=>{var ne,fe;return{...A,[g]:{preview:B,loading:!1,applying:((ne=A[g])==null?void 0:ne.applying)??!1,cleaning:((fe=A[g])==null?void 0:fe.cleaning)??!1,error:null}}})}catch(B){wt(A=>{var ne,fe,ue;return{...A,[g]:{preview:((ne=A[g])==null?void 0:ne.preview)??null,loading:!1,applying:((fe=A[g])==null?void 0:fe.applying)??!1,cleaning:((ue=A[g])==null?void 0:ue.cleaning)??!1,error:B instanceof Error?B.message:r("shell.worktreeMergePreviewFailed")}}})}},[]),cr=l.useCallback(async i=>{const u=i.trim();if(u){wt(g=>{var C,B;return{...g,[u]:{preview:((C=g[u])==null?void 0:C.preview)??null,loading:!1,applying:!0,cleaning:((B=g[u])==null?void 0:B.cleaning)??!1,error:null}}});try{const g=await hc(u);wt(C=>{var B;return{...C,[u]:{preview:g.preview,loading:!1,applying:!1,cleaning:((B=C[u])==null?void 0:B.cleaning)??!1,error:null}}}),Ge(),qe(),ze(u,!0),ct(g.preview.targetWorkspace.id),D.current({title:g.applied?r("shell.worktreeMergeApplySuccess"):r("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(g){wt(C=>{var B,A;return{...C,[u]:{preview:((B=C[u])==null?void 0:B.preview)??null,loading:!1,applying:!1,cleaning:((A=C[u])==null?void 0:A.cleaning)??!1,error:g instanceof Error?g.message:r("shell.worktreeMergeApplyFailed")}}}),D.current({title:g instanceof Error?g.message:r("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[ze,qe,ct,Ge]),Ce=l.useCallback(async i=>{var C,B;const u=i.workspaceId,g=an&&((B=(C=Je[u])==null?void 0:C.preview)==null?void 0:B.alreadyMerged)===!0;wt(A=>{var ne;return{...A,[u]:{preview:((ne=A[u])==null?void 0:ne.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const A=await fc(u,{deleteBranch:g});if(wt(ne=>{var fe;return{...ne,[u]:{preview:((fe=ne[u])==null?void 0:fe.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),Ln(!1),Qn(ne=>(ne==null?void 0:ne.workspaceId)===u?null:ne),Ge(),await qe(),s(Ut(i.parentWorkspaceId),{replace:!0}),A.branchDeleted){D.current({title:r("shell.worktreeCleanupDeleteBranchSuccess",{branch:A.deletedBranchName||i.branchName}),tone:"success"});return}if(A.branchDeleteRequested){D.current({title:r("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:i.branchName}),description:A.branchDeleteError||void 0,tone:"warning"});return}D.current({title:r("shell.worktreeCleanupSuccess"),tone:"success"})}catch(A){wt(ne=>{var fe;return{...ne,[u]:{preview:((fe=ne[u])==null?void 0:fe.preview)??null,loading:!1,applying:!1,cleaning:!1,error:A instanceof Error?A.message:r("shell.worktreeCleanupFailed")}}}),D.current({title:A instanceof Error?A.message:r("shell.worktreeCleanupFailed"),tone:"error"})}},[an,s,qe,Ge,Je]),Ms=l.useCallback(i=>{Ln(!1),Qn(i)},[]),fn=l.useCallback(i=>{var u;E.current=i,(u=w.current)==null||u.subscribeTerminalManager(i)},[]),lt=l.useCallback(i=>{var u;ge.current=i,(u=w.current)==null||u.requestTerminalManagerRefresh(i)},[]),Rs=l.useCallback(i=>(X.current.add(i),()=>{X.current.delete(i)}),[]),dt=l.useCallback((i,u)=>{rt(g=>sf(g,i,u??new Date().toISOString()))},[]),Ke=l.useCallback(async(i,u)=>{j.current.set(i,u),rt(g=>wi(g,i,u));try{const g=await Ai(i,u),C=Ht(g);C===u?j.current.set(i,C):j.current.delete(i),nt(g),Ge(),qe()}catch(g){throw j.current.delete(i),rt(C=>wi(C,i,!u)),g}},[qe,Ge,nt]),pn=l.useCallback((i,u)=>{pt("workbench.set_session_workspace",{sessionId:i,workspaceId:u}),Ye(g=>{if(!u){if(!(i in g))return g;const C={...g};return delete C[i],C}return g[i]===u?g:{...g,[i]:u}})},[]);l.useEffect(()=>{N.current=Q.length>0},[Q]),l.useEffect(()=>{pt("workbench.navigation_state",{navigationLoading:Ue,workspaceCount:Q.length,sessionCount:Q.reduce((i,u)=>i+u.sessions.length,0)})},[Q,Ue]),l.useEffect(()=>{P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{var G;P.current=null,!(M.current||N.current)&&(pt("workbench.refresh_navigation.ws_fallback_triggered"),(G=w.current)==null||G.requestRefresh())},1200);const i=new md({onConnectionChange:G=>{G==="connected"&&pc(),G==="reconnect_failed"&&!N.current&&($t(r("shell.navigationLoadFailed")),D.current({id:"workbench-navigation-connection",title:r("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:G=>{M.current=!0,pt("workbench.ws_snapshot_received",{workspaceCount:G.items.length,sessionCount:G.items.reduce((xe,It)=>xe+It.sessions.length,0)}),P.current!==null&&(window.clearTimeout(P.current),P.current=null),ts(G),nn(!1)},onFileTreeSnapshot:G=>{O.current.forEach(xe=>xe(G))},onGitSnapshot:G=>{Xs(Bl(G.workspaceId),{status:G.status,history:G.history,historyTotalCount:G.historyTotalCount,historyNextCursor:G.historyNextCursor,branches:G.branches}),on(xe=>{var Zt;const It=((Zt=Q.find(Gl=>Gl.workspace.id===G.workspaceId))==null?void 0:Zt.workspace)??null;if(!It)return xe;const Dt=xe[G.workspaceId],_e=Fl(_l((Dt==null?void 0:Dt.detail)??Dl(It),It),G);return Xs(Lo(G.workspaceId),_e),{...xe,[G.workspaceId]:{detail:_e,loading:!1,error:null}}}),U.current.forEach(xe=>xe(G))},onWorkspaceManagementSnapshot:G=>{Xs(Lo(G.workspaceId),G),on(xe=>({...xe,[G.workspaceId]:{detail:G,loading:!1,error:null}})),se.current.forEach(xe=>xe(G))},onTerminalManagerSnapshot:G=>{X.current.forEach(xe=>xe(G))},onUnauthorized:()=>{Js.clear(),s("/login",{replace:!0})}});w.current=i;const u=ee.current,g=_.current,C=L.current,B=y.current,A=K.current,ne=J.current,fe=E.current,ue=ge.current;return u&&i.subscribeFileTree(u.workspaceId,u.paths),C&&i.subscribeGit(C),A&&i.subscribeWorkspaceManagement(A),fe&&i.subscribeTerminalManager(fe),g&&i.requestFileTreeRefresh(g.workspaceId,g.paths),B&&i.requestGitRefresh(B),ne&&i.requestWorkspaceManagementRefresh(ne),ue&&i.requestTerminalManagerRefresh(ue),i.start(),()=>{P.current!==null&&(window.clearTimeout(P.current),P.current=null),w.current===i&&(w.current=null),i.close()}},[s]),l.useEffect(()=>{zn(Va,String(Le))},[Le]),l.useEffect(()=>{zn(Xa,String(at))},[at]),l.useEffect(()=>{zn(Ya,String(Be))},[Be]),l.useEffect(()=>{zn(Ja,String(Ne))},[Ne]),l.useEffect(()=>{if(!Ve){Gh(vo);return}zn(vo,Ve)},[Ve]),l.useEffect(()=>{if(bt||Ne)return;const i=window.setTimeout(()=>{Tn(!0)},sh);return()=>{window.clearTimeout(i)}},[bt,Ne]);const rs=Ys(n.pathname),he=(rs==null?void 0:rs.sessionId)??null,et=he?ql(he):!1,Ie=l.useMemo(()=>Wc(Q),[Q]),dr=l.useMemo(()=>new Set(Q.map(i=>i.workspace.id)),[Q]),os=l.useMemo(()=>new Set(Rt),[Rt]),as=l.useMemo(()=>Ie.filter(i=>i.session.isFavorite===!0).map(i=>i.session.sessionId),[Ie]),At=l.useMemo(()=>new Set(as),[as]),_n=l.useCallback(i=>{const u=No(i,Rt);m.current=u,Lr(u),mt.current=i,rt(i)},[Rt]),ur=l.useCallback(i=>{const u=!os.has(i),g=yi(Rt,i,u),C=No(Q,g);m.current=C,Lr(C),Gt(g),Li(i,{collapsed:u}).catch(B=>{const A=yi(g,i,!u),ne=No(Q,A);m.current=ne,Lr(ne),Gt(A),D.current({title:B instanceof Error?B.message:r("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[os,Rt,Q]),Es=l.useCallback(()=>{be.current={originalGroups:mt.current}},[]),Ws=l.useCallback((i,u,g)=>{const C=mt.current,B=Qh(C,i,u,g);B!==C&&_n(B)},[_n]),is=l.useCallback(()=>{const i=be.current;be.current=null;const u=mt.current;i&&(i.originalGroups.length===u.length&&i.originalGroups.every((g,C)=>{var B;return g.workspace.id===((B=u[C])==null?void 0:B.workspace.id)})||mc({workspaceIds:u.map(g=>g.workspace.id)}).catch(g=>{_n(i.originalGroups),D.current({title:g instanceof Error?g.message:r("shell.workspaceReorderFailed"),tone:"error"})}))},[_n]);l.useEffect(()=>{const i=new Map;if(Ie.forEach(({session:u})=>{i.set(u.sessionId,{activityState:u.activityState,completedAt:u.completedAt??null,runningState:u.runningState??null})}),!pe.current){pe.current=!0,de.current=i;return}Ie.forEach(({session:u})=>{var ne;if(u.sessionId===he)return;const g=de.current.get(u.sessionId);if(!g)return;const C=g.activityState!=="completed_unread"&&u.activityState==="completed_unread",B=((ne=u.title)==null?void 0:ne.trim())||r("common.unknown");if(f&&C){const fe=r("conversation.backgroundCompletionToastDescription",{title:B});D.current({id:`workbench-session-completed-${u.sessionId}-${u.completedAt??"unknown"}`,title:r("conversation.backgroundCompletionToastTitle"),description:fe,tone:"success",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>St(u.workspaceId,u.sessionId)}}),x.current.showNotification(r("conversation.backgroundCompletionToastTitle"),fe)}const A=g.runningState!=="failed"&&(u.runningState??null)==="failed";if(b&&A){const fe=gh(u)??r("conversation.runtimeFailed"),ue=r("conversation.backgroundFailureToastDescription",{title:B,detail:fe});D.current({id:`workbench-session-failed-${u.sessionId}-${u.updatedAt}`,title:r("conversation.backgroundFailureToastTitle"),description:ue,tone:"error",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>St(u.workspaceId,u.sessionId)}}),x.current.showNotification(r("conversation.backgroundFailureToastTitle"),ue)}}),de.current=i},[he,Ie,f,b,St]),l.useEffect(()=>{v.current=Ie.map(i=>i.session).filter(i=>i.sessionId!==he&&mh(i)).map(i=>{var u;return{sessionId:i.sessionId,workspaceId:i.workspaceId,title:((u=i.title)==null?void 0:u.trim())||r("common.unknown")}})},[he,Ie]),l.useEffect(()=>{let i=!1,u=null;const g=()=>{u=window.setTimeout(()=>{C().finally(()=>{i||g()})},ah)},C=async()=>{var ue;const B=v.current;if(B.length===0){He.current||(He.current=!0),Mt.current="";return}const A=new Set(B.map(G=>G.sessionId)),ne=await Promise.all(B.map(async G=>{try{const xe=await gc(G.sessionId);return{session:G,items:xe.items}}catch{return{session:G,items:null}}}));if(i)return;for(const G of ne){if(!G.items)continue;const xe=G.items.filter(_e=>_e.status==="pending"),It=new Set(xe.map(_e=>_e.id)),Dt=Me.current.get(G.session.sessionId)??new Set;He.current&&xe.forEach(_e=>{if(Dt.has(_e.id)||!h)return;const Zt=r("conversation.backgroundPermissionToastDescription",{title:G.session.title,requestTitle:_e.title});D.current({id:`workbench-permission-request-${_e.id}`,title:r("conversation.permissionRequestToastTitle"),description:Zt,tone:"warning",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>St(G.session.workspaceId,G.session.sessionId)}}),x.current.showNotification(r("conversation.permissionRequestToastTitle"),Zt)}),Me.current.set(G.session.sessionId,It)}for(const[G,xe]of Me.current.entries())!A.has(G)&&xe.size===0&&Me.current.delete(G);const fe=bh(Me.current,A);He.current&&fe!==Mt.current&&((ue=w.current)==null||ue.requestRefresh()),Mt.current=fe,He.current=!0};return C().finally(()=>{i||g()}),()=>{i=!0,u!==null&&window.clearTimeout(u)}},[h,St]),l.useEffect(()=>{if(Ue&&Q.length===0)return;const i=new Set(Q.map(u=>u.workspace.id));Gt(u=>Wl(u,i)),In(u=>u&&i.has(u)?u:null)},[Q,Ue]);const mn=Ie.find(i=>i.session.sessionId===he)??null,Ae=(mn==null?void 0:mn.workspace.id)??(he?Cs[he]??null:null),ut=li(n.pathname,n.search),ls=ut&&dr.has(ut)?ut:null,Ps=Ve&&dr.has(Ve)?Ve:null,As=Ae??ls??Ps??null,ie=As??((Bt=Q[0])==null?void 0:Bt.workspace.id)??null,Ls=l.useCallback(i=>{if(i){const u=Ie.find(g=>g.workspace.id===i)??null;if(u)return u}return Ie[0]??null},[Ie]),bn=l.useCallback(i=>{const u=typeof window>"u"?null:window.localStorage.getItem(Dr);if(!u)return null;const g=u.split("?")[0]??u,C=Ys(g);if(!C)return window.localStorage.removeItem(Dr),null;const B=C.sessionId,A=Ie.find(fe=>fe.session.sessionId===B)??null,ne=C.workspaceId??(A==null?void 0:A.workspace.id)??null;return A&&(!i||ne===i)?Ot(A.workspace.id,A.session.sessionId):(window.localStorage.removeItem(Dr),null)},[Ie]),cs=l.useMemo(()=>ln.filter(i=>!Xt.has(i.id)),[Xt,ln]),Fn=l.useMemo(()=>cs.filter(i=>jh(i,Wt)).length,[cs,Wt]);l.useEffect(()=>{xt&&Ts(cs)},[cs,Ts,xt]);const io=l.useCallback(i=>{yt(!1),i.routePath&&s(i.routePath)},[s]),On=l.useCallback(async(i,u)=>{const g=me.current+1;me.current=g;try{const C=await Au(i,u);if(g!==me.current)return;Ze(B=>{const A=new Set(B);return C.item?A.add(C.item.notificationId):A.delete(i),A})}catch(C){if(g!==me.current)return;D.current({title:r("shell.globalNotificationsArchiveFailed"),description:C instanceof Error?C.message:void 0,tone:"error"})}},[]);l.useEffect(()=>{Ae&&In(i=>i===Ae?i:Ae)},[Ae]),l.useEffect(()=>{var A;if(Ue)return;const i=((A=Q[0])==null?void 0:A.workspace.id)??null,u=ls??i??Ps,g=he&&!et?Ls(u):null,C=he&&!et?bn(u):null,B=g?Ot(g.workspace.id,g.session.sessionId):null;if(ut&&!ls){s(C??B??(i?Mh(n.pathname,i):jo(e)),{replace:!0});return}if(he&&!et&&!Ae){s(C??B??(i?Zs(i):jo(e)),{replace:!0});return}},[he,Ls,et,n.pathname,s,Q,Ue,bn,ut,Ae,e,Ps,ls]),l.useEffect(()=>{pt("workbench.current_workspace_resolved",{currentSessionId:he,sessionWorkspaceId:Ae,routeWorkspaceId:ut,currentWorkspaceId:ie,source:Ae?mn?"navigation":"sessionWorkspaceMap":ut?"route":Ve?"workspaceSelection":"navigationFallback"})},[mn,he,ie,ut,Ve,Ae]),l.useEffect(()=>{pt("workbench.info_panel_state",{infoPanelReady:bt,rightCollapsed:Ne,currentWorkspaceId:ie,sessionWorkspaceId:Ae,currentSessionId:he})},[he,ie,bt,Ne,Ae]);const ht=Wo(n.pathname)?"terminals":zr(n.pathname)?"butler":"conversation",Pe=e==="mobile",Hn=jo(e),hr=l.useMemo(()=>Q.map(i=>{const u=yl(i.sessions);return{workspace:i.workspace,visibleSessions:u,archivedSessions:i.sessions.filter(g=>Ht(g)&&!to(g)),visibleSessionTree:ra(u,c).filter(g=>!At.has(g.item.sessionId)&&!qo(Tt(g),C=>At.has(C.sessionId))),childWorktrees:Nl(i.childWorktrees,At,c),isCollapsed:os.has(i.workspace.id)}}),[os,At,Q,c]),Bs=l.useMemo(()=>vu(Q),[Q]),ft=l.useMemo(()=>Xh(Q,ie),[ie,Q]),fr=l.useMemo(()=>ie?(ft==null?void 0:ft.workspace)??Q.map(i=>i.workspace).find(i=>i.id===ie)??null:null,[ie,ft,Q]),Un=(ft==null?void 0:ft.meta)??null,Nt=(ie?Bs[ie]??null:null)??(fr?sa(fr):null),pr=Un?Je[Un.workspaceId]??null:null,$n=l.useMemo(()=>Ie.filter(i=>At.has(i.session.sessionId)&&!Ht(i.session)&&!Po(i.session)),[At,Ie]),Ds=n.pathname.startsWith("/settings")?"settings":zr(n.pathname)?"terminals":Wo(n.pathname)?"butler":Th(n.pathname)?n.pathname.endsWith("/tools/processes")||n.pathname==="/tools/processes"?"butler":"sessions":Ih(n.pathname)||ci(n.pathname)?"sessions":"workspaces",lo=Pe&&(Ds==="sessions"&&ci(n.pathname)||zr(n.pathname)),mr=Qr({isNativeMobile:o.isNativeMobile,viewportClass:o.viewportClass}),_s=er({viewportClass:o.viewportClass,activeEntry:Ds,hasNavigationPanel:Pe,hasAuxiliaryPanel:Pe,preferCompactLayout:mr}),br=Pe&&tl(_s),gr=Pe&&nl(_s),ds=l.useMemo(()=>Q.map(i=>i.workspace),[Q]),co=l.useMemo(()=>{const i=Et.trim().toLowerCase();return i?Ie.filter(u=>{const g=(u.session.title||"").toLowerCase(),C=u.workspace.name.toLowerCase(),B=no(u.session.provider,"full").toLowerCase();return g.includes(i)||C.includes(i)||B.includes(i)}):[]},[Ie,Et]);l.useEffect(()=>{var u;const i=ie??((u=Q[0])==null?void 0:u.workspace.id)??"";i&&Is(g=>g&&Q.some(B=>B.workspace.id===g)?g:i)},[ie,Q]),l.useEffect(()=>{he&&!et&&Ae&&zn(Dr,`${n.pathname}${n.search}`)},[he,et,n.pathname,n.search,Ae]),l.useEffect(()=>{if(he&&et){F.current=`${n.pathname}${n.search}`;return}he&&!et&&(F.current=null)},[he,et,n.pathname,n.search]),l.useEffect(()=>{Pe||(ke(!1),We(!1))},[Pe]),l.useEffect(()=>{!Pe||Ue||!Ch(n.pathname)||As||(ke(!1),We(!1),s(Hn,{replace:!0}))},[As,Pe,n.pathname,s,Ue,Hn]);function uo(){if(Pe){ke(!0);return}Xn(!1)}function ho(){if(Jt(),Pe){We(!0);return}qt(!1)}function fo(){if(Pe){ke(i=>!i);return}Xn(i=>!i)}function po(){if(Jt(),Pe){We(i=>!i);return}qt(i=>!i)}function Jt(){Tn(!0)}function us(i){In(i),Jt(),he&&Ae!==i&&s(Hn)}const hs=l.useCallback(async i=>{var C;const u=((C=Ie.find(B=>B.session.sessionId===i))==null?void 0:C.session)??null,g=(u==null?void 0:u.isFavorite)!==!0;rt(B=>xi(B,i,g));try{const B=await bc(i,g);nt(B),Ge()}catch(B){throw rt(A=>xi(A,i,!g)),B}},[Ie,Ge,nt]),kr=l.useCallback((i,u)=>{wl(i,u).then(()=>{s(Ji(i,u))}).catch(g=>{a({title:g instanceof Error?g.message:r("shell.startSessionFailed"),tone:"error"})})},[s,a]),wr=l.useCallback(i=>{var C;const u=((C=i.workspaceId)==null?void 0:C.trim())||ie,g=Rh(i.filePath);return!u||!g?!1:(Jt(),sn("files"),Pe?(ke(!1),We(!0)):qt(!1),or({requestId:H.current+1,workspaceId:u,filePath:g,openViewer:i.openViewer===!0}),H.current+=1,!0)},[ie,Pe]),xr=l.useCallback(async(i,u)=>{const g=await Bi(i,u.trim());return nt(g),g},[nt]);function Fs(i){Rn(!0)}function yr(){Rn(!1),En("sessions"),Wn(""),Kt(null),kt([]),Pn(!1)}async function vr(){const i=Et.trim();if(!i||!gt.trim()){kt([]),Kt(null);return}Pn(!0),Kt(null);try{const u=await Ic(gt,i);kt(u.items)}catch(u){kt([]),Kt(u instanceof Error?u.message:r("shell.searchCodeFailed"))}finally{Pn(!1)}}function Sr(i,u){const g=S.current;g&&(g.style.setProperty("--workbench-left-width",`${i}px`),g.style.setProperty("--workbench-left-current-width",Be?"0px":`${i}px`),g.style.setProperty("--workbench-right-width",`${u}px`),g.style.setProperty("--workbench-right-current-width",Ne?"0px":`${u}px`))}function gn(i={}){return{leftWidth:i.leftWidth??(Be?0:Y.current),rightWidth:i.rightWidth??(oe&&!Ne?T.current:0),leftCollapsed:i.leftCollapsed??Be,rightCollapsed:i.rightCollapsed??(!oe||Ne),prefersDarkAppearance:i.prefersDarkAppearance??Bn!=="light",isResizing:i.isResizing??it!==null}}function Os(i,u){var fe;u.preventDefault(),u.stopPropagation(),(fe=window.getSelection())==null||fe.removeAllRanges();const g=u.clientX,C=i==="left"?Le:at;js(i);const B=()=>{const ue=q.current;if(q.current=null,ue!==null){if(i==="left"){Y.current=ue,sr(G=>G===ue?G:ue),Sr(ue,T.current);return}T.current=ue,rr(G=>G===ue?G:ue),Sr(Y.current,ue)}};function A(ue){var Dt;ue.preventDefault(),(Dt=window.getSelection())==null||Dt.removeAllRanges();const G=ue.clientX-g,xe=i==="left"?Hr(C+G,Qa,ti):Hr(C-G,ei,ni),It=i==="left"?Y.current:T.current;xe===It&&q.current===null||(q.current=xe,re.current===null&&(re.current=window.requestAnimationFrame(()=>{re.current=null,B()})))}function ne(){document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",ne),re.current!==null&&(window.cancelAnimationFrame(re.current),re.current=null),B(),js(G=>G===i?null:G);const ue=gn({isResizing:!1});Oe.current=ue,o.bridge.syncNativeSidebarLayout(ue)}document.addEventListener("mousemove",A,{passive:!1}),document.addEventListener("mouseup",ne)}function qn(){if(p())return;if(Ie.length===0){s(Hn);return}const i=Ot(Ie[0].workspace.id,Ie[0].session.sessionId);s(i)}function d(){if(!p(ie)){if(ie){s(Zs(ie));return}s(Hn)}}function p(i){if(he&&Ae)return i&&Ae&&Ae!==i?!1:(s(`${n.pathname}${n.search}`),!0);if(F.current){if(i){const[g,C=""]=F.current.split("?"),B=li(g??F.current,C?`?${C}`:"");if(B&&B!==i)return!1}return s(F.current),!0}const u=bn(i);return u?(s(u),!0):!1}l.useEffect(()=>{if(typeof window>"u")return;function i(u){if(!(u.metaKey||u.ctrlKey)){u.key==="Escape"&&(ke(!1),We(!1));return}if(Kh(u.target))return;const C=u.key.toLowerCase();if(!u.shiftKey&&C==="b"){u.preventDefault(),fo();return}if(u.shiftKey&&C==="i"){u.preventDefault(),po();return}if(!u.shiftKey&&C===","){u.preventDefault(),s("/settings");return}if(!u.shiftKey&&C==="1"){u.preventDefault(),qn();return}if(!u.shiftKey&&C==="2"){u.preventDefault(),s(ie?ws(ie):st());return}if(!u.shiftKey&&C==="k"){u.preventDefault(),Vh();return}u.shiftKey&&C==="r"&&(u.preventDefault(),qe())}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[s,qe,Pe,qn]);const k=l.useMemo(()=>({shellMode:e,navigationGroups:Q,navigationLoading:Ue,navigationError:ot,currentWorkspaceId:ie,currentSessionId:he,favoriteSessionIds:as,favoriteSessions:$n,globalNotifications:ln,archivedNotificationIds:Array.from(Xt),showArchivedNotifications:Yt,unreadNotificationCount:Fn,refreshNavigation:qe,requestNavigationRefresh:Ge,openNotificationPanel:()=>{yt(!0)},closeNotificationPanel:()=>{yt(!1)},setShowArchivedNotifications:dn,archiveNotification:i=>{On(i,!0)},unarchiveNotification:i=>{On(i,!1)},setAuxiliaryPanel:$e,subscribeFileTree:Pt,requestFileTreeRefresh:ns,addFileTreeSnapshotListener:un,subscribeGitSnapshot:hn,requestGitRefresh:ct,addGitSnapshotListener:lr,subscribeWorkspaceManagementSnapshot:ss,requestWorkspaceManagementRefresh:Dn,addWorkspaceManagementSnapshotListener:jt,workspaceManagementStateById:Vt,subscribeTerminalManagerSnapshot:fn,requestTerminalManagerRefresh:lt,addTerminalManagerSnapshotListener:Rs,selectWorkspace:us,toggleFavoriteSession:hs,archiveSession:i=>Ke(i,!0),unarchiveSession:i=>Ke(i,!1),renameSession:xr,startDraftSession:kr,markNavigationSessionSeen:dt,upsertNavigationSession:nt,setSessionWorkspace:pn,revealWorkspaceFile:wr}),[un,lr,jt,Rs,Ke,he,ie,ln,as,$n,us,Xt,dt,ot,Q,Ue,Fn,ns,ct,Dn,qe,Ge,dn,$e,lt,xr,Yt,Vt,e,kr,pn,Pt,hn,ss,fn,On,hs,nt,wr]),R={"--workbench-left-width":`${Le}px`,"--workbench-left-current-width":Be?"0px":`${Le}px`,"--workbench-right-width":`${at}px`,"--workbench-right-current-width":Ne?"0px":`${at}px`},W=ht==="butler"?Xe:t.jsx(ji,{panelReady:bt,activeTab:Ns,fileRevealRequest:rn,onTabChange:i=>{Jt(),sn(i)},currentSessionId:et?null:he,activeWorkspaceId:ie,navigationGroups:Q,workspaceContext:Nt,worktreeMeta:Un,worktreeMergeState:pr,onRefreshWorktreeMergePreview:ze,onApplyWorktreeMerge:cr,onCleanupWorktree:Ce}),oe=W!==null,V=o.isDesktop&&o.ui.osFamily==="macos"&&o.ui.prefersOverlayTitlebar;l.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:i,body:u}=document,g=()=>{te.current!==null&&(window.clearTimeout(te.current),te.current=null);const B=z.current;z.current=!1,i.removeAttribute(Fr),u==null||u.removeAttribute(Fr),B&&ae.current&&(ae.current=!1,tt(A=>A+1))};if(!V){g();return}const C=()=>{z.current=!0,i.setAttribute(Fr,"true"),u==null||u.setAttribute(Fr,"true"),te.current!==null&&window.clearTimeout(te.current),te.current=window.setTimeout(()=>{g()},lh)};return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C),g()}},[V]);const we=l.useMemo(()=>({leftWidth:Be?0:Le,rightWidth:oe&&!Ne?at:0,leftCollapsed:Be,rightCollapsed:!oe||Ne,prefersDarkAppearance:Bn!=="light",isResizing:it!==null}),[it,Be,Le,Ne,at,oe,Bn]),De=l.useDeferredValue(we),Re=it===null?De:we,Oe=l.useRef(we);l.useEffect(()=>{Oe.current=we},[we]),l.useEffect(()=>{if(typeof window>"u")return;let i=null;const u=()=>{i=null,o.bridge.syncNativeSidebarLayout(Re)},g=()=>{i!==null&&window.cancelAnimationFrame(i),i=window.requestAnimationFrame(u)};return Qe?(g(),()=>{i!==null&&window.cancelAnimationFrame(i)}):(o.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{i!==null&&window.cancelAnimationFrame(i)})},[Re,o.bridge,Qe]),l.useLayoutEffect(()=>{const i=S.current;if(!i||!V||typeof window>"u"){ai(i);return}let u=null,g=null;const C=new Set([i]),B=()=>{ae.current=!1;const ne=window.getComputedStyle(i),fe=kl(ne,"--desktop-macos-traffic-light-center-y");if(fe===null){ai(i);return}const ue={navToolbar:yn(i,Te.navToolbar.selector),infoTabs:yn(i,Te.infoTabs.selector),auxiliaryToolbarButton:yn(i,Te.auxiliaryToolbarButton.selector),conversationHeaderMain:yn(i,Te.conversationHeaderMain.selector),conversationHeaderActions:yn(i,Te.conversationHeaderActions.selector),terminalTabbarMain:yn(i,Te.terminalTabbarMain.selector),collapsedLeftControls:yn(i,Te.collapsedLeftControls.selector),collapsedRightControls:yn(i,Te.collapsedRightControls.selector)},G=[ue.infoTabs,ue.conversationHeaderMain,ue.conversationHeaderActions,ue.terminalTabbarMain].filter(_e=>_e!==null),xe=[ue.collapsedLeftControls,ue.collapsedRightControls].filter(_e=>_e!==null),It=xe.length>0?Ft(ne,"--workbench-collapsed-controls-live-shift-y",fe,xe.reduce((_e,Zt)=>_e+Zt,0)/xe.length):null,Dt=G.length>0?Ft(ne,"--workbench-titlebar-live-content-shift-y",fe,G.reduce((_e,Zt)=>_e+Zt,0)/G.length):null;_t(i,"--workbench-titlebar-live-content-shift-y",Dt),_t(i,"--workbench-collapsed-controls-live-shift-y",It),_t(i,Te.navToolbar.variableName,Ft(ne,Te.navToolbar.variableName,fe,ue.navToolbar)),_t(i,Te.infoTabs.variableName,Ft(ne,Te.infoTabs.variableName,fe,ue.infoTabs)),_t(i,Te.auxiliaryToolbarButton.variableName,Ft(ne,Te.auxiliaryToolbarButton.variableName,fe,ue.auxiliaryToolbarButton)),_t(i,Te.conversationHeaderMain.variableName,Ft(ne,Te.conversationHeaderMain.variableName,fe,ue.conversationHeaderMain)),_t(i,Te.conversationHeaderActions.variableName,Ft(ne,Te.conversationHeaderActions.variableName,fe,ue.conversationHeaderActions)),_t(i,Te.terminalTabbarMain.variableName,Ft(ne,Te.terminalTabbarMain.variableName,fe,ue.terminalTabbarMain)),_t(i,Te.collapsedLeftControls.variableName,Ft(ne,Te.collapsedLeftControls.variableName,fe,ue.collapsedLeftControls)),_t(i,Te.collapsedRightControls.variableName,Ft(ne,Te.collapsedRightControls.variableName,fe,ue.collapsedRightControls))},A=()=>{if(z.current){ae.current=!0;return}u!==null&&window.cancelAnimationFrame(u),u=window.requestAnimationFrame(()=>{u=null,B()})};if(A(),typeof ResizeObserver<"u"){g=new ResizeObserver(()=>{A()});for(const ne of Object.values(Te))for(const fe of i.querySelectorAll(ne.selector))C.add(fe);for(const ne of C)g.observe(ne)}return window.addEventListener("resize",A),()=>{u!==null&&window.cancelAnimationFrame(u),window.removeEventListener("resize",A),g==null||g.disconnect()}},[ht,bt,Be,n.pathname,n.search,Ne,oe,V,ir]);const Ct=Pe?t.jsx(Si,{workspaceGroups:hr,workspaceVisualContextMap:Bs,sessionDisplaySortMode:c,favoriteSessions:$n,favoriteSessionIds:At,activeWorkspaceId:ie,isConversationActive:ht==="conversation",isTerminalActive:ht==="terminals",isButlerActive:ht==="butler",isSearchOpen:Mn,navigationLoading:Ue,navigationError:ot,activeSessionId:he,onRefreshNavigation:qe,onSessionUpdated:nt,onNavigateConversation:qn,onNavigateTerminals:()=>{ke(!1),s(ie?ws(ie):st())},onNavigateButler:()=>{ke(!1),s(ie?Kn(ie):st())},onOpenSearch:()=>{ke(!1),Fs()},onOpenSettings:()=>{ke(!1),s("/settings")},onSelectWorkspace:us,onToggleWorkspaceCollapse:ur,onStartWorkspaceReorder:Es,onPreviewWorkspaceReorder:Ws,onCommitWorkspaceReorder:is,allowWorkspaceReorder:!1,subscribeGitSnapshot:hn,requestGitRefresh:ct,subscribeWorkspaceManagementSnapshot:ss,requestWorkspaceManagementRefresh:Dn,onToggleFavoriteSession:hs,onArchiveSession:i=>Ke(i,!0),onUnarchiveSession:i=>Ke(i,!1),workspaceManagementStateById:Vt,setWorkspaceManagementStateById:on,unreadNotificationCount:Fn,notificationPanelOpen:xt,onToggleNotificationPanel:()=>{yt(i=>!i)},onClose:()=>ke(!1)}):null,Lt=Pe&&oe?W:null;return t.jsxs(xl.Provider,{value:k,children:[Pe?t.jsx(t.Fragment,{children:t.jsx(od,{activeEntry:Ds,presentation:lo?"conversation-focus":"default",navigationPanel:Ct,auxiliaryPanel:Lt,onOpenNavigation:()=>{We(!1),ke(!0)},onOpenSearch:()=>{ke(!1),We(!1),Fs()},onOpenAuxiliary:()=>{oe&&(Jt(),ke(!1),We(!0))},onNavigateWorkspaces:()=>{ke(!1),We(!1),s(st())},onNavigateTerminals:()=>{ke(!1),We(!1),s(ie?ws(ie):st())},onNavigateButler:()=>{ke(!1),We(!1),s(ie?Kn(ie):st())},onNavigateSessions:()=>{ke(!1),We(!1),d()},onNavigateToolFiles:()=>{ke(!1),We(!1),s(ie?Vi(ie):st())},onNavigateToolGit:()=>{ke(!1),We(!1),s(ie?Xi(ie):st())},onNavigateToolProcesses:()=>{ke(!1),We(!1),s(ie?Yi(ie):st())},onNavigateSettings:()=>{ke(!1),We(!1),s("/settings")},children:t.jsx(la,{})})}):t.jsx("div",{className:"workbench-shell",ref:S,style:R,onMouseDownCapture:ar,onDoubleClickCapture:ao,"data-nav-loading":Ue,"data-left-collapsed":Be,"data-right-collapsed":Ne,"data-info-ready":bt,"data-runtime-platform":o.platform,"data-os-family":o.ui.osFamily,"data-overlay-titlebar":o.ui.prefersOverlayTitlebar,children:t.jsxs("div",{className:"workbench-body-shell",children:[t.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":Be,children:t.jsx(Si,{workspaceGroups:hr,workspaceVisualContextMap:Bs,sessionDisplaySortMode:c,favoriteSessions:$n,favoriteSessionIds:At,activeWorkspaceId:ie,isConversationActive:ht==="conversation",isTerminalActive:ht==="terminals",isButlerActive:ht==="butler",isSearchOpen:Mn,navigationLoading:Ue,navigationError:ot,activeSessionId:he,onRefreshNavigation:qe,onSessionUpdated:nt,onNavigateConversation:qn,onNavigateTerminals:()=>s(ie?ws(ie):st()),onNavigateButler:()=>s(ie?Kn(ie):st()),onOpenSearch:()=>Fs(),onOpenSettings:()=>s("/settings"),onSelectWorkspace:us,onToggleWorkspaceCollapse:ur,onStartWorkspaceReorder:Es,onPreviewWorkspaceReorder:Ws,onCommitWorkspaceReorder:is,allowWorkspaceReorder:!0,subscribeGitSnapshot:hn,requestGitRefresh:ct,subscribeWorkspaceManagementSnapshot:ss,requestWorkspaceManagementRefresh:Dn,onToggleFavoriteSession:hs,onArchiveSession:i=>Ke(i,!0),onUnarchiveSession:i=>Ke(i,!1),workspaceManagementStateById:Vt,setWorkspaceManagementStateById:on,unreadNotificationCount:Fn,notificationPanelOpen:xt,onToggleNotificationPanel:()=>{yt(i=>!i)},onToggleCollapse:()=>Xn(!0)})}),t.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":Be,role:"separator","aria-label":r("shell.leftResizerLabel"),onMouseDown:Be?void 0:i=>Os("left",i)}),t.jsxs("div",{className:"workbench-main-shell",children:[t.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!Be&&!Ne,children:[t.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":Be,children:[t.jsx(vi,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:uo}),t.jsx(bl,{collapsed:!0}),t.jsx(Hl,{unreadCount:Fn,open:xt,onToggle:()=>{yt(i=>!i)},collapsed:!0})]}),oe?t.jsx("div",{className:"workbench-collapsed-controls right","data-visible":Ne,children:t.jsx(vi,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:ho})}):null]}),t.jsx(la,{})]}),oe?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Ne,role:"separator","aria-label":r("shell.rightResizerLabel"),onMouseDown:Ne?void 0:i=>Os("right",i)}),t.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(Nt==null?void 0:Nt.tone)??"root","data-worktree-depth":(Nt==null?void 0:Nt.depth)??0,"data-collapsed":Ne,"data-custom-panel":ht==="butler",style:Qt(Nt),children:ht==="butler"?t.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Xe}):t.jsx(ji,{panelReady:bt,activeTab:Ns,fileRevealRequest:rn,onTabChange:i=>{Jt(),sn(i)},onToggleCollapse:()=>qt(!0),currentSessionId:et?null:he,activeWorkspaceId:ie,navigationGroups:Q,workspaceContext:Nt,worktreeMeta:Un,worktreeMergeState:pr,onRefreshWorktreeMergePreview:ze,onApplyWorktreeMerge:cr,onCleanupWorktree:Ms})})]}):null]})}),t.jsx(ff,{open:xt,notifications:ln,archivedNotificationIds:Xt,showArchivedNotifications:Yt,onClose:()=>yt(!1),onToggleShowArchivedNotifications:dn,onArchiveNotification:i=>{On(i,!0)},onUnarchiveNotification:i=>{On(i,!1)},onSelectNotification:io,preferredWorkspaceId:ie,preferredSessionId:et?null:he}),t.jsx(Rf,{open:Mn,mode:Jn,keyword:Et,codeWorkspaceId:gt,codeResults:An,codeLoading:ro,codeError:oo,workspaceOptions:ds,sessionResults:co,onClose:yr,onModeChange:i=>{En(i),Kt(null),kt([])},onKeywordChange:i=>{Wn(i),Jn==="code"&&!i.trim()&&(kt([]),Kt(null))},onCodeWorkspaceChange:i=>Is(i),onCodeSearch:()=>{vr()},onOpenSession:i=>{yr();const u=Ie.find(g=>g.session.sessionId===i)??null;s(u?Ot(u.workspace.id,i):st())}}),t.jsxs(Fe,{open:ve!==null,title:r("shell.worktreeCleanupModalTitle"),description:r("shell.worktreeCleanupModalDescription"),onClose:()=>{var i;ve&&((i=Je[ve.workspaceId])!=null&&i.cleaning)||(Ln(!1),Qn(null))},children:[t.jsx("p",{className:"workbench-section-empty",children:ve?r("shell.worktreeCleanupConfirm",{name:ve.displayName||ve.branchName}):""}),ve?t.jsxs("div",{className:"worktree-cleanup-modal-options",children:[t.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[t.jsx("input",{type:"checkbox",checked:an,disabled:!!((je=Je[ve.workspaceId])!=null&&je.cleaning)||((fs=(jr=Je[ve.workspaceId])==null?void 0:jr.preview)==null?void 0:fs.alreadyMerged)!==!0,onChange:i=>Ln(i.target.checked)}),t.jsx("span",{children:r("shell.worktreeCleanupDeleteBranchLabel",{branch:ve.branchName})})]}),((Cr=(Nr=Je[ve.workspaceId])==null?void 0:Nr.preview)==null?void 0:Cr.alreadyMerged)!==!0?t.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:r("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!(ve&&((Ir=Je[ve.workspaceId])!=null&&Ir.cleaning)),onClick:()=>{Ln(!1),Qn(null)},children:r("common.cancel")}),t.jsx("button",{type:"button",className:an&&ve&&((wn=(Tr=Je[ve.workspaceId])==null?void 0:Tr.preview)==null?void 0:wn.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!ve||!!(ve&&((xn=Je[ve.workspaceId])!=null&&xn.cleaning)),onClick:()=>{ve&&Ce(ve)},children:ve&&((oa=Je[ve.workspaceId])!=null&&oa.cleaning)?r("shell.worktreeCleanupRunning"):an&&ve&&((ia=(aa=Je[ve.workspaceId])==null?void 0:aa.preview)==null?void 0:ia.alreadyMerged)===!0?r("shell.worktreeCleanupDeleteBranchAction"):r("shell.worktreeCleanupAction")})]})]}),Pe?t.jsxs(t.Fragment,{children:[br?null:t.jsx(Ni,{isOpen:Yn,side:"left",onClose:()=>ke(!1),children:Ct}),gr?null:t.jsx(Ni,{isOpen:zt,side:"right",onClose:()=>We(!1),children:Lt})]}):null]})}function Ni({isOpen:e,side:n,onClose:s,children:o,className:a,overlayClassName:c}){if(!e)return null;const h=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:["mobile-nav-overlay","open",c].filter(Boolean).join(" "),onClick:s,role:"button",tabIndex:0,"aria-label":r("common.back"),onKeyDown:f=>{f.key==="Escape"&&s()}}),t.jsx("div",{className:["mobile-nav-drawer",n,"open",a].filter(Boolean).join(" "),children:o})]});return typeof document>"u"?h:Zr.createPortal(h,document.body)}function Hp(){return l.useContext(xl)??{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 ql(e){return e.startsWith("draft-")}export{st as $,nu as A,zu as B,su as C,Zo as D,ku as E,tu as F,vu as G,ap as H,vn as I,Ss as J,bs as K,Dp as L,Pp as M,Ap as N,_p as O,Ep as P,Qo as Q,lu as R,cu as S,cp as T,rl as U,Qt as V,md as W,pt as X,Wc as Y,sa as Z,ip as _,Op as a,qo as a0,pd as a1,lp as a2,dp as a3,up as a4,gp as a5,kp as a6,bp as a7,pp as a8,hp as a9,Gf as aA,Rc as aB,Zf as aC,tp as aD,Tc as aE,op as aF,Qf as aG,Yf as aH,ep as aI,Jf as aJ,rp as aK,sp as aL,np as aM,zf as aN,Uf as aO,zi as aP,Mp as aa,fp as ab,jp as ac,Wp as ad,Lp as ae,Bp as af,Tp as ag,yp as ah,vp as ai,Sp as aj,Np as ak,Cp as al,Ip as am,mp as an,wp as ao,xp as ap,Rp as aq,xu as ar,Du as as,Eo as at,Kf as au,Xf as av,Vf as aw,$f as ax,Ic as ay,qf as az,Ot as b,Qu as c,Gu as d,Fp as e,Tu as f,Iu as g,ml as h,iu as i,Zs as j,ws as k,Eu as l,La as m,Ki as n,Kn as o,Yi as p,Ut as q,Vr as r,hu as s,pu as t,Hp as u,Vi as v,Xs as w,Xi as x,uu as y,ea as z};
|