@jingyi0605/codingns 0.6.0 → 0.6.1

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.
Files changed (170) hide show
  1. package/bin/codingns.mjs +15 -2
  2. package/dist/public/assets/{AdaptiveButlerPage-uFwDdN-F.js → AdaptiveButlerPage-Dw72U3hG.js} +3 -3
  3. package/dist/public/assets/{App-BZvapsi8.js → App-Dsf3ooXU.js} +3 -3
  4. package/dist/public/assets/{BootstrapPage-gHSoa4JN.js → BootstrapPage-CE0m1qSR.js} +1 -1
  5. package/dist/public/assets/ConversationPage-8wOY7SX-.js +4 -0
  6. package/dist/public/assets/{DesktopDetachPreviewPage-4eMRxiBW.js → DesktopDetachPreviewPage-Dxarr_Wf.js} +1 -1
  7. package/dist/public/assets/DesktopWindowPage-VytPwJ4c.js +2 -0
  8. package/dist/public/assets/FileContextPanel-DwFzLsOp.js +1 -0
  9. package/dist/public/assets/GitSidebar-CH6WqTrM.js +6 -0
  10. package/dist/public/assets/MobileCreateSessionSheet-DcxKM00P.js +1 -0
  11. package/dist/public/assets/{MobileTopHeaderFrame-Bwv8Ovm_.js → MobileTopHeaderFrame-C5rIKQT6.js} +1 -1
  12. package/dist/public/assets/MobileWorkspaceSwitcherHeader-CfUnHgv_.js +1 -0
  13. package/dist/public/assets/{RelayConnectEntryPage-D_4YL-YH.js → RelayConnectEntryPage-CgMvVZwa.js} +1 -1
  14. package/dist/public/assets/{ServerSettingsModal-CMSm3BZU.js → ServerSettingsModal-CFul__z1.js} +1 -1
  15. package/dist/public/assets/SessionIndexPage-B-tRhBXC.js +1 -0
  16. package/dist/public/assets/SettingsPage-C9LGxSQZ.js +1 -0
  17. package/dist/public/assets/TerminalManagerPanel-BbORd-ee.js +1 -0
  18. package/dist/public/assets/{TerminalPage-DaooFaJ4.js → TerminalPage-DWHv6mlu.js} +1 -1
  19. package/dist/public/assets/TerminalRuntimeFallbackModal-B29YxbQe.js +1 -0
  20. package/dist/public/assets/{ToolFilesPage-CGxBvYG0.js → ToolFilesPage-Dx9cv9hu.js} +1 -1
  21. package/dist/public/assets/ToolGitPage-D7H3vAia.js +1 -0
  22. package/dist/public/assets/ToolProcessesPage-PqQWxsy-.js +1 -0
  23. package/dist/public/assets/ToolsHomePage-CX05Pe_4.js +1 -0
  24. package/dist/public/assets/WorkbenchLandingPage-CchkAC75.js +1 -0
  25. package/dist/public/assets/WorkbenchLayout-pOZvEqp7.js +3 -0
  26. package/dist/public/assets/{WorkbenchModal-0tPIIhca.js → WorkbenchModal-ColqvV6a.js} +1 -1
  27. package/dist/public/assets/WorkbenchShellRoute-C0_h4lP6.js +1 -0
  28. package/dist/public/assets/WorkbenchShellRoute-RGZpA0_J.css +1 -0
  29. package/dist/public/assets/WorkspaceDebugDetailPage-Deqy2_pO.js +1 -0
  30. package/dist/public/assets/WorkspaceDetailPage-Cvf-ZdlB.js +1 -0
  31. package/dist/public/assets/WorkspaceHomePage-Dsyvqyk1.js +1 -0
  32. package/dist/public/assets/{client-runtime-manager-BZpL17fc.js → client-runtime-manager-DROQJ9v3.js} +1 -1
  33. package/dist/public/assets/{file-tree-icon-Db5LXC8h.js → file-tree-icon-Bp3Ntt7u.js} +1 -1
  34. package/dist/public/assets/index-B84Po2NA.css +1 -0
  35. package/dist/public/assets/index-C-0oeG_5.js +42 -0
  36. package/dist/public/assets/legna-code-6TqgZ4Ls.png +0 -0
  37. package/dist/public/assets/{login-direct-candidate-resolver-1mxe_Oh8.js → login-direct-candidate-resolver-DotM530R.js} +1 -1
  38. package/dist/public/assets/model-switch-api-Bh9nYslz.js +1 -0
  39. package/dist/public/assets/{preferences-service-DWnzl5a0.js → preferences-service-BG6GKG29.js} +1 -1
  40. package/dist/public/assets/{relay-entry-C5_Iay0I.js → relay-entry-pmr-c42O.js} +1 -1
  41. package/dist/public/assets/session-runtime-machine-YN84QBlr.js +21 -0
  42. package/dist/public/assets/{terminal-runtime-meta-cdtWVfCm.js → terminal-runtime-meta-8_uRZf7h.js} +1 -1
  43. package/dist/public/assets/useRegisteredDebugTemplates-DWX7LXQu.js +1 -0
  44. package/dist/public/index.html +2 -2
  45. package/dist/server/config/env.d.ts +2 -0
  46. package/dist/server/config/env.js +7 -0
  47. package/dist/server/config/env.js.map +1 -1
  48. package/dist/server/modules/model-switch/cc-switch-adapter.d.ts +7 -0
  49. package/dist/server/modules/model-switch/cc-switch-adapter.js +17 -0
  50. package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
  51. package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +4 -0
  52. package/dist/server/modules/parallel-sessions/parallel-session-controller.js +7 -0
  53. package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -1
  54. package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +6 -1
  55. package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +36 -2
  56. package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -1
  57. package/dist/server/modules/provider/opencode-model-options.d.ts +1 -0
  58. package/dist/server/modules/provider/opencode-model-options.js +54 -12
  59. package/dist/server/modules/provider/opencode-model-options.js.map +1 -1
  60. package/dist/server/modules/provider/provider-controller.d.ts +6 -1
  61. package/dist/server/modules/provider/provider-controller.js +24 -2
  62. package/dist/server/modules/provider/provider-controller.js.map +1 -1
  63. package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +2 -0
  64. package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
  65. package/dist/server/modules/provider/provider-discovery-helper-process.js +1 -1
  66. package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
  67. package/dist/server/modules/provider/provider-discovery-runtime.js +5 -1
  68. package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
  69. package/dist/server/modules/sessions/claude-runtime-helper-client.d.ts +1 -0
  70. package/dist/server/modules/sessions/claude-runtime-helper-client.js +14 -0
  71. package/dist/server/modules/sessions/claude-runtime-helper-client.js.map +1 -1
  72. package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +1 -0
  73. package/dist/server/modules/sessions/codex-app-server-helper-client.js +10 -0
  74. package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
  75. package/dist/server/modules/sessions/provider-session-delete-cli.js +2 -0
  76. package/dist/server/modules/sessions/provider-session-delete-cli.js.map +1 -1
  77. package/dist/server/modules/sessions/session-controller.d.ts +7 -0
  78. package/dist/server/modules/sessions/session-controller.js +22 -0
  79. package/dist/server/modules/sessions/session-controller.js.map +1 -1
  80. package/dist/server/modules/sessions/session-history-service.d.ts +12 -2
  81. package/dist/server/modules/sessions/session-history-service.js +284 -16
  82. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  83. package/dist/server/modules/sessions/session-live-runtime-service.d.ts +15 -2
  84. package/dist/server/modules/sessions/session-live-runtime-service.js +265 -50
  85. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  86. package/dist/server/modules/sessions/session-message-attachment-service.js +2 -2
  87. package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -1
  88. package/dist/server/modules/sessions/session-provider-config-service.d.ts +66 -0
  89. package/dist/server/modules/sessions/session-provider-config-service.js +821 -0
  90. package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -0
  91. package/dist/server/modules/sessions/session-provider-error-mapper.d.ts +2 -0
  92. package/dist/server/modules/sessions/session-provider-error-mapper.js +42 -0
  93. package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
  94. package/dist/server/server/create-server.js +11 -8
  95. package/dist/server/server/create-server.js.map +1 -1
  96. package/dist/server/storage/repositories/session-binding-repository.js +44 -5
  97. package/dist/server/storage/repositories/session-binding-repository.js.map +1 -1
  98. package/dist/server/storage/repositories/session-index-repository.js +6 -0
  99. package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
  100. package/dist/server/storage/sqlite/client.js +19 -0
  101. package/dist/server/storage/sqlite/client.js.map +1 -1
  102. package/dist/server/storage/sqlite/schema.sql +5 -0
  103. package/dist/server/types/domain.d.ts +6 -0
  104. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +5 -2
  105. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +40 -8
  106. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -1
  107. package/node_modules/@codingns/session-sync-core/dist/index.d.ts +2 -0
  108. package/node_modules/@codingns/session-sync-core/dist/index.js +2 -0
  109. package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -1
  110. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +10 -1
  111. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +110 -35
  112. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
  113. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
  114. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
  115. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
  116. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +131 -39
  117. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -1
  118. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
  119. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
  120. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
  121. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +8 -1
  122. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +19 -6
  123. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -1
  124. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +1 -0
  125. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +13 -8
  126. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
  127. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +5 -1
  128. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +103 -51
  129. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
  130. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +2 -1
  131. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +41 -21
  132. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  133. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +32 -8
  134. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -1
  135. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +10 -0
  136. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
  137. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
  138. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +167 -10
  139. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
  140. package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +2 -0
  141. package/node_modules/@codingns/session-sync-core/dist/types.d.ts +1 -1
  142. package/node_modules/@codingns/session-sync-core/dist/types.js +1 -1
  143. package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -1
  144. package/package.json +1 -1
  145. package/dist/public/assets/ConversationPage-z3sXtKZ7.js +0 -4
  146. package/dist/public/assets/DesktopWindowPage-CZcoGApB.js +0 -2
  147. package/dist/public/assets/FileContextPanel-C3qex8bb.js +0 -1
  148. package/dist/public/assets/GitSidebar-BK6H16XU.js +0 -6
  149. package/dist/public/assets/MobileCreateSessionSheet-BYfbvK8o.js +0 -1
  150. package/dist/public/assets/MobileSheet-Ckug8hTb.js +0 -1
  151. package/dist/public/assets/MobileWorkspaceSwitcherHeader-RqWrBdn2.js +0 -1
  152. package/dist/public/assets/SessionIndexPage-DuK10DL5.js +0 -1
  153. package/dist/public/assets/SettingsPage-fyD-xaHL.js +0 -1
  154. package/dist/public/assets/TerminalManagerPanel-CCLr1Ypk.js +0 -1
  155. package/dist/public/assets/TerminalRuntimeFallbackModal-aUzjEBwP.js +0 -1
  156. package/dist/public/assets/ToolGitPage-C264yjS9.js +0 -1
  157. package/dist/public/assets/ToolProcessesPage-BOP4A1cb.js +0 -1
  158. package/dist/public/assets/ToolsHomePage-CQxGiKQA.js +0 -1
  159. package/dist/public/assets/WorkbenchLandingPage-CvAY68ca.js +0 -1
  160. package/dist/public/assets/WorkbenchLayout-DGm8Tc5M.js +0 -3
  161. package/dist/public/assets/WorkbenchShellRoute-BF0nHWOk.css +0 -1
  162. package/dist/public/assets/WorkbenchShellRoute-DBBOsJo9.js +0 -1
  163. package/dist/public/assets/WorkspaceDebugDetailPage-CDerFYd2.js +0 -1
  164. package/dist/public/assets/WorkspaceDetailPage-BlJc1CHE.js +0 -1
  165. package/dist/public/assets/WorkspaceHomePage-BUsKJ3lv.js +0 -1
  166. package/dist/public/assets/default-session-permission-mode-DT4SGiwp.js +0 -1
  167. package/dist/public/assets/index-BZLcEHW3.js +0 -42
  168. package/dist/public/assets/index-BbspQPC2.css +0 -1
  169. package/dist/public/assets/session-runtime-machine-DdLeDqQr.js +0 -17
  170. package/dist/public/assets/useRegisteredDebugTemplates-oFAQNIqh.js +0 -1
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-DwFzLsOp.js","assets/index-C-0oeG_5.js","assets/index-B84Po2NA.css","assets/App-Dsf3ooXU.js","assets/App-CcDXqFl1.css","assets/model-switch-api-Bh9nYslz.js","assets/WorkbenchModal-ColqvV6a.js","assets/file-tree-icon-Bp3Ntt7u.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-pmr-c42O.js","assets/GitSidebar-CH6WqTrM.js","assets/TerminalManagerPanel-BbORd-ee.js","assets/terminal-runtime-meta-8_uRZf7h.js","assets/TerminalRuntimeFallbackModal-B29YxbQe.js"])))=>i.map(i=>d[i]);
2
+ var Vc=Object.defineProperty;var Xc=(e,t,s)=>t in e?Vc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Pe=(e,t,s)=>Xc(e,typeof t!="symbol"?t+"":t,s);import{C as re,t as r,b as i,j as n,e as Qt,m as kr,H as kl,J as Yc,F as Jc,K as Zc,w as wl,A as vl,p as Na,L as Qc,M as ed,N as xl,i as yl,O as ro,f as go,h as ao,P as td,l as Sl,y as nd,n as sd,z as rd,d as ad,_ as ko}from"./index-C-0oeG_5.js";import{m as _e,e as Hn,h as Ia,u as vr,g as Os,f as fs,i as od,j as id,O as Uo}from"./App-Dsf3ooXU.js";import{e as wo,l as ld,m as cd,a2 as jl,a3 as dd,M as ud,i as hd,j as pd,a4 as md,a5 as fd,q as bd,s as Go,o as gd,p as Cl,f as zo,h as ir,a as oo,t as kd,n as va,a6 as wd,a7 as vd,a8 as xd,u as Yr,g as yd,a9 as Sd,aa as jd,ab as Cd,ac as Nl,ad as Nd,ae as Il,af as Id,ag as Md,ah as Ml,I as Td,S as Rd,P as Ko,r as Ed,ai as Pd}from"./model-switch-api-Bh9nYslz.js";import{t as Ls,P as xa,g as Tl}from"./window-BVUB8gMK.js";import{R as Ad,_ as qo,a as Vo,C as Rl,i as be}from"./event-DvH9tcej.js";import{W as nt,D as Wd}from"./WorkbenchModal-ColqvV6a.js";import{r as Ld,b as Bd}from"./relay-entry-pmr-c42O.js";const Bs=new Map,El=48;function bs(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function Xo(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Dd(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function Pl(e){try{const t=JSON.parse(e);return Dd(t)?t:null}catch{return null}}function _d(){if(!bs())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Al(){if(!bs())return[];const e=[];for(const t of _d()){let s=null;try{s=window.sessionStorage.getItem(t)}catch{continue}if(!s)continue;const a=Pl(s);a&&e.push({key:t,savedAt:a.savedAt})}return e.sort((t,s)=>t.savedAt-s.savedAt)}function wr(e){if(bs())try{window.sessionStorage.removeItem(e)}catch{}}function Jr(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),s=(e==null?void 0:e.maxCount)??El,a=Al().filter(c=>!t.has(c.key)),o=Math.max(0,t.size+a.length-s);for(let c=0;c<o;c+=1){const p=a[c];if(!p)break;wr(p.key)}}function Fd(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Ha(e,t){if(!bs())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(s){return Fd(s)?"quota_exceeded":"failed"}}function Od(e,t){const s=Ha(e,t);if(s==="success"){Jr({preserveKeys:[e]});return}if(s==="quota_exceeded"){if(wr(e),Jr({maxCount:Math.max(0,El-1)}),Ha(e,t)==="success"){Jr({preserveKeys:[e]});return}for(const a of Al())if(a.key!==e&&(wr(a.key),Ha(e,t)==="success")){Jr({preserveKeys:[e]});return}}}function ya(e,t){const s=Bs.get(e);if(s){if(!Xo(s.savedAt,t))return s.value;Bs.delete(e)}if(!bs())return null;let a=null;try{a=window.sessionStorage.getItem(e)}catch{return null}if(!a)return null;const o=Pl(a);return!o||Xo(o.savedAt,t)?(wr(e),Bs.delete(e),null):(Bs.set(e,o),o.value)}function br(e,t){const s={savedAt:Date.now(),value:t};if(Bs.set(e,s),!!bs())try{Od(e,JSON.stringify(s))}catch{}}function Pf(e){Bs.delete(e),bs()&&wr(e)}const $d="codingns.debug.perf",Hd="codingns.debug.sessionMessageDedup",Ud="codingns.debug.opencodeOrder";function Gd(){if(typeof window>"u")return!1;try{return window.localStorage.getItem($d)==="1"}catch{return!1}}function pt(e,t){if(!Gd()||typeof performance>"u")return;const s=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${s}ms`,t);return}console.info(`[perf-ui] ${e} ${s}ms`)}function zd(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Hd)==="1"}catch{return!1}}function Af(e,t){if(!zd()||typeof performance>"u")return;const s=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${s}ms`,t);return}console.info(`[session-dedup] ${e} ${s}ms`)}function Kd(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ud)==="1"}catch{return!1}}function Wf(e,t){if(!Kd()||typeof performance>"u")return;const s=Math.round(performance.now()),a={scope:e,timestampMs:s,...t??{}};try{const o=window,c=o.__CODINGNS_OPENCODE_ORDER_DEBUG__??[];c.push(a),c.length>500&&c.splice(0,c.length-500),o.__CODINGNS_OPENCODE_ORDER_DEBUG__=c}catch{}if(t&&Object.keys(t).length>0){console.info(`[opencode-order-ui] ${e} ${s}ms`,t);return}console.info(`[opencode-order-ui] ${e} ${s}ms`)}function Lf(e,t,s,a){return re.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:s,expectedVersion:a??void 0})})}function Bf(e){return re.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function Df(e){return re.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function _f(e,t){const s=new URLSearchParams({workspaceId:e,path:t});return re.request(`/api/files/download?${s.toString()}`)}function qd(e,t,s=1,a=20){const o=new URLSearchParams({workspaceId:e,keyword:t,page:String(s),pageSize:String(a)});return re.request(`/api/files/search?${o.toString()}`)}function Ff(e,t){const s=new URLSearchParams({workspaceId:e,path:t});return re.request(`/api/files/preview?${s.toString()}`)}function Of(e){return re.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function $f(e){return re.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function Hf(e,t,s){const a=new URLSearchParams({workspaceId:e,path:t,staged:String(s)});return re.request(`/api/git/diff?${a.toString()}`)}function Uf(e,t){return re.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function Gf(e,t){return re.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function zf(e,t){return re.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function Kf(e,t){return re.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function qf(e,t){return re.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function Vf(e){return re.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function Xf(e,t=5,s=null){const a=new URLSearchParams({workspaceId:e,limit:String(t)});return s&&a.set("cursor",s),re.request(`/api/git/history?${a.toString()}`)}function Yf(e,t){const s=new URLSearchParams({workspaceId:e,commitHash:t});return re.request(`/api/git/commit-detail?${s.toString()}`)}function Vd(e){return re.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Xd(e){return re.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function Jf(e,t,s){return re.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:s})})}function Zf(e,t,s,a,o){return re.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...s?{remote:s}:{},...a?{auth:a}:{},...o?{remember:o}:{}})})}function Qf(e){return re.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var fa,ba;function Wl(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(s=>"rid"in s?s:Wl(s));else if("action"in e&&e.action){const s=new Rl;return s.onmessage=e.action,delete e.action,{...e,handler:s}}return e}async function $s(e,t){const s=new Rl;if(t&&typeof t=="object"&&("action"in t&&t.action&&(s.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Ls(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Ls(t.icon)),"items"in t&&t.items)){let a=function(o){var c;return"rid"in o?[o.rid,o.kind]:("item"in o&&typeof o.item=="object"&&(!((c=o.item.About)===null||c===void 0)&&c.icon)&&(o.item.About.icon=Ls(o.item.About.icon)),"icon"in o&&o.icon&&(o.icon=Ls(o.icon)),"items"in o&&o.items&&(o.items=o.items.map(a)),Wl(o))};t.items=t.items.map(a)}return be("plugin:menu|new",{kind:e,options:t,handler:s})}class Hs extends Ad{get id(){return qo(this,fa,"f")}get kind(){return qo(this,ba,"f")}constructor(t,s,a){super(t),fa.set(this,void 0),ba.set(this,void 0),Vo(this,fa,s),Vo(this,ba,a)}}fa=new WeakMap,ba=new WeakMap;class vo extends Hs{constructor(t,s){super(t,s,"MenuItem")}static async new(t){return $s("MenuItem",t).then(([s,a])=>new vo(s,a))}async text(){return be("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return be("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return be("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return be("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return be("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class xo extends Hs{constructor(t,s){super(t,s,"Check")}static async new(t){return $s("Check",t).then(([s,a])=>new xo(s,a))}async text(){return be("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return be("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return be("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return be("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return be("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return be("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return be("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var Yo;(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"})(Yo||(Yo={}));class yo extends Hs{constructor(t,s){super(t,s,"Icon")}static async new(t){return $s("Icon",t).then(([s,a])=>new yo(s,a))}async text(){return be("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return be("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return be("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return be("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return be("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return be("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Ls(t)})}}class So extends Hs{constructor(t,s){super(t,s,"Predefined")}static async new(t){return $s("Predefined",t).then(([s,a])=>new So(s,a))}async text(){return be("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return be("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function _s([e,t,s]){switch(s){case"Submenu":return new jo(e,t);case"Predefined":return new So(e,t);case"Check":return new xo(e,t);case"Icon":return new yo(e,t);case"MenuItem":default:return new vo(e,t)}}class jo extends Hs{constructor(t,s){super(t,s,"Submenu")}static async new(t){return $s("Submenu",t).then(([s,a])=>new jo(s,a))}async text(){return be("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return be("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return be("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return be("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return be("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(t){return be("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(t,s){return be("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(a=>"rid"in a?[a.rid,a.kind]:a),position:s})}async remove(t){return be("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return be("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(_s)}async items(){return be("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(_s))}async get(t){return be("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(s=>s?_s(s):null)}async popup(t,s){var a;return be("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(a=s==null?void 0:s.label)!==null&&a!==void 0?a:null,at:t instanceof xa?t:t?new xa(t):null})}async setAsWindowsMenuForNSApp(){return be("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return be("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return be("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Ls(t)})}}class Ds extends Hs{constructor(t,s){super(t,s,"Menu")}static async new(t){return $s("Menu",t).then(([s,a])=>new Ds(s,a))}static async default(){return be("plugin:menu|create_default").then(([t,s])=>new Ds(t,s))}async append(t){return be("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(t){return be("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(t,s){return be("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(a=>"rid"in a?[a.rid,a.kind]:a),position:s})}async remove(t){return be("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return be("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(_s)}async items(){return be("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(_s))}async get(t){return be("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(s=>s?_s(s):null)}async popup(t,s){var a;return be("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(a=s==null?void 0:s.label)!==null&&a!==void 0?a:null,at:t instanceof xa?t:t?new xa(t):null})}async setAsAppMenu(){return be("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Ds(t[0],t[1]):null)}async setAsWindowMenu(t){var s;return be("plugin:menu|set_as_window_menu",{rid:this.rid,window:(s=t==null?void 0:t.label)!==null&&s!==void 0?s:null}).then(a=>a?new Ds(a[0],a[1]):null)}}async function Yd(e){if(e.length===0)return;await(await Ds.new({items:e.map(s=>({id:s.id,text:s.label,enabled:!s.disabled,accelerator:s.accelerator,action:()=>{s.onSelect()}}))})).popup(void 0,Tl())}const Jo={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},Jd=2600,Ll="workbench.parallel.pane.palette";let As=null;const Zo=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function Zd(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function Bl(e){var s,a;const t=(s=e.displayParentSessionId)==null?void 0:s.trim();return t||((a=e.parentSessionId)==null?void 0:a.trim())||null}function Qd(e){var a;const t=(a=e==null?void 0:e.colorToken)==null?void 0:a.trim();if(!t)return;const s=Jo[t]??Jo["parallel-group-1"];return{"--parallel-group-accent":s.accent,"--parallel-group-soft":s.soft,"--parallel-group-surface":s.surface}}function eb(e){const t=Sa(e.overrideColor)??eu(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":Qo(t,.08),"--parallel-group-surface":Qo(t,.03)}}function tb(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const s=Dl();return Sa(s[t]??null)}function nb(e,t){if(typeof window>"u")return Sa(t);const s=e.trim();if(!s)return null;const a=Dl(),o=Sa(t);return o?a[s]=o:delete a[s],window.localStorage.setItem(Ll,JSON.stringify(a)),o}function eu(e,t){const s=Zo.length,a=Math.abs(iu(e))%s;return Zo[(a+t*5)%s]}function sb(e){return e?e.role==="anchor"?r("shell.parallelGroupAnchorBadge"):r("shell.parallelGroupMemberBadge"):null}function tu(e){return e?r("shell.parallelGroupBadge",{count:e.memberCount}):null}function rb(e){var s;return((s=e==null?void 0:e.branchName)==null?void 0:s.trim())||null}function nu(e){var s,a,o;return((a=(s=e==null?void 0:e.parallelGroup)==null?void 0:s.groupId)==null?void 0:a.trim())?((o=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:o.lifecycleStatus)!=="promoted":!1}function su(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function ru(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function au(e,t="create"){As={groupId:e,createdAt:Date.now(),...Zd(t)}}function ou(e){return!As||As.groupId!==e?null:Date.now()-As.createdAt>Jd?(As=null,null):As}function Dl(){if(typeof window>"u")return{};const e=window.localStorage.getItem(Ll);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function iu(e){let t=0;for(const s of e)t=t*31+s.charCodeAt(0)|0;return t}function Sa(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function Qo(e,t){const s=Math.max(0,Math.min(t,1)),a=Number.parseInt(e.slice(1,3),16),o=Number.parseInt(e.slice(3,5),16),c=Number.parseInt(e.slice(5,7),16);return`rgba(${a}, ${o}, ${c}, ${s})`}function _l(e,t){const s=new Map(e.map(c=>[t.getId(c),c])),a=new Map,o=[];for(const c of e){const p=lu(c,s,t);if(!p){o.push(c);continue}const h=a.get(p)??[];a.set(p,[...h,c])}return[...o].sort(t.compare).map(c=>$l(c,0,a,t,new Set))}function Us(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Fl(e){return e.flatMap(t=>[t.item,...Fl(Us(t))])}function _n(e){return e.flatMap(t=>[t,..._n(Us(t))])}function Co(e,t){return e.some(s=>t(s.item)||Co(Us(s),t))}function Ol(e,t,s){return e?s(e.item)===t?!0:Us(e).some(a=>Ol(a,t,s)):!1}function Ws(e,t,s){for(const a of e){const o=s(a.item);if(o===t)return[];const c=Ws(Us(a),t,s);if(Ol(a,t,s)&&c.length>=0)return[o,...c]}return[]}function $l(e,t,s,a,o){const c=a.getId(e),p=new Set(o);p.add(c);const h=[...s.get(c)??[]].filter(g=>!p.has(a.getId(g))).sort(a.compare).map(g=>$l(g,t+1,s,a,p));return{item:e,depth:t,children:h}}function lu(e,t,s){const a=ei(s.getParentId(e));if(!a)return null;const o=t.get(a);if(!o)return null;const c=new Set([s.getId(e)]);let p=o;for(;p;){const h=s.getId(p);if(c.has(h))return null;c.add(h);const g=ei(s.getParentId(p));if(!g||(p=t.get(g),!p))return a}return a}function ei(e){const t=e==null?void 0:e.trim();return t||null}function jt(){return"/workspaces"}function hn(e){return`/workspaces/${encodeURIComponent(e)}`}function Hl(e){return`${hn(e)}/debug`}function Fs(e){return`${hn(e)}/sessions`}function Ut(e,t){return`${Fs(e)}/${encodeURIComponent(t)}`}function Ul(e,t){const s=`${hn(e)}/tools`;if(!t)return s;const a=new URLSearchParams({tab:t});return`${s}?${a.toString()}`}function Gl(e){return`${hn(e)}/tools/files`}function zl(e){return`${hn(e)}/tools/git`}function Kl(e){return`${hn(e)}/tools/processes`}function ps(e){return`${hn(e)}/terminals`}function ms(e,t){const s=`${hn(e)}/butler`;if(!t)return s;const a=new URLSearchParams({tab:t});return`${s}?${a.toString()}`}function cu(e){return e.flatMap(t=>[...t.sessions.map(s=>({session:s,workspace:t.workspace})),...Vl(t.childWorktrees??[])]).sort((t,s)=>(s.session.lastMessageAt??s.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function ab(e,t){return _l(e,{getId:s=>s.session.sessionId,getParentId:s=>du(s.session,t),compare:hu})}function du(e,t){var s;return(t==null?void 0:t.mode)==="mobile"?((s=e.parentSessionId)==null?void 0:s.trim())||null:Bl(e)}function ql(e,t){const s=uu(),a=new URLSearchParams({provider:t});return`${Ut(e,s)}?${a.toString()}`}function uu(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function hu(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Vl(e){return e.flatMap(t=>[...t.sessions.map(s=>({session:s,workspace:t.workspace})),...Vl(t.children)])}const pu="mobile.tools.last-primary-tool";function Xl(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(pu)==="git"?"git":"files"}catch{return"files"}}function No(e){var a;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const o of t){const c=_e(o.pattern,e),p=((a=c==null?void 0:c.params.workspaceId)==null?void 0:a.trim())??null;if(p)return{workspaceId:p,routeKind:o.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 o of s)if(_e(o.pattern,e))return{workspaceId:null,routeKind:o.routeKind,legacy:!0};return null}function mu(e,t){const s=No(e);if((s==null?void 0:s.routeKind)==="git")return"git";if((s==null?void 0:s.routeKind)==="files")return"files";const a=new URLSearchParams(t).get("tab");return a==="git"?"git":a==="files"?"files":Xl()}function Io(e,t){const s=No(e);return(s==null?void 0:s.routeKind)==="processes"&&s.workspaceId?ps(s.workspaceId):s!=null&&s.workspaceId?Ul(s.workspaceId,mu(e,t)):s!=null&&s.legacy?Xl()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Mo({activeEntry:e,presentation:t,pathname:s,search:a,moreButtonLabel:o}){if(t==="conversation-focus"||e!=="butler")return null;const c=No(s);return c?c.routeKind==="processes"?{title:r("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:o}:(c.routeKind==="home"||c.routeKind==="files"||c.routeKind==="git",null):null}const Yl=i.createContext({composerPortalTarget:null});function To({composerPortalTarget:e,children:t}){return n.jsx(Yl.Provider,{value:{composerPortalTarget:e},children:t})}function ob(){return i.useContext(Yl)}function Ro(e,t,s){const[a,o]=i.useState(void 0);return i.useEffect(()=>{const c=e.current,p=t.current;if(!s||!c||!p){o(void 0),c&&c.style.removeProperty("--mobile-conversation-tabbar-height");return}const h=c,g=p;function f(){if(!e.current||!g.isConnected)return;const N=`${Math.round(g.getBoundingClientRect().height)}px`;h.style.setProperty("--mobile-conversation-tabbar-height",N),o(N)}f();const w=typeof ResizeObserver<"u"?new ResizeObserver(f):null;return w==null||w.observe(g),window.addEventListener("resize",f),()=>{w==null||w.disconnect(),window.removeEventListener("resize",f),h.style.removeProperty("--mobile-conversation-tabbar-height")}},[s,e,t]),a}const fu=3e3,Zr=10,ti=84,ni=.36;function Eo({enabled:e,rootRef:t,suspended:s=!1,resetKey:a}){const o=i.useRef(null),c=i.useRef(null),p=i.useRef("visible"),h=i.useRef(1),[g,f]=i.useState("visible"),[w,N]=i.useState(1);i.useEffect(()=>{p.current=g},[g]),i.useEffect(()=>{h.current=w},[w]);function j(){us(o),o.current=window.setTimeout(()=>{T()},fu)}function T(){f("hidden"),N(0)}function H(){f("visible"),N(1),j()}i.useEffect(()=>{if(us(o),!e){us(o),f("visible"),N(1);return}if(s){f("hidden"),N(0);return}return H(),()=>{us(o)}},[e,a,s]),i.useEffect(()=>()=>{us(o)},[]),i.useEffect(()=>{if(!e||s){c.current=null;return}const L=t.current;if(!L)return;function v(D){if(D.touches.length!==1){c.current=null;return}const y=D.touches[0],Y=ai(D.target);if(!y||!Y){c.current=null;return}c.current={surface:Y,startX:y.clientX,startY:y.clientY,pointerType:"touch",initialState:p.current==="visible"?"visible":"hidden",touchId:y.identifier,dragging:!1,latestProgress:h.current},p.current==="visible"&&us(o)}function K(D){const y=c.current;if(!y||y.pointerType!=="touch")return;const Y=Ua(D.touches,y.touchId);if(!Y)return;const Q=Y.clientX-y.startX,B=Y.clientY-y.startY;if(y.surface==="conversation"){if(Math.abs(B)<=Zr||Math.abs(B)<=Math.abs(Q))return;c.current=null,y.initialState==="visible"&&T();return}const me=y.initialState==="hidden"?-B:B;me<=Zr&&!y.dragging||(ii(D),y.dragging=!0,y.latestProgress=si(y.initialState,me),f("dragging"),N(y.latestProgress))}function F(D){const y=c.current;if(!(!y||y.pointerType!=="touch"||!Ua(D.changedTouches,y.touchId))){if(c.current=null,!y.dragging){y.initialState==="visible"&&j();return}ri(y.initialState,y.latestProgress,H,f,N)}}function te(D){const y=c.current;if(!(!y||y.pointerType!=="touch"||!Ua(D.changedTouches,y.touchId))){if(c.current=null,!y.dragging){y.initialState==="visible"&&j();return}if(y.initialState==="visible"){H();return}f("hidden"),N(0)}}function M(D){if(D.pointerType!=="touch")return;const y=ai(D.target);if(!y){c.current=null;return}if(c.current={surface:y,startX:D.clientX,startY:D.clientY,pointerType:"pointer",initialState:p.current==="visible"?"visible":"hidden",pointerId:D.pointerId,captureTarget:D.target instanceof Element?D.target:null,dragging:!1,latestProgress:h.current},D.target instanceof Element)try{D.target.setPointerCapture(D.pointerId)}catch{}p.current==="visible"&&us(o)}function X(D){const y=c.current;if(!y||y.pointerType!=="pointer")return;const Y=D.clientX-y.startX,Q=D.clientY-y.startY;if(y.surface==="conversation"){if(Math.abs(Q)<=Zr||Math.abs(Q)<=Math.abs(Y))return;c.current=null,y.initialState==="visible"&&T();return}const B=y.initialState==="hidden"?-Q:Q;B<=Zr&&!y.dragging||(ii(D),y.dragging=!0,y.latestProgress=si(y.initialState,B),f("dragging"),N(y.latestProgress))}function V(D){const y=c.current;if(!(!y||y.pointerType!=="pointer"||y.pointerId!==D.pointerId)){if(c.current=null,bu(y),!y.dragging){y.initialState==="visible"&&j();return}ri(y.initialState,y.latestProgress,H,f,N)}}return L.addEventListener("touchstart",v,{passive:!0}),L.addEventListener("pointerdown",M,{passive:!0}),window.addEventListener("touchmove",K,{passive:!1}),window.addEventListener("touchend",F),window.addEventListener("touchcancel",te),window.addEventListener("pointermove",X,{passive:!1}),window.addEventListener("pointerup",V),window.addEventListener("pointercancel",V),()=>{L.removeEventListener("touchstart",v),L.removeEventListener("pointerdown",M),window.removeEventListener("touchmove",K),window.removeEventListener("touchend",F),window.removeEventListener("touchcancel",te),window.removeEventListener("pointermove",X),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V)}},[e,t,s]);const O=e&&!s?w:e?0:1;return{state:s&&e?"hidden":g,progress:O,isOpen:O>.01}}function us(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function si(e,t){return oi(e==="hidden"?t/ti:1-t/ti,0,1)}function ri(e,t,s,a,o){if(e==="hidden"){if(t>=ni){s();return}a("hidden"),o(0);return}if(t<=1-ni){a("hidden"),o(0);return}s()}function bu(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 Ua(e,t){if(typeof t!="number")return e[0]??null;for(let s=0;s<e.length;s+=1){const a=e[s];if((a==null?void 0:a.identifier)===t)return a}return null}function ai(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 oi(e,t,s){return Math.min(Math.max(e,t),s)}function ii(e){e.cancelable&&e.preventDefault()}function xr({viewportClass:e,activeEntry:t,hasNavigationPanel:s,hasAuxiliaryPanel:a,preferCompactLayout:o=!1}){return o||e==="compact"?"compact":e==="expanded"&&s&&a?"expanded":t==="butler"&&a?"medium-auxiliary":s?"medium-navigation":a?"medium-auxiliary":"compact"}function Ma(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function Jl(e){return e==="medium-navigation"||e==="expanded"}function Zl(e){return e==="medium-auxiliary"||e==="expanded"}function Po({viewportClass:e,activeEntry:t,hasNavigationPanel:s,hasAuxiliaryPanel:a,preferCompactLayout:o=!1,children:c,navigationPanel:p,auxiliaryPanel:h}){const g=xr({viewportClass:e,activeEntry:t,hasNavigationPanel:s,hasAuxiliaryPanel:a,preferCompactLayout:o}),f=Jl(g)&&p,w=Zl(g)&&h;return n.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":g,children:[f?n.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:p}):null,n.jsx("div",{className:"mobile-adaptive-pane-main",children:c}),w?n.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:h}):null]})}function gu({activeEntry:e,presentation:t="default",children:s,navigationPanel:a,auxiliaryPanel:o,onNavigateWorkspaces:c,onNavigateTerminals:p,onNavigateSessions:h,onNavigateButler:g,onNavigateToolProcesses:f,onNavigateSettings:w}){const N=Hn(),j=wo(),T=Ia(),H=vr(),O=i.useRef(null),L=i.useRef(null),[v,K]=i.useState(null),F=t==="conversation-focus",te=Ma({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),M=Eo({enabled:F,rootRef:O,resetKey:`${T.pathname}${T.search}`}),X=xr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!o,preferCompactLayout:te}),V=Mo({activeEntry:e,presentation:t,pathname:T.pathname,search:T.search,moreButtonLabel:r("shell.androidMoreAction")}),D=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:n.jsx(vu,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:n.jsx(xu,{}),onClick:h},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:n.jsx(Su,{}),onClick:g},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:n.jsx(yu,{}),onClick:p},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:n.jsx(ju,{}),onClick:w}],y=F?{"--mobile-conversation-tabbar-progress":M.progress.toFixed(4)}:void 0;Ro(O,L,F);function Y(){const B=Io(T.pathname,T.search);if(!B){p();return}H(B,{replace:!0})}const Q=n.jsx("nav",{ref:L,className:"android-workbench-bottom-nav","aria-label":r("shell.title"),children:D.map(B=>n.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&j.trigger("selection"),B.onClick()},children:[n.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:B.icon}),n.jsx("span",{className:"android-workbench-bottom-nav-label",children:B.label})]},B.key))});return n.jsx(To,{composerPortalTarget:F?v:null,children:n.jsxs("div",{ref:O,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":X,"data-tabbar-open":F?M.isOpen:!0,"data-conversation-tabbar-state":F?M.state:"default",style:y,children:[V?n.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[n.jsxs("div",{className:"android-workbench-topbar-leading",children:[V.showBackButton?n.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":r("common.back"),onClick:Y,children:n.jsx(ku,{})}):null,n.jsx("div",{className:"android-workbench-topbar-copy",children:n.jsx("h1",{children:V.title})})]}),n.jsx("div",{className:"android-workbench-topbar-actions",children:V.showMoreButton?n.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":V.moreButtonLabel,onClick:f,children:n.jsx(wu,{})}):null})]}):null,n.jsx("div",{className:"android-workbench-content",children:n.jsx(Po,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!o,preferCompactLayout:te,navigationPanel:a,auxiliaryPanel:o,children:s})}),F?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:K,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:Q})]}):Q]})})}function ku(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"m15 18-6-6 6-6"}),n.jsx("path",{d:"M21 12H9"})]})}function wu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function vu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.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"}),n.jsx("path",{d:"M8 13h8"})]})}function xu(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.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 yu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function Su(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function ju(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.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 Cu=120,ur={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function io(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Nu(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function Iu(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(io);return e.length>0?Math.max(...e):0}function li(){if(typeof window>"u")return ur;const e=window.visualViewport,t=Iu(),s=(e==null?void 0:e.height)??t,a=io(s)?Math.round(s):null,o=io(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,c=a===null?0:Math.max(0,Math.round(t-a-o));return{viewportHeight:a,keyboardInset:c,keyboardOpen:Nu(typeof document<"u"?document.activeElement:null)&&c>=Cu}}function Ga(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(a=>a instanceof HTMLElement).forEach(a=>{if(!e){delete a.dataset.mobileKeyboardOpen,delete a.dataset.mobileViewportBound,a.style.removeProperty("--mobile-shell-viewport-height"),a.style.removeProperty("--mobile-shell-keyboard-inset");return}a.dataset.mobileKeyboardOpen=String(t.keyboardOpen),a.dataset.mobileViewportBound="true",t.viewportHeight===null?a.style.removeProperty("--mobile-shell-viewport-height"):a.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),a.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function Mu(e){const[t,s]=i.useState(()=>e?li():ur),a=i.useRef(null);return i.useEffect(()=>{if(!e){s(ur),Ga(!1,ur);return}function o(){s(li())}function c(){a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{a.current=null,o()},0)}o();const p=window.visualViewport;return window.addEventListener("resize",o),window.addEventListener("orientationchange",o),p==null||p.addEventListener("resize",o),p==null||p.addEventListener("scroll",o),document.addEventListener("focusin",o),document.addEventListener("focusout",c),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null),window.removeEventListener("resize",o),window.removeEventListener("orientationchange",o),p==null||p.removeEventListener("resize",o),p==null||p.removeEventListener("scroll",o),document.removeEventListener("focusin",o),document.removeEventListener("focusout",c),Ga(!1,ur)}},[e]),i.useEffect(()=>{Ga(e,t)},[e,t]),t}function Tu({activeEntry:e,presentation:t="default",children:s,navigationPanel:a,auxiliaryPanel:o,onNavigateWorkspaces:c,onNavigateTerminals:p,onNavigateSessions:h,onNavigateButler:g,onNavigateToolProcesses:f,onNavigateSettings:w}){const N=Hn(),j=wo(),T=Ia(),H=vr(),O=i.useRef(null),L=i.useRef(null),[v,K]=i.useState(null),F=t==="conversation-focus",te=Ma({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),M=Eo({enabled:F,rootRef:O,resetKey:`${T.pathname}${T.search}`}),X=xr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!o,preferCompactLayout:te}),V=Mo({activeEntry:e,presentation:t,pathname:T.pathname,search:T.search,moreButtonLabel:r("shell.iosMoreAction")}),D=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:n.jsx(Pu,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:n.jsx(Au,{}),onClick:h},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:n.jsx(Lu,{}),onClick:g},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:n.jsx(Wu,{}),onClick:p},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:n.jsx(Bu,{}),onClick:w}],y=F?{"--mobile-conversation-tabbar-progress":M.progress.toFixed(4)}:void 0;Ro(O,L,F);function Y(){const B=Io(T.pathname,T.search);if(!B){p();return}H(B,{replace:!0})}const Q=n.jsx("nav",{ref:L,className:"ios-workbench-tabbar","aria-label":r("shell.title"),children:D.map(B=>n.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&j.trigger("selection"),B.onClick()},children:[n.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:B.icon}),n.jsx("span",{className:"ios-workbench-tabbar-label",children:B.label})]},B.key))});return n.jsx(To,{composerPortalTarget:F?v:null,children:n.jsxs("div",{ref:O,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":X,"data-tabbar-open":F?M.isOpen:!0,"data-conversation-tabbar-state":F?M.state:"default",style:y,children:[V?n.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[n.jsx("div",{className:"ios-workbench-nav-leading",children:V.showBackButton?n.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":r("common.back"),onClick:Y,children:[n.jsx(Ru,{}),n.jsx("span",{children:r("common.back")})]}):null}),n.jsx("div",{className:"ios-workbench-nav-copy",children:n.jsx("h1",{children:V.title})}),n.jsx("div",{className:"ios-workbench-nav-actions",children:V.showMoreButton?n.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":V.moreButtonLabel,onClick:f,children:n.jsx(Eu,{})}):null})]}):null,n.jsx("div",{className:"ios-workbench-content",children:n.jsx(Po,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!o,preferCompactLayout:te,navigationPanel:a,auxiliaryPanel:o,children:s})}),F?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:K,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:Q})]}):Q]})})}function Ru(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:n.jsx("path",{d:"m15 18-6-6 6-6"})})}function Eu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Pu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.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"}),n.jsx("path",{d:"M8 13h8"})]})}function Au(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:n.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 Wu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function Lu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Bu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.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 Du(e){const t=Hn();return t.platform==="ios"?n.jsx(Tu,{...e}):t.platform==="android"?n.jsx(gu,{...e}):n.jsx(_u,{...e})}function _u({activeEntry:e,presentation:t="default",children:s,navigationPanel:a,auxiliaryPanel:o,onNavigateWorkspaces:c,onNavigateTerminals:p,onNavigateSessions:h,onNavigateButler:g,onNavigateToolProcesses:f,onNavigateSettings:w}){const N=Hn(),j=wo(),T=Ia(),H=vr(),O=i.useRef(null),L=i.useRef(null),[v,K]=i.useState(null),F=Mu(N.platform==="web"),te=N.platform==="web"&&F.keyboardOpen,M=t==="conversation-focus",X=Ma({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),V=Eo({enabled:M,rootRef:O,suspended:te,resetKey:`${T.pathname}${T.search}`}),D=xr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!o,preferCompactLayout:X}),y=Mo({activeEntry:e,presentation:t,pathname:T.pathname,search:T.search,moreButtonLabel:r("shell.iosMoreAction")}),Y=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:n.jsx($u,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:n.jsx(Hu,{}),onClick:h},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:n.jsx(Gu,{}),onClick:g},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:n.jsx(Uu,{}),onClick:p},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:n.jsx(zu,{}),onClick:w}],Q=M?{"--mobile-conversation-tabbar-progress":V.progress.toFixed(4)}:void 0;Ro(O,L,M);function B(){const ue=Io(T.pathname,T.search);if(!ue){p();return}H(ue,{replace:!0})}const me=n.jsx("nav",{ref:L,className:"mobile-workbench-tabbar","aria-label":r("shell.title"),hidden:te,children:Y.map(ue=>n.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":ue.key===e,"aria-current":ue.key===e?"page":void 0,onClick:()=>{ue.key!==e&&j.trigger("selection"),ue.onClick()},children:[n.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:ue.icon}),n.jsx("span",{className:"mobile-workbench-tabbar-label",children:ue.label})]},ue.key))});return n.jsx(To,{composerPortalTarget:M?v:null,children:n.jsxs("div",{ref:O,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":N.platform,"data-mobile-keyboard-open":te,"data-pane-layout":D,"data-tabbar-open":te?!1:M?V.isOpen:!0,"data-conversation-tabbar-state":M?V.state:"default",style:Q,children:[y?n.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[n.jsxs("div",{className:"mobile-workbench-header-leading",children:[y.showBackButton?n.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":r("common.back"),onClick:B,children:n.jsx(Fu,{})}):null,n.jsx("div",{className:"mobile-workbench-header-copy",children:n.jsx("h1",{children:y.title})})]}),n.jsx("div",{className:"mobile-workbench-header-actions",children:y.showMoreButton?n.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":y.moreButtonLabel,onClick:f,children:n.jsx(Ou,{})}):null})]}):null,n.jsx("div",{className:"mobile-workbench-content",children:n.jsx(Po,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!o,preferCompactLayout:X,navigationPanel:a,auxiliaryPanel:o,children:s})}),M?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:K,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:me})]}):me]})})}function Fu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"m15 18-6-6 6-6"}),n.jsx("path",{d:"M21 12H9"})]})}function Ou(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function $u(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.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"}),n.jsx("path",{d:"M8 13h8"})]})}function Hu(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:n.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 Uu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function Gu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function zu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.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 Ku{constructor(t){Pe(this,"maxAttempts");Pe(this,"baseDelayMs");Pe(this,"reconnectAttempts",0);Pe(this,"reconnectTimer",null);Pe(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!Qt.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class qu{constructor(t){Pe(this,"socket",null);Pe(this,"disposed",!1);Pe(this,"authRecoveryInFlight",!1);Pe(this,"pendingRefresh",!1);Pe(this,"workbenchKnownRevision");Pe(this,"lastWorkbenchSnapshot",null);Pe(this,"fileTreeSubscription",null);Pe(this,"gitSubscription",null);Pe(this,"terminalManagerSubscription",null);Pe(this,"workspaceManagementSubscription",null);Pe(this,"pendingFileTreeRefresh",null);Pe(this,"pendingGitRefresh",null);Pe(this,"pendingTerminalManagerRefresh",null);Pe(this,"pendingWorkspaceManagementRefresh",null);Pe(this,"fileTreeRevisionByPath",new Map);Pe(this,"gitRevisionByWorkspaceId",new Map);Pe(this,"terminalManagerRevisionByWorkspaceId",new Map);Pe(this,"workspaceManagementRevisionByWorkspaceId",new Map);Pe(this,"fileTreeListeners",new Set);Pe(this,"gitListeners",new Set);Pe(this,"terminalManagerListeners",new Set);Pe(this,"workspaceManagementListeners",new Set);Pe(this,"workbenchSubscribeStartedAtMs",null);Pe(this,"workbenchRefreshStartedAtMs",null);Pe(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new Ku({onReconnect:s=>{this.connect(s)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!ci(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),pt("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=Ht(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=Ht(t.revision)??null}subscribeFileTree(t,s,a){this.fileTreeSubscription={workspaceId:t,paths:di(s),knownRevisionByPath:za(a==null?void 0:a.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Ka(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,s,a){const o=di(s),c={type:"fileTree.refresh",workspaceId:t,paths:o,knownRevisions:Ka(t,o,za(a==null?void 0:a.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(c)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:o,knownRevisionByPath:za(a==null?void 0:a.knownRevisionByPath)}}subscribeGit(t,s){this.gitSubscription={workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,s){const a={type:"git.refresh",workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(a)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)}}subscribeTerminalManager(t,s){this.terminalManagerSubscription={workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,s){const a={type:"terminalManager.refresh",workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(a)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)}}subscribeWorkspaceManagement(t,s){this.workspaceManagementSubscription={workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,s){const a={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(a)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:Ht(s==null?void 0:s.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var g;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const s=(g=kr.getState().session)==null?void 0:g.accessToken;if(!s){this.options.onUnauthorized();return}const a=kl(),o=Yc(a),c=o.baseUrl,p=`${Jc("/ws",c)}?access_token=${encodeURIComponent(s)}`,h=o.transport.createWebSocket({path:"/ws",baseUrl:c,url:p});this.socket=h,h.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),h.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),pt("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:c}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&h.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Ka(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&h.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&h.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&h.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),h.addEventListener("message",f=>{var N,j,T,H,O,L,v,K,F,te;if(!(f instanceof MessageEvent)||typeof f.data!="string")return;const w=JSON.parse(f.data);if(w.type==="system.connected"){this.connectionManager.markConnected();return}if(w.type==="session.error"){w.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(w.type==="workbench.snapshot"&&(pt("workbench.snapshot.received",{unchanged:w.unchanged,revision:w.revision,workspaceCount:((N=w.snapshot)==null?void 0:N.items.length)??0,sessionCount:w.snapshot?Yu(w.snapshot):0,subscribeDurationMs:Qr(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Qr(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),w.type==="workbench.delta"){pt("workbench.delta.received",{baseRevision:w.baseRevision,revision:w.revision,changedWorkspaceCount:w.changedItems.length,removedWorkspaceCount:w.removedWorkspaceIds.length,subscribeDurationMs:Qr(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Qr(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const M=Xu(this.lastWorkbenchSnapshot,w);if(!M){pt("workbench.delta.mismatch",{currentRevision:((j=this.lastWorkbenchSnapshot)==null?void 0:j.revision)??null,baseRevision:w.baseRevision,revision:w.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=M,this.workbenchKnownRevision=w.revision,this.options.onSnapshot(M);return}if(w.type==="fileTree.snapshot"){const M=w.snapshot;if(M)M.revision=w.revision,this.fileTreeRevisionByPath.set(lo(M.workspaceId,M.path),w.revision);else if(w.unchanged&&this.fileTreeSubscription)for(const X of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(lo(this.fileTreeSubscription.workspaceId,X),w.revision);if(!M)return;(H=(T=this.options).onFileTreeSnapshot)==null||H.call(T,M),this.fileTreeListeners.forEach(X=>X(M));return}if(w.type==="git.snapshot"){const M=w.snapshot;if(M?(M.revision=w.revision,this.gitRevisionByWorkspaceId.set(M.workspaceId,w.revision)):w.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,w.revision),!M)return;(L=(O=this.options).onGitSnapshot)==null||L.call(O,M),this.gitListeners.forEach(X=>X(M));return}if(w.type==="terminalManager.snapshot"){const M=w.snapshot;if(M?(M.revision=w.revision,this.terminalManagerRevisionByWorkspaceId.set(M.workspaceId,w.revision)):w.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,w.revision),!M)return;(K=(v=this.options).onTerminalManagerSnapshot)==null||K.call(v,M),this.terminalManagerListeners.forEach(X=>X(M));return}if(w.type==="workspaceManagement.snapshot"){const M=w.snapshot;if(M?(M.revision=w.revision,this.workspaceManagementRevisionByWorkspaceId.set(M.workspaceId,w.revision)):w.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,w.revision),!M)return;(te=(F=this.options).onWorkspaceManagementSnapshot)==null||te.call(F,M),this.workspaceManagementListeners.forEach(X=>X(M));return}w.type==="workbench.snapshot"&&w.snapshot&&Vu(w.snapshot)?(w.snapshot.revision=w.revision,this.lastWorkbenchSnapshot=w.snapshot,this.workbenchKnownRevision=w.revision,this.options.onSnapshot(w.snapshot)):w.type==="workbench.snapshot"&&w.unchanged&&(this.workbenchKnownRevision=w.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:w.revision}))}),h.addEventListener("close",()=>{this.disposed||this.socket!==h||this.connectionManager.markDisconnected()}),h.addEventListener("error",()=>{this.disposed||this.socket!==h||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),kr.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(t){const s=this.socket;return ci(s)?(s.send(JSON.stringify(t)),!0):!1}}function ci(e){return e!==null&&e.readyState===1}function Vu(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function di(e){const t=new Set;for(const s of e??[""])t.add(s.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Ht(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Xu(e,t){if(!e||e.revision!==t.baseRevision)return null;const s=new Map(e.items.map(o=>[o.workspace.id,o]));for(const o of t.removedWorkspaceIds)s.delete(o);for(const o of t.changedItems)s.set(o.workspace.id,o);const a=[];for(const o of t.orderedWorkspaceIds){const c=s.get(o);if(!c)return null;a.push(c)}return{revision:t.revision,items:a}}function za(e){return e?Object.fromEntries(Object.entries(e).map(([t,s])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),Ht(s)]).filter(t=>t[1]!==null)):{}}function Ka(e,t,s,a){const o=t.map(c=>{const p=c.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[p,s[p]??a.get(lo(e,p))??null]}).filter(c=>!!c[1]);if(o.length!==0)return Object.fromEntries(o)}function lo(e,t){return`${e}::${t}`}function Yu(e){return e.items.reduce((t,s)=>t+s.sessions.length+Ql(s.childWorktrees??[]),0)}function Ql(e){return e.reduce((t,s)=>{if(typeof s!="object"||s===null)return t;const a=s,o=Array.isArray(a.sessions)?a.sessions.length:0,c=Array.isArray(a.children)?Ql(a.children):0;return t+o+c},0)}function Qr(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const ui=6,Ju=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function Zu(e){return e instanceof HTMLElement?!e.closest(Ju):!0}function co(e,t,s){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&Zu(s)}function ec(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function tc(e){return ec(e)?"":void 0}function Qu(e){if(!co(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,s=e.clientY;let a=!0;const o=()=>{a&&(a=!1,window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",p),window.removeEventListener("blur",h))},c=g=>{Math.abs(g.clientX-t)<ui&&Math.abs(g.clientY-s)<ui||(o(),eh())},p=()=>{o()},h=()=>{o()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",p),window.addEventListener("blur",h)}async function eh(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await Tl().startDragging()}const ja=.78,th=1;function nh(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function nc(e,t,s,a){const o=Math.hypot(s-e,a-t),c=Math.min(1,o/120);return ja+(th-ja)*c}function Fn(e){return Math.round(Number.isFinite(e)?e:0)}function sh(e){if(!nh())return null;const t=Fn(e.x),s=Fn(e.y);let a=!1,o=Promise.resolve();const c=(h,g)=>(o=o.then(async()=>{await window.__TAURI_INTERNALS__.invoke(h,g)}).catch(()=>{}),o),p=async()=>{a||(a=!0,await c("close_detach_preview"))};return c("show_detach_preview",{title:e.title,x:t,y:s,scale:ja}),{updatePosition(h,g){if(a)return;const f=Fn(h),w=Fn(g);c("update_detach_preview_position",{x:f,y:w,scale:nc(t,s,f,w)})},complete(){return p()},cancel(){return p()}}}function rh(e){if(typeof document>"u")return null;const t=Fn(e.x),s=Fn(e.y),a=document.createElement("div");a.className="desktop-window-detach-animation",a.setAttribute("aria-hidden","true"),a.dataset.state="preview",a.style.left=`${t}px`,a.style.top=`${s}px`,a.style.setProperty("--detach-preview-scale",ja.toFixed(3));const o=document.createElement("div");o.className="desktop-window-detach-animation-bar";const c=document.createElement("strong");c.className="desktop-window-detach-animation-title",c.textContent=e.title;const p=document.createElement("div");p.className="desktop-window-detach-animation-body",o.append(c),a.append(o,p),document.body.append(a);let h=!1;const g=()=>{h||(h=!0,a.remove())};return{updatePosition(f,w){if(h)return;const N=Fn(f),j=Fn(w),T=nc(t,s,N,j);a.style.left=`${N}px`,a.style.top=`${j}px`,a.style.setProperty("--detach-preview-scale",T.toFixed(3))},async complete(){g()},async cancel(){g()}}}function hi(e){return sh(e)??rh(e)}const ah={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 oh(e){return{...e,bounds:{...e.bounds}}}function ih(e,t,s){t&&(e.windows.registerDescriptor(t),s?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function lh(e){return ah[e]}function sc(e,t){return`${e}-${t}`}async function Ta(e,t,s){const a=s.workspaceId.trim(),o=lh(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!a)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${o.label}外部窗口必须绑定工作区。`};const c=sc(t,a),p=e.windows.getDescriptor(c),h=p?oh(p):null,g=e.windows.isWindowOpen(c),f=Zc({windowId:c,kind:t,workspaceId:a,workspaceName:s.workspaceName??(h==null?void 0:h.workspaceName)??null,sessionId:s.sessionId??(h==null?void 0:h.sessionId)??null,mode:"external",bounds:h==null?void 0:h.bounds,focusOwner:s.focusOwner??o.defaultFocusOwner});e.windows.registerDescriptor(f);const w=await e.bridge.createWindow(f);return w.ok?(e.windows.markWindowOpen(c),{ok:!0,value:f}):(h?ih(e,h,g):e.windows.removeWindow(c),{ok:!1,errorCode:w.errorCode,detail:w.detail})}function ib(e){return sc("terminals",e)}function ch(e,t){return Ta(e,"files",t)}function dh(e,t){return Ta(e,"git",t)}function uh(e,t){return Ta(e,"processes",t)}function lb(e,t){return Ta(e,"terminals",t)}async function pi(){return await re.request("/api/skills/overview")}async function hh(e){await re.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function ph(e){await re.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function mh(e){await re.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function fh({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:s}){const a=wl(S=>{var I;return((I=S.session)==null?void 0:I.accessToken)??null}),o=i.useRef(null),[c,p]=i.useState(null),[h,g]=i.useState(!1),[f,w]=i.useState(null),[N,j]=i.useState(null),[T,H]=i.useState(null),[O,L]=i.useState(!1),[v,K]=i.useState(!1),[F,te]=i.useState(null),[M,X]=i.useState("file"),[V,D]=i.useState("workspace"),[y,Y]=i.useState(""),[Q,B]=i.useState(()=>cr("workspace"));i.useEffect(()=>{let S=!0;if(!O)return;if(!a){p(null),j(null),H(null),g(!1);return}return(async()=>{g(!0);try{const Z=await pi();if(!S)return;p(Z),j(null)}catch(Z){if(!S)return;j(Es(Z))}finally{S&&g(!1)}})(),()=>{S=!1}},[a,O]);async function me(){const S=await pi();p(S),j(null)}async function ue(){if(a){w("refresh"),j(null),H(null);try{await me(),H(r("settings.skillRefreshSuccess"))}catch(S){j(Es(S))}finally{w(null)}}}async function ne(S){if(a){w(mi(S)),j(null),H(null);try{await ph({targetCli:S.targetCli,directoryPath:S.directoryPath,expectedContentHash:S.contentHash}),await me(),H(r("settings.skillImportSuccess",{name:S.name,target:On(S.targetCli)}))}catch(I){j(Es(I))}finally{w(null)}}}async function W(S){if(!a)return;const I=S.bindings.filter(Z=>Z.enabled).map(Z=>Z.targetCli);if(I.length===0){j(r("settings.skillSyncTargetMissing"));return}w(fi(S.skill.id)),j(null),H(null);try{await mh({skillId:S.skill.id,targetCli:I}),await me(),H(r("settings.skillSyncSuccess",{name:S.skill.name}))}catch(Z){j(Es(Z))}finally{w(null)}}async function x(S){var Z;const I=((Z=S.target.files)==null?void 0:Z[0])??null;if(S.target.value="",!!I){j(null),H(null);try{const U=await Eh(I),Ce=oc(I.name,U);te(Ce),B(cr(V))}catch(U){j(Es(U))}}}async function C(){const S=bi({sourceMode:M,fileDraft:F,pastedMarkdown:y});if(!a)return;if(!S){j(M==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty"));return}const I=S.directoryName;if(!I){j(r("settings.skillUploadDirectoryInvalid"));return}const Z=uo(V).filter(U=>Q[U]).map(U=>U);if(Z.length===0){j(r("settings.skillUploadTargetRequired"));return}w("upload"),j(null),H(null);try{await hh({markdownContent:S.rawContent,scope:V,fileName:S.fileName,directoryName:I,targetCli:Z}),await me(),H(r("settings.skillUploadSuccess",{name:I})),ae(V),K(!1)}catch(U){j(Es(U))}finally{w(null)}}function $(S){D(S),B(cr(S))}function se(S){X(S),te(null),Y(""),B(cr(V)),j(null)}function Me(S){B(I=>({...I,[S]:!I[S]}))}function xe(){K(!0),j(null)}function oe(){K(!1),j(null),ae(V)}function ae(S){te(null),Y(""),X("file"),B(cr(S))}const he=(c==null?void 0:c.summary)??{managedSkillCount:0,managedEntryCount:0},We=Mh((c==null?void 0:c.assistantRuntimeSkills)??[],(c==null?void 0:c.conflictedEntries)??[],(c==null?void 0:c.diagnostics)??[]),J=((c==null?void 0:c.conflictedEntries)??[]).filter(S=>!ac(S,(c==null?void 0:c.diagnostics)??[])),ge=((c==null?void 0:c.diagnostics)??[]).filter(S=>!yr(S)),Te=bi({sourceMode:M,fileDraft:F,pastedMarkdown:y}),Ye=t??r("settings.skillManageAction");return n.jsxs(n.Fragment,{children:[n.jsxs("button",{className:e,type:"button","data-open":O?"true":"false","aria-haspopup":"dialog","aria-expanded":O,onClick:()=>{L(!0)},children:[s,n.jsx("span",{children:Ye})]}),n.jsxs(nt,{open:O,title:r("settings.skillConfigModalTitle"),description:r("settings.skillConfigModalDescription"),className:"settings-skill-modal",headerActions:n.jsxs("div",{className:"settings-skill-modal-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:!a||h||f!==null,onClick:xe,children:r("settings.skillCreateAction")}),n.jsx("button",{className:"secondary-button",type:"button",disabled:!a||h||f!==null,onClick:()=>{ue()},children:f==="refresh"?r("common.loading"):r("settings.skillRefresh")})]}),onClose:()=>L(!1),children:[n.jsxs("section",{className:"settings-skill-summary-block",children:[n.jsxs("div",{className:"settings-skill-summary-grid",children:[n.jsx(ea,{label:r("settings.skillSummaryManagedSkills"),value:String(he.managedSkillCount)}),n.jsx(ea,{label:r("settings.skillSummaryManagedEntries"),value:String(he.managedEntryCount)}),n.jsx(ea,{label:r("settings.skillSummaryConflictedEntries"),value:String(J.length)}),n.jsx(ea,{label:r("settings.skillSummaryDiagnostics"),value:String(ge.length)})]}),n.jsx("div",{className:"settings-release-meta",children:n.jsxs("span",{children:[r("settings.skillScannedAt"),": ",h?r("common.loading"):Ih(c==null?void 0:c.scannedAt)]})}),T?n.jsx("p",{className:"settings-release-status",children:T}):null,N?n.jsx("p",{className:"settings-release-status",children:N}):null]}),n.jsx(lr,{title:r("settings.skillManagedListTitle"),emptyText:r("settings.skillManagedEmpty"),items:(c==null?void 0:c.managedSkills)??[],renderItem:S=>{const I=fi(S.skill.id);return n.jsxs("div",{className:"settings-skill-entry",children:[n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:S.skill.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:Sh(S.bindings)}),n.jsx("div",{className:"settings-skill-tags",children:S.bindings.map(Z=>n.jsxs("span",{className:"settings-skill-tag","data-status":Z.syncStatus,children:[On(Z.targetCli)," · ",yh(Z.syncStatus)]},`${S.skill.id}-${Z.targetCli}`))})]}),n.jsx("div",{className:"settings-skill-entry-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:h||f!==null,onClick:()=>{W(S)},children:f===I?r("common.loading"):r("settings.skillSyncAction")})})]},S.skill.id)}}),n.jsx(lr,{title:r("settings.skillUnmanagedListTitle"),emptyText:r("settings.skillUnmanagedEmpty"),items:(c==null?void 0:c.unmanagedEntries)??[],renderItem:S=>{const I=mi(S);return n.jsxs("div",{className:"settings-skill-entry",children:[n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:S.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:jh(S)})]}),n.jsx("div",{className:"settings-skill-entry-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:h||f!==null,onClick:()=>{ne(S)},children:f===I?r("common.loading"):r("settings.skillImportAction")})})]},`${S.targetCli}:${S.directoryPath}`)}}),n.jsx(lr,{title:r("settings.skillAssistantRuntimeListTitle"),description:r("settings.skillAssistantRuntimeListDescription"),emptyText:r("settings.skillAssistantRuntimeEmpty"),items:We,renderItem:S=>n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:S.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:r("settings.skillAssistantRuntimeItemDescription")}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillAssistantRuntimeUsedBy"),": ",rc(S.usedByTargetCli)]}),n.jsxs("div",{className:"settings-skill-tags",children:[n.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:r("settings.skillTagAssistantOnly")}),S.usedByTargetCli.map(I=>n.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:On(I)},`${S.directoryName}:${I}`))]})]})},`${S.directoryName}:${S.sourcePath}`)}),n.jsx(lr,{title:r("settings.skillConflictedListTitle"),emptyText:r("settings.skillConflictedEmpty"),items:J,renderItem:S=>{const I=Th(S,(c==null?void 0:c.diagnostics)??[]);return n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:S.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:Ch(S)}),I.length>0?n.jsx("div",{className:"settings-skill-tags",children:I.map(Z=>n.jsx("span",{className:"settings-skill-tag","data-status":Z.status,children:Z.label},Z.key))}):null]})},`${S.targetCli}:${S.directoryPath}`)}}),n.jsx(lr,{title:r("settings.skillDiagnosticsTitle"),emptyText:r("settings.skillDiagnosticsEmpty"),items:ge,renderItem:S=>{const I=Rh(S),Z=Nh(S);return n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:Z.title}),n.jsx("p",{className:"settings-skill-entry-meta",children:Z.detail}),I.length>0?n.jsx("div",{className:"settings-skill-tags",children:I.map(U=>n.jsx("span",{className:"settings-skill-tag","data-status":U.status,children:U.label},U.key))}):null]})},`${S.targetCli}:${S.code}:${S.directoryPath??S.rootDir}`)}})]}),n.jsx(nt,{open:v,title:r("settings.skillCreateModalTitle"),description:r("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:oe,children:n.jsxs("section",{className:"settings-skill-section",children:[n.jsx("h3",{className:"settings-skill-section-title",children:r("settings.skillUploadSectionTitle")}),n.jsx("p",{className:"settings-skill-section-description",children:r("settings.skillUploadSectionDescription")}),n.jsxs("div",{className:"settings-skill-create-panel",children:[n.jsx("input",{ref:o,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:S=>{x(S)}}),n.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":r("settings.skillCreateSourceTabsLabel"),children:wh.map(S=>{const I=M===S;return n.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":I,"data-active":I?"true":"false",onClick:()=>se(S),children:xh(S)},S)})}),n.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":r("settings.skillUploadScopeLabel"),children:kh.map(S=>n.jsxs("label",{className:"settings-skill-upload-target","data-selected":V===S?"true":"false",children:[n.jsx("input",{type:"radio",name:"skill-upload-scope",checked:V===S,onChange:()=>$(S)}),n.jsx("span",{children:vh(S)})]},S))}),M==="file"?n.jsx("div",{className:"settings-skill-create-toolbar",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:h||f!==null,onClick:()=>{var S;(S=o.current)==null||S.click()},children:r("settings.skillUploadPickAction")})}):n.jsxs("label",{className:"settings-skill-upload-field",children:[n.jsx("span",{children:r("settings.skillPasteLabel")}),n.jsx("textarea",{className:"settings-skill-create-textarea",value:y,onChange:S=>Y(S.target.value),placeholder:r("settings.skillPastePlaceholder")})]}),Te?n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:Te.previewTitle}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillUploadPickedFile"),": ",Te.fileName]})]})}):n.jsx("div",{className:"settings-skill-empty",children:M==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty")}),n.jsxs("div",{className:"settings-skill-upload-field",children:[n.jsx("span",{children:r("settings.skillUploadTargetsLabel")}),n.jsx("div",{className:"settings-skill-upload-targets",children:uo(V).map(S=>n.jsxs("label",{className:"settings-skill-upload-target","data-selected":Q[S]?"true":"false",children:[n.jsx("input",{type:"checkbox",checked:Q[S],onChange:()=>Me(S)}),n.jsx("span",{children:On(S)})]},S))})]}),Te!=null&&Te.notes.length?n.jsx("div",{className:"settings-skill-tags",children:Te.notes.map((S,I)=>n.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:S},`${Te.fileName}:${I}`))}):null,N?n.jsx("p",{className:"settings-release-status",children:N}):null,n.jsx("div",{className:"settings-skill-create-actions",children:n.jsx("button",{className:"primary-button",type:"button",disabled:h||f!==null,onClick:()=>{C()},children:f==="upload"?r("common.loading"):r("settings.skillCreateSubmitAction")})})]})]})})]})}function lr({title:e,description:t,emptyText:s,items:a,renderItem:o}){return n.jsxs("section",{className:"settings-skill-section",children:[n.jsx("h3",{className:"settings-skill-section-title",children:e}),t?n.jsx("p",{className:"settings-skill-section-description",children:t}):null,a.length>0?n.jsx("div",{className:"settings-skill-entry-list",children:a.map(c=>o(c))}):n.jsx("div",{className:"settings-skill-empty",children:s})]})}function ea({label:e,value:t}){return n.jsxs("div",{className:"settings-skill-summary-card",children:[n.jsx("span",{children:e}),n.jsx("strong",{children:t})]})}function mi(e){return`import:${e.targetCli}:${e.directoryPath}`}function fi(e){return`sync:${e}`}const bh=["codex","claude-code","gemini","opencode"],gh=["codex","claude-code"],kh=["workspace","assistant"],wh=["file","paste"];function Es(e){return e instanceof vl?e.message||r("settings.skillLoadFailed"):e instanceof Error?e.message:r("settings.skillLoadFailed")}function On(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 vh(e){return e==="assistant"?r("settings.skillUploadScopeAssistant"):r("settings.skillUploadScopeWorkspace")}function xh(e){return e==="paste"?r("settings.skillCreateSourcePaste"):r("settings.skillCreateSourceFile")}function cr(e){return{codex:new Set(uo(e)).has("codex"),"claude-code":!1,gemini:!1,opencode:!1}}function uo(e){return e==="assistant"?gh:bh}function bi({sourceMode:e,fileDraft:t,pastedMarkdown:s}){return e==="file"?t:s.trim()?oc(Ph(s),s):null}function yh(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 rc(e){return e.map(On).join(" / ")}function Sh(e){const t=e.filter(s=>s.enabled);return t.length===0?r("settings.skillManagedItemNoTarget"):r("settings.skillManagedItemDescription",{targets:rc(t.map(s=>s.targetCli))})}function jh(e){return r("settings.skillUnmanagedItemDescription",{target:On(e.targetCli)})}function Ch(e){return r("settings.skillConflictedItemDescription",{target:On(e.targetCli)})}function Nh(e){const t=On(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:r("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:r("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:r("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:r("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:r("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:r("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:r("settings.skillDiagnosticGenericTitle",{target:t}),detail:r("settings.skillDiagnosticGenericDetail",{target:t})}}}function Ih(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Mh(e,t,s){if(e.length>0)return e.map(o=>({name:o.name,directoryName:o.directoryName,sourcePath:o.sourcePath,usedByTargetCli:o.usedByTargetCli}));const a=new Map;for(const o of t)ac(o,s)&&a.set(gi(o.targetCli,o.directoryPath),{name:o.name,directoryName:o.directoryName,sourcePath:o.directoryPath,usedByTargetCli:[o.targetCli]});for(const o of s){if(!yr(o))continue;const c=o.directoryPath??o.rootDir,p=gi(o.targetCli,c);a.has(p)||a.set(p,{name:o.directoryName??"codingns-assistant",directoryName:o.directoryName??"codingns-assistant",sourcePath:c,usedByTargetCli:[o.targetCli]})}return[...a.values()]}function gi(e,t){return`${e}:${t}`}function ac(e,t){return t.some(s=>yr(s)&&s.targetCli===e.targetCli&&s.directoryPath===e.directoryPath&&s.directoryName===e.directoryName)}function yr(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function Th(e,t){return t.find(a=>yr(a)&&a.targetCli===e.targetCli&&a.directoryName===e.directoryName&&a.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Rh(e){return yr(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function oc(e,t){const s=[],a=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
3
+ `).trim();if(!a)throw new Error(r("settings.skillUploadContentEmpty"));a!==t.trim()&&s.push(r("settings.skillUploadNormalizedNote"));const o=ic(a),c=ho(e)??ho(o)??"";return c||s.push(r("settings.skillUploadDirectoryRequiredNote")),o||s.push(r("settings.skillUploadHeadingNote")),{fileName:e,rawContent:a,directoryName:c,previewTitle:o||Ah(c||"skill"),notes:s}}async function Eh(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(r("settings.skillUploadReadFailed"));return await new Promise((t,s)=>{const a=new FileReader;a.onerror=()=>{s(a.error??new Error(r("settings.skillUploadReadFailed")))},a.onload=()=>{if(typeof a.result=="string"){t(a.result);return}s(new Error(r("settings.skillUploadReadFailed")))},a.readAsText(e)})}function ho(e){const a=(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 a.length>0?a:null}function Ph(e){const t=ho(ic(e));return t?`${t}.md`:"pasted-skill.md"}function ic(e){var t,s;return((s=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:s.trim())??""}function Ah(e){return e.split(/[._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")||e}function Ao(e){var t,s;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((s=e.lastErrorDetail)!=null&&s.trim())}function Wh(e,t,s){return`${e} is-${lc(t,s)}`}function lc(e,t){t==null||t.isActive;const s=Dh(e);return t!=null&&t.hasSubagents?s==="error"?"error":s==="unread"?"subagent-unread":s==="running"||s==="running_inferred"?"subagent-running":"subagent":s==="running_inferred"?"running-inferred":s.replace("_","-")}function Lh(e){return e.runningState==="stale"?r("conversation.runtimeStale"):e.runningState==="unknown"?r("conversation.runtimeUnknown"):null}function Bh(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function cb(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function Dh(e){return Ao(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?_h(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function _h(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function Fh(e){return Wo(e)!==null}function Oh(e){return e.isSubagent===!0&&!Fh(e)}function Wo(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 $h(e){const t=Wo(e);return t==="reconstructed"?r("shell.sessionForkReconstructed"):t==="message"?r("shell.sessionForkMessage"):t==="session"?r("shell.sessionForkSession"):null}function Hh(e){return e.sessionKind==="annotation"?"annotation":null}function db(e){return Hh(e)==="annotation"?r("conversation.actionSessionBadge"):null}const ki=48;function Uh(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Lo(e,t){const s=Uh(e)||t,a=s.length>ki?s.slice(0,ki).trimEnd():s;return{fullTitle:s,displayTitle:a}}function ta(e,t){return(t??"").localeCompare(e??"")}function wi(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function na(e){return(e==null?void 0:e.trim())??""}function Bo(e,t,s){if(s==="updatedAt"){const p=ta(e.updatedAt,t.updatedAt);if(p!==0)return p}if(s==="title"){const p=wi(na(e.title),na(t.title));if(p!==0)return p}else{const p=ta(e.createdAt,t.createdAt);if(p!==0)return p}const a=ta(e.updatedAt,t.updatedAt);if(a!==0)return a;const o=ta(e.createdAt,t.createdAt);if(o!==0)return o;const c=wi(na(e.title),na(t.title));return c!==0?c:e.sessionId.localeCompare(t.sessionId)}function Sr(e,t){return[...e].sort((s,a)=>Bo(s,a,t))}function Do(e,t){return Array.isArray(e)?e.map(s=>({...s,sessions:Sr(s.sessions,t),children:Do(s.children,t)})):[]}const qa=5,Va=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function Gh(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function zh(e,t){const s=e.reduce((h,g)=>h+g.count,0);if(s<=0)return[];const o=e.slice(0,qa).map((h,g)=>({...h,key:h.type,ratio:h.count/s,color:Va[g]??Va[0]})),c=e.slice(qa);if(c.length===0)return o;const p=c.reduce((h,g)=>h+g.count,0);return o.push({key:"other",type:t,count:p,ratio:p/s,color:Va[qa]}),o}function Kh(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((a,o)=>{const c=t,p=o===e.length-1?1:Math.min(1,t+a.ratio);return t=p,`${a.color} ${vi(c)} ${vi(p)}`}).join(", ")})`}function qh(e){return{"--workbench-manage-chart-background":Kh(e)}}function vi(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const Vh=8,Xh=12,Yh=160,xi=96;function Jh(e,t,s,a={}){const o=a.gapPx??Vh,c=a.viewportMarginPx??Xh,p=a.defaultWidthPx??Yh,h=a.estimatedHeightPx??xi,g=a.minHeightPx??xi,f=Math.max(0,s.width),w=Math.max(0,s.height),N=Math.max(0,w-c*2),j=Math.max(0,f-c*2),T=sa(Math.max(t.width||p,p),0,j),H=Math.max(t.height||h,h),O=Math.max(0,f-e.x-c),L=Math.max(0,e.x-c),v=O<T&&L>O,K=Math.max(0,w-e.y-o-c),F=Math.max(0,e.y-o-c),te=K<H&&F>K,X=sa(Math.max(te?F:K,g),0,N),V=Math.min(H,X),D=v?e.x-T:e.x,y=Math.max(c,f-c-T),Y=te?e.y-o-V:e.y+o,Q=Math.max(c,w-c-V),B=sa(D,c,y),me=sa(Y,c,Q),ue=v||B<e.x?"right":"left";return{top:me,left:B,width:T,maxHeight:Math.max(0,X),transformOrigin:`${te?"bottom":"top"} ${ue}`}}function sa(e,t,s){return!Number.isFinite(e)||s<t?t:Math.min(Math.max(e,t),s)}const cc="workbench.navigation.snapshot",dc=1800*1e3,Zh="workbench.navigation.snapshot.host.";function uc(e){return`${Zh}${e}`}function Qh(e=dc,t=Na(Qt.getState())){if(t){const s=ya(uc(t),e);if(s)return s}return ya(cc,e)}function ra(e,t=Na(Qt.getState())){br(cc,e),t&&br(uc(t),e)}function yi(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(s=>({workspace:s.workspace,sessions:Sr(s.sessions,t),childWorktrees:ep(s.childWorktrees,t)}))}function ep(e,t){return Do(e,t)}function Ca(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 tp(e){const t=new Map;for(const s of e)t.set(s.workspace.id,Ca(s.workspace)),hc(t,s.childWorktrees??[],s.workspace,s.workspace);return Object.fromEntries(t)}function yn(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function hc(e,t,s,a,o=a.name){var c;for(const p of t){const h=((c=p.meta.displayName)==null?void 0:c.trim())||p.workspace.name;e.set(p.workspace.id,{workspaceId:p.workspace.id,tone:"worktree",backgroundColor:p.workspace.backgroundColor??null,displayName:h,workspaceName:p.workspace.name,branchName:p.meta.branchName||null,depth:p.meta.depth,rootWorkspaceId:s.id,rootDisplayName:s.name,parentWorkspaceId:p.meta.parentWorkspaceId||a.id,parentDisplayName:o}),hc(e,p.children,s,p.workspace,h)}}const np="X-CodingNS-Assistant-Source",sp="butler-ui",Xa=new Map;async function Sn(e,t={},s={}){const a=new Headers(t.headers);a.set(np,sp);const o=rp();if(Xa.get(o)===!1){if(s.unsupportedFallback!==void 0)return Si(s.unsupportedFallback);throw ji()}try{const p=await re.request(e,{...t,headers:a});return Xa.set(o,!0),p}catch(p){if(!ap(p))throw p;if(Xa.set(o,!1),s.unsupportedFallback!==void 0)return Si(s.unsupportedFallback);throw ji()}}function rp(){return kl()}function Si(e){return typeof e=="function"?e():e}function ap(e){return e instanceof vl&&(e.status===404||e.status===405||e.status===501)}function ji(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function op(){return re.request("/api/butler/profile")}function ub(e){return re.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function hb(e){return re.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function pb(){return re.request("/api/butler/control-session")}function mb(){return re.request("/api/butler/control-sessions")}function fb(e){return re.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function bb(e={}){var o;const t=new URLSearchParams;e.status&&t.set("status",e.status),(o=e.controlSessionId)!=null&&o.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const s=t.toString(),a=s?`/api/butler/control-timers?${s}`:"/api/butler/control-timers";return re.request(a)}function gb(){return re.request("/api/butler/control-session/reset",{method:"POST"})}function kb(e={}){return re.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function wb(e){return re.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function vb(e={}){var o;const t=new URLSearchParams;e.status&&t.set("status",e.status),(o=e.controlSessionId)!=null&&o.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const s=t.toString(),a=s?`/api/assistant/automations?${s}`:"/api/assistant/automations";return Sn(a,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function xb(e={}){var o;const t=new URLSearchParams;(o=e.controlSessionId)!=null&&o.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const s=t.toString(),a=s?`/api/assistant/automations/runs/recent?${s}`:"/api/assistant/automations/runs/recent";return Sn(a,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function yb(e){return Sn(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function Sb(e,t){return Sn(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function jb(e){return Sn(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function Cb(e={}){var o;const t=new URLSearchParams;e.status&&t.set("status",e.status),(o=e.controlSessionId)!=null&&o.trim()&&t.set("controlSessionId",e.controlSessionId.trim());const s=t.toString(),a=s?`/api/assistant/sandboxes?${s}`:"/api/assistant/sandboxes";return Sn(a,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function Nb(e){return Sn(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function Ib(e){return Sn(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function Mb(e){return Sn(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function Tb(e){return re.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function Rb(){return re.request("/api/butler/control-session/events")}function ip(){return re.request("/api/butler/overview")}function lp(e={}){var o;const t=new URLSearchParams;(o=e.workspaceId)!=null&&o.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel);const s=t.toString(),a=s?`/api/butler/projects?${s}`:"/api/butler/projects";return re.request(a)}function Eb(e,t={}){const s=new URLSearchParams;t.enabled!==null&&t.enabled!==void 0&&s.set("enabled",String(t.enabled)),t.executionMode&&s.set("executionMode",t.executionMode);const a=s.toString(),o=a?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${a}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return re.request(o)}function pc(e={}){var o,c;const t=new URLSearchParams;(o=e.workspaceId)!=null&&o.trim()&&t.set("workspaceId",e.workspaceId.trim()),(c=e.projectId)!=null&&c.trim()&&t.set("projectId",e.projectId.trim()),e.status&&t.set("status",e.status),e.itemType&&t.set("itemType",e.itemType);const s=t.toString(),a=s?`/api/butler/inbox?${s}`:"/api/butler/inbox";return re.request(a)}function cp(e){return re.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function dp(e={}){var o,c;const t=new URLSearchParams;e.status&&t.set("status",e.status),(o=e.projectId)!=null&&o.trim()&&t.set("projectId",e.projectId.trim()),(c=e.sessionId)!=null&&c.trim()&&t.set("sessionId",e.sessionId.trim());const s=t.toString(),a=s?`/api/butler/follow-up-tasks?${s}`:"/api/butler/follow-up-tasks";return re.request(a)}function Pb(e){return re.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function Ab(e){return re.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function Wb(e){return re.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function Lb(e,t){return re.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function Ci(e,t){return re.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:t.projectId,itemType:t.itemType,title:t.title,content:t.content,priority:t.priority,status:t.status})})}function Bb(e){return re.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function Db(e){return re.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function up(e){return re.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function hp(){return re.request("/api/butler/notifications/archives")}function pp(e,t){return re.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function mp(e){const t=new URLSearchParams;return t.set("sessionId",e),re.request(`/api/butler/session-target?${t.toString()}`)}function _b(e){const t=new URLSearchParams;return t.set("sessionId",e),re.request(`/api/butler/session-action-context?${t.toString()}`)}function Fb(e){return re.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}class po extends Error{constructor(t,s){super(s),this.code=t,this.name="HostSwitchError"}}class fp{constructor(){Pe(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const s=this.performSwitch(t).finally(()=>{this.inFlight===s&&(this.inFlight=null)});this.inFlight=s,await s}async performSwitch(t){const s=Qt.getState();if(Na(s)===t)return;const a=Qc(s,t);if(!a)throw new po("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await ed(a.baseUrl)).reachable)throw new po("HOST_UNREACHABLE",`目标 HOST 不可达:${a.baseUrl}`);const c=xl(a.id);if(c)try{await kr.loginForHost(a,{username:c.username,password:c.password})}catch{}const p=Qt.getState(),h=new Date().toISOString();if(yl(a)){Qt.updateRuntime({discoveredHosts:p.discoveredHosts.map(g=>g.id===t?{...g,lastConnectedAt:h,updatedAt:h}:g),activeDiscoveredHostId:t});return}ro.setActiveDiscoveredHost(null),await Qt.update({hosts:p.hosts.map(g=>g.id===t?{...g,lastConnectedAt:h,updatedAt:h}:g),activeHostId:t})}}const bp=new fp;function gp({open:e,id:t,role:s="dialog",labelledBy:a,className:o,anchorRef:c,popoverRef:p,children:h,maxWidth:g=360,gap:f=10,viewportPadding:w=16}){const[N,j]=i.useState(null);if(i.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){j(null);return}let H=0;const O=()=>{const v=c.current;if(!v)return;const K=v.getBoundingClientRect(),F=Math.max(180,Math.min(g,window.innerWidth-w*2)),te=Math.min(Math.max(w,K.right-F),Math.max(w,window.innerWidth-w-F)),M=K.top>=Math.min(240,window.innerHeight*.42),X=Math.round(M?K.top-f:K.bottom+f);j({top:X,left:Math.round(te),width:F,placeAbove:M})},L=()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(O)};return O(),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{window.cancelAnimationFrame(H),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[c,f,g,e,w]),!e||!N||typeof document>"u")return null;const T={position:"fixed",top:N.top,left:N.left,width:N.width,maxWidth:`calc(100vw - ${w*2}px)`,zIndex:9999,transform:N.placeAbove?"translateY(-100%)":void 0};return Os.createPortal(n.jsx("div",{id:t,ref:p,role:s,"aria-labelledby":a,className:o,"data-placement":N.placeAbove?"top":"bottom",style:T,children:h}),document.body)}const Ya={status:"idle",latencyMs:null};function mc({collapsed:e=!1}){const[t,s]=i.useState(!1),[a,o]=i.useState(!1),[c,p]=i.useState(""),[h,g]=i.useState(""),[f,w]=i.useState(""),[N,j]=i.useState(""),[T,H]=i.useState(null),[O,L]=i.useState(null),[v,K]=i.useState(null),[F,te]=i.useState(!1),[M,X]=i.useState(!1),[V,D]=i.useState(Ya),[y,Y]=i.useState(null),Q=i.useRef(null),B=i.useRef(null),me=i.useRef(null),ue=i.useRef(null),ne=go(I=>I),W=wl(I=>I.session),{showToast:x}=fs(),C=ao(ne),$=Na(ne),se=ld(),Me=td($),xe=i.useMemo(()=>Ni(ne.hosts,$),[$,ne.hosts]),oe=i.useMemo(()=>Ni(Sl(ne),$),[$,ne]),ae=i.useCallback(()=>{if(typeof window>"u")return;const I=Q.current;if(!I)return;const Z=I.getBoundingClientRect(),U=window.innerWidth,Ce=window.innerHeight,je=16,Re=8,mt=Math.min(320,Math.max(240,U-je*2)),_=Math.min(e?Math.max(je,Z.right+Re):Math.max(je,Z.left),Math.max(je,U-mt-je)),R=a?440:240,ie=e?Z.top:Z.bottom+Re,ce=Math.min(Math.max(je,ie),Math.max(je,Ce-R-je));Y({position:"fixed",top:ce,left:_,width:mt,maxWidth:U-je*2})},[e,a]);i.useEffect(()=>{if(!t){Y(null),te(!1),D(Ya);return}ro.refresh();function I(U){var Ce,je,Re;U.target instanceof Node&&!((Ce=Q.current)!=null&&Ce.contains(U.target))&&!((je=B.current)!=null&&je.contains(U.target))&&!((Re=ue.current)!=null&&Re.contains(U.target))&&(s(!1),o(!1),te(!1),K(null))}function Z(U){U.key==="Escape"&&(s(!1),o(!1),te(!1),K(null))}return window.addEventListener("pointerdown",I),window.addEventListener("keydown",Z),window.addEventListener("resize",ae),window.addEventListener("scroll",ae,!0),ae(),()=>{window.removeEventListener("pointerdown",I),window.removeEventListener("keydown",Z),window.removeEventListener("resize",ae),window.removeEventListener("scroll",ae,!0)}},[t,ae]),i.useEffect(()=>{if(!F||!t||(se==null?void 0:se.kind)!=="relay"){D(Ya);return}let I=!1;const Z=performance.now();return D({status:"probing",latencyMs:null}),re.request("/api/client/runtime-config").then(()=>{I||D({status:"ready",latencyMs:performance.now()-Z})}).catch(()=>{I||D({status:"error",latencyMs:null})}),()=>{I=!0}},[se==null?void 0:se.kind,F,t]);async function he(I){if(T||O||I.id===$){s(!1);return}H(I.id);try{await bp.switchHost(I.id),s(!1),o(!1),te(!1),K(null)}catch(Z){x({title:yp(Z,I.name),tone:"error"})}finally{H(null)}}async function We(I){if(!(I.id===$||T||O)){if(v!==I.id){K(I.id);return}L(I.id);try{await Qt.update({hosts:ne.hosts.filter(Z=>Z.id!==I.id)}),nd(I.id),kr.clearHostSession(I.id),K(null),x({title:r("shell.hostDeleteSuccess",{name:I.name})})}catch{x({title:r("shell.hostDeleteFailed",{name:I.name}),tone:"error"})}finally{L(null)}}}async function J(){if(M)return;const I=c.trim(),Z=f.trim();if((Z.length>0||N.length>0)&&(!Z||!N)){x({title:r("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Ce;try{Ce=sd(h)}catch{x({title:r("shell.hostAddInvalidUrl"),tone:"error"});return}X(!0);try{const je=await Ld(Ce),Re=Qt.getState(),At=ao(Re);if(je?Re.hosts.find(ce=>{var pe;return ce.baseUrl===Ce||!!je.bindingId&&((pe=ce.relayTunnel)==null?void 0:pe.bindingId)===je.bindingId}):Re.hosts.find(ce=>ce.baseUrl===Ce)){x({title:r("shell.hostAddDuplicate"),tone:"error"});return}const _=yl(At)&&At.baseUrl===Ce;_&&ro.setActiveDiscoveredHost(null);let R,ie;if(je){const pe=(await Qt.update(Bd(Re,je,{activate:_,displayName:I}))).hosts.find(ke=>vp(ke,Ce,je.bindingId??null));if(!pe)throw new Error("relay entry host missing after save");R=pe.id,ie=pe.name}else{const ce=new Date().toISOString(),pe={id:xp(),name:I||kp(Ce),baseUrl:Ce,kind:wp(Ce),createdAt:ce,updatedAt:ce,lastConnectedAt:null,lastUserId:null,lastUsername:null};await Qt.update({hosts:[...Re.hosts,pe],activeHostId:_?pe.id:Re.activeHostId}),R=pe.id,ie=pe.name}Z&&N&&rd({hostId:R,username:Z,password:N}),ge(),o(!1),K(null),x({title:r("shell.hostAddSuccess",{name:ie})})}catch{x({title:r("shell.hostAddFailed"),tone:"error"})}finally{X(!1)}}function ge(){p(""),g(""),w(""),j("")}if(!C)return null;const Te=W!=null&&W.user.username?`${C.baseUrl} · ${W.user.username}`:C.baseUrl,Ye=(se==null?void 0:se.kind)==="relay"?r("shell.hostSwitcherDetailStatusRelay"):r("shell.hostSwitcherDetailStatusDirect"),S=se?r(cd(se.kind)):r("common.unknown");return n.jsxs("div",{ref:Q,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[n.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.hostSwitcherAriaLabel"),title:Te,"aria-expanded":t,onClick:()=>{s(I=>!I),o(!1)},children:n.jsx(Cp,{})}),t&&y&&typeof document<"u"?Os.createPortal(n.jsxs("div",{ref:B,className:"workbench-host-switcher-menu",style:y,role:"menu","aria-label":r("shell.hostSwitcherTitle"),children:[n.jsx("div",{className:"workbench-host-switcher-menu-header",children:n.jsx("strong",{children:r("shell.hostSwitcherTitle")})}),n.jsxs("div",{className:"workbench-host-switcher-list",children:[n.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherSavedSection")}),xe.map(I=>{const Z=I.id===$,U=Z?(W==null?void 0:W.user.username)??I.lastUsername??I.baseUrl:I.lastUsername??I.baseUrl;return n.jsxs("div",{className:"workbench-host-switcher-item","data-active":Z,children:[n.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:T!==null||O!==null,onClick:()=>{he(I)},children:[n.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[n.jsxs("span",{className:"workbench-host-switcher-item-title",children:[I.name,Z?n.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),n.jsx("span",{className:"workbench-host-switcher-item-meta",children:U})]}),n.jsx("span",{className:"workbench-host-switcher-item-trailing",children:T===I.id?r("shell.hostSwitcherSwitching"):Z?n.jsx(Mi,{}):n.jsx(Ii,{})})]}),Z?n.jsx("button",{ref:me,type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostSwitcherDetailAriaLabel",{name:I.name}),"aria-expanded":F,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{te(Ce=>!Ce),K(null)},children:r("shell.hostSwitcherDetailAction")}):n.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostDeleteAriaLabel",{name:I.name}),title:v===I.id?r("shell.hostDeleteConfirmAction"):r("shell.hostDeleteAction"),"data-confirming":v===I.id,disabled:T!==null||O!==null,onClick:()=>{We(I)},children:O===I.id?r("shell.hostDeleteBusy"):v===I.id?r("shell.hostDeleteConfirmAction"):n.jsx(Ip,{})})]},I.id)}),oe.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherDiscoveredSection")}),oe.map(I=>{const Z=I.id===$,U=xl(I.id),Ce=Z?(W==null?void 0:W.user.username)??(U==null?void 0:U.username)??I.baseUrl:(U==null?void 0:U.username)??I.baseUrl;return n.jsxs("div",{className:"workbench-host-switcher-item","data-active":Z,"data-discovered":"true",children:[n.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:T!==null||O!==null,onClick:()=>{he(I)},children:[n.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[n.jsxs("span",{className:"workbench-host-switcher-item-title",children:[I.name,n.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:r("shell.hostSwitcherDiscoveredBadge")}),Z?n.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),n.jsx("span",{className:"workbench-host-switcher-item-meta",children:Ce})]}),n.jsx("span",{className:"workbench-host-switcher-item-trailing",children:T===I.id?r("shell.hostSwitcherSwitching"):Z?n.jsx(Mi,{}):n.jsx(Ii,{})})]}),Z?n.jsx("button",{ref:me,type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostSwitcherDetailAriaLabel",{name:I.name}),"aria-expanded":F,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{te(je=>!je),K(null)},children:r("shell.hostSwitcherDetailAction")}):null]},I.id)})]}):null,ne.localHostDiscovery.status==="refreshing"?n.jsx("div",{className:"workbench-host-switcher-state-row",children:r("shell.hostDiscoveryRefreshing")}):null,ne.localHostDiscovery.status==="failed"?n.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:r("shell.hostDiscoveryFailed")}):null]}),a?n.jsxs("div",{className:"workbench-host-switcher-form",children:[n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("shell.hostSwitcherNameLabel")}),n.jsx("input",{value:c,disabled:M,onChange:I=>p(I.target.value),placeholder:r("shell.hostSwitcherNamePlaceholder")})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("shell.hostSwitcherUrlLabel")}),n.jsx("input",{value:h,disabled:M,onChange:I=>g(I.target.value),placeholder:r("shell.hostSwitcherUrlPlaceholder")})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("auth.username")}),n.jsx("input",{value:f,disabled:M,onChange:I=>w(I.target.value),autoComplete:"username"})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("auth.password")}),n.jsx("input",{type:"password",value:N,disabled:M,onChange:I=>j(I.target.value),autoComplete:"current-password"})]}),n.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:M,onClick:()=>{o(!1),ge()},children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:M,onClick:()=>{J()},children:M?r("common.loading"):r("shell.hostSwitcherSaveAction")})]})]}):n.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{o(!0),K(null)},children:[n.jsx(Np,{}),r("shell.hostSwitcherAddAction")]}),n.jsxs(gp,{open:F&&se!==null&&me.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:me,popoverRef:ue,labelledBy:"workbench-host-switcher-detail-title",children:[n.jsx("div",{className:"workbench-host-switcher-detail-header",children:n.jsx("strong",{id:"workbench-host-switcher-detail-title",children:r("shell.hostSwitcherDetailTitle")})}),n.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailStatusLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:Ye})]}),n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailRouteLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:S})]}),n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailAddressLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(se==null?void 0:se.url)??C.baseUrl})]}),(se==null?void 0:se.kind)==="relay"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailLatencyLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:Sp(V)})]}),n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailTrafficLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:jp(Me.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function Ni(e,t){return[...e].sort((s,a)=>{if(s.id===t)return-1;if(a.id===t)return 1;const o=s.lastConnectedAt??s.updatedAt??s.createdAt;return(a.lastConnectedAt??a.updatedAt??a.createdAt).localeCompare(o)})}function kp(e){try{const t=new URL(e),s=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${s}`}catch{return e}}function wp(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function vp(e,t,s){var a;return!!(e.baseUrl===t||s&&((a=e.relayTunnel)==null?void 0:a.bindingId)===s)}function xp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function yp(e,t){return e instanceof po?e.code==="HOST_UNREACHABLE"?r("shell.hostSwitchUnreachable",{name:t}):r("shell.hostSwitchMissing"):r("shell.hostSwitchFailed")}function Sp(e){return e.status==="probing"?r("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?r("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:r("shell.hostSwitcherDetailUnavailable")}function jp(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function Cp(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[n.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function Ii(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Mi(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.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 Np(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Ip(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.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 aa={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function Mp({open:e,onClose:t,onCloned:s}){const{showToast:a}=fs(),[o,c]=i.useState(!1),[p,h]=i.useState(aa),[g,f]=i.useState(!1),[w,N]=i.useState(!1),[j,T]=i.useState(null),[H,O]=i.useState(""),[L,v]=i.useState(""),[K,F]=i.useState(null),[te,M]=i.useState([]),[X,V]=i.useState([]),D=o||w;i.useEffect(()=>{!e&&!o&&(h(aa),f(!1),T(null))},[o,e]);const y=i.useCallback(async W=>{N(!0),T(null);try{const x=await jl(W);O(x.currentPath),v(x.currentPath),F(x.parentPath),M(x.roots),V(x.items),h(C=>({...C,parentPath:x.currentPath}))}catch(x){O(""),F(null),V([]),T(x instanceof Error?x.message:r("shell.importBrowserBrowseFailed"))}finally{N(!1)}},[]);function Y(){o||(f(!1),T(null),h(aa),t())}function Q(){f(!0),y(p.parentPath||void 0)}function B(){o||(f(!1),T(null))}async function me(W){W.preventDefault(),await y(L)}function ue(){h(W=>({...W,parentPath:H})),f(!1),T(null)}async function ne(W){W.preventDefault();const x=p.repositoryUrl.trim(),C=p.parentPath.trim();if(!x){a({title:r("shell.cloneRepoRequired"),tone:"error"});return}if(!C){a({title:r("shell.clonePathRequired"),tone:"error"});return}c(!0);try{const $=await dd({repositoryUrl:x,parentPath:C,directoryName:p.directoryName.trim()||void 0,name:p.name.trim()||void 0,auth:p.authMode==="none"?{mode:"none"}:p.authMode==="basic"?{mode:"basic",username:p.username.trim(),password:p.password}:{mode:"token",username:p.username.trim()||void 0,token:p.token}});await(s==null?void 0:s($)),h(aa),f(!1),a({title:r("shell.cloneSuccess"),description:$.path,tone:"success"}),t()}catch($){a({title:$ instanceof Error?$.message:r("shell.cloneFailed"),tone:"error"})}finally{c(!1)}}return n.jsxs(n.Fragment,{children:[n.jsx(nt,{open:e,title:r("shell.cloneWorkspaceTitle"),description:r("shell.cloneWorkspaceHint"),onClose:Y,children:n.jsxs("form",{className:"workbench-clone-form",onSubmit:W=>void ne(W),children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneRepositoryLabel")}),n.jsx("input",{type:"text",value:p.repositoryUrl,placeholder:r("shell.cloneRepositoryPlaceholder"),onChange:W=>h(x=>({...x,repositoryUrl:W.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneParentPathLabel")}),n.jsxs("div",{className:"workbench-modal-inline-field",children:[n.jsx("input",{type:"text",value:p.parentPath,placeholder:r("shell.cloneParentPathPlaceholder"),onChange:W=>h(x=>({...x,parentPath:W.target.value}))}),n.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:Q,children:r("shell.clonePickDirectory")})]})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneDirectoryNameLabel")}),n.jsx("input",{type:"text",value:p.directoryName,placeholder:r("shell.cloneDirectoryNamePlaceholder"),onChange:W=>h(x=>({...x,directoryName:W.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importNameLabel")}),n.jsx("input",{type:"text",value:p.name,placeholder:r("shell.importNamePlaceholder"),onChange:W=>h(x=>({...x,name:W.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneAuthModeLabel")}),n.jsxs("select",{value:p.authMode,onChange:W=>h(x=>({...x,authMode:W.target.value})),children:[n.jsx("option",{value:"none",children:r("shell.cloneAuthModeNone")}),n.jsx("option",{value:"basic",children:r("shell.cloneAuthModeBasic")}),n.jsx("option",{value:"token",children:r("shell.cloneAuthModeToken")})]})]}),p.authMode==="basic"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:p.username,placeholder:r("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:W=>h(x=>({...x,username:W.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.clonePasswordLabel")}),n.jsx("input",{type:"password",value:p.password,placeholder:r("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:W=>h(x=>({...x,password:W.target.value}))})]})]}):null,p.authMode==="token"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:p.username,placeholder:r("shell.cloneTokenUsernamePlaceholder"),onChange:W=>h(x=>({...x,username:W.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneTokenLabel")}),n.jsx("input",{type:"password",value:p.token,placeholder:r("shell.cloneTokenPlaceholder"),onChange:W=>h(x=>({...x,token:W.target.value}))})]})]}):null,n.jsx("p",{className:"workbench-import-hint",children:r("shell.cloneHint")}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:Y,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:o,children:o?r("shell.cloneSubmitting"):r("shell.cloneSubmit")})]})]})}),n.jsxs(nt,{open:e&&g,title:r("shell.cloneBrowserTitle"),description:r("shell.cloneBrowserDescription"),onClose:B,children:[n.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:me,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importBrowserCurrentPath")}),n.jsx("input",{type:"text",value:L,placeholder:r("shell.importPathPlaceholder"),onChange:W=>v(W.target.value)})]}),n.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:D||!K,onClick:()=>{K&&y(K)},children:r("shell.importBrowserOpenParent")}),n.jsx("button",{type:"submit",className:"secondary-button",disabled:D,children:r("shell.importBrowserOpenPath")})]})]}),n.jsxs("section",{className:"workbench-directory-browser-panel",children:[n.jsxs("div",{className:"workbench-directory-browser-section",children:[n.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),n.jsx("div",{className:"workbench-directory-browser-root-list",children:te.map(W=>n.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:D,onClick:()=>{y(W.path)},children:W.name},W.path))})]}),n.jsx("div",{className:"workbench-directory-browser-current-path",children:H}),j?n.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:j}):null,w?n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):X.length>0?n.jsx("div",{className:"workbench-directory-browser-list",children:X.map(W=>n.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:D,onClick:()=>{y(W.path)},children:[n.jsx("span",{className:"workbench-directory-browser-item-name",children:W.name}),n.jsx("span",{className:"workbench-directory-browser-item-path",children:W.path})]},W.path))}):n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:B,children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:D||!H,onClick:ue,children:r("shell.cloneBrowserSubmit")})]})]})]})}const Tp="butler:inbox-updated";function Ja(){typeof window>"u"||window.dispatchEvent(new Event(Tp))}const Ti={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function fc({active:e,preferredWorkspaceId:t,preferredSessionId:s,creationRequestId:a=0,initialDraft:o=null,compactComposer:c=!1,composerOpen:p=!0,onComposerOpenChange:h}){const{showToast:g}=fs(),[f,w]=i.useState(!1),[N,j]=i.useState(!1),[T,H]=i.useState([]),[O,L]=i.useState([]),[v,K]=i.useState(null),[F,te]=i.useState(null),[M,X]=i.useState(Ti),[V,D]=i.useState(!1),y=i.useMemo(()=>Ei(T,t,F),[F,t,T]),Y=i.useMemo(()=>V?O:O.filter(x=>x.status!=="closed"),[O,V]);i.useEffect(()=>{e&&Q()},[e,s]),i.useEffect(()=>{!e||v||X(x=>{const C=Ai({projects:y,currentProjectId:x.projectId,preferredProjectId:F,preferredWorkspaceId:t});return C===x.projectId?x:{...x,projectId:C}})},[e,v,F,t,y]),i.useEffect(()=>{!e||a<=0||(B(void 0,t,o,F),h==null||h(!0))},[e,a,o,h,F,t]);async function Q(){w(!0);try{const[x,C,$]=await Promise.all([lp(),pc(),s?mp(s).catch(()=>null):Promise.resolve(null)]),se=($==null?void 0:$.target.project.id)??null;te(se),H(x.items),L(C.items),v||B(x.items,t,a>0?o:null,se)}catch(x){g({title:r("shell.butlerInboxLoadFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{w(!1)}}function B(x=T,C=t,$=o,se=F){var xe,oe;const Me=Ei(x,C,se);K(null),X({...Ti,projectId:Ai({projects:Me,preferredProjectId:se,preferredWorkspaceId:C}),title:((xe=$==null?void 0:$.title)==null?void 0:xe.trim())??"",content:((oe=$==null?void 0:$.content)==null?void 0:oe.trim())??""})}function me(x){K(x.id),X({projectId:x.projectId,itemType:x.itemType,title:x.title,content:x.content,status:x.status}),c&&(h==null||h(!0))}async function ue(x){x.preventDefault(),j(!0);try{v?(await Ci(v,{projectId:M.projectId,itemType:M.itemType,title:M.title,content:M.content,status:M.status,priority:"medium"}),g({title:r("shell.butlerInboxUpdated"),tone:"success"})):(await cp({projectId:M.projectId,itemType:M.itemType,title:M.title,content:M.content,status:M.status,priority:"medium"}),g({title:r("shell.butlerInboxCreated"),tone:"success"})),Ja(),await Q(),B(),c&&(h==null||h(!1))}catch(C){g({title:r("shell.butlerInboxSaveFailed"),description:C instanceof Error?C.message:void 0,tone:"error"})}finally{j(!1)}}async function ne(x){j(!0);try{await up(x),g({title:r("shell.butlerInboxDeleted"),tone:"success"}),Ja(),await Q(),v===x&&B()}catch(C){g({title:r("shell.butlerInboxDeleteFailed"),description:C instanceof Error?C.message:void 0,tone:"error"})}finally{j(!1)}}async function W(x,C){if(x.status!==C){j(!0);try{await Ci(x.id,{status:C}),g({title:r("shell.butlerInboxUpdated"),tone:"success"}),Ja(),await Q(),v===x.id&&X($=>({...$,status:C}))}catch($){g({title:r("shell.butlerInboxSaveFailed"),description:$ instanceof Error?$.message:void 0,tone:"error"})}finally{j(!1)}}}return n.jsxs("div",{className:"workspace-inbox-modal",children:[c?null:n.jsx("section",{className:"workspace-inbox-panel",children:n.jsx(Ri,{selectableProjects:y,formState:M,saving:N,editingItemId:v,useMobilePicker:!1,onProjectChange:x=>{X(C=>({...C,projectId:x}))},onItemTypeChange:x=>{X(C=>({...C,itemType:x}))},onStatusChange:x=>{X(C=>({...C,status:x}))},onTitleChange:x=>{X(C=>({...C,title:x}))},onContentChange:x=>{X(C=>({...C,content:x}))},onCancel:()=>B(),onSubmit:ue})}),n.jsxs("section",{className:"workspace-inbox-panel",children:[n.jsxs("header",{className:"workspace-inbox-panel-header",children:[n.jsxs("div",{children:[n.jsx("h3",{children:r("shell.butlerInboxListTitle")}),n.jsx("p",{children:r("shell.butlerInboxListDescription")})]}),n.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[n.jsx("input",{type:"checkbox",checked:V,onChange:x=>D(x.target.checked)}),n.jsx("span",{children:r("shell.butlerInboxShowClosedAction")})]})]}),f?n.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxLoading")}):null,!f&&Y.length===0?n.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxEmpty")}):null,!f&&Y.length>0?n.jsx("div",{className:"workspace-inbox-list",children:Y.map(x=>n.jsxs("article",{className:"workspace-inbox-item",children:[n.jsxs("div",{className:"workspace-inbox-item-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:x.title}),n.jsx("p",{children:x.projectName})]}),n.jsxs("div",{className:"workspace-inbox-item-badges",children:[n.jsx("span",{className:"workspace-inbox-badge",children:Wi(x.status)}),n.jsx("span",{className:"workspace-inbox-badge",children:Wp(x.itemType)})]})]}),n.jsx("p",{className:"workspace-inbox-item-content",children:x.content}),n.jsxs("div",{className:"workspace-inbox-item-footer",children:[n.jsx("span",{children:Lp(x.updatedAt)}),n.jsxs("div",{className:"workspace-inbox-item-actions",children:[n.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":r("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(C=>{const $=x.status===C;return n.jsx("button",{type:"button",className:"secondary-button","data-active":$,disabled:N,onClick:()=>{W(x,C)},children:Wi(C)},`${x.id}:${C}`)})}),n.jsx("button",{type:"button",className:"secondary-button",disabled:N,onClick:()=>me(x),children:r("shell.butlerInboxEditAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:N,onClick:()=>{ne(x.id)},children:r("shell.butlerInboxDeleteAction")})]})]})]},x.id))}):null]}),c?n.jsx(nt,{open:e&&p,title:v?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle"),description:r("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{h==null||h(!1),B()},children:n.jsx("div",{className:"workspace-inbox-composer-modal-body",children:n.jsx(Ri,{selectableProjects:y,formState:M,saving:N,editingItemId:v,useMobilePicker:!0,onProjectChange:x=>{X(C=>({...C,projectId:x}))},onItemTypeChange:x=>{X(C=>({...C,itemType:x}))},onStatusChange:x=>{X(C=>({...C,status:x}))},onTitleChange:x=>{X(C=>({...C,title:x}))},onContentChange:x=>{X(C=>({...C,content:x}))},onCancel:()=>{h==null||h(!1),B()},onSubmit:ue})})}):null]})}function Ri(e){const t=e.selectableProjects.map(o=>({value:o.id,label:o.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")}],a=[{value:"pending",label:r("shell.butlerInboxStatusPending")},{value:"in_progress",label:r("shell.butlerInboxStatusInProgress")},{value:"closed",label:r("shell.butlerInboxStatusClosed")}];return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"workspace-inbox-panel-header",children:[n.jsx("h3",{children:e.editingItemId?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle")}),n.jsx("p",{children:r("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?n.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxProjectsEmpty")}):n.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[n.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?n.jsxs(n.Fragment,{children:[n.jsx(Za,{label:r("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),n.jsx(Za,{label:r("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:s,disabled:e.saving,onChange:e.onItemTypeChange}),n.jsx(Za,{label:r("shell.butlerInboxStatusLabel"),value:e.formState.status,options:a,disabled:e.saving,onChange:e.onStatusChange})]}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxProjectLabel")}),n.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:o=>e.onProjectChange(o.target.value),children:e.selectableProjects.map(o=>n.jsx("option",{value:o.id,children:o.name},o.id))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxTypeLabel")}),n.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:o=>e.onItemTypeChange(o.target.value),children:[n.jsx("option",{value:"task",children:r("shell.butlerInboxTypeTask")}),n.jsx("option",{value:"bug",children:r("shell.butlerInboxTypeBug")}),n.jsx("option",{value:"feature",children:r("shell.butlerInboxTypeFeature")}),n.jsx("option",{value:"change",children:r("shell.butlerInboxTypeChange")})]})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxStatusLabel")}),n.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:o=>e.onStatusChange(o.target.value),children:[n.jsx("option",{value:"pending",children:r("shell.butlerInboxStatusPending")}),n.jsx("option",{value:"in_progress",children:r("shell.butlerInboxStatusInProgress")}),n.jsx("option",{value:"closed",children:r("shell.butlerInboxStatusClosed")})]})]})]})}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxTitleLabel")}),n.jsx("input",{value:e.formState.title,placeholder:r("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:o=>e.onTitleChange(o.target.value)})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxContentLabel")}),n.jsx("textarea",{rows:4,value:e.formState.content,placeholder:r("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:o=>e.onContentChange(o.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?r("shell.butlerInboxCancelEditAction"):r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?r("shell.butlerInboxUpdateAction"):r("shell.butlerInboxCreateAction")})]})]})]})}function Za({label:e,value:t,options:s,disabled:a,onChange:o}){const[c,p]=i.useState(!1),h=s.find(g=>g.value===t)??s[0]??null;return i.useEffect(()=>{if(!c)return;function g(f){f.key==="Escape"&&p(!1)}return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[c]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[n.jsx("span",{children:e}),n.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":c,disabled:a||s.length===0,onClick:()=>p(!0),children:[n.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(h==null?void 0:h.label)??""}),n.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:n.jsx(Pp,{expanded:c})})]})]}),n.jsx(Rp,{open:c,title:e,options:s,selectedValue:t,onClose:()=>p(!1),onSelect:g=>{o(g),p(!1)}})]})}function Rp({open:e,title:t,options:s,selectedValue:a,onClose:o,onSelect:c}){return e?n.jsx(ud,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:o,children:n.jsx(hd,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:s.map(p=>{const h=p.value===a;return n.jsx(pd,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":h,selected:h,trailing:n.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:h?n.jsx(Ap,{}):null}),onClick:()=>c(p.value),children:n.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[n.jsx("strong",{children:p.label}),p.description?n.jsx("span",{children:p.description}):null]})},p.value)})})}):null}function Ob({open:e,preferredWorkspaceId:t,preferredSessionId:s,creationRequestId:a=0,initialDraft:o=null,onClose:c,compactComposer:p=!1}){const[h,g]=i.useState(0),[f,w]=i.useState(!p);return i.useEffect(()=>{e||w(!p)},[p,e]),n.jsx(nt,{open:e,title:r("shell.butlerInboxModalTitle"),description:r("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!p,headerActions:p?n.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":r("shell.butlerInboxCreateAction"),title:r("shell.butlerInboxCreateAction"),onClick:()=>{g(N=>N+1),w(!0)},children:n.jsx(Ep,{})}):void 0,onClose:c,children:n.jsx(fc,{active:e,preferredWorkspaceId:t,preferredSessionId:s,creationRequestId:Math.max(a,h),initialDraft:o,compactComposer:p,composerOpen:f,onComposerOpenChange:w})})}function Ei(e,t,s){return[...e].filter(a=>a.lifecycleStatus!=="archived").sort((a,o)=>{const c=Pi(a,t,s),p=Pi(o,t,s);return c!==p?p-c:a.name.localeCompare(o.name,"zh-Hans-CN")})}function Pi(e,t,s){return s&&e.id===s?2:t&&e.workspaceId===t?1:0}function Ai({projects:e,currentProjectId:t,preferredProjectId:s,preferredWorkspaceId:a}){var c;if(t&&e.some(p=>p.id===t))return t;if(s&&e.some(p=>p.id===s))return s;const o=a?e.find(p=>p.workspaceId===a):null;return(o==null?void 0:o.id)||((c=e[0])==null?void 0:c.id)||""}function Ep(){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("path",{d:"M12 5v14"}),n.jsx("path",{d:"M5 12h14"})]})}function Pp({expanded:e}){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:n.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Ap(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.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 Wp(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 Wi(e){switch(e){case"in_progress":return r("shell.butlerInboxStatusInProgress");case"closed":return r("shell.butlerInboxStatusClosed");case"pending":default:return r("shell.butlerInboxStatusPending")}}function Lp(e){return new Date(e).toLocaleString()}function Bp({open:e,onClose:t,onImported:s}){const{showToast:a}=fs(),[o,c]=i.useState(!1),[p,h]=i.useState(!1),[g,f]=i.useState(!1),[w,N]=i.useState(null),[j,T]=i.useState(""),[H,O]=i.useState(""),[L,v]=i.useState(null),[K,F]=i.useState([]),[te,M]=i.useState([]),[X,V]=i.useState(!1),[D,y]=i.useState(""),Y=o||p||g,Q=i.useCallback(async C=>{c(!0),N(null);try{const $=await jl(C);T($.currentPath),O($.currentPath),v($.parentPath),F($.roots),M($.items)}catch($){T(""),v(null),M([]),N($ instanceof Error?$.message:r("shell.importBrowserBrowseFailed"))}finally{c(!1)}},[]);i.useEffect(()=>{if(!e){V(!1),y(""),N(null);return}Q(j||void 0)},[Q,e]);function B(){Y||(V(!1),y(""),t())}async function me(C){C.preventDefault(),await Q(H)}function ue(){!j||Y||(y(""),V(!0))}function ne(){p||(V(!1),y(""))}async function W(C){C==null||C.preventDefault();const $=D.trim();if(!(!j||!$||Y)){h(!0),N(null);try{const se=await fd({parentPath:j,directoryName:$});a({title:r("shell.importBrowserCreateDirectorySuccess"),description:se.path,tone:"success"}),V(!1),y(""),await Q(se.path)}catch(se){const Me=se instanceof Error?se.message:r("shell.importBrowserCreateDirectoryFailed");N(Me),a({title:Me,tone:"error"})}finally{h(!1)}}}async function x(){const C=j.trim();if(!(!C||Y)){f(!0),N(null);try{const $=await md({path:C});a({title:r("shell.importSuccess"),description:$.path,tone:"success"}),t(),Promise.resolve().then(()=>s==null?void 0:s($)).catch(se=>{a({title:se instanceof Error?se.message:r("shell.navigationLoadFailed"),tone:"error"})})}catch($){a({title:$ instanceof Error?$.message:r("shell.importFailed"),tone:"error"})}finally{f(!1)}}}return n.jsxs(n.Fragment,{children:[n.jsxs(nt,{open:e,title:r("shell.importBrowserTitle"),description:r("shell.importBrowserDescription"),onClose:B,children:[n.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:me,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importBrowserCurrentPath")}),n.jsx("input",{type:"text",value:H,placeholder:r("shell.importPathPlaceholder"),onChange:C=>O(C.target.value)})]}),n.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:Y||!L,onClick:()=>{L&&Q(L)},children:r("shell.importBrowserOpenParent")}),n.jsx("button",{type:"submit",className:"secondary-button",disabled:Y,children:r("shell.importBrowserOpenPath")}),n.jsx("button",{type:"button",className:"secondary-button",disabled:Y||!j,onClick:ue,children:r("shell.importBrowserCreateDirectory")})]})]}),n.jsxs("section",{className:"workbench-directory-browser-panel",children:[n.jsxs("div",{className:"workbench-directory-browser-section",children:[n.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),n.jsx("div",{className:"workbench-directory-browser-root-list",children:K.map(C=>n.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:Y,onClick:()=>{Q(C.path)},children:C.name},C.path))})]}),n.jsx("div",{className:"workbench-directory-browser-current-path",children:j}),w?n.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:w}):null,o?n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):te.length>0?n.jsx("div",{className:"workbench-directory-browser-list",children:te.map(C=>n.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:Y,onClick:()=>{Q(C.path)},children:[n.jsx("span",{className:"workbench-directory-browser-item-name",children:C.name}),n.jsx("span",{className:"workbench-directory-browser-item-path",children:C.path})]},C.path))}):n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:B,children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:Y||!j,onClick:()=>{x()},children:g?r("shell.importSubmitting"):r("shell.importBrowserSubmit")})]})]}),n.jsx(nt,{open:e&&X,title:r("shell.importBrowserCreateDirectoryTitle"),description:r("shell.importBrowserCreateDirectoryDescription"),onClose:ne,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:C=>void W(C),children:[n.jsx("div",{className:"workbench-directory-browser-current-path",children:j}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importBrowserCreateDirectoryLabel")}),n.jsx("input",{type:"text",value:D,placeholder:r("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:C=>y(C.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:ne,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:p||!D.trim(),children:p?r("shell.importBrowserCreatingDirectory"):r("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function Dp({onOpenSoftwareUpdate:e}){var a;const t=go(o=>o.platform),s=od(o=>o.latestState);return t!=="desktop"||!(s!=null&&s.hasUpdate)?null:n.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((a=s.manifest)==null?void 0:a.version)??r("settings.releaseUpdateReady"),onClick:e,children:n.jsx("span",{className:"workbench-nav-update-badge-label",children:r("settings.releaseUpdateBadge")})})}function _p(){const e=ad.getState().profile.defaultPermissionMode;return e==="default"?null:e}const hr="provider-default",ga="__global_default__";function Fp(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function oa(e,t){const s=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&s?{providerConfigMode:"cc-switch-preset",providerPresetId:s}:{providerConfigMode:"global-default",providerPresetId:null}}function Op(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:ga,label:r("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(s=>({value:s.id,label:s.name,summary:s.model??s.summary??null}))]}function $p(e){return e.usesProviderDefault===!0||e.id===hr}function Hp(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function Up({triggerId:e,ariaLabel:t,triggerLabel:s,presetOptions:a,selectedPresetValue:o,selectedPresetSummary:c,onSelectPreset:p,modelOptions:h,selectedModelValue:g,onSelectModel:f,loadingPresets:w=!1,loadingModels:N=!1,modelColumnDisabled:j=!1,showPresetColumn:T=!0,modelEmptyText:H}){const[O,L]=i.useState(!1),v=i.useRef(null),K=i.useRef(null),F=i.useRef(null),[te,M]=i.useState(null),X=i.useId(),V=i.useCallback(()=>{const D=K.current;if(!D||typeof window>"u")return;const y=D.getBoundingClientRect(),Y=D.closest(".workbench-modal-card"),Q=Y instanceof HTMLElement?Y.getBoundingClientRect():null,B=window.innerWidth,me=window.innerHeight,ue=12,ne=8,W=320,x=Math.min(560,Math.max(320,B-ue*2)),C=Math.min(x,420),$=Math.max(Math.min(x,Math.max(C,Math.round(y.width*1.9))),Math.min(320,x)),se=Math.min(Math.max(ue,y.left),Math.max(ue,B-$-ue)),Me=Q?Math.max(ue,Q.top+8):ue,xe=Q?Math.min(me-ue,Q.bottom-8):me-ue,oe=Math.max(0,y.top-Me-ne),ae=Math.max(0,xe-y.bottom-ne),he=Q?!(ae>=W||ae>oe+40):oe>=240||oe>=ae;M({position:"fixed",left:se,width:$,maxWidth:x,zIndex:1905,top:he?void 0:y.bottom+ne,bottom:he?me-y.top+ne:void 0})},[]);return i.useEffect(()=>{if(!O)return;function D(Y){var B,me;const Q=Y.target;!((B=v.current)!=null&&B.contains(Q))&&!((me=F.current)!=null&&me.contains(Q))&&L(!1)}function y(Y){Y.key==="Escape"&&L(!1)}return window.addEventListener("pointerdown",D),window.addEventListener("keydown",y),window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),V(),()=>{window.removeEventListener("pointerdown",D),window.removeEventListener("keydown",y),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[O,V]),n.jsxs("div",{ref:v,className:"composer-mac-select composer-deployment-select","data-open":O?"true":"false",children:[n.jsxs("button",{id:e,ref:K,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":O,"aria-controls":X,onClick:()=>L(D=>!D),children:[n.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:s}),n.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),O&&te&&typeof document<"u"?Os.createPortal(n.jsx("div",{ref:F,className:"composer-mac-select-popover composer-deployment-select-popover",style:te,role:"presentation",children:n.jsxs("div",{id:X,className:`composer-deployment-select-panel${T?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[T?n.jsxs("div",{className:"composer-deployment-select-column",children:[n.jsx("div",{className:"composer-deployment-select-column-header",children:r("conversation.deploymentConfigColumn")}),n.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":r("conversation.deploymentConfigColumn"),children:[a.map(D=>{const y=D.value===o;return n.jsxs("button",{type:"button",role:"option","aria-selected":y,className:`composer-deployment-select-option ${y?"is-selected":""}`,onClick:()=>p(D.value),children:[n.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:y?"✓":""}),n.jsxs("span",{className:"composer-deployment-select-option-copy",children:[n.jsx("span",{className:"composer-deployment-select-option-label",children:D.label}),D.summary?n.jsx("span",{className:"composer-deployment-select-option-summary",children:D.summary}):null]})]},D.value)}),w?n.jsx("div",{className:"composer-deployment-select-state",children:r("conversation.deploymentLoading")}):null]})]}):null,n.jsxs("div",{className:"composer-deployment-select-column","data-disabled":j?"true":"false",children:[n.jsx("div",{className:"composer-deployment-select-column-header",children:r("conversation.deploymentModelColumn")}),T&&c?n.jsx("div",{className:"composer-deployment-select-column-hint",children:c}):null,n.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":r("conversation.deploymentModelColumn"),children:N&&j?n.jsx("div",{className:"composer-deployment-select-state",children:r("conversation.deploymentModelLoading")}):h.length>0?h.map(D=>{const y=D.value===g;return n.jsxs("button",{type:"button",role:"option","aria-selected":y,className:`composer-deployment-select-option ${y?"is-selected":""}`,disabled:j,onClick:()=>{f(D.value),L(!1)},children:[n.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:y?"✓":""}),n.jsx("span",{className:"composer-deployment-select-option-copy",children:n.jsx("span",{className:"composer-deployment-select-option-label",children:D.label})})]},D.value)}):n.jsx("div",{className:"composer-deployment-select-state",children:H})})]})]})}),document.body):null]})}const ia=["codex","claude-code","gemini"];function bc(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function Li(e,t){return Array.from({length:t},()=>bc(e))}function Qa(e,t){var s;return(s=e==null?void 0:e.modelOptions)!=null&&s.length?e.modelOptions:va(t).modelOptions??[]}function Bi(e,t,s){return t!=="cc-switch-preset"||!s?null:`${e}::${s}`}function Di(e,t){return Math.max(0,e-t.length)}function Gp({open:e,source:t,onClose:s,onCreated:a}){const o=i.useId(),c=(t==null?void 0:t.defaultProvider)??"codex",p=(t==null?void 0:t.kind)==="group",h=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,g=i.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:h},(_,R)=>R+1):[2,3,4],[h,t==null?void 0:t.kind]),f=(t==null?void 0:t.kind)==="group"?1:2,w=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",[N,j]=i.useState(w),[T,H]=i.useState(f),[O,L]=i.useState(()=>Li(c,f)),[v,K]=i.useState({}),[F,te]=i.useState({}),[M,X]=i.useState({}),[V,D]=i.useState({}),[y,Y]=i.useState({}),[Q,B]=i.useState(!1),[me,ue]=i.useState(!1),[ne,W]=i.useState(null),[x,C]=i.useState(null),[$,se]=i.useState({}),Me=i.useRef(!1),xe=i.useRef({});i.useEffect(()=>{if(!e)return;const _=(t==null?void 0:t.defaultProvider)??"codex",R=(t==null?void 0:t.kind)==="group"?1:2;j((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),H(R),L(Li(_,R)),K({}),te({}),X({}),D({}),Y({}),B(!1),ue(!1),W(null),C(null),se({}),Me.current=!1,Object.keys(xe.current).forEach(ie=>{delete xe.current[ie]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),i.useEffect(()=>{L(_=>{var ce;if(_.length===T)return _;if(_.length>T)return _.slice(0,T);const R=_.slice(),ie=((ce=_[0])==null?void 0:ce.provider)??c;for(;R.length<T;)R.push(bc(ie));return R})},[c,T]),i.useEffect(()=>{g.length!==0&&H(_=>g.includes(_)?_:g[0]??_)},[g]),i.useEffect(()=>{if(!e||!t)return;let _=!1;return B(!0),bd(Go,t.workspaceId).then(R=>{_||K(R)}).finally(()=>{_||B(!1)}),()=>{_=!0}},[e,t==null?void 0:t.workspaceId]),i.useEffect(()=>{e&&(Me.current||(Me.current=!0,X(_=>({..._,...Object.fromEntries(ia.map(R=>[R,!0]))})),gd().then(_=>{const R=Object.fromEntries(_.items.map(ie=>[ie.app,ie]));te(Object.fromEntries(ia.map(ie=>[ie,R[ie]??null])))}).catch(()=>{te(Object.fromEntries(ia.map(_=>[_,null])))}).finally(()=>{X(_=>({..._,...Object.fromEntries(ia.map(R=>[R,!1]))}))})))},[e]),i.useEffect(()=>{if(!e||!t)return;const _=Array.from(new Set(O.map(R=>{const ie=oa(R.providerConfigMode,R.providerPresetId);return Bi(R.provider,ie.providerConfigMode,ie.providerPresetId)}).filter(R=>R!==null))).filter(R=>V[R]===void 0&&!xe.current[R]);if(_.length!==0)for(const R of _){const[ie,ce]=R.split("::");xe.current[R]=!0,Y(pe=>({...pe,[R]:!0})),Cl(ie,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ce}).then(pe=>{D(ke=>({...ke,[R]:pe}))}).catch(()=>{D(pe=>({...pe,[R]:null}))}).finally(()=>{delete xe.current[R],Y(pe=>({...pe,[R]:!1}))})}},[V,O,e,t]);const oe=i.useMemo(()=>Go.filter(_=>{const R=v[_];return R?R.canStartSession!==!1:!1}),[v]);i.useEffect(()=>{if(!oe.length)return;const _=oe.includes(c)?c:oe[0];L(R=>{let ie=!1;const ce=R.map(pe=>oe.includes(pe.provider)?pe:(ie=!0,{...pe,provider:_,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ie?ce:R})},[oe,c]);const ae=i.useMemo(()=>O.map((_,R)=>{var qe;const ie=oa(_.providerConfigMode,_.providerPresetId),ce=Fp(_.provider),pe=ce?F[ce]??null:null,ke=Op(pe),Qe=ie.providerConfigMode==="cc-switch-preset"?ie.providerPresetId??ga:ga,Ae=ke.find(Fe=>Fe.value===Qe)??ke[0]??null,et=Bi(_.provider,ie.providerConfigMode,ie.providerPresetId),it=v[_.provider]??null,st=et?V[et]??null:null,Wt=(ie.providerConfigMode==="cc-switch-preset"?st?Qa(st,_.provider):[{id:hr,name:r("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:Qa(it,_.provider)).map(Fe=>({value:Fe.id,label:$p(Fe)?r("conversation.modelUseCliDefault"):Fe.name})),rt=_.model.trim()||hr,Rt=((qe=Wt.find(Fe=>Fe.value===rt))==null?void 0:qe.label)??r("conversation.modelUseCliDefault"),Je=Hp(pe),ft=ce!==null,Se=et?y[et]===!0:!1,lt=!!(et&&Se&&st===null);return{index:R,draft:_,supportsDeploymentPicker:ft,showPresetColumn:Je,deploymentPresetOptions:ke,selectedPresetValue:Qe,selectedPresetOption:Ae,triggerLabel:Je?`${(Ae==null?void 0:Ae.label)??r("conversation.deploymentDefaultPreset")} · ${Rt}`:Rt,selectedModelValue:rt,modelOptions:Wt,loadingPresets:ce?M[ce]===!0:!1,loadingModels:Se,modelColumnDisabled:lt}}),[V,F,M,y,O,v]);if(i.useEffect(()=>{e&&L(_=>{let R=!1;const ie=_.map((ce,pe)=>{const ke=ae[pe];if(!ke)return ce;let Qe=ce;const Ae=oa(ce.providerConfigMode,ce.providerPresetId);Ae.providerConfigMode==="cc-switch-preset"&&Ae.providerPresetId&&!ke.loadingPresets&&!ke.deploymentPresetOptions.some(st=>st.value===Ae.providerPresetId)&&(Qe={...Qe,providerConfigMode:"global-default",providerPresetId:null,model:""},R=!0);const et=new Set(ke.modelOptions.map(st=>st.value)),it=Qe.model.trim()||hr;return et.has(it)||(Qe={...Qe,model:""},R=!0),Qe});return R?ie:_})},[ae,e]),!e||!t)return null;const he=t,We=x?Di(O.length,x.memberFailures):0,J=new Set(x?O.map((_,R)=>R).filter(_=>!(_ in $)):[]),ge=he.kind==="group"?r("shell.parallelAppendModalTitle"):r("shell.parallelCreateModalTitle"),Te=he.kind==="session"?`${he.workspaceName} · ${he.sessionTitle}`:he.workspaceName,Ye=he.kind==="group"?r("shell.parallelAppendSharedPromptLabel"):r("shell.parallelCreateSharedPromptLabel"),S=he.kind==="group"?r("shell.parallelAppendCountLabel"):r("shell.parallelCreateCountLabel"),I=he.kind==="group"?r("shell.parallelAppendSubmit"):r("shell.parallelCreateSubmit"),Z=he.kind==="group"?r("shell.parallelAppendSubmitting"):r("shell.parallelCreateSubmitting"),U=ne??(he.kind==="group"&&h===0?r("shell.parallelAppendNoRemainingSlots"):null)??(!Q&&oe.length===0?r("shell.parallelCreateNoAvailableProviders"):null),Ce={"--parallel-member-columns":String(Math.max(1,Math.min(T,4)))};function je(_){W(null),C(null),se(R=>{if(!(_ in R))return R;const ie={...R};return delete ie[_],ie})}function Re(){W(null),C(null),se({})}function At(_,R){je(_);const ie=R?"temporary_worktree":"none";L(ce=>ce.map((pe,ke)=>ke===_?{...pe,workspaceIsolationMode:ie}:pe))}async function mt(){const _=N.trim();if(!p&&!_){W(r("shell.parallelCreatePromptRequired"));return}if(he.kind==="group"&&h===0){W(r("shell.parallelAppendNoRemainingSlots"));return}if(!oe.length){W(r("shell.parallelCreateNoAvailableProviders"));return}ue(!0),W(null),C(null),se({});try{const R=_p(),ie=O.map(pe=>{const ke=oa(pe.providerConfigMode,pe.providerPresetId);return{provider:pe.provider,model:pe.model.trim()||null,providerConfigMode:ke.providerConfigMode,providerPresetId:ke.providerConfigMode==="cc-switch-preset"?ke.providerPresetId:null,memberPrompt:pe.memberPrompt.trim()||null,workspaceIsolationMode:pe.workspaceIsolationMode}}),ce=he.kind==="group"?await wd(he.groupId,{permissionMode:R,members:ie}):he.kind==="session"?await vd(he.sessionId,{sharedPrompt:_,permissionMode:R,members:ie}):await xd(he.workspaceId,{sharedPrompt:_,permissionMode:R,members:ie});if(ce.memberFailures.length>0){const pe=Di(O.length,ce.memberFailures);C(ce),se(Object.fromEntries(ce.memberFailures.map(ke=>[ke.ordinal,ke]))),W(pe>0?r("shell.parallelCreatePartialFailure",{successCount:pe,failureCount:ce.memberFailures.length}):r("shell.parallelCreateAllFailed",{failureCount:ce.memberFailures.length}));return}await a(ce)}catch(R){W(R instanceof Error?R.message:r("shell.parallelGroupLoadFailed"))}finally{ue(!1)}}return n.jsx(Wd,{open:e,title:ge,description:Te,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!me,onClose:s,footer:n.jsxs(kd,{align:"between",className:"parallel-create-modal-footer",children:[n.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:U?n.jsx("span",{className:"parallel-create-modal-error",children:U}):null}),n.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[x&&We>0?n.jsx("button",{type:"button",className:"secondary-button",disabled:me,onClick:()=>{a(x)},children:r("shell.parallelCreateContinuePartial")}):null,n.jsx("button",{type:"button",className:"secondary-button",disabled:me,onClick:s,children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:me||Q||oe.length===0||he.kind==="group"&&h===0,onClick:()=>{mt()},children:me?Z:I})]})]}),children:n.jsxs("div",{className:"parallel-create-layout",children:[n.jsx(zo,{className:"parallel-create-shared-section",tone:"accent",children:n.jsxs("div",{className:"parallel-create-target-row",children:[n.jsx(ir,{className:"parallel-create-target-field",label:Ye,htmlFor:`${o}-shared-prompt`,children:n.jsx("textarea",{id:`${o}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:N,readOnly:p,"aria-readonly":p,"data-readonly":p?"true":void 0,onChange:_=>{p||(Re(),j(_.target.value))}})}),n.jsx(ir,{className:"parallel-create-count-field",label:S,children:n.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":S,children:g.map(_=>n.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":T===_,onClick:()=>{Re(),H(_)},children:_},_))})})]})}),n.jsx(zo,{className:"parallel-create-members-section",heading:r("shell.parallelCreateMembersTitle"),children:n.jsx("div",{className:"parallel-create-member-list",style:Ce,children:ae.map(({draft:_,index:R,supportsDeploymentPicker:ie,showPresetColumn:ce,deploymentPresetOptions:pe,selectedPresetValue:ke,selectedPresetOption:Qe,triggerLabel:Ae,selectedModelValue:et,modelOptions:it,loadingPresets:st,loadingModels:vt,modelColumnDisabled:Wt})=>{var ft;const rt=oe,Rt=rt.includes(_.provider)?_.provider:"",Je=Qa(v[_.provider]??null,_.provider);return n.jsxs("article",{className:"parallel-create-member-card","data-state":$[R]?"error":J.has(R)?"success":void 0,children:[n.jsxs("header",{className:"parallel-create-member-header",children:[n.jsxs("div",{className:"parallel-create-member-title-block",children:[n.jsx("strong",{children:r("shell.parallelCreateMemberTitle",{index:R+1})}),n.jsx("span",{className:"parallel-create-member-provider",children:oo(_.provider,"full")}),n.jsxs("label",{className:"parallel-create-isolation-toggle",children:[n.jsx("input",{type:"checkbox",checked:_.workspaceIsolationMode==="temporary_worktree",onChange:Se=>{At(R,Se.target.checked)}}),n.jsx("span",{className:"parallel-create-isolation-copy",children:r("shell.parallelCreateIsolationLabel")})]})]}),$[R]?n.jsx("span",{className:"parallel-create-member-status error",children:r("shell.parallelCreateMemberFailed")}):J.has(R)?n.jsx("span",{className:"parallel-create-member-status success",children:r("shell.parallelCreateMemberSucceeded")}):null]}),n.jsxs("div",{className:"parallel-create-member-grid",children:[n.jsx(ir,{label:r("shell.createSessionProviderLabel"),htmlFor:`${o}-member-${R}-provider`,children:n.jsx("select",{id:`${o}-member-${R}-provider`,className:"parallel-create-select",value:Rt,disabled:!rt.length,onChange:Se=>{je(R);const lt=Se.target.value;L(qe=>qe.map((Fe,Lt)=>Lt===R?{...Fe,provider:lt,providerConfigMode:"global-default",providerPresetId:null,model:""}:Fe))},children:rt.length>0?rt.map(Se=>n.jsx("option",{value:Se,children:oo(Se,"full")},Se)):n.jsx("option",{value:"",disabled:!0,children:Q?r("shell.parallelCreateProvidersLoading"):r("shell.parallelCreateNoAvailableProviders")})})}),n.jsx(ir,{label:r("shell.parallelCreateModelLabel"),htmlFor:ie?void 0:`${o}-member-${R}-model`,children:ie?n.jsx("div",{className:"parallel-create-deployment-select",children:n.jsx(Up,{triggerId:`${o}-member-${R}-model`,ariaLabel:r("shell.parallelCreateModelLabel"),triggerLabel:Ae,presetOptions:pe,selectedPresetValue:ke,selectedPresetSummary:(Qe==null?void 0:Qe.summary)??null,onSelectPreset:Se=>{je(R),L(lt=>lt.map((qe,Fe)=>Fe!==R?qe:Se===ga?{...qe,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...qe,providerConfigMode:"cc-switch-preset",providerPresetId:Se,model:""}))},modelOptions:it,selectedModelValue:et,onSelectModel:Se=>{je(R),L(lt=>lt.map((qe,Fe)=>Fe===R?{...qe,model:Se===hr?"":Se}:qe))},loadingPresets:st,loadingModels:vt,modelColumnDisabled:Wt,showPresetColumn:ce,modelEmptyText:r("conversation.deploymentModelEmpty")})}):n.jsx("select",{id:`${o}-member-${R}-model`,className:"parallel-create-select",value:_.model,disabled:!rt.length,onChange:Se=>{je(R);const lt=Se.target.value;L(qe=>qe.map((Fe,Lt)=>Lt===R?{...Fe,model:lt}:Fe))},children:Je.length>0?n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"",children:((ft=Je.find(Se=>Se.usesProviderDefault===!0))==null?void 0:ft.name)??r("shell.parallelPaneModelFallback")}),Je.filter(Se=>Se.usesProviderDefault!==!0).map(Se=>n.jsx("option",{value:Se.id,children:Se.name},Se.id))]}):n.jsx("option",{value:"",children:r("shell.parallelCreateNoModelsAvailable")})})})]}),n.jsx(ir,{label:r("shell.parallelCreateMemberPromptLabel"),htmlFor:`${o}-member-${R}-prompt`,children:n.jsx("textarea",{id:`${o}-member-${R}-prompt`,className:"parallel-create-textarea member",rows:2,value:_.memberPrompt,onChange:Se=>{je(R);const lt=Se.target.value;L(qe=>qe.map((Fe,Lt)=>Lt===R?{...Fe,memberPrompt:lt}:Fe))}})}),$[R]?n.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[n.jsx("strong",{children:r("shell.parallelCreateMemberErrorTitle")}),n.jsx("p",{children:$[R].detail})]}):null]},`parallel-member-${R}`)})})})]})})}const zp=5e3;function gc(e){const t=i.useRef(null),s=e??t;return i.useEffect(()=>{const a=s.current;if(!a||typeof globalThis.window>"u")return;let o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},p=()=>{c(),a.removeAttribute("data-scrolling")},h=()=>{a.setAttribute("data-scrolling","true"),c(),o=window.setTimeout(()=>{a.removeAttribute("data-scrolling"),o=null},zp)},g=()=>{h()};return a.addEventListener("scroll",g,{passive:!0}),()=>{a.removeEventListener("scroll",g),p()}},[s]),s}const _i="workbench.left.width",Fi="workbench.right.width",Oi="workbench.left.collapsed",$i="workbench.right.collapsed",la="workbench.last.session.path",eo="workbench.workspace.selected.id",Hi="workbench.notifications.seen_at",Kp=280,qp=320,Ui=240,Gi=280,zi=520,Ki=560,Vp=200,to=20,dr=40,ca=5,Xp=3e4,Yp=12,qi=60*1e3,Jp=4e3,Vi=220,Xi=18,Zp=6,Ps="data-workbench-panel-resizing",da="data-workbench-window-resizing",Qp=180,em="workbench:focus-composer",tm=new Set(["starting","running","reconnecting","stale","unknown"]),nm=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],sm=["--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"],Ge={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 kc(e,t){const s=e.getPropertyValue(t).trim();if(!s)return null;const a=Number.parseFloat(s);return Number.isFinite(a)?a:null}function rm(e){return Math.round(e*100)/100}function am(e,t){const s=t.getBoundingClientRect();if(s.width<=0||s.height<=0)return null;const a=window.getComputedStyle(t);return a.display==="none"||a.visibility==="hidden"?null:s.top-e.top+s.height/2}function Dn(e,t){const s=e.getBoundingClientRect(),o=Array.from(e.querySelectorAll(t)).map(c=>am(s,c)).filter(c=>c!==null);return o.length===0?null:o.reduce((c,p)=>c+p,0)/o.length}function cn(e,t,s){const a=e.style.getPropertyValue(t).trim();if(s===null||!Number.isFinite(s)){a&&e.style.removeProperty(t);return}const o=`${rm(s)}px`;a!==o&&e.style.setProperty(t,o)}function dn(e,t,s,a){return a===null?null:(kc(e,t)??0)+(s-a)}function Yi(e){if(e)for(const t of sm)e.style.removeProperty(t)}function om(e){return tm.has(e.runningState??"idle")||e.activityState==="running"}function im(e,t){const s=[];for(const a of[...t].sort()){const o=e.get(a);!o||o.size===0||s.push(`${a}:${[...o].sort().join(",")}`)}return s.join("|")}function lm(e){var o,c;const t=((o=e.lastErrorCode)==null?void 0:o.trim())??"",s=((c=e.lastErrorDetail)==null?void 0:c.trim())??"",a=[t,s].filter(p=>p.length>0).join(" · ");return a?a.length<=Vi?a:`${a.slice(0,Vi-3)}...`:null}function cm(e,t,s){var c,p,h,g,f,w,N,j,T,H,O,L;const a=new Map(e.projects.map(v=>[v.id,v.workspaceId])),o=[];for(const v of s){const K=v.title.trim()||v.projectName;if(v.assistantState.lifecycleStage==="analyzed"&&!((c=v.assistantState.linkedSessionId)!=null&&c.trim())&&v.assistantState.lastAnalyzedAt){o.push({id:`todo-analysis-completed:${v.id}:${v.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:r("shell.globalNotificationTodoAnalyzedTitle",{title:K}),body:((p=v.assistantState.analysisSummary)==null?void 0:p.trim())||((h=v.assistantState.generatedPrompt)==null?void 0:h.trim())||v.content,routePath:ms(v.workspaceId),workspaceId:v.workspaceId,createdAt:v.assistantState.lastAnalyzedAt});continue}v.assistantState.lifecycleStage==="failed"&&o.push({id:`todo-analysis-failed:${v.id}:${v.updatedAt}`,kind:"todo_analyze_failed",title:r("shell.globalNotificationTodoAnalyzeFailedTitle",{title:K}),body:((g=v.assistantState.lastError)==null?void 0:g.trim())||v.content,routePath:ms(v.workspaceId),workspaceId:v.workspaceId,createdAt:v.updatedAt})}for(const v of t){const K=((f=v.sessionTitle)==null?void 0:f.trim())||v.projectName,F=v.updatedAt||v.lastAutomationAt||v.createdAt;if(v.status==="waiting_user"){o.push({id:`follow-up-waiting:${v.id}`,kind:"follow_up_waiting_user",title:r("shell.globalNotificationFollowUpWaitingTitle",{title:K}),body:((w=v.waitingReason)==null?void 0:w.trim())||((N=v.lastAutomationSummary)==null?void 0:N.trim())||v.objective,routePath:Ut(v.workspaceId,v.sessionId),workspaceId:v.workspaceId,createdAt:F});continue}if(v.status==="completed"){o.push({id:`follow-up-completed:${v.id}`,kind:"follow_up_completed",title:r("shell.globalNotificationFollowUpCompletedTitle",{title:K}),body:((j=v.lastAutomationSummary)==null?void 0:j.trim())||v.objective,routePath:Ut(v.workspaceId,v.sessionId),workspaceId:v.workspaceId,createdAt:F});continue}v.status==="failed"&&o.push({id:`follow-up-failed:${v.id}`,kind:"follow_up_failed",title:r("shell.globalNotificationFollowUpFailedTitle",{title:K}),body:((T=v.lastAutomationSummary)==null?void 0:T.trim())||((H=v.waitingReason)==null?void 0:H.trim())||v.objective,routePath:Ut(v.workspaceId,v.sessionId),workspaceId:v.workspaceId,createdAt:F})}for(const v of e.verifications){if(v.status!=="failed")continue;const K=v.projectId?a.get(v.projectId)??null:null,F=((O=v.targetRef)==null?void 0:O.trim())||v.verificationType;o.push({id:`verification-failed:${v.id}`,kind:"verification_failed",title:r("shell.globalNotificationVerificationFailedTitle",{title:F}),body:((L=v.summary)==null?void 0:L.trim())||r("shell.globalNotificationVerificationFailedFallback"),routePath:K?ms(K):null,workspaceId:K,createdAt:v.finishedAt||v.startedAt||v.createdAt})}return o.sort((v,K)=>{const F=Ji(v.kind)-Ji(K.kind);return F!==0?F:$n(K.createdAt)-$n(v.createdAt)}).slice(0,Yp)}function Ji(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 dm(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 $n(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function um(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function hm(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function pm(e,t){const s=new Set,a=(e==null?void 0:e.currentBranch)??"",o=((e==null?void 0:e.local)??[]).slice().sort((h,g)=>Number(g.current)-Number(h.current)||h.name.localeCompare(g.name)).map(h=>({value:h.name,current:h.current,recommended:h.name===a})).filter(h=>!h.value||s.has(h.value)?!1:(s.add(h.value),!0)),c=((e==null?void 0:e.remote)??[]).map(h=>({value:h.name})).filter(h=>!h.value||s.has(h.value)?!1:(s.add(h.value),!0)),p=t.map(h=>({value:h.name})).filter(h=>!h.value||s.has(h.value)?!1:(s.add(h.value),!0));return{localBranches:o,remoteBranches:c,tags:p}}function mm(e){return e.getBoundingClientRect()}function fm(e,t){return t?$n(e.createdAt)>$n(t):!0}function bm(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Zi(e,t){var p,h;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 g of s){const f=_e(g,e),w=(p=f==null?void 0:f.params.workspaceId)==null?void 0:p.trim();if(w)return w}const a=gr(e),o=(a==null?void 0:a.sessionId)??null;return!o||!Kc(o)?null:((h=new URLSearchParams(t).get("workspaceId"))==null?void 0:h.trim())||null}function gm(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function no(e){return e==="mobile"?jt():"/landing"}function gr(e){var c,p,h;const t=_e("/workspaces/:workspaceId/sessions/:sessionId",e),s=(c=t==null?void 0:t.params.sessionId)==null?void 0:c.trim();if(s)return{sessionId:s,workspaceId:((p=t==null?void 0:t.params.workspaceId)==null?void 0:p.trim())??null};const a=_e("/sessions/:sessionId",e),o=(h=a==null?void 0:a.params.sessionId)==null?void 0:h.trim();return o?{sessionId:o,workspaceId:null}:null}function km(e){return!!(_e("/sessions",e)||_e("/workspaces/:workspaceId/sessions",e))}function Qi(e){return!!gr(e)}function wm(e){return!!(_e("/tools",e)||_e("/tools/files",e)||_e("/tools/git",e)||_e("/tools/processes",e)||_e("/workspaces/:workspaceId/tools",e)||_e("/workspaces/:workspaceId/tools/files",e)||_e("/workspaces/:workspaceId/tools/git",e)||_e("/workspaces/:workspaceId/tools/processes",e))}function ka(e){return!!(_e("/terminals",e)||_e("/workspaces/:workspaceId/terminals",e))}function wa(e){return!!_e("/workspaces/:workspaceId/butler",e)}function vm(e,t){return _e("/workspaces/:workspaceId/debug",e)?Hl(t):_e("/workspaces/:workspaceId",e)?hn(t):_e("/workspaces/:workspaceId/tools/files",e)||_e("/tools/files",e)?Gl(t):_e("/workspaces/:workspaceId/tools/git",e)||_e("/tools/git",e)?zl(t):_e("/workspaces/:workspaceId/tools/processes",e)||_e("/tools/processes",e)?Kl(t):_e("/workspaces/:workspaceId/tools",e)||_e("/tools",e)?Ul(t):ka(e)?ps(t):wa(e)?ms(t):Fs(t)}function xm(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const ym=i.lazy(async()=>({default:(await ko(()=>import("./FileContextPanel-DwFzLsOp.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),Sm=i.lazy(async()=>({default:(await ko(()=>import("./GitSidebar-CH6WqTrM.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),jm=i.lazy(async()=>({default:(await ko(()=>import("./TerminalManagerPanel-BbORd-ee.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function Cm(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Zt(e){return Us(e)}function wc(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function pr(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(Cm):[]}async function vc(e,t){const s=await Cl(t,e);if(s.canStartSession===!1)throw new Error(s.limitations[0]??r("conversation.capabilityDenied"))}const xc=i.createContext(null);function mo(e){return Oh(e)}function un(e){return e.isArchived===!0}function Ra(e){return Bl(e)}function _o(e,t){return _l(e,{getId:s=>s.sessionId,getParentId:Ra,compare:(s,a)=>Bo(s,a,t)})}function yc(e){return e.filter(t=>{if(un(t))return!1;const s=Ra(t);if(!s)return!0;const a=e.find(o=>o.sessionId===s);return!a||!un(a)})}function Nm(e){return e.flatMap(t=>{const s=wc(t);return s?[s,...Fl(Zt(t))]:[]})}function Im(e,t,s){const a=new Set(_n(Zt(e)).sort((o,c)=>Bo(o.item,c.item,s)).slice(0,t).map(o=>o.item.sessionId));return{...e,children:Sc(Zt(e),a)}}function Sc(e,t){return e.flatMap(s=>{const a=Sc(Zt(s),t);return!t.has(s.item.sessionId)&&a.length===0?[]:[{...s,children:a}]})}function ua(e,t,s,a=-1){if(e<=0)return 0;const o=a>=0?Math.max(t,a+1):t;return Math.min(e,Math.max(s??0,o))}function el(e,t){const s=Object.keys(e),a=Object.keys(t);return s.length!==a.length?!1:s.every(o=>e[o]===t[o])}function Mm(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function Tm(e){return Ao(e)||e.syncStatus==="error"}function Rm(e){var a,o;if(!Tm(e))return null;const t=((a=e.lastErrorCode)==null?void 0:a.trim())??"",s=((o=e.lastErrorDetail)==null?void 0:o.replace(/\s+/g," ").trim())??"";return t&&s&&!s.includes(t)?`${t} · ${s}`:s||t||(e.syncStatus==="error"&&!Ao(e)?r("conversation.syncStatusError"):r("conversation.runtimeErrorTitle"))}function Em(e,t=110){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Ea(e,t="compact"){return oo(e,t)}const Pm={position:"relative",zIndex:0},Am={zIndex:1};function jc(e,t,s,a){const o=[],c=(a==null?void 0:a.trim())||t.name;s&&o.push(c);const p=Mm(e);return p&&o.push(p),o.join(" · ")||c}function tl(e,t){return Wh("session-state-indicator",e,t)}function Wm(e,t){return lc(e,t)}function nl(e,t){try{const s=window.localStorage.getItem(e),a=s?Number(s):Number.NaN;return Number.isFinite(a)?a:t}catch{return t}}function sl(e,t){try{const s=window.localStorage.getItem(e);return s===null?t:s==="true"}catch{return t}}function rl(e){var t;try{const s=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return s||null}catch{return null}}function hs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function Lm(e){try{window.localStorage.removeItem(e)}catch{}}function ha(e,t,s){return Math.max(t,Math.min(s,e))}function pa(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Bm(e){const t=window.getComputedStyle(e),s=pa(t.getPropertyValue("--desktop-macos-titlebar-height")),a=pa(t.getPropertyValue("--workbench-header-min-height")),o=pa(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),c=pa(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(s,a,40)+o+c+8}function al(e,t){const s=t.getBoundingClientRect();return e>=s.top&&e<=s.top+Bm(t)}function Dm(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function _m(){typeof window>"u"||window.dispatchEvent(new CustomEvent(em))}function Cc(e,t){const s=t==null?void 0:t.trim();if(!s)return null;for(const a of e){if(a.workspace.id===s)return a;const o=Cc(a.children,s);if(o)return o}return null}function ol(e,t){const s=t==null?void 0:t.trim();if(!s)return null;for(const a of e){const o=Cc(a.childWorktrees,s);if(o)return o}return null}function Nc(e){return e.flatMap(t=>[t.workspace.id,...Nc(t.children)])}function Fm(e){return new Set(e.flatMap(t=>[t.workspace.id,...Nc(t.childWorktrees)]))}function il(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var s;return t.collapsed===!0&&((s=t.workspace)==null?void 0:s.id)}).map(t=>t.workspace.id)}function so(e,t){const s=new Set(t);return{items:e.map(a=>({workspace:a.workspace,sessions:a.sessions,childWorktrees:a.childWorktrees,collapsed:s.has(a.workspace.id)}))}}function Ic(e,t,s){return e.map(a=>{const o=yc(a.sessions);return{workspace:a.workspace,meta:a.meta,visibleSessions:o,archivedSessions:a.sessions.filter(c=>un(c)&&!Ra(c)),visibleSessionTree:_o(o,s).filter(c=>!t.has(c.item.sessionId)&&!Co(Zt(c),p=>t.has(p.sessionId))),children:Ic(a.children,t,s)}})}function fo(e){return e.flatMap(t=>[t.workspace.id,...fo(t.children)])}function mr(e){return e.flatMap(t=>[...t.visibleSessionTree,...mr(t.children)])}function Om(e,t){if(!t)return null;for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,visibleSessionTree:pr(s)};const a=Tc(s.childWorktrees,t);if(a)return a}return null}function Mc(e,t){for(const s of e){const a=_n(s.visibleSessionTree).find(c=>c.item.sessionId===t);if(a)return a;const o=Mc(s.children,t);if(o)return o}return null}function Tc(e,t){for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,visibleSessionTree:s.visibleSessionTree};const a=Tc(s.children,t);if(a)return a}return null}function $m(e,t){if(!t)return null;for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const a=Rc(s.childWorktrees,t);if(a)return a}return null}function ll(e,t){if(!t)return null;for(const s of e){if(s.workspace.id===t)return s.workspace;const a=Ec(s.childWorktrees,t);if(a)return a}return null}function Rc(e,t){for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const a=Rc(s.children,t);if(a)return a}return null}function Ec(e,t){for(const s of e){if(s.workspace.id===t)return s.workspace;const a=Ec(s.children,t);if(a)return a}return null}function Pc(e,t){for(const s of e){if(s.workspace.id===t)return[s.workspace.id];const a=Pc(s.children,t);if(a.length>0)return[s.workspace.id,...a]}return[]}function cl(e){return e.flatMap(t=>[t.workspace.id,...Ac(t.childWorktrees)])}function Ac(e){return e.flatMap(t=>[t.workspace.id,...Ac(t.children)])}function Hm(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const s=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&s.push(e.parentDisplayName),s.join(" / ")}function Um(e,t,s,a){if(t===s)return e;const o=e.findIndex(f=>f.workspace.id===t),c=e.findIndex(f=>f.workspace.id===s);if(o<0||c<0)return e;const p=[...e],[h]=p.splice(o,1);if(!h)return e;const g=p.findIndex(f=>f.workspace.id===s);return g<0?e:(p.splice(a==="before"?g:g+1,0,h),p.every((f,w)=>{var N;return f.workspace.id===((N=e[w])==null?void 0:N.workspace.id)})?e:p)}function Gm(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let s=!1;const a=e.items.map(o=>{let c=!1;const p=o.sessions.map(g=>{const f=t.get(g.sessionId);return f===void 0||un(g)===f?g:(s=!0,c=!0,{...g,isArchived:f})}),h=Lc(o.childWorktrees??[],t,g=>{g&&(s=!0,c=!0)});return c?{...o,sessions:p,childWorktrees:h}:o});return s?{...e,items:a}:e}function zm(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const s of t.items){for(const a of s.sessions){const o=e.get(a.sessionId);o!==void 0&&un(a)===o&&e.delete(a.sessionId)}Bc(e,s.childWorktrees??[])}}function Km(e,t,s){let a=!1;const o=e.map(c=>{if(c.workspace.id!==t.workspaceId){const{nodes:g,changed:f}=Dc(c.childWorktrees,t,s);return f?(a=!0,{...c,childWorktrees:g}):c}const p=c.sessions.findIndex(g=>g.sessionId===t.sessionId),h=p>=0?c.sessions.map((g,f)=>f===p?t:g):[t,...c.sessions];return a=!0,{...c,sessions:Sr(h,s)}});return a?o:e}function qm(e,t,s){let a=!1;const o=e.map(c=>{let p=!1;const h=c.sessions.map(f=>f.sessionId!==t?f:(a=!0,p=!0,{...f,lastSeenAt:f.lastSeenAt&&f.lastSeenAt>s?f.lastSeenAt:s,activityState:f.activityState==="completed_unread"?"idle":f.activityState})),g=Pa(c.childWorktrees,f=>f.sessionId!==t?f:(a=!0,p=!0,{...f,lastSeenAt:f.lastSeenAt&&f.lastSeenAt>s?f.lastSeenAt:s,activityState:f.activityState==="completed_unread"?"idle":f.activityState}));return p?{...c,sessions:h,childWorktrees:g}:c});return a?o:e}function dl(e,t,s){let a=!1;const o=e.map(c=>{let p=!1;const h=c.sessions.map(f=>f.sessionId!==t||f.isArchived===s?f:(a=!0,p=!0,{...f,isArchived:s})),g=Pa(c.childWorktrees,f=>f.sessionId!==t||f.isArchived===s?f:(a=!0,p=!0,{...f,isArchived:s}));return p?{...c,sessions:h,childWorktrees:g}:c});return a?o:e}function ul(e,t,s){let a=!1;const o=e.map(c=>{let p=!1;const h=c.sessions.map(f=>f.sessionId!==t||f.isFavorite===!0===s?f:(a=!0,p=!0,{...f,isFavorite:s})),g=Pa(c.childWorktrees,f=>f.sessionId!==t||f.isFavorite===!0===s?f:(a=!0,p=!0,{...f,isFavorite:s}));return p?{...c,sessions:h,childWorktrees:g}:c});return a?o:e}function Vm(e,t){return e.includes(t)?e.filter(s=>s!==t):[...e,t]}function Xm(e){return e?e.slice(0,8):"--"}function hl(e,t,s){return s?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(a=>a!==t):e}function Wc(e,t){const s=e.filter(a=>t.has(a));return s.length===e.length?e:s}function Lc(e,t,s){return e.map(a=>{let o=!1;const c=a.sessions.map(h=>{const g=t.get(h.sessionId);return g===void 0||un(h)===g?h:(o=!0,{...h,isArchived:g})}),p=Lc(a.children,t,h=>{h&&(o=!0)});return s(o),o?{...a,sessions:c,children:p}:a})}function Bc(e,t){for(const s of t){for(const a of s.sessions){const o=e.get(a.sessionId);o!==void 0&&un(a)===o&&e.delete(a.sessionId)}Bc(e,s.children)}}function Dc(e,t,s){let a=!1;const o=e.map(c=>{if(c.workspace.id===t.workspaceId){const h=c.sessions.findIndex(f=>f.sessionId===t.sessionId),g=h>=0?c.sessions.map((f,w)=>w===h?t:f):[t,...c.sessions];return a=!0,{...c,sessions:Sr(g,s)}}const p=Dc(c.children,t,s);return p.changed?(a=!0,{...c,children:p.nodes}):c});return{nodes:a?o:[...e],changed:a}}function Ym(e,t){return e.map(s=>({...s,sessions:Sr(s.sessions,t),childWorktrees:Do(s.childWorktrees,t)}))}function Pa(e,t){let s=!1;const a=e.map(o=>{let c=!1;const p=o.sessions.map(g=>{const f=t(g);return f!==g&&(c=!0,s=!0),f}),h=Pa(o.children,t);return h!==o.children&&(c=!0,s=!0),c?{...o,sessions:p,children:h}:o});return s?a:[...e]}function bo(e){return`workspace-management.summary.${e}`}function _c(e){return`git-sidebar.snapshot.${e}`}function Fc(e,t){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 Oc(e,t){const s=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!s,repoRoot:s}}}function $c(e,t){var c,p,h,g;const s=((c=t.status)==null?void 0:c.snapshot.enabled)!==!1,a=s?((p=t.status)==null?void 0:p.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,o=s?((h=t.status)==null?void 0:h.snapshot.branch)??((g=t.branches)==null?void 0:g.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:s&&(e.git.isRepository||!!a),repoRoot:a,currentBranch:o,error:null}}}function Hc({count:e,className:t="workbench-skeleton-lines"}){return n.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(s,a)=>n.jsx("span",{className:"skeleton-line"},a))})}function Jm(){return n.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>n.jsxs("section",{className:"workbench-skeleton-card",children:[n.jsxs("div",{className:"workbench-skeleton-heading",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx("span",{className:"skeleton-line tiny"})]}),n.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(s,a)=>n.jsxs("div",{className:"workbench-skeleton-session",children:[n.jsx("span",{className:"workbench-skeleton-dot"}),n.jsx(Hc,{count:2,className:"workbench-skeleton-lines compact"})]},a))})]},t))})}function ma(){return n.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>n.jsxs("article",{className:"workbench-info-skeleton-card",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx(Hc,{count:3})]},t))})}function Zm({side:e,collapsed:t}){const s=e==="left"?8.5:15.5,a=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("line",{x1:s,y1:"4",x2:s,y2:"20"}),n.jsx("polyline",{points:a})]})}function pl({ariaLabel:e,side:t,collapsed:s,className:a="panel-icon-button",onClick:o}){return n.jsx("button",{className:a,type:"button","aria-label":e,title:e,onClick:o,children:n.jsx(Zm,{side:t,collapsed:s})})}function fr({expanded:e}){return n.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:n.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Qm(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"7 10 12 15 17 10"}),n.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function ef(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),n.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),n.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),n.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function tf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.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"}),n.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Uc(e){return n.jsx("div",{className:"workbench-notification-anchor",children:n.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:[n.jsx(tf,{}),e.unreadCount>0?n.jsx("span",{className:"workbench-notification-badge","aria-label":r("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function nf(e){const[t,s]=i.useState("notifications");i.useEffect(()=>{e.open&&s("notifications")},[e.open]);const a=i.useMemo(()=>e.notifications.filter(o=>e.showArchivedNotifications||!e.archivedNotificationIds.has(o.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return n.jsxs(nt,{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:[n.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":r("shell.globalNotificationsPanelTitle"),children:[n.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>s("notifications"),children:r("shell.globalNotificationsAction")}),n.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>s("inbox"),children:r("shell.butlerInboxAction")})]}),n.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?n.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.globalNotificationsAction"),children:[n.jsx("div",{className:"workbench-notification-toolbar",children:n.jsxs("label",{className:"workbench-notification-filter",children:[n.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:o=>e.onToggleShowArchivedNotifications(o.target.checked)}),n.jsx("span",{children:r("shell.globalNotificationsShowArchived")})]})}),a.length>0?n.jsx("div",{className:"workbench-notification-list",children:a.map(o=>{const c=e.archivedNotificationIds.has(o.id);return n.jsxs("article",{className:"workbench-notification-item","data-archived":c,children:[n.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(o)},children:[n.jsx("span",{className:"workbench-notification-item-kind",children:dm(o.kind)}),n.jsx("strong",{children:o.title}),n.jsx("p",{children:o.body})]}),n.jsxs("div",{className:"workbench-notification-item-side",children:[n.jsx("time",{children:bm(o.createdAt)}),n.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(c){e.onUnarchiveNotification(o.id);return}e.onArchiveNotification(o.id)},children:c?r("shell.globalNotificationsRemoveArchiveAction"):r("shell.globalNotificationsArchiveAction")})]})]},o.id)})}):n.jsx("p",{className:"workbench-notification-empty",children:r("shell.globalNotificationsEmpty")})]}):n.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.butlerInboxAction"),children:n.jsx(fc,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),n.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:n.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:r("common.close")})})]})}function sf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function rf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"11",cy:"11",r:"7"}),n.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function af(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:n.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 of(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("path",{d:"M7 9l3 3-3 3"}),n.jsx("path",{d:"M13 15h4"})]})}function lf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),n.jsx("circle",{cx:"9",cy:"11",r:"1"}),n.jsx("circle",{cx:"15",cy:"11",r:"1"}),n.jsx("path",{d:"M8 15h8"}),n.jsx("path",{d:"M12 5V3"})]})}function cf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.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"}),n.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 Gc(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),n.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function df(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"18",cy:"6",r:"3"}),n.jsx("circle",{cx:"6",cy:"6",r:"3"}),n.jsx("circle",{cx:"18",cy:"18",r:"3"}),n.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),n.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function uf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.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 hf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),n.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),n.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),n.jsx("path",{d:"M14 16l2 2 4-4"})]})}function pf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),n.jsx("path",{d:"M10 12h8"}),n.jsx("path",{d:"M15 8l4 4-4 4"})]})}function mf({selected:e}){return e?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),n.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function zc({active:e,className:t}){return e?n.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:n.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):n.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:n.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function ff(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 7h18"}),n.jsx("path",{d:"M5 7l1 12h12l1-12"}),n.jsx("path",{d:"M9 11h6"}),n.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function bf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M12 20h9"}),n.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 gf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 6h18"}),n.jsx("path",{d:"M8 6V4h8v2"}),n.jsx("path",{d:"M6 6l1 14h10l1-14"}),n.jsx("path",{d:"M10 11v5"}),n.jsx("path",{d:"M14 11v5"})]})}function kf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.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"}),n.jsx("path",{d:"M9 13h6"})]})}function wf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("circle",{cx:"12",cy:"12",r:"9"}),n.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"}),n.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function vf({open:e,mode:t,keyword:s,codeWorkspaceId:a,codeResults:o,codeLoading:c,codeError:p,workspaceOptions:h,sessionResults:g,onClose:f,onModeChange:w,onKeywordChange:N,onCodeWorkspaceChange:j,onCodeSearch:T,onOpenSession:H}){const O=s.trim().length>0&&a.trim().length>0;return n.jsx(nt,{open:e,title:r("shell.searchModalTitle"),description:r("shell.searchModalDescription"),onClose:f,children:n.jsxs("div",{className:"workbench-search-modal",children:[n.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":r("shell.searchModeLabel"),children:[n.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>w("sessions"),children:r("shell.searchModeSessions")}),n.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>w("code"),children:r("shell.searchModeCode")})]}),t==="sessions"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.searchKeywordLabel")}),n.jsx("input",{type:"text",value:s,placeholder:r("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:L=>N(L.target.value)})]}),n.jsx("div",{className:"workbench-search-results",children:s.trim().length===0?n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionHint")}):g.length>0?g.map(L=>{const v=Lo(L.session.title,r("common.unknown"));return n.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>H(L.session.sessionId),children:[n.jsx("span",{className:"workbench-search-result-title",title:v.fullTitle,children:v.displayTitle}),n.jsxs("span",{className:"workbench-search-result-meta",children:[L.workspace.name," · ",Ea(L.session.provider,"full")]})]},L.session.sessionId)}):n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionEmpty")})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.searchWorkspaceLabel")}),n.jsx("select",{value:a,onChange:L=>j(L.target.value),children:h.map(L=>n.jsx("option",{value:L.id,children:L.name},L.id))})]}),n.jsxs("form",{className:"workbench-search-code-form",onSubmit:L=>{L.preventDefault(),T()},children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.searchKeywordLabel")}),n.jsx("input",{type:"text",value:s,placeholder:r("shell.searchCodePlaceholder"),autoFocus:!0,onChange:L=>N(L.target.value)})]}),n.jsx("button",{type:"submit",className:"primary-button",disabled:!O||c,children:c?r("common.loading"):r("shell.searchSubmit")})]}),n.jsxs("div",{className:"workbench-search-results",children:[p?n.jsx("p",{className:"status-text","data-tone":"error",children:p}):null,!p&&s.trim().length===0?n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeHint")}):null,!p&&s.trim().length>0&&!c&&o.length===0?n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeEmpty")}):null,o.map(L=>n.jsxs("div",{className:"workbench-search-result-item static",children:[n.jsx("span",{className:"workbench-search-result-title",children:L.name}),n.jsx("span",{className:"workbench-search-result-meta",children:L.path})]},`${L.path}-${L.kind}`))]})]})]})})}function ml({menuKey:e,session:t,workspace:s,workspaceContext:a,isActive:o,isFavorite:c,menuOpen:p,menuAnchorPoint:h,showWorkspaceName:g,depth:f=0,showActions:w=!0,hasSubagents:N=!1,subagentListExpanded:j=!1,selectionMode:T=!1,selected:H=!1,onToggleSelect:O,onToggleSubagents:L,onOpen:v,onRename:K,onOpenContextMenu:F,onToggleFavorite:te,onArchive:M,onDelete:X,onCloseMenu:V}){var he,We,J;const D=Hn(),y=va(t.provider).supportsSessionDelete===!0,Y=mo(t)?((he=t.subagentLabel)==null?void 0:he.trim())||r("shell.subagentBadge"):null,Q=Lo(t.title,r("common.unknown")),B=Rm(t),me=B?Em(B):null,ue=Lh(t),ne=ue?Bh("session-activity-badge",t):null,W=Wo(t),x=$h(t),C=tu(t.parallelGroup),$=Qd(t.parallelGroup),se=i.useRef(null),[Me,xe]=i.useState(null);i.useLayoutEffect(()=>{if(D.isDesktop||!p||!h||typeof window>"u"){xe(null);return}const ge=()=>{var Ye,S;const Te=Jh(h,{width:((Ye=se.current)==null?void 0:Ye.offsetWidth)??0,height:((S=se.current)==null?void 0:S.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:y&&X?216:168});xe({position:"fixed",top:`${Math.round(Te.top)}px`,left:`${Math.round(Te.left)}px`,width:`${Math.round(Te.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(Te.maxHeight)}px`,transformOrigin:Te.transformOrigin})};return ge(),window.addEventListener("resize",ge),window.addEventListener("scroll",ge,!0),()=>{window.removeEventListener("resize",ge),window.removeEventListener("scroll",ge,!0)}},[h,p,D.isDesktop]);async function oe(){await Yd([{id:`rename:${t.sessionId}`,label:r("shell.renameAction"),onSelect:K},{id:`favorite:${t.sessionId}`,label:c?r("shell.unfavoriteAction"):r("shell.favoriteAction"),onSelect:te},{id:`archive:${t.sessionId}`,label:r("shell.archiveAction"),onSelect:M},...y&&X?[{id:`delete:${t.sessionId}`,label:r("shell.deleteSessionAction"),onSelect:X}]:[]])}const ae=!D.isDesktop&&p&&typeof document<"u"?Os.createPortal(n.jsxs("div",{ref:se,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":r("shell.sessionMoreAction"),onClick:ge=>ge.stopPropagation(),style:Me??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{K(),V()},children:[n.jsx(bf,{}),n.jsx("span",{children:r("shell.renameAction")})]}),n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{te(),V()},children:[n.jsx(zc,{active:c}),n.jsx("span",{children:c?r("shell.unfavoriteAction"):r("shell.favoriteAction")})]}),n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{M(),V()},children:[n.jsx(ff,{}),n.jsx("span",{children:r("shell.archiveAction")})]}),y&&X?n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{X(),V()},children:[n.jsx(gf,{}),n.jsx("span",{children:r("shell.deleteSessionAction")})]}):null]}),document.body):null;return n.jsxs("article",{className:"workbench-session-card","data-active":o,"data-depth":f,"data-subagent":mo(t),"data-workspace-tone":a.tone,"data-worktree-depth":a.depth,"data-has-subagents":N,"data-selecting":T,"data-selected":H,"data-parallel-group":t.parallelGroup?"true":void 0,"data-parallel-role":((We=t.parallelGroup)==null?void 0:We.role)??void 0,"data-parallel-color-token":((J=t.parallelGroup)==null?void 0:J.colorToken)??void 0,style:{...yn(a)??{},...$??{}},onContextMenu:ge=>{if(!(T||!w||!F)){if(ge.preventDefault(),ge.stopPropagation(),D.isDesktop){oe();return}F({x:ge.clientX,y:ge.clientY})}},children:[n.jsxs("div",{className:"workbench-session-main",children:[T?n.jsx("span",{className:"workbench-session-selection-indicator","data-selected":H,"aria-hidden":"true",children:n.jsx(mf,{selected:H})}):N?n.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:Am,"data-indicator-variant":Wm(t,{hasSubagents:!0,isActive:o}),"aria-label":j?r("shell.subagentCollapse"):r("shell.subagentExpand"),title:j?r("shell.subagentCollapse"):r("shell.subagentExpand"),"aria-expanded":j,onClick:ge=>{ge.stopPropagation(),L==null||L()},children:[n.jsx("span",{className:tl(t,{hasSubagents:!0,isActive:o}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),n.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:n.jsx(fr,{expanded:j})})]}):n.jsx("span",{className:tl(t,{isActive:o}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),n.jsx("button",{type:"button",className:"workbench-session-link",style:N?Pm:void 0,"data-active":o,"aria-pressed":T?H:void 0,onClick:T?O:v,onKeyDown:ge=>{if(T||!w||!F||ge.key!=="ContextMenu"&&!(ge.shiftKey&&ge.key==="F10"))return;if(ge.preventDefault(),ge.stopPropagation(),D.isDesktop){oe();return}const Te=ge.currentTarget.getBoundingClientRect();F({x:Te.right,y:Te.bottom})},children:n.jsxs("div",{className:"workbench-session-link-copy",children:[n.jsxs("div",{className:"session-title-row",children:[n.jsx("span",{className:"session-title",title:Q.fullTitle,children:Q.displayTitle}),Y?n.jsx("span",{className:"session-subagent-badge",children:Y}):null,C?n.jsx("span",{className:"session-parallel-badge",children:C}):null,!C&&x&&W?n.jsx("span",{className:`session-fork-badge ${W}`,children:x}):null]}),n.jsxs("div",{className:"session-meta-row",children:[n.jsx("span",{className:"session-meta",children:jc(t,s,g,a.displayName)}),ue&&ne?n.jsx("span",{className:ne,children:ue}):null,n.jsx("span",{className:`session-provider-badge ${t.provider}`,children:Ea(t.provider)})]}),me?n.jsx("div",{className:"session-error-row",title:B??void 0,children:n.jsx("span",{className:"session-error-text",children:me})}):null]})})]}),ae]})}function fl({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:s,favoriteSessions:a,favoriteSessionIds:o,activeWorkspaceId:c,isConversationActive:p,isTerminalActive:h,isButlerActive:g,isSearchOpen:f,navigationLoading:w,navigationError:N,activeSessionId:j,onRefreshNavigation:T,onSessionUpdated:H,onNavigateConversation:O,onNavigateTerminals:L,onNavigateButler:v,onOpenSearch:K,onOpenSettings:F,onSelectWorkspace:te,onToggleWorkspaceCollapse:M,onStartWorkspaceReorder:X,onPreviewWorkspaceReorder:V,onCommitWorkspaceReorder:D,allowWorkspaceReorder:y,subscribeGitSnapshot:Y,requestGitRefresh:Q,subscribeWorkspaceManagementSnapshot:B,requestWorkspaceManagementRefresh:me,onToggleFavoriteSession:ue,onArchiveSession:ne,onUnarchiveSession:W,workspaceManagementStateById:x,setWorkspaceManagementStateById:C,unreadNotificationCount:$,notificationPanelOpen:se,onToggleNotificationPanel:Me,onClose:xe,onToggleCollapse:oe}){var zr;const ae=vr(),he=Hn(),We=tc(he),{showToast:J}=fs(),ge=gc(),Te=go(d=>d),Ye=((zr=ao(Te))==null?void 0:zr.name)??"",S=Te.hosts.length+Sl(Te).length>1&&Ye.length>0,[I,Z]=i.useState(!1),[U,Ce]=i.useState(!1),[je,Re]=i.useState(!1),[At,mt]=i.useState([]),[_,R]=i.useState(null),[ie,ce]=i.useState(null),[pe,ke]=i.useState(null),[Qe,Ae]=i.useState(null),[et,it]=i.useState(null),[st,vt]=i.useState(null),[Wt,rt]=i.useState(null),[Rt,Je]=i.useState(!1),[ft,Se]=i.useState(!1),[lt,qe]=i.useState(""),[Fe,Lt]=i.useState(""),[Be,jn]=i.useState(""),[$e,Un]=i.useState({localBranches:[],remoteBranches:[],tags:[]}),[xt,yt]=i.useState(!1),[Gs,ct]=i.useState(-1),[gs,Gn]=i.useState(!1),[ks,pn]=i.useState(!1),[Cn,Nn]=i.useState(null),[en,jr]=i.useState(null),[zs,Ks]=i.useState(null),[In,Cr]=i.useState(null),[Bt,Mn]=i.useState(null),[zn,Kn]=i.useState(null),[bt,gt]=i.useState(null),[Dt,Nr]=i.useState(!1),[tt,_t]=i.useState(null),[Oe,qn]=i.useState(null),[Vn,Tn]=i.useState(to),[Xn,ws]=i.useState({}),[Yn,Jn]=i.useState({}),[Rn,tn]=i.useState([]),[En,Zn]=i.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[Ft,vs]=i.useState(null),[mn,Qn]=i.useState(""),[fn,xs]=i.useState(null),[kt,es]=i.useState(null),[St,ze]=i.useState([]),[wt,Et]=i.useState(!1),[Pn,ys]=i.useState({}),[Ss,js]=i.useState(null),nn=i.useRef(null),Ot=i.useRef(null),sn=i.useRef(null),An=i.useRef(new Map),rn=i.useRef(null),Cs=i.useRef(null),an=i.useRef(null),Ir=i.useMemo(()=>new Set(En.expandedWorkspaceIds),[En.expandedWorkspaceIds]),Mr=i.useMemo(()=>new Set(En.collapsedWorkspaceIds),[En.collapsedWorkspaceIds]),Tr=Ss!==null,Gt=y&&he.isDesktop&&he.ui.osFamily==="macos",at=i.useCallback(()=>{_t(null),qn(null)},[]),qs=i.useCallback((d,m)=>{_t(d),qn(m)},[]),De=ll(e,et)??((Wt==null?void 0:Wt.id)===et?Wt:null),zt=Be.trim().toLowerCase(),Wn=i.useMemo(()=>[{key:"localBranches",label:r("shell.createWorktreeBaseRefLocalGroup"),items:$e.localBranches},{key:"remoteBranches",label:r("shell.createWorktreeBaseRefRemoteGroup"),items:$e.remoteBranches},{key:"tags",label:r("shell.createWorktreeBaseRefTagGroup"),items:$e.tags}].map(m=>({...m,items:m.items.filter(k=>zt?k.value.toLowerCase().includes(zt):!0)})).filter(m=>m.items.length>0),[zt,$e]),Ct=i.useMemo(()=>Wn.flatMap(d=>d.items),[Wn]),Ie=De?`create-worktree-base-ref-listbox-${De.id}`:"create-worktree-base-ref-listbox",Xe=$m(e,In),Ee=Xe?wn(Xe.workspace):null,Pt=i.useMemo(()=>Om(e,kt),[kt,e]),Ln=i.useMemo(()=>Pt?Nm(Pt.visibleSessionTree):[],[Pt]),Nt=i.useMemo(()=>Ln.map(d=>d.sessionId),[Ln]),Kt=i.useMemo(()=>new Set(Nt),[Nt]),ts=i.useMemo(()=>new Set(St),[St]),Rr=Nt.length>0&&St.length===Nt.length;i.useEffect(()=>{C(d=>{const m=cl(e),k=new Set(m),A={};Object.entries(d).forEach(([q,Ne])=>{k.has(q)&&(A[q]=Ne)}),m.forEach(q=>{const Ne=ll(e,q);if(!Ne)return;const Ke=ya(bo(q),qi),Ve=ya(_c(q),qi),ht=A[q];let Xt=Oc((ht==null?void 0:ht.detail)??Ke??Fc(Ne),Ne);(Ve!=null&&Ve.status||Ve!=null&&Ve.branches)&&(Xt=$c(Xt,{status:Ve.status??null,branches:Ve.branches??null})),A[q]={detail:Xt,loading:!1,error:null}});const E=Object.keys(d),de=Object.keys(A);return E.length===de.length&&de.every(q=>d[q]===A[q])?d:A})},[e]);const Er=i.useCallback(async d=>{await T(),await he.bridge.showNotification(r("shell.importSuccess"),d.path)},[T,he.bridge]),Pr=i.useCallback(async d=>{await T(),await he.bridge.showNotification(r("shell.cloneSuccess"),d.path)},[T,he.bridge]);function Ar(d){if(At.includes(d)){mt(k=>k.filter(A=>A!==d));return}mt(k=>[...k,d]),Y(d),Q(d),B(d),me(d)}async function dt(d,m){if(Pn[d])return;const k=(m==null?void 0:m.trim().toUpperCase())??null;ys(A=>({...A,[d]:!0}));try{await Il(d,{backgroundColor:k}),await T()}catch(A){J({title:A instanceof Error?A.message:r("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{ys(A=>({...A,[d]:!1}))}}async function Ze(){if(!(!_||ie)){ce(_.id);try{await Ed(_.id),mt(d=>d.filter(m=>m!==_.id)),C(d=>{const m={...d};return delete m[_.id],m}),R(null),await T(),J({title:r("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(d){J({title:d instanceof Error?d.message:r("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{ce(null)}}}i.useEffect(()=>{if(!tt)return;function d(m){const k=m.target;k instanceof HTMLElement&&k.closest(".workbench-session-menu")||at()}return window.addEventListener("pointerdown",d),()=>{window.removeEventListener("pointerdown",d)}},[at,tt]),i.useEffect(()=>{if(!kt){St.length>0&&ze([]),bt&&gt(null);return}if(!Pt){es(null),ze([]),gt(null);return}ze(d=>Wc(d,Kt))},[Pt,bt,Kt,kt,St.length]),i.useEffect(()=>{kt&&Nt.length===0&&(es(null),ze([]),gt(null))},[Nt.length,kt]),i.useEffect(()=>{const d=new Set(cl(e)),m=new Set(e.flatMap(k=>fo(k.childWorktrees)));mt(k=>k.filter(A=>d.has(A))),Zn(k=>({expandedWorkspaceIds:k.expandedWorkspaceIds.filter(A=>m.has(A)),collapsedWorkspaceIds:k.collapsedWorkspaceIds.filter(A=>m.has(A))})),R(k=>k&&d.has(k.id)?k:null),ys(k=>Object.fromEntries(Object.entries(k).filter(([A,E])=>E&&d.has(A))))},[e]),i.useEffect(()=>{const d=a.findIndex(m=>m.session.sessionId===j);Tn(m=>{const k=ua(a.length,to,m,d);return k===m?m:k})},[j,a]),i.useEffect(()=>{ws(d=>{const m={};for(const k of e){const A=pr(k),E=A.findIndex(de=>de.item.sessionId===j||Ws([de],j??"",q=>q.sessionId).length>0);m[k.workspace.id]=ua(A.length,dr,d[k.workspace.id],E);for(const de of mr(k.childWorktrees)){de.item.sessionId===j||Ws([de],j??"",Ve=>Ve.sessionId).length>0;const q=de.item.workspaceId;if(m[q]!==void 0)continue;const Ne=mr(k.childWorktrees).filter(Ve=>Ve.item.workspaceId===q&&Ve.depth===0),Ke=Ne.findIndex(Ve=>Ve.item.sessionId===j||Ws([Ve],j??"",ht=>ht.sessionId).length>0);m[q]=ua(Ne.length,dr,d[q],Ke)}}return el(d,m)?d:m})},[j,e]),i.useEffect(()=>{Jn(d=>{const m={};for(const k of e)for(const A of[...pr(k),...mr(k.childWorktrees)])for(const E of _n(Zt(A))){const de=Zt(E);if(de.length===0)continue;const q=_n(de),Ne=q.findIndex(Ke=>Ke.item.sessionId===j);m[E.item.sessionId]=ua(q.length,ca,d[E.item.sessionId],Ne)}return el(d,m)?d:m})},[j,e]),i.useEffect(()=>{if(!j)return;const d=e.flatMap(m=>[...Ws(pr(m),j,k=>k.sessionId),...mr(m.childWorktrees).flatMap(k=>Ws([k],j,A=>A.sessionId))]);d.length!==0&&tn(m=>{const k=new Set(m);let A=!1;for(const E of d)k.has(E)||(k.add(E),A=!0);return A?Array.from(k):m})},[j,e]),i.useEffect(()=>{if(!c)return;const d=[];for(const m of e){const k=Pc(m.childWorktrees,c);k.length!==0&&d.push(...k)}d.length>0&&Zn(m=>{const k=new Set(m.expandedWorkspaceIds);let A=!1;for(const E of d)k.has(E)||(k.add(E),A=!0);return A?{expandedWorkspaceIds:Array.from(k),collapsedWorkspaceIds:m.collapsedWorkspaceIds}:m})},[c,e]),i.useEffect(()=>{if(!et){rt(null),Je(!1),Se(!1),qe(""),Lt(""),jn(""),yt(!1),ct(-1),Gn(!1),Un({localBranches:[],remoteBranches:[],tags:[]}),pn(!1),Nn(null);return}Je(!1),qe(""),Lt(""),jn(""),yt(!1),ct(-1),Gn(!1),Un({localBranches:[],remoteBranches:[],tags:[]}),pn(!1),Nn(null)},[et]),i.useEffect(()=>{const d=De;if(!Rt||!d)return;let m=!1;const k=d.id;return pn(!0),Nn(null),Promise.all([Vd(k),Xd(k)]).then(([A,E])=>{m||Un(pm(A,E))}).catch(()=>{m||(Un({localBranches:[],remoteBranches:[],tags:[]}),Nn(r("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{m||pn(!1)}),()=>{m=!0}},[De==null?void 0:De.id,Rt]),i.useLayoutEffect(()=>{if(!xt||!nn.current){jr(null),Ks(null);return}const d=()=>{const k=nn.current;if(!k)return;const A=mm(k);jr({top:A.bottom+8,left:A.left,width:A.width})};d();const m=k=>{var E,de;const A=k.target;A instanceof Node&&((E=nn.current)!=null&&E.contains(A)||(de=Ot.current)!=null&&de.contains(A)||(yt(!1),ct(-1)))};return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),window.addEventListener("pointerdown",m),()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),window.removeEventListener("pointerdown",m)}},[Ct.length,xt]),i.useLayoutEffect(()=>{if(!xt||!Ot.current){Ks(null);return}const d=Ot.current,m=()=>{const A=Math.ceil(d.getBoundingClientRect().height);Ks(E=>E===A?E:A)};if(m(),typeof ResizeObserver>"u")return;const k=new ResizeObserver(()=>{m()});return k.observe(d),()=>{k.disconnect()}},[xt,Wn,ks,Cn]);function qt(){Z(!0)}function ns(){Ce(!0)}function Vs(d){Bn(),it(null),vt({kind:"workspace",workspaceId:d.id,workspaceName:d.name})}function Bn(){Je(!1),qe(""),Lt(""),jn(""),yt(!1),ct(-1),Gn(!1)}function fe(d,m){const k=d.getBoundingClientRect();return m<=k.top+k.height/2?"before":"after"}function Xs(){sn.current!==null&&(cancelAnimationFrame(sn.current),sn.current=null),js(null)}function ss(d){const m=(d==null?void 0:d.commit)??!1,k=(d==null?void 0:d.preserveClickSuppression)??!1,A=rn.current,E=Cs.current;rn.current=null,Cs.current=null,E==null||E(),A!=null&&A.dragging&&(Xs(),m&&D(),!k&&an.current===A.workspaceId&&(an.current=null))}function Ns(d){if(an.current===d){an.current=null;return}M(d)}function rs(d,m){if(m){An.current.set(d,m);return}An.current.delete(d)}function Aa(d,m){for(const[k,A]of An.current){const E=A.getBoundingClientRect();if(d>=E.left&&d<=E.right&&m>=E.top&&m<=E.bottom)return{workspaceId:k,element:A}}return null}function as(d,m){var Ne;if(!Gt||d.button!==0)return;ss();const k=d.currentTarget,A={pointerId:d.pointerId,workspaceId:m,startX:d.clientX,startY:d.clientY,pointerTarget:k,dragging:!1};rn.current=A,(Ne=k.setPointerCapture)==null||Ne.call(k,d.pointerId);const E=Ke=>{It(Ke)},de=Ke=>{Ue(Ke.pointerId,{commit:!0,preserveClickSuppression:!0})},q=Ke=>{Ue(Ke.pointerId,{commit:!1,preserveClickSuppression:!1})};Cs.current=()=>{k.removeEventListener("pointermove",E),k.removeEventListener("pointerup",de),k.removeEventListener("pointercancel",q),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",de),window.removeEventListener("pointercancel",q)},k.addEventListener("pointermove",E),k.addEventListener("pointerup",de),k.addEventListener("pointercancel",q),window.addEventListener("pointermove",E,{passive:!1}),window.addEventListener("pointerup",de),window.addEventListener("pointercancel",q)}function It(d){const m=rn.current;if(!m||m.pointerId!==d.pointerId)return;if(!m.dragging){if(Math.hypot(d.clientX-m.startX,d.clientY-m.startY)<Zp)return;m.dragging=!0,an.current=m.workspaceId,X(),js(m.workspaceId)}d.preventDefault();const k=Aa(d.clientX,d.clientY);!k||k.workspaceId===m.workspaceId||V(m.workspaceId,k.workspaceId,fe(k.element,d.clientY))}function Ue(d,m){var A,E;const k=rn.current;!k||k.pointerId!==d||((E=(A=k.pointerTarget).releasePointerCapture)==null||E.call(A,d),ss(m))}function os(d){It(d)}function Wr(d){Ue(d.pointerId,{commit:!0,preserveClickSuppression:!0})}function Is(d){Ue(d.pointerId,{commit:!1,preserveClickSuppression:!1})}function Ms(d,m){d.dataTransfer.effectAllowed="move",d.dataTransfer.setData("text/plain",m),X(),sn.current!==null&&cancelAnimationFrame(sn.current),sn.current=requestAnimationFrame(()=>{sn.current=null,js(m)})}function Fo(d,m){const k=Ss||d.dataTransfer.getData("text/plain");!k||k===m||(d.preventDefault(),d.dataTransfer.dropEffect="move",V(k,m,fe(d.currentTarget,d.clientY)))}function Vt(d){d.preventDefault()}function bn(){Xs(),D()}i.useEffect(()=>()=>{ss()},[]);function Lr(d){return Yn[d]??ca}function Br(d){return Rn.includes(d)}function gn(d){return Xn[d]??dr}function Wa(){Tn(d=>Math.min(a.length,d+to))}function $t(d,m){ws(k=>({...k,[d]:Math.min(m,(k[d]??dr)+dr)}))}function Dr(d){Jn(m=>({...m,[d]:(m[d]??ca)+ca}))}function Ys(d){tn(m=>m.includes(d)?m.filter(k=>k!==d):[...m,d])}function ut(d,m){return Mr.has(d)?!1:m||Ir.has(d)}function Ts(d,m){const k=!ut(d,m);Zn(A=>{const E=A.expandedWorkspaceIds.filter(q=>q!==d),de=A.collapsedWorkspaceIds.filter(q=>q!==d);return k?{expandedWorkspaceIds:[...E,d],collapsedWorkspaceIds:de}:{expandedWorkspaceIds:E,collapsedWorkspaceIds:[...de,d]}})}function Js(d){for(const m of e){const k=_n(_o(m.visibleSessions,s)).find(A=>A.item.sessionId===d)??Mc(m.childWorktrees,d);if(k)return Zt(k)}return[]}function _r(d,m){const k=wn(d);return n.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":k.tone,style:yn(k),onClick:()=>Cr(d.id),children:[n.jsxs("span",{className:"workbench-archive-folder-main",children:[n.jsx(kf,{}),n.jsx("span",{children:r("shell.archiveFolderLabel")})]}),n.jsx("span",{className:"workbench-section-counter",children:m.length})]})}function Fr(){return n.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[n.jsx("span",{className:"workbench-workspace-batch-label",children:r("shell.batchSelectionMode")}),n.jsxs("span",{className:"workbench-workspace-batch-counter",children:[St.length,"/",Nt.length]}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Da,children:Rr?r("shell.clearSelectedSessions"):r("shell.selectAllSessions")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:St.length===0||wt||Dt,onClick:()=>{Ur()},children:wt?r("shell.batchArchiving"):r("shell.batchArchiveAction")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action danger",disabled:St.length===0||wt||Dt,onClick:_a,children:Dt?r("shell.batchDeleting"):r("shell.batchDeleteAction")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Ba,children:r("common.cancel")})]})}function Zs(d,m="workbench-workspace-actions"){return n.jsxs("div",{className:m,children:[n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.switchWorkspace"),title:r("shell.switchWorkspace"),"aria-pressed":c===d,onClick:()=>{te(d),xe==null||xe()},children:n.jsx(pf,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.batchSelectSessions"),title:r("shell.batchSelectSessions"),onClick:()=>La(d),children:n.jsx(hf,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":r("shell.createSession"),title:r("shell.createSession"),onClick:()=>it(d),children:n.jsx(sf,{})})]})}function Or(d){const m=d.visibleSessionTree,A=new Set(fo(d.children)).has(c??""),E=d.workspace.id===c||A,de=Tr||!ut(d.workspace.id,E),q=wn(d.workspace);return n.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":kt===d.workspace.id,"data-worktree-depth":d.meta.depth,"data-workspace-tone":"worktree",style:yn(q),children:[n.jsxs("div",{className:"workbench-workspace-header minimal",children:[n.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":de?r("shell.worktreeExpand"):r("shell.worktreeCollapse"),onClick:()=>Ts(d.workspace.id,E),children:[n.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:n.jsx(fr,{expanded:!de})}),n.jsxs("span",{children:[n.jsx("strong",{children:d.meta.displayName||d.workspace.name}),n.jsx("span",{className:"session-meta",children:d.meta.branchName})]})]}),kt===d.workspace.id?Fr():Zs(d.workspace.id)]}),de?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-session-list","data-workspace-tone":q.tone,style:yn(q),children:[m.length===0?n.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):m.slice(0,gn(d.workspace.id)).map(Ne=>Rs({node:Ne,workspace:d.workspace,workspaceContext:q,menuKeyPrefix:`worktree:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:kt===d.workspace.id,favoriteEnabled:!0})),m.length>gn(d.workspace.id)?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>$t(d.workspace.id,m.length),children:r("shell.sessionExpandMore")}):null]}),d.children.length>0?n.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.children.map(Ne=>Or(Ne))}):null,_r(d.workspace,d.archivedSessions)]})]},d.workspace.id)}function Rs(d){var rr;const{node:m,workspace:k,workspaceContext:A,menuKeyPrefix:E,showWorkspaceName:de,selectionMode:q,favoriteEnabled:Ne,ancestorExpanded:Ke=!1,allowToggle:Ve=m.depth===0,ancestorHasNextSiblings:ht=[],hasNextSibling:Xt=!1,isFirstSibling:on=!1}=d,we=m.item,vn=Zt(m),Yt=Ke||Br(we.sessionId),He=Yt&&Ve,Kr=He?Im(m,Lr(we.sessionId),s):m,ds=Yt?Zt(Kr):[],qr=_n(vn).length,Vr=_n(ds).length,Xr=He&&Vr<qr,nr=m.depth>0?[...ht,Xt]:[...ht],sr=Yt&&((rr=we.parallelGroup)==null?void 0:rr.role)==="anchor"&&vn.some(Mt=>{var Tt,ar,or;return((ar=(Tt=wc(Mt))==null?void 0:Tt.parallelGroup)==null?void 0:ar.groupId)===((or=we.parallelGroup)==null?void 0:or.groupId)});return n.jsxs("div",{className:"workbench-session-tree-node",children:[n.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":m.depth},children:[m.depth>0?n.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[ht.map((Mt,Tt)=>Mt?n.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":Tt+1}},`${we.sessionId}:ancestor:${Tt}`):null),n.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":Xt,"data-first":on,style:{"--workbench-session-tree-level":m.depth},children:n.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,n.jsx(ml,{menuKey:`${E}:${we.sessionId}`,session:we,workspace:k,workspaceContext:A,isActive:we.sessionId===j,isFavorite:Ne&&o.has(we.sessionId),menuOpen:tt===`${E}:${we.sessionId}`,showWorkspaceName:de,depth:m.depth,showActions:Ne,hasSubagents:Ve&&vn.length>0,subagentListExpanded:Yt,selectionMode:q,selected:ts.has(we.sessionId),onToggleSelect:()=>$r(we.sessionId),onToggleSubagents:()=>Ys(we.sessionId),onOpen:()=>{ae(Ut(k.id,we.sessionId)),xe==null||xe()},onRename:()=>er(we,k),menuAnchorPoint:tt===`${E}:${we.sessionId}`?Oe:null,onOpenContextMenu:Mt=>qs(`${E}:${we.sessionId}`,Mt),onToggleFavorite:()=>is(we.sessionId),onArchive:()=>ls(we.sessionId),onDelete:va(we.provider).supportsSessionDelete===!0?()=>{at(),Mn({session:we,workspace:k})}:void 0,onCloseMenu:at})]}),vn.length>0&&Yt?n.jsxs("div",{className:"workbench-subsession-list",children:[sr?n.jsx("div",{className:"workbench-session-tree-node",children:n.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":m.depth+1},children:[n.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[nr.map((Mt,Tt)=>Mt?n.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":Tt+1}},`parallel-anchor-replica:${we.sessionId}:ancestor:${Tt}`):null),n.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":ds.length>0,"data-first":"true",style:{"--workbench-session-tree-level":m.depth+1},children:n.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}),n.jsx(ml,{menuKey:`${E}:parallel-anchor-replica:${we.sessionId}`,session:we,workspace:k,workspaceContext:A,isActive:!1,isFavorite:Ne&&o.has(we.sessionId),menuOpen:tt===`${E}:parallel-anchor-replica:${we.sessionId}`,showWorkspaceName:de,depth:m.depth+1,showActions:Ne,hasSubagents:!1,subagentListExpanded:!1,selectionMode:q,selected:ts.has(we.sessionId),onToggleSelect:()=>$r(we.sessionId),onOpen:()=>{ae(Ut(k.id,we.sessionId)),xe==null||xe()},onRename:()=>er(we,k),menuAnchorPoint:tt===`${E}:parallel-anchor-replica:${we.sessionId}`?Oe:null,onOpenContextMenu:Mt=>qs(`${E}:parallel-anchor-replica:${we.sessionId}`,Mt),onToggleFavorite:()=>is(we.sessionId),onArchive:()=>ls(we.sessionId),onDelete:va(we.provider).supportsSessionDelete===!0?()=>{at(),Mn({session:we,workspace:k})}:void 0,onCloseMenu:at})]})},`parallel-anchor-replica:${we.sessionId}`):null,ds.map((Mt,Tt)=>Rs({node:Mt,workspace:k,workspaceContext:A,menuKeyPrefix:E,showWorkspaceName:de,selectionMode:q,favoriteEnabled:Ne,ancestorExpanded:!0,allowToggle:!1,ancestorHasNextSiblings:nr,hasNextSibling:Tt<ds.length-1,isFirstSibling:!sr&&Tt===0})),Xr?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Dr(we.sessionId),children:r("shell.subagentExpandMore")}):null]}):null]},we.sessionId)}function La(d){at(),es(d),ze([]),gt(null)}function Ba(){es(null),ze([]),gt(null)}function $r(d){ze(m=>Vm(m,d))}function Da(){ze(d=>d.length===Nt.length?[]:Nt)}function _a(){if(!Pt||St.length===0||wt||Dt)return;const d=new Map(Ln.map(k=>[k.sessionId,k])),m=St.flatMap(k=>{const A=d.get(k);return A?[A]:[]});m.length!==0&&(at(),gt({workspace:Pt.workspace,sessions:m}))}async function Fa(d,m){ke(d),Ae(m);try{await vc(d,m),it(null),ae(ql(d,m)),xe==null||xe()}catch(k){J({title:k instanceof Error?k.message:r("shell.startSessionFailed"),tone:"error"})}finally{ke(null),Ae(null)}}async function kn(d){if(d.preventDefault(),!De||ft)return;const m=lt.trim(),k=Fe.trim(),A=Be.trim();if(!m){J({title:r("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!um(m)){J({title:r("shell.createWorktreeBranchInvalid"),tone:"error"});return}Se(!0);try{const E=await Pd({sourceWorkspaceId:De.id,branchName:m,displayName:k||void 0,baseRef:A||void 0});rt(E.workspace),te(E.workspace.id),await T(),it(E.workspace.id),Bn(),J({title:r("shell.createWorktreeSucceeded",{name:E.meta.displayName||E.workspace.name}),tone:"success"})}catch(E){J({title:E instanceof Error?E.message:r("shell.createWorktreeFailed"),tone:"error"})}finally{Se(!1)}}async function is(d){const m=o.has(d);at();try{await ue(d),J({title:m?r("shell.favoriteRemoved"):r("shell.favoriteAdded"),tone:"success"})}catch(k){J({title:k instanceof Error?k.message:r("shell.favoriteToggleFailed"),tone:"error"})}}async function ls(d){at();try{await ne(d),J({title:r("shell.archiveAdded"),tone:"success"})}catch(m){J({title:m instanceof Error?m.message:r("shell.navigationLoadFailed"),tone:"error"})}}async function Hr(){if(!Bt||zn)return;const{session:d,workspace:m}=Bt;Kn(d.sessionId),at();try{await Ko(d.sessionId),ze(k=>k.filter(A=>A!==d.sessionId)),Mn(null),j===d.sessionId&&ae(m.id?Fs(m.id):jt()),await T(),J({title:r("shell.deleteSessionSuccess"),tone:"success"})}catch(k){J({title:k instanceof Error?k.message:r("shell.deleteSessionFailed"),tone:"error"})}finally{Kn(null)}}async function Ur(){if(!(St.length===0||wt||Dt)){at(),Et(!0);try{const d=[...St],m=await Promise.allSettled(d.map(async E=>({sessionId:E,session:await Nl(E,!0)}))),k=[];let A=0;for(const E of m){if(E.status==="fulfilled"){k.push(E.value.sessionId),H(E.value.session);continue}A+=1}k.length>0&&(await T(),ze(E=>E.filter(de=>!k.includes(de)))),A>0?J({title:k.length>0?r("shell.batchArchivePartialFailed"):r("shell.batchArchiveFailed"),tone:"error"}):J({title:r("shell.batchArchiveSuccess"),tone:"success"})}catch(d){J({title:d instanceof Error?d.message:r("shell.batchArchiveFailed"),tone:"error"})}finally{Et(!1)}}}async function Gr(){if(!bt||Dt)return;const{workspace:d,sessions:m}=bt,k=m.map(A=>A.sessionId);if(k.length===0){gt(null);return}Nr(!0),at();try{const A=await Promise.allSettled(k.map(async q=>(await Ko(q),q))),E=[];let de=0;for(const q of A){if(q.status==="fulfilled"){E.push(q.value);continue}de+=1}if(E.length>0&&(j&&E.includes(j)&&ae(d.id?Fs(d.id):jt()),ze(q=>q.filter(Ne=>!E.includes(Ne))),await T()),de>0){gt(q=>{if(!q)return q;const Ne=q.sessions.filter(Ke=>!E.includes(Ke.sessionId));return Ne.length>0?{...q,sessions:Ne}:null}),J({title:E.length>0?r("shell.batchDeletePartialFailed"):r("shell.batchDeleteFailed"),tone:"error"});return}gt(null),J({title:r("shell.batchDeleteSuccess"),tone:"success"})}catch(A){J({title:A instanceof Error?A.message:r("shell.batchDeleteFailed"),tone:"error"})}finally{Nr(!1)}}async function Qs(d){at();try{await W(d),J({title:r("shell.archiveRestored"),tone:"success"})}catch(m){J({title:m instanceof Error?m.message:r("shell.navigationLoadFailed"),tone:"error"})}}function er(d,m){at(),vs({session:d,workspace:m}),Qn(d.title)}async function Oa(d){if(d.preventDefault(),!Ft)return;const m=mn.trim();if(m){xs(Ft.session.sessionId);try{const k=await Ml(Ft.session.sessionId,m);H(k),vs(null),Qn(""),J({title:r("shell.renameSuccess"),tone:"success"})}catch(k){J({title:k instanceof Error?k.message:r("shell.renameFailed"),tone:"error"})}finally{xs(null)}}}const tr=a.slice(0,Vn),$a=tr.length<a.length;function wn(d){return t[d.id]??Ca(d)}function cs(d,m,k,A,E=[]){var Yt;const de=At.includes(d.id),q=x[d.id]??{detail:null,loading:!1,error:null},Ne=ie===d.id,Ke=Pn[d.id]===!0,Ve=(Yt=q.detail)!=null&&Yt.git.remotes.length?q.detail.git.remotes.map(He=>`${He.name}: ${He.url}`).join(" · "):r("shell.manageWorkspaceNoRemote"),ht=q.detail?zh(q.detail.codeComposition.items,r("shell.manageWorkspaceCodeCompositionOther")):[],Xt=ht.length>0?qh(ht):void 0,on=wn(d),we=Hm(on,E),vn=[...E,on.displayName];return n.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":on.tone,"data-worktree-node":A,style:yn(on),children:[n.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":de,onClick:()=>Ar(d.id),children:[n.jsxs("span",{className:"workbench-manage-item-heading",children:[n.jsx(fr,{expanded:de}),n.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[n.jsx("strong",{children:on.displayName}),n.jsx("span",{className:"workbench-manage-item-tree-path",children:we})]})]}),n.jsx("span",{className:"workbench-section-counter",children:m})]}),de?n.jsxs("div",{className:"workbench-manage-item-body",children:[n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspacePathLabel")}),n.jsx("p",{className:"workbench-manage-detail-value",children:d.path})]}),A?n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsxs("div",{className:"workbench-manage-detail-header",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceColorLabel")}),n.jsxs("div",{className:"workbench-manage-color-actions",children:[n.jsx("div",{className:"workbench-manage-color-palette","aria-label":r("shell.manageWorkspaceColorLabel"),children:nm.map(He=>n.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":r("shell.manageWorkspaceColorSelectSwatch",{color:He}),"aria-pressed":d.backgroundColor===He,disabled:Ke,"data-selected":d.backgroundColor===He,style:{backgroundColor:He},onClick:()=>{dt(d.id,He)}},He))}),n.jsx("button",{type:"button",className:"ghost-button",disabled:Ke||!d.backgroundColor,onClick:()=>{dt(d.id,null)},children:r("shell.manageWorkspaceColorClearAction")})]})]}),n.jsx("p",{className:"workbench-manage-hint",children:d.backgroundColor??r("shell.manageWorkspaceColorUnset")})]}):null,q.loading&&q.detail===null?n.jsx("p",{className:"workbench-manage-status status-text",children:r("shell.manageWorkspaceLoading")}):null,q.error?n.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:q.error}):null,q.detail?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-manage-detail-block",children:n.jsxs("div",{className:"workbench-manage-detail-header",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitCommitCount")}),n.jsx("strong",{className:"workbench-manage-detail-accent",children:q.detail.git.commitCount??"--"})]})}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitInfoLabel")}),q.detail.git.isRepository?n.jsxs("div",{className:"workbench-manage-kv-list",children:[n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:r("shell.manageWorkspaceRepoRoot")}),n.jsx("span",{children:q.detail.git.repoRoot??"--"})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:r("shell.manageWorkspaceCurrentBranch")}),n.jsx("span",{children:q.detail.git.currentBranch??"--"})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:r("shell.manageWorkspaceRemoteLabel")}),n.jsx("span",{children:Ve})]})]}):n.jsx("p",{className:"workbench-section-empty",children:q.detail.git.error??r("shell.manageWorkspaceNotGit")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceCodeCompositionLabel")}),ht.length>0?n.jsxs("div",{className:"workbench-manage-type-chart",children:[n.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Xt,"aria-hidden":"true",children:[n.jsx("strong",{className:"workbench-manage-type-chart-total",children:q.detail.codeComposition.scannedFileCount}),n.jsx("span",{className:"workbench-manage-type-chart-caption",children:r("shell.manageWorkspaceCodeCompositionFiles")})]}),n.jsx("div",{className:"workbench-manage-type-list",children:ht.map(He=>n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsxs("span",{className:"workbench-manage-type-meta",children:[n.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:He.color},"aria-hidden":"true"}),n.jsx("span",{className:"workbench-manage-type-name",children:He.type})]}),n.jsxs("span",{children:[He.count," · ",Gh(He)]})]},He.key))})]}):n.jsx("p",{className:"workbench-section-empty",children:q.detail.codeComposition.error??r("shell.manageWorkspaceNoCodeComposition")}),q.detail.codeComposition.truncated?n.jsx("p",{className:"workbench-manage-hint",children:r("shell.manageWorkspaceCodeTruncated",{count:q.detail.codeComposition.scannedFileCount})}):null]})]}):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Re(!1),ae(Hl(d.id))},children:r("shell.workspaceDetailDebugOpenPageAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!ie,onClick:()=>R(d),children:Ne?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveAction")})]})]}):null,k.length>0?n.jsx("div",{className:"workbench-manage-children",children:k.map(He=>cs(He.workspace,He.visibleSessions.length+He.archivedSessions.length,He.children,!0,vn))}):null]},d.id)}return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":We,children:n.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":We,children:[oe?n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideSessionSidebar"),title:r("shell.hideSessionSidebar"),onClick:oe,children:n.jsx(Gc,{})}):null,n.jsx(mc,{}),n.jsx(Uc,{unreadCount:$,open:se,onToggle:Me})]})}),n.jsxs("div",{ref:ge,className:"workbench-nav-body","data-scrollbar-autohide":"true",children:[n.jsxs("div",{className:"workbench-nav-segment",children:[n.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":r("shell.centerTabsLabel"),children:[n.jsxs("div",{className:"workbench-nav-segment-pair",children:[n.jsxs("button",{type:"button",className:p?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":p,onClick:O,children:[n.jsx(af,{}),n.jsx("span",{children:r("shell.conversationEntry")})]}),n.jsxs("button",{type:"button",className:g?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":g,onClick:v,children:[n.jsx(lf,{}),n.jsx("span",{children:r("shell.butlerEntry")})]})]}),n.jsxs("button",{type:"button",className:h?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":h,onClick:L,children:[n.jsx(of,{}),n.jsx("span",{children:r("shell.terminalsEntry")})]})]}),n.jsx(fh,{triggerClassName:"workbench-nav-segment-button",triggerLabel:r("shell.skillsEntry"),triggerLeading:n.jsx(cf,{})}),n.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":f,"aria-haspopup":"dialog","aria-expanded":f,onClick:K,children:[n.jsx(rf,{}),n.jsx("span",{children:r("shell.searchEntry")})]})]}),N?n.jsx("div",{className:"workbench-status-row",children:n.jsx("p",{className:"status-text","data-tone":"error",children:N})}):null,a.length>0?n.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[n.jsxs("div",{className:"workbench-section-heading",children:[n.jsxs("div",{className:"workbench-section-heading-main",children:[n.jsx(zc,{active:!0,className:"workbench-favorite-heading-icon"}),n.jsx("span",{children:r("shell.favoriteSectionTitle")})]}),n.jsx("span",{className:"workbench-section-counter",children:a.length})]}),n.jsxs("div",{className:"workbench-session-list",children:[tr.map(d=>{const m=Js(d.session.sessionId);return n.jsx("div",{children:Rs({node:{item:d.session,depth:0,children:m},workspace:d.workspace,workspaceContext:wn(d.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},d.session.sessionId)}),$a?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:Wa,children:r("shell.favoriteExpandMore")}):null]})]}):null,w&&e.length===0?n.jsx(Jm,{}):null,!w&&!N&&e.length===0?n.jsx("div",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:r("shell.emptyNavigationBody")})}):null,n.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[n.jsxs("div",{className:"workbench-section-heading",children:[n.jsx("div",{className:"workbench-section-heading-main",children:n.jsx("span",{children:r("shell.workspaceSectionTitle")})}),n.jsxs("div",{className:"workbench-section-actions",children:[n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.manageWorkspaceAction"),title:r("shell.manageWorkspaceAction"),onClick:()=>Re(!0),children:n.jsx(ef,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.importWorkspaceTitle"),title:r("shell.importWorkspaceTitle"),onClick:qt,children:n.jsx(Qm,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.cloneWorkspaceTitle"),title:r("shell.cloneWorkspaceTitle"),onClick:ns,children:n.jsx(df,{})})]})]}),e.map(d=>{const m=pr(d),k=Ss===d.workspace.id,A=d.isCollapsed||Tr;return n.jsxs("section",{className:"workbench-workspace-group",ref:E=>rs(d.workspace.id,E),"data-workspace-group-id":d.workspace.id,"data-batch-active":kt===d.workspace.id,"data-dragging":k,onDragOver:E=>Fo(E,d.workspace.id),onDrop:Vt,children:[n.jsxs("div",{className:"workbench-workspace-header minimal",children:[n.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":A?r("shell.workspaceExpand"):r("shell.workspaceCollapse"),draggable:y&&!Gt,onClick:()=>Ns(d.workspace.id),onPointerDown:Gt?E=>as(E,d.workspace.id):void 0,onPointerMove:Gt?os:void 0,onPointerUp:Gt?Wr:void 0,onPointerCancel:Gt?Is:void 0,onDragStart:y&&!Gt?E=>Ms(E,d.workspace.id):void 0,onDragEnd:y&&!Gt?bn:void 0,"data-reorder-enabled":y?"true":void 0,children:[n.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:n.jsx(fr,{expanded:!A})}),n.jsx("strong",{children:d.workspace.name})]}),kt===d.workspace.id?Fr():Zs(d.workspace.id)]}),A?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-session-list",children:[m.length===0?n.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):m.slice(0,gn(d.workspace.id)).map(E=>Rs({node:E,workspace:d.workspace,workspaceContext:wn(d.workspace),menuKeyPrefix:`workspace:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:kt===d.workspace.id,favoriteEnabled:!0})),m.length>gn(d.workspace.id)?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>$t(d.workspace.id,m.length),children:r("shell.sessionExpandMore")}):null]}),d.childWorktrees.length>0?n.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.childWorktrees.map(E=>Or(E))}):null,_r(d.workspace,d.archivedSessions)]})]},d.workspace.id)})]})]}),n.jsx("div",{className:"workbench-nav-footer minimal",children:n.jsxs("div",{className:"workbench-nav-footer-actions",children:[n.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:F,title:S?`${r("settings.title")} · ${Ye}`:r("settings.title"),children:[n.jsx(uf,{}),n.jsx("span",{className:"settings-entry-label",children:r("settings.title")}),S?n.jsx("span",{className:"workbench-nav-settings-host-badge",title:Ye,children:Ye}):null]}),n.jsx(Dp,{onOpenSoftwareUpdate:()=>ae("/settings/software-update")})]})}),n.jsx(nt,{open:je,title:r("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:r("shell.manageWorkspaceDescription"),headerActions:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:qt,children:r("shell.manageWorkspaceImportAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:ns,children:r("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{ie||Re(!1)},children:e.length>0?n.jsx("div",{className:"workbench-manage-list",children:e.map(d=>cs(d.workspace,d.visibleSessions.length+d.archivedSessions.length,d.childWorktrees,!1))}):n.jsx("p",{className:"workbench-section-empty",children:r("shell.manageWorkspaceEmpty")})}),n.jsxs(nt,{open:Bt!==null,title:r("shell.deleteSessionConfirmTitle"),description:r("shell.deleteSessionConfirmDescription"),onClose:()=>{zn||Mn(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:Bt?Bt.session.title:""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!zn,onClick:()=>Mn(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!zn,onClick:()=>{Hr()},children:zn?r("common.loading"):r("shell.deleteSessionAction")})]})]}),n.jsxs(nt,{open:bt!==null,title:r("shell.batchDeleteConfirmTitle"),description:r("shell.batchDeleteConfirmDescription",{count:`${(bt==null?void 0:bt.sessions.length)??0}`}),onClose:()=>{Dt||gt(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:bt?r("shell.batchDeleteSelectionSummary",{count:`${bt.sessions.length}`}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:Dt,onClick:()=>gt(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:Dt,onClick:()=>{Gr()},children:Dt?r("shell.batchDeleting"):r("shell.batchDeleteAction")})]})]}),n.jsxs(nt,{open:_!==null,title:r("shell.manageWorkspaceRemoveConfirmTitle"),description:r("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{ie||R(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:_?r("shell.manageWorkspaceRemoveConfirmTarget",{name:_.name}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!ie,onClick:()=>R(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!ie,onClick:()=>{Ze()},children:ie?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveConfirmAction")})]})]}),n.jsx(Mp,{open:U,onClose:()=>Ce(!1),onCloned:Pr}),n.jsx(Bp,{open:I,onClose:()=>Z(!1),onImported:Er}),n.jsx(Gp,{open:st!==null,source:st,onClose:()=>vt(null),onCreated:async d=>{d.members.forEach(k=>{H(k.session)}),au(d.group.id),await T();const m=d.members.find(k=>k.session.sessionId===d.group.anchorSessionId)??d.members[0]??null;m&&ae(Ut(su(m.session,m.sessionIsolatedWorkspace),m.session.sessionId)),vt(null),J({title:r("shell.parallelCreateSucceeded"),tone:"success"})}}),n.jsx(nt,{open:De!==null,title:r("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:De?`${r("shell.createSessionTarget")} · ${De.name}`:r("shell.createSessionModalDescription"),headerActions:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"primary-button create-session-parallel-trigger",disabled:ft||!!pe||!De,onClick:()=>{De&&Vs(De)},children:r("shell.parallelCreateAction")}),n.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:ft||!!pe,onClick:()=>Je(!0),children:r("shell.createWorktreeAction")})]}),onClose:()=>it(null),children:n.jsxs("section",{className:"create-session-modal-section",children:[n.jsx("div",{className:"create-session-modal-section-header",children:n.jsx("strong",{children:r("shell.createSessionProviderLabel")})}),n.jsx(Rd,{disabled:!!pe||ft,workspaceId:(De==null?void 0:De.id)??null,pendingProvider:pe===(De==null?void 0:De.id)?Qe??null:null,onSelect:d=>{De&&Fa(De.id,d)}})]})}),n.jsx(nt,{open:De!==null&&Rt,title:r("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:n.jsx("button",{type:"button",className:gs?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":r("shell.createWorktreeHelpAction"),title:r("shell.createWorktreeHelpAction"),"aria-pressed":gs,onClick:()=>Gn(d=>!d),children:n.jsx(wf,{})}),description:De?`${r("shell.createWorktreeSectionDescription")} ${r("shell.createSessionTarget")} · ${De.name}`:r("shell.createWorktreeSectionDescription"),onClose:Bn,children:n.jsxs("form",{className:"create-session-worktree-form",onSubmit:kn,children:[gs?n.jsxs("section",{className:"create-session-worktree-help-card","aria-label":r("shell.createWorktreeHelpTitle"),children:[n.jsx("strong",{children:r("shell.createWorktreeHelpTitle")}),n.jsxs("div",{className:"create-session-worktree-help-grid",children:[n.jsxs("article",{children:[n.jsx("h3",{children:r("shell.createWorktreeHelpBranchTitle")}),n.jsx("p",{children:r("shell.createWorktreeHelpBranchBody")})]}),n.jsxs("article",{children:[n.jsx("h3",{children:r("shell.createWorktreeHelpDisplayNameTitle")}),n.jsx("p",{children:r("shell.createWorktreeHelpDisplayNameBody")})]}),n.jsxs("article",{children:[n.jsx("h3",{children:r("shell.createWorktreeHelpBaseRefTitle")}),n.jsx("p",{children:r("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:r("shell.createWorktreeBranchLabel")}),n.jsx("input",{className:"settings-text-input",value:lt,placeholder:r("shell.createWorktreeBranchPlaceholder"),onChange:d=>{const m=d.target.value;hm(m)&&qe(m)}})]}),n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:r("shell.createWorktreeDisplayNameLabel")}),n.jsx("input",{className:"settings-text-input",value:Fe,placeholder:r("shell.createWorktreeDisplayNamePlaceholder"),onChange:d=>Lt(d.target.value)})]}),n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:r("shell.createWorktreeBaseRefLabel")}),n.jsx("div",{className:"create-session-worktree-combobox",ref:nn,onBlurCapture:d=>{var k,A;const m=d.relatedTarget;m instanceof Node&&((k=nn.current)!=null&&k.contains(m)||(A=Ot.current)!=null&&A.contains(m))||(yt(!1),ct(-1))},children:n.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[n.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":xt,"aria-controls":Ie,value:Be,placeholder:r("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{yt(!0),ct(Ct.length>0?0:-1)},onChange:d=>{jn(d.target.value),yt(!0),ct(Ct.length>0?0:-1)},onKeyDown:d=>{if(d.key==="ArrowDown"){if(d.preventDefault(),!xt){yt(!0);return}Ct.length>0&&ct(m=>m>=Ct.length-1?0:m+1);return}if(d.key==="ArrowUp"){if(d.preventDefault(),!xt){yt(!0);return}Ct.length>0&&ct(m=>m<=0?Ct.length-1:m-1);return}if(d.key==="Enter"&&xt&&Gs>=0){d.preventDefault();const m=Ct[Gs];m&&(jn(m.value),yt(!1),ct(-1));return}d.key==="Escape"&&yt(!1)}}),n.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":r("shell.createWorktreeBaseRefToggle"),"aria-expanded":xt,onClick:()=>{yt(d=>!d),ct(!xt&&Ct.length>0?0:-1)},children:n.jsx(fr,{expanded:xt})})]})}),n.jsx("span",{className:"create-session-worktree-field-hint",children:ks?r("shell.createWorktreeBaseRefLoading"):Cn||r("shell.createWorktreeBaseRefHint",{localCount:$e.localBranches.length,remoteCount:$e.remoteBranches.length,tagCount:$e.tags.length})})]}),xt&&en&&typeof document<"u"?Os.createPortal(n.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[n.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${en.top}px`,"--create-worktree-combobox-left":`${en.left}px`,"--create-worktree-combobox-width":`${en.width}px`,"--create-worktree-combobox-height":`${zs??0}px`}}),n.jsx("div",{ref:Ot,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${en.top}px`,"--create-worktree-combobox-left":`${en.left}px`,"--create-worktree-combobox-width":`${en.width}px`},children:ks?n.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefLoading")}):Cn?n.jsx("p",{className:"create-session-worktree-combobox-empty",children:Cn}):Wn.length>0?n.jsx("div",{id:Ie,className:"create-session-worktree-combobox-list",role:"listbox",children:Wn.map(d=>n.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":d.label,children:[n.jsx("header",{className:"create-session-worktree-combobox-group-title",children:d.label}),n.jsx("div",{className:"create-session-worktree-combobox-group-options",children:d.items.map(m=>{const k=Ct.findIndex(de=>de.value===m.value),A=Be===m.value,E=Gs===k;return n.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":A,"data-highlighted":E,onMouseDown:de=>de.preventDefault(),onMouseEnter:()=>ct(k),onClick:()=>{jn(m.value),yt(!1),ct(-1)},children:[n.jsx("span",{className:"create-session-worktree-combobox-option-label",children:m.value}),n.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[m.current?n.jsx("span",{className:"create-session-worktree-combobox-badge",children:r("shell.createWorktreeBaseRefCurrentBadge")}):null,m.recommended?n.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:r("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${d.key}:${m.value}`)})})]},d.key))}):n.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:ft,onClick:Bn,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:ft,children:ft?r("shell.createWorktreeSubmitting"):r("shell.createWorktreeSubmit")})]})]})}),n.jsx(nt,{open:Xe!==null,title:r("shell.archiveModalTitle"),description:Xe?`${Xe.workspace.name} · ${r("shell.archiveModalDescription")}`:r("shell.archiveModalDescription"),onClose:()=>Cr(null),children:Xe&&Xe.archivedSessions.length>0?n.jsx("div",{className:"workbench-archive-list","data-workspace-tone":(Ee==null?void 0:Ee.tone)??"root",style:yn(Ee),children:Xe.archivedSessions.map(d=>{const m=Lo(d.title,r("common.unknown"));return n.jsxs("article",{className:"workbench-archive-item","data-workspace-tone":(Ee==null?void 0:Ee.tone)??"root",style:yn(Ee),children:[n.jsxs("div",{className:"workbench-archive-item-main",children:[n.jsx("strong",{title:m.fullTitle,children:m.displayTitle}),n.jsxs("p",{children:[jc(d,Xe.workspace,!1)," ·"," ",Ea(d.provider)]})]}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>Qs(d.sessionId),children:r("shell.unarchiveAction")})]},d.sessionId)})}):n.jsx("p",{className:"workbench-section-empty",children:r("shell.archiveEmpty")})}),n.jsx(nt,{open:Ft!==null,title:r("shell.renameModalTitle"),description:r("shell.renameModalDescription"),onClose:()=>{fn||(vs(null),Qn(""))},children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:Oa,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.renameInputLabel")}),n.jsx("input",{type:"text",value:mn,placeholder:r("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:d=>Qn(d.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!fn,onClick:()=>{vs(null),Qn("")},children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:!mn.trim()||fn===(Ft==null?void 0:Ft.session.sessionId),children:fn===(Ft==null?void 0:Ft.session.sessionId)?r("shell.renamingSession"):r("common.save")})]})]})})]})}function bl({panelReady:e,activeTab:t,fileRevealRequest:s,onTabChange:a,onToggleCollapse:o,currentSessionId:c,activeWorkspaceId:p,navigationGroups:h,workspaceContext:g,worktreeMeta:f,worktreeMergeState:w,onRefreshWorktreeMergePreview:N,onApplyWorktreeMerge:j,onCleanupWorktree:T}){var ue;const H=p??((ue=h[0])==null?void 0:ue.workspace.id)??null,O=Hn(),L=tc(O),{showToast:v}=fs(),K=gc(),F=i.useRef(null),te=i.useRef(null),M=O.isDesktop&&O.bridge.supported,X=M&&!!p,V=M&&!!H,D=M&&!!H,y=typeof globalThis<"u"&&"PointerEvent"in globalThis,Y=i.useCallback(async(ne,W,x)=>{if(ne==="files"){const $=await ch(O,{workspaceId:W,sessionId:x,focusOwner:"file-context-panel"});$.ok||v({title:$.detail??r("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(ne==="git"){const $=await dh(O,{workspaceId:W,focusOwner:"git-sidebar"});$.ok||v({title:$.detail??r("git.openExternalFailed"),tone:"error"});return}const C=await uh(O,{workspaceId:W,focusOwner:"terminal-manager-panel"});C.ok||v({title:C.detail??r("terminalManager.openExternalFailed"),tone:"error"})},[O,v]),Q=i.useCallback((ne,W)=>{if(ne.button!==0||!M)return;const x=W==="files"?p:W==="git"||W==="terminals"?H:null;if(!x)return;const C=W==="files"?c:null;F.current={tab:W,startX:ne.clientX,startY:ne.clientY,workspaceId:x,sessionId:C,detached:!1,preview:null};const $=oe=>{var J;const ae=F.current;if(!ae)return;const he=Math.abs(oe.clientX-ae.startX),We=Math.abs(oe.clientY-ae.startY);!ae.detached&&Math.max(he,We)<Xi||(ae.detached||(ae.detached=!0,te.current=ae.tab,ae.preview=hi({title:ae.tab==="files"?r("shell.filesEntry"):ae.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:oe.clientX,y:oe.clientY})),(J=ae.preview)==null||J.updatePosition(oe.clientX,oe.clientY))},se=oe=>{var he;const ae=(he=F.current)==null?void 0:he.preview;oe&&(ae==null||ae.cancel()),window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",Me),window.removeEventListener("blur",xe),F.current=null},Me=async()=>{var ae;const oe=F.current;se(!1),oe!=null&&oe.detached&&(await((ae=oe.preview)==null?void 0:ae.complete()),await Y(oe.tab,oe.workspaceId,oe.sessionId))},xe=()=>{se(!0)};window.addEventListener("mousemove",$),window.addEventListener("mouseup",Me),window.addEventListener("blur",xe)},[p,M,c,H,Y]),B=i.useCallback((ne,W)=>{if(ne.button!==0||!M)return;const x=W==="files"?p:W==="git"||W==="terminals"?H:null;if(!x)return;const C=ne.currentTarget,$=ne.pointerId;C.setPointerCapture($);const se=W==="files"?c:null;F.current={tab:W,startX:ne.clientX,startY:ne.clientY,workspaceId:x,sessionId:se,detached:!1,preview:null};const Me=We=>{var Ye;if(We.pointerId!==$)return;const J=F.current;if(!J)return;const ge=Math.abs(We.clientX-J.startX),Te=Math.abs(We.clientY-J.startY);!J.detached&&Math.max(ge,Te)<Xi||(J.detached||(J.detached=!0,te.current=J.tab,J.preview=hi({title:J.tab==="files"?r("shell.filesEntry"):J.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:We.clientX,y:We.clientY})),(Ye=J.preview)==null||Ye.updatePosition(We.clientX,We.clientY))},xe=We=>{var ge;const J=(ge=F.current)==null?void 0:ge.preview;We&&(J==null||J.cancel()),C.removeEventListener("pointermove",Me),C.removeEventListener("pointerup",oe),C.removeEventListener("pointercancel",ae),C.removeEventListener("lostpointercapture",ae),window.removeEventListener("blur",he),F.current=null,C.hasPointerCapture($)&&C.releasePointerCapture($)},oe=async We=>{var ge;if(We.pointerId!==$)return;const J=F.current;xe(!1),J!=null&&J.detached&&(await((ge=J.preview)==null?void 0:ge.complete()),await Y(J.tab,J.workspaceId,J.sessionId))},ae=We=>{We.pointerId===$&&xe(!0)},he=()=>{xe(!0)};C.addEventListener("pointermove",Me),C.addEventListener("pointerup",oe),C.addEventListener("pointercancel",ae),C.addEventListener("lostpointercapture",ae),window.addEventListener("blur",he)},[p,M,c,H,Y]),me=i.useCallback(ne=>{if(te.current===ne){te.current=null;return}a(ne)},[a]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(g==null?void 0:g.tone)??"root",style:yn(g),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":L,children:[o?n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideInfoSidebar"),title:r("shell.hideInfoSidebar"),onClick:o,children:n.jsx(Gc,{})}):null,n.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":r("shell.infoTabsLabel"),"data-tauri-drag-region":L,children:[n.jsx("button",{className:t==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="files",title:X?"拖拽标签到独立窗口":void 0,onPointerDown:ne=>B(ne,"files"),onMouseDown:y?void 0:ne=>Q(ne,"files"),onClick:()=>me("files"),children:r("shell.filesEntry")}),n.jsx("button",{className:t==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="git",title:V?"拖拽标签到独立窗口":void 0,onPointerDown:ne=>B(ne,"git"),onMouseDown:y?void 0:ne=>Q(ne,"git"),onClick:()=>me("git"),children:r("shell.gitEntry")}),n.jsx("button",{className:t==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="terminals",title:D?"拖拽标签到独立窗口":void 0,onPointerDown:ne=>B(ne,"terminals"),onMouseDown:y?void 0:ne=>Q(ne,"terminals"),onClick:()=>me("terminals"),children:r("shell.terminalManagerEntry")})]})]}),n.jsxs("div",{ref:K,className:"workbench-auxiliary-body","data-scrollbar-autohide":"true",children:[e?null:n.jsx(ma,{}),e&&t==="git"&&f?n.jsx(xf,{meta:f,state:w,onRefresh:()=>N(f.workspaceId,!0),onApply:()=>j(f.workspaceId),onCleanup:()=>T(f)}):null,e&&t==="files"?p?n.jsx(i.Suspense,{fallback:n.jsx(ma,{}),children:n.jsx(ym,{sessionId:c,workspaceId:p,externalRevealRequest:s})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:r("shell.filesPanelEmpty")})}):null,e&&t==="git"?H?n.jsx(i.Suspense,{fallback:n.jsx(ma,{}),children:n.jsx(Sm,{workspaceId:H})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:r("shell.gitPanelEmpty")})}):null,e&&t==="terminals"?n.jsx(i.Suspense,{fallback:n.jsx(ma,{}),children:n.jsx(jm,{currentWorkspaceId:p,navigationGroups:h})}):null]})]})}function xf({meta:e,state:t,onRefresh:s,onApply:a,onCleanup:o}){const[c,p]=i.useState(!1),h=(t==null?void 0:t.preview)??null,g=(t==null?void 0:t.loading)??!1,f=(t==null?void 0:t.applying)??!1,w=(t==null?void 0:t.cleaning)??!1,N=h!==null,j=(h==null?void 0:h.alreadyMerged)===!0,T=new Set((h==null?void 0:h.blockers.map(B=>B.code))??[]),H=T.size>0||!!(t!=null&&t.error),O=j&&!H,L=(h==null?void 0:h.canMerge)===!0&&!g&&!f&&!w&&!O,v=O&&!g&&!f&&!w&&!T.has("SOURCE_DIRTY")&&!T.has("HAS_ACTIVE_CHILDREN"),K=g||f||w?"loading":H?"blocked":O?"merged":h!=null&&h.canMerge?"ready":N?"blocked":"idle",F=(h==null?void 0:h.targetWorkspace.name)??r("common.unknown"),te=(h==null?void 0:h.sourceBranchName)??e.branchName,M=(h==null?void 0:h.targetBranchName)??e.baseRef??r("common.unknown"),X=Sf({t:r,hasPreview:N,showMergedState:O,isMerged:j,canMerge:(h==null?void 0:h.canMerge)===!0,ahead:(h==null?void 0:h.ahead)??0,blockerCodeSet:T}),V=g?r("shell.worktreeMergePreviewLoading"):f?r("shell.worktreeMergeApplying"):w?r("shell.worktreeCleanupRunning"):O?r("shell.worktreeMergeAlreadyMerged"):h!=null&&h.canMerge?r("shell.worktreeMergeReady"):N?r("shell.worktreeMergeBlocked"):r("shell.worktreeMergePreviewIdle"),D=[r("shell.worktreeMergeCurrentBranch",{branch:te}),r("shell.worktreeMergeParentBranch",{branch:M}),r("shell.worktreeMergeTargetWorkspace",{name:F}),h?r("shell.worktreeMergeAheadBehind",{ahead:h.ahead,behind:h.behind}):r("shell.worktreeMergeAheadBehindPending"),h!=null&&h.mergeBaseCommit?r("shell.worktreeMergeBaseCommit",{commit:Xm(h.mergeBaseCommit)}):null].filter(B=>!!B),y=`worktree-merge-panel-details-${e.workspaceId}`,Y=c?r("shell.worktreeMergeCollapseDetails"):r("shell.worktreeMergeExpandDetails"),Q=yf({t:r,loading:g,applying:f,cleaning:w,hasPreview:N,canMerge:(h==null?void 0:h.canMerge)===!0,showMergedState:O,blockerCodeSet:T});return i.useEffect(()=>{p(!1)},[e.workspaceId]),n.jsxs("section",{className:"worktree-merge-panel","data-state":K,children:[n.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":Y,"aria-expanded":c,"aria-controls":y,onClick:()=>{p(B=>!B)},children:[n.jsx("span",{className:"worktree-merge-panel-summary-label",children:r("shell.worktreeMergePanelLabel")}),n.jsx("span",{className:"worktree-merge-panel-summary-main",children:n.jsx("span",{className:"worktree-merge-panel-summary-tags",children:Q.map(B=>n.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":K,children:B},B))})}),n.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:Y})]}),c?n.jsxs("div",{id:y,className:"worktree-merge-panel-details",children:[n.jsx("div",{className:"worktree-merge-panel-detail-head",children:n.jsx("span",{className:"worktree-merge-panel-status","data-state":K,children:V})}),n.jsx("div",{className:"worktree-merge-panel-meta",children:D.map(B=>n.jsx("span",{children:B},B))}),N?n.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":r("shell.worktreeMergeChecklistTitle"),children:X.map(B=>n.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":B.state,children:[n.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:B.state==="done"?"✓":B.state==="blocked"?"!":"·"}),n.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[n.jsx("strong",{children:B.label}),B.detail?n.jsx("span",{children:B.detail}):null]})]},B.key))}):null,t!=null&&t.error?n.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:t.error}):null,h!=null&&h.conflictPaths.length?n.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[n.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:r("shell.worktreeMergeConflictLabel")}),n.jsx("div",{className:"worktree-merge-panel-conflict-list",children:h.conflictPaths.map(B=>n.jsx("code",{children:B},B))})]}):null,n.jsxs("div",{className:"worktree-merge-panel-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:g||f||w,onClick:s,children:N?r("shell.worktreeMergePreviewRefresh"):r("shell.worktreeMergePreviewAction")}),n.jsx("button",{type:"button",className:"primary-button",disabled:!L,onClick:a,children:f?r("shell.worktreeMergeApplying"):r("shell.worktreeMergeApplyAction")}),n.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!v,onClick:o,children:w?r("shell.worktreeCleanupRunning"):r("shell.worktreeCleanupAction")})]})]}):null]})}function yf(e){const{t,loading:s,applying:a,cleaning:o,hasPreview:c,canMerge:p,showMergedState:h,blockerCodeSet:g}=e;if(s)return[t("shell.worktreeMergeCompactChecking")];if(a)return[t("shell.worktreeMergeCompactMerging")];if(o)return[t("shell.worktreeMergeCompactCleaning")];const f=[];return g.has("SOURCE_NOT_ACTIVE")&&f.push(t("shell.worktreeMergeCompactInactive")),g.has("SOURCE_DIRTY")&&f.push(t("shell.worktreeMergeCompactDirty")),g.has("TARGET_DIRTY")&&f.push(t("shell.worktreeMergeCompactTargetDirty")),g.has("HAS_CONFLICTS")&&f.push(t("shell.worktreeMergeCompactConflict")),g.has("HAS_ACTIVE_CHILDREN")&&f.push(t("shell.worktreeMergeCompactChildren")),f.length>0?f:p?[t("shell.worktreeMergeCompactReady")]:h?[t("shell.worktreeMergeCompactMerged")]:c?g.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function Sf(e){const{t,hasPreview:s,showMergedState:a,isMerged:o,canMerge:c,ahead:p,blockerCodeSet:h}=e,g=h.has("SOURCE_NOT_ACTIVE"),f=h.has("SOURCE_DIRTY"),w=h.has("TARGET_DIRTY"),N=h.has("HAS_ACTIVE_CHILDREN"),j=h.has("HAS_CONFLICTS"),T=s&&!o&&(h.has("NO_COMMITS_TO_MERGE")||p<=0),H=a?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:c?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultReady"),detail:t("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:s?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultBlocked"),detail:t("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:t("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:t("shell.worktreeMergeChecklistSourceState"),detail:s&&g?t("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:s?g?"blocked":"done":"pending"},{key:"clean-source",label:t("shell.worktreeMergeChecklistSourceClean"),detail:s&&f?t("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:s?f?"blocked":"done":"pending"},{key:"clean-target",label:t("shell.worktreeMergeChecklistTargetClean"),detail:s&&w?t("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:s?w?"blocked":"done":"pending"},{key:"children",label:t("shell.worktreeMergeChecklistChildren"),detail:s&&N?t("shell.worktreeMergeChecklistChildrenBlocked"):null,state:s?N?"blocked":"done":"pending"},{key:"commits",label:t("shell.worktreeMergeChecklistCommits"),detail:T?t(o?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:T?o?"done":"blocked":s?"done":"pending"},{key:"conflicts",label:t("shell.worktreeMergeChecklistConflicts"),detail:j?t("shell.worktreeMergeChecklistConflictsBlocked"):null,state:j?"blocked":s?"done":"pending"},H]}function $b({shellMode:e="desktop"}){var vn,Yt,He,Kr,ds,qr,Vr,Xr,nr,sr,rr,Mt,Tt,ar,or,Oo,$o,Ho;const t=Ia(),s=vr(),a=Hn(),{showToast:o}=fs(),c=Yr(l=>l.sessionDisplaySortMode),p=Yr(l=>l.notificationPreferences.notifyOnPermissionRequest),h=Yr(l=>l.notificationPreferences.notifyOnSessionCompleted),g=Yr(l=>l.notificationPreferences.notifyOnSessionFailed),f=i.useRef(Qh(dc)),w=i.useRef(0),N=i.useRef((((Yt=(vn=f.current)==null?void 0:vn.items)==null?void 0:Yt.length)??0)>0),j=i.useRef(new Map),T=i.useRef(!1),H=i.useRef(null),O=i.useRef(0),L=i.useRef(null),v=i.useRef(null),K=i.useRef(new Set),F=i.useRef(new Set),te=i.useRef(new Set),M=i.useRef(new Set),X=i.useRef(null),V=i.useRef(null),D=i.useRef(null),y=i.useRef(null),Y=i.useRef(null),Q=i.useRef(null),B=i.useRef(null),me=i.useRef(null),ue=i.useRef(0),ne=i.useRef(0),W=i.useRef(o),x=i.useRef(a.bridge),C=i.useRef(null),$=i.useRef(0),se=i.useRef(0),Me=i.useRef(null),xe=i.useRef(null),oe=i.useRef(null),ae=i.useRef(!1),he=i.useRef(!1),We=i.useRef(!1),J=i.useRef(new Map),ge=i.useRef(!1),Te=i.useRef(new Map),Ye=i.useRef(""),S=i.useRef([]),I=i.useRef(c),Z=i.useRef(null),[U,Ce]=i.useState(()=>yi(f.current,c)),je=i.useRef(U),[Re,At]=i.useState(()=>{var l,u;return(((u=(l=f.current)==null?void 0:l.items)==null?void 0:u.length)??0)===0}),[mt,_]=i.useState(null),[R,ie]=i.useState(()=>ha(nl(_i,Kp),Ui,zi)),[ce,pe]=i.useState(()=>ha(nl(Fi,qp),Gi,Ki)),[ke,Qe]=i.useState(()=>sl(Oi,!1)),[Ae,et]=i.useState(()=>sl($i,!1)),[it,st]=i.useState(null),[vt,Wt]=i.useState(null),[rt,Rt]=i.useState(()=>il(f.current)),[Je,ft]=i.useState(()=>rl(eo)),[Se,lt]=i.useState(!1),[qe,Fe]=i.useState("files"),[Lt,Be]=i.useState(!1),[jn,$e]=i.useState(!1),[Un,xt]=i.useState(null),[yt,Gs]=i.useState({}),[ct,gs]=i.useState(!1),[Gn,ks]=i.useState("sessions"),[pn,Cn]=i.useState(""),[Nn,en]=i.useState(""),[jr,zs]=i.useState(!1),[Ks,In]=i.useState(null),[Cr,Bt]=i.useState([]),[Mn,zn]=i.useState(null),[Kn,bt]=i.useState({}),gt=ec(a),Dt=i.useCallback(l=>{if(gt)return;const u=C.current;u&&(!co(a,l.button,l.target)||!al(l.clientY,u)||Qu({platform:a,button:l.button,target:l.target,clientX:l.clientX,clientY:l.clientY}))},[a,gt]),Nr=i.useCallback(l=>{if(gt)return;const u=C.current;u&&(!co(a,l.button,l.target)||!al(l.clientY,u)||a.bridge.setWindowState("toggle-zoom"))},[a,gt]),[tt,_t]=i.useState({}),[Oe,qn]=i.useState(null),[Vn,Tn]=i.useState(!1),[Xn,ws]=i.useState([]),[Yn,Jn]=i.useState(()=>new Set),[Rn,tn]=i.useState(!1),[En,Zn]=i.useState(!1),[Ft,vs]=i.useState(0),[mn,Qn]=i.useState(()=>rl(Hi)),fn=e==="desktop"&&a.isDesktop&&a.ui.osFamily==="macos"&&a.ui.prefersOverlayTitlebar,{theme:xs}=id();i.useEffect(()=>{W.current=o},[o]),i.useEffect(()=>{if(typeof document>"u")return;const{documentElement:l,body:u}=document,b=document.getElementById("root");if(!fn){l.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy");return}const P=l.style.background,G=(u==null?void 0:u.style.background)??"",z=(b==null?void 0:b.style.background)??"";return l.setAttribute("data-workbench-macos-vibrancy","true"),u==null||u.setAttribute("data-workbench-macos-vibrancy","true"),l.style.background="transparent",u==null||u.style.setProperty("background","transparent"),b==null||b.style.setProperty("background","transparent"),()=>{l.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy"),l.style.background=P,u&&(u.style.background=G),b instanceof HTMLElement&&(b.style.background=z)}},[fn]),i.useEffect(()=>()=>{oe.current!==null&&window.clearTimeout(oe.current)},[]),i.useEffect(()=>{var G;if(typeof document>"u")return;const{documentElement:l,body:u}=document;if(!vt){l.removeAttribute(Ps),u==null||u.removeAttribute(Ps);return}const b=l.style.cursor,P=(u==null?void 0:u.style.cursor)??"";return l.setAttribute(Ps,vt),u==null||u.setAttribute(Ps,vt),l.style.cursor="col-resize",u==null||u.style.setProperty("cursor","col-resize"),(G=window.getSelection())==null||G.removeAllRanges(),()=>{l.removeAttribute(Ps),u==null||u.removeAttribute(Ps),l.style.cursor=b,u&&(u.style.cursor=P)}},[vt]),i.useEffect(()=>{I.current=c,Ce(l=>Ym(l,c))},[c]),i.useEffect(()=>{je.current=U},[U]),i.useEffect(()=>{x.current=a.bridge},[a.bridge]),i.useEffect(()=>{$.current=R},[R]),i.useEffect(()=>{se.current=ce},[ce]),i.useEffect(()=>()=>{Me.current!==null&&window.cancelAnimationFrame(Me.current)},[]);const kt=i.useCallback(async()=>{const l=ue.current+1;ue.current=l;try{const u=await op();if(l!==ue.current)return;if(!u.initialized){ws([]),Jn(new Set);return}const[b,P,G,z]=await Promise.all([ip(),dp(),pc(),hp()]);if(l!==ue.current)return;ws(cm(b.overview,P.items,G.items)),Jn(new Set(z.items.map(le=>le.notificationId)))}catch{if(l!==ue.current)return;ws([]),Jn(new Set)}},[]),es=i.useCallback(l=>{const u=l.map(b=>b.createdAt).sort((b,P)=>$n(P)-$n(b))[0]??null;u&&Qn(b=>b&&$n(b)>=$n(u)?b:u)},[]);i.useEffect(()=>{mn&&hs(Hi,mn)},[mn]),i.useEffect(()=>{kt();const l=window.setInterval(()=>{kt()},Xp);return()=>{window.clearInterval(l)}},[kt]),i.useEffect(()=>{pt("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),i.useEffect(()=>{var l,u;pt("workbench.cached_snapshot_loaded",{cached:!!f.current,workspaceCount:((l=f.current)==null?void 0:l.items.length)??0,sessionCount:((u=f.current)==null?void 0:u.items.reduce((b,P)=>b+P.sessions.length,0))??0})},[]);function St(l){var P;if(!l||!Array.isArray(l.items))return;zm(j.current,l);const u=Gm(l,j.current);pt("workbench.apply_snapshot",{workspaceCount:u.items.length,sessionCount:u.items.reduce((G,z)=>G+z.sessions.length,0),currentSessionId:((P=gr(t.pathname))==null?void 0:P.sessionId)??null});const b=yi(u,I.current);f.current=u,ra(u),je.current=b,Ce(b),Rt(il(u)),_(null)}const ze=i.useCallback(async()=>{const l=w.current+1;w.current=l,At(u=>u||!N.current),pt("workbench.refresh_navigation.start",{requestId:l,hasNavigationData:N.current});try{const u=await yd();if(l!==w.current){pt("workbench.refresh_navigation.stale",{requestId:l});return}St(u)}catch(u){if(l!==w.current)return;_(u instanceof Error?u.message:r("shell.navigationLoadFailed")),W.current({title:u instanceof Error?u.message:r("shell.navigationLoadFailed"),tone:"error"})}finally{pt("workbench.refresh_navigation.end",{requestId:l,success:l===w.current}),l===w.current&&At(!1)}},[]),wt=i.useCallback(l=>{Ce(u=>{const b=Km(u,l,I.current);return je.current=b,b})},[]),Et=i.useCallback(()=>{var l;(l=v.current)==null||l.requestRefresh()},[]),Pn=i.useCallback((l,u)=>{s(Ut(l,u))},[s]),ys=i.useCallback((l,u,b)=>{var P;X.current={workspaceId:l,paths:u,knownRevisionByPath:b==null?void 0:b.knownRevisionByPath},(P=v.current)==null||P.subscribeFileTree(l,u,b)},[]),Ss=i.useCallback((l,u,b)=>{var P;V.current={workspaceId:l,paths:u,knownRevisionByPath:b==null?void 0:b.knownRevisionByPath},(P=v.current)==null||P.requestFileTreeRefresh(l,u,b)},[]),js=i.useCallback(l=>(K.current.add(l),()=>{K.current.delete(l)}),[]),nn=i.useCallback((l,u)=>{var b;D.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.subscribeGit(l,u)},[]),Ot=i.useCallback((l,u)=>{var b;y.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.requestGitRefresh(l,u)},[]),sn=i.useCallback(l=>(F.current.add(l),()=>{F.current.delete(l)}),[]),An=i.useCallback((l,u)=>{var b;Y.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.subscribeWorkspaceManagement(l,u)},[]),rn=i.useCallback((l,u)=>{var b;Q.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},bt(P=>{var G;return{...P,[l]:{detail:((G=P[l])==null?void 0:G.detail)??null,loading:!0,error:null}}}),(b=v.current)==null||b.requestWorkspaceManagementRefresh(l,u)},[]),Cs=i.useCallback(l=>(te.current.add(l),()=>{te.current.delete(l)}),[]),an=i.useCallback(async(l,u=!1)=>{const b=l.trim();if(!b)return;let P=!0;if(_t(G=>{const z=G[b];return!u&&(z!=null&&z.loading)?(P=!1,G):{...G,[b]:{preview:(z==null?void 0:z.preview)??null,loading:!0,applying:(z==null?void 0:z.applying)??!1,cleaning:(z==null?void 0:z.cleaning)??!1,error:null}}}),!!P)try{const G=await Sd(b);_t(z=>{var le,ye;return{...z,[b]:{preview:G,loading:!1,applying:((le=z[b])==null?void 0:le.applying)??!1,cleaning:((ye=z[b])==null?void 0:ye.cleaning)??!1,error:null}}})}catch(G){_t(z=>{var le,ye,ve;return{...z,[b]:{preview:((le=z[b])==null?void 0:le.preview)??null,loading:!1,applying:((ye=z[b])==null?void 0:ye.applying)??!1,cleaning:((ve=z[b])==null?void 0:ve.cleaning)??!1,error:G instanceof Error?G.message:r("shell.worktreeMergePreviewFailed")}}})}},[]),Ir=i.useCallback(async l=>{const u=l.trim();if(u){_t(b=>{var P,G;return{...b,[u]:{preview:((P=b[u])==null?void 0:P.preview)??null,loading:!1,applying:!0,cleaning:((G=b[u])==null?void 0:G.cleaning)??!1,error:null}}});try{const b=await jd(u);_t(P=>{var G;return{...P,[u]:{preview:b.preview,loading:!1,applying:!1,cleaning:((G=P[u])==null?void 0:G.cleaning)??!1,error:null}}}),Et(),ze(),an(u,!0),Ot(b.preview.targetWorkspace.id),W.current({title:b.applied?r("shell.worktreeMergeApplySuccess"):r("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(b){_t(P=>{var G,z;return{...P,[u]:{preview:((G=P[u])==null?void 0:G.preview)??null,loading:!1,applying:!1,cleaning:((z=P[u])==null?void 0:z.cleaning)??!1,error:b instanceof Error?b.message:r("shell.worktreeMergeApplyFailed")}}}),W.current({title:b instanceof Error?b.message:r("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[an,ze,Ot,Et]),Mr=i.useCallback(async l=>{var P,G;const u=l.workspaceId,b=Vn&&((G=(P=tt[u])==null?void 0:P.preview)==null?void 0:G.alreadyMerged)===!0;_t(z=>{var le;return{...z,[u]:{preview:((le=z[u])==null?void 0:le.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const z=await Cd(u,{deleteBranch:b});if(_t(le=>{var ye;return{...le,[u]:{preview:((ye=le[u])==null?void 0:ye.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),Tn(!1),qn(le=>(le==null?void 0:le.workspaceId)===u?null:le),Et(),await ze(),s(hn(l.parentWorkspaceId),{replace:!0}),z.branchDeleted){W.current({title:r("shell.worktreeCleanupDeleteBranchSuccess",{branch:z.deletedBranchName||l.branchName}),tone:"success"});return}if(z.branchDeleteRequested){W.current({title:r("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:l.branchName}),description:z.branchDeleteError||void 0,tone:"warning"});return}W.current({title:r("shell.worktreeCleanupSuccess"),tone:"success"})}catch(z){_t(le=>{var ye;return{...le,[u]:{preview:((ye=le[u])==null?void 0:ye.preview)??null,loading:!1,applying:!1,cleaning:!1,error:z instanceof Error?z.message:r("shell.worktreeCleanupFailed")}}}),W.current({title:z instanceof Error?z.message:r("shell.worktreeCleanupFailed"),tone:"error"})}},[Vn,s,ze,Et,tt]),Tr=i.useCallback(l=>{Tn(!1),qn(l)},[]),Gt=i.useCallback((l,u)=>{var b;B.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.subscribeTerminalManager(l,u)},[]),at=i.useCallback((l,u)=>{var b;me.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.requestTerminalManagerRefresh(l,u)},[]),qs=i.useCallback(l=>(M.current.add(l),()=>{M.current.delete(l)}),[]),De=i.useCallback((l,u)=>{Ce(b=>qm(b,l,u??new Date().toISOString()))},[]),zt=i.useCallback(async(l,u)=>{j.current.set(l,u),Ce(b=>dl(b,l,u));try{const b=await Nl(l,u),P=un(b);P===u?j.current.set(l,P):j.current.delete(l),wt(b),Et(),ze()}catch(b){throw j.current.delete(l),Ce(P=>dl(P,l,!u)),b}},[ze,Et,wt]),Wn=i.useCallback((l,u)=>{pt("workbench.set_session_workspace",{sessionId:l,workspaceId:u}),Gs(b=>{if(!u){if(!(l in b))return b;const P={...b};return delete P[l],P}return b[l]===u?b:{...b,[l]:u}})},[]);i.useEffect(()=>{N.current=U.length>0},[U]),i.useEffect(()=>{pt("workbench.navigation_state",{navigationLoading:Re,workspaceCount:U.length,sessionCount:U.reduce((l,u)=>l+u.sessions.length,0)})},[U,Re]),i.useEffect(()=>{L.current!==null&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>{var ee;L.current=null,!(T.current||N.current)&&(pt("workbench.refresh_navigation.ws_fallback_triggered"),(ee=v.current)==null||ee.requestRefresh())},1200);const l=new qu({onConnectionChange:ee=>{ee==="connected"&&Nd(),ee==="reconnect_failed"&&!N.current&&(_(r("shell.navigationLoadFailed")),W.current({id:"workbench-navigation-connection",title:r("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:ee=>{T.current=!0,pt("workbench.ws_snapshot_received",{workspaceCount:ee.items.length,sessionCount:ee.items.reduce((Le,Jt)=>Le+Jt.sessions.length,0)}),L.current!==null&&(window.clearTimeout(L.current),L.current=null),St(ee),At(!1)},onFileTreeSnapshot:ee=>{K.current.forEach(Le=>Le(ee))},onGitSnapshot:ee=>{br(_c(ee.workspaceId),{revision:ee.revision??null,status:ee.status,history:ee.history,historyTotalCount:ee.historyTotalCount,historyNextCursor:ee.historyNextCursor,branches:ee.branches}),bt(Le=>{var xn;const Jt=((xn=U.find(qc=>qc.workspace.id===ee.workspaceId))==null?void 0:xn.workspace)??null;if(!Jt)return Le;const ln=Le[ee.workspaceId],ot=$c(Oc((ln==null?void 0:ln.detail)??Fc(Jt),Jt),ee);return br(bo(ee.workspaceId),ot),{...Le,[ee.workspaceId]:{detail:ot,loading:!1,error:null}}}),F.current.forEach(Le=>Le(ee))},onWorkspaceManagementSnapshot:ee=>{br(bo(ee.workspaceId),ee),bt(Le=>({...Le,[ee.workspaceId]:{detail:ee,loading:!1,error:null}})),te.current.forEach(Le=>Le(ee))},onTerminalManagerSnapshot:ee=>{M.current.forEach(Le=>Le(ee))},onUnauthorized:()=>{kr.clear(),s("/login",{replace:!0})}});l.primeWorkbenchSnapshot(f.current),v.current=l;const u=X.current,b=V.current,P=D.current,G=y.current,z=Y.current,le=Q.current,ye=B.current,ve=me.current;return u&&l.subscribeFileTree(u.workspaceId,u.paths,{knownRevisionByPath:u.knownRevisionByPath}),P&&l.subscribeGit(P.workspaceId,{knownRevision:P.knownRevision}),z&&l.subscribeWorkspaceManagement(z.workspaceId,{knownRevision:z.knownRevision}),ye&&l.subscribeTerminalManager(ye.workspaceId,{knownRevision:ye.knownRevision}),b&&l.requestFileTreeRefresh(b.workspaceId,b.paths,{knownRevisionByPath:b.knownRevisionByPath}),G&&l.requestGitRefresh(G.workspaceId,{knownRevision:G.knownRevision}),le&&l.requestWorkspaceManagementRefresh(le.workspaceId,{knownRevision:le.knownRevision}),ve&&l.requestTerminalManagerRefresh(ve.workspaceId,{knownRevision:ve.knownRevision}),l.start(),()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null),v.current===l&&(v.current=null),l.close()}},[s]),i.useEffect(()=>{hs(_i,String(R))},[R]),i.useEffect(()=>{hs(Fi,String(ce))},[ce]),i.useEffect(()=>{hs(Oi,String(ke))},[ke]),i.useEffect(()=>{hs($i,String(Ae))},[Ae]),i.useEffect(()=>{if(!Je){Lm(eo);return}hs(eo,Je)},[Je]),i.useEffect(()=>{if(Se||Ae)return;const l=window.setTimeout(()=>{lt(!0)},Vp);return()=>{window.clearTimeout(l)}},[Se,Ae]);const Ct=gr(t.pathname),Ie=(Ct==null?void 0:Ct.sessionId)??null,Xe=Ie?Kc(Ie):!1,Ee=i.useMemo(()=>cu(U),[U]),Pt=i.useMemo(()=>Fm(U),[U]),Ln=i.useMemo(()=>new Set(rt),[rt]),Nt=i.useMemo(()=>Ee.filter(l=>l.session.isFavorite===!0).map(l=>l.session.sessionId),[Ee]),Kt=i.useMemo(()=>new Set(Nt),[Nt]),ts=i.useCallback(l=>{const u=so(l,rt);f.current=u,ra(u),je.current=l,Ce(l)},[rt]),Rr=i.useCallback(l=>{const u=!Ln.has(l),b=hl(rt,l,u),P=so(U,b);f.current=P,ra(P),Rt(b),Il(l,{collapsed:u}).catch(G=>{const z=hl(b,l,!u),le=so(U,z);f.current=le,ra(le),Rt(z),W.current({title:G instanceof Error?G.message:r("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[Ln,rt,U]),Er=i.useCallback(()=>{Z.current={originalGroups:je.current}},[]),Pr=i.useCallback((l,u,b)=>{const P=je.current,G=Um(P,l,u,b);G!==P&&ts(G)},[ts]),Ar=i.useCallback(()=>{const l=Z.current;Z.current=null;const u=je.current;l&&(l.originalGroups.length===u.length&&l.originalGroups.every((b,P)=>{var G;return b.workspace.id===((G=u[P])==null?void 0:G.workspace.id)})||Id({workspaceIds:u.map(b=>b.workspace.id)}).catch(b=>{ts(l.originalGroups),W.current({title:b instanceof Error?b.message:r("shell.workspaceReorderFailed"),tone:"error"})}))},[ts]);i.useEffect(()=>{const l=new Map;if(Ee.forEach(({session:u})=>{l.set(u.sessionId,{activityState:u.activityState,completedAt:u.completedAt??null,runningState:u.runningState??null})}),!We.current){We.current=!0,J.current=l;return}Ee.forEach(({session:u})=>{var le;if(u.sessionId===Ie)return;const b=J.current.get(u.sessionId);if(!b)return;const P=b.activityState!=="completed_unread"&&u.activityState==="completed_unread",G=((le=u.title)==null?void 0:le.trim())||r("common.unknown");if(h&&P){const ye=r("conversation.backgroundCompletionToastDescription",{title:G});W.current({id:`workbench-session-completed-${u.sessionId}-${u.completedAt??"unknown"}`,title:r("conversation.backgroundCompletionToastTitle"),description:ye,tone:"success",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>Pn(u.workspaceId,u.sessionId)}}),x.current.showNotification(r("conversation.backgroundCompletionToastTitle"),ye)}const z=b.runningState!=="failed"&&(u.runningState??null)==="failed";if(g&&z){const ye=lm(u)??r("conversation.runtimeFailed"),ve=r("conversation.backgroundFailureToastDescription",{title:G,detail:ye});W.current({id:`workbench-session-failed-${u.sessionId}-${u.updatedAt}`,title:r("conversation.backgroundFailureToastTitle"),description:ve,tone:"error",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>Pn(u.workspaceId,u.sessionId)}}),x.current.showNotification(r("conversation.backgroundFailureToastTitle"),ve)}}),J.current=l},[Ie,Ee,h,g,Pn]),i.useEffect(()=>{S.current=Ee.map(l=>l.session).filter(l=>l.sessionId!==Ie&&om(l)).map(l=>{var u;return{sessionId:l.sessionId,workspaceId:l.workspaceId,title:((u=l.title)==null?void 0:u.trim())||r("common.unknown")}})},[Ie,Ee]),i.useEffect(()=>{let l=!1,u=null;const b=()=>{u=window.setTimeout(()=>{P().finally(()=>{l||b()})},Jp)},P=async()=>{var ve;const G=S.current;if(G.length===0){ge.current||(ge.current=!0),Ye.current="";return}const z=new Set(G.map(ee=>ee.sessionId)),le=await Promise.all(G.map(async ee=>{try{const Le=await Td(ee.sessionId);return{session:ee,items:Le.items}}catch{return{session:ee,items:null}}}));if(l)return;for(const ee of le){if(!ee.items)continue;const Le=ee.items.filter(ot=>ot.status==="pending"),Jt=new Set(Le.map(ot=>ot.id)),ln=Te.current.get(ee.session.sessionId)??new Set;ge.current&&Le.forEach(ot=>{if(ln.has(ot.id)||!p)return;const xn=r("conversation.backgroundPermissionToastDescription",{title:ee.session.title,requestTitle:ot.title});W.current({id:`workbench-permission-request-${ot.id}`,title:r("conversation.permissionRequestToastTitle"),description:xn,tone:"warning",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>Pn(ee.session.workspaceId,ee.session.sessionId)}}),x.current.showNotification(r("conversation.permissionRequestToastTitle"),xn)}),Te.current.set(ee.session.sessionId,Jt)}for(const[ee,Le]of Te.current.entries())!z.has(ee)&&Le.size===0&&Te.current.delete(ee);const ye=im(Te.current,z);ge.current&&ye!==Ye.current&&((ve=v.current)==null||ve.requestRefresh()),Ye.current=ye,ge.current=!0};return P().finally(()=>{l||b()}),()=>{l=!0,u!==null&&window.clearTimeout(u)}},[p,Pn]),i.useEffect(()=>{Re&&U.length===0||(Rt(l=>Wc(l,Pt)),ft(l=>l&&Pt.has(l)?l:null))},[Pt,Re]);const dt=Ee.find(l=>l.session.sessionId===Ie)??null,Ze=(dt==null?void 0:dt.workspace.id)??(Ie?yt[Ie]??null:null),qt=Zi(t.pathname,t.search),ns=qt&&Pt.has(qt)?qt:null,Vs=Je&&Pt.has(Je)?Je:null,Bn=Ze??ns??Vs??null,fe=Bn??((He=U[0])==null?void 0:He.workspace.id)??null,Xs=i.useCallback(l=>{if(l){const u=Ee.find(b=>b.workspace.id===l)??null;if(u)return u}return Ee[0]??null},[Ee]),ss=i.useCallback(l=>{const u=typeof window>"u"?null:window.localStorage.getItem(la);if(!u)return null;const b=u.split("?")[0]??u,P=gr(b);if(!P)return window.localStorage.removeItem(la),null;const G=P.sessionId,z=Ee.find(ye=>ye.session.sessionId===G)??null,le=P.workspaceId??(z==null?void 0:z.workspace.id)??null;return z&&(!l||le===l)?Ut(z.workspace.id,z.session.sessionId):(window.localStorage.removeItem(la),null)},[Ee]),Ns=i.useMemo(()=>Xn.filter(l=>!Yn.has(l.id)),[Yn,Xn]),rs=i.useMemo(()=>Ns.filter(l=>fm(l,mn)).length,[Ns,mn]);i.useEffect(()=>{Rn&&es(Ns)},[Ns,es,Rn]);const Aa=i.useCallback(l=>{tn(!1),l.routePath&&s(l.routePath)},[s]),as=i.useCallback(async(l,u)=>{const b=ne.current+1;ne.current=b;try{const P=await pp(l,u);if(b!==ne.current)return;Jn(G=>{const z=new Set(G);return P.item?z.add(P.item.notificationId):z.delete(l),z})}catch(P){if(b!==ne.current)return;W.current({title:r("shell.globalNotificationsArchiveFailed"),description:P instanceof Error?P.message:void 0,tone:"error"})}},[]);i.useEffect(()=>{Ze&&ft(l=>l===Ze?l:Ze)},[Ze]),i.useEffect(()=>{var z;if(Re)return;const l=((z=U[0])==null?void 0:z.workspace.id)??null,u=ns??l??Vs,b=Ie&&!Xe?Xs(u):null,P=Ie&&!Xe?ss(u):null,G=b?Ut(b.workspace.id,b.session.sessionId):null;if(qt&&!ns){s(P??G??(l?vm(t.pathname,l):no(e)),{replace:!0});return}if(Ie&&!Xe&&!Ze){s(P??G??(l?Fs(l):no(e)),{replace:!0});return}},[Ie,Xs,Xe,t.pathname,s,U,Re,ss,qt,Ze,e,Vs,ns]),i.useEffect(()=>{pt("workbench.current_workspace_resolved",{currentSessionId:Ie,sessionWorkspaceId:Ze,routeWorkspaceId:qt,currentWorkspaceId:fe,source:Ze?dt?"navigation":"sessionWorkspaceMap":qt?"route":Je?"workspaceSelection":"navigationFallback"})},[dt,Ie,fe,qt,Je,Ze]);const It=ka(t.pathname)?"terminals":wa(t.pathname)?"butler":"conversation",Ue=e==="mobile",os=no(e),Wr=i.useMemo(()=>U.map(l=>{const u=yc(l.sessions);return{workspace:l.workspace,visibleSessions:u,archivedSessions:l.sessions.filter(b=>un(b)&&!Ra(b)),visibleSessionTree:_o(u,c).filter(b=>!Kt.has(b.item.sessionId)&&!Co(Zt(b),P=>Kt.has(P.sessionId))),childWorktrees:Ic(l.childWorktrees,Kt,c),isCollapsed:Ln.has(l.workspace.id)}}),[Ln,Kt,U,c]),Is=i.useMemo(()=>tp(U),[U]),Ms=i.useMemo(()=>ol(U,fe),[fe,U]),Vt=(dt?ru(dt.session,dt.session.sessionIsolatedWorkspace):fe)??fe,bn=i.useMemo(()=>ol(U,Vt),[Vt,U]),Lr=i.useMemo(()=>fe?(Ms==null?void 0:Ms.workspace)??U.map(l=>l.workspace).find(l=>l.id===fe)??null:null,[fe,Ms,U]),Br=i.useMemo(()=>Vt?(bn==null?void 0:bn.workspace)??U.map(l=>l.workspace).find(l=>l.id===Vt)??null:null,[Vt,bn,U]),gn=(bn==null?void 0:bn.meta)??null,Wa=(fe?Is[fe]??null:null)??(Lr?Ca(Lr):null),$t=(Vt?Is[Vt]??null:null)??(Br?Ca(Br):Wa),Dr=gn?tt[gn.workspaceId]??null:null,Ys=((qr=(ds=(Kr=dt==null?void 0:dt.session)==null?void 0:Kr.parallelGroup)==null?void 0:ds.groupId)==null?void 0:qr.trim())||null,ut=It==="conversation"&&nu((dt==null?void 0:dt.session)??null);i.useEffect(()=>{if(typeof window>"u"||!ut||!Ys){st(null);return}const l=ou(Ys);if(!l||l.sidebarCollapseDurationMs<=0){st(null);return}st(l);const u=Date.now()-l.createdAt,b=l.totalDurationMs-u;if(b<=0){st(null);return}const P=window.setTimeout(()=>{st(null)},b);return()=>{window.clearTimeout(P)}},[Ys,ut]),i.useEffect(()=>{pt("workbench.info_panel_state",{infoPanelReady:Se,rightCollapsed:Ae||ut,currentWorkspaceId:fe,sessionWorkspaceId:Ze,currentSessionId:Ie})},[Ie,fe,Se,ut,Ae,Ze]);const Ts=i.useMemo(()=>Ee.filter(l=>Kt.has(l.session.sessionId)&&!un(l.session)&&!mo(l.session)),[Kt,Ee]),Js=t.pathname.startsWith("/settings")?"settings":wa(t.pathname)?"terminals":ka(t.pathname)?"butler":wm(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":km(t.pathname)||Qi(t.pathname)?"sessions":"workspaces",_r=Ue&&(Js==="sessions"&&Qi(t.pathname)||wa(t.pathname)),Fr=Ma({isNativeMobile:a.isNativeMobile,viewportClass:a.viewportClass}),Zs=xr({viewportClass:a.viewportClass,activeEntry:Js,hasNavigationPanel:Ue,hasAuxiliaryPanel:Ue,preferCompactLayout:Fr}),Or=Ue&&Jl(Zs),Rs=Ue&&Zl(Zs),La=i.useMemo(()=>U.map(l=>l.workspace),[U]),Ba=i.useMemo(()=>{const l=pn.trim().toLowerCase();return l?Ee.filter(u=>{const b=(u.session.title||"").toLowerCase(),P=u.workspace.name.toLowerCase(),G=Ea(u.session.provider,"full").toLowerCase();return b.includes(l)||P.includes(l)||G.includes(l)}):[]},[Ee,pn]);i.useEffect(()=>{var u;const l=fe??((u=U[0])==null?void 0:u.workspace.id)??"";l&&en(b=>b&&U.some(G=>G.workspace.id===b)?b:l)},[fe,U]),i.useEffect(()=>{Ie&&!Xe&&Ze&&hs(la,`${t.pathname}${t.search}`)},[Ie,Xe,t.pathname,t.search,Ze]),i.useEffect(()=>{if(Ie&&Xe){H.current=`${t.pathname}${t.search}`;return}Ie&&!Xe&&(H.current=null)},[Ie,Xe,t.pathname,t.search]),i.useEffect(()=>{Ue||(Be(!1),$e(!1))},[Ue]),i.useEffect(()=>{!Ue||Re||!gm(t.pathname)||Bn||(Be(!1),$e(!1),s(os,{replace:!0}))},[Bn,Ue,t.pathname,s,Re,os]);function $r(){if(Ue){Be(!0);return}Qe(!1)}function Da(){if(!ut){if(kn(),Ue){$e(!0);return}et(!1)}}function _a(){if(Ue){Be(l=>!l);return}Qe(l=>!l)}function Fa(){if(!ut){if(kn(),Ue){$e(l=>!l);return}et(l=>!l)}}function kn(){lt(!0)}function is(l){if(ft(l),kn(),ka(t.pathname)){const u=ps(l);t.pathname!==u&&s(u);return}Ie&&Ze!==l&&s(os)}const ls=i.useCallback(async l=>{var P;const u=((P=Ee.find(G=>G.session.sessionId===l))==null?void 0:P.session)??null,b=(u==null?void 0:u.isFavorite)!==!0;Ce(G=>ul(G,l,b));try{const G=await Md(l,b);wt(G),Et()}catch(G){throw Ce(z=>ul(z,l,!b)),G}},[Ee,Et,wt]),Hr=i.useCallback((l,u)=>{vc(l,u).then(()=>{s(ql(l,u))}).catch(b=>{o({title:b instanceof Error?b.message:r("shell.startSessionFailed"),tone:"error"})})},[s,o]),Ur=i.useCallback(l=>{var P;const u=((P=l.workspaceId)==null?void 0:P.trim())||fe,b=xm(l.filePath);return!u||!b?!1:(kn(),Fe("files"),Ue?(Be(!1),$e(!0)):et(!1),zn({requestId:O.current+1,workspaceId:u,filePath:b,openViewer:l.openViewer===!0}),O.current+=1,!0)},[fe,Ue]),Gr=i.useCallback(async(l,u)=>{const b=await Ml(l,u.trim());return wt(b),b},[wt]);function Qs(l){gs(!0)}function er(){gs(!1),ks("sessions"),Cn(""),In(null),Bt([]),zs(!1)}async function Oa(){const l=pn.trim();if(!l||!Nn.trim()){Bt([]),In(null);return}zs(!0),In(null);try{const u=await qd(Nn,l);Bt(u.items)}catch(u){Bt([]),In(u instanceof Error?u.message:r("shell.searchCodeFailed"))}finally{zs(!1)}}function tr(l,u){const b=C.current;b&&(b.style.setProperty("--workbench-left-width",`${l}px`),b.style.setProperty("--workbench-left-current-width",ke?"0px":`${l}px`),b.style.setProperty("--workbench-right-width",`${u}px`),b.style.setProperty("--workbench-right-current-width",Ae?"0px":`${u}px`))}function $a(l={}){return{leftWidth:l.leftWidth??(ke?0:$.current),rightWidth:l.rightWidth??(E&&!Ae?se.current:0),leftCollapsed:l.leftCollapsed??ke,rightCollapsed:l.rightCollapsed??(!E||Ae),prefersDarkAppearance:l.prefersDarkAppearance??xs!=="light",isResizing:l.isResizing??vt!==null}}function wn(l,u){var ye;u.preventDefault(),u.stopPropagation(),(ye=window.getSelection())==null||ye.removeAllRanges();const b=u.clientX,P=l==="left"?R:ce;Wt(l);const G=()=>{const ve=xe.current;if(xe.current=null,ve!==null){if(l==="left"){$.current=ve,ie(ee=>ee===ve?ee:ve),tr(ve,se.current);return}se.current=ve,pe(ee=>ee===ve?ee:ve),tr($.current,ve)}};function z(ve){var ln;ve.preventDefault(),(ln=window.getSelection())==null||ln.removeAllRanges();const ee=ve.clientX-b,Le=l==="left"?ha(P+ee,Ui,zi):ha(P-ee,Gi,Ki),Jt=l==="left"?$.current:se.current;Le===Jt&&xe.current===null||(xe.current=Le,Me.current===null&&(Me.current=window.requestAnimationFrame(()=>{Me.current=null,G()})))}function le(){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",le),Me.current!==null&&(window.cancelAnimationFrame(Me.current),Me.current=null),G(),Wt(ee=>ee===l?null:ee);const ve=$a({isResizing:!1});Xt.current=ve,a.bridge.syncNativeSidebarLayout(ve)}document.addEventListener("mousemove",z,{passive:!1}),document.addEventListener("mouseup",le)}function cs(){if(d())return;if(Ee.length===0){s(os);return}const l=Ut(Ee[0].workspace.id,Ee[0].session.sessionId);s(l)}function zr(){if(!d(fe)){if(fe){s(Fs(fe));return}s(os)}}function d(l){if(Ie&&Ze)return l&&Ze&&Ze!==l?!1:(s(`${t.pathname}${t.search}`),!0);if(H.current){if(l){const[b,P=""]=H.current.split("?"),G=Zi(b??H.current,P?`?${P}`:"");if(G&&G!==l)return!1}return s(H.current),!0}const u=ss(l);return u?(s(u),!0):!1}i.useEffect(()=>{if(typeof window>"u")return;function l(u){if(!(u.metaKey||u.ctrlKey)){u.key==="Escape"&&(Be(!1),$e(!1));return}if(Dm(u.target))return;const P=u.key.toLowerCase();if(!u.shiftKey&&P==="b"){u.preventDefault(),_a();return}if(u.shiftKey&&P==="i"){u.preventDefault(),Fa();return}if(!u.shiftKey&&P===","){u.preventDefault(),s("/settings");return}if(!u.shiftKey&&P==="1"){u.preventDefault(),cs();return}if(!u.shiftKey&&P==="2"){u.preventDefault(),s(fe?ps(fe):jt());return}if(!u.shiftKey&&P==="k"){u.preventDefault(),_m();return}u.shiftKey&&P==="r"&&(u.preventDefault(),ze())}return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l)}},[s,ze,Ue,cs]);const m=i.useMemo(()=>({shellMode:e,navigationGroups:U,navigationLoading:Re,navigationError:mt,currentWorkspaceId:fe,currentSessionId:Ie,favoriteSessionIds:Nt,favoriteSessions:Ts,globalNotifications:Xn,archivedNotificationIds:Array.from(Yn),showArchivedNotifications:En,unreadNotificationCount:rs,refreshNavigation:ze,requestNavigationRefresh:Et,openNotificationPanel:()=>{tn(!0)},closeNotificationPanel:()=>{tn(!1)},setShowArchivedNotifications:Zn,archiveNotification:l=>{as(l,!0)},unarchiveNotification:l=>{as(l,!1)},setAuxiliaryPanel:xt,subscribeFileTree:ys,requestFileTreeRefresh:Ss,addFileTreeSnapshotListener:js,subscribeGitSnapshot:nn,requestGitRefresh:Ot,addGitSnapshotListener:sn,subscribeWorkspaceManagementSnapshot:An,requestWorkspaceManagementRefresh:rn,addWorkspaceManagementSnapshotListener:Cs,workspaceManagementStateById:Kn,subscribeTerminalManagerSnapshot:Gt,requestTerminalManagerRefresh:at,addTerminalManagerSnapshotListener:qs,selectWorkspace:is,toggleFavoriteSession:ls,archiveSession:l=>zt(l,!0),unarchiveSession:l=>zt(l,!1),renameSession:Gr,startDraftSession:Hr,markNavigationSessionSeen:De,upsertNavigationSession:wt,setSessionWorkspace:Wn,revealWorkspaceFile:Ur}),[js,sn,Cs,qs,zt,Ie,fe,Xn,Nt,Ts,is,Yn,De,mt,U,Re,rs,Ss,Ot,rn,ze,Et,Zn,xt,at,Gr,En,Kn,e,Hr,Wn,ys,nn,An,Gt,as,ls,wt,Ur]),k={"--workbench-left-width":`${R}px`,"--workbench-left-current-width":ke?"0px":`${R}px`,"--workbench-right-width":`${ce}px`,"--workbench-right-current-width":Ae||ut?"0px":`${ce}px`,"--workbench-right-sidebar-duration":it&&!Ae?`${it.sidebarCollapseDurationMs}ms`:void 0,"--workbench-right-sidebar-content-duration":it&&!Ae?`${Math.max(320,it.sidebarCollapseDurationMs-120)}ms`:void 0},A=It==="butler"?Un:n.jsx(bl,{panelReady:Se,activeTab:qe,fileRevealRequest:Mn,onTabChange:l=>{kn(),Fe(l)},currentSessionId:Xe?null:Ie,activeWorkspaceId:Vt,navigationGroups:U,workspaceContext:$t,worktreeMeta:gn,worktreeMergeState:Dr,onRefreshWorktreeMergePreview:an,onApplyWorktreeMerge:Ir,onCleanupWorktree:Mr}),E=A!==null,de=Ae||ut,q=ut&&it!==null&&!Ae,Ne=a.isDesktop&&a.ui.osFamily==="macos"&&a.ui.prefersOverlayTitlebar;i.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:l,body:u}=document,b=()=>{oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null);const G=ae.current;ae.current=!1,l.removeAttribute(da),u==null||u.removeAttribute(da),G&&he.current&&(he.current=!1,vs(z=>z+1))};if(!Ne){b();return}const P=()=>{ae.current=!0,l.setAttribute(da,"true"),u==null||u.setAttribute(da,"true"),oe.current!==null&&window.clearTimeout(oe.current),oe.current=window.setTimeout(()=>{b()},Qp)};return window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P),b()}},[Ne]);const Ke=i.useMemo(()=>({leftWidth:ke?0:R,rightWidth:E&&!de?ce:0,leftCollapsed:ke,rightCollapsed:!E||de,prefersDarkAppearance:xs!=="light",isResizing:vt!==null}),[vt,de,ke,R,ce,E,xs]),Ve=i.useDeferredValue(Ke),ht=vt===null?Ve:Ke,Xt=i.useRef(Ke);i.useEffect(()=>{Xt.current=Ke},[Ke]),i.useEffect(()=>{if(typeof window>"u")return;let l=null;const u=()=>{l=null,a.bridge.syncNativeSidebarLayout(ht)},b=()=>{l!==null&&window.cancelAnimationFrame(l),l=window.requestAnimationFrame(u)};return fn?(b(),()=>{l!==null&&window.cancelAnimationFrame(l)}):(a.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{l!==null&&window.cancelAnimationFrame(l)})},[ht,a.bridge,fn]),i.useLayoutEffect(()=>{const l=C.current;if(!l||!Ne||typeof window>"u"){Yi(l);return}let u=null,b=null;const P=new Set([l]),G=()=>{he.current=!1;const le=window.getComputedStyle(l),ye=kc(le,"--desktop-macos-traffic-light-center-y");if(ye===null){Yi(l);return}const ve={navToolbar:Dn(l,Ge.navToolbar.selector),infoTabs:Dn(l,Ge.infoTabs.selector),auxiliaryToolbarButton:Dn(l,Ge.auxiliaryToolbarButton.selector),conversationHeaderMain:Dn(l,Ge.conversationHeaderMain.selector),conversationHeaderActions:Dn(l,Ge.conversationHeaderActions.selector),terminalTabbarMain:Dn(l,Ge.terminalTabbarMain.selector),collapsedLeftControls:Dn(l,Ge.collapsedLeftControls.selector),collapsedRightControls:Dn(l,Ge.collapsedRightControls.selector)},ee=[ve.infoTabs,ve.conversationHeaderMain,ve.conversationHeaderActions,ve.terminalTabbarMain].filter(ot=>ot!==null),Le=[ve.collapsedLeftControls,ve.collapsedRightControls].filter(ot=>ot!==null),Jt=Le.length>0?dn(le,"--workbench-collapsed-controls-live-shift-y",ye,Le.reduce((ot,xn)=>ot+xn,0)/Le.length):null,ln=ee.length>0?dn(le,"--workbench-titlebar-live-content-shift-y",ye,ee.reduce((ot,xn)=>ot+xn,0)/ee.length):null;cn(l,"--workbench-titlebar-live-content-shift-y",ln),cn(l,"--workbench-collapsed-controls-live-shift-y",Jt),cn(l,Ge.navToolbar.variableName,dn(le,Ge.navToolbar.variableName,ye,ve.navToolbar)),cn(l,Ge.infoTabs.variableName,dn(le,Ge.infoTabs.variableName,ye,ve.infoTabs)),cn(l,Ge.auxiliaryToolbarButton.variableName,dn(le,Ge.auxiliaryToolbarButton.variableName,ye,ve.auxiliaryToolbarButton)),cn(l,Ge.conversationHeaderMain.variableName,dn(le,Ge.conversationHeaderMain.variableName,ye,ve.conversationHeaderMain)),cn(l,Ge.conversationHeaderActions.variableName,dn(le,Ge.conversationHeaderActions.variableName,ye,ve.conversationHeaderActions)),cn(l,Ge.terminalTabbarMain.variableName,dn(le,Ge.terminalTabbarMain.variableName,ye,ve.terminalTabbarMain)),cn(l,Ge.collapsedLeftControls.variableName,dn(le,Ge.collapsedLeftControls.variableName,ye,ve.collapsedLeftControls)),cn(l,Ge.collapsedRightControls.variableName,dn(le,Ge.collapsedRightControls.variableName,ye,ve.collapsedRightControls))},z=()=>{if(ae.current){he.current=!0;return}u!==null&&window.cancelAnimationFrame(u),u=window.requestAnimationFrame(()=>{u=null,G()})};if(z(),typeof ResizeObserver<"u"){b=new ResizeObserver(()=>{z()});for(const le of Object.values(Ge))for(const ye of l.querySelectorAll(le.selector))P.add(ye);for(const le of P)b.observe(le)}return window.addEventListener("resize",z),()=>{u!==null&&window.cancelAnimationFrame(u),window.removeEventListener("resize",z),b==null||b.disconnect()}},[It,Se,ke,t.pathname,t.search,Ae,E,Ne,Ft]);const on=Ue?n.jsx(fl,{workspaceGroups:Wr,workspaceVisualContextMap:Is,sessionDisplaySortMode:c,favoriteSessions:Ts,favoriteSessionIds:Kt,activeWorkspaceId:fe,isConversationActive:It==="conversation",isTerminalActive:It==="terminals",isButlerActive:It==="butler",isSearchOpen:ct,navigationLoading:Re,navigationError:mt,activeSessionId:Ie,onRefreshNavigation:ze,onSessionUpdated:wt,onNavigateConversation:cs,onNavigateTerminals:()=>{Be(!1),s(fe?ps(fe):jt())},onNavigateButler:()=>{Be(!1),s(fe?ms(fe):jt())},onOpenSearch:()=>{Be(!1),Qs()},onOpenSettings:()=>{Be(!1),s("/settings")},onSelectWorkspace:is,onToggleWorkspaceCollapse:Rr,onStartWorkspaceReorder:Er,onPreviewWorkspaceReorder:Pr,onCommitWorkspaceReorder:Ar,allowWorkspaceReorder:!1,subscribeGitSnapshot:nn,requestGitRefresh:Ot,subscribeWorkspaceManagementSnapshot:An,requestWorkspaceManagementRefresh:rn,onToggleFavoriteSession:ls,onArchiveSession:l=>zt(l,!0),onUnarchiveSession:l=>zt(l,!1),workspaceManagementStateById:Kn,setWorkspaceManagementStateById:bt,unreadNotificationCount:rs,notificationPanelOpen:Rn,onToggleNotificationPanel:()=>{tn(l=>!l)},onClose:()=>Be(!1)}):null,we=Ue&&E?A:null;return n.jsxs(xc.Provider,{value:m,children:[Ue?n.jsx(n.Fragment,{children:n.jsx(Du,{activeEntry:Js,presentation:_r?"conversation-focus":"default",navigationPanel:on,auxiliaryPanel:we,onOpenNavigation:()=>{$e(!1),Be(!0)},onOpenSearch:()=>{Be(!1),$e(!1),Qs()},onOpenAuxiliary:()=>{E&&(kn(),Be(!1),$e(!0))},onNavigateWorkspaces:()=>{Be(!1),$e(!1),s(jt())},onNavigateTerminals:()=>{Be(!1),$e(!1),s(fe?ps(fe):jt())},onNavigateButler:()=>{Be(!1),$e(!1),s(fe?ms(fe):jt())},onNavigateSessions:()=>{Be(!1),$e(!1),zr()},onNavigateToolFiles:()=>{Be(!1),$e(!1),s(fe?Gl(fe):jt())},onNavigateToolGit:()=>{Be(!1),$e(!1),s(fe?zl(fe):jt())},onNavigateToolProcesses:()=>{Be(!1),$e(!1),s(fe?Kl(fe):jt())},onNavigateSettings:()=>{Be(!1),$e(!1),s("/settings")},children:n.jsx(Uo,{})})}):n.jsx("div",{className:"workbench-shell",ref:C,style:k,onMouseDownCapture:Dt,onDoubleClickCapture:Nr,"data-nav-loading":Re,"data-left-collapsed":ke,"data-right-collapsed":de,"data-info-ready":Se,"data-parallel-conversation-active":ut?"true":void 0,"data-parallel-sidebar-transition":q?"true":void 0,"data-runtime-platform":a.platform,"data-os-family":a.ui.osFamily,"data-overlay-titlebar":a.ui.prefersOverlayTitlebar,children:n.jsxs("div",{className:"workbench-body-shell",children:[n.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":ke,children:n.jsx(fl,{workspaceGroups:Wr,workspaceVisualContextMap:Is,sessionDisplaySortMode:c,favoriteSessions:Ts,favoriteSessionIds:Kt,activeWorkspaceId:fe,isConversationActive:It==="conversation",isTerminalActive:It==="terminals",isButlerActive:It==="butler",isSearchOpen:ct,navigationLoading:Re,navigationError:mt,activeSessionId:Ie,onRefreshNavigation:ze,onSessionUpdated:wt,onNavigateConversation:cs,onNavigateTerminals:()=>s(fe?ps(fe):jt()),onNavigateButler:()=>s(fe?ms(fe):jt()),onOpenSearch:()=>Qs(),onOpenSettings:()=>s("/settings"),onSelectWorkspace:is,onToggleWorkspaceCollapse:Rr,onStartWorkspaceReorder:Er,onPreviewWorkspaceReorder:Pr,onCommitWorkspaceReorder:Ar,allowWorkspaceReorder:!0,subscribeGitSnapshot:nn,requestGitRefresh:Ot,subscribeWorkspaceManagementSnapshot:An,requestWorkspaceManagementRefresh:rn,onToggleFavoriteSession:ls,onArchiveSession:l=>zt(l,!0),onUnarchiveSession:l=>zt(l,!1),workspaceManagementStateById:Kn,setWorkspaceManagementStateById:bt,unreadNotificationCount:rs,notificationPanelOpen:Rn,onToggleNotificationPanel:()=>{tn(l=>!l)},onToggleCollapse:()=>Qe(!0)})}),n.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":ke,role:"separator","aria-label":r("shell.leftResizerLabel"),onMouseDown:ke?void 0:l=>wn("left",l)}),n.jsxs("div",{className:"workbench-main-shell",children:[n.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!ke&&!Ae,children:[n.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":ke,children:[n.jsx(pl,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:$r}),n.jsx(mc,{collapsed:!0}),n.jsx(Uc,{unreadCount:rs,open:Rn,onToggle:()=>{tn(l=>!l)},collapsed:!0})]}),E&&!ut?n.jsx("div",{className:"workbench-collapsed-controls right","data-visible":Ae,children:n.jsx(pl,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:Da})}):null]}),n.jsx(Uo,{})]}),E?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":de,"data-auto-hidden":ut?"true":void 0,role:"separator","aria-label":r("shell.rightResizerLabel"),onMouseDown:de?void 0:l=>wn("right",l)}),n.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":($t==null?void 0:$t.tone)??"root","data-worktree-depth":($t==null?void 0:$t.depth)??0,"data-collapsed":de,"data-auto-hidden":ut?"true":void 0,"data-custom-panel":It==="butler","data-parallel-transition":q?"true":void 0,"aria-hidden":de&&!q,style:yn($t),children:ut&&!q?null:It==="butler"?n.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Un}):n.jsx(bl,{panelReady:Se,activeTab:qe,fileRevealRequest:Mn,onTabChange:l=>{kn(),Fe(l)},onToggleCollapse:()=>et(!0),currentSessionId:Xe?null:Ie,activeWorkspaceId:Vt,navigationGroups:U,workspaceContext:$t,worktreeMeta:gn,worktreeMergeState:Dr,onRefreshWorktreeMergePreview:an,onApplyWorktreeMerge:Ir,onCleanupWorktree:Tr})})]}):null]})}),n.jsx(nf,{open:Rn,notifications:Xn,archivedNotificationIds:Yn,showArchivedNotifications:En,onClose:()=>tn(!1),onToggleShowArchivedNotifications:Zn,onArchiveNotification:l=>{as(l,!0)},onUnarchiveNotification:l=>{as(l,!1)},onSelectNotification:Aa,preferredWorkspaceId:fe,preferredSessionId:Xe?null:Ie}),n.jsx(vf,{open:ct,mode:Gn,keyword:pn,codeWorkspaceId:Nn,codeResults:Cr,codeLoading:jr,codeError:Ks,workspaceOptions:La,sessionResults:Ba,onClose:er,onModeChange:l=>{ks(l),In(null),Bt([])},onKeywordChange:l=>{Cn(l),Gn==="code"&&!l.trim()&&(Bt([]),In(null))},onCodeWorkspaceChange:l=>en(l),onCodeSearch:()=>{Oa()},onOpenSession:l=>{er();const u=Ee.find(b=>b.session.sessionId===l)??null;s(u?Ut(u.workspace.id,l):jt())}}),n.jsxs(nt,{open:Oe!==null,title:r("shell.worktreeCleanupModalTitle"),description:r("shell.worktreeCleanupModalDescription"),onClose:()=>{var l;Oe&&((l=tt[Oe.workspaceId])!=null&&l.cleaning)||(Tn(!1),qn(null))},children:[n.jsx("p",{className:"workbench-section-empty",children:Oe?r("shell.worktreeCleanupConfirm",{name:Oe.displayName||Oe.branchName}):""}),Oe?n.jsxs("div",{className:"worktree-cleanup-modal-options",children:[n.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[n.jsx("input",{type:"checkbox",checked:Vn,disabled:!!((Vr=tt[Oe.workspaceId])!=null&&Vr.cleaning)||((nr=(Xr=tt[Oe.workspaceId])==null?void 0:Xr.preview)==null?void 0:nr.alreadyMerged)!==!0,onChange:l=>Tn(l.target.checked)}),n.jsx("span",{children:r("shell.worktreeCleanupDeleteBranchLabel",{branch:Oe.branchName})})]}),((rr=(sr=tt[Oe.workspaceId])==null?void 0:sr.preview)==null?void 0:rr.alreadyMerged)!==!0?n.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:r("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!(Oe&&((Mt=tt[Oe.workspaceId])!=null&&Mt.cleaning)),onClick:()=>{Tn(!1),qn(null)},children:r("common.cancel")}),n.jsx("button",{type:"button",className:Vn&&Oe&&((ar=(Tt=tt[Oe.workspaceId])==null?void 0:Tt.preview)==null?void 0:ar.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!Oe||!!(Oe&&((or=tt[Oe.workspaceId])!=null&&or.cleaning)),onClick:()=>{Oe&&Mr(Oe)},children:Oe&&((Oo=tt[Oe.workspaceId])!=null&&Oo.cleaning)?r("shell.worktreeCleanupRunning"):Vn&&Oe&&((Ho=($o=tt[Oe.workspaceId])==null?void 0:$o.preview)==null?void 0:Ho.alreadyMerged)===!0?r("shell.worktreeCleanupDeleteBranchAction"):r("shell.worktreeCleanupAction")})]})]}),Ue?n.jsxs(n.Fragment,{children:[Or?null:n.jsx(gl,{isOpen:Lt,side:"left",onClose:()=>Be(!1),children:on}),Rs?null:n.jsx(gl,{isOpen:jn,side:"right",onClose:()=>$e(!1),children:we})]}):null]})}function gl({isOpen:e,side:t,onClose:s,children:a,className:o,overlayClassName:c}){if(!e)return null;const p=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:["mobile-nav-overlay","open",c].filter(Boolean).join(" "),onClick:s,role:"button",tabIndex:0,"aria-label":r("common.back"),onKeyDown:h=>{h.key==="Escape"&&s()}}),n.jsx("div",{className:["mobile-nav-drawer",t,"open",o].filter(Boolean).join(" "),children:a})]});return typeof document>"u"?p:Os.createPortal(p,document.body)}function Hb(){return i.useContext(xc)??{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 Kc(e){return e.startsWith("draft-")}export{_b as $,Gh as A,Tp as B,Lo as C,Lh as D,Bh as E,tu as F,sb as G,Qd as H,Ao as I,Jh as J,Wh as K,tp as L,du as M,ab as N,_n as O,Us as P,Ws as Q,oa as R,hr as S,Fp as T,Hp as U,Op as V,qu as W,ga as X,$p as Y,Up as Z,_p as _,$b as a,po as a$,Wb as a0,Lb as a1,Fb as a2,Pb as a3,Wf as a4,pt as a5,Af as a6,cu as a7,su as a8,Ca as a9,hb as aA,kb as aB,wb as aC,gb as aD,fb as aE,pb as aF,Rb as aG,mb as aH,Cb as aI,Ab as aJ,Bb as aK,Db as aL,Tb as aM,yb as aN,Sb as aO,jb as aP,Nb as aQ,Ib as aR,Mb as aS,gp as aT,bb as aU,vb as aV,xb as aW,Eb as aX,gc as aY,Qh as aZ,bp as a_,Gp as aa,Zd as ab,ou as ac,tb as ad,eb as ae,rb as af,ru as ag,yn as ah,Zo as ai,nb as aj,ch as ak,dh as al,uh as am,lb as an,Wo as ao,$h as ap,Hh as aq,db as ar,ob as as,nu as at,au,Co as av,jt as aw,Ku as ax,ib as ay,ub as az,ya as b,Of as b0,Uf as b1,Hf as b2,Bf as b3,qd as b4,Df as b5,_f as b6,Yd as b7,Pf as b8,$f as b9,Kf as ba,Xf as bb,Vd as bc,Qf as bd,qf as be,Gf as bf,Vf as bg,zf as bh,Zf as bi,Jf as bj,Yf as bk,Ff as bl,Lf as bm,Hl as bn,Ut as c,Bp as d,Mp as e,Ob as f,Oh as g,op as h,cb as i,ip as j,pc as k,dp as l,yi as m,Fs as n,ps as o,Ul as p,ms as q,tc as r,Kl as s,hn as t,Hb as u,zh as v,br as w,qh as x,Gl as y,zl as z};