@jingyi0605/codingns 0.6.5 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/dist/public/assets/AdaptiveButlerPage-B8mg25ze.js +3 -0
  2. package/dist/public/assets/{App-B9HcTkMT.js → App-C2lNmeKL.js} +6 -6
  3. package/dist/public/assets/{BootstrapPage-BgLdZEKQ.js → BootstrapPage-CAVA-a8h.js} +1 -1
  4. package/dist/public/assets/ConversationPage-B6BGOX4C.js +6 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-YCBnyC58.js → DesktopDetachPreviewPage-B37DUL15.js} +1 -1
  6. package/dist/public/assets/{DesktopWindowPage-CrvndE23.js → DesktopWindowPage-CDA6l7lm.js} +1 -1
  7. package/dist/public/assets/{FileContextPanel-CdC7GGw5.js → FileContextPanel-CMGTtAB6.js} +1 -1
  8. package/dist/public/assets/{GitSidebar-z2SBinQh.js → GitSidebar--DCqBiGL.js} +1 -1
  9. package/dist/public/assets/{MobileCreateSessionSheet-Cb2HM-y3.js → MobileCreateSessionSheet-THIrIzJ3.js} +1 -1
  10. package/dist/public/assets/{MobileTopHeaderFrame-etF2HKlm.js → MobileTopHeaderFrame-D-X7pVnV.js} +1 -1
  11. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-CuGJ31kb.js → MobileWorkspaceSwitcherHeader-Cczi7RYu.js} +1 -1
  12. package/dist/public/assets/{RelayConnectEntryPage-BB6DbGtP.js → RelayConnectEntryPage-D417tgWj.js} +1 -1
  13. package/dist/public/assets/{ServerSettingsModal-Bl1sacZg.js → ServerSettingsModal-BdTxbRbU.js} +1 -1
  14. package/dist/public/assets/SessionIndexPage-D5iefVcc.js +1 -0
  15. package/dist/public/assets/SettingsPage-iCFe_DHP.js +2 -0
  16. package/dist/public/assets/{TerminalManagerPanel-BOm8Hi_v.js → TerminalManagerPanel-CtldwWz8.js} +1 -1
  17. package/dist/public/assets/{TerminalPage-B5JNFU6w.js → TerminalPage-DAzQTmQC.js} +18 -18
  18. package/dist/public/assets/{TerminalRuntimeFallbackModal-CM3LRKOJ.js → TerminalRuntimeFallbackModal-DLOhAvaq.js} +1 -1
  19. package/dist/public/assets/{ToolFilesPage-GSqKQsj_.js → ToolFilesPage-D7thcDEv.js} +1 -1
  20. package/dist/public/assets/{ToolGitPage-BVFWMMQp.js → ToolGitPage-uPRsxdcn.js} +1 -1
  21. package/dist/public/assets/{ToolProcessesPage-DZ456fYz.js → ToolProcessesPage-B1uOk0Ef.js} +1 -1
  22. package/dist/public/assets/{ToolsHomePage-DsJp0y8A.js → ToolsHomePage-rU3V8mmh.js} +1 -1
  23. package/dist/public/assets/{WorkbenchLandingPage-DyPei0e-.js → WorkbenchLandingPage-BudM2C69.js} +1 -1
  24. package/dist/public/assets/WorkbenchLayout-Dybarc1V.js +244 -0
  25. package/dist/public/assets/{WorkbenchModal-LNfB69qx.js → WorkbenchModal-DMQutm1x.js} +1 -1
  26. package/dist/public/assets/WorkbenchShellRoute-Cy4WBbzq.js +1 -0
  27. package/dist/public/assets/{WorkspaceDebugDetailPage-CaXj5zVI.js → WorkspaceDebugDetailPage-CHqo-uDf.js} +1 -1
  28. package/dist/public/assets/{WorkspaceDetailPage-DOexuuaw.js → WorkspaceDetailPage-CGkAH1W-.js} +1 -1
  29. package/dist/public/assets/{WorkspaceHomePage-DkCHNjKD.js → WorkspaceHomePage-CfuPVITd.js} +1 -1
  30. package/dist/public/assets/{client-runtime-manager-6OoYHXGd.js → client-runtime-manager-CKbtaemV.js} +1 -1
  31. package/dist/public/assets/file-tree-icon-Bc0KADEl.js +3 -0
  32. package/dist/public/assets/index-DNRyROOG.css +1 -0
  33. package/dist/public/assets/index-oGylLBIX.js +42 -0
  34. package/dist/public/assets/{login-direct-candidate-resolver-CLlYtBRq.js → login-direct-candidate-resolver-DjJMbqB7.js} +1 -1
  35. package/dist/public/assets/model-switch-api-T55eW6D4.js +1 -0
  36. package/dist/public/assets/{preferences-service-BCcfYP_d.js → preferences-service-BTKBl5xM.js} +1 -1
  37. package/dist/public/assets/realtime-client-ww7MnbTD.js +1 -0
  38. package/dist/public/assets/{relay-entry-BmLkMKuq.js → relay-entry-sdeFnTbY.js} +1 -1
  39. package/dist/public/assets/styles-BjPytabP.css +1 -0
  40. package/dist/public/assets/{terminal-runtime-meta-0h-75uRy.js → terminal-runtime-meta-Cvt1ID92.js} +1 -1
  41. package/dist/public/assets/{useRegisteredDebugTemplates-rBVmAqh3.js → useRegisteredDebugTemplates-O-ymgLd9.js} +1 -1
  42. package/dist/public/index.html +2 -2
  43. package/dist/server/config/env.js +21 -1
  44. package/dist/server/config/env.js.map +1 -1
  45. package/dist/server/config/opencode-base-url-resolver.d.ts +16 -0
  46. package/dist/server/config/opencode-base-url-resolver.js +154 -0
  47. package/dist/server/config/opencode-base-url-resolver.js.map +1 -1
  48. package/dist/server/helpers/wechat-claw-runtime/main.d.ts +1 -0
  49. package/dist/server/helpers/wechat-claw-runtime/main.js +38 -0
  50. package/dist/server/helpers/wechat-claw-runtime/main.js.map +1 -0
  51. package/dist/server/helpers/wechat-claw-runtime/modules/errors.d.ts +5 -0
  52. package/dist/server/helpers/wechat-claw-runtime/modules/errors.js +32 -0
  53. package/dist/server/helpers/wechat-claw-runtime/modules/errors.js.map +1 -0
  54. package/dist/server/helpers/wechat-claw-runtime/modules/login-service.d.ts +16 -0
  55. package/dist/server/helpers/wechat-claw-runtime/modules/login-service.js +209 -0
  56. package/dist/server/helpers/wechat-claw-runtime/modules/login-service.js.map +1 -0
  57. package/dist/server/helpers/wechat-claw-runtime/modules/poll-service.d.ts +18 -0
  58. package/dist/server/helpers/wechat-claw-runtime/modules/poll-service.js +135 -0
  59. package/dist/server/helpers/wechat-claw-runtime/modules/poll-service.js.map +1 -0
  60. package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.d.ts +34 -0
  61. package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +394 -0
  62. package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -0
  63. package/dist/server/helpers/wechat-claw-runtime/modules/send-service.d.ts +9 -0
  64. package/dist/server/helpers/wechat-claw-runtime/modules/send-service.js +64 -0
  65. package/dist/server/helpers/wechat-claw-runtime/modules/send-service.js.map +1 -0
  66. package/dist/server/helpers/wechat-claw-runtime/modules/types.d.ts +167 -0
  67. package/dist/server/helpers/wechat-claw-runtime/modules/types.js +3 -0
  68. package/dist/server/helpers/wechat-claw-runtime/modules/types.js.map +1 -0
  69. package/dist/server/helpers/wechat-claw-runtime/modules/wechat-api-client.d.ts +34 -0
  70. package/dist/server/helpers/wechat-claw-runtime/modules/wechat-api-client.js +160 -0
  71. package/dist/server/helpers/wechat-claw-runtime/modules/wechat-api-client.js.map +1 -0
  72. package/dist/server/helpers/wechat-claw-runtime/routes/accounts.d.ts +9 -0
  73. package/dist/server/helpers/wechat-claw-runtime/routes/accounts.js +24 -0
  74. package/dist/server/helpers/wechat-claw-runtime/routes/accounts.js.map +1 -0
  75. package/dist/server/helpers/wechat-claw-runtime/server.d.ts +5 -0
  76. package/dist/server/helpers/wechat-claw-runtime/server.js +36 -0
  77. package/dist/server/helpers/wechat-claw-runtime/server.js.map +1 -0
  78. package/dist/server/middlewares/auth-guard.js +4 -1
  79. package/dist/server/middlewares/auth-guard.js.map +1 -1
  80. package/dist/server/modules/butler/butler-control-session-service.d.ts +16 -1
  81. package/dist/server/modules/butler/butler-control-session-service.js +106 -75
  82. package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
  83. package/dist/server/modules/butler/butler-session-service.js +44 -15
  84. package/dist/server/modules/butler/butler-session-service.js.map +1 -1
  85. package/dist/server/modules/channels/channel-bridge-service.d.ts +55 -0
  86. package/dist/server/modules/channels/channel-bridge-service.js +340 -0
  87. package/dist/server/modules/channels/channel-bridge-service.js.map +1 -0
  88. package/dist/server/modules/channels/channel-controller.d.ts +52 -0
  89. package/dist/server/modules/channels/channel-controller.js +54 -0
  90. package/dist/server/modules/channels/channel-controller.js.map +1 -0
  91. package/dist/server/modules/channels/channel-delivery-service.d.ts +63 -0
  92. package/dist/server/modules/channels/channel-delivery-service.js +429 -0
  93. package/dist/server/modules/channels/channel-delivery-service.js.map +1 -0
  94. package/dist/server/modules/channels/channel-gateway-controller.d.ts +15 -0
  95. package/dist/server/modules/channels/channel-gateway-controller.js +16 -0
  96. package/dist/server/modules/channels/channel-gateway-controller.js.map +1 -0
  97. package/dist/server/modules/channels/channel-gateway-service.d.ts +24 -0
  98. package/dist/server/modules/channels/channel-gateway-service.js +56 -0
  99. package/dist/server/modules/channels/channel-gateway-service.js.map +1 -0
  100. package/dist/server/modules/channels/channel-platform-adapters.d.ts +46 -0
  101. package/dist/server/modules/channels/channel-platform-adapters.js +315 -0
  102. package/dist/server/modules/channels/channel-platform-adapters.js.map +1 -0
  103. package/dist/server/modules/channels/channel-platform-catalog.d.ts +3 -0
  104. package/dist/server/modules/channels/channel-platform-catalog.js +42 -0
  105. package/dist/server/modules/channels/channel-platform-catalog.js.map +1 -0
  106. package/dist/server/modules/channels/channel-polling-scheduler.d.ts +31 -0
  107. package/dist/server/modules/channels/channel-polling-scheduler.js +93 -0
  108. package/dist/server/modules/channels/channel-polling-scheduler.js.map +1 -0
  109. package/dist/server/modules/channels/channel-polling-service.d.ts +46 -0
  110. package/dist/server/modules/channels/channel-polling-service.js +176 -0
  111. package/dist/server/modules/channels/channel-polling-service.js.map +1 -0
  112. package/dist/server/modules/channels/channel-service.d.ts +108 -0
  113. package/dist/server/modules/channels/channel-service.js +397 -0
  114. package/dist/server/modules/channels/channel-service.js.map +1 -0
  115. package/dist/server/modules/channels/wechat-claw-client.d.ts +51 -0
  116. package/dist/server/modules/channels/wechat-claw-client.js +245 -0
  117. package/dist/server/modules/channels/wechat-claw-client.js.map +1 -0
  118. package/dist/server/modules/channels/wechat-claw-runtime-boundary.d.ts +4 -0
  119. package/dist/server/modules/channels/wechat-claw-runtime-boundary.js +13 -0
  120. package/dist/server/modules/channels/wechat-claw-runtime-boundary.js.map +1 -0
  121. package/dist/server/modules/channels/wechat-claw-runtime-client.d.ts +14 -0
  122. package/dist/server/modules/channels/wechat-claw-runtime-client.js +95 -0
  123. package/dist/server/modules/channels/wechat-claw-runtime-client.js.map +1 -0
  124. package/dist/server/modules/channels/wechat-claw-runtime-manager.d.ts +16 -0
  125. package/dist/server/modules/channels/wechat-claw-runtime-manager.js +133 -0
  126. package/dist/server/modules/channels/wechat-claw-runtime-manager.js.map +1 -0
  127. package/dist/server/modules/channels/wechat-claw-runtime-types.d.ts +1 -0
  128. package/dist/server/modules/channels/wechat-claw-runtime-types.js +2 -0
  129. package/dist/server/modules/channels/wechat-claw-runtime-types.js.map +1 -0
  130. package/dist/server/modules/opencli/opencli-bridge-skill-service.js +2 -1
  131. package/dist/server/modules/opencli/opencli-bridge-skill-service.js.map +1 -1
  132. package/dist/server/modules/provider/provider-catalog-service.d.ts +5 -6
  133. package/dist/server/modules/provider/provider-catalog-service.js +12 -57
  134. package/dist/server/modules/provider/provider-catalog-service.js.map +1 -1
  135. package/dist/server/modules/provider/provider-controller.d.ts +1 -0
  136. package/dist/server/modules/provider/provider-controller.js +5 -0
  137. package/dist/server/modules/provider/provider-controller.js.map +1 -1
  138. package/dist/server/modules/provider/provider-runtime-state-service.d.ts +24 -0
  139. package/dist/server/modules/provider/provider-runtime-state-service.js +141 -0
  140. package/dist/server/modules/provider/provider-runtime-state-service.js.map +1 -0
  141. package/dist/server/modules/sessions/session-history-service.d.ts +3 -3
  142. package/dist/server/modules/sessions/session-history-service.js +150 -47
  143. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  144. package/dist/server/modules/sessions/session-live-runtime-service.js +9 -11
  145. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  146. package/dist/server/modules/sessions/session-provider-config-service.d.ts +1 -0
  147. package/dist/server/modules/sessions/session-provider-config-service.js +28 -7
  148. package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -1
  149. package/dist/server/modules/sessions/session-provider-error-mapper.js +7 -0
  150. package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
  151. package/dist/server/modules/tasks/task-types.d.ts +2 -0
  152. package/dist/server/modules/tasks/task-types.js +2 -0
  153. package/dist/server/modules/tasks/task-types.js.map +1 -1
  154. package/dist/server/routes/channels.d.ts +3 -0
  155. package/dist/server/routes/channels.js +16 -0
  156. package/dist/server/routes/channels.js.map +1 -0
  157. package/dist/server/routes/providers.js +1 -0
  158. package/dist/server/routes/providers.js.map +1 -1
  159. package/dist/server/routes/public.d.ts +2 -1
  160. package/dist/server/routes/public.js +3 -1
  161. package/dist/server/routes/public.js.map +1 -1
  162. package/dist/server/server/create-server.d.ts +22 -0
  163. package/dist/server/server/create-server.js +62 -3
  164. package/dist/server/server/create-server.js.map +1 -1
  165. package/dist/server/shared/http/error-handler.js +59 -3
  166. package/dist/server/shared/http/error-handler.js.map +1 -1
  167. package/dist/server/storage/repositories/channel-account-repository.d.ts +12 -0
  168. package/dist/server/storage/repositories/channel-account-repository.js +153 -0
  169. package/dist/server/storage/repositories/channel-account-repository.js.map +1 -0
  170. package/dist/server/storage/repositories/channel-delivery-repository.d.ts +13 -0
  171. package/dist/server/storage/repositories/channel-delivery-repository.js +156 -0
  172. package/dist/server/storage/repositories/channel-delivery-repository.js.map +1 -0
  173. package/dist/server/storage/repositories/channel-inbound-event-repository.d.ts +12 -0
  174. package/dist/server/storage/repositories/channel-inbound-event-repository.js +144 -0
  175. package/dist/server/storage/repositories/channel-inbound-event-repository.js.map +1 -0
  176. package/dist/server/storage/repositories/channel-thread-repository.d.ts +12 -0
  177. package/dist/server/storage/repositories/channel-thread-repository.js +152 -0
  178. package/dist/server/storage/repositories/channel-thread-repository.js.map +1 -0
  179. package/dist/server/storage/repositories/provider-runtime-state-repository.d.ts +9 -0
  180. package/dist/server/storage/repositories/provider-runtime-state-repository.js +50 -0
  181. package/dist/server/storage/repositories/provider-runtime-state-repository.js.map +1 -0
  182. package/dist/server/storage/sqlite/schema.sql +114 -0
  183. package/dist/server/types/domain.d.ts +82 -0
  184. package/dist/server/ws/workbench-ws-hub.js +8 -2
  185. package/dist/server/ws/workbench-ws-hub.js.map +1 -1
  186. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +28 -11
  187. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
  188. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +61 -8
  189. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
  190. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +3 -0
  191. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +94 -21
  192. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
  193. package/package.json +1 -1
  194. package/dist/public/assets/AdaptiveButlerPage-CfsUVZKl.js +0 -3
  195. package/dist/public/assets/ConversationPage-Cj8go7L0.js +0 -4
  196. package/dist/public/assets/SessionIndexPage-NbF9gJnp.js +0 -1
  197. package/dist/public/assets/SettingsPage-DGsmQpLv.js +0 -1
  198. package/dist/public/assets/WorkbenchLayout-DlbgBT3n.js +0 -4
  199. package/dist/public/assets/WorkbenchShellRoute-BsxumYx5.js +0 -1
  200. package/dist/public/assets/file-tree-icon-9pt1OStn.js +0 -31
  201. package/dist/public/assets/index-BwlbvwaA.css +0 -1
  202. package/dist/public/assets/index-DSw-TkQL.js +0 -42
  203. package/dist/public/assets/model-switch-api-C-l8-E1S.js +0 -1
  204. package/dist/public/assets/session-runtime-machine-DgtvREca.js +0 -21
  205. package/dist/public/assets/styles-CsEMfdaS.css +0 -1
  206. /package/dist/public/assets/{styles-DRVvx_kv.js → styles-lhQGDlPF.js} +0 -0
@@ -0,0 +1,244 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-CMGTtAB6.js","assets/index-oGylLBIX.js","assets/index-DNRyROOG.css","assets/App-C2lNmeKL.js","assets/App-CcDXqFl1.css","assets/model-switch-api-T55eW6D4.js","assets/WorkbenchModal-DMQutm1x.js","assets/file-tree-icon-Bc0KADEl.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-sdeFnTbY.js","assets/GitSidebar--DCqBiGL.js","assets/TerminalManagerPanel-CtldwWz8.js","assets/terminal-runtime-meta-Cvt1ID92.js","assets/TerminalRuntimeFallbackModal-DLOhAvaq.js"])))=>i.map(i=>d[i]);
2
+ var Jb=Object.defineProperty;var Qb=(e,t,n)=>t in e?Jb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ue=(e,t,n)=>Qb(e,typeof t!="symbol"?t+"":t,n);import{C as xe,t as l,b as f,j as s,e as Rn,m as Yi,H as sf,J as Zb,F as ek,K as tk,w as Xc,A as Jc,g as of,p as Ba,L as nk,M as rk,N as af,i as lf,O as lc,f as Qc,h as cc,P as sk,l as cf,y as ik,n as ok,z as ak,d as lk,_ as Zc}from"./index-oGylLBIX.js";import{m as rt,e as vn,h as Oa,u as io,f as Pn,g as or,i as ck,j as uk,O as ed}from"./App-C2lNmeKL.js";import{e as eu,f as Vs,i as tu,j as ln,k as Po,V as uf,A as dk,a2 as hk,a3 as pk,H as df,l as fk,m as mk,a4 as hf,a5 as gk,M as bk,a6 as kk,a7 as xk,n as yk,t as wk,q as vk,s as pf,h as $s,a as uc,v as Sk,o as Ck,p as nu,a8 as Nk,a9 as jk,aa as Tk,u as Lo,g as Ik,ab as Ek,ac as Mk,ad as Rk,ae as ff,af as Ak,ag as mf,ah as Pk,ai as Lk,aj as gf,K as Dk,S as _k,R as td,r as Bk,ak as Ok}from"./model-switch-api-T55eW6D4.js";import{t as Ks,P as xa,g as bf}from"./window-BVUB8gMK.js";import{R as Wk,_ as nd,a as rd,C as kf,i as Le}from"./event-DvH9tcej.js";import{W as Nt,M as Fk,D as ru}from"./WorkbenchModal-DMQutm1x.js";import{r as $k,b as zk}from"./relay-entry-sdeFnTbY.js";const Ys=new Map,xf=48;function us(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function sd(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Hk(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function yf(e){try{const t=JSON.parse(e);return Hk(t)?t:null}catch{return null}}function Uk(){if(!us())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 wf(){if(!us())return[];const e=[];for(const t of Uk()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=yf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function Xi(e){if(us())try{window.sessionStorage.removeItem(e)}catch{}}function Do(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??xf,r=wf().filter(o=>!t.has(o.key)),i=Math.max(0,t.size+r.length-n);for(let o=0;o<i;o+=1){const a=r[o];if(!a)break;Xi(a.key)}}function qk(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function bl(e,t){if(!us())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return qk(n)?"quota_exceeded":"failed"}}function Gk(e,t){const n=bl(e,t);if(n==="success"){Do({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(Xi(e),Do({maxCount:Math.max(0,xf-1)}),bl(e,t)==="success"){Do({preserveKeys:[e]});return}for(const r of wf())if(r.key!==e&&(Xi(r.key),bl(e,t)==="success")){Do({preserveKeys:[e]});return}}}function ya(e,t){const n=Ys.get(e);if(n){if(!sd(n.savedAt,t))return n.value;Ys.delete(e)}if(!us())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=yf(r);return!i||sd(i.savedAt,t)?(Xi(e),Ys.delete(e),null):(Ys.set(e,i),i.value)}function Hi(e,t){const n={savedAt:Date.now(),value:t};if(Ys.set(e,n),!!us())try{Gk(e,JSON.stringify(n))}catch{}}function SA(e){Ys.delete(e),us()&&Xi(e)}const Vk="codingns.debug.perf",Kk="codingns.debug.sessionMessageDedup",Yk="codingns.debug.opencodeOrder",Xk="codingns.debug.timelineScroll";function Jk(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Vk)==="1"}catch{return!1}}function Dt(e,t){if(!Jk()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function Qk(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Kk)==="1"}catch{return!1}}function dc(e,t){if(!Qk()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function Zk(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Yk)==="1"}catch{return!1}}function CA(e,t){if(!Zk()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_OPENCODE_ORDER_DEBUG__??[];o.push(r),o.length>500&&o.splice(0,o.length-500),i.__CODINGNS_OPENCODE_ORDER_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[opencode-order-ui] ${e} ${n}ms`,t);return}console.info(`[opencode-order-ui] ${e} ${n}ms`)}function hc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Xk)==="1"}catch{return!1}}function ex(e,t){if(!hc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function NA(e,t,n,r){return xe.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function jA(e){return xe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function TA(e){return xe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function IA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/download?${n.toString()}`)}function tx(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return xe.request(`/api/files/search?${i.toString()}`)}function EA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview?${n.toString()}`)}function MA(e){return xe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function RA(e){return xe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function AA(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return xe.request(`/api/git/diff?${r.toString()}`)}function PA(e,t){return xe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function LA(e,t){return xe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function DA(e,t){return xe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function _A(e,t){return xe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function BA(e,t){return xe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function OA(e){return xe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function WA(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),xe.request(`/api/git/history?${r.toString()}`)}function FA(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return xe.request(`/api/git/commit-detail?${n.toString()}`)}function nx(e){return xe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function rx(e){return xe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function $A(e,t,n){return xe.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function zA(e,t,n,r,i){return xe.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function HA(e){return xe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var ha,pa;function vf(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:vf(n));else if("action"in e&&e.action){const n=new kf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function ii(e,t){const n=new kf;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Ks(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Ks(t.icon)),"items"in t&&t.items)){let r=function(i){var o;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((o=i.item.About)===null||o===void 0)&&o.icon)&&(i.item.About.icon=Ks(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=Ks(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),vf(i))};t.items=t.items.map(r)}return Le("plugin:menu|new",{kind:e,options:t,handler:n})}class oi extends Wk{get id(){return nd(this,ha,"f")}get kind(){return nd(this,pa,"f")}constructor(t,n,r){super(t),ha.set(this,void 0),pa.set(this,void 0),rd(this,ha,n),rd(this,pa,r)}}ha=new WeakMap,pa=new WeakMap;class su extends oi{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return ii("MenuItem",t).then(([n,r])=>new su(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class iu extends oi{constructor(t,n){super(t,n,"Check")}static async new(t){return ii("Check",t).then(([n,r])=>new iu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return Le("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return Le("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var id;(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"})(id||(id={}));class ou extends oi{constructor(t,n){super(t,n,"Icon")}static async new(t){return ii("Icon",t).then(([n,r])=>new ou(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Ks(t)})}}class au extends oi{constructor(t,n){super(t,n,"Predefined")}static async new(t){return ii("Predefined",t).then(([n,r])=>new au(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function Zs([e,t,n]){switch(n){case"Submenu":return new Wa(e,t);case"Predefined":return new au(e,t);case"Check":return new iu(e,t);case"Icon":return new ou(e,t);case"MenuItem":default:return new su(e,t)}}class Wa extends oi{constructor(t,n){super(t,n,"Submenu")}static async new(t){return ii("Submenu",t).then(([n,r])=>new Wa(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(Zs)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(Zs))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?Zs(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof xa?t:t?new xa(t):null})}async setAsWindowsMenuForNSApp(){return Le("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return Le("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Ks(t)})}}class Xs extends oi{constructor(t,n){super(t,n,"Menu")}static async new(t){return ii("Menu",t).then(([n,r])=>new Xs(n,r))}static async default(){return Le("plugin:menu|create_default").then(([t,n])=>new Xs(t,n))}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(Zs)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(Zs))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?Zs(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof xa?t:t?new xa(t):null})}async setAsAppMenu(){return Le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Xs(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return Le("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new Xs(r[0],r[1]):null)}}async function sx(e){if(e.length===0)return;await(await Xs.new({items:await Promise.all(e.map(n=>Sf(n)))})).popup(void 0,bf())}async function Sf(e){return"items"in e?Wa.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>Sf(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const od={"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)"}},ix=2600,Cf="workbench.parallel.pane.palette";let zs=null;const ad=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function ox(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 Nf(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function ax(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=od[t]??od["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function UA(e){const t=wa(e.overrideColor)??lx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":ld(t,.08),"--parallel-group-surface":ld(t,.03)}}function qA(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=jf();return wa(n[t]??null)}function GA(e,t){if(typeof window>"u")return wa(t);const n=e.trim();if(!n)return null;const r=jf(),i=wa(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(Cf,JSON.stringify(r)),i}function lx(e,t){const n=ad.length,r=Math.abs(fx(e))%n;return ad[(r+t*5)%n]}function VA(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function cx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function KA(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function YA(e){var n,r,i;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function ux(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function dx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function hx(e,t="create"){zs={groupId:e,createdAt:Date.now(),...ox(t)}}function px(e){return!zs||zs.groupId!==e?null:Date.now()-zs.createdAt>ix?(zs=null,null):zs}function jf(){if(typeof window>"u")return{};const e=window.localStorage.getItem(Cf);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function fx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function wa(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function ld(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),o=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${i}, ${o}, ${n})`}function lu(e,t){const n=new Map(e.map(o=>[t.getId(o),o])),r=new Map,i=[];for(const o of e){const a=mx(o,n,t);if(!a){i.push(o);continue}const c=r.get(a)??[];r.set(a,[...c,o])}return[...i].sort(t.compare).map(o=>Ef(o,0,r,t,new Set))}function ai(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Tf(e){return e.flatMap(t=>[t.item,...Tf(ai(t))])}function ns(e){return e.flatMap(t=>[t,...ns(ai(t))])}function cu(e,t){return e.some(n=>t(n.item)||cu(ai(n),t))}function If(e,t,n){return e?n(e.item)===t?!0:ai(e).some(r=>If(r,t,n)):!1}function Hs(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const o=Hs(ai(r),t,n);if(If(r,t,n)&&o.length>=0)return[i,...o]}return[]}function Ef(e,t,n,r,i){const o=r.getId(e),a=new Set(i);a.add(o);const c=[...n.get(o)??[]].filter(u=>!a.has(r.getId(u))).sort(r.compare).map(u=>Ef(u,t+1,n,r,a));return{item:e,depth:t,children:c}}function mx(e,t,n){const r=cd(n.getParentId(e));if(!r)return null;const i=t.get(r);if(!i)return null;const o=new Set([n.getId(e)]);let a=i;for(;a;){const c=n.getId(a);if(o.has(c))return null;o.add(c);const u=cd(n.getParentId(a));if(!u||(a=t.get(u),!a))return r}return r}function cd(e){const t=e==null?void 0:e.trim();return t||null}function Yt(){return"/workspaces"}function Qn(e){return`/workspaces/${encodeURIComponent(e)}`}function Mf(e){return`${Qn(e)}/debug`}function ri(e){return`${Qn(e)}/sessions`}function Mn(e,t){return`${ri(e)}/${encodeURIComponent(t)}`}function Rf(e,t){const n=`${Qn(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Af(e){return`${Qn(e)}/tools/files`}function Pf(e){return`${Qn(e)}/tools/git`}function Lf(e){return`${Qn(e)}/tools/processes`}function rs(e){return`${Qn(e)}/terminals`}function as(e,t){const n=`${Qn(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function gx(e){return Bf(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),..._f(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function XA(e,t){return lu(Bf(e),{getId:n=>n.session.sessionId,getParentId:n=>bx(n.session,t),compare:xx})}function bx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:Nf(e)}function Df(e,t){const n=kx(),r=new URLSearchParams({provider:t});return`${Mn(e,n)}?${r.toString()}`}function kx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function xx(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function _f(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),..._f(t.children)])}function Bf(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}const yx="mobile.tools.last-primary-tool";function Of(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(yx)==="git"?"git":"files"}catch{return"files"}}function uu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const o=rt(i.pattern,e),a=((r=o==null?void 0:o.params.workspaceId)==null?void 0:r.trim())??null;if(a)return{workspaceId:a,routeKind:i.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of n)if(rt(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function wx(e,t){const n=uu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":Of()}function du(e,t){const n=uu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?rs(n.workspaceId):n!=null&&n.workspaceId?Rf(n.workspaceId,wx(e,t)):n!=null&&n.legacy?Of()==="git"?"/tools?tab=git":"/tools?tab=files":null}function hu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const o=uu(n);return o?o.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(o.routeKind==="home"||o.routeKind==="files"||o.routeKind==="git",null):null}const Wf=f.createContext({composerPortalTarget:null});function pu({composerPortalTarget:e,children:t}){return s.jsx(Wf.Provider,{value:{composerPortalTarget:e},children:t})}function JA(){return f.useContext(Wf)}function fu(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const o=e.current,a=t.current;if(!n||!o||!a){i(void 0),o&&o.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=o,u=a;function d(){if(!e.current||!u.isConnected)return;const p=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",p),i(p)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const vx=3e3,_o=10,ud=84,dd=.36;function mu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),o=f.useRef(null),a=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{a.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function m(){Zr(i),i.current=window.setTimeout(()=>{g()},vx)}function g(){d("hidden"),p(0)}function x(){d("visible"),p(1),m()}f.useEffect(()=>{if(Zr(i),!e){Zr(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return x(),()=>{Zr(i)}},[e,r,n]),f.useEffect(()=>()=>{Zr(i)},[]),f.useEffect(()=>{if(!e||n){o.current=null;return}const C=t.current;if(!C)return;function y(U){if(U.touches.length!==1){o.current=null;return}const L=U.touches[0],I=fd(U.target);if(!L||!I){o.current=null;return}o.current={surface:I,startX:L.clientX,startY:L.clientY,pointerType:"touch",initialState:a.current==="visible"?"visible":"hidden",touchId:L.identifier,dragging:!1,latestProgress:c.current},a.current==="visible"&&Zr(i)}function A(U){const L=o.current;if(!L||L.pointerType!=="touch")return;const I=kl(U.touches,L.touchId);if(!I)return;const H=I.clientX-L.startX,_=I.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(_)<=_o||Math.abs(_)<=Math.abs(H))return;o.current=null,L.initialState==="visible"&&g();return}const se=L.initialState==="hidden"?-_:_;se<=_o&&!L.dragging||(gd(U),L.dragging=!0,L.latestProgress=hd(L.initialState,se),d("dragging"),p(L.latestProgress))}function T(U){const L=o.current;if(!(!L||L.pointerType!=="touch"||!kl(U.changedTouches,L.touchId))){if(o.current=null,!L.dragging){L.initialState==="visible"&&m();return}pd(L.initialState,L.latestProgress,x,d,p)}}function G(U){const L=o.current;if(!(!L||L.pointerType!=="touch"||!kl(U.changedTouches,L.touchId))){if(o.current=null,!L.dragging){L.initialState==="visible"&&m();return}if(L.initialState==="visible"){x();return}d("hidden"),p(0)}}function P(U){if(U.pointerType!=="touch")return;const L=fd(U.target);if(!L){o.current=null;return}if(o.current={surface:L,startX:U.clientX,startY:U.clientY,pointerType:"pointer",initialState:a.current==="visible"?"visible":"hidden",pointerId:U.pointerId,captureTarget:U.target instanceof Element?U.target:null,dragging:!1,latestProgress:c.current},U.target instanceof Element)try{U.target.setPointerCapture(U.pointerId)}catch{}a.current==="visible"&&Zr(i)}function E(U){const L=o.current;if(!L||L.pointerType!=="pointer")return;const I=U.clientX-L.startX,H=U.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(H)<=_o||Math.abs(H)<=Math.abs(I))return;o.current=null,L.initialState==="visible"&&g();return}const _=L.initialState==="hidden"?-H:H;_<=_o&&!L.dragging||(gd(U),L.dragging=!0,L.latestProgress=hd(L.initialState,_),d("dragging"),p(L.latestProgress))}function V(U){const L=o.current;if(!(!L||L.pointerType!=="pointer"||L.pointerId!==U.pointerId)){if(o.current=null,Sx(L),!L.dragging){L.initialState==="visible"&&m();return}pd(L.initialState,L.latestProgress,x,d,p)}}return C.addEventListener("touchstart",y,{passive:!0}),C.addEventListener("pointerdown",P,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",T),window.addEventListener("touchcancel",G),window.addEventListener("pointermove",E,{passive:!1}),window.addEventListener("pointerup",V),window.addEventListener("pointercancel",V),()=>{C.removeEventListener("touchstart",y),C.removeEventListener("pointerdown",P),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",T),window.removeEventListener("touchcancel",G),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function Zr(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function hd(e,t){return md(e==="hidden"?t/ud:1-t/ud,0,1)}function pd(e,t,n,r,i){if(e==="hidden"){if(t>=dd){n();return}r("hidden"),i(0);return}if(t<=1-dd){r("hidden"),i(0);return}n()}function Sx(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 kl(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function fd(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 md(e,t,n){return Math.min(Math.max(e,t),n)}function gd(e){e.cancelable&&e.preventDefault()}function oo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function Fa(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function Ff(e){return e==="medium-navigation"||e==="expanded"}function $f(e){return e==="medium-auxiliary"||e==="expanded"}function gu({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:o,navigationPanel:a,auxiliaryPanel:c}){const u=oo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=Ff(u)&&a,h=$f(u)&&c;return s.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?s.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:a}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:o}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function Cx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=vn(),m=eu(),g=Oa(),x=io(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),T=t==="conversation-focus",G=Fa({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),P=mu({enabled:T,rootRef:S,resetKey:`${g.pathname}${g.search}`}),E=oo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:G}),V=hu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.androidMoreAction")}),U=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Tx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Ix,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Mx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Ex,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Rx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":P.progress.toFixed(4)}:void 0;fu(S,C,T);function I(){const _=du(g.pathname,g.search);if(!_){a();return}x(_,{replace:!0})}const H=s.jsx("nav",{ref:C,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:U.map(_=>s.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":_.key===e,"aria-current":_.key===e?"page":void 0,onClick:()=>{_.key!==e&&m.trigger("selection"),_.onClick()},children:[s.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:_.icon}),s.jsx("span",{className:"android-workbench-bottom-nav-label",children:_.label})]},_.key))});return s.jsx(pu,{composerPortalTarget:T?y:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":E,"data-tabbar-open":T?P.isOpen:!0,"data-conversation-tabbar-state":T?P.state:"default",style:L,children:[V?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[V.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:I,children:s.jsx(Nx,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:V.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:V.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":V.moreButtonLabel,onClick:d,children:s.jsx(jx,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(gu,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:G,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Nx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function jx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Tx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Ix(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Ex(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Mx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Rx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const Ax=120,_i={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function pc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Px(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 Lx(){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(pc);return e.length>0?Math.max(...e):0}function bd(){if(typeof window>"u")return _i;const e=window.visualViewport,t=Lx(),n=(e==null?void 0:e.height)??t,r=pc(n)?Math.round(n):null,i=pc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,o=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:o,keyboardOpen:Px(typeof document<"u"?document.activeElement:null)&&o>=Ax}}function xl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function Dx(e){const[t,n]=f.useState(()=>e?bd():_i),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(_i),xl(!1,_i);return}function i(){n(bd())}function o(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const a=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),a==null||a.addEventListener("resize",i),a==null||a.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",o),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),a==null||a.removeEventListener("resize",i),a==null||a.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",o),xl(!1,_i)}},[e]),f.useEffect(()=>{xl(e,t)},[e,t]),t}function _x({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=vn(),m=eu(),g=Oa(),x=io(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),T=t==="conversation-focus",G=Fa({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),P=mu({enabled:T,rootRef:S,resetKey:`${g.pathname}${g.search}`}),E=oo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:G}),V=hu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),U=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Wx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Fx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(zx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx($x,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Hx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":P.progress.toFixed(4)}:void 0;fu(S,C,T);function I(){const _=du(g.pathname,g.search);if(!_){a();return}x(_,{replace:!0})}const H=s.jsx("nav",{ref:C,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:U.map(_=>s.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":_.key===e,"aria-current":_.key===e?"page":void 0,onClick:()=>{_.key!==e&&m.trigger("selection"),_.onClick()},children:[s.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:_.icon}),s.jsx("span",{className:"ios-workbench-tabbar-label",children:_.label})]},_.key))});return s.jsx(pu,{composerPortalTarget:T?y:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":E,"data-tabbar-open":T?P.isOpen:!0,"data-conversation-tabbar-state":T?P.state:"default",style:L,children:[V?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:V.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:I,children:[s.jsx(Bx,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:V.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:V.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":V.moreButtonLabel,onClick:d,children:s.jsx(Ox,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(gu,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:G,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Bx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function Ox(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Wx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Fx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function $x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function zx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Hx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Ux(e){const t=vn();return t.platform==="ios"?s.jsx(_x,{...e}):t.platform==="android"?s.jsx(Cx,{...e}):s.jsx(qx,{...e})}function qx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=vn(),m=eu(),g=Oa(),x=io(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),T=Dx(p.platform==="web"),G=p.platform==="web"&&T.keyboardOpen,P=t==="conversation-focus",E=Fa({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),V=mu({enabled:P,rootRef:S,suspended:G,resetKey:`${g.pathname}${g.search}`}),U=oo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:E}),L=hu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),I=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Kx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Yx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Jx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Xx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Qx,{}),onClick:h}],H=P?{"--mobile-conversation-tabbar-progress":V.progress.toFixed(4)}:void 0;fu(S,C,P);function _(){const Y=du(g.pathname,g.search);if(!Y){a();return}x(Y,{replace:!0})}const se=s.jsx("nav",{ref:C,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:G,children:I.map(Y=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":Y.key===e,"aria-current":Y.key===e?"page":void 0,onClick:()=>{Y.key!==e&&m.trigger("selection"),Y.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:Y.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:Y.label})]},Y.key))});return s.jsx(pu,{composerPortalTarget:P?y:null,children:s.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":p.platform,"data-mobile-keyboard-open":G,"data-pane-layout":U,"data-tabbar-open":G?!1:P?V.isOpen:!0,"data-conversation-tabbar-state":P?V.state:"default",style:H,children:[L?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[L.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:_,children:s.jsx(Gx,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:L.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:L.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":L.moreButtonLabel,onClick:d,children:s.jsx(Vx,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(gu,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:E,navigationPanel:r,auxiliaryPanel:i,children:n})}),P?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:se})]}):se]})})}function Gx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function Vx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Kx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Yx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Xx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Jx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Qx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class Zx{constructor(t){Ue(this,"maxAttempts");Ue(this,"baseDelayMs");Ue(this,"reconnectAttempts",0);Ue(this,"reconnectTimer",null);Ue(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(!Rn.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 ey{constructor(t){Ue(this,"socket",null);Ue(this,"disposed",!1);Ue(this,"authRecoveryInFlight",!1);Ue(this,"pendingRefresh",!1);Ue(this,"workbenchKnownRevision");Ue(this,"lastWorkbenchSnapshot",null);Ue(this,"fileTreeSubscription",null);Ue(this,"gitSubscription",null);Ue(this,"terminalManagerSubscription",null);Ue(this,"workspaceManagementSubscription",null);Ue(this,"pendingFileTreeRefresh",null);Ue(this,"pendingGitRefresh",null);Ue(this,"pendingTerminalManagerRefresh",null);Ue(this,"pendingWorkspaceManagementRefresh",null);Ue(this,"fileTreeRevisionByPath",new Map);Ue(this,"gitRevisionByWorkspaceId",new Map);Ue(this,"terminalManagerRevisionByWorkspaceId",new Map);Ue(this,"workspaceManagementRevisionByWorkspaceId",new Map);Ue(this,"fileTreeListeners",new Set);Ue(this,"gitListeners",new Set);Ue(this,"terminalManagerListeners",new Set);Ue(this,"workspaceManagementListeners",new Set);Ue(this,"workbenchSubscribeStartedAtMs",null);Ue(this,"workbenchRefreshStartedAtMs",null);Ue(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new Zx({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!kd(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),Dt("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=yn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=yn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:xd(n),knownRevisionByPath:yl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:wl(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=xd(n),o={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:wl(t,i,yl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(o)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:yl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:yn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=Yi.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=sf(),i=Zb(r),o=i.baseUrl,a=`${ek("/ws",o)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:o,url:a});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),Dt("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:o}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:wl(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var p,m,g,x,S,C,y,A,T,G;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const h=JSON.parse(d.data);if(h.type==="system.connected"){this.connectionManager.markConnected();return}if(h.type==="session.error"){h.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(h.type==="workbench.snapshot"&&(Dt("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?ry(h.snapshot):0,subscribeDurationMs:Bo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Bo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){Dt("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:Bo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Bo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const P=ny(this.lastWorkbenchSnapshot,h);if(!P){Dt("workbench.delta.mismatch",{currentRevision:((m=this.lastWorkbenchSnapshot)==null?void 0:m.revision)??null,baseRevision:h.baseRevision,revision:h.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=P,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(P);return}if(h.type==="fileTree.snapshot"){const P=h.snapshot;if(P)P.revision=h.revision,this.fileTreeRevisionByPath.set(fc(P.workspaceId,P.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const E of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(fc(this.fileTreeSubscription.workspaceId,E),h.revision);if(!P)return;(x=(g=this.options).onFileTreeSnapshot)==null||x.call(g,P),this.fileTreeListeners.forEach(E=>E(P));return}if(h.type==="git.snapshot"){const P=h.snapshot;if(P?(P.revision=h.revision,this.gitRevisionByWorkspaceId.set(P.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!P)return;(C=(S=this.options).onGitSnapshot)==null||C.call(S,P),this.gitListeners.forEach(E=>E(P));return}if(h.type==="terminalManager.snapshot"){const P=h.snapshot;if(P?(P.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(P.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!P)return;(A=(y=this.options).onTerminalManagerSnapshot)==null||A.call(y,P),this.terminalManagerListeners.forEach(E=>E(P));return}if(h.type==="workspaceManagement.snapshot"){const P=h.snapshot;if(P?(P.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(P.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!P)return;(G=(T=this.options).onWorkspaceManagementSnapshot)==null||G.call(T,P),this.workspaceManagementListeners.forEach(E=>E(P));return}h.type==="workbench.snapshot"&&h.snapshot&&ty(h.snapshot)?(h.snapshot.revision=h.revision,this.lastWorkbenchSnapshot=h.snapshot,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(h.snapshot)):h.type==="workbench.snapshot"&&h.unchanged&&(this.workbenchKnownRevision=h.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:h.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),Yi.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return kd(n)?(n.send(JSON.stringify(t)),!0):!1}}function kd(e){return e!==null&&e.readyState===1}function ty(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function xd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function yn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function ny(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)n.delete(i);for(const i of t.changedItems)n.set(i.workspace.id,i);const r=[];for(const i of t.orderedWorkspaceIds){const o=n.get(i);if(!o)return null;r.push(o)}return{revision:t.revision,items:r}}function yl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),yn(n)]).filter(t=>t[1]!==null)):{}}function wl(e,t,n,r){const i=t.map(o=>{const a=o.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[a,n[a]??r.get(fc(e,a))??null]}).filter(o=>!!o[1]);if(i.length!==0)return Object.fromEntries(i)}function fc(e,t){return`${e}::${t}`}function ry(e){return e.items.reduce((t,n)=>t+n.sessions.length+zf(n.childWorktrees??[]),0)}function zf(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,i=Array.isArray(r.sessions)?r.sessions.length:0,o=Array.isArray(r.children)?zf(r.children):0;return t+i+o},0)}function Bo(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const yd=6,sy=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function iy(e){return e instanceof HTMLElement?!e.closest(sy):!0}function mc(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&iy(n)}function Hf(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Uf(e){return Hf(e)?"":void 0}function oy(e){if(!mc(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const i=()=>{r&&(r=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),window.removeEventListener("blur",c))},o=u=>{Math.abs(u.clientX-t)<yd&&Math.abs(u.clientY-n)<yd||(i(),ay())},a=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),window.addEventListener("blur",c)}async function ay(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await bf().startDragging()}const va=.78,ly=1;function cy(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function qf(e,t,n,r){const i=Math.hypot(n-e,r-t),o=Math.min(1,i/120);return va+(ly-va)*o}function Ar(e){return Math.round(Number.isFinite(e)?e:0)}function uy(e){if(!cy())return null;const t=Ar(e.x),n=Ar(e.y);let r=!1,i=Promise.resolve();const o=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),a=async()=>{r||(r=!0,await o("close_detach_preview"))};return o("show_detach_preview",{title:e.title,x:t,y:n,scale:va}),{updatePosition(c,u){if(r)return;const d=Ar(c),h=Ar(u);o("update_detach_preview_position",{x:d,y:h,scale:qf(t,n,d,h)})},complete(){return a()},cancel(){return a()}}}function dy(e){if(typeof document>"u")return null;const t=Ar(e.x),n=Ar(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",va.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const o=document.createElement("strong");o.className="desktop-window-detach-animation-title",o.textContent=e.title;const a=document.createElement("div");a.className="desktop-window-detach-animation-body",i.append(o),r.append(i,a),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=Ar(d),m=Ar(h),g=qf(t,n,p,m);r.style.left=`${p}px`,r.style.top=`${m}px`,r.style.setProperty("--detach-preview-scale",g.toFixed(3))},async complete(){u()},async cancel(){u()}}}function wd(e){return uy(e)??dy(e)}const hy={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 py(e){return{...e,bounds:{...e.bounds}}}function fy(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function my(e){return hy[e]}function Gf(e,t){return`${e}-${t}`}async function $a(e,t,n){const r=n.workspaceId.trim(),i=my(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const o=Gf(t,r),a=e.windows.getDescriptor(o),c=a?py(a):null,u=e.windows.isWindowOpen(o),d=tk({windowId:o,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(o),{ok:!0,value:d}):(c?fy(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function QA(e){return Gf("terminals",e)}function gy(e,t){return $a(e,"files",t)}function by(e,t){return $a(e,"git",t)}function ky(e,t){return $a(e,"processes",t)}function ZA(e,t){return $a(e,"terminals",t)}async function vd(){return await xe.request("/api/skills/overview")}async function xy(e){await xe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function yy(e){await xe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function wy(e){await xe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}async function vy(){return await xe.request("/api/opencli/catalog")}async function Sd(){return await xe.request("/api/opencli/check",{method:"POST"})}async function Sy(e){return await xe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const vl="all",Sl="status";function Cy({toolbarMode:e="internal",onToolbarStateChange:t}={}){var _e,Ge,Ke,ft;const n=Xc(F=>{var te;return((te=F.session)==null?void 0:te.accessToken)??null}),[r,i]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState(null),[y,A]=f.useState(null),[T,G]=f.useState(vl),[P,E]=f.useState(null),[V,U]=f.useState(!1),[L,I]=f.useState(""),[H,_]=f.useState(Sl);f.useEffect(()=>{let F=!0;if(!n){i(null),m(!1),x([]),A(null),C(null),a(!1),G(vl),E(null),U(!1),I(""),_(Sl);return}return(async()=>{a(!0),A(null),C(null);try{const re=await Sd();if(!F)return;N(re)}catch(re){if(!F)return;const ve=Wo(re);try{const Se=await vy();if(!F)return;N(Se),A(ve)}catch(Se){if(!F)return;A(Wo(Se))}}finally{F&&a(!1)}})(),()=>{F=!1}},[n]);const se=f.useMemo(()=>new Set(g),[g]),Y=f.useMemo(()=>Ty((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),W=f.useMemo(()=>Ry(),[]);f.useEffect(()=>{Y.some(F=>F.id===T)||G(vl)},[T,Y]);const q=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(F=>F.commands.some(te=>Cd(te,T,se))),[T,r==null?void 0:r.siteGroups,se]),D=f.useMemo(()=>P?q.find(F=>F.site===P)??null:null,[P,q]);f.useEffect(()=>{P&&!D&&E(null)},[P,D]),f.useEffect(()=>{I(""),_(Sl)},[P]);const K=f.useMemo(()=>{if(!D)return[];const F=L.trim().toLowerCase();return D.commands.filter(te=>Cd(te,T,se)&&Ey(te,F)).sort((te,re)=>My(te,re,{sortId:H,selectedCommandIdSet:se}))},[T,D,L,H,se]),ee=!!(r&&(r.provider.enabled!==p||r.entries.some(F=>F.enabled!==se.has(F.commandId)))),v=f.useMemo(()=>({draftEnabled:p,enableDisabled:o||c||d,refreshDisabled:!n||o||c||d,detailDisabled:!r||o,saveDisabled:!n||o||c||d||!r||!ee,refreshing:c,saving:d,onEnabledChange:ce,onRefresh:()=>{Ce()},onShowDetails:()=>U(!0),onSave:()=>{je()}}),[n,r,g,p,ee,o,c,d]);f.useEffect(()=>{t==null||t(v)},[t,v]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function Ce(){if(n){u(!0),A(null),C(null);try{const F=await Sd();N(F),C(Wy(F.refreshState,F.runtimeAvailability))}catch(F){A(Wo(F))}finally{u(!1)}}}async function je(){if(n){h(!0),A(null),C(null);try{const F=await Sy({enabled:p,enabledCommandIds:g});N(F),C(Fy(F))}catch(F){A(Wo(F))}finally{h(!1)}}}function N(F){i(F),m(F.provider.enabled),x(F.entries.filter(te=>te.enabled).map(te=>te.commandId).sort((te,re)=>te.localeCompare(re))),A(null)}function ce(F){m(F)}function Ie(F,te){const re=F.commands.map(ve=>ve.commandId);x(ve=>{const Se=new Set(ve);for(const ye of re)te?Se.add(ye):Se.delete(ye);return[...Se].sort((ye,ze)=>ye.localeCompare(ze))})}function fe(F,te){x(re=>{const ve=new Set(re);return te?ve.add(F):ve.delete(F),[...ve].sort((Se,ye)=>Se.localeCompare(ye))})}const oe=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return s.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?s.jsx(Ny,{state:v,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Oo,{label:l("settings.opencliSummaryInstallState"),value:Td(oe.installState)}),s.jsx(Oo,{label:l("settings.opencliSummaryCatalogCount"),value:String(oe.catalogCount)}),s.jsx(Oo,{label:l("settings.opencliSummaryEnabledCount"),value:String(g.length)}),s.jsx(Oo,{label:l("settings.opencliSummaryBrowserCount"),value:String(oe.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,y?s.jsx("p",{className:"settings-release-status",children:y}):null,o?s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?s.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[s.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:Y.map(F=>{const te=T===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":te,"data-active":te?"true":"false",onClick:()=>G(F.id),children:F.label},F.id)})}),q.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:q.map(F=>{const te=Iy(F,se),re=Ay(F.commands),ve=jd(F,{maxDescriptions:2}),Se=jd(F),ye=Kf(F.site),ze=P===F.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":ze?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:ye.style,children:s.jsx("span",{children:ye.label})}),s.jsxs("div",{className:"settings-opencli-site-card-body",children:[s.jsxs("div",{className:"settings-opencli-site-card-topline",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:F.site}),s.jsxs("div",{className:"settings-opencli-site-card-actions",children:[s.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>E(F.site),children:l("settings.opencliSiteViewAction")}),s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:F.site}),type:"checkbox",checked:te.allSelected,disabled:c||d,ref:Ve=>{Ve&&(Ve.indeterminate=te.partialSelected)},onChange:Ve=>Ie(F,Ve.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:Se,children:ve})]})]}),s.jsx("div",{className:"settings-opencli-site-card-summary",children:s.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:s.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(re.length>0?re:["unknown"]).slice(0,2).map(Ve=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Jf(Ve),children:Yf(Ve)},`${F.site}:${Ve}`))})})})]},F.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:$y(r)}),s.jsx(Nt,{open:V,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>U(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Vs,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx(Po,{children:Td(r.provider.installState)}),s.jsx(Po,{children:Dy(r.provider.healthState)}),s.jsx(Po,{children:By(((_e=r.activeRuntimeProfile)==null?void 0:_e.status)??null)})]}),children:s.jsxs(tu,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(ln,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(ln,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(oe.catalogCount)})}),s.jsx(ln,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(g.length)})}),s.jsx(ln,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(oe.browserDependentCount)})}),s.jsx(ln,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(ln,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:_y(r.effectiveCatalogSource??null)})}),s.jsx(ln,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Id(r.provider.lastCheckedAt)})}),s.jsx(ln,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Id(r.provider.catalogRefreshedAt)})}),s.jsx(ln,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(ln,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(ln,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ge=r.activeRuntimeProfile)==null?void 0:Ge.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(Ke=r.activeRuntimeProfile)!=null&&Ke.lastErrorDetail?s.jsx(Vs,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:s.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(ft=r.activeRuntimeProfile)!=null&&ft.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(Nt,{open:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:K.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>E(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Vs,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Vf(D.commands).map(F=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:F},F))})}),s.jsx(Vs,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx(Po,{children:l("settings.opencliCommandResultCount",{count:K.length})}),children:s.jsxs("div",{className:"settings-opencli-command-tools",children:[s.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),s.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:L,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:F=>I(F.target.value)})]}),s.jsxs("div",{className:"settings-opencli-command-sort",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),s.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:W.map(F=>{const te=H===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":te,"data-active":te?"true":"false",onClick:()=>_(F.id),children:F.label},F.id)})})]})]})}),K.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:K.map(F=>s.jsx(jy,{command:F,checked:se.has(F.commandId),disabled:c||d,onToggle:fe},F.commandId))}):s.jsx(uf,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ny({state:e,className:t}){return s.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function jy({command:e,checked:t,disabled:n,onToggle:r}){const i=Kf(e.commandId);return s.jsxs("div",{className:"settings-opencli-command-card",children:[s.jsxs("div",{className:"settings-opencli-command-card-head",children:[s.jsx("div",{className:"settings-opencli-command-badge",style:i.style,children:s.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),s.jsxs("div",{className:"settings-opencli-command-card-main",children:[s.jsxs("label",{className:"settings-opencli-checkbox",children:[s.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:o=>r(e.commandId,o.target.checked)}),s.jsx("span",{children:e.commandId})]}),s.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Jf(e.strategy),children:Oy(e.strategy)}),e.browser?s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Oo({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Ty(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Yf(n)})}))]}function Cd(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Iy(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function Ey(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
3
+ `).toLowerCase().includes(t):!0}function My(e,t,n){const r=Nd(e,n)-Nd(t,n);if(r!==0)return r;const i=e.name.localeCompare(t.name);return i!==0?i:e.commandId.localeCompare(t.commandId)}function Nd(e,t){const n=t.selectedCommandIdSet.has(e.commandId)?0:1,r=e.browser?1:0;switch(t.sortId){case"browser":return(e.browser?0:2)+n;case"name":return 0;case"status":default:return n*2+r}}function Ry(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function Vf(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function jd(e,t={}){const n=Vf(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function Ay(e){return Array.from(new Set(e.map(t=>t.strategy.trim()).filter(t=>t.length>0&&t!=="unknown"))).sort((t,n)=>t.localeCompare(n))}function Kf(e){const t=zy[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=Ed[Math.abs(Ly(e))%Ed.length];return{label:Py(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function Py(e){const t=e.split(/[^a-z0-9]+/i).map(r=>r.trim()).filter(r=>r.length>0);if(t.length>=2)return`${t[0][0]??""}${t[1][0]??""}`.toUpperCase();const n=t[0]??e;return n.slice(0,Math.min(2,n.length)).toUpperCase()}function Ly(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function Wo(e){return e instanceof Jc?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function Td(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function Dy(e){switch(e){case"ready":return l("settings.opencliHealthReady");case"bridge_missing":return l("settings.opencliHealthBridgeMissing");case"binary_ready":return l("settings.opencliHealthBinaryReady");case"runtime_build_failed":return l("settings.opencliHealthRuntimeBuildFailed");default:return l("settings.opencliHealthUnknown")}}function _y(e){switch(e){case"manifest":return l("settings.opencliCatalogSourceManifest");case"cli_list":return l("settings.opencliCatalogSourceCliList");case"local_manifest":return l("settings.opencliCatalogSourceLocalManifest");case"cache":return l("settings.opencliCatalogSourceCache");default:return"-"}}function By(e){switch(e){case"ready":return l("settings.opencliRuntimeReady");case"failed":return l("settings.opencliRuntimeFailed");case"pending":return l("settings.opencliRuntimePending");case"stale":return l("settings.opencliRuntimeStale");default:return l("settings.opencliRuntimeIdle")}}function Oy(e){return l("settings.opencliStrategyLabel",{strategy:Xf(e)})}function Yf(e){return l("settings.opencliStrategyShortLabel",{strategy:Xf(e)})}function Xf(e){switch(Qf(e)){case"cookie":return l("settings.opencliStrategyCookie");case"header":return l("settings.opencliStrategyHeader");case"intercept":return l("settings.opencliStrategyIntercept");case"local":return l("settings.opencliStrategyLocal");case"public":return l("settings.opencliStrategyPublic");case"ui":return l("settings.opencliStrategyUi");default:return l("settings.opencliStrategyUnknown")}}function Jf(e){return Qf(e)}function Qf(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function Wy(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function Fy(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function $y(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function Id(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const Ed=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],zy={github:{label:"GH",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"},hackernews:{label:"HN",background:"linear-gradient(135deg, #f97316 0%, #fb923c 100%)"},twitter:{label:"TW",background:"linear-gradient(135deg, #2563eb 0%, #38bdf8 100%)"},x:{label:"X",background:"linear-gradient(135deg, #111827 0%, #6b7280 100%)"},reddit:{label:"RD",background:"linear-gradient(135deg, #f97316 0%, #ef4444 100%)"}},Hy=[{id:"skills"},{id:"opencli"}];function Uy({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n}){const r=Xc(j=>{var $;return(($=j.session)==null?void 0:$.accessToken)??null}),i=f.useRef(null),[o,a]=f.useState(null),[c,u]=f.useState(!1),[d,h]=f.useState(null),[p,m]=f.useState(null),[g,x]=f.useState(null),[S,C]=f.useState(!1),[y,A]=f.useState(!1),[T,G]=f.useState(null),[P,E]=f.useState("file"),[V,U]=f.useState("workspace"),[L,I]=f.useState(""),[H,_]=f.useState(()=>Ei("workspace")),[se,Y]=f.useState("skills"),[W,q]=f.useState(null),D=f.useId(),ee=dk(S&&!!r).items??[],v=f.useMemo(()=>Qy(ee),[ee]);f.useEffect(()=>{let j=!0;if(!S)return;if(!r){a(null),m(null),x(null),u(!1);return}return(async()=>{u(!0);try{const ie=await vd();if(!j)return;a(ie),m(null)}catch(ie){if(!j)return;m(As(ie))}finally{j&&u(!1)}})(),()=>{j=!1}},[r,S]);async function Ce(){const j=await vd();a(j),m(null)}async function je(){if(r){h("refresh"),m(null),x(null);try{await Ce(),x(l("settings.skillRefreshSuccess"))}catch(j){m(As(j))}finally{h(null)}}}async function N(j){if(r){h(Md(j)),m(null),x(null);try{await yy({targetCli:j.targetCli,directoryPath:j.directoryPath,expectedContentHash:j.contentHash}),await Ce(),x(l("settings.skillImportSuccess",{name:j.name,target:un(j.targetCli)}))}catch($){m(As($))}finally{h(null)}}}async function ce(j){if(!r)return;const $=j.bindings.filter(ie=>ie.enabled).map(ie=>ie.targetCli).filter(ie=>Ft(ie,v));if($.length===0){m(ow(j.bindings));return}h(Rd(j.skill.id)),m(null),x(null);try{await wy({skillId:j.skill.id,targetCli:$}),await Ce(),x(l("settings.skillSyncSuccess",{name:j.skill.name}))}catch(ie){m(As(ie))}finally{h(null)}}async function Ie(j){var ie;const $=((ie=j.target.files)==null?void 0:ie[0])??null;if(j.target.value="",!!$){m(null),x(null);try{const me=await pw($),we=tm($.name,me);G(we),_(Ei(V,v))}catch(me){m(As(me))}}}async function fe(){const j=Ad({sourceMode:P,fileDraft:T,pastedMarkdown:L});if(!r)return;if(!j){m(P==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const $=j.directoryName;if(!$){m(l("settings.skillUploadDirectoryInvalid"));return}const ie=Sa(V).filter(me=>H[me]).filter(me=>Ft(me,v)).map(me=>me);if(ie.length===0){m(aw(V,v));return}h("upload"),m(null),x(null);try{await xy({markdownContent:j.rawContent,scope:V,fileName:j.fileName,directoryName:$,targetCli:ie}),await Ce(),x(l("settings.skillUploadSuccess",{name:$})),F(V),A(!1)}catch(me){m(As(me))}finally{h(null)}}function oe(j){U(j),_(Ei(j,v))}function _e(j){E(j),G(null),I(""),_(Ei(V,v)),m(null)}function Ge(j){Ft(j,v)&&_($=>({...$,[j]:!$[j]}))}function Ke(){A(!0),m(null),F(V)}function ft(){A(!1),m(null),F(V)}function F(j){G(null),I(""),E("file"),_(Ei(j,v))}const te=(o==null?void 0:o.summary)??{managedSkillCount:0,managedEntryCount:0},re=uw((o==null?void 0:o.assistantRuntimeSkills)??[],(o==null?void 0:o.conflictedEntries)??[],(o==null?void 0:o.diagnostics)??[]),ve=((o==null?void 0:o.conflictedEntries)??[]).filter(j=>!em(j,(o==null?void 0:o.diagnostics)??[])),Se=((o==null?void 0:o.diagnostics)??[]).filter(j=>!ao(j)),ye=Ad({sourceMode:P,fileDraft:T,pastedMarkdown:L}),ze=t??l("settings.skillManageAction"),Ve=se==="skills",Je=se==="opencli";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:e,type:"button","data-open":S?"true":"false","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>{Y("skills"),C(!0)},children:[n,s.jsx("span",{children:ze})]}),s.jsxs(Nt,{open:S,title:l("settings.skillConfigModalTitle"),hideHeader:!0,className:"settings-skill-modal",onClose:()=>{Y("skills"),C(!1)},children:[s.jsxs("div",{className:"settings-skill-modal-topbar",children:[s.jsxs("div",{className:"settings-skill-modal-topbar-main",children:[s.jsx("div",{className:"settings-model-tabs settings-skill-tabs",role:"tablist","aria-label":l("settings.skillConfigTabsLabel"),children:Hy.map(j=>{const $=se===j.id,ie=`${D}-${j.id}-tab`,me=`${D}-${j.id}-panel`;return s.jsx("button",{id:ie,type:"button",role:"tab",className:"settings-model-tab","aria-selected":$,"aria-controls":me,"data-active":$?"true":"false",onClick:()=>Y(j.id),children:gw(j.id)},j.id)})}),Ve?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:Ke,children:l("settings.skillCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:()=>{je()},children:d==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Je&&W?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar settings-opencli-toolbar",children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:W.draftEnabled,disabled:W.enableDisabled,onChange:j=>W.onEnabledChange(j.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:W.refreshDisabled,onClick:W.onRefresh,children:W.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:W.detailDisabled,onClick:W.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:W.saveDisabled,onClick:W.onSave,children:W.saving?l("common.loading"):l("settings.opencliSaveAction")})]}):null]}),s.jsx(Fk,{onClick:()=>{Y("skills"),C(!1)}})]}),Ve?s.jsxs("div",{id:`${D}-skills-panel`,role:"tabpanel","aria-labelledby":`${D}-skills-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Fo,{label:l("settings.skillSummaryManagedSkills"),value:String(te.managedSkillCount)}),s.jsx(Fo,{label:l("settings.skillSummaryManagedEntries"),value:String(te.managedEntryCount)}),s.jsx(Fo,{label:l("settings.skillSummaryConflictedEntries"),value:String(ve.length)}),s.jsx(Fo,{label:l("settings.skillSummaryDiagnostics"),value:String(Se.length)})]}),s.jsx("div",{className:"settings-release-meta",children:s.jsxs("span",{children:[l("settings.skillScannedAt"),": ",c?l("common.loading"):cw(o==null?void 0:o.scannedAt)]})}),g?s.jsx("p",{className:"settings-release-status",children:g}):null,p?s.jsx("p",{className:"settings-release-status",children:p}):null]}),s.jsx(Ii,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(o==null?void 0:o.managedSkills)??[],renderItem:j=>{const $=Rd(j.skill.id);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:j.skill.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:rw(j.bindings)}),s.jsx("div",{className:"settings-skill-tags",children:j.bindings.map(ie=>s.jsx("span",{className:"settings-skill-tag","data-status":tw(ie,v),children:nw(ie,v)},`${j.skill.id}-${ie.targetCli}`))})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!ew(j.bindings,v),onClick:()=>{ce(j)},children:d===$?l("common.loading"):l("settings.skillSyncAction")})})]},j.skill.id)}}),s.jsx(Ii,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(o==null?void 0:o.unmanagedEntries)??[],renderItem:j=>{const $=Md(j);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:j.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:sw(j,v)}),Ft(j.targetCli,v)?null:s.jsx("div",{className:"settings-skill-tags",children:s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.skillTargetDisabledTag")})})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!Ft(j.targetCli,v),onClick:()=>{N(j)},children:d===$?l("common.loading"):l("settings.skillImportAction")})})]},`${j.targetCli}:${j.directoryPath}`)}}),s.jsx(Ii,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:re,renderItem:j=>s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:j.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillAssistantRuntimeItemDescription")}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillAssistantRuntimeUsedBy"),": ",Zf(j.usedByTargetCli)]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:l("settings.skillTagAssistantOnly")}),j.usedByTargetCli.map($=>s.jsx("span",{className:"settings-skill-tag","data-status":Ft($,v)?"synced":"failed",children:Ft($,v)?un($):`${un($)} · ${l("settings.skillTargetDisabledTag")}`},`${j.directoryName}:${$}`))]})]})},`${j.directoryName}:${j.sourcePath}`)}),s.jsx(Ii,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:ve,renderItem:j=>{const $=dw(j,(o==null?void 0:o.diagnostics)??[]);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:j.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:iw(j,v)}),$.length>0?s.jsx("div",{className:"settings-skill-tags",children:$.map(ie=>s.jsx("span",{className:"settings-skill-tag","data-status":ie.status,children:ie.label},ie.key))}):null]})},`${j.targetCli}:${j.directoryPath}`)}}),s.jsx(Ii,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:Se,renderItem:j=>{const $=hw(j),ie=lw(j);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:ie.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:ie.detail}),$.length>0?s.jsx("div",{className:"settings-skill-tags",children:$.map(me=>s.jsx("span",{className:"settings-skill-tag","data-status":me.status,children:me.label},me.key))}):null]})},`${j.targetCli}:${j.code}:${j.directoryPath??j.rootDir}`)}})]}):s.jsx("div",{id:`${D}-opencli-panel`,role:"tabpanel","aria-labelledby":`${D}-opencli-tab`,className:"settings-skill-panel",children:s.jsx(Cy,{toolbarMode:"external",onToolbarStateChange:q})})]}),s.jsx(Nt,{open:y,title:l("settings.skillCreateModalTitle"),description:l("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:ft,children:s.jsxs("section",{className:"settings-skill-section",children:[s.jsx("h3",{className:"settings-skill-section-title",children:l("settings.skillUploadSectionTitle")}),s.jsx("p",{className:"settings-skill-section-description",children:l("settings.skillUploadSectionDescription")}),s.jsxs("div",{className:"settings-skill-create-panel",children:[s.jsx("input",{ref:i,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:j=>{Ie(j)}}),s.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:Ky.map(j=>{const $=P===j;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":$,"data-active":$?"true":"false",onClick:()=>_e(j),children:Xy(j)},j)})}),s.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:Vy.map(j=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":V===j?"true":"false",children:[s.jsx("input",{type:"radio",name:"skill-upload-scope",checked:V===j,onChange:()=>oe(j)}),s.jsx("span",{children:Yy(j)})]},j))}),P==="file"?s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null,onClick:()=>{var j;(j=i.current)==null||j.click()},children:l("settings.skillUploadPickAction")})}):s.jsxs("label",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillPasteLabel")}),s.jsx("textarea",{className:"settings-skill-create-textarea",value:L,onChange:j=>I(j.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),ye?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:ye.previewTitle}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",ye.fileName]})]})}):s.jsx("div",{className:"settings-skill-empty",children:P==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty")}),s.jsxs("div",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillUploadTargetsLabel")}),s.jsx("div",{className:"settings-skill-upload-targets",children:Sa(V).map(j=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":H[j]?"true":"false",children:[s.jsx("input",{type:"checkbox",checked:H[j],disabled:!Ft(j,v),onChange:()=>Ge(j)}),s.jsx("span",{children:Ft(j,v)?un(j):`${un(j)} · ${l("settings.skillTargetDisabledTag")}`})]},j))})]}),ye!=null&&ye.notes.length?s.jsx("div",{className:"settings-skill-tags",children:ye.notes.map((j,$)=>s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:j},`${ye.fileName}:${$}`))}):null,p?s.jsx("p",{className:"settings-release-status",children:p}):null,s.jsx("div",{className:"settings-skill-create-actions",children:s.jsx("button",{className:"primary-button",type:"button",disabled:c||d!==null,onClick:()=>{fe()},children:d==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function Ii({title:e,description:t,emptyText:n,items:r,renderItem:i}){return s.jsxs("section",{className:"settings-skill-section",children:[s.jsx("h3",{className:"settings-skill-section-title",children:e}),t?s.jsx("p",{className:"settings-skill-section-description",children:t}):null,r.length>0?s.jsx("div",{className:"settings-skill-entry-list",children:r.map(o=>i(o))}):s.jsx("div",{className:"settings-skill-empty",children:n})]})}function Fo({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Md(e){return`import:${e.targetCli}:${e.directoryPath}`}function Rd(e){return`sync:${e}`}const qy=["codex","claude-code","gemini","opencode"],Gy=["codex","claude-code"],Vy=["workspace","assistant"],Ky=["file","paste"];function As(e){return e instanceof Jc?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function un(e){switch(e){case"claude-code":return l("settings.skillTargetClaudeCode");case"gemini":return l("settings.skillTargetGemini");case"opencode":return l("settings.skillTargetOpenCode");default:return l("settings.skillTargetCodex")}}function Yy(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function Xy(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function Ei(e,t={}){const r=Sa(e).filter(i=>Ft(i,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function Sa(e){return e==="assistant"?Gy:qy}function Ad({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?tm(fw(n),n):null}function Jy(e){switch(e){case"conflicted":return l("settings.skillBindingConflicted");case"failed":return l("settings.skillBindingFailed");case"pending":return l("settings.skillBindingPending");default:return l("settings.skillBindingSynced")}}function Qy(e){const t={};for(const n of e){const r=Zy(n.provider);r&&(t[r]=n)}return t}function Zy(e){switch(e){case"claude-code":return"claude-code";case"codex":return"codex";case"gemini":return"gemini";case"opencode":return"opencode";default:return null}}function Ft(e,t){var n;return((n=t[e])==null?void 0:n.enabled)!==!1}function ew(e,t){return e.some(n=>n.enabled&&Ft(n.targetCli,t))}function tw(e,t){return Ft(e.targetCli,t)?e.syncStatus:"failed"}function nw(e,t){return Ft(e.targetCli,t)?`${un(e.targetCli)} · ${Jy(e.syncStatus)}`:`${un(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function Zf(e){return e.map(un).join(" / ")}function rw(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:Zf(t.map(n=>n.targetCli))})}function sw(e,t){return Ft(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:un(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:un(e.targetCli)})}function iw(e,t){return Ft(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:un(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:un(e.targetCli)})}function ow(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function aw(e,t){return Sa(e).some(r=>Ft(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function lw(e){const t=un(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:l("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:l("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:l("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:l("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:l("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:l("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:l("settings.skillDiagnosticGenericTitle",{target:t}),detail:l("settings.skillDiagnosticGenericDetail",{target:t})}}}function cw(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function uw(e,t,n){if(e.length>0)return e.map(i=>({name:i.name,directoryName:i.directoryName,sourcePath:i.sourcePath,usedByTargetCli:i.usedByTargetCli}));const r=new Map;for(const i of t)em(i,n)&&r.set(Pd(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli]});for(const i of n){if(!ao(i))continue;const o=i.directoryPath??i.rootDir,a=Pd(i.targetCli,o);r.has(a)||r.set(a,{name:i.directoryName??"codingns-assistant",directoryName:i.directoryName??"codingns-assistant",sourcePath:o,usedByTargetCli:[i.targetCli]})}return[...r.values()]}function Pd(e,t){return`${e}:${t}`}function em(e,t){return t.some(n=>ao(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function ao(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function dw(e,t){return t.find(r=>ao(r)&&r.targetCli===e.targetCli&&r.directoryName===e.directoryName&&r.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function hw(e){return ao(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function tm(e,t){const n=[],r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
4
+ `).trim();if(!r)throw new Error(l("settings.skillUploadContentEmpty"));r!==t.trim()&&n.push(l("settings.skillUploadNormalizedNote"));const i=nm(r),o=gc(e)??gc(i)??"";return o||n.push(l("settings.skillUploadDirectoryRequiredNote")),i||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:o,previewTitle:i||mw(o||"skill"),notes:n}}async function pw(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(typeof r.result=="string"){t(r.result);return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsText(e)})}function gc(e){const r=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return r.length>0?r:null}function fw(e){const t=gc(nm(e));return t?`${t}.md`:"pasted-skill.md"}function nm(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function mw(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function gw(e){switch(e){case"opencli":return l("settings.skillConfigTabOpenCli");default:return l("settings.skillConfigTabSkills")}}function bw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const kw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yw={};function Ld(e,t){return(yw.jsx?xw:kw).test(e)}const ww=/[ \t\n\f\r]/g;function vw(e){return typeof e=="object"?e.type==="text"?Dd(e.value):!1:Dd(e)}function Dd(e){return e.replace(ww,"")===""}class lo{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}lo.prototype.normal={};lo.prototype.property={};lo.prototype.space=void 0;function rm(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new lo(n,r,t)}function bc(e){return e.toLowerCase()}class nn{constructor(t,n){this.attribute=n,this.property=t}}nn.prototype.attribute="";nn.prototype.booleanish=!1;nn.prototype.boolean=!1;nn.prototype.commaOrSpaceSeparated=!1;nn.prototype.commaSeparated=!1;nn.prototype.defined=!1;nn.prototype.mustUseProperty=!1;nn.prototype.number=!1;nn.prototype.overloadedBoolean=!1;nn.prototype.property="";nn.prototype.spaceSeparated=!1;nn.prototype.space=void 0;let Sw=0;const Be=ds(),It=ds(),kc=ds(),ae=ds(),dt=ds(),ei=ds(),an=ds();function ds(){return 2**++Sw}const xc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Be,booleanish:It,commaOrSpaceSeparated:an,commaSeparated:ei,number:ae,overloadedBoolean:kc,spaceSeparated:dt},Symbol.toStringTag,{value:"Module"})),Cl=Object.keys(xc);class bu extends nn{constructor(t,n,r,i){let o=-1;if(super(t,n),_d(this,"space",i),typeof r=="number")for(;++o<Cl.length;){const a=Cl[o];_d(this,Cl[o],(r&xc[a])===xc[a])}}}bu.prototype.defined=!0;function _d(e,t,n){n&&(e[t]=n)}function li(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new bu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[bc(r)]=r,n[bc(o.attribute)]=r}return new lo(t,n,e.space)}const sm=li({properties:{ariaActiveDescendant:null,ariaAtomic:It,ariaAutoComplete:null,ariaBusy:It,ariaChecked:It,ariaColCount:ae,ariaColIndex:ae,ariaColSpan:ae,ariaControls:dt,ariaCurrent:null,ariaDescribedBy:dt,ariaDetails:null,ariaDisabled:It,ariaDropEffect:dt,ariaErrorMessage:null,ariaExpanded:It,ariaFlowTo:dt,ariaGrabbed:It,ariaHasPopup:null,ariaHidden:It,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:dt,ariaLevel:ae,ariaLive:null,ariaModal:It,ariaMultiLine:It,ariaMultiSelectable:It,ariaOrientation:null,ariaOwns:dt,ariaPlaceholder:null,ariaPosInSet:ae,ariaPressed:It,ariaReadOnly:It,ariaRelevant:null,ariaRequired:It,ariaRoleDescription:dt,ariaRowCount:ae,ariaRowIndex:ae,ariaRowSpan:ae,ariaSelected:It,ariaSetSize:ae,ariaSort:null,ariaValueMax:ae,ariaValueMin:ae,ariaValueNow:ae,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function im(e,t){return t in e?e[t]:t}function om(e,t){return im(e,t.toLowerCase())}const Cw=li({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ei,acceptCharset:dt,accessKey:dt,action:null,allow:null,allowFullScreen:Be,allowPaymentRequest:Be,allowUserMedia:Be,alt:null,as:null,async:Be,autoCapitalize:null,autoComplete:dt,autoFocus:Be,autoPlay:Be,blocking:dt,capture:null,charSet:null,checked:Be,cite:null,className:dt,cols:ae,colSpan:null,content:null,contentEditable:It,controls:Be,controlsList:dt,coords:ae|ei,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Be,defer:Be,dir:null,dirName:null,disabled:Be,download:kc,draggable:It,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Be,formTarget:null,headers:dt,height:ae,hidden:kc,high:ae,href:null,hrefLang:null,htmlFor:dt,httpEquiv:dt,id:null,imageSizes:null,imageSrcSet:null,inert:Be,inputMode:null,integrity:null,is:null,isMap:Be,itemId:null,itemProp:dt,itemRef:dt,itemScope:Be,itemType:dt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Be,low:ae,manifest:null,max:null,maxLength:ae,media:null,method:null,min:null,minLength:ae,multiple:Be,muted:Be,name:null,nonce:null,noModule:Be,noValidate:Be,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Be,optimum:ae,pattern:null,ping:dt,placeholder:null,playsInline:Be,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Be,referrerPolicy:null,rel:dt,required:Be,reversed:Be,rows:ae,rowSpan:ae,sandbox:dt,scope:null,scoped:Be,seamless:Be,selected:Be,shadowRootClonable:Be,shadowRootDelegatesFocus:Be,shadowRootMode:null,shape:null,size:ae,sizes:null,slot:null,span:ae,spellCheck:It,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ae,step:null,style:null,tabIndex:ae,target:null,title:null,translate:null,type:null,typeMustMatch:Be,useMap:null,value:It,width:ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:dt,axis:null,background:null,bgColor:null,border:ae,borderColor:null,bottomMargin:ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Be,declare:Be,event:null,face:null,frame:null,frameBorder:null,hSpace:ae,leftMargin:ae,link:null,longDesc:null,lowSrc:null,marginHeight:ae,marginWidth:ae,noResize:Be,noHref:Be,noShade:Be,noWrap:Be,object:null,profile:null,prompt:null,rev:null,rightMargin:ae,rules:null,scheme:null,scrolling:It,standby:null,summary:null,text:null,topMargin:ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ae,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Be,disableRemotePlayback:Be,prefix:null,property:null,results:ae,security:null,unselectable:null},space:"html",transform:om}),Nw=li({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:an,accentHeight:ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ae,amplitude:ae,arabicForm:null,ascent:ae,attributeName:null,attributeType:null,azimuth:ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ae,by:null,calcMode:null,capHeight:ae,className:dt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ae,diffuseConstant:ae,direction:null,display:null,dur:null,divisor:ae,dominantBaseline:null,download:Be,dx:null,dy:null,edgeMode:null,editable:null,elevation:ae,enableBackground:null,end:null,event:null,exponent:ae,externalResourcesRequired:null,fill:null,fillOpacity:ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ei,g2:ei,glyphName:ei,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ae,horizOriginX:ae,horizOriginY:ae,id:null,ideographic:ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ae,k:ae,k1:ae,k2:ae,k3:ae,k4:ae,kernelMatrix:an,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ae,overlineThickness:ae,paintOrder:null,panose1:null,path:null,pathLength:ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:dt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ae,pointsAtY:ae,pointsAtZ:ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:an,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:an,rev:an,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:an,requiredFeatures:an,requiredFonts:an,requiredFormats:an,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ae,specularExponent:ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ae,strikethroughThickness:ae,string:null,stroke:null,strokeDashArray:an,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ae,strokeOpacity:ae,strokeWidth:null,style:null,surfaceScale:ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:an,tabIndex:ae,tableValues:null,target:null,targetX:ae,targetY:ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:an,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ae,underlineThickness:ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ae,values:null,vAlphabetic:ae,vMathematical:ae,vectorEffect:null,vHanging:ae,vIdeographic:ae,version:null,vertAdvY:ae,vertOriginX:ae,vertOriginY:ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:im}),am=li({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),lm=li({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:om}),cm=li({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),jw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Tw=/[A-Z]/g,Bd=/-[a-z]/g,Iw=/^data[-\w.:]+$/i;function Ew(e,t){const n=bc(t);let r=t,i=nn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Iw.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Bd,Rw);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Bd.test(o)){let a=o.replace(Tw,Mw);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=bu}return new i(r,t)}function Mw(e){return"-"+e.toLowerCase()}function Rw(e){return e.charAt(1).toUpperCase()}const Aw=rm([sm,Cw,am,lm,cm],"html"),ku=rm([sm,Nw,am,lm,cm],"svg");function Pw(e){return e.join(" ").trim()}var Ps={},Nl,Od;function Lw(){if(Od)return Nl;Od=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,u=`
5
+ `,d="/",h="*",p="",m="comment",g="declaration";function x(C,y){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];y=y||{};var A=1,T=1;function G(Y){var W=Y.match(t);W&&(A+=W.length);var q=Y.lastIndexOf(u);T=~q?Y.length-q:T+Y.length}function P(){var Y={line:A,column:T};return function(W){return W.position=new E(Y),L(),W}}function E(Y){this.start=Y,this.end={line:A,column:T},this.source=y.source}E.prototype.content=C;function V(Y){var W=new Error(y.source+":"+A+":"+T+": "+Y);if(W.reason=Y,W.filename=y.source,W.line=A,W.column=T,W.source=C,!y.silent)throw W}function U(Y){var W=Y.exec(C);if(W){var q=W[0];return G(q),C=C.slice(q.length),W}}function L(){U(n)}function I(Y){var W;for(Y=Y||[];W=H();)W!==!1&&Y.push(W);return Y}function H(){var Y=P();if(!(d!=C.charAt(0)||h!=C.charAt(1))){for(var W=2;p!=C.charAt(W)&&(h!=C.charAt(W)||d!=C.charAt(W+1));)++W;if(W+=2,p===C.charAt(W-1))return V("End of comment missing");var q=C.slice(2,W-2);return T+=2,G(q),C=C.slice(W),T+=2,Y({type:m,comment:q})}}function _(){var Y=P(),W=U(r);if(W){if(H(),!U(i))return V("property missing ':'");var q=U(o),D=Y({type:g,property:S(W[0].replace(e,p)),value:q?S(q[0].replace(e,p)):p});return U(a),D}}function se(){var Y=[];I(Y);for(var W;W=_();)W!==!1&&(Y.push(W),I(Y));return Y}return L(),se()}function S(C){return C?C.replace(c,p):p}return Nl=x,Nl}var Wd;function Dw(){if(Wd)return Ps;Wd=1;var e=Ps&&Ps.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.default=n;const t=e(Lw());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),c=typeof i=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;c?i(d,h,u):h&&(o=o||{},o[d]=h)}),o}return Ps}var Mi={},Fd;function _w(){if(Fd)return Mi;Fd=1,Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(d){return!d||n.test(d)||e.test(d)},a=function(d,h){return h.toUpperCase()},c=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),o(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,c):d=d.replace(r,c),d.replace(t,a))};return Mi.camelCase=u,Mi}var Ri,$d;function Bw(){if($d)return Ri;$d=1;var e=Ri&&Ri.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Dw()),n=_w();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(c,u){c&&u&&(a[(0,n.camelCase)(c,o)]=u)}),a}return r.default=r,Ri=r,Ri}var Ow=Bw();const Ww=of(Ow),um=dm("end"),xu=dm("start");function dm(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Fw(e){const t=xu(e),n=um(e);if(t&&n)return{start:t,end:n}}function Ui(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?zd(e.position):"start"in e||"end"in e?zd(e):"line"in e||"column"in e?yc(e):""}function yc(e){return Hd(e&&e.line)+":"+Hd(e&&e.column)}function zd(e){return yc(e&&e.start)+"-"+yc(e&&e.end)}function Hd(e){return e&&typeof e=="number"?e:1}class zt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=Ui(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}zt.prototype.file="";zt.prototype.name="";zt.prototype.reason="";zt.prototype.message="";zt.prototype.stack="";zt.prototype.column=void 0;zt.prototype.line=void 0;zt.prototype.ancestors=void 0;zt.prototype.cause=void 0;zt.prototype.fatal=void 0;zt.prototype.place=void 0;zt.prototype.ruleId=void 0;zt.prototype.source=void 0;const yu={}.hasOwnProperty,$w=new Map,zw=/[A-Z]/g,Hw=new Set(["table","tbody","thead","tfoot","tr"]),Uw=new Set(["td","th"]),hm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qw(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Zw(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Qw(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ku:Aw,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=pm(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function pm(e,t,n){if(t.type==="element")return Gw(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Vw(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Yw(e,t,n);if(t.type==="mdxjsEsm")return Kw(e,t);if(t.type==="root")return Xw(e,t,n);if(t.type==="text")return Jw(e,t)}function Gw(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ku,e.schema=i),e.ancestors.push(t);const o=mm(e,t.tagName,!1),a=ev(e,t);let c=vu(e,t);return Hw.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!vw(u):!0})),fm(e,a,o,t),wu(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function Vw(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Ji(e,t.position)}function Kw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ji(e,t.position)}function Yw(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ku,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:mm(e,t.name,!0),a=tv(e,t),c=vu(e,t);return fm(e,a,o,t),wu(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function Xw(e,t,n){const r={};return wu(r,vu(e,t)),e.create(t,e.Fragment,r,n)}function Jw(e,t){return t.value}function fm(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Qw(e,t,n){return r;function r(i,o,a,c){const d=Array.isArray(a.children)?n:t;return c?d(o,a,c):d(o,a)}}function Zw(e,t){return n;function n(r,i,o,a){const c=Array.isArray(o.children),u=xu(r);return t(i,o,a,c,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function ev(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&yu.call(t.properties,i)){const o=nv(e,i,t.properties[i]);if(o){const[a,c]=o;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&Uw.has(t.tagName)?r=c:n[a]=c}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function tv(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Ji(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Ji(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function vu(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:$w;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const d=i.get(u)||0;a=u+"-"+d,i.set(u,d+1)}}const c=pm(e,o,a);c!==void 0&&n.push(c)}return n}function nv(e,t,n){const r=Ew(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?bw(n):Pw(n)),r.property==="style"){let i=typeof n=="object"?n:rv(e,String(n));return e.stylePropertyNameCase==="css"&&(i=sv(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?jw[r.property]||r.property:r.attribute,n]}}function rv(e,t){try{return Ww(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new zt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=hm+"#cannot-parse-style-attribute",i}}function mm(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,a;for(;++o<i.length;){const c=Ld(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(o&&c.type==="Literal"),optional:!1}:c}r=a}else r=Ld(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return yu.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ji(e)}function Ji(e,t){const n=new zt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=hm+"#cannot-handle-mdx-estrees-without-createevaluater",n}function sv(e){const t={};let n;for(n in e)yu.call(e,n)&&(t[iv(n)]=e[n]);return t}function iv(e){let t=e.replace(zw,ov);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function ov(e){return"-"+e.toLowerCase()}const jl={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},av={};function Su(e,t){const n=av,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return gm(e,r,i)}function gm(e,t,n){if(lv(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Ud(e.children,t,n)}return Array.isArray(e)?Ud(e,t,n):""}function Ud(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=gm(e[i],t,n);return r.join("")}function lv(e){return!!(e&&typeof e=="object")}const qd=document.createElement("i");function Cu(e){const t="&"+e+";";qd.innerHTML=t;const n=qd.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function wn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}const Gd={}.hasOwnProperty;function bm(e){const t={};let n=-1;for(;++n<e.length;)cv(t,e[n]);return t}function cv(e,t){let n;for(n in t){const i=(Gd.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Gd.call(i,a)||(i[a]=[]);const c=o[a];uv(i[a],Array.isArray(c)?c:c?[c]:[])}}}function uv(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function km(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function An(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Xt=Dr(/[A-Za-z]/),$t=Dr(/[\dA-Za-z]/),dv=Dr(/[#-'*+\--9=?A-Z^-~]/);function Ca(e){return e!==null&&(e<32||e===127)}const wc=Dr(/\d/),hv=Dr(/[\dA-Fa-f]/),pv=Dr(/[!-/:-@[-`{-~]/);function Te(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function $e(e){return e===-2||e===-1||e===32}const za=Dr(new RegExp("\\p{P}|\\p{S}","u")),ls=Dr(/\s/);function Dr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ci(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&$t(e.charCodeAt(n+1))&&$t(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const c=e.charCodeAt(n+1);o<56320&&c>56319&&c<57344?(a=String.fromCharCode(o,c),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return $e(u)?(e.enter(n),c(u)):t(u)}function c(u){return $e(u)&&o++<i?(e.consume(u),c):(e.exit(n),t(u))}}const fv={tokenize:mv};function mv(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),qe(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),o(c)}function o(c){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(c)}function a(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Te(c)?(e.consume(c),e.exit("chunkText"),o):(e.consume(c),a)}}const gv={tokenize:bv},Vd={tokenize:kv};function bv(e){const t=this,n=[];let r=0,i,o,a;return c;function c(T){if(r<n.length){const G=n[r];return t.containerState=G[1],e.attempt(G[0].continuation,u,d)(T)}return d(T)}function u(T){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&A();const G=t.events.length;let P=G,E;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){E=t.events[P][1].end;break}y(r);let V=G;for(;V<t.events.length;)t.events[V][1].end={...E},V++;return dn(t.events,P+1,0,t.events.slice(G)),t.events.length=V,d(T)}return c(T)}function d(T){if(r===n.length){if(!i)return m(T);if(i.currentConstruct&&i.currentConstruct.concrete)return x(T);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Vd,h,p)(T)}function h(T){return i&&A(),y(r),m(T)}function p(T){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,x(T)}function m(T){return t.containerState={},e.attempt(Vd,g,x)(T)}function g(T){return r++,n.push([t.currentConstruct,t.containerState]),m(T)}function x(T){if(T===null){i&&A(),y(0),e.consume(T);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),S(T)}function S(T){if(T===null){C(e.exit("chunkFlow"),!0),y(0),e.consume(T);return}return Te(T)?(e.consume(T),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(T),S)}function C(T,G){const P=t.sliceStream(T);if(G&&P.push(null),T.previous=o,o&&(o.next=T),o=T,i.defineSkip(T.start),i.write(P),t.parser.lazy[T.start.line]){let E=i.events.length;for(;E--;)if(i.events[E][1].start.offset<a&&(!i.events[E][1].end||i.events[E][1].end.offset>a))return;const V=t.events.length;let U=V,L,I;for(;U--;)if(t.events[U][0]==="exit"&&t.events[U][1].type==="chunkFlow"){if(L){I=t.events[U][1].end;break}L=!0}for(y(r),E=V;E<t.events.length;)t.events[E][1].end={...I},E++;dn(t.events,U+1,0,t.events.slice(V)),t.events.length=E}}function y(T){let G=n.length;for(;G-- >T;){const P=n[G];t.containerState=P[1],P[0].exit.call(t,e)}n.length=T}function A(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function kv(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function si(e){if(e===null||ot(e)||ls(e))return 1;if(za(e))return 2}function Ha(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const vc={name:"attention",resolveAll:xv,tokenize:yv};function xv(e,t){let n=-1,r,i,o,a,c,u,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},m={...e[n][1].start};Kd(p,-u),Kd(m,u),a={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},c={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...a.start},end:{...c.end}},e[r][1].end={...a.start},e[n][1].start={...c.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=wn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=wn(d,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=wn(d,Ha(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=wn(d,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=wn(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,dn(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function yv(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=si(r);let o;return a;function a(u){return o=u,e.enter("attentionSequence"),c(u)}function c(u){if(u===o)return e.consume(u),c;const d=e.exit("attentionSequence"),h=si(u),p=!h||h===2&&i||n.includes(u),m=!i||i===2&&h||n.includes(r);return d._open=!!(o===42?p:p&&(i||!m)),d._close=!!(o===42?m:m&&(h||!p)),t(u)}}function Kd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const wv={name:"autolink",tokenize:vv};function vv(e,t,n){let r=0;return i;function i(g){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(g){return Xt(g)?(e.consume(g),a):g===64?n(g):d(g)}function a(g){return g===43||g===45||g===46||$t(g)?(r=1,c(g)):d(g)}function c(g){return g===58?(e.consume(g),r=0,u):(g===43||g===45||g===46||$t(g))&&r++<32?(e.consume(g),c):(r=0,d(g))}function u(g){return g===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):g===null||g===32||g===60||Ca(g)?n(g):(e.consume(g),u)}function d(g){return g===64?(e.consume(g),h):dv(g)?(e.consume(g),d):n(g)}function h(g){return $t(g)?p(g):n(g)}function p(g){return g===46?(e.consume(g),r=0,h):g===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):m(g)}function m(g){if((g===45||$t(g))&&r++<63){const x=g===45?m:p;return e.consume(g),x}return n(g)}}const co={partial:!0,tokenize:Sv};function Sv(e,t,n){return r;function r(o){return $e(o)?qe(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||Te(o)?t(o):n(o)}}const xm={continuation:{tokenize:Nv},exit:jv,name:"blockQuote",tokenize:Cv};function Cv(e,t,n){const r=this;return i;function i(a){if(a===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return $e(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Nv(e,t,n){const r=this;return i;function i(a){return $e(a)?qe(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(xm,t,n)(a)}}function jv(e){e.exit("blockQuote")}const ym={name:"characterEscape",tokenize:Tv};function Tv(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return pv(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const wm={name:"characterReference",tokenize:Iv};function Iv(e,t,n){const r=this;let i=0,o,a;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,a=$t,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=hv,h):(e.enter("characterReferenceValue"),o=7,a=wc,h(p))}function h(p){if(p===59&&i){const m=e.exit("characterReferenceValue");return a===$t&&!Cu(r.sliceSerialize(m))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&i++<o?(e.consume(p),h):n(p)}}const Yd={partial:!0,tokenize:Mv},Xd={concrete:!0,name:"codeFenced",tokenize:Ev};function Ev(e,t,n){const r=this,i={partial:!0,tokenize:P};let o=0,a=0,c;return u;function u(E){return d(E)}function d(E){const V=r.events[r.events.length-1];return o=V&&V[1].type==="linePrefix"?V[2].sliceSerialize(V[1],!0).length:0,c=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(E)}function h(E){return E===c?(a++,e.consume(E),h):a<3?n(E):(e.exit("codeFencedFenceSequence"),$e(E)?qe(e,p,"whitespace")(E):p(E))}function p(E){return E===null||Te(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(Yd,S,G)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(E))}function m(E){return E===null||Te(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(E)):$e(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,g,"whitespace")(E)):E===96&&E===c?n(E):(e.consume(E),m)}function g(E){return E===null||Te(E)?p(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),x(E))}function x(E){return E===null||Te(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(E)):E===96&&E===c?n(E):(e.consume(E),x)}function S(E){return e.attempt(i,G,C)(E)}function C(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),y}function y(E){return o>0&&$e(E)?qe(e,A,"linePrefix",o+1)(E):A(E)}function A(E){return E===null||Te(E)?e.check(Yd,S,G)(E):(e.enter("codeFlowValue"),T(E))}function T(E){return E===null||Te(E)?(e.exit("codeFlowValue"),A(E)):(e.consume(E),T)}function G(E){return e.exit("codeFenced"),t(E)}function P(E,V,U){let L=0;return I;function I(W){return E.enter("lineEnding"),E.consume(W),E.exit("lineEnding"),H}function H(W){return E.enter("codeFencedFence"),$e(W)?qe(E,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):_(W)}function _(W){return W===c?(E.enter("codeFencedFenceSequence"),se(W)):U(W)}function se(W){return W===c?(L++,E.consume(W),se):L>=a?(E.exit("codeFencedFenceSequence"),$e(W)?qe(E,Y,"whitespace")(W):Y(W)):U(W)}function Y(W){return W===null||Te(W)?(E.exit("codeFencedFence"),V(W)):U(W)}}}function Mv(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Tl={name:"codeIndented",tokenize:Av},Rv={partial:!0,tokenize:Pv};function Av(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),qe(e,o,"linePrefix",5)(d)}function o(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?u(d):Te(d)?e.attempt(Rv,a,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Te(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function Pv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):Te(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):qe(e,o,"linePrefix",5)(a)}function o(a){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):Te(a)?i(a):n(a)}}const Lv={name:"codeText",previous:_v,resolve:Dv,tokenize:Bv};function Dv(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function _v(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Bv(e,t,n){let r=0,i,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),r++,c):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(o=e.enter("codeTextSequence"),i=0,h(p)):Te(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||Te(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),d)}function h(p){return p===96?(e.consume(p),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",d(p))}}class Ov{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ai(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ai(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ai(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ai(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ai(this.left,n.reverse())}}}function Ai(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function vm(e){const t={};let n=-1,r,i,o,a,c,u,d;const h=new Ov(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Wv(h,n)),n=t[n],d=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=h.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},c=h.slice(i,n),c.unshift(r),h.splice(i,n-i+1,c))}}return dn(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function Wv(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const c=a.events,u=[],d={};let h,p,m=-1,g=n,x=0,S=0;const C=[S];for(;g;){for(;e.get(++i)[1]!==g;);o.push(i),g._tokenizer||(h=r.sliceStream(g),g.next||h.push(null),p&&a.defineSkip(g.start),g._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),g._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=g,g=g.next}for(g=n;++m<c.length;)c[m][0]==="exit"&&c[m-1][0]==="enter"&&c[m][1].type===c[m-1][1].type&&c[m][1].start.line!==c[m][1].end.line&&(S=m+1,C.push(S),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(a.events=[],g?(g._tokenizer=void 0,g.previous=void 0):C.pop(),m=C.length;m--;){const y=c.slice(C[m],C[m+1]),A=o.pop();u.push([A,A+y.length-1]),e.splice(A,2,y)}for(u.reverse(),m=-1;++m<u.length;)d[x+u[m][0]]=x+u[m][1],x+=u[m][1]-u[m][0]-1;return d}const Fv={resolve:zv,tokenize:Hv},$v={partial:!0,tokenize:Uv};function zv(e){return vm(e),e}function Hv(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(c)}function i(c){return c===null?o(c):Te(c)?e.check($v,a,o)(c):(e.consume(c),i)}function o(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function a(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Uv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,o,"linePrefix")}function o(a){if(a===null||Te(a))return n(a);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Sm(e,t,n,r,i,o,a,c,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),m):y===null||y===32||y===41||Ca(y)?n(y):(e.enter(r),e.enter(a),e.enter(c),e.enter("chunkString",{contentType:"string"}),S(y))}function m(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===62?(e.exit("chunkString"),e.exit(c),m(y)):y===null||y===60||Te(y)?n(y):(e.consume(y),y===92?x:g)}function x(y){return y===60||y===62||y===92?(e.consume(y),g):g(y)}function S(y){return!h&&(y===null||y===41||ot(y))?(e.exit("chunkString"),e.exit(c),e.exit(a),e.exit(r),t(y)):h<d&&y===40?(e.consume(y),h++,S):y===41?(e.consume(y),h--,S):y===null||y===32||y===40||Ca(y)?n(y):(e.consume(y),y===92?C:S)}function C(y){return y===40||y===41||y===92?(e.consume(y),S):S(y)}}function Cm(e,t,n,r,i,o){const a=this;let c=0,u;return d;function d(g){return e.enter(r),e.enter(i),e.consume(g),e.exit(i),e.enter(o),h}function h(g){return c>999||g===null||g===91||g===93&&!u||g===94&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?n(g):g===93?(e.exit(o),e.enter(i),e.consume(g),e.exit(i),e.exit(r),t):Te(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===null||g===91||g===93||Te(g)||c++>999?(e.exit("chunkString"),h(g)):(e.consume(g),u||(u=!$e(g)),g===92?m:p)}function m(g){return g===91||g===92||g===93?(e.consume(g),c++,p):p(g)}}function Nm(e,t,n,r,i,o){let a;return c;function c(m){return m===34||m===39||m===40?(e.enter(r),e.enter(i),e.consume(m),e.exit(i),a=m===40?41:m,u):n(m)}function u(m){return m===a?(e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):(e.enter(o),d(m))}function d(m){return m===a?(e.exit(o),u(a)):m===null?n(m):Te(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),qe(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(m))}function h(m){return m===a||m===null||Te(m)?(e.exit("chunkString"),d(m)):(e.consume(m),m===92?p:h)}function p(m){return m===a||m===92?(e.consume(m),h):h(m)}}function qi(e,t){let n;return r;function r(i){return Te(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):$e(i)?qe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const qv={name:"definition",tokenize:Vv},Gv={partial:!0,tokenize:Kv};function Vv(e,t,n){const r=this;let i;return o;function o(g){return e.enter("definition"),a(g)}function a(g){return Cm.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function c(g){return i=An(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),u):n(g)}function u(g){return ot(g)?qi(e,d)(g):d(g)}function d(g){return Sm(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function h(g){return e.attempt(Gv,p,p)(g)}function p(g){return $e(g)?qe(e,m,"whitespace")(g):m(g)}function m(g){return g===null||Te(g)?(e.exit("definition"),r.parser.defined.push(i),t(g)):n(g)}}function Kv(e,t,n){return r;function r(c){return ot(c)?qi(e,i)(c):n(c)}function i(c){return Nm(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return $e(c)?qe(e,a,"whitespace")(c):a(c)}function a(c){return c===null||Te(c)?t(c):n(c)}}const Yv={name:"hardBreakEscape",tokenize:Xv};function Xv(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return Te(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const Jv={name:"headingAtx",resolve:Qv,tokenize:Zv};function Qv(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},dn(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function Zv(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),o(h)}function o(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||ot(h)?(e.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Te(h)?(e.exit("atxHeading"),t(h)):$e(h)?qe(e,c,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function u(h){return h===35?(e.consume(h),u):(e.exit("atxHeadingSequence"),c(h))}function d(h){return h===null||h===35||ot(h)?(e.exit("atxHeadingText"),c(h)):(e.consume(h),d)}}const eS=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Jd=["pre","script","style","textarea"],tS={concrete:!0,name:"htmlFlow",resolveTo:sS,tokenize:iS},nS={partial:!0,tokenize:aS},rS={partial:!0,tokenize:oS};function sS(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function iS(e,t,n){const r=this;let i,o,a,c,u;return d;function d(N){return h(N)}function h(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),p}function p(N){return N===33?(e.consume(N),m):N===47?(e.consume(N),o=!0,S):N===63?(e.consume(N),i=3,r.interrupt?t:v):Xt(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function m(N){return N===45?(e.consume(N),i=2,g):N===91?(e.consume(N),i=5,c=0,x):Xt(N)?(e.consume(N),i=4,r.interrupt?t:v):n(N)}function g(N){return N===45?(e.consume(N),r.interrupt?t:v):n(N)}function x(N){const ce="CDATA[";return N===ce.charCodeAt(c++)?(e.consume(N),c===ce.length?r.interrupt?t:_:x):n(N)}function S(N){return Xt(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function C(N){if(N===null||N===47||N===62||ot(N)){const ce=N===47,Ie=a.toLowerCase();return!ce&&!o&&Jd.includes(Ie)?(i=1,r.interrupt?t(N):_(N)):eS.includes(a.toLowerCase())?(i=6,ce?(e.consume(N),y):r.interrupt?t(N):_(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):o?A(N):T(N))}return N===45||$t(N)?(e.consume(N),a+=String.fromCharCode(N),C):n(N)}function y(N){return N===62?(e.consume(N),r.interrupt?t:_):n(N)}function A(N){return $e(N)?(e.consume(N),A):I(N)}function T(N){return N===47?(e.consume(N),I):N===58||N===95||Xt(N)?(e.consume(N),G):$e(N)?(e.consume(N),T):I(N)}function G(N){return N===45||N===46||N===58||N===95||$t(N)?(e.consume(N),G):P(N)}function P(N){return N===61?(e.consume(N),E):$e(N)?(e.consume(N),P):T(N)}function E(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,V):$e(N)?(e.consume(N),E):U(N)}function V(N){return N===u?(e.consume(N),u=null,L):N===null||Te(N)?n(N):(e.consume(N),V)}function U(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||ot(N)?P(N):(e.consume(N),U)}function L(N){return N===47||N===62||$e(N)?T(N):n(N)}function I(N){return N===62?(e.consume(N),H):n(N)}function H(N){return N===null||Te(N)?_(N):$e(N)?(e.consume(N),H):n(N)}function _(N){return N===45&&i===2?(e.consume(N),q):N===60&&i===1?(e.consume(N),D):N===62&&i===4?(e.consume(N),Ce):N===63&&i===3?(e.consume(N),v):N===93&&i===5?(e.consume(N),ee):Te(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(nS,je,se)(N)):N===null||Te(N)?(e.exit("htmlFlowData"),se(N)):(e.consume(N),_)}function se(N){return e.check(rS,Y,je)(N)}function Y(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),W}function W(N){return N===null||Te(N)?se(N):(e.enter("htmlFlowData"),_(N))}function q(N){return N===45?(e.consume(N),v):_(N)}function D(N){return N===47?(e.consume(N),a="",K):_(N)}function K(N){if(N===62){const ce=a.toLowerCase();return Jd.includes(ce)?(e.consume(N),Ce):_(N)}return Xt(N)&&a.length<8?(e.consume(N),a+=String.fromCharCode(N),K):_(N)}function ee(N){return N===93?(e.consume(N),v):_(N)}function v(N){return N===62?(e.consume(N),Ce):N===45&&i===2?(e.consume(N),v):_(N)}function Ce(N){return N===null||Te(N)?(e.exit("htmlFlowData"),je(N)):(e.consume(N),Ce)}function je(N){return e.exit("htmlFlow"),t(N)}}function oS(e,t,n){const r=this;return i;function i(a){return Te(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function aS(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(co,t,n)}}const lS={name:"htmlText",tokenize:cS};function cS(e,t,n){const r=this;let i,o,a;return c;function c(v){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(v),u}function u(v){return v===33?(e.consume(v),d):v===47?(e.consume(v),P):v===63?(e.consume(v),T):Xt(v)?(e.consume(v),U):n(v)}function d(v){return v===45?(e.consume(v),h):v===91?(e.consume(v),o=0,x):Xt(v)?(e.consume(v),A):n(v)}function h(v){return v===45?(e.consume(v),g):n(v)}function p(v){return v===null?n(v):v===45?(e.consume(v),m):Te(v)?(a=p,D(v)):(e.consume(v),p)}function m(v){return v===45?(e.consume(v),g):p(v)}function g(v){return v===62?q(v):v===45?m(v):p(v)}function x(v){const Ce="CDATA[";return v===Ce.charCodeAt(o++)?(e.consume(v),o===Ce.length?S:x):n(v)}function S(v){return v===null?n(v):v===93?(e.consume(v),C):Te(v)?(a=S,D(v)):(e.consume(v),S)}function C(v){return v===93?(e.consume(v),y):S(v)}function y(v){return v===62?q(v):v===93?(e.consume(v),y):S(v)}function A(v){return v===null||v===62?q(v):Te(v)?(a=A,D(v)):(e.consume(v),A)}function T(v){return v===null?n(v):v===63?(e.consume(v),G):Te(v)?(a=T,D(v)):(e.consume(v),T)}function G(v){return v===62?q(v):T(v)}function P(v){return Xt(v)?(e.consume(v),E):n(v)}function E(v){return v===45||$t(v)?(e.consume(v),E):V(v)}function V(v){return Te(v)?(a=V,D(v)):$e(v)?(e.consume(v),V):q(v)}function U(v){return v===45||$t(v)?(e.consume(v),U):v===47||v===62||ot(v)?L(v):n(v)}function L(v){return v===47?(e.consume(v),q):v===58||v===95||Xt(v)?(e.consume(v),I):Te(v)?(a=L,D(v)):$e(v)?(e.consume(v),L):q(v)}function I(v){return v===45||v===46||v===58||v===95||$t(v)?(e.consume(v),I):H(v)}function H(v){return v===61?(e.consume(v),_):Te(v)?(a=H,D(v)):$e(v)?(e.consume(v),H):L(v)}function _(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),i=v,se):Te(v)?(a=_,D(v)):$e(v)?(e.consume(v),_):(e.consume(v),Y)}function se(v){return v===i?(e.consume(v),i=void 0,W):v===null?n(v):Te(v)?(a=se,D(v)):(e.consume(v),se)}function Y(v){return v===null||v===34||v===39||v===60||v===61||v===96?n(v):v===47||v===62||ot(v)?L(v):(e.consume(v),Y)}function W(v){return v===47||v===62||ot(v)?L(v):n(v)}function q(v){return v===62?(e.consume(v),e.exit("htmlTextData"),e.exit("htmlText"),t):n(v)}function D(v){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),K}function K(v){return $e(v)?qe(e,ee,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):ee(v)}function ee(v){return e.enter("htmlTextData"),a(v)}}const Nu={name:"labelEnd",resolveAll:pS,resolveTo:fS,tokenize:mS},uS={tokenize:gS},dS={tokenize:bS},hS={tokenize:kS};function pS(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&dn(e,0,e.length,n),e}function fS(e,t){let n=e.length,r=0,i,o,a,c;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return c=[["enter",u,t],["enter",d,t]],c=wn(c,e.slice(o+1,o+r+3)),c=wn(c,[["enter",h,t]]),c=wn(c,Ha(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),c=wn(c,[["exit",h,t],e[a-2],e[a-1],["exit",d,t]]),c=wn(c,e.slice(a+1)),c=wn(c,[["exit",u,t]]),dn(e,o,e.length,c),e}function mS(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return c;function c(m){return o?o._inactive?p(m):(a=r.parser.defined.includes(An(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):n(m)}function u(m){return m===40?e.attempt(uS,h,a?h:p)(m):m===91?e.attempt(dS,h,a?d:p)(m):a?h(m):p(m)}function d(m){return e.attempt(hS,h,p)(m)}function h(m){return t(m)}function p(m){return o._balanced=!0,n(m)}}function gS(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return ot(p)?qi(e,o)(p):o(p)}function o(p){return p===41?h(p):Sm(e,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return ot(p)?qi(e,u)(p):h(p)}function c(p){return n(p)}function u(p){return p===34||p===39||p===40?Nm(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return ot(p)?qi(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function bS(e,t,n){const r=this;return i;function i(c){return Cm.call(r,e,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return r.parser.defined.includes(An(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function a(c){return n(c)}}function kS(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const xS={name:"labelStartImage",resolveAll:Nu.resolveAll,tokenize:yS};function yS(e,t,n){const r=this;return i;function i(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),o}function o(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),a):n(c)}function a(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const wS={name:"labelStartLink",resolveAll:Nu.resolveAll,tokenize:vS};function vS(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Il={name:"lineEnding",tokenize:SS};function SS(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}const fa={name:"thematicBreak",tokenize:CS};function CS(e,t,n){let r=0,i;return o;function o(d){return e.enter("thematicBreak"),a(d)}function a(d){return i=d,c(d)}function c(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Te(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),$e(d)?qe(e,c,"whitespace")(d):c(d))}}const en={continuation:{tokenize:IS},exit:MS,name:"list",tokenize:TS},NS={partial:!0,tokenize:RS},jS={partial:!0,tokenize:ES};function TS(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return c;function c(g){const x=r.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!r.containerState.marker||g===r.containerState.marker:wc(g)){if(r.containerState.type||(r.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),g===42||g===45?e.check(fa,n,d)(g):d(g);if(!r.interrupt||g===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(g)}return n(g)}function u(g){return wc(g)&&++a<10?(e.consume(g),u):(!r.interrupt||a<2)&&(r.containerState.marker?g===r.containerState.marker:g===41||g===46)?(e.exit("listItemValue"),d(g)):n(g)}function d(g){return e.enter("listItemMarker"),e.consume(g),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||g,e.check(co,r.interrupt?n:h,e.attempt(NS,m,p))}function h(g){return r.containerState.initialBlankLine=!0,o++,m(g)}function p(g){return $e(g)?(e.enter("listItemPrefixWhitespace"),e.consume(g),e.exit("listItemPrefixWhitespace"),m):n(g)}function m(g){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(g)}}function IS(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(co,i,o);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(c)}function o(c){return r.containerState.furtherBlankLines||!$e(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(jS,t,a)(c))}function a(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(en,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function ES(e,t,n){const r=this;return qe(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function MS(e){e.exit(this.containerState.type)}function RS(e,t,n){const r=this;return qe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!$e(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Qd={name:"setextUnderline",resolveTo:AS,tokenize:PS};function AS(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function PS(e,t,n){const r=this;let i;return o;function o(d){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===i?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),$e(d)?qe(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Te(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const LS={tokenize:DS};function DS(e){const t=this,n=e.attempt(co,r,e.attempt(this.parser.constructs.flowInitial,i,qe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Fv,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const _S={resolveAll:Tm()},BS=jm("string"),OS=jm("text");function jm(e){return{resolveAll:Tm(e==="text"?WS:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,c);return a;function a(h){return d(h)?o(h):c(h)}function c(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),u}function u(h){return d(h)?(n.exit("data"),o(h)):(n.consume(h),u)}function d(h){if(h===null)return!0;const p=i[h];let m=-1;if(p)for(;++m<p.length;){const g=p[m];if(!g.previous||g.previous.call(r,r.previous))return!0}return!1}}}function Tm(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function WS(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let o=i.length,a=-1,c=0,u;for(;o--;){const d=i[o];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)c++,a--;if(a)break;a=-1}else if(d===-2)u=!0,c++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const d={type:n===e.length||u||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const FS={42:en,43:en,45:en,48:en,49:en,50:en,51:en,52:en,53:en,54:en,55:en,56:en,57:en,62:xm},$S={91:qv},zS={[-2]:Tl,[-1]:Tl,32:Tl},HS={35:Jv,42:fa,45:[Qd,fa],60:tS,61:Qd,95:fa,96:Xd,126:Xd},US={38:wm,92:ym},qS={[-5]:Il,[-4]:Il,[-3]:Il,33:xS,38:wm,42:vc,60:[wv,lS],91:wS,92:[Yv,ym],93:Nu,95:vc,96:Lv},GS={null:[vc,_S]},VS={null:[42,95]},KS={null:[]},YS=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:VS,contentInitial:$S,disable:KS,document:FS,flow:HS,flowInitial:zS,insideSpan:GS,string:US,text:qS},Symbol.toStringTag,{value:"Module"}));function XS(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let a=[],c=[];const u={attempt:V(P),check:V(E),consume:A,enter:T,exit:G,interrupt:V(E,{interrupt:!0})},d={code:null,containerState:{},defineSkip:S,events:[],now:x,parser:e,previous:null,sliceSerialize:m,sliceStream:g,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&o.push(t),d;function p(H){return a=wn(a,H),C(),a[a.length-1]!==null?[]:(U(t,0),d.events=Ha(o,d.events,d),d.events)}function m(H,_){return QS(g(H),_)}function g(H){return JS(a,H)}function x(){const{_bufferIndex:H,_index:_,line:se,column:Y,offset:W}=r;return{_bufferIndex:H,_index:_,line:se,column:Y,offset:W}}function S(H){i[H.line]=H.column,I()}function C(){let H;for(;r._index<a.length;){const _=a[r._index];if(typeof _=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<_.length;)y(_.charCodeAt(r._bufferIndex));else y(_)}}function y(H){h=h(H)}function A(H){Te(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,I()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=H}function T(H,_){const se=_||{};return se.type=H,se.start=x(),d.events.push(["enter",se,d]),c.push(se),se}function G(H){const _=c.pop();return _.end=x(),d.events.push(["exit",_,d]),_}function P(H,_){U(H,_.from)}function E(H,_){_.restore()}function V(H,_){return se;function se(Y,W,q){let D,K,ee,v;return Array.isArray(Y)?je(Y):"tokenize"in Y?je([Y]):Ce(Y);function Ce(fe){return oe;function oe(_e){const Ge=_e!==null&&fe[_e],Ke=_e!==null&&fe.null,ft=[...Array.isArray(Ge)?Ge:Ge?[Ge]:[],...Array.isArray(Ke)?Ke:Ke?[Ke]:[]];return je(ft)(_e)}}function je(fe){return D=fe,K=0,fe.length===0?q:N(fe[K])}function N(fe){return oe;function oe(_e){return v=L(),ee=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?Ie():fe.tokenize.call(_?Object.assign(Object.create(d),_):d,u,ce,Ie)(_e)}}function ce(fe){return H(ee,v),W}function Ie(fe){return v.restore(),++K<D.length?N(D[K]):q}}}function U(H,_){H.resolveAll&&!o.includes(H)&&o.push(H),H.resolve&&dn(d.events,_,d.events.length-_,H.resolve(d.events.slice(_),d)),H.resolveTo&&(d.events=H.resolveTo(d.events,d))}function L(){const H=x(),_=d.previous,se=d.currentConstruct,Y=d.events.length,W=Array.from(c);return{from:Y,restore:q};function q(){r=H,d.previous=_,d.currentConstruct=se,d.events.length=Y,c=W,I()}}function I(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function JS(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const c=a[0];typeof c=="string"?a[0]=c.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function QS(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
6
+ `;break}case-3:{a=`\r
7
+ `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function ZS(e){const r={constructs:bm([YS,...(e||{}).extensions||[]]),content:i(fv),defined:[],document:i(gv),flow:i(LS),lazy:{},string:i(BS),text:i(OS)};return r;function i(o){return a;function a(c){return XS(r,o,c)}}}function eC(e){for(;!vm(e););return e}const Zd=/[\0\t\n\r]/g;function tC(){let e=1,t="",n=!0,r;return i;function i(o,a,c){const u=[];let d,h,p,m,g;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(Zd.lastIndex=p,d=Zd.exec(o),m=d&&d.index!==void 0?d.index:o.length,g=o.charCodeAt(m),!d){t=o.slice(p);break}if(g===10&&p===m&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<m&&(u.push(o.slice(p,m)),e+=m-p),g){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}p=m+1}return c&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const nC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function rC(e){return e.replace(nC,sC)}function sC(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return km(n.slice(o?2:1),o?16:10)}return Cu(n)||e}const Im={}.hasOwnProperty;function iC(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),oC(n)(eC(ZS(n).document().write(tC()(e,t,!0))))}function oC(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ve),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(ve),blockQuote:o(Ke),characterEscape:L,characterReference:L,codeFenced:o(ft),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ft,a),codeText:o(F,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(te),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(re),hardBreakEscape:o(Se),hardBreakTrailing:o(Se),htmlFlow:o(ye,a),htmlFlowData:L,htmlText:o(ye,a),htmlTextData:L,image:o(ze),label:a,link:o(Ve),listItem:o(j),listItemValue:m,listOrdered:o(Je,p),listUnordered:o(Je),paragraph:o($),reference:N,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(ve),strong:o(ie),thematicBreak:o(we)},exit:{atxHeading:u(),atxHeadingSequence:P,autolink:u(),autolinkEmail:Ge,autolinkProtocol:_e,blockQuote:u(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:fe,characterReference:oe,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:g,codeFencedFenceMeta:x,codeFlowValue:I,codeIndented:u(y),codeText:u(W),codeTextData:I,data:I,definition:u(),definitionDestinationString:G,definitionLabelString:A,definitionTitleString:T,emphasis:u(),hardBreakEscape:u(_),hardBreakTrailing:u(_),htmlFlow:u(se),htmlFlowData:I,htmlText:u(Y),htmlTextData:I,image:u(D),label:ee,labelText:K,lineEnding:H,link:u(q),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ce,resourceDestinationString:v,resourceTitleString:Ce,resource:je,setextHeading:u(U),setextHeadingLineSequence:V,setextHeadingText:E,strong:u(),thematicBreak:u()}};Em(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(z){let J={type:"root",children:[]};const he={stack:[J],tokenStack:[],config:t,enter:c,exit:d,buffer:a,resume:h,data:n},ke=[];let De=-1;for(;++De<z.length;)if(z[De][1].type==="listOrdered"||z[De][1].type==="listUnordered")if(z[De][0]==="enter")ke.push(De);else{const We=ke.pop();De=i(z,We,De)}for(De=-1;++De<z.length;){const We=t[z[De][0]];Im.call(We,z[De][1].type)&&We[z[De][1].type].call(Object.assign({sliceSerialize:z[De][2].sliceSerialize},he),z[De][1])}if(he.tokenStack.length>0){const We=he.tokenStack[he.tokenStack.length-1];(We[1]||eh).call(he,void 0,We[0])}for(J.position={start:jr(z.length>0?z[0][1].start:{line:1,column:1,offset:0}),end:jr(z.length>0?z[z.length-2][1].end:{line:1,column:1,offset:0})},De=-1;++De<t.transforms.length;)J=t.transforms[De](J)||J;return J}function i(z,J,he){let ke=J-1,De=-1,We=!1,mt,Ze,ht,lt;for(;++ke<=he;){const Ye=z[ke];switch(Ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ye[0]==="enter"?De++:De--,lt=void 0;break}case"lineEndingBlank":{Ye[0]==="enter"&&(mt&&!lt&&!De&&!ht&&(ht=ke),lt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:lt=void 0}if(!De&&Ye[0]==="enter"&&Ye[1].type==="listItemPrefix"||De===-1&&Ye[0]==="exit"&&(Ye[1].type==="listUnordered"||Ye[1].type==="listOrdered")){if(mt){let et=ke;for(Ze=void 0;et--;){const bt=z[et];if(bt[1].type==="lineEnding"||bt[1].type==="lineEndingBlank"){if(bt[0]==="exit")continue;Ze&&(z[Ze][1].type="lineEndingBlank",We=!0),bt[1].type="lineEnding",Ze=et}else if(!(bt[1].type==="linePrefix"||bt[1].type==="blockQuotePrefix"||bt[1].type==="blockQuotePrefixWhitespace"||bt[1].type==="blockQuoteMarker"||bt[1].type==="listItemIndent"))break}ht&&(!Ze||ht<Ze)&&(mt._spread=!0),mt.end=Object.assign({},Ze?z[Ze][1].start:Ye[1].end),z.splice(Ze||ke,0,["exit",mt,Ye[2]]),ke++,he++}if(Ye[1].type==="listItemPrefix"){const et={type:"listItem",_spread:!1,start:Object.assign({},Ye[1].start),end:void 0};mt=et,z.splice(ke,0,["enter",et,Ye[2]]),ke++,he++,ht=void 0,lt=!0}}}return z[J][1]._spread=We,he}function o(z,J){return he;function he(ke){c.call(this,z(ke),ke),J&&J.call(this,ke)}}function a(){this.stack.push({type:"fragment",children:[]})}function c(z,J,he){this.stack[this.stack.length-1].children.push(z),this.stack.push(z),this.tokenStack.push([J,he||void 0]),z.position={start:jr(J.start),end:void 0}}function u(z){return J;function J(he){z&&z.call(this,he),d.call(this,he)}}function d(z,J){const he=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==z.type&&(J?J.call(this,z,ke[0]):(ke[1]||eh).call(this,z,ke[0]));else throw new Error("Cannot close `"+z.type+"` ("+Ui({start:z.start,end:z.end})+"): it’s not open");he.position.end=jr(z.end)}function h(){return Su(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(z){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(z),10),this.data.expectingFirstListItemValue=void 0}}function g(){const z=this.resume(),J=this.stack[this.stack.length-1];J.lang=z}function x(){const z=this.resume(),J=this.stack[this.stack.length-1];J.meta=z}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const z=this.resume(),J=this.stack[this.stack.length-1];J.value=z.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const z=this.resume(),J=this.stack[this.stack.length-1];J.value=z.replace(/(\r?\n|\r)$/g,"")}function A(z){const J=this.resume(),he=this.stack[this.stack.length-1];he.label=J,he.identifier=An(this.sliceSerialize(z)).toLowerCase()}function T(){const z=this.resume(),J=this.stack[this.stack.length-1];J.title=z}function G(){const z=this.resume(),J=this.stack[this.stack.length-1];J.url=z}function P(z){const J=this.stack[this.stack.length-1];if(!J.depth){const he=this.sliceSerialize(z).length;J.depth=he}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function V(z){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(z).codePointAt(0)===61?1:2}function U(){this.data.setextHeadingSlurpLineEnding=void 0}function L(z){const he=this.stack[this.stack.length-1].children;let ke=he[he.length-1];(!ke||ke.type!=="text")&&(ke=me(),ke.position={start:jr(z.start),end:void 0},he.push(ke)),this.stack.push(ke)}function I(z){const J=this.stack.pop();J.value+=this.sliceSerialize(z),J.position.end=jr(z.end)}function H(z){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=J.children[J.children.length-1];he.position.end=jr(z.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(L.call(this,z),I.call(this,z))}function _(){this.data.atHardBreak=!0}function se(){const z=this.resume(),J=this.stack[this.stack.length-1];J.value=z}function Y(){const z=this.resume(),J=this.stack[this.stack.length-1];J.value=z}function W(){const z=this.resume(),J=this.stack[this.stack.length-1];J.value=z}function q(){const z=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";z.type+="Reference",z.referenceType=J,delete z.url,delete z.title}else delete z.identifier,delete z.label;this.data.referenceType=void 0}function D(){const z=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";z.type+="Reference",z.referenceType=J,delete z.url,delete z.title}else delete z.identifier,delete z.label;this.data.referenceType=void 0}function K(z){const J=this.sliceSerialize(z),he=this.stack[this.stack.length-2];he.label=rC(J),he.identifier=An(J).toLowerCase()}function ee(){const z=this.stack[this.stack.length-1],J=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const ke=z.children;he.children=ke}else he.alt=J}function v(){const z=this.resume(),J=this.stack[this.stack.length-1];J.url=z}function Ce(){const z=this.resume(),J=this.stack[this.stack.length-1];J.title=z}function je(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function ce(z){const J=this.resume(),he=this.stack[this.stack.length-1];he.label=J,he.identifier=An(this.sliceSerialize(z)).toLowerCase(),this.data.referenceType="full"}function Ie(z){this.data.characterReferenceType=z.type}function fe(z){const J=this.sliceSerialize(z),he=this.data.characterReferenceType;let ke;he?(ke=km(J,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=Cu(J);const De=this.stack[this.stack.length-1];De.value+=ke}function oe(z){const J=this.stack.pop();J.position.end=jr(z.end)}function _e(z){I.call(this,z);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(z)}function Ge(z){I.call(this,z);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(z)}function Ke(){return{type:"blockquote",children:[]}}function ft(){return{type:"code",lang:null,meta:null,value:""}}function F(){return{type:"inlineCode",value:""}}function te(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function re(){return{type:"emphasis",children:[]}}function ve(){return{type:"heading",depth:0,children:[]}}function Se(){return{type:"break"}}function ye(){return{type:"html",value:""}}function ze(){return{type:"image",title:null,url:"",alt:null}}function Ve(){return{type:"link",title:null,url:"",children:[]}}function Je(z){return{type:"list",ordered:z.type==="listOrdered",start:null,spread:z._spread,children:[]}}function j(z){return{type:"listItem",spread:z._spread,checked:null,children:[]}}function $(){return{type:"paragraph",children:[]}}function ie(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function jr(e){return{line:e.line,column:e.column,offset:e.offset}}function Em(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Em(e,r):aC(e,r)}}function aC(e,t){let n;for(n in t)if(Im.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function eh(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ui({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ui({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ui({start:t.start,end:t.end})+") is still open")}function lC(e){const t=this;t.parser=n;function n(r){return iC(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function cC(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function uC(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
8
+ `}]}function dC(e,t){const n=t.value?t.value+`
9
+ `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function hC(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pC(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fC(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=ci(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,c+=1,e.footnoteCounts.set(r,c);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function mC(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gC(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Mm(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function bC(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Mm(e,t);const i={src:ci(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function kC(e,t){const n={src:ci(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function xC(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function yC(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Mm(e,t);const i={href:ci(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function wC(e,t){const n={href:ci(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function vC(e,t,n){const r=e.all(t),i=n?SC(n):Rm(t),o={},a=[];if(typeof t.checked=="boolean"){const h=r[0];let p;h&&h.type==="element"&&h.tagName==="p"?p=h:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const h=r[c];(i||c!==0||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
10
+ `}),h.type==="element"&&h.tagName==="p"&&!i?a.push(...h.children):a.push(h)}const u=r[r.length-1];u&&(i||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
11
+ `});const d={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,d),e.applyData(t,d)}function SC(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Rm(n[r])}return t}function Rm(e){const t=e.spread;return t??e.children.length>1}function CC(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function NC(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jC(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function TC(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IC(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=xu(t.children[1]),u=um(t.children[t.children.length-1]);c&&u&&(a.position={start:c,end:u}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function EC(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,c=a?a.length:t.children.length;let u=-1;const d=[];for(;++u<c;){const p=t.children[u],m={},g=a?a[u]:void 0;g&&(m.align=g);let x={type:"element",tagName:o,properties:m,children:[]};p&&(x.children=e.all(p),e.patch(p,x),x=e.applyData(p,x)),d.push(x)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,h),e.applyData(t,h)}function MC(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const th=9,nh=32;function RC(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(rh(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(rh(t.slice(i),i>0,!1)),o.join("")}function rh(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===th||o===nh;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===th||o===nh;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function AC(e,t){const n={type:"text",value:RC(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function PC(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const LC={blockquote:cC,break:uC,code:dC,delete:hC,emphasis:pC,footnoteReference:fC,heading:mC,html:gC,imageReference:bC,image:kC,inlineCode:xC,linkReference:yC,link:wC,listItem:vC,list:CC,paragraph:NC,root:jC,strong:TC,table:IC,tableCell:MC,tableRow:EC,text:AC,thematicBreak:PC,toml:$o,yaml:$o,definition:$o,footnoteDefinition:$o};function $o(){}const Am=-1,Ua=0,Gi=1,Na=2,ju=3,Tu=4,Iu=5,Eu=6,Pm=7,Lm=8,sh=typeof self=="object"?self:globalThis,DC=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case Ua:case Am:return n(a,i);case Gi:{const c=n([],i);for(const u of a)c.push(r(u));return c}case Na:{const c=n({},i);for(const[u,d]of a)c[r(u)]=r(d);return c}case ju:return n(new Date(a),i);case Tu:{const{source:c,flags:u}=a;return n(new RegExp(c,u),i)}case Iu:{const c=n(new Map,i);for(const[u,d]of a)c.set(r(u),r(d));return c}case Eu:{const c=n(new Set,i);for(const u of a)c.add(r(u));return c}case Pm:{const{name:c,message:u}=a;return n(new sh[c](u),i)}case Lm:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:c}=new Uint8Array(a);return n(new DataView(c),a)}}return n(new sh[o](a),i)};return r},ih=e=>DC(new Map,e)(0),Ls="",{toString:_C}={},{keys:BC}=Object,Pi=e=>{const t=typeof e;if(t!=="object"||!e)return[Ua,t];const n=_C.call(e).slice(8,-1);switch(n){case"Array":return[Gi,Ls];case"Object":return[Na,Ls];case"Date":return[ju,Ls];case"RegExp":return[Tu,Ls];case"Map":return[Iu,Ls];case"Set":return[Eu,Ls];case"DataView":return[Gi,n]}return n.includes("Array")?[Gi,n]:n.includes("Error")?[Pm,n]:[Na,n]},zo=([e,t])=>e===Ua&&(t==="function"||t==="symbol"),OC=(e,t,n,r)=>{const i=(a,c)=>{const u=r.push(a)-1;return n.set(c,u),u},o=a=>{if(n.has(a))return n.get(a);let[c,u]=Pi(a);switch(c){case Ua:{let h=a;switch(u){case"bigint":c=Lm,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);h=null;break;case"undefined":return i([Am],a)}return i([c,h],a)}case Gi:{if(u){let m=a;return u==="DataView"?m=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(m=new Uint8Array(a)),i([u,[...m]],a)}const h=[],p=i([c,h],a);for(const m of a)h.push(o(m));return p}case Na:{if(u)switch(u){case"BigInt":return i([u,a.toString()],a);case"Boolean":case"Number":case"String":return i([u,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const h=[],p=i([c,h],a);for(const m of BC(a))(e||!zo(Pi(a[m])))&&h.push([o(m),o(a[m])]);return p}case ju:return i([c,a.toISOString()],a);case Tu:{const{source:h,flags:p}=a;return i([c,{source:h,flags:p}],a)}case Iu:{const h=[],p=i([c,h],a);for(const[m,g]of a)(e||!(zo(Pi(m))||zo(Pi(g))))&&h.push([o(m),o(g)]);return p}case Eu:{const h=[],p=i([c,h],a);for(const m of a)(e||!zo(Pi(m)))&&h.push(o(m));return p}}const{message:d}=a;return i([c,{name:u,message:d}],a)};return o},oh=(e,{json:t,lossy:n}={})=>{const r=[];return OC(!(t||n),!!t,new Map,r)(e),r},ja=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ih(oh(e,t)):structuredClone(e):(e,t)=>ih(oh(e,t));function WC(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function FC(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function $C(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||WC,r=e.options.footnoteBackLabel||FC,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const h=e.all(d),p=String(d.identifier).toUpperCase(),m=ci(p.toLowerCase());let g=0;const x=[],S=e.footnoteCounts.get(p);for(;S!==void 0&&++g<=S;){x.length>0&&x.push({type:"text",value:" "});let A=typeof n=="string"?n:n(u,g);typeof A=="string"&&(A={type:"text",value:A}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+m+(g>1?"-"+g:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,g),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const C=h[h.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const A=C.children[C.children.length-1];A&&A.type==="text"?A.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...x)}else h.push(...x);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+m},children:e.wrap(h,!0)};e.patch(d,y),c.push(y)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...ja(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
12
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
13
+ `}]}}const qa=(function(e){if(e==null)return qC;if(typeof e=="function")return Ga(e);if(typeof e=="object")return Array.isArray(e)?zC(e):HC(e);if(typeof e=="string")return UC(e);throw new Error("Expected function, string, or object as test")});function zC(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=qa(e[n]);return Ga(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function HC(e){const t=e;return Ga(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function UC(e){return Ga(t);function t(n){return n&&n.type===e}}function Ga(e){return t;function t(n,r,i){return!!(GC(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function qC(){return!0}function GC(e){return e!==null&&typeof e=="object"&&"type"in e}const Dm=[],VC=!0,Sc=!1,KC="skip";function _m(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=qa(i),a=r?-1:1;c(e,void 0,[])();function c(u,d,h){const p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){const g=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(u.type+(g?"<"+g+">":""))+")"})}return m;function m(){let g=Dm,x,S,C;if((!t||o(u,d,h[h.length-1]||void 0))&&(g=YC(n(u,h)),g[0]===Sc))return g;if("children"in u&&u.children){const y=u;if(y.children&&g[0]!==KC)for(S=(r?y.children.length:-1)+a,C=h.concat(y);S>-1&&S<y.children.length;){const A=y.children[S];if(x=c(A,S,C)(),x[0]===Sc)return x;S=typeof x[1]=="number"?x[1]:S+a}}return g}}}function YC(e){return Array.isArray(e)?e:typeof e=="number"?[VC,e]:e==null?Dm:[e]}function Mu(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),_m(e,o,c,i);function c(u,d){const h=d[d.length-1],p=h?h.children.indexOf(u):void 0;return a(u,p,h)}}const Cc={}.hasOwnProperty,XC={};function JC(e,t){const n=t||XC,r=new Map,i=new Map,o=new Map,a={...LC,...n.handlers},c={all:d,applyData:ZC,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:u,options:n,patch:QC,wrap:t1};return Mu(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const p=h.type==="definition"?r:i,m=String(h.identifier).toUpperCase();p.has(m)||p.set(m,h)}}),c;function u(h,p){const m=h.type,g=c.handlers[m];if(Cc.call(c.handlers,m)&&g)return g(c,h,p);if(c.options.passThrough&&c.options.passThrough.includes(m)){if("children"in h){const{children:S,...C}=h,y=ja(C);return y.children=c.all(h),y}return ja(h)}return(c.options.unknownHandler||e1)(c,h,p)}function d(h){const p=[];if("children"in h){const m=h.children;let g=-1;for(;++g<m.length;){const x=c.one(m[g],h);if(x){if(g&&m[g-1].type==="break"&&(!Array.isArray(x)&&x.type==="text"&&(x.value=ah(x.value)),!Array.isArray(x)&&x.type==="element")){const S=x.children[0];S&&S.type==="text"&&(S.value=ah(S.value))}Array.isArray(x)?p.push(...x):p.push(x)}}}return p}}function QC(e,t){e.position&&(t.position=Fw(e))}function ZC(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,ja(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function e1(e,t){const n=t.data||{},r="value"in t&&!(Cc.call(n,"hProperties")||Cc.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function t1(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
14
+ `});++r<e.length;)r&&n.push({type:"text",value:`
15
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
16
+ `}),n}function ah(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function lh(e,t){const n=JC(e,t),r=n.one(e,void 0),i=$C(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
17
+ `},i),o}function n1(e,t){return e&&"run"in e?async function(n,r){const i=lh(n,{file:r,...t});await e.run(i,r)}:function(n,r){return lh(n,{file:r,...e||t})}}function ch(e){if(e)throw e}var El,uh;function r1(){if(uh)return El;uh=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var h=e.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!h&&!p)return!1;var m;for(m in d);return typeof m>"u"||e.call(d,m)},a=function(d,h){n&&h.name==="__proto__"?n(d,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):d[h.name]=h.newValue},c=function(d,h){if(h==="__proto__")if(e.call(d,h)){if(r)return r(d,h).value}else return;return d[h]};return El=function u(){var d,h,p,m,g,x,S=arguments[0],C=1,y=arguments.length,A=!1;for(typeof S=="boolean"&&(A=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});C<y;++C)if(d=arguments[C],d!=null)for(h in d)p=c(S,h),m=c(d,h),S!==m&&(A&&m&&(o(m)||(g=i(m)))?(g?(g=!1,x=p&&i(p)?p:[]):x=p&&o(p)?p:{},a(S,{name:h,newValue:u(A,x,m)})):typeof m<"u"&&a(S,{name:h,newValue:m}));return S},El}var s1=r1();const Ml=of(s1);function Nc(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function i1(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...i);function c(u,...d){const h=e[++o];let p=-1;if(u){a(u);return}for(;++p<i.length;)(d[p]===null||d[p]===void 0)&&(d[p]=i[p]);i=d,h?o1(h,c)(...d):a(null,...d)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function o1(e,t){let n;return r;function r(...a){const c=e.length>a.length;let u;c&&a.push(i);try{u=e.apply(this,a)}catch(d){const h=d;if(c&&n)throw h;return i(h)}c||(u&&u.then&&typeof u.then=="function"?u.then(o,i):u instanceof Error?i(u):o(u))}function i(a,...c){n||(n=!0,t(a,...c))}function o(a){i(null,a)}}const Kn={basename:a1,dirname:l1,extname:c1,join:u1,sep:"/"};function a1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');uo(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,c=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),c>-1&&(e.codePointAt(i)===t.codePointAt(c--)?c<0&&(r=i):(c=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function l1(e){if(uo(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function c1(e){uo(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function u1(...e){let t=-1,n;for(;++t<e.length;)uo(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":d1(n)}function d1(e){uo(e);const t=e.codePointAt(0)===47;let n=h1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function h1(e,t){let n="",r=0,i=-1,o=0,a=-1,c,u;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else c===46&&o>-1?o++:o=-1}return n}function uo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const p1={cwd:f1};function f1(){return"/"}function jc(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function m1(e){if(typeof e=="string")e=new URL(e);else if(!jc(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return g1(e)}function g1(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Rl=["history","path","basename","stem","extname","dirname"];class Bm{constructor(t){let n;t?jc(t)?n={path:t}:typeof t=="string"||b1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":p1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Rl.length;){const o=Rl[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)Rl.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Kn.basename(this.path):void 0}set basename(t){Pl(t,"basename"),Al(t,"basename"),this.path=Kn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Kn.dirname(this.path):void 0}set dirname(t){dh(this.basename,"dirname"),this.path=Kn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Kn.extname(this.path):void 0}set extname(t){if(Al(t,"extname"),dh(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Kn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jc(t)&&(t=m1(t)),Pl(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Kn.basename(this.path,this.extname):void 0}set stem(t){Pl(t,"stem"),Al(t,"stem"),this.path=Kn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new zt(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Al(e,t){if(e&&e.includes(Kn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Kn.sep+"`")}function Pl(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function dh(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function b1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const k1=(function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),x1={}.hasOwnProperty;class Ru extends k1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=i1()}copy(){const t=new Ru;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Ml(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(_l("data",this.frozen),this.namespace[t]=n,this):x1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(_l("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Ho(t),r=this.parser||this.Parser;return Ll("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ll("process",this.parser||this.Parser),Dl("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,a){const c=Ho(t),u=r.parse(c);r.run(u,c,function(h,p,m){if(h||!p||!m)return d(h);const g=p,x=r.stringify(g,m);v1(x)?m.value=x:m.result=x,d(h,m)});function d(h,p){h||!p?a(h):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),Ll("processSync",this.parser||this.Parser),Dl("processSync",this.compiler||this.Compiler),this.process(t,i),ph("processSync","process",n),r;function i(o,a){n=!0,ch(o),r=a}}run(t,n,r){hh(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,c){const u=Ho(n);i.run(t,u,d);function d(h,p,m){const g=p||t;h?c(h):a?a(g):r(void 0,g,m)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),ph("runSync","run",r),i;function o(a,c){ch(a),i=c,r=!0}}stringify(t,n){this.freeze();const r=Ho(n),i=this.compiler||this.Compiler;return Dl("stringify",i),hh(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(_l("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[h,...p]=d;u(h,p)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(d.plugins),d.settings&&(i.settings=Ml(!0,i.settings,d.settings))}function c(d){let h=-1;if(d!=null)if(Array.isArray(d))for(;++h<d.length;){const p=d[h];o(p)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,h){let p=-1,m=-1;for(;++p<r.length;)if(r[p][0]===d){m=p;break}if(m===-1)r.push([d,...h]);else if(h.length>0){let[g,...x]=h;const S=r[m][1];Nc(S)&&Nc(g)&&(g=Ml(!0,S,g)),r[m]=[d,g,...x]}}}}const y1=new Ru().freeze();function Ll(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Dl(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function _l(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function hh(e){if(!Nc(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ph(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ho(e){return w1(e)?e:new Bm(e)}function w1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function v1(e){return typeof e=="string"||S1(e)}function S1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const C1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",fh=[],mh={allowDangerousHtml:!0},N1=/^(https?|ircs?|mailto|xmpp)$/i,j1=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function T1(e){const t=I1(e),n=E1(e);return M1(t.runSync(t.parse(n),n),e)}function I1(e){const t=e.rehypePlugins||fh,n=e.remarkPlugins||fh,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...mh}:mh;return y1().use(lC).use(n).use(n1,r).use(t)}function E1(e){const t=e.children||"",n=new Bm;return typeof t=="string"&&(n.value=t),n}function M1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,u=t.urlTransform||R1;for(const h of j1)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+C1+h.id,void 0);return Mu(e,d),qw(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function d(h,p,m){if(h.type==="raw"&&m&&typeof p=="number")return a?m.children.splice(p,1):m.children[p]={type:"text",value:h.value},p;if(h.type==="element"){let g;for(g in jl)if(Object.hasOwn(jl,g)&&Object.hasOwn(h.properties,g)){const x=h.properties[g],S=jl[g];(S===null||S.includes(h.tagName))&&(h.properties[g]=u(String(x||""),g,h))}}if(h.type==="element"){let g=n?!n.includes(h.tagName):o?o.includes(h.tagName):!1;if(!g&&r&&typeof p=="number"&&(g=!r(h,p,m)),g&&m&&typeof p=="number")return c&&h.children?m.children.splice(p,1,...h.children):m.children.splice(p,1),p}}}function R1(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||N1.test(e.slice(0,t))?e:""}function gh(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function A1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function P1(e,t,n){const i=qa((n||{}).ignore||[]),o=L1(t);let a=-1;for(;++a<o.length;)_m(e,"text",c);function c(d,h){let p=-1,m;for(;++p<h.length;){const g=h[p],x=m?m.children:void 0;if(i(g,x?x.indexOf(g):void 0,m))return;m=g}if(m)return u(d,h)}function u(d,h){const p=h[h.length-1],m=o[a][0],g=o[a][1];let x=0;const C=p.children.indexOf(d);let y=!1,A=[];m.lastIndex=0;let T=m.exec(d.value);for(;T;){const G=T.index,P={index:T.index,input:T.input,stack:[...h,d]};let E=g(...T,P);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?m.lastIndex=G+1:(x!==G&&A.push({type:"text",value:d.value.slice(x,G)}),Array.isArray(E)?A.push(...E):E&&A.push(E),x=G+T[0].length,y=!0),!m.global)break;T=m.exec(d.value)}return y?(x<d.value.length&&A.push({type:"text",value:d.value.slice(x)}),p.children.splice(C,1,...A)):A=[d],C+A.length}}function L1(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([D1(i[0]),_1(i[1])])}return t}function D1(e){return typeof e=="string"?new RegExp(A1(e),"g"):e}function _1(e){return typeof e=="function"?e:function(){return e}}const Bl="phrasing",Ol=["autolink","link","image","label"];function B1(){return{transforms:[U1],enter:{literalAutolink:W1,literalAutolinkEmail:Wl,literalAutolinkHttp:Wl,literalAutolinkWww:Wl},exit:{literalAutolink:H1,literalAutolinkEmail:z1,literalAutolinkHttp:F1,literalAutolinkWww:$1}}}function O1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Bl,notInConstruct:Ol},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Bl,notInConstruct:Ol},{character:":",before:"[ps]",after:"\\/",inConstruct:Bl,notInConstruct:Ol}]}}function W1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Wl(e){this.config.enter.autolinkProtocol.call(this,e)}function F1(e){this.config.exit.autolinkProtocol.call(this,e)}function $1(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function z1(e){this.config.exit.autolinkEmail.call(this,e)}function H1(e){this.exit(e)}function U1(e){P1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,q1],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),G1]],{ignore:["link","linkReference"]})}function q1(e,t,n,r,i){let o="";if(!Om(i)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!V1(n)))return!1;const a=K1(n+r);if(!a[0])return!1;const c={type:"link",title:null,url:o+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[c,{type:"text",value:a[1]}]:c}function G1(e,t,n,r){return!Om(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function V1(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function K1(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=gh(e,"(");let o=gh(e,")");for(;r!==-1&&i>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function Om(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||ls(n)||za(n))&&(!t||n!==47)}Wm.peek=r0;function Y1(){this.buffer()}function X1(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function J1(){this.buffer()}function Q1(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Z1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=An(this.sliceSerialize(e)).toLowerCase(),n.label=t}function e0(e){this.exit(e)}function t0(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=An(this.sliceSerialize(e)).toLowerCase(),n.label=t}function n0(e){this.exit(e)}function r0(){return"["}function Wm(e,t,n,r){const i=n.createTracker(r);let o=i.move("[^");const a=n.enter("footnoteReference"),c=n.enter("reference");return o+=i.move(n.safe(n.associationId(e),{after:"]",before:o})),c(),a(),o+=i.move("]"),o}function s0(){return{enter:{gfmFootnoteCallString:Y1,gfmFootnoteCall:X1,gfmFootnoteDefinitionLabelString:J1,gfmFootnoteDefinition:Q1},exit:{gfmFootnoteCallString:Z1,gfmFootnoteCall:e0,gfmFootnoteDefinitionLabelString:t0,gfmFootnoteDefinition:n0}}}function i0(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Wm},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,o,a){const c=o.createTracker(a);let u=c.move("[^");const d=o.enter("footnoteDefinition"),h=o.enter("label");return u+=c.move(o.safe(o.associationId(r),{before:u,after:"]"})),h(),u+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),u+=c.move((t?`
18
+ `:" ")+o.indentLines(o.containerFlow(r,c.current()),t?Fm:o0))),d(),u}}function o0(e,t,n){return t===0?e:Fm(e,t,n)}function Fm(e,t,n){return(n?"":" ")+e}const a0=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];$m.peek=h0;function l0(){return{canContainEols:["delete"],enter:{strikethrough:u0},exit:{strikethrough:d0}}}function c0(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:a0}],handlers:{delete:$m}}}function u0(e){this.enter({type:"delete",children:[]},e)}function d0(e){this.exit(e)}function $m(e,t,n,r){const i=n.createTracker(r),o=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),o(),a}function h0(){return"~"}function p0(e){return e.length}function f0(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||p0,o=[],a=[],c=[],u=[];let d=0,h=-1;for(;++h<e.length;){const S=[],C=[];let y=-1;for(e[h].length>d&&(d=e[h].length);++y<e[h].length;){const A=m0(e[h][y]);if(n.alignDelimiters!==!1){const T=i(A);C[y]=T,(u[y]===void 0||T>u[y])&&(u[y]=T)}S.push(A)}a[h]=S,c[h]=C}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)o[p]=bh(r[p]);else{const S=bh(r);for(;++p<d;)o[p]=S}p=-1;const m=[],g=[];for(;++p<d;){const S=o[p];let C="",y="";S===99?(C=":",y=":"):S===108?C=":":S===114&&(y=":");let A=n.alignDelimiters===!1?1:Math.max(1,u[p]-C.length-y.length);const T=C+"-".repeat(A)+y;n.alignDelimiters!==!1&&(A=C.length+A+y.length,A>u[p]&&(u[p]=A),g[p]=A),m[p]=T}a.splice(1,0,m),c.splice(1,0,g),h=-1;const x=[];for(;++h<a.length;){const S=a[h],C=c[h];p=-1;const y=[];for(;++p<d;){const A=S[p]||"";let T="",G="";if(n.alignDelimiters!==!1){const P=u[p]-(C[p]||0),E=o[p];E===114?T=" ".repeat(P):E===99?P%2?(T=" ".repeat(P/2+.5),G=" ".repeat(P/2-.5)):(T=" ".repeat(P/2),G=T):G=" ".repeat(P)}n.delimiterStart!==!1&&!p&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||p)&&y.push(" "),n.alignDelimiters!==!1&&y.push(T),y.push(A),n.alignDelimiters!==!1&&y.push(G),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||p!==d-1)&&y.push("|")}x.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return x.join(`
19
+ `)}function m0(e){return e==null?"":String(e)}function bh(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function g0(e,t,n,r){const i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),b0);return i(),a}function b0(e,t,n){return">"+(n?"":" ")+e}function k0(e,t){return kh(e,t.inConstruct,!0)&&!kh(e,t.notInConstruct,!1)}function kh(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function xh(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
20
+ `&&k0(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
21
+ `}function x0(e,t){const n=String(e);let r=n.indexOf(t),i=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>a&&(a=o):o=1,i=r+t.length,r=n.indexOf(t,i);return a}function y0(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function w0(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function v0(e,t,n,r){const i=w0(n),o=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(y0(e,n)){const p=n.enter("codeIndented"),m=n.indentLines(o,S0);return p(),m}const c=n.createTracker(r),u=i.repeat(Math.max(x0(o,i)+1,3)),d=n.enter("codeFenced");let h=c.move(u);if(e.lang){const p=n.enter(`codeFencedLang${a}`);h+=c.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${a}`);h+=c.move(" "),h+=c.move(n.safe(e.meta,{before:h,after:`
22
+ `,encode:["`"],...c.current()})),p()}return h+=c.move(`
23
+ `),o&&(h+=c.move(o+`
24
+ `)),h+=c.move(u),d(),h}function S0(e,t,n){return(n?"":" ")+e}function Au(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function C0(e,t,n,r){const i=Au(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("[");return d+=u.move(n.safe(n.associationId(e),{before:d,after:"]",...u.current()})),d+=u.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(c=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":`
25
+ `,...u.current()}))),c(),e.title&&(c=n.enter(`title${o}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),c()),a(),d}function N0(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Qi(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ta(e,t,n){const r=si(e),i=si(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zm.peek=j0;function zm(e,t,n,r){const i=N0(n),o=n.enter("emphasis"),a=n.createTracker(r),c=a.move(i);let u=a.move(n.containerPhrasing(e,{after:i,before:c,...a.current()}));const d=u.charCodeAt(0),h=Ta(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=Qi(d)+u.slice(1));const p=u.charCodeAt(u.length-1),m=Ta(r.after.charCodeAt(0),p,i);m.inside&&(u=u.slice(0,-1)+Qi(p));const g=a.move(i);return o(),n.attentionEncodeSurroundingInfo={after:m.outside,before:h.outside},c+u+g}function j0(e,t,n){return n.options.emphasis||"*"}function T0(e,t){let n=!1;return Mu(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Sc}),!!((!e.depth||e.depth<3)&&Su(e)&&(t.options.setext||n))}function I0(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(T0(e,n)){const h=n.enter("headingSetext"),p=n.enter("phrasing"),m=n.containerPhrasing(e,{...o.current(),before:`
26
+ `,after:`
27
+ `});return p(),h(),m+`
28
+ `+(i===1?"=":"-").repeat(m.length-(Math.max(m.lastIndexOf("\r"),m.lastIndexOf(`
29
+ `))+1))}const a="#".repeat(i),c=n.enter("headingAtx"),u=n.enter("phrasing");o.move(a+" ");let d=n.containerPhrasing(e,{before:"# ",after:`
30
+ `,...o.current()});return/^[\t ]/.test(d)&&(d=Qi(d.charCodeAt(0))+d.slice(1)),d=d?a+" "+d:a,n.options.closeAtx&&(d+=" "+a),u(),c(),d}Hm.peek=E0;function Hm(e){return e.value||""}function E0(){return"<"}Um.peek=M0;function Um(e,t,n,r){const i=Au(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("![");return d+=u.move(n.safe(e.alt,{before:d,after:"]",...u.current()})),d+=u.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(c=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":")",...u.current()}))),c(),e.title&&(c=n.enter(`title${o}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),c()),d+=u.move(")"),a(),d}function M0(){return"!"}qm.peek=R0;function qm(e,t,n,r){const i=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("![");const d=n.safe(e.alt,{before:u,after:"]",...c.current()});u+=c.move(d+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return a(),n.stack=h,o(),i==="full"||!d||d!==p?u+=c.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function R0(){return"!"}Gm.peek=A0;function Gm(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],c=n.compilePattern(a);let u;if(a.atBreak)for(;u=c.exec(r);){let d=u.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(u.index+1)}}return i+r+i}function A0(){return"`"}function Vm(e,t){const n=Su(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Km.peek=P0;function Km(e,t,n,r){const i=Au(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let c,u;if(Vm(e,n)){const h=n.stack;n.stack=[],c=n.enter("autolink");let p=a.move("<");return p+=a.move(n.containerPhrasing(e,{before:p,after:">",...a.current()})),p+=a.move(">"),c(),n.stack=h,p}c=n.enter("link"),u=n.enter("label");let d=a.move("[");return d+=a.move(n.containerPhrasing(e,{before:d,after:"](",...a.current()})),d+=a.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),d+=a.move("<"),d+=a.move(n.safe(e.url,{before:d,after:">",...a.current()})),d+=a.move(">")):(u=n.enter("destinationRaw"),d+=a.move(n.safe(e.url,{before:d,after:e.title?" ":")",...a.current()}))),u(),e.title&&(u=n.enter(`title${o}`),d+=a.move(" "+i),d+=a.move(n.safe(e.title,{before:d,after:i,...a.current()})),d+=a.move(i),u()),d+=a.move(")"),c(),d}function P0(e,t,n){return Vm(e,n)?"<":"["}Ym.peek=L0;function Ym(e,t,n,r){const i=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("[");const d=n.containerPhrasing(e,{before:u,after:"]",...c.current()});u+=c.move(d+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return a(),n.stack=h,o(),i==="full"||!d||d!==p?u+=c.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function L0(){return"["}function Pu(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function D0(e){const t=Pu(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function _0(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Xm(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function B0(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?_0(n):Pu(n);const c=e.ordered?a==="."?")":".":D0(n);let u=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),Xm(n)===a&&h){let p=-1;for(;++p<e.children.length;){const m=e.children[p];if(m&&m.type==="listItem"&&m.children&&m.children[0]&&m.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(a=c),n.bulletCurrent=a;const d=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,i(),d}function O0(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function W0(e,t,n,r){const i=O0(n);let o=n.bulletCurrent||Pu(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const c=n.createTracker(r);c.move(o+" ".repeat(a-o.length)),c.shift(a);const u=n.enter("listItem"),d=n.indentLines(n.containerFlow(e,c.current()),h);return u(),d;function h(p,m,g){return m?(g?"":" ".repeat(a))+p:(g?o:o+" ".repeat(a-o.length))+p}}function F0(e,t,n,r){const i=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),i(),a}const $0=qa(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function z0(e,t,n,r){return(e.children.some(function(a){return $0(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function H0(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Jm.peek=U0;function Jm(e,t,n,r){const i=H0(n),o=n.enter("strong"),a=n.createTracker(r),c=a.move(i+i);let u=a.move(n.containerPhrasing(e,{after:i,before:c,...a.current()}));const d=u.charCodeAt(0),h=Ta(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=Qi(d)+u.slice(1));const p=u.charCodeAt(u.length-1),m=Ta(r.after.charCodeAt(0),p,i);m.inside&&(u=u.slice(0,-1)+Qi(p));const g=a.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:m.outside,before:h.outside},c+u+g}function U0(e,t,n){return n.options.strong||"*"}function q0(e,t,n,r){return n.safe(e.value,r)}function G0(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function V0(e,t,n){const r=(Xm(n)+(n.options.ruleSpaces?" ":"")).repeat(G0(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Qm={blockquote:g0,break:xh,code:v0,definition:C0,emphasis:zm,hardBreak:xh,heading:I0,html:Hm,image:Um,imageReference:qm,inlineCode:Gm,link:Km,linkReference:Ym,list:B0,listItem:W0,paragraph:F0,root:z0,strong:Jm,text:q0,thematicBreak:V0};function K0(){return{enter:{table:Y0,tableData:yh,tableHeader:yh,tableRow:J0},exit:{codeText:Q0,table:X0,tableData:Fl,tableHeader:Fl,tableRow:Fl}}}function Y0(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function X0(e){this.exit(e),this.data.inTable=void 0}function J0(e){this.enter({type:"tableRow",children:[]},e)}function Fl(e){this.exit(e)}function yh(e){this.enter({type:"tableCell",children:[]},e)}function Q0(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Z0));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Z0(e,t){return t==="|"?t:e}function eN(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
31
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:m,table:a,tableCell:u,tableRow:c}};function a(g,x,S,C){return d(h(g,S,C),g.align)}function c(g,x,S,C){const y=p(g,S,C),A=d([y]);return A.slice(0,A.indexOf(`
32
+ `))}function u(g,x,S,C){const y=S.enter("tableCell"),A=S.enter("phrasing"),T=S.containerPhrasing(g,{...C,before:o,after:o});return A(),y(),T}function d(g,x){return f0(g,{align:x,alignDelimiters:r,padding:n,stringLength:i})}function h(g,x,S){const C=g.children;let y=-1;const A=[],T=x.enter("table");for(;++y<C.length;)A[y]=p(C[y],x,S);return T(),A}function p(g,x,S){const C=g.children;let y=-1;const A=[],T=x.enter("tableRow");for(;++y<C.length;)A[y]=u(C[y],g,x,S);return T(),A}function m(g,x,S){let C=Qm.inlineCode(g,x,S);return S.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function tN(){return{exit:{taskListCheckValueChecked:wh,taskListCheckValueUnchecked:wh,paragraph:rN}}}function nN(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:sN}}}function wh(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function rN(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,a;for(;++o<i.length;){const c=i[o];if(c.type==="paragraph"){a=c;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function sN(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);o&&c.move(a);let u=Qm.listItem(e,t,n,{...r,...c.current()});return o&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(h){return h+a}}function iN(){return[B1(),s0(),l0(),K0(),tN()]}function oN(e){return{extensions:[O1(),i0(e),c0(),eN(e),nN()]}}const aN={tokenize:pN,partial:!0},Zm={tokenize:fN,partial:!0},eg={tokenize:mN,partial:!0},tg={tokenize:gN,partial:!0},lN={tokenize:bN,partial:!0},ng={name:"wwwAutolink",tokenize:dN,previous:sg},rg={name:"protocolAutolink",tokenize:hN,previous:ig},ar={name:"emailAutolink",tokenize:uN,previous:og},Zn={};function cN(){return{text:Zn}}let es=48;for(;es<123;)Zn[es]=ar,es++,es===58?es=65:es===91&&(es=97);Zn[43]=ar;Zn[45]=ar;Zn[46]=ar;Zn[95]=ar;Zn[72]=[ar,rg];Zn[104]=[ar,rg];Zn[87]=[ar,ng];Zn[119]=[ar,ng];function uN(e,t,n){const r=this;let i,o;return a;function a(p){return!Tc(p)||!og.call(r,r.previous)||Lu(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(p))}function c(p){return Tc(p)?(e.consume(p),c):p===64?(e.consume(p),u):n(p)}function u(p){return p===46?e.check(lN,h,d)(p):p===45||p===95||$t(p)?(o=!0,e.consume(p),u):h(p)}function d(p){return e.consume(p),i=!0,u}function h(p){return o&&i&&Xt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function dN(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!sg.call(r,r.previous)||Lu(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(aN,e.attempt(Zm,e.attempt(eg,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function hN(e,t,n){const r=this;let i="",o=!1;return a;function a(p){return(p===72||p===104)&&ig.call(r,r.previous)&&!Lu(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),c):n(p)}function c(p){if(Xt(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),c;if(p===58){const m=i.toLowerCase();if(m==="http"||m==="https")return e.consume(p),u}return n(p)}function u(p){return p===47?(e.consume(p),o?d:(o=!0,u)):n(p)}function d(p){return p===null||Ca(p)||ot(p)||ls(p)||za(p)?n(p):e.attempt(Zm,e.attempt(eg,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function pN(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function fN(e,t,n){let r,i,o;return a;function a(d){return d===46||d===95?e.check(tg,u,c)(d):d===null||ot(d)||ls(d)||d!==45&&za(d)?u(d):(o=!0,e.consume(d),a)}function c(d){return d===95?r=!0:(i=r,r=void 0),e.consume(d),a}function u(d){return i||r||!o?n(d):t(d)}}function mN(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(tg,t,o)(a):a===null||ot(a)||ls(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function gN(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),o):c===93?(e.consume(c),i):c===60||c===null||ot(c)||ls(c)?t(c):n(c)}function i(c){return c===null||c===40||c===91||ot(c)||ls(c)?t(c):r(c)}function o(c){return Xt(c)?a(c):n(c)}function a(c){return c===59?(e.consume(c),r):Xt(c)?(e.consume(c),a):n(c)}}function bN(e,t,n){return r;function r(o){return e.consume(o),i}function i(o){return $t(o)?n(o):t(o)}}function sg(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function ig(e){return!Xt(e)}function og(e){return!(e===47||Tc(e))}function Tc(e){return e===43||e===45||e===46||e===95||$t(e)}function Lu(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const kN={tokenize:jN,partial:!0};function xN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:SN,continuation:{tokenize:CN},exit:NN}},text:{91:{name:"gfmFootnoteCall",tokenize:vN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:yN,resolveTo:wN}}}}function yN(e,t,n){const r=this;let i=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){a=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return c;function c(u){if(!a||!a._balanced)return n(u);const d=An(r.sliceSerialize({start:a.end,end:r.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function wN(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function vN(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),u}function u(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(o>999||p===93&&!a||p===null||p===91||ot(p))return n(p);if(p===93){e.exit("chunkString");const m=e.exit("gfmFootnoteCallString");return i.includes(An(r.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return ot(p)||(a=!0),o++,e.consume(p),p===92?h:d}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function SN(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,c;return u;function u(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(x)}function h(x){if(a>999||x===93&&!c||x===null||x===91||ot(x))return n(x);if(x===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return o=An(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return ot(x)||(c=!0),a++,e.consume(x),x===92?p:h}function p(x){return x===91||x===92||x===93?(e.consume(x),a++,h):h(x)}function m(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),i.includes(o)||i.push(o),qe(e,g,"gfmFootnoteDefinitionWhitespace")):n(x)}function g(x){return t(x)}}function CN(e,t,n){return e.check(co,t,e.attempt(kN,t,n))}function NN(e){e.exit("gfmFootnoteDefinition")}function jN(e,t,n){const r=this;return qe(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function TN(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,c){let u=-1;for(;++u<a.length;)if(a[u][0]==="enter"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._close){let d=u;for(;d--;)if(a[d][0]==="exit"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[d][1].end.offset-a[d][1].start.offset){a[u][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[u][1].end)},p={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[u][1].start)},m=[["enter",h,c],["enter",a[d][1],c],["exit",a[d][1],c],["enter",p,c]],g=c.parser.constructs.insideSpan.null;g&&dn(m,m.length,0,Ha(g,a.slice(d+1,u),c)),dn(m,m.length,0,[["exit",p,c],["enter",a[u][1],c],["exit",a[u][1],c],["exit",h,c]]),dn(a,d-1,u-d+3,m),u=d+m.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type==="strikethroughSequenceTemporary"&&(a[u][1].type="data");return a}function o(a,c,u){const d=this.previous,h=this.events;let p=0;return m;function m(x){return d===126&&h[h.length-1][1].type!=="characterEscape"?u(x):(a.enter("strikethroughSequenceTemporary"),g(x))}function g(x){const S=si(d);if(x===126)return p>1?u(x):(a.consume(x),p++,g);if(p<2&&!n)return u(x);const C=a.exit("strikethroughSequenceTemporary"),y=si(x);return C._open=!y||y===2&&!!S,C._close=!S||S===2&&!!y,c(x)}}}class IN{constructor(){this.map=[]}add(t,n,r){EN(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const o of i)t.push(o);i=r.pop()}this.map.length=0}}function EN(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function MN(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function RN(){return{flow:{null:{name:"table",tokenize:AN,resolveAll:PN}}}}function AN(e,t,n){const r=this;let i=0,o=0,a;return c;function c(I){let H=r.events.length-1;for(;H>-1;){const Y=r.events[H][1].type;if(Y==="lineEnding"||Y==="linePrefix")H--;else break}const _=H>-1?r.events[H][1].type:null,se=_==="tableHead"||_==="tableRow"?E:u;return se===E&&r.parser.lazy[r.now().line]?n(I):se(I)}function u(I){return e.enter("tableHead"),e.enter("tableRow"),d(I)}function d(I){return I===124||(a=!0,o+=1),h(I)}function h(I){return I===null?n(I):Te(I)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),g):n(I):$e(I)?qe(e,h,"whitespace")(I):(o+=1,a&&(a=!1,i+=1),I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),p(I)))}function p(I){return I===null||I===124||ot(I)?(e.exit("data"),h(I)):(e.consume(I),I===92?m:p)}function m(I){return I===92||I===124?(e.consume(I),p):p(I)}function g(I){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(I):(e.enter("tableDelimiterRow"),a=!1,$e(I)?qe(e,x,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):x(I))}function x(I){return I===45||I===58?C(I):I===124?(a=!0,e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),S):P(I)}function S(I){return $e(I)?qe(e,C,"whitespace")(I):C(I)}function C(I){return I===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),y):I===45?(o+=1,y(I)):I===null||Te(I)?G(I):P(I)}function y(I){return I===45?(e.enter("tableDelimiterFiller"),A(I)):P(I)}function A(I){return I===45?(e.consume(I),A):I===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(I))}function T(I){return $e(I)?qe(e,G,"whitespace")(I):G(I)}function G(I){return I===124?x(I):I===null||Te(I)?!a||i!==o?P(I):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(I)):P(I)}function P(I){return n(I)}function E(I){return e.enter("tableRow"),V(I)}function V(I){return I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),V):I===null||Te(I)?(e.exit("tableRow"),t(I)):$e(I)?qe(e,V,"whitespace")(I):(e.enter("data"),U(I))}function U(I){return I===null||I===124||ot(I)?(e.exit("data"),V(I)):(e.consume(I),I===92?L:U)}function L(I){return I===92||I===124?(e.consume(I),U):U(I)}}function PN(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],a=[0,0,0,0],c=!1,u=0,d,h,p;const m=new IN;for(;++n<e.length;){const g=e[n],x=g[1];g[0]==="enter"?x.type==="tableHead"?(c=!1,u!==0&&(vh(m,t,u,d,h),h=void 0,u=0),d={type:"table",start:Object.assign({},x.start),end:Object.assign({},x.end)},m.add(n,0,[["enter",d,t]])):x.type==="tableRow"||x.type==="tableDelimiterRow"?(r=!0,p=void 0,o=[0,0,0,0],a=[0,n+1,0,0],c&&(c=!1,h={type:"tableBody",start:Object.assign({},x.start),end:Object.assign({},x.end)},m.add(n,0,[["enter",h,t]])),i=x.type==="tableDelimiterRow"?2:h?3:1):i&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],p=Uo(m,t,o,i,void 0,p),o=[0,0,0,0]),a[2]=n)):x.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],p=Uo(m,t,o,i,void 0,p)),o=a,a=[o[1],n,0,0])):x.type==="tableHead"?(c=!0,u=n):x.type==="tableRow"||x.type==="tableDelimiterRow"?(u=n,o[1]!==0?(a[0]=a[1],p=Uo(m,t,o,i,n,p)):a[1]!==0&&(p=Uo(m,t,a,i,n,p)),i=0):i&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&vh(m,t,u,d,h),m.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=MN(t.events,n))}return e}function Uo(e,t,n,r,i,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},Us(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const u=Us(t.events,n[1]);if(o={type:a,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const d=Us(t.events,n[2]),h=Us(t.events,n[3]),p={type:c,start:Object.assign({},d),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const m=t.events[n[2]],g=t.events[n[3]];if(m[1].end=Object.assign({},g[1].end),m[1].type="chunkText",m[1].contentType="text",n[3]>n[2]+1){const x=n[2]+1,S=n[3]-n[2]-1;e.add(x,S,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(o.end=Object.assign({},Us(t.events,i)),e.add(i,0,[["exit",o,t]]),o=void 0),o}function vh(e,t,n,r,i){const o=[],a=Us(t.events,n);i&&(i.end=Object.assign({},a),o.push(["exit",i,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function Us(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const LN={name:"tasklistCheck",tokenize:_N};function DN(){return{text:{91:LN}}}function _N(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),o)}function o(u){return ot(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),a):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),a):n(u)}function a(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(u)}function c(u){return Te(u)?t(u):$e(u)?e.check({tokenize:BN},t,n)(u):n(u)}}function BN(e,t,n){return qe(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function ON(e){return bm([cN(),xN(),TN(e),RN(),DN()])}const WN={};function FN(e){const t=this,n=e||WN,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(ON(n)),o.push(iN()),a.push(oN(n))}const $N="X-CodingNS-Assistant-Source",zN="butler-ui",$l=new Map;async function lr(e,t={},n={}){const r=new Headers(t.headers);r.set($N,zN);const i=HN();if($l.get(i)===!1){if(n.unsupportedFallback!==void 0)return Sh(n.unsupportedFallback);throw Ch()}try{const a=await xe.request(e,{...t,headers:r});return $l.set(i,!0),a}catch(a){if(!UN(a))throw a;if($l.set(i,!1),n.unsupportedFallback!==void 0)return Sh(n.unsupportedFallback);throw Ch()}}function HN(){return sf()}function Sh(e){return typeof e=="function"?e():e}function UN(e){return e instanceof Jc&&(e.status===404||e.status===405||e.status===501)}function Ch(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function qN(){return xe.request("/api/butler/profile")}function eP(e){return xe.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function tP(e){return xe.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function nP(){return xe.request("/api/butler/control-session")}function rP(){return xe.request("/api/butler/control-sessions")}function sP(e){return xe.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function iP(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/butler/control-timers?${n}`:"/api/butler/control-timers";return xe.request(r)}function oP(){return xe.request("/api/butler/control-session/reset",{method:"POST"})}function aP(e={}){return xe.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function lP(e){return xe.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function cP(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations?${n}`:"/api/assistant/automations";return lr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function uP(e={}){var i;const t=new URLSearchParams;(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations/runs/recent?${n}`:"/api/assistant/automations/runs/recent";return lr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function dP(e){return lr(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function hP(e,t){return lr(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function pP(e){return lr(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function fP(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim());const n=t.toString(),r=n?`/api/assistant/sandboxes?${n}`:"/api/assistant/sandboxes";return lr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function mP(e){return lr(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function gP(e){return lr(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function bP(e){return lr(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function kP(e){return xe.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function xP(){return xe.request("/api/butler/control-session/events")}function GN(){return xe.request("/api/butler/overview")}function VN(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel);const n=t.toString(),r=n?`/api/butler/projects?${n}`:"/api/butler/projects";return xe.request(r)}function yP(e,t={}){const n=new URLSearchParams;t.enabled!==null&&t.enabled!==void 0&&n.set("enabled",String(t.enabled)),t.executionMode&&n.set("executionMode",t.executionMode);const r=n.toString(),i=r?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${r}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return xe.request(i)}function ag(e={}){var i,o;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),(o=e.projectId)!=null&&o.trim()&&t.set("projectId",e.projectId.trim()),e.status&&t.set("status",e.status),e.itemType&&t.set("itemType",e.itemType);const n=t.toString(),r=n?`/api/butler/inbox?${n}`:"/api/butler/inbox";return xe.request(r)}function KN(e){return xe.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function YN(e={}){var i,o;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.projectId)!=null&&i.trim()&&t.set("projectId",e.projectId.trim()),(o=e.sessionId)!=null&&o.trim()&&t.set("sessionId",e.sessionId.trim());const n=t.toString(),r=n?`/api/butler/follow-up-tasks?${n}`:"/api/butler/follow-up-tasks";return xe.request(r)}function wP(e){return xe.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function XN(e){return xe.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function vP(e){return xe.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function SP(e,t){return xe.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function Nh(e,t){return xe.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 CP(e){return xe.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function NP(e){return xe.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function JN(e){return xe.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function QN(){return xe.request("/api/butler/notifications/archives")}function ZN(e,t){return xe.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function ej(e){const t=new URLSearchParams;return t.set("sessionId",e),xe.request(`/api/butler/session-target?${t.toString()}`)}function jP(e){const t=new URLSearchParams;return t.set("sessionId",e),xe.request(`/api/butler/session-action-context?${t.toString()}`)}function TP(e){return xe.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}const Ia="*** Begin Patch",Ea="*** End Patch";function jh(e){const t=e.replace(/\r\n/g,`
33
+ `);if(!t.includes(Ia)||!t.includes(Ea))return null;const n=t.split(`
34
+ `),r=[];let i=null,o=null;for(const a of n){if(a===Ia||a===Ea)continue;if(a.startsWith("*** Update File: ")){i=zl("update",a.slice(17)),r.push(i),o=null;continue}if(a.startsWith("*** Add File: ")){i=zl("add",a.slice(14)),r.push(i),o={oldLineNumber:0,newLineNumber:1};continue}if(a.startsWith("*** Delete File: ")){i=zl("delete",a.slice(17)),r.push(i),o=null;continue}if(!i)continue;if(a.startsWith("*** Move to: ")){i.nextPath=a.slice(13),i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a.startsWith("@@")){o=rj(a)??{oldLineNumber:0,newLineNumber:0},i.lines.push({kind:"hunk",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a==="*** End of File"){i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(i.action==="add"&&a.startsWith("+")){i.additions+=1,i.statsKnown=!0,i.lines.push({kind:"add",text:a,oldLineNumber:null,newLineNumber:(o==null?void 0:o.newLineNumber)??i.additions}),o&&(o.newLineNumber+=1);continue}if(!o){i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a.startsWith("+")){i.additions+=1,i.statsKnown=!0,i.lines.push({kind:"add",text:a,oldLineNumber:null,newLineNumber:o.newLineNumber}),o.newLineNumber+=1;continue}if(a.startsWith("-")){i.deletions+=1,i.statsKnown=!0,i.lines.push({kind:"remove",text:a,oldLineNumber:o.oldLineNumber,newLineNumber:null}),o.oldLineNumber+=1;continue}if(a.startsWith(" ")||a.length===0){i.lines.push({kind:"context",text:a,oldLineNumber:o.oldLineNumber,newLineNumber:o.newLineNumber}),o.oldLineNumber+=1,o.newLineNumber+=1;continue}i.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null})}return r.length===0?null:{files:r,totalAdditions:r.reduce((a,c)=>a+c.additions,0),totalDeletions:r.reduce((a,c)=>a+c.deletions,0)}}function tj(e,t=[]){const n=e.replace(/\r\n/g,`
35
+ `).trim();if(!n)return null;if(n.includes(Ia)&&n.includes(Ea))return n;const r=[...new Set(t.map(i=>i.trim()).filter(i=>i.length>0))];return r.length!==1||!sj(n)?null:[Ia,`*** Update File: ${r[0]}`,n,Ea].join(`
36
+ `)}function nj(e){const t=ij(e);if(!t)return[];const n=t.replace(/\r\n/g,`
37
+ `).split(`
38
+ `),r=[];let i=!1;for(const o of n){const a=o.trim();if(!i){/^Success\.\s+Updated the following files:/i.test(a)&&(i=!0);continue}if(!a){if(r.length>0)break;continue}const c=a.match(/^[A-Z?]\s+(.+)$/),u=((c==null?void 0:c[1])??a).trim();if(!u)break;r.push(u)}return[...new Set(r)]}function Th(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function zl(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,statsKnown:!1,lines:[]}}function rj(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function sj(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
39
+ @@`)||e.startsWith("+")||e.startsWith("-")}function ij(e){const t=e.trim();if(!t)return"";if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;if(typeof r.output=="string"&&r.output.trim().length>0)return r.output;if(typeof r.result=="string"&&r.result.trim().length>0)return r.result;if(typeof r.message=="string"&&r.message.trim().length>0)return r.message}catch{return t}return t}const oj=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,aj=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,lj=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,cj=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,uj=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,Ih=/```question\s*([\s\S]*?)```/i;function cs(e){const t=hj(e),n=dj(t);if(n)return n;const r=pj(t);return r||{...cg(t),structuredQuestions:null}}function dj(e){var r;const t=e.match(Ih);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";if(!n)return null;try{const i=JSON.parse(n),o=lg(i);return o?{text:Du(e.replace(Ih,"").trim()),inlineImages:[],structuredQuestions:o}:null}catch{return null}}function hj(e){return e.replace(uj,"")}function pj(e){const t=e.trim();if(!mj(t))return null;try{const n=JSON.parse(t),r=lg(n),i=gj(r?fj(n):n);return i.text||i.inlineImages.length>0||r?{...i,structuredQuestions:r}:null}catch{return null}}function fj(e){const t=ho(e);if(!t||!("questions"in t))return e;const{questions:n,...r}=t;return r}function mj(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function gj(e){const t=[],n=[];return ma(e,t,n),{text:Du(t.join(`
40
+
41
+ `)),inlineImages:ug(n),structuredQuestions:null}}function lg(e){const t=ho(e);if(!t)return null;const n=bj(t.questions);return n.length===0?null:{questions:n}}function bj(e){return Array.isArray(e)?e.map((t,n)=>kj(t,n)).filter(t=>t!==null):[]}function kj(e,t){const n=ho(e);if(!n)return null;const r=Yn(_t(n.question));if(!r)return null;const i=xj(n.options);return i.length===0?null:{id:Yn(_t(n.id))??`structured-question-${t+1}`,header:Yn(_t(n.header))??"问题",question:r,allowOther:!!(n.allowOther??n.isOther),secret:!!(n.secret??n.isSecret),options:i}}function xj(e){return Array.isArray(e)?e.map(t=>{const n=ho(t);if(!n)return null;const r=Yn(_t(n.label));return r?{label:r,description:Yn(_t(n.description))}:null}).filter(t=>t!==null):[]}function ma(e,t,n){if(typeof e=="string"){const a=cg(e);a.text&&t.push(a.text),n.push(...a.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(a=>ma(a,t,n));return}if(typeof e!="object")return;const r=e,i=new Set,o=yj(r);o&&(n.push(o),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(a=>{a in r&&i.add(a)}));for(const a of["image_url","url","src","source"]){const c=r[a];typeof c!="string"||!dg(c)||(n.push(is(c,_t(r.alt))),i.add(a))}for(const a of["text","message","content","output","result","summary","caption"])a in r&&(i.add(a),ma(r[a],t,n));i.size>0||Object.values(r).forEach(a=>{ma(a,t,n)})}function cg(e){const t=[];let n=e;return n=n.replace(cj,(r,i,o)=>{const a=Cj(i,"name"),c=Sj(o);return c!=null&&c.url&&t.push(is(c.url,c.altText||a)),""}),n=n.replace(aj,(r,i,o)=>(t.push(is(o,i)),"")),n=n.replace(lj,(r,i)=>(t.push(is(i,null)),"")),n=n.replace(oj,(r,i,o)=>(t.push(is(r,null,`image/${i}`,Ma(o))),"")),{text:Du(n),inlineImages:ug(t),structuredQuestions:null}}function is(e,t,n,r){const i=n??wj(e)??"image/png";return{url:e,mimeType:i,altText:Yn(t),estimatedBytes:r??vj(e)}}function yj(e){const t=ho(e.source);if(t){const i=_t(t.type).trim().toLowerCase(),o=Mh(t.media_type??t.mime_type??t.mimeType),a=Eh(t.data);if(i==="base64"&&o&&a)return is(`data:${o};base64,${a}`,Yn(_t(t.alt)||_t(t.name)||_t(e.alt)||_t(e.name)),o,Ma(a))}const n=Mh(e.media_type??e.mime_type??e.mimeType),r=Eh(e.data);return n&&r?is(`data:${n};base64,${r}`,Yn(_t(e.alt)||_t(e.name)),n,Ma(r)):null}function ug(e){const t=new Map;return e.forEach(n=>{t.has(n.url)||t.set(n.url,n)}),[...t.values()]}function Du(e){return e.replace(/\r\n/g,`
42
+ `).replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
43
+ `).replace(/\n{3,}/g,`
44
+
45
+ `).trim()}function dg(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function wj(e){var n;const t=e.match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,/i);return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())??null}function vj(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?Ma(t[1]):null}function Ma(e){const t=e.trim(),n=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-n)}function Yn(e){const t=_t(e).trim();return t.length>0?t:null}function Eh(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function Mh(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function _t(e){return typeof e=="string"?e:""}function ho(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Sj(e){const t=e.trim();if(t.length===0)return null;try{const n=JSON.parse(t),r=_t(n.image_url??n.imageUrl).trim(),i=Yn(_t(n.name)||_t(n.alt));return{url:dg(r)?r:null,altText:i}}catch{const n=t.match(/(data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)/i);return n?{url:n[1],altText:null}:null}}function Cj(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return Yn((r==null?void 0:r[1])??(r==null?void 0:r[2])??(r==null?void 0:r[3])??(r==null?void 0:r[4])??"")}const Nj=new Set(["updateplan"]),hg=new Set(["todowrite"]),Ic=new Set(["todoread"]),pg=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function IP(e,t){const n=Ij(e,t);return n||Ej(e,t)}function jj(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function Tj(e,t,n){if(!e)return null;if(Ec(e.name)){const a=ti(e);if(!a||!Ka(a.value))return null;const c=fg(a.value,n);return!c||c.items.length===0?null:{provider:t,source:"plan",explanation:c.explanation,items:c.items,updatedAt:n}}const r=Va(e.name);if(!hg.has(r)&&!Ic.has(r)&&!pg.has(r))return null;const i=ti(e,(Ic.has(r),"prefer-output"));if(!i)return null;if(r==="taskdelete"||r==="taskremove"){const a=mg(i.value);return a.length>0?{provider:t,source:"todo",explanation:null,items:a.map((c,u)=>({id:c,title:`Task ${u+1}`,status:"cancelled",detail:c,updatedAt:n})),updatedAt:n}:null}const o=Bi(i.value,n);return o.length===0?null:{provider:t,source:Ec(e.name)?"plan":"todo",explanation:null,items:o,updatedAt:n}}function Ij(e,t){let n=null;for(const r of e){const i=r.toolCall;if(!i||Va(i.name)===""||!Ec(i.name))continue;const o=ti(i);if(!o||typeof o.value!="object"||o.value===null)continue;const a=fg(o.value,r.timestamp);!a||a.items.length===0||(n={provider:t,source:"plan",explanation:a.explanation,items:a.items,updatedAt:r.timestamp})}return n}function Ej(e,t){const n=new Map;let r=null;for(const o of e){const a=o.toolCall;if(!a)continue;const c=Va(a.name);if(hg.has(c)){const h=ti(a),p=h?Bi(h.value,o.timestamp):[];p.length>0&&(Hl(n,p),r=o.timestamp);continue}if(Ic.has(c)){const h=ti(a,"prefer-output"),p=h?Bi(h.value,o.timestamp):[];p.length>0&&(Hl(n,p),r=o.timestamp);continue}if(!pg.has(c))continue;const u=ti(a,"prefer-output");if(!u)continue;if(c==="tasklist"||c==="taskget"){const h=Bi(u.value,o.timestamp);h.length>0&&(Hl(n,h),r=o.timestamp);continue}if(c==="taskdelete"||c==="taskremove"){const h=mg(u.value);if(h.length>0){for(const p of h)n.delete(p);r=o.timestamp}continue}const d=Bi(u.value,o.timestamp);if(d.length!==0){for(const h of d)Rj(n,h);r=o.timestamp}}const i=Array.from(n.values()).sort((o,a)=>o.updatedAt.localeCompare(a.updatedAt)).map(o=>({...o}));return i.length===0||!r?null:{provider:t,source:"todo",explanation:null,items:i,updatedAt:r}}function Ec(e){return Nj.has(Va(e))}function fg(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((i,o)=>gg(i,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${o+1}`,fallbackStatus:"pending",updatedAt:t})).filter(i=>i!==null);return r.length===0?null:{items:r,explanation:yt(e.explanation)}}function ti(e,t="prefer-input"){const n=t==="prefer-output"?[{text:e.output,source:"output"},{text:e.input,source:"input"}]:[{text:e.input,source:"input"},{text:e.output,source:"output"}];for(const r of n){const i=Mj(r.text);if(i!==null)return{value:i,source:r.source}}return null}function Mj(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=qo(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const u=qo(r[1].trim());if(u!==null)return u}const i=t.indexOf("{"),o=t.lastIndexOf("}");if(i>=0&&o>i){const u=qo(t.slice(i,o+1));if(u!==null)return u}const a=t.indexOf("["),c=t.lastIndexOf("]");return a>=0&&c>a?qo(t.slice(a,c+1)):null}function qo(e){try{return JSON.parse(e)}catch{return null}}function Bi(e,t){return Vi(e).map((r,i)=>gg(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${i+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function Vi(e){if(Array.isArray(e))return e.flatMap(n=>Vi(n));if(!Ka(e))return[];if(Dj(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=Vi(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>Vi(n))}function mg(e){const n=Vi(e).map(i=>Mc(i)).filter(i=>i!==null);if(n.length>0)return n;if(!Ka(e))return[];const r=Mc(e);return r?[r]:[]}function gg(e,t){if(!Ka(e))return null;const n=yt(e.step)??yt(e.title)??yt(e.content)??yt(e.task)??yt(e.text)??yt(e.name)??yt(e.subject)??yt(e.description)??t.fallbackTitle,r=Mc(e)??Lj(t.fallbackIdPrefix,n),i=Pj(e,n);return{id:r,title:n,status:Aj(e.status,t.fallbackStatus),detail:i,updatedAt:t.updatedAt}}function Rj(e,t){const n=e.get(t.id);if(!n){e.set(t.id,{...t});return}e.set(t.id,{id:n.id,title:t.title||n.title,status:t.status,detail:t.detail??n.detail,updatedAt:t.updatedAt})}function Hl(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function Aj(e,t){var r;const n=(r=yt(e))==null?void 0:r.toLowerCase().replace(/[\s-]+/g,"_");return n?["pending","todo","open","queued","not_started","created"].includes(n)?"pending":["in_progress","progress","active","doing","running","started"].includes(n)?"in_progress":["completed","complete","done","success","succeeded","finished","closed"].includes(n)?"completed":["failed","error","errored"].includes(n)?"failed":["cancelled","canceled","aborted","skipped"].includes(n)?"cancelled":t:t}function Pj(e,t){const n=[yt(e.detail),yt(e.details),yt(e.description),yt(e.reason),yt(e.summary),yt(e.note),yt(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function Mc(e){return yt(e.id)??yt(e.taskId)??yt(e.task_id)??yt(e.uuid)??yt(e.key)}function Lj(e,t){return`${e}:${t.trim().toLowerCase()}`}function Dj(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>yt(t)!==null)}function Va(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function Ka(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yt(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function _j(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("rect",{x:"7",y:"5",width:"9",height:"11",rx:"2.5"}),s.jsx("path",{d:"M5.5 12.5H5A2 2 0 0 1 3 10.5V5a2 2 0 0 1 2-2h5.5"})]})}function Bj(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"6",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"14",r:"2.25"}),s.jsx("path",{d:"M8.4 5.7h2.2a2.7 2.7 0 0 1 2.7 2.7v1.2"}),s.jsx("path",{d:"M8.1 5.9l4.1 6.2"})]})}function EP(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M10 2.8l1.6 3.4 3.8.5-2.8 2.6.7 3.9-3.3-1.8-3.3 1.8.7-3.9-2.8-2.6 3.8-.5L10 2.8z"}),s.jsx("path",{d:"M15.8 13.3l.7 1.5 1.7.2-1.2 1.1.3 1.8-1.5-.8-1.5.8.3-1.8-1.2-1.1 1.7-.2.7-1.5z"})]})}function MP(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"14",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"10",cy:"14",r:"2.2"}),s.jsx("path",{d:"M8.2 5h3.6"}),s.jsx("path",{d:"M10 7.2v4.6"}),s.jsx("path",{d:"M7.3 6.8l1.7 4"}),s.jsx("path",{d:"M12.7 6.8l-1.7 4"})]})}function RP(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"4.5",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"10",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"15.5",cy:"10",r:"1.5"})]})}function AP(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M4.5 5.5h1.2"}),s.jsx("path",{d:"M8 5.5h7.5"}),s.jsx("path",{d:"M4.5 10h1.2"}),s.jsx("path",{d:"M8 10h7.5"}),s.jsx("path",{d:"M4.5 14.5h1.2"}),s.jsx("path",{d:"M8 14.5h7.5"}),s.jsx("path",{d:"M5.1 5.5l.5.5 1-1"}),s.jsx("circle",{cx:"5.1",cy:"10",r:".8",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M5.1 14.5l.5.5 1-1"})]})}const bg="codingns.user-app.conversation-scroll",Ds=1,Oj=200,Wj=1e7;function kg(){return typeof window<"u"&&typeof window.localStorage<"u"}function xg(e){return e.trim()}function yg(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),Wj)}function wg(e){return!e||typeof e!="object"?null:{scrollTop:yg(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function vg(){if(!kg())return{schemaVersion:Ds,bySessionId:{}};const e=window.localStorage.getItem(bg);if(!e)return{schemaVersion:Ds,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==Ds||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:Ds,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,i])=>{const o=wg(i);return o?[r,o]:null}).filter(r=>!!r));return{schemaVersion:Ds,bySessionId:n}}catch{return{schemaVersion:Ds,bySessionId:{}}}}function Fj(e){if(kg())try{window.localStorage.setItem(bg,JSON.stringify(e))}catch{}}function Go(e){const t=xg(e);if(!t)return null;const n=vg().bySessionId[t],r=wg(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function Rh(e,t){const n=xg(e);if(!n)return;const r=vg();r.bySessionId[n]={scrollTop:yg(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const i=Object.entries(r.bySessionId).sort((o,a)=>a[1].updatedAt-o[1].updatedAt).slice(0,Oj);r.bySessionId=Object.fromEntries(i),Fj(r)}const $j=5e3;let _s=null;function zj(){var t;if(_s!==null)return _s;if(typeof document>"u")return _s=0,_s;const e=document.createElement("div");return e.dataset.scrollbarProbe="true",e.style.position="absolute",e.style.top="-9999px",e.style.width="120px",e.style.height="120px",e.style.overflow="scroll",e.style.visibility="hidden",e.style.pointerEvents="none",(t=document.body)==null||t.appendChild(e),_s=Math.max(0,e.offsetWidth-e.clientWidth),e.remove(),_s}function Hj(e){if(zj()>0){e.dataset.scrollbarLayout="stable";return}e.removeAttribute("data-scrollbar-layout")}function _u(e){const t=f.useRef(null),n=e??t;return f.useEffect(()=>{const r=n.current;if(!r||typeof globalThis.window>"u")return;Hj(r);let i=null;const o=()=>{i!==null&&(window.clearTimeout(i),i=null)},a=()=>{o(),r.removeAttribute("data-scrolling")},c=()=>{r.setAttribute("data-scrolling","true"),o(),i=window.setTimeout(()=>{r.removeAttribute("data-scrolling"),i=null},$j)},u=()=>{c()};return r.addEventListener("scroll",u,{passive:!0}),()=>{r.removeEventListener("scroll",u),a()}},[n]),n}function Bu(e){var t,n;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((n=e.lastErrorDetail)!=null&&n.trim())}function Uj(e,t,n){return`${e} is-${Sg(t,n)}`}function Sg(e,t){t==null||t.isActive;const n=Vj(e);return t!=null&&t.hasSubagents?n==="error"?"error":n==="unread"?"subagent-unread":n==="running"||n==="running_inferred"?"subagent-running":"subagent":n==="running_inferred"?"running-inferred":n.replace("_","-")}function qj(e){return e.runningState==="stale"?l("conversation.runtimeStale"):e.runningState==="unknown"?l("conversation.runtimeUnknown"):null}function Gj(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function PP(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function Vj(e){return Bu(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?Kj(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function Kj(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function Yj(e){return Bu(e)||e.syncStatus==="error"}function Xj(e){if(!Yj(e))return null;const t=Qj(e.lastErrorCode),n=Zj(e.lastErrorDetail),r=Jj(t,n,e.syncStatus);return{title:e.syncStatus==="error"&&!Bu(e)?l("conversation.syncStatusError"):l("conversation.runtimeErrorTitle"),summary:r,code:t,detail:n}}function Jj(e,t,n){return e&&t&&!t.includes(e)?`${e} · ${t}`:t||e||(n==="error"?l("conversation.syncStatusError"):l("conversation.runtimeErrorFallbackDetail"))}function Qj(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}function Zj(e){const t=(e==null?void 0:e.replace(/\s+/g," ").trim())??"";return t.length>0?t:null}function Cg(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function Ng(e){var r;const t=e.match(/^\s*<turn_aborted>([\s\S]*?)<\/turn_aborted>\s*$/i);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";return!n||/^previous turn aborted$/i.test(n)?{detail:null}:{detail:n}}function eT(e){return e==="user"?l("conversation.turnAbortedUser"):e==="runtime"?l("conversation.turnAbortedUnexpected"):l("conversation.turnAbortedGeneric")}const tT=480,Ah=80,Ph=240,nT=120,rT=18,sT=50,iT=3500,Rc=f.createContext(!1);function Ac(e){return e.replace(/\\/g,"/")}function Ra(e){return/^[a-zA-Z]:\//.test(e)}function oT(e){return e.startsWith("/")||e.startsWith("//")||Ra(e)}function aT(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Ra(e)}function Lh(e){return e.replace(/\/+$/,"")}function lT(e){const t=e.indexOf("#"),n=t>=0?e.slice(0,t):e,r=n.indexOf("?");return(r>=0?n.slice(0,r):n).replace(/:(\d+)(?::(\d+))?$/,"")}function cT(e){const t=[];for(const n of Ac(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function Ou(e){try{return decodeURIComponent(e)}catch{return e}}function uT(e,t){const n=Ou(e).trim();if(!n||n.startsWith("#"))return null;let r=n;if(/^file:\/\//i.test(r))try{r=decodeURIComponent(new URL(r).pathname),/^\/[a-zA-Z]:\//.test(r)&&(r=r.slice(1))}catch{return null}else if(aT(r))return null;if(r=Ac(lT(r.trim())),!r)return null;const i=Lh(Ac(t.trim()));if(!i)return null;if(oT(r)){const o=Lh(r),a=Ra(i)?i.toLowerCase():i,c=Ra(o)?o.toLowerCase():o;if(c===a)return null;const u=`${a}/`;return c.startsWith(u)?o.slice(i.length+1):null}return cT(r)}function Aa(e){return e.kind==="tool_call"||e.kind==="tool_result"}function jg(e){return e.toolCall?e.toolCall:Aa(e)?{callId:e.rawRef||e.id,name:"tool",input:e.kind==="tool_call"?e.content:"",output:e.kind==="tool_result"&&e.content?e.content:null,error:null,status:e.kind==="tool_call"?"running":"completed"}:null}function dT(e){return e==="shell_command"||e==="tool"?l("conversation.roleTool"):e}function Wu(e){if(!e.trim())return null;try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function hT(e,t){const n=e[t];return typeof n=="string"?n:""}function Bs(e,t){for(const n of t){const r=hT(e,n);if(r)return r}return""}function Zi(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Rt(e,t){if(!e)return null;const n=e[t];return Zi(n)?n:null}function Ul(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function nt(e,t){if(!e)return null;const n=e[t];if(typeof n=="string"){const r=n.trim();return r||null}return typeof n=="number"||typeof n=="boolean"?String(n):null}function pT(e){const t=[e.output,e.input];for(const n of t){const r=Tg(n,0);if(r)return r}return null}function Tg(e,t){if(!(e!=null&&e.trim())||t>2)return null;try{return Ig(JSON.parse(e),t)}catch{return null}}function Ig(e,t){if(!Zi(e))return null;if(fT(e))return{ok:!0,capability:nt(e,"capability")??"",auditId:nt(e,"auditId")??"",timestamp:nt(e,"timestamp")??"",targetRef:{kind:nt(Rt(e,"targetRef"),"kind")??"none",id:nt(Rt(e,"targetRef"),"id")},payload:Rt(e,"payload")??{}};const n=["output","result","data","payload"];for(const r of n){const i=e[r];if(typeof i=="string"){const o=Tg(i,t+1);if(o)return o}if(Zi(i)){const o=Ig(i,t+1);if(o)return o}}return null}function fT(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&Zi(e.targetRef)&&Zi(e.payload)}function mT(e){const t=new Map,n=new Map,r=new Map;return e.forEach(i=>{t.set(i.workspace.id,i.workspace.name),i.sessions.forEach(o=>{const a=typeof o.title=="string"&&o.title.trim()?o.title.trim():o.sessionId;n.set(o.sessionId,a),r.set(o.sessionId,i.workspace.id)})}),{workspaceNamesById:t,sessionNamesById:n,sessionWorkspaceIdsById:r}}function gT(e,t){const n=pT(e);return n?{...Mg(n.capability),rows:jT(n,t)}:null}function bT(e,t){const n=kT(e);if(!n)return null;const r=xT(n);return r?{...vT(r),rows:NT(r,t)}:null}function kT(e){const t=Wu(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(!n)return null;const r=n.indexOf("codingns assistant");return r<0?null:n.slice(r).trim()}function xT(e){const t=yT(e),n=t.findIndex((h,p)=>h==="codingns"&&t[p+1]==="assistant");if(n<0)return null;const r=t.slice(n+2);if(r.length===0||r[0]==="--help"||r[0]==="-h")return{group:null,action:null,mode:"help",options:{},positionals:[]};if(r[0]==="help")return{group:r[1]??null,action:r[2]??null,mode:"help",options:{},positionals:[]};const i=r[0]??null,o=r[1],a=o&&!o.startsWith("-")?o:null,c=r.slice(a?2:1),{options:u,positionals:d}=wT(c);return!a&&u["--help"]?{group:i,action:null,mode:"help",options:u,positionals:d}:{group:i,action:a,mode:"execute",options:u,positionals:d}}function yT(e){const t=[],n=/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`|\S+/g;for(const r of e.matchAll(n)){const i=r[0]??"";if(!i)continue;const o=i[0];if((o==='"'||o==="'"||o==="`")&&i[i.length-1]===o){t.push(i.slice(1,-1));continue}t.push(i)}return t}function wT(e){const t={},n=[];for(let r=0;r<e.length;r+=1){const i=e[r]??"";if(!i.startsWith("--")){n.push(i);continue}const o=e[r+1];if(!o||o.startsWith("--")){t[i]=!0;continue}t[i]=o,r+=1}return{options:t,positionals:n}}function vT(e){if(e.mode==="help")return ST(e.group,e.action);const t=CT(e.group,e.action);return t?Mg(t):{kind:Fu(e.group),badge:Eg(e.group),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCliSummaryCommand")}}function ST(e,t){return e?e==="sessions"?{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:t?l("conversation.assistantCliHelpSessionActionTitle",{action:t}):l("conversation.assistantCliHelpSessionsTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="timers"?{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCliHelpTimersTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="terminals"?{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCliHelpTerminalsTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="workspaces"||e==="worktrees"?{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCliHelpWorkspacesTitle"),summary:l("conversation.assistantCliSummaryHelp")}:{kind:Fu(e),badge:Eg(e),title:l("conversation.assistantCliHelpGenericTitle",{group:e}),summary:l("conversation.assistantCliSummaryHelp")}:{kind:"query",badge:l("conversation.assistantCapabilityBadgeQuery"),title:l("conversation.assistantCliHelpRootTitle"),summary:l("conversation.assistantCliSummaryHelp")}}function CT(e,t){const n=e==null?void 0:e.trim(),r=t==null?void 0:t.trim();return n?n==="capabilities"&&r==="list"?"capabilities.list":n==="projects"&&r==="list"?"projects.list":n==="projects"&&r==="get"?"projects.get":n==="sessions"&&r==="list"?"projects.sessions.list":n==="sessions"&&r==="get"?"sessions.get":n==="sessions"&&r==="messages"?"sessions.messages.list":n==="sessions"&&r==="runtime"?"sessions.runtime.get":n==="sessions"&&r==="start"?"projects.sessions.start":n==="sessions"&&r==="send"?"sessions.message.send":n==="sessions"&&r==="fork"?"sessions.fork":n==="timers"&&r==="create"?"timers.create":n==="timers"&&r==="cancel"?"timers.cancel":n==="timers"&&r==="list"?"timers.list":n==="terminals"&&r==="send"?"terminals.input.send":n==="terminals"&&r==="close"?"terminals.close":n==="terminals"&&r==="history"?"terminals.history.read":n==="terminals"&&r==="list"?"terminals.list":n==="workspaces"&&r==="list"?"workspaces.list":n==="workspaces"&&r==="clone"?"workspaces.clone":n==="workspaces"&&r==="import"?"workspaces.import":n==="workspaces"&&r==="management"?"workspaces.management.get":n==="worktrees"&&r==="tree"?"worktrees.tree":n==="worktrees"&&r==="create"?"worktrees.create":null:null}function Fu(e){switch(e){case"sessions":case"projects":return"session";case"timers":return"automation";case"terminals":return"terminal";case"workspaces":case"worktrees":return"workspace";case"debug-targets":case"debug-runtimes":return"debug";default:return"query"}}function Eg(e){switch(Fu(e)){case"session":return l("conversation.assistantCapabilityBadgeSession");case"automation":return l("conversation.assistantCapabilityBadgeAutomation");case"terminal":return l("conversation.assistantCapabilityBadgeTerminal");case"workspace":return l("conversation.assistantCapabilityBadgeWorkspace");case"debug":return l("conversation.assistantCapabilityBadgeDebug");case"query":default:return l("conversation.assistantCapabilityBadgeQuery")}}function NT(e,t){const n=[],r=Os(e,"--session-id")??e.positionals[0]??null,i=Os(e,"--project")??Os(e,"--project-id");return e.mode==="help"?(Oe(n,l("conversation.assistantCliLabelScope"),e.group??l("conversation.assistantCliScopeRoot")),Oe(n,l("conversation.assistantCliLabelAction"),e.action),n):(e.group==="sessions"&&Oe(n,l("conversation.assistantCapabilityLabelSession"),os(r,null,t)),e.group==="timers"&&(Oe(n,l("conversation.assistantCapabilityLabelSession"),os(r,null,t)),Oe(n,l("conversation.assistantCliLabelDelay"),Os(e,"--after-seconds"))),e.group==="terminals"&&Oe(n,l("conversation.assistantCapabilityLabelTerminal"),e.positionals[0]??null),(e.group==="workspaces"||e.group==="worktrees")&&Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rr(e.positionals[0]??null,null,t)),Oe(n,l("conversation.assistantCliLabelProject"),i),Oe(n,l("conversation.assistantCliLabelMessage"),Os(e,"--message")),Oe(n,l("conversation.assistantCliLabelInput"),Os(e,"--input")),n.slice(0,4))}function Os(e,t){const n=e.options[t];return typeof n=="string"?n:null}function Mg(e){switch(e){case"projects.sessions.start":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilityProjectSessionStartTitle"),summary:l("conversation.assistantCapabilitySummarySessionStart")};case"sessions.message.send":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionSendTitle"),summary:l("conversation.assistantCapabilitySummarySessionSend")};case"sessions.fork":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionForkTitle"),summary:l("conversation.assistantCapabilitySummarySessionFork")};case"timers.create":return{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityTimerCreateTitle"),summary:l("conversation.assistantCapabilitySummaryTimerCreate")};case"timers.cancel":return{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityTimerCancelTitle"),summary:l("conversation.assistantCapabilitySummaryTimerCancel")};case"terminals.input.send":return{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalInputTitle"),summary:l("conversation.assistantCapabilitySummaryTerminalInput")};case"terminals.close":return{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalCloseTitle"),summary:l("conversation.assistantCapabilitySummaryTerminalClose")};case"workspaces.directory.create":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceDirectoryCreateTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.import":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceImportTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.clone":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceCloneTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.navigation-state.update":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceNavigationUpdateTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.remove":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceRemoveTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"worktrees.create":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeCreateTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.merge-into-parent":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeMergeTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.cleanup":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeCleanupTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"debug-targets.run":return{kind:"debug",badge:l("conversation.assistantCapabilityBadgeDebug"),title:l("conversation.assistantCapabilityDebugRunTitle"),summary:l("conversation.assistantCapabilitySummaryDebug")};default:return e.startsWith("sessions.")||e.startsWith("projects.")?{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("timers.")?{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityAutomationReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("terminals.")?{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("workspaces.")||e.startsWith("worktrees.")?{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("debug-targets.")||e.startsWith("debug-runtimes.")?{kind:"debug",badge:l("conversation.assistantCapabilityBadgeDebug"),title:l("conversation.assistantCapabilityDebugReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:{kind:"query",badge:l("conversation.assistantCapabilityBadgeQuery"),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}}}function jT(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const i=Rt(r,"session");Oe(n,l("conversation.assistantCapabilityLabelSession"),os(nt(i,"sessionId"),nt(i,"title"),t)),Oe(n,l("conversation.assistantCapabilityLabelProvider"),nt(i,"provider"));break}case"sessions.message.send":{const i=Rt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelSession"),os(e.targetRef.id,null,t)),Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rg(e.targetRef.id,t)),Oe(n,l("conversation.assistantCapabilityLabelStatus"),l("conversation.assistantCapabilityStatusCompleted")),Oe(n,l("conversation.assistantCapabilityLabelDueAt"),Dh(nt(i,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const i=Rt(r,"session");Oe(n,l("conversation.assistantCapabilityLabelSession"),os(nt(i,"sessionId"),nt(i,"title"),t)),Oe(n,l("conversation.assistantCapabilityLabelProvider"),nt(i,"provider"));break}case"timers.create":case"timers.cancel":{const i=Rt(r,"timer"),o=Rt(i,"controlSession"),a=Rt(o,"session");Oe(n,l("conversation.assistantCapabilityLabelTimer"),nt(i,"title")),Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rr(nt(a,"workspaceId"),null,t)),Oe(n,l("conversation.assistantCapabilityLabelSession"),os(nt(i,"targetSessionId"),null,t)),Oe(n,l("conversation.assistantCapabilityLabelDueAt"),Dh(nt(i,"dueAt"))),Oe(n,l("conversation.assistantCapabilityLabelStatus"),ET(nt(i,"status")));break}case"terminals.input.send":case"terminals.close":Oe(n,l("conversation.assistantCapabilityLabelTerminal"),e.targetRef.id);break;case"workspaces.directory.create":{const i=Rt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelPath"),nt(i,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const i=Rt(r,"workspace");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rr(nt(i,"id")??e.targetRef.id,nt(i,"name"),t)),Oe(n,l("conversation.assistantCapabilityLabelPath"),nt(i,"path"));break}case"workspaces.navigation-state.update":{const i=Rt(r,"state");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rr(nt(i,"workspaceId")??e.targetRef.id,null,t)),Oe(n,l("conversation.assistantCapabilityLabelStatus"),nt(i,"collapsed")==="true"?l("conversation.assistantCapabilityNavigationCollapsed"):l("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const i=Rt(r,"result"),o=Rt(i,"workspace");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rr(nt(o,"id")??e.targetRef.id,nt(o,"name"),t)),Oe(n,l("conversation.assistantCapabilityLabelBranch"),nt(i,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const i=Rt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Rr(e.targetRef.id,null,t)),Oe(n,l("conversation.assistantCapabilityLabelStatus"),nt(i,"status"));break}case"debug-targets.run":{const i=Rt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),Oe(n,l("conversation.assistantCapabilityLabelRuntime"),nt(i,"runtimeId"));break}}return TT(n,e,t),n.slice(0,4)}function TT(e,t,n){t.targetRef.kind==="session"&&(Oe(e,l("conversation.assistantCapabilityLabelSession"),os(t.targetRef.id,null,n)),Oe(e,l("conversation.assistantCapabilityLabelWorkspace"),Rg(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&Oe(e,l("conversation.assistantCapabilityLabelWorkspace"),Rr(t.targetRef.id,null,n)),t.targetRef.kind==="terminal"&&Oe(e,l("conversation.assistantCapabilityLabelTerminal"),t.targetRef.id),t.targetRef.kind==="timer"&&Oe(e,l("conversation.assistantCapabilityLabelTimer"),t.targetRef.id);const r=IT(t.payload);r!==null&&Oe(e,l("conversation.assistantCapabilityLabelCount"),String(r))}function Oe(e,t,n){const r=n==null?void 0:n.trim();r&&(e.some(i=>i.label===t)||e.push({label:t,value:r}))}function os(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const i=e==null?void 0:e.trim();return i?n.sessionNamesById.get(i)??i:null}function Rr(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const i=e==null?void 0:e.trim();return i?n.workspaceNamesById.get(i)??i:null}function Rg(e,t){const n=e==null?void 0:e.trim();return n?Rr(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function IT(e){const t=Ul(e,"items");if(t)return t.length;const n=Rt(e,"page"),r=Ul(n,"items");if(r)return r.length;const i=Rt(e,"history"),o=Ul(i,"items");return o?o.length:null}function Dh(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n)):t}function ET(e){switch(e){case"active":return l("conversation.assistantCapabilityStatusActive");case"completed":return l("conversation.assistantCapabilityStatusCompleted");case"cancelled":return l("conversation.assistantCapabilityStatusCancelled");case"failed":return l("conversation.assistantCapabilityStatusFailed");default:return e}}function MT({kind:e}){switch(e){case"session":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M5 7.5A2.5 2.5 0 0 1 7.5 5h9A2.5 2.5 0 0 1 19 7.5v5A2.5 2.5 0 0 1 16.5 15H11l-4 4v-4H7.5A2.5 2.5 0 0 1 5 12.5z"})});case"automation":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"7.5"}),s.jsx("path",{d:"M12 8.5v4.2l2.8 1.8"})]});case"terminal":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"m7 8 3.5 3.5L7 15"}),s.jsx("path",{d:"M13 15h4"}),s.jsx("rect",{x:"4.5",y:"5.5",width:"15",height:"13",rx:"2.5"})]});case"workspace":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M4.5 8.5A2.5 2.5 0 0 1 7 6h3l1.5 1.5H17A2.5 2.5 0 0 1 19.5 10v6A2.5 2.5 0 0 1 17 18.5H7A2.5 2.5 0 0 1 4.5 16z"})});case"debug":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M9 4.5h6"}),s.jsx("path",{d:"M10 8h4a4 4 0 0 1 4 4v1a6 6 0 0 1-12 0v-1a4 4 0 0 1 4-4Z"}),s.jsx("path",{d:"M4.5 11h3M16.5 11h3M5.5 7.5l2 1.5M18.5 7.5l-2 1.5"})]});case"query":default:return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"11",cy:"11",r:"5.5"}),s.jsx("path",{d:"m16 16 3.5 3.5"})]})}}function RT(e){if(e.name==="apply_patch"){const c=jh(e.input);if(c)return c;const u=nj(e.output||e.error||""),d=tj(e.input,u);return d?jh(d):null}const t=e.name.trim().toLowerCase(),n=AT(t);if(!n)return null;const r=Wu(e.input);if(!r)return null;const i=Bs(r,["file_path","filePath","path"]);if(!i)return null;if(n==="write"){const c=Bs(r,["content","new_content","newContent"]),u=c.length>0?c.split(/\r?\n/):[];return{files:[{path:i,nextPath:null,action:"add",additions:u.length,deletions:0,statsKnown:!0,lines:u.map((d,h)=>({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:h+1}))}],totalAdditions:u.length,totalDeletions:0}}if(n==="edit"){const c=Bs(r,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),u=Bs(r,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/);return _h(i,[{oldLines:c,newLines:u}])}const a=(Array.isArray(r.edits)?r.edits:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;const u=c;return{oldLines:Bs(u,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),newLines:Bs(u,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/)}}).filter(c=>!!c);return a.length>0?_h(i,a):null}function AT(e){return e==="write"||e==="overwrite"?"write":e==="edit"?"edit":e==="multiedit"||e==="multi_edit"?"multiedit":null}function _h(e,t){const n=[];let r=0,i=0;return t.forEach((o,a)=>{n.push({kind:"hunk",text:`@@ -1,${o.oldLines.length} +1,${o.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),o.oldLines.forEach((c,u)=>{c.length===0&&o.oldLines.length===1&&o.newLines.length>0||(i+=1,n.push({kind:"remove",text:`-${c}`,oldLineNumber:u+1,newLineNumber:null}))}),o.newLines.forEach((c,u)=>{c.length===0&&o.newLines.length===1&&o.oldLines.length>0||(r+=1,n.push({kind:"add",text:`+${c}`,oldLineNumber:null,newLineNumber:u+1}))}),a<t.length-1&&n.push({kind:"meta",text:"***",oldLineNumber:null,newLineNumber:null})}),{files:[{path:e,nextPath:null,action:"update",additions:r,deletions:i,statsKnown:!0,lines:n}],totalAdditions:r,totalDeletions:i}}function PT(e){const t=Wu(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(n)return`${l("conversation.toolPreviewCommand")}:${n}`;if(e.name==="read_thread_terminal")return l("conversation.toolPreviewTerminal");const r=e.input||e.error||e.output||l("conversation.toolResultEmpty");return r.length>60?`${r.slice(0,60)}...`:r}function LT(e){var o;const t=e.map(a=>({message:a,tool:jg(a)})).filter(a=>!!a.tool);if(t.length===0)return null;const n={...t[0].tool};let r=!1,i=!1;for(const{message:a,tool:c}of t)a.kind==="tool_call"&&(r=!0,!n.input&&c.input&&(n.input=c.input)),a.kind==="tool_result"&&(i=!0,n.output=c.output,n.error=c.error,n.status=c.status,!n.input&&c.input&&(n.input=c.input)),!n.name&&c.name&&(n.name=c.name);return{key:t.map(({message:a})=>a.id).join(":"),tool:n,hasRequest:r,hasResult:i,updatedAt:((o=t.at(-1))==null?void 0:o.message.timestamp)??t[0].message.timestamp}}function DT(e){const t=new Map;for(const n of e){const r=jg(n);if(!r)continue;const i=t.get(r.callId);if(i){i.messages.push(n);continue}t.set(r.callId,{messages:[n],firstSequence:n.sequence})}return Array.from(t.values()).sort((n,r)=>n.firstSequence-r.firstSequence).map(n=>LT(n.messages)).filter(n=>!!n)}function Ag(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n];if(_T(e,n))continue;if(!Aa(r)){t.push({type:"message",key:r.id,message:r});continue}const i=[r];let o=n+1;for(;o<e.length;){const c=e[o];if(!Aa(c))break;i.push(c),o+=1}const a=DT(i);if(a.length===0){t.push({type:"message",key:r.id,message:r}),n=o-1;continue}a.forEach(c=>{t.push({type:"tool_group",key:c.key,group:c})}),n=o-1}return t}function _T(e,t){const n=e[t];if(!n||Ng(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const i=e[r];if(!(!i||Aa(i)))return i.role==="user"}return!1}function BT(e,t){if(!hk(null,e))return!1;const n=t.trim();return/AGENTS\.md instructions for/i.test(n)&&/<INSTRUCTIONS>/i.test(n)&&/<\/INSTRUCTIONS>/i.test(n)}function OT(e,t){if(e!=="claude-code")return!1;const n=t.trim();return/Base directory for this skill:/i.test(n)&&/^#\s+.+/im.test(n)&&/\bARGUMENTS:/i.test(n)}function WT(e,t){if(e==="skill_context"){const r=t.split(/\r?\n/).map(i=>i.trim()).find(i=>/^#\s+/.test(i));if(r)return r.replace(/^#+\s*/,"")}const n=t.split(/\r?\n/).map(r=>r.trim()).find(Boolean);return n?n.replace(/^#+\s*/,""):l("conversation.rulesMessageTitle")}function Pg(e,t){const n=new Set;if(t!=="kimi")return n;for(const r of e){if(r.role==="system"&&r.kind==="text"){n.add(r.id);continue}break}return n}function eo(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>eo(n)).join(""):e&&typeof e=="object"&&"props"in e?eo(((t=e.props)==null?void 0:t.children)??""):""}function FT(e){const t=Array.isArray(e)?e[0]:e;if(!f.isValidElement(t))return null;const n=t.props,r=typeof n.className=="string"?n.className:"",i=/language-([^\s]+)/.exec(r);return{content:eo(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(i==null?void 0:i[1])??null}}function $T(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function $u(e,t){var n;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!$T(e))throw new Error(l("conversation.copyContentFailed"))}}function zT({className:e,children:t,onCopy:n,exportMode:r=!1}){const i=f.useContext(Rc),o=eo(t).trim();if(r||i||!o)return s.jsx("code",{className:e||void 0,children:t});function a(c){c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),n(o))}return s.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":l("conversation.copyAction"),onClick:()=>n(o),onKeyDown:a,children:t})}function HT({href:e,children:t,className:n,onInteract:r,exportMode:i=!1}){if(i)return s.jsx(Rc.Provider,{value:!0,children:s.jsx("a",{href:e,className:n,children:t})});const o=eo(t).trim()||(e?Ou(e).trim():"");return s.jsx(Rc.Provider,{value:!0,children:s.jsx("a",{href:e,className:[n,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:a=>{a.preventDefault(),r(e,o)},children:t})})}function Lg({language:e,codeClassName:t,content:n,exportMode:r=!1}){const{showToast:i}=Pn(),o=vn(),a=(e==null?void 0:e.trim().toLowerCase())??null,c=a==="text",u=a||"code";async function d(){try{await $u(n,o),i({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(h){i({title:h instanceof Error?h.message:l("conversation.copyContentFailed"),tone:"error"})}}return s.jsxs("div",{className:`code-block${c?" text-code-block":""}`,children:[s.jsxs("div",{className:"code-header",children:[s.jsx("span",{className:"code-header-label",children:u}),r?null:s.jsx("button",{className:"code-copy-button",type:"button",onClick:()=>void d(),children:l("conversation.copyAction")})]}),s.jsx("pre",{className:t,children:s.jsx("code",{children:n})})]})}function Oi({content:e,className:t,exportMode:n=!1}){const{showToast:r}=Pn(),i=vn(),{navigationGroups:o,currentWorkspaceId:a,revealWorkspaceFile:c}=Fb(),u=f.useMemo(()=>{var p;return((p=o.find(m=>m.workspace.id===a))==null?void 0:p.workspace)??null},[a,o]);async function d(p){if(p.trim())try{await $u(p,i),r({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(m){r({title:m instanceof Error?m.message:l("conversation.copyContentFailed"),tone:"error"})}}function h(p,m){const g=p&&(u!=null&&u.path)?uT(p,u.path):null;g&&c({workspaceId:(u==null?void 0:u.id)??a,filePath:g,openViewer:!1})||d(m||(p?Ou(p).trim():""))}return s.jsx("div",{className:t,children:s.jsx(T1,{remarkPlugins:[FN],components:{p:({node:p,...m})=>s.jsx("p",{...m}),a(p){return s.jsx(HT,{href:typeof p.href=="string"?p.href:void 0,className:typeof p.className=="string"?p.className:void 0,onInteract:h,exportMode:n,children:p.children})},pre(p){const m=FT(p.children);return m?s.jsx(Lg,{language:m.language,codeClassName:m.codeClassName,content:m.content,exportMode:n}):s.jsx("pre",{children:p.children})},code(p){const m=typeof p.className=="string"?p.className:"";return s.jsx(zT,{className:m||void 0,exportMode:n,onCopy:g=>{d(g)},children:p.children})}},children:e})})}function Bh(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function UT(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Vo({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return s.jsx(qT,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function qT({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){const[i,o]=f.useState({}),[a,c]=f.useState(null),u=f.useMemo(()=>n.map((m,g)=>{const x=Bh(m,t==null?void 0:t[g]);if(x)return{id:m.id,kind:m.kind,fileName:m.fileName,fileSize:m.fileSize,url:x,status:"ready"};const S=i[m.id];return{id:m.id,kind:m.kind,fileName:m.fileName,fileSize:m.fileSize,url:(S==null?void 0:S.url)??null,status:(S==null?void 0:S.status)??(e?"loading":"error")}}),[t,n,i,e]),d=f.useMemo(()=>r.map((m,g)=>({id:`inline-image-${g}`,kind:"image",fileName:m.altText||`${l("conversation.imageAttachmentLabel")} ${g+1}`,fileSize:m.estimatedBytes,url:m.url,status:"ready"})),[r]),h=f.useMemo(()=>[...d,...u],[u,d]),p=h.find(m=>m.id===a)??null;return f.useEffect(()=>{if(!a)return;function m(g){g.key==="Escape"&&c(null)}return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[a]),f.useEffect(()=>{const m=n.filter((S,C)=>!Bh(S,t==null?void 0:t[C]));if(!e||m.length===0){o({});return}let g=!1;const x=[];return o(Object.fromEntries(m.map(S=>[S.id,{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"loading"}]))),Promise.all(m.map(async S=>{try{const C=await pk(e,S.id),y=URL.createObjectURL(C);return x.push(y),{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:y,status:"ready"}}catch{return{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"error"}}})).then(S=>{if(g){x.forEach(C=>URL.revokeObjectURL(C));return}o(Object.fromEntries(S.map(C=>[C.id,C])))}),()=>{g=!0,x.forEach(S=>URL.revokeObjectURL(S))}},[t,n,e]),h.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-attachments",children:h.map(m=>{const g=m.kind==="image",x=m.status==="loading"?l("conversation.attachmentPreviewLoading"):m.status==="error"?l("conversation.attachmentPreviewUnavailable"):g?l("conversation.attachmentPreviewOpen"):l("conversation.attachmentDownload"),S=UT(m.fileSize),C=s.jsx("div",{className:"message-attachment-card",children:g?m.url?s.jsx("img",{className:"message-attachment-thumbnail",src:m.url,alt:m.fileName||l("conversation.attachmentPreviewAlt"),loading:"lazy"}):s.jsx("div",{className:"message-attachment-placeholder","aria-hidden":"true",children:m.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")}):s.jsxs("div",{className:"message-attachment-file-card",children:[s.jsx("div",{className:"message-attachment-file-icon","aria-hidden":"true",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),s.jsx("path",{d:"M14 2v5h5"}),s.jsx("path",{d:"M9 13h6"}),s.jsx("path",{d:"M9 17h6"})]})}),s.jsxs("div",{className:"message-attachment-file-meta",children:[s.jsx("strong",{title:m.fileName,children:m.fileName}),s.jsx("span",{children:S??l("conversation.fileAttachmentLabel")})]})]})});return!g&&m.url?s.jsx("a",{className:"message-attachment-button",href:m.url,download:m.fileName,"aria-label":`${m.fileName} - ${x}`,title:x,children:C},m.id):s.jsx("button",{type:"button",className:"message-attachment-button",onClick:()=>g&&m.url&&c(m.id),disabled:!m.url,"aria-label":`${m.fileName} - ${x}`,title:x,children:C},m.id)})}),s.jsx(ru,{open:!!(p!=null&&p.url),title:l("conversation.imagePreviewTitle"),description:p==null?void 0:p.fileName,size:"xwide",layout:"viewer",className:"message-image-modal",bodyClassName:"message-image-modal-body",onClose:()=>c(null),children:p!=null&&p.url?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-image-modal-stage",children:s.jsx("img",{className:"message-image-modal-image",src:p.url,alt:p.fileName||l("conversation.attachmentPreviewAlt")})}),s.jsx("p",{className:"message-image-modal-hint",children:l("conversation.imagePreviewHint")})]}):null})]})}function GT(){return s.jsx("div",{className:"timeline-skeleton","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("article",{className:`timeline-skeleton-item ${t%2===0?"assistant":"user"}`,children:[s.jsx("div",{className:"timeline-skeleton-avatar"}),s.jsxs("div",{className:"timeline-skeleton-bubble",children:[s.jsx("span",{className:"timeline-skeleton-line long"}),s.jsx("span",{className:"timeline-skeleton-line medium"}),s.jsx("span",{className:"timeline-skeleton-line short"})]})]},t))})}function VT({tool:e,preview:t,exportMode:n=!1}){const[r,i]=f.useState(null),o=r===null?null:t.files[r]??null;return f.useEffect(()=>{if(r===null)return;function a(c){c.key==="Escape"&&i(null)}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((a,c)=>n?s.jsxs("div",{className:"apply-patch-summary-row",children:[s.jsx("span",{className:"apply-patch-summary-label",children:ql(a.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:Ko(a),children:Th(a.nextPath??a.path)}),Vl(a)]},Gl(a,c)):s.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>i(c),children:[s.jsx("span",{className:"apply-patch-summary-label",children:ql(a.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:Ko(a),children:Th(a.nextPath??a.path)}),Vl(a)]},Gl(a,c)))}),s.jsx(ru,{open:o!==null,title:l("conversation.applyPatchDialogTitle"),description:l("conversation.applyPatchDialogDescription"),size:"full",layout:"viewer",className:"apply-patch-modal",bodyClassName:"apply-patch-modal-body",onClose:()=>i(null),children:o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"apply-patch-modal-totals",children:QT(o)}),s.jsxs("section",{className:"apply-patch-file-panel",children:[s.jsxs("div",{className:"apply-patch-file-panel-header",children:[s.jsxs("div",{className:"apply-patch-file-panel-title",children:[s.jsx("span",{className:"apply-patch-summary-label",children:ql(o.action)}),s.jsx("strong",{children:Ko(o)})]}),Vl(o)]}),s.jsx("div",{className:"apply-patch-diff-view",children:s.jsx("div",{className:"apply-patch-diff-scroll",children:o.lines.map((a,c)=>s.jsxs("div",{className:`apply-patch-diff-line ${ZT(a.kind)}`,children:[s.jsx("span",{className:"apply-patch-line-number",children:Wh(a.oldLineNumber)}),s.jsx("span",{className:"apply-patch-line-number",children:Wh(a.newLineNumber)}),s.jsx("span",{className:"apply-patch-line-content",children:a.text||" "})]},`${Ko(o)}:${c}`))})})]},Gl(o,r??0)),e.error?s.jsxs("section",{className:"apply-patch-error-panel",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:"tool-call-error",children:e.error})]}):null]}):null})]})}function Dg({group:e,exportMode:t=!1}){const[n,r]=f.useState(!1),{navigationGroups:i}=Fb(),{tool:o,hasRequest:a,hasResult:c}=e,u=dT(o.name),d=f.useMemo(()=>mT(i),[i]),h=f.useMemo(()=>gT(o,d),[d,o]),p=f.useMemo(()=>bT(o,d),[d,o]),m=f.useMemo(()=>Tj(o,null,e.updatedAt),[e.updatedAt,o]),g=f.useMemo(()=>RT(o),[o.input,o.name]);if(g)return s.jsx(VT,{tool:o,preview:g,exportMode:t});if(h)return s.jsx(Oh,{tool:o,snapshot:h,expanded:n,hasRequest:a,hasResult:c,exportMode:t,onToggleExpanded:()=>{r(A=>!A)}});if(p)return s.jsx(Oh,{tool:o,snapshot:p,expanded:n,hasRequest:a,hasResult:c,exportMode:t,onToggleExpanded:()=>{r(A=>!A)}});if(m)return s.jsx(KT,{tool:o,snapshot:m,expanded:n,hasRequest:a,hasResult:c,exportMode:t,onToggleExpanded:()=>{r(A=>!A)}});const x=PT(o),S=!!(o.input||o.output||o.error),C=S&&!t,y=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:u}),s.jsx("span",{className:"tool-call-input-preview",children:x})]}),s.jsx("div",{className:"tool-call-meta",children:C&&s.jsx("span",{className:`tool-call-toggle ${n?"expanded":""}`,children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]});return s.jsxs("div",{className:`tool-call-item ${c?"tool-result":""}`,children:[t?s.jsx("div",{className:"tool-call-header",children:y}):s.jsx("button",{type:"button",className:"tool-call-header",onClick:()=>S&&r(A=>!A),children:y}),n&&S&&s.jsxs("div",{className:"tool-call-output",children:[a&&o.input&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:o.input})]}),(c||o.error||o.output)&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:o.error?"tool-call-error":void 0,children:o.error||o.output||l("conversation.toolResultEmpty")})]})]})]})}function Oh({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:o,exportMode:a=!1}){const c=n?l("conversation.assistantCapabilityRawCollapse"):l("conversation.assistantCapabilityRawExpand");return s.jsxs("div",{className:"tool-call-item assistant-capability-item","data-kind":t.kind,children:[s.jsxs("div",{className:"assistant-capability-header",children:[s.jsxs("div",{className:"assistant-capability-heading",children:[s.jsx("span",{className:"assistant-capability-icon",children:s.jsx(MT,{kind:t.kind})}),s.jsxs("div",{className:"assistant-capability-heading-main",children:[s.jsx("span",{className:"assistant-capability-badge",children:t.badge}),s.jsx("strong",{children:t.title}),s.jsx("span",{className:"assistant-capability-summary",children:t.summary})]})]}),a?null:s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:c})]}),t.rows.length>0?s.jsx("div",{className:"assistant-capability-list",children:t.rows.map(u=>s.jsxs("div",{className:"assistant-capability-row",children:[s.jsx("span",{className:"assistant-capability-row-label",children:u.label}),s.jsx("span",{className:"assistant-capability-row-value",children:u.value})]},u.label))}):null,!a&&n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,i||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null]})}function KT({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:o,exportMode:a=!1}){const c=jj(t.items),u=n?l("conversation.taskCardRawCollapse"):l("conversation.taskCardRawExpand");return s.jsxs("div",{className:"tool-call-item task-tool-item",children:[s.jsxs("div",{className:"task-tool-header",children:[s.jsxs("div",{className:"task-tool-heading",children:[s.jsx("span",{className:"task-tool-badge",children:t.source==="plan"?l("conversation.taskCardPlanTitle"):l("conversation.taskCardTodoTitle")}),s.jsxs("div",{className:"task-tool-heading-main",children:[s.jsx("strong",{children:YT(t,e.name)}),s.jsx("span",{className:"task-tool-summary-text",children:XT(t.items,c)})]})]}),a?null:s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:u})]}),s.jsx("ol",{className:"task-tool-list",children:t.items.map(d=>s.jsxs("li",{className:"task-tool-list-item","data-status":d.status,children:[s.jsx("span",{className:"task-tool-item-indicator","data-status":d.status,"aria-hidden":"true"}),s.jsx("strong",{className:"task-tool-item-title",children:d.title}),d.detail?s.jsx("span",{className:"task-tool-item-detail",children:d.detail}):null,s.jsx("span",{className:"task-tool-item-status",children:JT(d.status)})]},d.id))}),!a&&n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,i||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null]})}function YT(e,t){if(e.source==="plan")return l("conversation.taskCardPlanUpdated");const n=t.trim().toLowerCase();return n==="taskcreate"||n==="todowrite"||n==="todoread"?l("conversation.taskCardTodoUpdated"):n.startsWith("task")?l("conversation.taskCardTodoUpdated"):l("conversation.taskCardTodoUpdated")}function XT(e,t){const n=[l("conversation.taskCardSummaryTotal",{count:e.length})];return t.in_progress>0&&n.push(l("conversation.taskCardSummaryInProgress",{count:t.in_progress})),t.pending>0&&n.push(l("conversation.taskCardSummaryPending",{count:t.pending})),t.completed>0&&n.push(l("conversation.taskCardSummaryCompleted",{count:t.completed})),t.failed>0&&n.push(l("conversation.taskCardSummaryFailed",{count:t.failed})),n.join(" / ")}function JT(e){switch(e){case"in_progress":return l("conversation.taskProgressStatusInProgress");case"completed":return l("conversation.taskProgressStatusCompleted");case"failed":return l("conversation.taskProgressStatusFailed");case"cancelled":return l("conversation.taskProgressStatusCancelled");case"pending":default:return l("conversation.taskProgressStatusPending")}}function ql(e){return e==="add"?l("conversation.applyPatchAddedLabel"):e==="delete"?l("conversation.applyPatchDeletedLabel"):l("conversation.applyPatchEditedLabel")}function Ko(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function Gl(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function Vl(e){return e.statsKnown?s.jsxs("span",{className:"apply-patch-summary-stats",children:[s.jsxs("span",{className:"apply-patch-summary-added",children:["+",e.additions]}),s.jsxs("span",{className:"apply-patch-summary-removed",children:["-",e.deletions]})]}):s.jsx("span",{className:"apply-patch-summary-stats",children:s.jsx("span",{className:"apply-patch-summary-edited",children:l("conversation.applyPatchEditedStat")})})}function QT(e){return e.statsKnown?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"apply-patch-stat-pill positive",children:[l("conversation.applyPatchAddedStat")," +",e.additions]}),s.jsxs("span",{className:"apply-patch-stat-pill negative",children:[l("conversation.applyPatchRemovedStat")," -",e.deletions]})]}):s.jsx("span",{className:"apply-patch-stat-pill neutral",children:l("conversation.applyPatchEditedStat")})}function ZT(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function Wh(e){return e===null||e<=0?"":String(e)}function eI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function _g({timestamp:e,leading:t,children:n}){return s.jsxs("div",{className:"user-message-footer",children:[s.jsx("div",{className:"user-message-footer-leading",children:t}),s.jsxs("div",{className:"user-message-footer-trailing",children:[s.jsx("time",{className:"message-time",dateTime:e,children:eI(e)}),n]})]})}function ss({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:i}){const{showToast:o}=Pn(),a=vn(),[c,u]=f.useState(!1),[d,h]=f.useState(!1),p=e.trim().length>0,m=t&&p;async function g(){if(!(!m||c)){u(!0);try{await $u(e,a),o({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(S){o({title:S instanceof Error?S.message:l("conversation.copyContentFailed"),tone:"error"})}finally{u(!1)}}}async function x(){if(!(!i||d)){h(!0);try{await i()}finally{h(!1)}}}return!m&&!n?null:s.jsxs("div",{className:r?"message-metadata-bar compact":"message-metadata-bar",children:[m?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":l("conversation.copyAction"),title:l("conversation.copyAction"),onClick:()=>{g()},disabled:c,children:s.jsx(_j,{})}):null,n?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":d?l("conversation.forkingAction"):l("conversation.forkFromHereAction"),title:d?l("conversation.forkingAction"):l("conversation.forkFromHereAction"),onClick:()=>{x()},disabled:d,children:s.jsx(Bj,{})}):null]})}function tI({message:e,kind:t,tone:n,actionState:r,onRetry:i,onForkMessage:o,forceExpanded:a=!1,exportMode:c=!1}){const[u,d]=f.useState(!1),h=WT(t,e.content),p=n==="user-message",m=a||u,g=t==="system_prompt"?l("conversation.systemPromptTitle"):t==="skill_context"?l("conversation.skillContextTitle"):l("conversation.rulesMessageTitle"),x=t==="system_prompt"?l("conversation.systemPromptHint"):t==="skill_context"?l("conversation.skillContextHint"):l("conversation.rulesMessageHint"),S=m?t==="system_prompt"?l("conversation.systemPromptCollapse"):t==="skill_context"?l("conversation.skillContextCollapse"):l("conversation.rulesMessageCollapse"):t==="system_prompt"?l("conversation.systemPromptExpand"):t==="skill_context"?l("conversation.skillContextExpand"):l("conversation.rulesMessageExpand");return s.jsx("article",{className:`message-item ${n} rules-message-row`,"data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsxs("div",{className:"rules-message-card",children:[a?s.jsx("div",{className:"rules-message-toggle","aria-expanded":m,children:s.jsxs("div",{className:"rules-message-heading",children:[s.jsx("span",{className:"rules-message-badge",children:g}),s.jsx("span",{className:"rules-message-summary",children:h})]})}):s.jsxs("button",{type:"button",className:"rules-message-toggle","aria-expanded":m,onClick:()=>d(C=>!C),children:[s.jsxs("div",{className:"rules-message-heading",children:[s.jsx("span",{className:"rules-message-badge",children:g}),s.jsx("span",{className:"rules-message-summary",children:h})]}),s.jsx("span",{className:"rules-message-action",children:S})]}),s.jsx("p",{className:"rules-message-hint",children:x}),m&&s.jsx("div",{className:"rules-message-body",children:s.jsx(Oi,{content:e.content,className:"message-text message-content markdown-content",exportMode:c})}),p?s.jsx(_g,{timestamp:e.timestamp,children:s.jsx(ss,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(e):null})}):s.jsx(ss,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>i(e.clientRequestId),children:l("conversation.resendButton")})]})})}function Bg({message:e,provider:t,interruptedSource:n=null,foldedPromptKind:r=null,actionState:i,onRetry:o,onForkMessage:a,assistantAvatar:c,exportMode:u=!1,onSubmitStructuredQuestion:d}){const h=e.role==="user",p=e.kind==="thinking",m=e.role==="assistant"&&e.kind==="text",g=t==="codex"&&e.kind==="text"?Ng(e.content):null,x=r??(BT(t,e.content)?"rules":OT(t,e.content)?"skill_context":null),S=f.useMemo(()=>cs(e.content),[e.content]),C=S.text,y=S.inlineImages,A=S.structuredQuestions,[T,G]=f.useState(!1),[P,E]=f.useState(!1),[V,U]=f.useState(null),[L,I]=f.useState(null);if(x){const H=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return s.jsx(tI,{message:e,kind:x,tone:H,actionState:i,onRetry:o,onForkMessage:a,forceExpanded:u,exportMode:u})}if(g){const H=eT(n),_=g.detail?`${H}
46
+
47
+ ${g.detail}`:H;return s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:c??s.jsx(Kl,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Oi,{content:_,className:"message-text message-content markdown-content",exportMode:u}),s.jsx(ss,{text:_,canCopy:i.canCopy,canFork:!1,onFork:null})]})]})}if(h){const H=e.origin==="butler_proxy"||sI(e.clientRequestId),_=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function se(){if(!_)return;const W=!T;if(G(W),!(!W||L||P)){E(!0),U(null);try{const q=await XN(e.originRef);I(q.task)}catch(q){U(q instanceof Error?q.message:l("conversation.butlerOriginDetailLoadFailed"))}finally{E(!1)}}}const Y=H?_?s.jsxs("div",{className:"message-origin-detail-anchor",children:[s.jsx("button",{type:"button",className:"message-origin-badge message-origin-badge-button","aria-expanded":T,onClick:()=>{se()},children:l("conversation.butlerProxyMessageBadge")}),T?s.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[s.jsx("strong",{children:l("conversation.butlerOriginDetailTitle")}),P?s.jsx("p",{children:l("conversation.butlerOriginDetailLoading")}):V?s.jsx("p",{children:V}):L?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:[l("conversation.butlerOriginDetailObjectiveLabel"),":",L.objective]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailStatusLabel"),":",iI(L.status)]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailSummaryLabel"),":",L.lastAutomationSummary||l("conversation.butlerAnalysisEmpty")]}),L.waitingReason?s.jsxs("p",{children:[l("conversation.butlerOriginDetailWaitingReasonLabel"),":",L.waitingReason]}):null]}):s.jsx("p",{children:l("conversation.butlerAnalysisEmpty")})]}):null]}):s.jsx("span",{className:"message-origin-badge",children:l("conversation.butlerProxyMessageBadge")}):null;return s.jsx("article",{className:"message-item user-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Vo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C?s.jsx(Oi,{content:C,className:"message-text message-content markdown-content",exportMode:u}):null,e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>o(e.clientRequestId),children:l("conversation.resendButton")}),s.jsx(_g,{timestamp:e.timestamp,leading:Y,children:s.jsx(ss,{text:C,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),compact:!0,onFork:a?()=>a(e):null})})]})})}return p?s.jsxs("article",{className:"message-item assistant-message thinking-message-row","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:c??s.jsx(Kl,{})}),s.jsxs("div",{className:"thinking-message-content",children:[s.jsx("div",{className:"thinking-message-label",children:l("conversation.thinkingLabel")}),s.jsx(Vo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C&&s.jsx(Oi,{content:C,className:"message-text message-content markdown-content thinking-message-text",exportMode:u}),s.jsx(ss,{text:C,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})]}):m?s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:c??s.jsx(Kl,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Vo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C&&s.jsx(Oi,{content:C,className:"message-text message-content markdown-content",exportMode:u}),A&&d?s.jsx(nI,{messageId:e.id,prompt:A,onSubmit:d}):null,s.jsx(ss,{text:C,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})]}):s.jsx("article",{className:"message-item system-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Vo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C?s.jsx("div",{className:"message-text message-content",children:s.jsx(Lg,{language:"text",content:C,exportMode:u})}):null,s.jsx(ss,{text:C,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})})}function nI({messageId:e,prompt:t,onSubmit:n}){const[r,i]=f.useState({}),[o,a]=f.useState(!1),c=t.questions.some(u=>{var d;return(((d=r[u.id])==null?void 0:d.filter(Boolean).length)??0)===0});return s.jsxs("section",{className:"permission-request-card permission-request-card-inline",children:[s.jsxs("header",{className:"permission-request-card-header",children:[s.jsx("div",{className:"permission-request-provider",children:s.jsxs("div",{className:"permission-request-provider-copy",children:[s.jsx("strong",{children:l("conversation.permissionRequestQuestionsLabel")}),s.jsx("span",{children:l("conversation.permissionRequestSectionDescription")})]})}),s.jsx("span",{className:"permission-request-kind",children:l("conversation.permissionRequestKindUserInput")})]}),s.jsx("div",{className:"permission-request-card-body",children:s.jsxs("div",{className:"permission-request-block",children:[s.jsx("div",{className:"permission-request-block-label",children:l("conversation.permissionRequestQuestionsLabel")}),s.jsx("div",{className:"permission-request-question-list",children:t.questions.map(u=>s.jsxs("div",{className:"permission-request-question",children:[s.jsx("div",{className:"permission-request-question-header",children:u.header}),s.jsx("p",{children:u.question}),s.jsx("div",{className:"permission-request-question-options",children:u.options.map(d=>{var p;const h=((p=r[u.id])==null?void 0:p.includes(d.label))??!1;return s.jsxs("label",{className:"permission-request-question-option",children:[s.jsx("input",{type:"radio",name:`${e}:${u.id}`,checked:h,onChange:()=>{i(m=>({...m,[u.id]:[d.label]}))}}),s.jsxs("span",{children:[s.jsx("strong",{children:d.label}),d.description?s.jsx("small",{children:d.description}):null]})]},`${u.id}:${d.label}`)})})]},`${e}:${u.id}`))})]})}),s.jsx("footer",{className:"permission-request-card-footer",children:s.jsx("button",{type:"button",className:"primary-button permission-request-action",disabled:o||c,onClick:async()=>{a(!0);try{await n({messageId:e,answers:r})}finally{a(!1)}},children:o?l("conversation.permissionRequestSubmitting"):l("common.confirm")})})]})}function rI({sessionId:e,messages:t,provider:n,interruptedSource:r=null,runtimeThinkingPlaceholder:i=null,assistantAvatar:o}){const a=Ag(t),c=f.useMemo(()=>Pg(t,n),[t,n]);return s.jsx("section",{className:"message-timeline message-timeline-export","aria-label":l("conversation.exportPrintContainerTitle"),children:s.jsxs("div",{className:"message-list message-list-export","data-export-mode":"true",children:[a.length===0?s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}):null,a.map(u=>u.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(Dg,{group:u.group,exportMode:!0})},u.key):s.jsx(Bg,{message:u.message,provider:n,foldedPromptKind:c.has(u.message.id)?"system_prompt":null,actionState:{canCopy:!1,canFork:!1},onRetry:()=>{},onForkMessage:null,interruptedSource:r,assistantAvatar:o,exportMode:!0},u.key)),i?s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":i,children:[s.jsx("span",{children:Cg(i)||i}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null]})})}function Kl(){return s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4M12 8h.01"})]})}function sI(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function iI(e){switch(e){case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"active":default:return l("shell.butlerAutomationStatusActive")}}function LP({sessionId:e="session",messages:t,historyState:n,loadingOlderMessages:r=!1,hasOlderMessages:i=!1,onLoadOlderMessages:o=()=>{},onRetryMessage:a,onForkMessage:c,provider:u,interruptedSource:d=null,runtimeThinkingPlaceholder:h=null,assistantAvatar:p,followTailUpdates:m=!1,sessionRunningState:g=null,sessionSyncStatus:x=null,sessionLastErrorCode:S=null,sessionLastErrorDetail:C=null,onSubmitStructuredQuestion:y}){var Ht;const{showToast:A}=Pn(),T=vn(),G=!m,P=f.useRef(null);_u(P);const E=f.useRef(e),V=f.useRef(0),U=f.useRef(null),L=f.useRef(!0),I=f.useRef(null),H=f.useRef(null),_=f.useRef(!1),se=f.useRef(m?null:Go(e)),Y=f.useRef(m?null:((Ht=Go(e))==null?void 0:Ht.lastMessageSignature)??null),W=f.useRef(m?null:Go(e)),q=f.useRef(null),D=f.useRef(null),K=f.useRef(null),ee=f.useRef(0),v=f.useRef(!1),Ce=f.useRef(null),je=f.useRef(null),[N,ce]=f.useState(!1),[Ie,fe]=f.useState(!1),oe=f.useRef(!1),_e=Ag(t),Ge=T.isMobile?0:iT,Ke=f.useMemo(()=>Pg(t,u),[t,u]),ft=f.useMemo(()=>oI(t),[t]),F=n==="loading"&&t.length===0,te=f.useMemo(()=>Xj({runningState:g,syncStatus:x,lastErrorCode:S,lastErrorDetail:C}),[S,C,g,x]);function re(B){var ue,de,Pe;if(!B)return null;try{const ge=JSON.parse(B);return{id:typeof ge.id=="string"?ge.id:null,timestamp:typeof ge.timestamp=="string"?ge.timestamp:null,deliveryState:typeof ge.deliveryState=="string"?ge.deliveryState:null,contentLength:typeof ge.content=="string"?ge.content.length:0,attachmentCount:Array.isArray(ge.attachments)?ge.attachments.length:0,toolStatus:typeof((ue=ge.toolCall)==null?void 0:ue.status)=="string"?ge.toolCall.status:null,hasToolOutput:typeof((de=ge.toolCall)==null?void 0:de.output)=="string"?ge.toolCall.output.length>0:!1,hasToolError:typeof((Pe=ge.toolCall)==null?void 0:Pe.error)=="string"?ge.toolCall.error.length>0:!1}}catch{return{parseError:!0,length:B.length}}}function ve(B){var ue;return{id:B.id,rawRef:B.rawRef,role:B.role,kind:B.kind,deliveryState:B.deliveryState,timestamp:B.timestamp,sequence:B.sequence,attachmentCount:((ue=B.attachments)==null?void 0:ue.length)??0,contentPreview:cs(B.content).text.replace(/\r\n/g,`
48
+ `).trimEnd().slice(0,120)}}function Se(B){return B.type==="message"?{type:B.type,key:B.key,message:ve(B.message)}:{type:B.type,key:B.key,callId:B.group.tool.callId,name:B.group.tool.name,hasRequest:B.group.hasRequest,hasResult:B.group.hasResult,updatedAt:B.group.updatedAt}}function ye(B,ue={}){const de=t[0]??null,Pe=t.at(-1)??null,ge=_e.at(-1)??null,Ut=se.current,kt=W.current,wt=B?B.scrollHeight-B.clientHeight-B.scrollTop:null;return{sessionId:e,historyState:n,followTailUpdates:m,messagesLength:t.length,renderItemsLength:_e.length,firstMessageId:(de==null?void 0:de.id)??null,firstMessageRole:(de==null?void 0:de.role)??null,lastMessageId:(Pe==null?void 0:Pe.id)??null,lastMessageRole:(Pe==null?void 0:Pe.role)??null,lastMessageKind:(Pe==null?void 0:Pe.kind)??null,lastMessageTimestamp:(Pe==null?void 0:Pe.timestamp)??null,tailItemType:(ge==null?void 0:ge.type)??null,tailToolCallId:ge&&ge.type==="tool_group"?ge.group.tool.callId:null,scrollTop:(B==null?void 0:B.scrollTop)??null,scrollHeight:(B==null?void 0:B.scrollHeight)??null,clientHeight:(B==null?void 0:B.clientHeight)??null,distanceToBottom:wt,stickToBottomRef:L.current,hasNewMessagesBelow:oe.current,previousMessageCount:V.current,previousLastMessage:re(U.current),tailMessages:t.slice(-5).map(ve),tailRenderItems:_e.slice(-5).map(Se),pendingRestoreState:Ut===null?null:{scrollTop:Ut.scrollTop,stickToBottom:Ut.stickToBottom,lastMessage:re(Ut.lastMessageSignature)},currentScrollState:kt===null?null:{scrollTop:kt.scrollTop,stickToBottom:kt.stickToBottom,lastMessage:re(kt.lastMessageSignature)},restoredTailMessage:re(Y.current),...ue}}function ze(B,ue,de={}){hc()&&ex(B,ye(ue,de))}function Ve(B){const de=B.scrollHeight-B.clientHeight-B.scrollTop<=Ah;return{scrollTop:B.scrollTop,stickToBottom:de,lastMessageSignature:oe.current&&!de?Y.current:Ws(t.at(-1)??null)}}function Je(B){return W.current=Ve(B),W.current}function j(B){const ue=B.scrollHeight-B.clientHeight-B.scrollTop,de=ue<=Ah;L.current=de,de&&oe.current&&(he(),oe.current=!1,Y.current=Ws(t.at(-1)??null),fe(!1)),ce(t.length>0&&(ue>Ph||oe.current)),Je(B),ze("affordance.sync",B,{distanceToBottom:ue,nextStickToBottom:de})}function $(B=P.current){G&&(B&&Je(B),W.current&&Rh(e,W.current))}function ie(B){G&&W.current&&Rh(B,W.current)}function me(){q.current!==null&&(window.clearTimeout(q.current),q.current=null)}function we(){G&&(me(),q.current=window.setTimeout(()=>{q.current=null,$()},nT))}function z(B,ue,de={}){ze("jump_to_bottom.before",B,{reason:ue,...de}),B.scrollTop=B.scrollHeight,ze("jump_to_bottom.after",B,{reason:ue,...de})}function J(){D.current!==null&&(window.clearTimeout(D.current),D.current=null)}function he(){J(),v.current=!1,K.current=null,ee.current=0,Ce.current=null}function ke(B,ue){const de=Math.max(0,B.scrollHeight-B.clientHeight),Pe=Math.max(0,Math.min(ue,de));Ce.current=Pe,B.scrollTop=Pe,L.current=!1,ze("manual_restore.apply",B,{targetScrollTop:ue,maxScrollableTop:de,nextScrollTop:Pe}),ce(t.length>0&&(de-Pe>Ph||oe.current))}function De(){J(),v.current&&(D.current=window.setTimeout(()=>{D.current=null;const B=P.current,ue=K.current;if(!B||ue===null){he();return}if(ke(B,ue),Date.now()<ee.current){De();return}he(),j(B)},sT))}function We(B,ue){if(Ge<=0){ke(ue,B),he();return}v.current=!0,K.current=B,ee.current=Date.now()+Ge,ke(ue,B),De()}function mt(){v.current&&(ze("manual_restore.interrupt",P.current),he())}function Ze(B){return _.current||!i||r||n!=="ready"||B.scrollTop>tT?!1:(_.current=!0,I.current=B.scrollHeight-B.scrollTop,H.current=Ws(t[0]??null),ze("older_history.prefetch",B,{pendingOlderLoadOffset:I.current,pendingOlderLoadHeadMessage:re(H.current)}),o(),!0)}f.useEffect(()=>{n==="error"&&A({title:l("conversation.historyLoadFailed"),tone:"error"})},[n,A]),f.useLayoutEffect(()=>{var B,ue;if(E.current!==e){const de=E.current;ie(de),E.current=e,V.current=0,U.current=null,se.current=m?null:Go(e),Y.current=((B=se.current)==null?void 0:B.lastMessageSignature)??null,W.current=se.current,L.current=m?!0:((ue=se.current)==null?void 0:ue.stickToBottom)??!0,I.current=null,H.current=null,he(),oe.current=!1,fe(!1),ce(!1),ze("session.switch",P.current,{previousSessionId:de,nextSessionId:e})}},[m,G,e]),f.useLayoutEffect(()=>()=>{me(),he(),ie(E.current)},[G,e]),f.useLayoutEffect(()=>{const B=P.current,ue=Ws(t.at(-1)??null);if(!B){V.current=t.length,U.current=ue;return}const de=V.current,Pe=U.current,ge=se.current,Ut=de===0||t.length!==de||ue!==Pe;if(ze("messages.effect.start",B,{previousCount:de,previousLastMessage:re(Pe),currentLastMessage:re(ue),hasTailUpdate:Ut}),ge&&n==="ready"){const hn=!ge.stickToBottom&&ge.lastMessageSignature!==null&&ue!==null&&ge.lastMessageSignature!==ue;ge.stickToBottom?(he(),z(B,"restore_ready_stick_to_bottom",{hasTailUpdates:hn})):(We(ge.scrollTop,B),ze("restore_ready.manual",B,{hasTailUpdates:hn,targetScrollTop:ge.scrollTop})),oe.current=hn,Y.current=ge.lastMessageSignature,fe(hn),se.current=null,j(B),V.current=t.length,U.current=ue,Je(B);return}if(ge&&n==="error"){ge.stickToBottom?(he(),z(B,"restore_error_stick_to_bottom")):(We(ge.scrollTop,B),ze("restore_error.manual",B,{targetScrollTop:ge.scrollTop})),se.current=null,j(B),V.current=t.length,U.current=ue,Je(B);return}if(v.current){ke(B,K.current??B.scrollTop),V.current=t.length,U.current=ue,Je(B);return}const kt=Ws(t[0]??null),wt=I.current,er=H.current,jt=wt!==null&&!r&&er!==null&&er!==kt&&t.length>=de,Ln=Ut&&(m||L.current);ze("messages.effect.decision",B,{currentHeadMessage:re(kt),pendingOlderLoadOffset:wt,pendingOlderLoadHeadMessage:re(er),shouldRestoreOlderLoadOffset:jt,shouldFollowTailUpdate:Ln,loadingOlderMessages:r}),jt?(B.scrollTop=Math.max(0,B.scrollHeight-wt),I.current=null,H.current=null):I.current!==null&&!r?(I.current=null,H.current=null,Ln&&z(B,"older_load_offset_cleared_follow_tail",{pendingOlderLoadOffset:wt})):Ln&&z(B,"tail_update_follow"),j(B),V.current=t.length,U.current=ue},[n,r,t,e]),f.useEffect(()=>{if(!i){_.current=!1;return}!r&&I.current===null&&(_.current=!1)},[i,r,t.length]),f.useEffect(()=>{const B=P.current;if(!hc()||!B||typeof ResizeObserver>"u")return;const ue=new ResizeObserver(()=>{ze("list.resize",B)});return ue.observe(B),()=>{ue.disconnect()}},[t.length,e]);function ht(){const B=P.current;if(B){if(v.current){const ue=Ce.current;ue!==null&&Math.abs(B.scrollTop-ue)<=1?Ce.current=null:mt()}j(B),we(),ze("scroll",B),Ze(B)}}function lt(B){if(B.deltaY!==0&&mt(),B.deltaY>=0)return;const ue=P.current;ue&&Ze(ue)}function Ye(B){var ue;mt(),je.current=((ue=B.touches[0])==null?void 0:ue.clientY)??null}function et(B){var ge;const ue=je.current,de=((ge=B.touches[0])==null?void 0:ge.clientY)??null;if(ue===null||de===null||de-ue<rT)return;mt();const Pe=P.current;Pe&&Ze(Pe)}function bt(){je.current=null}return s.jsxs("section",{className:"message-timeline",children:[n==="loading"&&s.jsx("div",{className:"timeline-status",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoading")})}),s.jsxs("div",{ref:P,className:"message-list","data-scrollbar-autohide":"true",onScroll:ht,onPointerDown:mt,onWheel:lt,onTouchStart:Ye,onTouchMove:et,onTouchEnd:bt,onTouchCancel:bt,children:[F?s.jsx(GT,{}):null,r?s.jsx("div",{className:"timeline-status timeline-status-inline",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoadingOlder")})}):null,_e.length===0&&n==="ready"&&s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}),_e.map(B=>B.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(Dg,{group:B.group})},B.key):s.jsx(Bg,{message:B.message,provider:u,foldedPromptKind:Ke.has(B.message.id)?"system_prompt":null,actionState:ft.get(B.message.id)??{canCopy:B.message.role==="user",canFork:!1},onRetry:a,onForkMessage:c,interruptedSource:d,assistantAvatar:p,onSubmitStructuredQuestion:y},B.key)),h?s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":h,children:[s.jsx("span",{children:Cg(h)||h}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null,te?s.jsxs("section",{className:"session-runtime-error-panel",role:"status","aria-label":te.title,children:[s.jsxs("div",{className:"session-runtime-error-panel__header",children:[s.jsx("span",{className:"session-runtime-error-panel__dot","aria-hidden":"true"}),s.jsx("strong",{children:te.title})]}),s.jsx("p",{className:"session-runtime-error-panel__summary",children:te.summary}),te.code?s.jsxs("div",{className:"session-runtime-error-panel__meta",children:[s.jsx("span",{className:"session-runtime-error-panel__label",children:l("conversation.runtimeErrorCodeLabel")}),s.jsx("code",{children:te.code})]}):null,te.detail?s.jsxs("div",{className:"session-runtime-error-panel__detail",children:[s.jsx("span",{className:"session-runtime-error-panel__label",children:l("conversation.runtimeErrorDetailLabel")}),s.jsx("pre",{children:te.detail})]}):null]}):null]}),N?s.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":Ie?"true":"false","aria-label":l("conversation.scrollToBottomAction"),title:l("conversation.scrollToBottomAction"),onClick:()=>{const B=P.current;B&&(he(),z(B,"scroll_button_click"),oe.current=!1,Y.current=Ws(t.at(-1)??null),fe(!1),j(B),$(B))},children:[Ie?s.jsx("span",{className:"conversation-scroll-to-bottom-button-badge",children:"NEW"}):null,s.jsx("svg",{className:"conversation-scroll-to-bottom-button-icon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M10 4.25a.75.75 0 0 1 .75.75v7.19l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V5a.75.75 0 0 1 .75-.75Zm-4 11a.75.75 0 0 1 0-1.5h8a.75.75 0 0 1 0 1.5H6Z",fill:"currentColor"})})]}):null]})}function Ws(e){return e?JSON.stringify({id:e.id,content:e.content,attachments:e.attachments,timestamp:e.timestamp,deliveryState:e.deliveryState,toolCall:e.toolCall?{status:e.toolCall.status,output:e.toolCall.output,error:e.toolCall.error}:null}):null}function oI(e){const t=new Map;let n=0;function r(i){let o=null;for(let a=i-1;a>=n;a-=1){const c=e[a];if(!(!c||!aI(c))){o=c.id;break}}for(let a=n;a<i;a+=1){const c=e[a];if(c){if(c.role==="user"){t.set(c.id,{canCopy:!0,canFork:!1});continue}t.set(c.id,{canCopy:c.id===o,canFork:c.id===o})}}}for(let i=0;i<e.length;i+=1){const o=e[i];o&&o.role==="user"&&i>n&&(r(i),n=i)}return r(e.length),t}function aI(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function lI(e){return zu(e)!==null}function cI(e){return e.isSubagent===!0&&!lI(e)}function zu(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 uI(e){const t=zu(e);return t==="reconstructed"?l("shell.sessionForkReconstructed"):t==="message"?l("shell.sessionForkMessage"):t==="session"?l("shell.sessionForkSession"):null}function dI(e){return e.sessionKind==="annotation"?"annotation":null}function DP(e){return dI(e)==="annotation"?l("conversation.actionSessionBadge"):null}const hI=3*1e3,Pc=120*1e3,pI=8,fI=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,mI=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/;function _P(e){return{session:(e==null?void 0:e.session)??null,capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:(e==null?void 0:e.messages)??[],permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],historyState:"idle",loadingOlderMessages:!1,olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,connectionState:"closed",lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0,interruptSource:(e==null?void 0:e.interruptSource)??null,errorCode:null,errorDetail:null}}function Hu(e,t,n="sent",r=null){const i=t.kind??(t.role==="tool"?"tool_result":"text"),o=t.toolCall??(i==="tool_call"||i==="tool_result"?{callId:t.rawRef||t.messageId,name:"tool",input:i==="tool_call"?t.content:"",output:i==="tool_result"&&t.content?t.content:null,error:null,status:i==="tool_call"?"running":"completed"}:null);return{id:t.messageId,sessionId:e,role:t.role,kind:i,content:zI(t.provider,t.role,i,t.content),toolCall:o,attachments:t.attachments??[],attachmentPayloads:null,origin:t.origin??null,originRef:t.originRef??null,timestamp:t.timestamp,sequence:t.sequence,rawRef:t.rawRef,deliveryState:n,clientRequestId:r}}function BP(e,t,n,r=[],i=[],o=Number.MAX_SAFE_INTEGER){return{id:`pending-${n}`,sessionId:e,role:"user",kind:"text",content:t,toolCall:null,attachments:r,attachmentPayloads:i,origin:null,originRef:null,timestamp:new Date().toISOString(),sequence:o,rawRef:`pending://${n}`,deliveryState:"sending",clientRequestId:n}}function OP(e,t){return Uu([...e,t])}function WP(e,t,n){const r=new Map,i=new Set,o=[];for(const a of e)r.set(a.id,a),i.add(a.id);for(const a of n){const c=Hu(t,a);o.push(c);const u=VI(r,c,t);if(u&&u!==c.id)continue;const d=GI(r,c,t);d&&d!==c.id&&r.delete(d);const h=KI(r,i,c);if(h&&h!==c.id){const g=r.get(h)??null;if(g){const x=Hh(g,c);dc("session.messages.codex_equivalent_replace",{sessionId:t,previous:Mr(g),incoming:Mr(c),merged:Mr(x)}),r.delete(h),r.set(a.messageId,x);continue}}const p=YI(r,c);if(p&&p!==c.id){const g=r.get(p)??null;if(g){const x=RI(g,c);dc("session.messages.opencode_equivalent_replace",{sessionId:t,previous:Mr(g),incoming:Mr(c),merged:Mr(x)}),r.set(p,x);continue}}const m=r.get(a.messageId)??null;r.set(a.messageId,m?Hh(m,c):c)}return Uu(XI(Array.from(r.values()),o))}function FP(e,t,n,r){const i=r===null?null:e.find(u=>u.clientRequestId===r)??null,o=e.filter(u=>u.clientRequestId!==r),a=Hu(t,n,"sent",r),c=MI(a,i);return Uu([...o.filter(u=>u.id!==c.id),c])}function $P(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function gI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!AI(r,n)){t.push(n);continue}t[t.length-1]=_I(r,n)}return t}function bI(e){const t=[];let n=null,r=!1;for(const i of e)if(!PI(n,i,r)){if(t.push(i),no(i)){n=i,r=!1;continue}n&&LI(i)&&(r=!0)}return t}function kI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Fg(r,n)){t.push(n);continue}t[t.length-1]=$g(r,n)}return t}function xI(e){const t=[];for(const n of e){if(t.push(n),t.length<4)continue;const r=t[t.length-4],i=t[t.length-3],o=t[t.length-2],a=t[t.length-1];DI(r,i,o,a)&&t.splice(t.length-3,3,$g(i,a))}return t}function yI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!BI(r,n)){t.push(n);continue}t[t.length-1]=WI(r,n)}return t}function wI(e){const t=[];for(const n of e){const r=t.findIndex(i=>OI(i,n));if(r===-1){t.push(n);continue}t[r]=FI(t[r],n)}return t}function Uu(e){const t=[...e].sort((n,r)=>Og(n,r));return wI(yI(bI(xI(kI(gI(t))))))}function Og(e,t){if(e.sequence!==t.sequence)return e.sequence-t.sequence;const n=vI(e.rawRef,t.rawRef);if(n!==0)return n;const r=e.timestamp.localeCompare(t.timestamp);if(r!==0)return r;const i=SI(e.rawRef,t.rawRef);if(i!==0)return i;const o=EI(e.role,t.role);if(o!==0)return o;const a=e.rawRef.localeCompare(t.rawRef);return a!==0?a:e.id.localeCompare(t.id)}function vI(e,t){const n=II(e,t);if(n!==null&&n!==0)return n;const r=CI(e,t);if(r!==null&&r!==0)return r;const i=$h(e),o=$h(t);if(!i&&!o||!i||!o)return 0;const a=Math.max(i.length,o.length);for(let c=0;c<a;c+=1){const u=i[c],d=o[c];if(u===void 0&&d===void 0)return 0;if(u===void 0)return-1;if(d===void 0)return 1;if(u!==d)return u-d}return 0}function SI(e,t){const n=Lc(e),r=Lc(t);return n===null&&r===null?0:n===null?1:r===null?-1:n-r}function Lc(e){const t=e.match(/(?:^|[?#&])line=(\d+)(?:$|[&#])/);if(!t)return null;const n=Number.parseInt(t[1]??"",10);return Number.isFinite(n)?n:null}function CI(e,t){const n=Fh(e),r=Fh(t);if(!n||!r||n!==r)return null;const i=to(e,"part"),o=to(t,"part");return i===null||o===null?null:i-o}function Fh(e){const t=e.match(/^(.+\/message\/[^/?#]+)\/part\/[^/?#]+(?:[?#].*)?$/i);return(t==null?void 0:t[1])??null}function $h(e){const t=Lc(e);if(t!==null){const i=to(e,"part");return i===null?[t]:[t,i]}const n=NI(e);if(n)return n;const r=jI(e);return r||null}function NI(e){const t=to(e,"index");if(t===null)return null;const n=to(e,"part");return n===null?[t]:[t,n]}function to(e,t){const n=e.match(new RegExp(`(?:^|[?#&])${t}=(\\d+)(?:$|[&#])`));if(!n)return null;const r=Number.parseInt(n[1]??"",10);return Number.isFinite(r)?r:null}function jI(e){const t=e.match(/\/message\/(user|assistant|tool)-(\d+)\/part\/([a-z_]+)-(\d+)/i);if(!t)return null;const n=TI(t[1]??""),r=Number.parseInt(t[2]??"",10),i=Wi(t[3]??""),o=Number.parseInt(t[4]??"",10);return!Number.isFinite(r)||!Number.isFinite(o)?null:[r,n,i,o]}function TI(e){switch(e.toLowerCase()){case"user":return 0;case"assistant":return 1;case"tool":return 2;default:return 3}}function Wi(e){switch(e.toLowerCase()){case"reasoning":case"thinking":return 0;case"text":return 1;case"tool":case"tool_call":case"tool_result":return 2;default:return 3}}function II(e,t){const n="claude-code://message/";if(!e.startsWith(n)||!t.startsWith(n))return null;let r="",i="";try{r=decodeURIComponent(e.slice(n.length)),i=decodeURIComponent(t.slice(n.length))}catch{return null}const o=r.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i),a=i.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i);if(o&&a){const C=o[1]??"",y=a[1]??"",A=o[2]??"",T=a[2]??"";return C!==y||A!==T?0:Wi(o[3]??"")-Wi(a[3]??"")}const c=r.match(/^message:(assistant|user):([^:]+):part:(\d+):type:([a-z_]+)$/i),u=i.match(/^message:(assistant|user):([^:]+):part:(\d+):type:([a-z_]+)$/i);if(!c||!u)return null;const d=c[1]??"",h=u[1]??"",p=c[2]??"",m=u[2]??"";if(d!==h||p!==m)return 0;const g=Number.parseInt(c[3]??"",10),x=Number.parseInt(u[3]??"",10);if(!Number.isFinite(g)||!Number.isFinite(x))return null;const S=g-x;return S!==0?S:Wi(c[4]??"")-Wi(u[4]??"")}function EI(e,t){return zh(e)-zh(t)}function zh(e){switch(e){case"user":return 0;case"assistant":return 1;case"tool":return 2;case"system":default:return 3}}function MI(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function Hh(e,t){if(e.id!==t.id)return t;if(e.role!==t.role||e.kind!==t.kind)return Lr(e,t);const n=_c(e.toolCall,t.toolCall),r=Bc(e.content,t.content,e.timestamp,t.timestamp),i=Oc(e.attachments,t.attachments),o=Wc(e,t);return{...Lr(e,t),content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence}}function RI(e,t){if(qg(e,t)){const a=_c(e.toolCall,t.toolCall),c=Bc(e.content,t.content,e.timestamp,t.timestamp),u=Oc(e.attachments,t.attachments),d=Wc(e,t);return{...Lr(e,t),id:e.id,kind:(a==null?void 0:a.status)==="running"?"tool_call":"tool_result",content:c,toolCall:a,attachments:u,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:d.rawRef,timestamp:d.timestamp,sequence:d.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}if(e.role!==t.role||e.kind!==t.kind)return{...Lr(e,t),id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId};const n=_c(e.toolCall,t.toolCall),r=Bc(e.content,t.content,e.timestamp,t.timestamp),i=Oc(e.attachments,t.attachments),o=Wc(e,t);return{...Lr(e,t),id:e.id,content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function AI(e,t){return Wg(e,t,hI)}function Wg(e,t,n){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const r=cs(e.content),i=cs(t.content);return hs(e.timestamp,t.timestamp,n)&&at(r.text)===at(i.text)&&qI(r.inlineImages,i.inlineImages)}function PI(e,t,n){return!e||n||!no(e)||!no(t)?!1:hs(e.timestamp,t.timestamp,120*1e3)&&at(e.content)===at(t.content)}function no(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function Dc(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")}function LI(e){return Dc(e)&&e.kind==="text"}function Fg(e,t){return Dc(e)&&Dc(t)&&e.kind===t.kind&&hs(e.timestamp,t.timestamp,120*1e3)&&at(e.content)===at(t.content)}function DI(e,t,n,r){return!e||!t||!n||!r||!no(e)||!no(n)?!1:Fg(t,r)&&hs(e.timestamp,n.timestamp,120*1e3)&&at(e.content)===at(n.content)}function $g(e,t){var a,c;const n=((a=e.attachments)==null?void 0:a.length)??0,r=((c=t.attachments)==null?void 0:c.length)??0;if(n!==r)return n>r?e:t;const i=at(e.content).length,o=at(t.content).length;return i!==o?i>o?e:t:Lr(e,t)}function _I(e,t){var h,p;const n=((h=e.attachments)==null?void 0:h.length)??0,r=((p=t.attachments)==null?void 0:p.length)??0;if(n!==r)return n>r?e:t;const i=cs(e.content).inlineImages.length,o=cs(t.content).inlineImages.length;if(i!==o)return i>o?e:t;const a=e.content!==at(e.content),c=t.content!==at(t.content);if(a!==c)return a?t:e;const u=ro(e.content),d=ro(t.content);return u!==d?u?t:e:t}function BI(e,t){return!Uh(e)||!Uh(t)?!1:e.role===t.role&&hs(e.timestamp,t.timestamp,120*1e3)&&at(e.content)===at(t.content)}function OI(e,t){return!qh(e)||!qh(t)?!1:e.role===t.role&&hs(e.timestamp,t.timestamp,120*1e3)&&at(e.content)===at(t.content)}function Uh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function qh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function WI(e,t){var u,d;const n=((u=e.attachments)==null?void 0:u.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const i=at(e.content).length,o=at(t.content).length;if(i!==o)return i>o?e:t;const a=e.rawRef.includes("#file="),c=t.rawRef.includes("#file=");return a!==c?a?e:t:Lr(e,t)}function FI(e,t){var u,d;const n=((u=e.attachments)==null?void 0:u.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const i=at(e.content).length,o=at(t.content).length;if(i!==o)return i>o?e:t;const a=e.rawRef.includes("/context#"),c=t.rawRef.includes("/context#");return a!==c?a?e:t:Lr(e,t)}function _c(e,t){return e?t?{...$I(e,t),input:zg(e.input,t.input),output:Vh(e.output,t.output),error:Vh(e.error,t.error)}:e:t}function $I(e,t){const n=Gh(e.status),r=Gh(t.status);return r!==n?r>n?t:e:t}function Gh(e){return e==="running"?0:1}function Bc(e,t,n,r){const i=at(e),o=at(t);if(i===o){const a=UI(e,t);return a!==null?a:e.length>=t.length?e:t}return i.length>o.length&&i.includes(o)?e:o.length>i.length&&o.includes(i)||r.localeCompare(n)>=0?t:e}function Oc(e,t){const n=(e==null?void 0:e.length)??0,r=(t==null?void 0:t.length)??0;return r!==n?r>n?t:e:t??e}function zg(e,t){return t.length>e.length?t:e}function Vh(e,t){return e===null?t:t===null?e:zg(e,t)}function Lr(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function Wc(e,t){return Og(e,t)<=0?e:t}function at(e){return HI(e).replace(/\r\n/g,`
49
+ `).trimEnd()}function Fc(e){return at(e).replace(/[ \t]+\n/g,`
50
+ `).replace(/\n{2,}/g,`
51
+ `).trim()}function zI(e,t,n,r){return e!=="claude-code"&&e!=="codex"||t!=="user"&&t!=="assistant"||n!=="text"&&n!=="thinking"?r:Hg(r)}function HI(e){return Hg(e).replace(/\r\n/g,`
52
+ `).trimEnd()}function ro(e){return mI.test(e)}function Hg(e){return ro(e)?e.replace(fI,"").replace(/[ \t]+\n/g,`
53
+ `).replace(/\n{3,}/g,`
54
+
55
+ `).trimEnd():e}function UI(e,t){const n=ro(e),r=ro(t);return n===r?null:n?t:e}function qI(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((n,r)=>{var i;return n.url===((i=t[r])==null?void 0:i.url)})}function GI(e,t,n){return Gg(t)?Ug(e,t,"optimistic",n):null}function VI(e,t,n){return Ya(t)?Ug(e,t,"authoritative",n):null}function KI(e,t,n){if(!Pa(n))return null;const r=Jn(n.timestamp);let i=null,o=Number.POSITIVE_INFINITY;for(const[a,c]of e.entries()){if(a===n.id||!t.has(a)||!JI(c,n))continue;const u=Jn(c.timestamp),d=Math.abs(u-r),p=Math.abs(c.sequence-n.sequence)*Pc+d;p<o&&(i=a,o=p)}return i}function YI(e,t){if(!Kh(t))return null;const n=La(t.rawRef);if(n===null)return null;const r=Jn(t.timestamp);let i=null,o=Number.POSITIVE_INFINITY;for(const[a,c]of e.entries()){if(a===t.id||!Kh(c)||c.role!==t.role)continue;if(qg(c,t))return a;if(c.kind!==t.kind||La(c.rawRef)!==n)continue;const d=Jn(c.timestamp),h=Math.abs(d-r),m=Math.abs(c.sequence-t.sequence)*6e4+h;m<o&&(i=a,o=m)}return i}function Ug(e,t,n,r){const i=Jn(t.timestamp),o=at(t.content),a=Fc(t.content),c=$c(t.attachments);let u=null,d=Number.POSITIVE_INFINITY;const h=[];for(const[p,m]of e.entries()){if(!(n==="optimistic"?Ya(m):Gg(m)))continue;const x=at(m.content),S=Fc(m.content),C=x===o,y=S===a;if(!C&&!y)continue;const A=Jn(m.timestamp),T=Math.abs(A-i);if(T>300*1e3)continue;const G=Math.abs(m.sequence-t.sequence),P=$c(m.attachments),E=eE(P,c);if(E==="conflict"&&(C||o.length===0)){h.push(Xh(m,{strictTextMatches:C,relaxedTextMatches:y,attachmentCompatibility:E,distanceMs:T,sequenceDistance:G}));continue}const V=T+G*15e3+(C?0:500)+tE(E);h.push(Xh(m,{strictTextMatches:C,relaxedTextMatches:y,attachmentCompatibility:E,distanceMs:T,sequenceDistance:G})),V<d&&(u=p,d=V)}return h.length>0&&dc("session.messages.user_match",{sessionId:r,target:n,matchedId:u,matchedScore:Number.isFinite(d)?d:null,incoming:nE(t,{relaxedContent:a,attachmentSignature:c}),candidates:h.slice(0,5)}),u}function Pa(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.role==="assistant"||e.role==="tool")}function XI(e,t){const n=t.filter(Pa);return n.length===0?e:e.map(r=>{if(!ZI(r))return r;const i=Jn(r.timestamp),o=n.reduce((a,c)=>Jn(c.timestamp)<i?a:Math.min(a,c.sequence),Number.POSITIVE_INFINITY);return!Number.isFinite(o)||o>=r.sequence?r:{...r,sequence:o}})}function Kh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&!Ya(e)&&(e.role==="user"||e.role==="assistant"||e.role==="tool")}function Yh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")&&e.toolCall!==null}function qg(e,t){var i,o;if(!Yh(e)||!Yh(t))return!1;const n=((i=e.toolCall)==null?void 0:i.callId.trim())??"",r=((o=t.toolCall)==null?void 0:o.callId.trim())??"";return n&&r?n===r:La(e.rawRef)===La(t.rawRef)}function La(e){if(!e.startsWith("opencode://"))return null;const t=e.indexOf("#"),n=t>=0?e.slice(t):"",r=t>=0?e.slice(0,t):e,i=r.indexOf("?");if(i<0)return e;const o=r.slice(0,i),a=new URLSearchParams(r.slice(i+1));if(!a.has("part"))return e;a.delete("part");const c=a.toString();return`${o}${c?`?${c}`:""}${n}`}function JI(e,t){return!Pa(e)||!Pa(t)||e.role!==t.role||e.kind!==t.kind||Math.abs(e.sequence-t.sequence)>pI||!hs(e.timestamp,t.timestamp,Pc)?!1:t.kind==="text"||t.kind==="thinking"?Wg(e,t,Pc):t.kind==="tool_call"||t.kind==="tool_result"?QI(e,t):!1}function QI(e,t){return e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!=="tool"||t.role!=="tool"||e.kind!==t.kind||e.toolCall===null||t.toolCall===null?!1:e.toolCall.callId===t.toolCall.callId}function Ya(e){return e.role!=="user"||e.kind!=="text"||e.deliveryState==="failed"?!1:e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic")}function ZI(e){return e.deliveryState==="sent"&&e.role==="user"&&e.kind==="text"&&e.rawRef.startsWith("synthetic://codex/")}function Gg(e){return e.role==="user"&&e.kind==="text"&&!Ya(e)}function Jn(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function Mr(e){var t;return{id:e.id,rawRef:e.rawRef,role:e.role,kind:e.kind,sequence:e.sequence,timestamp:e.timestamp,callId:((t=e.toolCall)==null?void 0:t.callId)??null,contentPreview:e.kind==="text"||e.kind==="thinking"?at(cs(e.content).text).slice(0,160):at(e.content).slice(0,160)}}function $c(e){return(e??[]).map(t=>[t.kind,t.fileName.trim().toLowerCase(),t.mimeType.trim().toLowerCase(),String(t.fileSize)].join(":")).sort().join("|")}function eE(e,t){return!e&&!t?"same":!e||!t?"one_side_missing":e===t?"same":"conflict"}function tE(e){switch(e){case"same":return 0;case"one_side_missing":return 2500;case"conflict":default:return 12e4}}function Xh(e,t){return{...Mr(e),comparableContent:Fc(e.content).slice(0,160),attachmentSignature:$c(e.attachments),strictTextMatches:t.strictTextMatches,relaxedTextMatches:t.relaxedTextMatches,attachmentCompatibility:t.attachmentCompatibility,distanceMs:t.distanceMs,sequenceDistance:t.sequenceDistance}}function nE(e,t){return{...Mr(e),comparableContent:t.relaxedContent.slice(0,160),attachmentSignature:t.attachmentSignature}}function zP(e){return e.reduce((n,r)=>Number.isFinite(r.sequence)&&r.sequence>n?r.sequence:n,0)+1}function hs(e,t,n){return Math.abs(Jn(e)-Jn(t))<=n}const rE=200;async function sE(e){const t=[],n=new Set;let r=null;for(;!(r&&n.has(r));){r&&n.add(r);const i=await df(e,r,rE,"forward"),o=i.messages.map(a=>Hu(e,a));if(t.push(...o),!i.nextCursor||i.nextCursor===r||o.length===0)break;r=i.nextCursor}return{messages:t}}function Yl(e,t,n=new Date){return`${hE(e.title||l("conversation.titleFallback"))}-${dE(n)}.${t}`}function iE(e,t,n=new Date){const i=[`# ${(e.title||l("conversation.titleFallback")).trim()||l("conversation.titleFallback")}`,"",`${l("conversation.exportMarkdownSessionIdLabel")}:\`${e.sessionId}\``,`${l("conversation.exportMarkdownProviderLabel")}:${e.provider}`,`${l("conversation.exportMarkdownWorkspaceLabel")}:\`${e.workspaceId}\``,`${l("conversation.exportMarkdownCreatedAtLabel")}:${ni(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${ni(n.toISOString())}`,""];return t.forEach((o,a)=>{var c,u,d;i.push(`## ${a+1}. ${Vg(o)}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownTimeLabel")}:${ni(o.timestamp)}`),i.push(`- ${l("conversation.exportMarkdownTypeLabel")}:${uE(o)}`),(((c=o.attachments)==null?void 0:c.length)??0)>0&&i.push(`- ${l("conversation.exportMarkdownAttachmentsLabel")}:${o.attachments.length}`),i.push(""),o.content.trim()&&(i.push(o.content),i.push("")),o.toolCall&&(i.push(`### ${l("conversation.exportMarkdownToolSectionTitle")}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownToolNameLabel")}:${o.toolCall.name}`),i.push(`- ${l("conversation.exportMarkdownToolStatusLabel")}:${o.toolCall.status}`),i.push(""),o.toolCall.input.trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolInputLabel")}`),i.push(""),i.push("```text"),i.push(o.toolCall.input),i.push("```"),i.push("")),(o.toolCall.output??"").trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolOutputLabel")}`),i.push(""),i.push("```text"),i.push(o.toolCall.output??""),i.push("```"),i.push("")),(o.toolCall.error??"").trim()&&(i.push(`#### ${l("conversation.exportMarkdownToolErrorLabel")}`),i.push(""),i.push("```text"),i.push(o.toolCall.error??""),i.push("```"),i.push(""))),(((u=o.attachments)==null?void 0:u.length)??0)>0&&(i.push(`### ${l("conversation.exportMarkdownAttachmentsSectionTitle")}`),i.push(""),(d=o.attachments)==null||d.forEach(h=>{i.push(`- ${h.fileName} (${h.kind}, ${h.mimeType}, ${Kg(h.fileSize)})`)}),i.push(""))}),`${i.join(`
56
+ `).trimEnd()}
57
+ `}function Jh(e,t,n="text/plain;charset=utf-8"){if(typeof document>"u")throw new Error(l("conversation.exportDownloadFailed"));const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.append(o),o.click(),o.remove(),URL.revokeObjectURL(i)}function oE(e,t,n="application/octet-stream"){if(typeof document>"u")throw new Error(l("conversation.exportDownloadFailed"));const r=new Uint8Array(t.byteLength);r.set(t);const i=new Blob([r],{type:n}),o=URL.createObjectURL(i),a=document.createElement("a");a.href=o,a.download=e,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(o)}function aE(e,t,n=new Date){const r=(e.title||l("conversation.titleFallback")).trim()||l("conversation.titleFallback"),i=[`${l("conversation.exportMarkdownSessionIdLabel")}:${e.sessionId}`,`${l("conversation.exportMarkdownProviderLabel")}:${e.provider}`,`${l("conversation.exportMarkdownWorkspaceLabel")}:${e.workspaceId}`,`${l("conversation.exportMarkdownCreatedAtLabel")}:${ni(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${ni(n.toISOString())}`],o=new gE;return o.renderDocumentHeader(r,i),t.forEach((a,c)=>{o.renderMessageCard(c,a)}),jE(o.finish())}function lE(e){const t=Qh(e.htmlAttributes,e.htmlStyle),n=Qh(e.bodyAttributes,e.bodyStyle);return["<!DOCTYPE html>",`<html${t}>`,"<head>",'<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${Yg(e.title)}</title>`,`<style>${e.styleText}</style>`,"</head>",`<body${n}>`,e.bodyHtml,"</body>","</html>"].join("")}function Vg(e){return`${cE(e)} · ${ni(e.timestamp)}`}function cE(e){switch(e.role){case"user":return l("conversation.roleUser");case"assistant":return l("conversation.roleAssistant");case"tool":return l("conversation.roleTool");case"system":default:return l("conversation.roleSystem")}}function uE(e){return e.kind==="thinking"?l("conversation.thinkingLabel"):e.kind==="tool_call"?l("conversation.exportMarkdownToolCallType"):e.kind==="tool_result"?l("conversation.exportMarkdownToolResultType"):l("conversation.exportMarkdownTextType")}function ni(e){const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function dE(e){const t=String(e.getFullYear()),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`${t}${n}${r}-${i}${o}${a}`}function Kg(e){return!Number.isFinite(e)||e<0?l("conversation.exportMarkdownUnknownSize"):e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function hE(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-")||"session"}function Qh(e,t){const n=Object.entries(e??{}).filter(([,r])=>r.trim().length>0);return t!=null&&t.trim()&&n.push(["style",t.trim()]),n.length===0?"":` ${n.map(([r,i])=>`${r}="${pE(i)}"`).join(" ")}`}function Yg(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function pE(e){return Yg(e).replaceAll('"',"&quot;")}const Xg=595.28,Fi=841.89,Zh=40,ep=40,qs=36,Jg=Xg-qs*2,fE=14,zc=12,Yo=12,mE=72,Xo=11,Js=9,Li=12,tp=20;class gE{constructor(){Ue(this,"pages",[[]]);Ue(this,"cursorTop",Zh)}renderDocumentHeader(t,n){this.drawRichText(t,qs,this.cursorTop,tp,[15,23,42],"sans"),this.cursorTop+=tp+8,n.forEach(r=>{this.drawRichText(r,qs,this.cursorTop,Js,[71,85,105],"sans"),this.cursorTop+=Ir(Js)}),this.cursorTop+=18}renderMessageCard(t,n){const r=bE(t,n);let i=0,o=0;for(;i<r.lines.length||o===0;){this.ensureVerticalSpace(mE);const a=this.pickSegmentLines(r.lines,i);a.count===0&&r.lines.length>0&&(a.lines.push(r.lines[i]),a.count=1,a.height=Ir(r.lines[i].fontSize));const c=o===0?r.header:`${r.header} · 续`,u=Yo*2+Ir(Li)+8+Math.max(a.height,0);if(this.ensureVerticalSpace(u),this.drawCardSegment(r,c,a.lines,a.height),this.cursorTop+=u+fE,i+=a.count,o+=1,r.lines.length===0)break}}finish(){return this.pages.map(t=>t.join(`
58
+ `))}drawCardSegment(t,n,r,i){const o=Yo*2+Ir(Li)+8+Math.max(i,0),a=this.cursorTop,c=Fi-a-o;this.pushCommand(`${Jo(t.backgroundColor)} rg ${Jo(t.borderColor)} RG 1 w ${cn(qs)} ${cn(c)} ${cn(Jg)} ${cn(o)} re B`);let u=a+Yo;this.drawRichText(n,qs+zc,u,Li,t.headerColor,"sans"),u+=Ir(Li)+8,r.forEach(d=>{u+=d.gapBefore,this.drawRichText(d.text,qs+zc,u,d.fontSize,d.color,d.fontKind),u+=Ir(d.fontSize)})}pickSegmentLines(t,n){const r={lines:[],count:0,height:0},i=Fi-this.cursorTop-ep-Yo*2-Ir(Li)-8;if(i<=0)return r;let o=0;for(let a=n;a<t.length;a+=1){const c=t[a],u=o+c.gapBefore+Ir(c.fontSize);if(r.count>0&&u>i)break;r.lines.push(c),r.count+=1,o=u}return r.height=o,r}ensureVerticalSpace(t){this.cursorTop+t<=Fi-ep||(this.pages.push([]),this.cursorTop=Zh)}drawRichText(t,n,r,i,o,a){const c=Fi-r-i;let u=n;wE(t).forEach(h=>{if(h.text){if(h.fontRef==="F1"){u=this.drawPdfUnicodeRun(h.text,u,c,i,o);return}this.pushCommand(`BT /${h.fontRef} ${cn(i)} Tf ${Jo(o)} rg 1 0 0 1 ${cn(u)} ${cn(c)} Tm (${NE(h.text)}) Tj ET`),u+=SE(h.text,i,h.fontRef)}})}drawPdfUnicodeRun(t,n,r,i,o){let a=n;for(const c of Array.from(t))this.pushCommand(`BT /F1 ${cn(i)} Tf ${Jo(o)} rg 1 0 0 1 ${cn(a)} ${cn(r)} Tm <${yE(c)}> Tj ET`),a+=qu(c,i,"F1");return a}pushCommand(t){var n;(n=this.pages[this.pages.length-1])==null||n.push(t)}}function bE(e,t){var a,c;const n=kE(t.role),r=Jg-zc*2,i=[],o=`${e+1}. ${Vg(t)}`;if(t.content.trim()&&Tr(i,t.content,r,Xo,[15,23,42],0,"sans"),t.toolCall){const u=`${l("conversation.exportMarkdownToolSectionTitle")} · ${t.toolCall.name} · ${t.toolCall.status}`;Tr(i,u,r,Xo,[30,41,59],10,"sans"),t.toolCall.input.trim()&&Tr(i,`${l("conversation.exportMarkdownToolInputLabel")}:${t.toolCall.input}`,r,Js,[71,85,105],6,"mono"),(t.toolCall.output??"").trim()&&Tr(i,`${l("conversation.exportMarkdownToolOutputLabel")}:${t.toolCall.output??""}`,r,Js,[71,85,105],6,"mono"),(t.toolCall.error??"").trim()&&Tr(i,`${l("conversation.exportMarkdownToolErrorLabel")}:${t.toolCall.error??""}`,r,Js,[185,28,28],6,"mono")}return(((a=t.attachments)==null?void 0:a.length)??0)>0&&(Tr(i,l("conversation.exportMarkdownAttachmentsSectionTitle"),r,Xo,[30,41,59],10,"sans"),(c=t.attachments)==null||c.forEach(u=>{Tr(i,`- ${u.fileName} (${u.kind}, ${u.mimeType}, ${Kg(u.fileSize)})`,r,Js,[71,85,105],4,"sans")})),i.length===0&&Tr(i,l("conversation.exportMarkdownTextType"),r,Xo,[100,116,139],0,"sans"),{header:o,headerColor:n.headerColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,lines:i}}function kE(e){switch(e){case"user":return{headerColor:[30,64,175],backgroundColor:[239,246,255],borderColor:[191,219,254]};case"tool":return{headerColor:[6,95,70],backgroundColor:[236,253,245],borderColor:[167,243,208]};case"system":return{headerColor:[71,85,105],backgroundColor:[248,250,252],borderColor:[226,232,240]};case"assistant":default:return{headerColor:[15,23,42],backgroundColor:[255,255,255],borderColor:[226,232,240]}}}function Tr(e,t,n,r,i,o=0,a="sans"){t.replace(/\r\n/g,`
59
+ `).split(`
60
+ `).forEach((d,h)=>{const p=xE(d,n,r);if(p.length===0){e.push({text:" ",fontSize:r,color:i,gapBefore:h===0?o:4,fontKind:a});return}p.forEach((m,g)=>{e.push({text:m,fontSize:r,color:i,gapBefore:h===0&&g===0?o:g===0?4:0,fontKind:a})})})}function xE(e,t,n,r){if(!e.trim())return[];const i=[];let o="",a=0;const c=Qg();for(const u of Array.from(e)){const d=qu(u,n,c);if(o&&a+d>t){i.push(o.trimEnd()),o=u,a=d;continue}o+=u,a+=d}return o.trim().length>0&&i.push(o.trimEnd()),i}function qu(e,t,n){if(n==="F1")return t*(CE(e)/1e3);const r=n==="F3"?600:Zg[e]??556;return t*(r/1e3)}function Ir(e){return e*1.5}function Jo(e){return e.map(t=>cn(t/255)).join(" ")}function cn(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/u,"").replace(/\.$/u,"")}function yE(e){return[254,255,...Array.from(e).flatMap(r=>{const i=r.codePointAt(0)??32;if(i<=65535)return[i];const o=i-65536,a=55296+(o>>10&1023),c=56320+(o&1023);return[a,c]}).flatMap(r=>[r>>8&255,r&255])].map(r=>r.toString(16).padStart(2,"0").toUpperCase()).join("")}function wE(e,t){if(!e)return[];const n=Qg();return[{text:e,fontRef:n}]}function Qg(e,t){return"F1"}function vE(e){const t=e.codePointAt(0)??0;return t>=32&&t<=126}function SE(e,t,n){return Array.from(e).reduce((r,i)=>r+qu(i,t,n),0)}function CE(e){return vE(e)?Zg[e]??556:e===" "?278:1e3}function NE(e){return e.replace(/\\/gu,"\\\\").replace(/\(/gu,"\\(").replace(/\)/gu,"\\)")}const Zg={" ":278,"!":278,'"':355,"#":556,$:556,"%":889,"&":667,"'":191,"(":333,")":333,"*":389,"+":584,",":278,"-":333,".":278,"/":278,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,":":278,";":278,"<":584,"=":584,">":584,"?":556,"@":1015,A:667,B:667,C:722,D:722,E:667,F:611,G:778,H:722,I:278,J:500,K:667,L:556,M:833,N:722,O:778,P:667,Q:778,R:722,S:667,T:611,U:722,V:667,W:944,X:667,Y:667,Z:611,"[":278,"\\":278,"]":278,"^":469,_:556,"`":333,a:556,b:556,c:500,d:556,e:556,f:278,g:556,h:556,i:222,j:222,k:500,l:222,m:833,n:556,o:556,p:556,q:556,r:333,s:500,t:278,u:556,v:500,w:722,x:500,y:500,z:500,"{":334,"|":260,"}":334,"~":584};function jE(e){const t=[],n=[];t[1]="<< /Type /Catalog /Pages 2 0 R >>",t[3]="<< /Type /Font /Subtype /Type0 /BaseFont /STSong-Light /Encoding /UniGB-UCS2-H /DescendantFonts [4 0 R] >>",t[4]="<< /Type /Font /Subtype /CIDFontType0 /BaseFont /STSong-Light /CIDSystemInfo << /Registry (Adobe) /Ordering (GB1) /Supplement 4 >> /DW 1000 >>",t[5]="<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",t[6]="<< /Type /Font /Subtype /Type1 /BaseFont /Courier >>";let c=7;e.forEach(x=>{const S=c,C=c+1;n.push(S),c+=2;const y=new TextEncoder().encode(x);t[C]=`<< /Length ${y.length} >>
61
+ stream
62
+ ${x}
63
+ endstream`,t[S]=["<< /Type /Page","/Parent 2 0 R",`/MediaBox [0 0 ${cn(Xg)} ${cn(Fi)}]`,"/Resources << /Font << /F1 3 0 R /F2 5 0 R /F3 6 0 R >> >>",`/Contents ${C} 0 R`,">>"].join(" ")}),t[2]=`<< /Type /Pages /Kids [${n.map(x=>`${x} 0 R`).join(" ")}] /Count ${n.length} >>`;const u=t.filter(Boolean).length,d=[`%PDF-1.4
64
+ %----
65
+ `],h=[0];let p=new TextEncoder().encode(d[0]).length;for(let x=1;x<t.length;x+=1){const S=t[x];if(!S)continue;h[x]=p;const C=`${x} 0 obj
66
+ ${S}
67
+ endobj
68
+ `;d.push(C),p+=new TextEncoder().encode(C).length}const m=p,g=["xref",`0 ${u+1}`,"0000000000 65535 f "];for(let x=1;x<h.length;x+=1){const S=h[x];typeof S=="number"&&g.push(`${String(S).padStart(10,"0")} 00000 n `)}return d.push(`${g.join(`
69
+ `)}
70
+ `),d.push(["trailer",`<< /Size ${u+1} /Root 1 0 R >>`,"startxref",String(m),"%%EOF"].join(`
71
+ `)),new TextEncoder().encode(d.join(""))}const np=48;function TE(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Gu(e,t){const n=TE(e)||t,r=n.length>np?n.slice(0,np).trimEnd():n;return{fullTitle:n,displayTitle:r}}function Qo(e,t){return(t??"").localeCompare(e??"")}function rp(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Zo(e){return(e==null?void 0:e.trim())??""}function so(e,t,n){if(n==="updatedAt"){const a=Qo(e.updatedAt,t.updatedAt);if(a!==0)return a}if(n==="title"){const a=rp(Zo(e.title),Zo(t.title));if(a!==0)return a}else{const a=Qo(e.createdAt,t.createdAt);if(a!==0)return a}const r=Qo(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=Qo(e.createdAt,t.createdAt);if(i!==0)return i;const o=rp(Zo(e.title),Zo(t.title));return o!==0?o:e.sessionId.localeCompare(t.sessionId)}function po(e,t){return[...e].sort((n,r)=>so(n,r,t))}function Vu(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:po(n.sessions,t),children:Vu(n.children,t)})):[]}const Xl=5,Jl=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function IE(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function EE(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,Xl).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:Jl[u]??Jl[0]})),o=e.slice(Xl);if(o.length===0)return i;const a=o.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:a,ratio:a/n,color:Jl[Xl]}),i}function ME(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,i)=>{const o=t,a=i===e.length-1?1:Math.min(1,t+r.ratio);return t=a,`${r.color} ${sp(o)} ${sp(a)}`}).join(", ")})`}function RE(e){return{"--workbench-manage-chart-background":ME(e)}}function sp(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const AE=8,PE=12,LE=160,ip=96;function DE(e,t,n,r={}){const i=r.gapPx??AE,o=r.viewportMarginPx??PE,a=r.defaultWidthPx??LE,c=r.estimatedHeightPx??ip,u=r.minHeightPx??ip,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-o*2),m=Math.max(0,d-o*2),g=ea(Math.max(t.width||a,a),0,m),x=Math.max(t.height||c,c),S=Math.max(0,d-e.x-o),C=Math.max(0,e.x-o),y=S<g&&C>S,A=Math.max(0,h-e.y-i-o),T=Math.max(0,e.y-i-o),G=A<x&&T>A,E=ea(Math.max(G?T:A,u),0,p),V=Math.min(x,E),U=y?e.x-g:e.x,L=Math.max(o,d-o-g),I=G?e.y-i-V:e.y+i,H=Math.max(o,h-o-V),_=ea(U,o,L),se=ea(I,o,H),Y=y||_<e.x?"right":"left";return{top:se,left:_,width:g,maxHeight:Math.max(0,E),transformOrigin:`${G?"bottom":"top"} ${Y}`}}function ea(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const eb="workbench.navigation.snapshot",tb=1800*1e3,_E="workbench.navigation.snapshot.host.";function nb(e){return`${_E}${e}`}function BE(e=tb,t=Ba(Rn.getState())){if(t){const n=ya(nb(t),e);if(n)return n}return ya(eb,e)}function ta(e,t=Ba(Rn.getState())){Hi(eb,e),t&&Hi(nb(t),e)}function op(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:po(n.sessions,t),childWorktrees:OE(n.childWorktrees,t)}))}function OE(e,t){return Vu(e,t)}function Da(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 WE(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Da(n.workspace)),rb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function ir(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function rb(e,t,n,r,i=r.name){var o;for(const a of t){const c=((o=a.meta.displayName)==null?void 0:o.trim())||a.workspace.name;e.set(a.workspace.id,{workspaceId:a.workspace.id,tone:"worktree",backgroundColor:a.workspace.backgroundColor??null,displayName:c,workspaceName:a.workspace.name,branchName:a.meta.branchName||null,depth:a.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:a.meta.parentWorkspaceId||r.id,parentDisplayName:i}),rb(e,a.children,n,a.workspace,c)}}class Hc extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class FE{constructor(){Ue(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=Rn.getState();if(Ba(n)===t)return;const r=nk(n,t);if(!r)throw new Hc("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await rk(r.baseUrl)).reachable)throw new Hc("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const o=af(r.id);if(o)try{await Yi.loginForHost(r,{username:o.username,password:o.password})}catch{}const a=Rn.getState(),c=new Date().toISOString();if(lf(r)){Rn.updateRuntime({discoveredHosts:a.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}lc.setActiveDiscoveredHost(null),await Rn.update({hosts:a.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const $E=new FE,zE=1700;function HE({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:o,popoverRef:a,children:c,maxWidth:u=360,gap:d=10,viewportPadding:h=16}){const[p,m]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){m(null);return}let x=0;const S=()=>{const y=o.current;if(!y)return;const A=y.getBoundingClientRect(),T=Math.max(180,Math.min(u,window.innerWidth-h*2)),G=Math.min(Math.max(h,A.right-T),Math.max(h,window.innerWidth-h-T)),P=A.top>=Math.min(240,window.innerHeight*.42),E=Math.round(P?A.top-d:A.bottom+d);m({top:E,left:Math.round(G),width:T,placeAbove:P})},C=()=>{window.cancelAnimationFrame(x),x=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.cancelAnimationFrame(x),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[o,d,u,e,h]),!e||!p||typeof document>"u")return null;const g={position:"fixed",top:p.top,left:p.left,width:p.width,maxWidth:`calc(100vw - ${h*2}px)`,zIndex:zE,transform:p.placeAbove?"translateY(-100%)":void 0};return or.createPortal(s.jsx("div",{id:t,ref:a,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:g,children:c}),document.body)}const Ql={status:"idle",latencyMs:null};function sb({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[o,a]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,m]=f.useState(""),[g,x]=f.useState(null),[S,C]=f.useState(null),[y,A]=f.useState(null),[T,G]=f.useState(!1),[P,E]=f.useState(!1),[V,U]=f.useState(Ql),[L,I]=f.useState(null),H=f.useRef(null),_=f.useRef(null),se=f.useRef(null),Y=f.useRef(null),W=Qc(F=>F),q=Xc(F=>F.session),{showToast:D}=Pn(),K=cc(W),ee=Ba(W),v=fk(),Ce=sk(ee),je=f.useMemo(()=>ap(W.hosts,ee),[ee,W.hosts]),N=f.useMemo(()=>ap(cf(W),ee),[ee,W]),ce=f.useCallback(()=>{if(typeof window>"u")return;const F=H.current;if(!F)return;const te=F.getBoundingClientRect(),re=window.innerWidth,ve=window.innerHeight,Se=16,ye=8,Ve=Math.min(320,Math.max(240,re-Se*2)),Je=Math.min(e?Math.max(Se,te.right+ye):Math.max(Se,te.left),Math.max(Se,re-Ve-Se)),j=r?440:240,$=e?te.top:te.bottom+ye,ie=Math.min(Math.max(Se,$),Math.max(Se,ve-j-Se));I({position:"fixed",top:ie,left:Je,width:Ve,maxWidth:re-Se*2})},[e,r]);f.useEffect(()=>{if(!t){I(null),G(!1),U(Ql);return}lc.refresh();function F(re){var ve,Se,ye;re.target instanceof Node&&!((ve=H.current)!=null&&ve.contains(re.target))&&!((Se=_.current)!=null&&Se.contains(re.target))&&!((ye=Y.current)!=null&&ye.contains(re.target))&&(n(!1),i(!1),G(!1),A(null))}function te(re){re.key==="Escape"&&(n(!1),i(!1),G(!1),A(null))}return window.addEventListener("pointerdown",F),window.addEventListener("keydown",te),window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),ce(),()=>{window.removeEventListener("pointerdown",F),window.removeEventListener("keydown",te),window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[t,ce]),f.useEffect(()=>{if(!T||!t||(v==null?void 0:v.kind)!=="relay"){U(Ql);return}let F=!1;const te=performance.now();return U({status:"probing",latencyMs:null}),xe.request("/api/client/runtime-config").then(()=>{F||U({status:"ready",latencyMs:performance.now()-te})}).catch(()=>{F||U({status:"error",latencyMs:null})}),()=>{F=!0}},[v==null?void 0:v.kind,T,t]);async function Ie(F){if(g||S||F.id===ee){n(!1);return}x(F.id);try{await $E.switchHost(F.id),n(!1),i(!1),G(!1),A(null)}catch(te){D({title:KE(te,F.name),tone:"error"})}finally{x(null)}}async function fe(F){if(!(F.id===ee||g||S)){if(y!==F.id){A(F.id);return}C(F.id);try{await Rn.update({hosts:W.hosts.filter(te=>te.id!==F.id)}),ik(F.id),Yi.clearHostSession(F.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:F.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:F.name}),tone:"error"})}finally{C(null)}}}async function oe(){if(P)return;const F=o.trim(),te=d.trim();if((te.length>0||p.length>0)&&(!te||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let ve;try{ve=ok(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}E(!0);try{const Se=await $k(ve),ye=Rn.getState(),ze=cc(ye);if(Se?ye.hosts.find(ie=>{var me;return ie.baseUrl===ve||!!Se.bindingId&&((me=ie.relayTunnel)==null?void 0:me.bindingId)===Se.bindingId}):ye.hosts.find(ie=>ie.baseUrl===ve)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const Je=lf(ze)&&ze.baseUrl===ve;Je&&lc.setActiveDiscoveredHost(null);let j,$;if(Se){const me=(await Rn.update(zk(ye,Se,{activate:Je,displayName:F}))).hosts.find(we=>GE(we,ve,Se.bindingId??null));if(!me)throw new Error("relay entry host missing after save");j=me.id,$=me.name}else{const ie=new Date().toISOString(),me={id:VE(),name:F||UE(ve),baseUrl:ve,kind:qE(ve),createdAt:ie,updatedAt:ie,lastConnectedAt:null,lastUserId:null,lastUsername:null};await Rn.update({hosts:[...ye.hosts,me],activeHostId:Je?me.id:ye.activeHostId}),j=me.id,$=me.name}te&&p&&ak({hostId:j,username:te,password:p}),_e(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:$})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{E(!1)}}function _e(){a(""),u(""),h(""),m("")}if(!K)return null;const Ge=q!=null&&q.user.username?`${K.baseUrl} · ${q.user.username}`:K.baseUrl,Ke=(v==null?void 0:v.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),ft=v?l(mk(v.kind)):l("common.unknown");return s.jsxs("div",{ref:H,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[s.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:Ge,"aria-expanded":t,onClick:()=>{n(F=>!F),i(!1)},children:s.jsx(JE,{})}),t&&L&&typeof document<"u"?or.createPortal(s.jsxs("div",{ref:_,className:"workbench-host-switcher-menu",style:L,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[s.jsx("div",{className:"workbench-host-switcher-menu-header",children:s.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-list",children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),je.map(F=>{const te=F.id===ee,re=te?(q==null?void 0:q.user.username)??F.lastUsername??F.baseUrl:F.lastUsername??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":te,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ie(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,te?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:re})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):te?s.jsx(cp,{}):s.jsx(lp,{})})]}),te?s.jsx("button",{ref:se,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{G(ve=>!ve),A(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:F.name}),title:y===F.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":y===F.id,disabled:g!==null||S!==null,onClick:()=>{fe(F)},children:S===F.id?l("shell.hostDeleteBusy"):y===F.id?l("shell.hostDeleteConfirmAction"):s.jsx(ZE,{})})]},F.id)}),N.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(F=>{const te=F.id===ee,re=af(F.id),ve=te?(q==null?void 0:q.user.username)??(re==null?void 0:re.username)??F.baseUrl:(re==null?void 0:re.username)??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":te,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ie(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),te?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:ve})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):te?s.jsx(cp,{}):s.jsx(lp,{})})]}),te?s.jsx("button",{ref:se,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{G(Se=>!Se),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},F.id)})]}):null,W.localHostDiscovery.status==="refreshing"?s.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,W.localHostDiscovery.status==="failed"?s.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?s.jsxs("div",{className:"workbench-host-switcher-form",children:[s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),s.jsx("input",{value:o,disabled:P,onChange:F=>a(F.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),s.jsx("input",{value:c,disabled:P,onChange:F=>u(F.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.username")}),s.jsx("input",{value:d,disabled:P,onChange:F=>h(F.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.password")}),s.jsx("input",{type:"password",value:p,disabled:P,onChange:F=>m(F.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:P,onClick:()=>{i(!1),_e()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:P,onClick:()=>{oe()},children:P?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(QE,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(HE,{open:T&&v!==null&&se.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:se,popoverRef:Y,labelledBy:"workbench-host-switcher-detail-title",children:[s.jsx("div",{className:"workbench-host-switcher-detail-header",children:s.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:Ke})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:ft})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(v==null?void 0:v.url)??K.baseUrl})]}),(v==null?void 0:v.kind)==="relay"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:YE(V)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:XE(Ce.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function ap(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const i=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(i)})}function UE(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function qE(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 GE(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function VE(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function KE(e,t){return e instanceof Hc?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function YE(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function XE(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 JE(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function lp(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function cp(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function QE(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function ZE(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const na={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function eM({open:e,onClose:t,onCloned:n}){const{showToast:r}=Pn(),[i,o]=f.useState(!1),[a,c]=f.useState(na),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[m,g]=f.useState(null),[x,S]=f.useState(""),[C,y]=f.useState(""),[A,T]=f.useState(null),[G,P]=f.useState([]),[E,V]=f.useState([]),U=i||h;f.useEffect(()=>{!e&&!i&&(c(na),d(!1),g(null))},[i,e]);const L=f.useCallback(async q=>{p(!0),g(null);try{const D=await hf(q);S(D.currentPath),y(D.currentPath),T(D.parentPath),P(D.roots),V(D.items),c(K=>({...K,parentPath:D.currentPath}))}catch(D){S(""),T(null),V([]),g(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function I(){i||(d(!1),g(null),c(na),t())}function H(){d(!0),L(a.parentPath||void 0)}function _(){i||(d(!1),g(null))}async function se(q){q.preventDefault(),await L(C)}function Y(){c(q=>({...q,parentPath:x})),d(!1),g(null)}async function W(q){q.preventDefault();const D=a.repositoryUrl.trim(),K=a.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!K){r({title:l("shell.clonePathRequired"),tone:"error"});return}o(!0);try{const ee=await gk({repositoryUrl:D,parentPath:K,directoryName:a.directoryName.trim()||void 0,name:a.name.trim()||void 0,auth:a.authMode==="none"?{mode:"none"}:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}});await(n==null?void 0:n(ee)),c(na),d(!1),r({title:l("shell.cloneSuccess"),description:ee.path,tone:"success"}),t()}catch(ee){r({title:ee instanceof Error?ee.message:l("shell.cloneFailed"),tone:"error"})}finally{o(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(Nt,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:I,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:q=>void W(q),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:a.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:q=>c(D=>({...D,repositoryUrl:q.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneParentPathLabel")}),s.jsxs("div",{className:"workbench-modal-inline-field",children:[s.jsx("input",{type:"text",value:a.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:q=>c(D=>({...D,parentPath:q.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:H,children:l("shell.clonePickDirectory")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),s.jsx("input",{type:"text",value:a.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:q=>c(D=>({...D,directoryName:q.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:a.name,placeholder:l("shell.importNamePlaceholder"),onChange:q=>c(D=>({...D,name:q.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:a.authMode,onChange:q=>c(D=>({...D,authMode:q.target.value})),children:[s.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),s.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),s.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),a.authMode==="basic"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:q=>c(D=>({...D,username:q.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:a.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:q=>c(D=>({...D,password:q.target.value}))})]})]}):null,a.authMode==="token"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:q=>c(D=>({...D,username:q.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:a.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:q=>c(D=>({...D,token:q.target.value}))})]})]}):null,s.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:I,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(Nt,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:se,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:C,placeholder:l("shell.importPathPlaceholder"),onChange:q=>y(q.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:U||!A,onClick:()=>{A&&L(A)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:U,children:l("shell.importBrowserOpenPath")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:G.map(q=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:U,onClick:()=>{L(q.path)},children:q.name},q.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:x}),m?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:m}):null,h?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):E.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:E.map(q=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:U,onClick:()=>{L(q.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:q.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:q.path})]},q.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:U||!x,onClick:Y,children:l("shell.cloneBrowserSubmit")})]})]})]})}const tM="butler:inbox-updated";function Zl(){typeof window>"u"||window.dispatchEvent(new Event(tM))}const up={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function ib({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:o=!1,composerOpen:a=!0,onComposerOpenChange:c}){const{showToast:u}=Pn(),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState([]),[y,A]=f.useState(null),[T,G]=f.useState(null),[P,E]=f.useState(up),[V,U]=f.useState(!1),L=f.useMemo(()=>hp(g,t,T),[T,t,g]),I=f.useMemo(()=>V?S:S.filter(D=>D.status!=="closed"),[S,V]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||y||E(D=>{const K=fp({projects:L,currentProjectId:D.projectId,preferredProjectId:T,preferredWorkspaceId:t});return K===D.projectId?D:{...D,projectId:K}})},[e,y,T,t,L]),f.useEffect(()=>{!e||r<=0||(_(void 0,t,i,T),c==null||c(!0))},[e,r,i,c,T,t]);async function H(){h(!0);try{const[D,K,ee]=await Promise.all([VN(),ag(),n?ej(n).catch(()=>null):Promise.resolve(null)]),v=(ee==null?void 0:ee.target.project.id)??null;G(v),x(D.items),C(K.items),y||_(D.items,t,r>0?i:null,v)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{h(!1)}}function _(D=g,K=t,ee=i,v=T){var je,N;const Ce=hp(D,K,v);A(null),E({...up,projectId:fp({projects:Ce,preferredProjectId:v,preferredWorkspaceId:K}),title:((je=ee==null?void 0:ee.title)==null?void 0:je.trim())??"",content:((N=ee==null?void 0:ee.content)==null?void 0:N.trim())??""})}function se(D){A(D.id),E({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),o&&(c==null||c(!0))}async function Y(D){D.preventDefault(),m(!0);try{y?(await Nh(y,{projectId:P.projectId,itemType:P.itemType,title:P.title,content:P.content,status:P.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await KN({projectId:P.projectId,itemType:P.itemType,title:P.title,content:P.content,status:P.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),Zl(),await H(),_(),o&&(c==null||c(!1))}catch(K){u({title:l("shell.butlerInboxSaveFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{m(!1)}}async function W(D){m(!0);try{await JN(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),Zl(),await H(),y===D&&_()}catch(K){u({title:l("shell.butlerInboxDeleteFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{m(!1)}}async function q(D,K){if(D.status!==K){m(!0);try{await Nh(D.id,{status:K}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),Zl(),await H(),y===D.id&&E(ee=>({...ee,status:K}))}catch(ee){u({title:l("shell.butlerInboxSaveFailed"),description:ee instanceof Error?ee.message:void 0,tone:"error"})}finally{m(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[o?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(dp,{selectableProjects:L,formState:P,saving:p,editingItemId:y,useMobilePicker:!1,onProjectChange:D=>{E(K=>({...K,projectId:D}))},onItemTypeChange:D=>{E(K=>({...K,itemType:D}))},onStatusChange:D=>{E(K=>({...K,status:D}))},onTitleChange:D=>{E(K=>({...K,title:D}))},onContentChange:D=>{E(K=>({...K,content:D}))},onCancel:()=>_(),onSubmit:Y})}),s.jsxs("section",{className:"workspace-inbox-panel",children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:l("shell.butlerInboxListTitle")}),s.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),s.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[s.jsx("input",{type:"checkbox",checked:V,onChange:D=>U(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&I.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&I.length>0?s.jsx("div",{className:"workspace-inbox-list",children:I.map(D=>s.jsxs("article",{className:"workspace-inbox-item",children:[s.jsxs("div",{className:"workspace-inbox-item-header",children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.title}),s.jsx("p",{children:D.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:mp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:oM(D.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:aM(D.updatedAt)}),s.jsxs("div",{className:"workspace-inbox-item-actions",children:[s.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(K=>{const ee=D.status===K;return s.jsx("button",{type:"button",className:"secondary-button","data-active":ee,disabled:p,onClick:()=>{q(D,K)},children:mp(K)},`${D.id}:${K}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>se(D),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{W(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),o?s.jsx(Nt,{open:e&&a,title:y?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),_()},children:s.jsx("div",{className:"workspace-inbox-composer-modal-body",children:s.jsx(dp,{selectableProjects:L,formState:P,saving:p,editingItemId:y,useMobilePicker:!0,onProjectChange:D=>{E(K=>({...K,projectId:D}))},onItemTypeChange:D=>{E(K=>({...K,itemType:D}))},onStatusChange:D=>{E(K=>({...K,status:D}))},onTitleChange:D=>{E(K=>({...K,title:D}))},onContentChange:D=>{E(K=>({...K,content:D}))},onCancel:()=>{c==null||c(!1),_()},onSubmit:Y})})}):null]})}function dp(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),s.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):s.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[s.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?s.jsxs(s.Fragment,{children:[s.jsx(ec,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(ec,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(ec,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),s.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),s.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[s.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),s.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),s.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),s.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),s.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[s.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),s.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),s.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),s.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxContentLabel")}),s.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function ec({label:e,value:t,options:n,disabled:r,onChange:i}){const[o,a]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!o)return;function u(d){d.key==="Escape"&&a(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[o]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":o,disabled:r||n.length===0,onClick:()=>a(!0),children:[s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:s.jsx(sM,{expanded:o})})]})]}),s.jsx(nM,{open:o,title:e,options:n,selectedValue:t,onClose:()=>a(!1),onSelect:u=>{i(u),a(!1)}})]})}function nM({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:o}){return e?s.jsx(bk,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:s.jsx(tu,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(a=>{const c=a.value===r;return s.jsx(ln,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:s.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?s.jsx(iM,{}):null}),onClick:()=>o(a.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:a.label}),a.description?s.jsx("span",{children:a.description}):null]})},a.value)})})}):null}function HP({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:o,compactComposer:a=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!a);return f.useEffect(()=>{e||h(!a)},[a,e]),s.jsx(Nt,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!a,headerActions:a?s.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(p=>p+1),h(!0)},children:s.jsx(rM,{})}):void 0,onClose:o,children:s.jsx(ib,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:a,composerOpen:d,onComposerOpenChange:h})})}function hp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const o=pp(r,t,n),a=pp(i,t,n);return o!==a?a-o:r.name.localeCompare(i.name,"zh-Hans-CN")})}function pp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function fp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var o;if(t&&e.some(a=>a.id===t))return t;if(n&&e.some(a=>a.id===n))return n;const i=r?e.find(a=>a.workspaceId===r):null;return(i==null?void 0:i.id)||((o=e[0])==null?void 0:o.id)||""}function rM(){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]})}function sM({expanded:e}){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:s.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function iM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function oM(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function mp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function aM(e){return new Date(e).toLocaleString()}function lM({open:e,onClose:t,onImported:n}){const{showToast:r}=Pn(),[i,o]=f.useState(!1),[a,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[m,g]=f.useState(""),[x,S]=f.useState(""),[C,y]=f.useState(null),[A,T]=f.useState([]),[G,P]=f.useState([]),[E,V]=f.useState(!1),[U,L]=f.useState(""),I=i||a||u,H=f.useCallback(async K=>{o(!0),p(null);try{const ee=await hf(K);g(ee.currentPath),S(ee.currentPath),y(ee.parentPath),T(ee.roots),P(ee.items)}catch(ee){g(""),y(null),P([]),p(ee instanceof Error?ee.message:l("shell.importBrowserBrowseFailed"))}finally{o(!1)}},[]);f.useEffect(()=>{if(!e){V(!1),L(""),p(null);return}H(m||void 0)},[H,e]);function _(){I||(V(!1),L(""),t())}async function se(K){K.preventDefault(),await H(x)}function Y(){!m||I||(L(""),V(!0))}function W(){a||(V(!1),L(""))}async function q(K){K==null||K.preventDefault();const ee=U.trim();if(!(!m||!ee||I)){c(!0),p(null);try{const v=await xk({parentPath:m,directoryName:ee});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:v.path,tone:"success"}),V(!1),L(""),await H(v.path)}catch(v){const Ce=v instanceof Error?v.message:l("shell.importBrowserCreateDirectoryFailed");p(Ce),r({title:Ce,tone:"error"})}finally{c(!1)}}}async function D(){const K=m.trim();if(!(!K||I)){d(!0),p(null);try{const ee=await kk({path:K});r({title:l("shell.importSuccess"),description:ee.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(ee)).catch(v=>{r({title:v instanceof Error?v.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(ee){r({title:ee instanceof Error?ee.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:se,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:x,placeholder:l("shell.importPathPlaceholder"),onChange:K=>S(K.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:I||!C,onClick:()=>{C&&H(C)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:I,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:I||!m,onClick:Y,children:l("shell.importBrowserCreateDirectory")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:A.map(K=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:I,onClick:()=>{H(K.path)},children:K.name},K.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),h?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:h}):null,i?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):G.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:G.map(K=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:I,onClick:()=>{H(K.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:K.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:K.path})]},K.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:I,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:I||!m,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(Nt,{open:e&&E,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:W,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:K=>void q(K),children:[s.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),s.jsx("input",{type:"text",value:U,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:K=>L(K.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:W,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:a||!U.trim(),children:a?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function cM({onOpenSoftwareUpdate:e}){var r;const t=Qc(i=>i.platform),n=ck(i=>i.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:s.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:s.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function uM(){const e=lk.getState().profile.defaultPermissionMode;return e==="default"?null:e}const $i="provider-default",ga="__global_default__";function dM(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function ra(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function hM(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:ga,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function pM(e){return e.usesProviderDefault===!0||e.id===$i}function fM(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function mM({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:o,onSelectPreset:a,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:m=!1,showPresetColumn:g=!0,modelEmptyText:x}){const[S,C]=f.useState(!1),y=f.useRef(null),A=f.useRef(null),T=f.useRef(null),[G,P]=f.useState(null),E=f.useId(),V=f.useCallback(()=>{const U=A.current;if(!U||typeof window>"u")return;const L=U.getBoundingClientRect(),I=U.closest(".workbench-modal-card"),H=I instanceof HTMLElement?I.getBoundingClientRect():null,_=window.innerWidth,se=window.innerHeight,Y=12,W=8,q=320,D=Math.min(560,Math.max(320,_-Y*2)),K=Math.min(D,420),ee=Math.max(Math.min(D,Math.max(K,Math.round(L.width*1.9))),Math.min(320,D)),v=Math.min(Math.max(Y,L.left),Math.max(Y,_-ee-Y)),Ce=H?Math.max(Y,H.top+8):Y,je=H?Math.min(se-Y,H.bottom-8):se-Y,N=Math.max(0,L.top-Ce-W),ce=Math.max(0,je-L.bottom-W),Ie=H?!(ce>=q||ce>N+40):N>=240||N>=ce;P({position:"fixed",left:v,width:ee,maxWidth:D,zIndex:1905,top:Ie?void 0:L.bottom+W,bottom:Ie?se-L.top+W:void 0})},[]);return f.useEffect(()=>{if(!S)return;function U(I){var _,se;const H=I.target;!((_=y.current)!=null&&_.contains(H))&&!((se=T.current)!=null&&se.contains(H))&&C(!1)}function L(I){I.key==="Escape"&&C(!1)}return window.addEventListener("pointerdown",U),window.addEventListener("keydown",L),window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),V(),()=>{window.removeEventListener("pointerdown",U),window.removeEventListener("keydown",L),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[S,V]),s.jsxs("div",{ref:y,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":E,onClick:()=>C(U=>!U),children:[s.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&G&&typeof document<"u"?or.createPortal(s.jsx("div",{ref:T,className:"composer-mac-select-popover composer-deployment-select-popover",style:G,role:"presentation",children:s.jsxs("div",{id:E,className:`composer-deployment-select-panel${g?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[g?s.jsxs("div",{className:"composer-deployment-select-column",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),s.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(U=>{const L=U.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,onClick:()=>a(U.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:U.label}),U.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:U.summary}):null]})]},U.value)}),h?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,s.jsxs("div",{className:"composer-deployment-select-column","data-disabled":m?"true":"false",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),g&&o?s.jsx("div",{className:"composer-deployment-select-column-hint",children:o}):null,s.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:p&&m?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(U=>{const L=U.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,disabled:m,onClick:()=>{d(U.value),C(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:U.label})})]},U.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:x})})]})]})}),document.body):null]})}const ob=144,gM=196,bM=124,kM=72;let gp=null;function xM(e,t){if(typeof document>"u")return t.length*8;gp??(gp=document.createElement("canvas"));const n=gp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",o=r.fontWeight||"600",a=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${o} ${a} ${c}`,n.measureText(t).width}function yM({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const o=e.reduce((a,c)=>Math.max(a,Math.ceil(i(c)+kM)),0);return Math.min(n,Math.max(t,ob,r,o))}function bp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:o=!1,compact:a=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),m=f.useRef(null),[g,x]=f.useState(null),S=f.useId(),C=r.find(T=>T.value===n)??r[0]??null,y=f.useMemo(()=>r.map(T=>T.label),[r]),A=f.useCallback(()=>{const T=p.current;if(!T||typeof window>"u")return;const G=T.getBoundingClientRect(),P=window.innerWidth,E=window.innerHeight,V=12,U=10,L=Math.max(ob,P-V*2),I=a?bM:gM,H=yM({labels:y,triggerWidth:G.width,maxWidth:L,preferredWidth:I,measureText:q=>xM(T,q)}),_=Math.min(Math.max(V,G.left),Math.max(V,P-H-V)),se=G.top-V,Y=E-G.bottom-V,W=se>=180||se>=Y;x({position:"fixed",left:_,width:H,maxWidth:L,zIndex:1905,top:W?void 0:G.bottom+U,bottom:W?E-G.top+U:void 0})},[a,y]);return f.useEffect(()=>{if(!u)return;function T(P){var V,U;const E=P.target;!((V=h.current)!=null&&V.contains(E))&&!((U=m.current)!=null&&U.contains(E))&&d(!1)}function G(P){P.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",G),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",G),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),C?s.jsxs("div",{ref:h,className:`composer-mac-select ${a?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[s.jsxs("button",{id:e,ref:p,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:o,onClick:()=>d(T=>!T),children:[s.jsx("span",{className:"composer-mac-select-label",children:C.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&g&&typeof document<"u"?or.createPortal(s.jsx("div",{ref:m,className:"composer-mac-select-popover",style:g,role:"presentation",children:s.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(T=>{const G=T.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":G,className:`composer-mac-select-option ${G?"is-selected":""}`,onClick:()=>{i(T.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:G?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:T.label})]},T.value)})})}),document.body):null]}):null}const sa=["codex","claude-code","gemini"];function ab(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function kp(e,t){return Array.from({length:t},()=>ab(e))}function tc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:nu(t).modelOptions??[]}function xp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function yp(e,t){return Math.max(0,e-t.length)}function wM({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),o=(t==null?void 0:t.defaultProvider)??"codex",a=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(j,$)=>$+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,h=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:p}=yk(Ck,e),[m,g]=f.useState(h),[x,S]=f.useState(d),[C,y]=f.useState(()=>kp(o,d)),[A,T]=f.useState({}),[G,P]=f.useState({}),[E,V]=f.useState({}),[U,L]=f.useState({}),[I,H]=f.useState({}),[_,se]=f.useState(!1),[Y,W]=f.useState(!1),[q,D]=f.useState(null),[K,ee]=f.useState(null),[v,Ce]=f.useState({}),je=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const j=(t==null?void 0:t.defaultProvider)??"codex",$=(t==null?void 0:t.kind)==="group"?1:2;g((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S($),y(kp(j,$)),T({}),P({}),V({}),L({}),H({}),se(!1),W(!1),D(null),ee(null),Ce({}),je.current=!1,Object.keys(N.current).forEach(ie=>{delete N.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]),f.useEffect(()=>{y(j=>{var me;if(j.length===x)return j;if(j.length>x)return j.slice(0,x);const $=j.slice(),ie=((me=j[0])==null?void 0:me.provider)??o;for(;$.length<x;)$.push(ab(ie));return $})},[o,x]),f.useEffect(()=>{u.length!==0&&S(j=>u.includes(j)?j:u[0]??j)},[u]),f.useEffect(()=>{if(!e||!t)return;let j=!1;return se(!0),wk(p,t.workspaceId).then($=>{j||T($)}).finally(()=>{j||se(!1)}),()=>{j=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(je.current||(je.current=!0,V(j=>({...j,...Object.fromEntries(sa.map($=>[$,!0]))})),vk().then(j=>{const $=Object.fromEntries(j.items.map(ie=>[ie.app,ie]));P(Object.fromEntries(sa.map(ie=>[ie,$[ie]??null])))}).catch(()=>{P(Object.fromEntries(sa.map(j=>[j,null])))}).finally(()=>{V(j=>({...j,...Object.fromEntries(sa.map($=>[$,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const j=Array.from(new Set(C.map($=>{const ie=ra($.providerConfigMode,$.providerPresetId);return xp($.provider,ie.providerConfigMode,ie.providerPresetId)}).filter($=>$!==null))).filter($=>U[$]===void 0&&!N.current[$]);if(j.length!==0)for(const $ of j){const[ie,me]=$.split("::");N.current[$]=!0,H(we=>({...we,[$]:!0})),pf(ie,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:me}).then(we=>{L(z=>({...z,[$]:we}))}).catch(()=>{L(we=>({...we,[$]:null}))}).finally(()=>{delete N.current[$],H(we=>({...we,[$]:!1}))})}},[U,C,e,t]);const ce=f.useMemo(()=>p.filter(j=>{const $=A[j];return $?$.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!ce.length)return;const j=ce.includes(o)?o:ce[0];y($=>{let ie=!1;const me=$.map(we=>ce.includes(we.provider)?we:(ie=!0,{...we,provider:j,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ie?me:$})},[ce,o]);const Ie=f.useMemo(()=>C.map((j,$)=>{var B;const ie=ra(j.providerConfigMode,j.providerPresetId),me=dM(j.provider),we=me?G[me]??null:null,z=hM(we),J=ie.providerConfigMode==="cc-switch-preset"?ie.providerPresetId??ga:ga,he=z.find(ue=>ue.value===J)??z[0]??null,ke=xp(j.provider,ie.providerConfigMode,ie.providerPresetId),De=A[j.provider]??null,We=ke?U[ke]??null:null,Ze=(ie.providerConfigMode==="cc-switch-preset"?We?tc(We,j.provider):[{id:$i,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:tc(De,j.provider)).map(ue=>({value:ue.id,label:pM(ue)?l("conversation.modelUseCliDefault"):ue.name})),ht=j.model.trim()||$i,lt=((B=Ze.find(ue=>ue.value===ht))==null?void 0:B.label)??l("conversation.modelUseCliDefault"),Ye=fM(we),et=me!==null,bt=ke?I[ke]===!0:!1,Ht=!!(ke&&bt&&We===null);return{index:$,draft:j,supportsDeploymentPicker:et,showPresetColumn:Ye,deploymentPresetOptions:z,selectedPresetValue:J,selectedPresetOption:he,triggerLabel:Ye?`${(he==null?void 0:he.label)??l("conversation.deploymentDefaultPreset")} · ${lt}`:lt,selectedModelValue:ht,modelOptions:Ze,loadingPresets:me?E[me]===!0:!1,loadingModels:bt,modelColumnDisabled:Ht}}),[U,G,E,I,C,A]);if(f.useEffect(()=>{e&&y(j=>{let $=!1;const ie=j.map((me,we)=>{const z=Ie[we];if(!z)return me;let J=me;const he=ra(me.providerConfigMode,me.providerPresetId);he.providerConfigMode==="cc-switch-preset"&&he.providerPresetId&&!z.loadingPresets&&!z.deploymentPresetOptions.some(We=>We.value===he.providerPresetId)&&(J={...J,providerConfigMode:"global-default",providerPresetId:null,model:""},$=!0);const ke=new Set(z.modelOptions.map(We=>We.value)),De=J.model.trim()||$i;return ke.has(De)||(J={...J,model:""},$=!0),J});return $?ie:j})},[Ie,e]),!e||!t)return null;const fe=t,oe=K?yp(C.length,K.memberFailures):0,_e=new Set(K?C.map((j,$)=>$).filter(j=>!(j in v)):[]),Ge=fe.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),Ke=fe.kind==="session"?`${fe.workspaceName} · ${fe.sessionTitle}`:fe.workspaceName,ft=fe.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),F=fe.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),te=fe.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),re=fe.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),ve=q??(fe.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!_&&ce.length===0?l("shell.parallelCreateNoAvailableProviders"):null),Se={"--parallel-member-columns":String(Math.max(1,Math.min(x,4)))};function ye(j){D(null),ee(null),Ce($=>{if(!(j in $))return $;const ie={...$};return delete ie[j],ie})}function ze(){D(null),ee(null),Ce({})}function Ve(j,$){ye(j);const ie=$?"temporary_worktree":"none";y(me=>me.map((we,z)=>z===j?{...we,workspaceIsolationMode:ie}:we))}async function Je(){const j=m.trim();if(!a&&!j){D(l("shell.parallelCreatePromptRequired"));return}if(fe.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!ce.length){D(l("shell.parallelCreateNoAvailableProviders"));return}W(!0),D(null),ee(null),Ce({});try{const $=uM(),ie=C.map(we=>{const z=ra(we.providerConfigMode,we.providerPresetId);return{provider:we.provider,model:we.model.trim()||null,providerConfigMode:z.providerConfigMode,providerPresetId:z.providerConfigMode==="cc-switch-preset"?z.providerPresetId:null,memberPrompt:we.memberPrompt.trim()||null,workspaceIsolationMode:we.workspaceIsolationMode}}),me=fe.kind==="group"?await Nk(fe.groupId,{permissionMode:$,members:ie}):fe.kind==="session"?await jk(fe.sessionId,{sharedPrompt:j,permissionMode:$,members:ie}):await Tk(fe.workspaceId,{sharedPrompt:j,permissionMode:$,members:ie});if(me.memberFailures.length>0){const we=yp(C.length,me.memberFailures);ee(me),Ce(Object.fromEntries(me.memberFailures.map(z=>[z.ordinal,z]))),D(we>0?l("shell.parallelCreatePartialFailure",{successCount:we,failureCount:me.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:me.memberFailures.length}));return}await r(me)}catch($){D($ instanceof Error?$.message:l("shell.parallelGroupLoadFailed"))}finally{W(!1)}}return s.jsx(ru,{open:e,title:Ge,description:Ke,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!Y,onClose:n,footer:s.jsxs(Sk,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:ve?s.jsx("span",{className:"parallel-create-modal-error",children:ve}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[K&&oe>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:()=>{r(K)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:Y||_||ce.length===0||fe.kind==="group"&&c===0,onClick:()=>{Je()},children:Y?re:te})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Vs,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx($s,{className:"parallel-create-target-field",label:ft,htmlFor:`${i}-shared-prompt`,children:s.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:m,readOnly:a,"aria-readonly":a,"data-readonly":a?"true":void 0,onChange:j=>{a||(ze(),g(j.target.value))}})}),s.jsx($s,{className:"parallel-create-count-field",label:F,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":F,children:u.map(j=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":x===j,onClick:()=>{ze(),S(j)},children:j},j))})})]})}),s.jsx(Vs,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:Se,children:Ie.map(({draft:j,index:$,supportsDeploymentPicker:ie,showPresetColumn:me,deploymentPresetOptions:we,selectedPresetValue:z,selectedPresetOption:J,triggerLabel:he,selectedModelValue:ke,modelOptions:De,loadingPresets:We,loadingModels:mt,modelColumnDisabled:Ze})=>{var Ht;const ht=ce,lt=ht.includes(j.provider)?j.provider:"",Ye=ht.length>0?ht.map(B=>({value:B,label:uc(B,"full")})):[{value:"",label:_?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],et=tc(A[j.provider]??null,j.provider),bt=et.length>0?[{value:"",label:((Ht=et.find(B=>B.usesProviderDefault===!0))==null?void 0:Ht.name)??l("shell.parallelPaneModelFallback")},...et.filter(B=>B.usesProviderDefault!==!0).map(B=>({value:B.id,label:B.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":v[$]?"error":_e.has($)?"success":void 0,children:[s.jsxs("header",{className:"parallel-create-member-header",children:[s.jsxs("div",{className:"parallel-create-member-title-block",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:$+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:uc(j.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:j.workspaceIsolationMode==="temporary_worktree",onChange:B=>{Ve($,B.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),v[$]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):_e.has($)?s.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),s.jsxs("div",{className:"parallel-create-member-grid",children:[s.jsx($s,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${$}-provider`,children:s.jsx(bp,{triggerId:`${i}-member-${$}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:lt,options:Ye,disabled:!ht.length,onChange:B=>{ye($);const ue=B;y(de=>de.map((Pe,ge)=>ge===$?{...Pe,provider:ue,providerConfigMode:"global-default",providerPresetId:null,model:""}:Pe))}})}),s.jsx($s,{label:l("shell.parallelCreateModelLabel"),htmlFor:ie?void 0:`${i}-member-${$}-model`,children:ie?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(mM,{triggerId:`${i}-member-${$}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:he,presetOptions:we,selectedPresetValue:z,selectedPresetSummary:(J==null?void 0:J.summary)??null,onSelectPreset:B=>{ye($),y(ue=>ue.map((de,Pe)=>Pe!==$?de:B===ga?{...de,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...de,providerConfigMode:"cc-switch-preset",providerPresetId:B,model:""}))},modelOptions:De,selectedModelValue:ke,onSelectModel:B=>{ye($),y(ue=>ue.map((de,Pe)=>Pe===$?{...de,model:B===$i?"":B}:de))},loadingPresets:We,loadingModels:mt,modelColumnDisabled:Ze,showPresetColumn:me,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(bp,{triggerId:`${i}-member-${$}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:j.model,options:bt,disabled:!ht.length||et.length===0,onChange:B=>{ye($),y(ue=>ue.map((de,Pe)=>Pe===$?{...de,model:B}:de))}})})]}),s.jsx($s,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${$}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${$}-prompt`,className:"parallel-create-textarea member",rows:2,value:j.memberPrompt,onChange:B=>{ye($);const ue=B.target.value;y(de=>de.map((Pe,ge)=>ge===$?{...Pe,memberPrompt:ue}:Pe))}})}),v[$]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:v[$].detail})]}):null]},`parallel-member-${$}`)})})})]})})}const vM=12,SM=180,wp=72;function CM(e,t){const[n,r]=f.useState(!1),[i,o]=f.useState(""),[a,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[m,g]=f.useState(null);f.useEffect(()=>{e||(r(!1),o(""),g(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const C=t.filter(A=>u[A.sessionId]!==!0);if(C.length===0)return;let y=!1;return p(!0),g(null),Promise.allSettled(C.map(async A=>{const T=await df(A.sessionId,null,vM,"backward");return{sessionId:A.sessionId,summary:NM(T.messages)}})).then(A=>{if(y)return;const T={},G={};let P=0;C.forEach(E=>{T[E.sessionId]=!0});for(const E of A){if(E.status==="fulfilled"){G[E.value.sessionId]=E.value.summary;continue}P+=1}d(E=>({...E,...T})),Object.keys(G).length>0&&c(E=>({...E,...G})),g(P>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{y||p(!1)}),()=>{y=!0}},[u,e,n,t]);const x=f.useMemo(()=>{const C=nc(i);return C?t.filter(y=>nc(y.title).includes(C)?!0:nc(a[y.sessionId]??"").includes(C)):t},[i,t,a]);function S(){r(C=>{const y=!C;return y||(o(""),g(null)),y})}return{searchOpen:n,searchKeyword:i,filteredSessions:x,summaryLoading:h,summaryError:m,summaryBySessionId:a,setSearchKeyword:o,toggleSearch:S}}function NM(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(jM).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return Uc(n,SM)}function jM(e){var n,r;const t=lb(e.content);return t.length>0?Uc(t,wp):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?Uc(e.toolCall.name.trim(),wp):""}function nc(e){return lb(e).toLocaleLowerCase()}function lb(e){return e.replace(/\s+/g," ").trim()}function Uc(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const vp="workbench.left.width",Sp="workbench.right.width",Cp="workbench.left.collapsed",Np="workbench.right.collapsed",ia="workbench.last.session.path",rc="workbench.workspace.selected.id",jp="workbench.notifications.seen_at",TM=280,IM=320,Tp=240,Ip=280,Ep=520,Mp=560,EM=200,sc=20,Di=40,oa=5,MM=3e4,RM=12,Rp=60*1e3,AM=4e3,Ap=220,Pp=18,PM=6,Fs="data-workbench-panel-resizing",aa="data-workbench-window-resizing",LM=180,DM="workbench:focus-composer",_M=new Set(["starting","running","reconnecting","stale","unknown"]),BM=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],OM=["--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"],pt={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 cb(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function WM(e){return Math.round(e*100)/100}function FM(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function Er(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(o=>FM(n,o)).filter(o=>o!==null);return i.length===0?null:i.reduce((o,a)=>o+a,0)/i.length}function Gn(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${WM(n)}px`;r!==i&&e.style.setProperty(t,i)}function Vn(e,t,n,r){return r===null?null:(cb(e,t)??0)+(n-r)}function Lp(e){if(e)for(const t of OM)e.style.removeProperty(t)}function $M(e){return _M.has(e.runningState??"idle")||e.activityState==="running"}function zM(e,t){const n=[];for(const r of[...t].sort()){const i=e.get(r);!i||i.size===0||n.push(`${r}:${[...i].sort().join(",")}`)}return n.join("|")}function HM(e){var i,o;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((o=e.lastErrorDetail)==null?void 0:o.trim())??"",r=[t,n].filter(a=>a.length>0).join(" · ");return r?r.length<=Ap?r:`${r.slice(0,Ap-3)}...`:null}function UM(e,t,n){var o,a,c,u,d,h,p,m,g,x,S,C;const r=new Map(e.projects.map(y=>[y.id,y.workspaceId])),i=[];for(const y of n){const A=y.title.trim()||y.projectName;if(y.assistantState.lifecycleStage==="analyzed"&&!((o=y.assistantState.linkedSessionId)!=null&&o.trim())&&y.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${y.id}:${y.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((a=y.assistantState.analysisSummary)==null?void 0:a.trim())||((c=y.assistantState.generatedPrompt)==null?void 0:c.trim())||y.content,routePath:as(y.workspaceId),workspaceId:y.workspaceId,createdAt:y.assistantState.lastAnalyzedAt});continue}y.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${y.id}:${y.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=y.assistantState.lastError)==null?void 0:u.trim())||y.content,routePath:as(y.workspaceId),workspaceId:y.workspaceId,createdAt:y.updatedAt})}for(const y of t){const A=((d=y.sessionTitle)==null?void 0:d.trim())||y.projectName,T=y.updatedAt||y.lastAutomationAt||y.createdAt;if(y.status==="waiting_user"){i.push({id:`follow-up-waiting:${y.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((h=y.waitingReason)==null?void 0:h.trim())||((p=y.lastAutomationSummary)==null?void 0:p.trim())||y.objective,routePath:Mn(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:T});continue}if(y.status==="completed"){i.push({id:`follow-up-completed:${y.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((m=y.lastAutomationSummary)==null?void 0:m.trim())||y.objective,routePath:Mn(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:T});continue}y.status==="failed"&&i.push({id:`follow-up-failed:${y.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((g=y.lastAutomationSummary)==null?void 0:g.trim())||((x=y.waitingReason)==null?void 0:x.trim())||y.objective,routePath:Mn(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:T})}for(const y of e.verifications){if(y.status!=="failed")continue;const A=y.projectId?r.get(y.projectId)??null:null,T=((S=y.targetRef)==null?void 0:S.trim())||y.verificationType;i.push({id:`verification-failed:${y.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:T}),body:((C=y.summary)==null?void 0:C.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?as(A):null,workspaceId:A,createdAt:y.finishedAt||y.startedAt||y.createdAt})}return i.sort((y,A)=>{const T=Dp(y.kind)-Dp(A.kind);return T!==0?T:Pr(A.createdAt)-Pr(y.createdAt)}).slice(0,RM)}function Dp(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 qM(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function Pr(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function GM(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function VM(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function KM(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:o,tags:a}}function YM(e){return e.getBoundingClientRect()}function XM(e,t){return t?Pr(e.createdAt)>Pr(t):!0}function JM(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 _p(e,t){var a,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const u of n){const d=rt(u,e),h=(a=d==null?void 0:d.params.workspaceId)==null?void 0:a.trim();if(h)return h}const r=Ki(e),i=(r==null?void 0:r.sessionId)??null;return!i||!$b(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function QM(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function ic(e){return e==="mobile"?Yt():"/landing"}function Ki(e){var o,a,c;const t=rt("/workspaces/:workspaceId/sessions/:sessionId",e),n=(o=t==null?void 0:t.params.sessionId)==null?void 0:o.trim();if(n)return{sessionId:n,workspaceId:((a=t==null?void 0:t.params.workspaceId)==null?void 0:a.trim())??null};const r=rt("/sessions/:sessionId",e),i=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return i?{sessionId:i,workspaceId:null}:null}function ZM(e){return!!(rt("/sessions",e)||rt("/workspaces/:workspaceId/sessions",e))}function Bp(e){return!!Ki(e)}function eR(e){return!!(rt("/tools",e)||rt("/tools/files",e)||rt("/tools/git",e)||rt("/tools/processes",e)||rt("/workspaces/:workspaceId/tools",e)||rt("/workspaces/:workspaceId/tools/files",e)||rt("/workspaces/:workspaceId/tools/git",e)||rt("/workspaces/:workspaceId/tools/processes",e))}function ba(e){return!!(rt("/terminals",e)||rt("/workspaces/:workspaceId/terminals",e))}function ka(e){return!!rt("/workspaces/:workspaceId/butler",e)}function tR(e,t){return rt("/workspaces/:workspaceId/debug",e)?Mf(t):rt("/workspaces/:workspaceId",e)?Qn(t):rt("/workspaces/:workspaceId/tools/files",e)||rt("/tools/files",e)?Af(t):rt("/workspaces/:workspaceId/tools/git",e)||rt("/tools/git",e)?Pf(t):rt("/workspaces/:workspaceId/tools/processes",e)||rt("/tools/processes",e)?Lf(t):rt("/workspaces/:workspaceId/tools",e)||rt("/tools",e)?Rf(t):ba(e)?rs(t):ka(e)?as(t):ri(t)}function nR(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const rR=f.lazy(async()=>({default:(await Zc(()=>import("./FileContextPanel-CMGTtAB6.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),sR=f.lazy(async()=>({default:(await Zc(()=>import("./GitSidebar--DCqBiGL.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),iR=f.lazy(async()=>({default:(await Zc(()=>import("./TerminalManagerPanel-CtldwWz8.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function oR(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function tn(e){return ai(e)}function aR(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function Gs(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(oR):[]}async function ub(e,t){const n=await pf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const db=f.createContext(null);function _a(e){return cI(e)}function Xn(e){return e.isArchived===!0}function fo(e){return Nf(e)}function hb(e,t){return lu(e,{getId:n=>n.sessionId,getParentId:fo,compare:(n,r)=>so(n,r,t)})}function lR(e,t){const n=cR(e);return pb(n,t)}function pb(e,t){const n=uR(e);return lu(n,{getId:r=>r.session.sessionId,getParentId:r=>fo(r.session),compare:(r,i)=>so(r.session,i.session,t)}).map(r=>mb(r))}function cR(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...fb(t.childWorktrees)])}function fb(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...fb(t.children)])}function uR(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}function mb(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>mb(n,t+1))}}function qc(e,t){return{...e,depth:e.depth+t,children:tn(e).map(n=>qc(n,t))}}function Op(e){return`${e}::parallel-anchor-member`}function Wp(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function Gc(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=Gc(tn(n),t);if(r)return r}return null}function dR(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=gb(r,n,null);if(i)return i}return null}function gb(e,t,n){var i,o;const r=((o=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:o.trim())||n;if(e.item.sessionId===t)return r;for(const a of tn(e)){const c=gb(a,t,r);if(c)return c}return null}function bb(e){return e.filter(t=>{if(Xn(t))return!1;const n=fo(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&Xn(r)?!_a(t):!0})}function hR(e){return e.flatMap(t=>{const n=aR(t);return n?[n,...Tf(tn(t))]:[]})}function pR(e,t,n){var m;const r=tn(e),i=ns(r).sort((g,x)=>so(g.item,x.item,n));if(!(((m=e.item.parallelGroup)==null?void 0:m.role)==="anchor"&&r.some(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const g=new Set(i.slice(0,Math.max(0,t)).map(x=>x.item.sessionId));return{...e,children:Vc(r,g)}}const a=r.slice().sort((g,x)=>so(g.item,x.item,n)),c=a.filter(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),u=a.filter(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),d=[...c,...u],h=Math.max(0,t-d.length),p=new Set(d);for(const g of i){if(p.size>=d.length+h)break;p.add(g.item.sessionId)}return{...e,children:Vc(r,p)}}function Vc(e,t){return e.flatMap(n=>{const r=Vc(tn(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function la(e,t,n,r=-1){if(e<=0)return 0;const i=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,i))}function Fp(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>e[i]===t[i])}function fR(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function Xa(e,t="compact"){return uc(e,t)}const mR={position:"relative",zIndex:0},gR={zIndex:1};function kb(e,t,n,r){const i=[],o=(r==null?void 0:r.trim())||t.name;n&&i.push(o);const a=fR(e);return a&&i.push(a),i.join(" · ")||o}function $p(e,t){return Uj("session-state-indicator",e,t)}function bR(e,t){return Sg(e,t)}function zp(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function Hp(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Up(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function ts(e,t){try{window.localStorage.setItem(e,t)}catch{}}function kR(e){try{window.localStorage.removeItem(e)}catch{}}function ca(e,t,n){return Math.max(t,Math.min(n,e))}function ua(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function xR(e){const t=window.getComputedStyle(e),n=ua(t.getPropertyValue("--desktop-macos-titlebar-height")),r=ua(t.getPropertyValue("--workbench-header-min-height")),i=ua(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),o=ua(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+o+8}function qp(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+xR(t)}function yR(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function wR(){typeof window>"u"||window.dispatchEvent(new CustomEvent(DM))}function xb(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const i=xb(r.children,n);if(i)return i}return null}function Gp(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=xb(r.childWorktrees,n);if(i)return i}return null}function yb(e){return e.flatMap(t=>[t.workspace.id,...yb(t.children)])}function vR(e){return new Set(e.flatMap(t=>[t.workspace.id,...yb(t.childWorktrees)]))}function Vp(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function oc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function wb(e,t,n,r=new Set){return e.map(i=>{const o=i.sessions.filter(c=>!r.has(c.sessionId)),a=bb(o);return{workspace:i.workspace,meta:i.meta,visibleSessions:a,archivedSessions:o.filter(c=>Xn(c)&&!fo(c)),visibleSessionTree:hb(a,n).filter(c=>!t.has(c.item.sessionId)&&!cu(tn(c),u=>t.has(u.sessionId))),children:wb(i.children,t,n,r)}})}function Kc(e){return e.flatMap(t=>[t.workspace.id,...Kc(t.children)])}function zi(e){return e.flatMap(t=>[...t.visibleSessionTree,...zi(t.children)])}function vb(e){return e.flatMap(t=>[t,...vb(t.children)])}function SR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:Gs(n)};const r=Sb(n.childWorktrees,t);if(r)return r}return null}function Sb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=Sb(n.children,t);if(r)return r}return null}function CR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Cb(n.childWorktrees,t);if(r)return r}return null}function ac(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Nb(n.childWorktrees,t);if(r)return r}return null}function Cb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Cb(n.children,t);if(r)return r}return null}function Nb(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Nb(n.children,t);if(r)return r}return null}function jb(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=jb(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function Kp(e){return e.flatMap(t=>[t.workspace.id,...Tb(t.childWorktrees)])}function Tb(e){return e.flatMap(t=>[t.workspace.id,...Tb(t.children)])}function NR(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function jR(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),o=e.findIndex(d=>d.workspace.id===n);if(i<0||o<0)return e;const a=[...e],[c]=a.splice(i,1);if(!c)return e;const u=a.findIndex(d=>d.workspace.id===n);return u<0?e:(a.splice(r==="before"?u:u+1,0,c),a.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:a)}function TR(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||Xn(u)===d?u:(n=!0,o=!0,{...u,isArchived:d})}),c=Eb(i.childWorktrees??[],t,u=>{u&&(n=!0,o=!0)});return o?{...i,sessions:a,childWorktrees:c}:i});return n?{...e,items:r}:e}function IR(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Xn(r)===i&&e.delete(r.sessionId)}Mb(e,n.childWorktrees??[])}}function ER(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Rb(o.childWorktrees,t,n);return d?(r=!0,{...o,childWorktrees:u}):o}const a=o.sessions.findIndex(u=>u.sessionId===t.sessionId),c=a>=0?o.sessions.map((u,d)=>d===a?t:u):[t,...o.sessions];return r=!0,{...o,sessions:po(c,n)}});return r?i:e}function MR(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=Ja(o.childWorktrees,d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Yp(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n})),u=Ja(o.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Xp(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n})),u=Ja(o.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function RR(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function AR(e){return e?e.slice(0,8):"--"}function Jp(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function Ib(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Eb(e,t,n){return e.map(r=>{let i=!1;const o=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||Xn(c)===u?c:(i=!0,{...c,isArchived:u})}),a=Eb(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:o,children:a}:r})}function Mb(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Xn(r)===i&&e.delete(r.sessionId)}Mb(e,n.children)}}function Rb(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id===t.workspaceId){const c=o.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?o.sessions.map((d,h)=>h===c?t:d):[t,...o.sessions];return r=!0,{...o,sessions:po(u,n)}}const a=Rb(o.children,t,n);return a.changed?(r=!0,{...o,children:a.nodes}):o});return{nodes:r?i:[...e],changed:r}}function PR(e,t){return e.map(n=>({...n,sessions:po(n.sessions,t),childWorktrees:Vu(n.childWorktrees,t)}))}function Ja(e,t){let n=!1;const r=e.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t(u);return d!==u&&(o=!0,n=!0),d}),c=Ja(i.children,t);return c!==i.children&&(o=!0,n=!0),o?{...i,sessions:a,children:c}:i});return n?r:[...e]}function Yc(e){return`workspace-management.summary.${e}`}function Ab(e){return`git-sidebar.snapshot.${e}`}function Pb(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Lb(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function Db(e,t){var o,a,c,u;const n=((o=t.status)==null?void 0:o.snapshot.enabled)!==!1,r=n?((a=t.status)==null?void 0:a.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:i,error:null}}}function _b({count:e,className:t="workbench-skeleton-lines"}){return s.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>s.jsx("span",{className:"skeleton-line"},r))})}function LR(){return s.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("section",{className:"workbench-skeleton-card",children:[s.jsxs("div",{className:"workbench-skeleton-heading",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx("span",{className:"skeleton-line tiny"})]}),s.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>s.jsxs("div",{className:"workbench-skeleton-session",children:[s.jsx("span",{className:"workbench-skeleton-dot"}),s.jsx(_b,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function da(){return s.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>s.jsxs("article",{className:"workbench-info-skeleton-card",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx(_b,{count:3})]},t))})}function DR({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),s.jsx("polyline",{points:r})]})}function Qp({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:i}){return s.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:i,children:s.jsx(DR,{side:t,collapsed:n})})}function Qs({expanded:e}){return s.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})}function _R(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function BR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),s.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function OR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Bb(e){return s.jsx("div",{className:"workbench-notification-anchor",children:s.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[s.jsx(OR,{}),e.unreadCount>0?s.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function WR(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return s.jsxs(Nt,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[s.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[s.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),s.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),s.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?s.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[s.jsx("div",{className:"workbench-notification-toolbar",children:s.jsxs("label",{className:"workbench-notification-filter",children:[s.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),s.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?s.jsx("div",{className:"workbench-notification-list",children:r.map(i=>{const o=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":o,children:[s.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[s.jsx("span",{className:"workbench-notification-item-kind",children:qM(i.kind)}),s.jsx("strong",{children:i.title}),s.jsx("p",{children:i.body})]}),s.jsxs("div",{className:"workbench-notification-item-side",children:[s.jsx("time",{children:JM(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(o){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:o?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):s.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):s.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:s.jsx(ib,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),s.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:s.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function FR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function $R(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function zR(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function HR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M13 15h4"})]})}function UR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"11",r:"1"}),s.jsx("circle",{cx:"15",cy:"11",r:"1"}),s.jsx("path",{d:"M8 15h8"}),s.jsx("path",{d:"M12 5V3"})]})}function qR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),s.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Ob(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),s.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function GR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),s.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function VR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function KR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),s.jsx("path",{d:"M14 16l2 2 4-4"})]})}function YR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),s.jsx("path",{d:"M10 12h8"}),s.jsx("path",{d:"M15 8l4 4-4 4"})]})}function XR({selected:e}){return e?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),s.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Wb({active:e,className:t}){return e?s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function JR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7h18"}),s.jsx("path",{d:"M5 7l1 12h12l1-12"}),s.jsx("path",{d:"M9 11h6"}),s.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function QR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function ZR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 4v10"}),s.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),s.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function eA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 14h10l1-14"}),s.jsx("path",{d:"M10 11v5"}),s.jsx("path",{d:"M14 11v5"})]})}function tA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M9 13h6"})]})}function nA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function rA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:o,codeError:a,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:m,onCodeSearch:g,onOpenSession:x}){const S=n.trim().length>0&&r.trim().length>0;return s.jsx(Nt,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:s.jsxs("div",{className:"workbench-search-modal",children:[s.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[s.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>h("sessions"),children:l("shell.searchModeSessions")}),s.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>h("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:C=>p(C.target.value)})]}),s.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(C=>{const y=Gu(C.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>x(C.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:y.fullTitle,children:y.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[C.workspace.name," · ",Xa(C.session.provider,"full")]})]},C.session.sessionId)}):s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchWorkspaceLabel")}),s.jsx("select",{value:r,onChange:C=>m(C.target.value),children:c.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:C=>{C.preventDefault(),g()},children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:C=>p(C.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||o,children:o?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[a?s.jsx("p",{className:"status-text","data-tone":"error",children:a}):null,!a&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!a&&n.trim().length>0&&!o&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(C=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:C.name}),s.jsx("span",{className:"workbench-search-result-meta",children:C.path})]},`${C.path}-${C.kind}`))]})]})]})})}const sA=`
72
+ html,
73
+ body {
74
+ width: 100% !important;
75
+ height: auto !important;
76
+ min-height: auto !important;
77
+ overflow: visible !important;
78
+ overflow-x: visible !important;
79
+ }
80
+
81
+ body {
82
+ margin: 0 !important;
83
+ padding: 0 !important;
84
+ }
85
+
86
+ .session-export-document-root {
87
+ position: static !important;
88
+ inset: auto !important;
89
+ z-index: auto !important;
90
+ opacity: 1 !important;
91
+ pointer-events: auto !important;
92
+ overflow: visible !important;
93
+ }
94
+
95
+ .session-export-document-root,
96
+ .session-export-document-root * {
97
+ font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif);
98
+ letter-spacing: normal !important;
99
+ word-spacing: normal !important;
100
+ text-align: left !important;
101
+ -webkit-text-fill-color: currentColor !important;
102
+ text-fill-color: currentColor !important;
103
+ -webkit-background-clip: border-box !important;
104
+ background-clip: border-box !important;
105
+ text-shadow: none !important;
106
+ mix-blend-mode: normal !important;
107
+ }
108
+
109
+ .session-export-document-root .markdown-content p,
110
+ .session-export-document-root .markdown-content blockquote,
111
+ .session-export-document-root .markdown-content td {
112
+ display: block !important;
113
+ }
114
+
115
+ .session-export-document-root .markdown-content li {
116
+ display: list-item !important;
117
+ }
118
+
119
+ .session-export-document-root .markdown-content code,
120
+ .session-export-document-root .markdown-content pre,
121
+ .session-export-document-root .code-block pre,
122
+ .session-export-document-root .tool-call-section pre,
123
+ .session-export-document-root .tool-call-input-preview,
124
+ .session-export-document-root .apply-patch-line-content,
125
+ .session-export-document-root .apply-patch-summary-file {
126
+ font-family:
127
+ var(--font-mono, "SF Mono", "Consolas", "Cascadia Code", "Courier New", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", monospace) !important;
128
+ }
129
+
130
+ .session-export-document-root .thinking-message-label,
131
+ .session-export-document-root .thinking-status-text {
132
+ background: none !important;
133
+ color: var(--text-secondary, #475569) !important;
134
+ -webkit-text-fill-color: currentColor !important;
135
+ animation: none !important;
136
+ }
137
+
138
+ @media print {
139
+ body * {
140
+ visibility: hidden;
141
+ }
142
+
143
+ .session-export-document-root,
144
+ .session-export-document-root * {
145
+ visibility: visible;
146
+ }
147
+
148
+ .session-export-document-root {
149
+ position: static !important;
150
+ }
151
+
152
+ .session-export-document-root .session-export-print-shell {
153
+ width: 100%;
154
+ max-width: none;
155
+ margin: 0;
156
+ padding: 0;
157
+ }
158
+
159
+ .session-export-document-root .message-timeline-export,
160
+ .session-export-document-root .message-timeline-export .message-list-export {
161
+ overflow: visible;
162
+ height: auto;
163
+ max-height: none;
164
+ }
165
+
166
+ .session-export-document-root .tool-call-header,
167
+ .session-export-document-root .tool-call-info,
168
+ .session-export-document-root .task-tool-header,
169
+ .session-export-document-root .task-tool-heading,
170
+ .session-export-document-root .task-tool-heading-main,
171
+ .session-export-document-root .task-tool-list-item,
172
+ .session-export-document-root .assistant-capability-header,
173
+ .session-export-document-root .assistant-capability-heading,
174
+ .session-export-document-root .assistant-capability-heading-main,
175
+ .session-export-document-root .assistant-capability-row,
176
+ .session-export-document-root .apply-patch-summary-row,
177
+ .session-export-document-root .rules-message-toggle {
178
+ display: flex !important;
179
+ flex-wrap: wrap !important;
180
+ align-items: flex-start !important;
181
+ justify-content: flex-start !important;
182
+ }
183
+
184
+ .session-export-document-root .task-tool-list-item,
185
+ .session-export-document-root .assistant-capability-row,
186
+ .session-export-document-root .apply-patch-summary-row {
187
+ row-gap: 4px !important;
188
+ }
189
+
190
+ .session-export-document-root .tool-call-input-preview,
191
+ .session-export-document-root .rules-message-summary,
192
+ .session-export-document-root .task-tool-summary-text,
193
+ .session-export-document-root .task-tool-item-title,
194
+ .session-export-document-root .task-tool-item-detail,
195
+ .session-export-document-root .task-tool-item-status,
196
+ .session-export-document-root .assistant-capability-heading-main strong,
197
+ .session-export-document-root .assistant-capability-summary,
198
+ .session-export-document-root .assistant-capability-row-label,
199
+ .session-export-document-root .assistant-capability-row-value,
200
+ .session-export-document-root .apply-patch-summary-file,
201
+ .session-export-document-root .apply-patch-summary-stats,
202
+ .session-export-document-root .session-title,
203
+ .session-export-document-root .message-text,
204
+ .session-export-document-root .markdown-content,
205
+ .session-export-document-root .thinking-message-text,
206
+ .session-export-document-root .thinking-message-text :where(p, li, blockquote, strong, em, a, span),
207
+ .session-export-document-root .thinking-message-label,
208
+ .session-export-document-root .thinking-status-text {
209
+ white-space: normal !important;
210
+ overflow: visible !important;
211
+ text-overflow: clip !important;
212
+ word-break: break-word !important;
213
+ overflow-wrap: anywhere !important;
214
+ }
215
+
216
+ .session-export-document-root .assistant-capability-summary {
217
+ display: inline !important;
218
+ }
219
+
220
+ .session-export-document-root .task-tool-list {
221
+ list-style: decimal !important;
222
+ padding-left: 24px !important;
223
+ }
224
+
225
+ .session-export-document-root .message-timeline-export .conversation-scroll-to-bottom-button,
226
+ .session-export-document-root .message-timeline-export .message-metadata-bar,
227
+ .session-export-document-root .message-timeline-export .retry-button,
228
+ .session-export-document-root .message-timeline-export .code-copy-button,
229
+ .session-export-document-root .message-timeline-export .rules-message-action,
230
+ .session-export-document-root .message-timeline-export .message-origin-detail-popover {
231
+ display: none !important;
232
+ }
233
+
234
+ .session-export-document-root .message-item,
235
+ .session-export-document-root .tool-message-row,
236
+ .session-export-document-root .rules-message-row {
237
+ break-inside: avoid;
238
+ page-break-inside: avoid;
239
+ }
240
+ }
241
+ `;function iA({menuKey:e,session:t,workspace:n,workspaceContext:r,isActive:i,isFavorite:o,menuOpen:a,menuAnchorPoint:c,showWorkspaceName:u,depth:d=0,showActions:h=!0,exportDisabled:p=!1,hasSubagents:m=!1,subagentListExpanded:g=!1,showParallelBadge:x=!0,selectionMode:S=!1,selected:C=!1,onToggleSelect:y,onToggleSubagents:A,onOpen:T,onRename:G,onOpenContextMenu:P,onExport:E,onToggleFavorite:V,onArchive:U,onDelete:L,onCloseMenu:I}){var Ge,Ke,ft,F;const H=vn(),_=nu(t.provider).supportsSessionDelete===!0,se=!H.isDesktop&&!H.isMobile,Y=_a(t)?((Ge=t.subagentLabel)==null?void 0:Ge.trim())||l("shell.subagentBadge"):null,W=Gu(t.title,l("common.unknown")),q=qj(t),D=q?Gj("session-activity-badge",t):null,K=zu(t),ee=uI(t),v=x&&((Ke=t.parallelGroup)==null?void 0:Ke.role)==="anchor"?cx(t.parallelGroup):null,Ce=ax(t.parallelGroup),je=f.useRef(null),[N,ce]=f.useState(null),[Ie,fe]=f.useState(!1);f.useEffect(()=>{a||fe(!1)},[a]),f.useLayoutEffect(()=>{if(H.isDesktop||!a||!c||typeof window>"u"){ce(null);return}const te=()=>{var ve,Se;const re=DE(c,{width:((ve=je.current)==null?void 0:ve.offsetWidth)??0,height:((Se=je.current)==null?void 0:Se.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:_&&L?216:168});ce({position:"fixed",top:`${Math.round(re.top)}px`,left:`${Math.round(re.left)}px`,width:`${Math.round(re.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(re.maxHeight)}px`,transformOrigin:re.transformOrigin})};return te(),window.addEventListener("resize",te),window.addEventListener("scroll",te,!0),()=>{window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0)}},[c,a,H.isDesktop]);async function oe(){await sx([{id:`rename:${t.sessionId}`,label:l("shell.renameAction"),onSelect:G},{id:`export:${t.sessionId}`,label:l("conversation.exportAction"),disabled:p,items:[{id:`export-markdown:${t.sessionId}`,label:l("conversation.exportMarkdownAction"),onSelect:()=>E("md")},{id:`export-pdf:${t.sessionId}`,label:l("conversation.exportPdfAction"),onSelect:()=>E("pdf")},{id:`export-html:${t.sessionId}`,label:l("conversation.exportHtmlAction"),onSelect:()=>E("html")}]},{id:`favorite:${t.sessionId}`,label:o?l("shell.unfavoriteAction"):l("shell.favoriteAction"),onSelect:V},{id:`archive:${t.sessionId}`,label:l("shell.archiveAction"),onSelect:U},..._&&L?[{id:`delete:${t.sessionId}`,label:l("shell.deleteSessionAction"),onSelect:L}]:[]])}const _e=!H.isDesktop&&a&&typeof document<"u"?or.createPortal(s.jsxs("div",{ref:je,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":l("shell.sessionMoreAction"),onClick:te=>te.stopPropagation(),style:N??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{G(),I()},children:[s.jsx(QR,{}),s.jsx("span",{children:l("shell.renameAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{V(),I()},children:[s.jsx(Wb,{active:o}),s.jsx("span",{children:o?l("shell.unfavoriteAction"):l("shell.favoriteAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{U(),I()},children:[s.jsx(JR,{}),s.jsx("span",{children:l("shell.archiveAction")})]}),se?s.jsxs("div",{className:"workbench-session-submenu","data-open":Ie,children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item","aria-haspopup":"menu","aria-expanded":Ie,onClick:()=>{fe(te=>!te)},children:[s.jsx(ZR,{}),s.jsx("span",{children:l("conversation.exportAction")}),s.jsx("span",{className:"workbench-session-submenu-caret","aria-hidden":"true",children:s.jsx(Qs,{expanded:Ie})})]}),Ie?s.jsxs("div",{className:"workbench-session-submenu-panel",role:"menu","aria-label":l("conversation.exportAction"),children:[s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{E("md"),I()},children:s.jsx("span",{children:l("conversation.exportMarkdownAction")})}),s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{E("pdf"),I()},children:s.jsx("span",{children:l("conversation.exportPdfAction")})}),s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{E("html"),I()},children:s.jsx("span",{children:l("conversation.exportHtmlAction")})})]}):null]}):null,_&&L?s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{L(),I()},children:[s.jsx(eA,{}),s.jsx("span",{children:l("shell.deleteSessionAction")})]}):null]}),document.body):null;return s.jsxs("article",{className:"workbench-session-card","data-active":i,"data-depth":d,"data-subagent":_a(t),"data-workspace-tone":r.tone,"data-worktree-depth":r.depth,"data-has-subagents":m,"data-selecting":S,"data-selected":C,"data-parallel-group":t.parallelGroup?"true":void 0,"data-parallel-role":((ft=t.parallelGroup)==null?void 0:ft.role)??void 0,"data-parallel-color-token":((F=t.parallelGroup)==null?void 0:F.colorToken)??void 0,style:{...ir(r)??{},...Ce??{}},onContextMenu:te=>{if(!(S||!h||!P)){if(te.preventDefault(),te.stopPropagation(),H.isDesktop){oe();return}P({x:te.clientX,y:te.clientY})}},children:[s.jsxs("div",{className:"workbench-session-main",children:[S?s.jsx("span",{className:"workbench-session-selection-indicator","data-selected":C,"aria-hidden":"true",children:s.jsx(XR,{selected:C})}):m?s.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:gR,"data-indicator-variant":bR(t,{hasSubagents:!0,isActive:i}),"aria-label":g?l("shell.subagentCollapse"):l("shell.subagentExpand"),title:g?l("shell.subagentCollapse"):l("shell.subagentExpand"),"aria-expanded":g,onClick:te=>{te.stopPropagation(),A==null||A()},children:[s.jsx("span",{className:$p(t,{hasSubagents:!0,isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),s.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:s.jsx(Qs,{expanded:g})})]}):s.jsx("span",{className:$p(t,{isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),s.jsx("button",{type:"button",className:"workbench-session-link",style:m?mR:void 0,"data-active":i,"aria-pressed":S?C:void 0,onClick:S?y:T,onKeyDown:te=>{if(S||!h||!P||te.key!=="ContextMenu"&&!(te.shiftKey&&te.key==="F10"))return;if(te.preventDefault(),te.stopPropagation(),H.isDesktop){oe();return}const re=te.currentTarget.getBoundingClientRect();P({x:re.right,y:re.bottom})},children:s.jsxs("div",{className:"workbench-session-link-copy",children:[s.jsxs("div",{className:"session-title-row",children:[s.jsx("span",{className:"session-title",title:W.fullTitle,children:W.displayTitle}),Y?s.jsx("span",{className:"session-subagent-badge",children:Y}):null,v?s.jsx("span",{className:"session-parallel-badge",children:v}):null,!v&&ee&&K?s.jsx("span",{className:`session-fork-badge ${K}`,children:ee}):null]}),s.jsxs("div",{className:"session-meta-row",children:[s.jsx("span",{className:"session-meta",children:kb(t,n,u,r.displayName)}),q&&D?s.jsx("span",{className:D,children:q}):null,s.jsx("span",{className:`session-provider-badge ${t.provider}`,children:Xa(t.provider)})]})]})})]}),_e]})}async function oA(e,t=document){await ef(),await ef(),await Ku(420),await lA(t,1800),e&&await cA(e,1800)}function aA(){if(typeof document>"u")return"";const e=[];for(const t of Array.from(document.styleSheets))try{const n=t.cssRules;if(!n||n.length===0)continue;e.push(Array.from(n).map(r=>r.cssText).join(`
242
+ `))}catch{continue}return e.join(`
243
+ `)}function Zp(e){const t={};for(const n of Array.from(e.attributes))n.name!=="style"&&(t[n.name]=n.value);return t}function ef(){return new Promise(e=>{window.requestAnimationFrame(()=>e())})}function Ku(e){return new Promise(t=>{window.setTimeout(t,e)})}async function lA(e,t){const n=e.fonts;!n||typeof n.ready>"u"||await Promise.race([n.ready.catch(()=>{}),Ku(t)])}async function cA(e,t){const n=Array.from(e.querySelectorAll("img"));n.length!==0&&await Promise.race([Promise.all(n.map(r=>dA(r))),Ku(t)])}function uA(){if(typeof document>"u")return{shellWidthPx:null};const e=[".conversation-timeline-shell",".conversation-main",".conversation-panel"];for(const t of e){const n=document.querySelector(t);if(!(n instanceof HTMLElement))continue;const r=n.getBoundingClientRect();if(!(!Number.isFinite(r.width)||r.width<=0))return{shellWidthPx:Math.round(r.width)}}return{shellWidthPx:null}}function dA(e){return e.complete?Promise.resolve():new Promise(t=>{const n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),t()};e.addEventListener("load",n),e.addEventListener("error",n)})}function tf({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:n,favoriteSessions:r,favoriteSessionIds:i,activeWorkspaceId:o,isConversationActive:a,isTerminalActive:c,isButlerActive:u,isSearchOpen:d,navigationLoading:h,navigationError:p,activeSessionId:m,onRefreshNavigation:g,onSessionUpdated:x,onNavigateConversation:S,onNavigateTerminals:C,onNavigateButler:y,onOpenSearch:A,onOpenSettings:T,onSelectWorkspace:G,onToggleWorkspaceCollapse:P,onStartWorkspaceReorder:E,onPreviewWorkspaceReorder:V,onCommitWorkspaceReorder:U,allowWorkspaceReorder:L,subscribeGitSnapshot:I,requestGitRefresh:H,subscribeWorkspaceManagementSnapshot:_,requestWorkspaceManagementRefresh:se,onToggleFavoriteSession:Y,onArchiveSession:W,onUnarchiveSession:q,workspaceManagementStateById:D,setWorkspaceManagementStateById:K,unreadNotificationCount:ee,notificationPanelOpen:v,onToggleNotificationPanel:Ce,onClose:je,onToggleCollapse:N}){var ji;const ce=io(),Ie=vn(),fe=Uf(Ie),{showToast:oe}=Pn(),_e=_u(),Ge=Qc(k=>k),Ke=((ji=cc(Ge))==null?void 0:ji.name)??"",ft=Ge.hosts.length+cf(Ge).length>1&&Ke.length>0,[F,te]=f.useState(!1),[re,ve]=f.useState(!1),[Se,ye]=f.useState(!1),[ze,Ve]=f.useState([]),[Je,j]=f.useState(null),[$,ie]=f.useState(null),[me,we]=f.useState(null),[z,J]=f.useState(null),[he,ke]=f.useState(null),[De,We]=f.useState(null),[mt,Ze]=f.useState(null),[ht,lt]=f.useState(!1),[Ye,et]=f.useState(!1),[bt,Ht]=f.useState(""),[B,ue]=f.useState(""),[de,Pe]=f.useState(""),[ge,Ut]=f.useState({localBranches:[],remoteBranches:[],tags:[]}),[kt,wt]=f.useState(!1),[er,jt]=f.useState(-1),[Ln,hn]=f.useState(!1),[ps,tr]=f.useState(!1),[cr,ur]=f.useState(null),[Dn,mo]=f.useState(null),[ui,di]=f.useState(null),[dr,go]=f.useState(null),[pn,_r]=f.useState(null),[Br,Or]=f.useState(null),[Bt,Ot]=f.useState(null),[fn,bo]=f.useState(!1),[At,mn]=f.useState(null),[ct,Wr]=f.useState(null),[hr,pr]=f.useState(null),[rn,fs]=f.useState(null),[Fr,$r]=f.useState(sc),[fr,_n]=f.useState({}),[hi,ms]=f.useState({}),[Qa,ko]=f.useState([]),[Bn,pi]=f.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[qt,mr]=f.useState(null),[zr,gr]=f.useState(""),[Hr,Gt]=f.useState(null),[xt,Vt]=f.useState(null),[Mt,Jt]=f.useState([]),[br,fi]=f.useState(!1),[Ur,On]=f.useState({}),[gs,kr]=f.useState(null),Wn=f.useRef(null),xr=f.useRef(null),yr=f.useRef(null),Fn=f.useRef(null),bs=f.useRef(new Map),qr=f.useRef(null),ks=f.useRef(null),wr=f.useRef(null),xo=f.useMemo(()=>new Set(Bn.expandedWorkspaceIds),[Bn.expandedWorkspaceIds]),yo=f.useMemo(()=>new Set(Bn.collapsedWorkspaceIds),[Bn.collapsedWorkspaceIds]),$n=gs!==null,Sn=L&&Ie.isDesktop&&Ie.ui.osFamily==="macos",vr=f.useMemo(()=>lR(e,n),[e,n]),Fe=f.useMemo(()=>{const k=new Map;for(const M of e){k.set(M.workspace.id,Gs(M).map(O=>Gc(vr,O.item.sessionId)??O));for(const O of vb(M.childWorktrees)){const Q=O.visibleSessionTree.map(ne=>Gc(vr,ne.item.sessionId)??ne).filter(ne=>ne.item.workspaceId===O.workspace.id&&ne.depth===0);k.set(O.workspace.id,Q)}}return k},[vr,e]),st=f.useCallback(()=>{mn(null),Wr(null)},[]),it=f.useCallback((k,M)=>{mn(k),Wr(M)},[]),tt=ac(e,he)??((mt==null?void 0:mt.id)===he?mt:null),nr=de.trim().toLowerCase(),zn=f.useMemo(()=>[{key:"localBranches",label:l("shell.createWorktreeBaseRefLocalGroup"),items:ge.localBranches},{key:"remoteBranches",label:l("shell.createWorktreeBaseRefRemoteGroup"),items:ge.remoteBranches},{key:"tags",label:l("shell.createWorktreeBaseRefTagGroup"),items:ge.tags}].map(M=>({...M,items:M.items.filter(O=>nr?O.value.toLowerCase().includes(nr):!0)})).filter(M=>M.items.length>0),[nr,ge]),Kt=f.useMemo(()=>zn.flatMap(k=>k.items),[zn]),Cn=tt?`create-worktree-base-ref-listbox-${tt.id}`:"create-worktree-base-ref-listbox",Wt=CR(e,dr),Nn=Wt?qn(Wt.workspace):null,xs=(Wt==null?void 0:Wt.archivedSessions)??[],{searchOpen:ys,searchKeyword:mi,filteredSessions:Pt,summaryLoading:Tt,summaryError:jn,summaryBySessionId:ws,setSearchKeyword:gi,toggleSearch:bi}=CM(Wt!==null,xs),Me=f.useId(),Hn=f.useMemo(()=>SR(e,xt),[xt,e]),Gr=f.useMemo(()=>Hn?hR(Hn.visibleSessionTree):[],[Hn]),Qt=f.useMemo(()=>Gr.map(k=>k.sessionId),[Gr]),Sr=f.useMemo(()=>new Set(Qt),[Qt]),Za=f.useMemo(()=>new Set(Mt),[Mt]),Vr=Qt.length>0&&Mt.length===Qt.length;f.useEffect(()=>{K(k=>{const M=Kp(e),O=new Set(M),Q={};Object.entries(k).forEach(([pe,He])=>{O.has(pe)&&(Q[pe]=He)}),M.forEach(pe=>{const He=ac(e,pe);if(!He)return;const gt=ya(Yc(pe),Rp),ut=ya(Ab(pe),Rp),Et=Q[pe];let kn=Lb((Et==null?void 0:Et.detail)??gt??Pb(He),He);(ut!=null&&ut.status||ut!=null&&ut.branches)&&(kn=Db(kn,{status:ut.status??null,branches:ut.branches??null})),Q[pe]={detail:kn,loading:!1,error:null}});const ne=Object.keys(k),Re=Object.keys(Q);return ne.length===Re.length&&Re.every(pe=>k[pe]===Q[pe])?k:Q})},[e]);const sn=f.useCallback(async k=>{await g(),await Ie.bridge.showNotification(l("shell.importSuccess"),k.path)},[g,Ie.bridge]),vt=f.useCallback(async k=>{await g(),await Ie.bridge.showNotification(l("shell.cloneSuccess"),k.path)},[g,Ie.bridge]);function Kr(k){if(ze.includes(k)){Ve(O=>O.filter(Q=>Q!==k));return}Ve(O=>[...O,k]),I(k),H(k),_(k),se(k)}async function ki(k,M){if(Ur[k])return;const O=(M==null?void 0:M.trim().toUpperCase())??null;On(Q=>({...Q,[k]:!0}));try{await mf(k,{backgroundColor:O}),await g()}catch(Q){oe({title:Q instanceof Error?Q.message:l("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{On(Q=>({...Q,[k]:!1}))}}async function vs(){if(!(!Je||$)){ie(Je.id);try{await Bk(Je.id),Ve(k=>k.filter(M=>M!==Je.id)),K(k=>{const M={...k};return delete M[Je.id],M}),j(null),await g(),oe({title:l("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(k){oe({title:k instanceof Error?k.message:l("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{ie(null)}}}f.useEffect(()=>{if(!At)return;function k(M){const O=M.target;O instanceof HTMLElement&&O.closest(".workbench-session-menu")||st()}return window.addEventListener("pointerdown",k),()=>{window.removeEventListener("pointerdown",k)}},[st,At]),f.useEffect(()=>{if(!xt){Mt.length>0&&Jt([]),Bt&&Ot(null);return}if(!Hn){Vt(null),Jt([]),Ot(null);return}Jt(k=>Ib(k,Sr))},[Hn,Bt,Sr,xt,Mt.length]),f.useEffect(()=>{xt&&Qt.length===0&&(Vt(null),Jt([]),Ot(null))},[Qt.length,xt]),f.useEffect(()=>{const k=new Set(Kp(e)),M=new Set(e.flatMap(O=>Kc(O.childWorktrees)));Ve(O=>O.filter(Q=>k.has(Q))),pi(O=>({expandedWorkspaceIds:O.expandedWorkspaceIds.filter(Q=>M.has(Q)),collapsedWorkspaceIds:O.collapsedWorkspaceIds.filter(Q=>M.has(Q))})),j(O=>O&&k.has(O.id)?O:null),On(O=>Object.fromEntries(Object.entries(O).filter(([Q,ne])=>ne&&k.has(Q))))},[e]),f.useEffect(()=>{const k=r.findIndex(M=>M.session.sessionId===m);$r(M=>{const O=la(r.length,sc,M,k);return O===M?M:O})},[m,r]),f.useEffect(()=>{_n(k=>{const M={};for(const O of e){const Q=Gs(O),ne=Q.findIndex(Re=>Re.item.sessionId===m||Hs([Re],m??"",pe=>pe.sessionId).length>0);M[O.workspace.id]=la(Q.length,Di,k[O.workspace.id],ne);for(const Re of zi(O.childWorktrees)){Re.item.sessionId===m||Hs([Re],m??"",ut=>ut.sessionId).length>0;const pe=Re.item.workspaceId;if(M[pe]!==void 0)continue;const He=zi(O.childWorktrees).filter(ut=>ut.item.workspaceId===pe&&ut.depth===0),gt=He.findIndex(ut=>ut.item.sessionId===m||Hs([ut],m??"",Et=>Et.sessionId).length>0);M[pe]=la(He.length,Di,k[pe],gt)}}return Fp(k,M)?k:M})},[m,e]),f.useEffect(()=>{ms(k=>{const M={};for(const O of e)for(const Q of[...Gs(O),...zi(O.childWorktrees)])for(const ne of ns(tn(Q))){const Re=tn(ne);if(Re.length===0)continue;const pe=ns(Re),He=pe.findIndex(gt=>gt.item.sessionId===m);M[ne.item.sessionId]=la(pe.length,oa,k[ne.item.sessionId],He)}return Fp(k,M)?k:M})},[m,e]),f.useEffect(()=>{if(!m)return;const k=e.flatMap(M=>[...Hs(Gs(M),m,O=>O.sessionId),...zi(M.childWorktrees).flatMap(O=>Hs([O],m,Q=>Q.sessionId))]);k.length!==0&&ko(M=>{const O=new Set(M);let Q=!1;for(const ne of k)O.has(ne)||(O.add(ne),Q=!0);return Q?Array.from(O):M})},[m,e]),f.useEffect(()=>{if(!o)return;const k=[];for(const M of e){const O=jb(M.childWorktrees,o);O.length!==0&&k.push(...O)}k.length>0&&pi(M=>{const O=new Set(M.expandedWorkspaceIds);let Q=!1;for(const ne of k)O.has(ne)||(O.add(ne),Q=!0);return Q?{expandedWorkspaceIds:Array.from(O),collapsedWorkspaceIds:M.collapsedWorkspaceIds}:M})},[o,e]),f.useEffect(()=>{if(!he){Ze(null),lt(!1),et(!1),Ht(""),ue(""),Pe(""),wt(!1),jt(-1),hn(!1),Ut({localBranches:[],remoteBranches:[],tags:[]}),tr(!1),ur(null);return}lt(!1),Ht(""),ue(""),Pe(""),wt(!1),jt(-1),hn(!1),Ut({localBranches:[],remoteBranches:[],tags:[]}),tr(!1),ur(null)},[he]),f.useEffect(()=>{const k=tt;if(!ht||!k)return;let M=!1;const O=k.id;return tr(!0),ur(null),Promise.all([nx(O),rx(O)]).then(([Q,ne])=>{M||Ut(KM(Q,ne))}).catch(()=>{M||(Ut({localBranches:[],remoteBranches:[],tags:[]}),ur(l("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{M||tr(!1)}),()=>{M=!0}},[tt==null?void 0:tt.id,ht]),f.useLayoutEffect(()=>{if(!kt||!Wn.current){mo(null),di(null);return}const k=()=>{const O=Wn.current;if(!O)return;const Q=YM(O);mo({top:Q.bottom+8,left:Q.left,width:Q.width})};k();const M=O=>{var ne,Re;const Q=O.target;Q instanceof Node&&((ne=Wn.current)!=null&&ne.contains(Q)||(Re=xr.current)!=null&&Re.contains(Q)||(wt(!1),jt(-1)))};return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),window.addEventListener("pointerdown",M),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),window.removeEventListener("pointerdown",M)}},[Kt.length,kt]),f.useLayoutEffect(()=>{if(!kt||!xr.current){di(null);return}const k=xr.current,M=()=>{const Q=Math.ceil(k.getBoundingClientRect().height);di(ne=>ne===Q?ne:Q)};if(M(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(()=>{M()});return O.observe(k),()=>{O.disconnect()}},[kt,zn,ps,cr]);function Yr(){te(!0)}function el(){ve(!0)}function Tn(k){gn(),ke(null),We({kind:"workspace",workspaceId:k.id,workspaceName:k.name})}function gn(){lt(!1),Ht(""),ue(""),Pe(""),wt(!1),jt(-1),hn(!1)}function xi(k,M){const O=k.getBoundingClientRect();return M<=O.top+O.height/2?"before":"after"}function yi(){Fn.current!==null&&(cancelAnimationFrame(Fn.current),Fn.current=null),kr(null)}function Cr(k){const M=(k==null?void 0:k.commit)??!1,O=(k==null?void 0:k.preserveClickSuppression)??!1,Q=qr.current,ne=ks.current;qr.current=null,ks.current=null,ne==null||ne(),Q!=null&&Q.dragging&&(yi(),M&&U(),!O&&wr.current===Q.workspaceId&&(wr.current=null))}function tl(k){if(wr.current===k){wr.current=null;return}P(k)}function In(k,M){if(M){bs.current.set(k,M);return}bs.current.delete(k)}function wo(k,M){for(const[O,Q]of bs.current){const ne=Q.getBoundingClientRect();if(k>=ne.left&&k<=ne.right&&M>=ne.top&&M<=ne.bottom)return{workspaceId:O,element:Q}}return null}function Ss(k,M){var He;if(!Sn||k.button!==0)return;Cr();const O=k.currentTarget,Q={pointerId:k.pointerId,workspaceId:M,startX:k.clientX,startY:k.clientY,pointerTarget:O,dragging:!1};qr.current=Q,(He=O.setPointerCapture)==null||He.call(O,k.pointerId);const ne=gt=>{Lt(gt)},Re=gt=>{rr(gt.pointerId,{commit:!0,preserveClickSuppression:!0})},pe=gt=>{rr(gt.pointerId,{commit:!1,preserveClickSuppression:!1})};ks.current=()=>{O.removeEventListener("pointermove",ne),O.removeEventListener("pointerup",Re),O.removeEventListener("pointercancel",pe),window.removeEventListener("pointermove",ne),window.removeEventListener("pointerup",Re),window.removeEventListener("pointercancel",pe)},O.addEventListener("pointermove",ne),O.addEventListener("pointerup",Re),O.addEventListener("pointercancel",pe),window.addEventListener("pointermove",ne,{passive:!1}),window.addEventListener("pointerup",Re),window.addEventListener("pointercancel",pe)}function Lt(k){const M=qr.current;if(!M||M.pointerId!==k.pointerId)return;if(!M.dragging){if(Math.hypot(k.clientX-M.startX,k.clientY-M.startY)<PM)return;M.dragging=!0,wr.current=M.workspaceId,E(),kr(M.workspaceId)}k.preventDefault();const O=wo(k.clientX,k.clientY);!O||O.workspaceId===M.workspaceId||V(M.workspaceId,O.workspaceId,xi(O.element,k.clientY))}function rr(k,M){var Q,ne;const O=qr.current;!O||O.pointerId!==k||((ne=(Q=O.pointerTarget).releasePointerCapture)==null||ne.call(Q,k),Cr(M))}function wi(k){Lt(k)}function nl(k){rr(k.pointerId,{commit:!0,preserveClickSuppression:!0})}function rl(k){rr(k.pointerId,{commit:!1,preserveClickSuppression:!1})}function vo(k,M){k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",M),E(),Fn.current!==null&&cancelAnimationFrame(Fn.current),Fn.current=requestAnimationFrame(()=>{Fn.current=null,kr(M)})}function sl(k,M){const O=gs||k.dataTransfer.getData("text/plain");!O||O===M||(k.preventDefault(),k.dataTransfer.dropEffect="move",V(O,M,xi(k.currentTarget,k.clientY)))}function il(k){k.preventDefault()}function ol(){yi(),U()}f.useEffect(()=>()=>{Cr()},[]);function al(k){return hi[k]??oa}function ll(k){return Qa.includes(k)}function Cs(k){return fr[k]??Di}function cl(){$r(k=>Math.min(r.length,k+sc))}function So(k,M){_n(O=>({...O,[k]:Math.min(M,(O[k]??Di)+Di)}))}function sr(k){ms(M=>({...M,[k]:(M[k]??oa)+oa}))}function Ns(k){ko(M=>M.includes(k)?M.filter(O=>O!==k):[...M,k])}function Xr(k,M){return yo.has(k)?!1:M||xo.has(k)}function Co(k,M){const O=!Xr(k,M);pi(Q=>{const ne=Q.expandedWorkspaceIds.filter(pe=>pe!==k),Re=Q.collapsedWorkspaceIds.filter(pe=>pe!==k);return O?{expandedWorkspaceIds:[...ne,k],collapsedWorkspaceIds:Re}:{expandedWorkspaceIds:ne,collapsedWorkspaceIds:[...Re,k]}})}function No(k){const M=ns(vr).find(O=>O.item.sessionId===k)??null;return M?tn(M):[]}function vi(k,M){const O=qn(k);return s.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":O.tone,style:ir(O),onClick:()=>go(k.id),children:[s.jsxs("span",{className:"workbench-archive-folder-main",children:[s.jsx(tA,{}),s.jsx("span",{children:l("shell.archiveFolderLabel")})]}),s.jsx("span",{className:"workbench-section-counter",children:M.length})]})}function js(){return s.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[s.jsx("span",{className:"workbench-workspace-batch-label",children:l("shell.batchSelectionMode")}),s.jsxs("span",{className:"workbench-workspace-batch-counter",children:[Mt.length,"/",Qt.length]}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:dl,children:Vr?l("shell.clearSelectedSessions"):l("shell.selectAllSessions")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Mt.length===0||br||fn,onClick:()=>{Es()},children:br?l("shell.batchArchiving"):l("shell.batchArchiveAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action danger",disabled:Mt.length===0||br||fn,onClick:Io,children:fn?l("shell.batchDeleting"):l("shell.batchDeleteAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:To,children:l("common.cancel")})]})}function Si(k,M="workbench-workspace-actions"){return s.jsxs("div",{className:M,children:[s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.switchWorkspace"),title:l("shell.switchWorkspace"),"aria-pressed":o===k,onClick:()=>{G(k),je==null||je()},children:s.jsx(YR,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.batchSelectSessions"),title:l("shell.batchSelectSessions"),onClick:()=>ul(k),children:s.jsx(KR,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":l("shell.createSession"),title:l("shell.createSession"),onClick:()=>ke(k),children:s.jsx(FR,{})})]})}function jo(k){const M=Fe.get(k.workspace.id)??k.visibleSessionTree,Q=new Set(Kc(k.children)).has(o??""),ne=k.workspace.id===o||Q,Re=$n||!Xr(k.workspace.id,ne),pe=qn(k.workspace);return s.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":xt===k.workspace.id,"data-worktree-depth":k.meta.depth,"data-workspace-tone":"worktree",style:ir(pe),children:[s.jsxs("div",{className:"workbench-workspace-header minimal",children:[s.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":Re?l("shell.worktreeExpand"):l("shell.worktreeCollapse"),onClick:()=>Co(k.workspace.id,ne),children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(Qs,{expanded:!Re})}),s.jsxs("span",{children:[s.jsx("strong",{children:k.meta.displayName||k.workspace.name}),s.jsx("span",{className:"session-meta",children:k.meta.branchName})]})]}),xt===k.workspace.id?js():Si(k.workspace.id)]}),Re?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-session-list","data-workspace-tone":pe.tone,style:ir(pe),children:[M.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,Cs(k.workspace.id)).map(He=>Jr({node:He,workspace:k.workspace,workspaceContext:pe,menuKeyPrefix:`worktree:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:xt===k.workspace.id,favoriteEnabled:!0})),M.length>Cs(k.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>So(k.workspace.id,M.length),children:l("shell.sessionExpandMore")}):null]}),k.children.length>0?s.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:k.children.map(He=>jo(He))}):null,vi(k.workspace,k.archivedSessions)]})]},k.workspace.id)}function Jr(k){var Xu,Ju,Qu,Zu;const{node:M,fullNode:O=M,branchKey:Q,subagentStateKey:ne,workspace:Re,workspaceContext:pe,menuKeyPrefix:He,showWorkspaceName:gt,selectionMode:ut,favoriteEnabled:Et,showParallelBadge:kn=!0,forceInactive:xn=!1,ancestorExpanded:Nr=!1,allowToggle:b=M.depth===0,ancestorHasNextSiblings:w=[],hasNextSibling:R=!1,isFirstSibling:X=!1}=k,Z=M.item,le=ac(e,Z.workspaceId)??Re,Ne=qn(le),Ee=tn(O),Ae=ne??Z.sessionId,be=ll(Ae),Xe=Nr&&tn(M).length>0,Zt=be,on=Xe||Zt,St=be&&b,En=Xe?M:St?pR(M,al(Ae),n):O,Ms=on?tn(En):[],zb=ns(Ee).length,Hb=ns(Ms).length,Ub=St&&Hb<zb,qb=M.depth>0?[...w,R]:[...w],Rs=((Ju=(Xu=Z.parallelGroup)==null?void 0:Xu.groupId)==null?void 0:Ju.trim())||null,ml=((Qu=Z.parallelGroup)==null?void 0:Qu.role)==="anchor"&&Rs?Ms.filter(Qe=>{var Ct;return((Ct=Qe.item.parallelGroup)==null?void 0:Ct.groupId)===Rs}):[],Gb=Ms.filter(Qe=>{var Ct;return((Ct=Qe.item.parallelGroup)==null?void 0:Ct.groupId)!==Rs}),Vb=((Zu=Z.parallelGroup)==null?void 0:Zu.role)==="anchor"&&Rs?Ee.filter(Qe=>{var Ct;return((Ct=Qe.item.parallelGroup)==null?void 0:Ct.groupId)===Rs}):[],Kb=Ee.filter(Qe=>{var Ct;return((Ct=Qe.item.parallelGroup)==null?void 0:Ct.groupId)!==Rs}),Yb=ml.length>0?Gb:[],Yu=ml.length>0?[Wp({session:Z,depth:M.depth+1,children:Yb.map(Qe=>qc(Qe,1))}),...ml].map((Qe,Ct)=>{const Ti=Ct===0,Xb=Wp({session:Z,depth:M.depth+1,children:Kb.map(gl=>qc(gl,1))});return{node:Qe,fullNode:Ti?Xb:Vb.find(gl=>gl.item.sessionId===Qe.item.sessionId)??Qe,branchKey:Ti?Op(Z.sessionId):void 0,subagentStateKey:Ti?Op(Z.sessionId):void 0,showParallelBadge:!Ti,forceInactive:Ti}}):Ms.map(Qe=>({node:Qe,fullNode:Ee.find(Ct=>Ct.item.sessionId===Qe.item.sessionId)??Qe}));return s.jsxs("div",{className:"workbench-session-tree-node",children:[s.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":M.depth},children:[M.depth>0?s.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[w.map((Qe,Ct)=>Qe?s.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":Ct+1}},`${Z.sessionId}:ancestor:${Ct}`):null),s.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":R,"data-first":X,style:{"--workbench-session-tree-level":M.depth},children:s.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,s.jsx(iA,{menuKey:`${He}:${Q??Z.sessionId}`,session:Z,workspace:le,workspaceContext:Ne,isActive:!xn&&Z.sessionId===m,isFavorite:Et&&i.has(Z.sessionId),menuOpen:At===`${He}:${Q??Z.sessionId}`,showWorkspaceName:gt,depth:M.depth,showActions:Et,exportDisabled:hr!==null,hasSubagents:b&&Ee.length>0,subagentListExpanded:Zt,showParallelBadge:kn,selectionMode:ut,selected:Za.has(Z.sessionId),onToggleSelect:()=>Ts(Z.sessionId),onToggleSubagents:()=>Ns(Ae),onOpen:()=>{ce(Mn(le.id,Z.sessionId)),je==null||je()},onRename:()=>Mo(Z,le),menuAnchorPoint:At===`${He}:${Q??Z.sessionId}`?ct:null,onOpenContextMenu:Qe=>it(`${He}:${Q??Z.sessionId}`,Qe),onExport:Qe=>Un(Z,Qe),onToggleFavorite:()=>Eo(Z.sessionId),onArchive:()=>bn(Z.sessionId),onDelete:nu(Z.provider).supportsSessionDelete===!0?()=>{st(),_r({session:Z,workspace:le})}:void 0,onCloseMenu:st})]}),Ee.length>0&&on?s.jsxs("div",{className:"workbench-subsession-list",children:[Yu.map((Qe,Ct)=>Jr({node:Qe.node,fullNode:Qe.fullNode,branchKey:Qe.branchKey,subagentStateKey:Qe.subagentStateKey,workspace:Re,workspaceContext:pe,menuKeyPrefix:He,showWorkspaceName:gt,selectionMode:ut,favoriteEnabled:Et,showParallelBadge:Qe.showParallelBadge,forceInactive:Qe.forceInactive,allowToggle:!0,ancestorHasNextSiblings:qb,hasNextSibling:Ct<Yu.length-1,isFirstSibling:Ct===0})),Ub?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>sr(Ae),children:l("shell.subagentExpandMore")}):null]}):null]},Q??Z.sessionId)}function ul(k){st(),Vt(k),Jt([]),Ot(null)}function To(){Vt(null),Jt([]),Ot(null)}function Ts(k){Jt(M=>RR(M,k))}function dl(){Jt(k=>k.length===Qt.length?[]:Qt)}function Io(){if(!Hn||Mt.length===0||br||fn)return;const k=new Map(Gr.map(O=>[O.sessionId,O])),M=Mt.flatMap(O=>{const Q=k.get(O);return Q?[Q]:[]});M.length!==0&&(st(),Ot({workspace:Hn.workspace,sessions:M}))}async function hl(k,M){we(k),J(M);try{await ub(k,M),ke(null),ce(Df(k,M)),je==null||je()}catch(O){oe({title:O instanceof Error?O.message:l("shell.startSessionFailed"),tone:"error"})}finally{we(null),J(null)}}async function pl(k){if(k.preventDefault(),!tt||Ye)return;const M=bt.trim(),O=B.trim(),Q=de.trim();if(!M){oe({title:l("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!GM(M)){oe({title:l("shell.createWorktreeBranchInvalid"),tone:"error"});return}et(!0);try{const ne=await Ok({sourceWorkspaceId:tt.id,branchName:M,displayName:O||void 0,baseRef:Q||void 0});Ze(ne.workspace),G(ne.workspace.id),await g(),ke(ne.workspace.id),gn(),oe({title:l("shell.createWorktreeSucceeded",{name:ne.meta.displayName||ne.workspace.name}),tone:"success"})}catch(ne){oe({title:ne instanceof Error?ne.message:l("shell.createWorktreeFailed"),tone:"error"})}finally{et(!1)}}async function Eo(k){const M=i.has(k);st();try{await Y(k),oe({title:M?l("shell.favoriteRemoved"):l("shell.favoriteAdded"),tone:"success"})}catch(O){oe({title:O instanceof Error?O.message:l("shell.favoriteToggleFailed"),tone:"error"})}}async function bn(k){st();try{await W(k),oe({title:l("shell.archiveAdded"),tone:"success"})}catch(M){oe({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}async function Un(k,M){var O,Q;if(!hr){st(),pr(k.sessionId);try{const ne=await sE(k.sessionId),Re=uA();if(M==="md"){const w=Yl(k,"md"),R=iE(k,ne.messages);Jh(w,R,"text/markdown;charset=utf-8"),oe({title:l("conversation.exportMarkdownSuccess"),tone:"success"});return}or.flushSync(()=>{fs({session:k,messages:ne.messages,shellWidthPx:Re.shellWidthPx})}),await oA(yr.current);const pe=((O=yr.current)==null?void 0:O.innerHTML.trim())??"";if(!pe)throw new Error(l("conversation.exportLoadFailed"));const He=Zp(document.documentElement),gt=document.body?Zp(document.body):{},ut=document.documentElement.getAttribute("style"),Et=((Q=document.body)==null?void 0:Q.getAttribute("style"))??null,kn=`${aA()}
244
+ ${sA}`,xn=lE({title:k.title||l("conversation.titleFallback"),bodyHtml:`<div class="session-export-document-root">${pe}</div>`,styleText:kn,htmlAttributes:He,bodyAttributes:gt,htmlStyle:ut,bodyStyle:Et});if(M==="html"){const w=Yl(k,"html");Jh(w,xn,"text/html;charset=utf-8"),oe({title:l("conversation.exportHtmlSuccess"),tone:"success"});return}const Nr=Yl(k,"pdf"),b=aE(k,ne.messages);oE(Nr,b,"application/pdf"),oe({title:l("conversation.exportPdfPreparing"),tone:"success"})}catch(ne){oe({title:ne instanceof Error?ne.message:l("conversation.exportLoadFailed"),tone:"error"})}finally{or.flushSync(()=>{fs(null)}),pr(null)}}}async function Is(){if(!pn||Br)return;const{session:k,workspace:M}=pn;Or(k.sessionId),st();try{await td(k.sessionId),Jt(O=>O.filter(Q=>Q!==k.sessionId)),_r(null),m===k.sessionId&&ce(M.id?ri(M.id):Yt()),await g(),oe({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(O){oe({title:O instanceof Error?O.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{Or(null)}}async function Es(){if(!(Mt.length===0||br||fn)){st(),fi(!0);try{const k=[...Mt],M=await Promise.allSettled(k.map(async ne=>({sessionId:ne,session:await ff(ne,!0)}))),O=[];let Q=0;for(const ne of M){if(ne.status==="fulfilled"){O.push(ne.value.sessionId),x(ne.value.session);continue}Q+=1}O.length>0&&(await g(),Jt(ne=>ne.filter(Re=>!O.includes(Re)))),Q>0?oe({title:O.length>0?l("shell.batchArchivePartialFailed"):l("shell.batchArchiveFailed"),tone:"error"}):oe({title:l("shell.batchArchiveSuccess"),tone:"success"})}catch(k){oe({title:k instanceof Error?k.message:l("shell.batchArchiveFailed"),tone:"error"})}finally{fi(!1)}}}async function Qr(){if(!Bt||fn)return;const{workspace:k,sessions:M}=Bt,O=M.map(Q=>Q.sessionId);if(O.length===0){Ot(null);return}bo(!0),st();try{const Q=await Promise.allSettled(O.map(async pe=>(await td(pe),pe))),ne=[];let Re=0;for(const pe of Q){if(pe.status==="fulfilled"){ne.push(pe.value);continue}Re+=1}if(ne.length>0&&(m&&ne.includes(m)&&ce(k.id?ri(k.id):Yt()),Jt(pe=>pe.filter(He=>!ne.includes(He))),await g()),Re>0){Ot(pe=>{if(!pe)return pe;const He=pe.sessions.filter(gt=>!ne.includes(gt.sessionId));return He.length>0?{...pe,sessions:He}:null}),oe({title:ne.length>0?l("shell.batchDeletePartialFailed"):l("shell.batchDeleteFailed"),tone:"error"});return}Ot(null),oe({title:l("shell.batchDeleteSuccess"),tone:"success"})}catch(Q){oe({title:Q instanceof Error?Q.message:l("shell.batchDeleteFailed"),tone:"error"})}finally{bo(!1)}}async function fl(k){st();try{await q(k),oe({title:l("shell.archiveRestored"),tone:"success"})}catch(M){oe({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}function Mo(k,M){st(),mr({session:k,workspace:M}),gr(k.title)}async function Ro(k){if(k.preventDefault(),!qt)return;const M=zr.trim();if(M){Gt(qt.session.sessionId);try{const O=await gf(qt.session.sessionId,M);x(O),mr(null),gr(""),oe({title:l("shell.renameSuccess"),tone:"success"})}catch(O){oe({title:O instanceof Error?O.message:l("shell.renameFailed"),tone:"error"})}finally{Gt(null)}}}const Ci=r.slice(0,Fr),Ao=Ci.length<r.length;function qn(k){return t[k.id]??Da(k)}function Ni(k,M,O,Q,ne=[]){var w;const Re=ze.includes(k.id),pe=D[k.id]??{detail:null,loading:!1,error:null},He=$===k.id,gt=Ur[k.id]===!0,ut=(w=pe.detail)!=null&&w.git.remotes.length?pe.detail.git.remotes.map(R=>`${R.name}: ${R.url}`).join(" · "):l("shell.manageWorkspaceNoRemote"),Et=pe.detail?EE(pe.detail.codeComposition.items,l("shell.manageWorkspaceCodeCompositionOther")):[],kn=Et.length>0?RE(Et):void 0,xn=qn(k),Nr=NR(xn,ne),b=[...ne,xn.displayName];return s.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":xn.tone,"data-worktree-node":Q,style:ir(xn),children:[s.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":Re,onClick:()=>Kr(k.id),children:[s.jsxs("span",{className:"workbench-manage-item-heading",children:[s.jsx(Qs,{expanded:Re}),s.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[s.jsx("strong",{children:xn.displayName}),s.jsx("span",{className:"workbench-manage-item-tree-path",children:Nr})]})]}),s.jsx("span",{className:"workbench-section-counter",children:M})]}),Re?s.jsxs("div",{className:"workbench-manage-item-body",children:[s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspacePathLabel")}),s.jsx("p",{className:"workbench-manage-detail-value",children:k.path})]}),Q?s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsxs("div",{className:"workbench-manage-detail-header",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceColorLabel")}),s.jsxs("div",{className:"workbench-manage-color-actions",children:[s.jsx("div",{className:"workbench-manage-color-palette","aria-label":l("shell.manageWorkspaceColorLabel"),children:BM.map(R=>s.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":l("shell.manageWorkspaceColorSelectSwatch",{color:R}),"aria-pressed":k.backgroundColor===R,disabled:gt,"data-selected":k.backgroundColor===R,style:{backgroundColor:R},onClick:()=>{ki(k.id,R)}},R))}),s.jsx("button",{type:"button",className:"ghost-button",disabled:gt||!k.backgroundColor,onClick:()=>{ki(k.id,null)},children:l("shell.manageWorkspaceColorClearAction")})]})]}),s.jsx("p",{className:"workbench-manage-hint",children:k.backgroundColor??l("shell.manageWorkspaceColorUnset")})]}):null,pe.loading&&pe.detail===null?s.jsx("p",{className:"workbench-manage-status status-text",children:l("shell.manageWorkspaceLoading")}):null,pe.error?s.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:pe.error}):null,pe.detail?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-manage-detail-block",children:s.jsxs("div",{className:"workbench-manage-detail-header",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitCommitCount")}),s.jsx("strong",{className:"workbench-manage-detail-accent",children:pe.detail.git.commitCount??"--"})]})}),s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitInfoLabel")}),pe.detail.git.isRepository?s.jsxs("div",{className:"workbench-manage-kv-list",children:[s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceRepoRoot")}),s.jsx("span",{children:pe.detail.git.repoRoot??"--"})]}),s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceCurrentBranch")}),s.jsx("span",{children:pe.detail.git.currentBranch??"--"})]}),s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceRemoteLabel")}),s.jsx("span",{children:ut})]})]}):s.jsx("p",{className:"workbench-section-empty",children:pe.detail.git.error??l("shell.manageWorkspaceNotGit")})]}),s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceCodeCompositionLabel")}),Et.length>0?s.jsxs("div",{className:"workbench-manage-type-chart",children:[s.jsxs("div",{className:"workbench-manage-type-chart-ring",style:kn,"aria-hidden":"true",children:[s.jsx("strong",{className:"workbench-manage-type-chart-total",children:pe.detail.codeComposition.scannedFileCount}),s.jsx("span",{className:"workbench-manage-type-chart-caption",children:l("shell.manageWorkspaceCodeCompositionFiles")})]}),s.jsx("div",{className:"workbench-manage-type-list",children:Et.map(R=>s.jsxs("div",{className:"workbench-manage-type-item",children:[s.jsxs("span",{className:"workbench-manage-type-meta",children:[s.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:R.color},"aria-hidden":"true"}),s.jsx("span",{className:"workbench-manage-type-name",children:R.type})]}),s.jsxs("span",{children:[R.count," · ",IE(R)]})]},R.key))})]}):s.jsx("p",{className:"workbench-section-empty",children:pe.detail.codeComposition.error??l("shell.manageWorkspaceNoCodeComposition")}),pe.detail.codeComposition.truncated?s.jsx("p",{className:"workbench-manage-hint",children:l("shell.manageWorkspaceCodeTruncated",{count:pe.detail.codeComposition.scannedFileCount})}):null]})]}):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ye(!1),ce(Mf(k.id))},children:l("shell.workspaceDetailDebugOpenPageAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!$,onClick:()=>j(k),children:He?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveAction")})]})]}):null,O.length>0?s.jsx("div",{className:"workbench-manage-children",children:O.map(R=>Ni(R.workspace,R.visibleSessions.length+R.archivedSessions.length,R.children,!0,b))}):null]},k.id)}return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":fe,children:s.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":fe,children:[N?s.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideSessionSidebar"),title:l("shell.hideSessionSidebar"),onClick:N,children:s.jsx(Ob,{})}):null,s.jsx(sb,{}),s.jsx(Bb,{unreadCount:ee,open:v,onToggle:Ce})]})}),s.jsxs("div",{ref:_e,className:"workbench-nav-body","data-scrollbar-autohide":"true",children:[s.jsxs("div",{className:"workbench-nav-segment",children:[s.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":l("shell.centerTabsLabel"),children:[s.jsxs("div",{className:"workbench-nav-segment-pair",children:[s.jsxs("button",{type:"button",className:a?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":a,onClick:S,children:[s.jsx(zR,{}),s.jsx("span",{children:l("shell.conversationEntry")})]}),s.jsxs("button",{type:"button",className:u?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":u,onClick:y,children:[s.jsx(UR,{}),s.jsx("span",{children:l("shell.butlerEntry")})]})]}),s.jsxs("button",{type:"button",className:c?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":c,onClick:C,children:[s.jsx(HR,{}),s.jsx("span",{children:l("shell.terminalsEntry")})]})]}),s.jsx(Uy,{triggerClassName:"workbench-nav-segment-button",triggerLabel:l("shell.skillsEntry"),triggerLeading:s.jsx(qR,{})}),s.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":d,"aria-haspopup":"dialog","aria-expanded":d,onClick:A,children:[s.jsx($R,{}),s.jsx("span",{children:l("shell.searchEntry")})]})]}),p?s.jsx("div",{className:"workbench-status-row",children:s.jsx("p",{className:"status-text","data-tone":"error",children:p})}):null,r.length>0?s.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[s.jsxs("div",{className:"workbench-section-heading",children:[s.jsxs("div",{className:"workbench-section-heading-main",children:[s.jsx(Wb,{active:!0,className:"workbench-favorite-heading-icon"}),s.jsx("span",{children:l("shell.favoriteSectionTitle")})]}),s.jsx("span",{className:"workbench-section-counter",children:r.length})]}),s.jsxs("div",{className:"workbench-session-list",children:[Ci.map(k=>{const M=No(k.session.sessionId);return s.jsx("div",{children:Jr({node:{item:k.session,depth:0,children:M},workspace:k.workspace,workspaceContext:qn(k.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},k.session.sessionId)}),Ao?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:cl,children:l("shell.favoriteExpandMore")}):null]})]}):null,h&&e.length===0?s.jsx(LR,{}):null,!h&&!p&&e.length===0?s.jsx("div",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.emptyNavigationBody")})}):null,s.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[s.jsxs("div",{className:"workbench-section-heading",children:[s.jsx("div",{className:"workbench-section-heading-main",children:s.jsx("span",{children:l("shell.workspaceSectionTitle")})}),s.jsxs("div",{className:"workbench-section-actions",children:[s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.manageWorkspaceAction"),title:l("shell.manageWorkspaceAction"),onClick:()=>ye(!0),children:s.jsx(BR,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.importWorkspaceTitle"),title:l("shell.importWorkspaceTitle"),onClick:Yr,children:s.jsx(_R,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.cloneWorkspaceTitle"),title:l("shell.cloneWorkspaceTitle"),onClick:el,children:s.jsx(GR,{})})]})]}),e.map(k=>{const M=Fe.get(k.workspace.id)??Gs(k),O=gs===k.workspace.id,Q=k.isCollapsed||$n;return s.jsxs("section",{className:"workbench-workspace-group",ref:ne=>In(k.workspace.id,ne),"data-workspace-group-id":k.workspace.id,"data-batch-active":xt===k.workspace.id,"data-dragging":O,onDragOver:ne=>sl(ne,k.workspace.id),onDrop:il,children:[s.jsxs("div",{className:"workbench-workspace-header minimal",children:[s.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":Q?l("shell.workspaceExpand"):l("shell.workspaceCollapse"),draggable:L&&!Sn,onClick:()=>tl(k.workspace.id),onPointerDown:Sn?ne=>Ss(ne,k.workspace.id):void 0,onPointerMove:Sn?wi:void 0,onPointerUp:Sn?nl:void 0,onPointerCancel:Sn?rl:void 0,onDragStart:L&&!Sn?ne=>vo(ne,k.workspace.id):void 0,onDragEnd:L&&!Sn?ol:void 0,"data-reorder-enabled":L?"true":void 0,children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(Qs,{expanded:!Q})}),s.jsx("strong",{children:k.workspace.name})]}),xt===k.workspace.id?js():Si(k.workspace.id)]}),Q?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-session-list",children:[M.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,Cs(k.workspace.id)).map(ne=>Jr({node:ne,workspace:k.workspace,workspaceContext:qn(k.workspace),menuKeyPrefix:`workspace:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:xt===k.workspace.id,favoriteEnabled:!0})),M.length>Cs(k.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>So(k.workspace.id,M.length),children:l("shell.sessionExpandMore")}):null]}),k.childWorktrees.length>0?s.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:k.childWorktrees.map(ne=>jo(ne))}):null,vi(k.workspace,k.archivedSessions)]})]},k.workspace.id)})]})]}),s.jsx("div",{className:"workbench-nav-footer minimal",children:s.jsxs("div",{className:"workbench-nav-footer-actions",children:[s.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:T,title:ft?`${l("settings.title")} · ${Ke}`:l("settings.title"),children:[s.jsx(VR,{}),s.jsx("span",{className:"settings-entry-label",children:l("settings.title")}),ft?s.jsx("span",{className:"workbench-nav-settings-host-badge",title:Ke,children:Ke}):null]}),s.jsx(cM,{onOpenSoftwareUpdate:()=>ce("/settings/software-update")})]})}),s.jsx(Nt,{open:Se,title:l("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:l("shell.manageWorkspaceDescription"),headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:Yr,children:l("shell.manageWorkspaceImportAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:el,children:l("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{$||ye(!1)},children:e.length>0?s.jsx("div",{className:"workbench-manage-list",children:e.map(k=>Ni(k.workspace,k.visibleSessions.length+k.archivedSessions.length,k.childWorktrees,!1))}):s.jsx("p",{className:"workbench-section-empty",children:l("shell.manageWorkspaceEmpty")})}),s.jsxs(Nt,{open:pn!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),onClose:()=>{Br||_r(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:pn?pn.session.title:""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!Br,onClick:()=>_r(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Br,onClick:()=>{Is()},children:Br?l("common.loading"):l("shell.deleteSessionAction")})]})]}),s.jsxs(Nt,{open:Bt!==null,title:l("shell.batchDeleteConfirmTitle"),description:l("shell.batchDeleteConfirmDescription",{count:`${(Bt==null?void 0:Bt.sessions.length)??0}`}),onClose:()=>{fn||Ot(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:Bt?l("shell.batchDeleteSelectionSummary",{count:`${Bt.sessions.length}`}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:fn,onClick:()=>Ot(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:fn,onClick:()=>{Qr()},children:fn?l("shell.batchDeleting"):l("shell.batchDeleteAction")})]})]}),s.jsxs(Nt,{open:Je!==null,title:l("shell.manageWorkspaceRemoveConfirmTitle"),description:l("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{$||j(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:Je?l("shell.manageWorkspaceRemoveConfirmTarget",{name:Je.name}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!$,onClick:()=>j(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!$,onClick:()=>{vs()},children:$?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveConfirmAction")})]})]}),s.jsx(eM,{open:re,onClose:()=>ve(!1),onCloned:vt}),s.jsx(lM,{open:F,onClose:()=>te(!1),onImported:sn}),s.jsx(wM,{open:De!==null,source:De,onClose:()=>We(null),onCreated:async k=>{k.members.forEach(O=>{x(O.session)}),hx(k.group.id),await g();const M=k.members.find(O=>O.session.sessionId===k.group.anchorSessionId)??k.members[0]??null;M&&ce(Mn(ux(M.session,M.sessionIsolatedWorkspace),M.session.sessionId)),We(null),oe({title:l("shell.parallelCreateSucceeded"),tone:"success"})}}),s.jsx(Nt,{open:tt!==null,title:l("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:tt?`${l("shell.createSessionTarget")} · ${tt.name}`:l("shell.createSessionModalDescription"),headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"primary-button create-session-parallel-trigger",disabled:Ye||!!me||!tt,onClick:()=>{tt&&Tn(tt)},children:l("shell.parallelCreateAction")}),s.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:Ye||!!me,onClick:()=>lt(!0),children:l("shell.createWorktreeAction")})]}),onClose:()=>ke(null),children:s.jsxs("section",{className:"create-session-modal-section",children:[s.jsx("div",{className:"create-session-modal-section-header",children:s.jsx("strong",{children:l("shell.createSessionProviderLabel")})}),s.jsx(_k,{disabled:!!me||Ye,workspaceId:(tt==null?void 0:tt.id)??null,pendingProvider:me===(tt==null?void 0:tt.id)?z??null:null,onSelect:k=>{tt&&hl(tt.id,k)}})]})}),s.jsx(Nt,{open:tt!==null&&ht,title:l("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:s.jsx("button",{type:"button",className:Ln?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":l("shell.createWorktreeHelpAction"),title:l("shell.createWorktreeHelpAction"),"aria-pressed":Ln,onClick:()=>hn(k=>!k),children:s.jsx(nA,{})}),description:tt?`${l("shell.createWorktreeSectionDescription")} ${l("shell.createSessionTarget")} · ${tt.name}`:l("shell.createWorktreeSectionDescription"),onClose:gn,children:s.jsxs("form",{className:"create-session-worktree-form",onSubmit:pl,children:[Ln?s.jsxs("section",{className:"create-session-worktree-help-card","aria-label":l("shell.createWorktreeHelpTitle"),children:[s.jsx("strong",{children:l("shell.createWorktreeHelpTitle")}),s.jsxs("div",{className:"create-session-worktree-help-grid",children:[s.jsxs("article",{children:[s.jsx("h3",{children:l("shell.createWorktreeHelpBranchTitle")}),s.jsx("p",{children:l("shell.createWorktreeHelpBranchBody")})]}),s.jsxs("article",{children:[s.jsx("h3",{children:l("shell.createWorktreeHelpDisplayNameTitle")}),s.jsx("p",{children:l("shell.createWorktreeHelpDisplayNameBody")})]}),s.jsxs("article",{children:[s.jsx("h3",{children:l("shell.createWorktreeHelpBaseRefTitle")}),s.jsx("p",{children:l("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,s.jsxs("label",{className:"create-session-worktree-field",children:[s.jsx("span",{children:l("shell.createWorktreeBranchLabel")}),s.jsx("input",{className:"settings-text-input",value:bt,placeholder:l("shell.createWorktreeBranchPlaceholder"),onChange:k=>{const M=k.target.value;VM(M)&&Ht(M)}})]}),s.jsxs("label",{className:"create-session-worktree-field",children:[s.jsx("span",{children:l("shell.createWorktreeDisplayNameLabel")}),s.jsx("input",{className:"settings-text-input",value:B,placeholder:l("shell.createWorktreeDisplayNamePlaceholder"),onChange:k=>ue(k.target.value)})]}),s.jsxs("label",{className:"create-session-worktree-field",children:[s.jsx("span",{children:l("shell.createWorktreeBaseRefLabel")}),s.jsx("div",{className:"create-session-worktree-combobox",ref:Wn,onBlurCapture:k=>{var O,Q;const M=k.relatedTarget;M instanceof Node&&((O=Wn.current)!=null&&O.contains(M)||(Q=xr.current)!=null&&Q.contains(M))||(wt(!1),jt(-1))},children:s.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[s.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":kt,"aria-controls":Cn,value:de,placeholder:l("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{wt(!0),jt(Kt.length>0?0:-1)},onChange:k=>{Pe(k.target.value),wt(!0),jt(Kt.length>0?0:-1)},onKeyDown:k=>{if(k.key==="ArrowDown"){if(k.preventDefault(),!kt){wt(!0);return}Kt.length>0&&jt(M=>M>=Kt.length-1?0:M+1);return}if(k.key==="ArrowUp"){if(k.preventDefault(),!kt){wt(!0);return}Kt.length>0&&jt(M=>M<=0?Kt.length-1:M-1);return}if(k.key==="Enter"&&kt&&er>=0){k.preventDefault();const M=Kt[er];M&&(Pe(M.value),wt(!1),jt(-1));return}k.key==="Escape"&&wt(!1)}}),s.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":l("shell.createWorktreeBaseRefToggle"),"aria-expanded":kt,onClick:()=>{wt(k=>!k),jt(!kt&&Kt.length>0?0:-1)},children:s.jsx(Qs,{expanded:kt})})]})}),s.jsx("span",{className:"create-session-worktree-field-hint",children:ps?l("shell.createWorktreeBaseRefLoading"):cr||l("shell.createWorktreeBaseRefHint",{localCount:ge.localBranches.length,remoteCount:ge.remoteBranches.length,tagCount:ge.tags.length})})]}),kt&&Dn&&typeof document<"u"?or.createPortal(s.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[s.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${Dn.top}px`,"--create-worktree-combobox-left":`${Dn.left}px`,"--create-worktree-combobox-width":`${Dn.width}px`,"--create-worktree-combobox-height":`${ui??0}px`}}),s.jsx("div",{ref:xr,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${Dn.top}px`,"--create-worktree-combobox-left":`${Dn.left}px`,"--create-worktree-combobox-width":`${Dn.width}px`},children:ps?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefLoading")}):cr?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:cr}):zn.length>0?s.jsx("div",{id:Cn,className:"create-session-worktree-combobox-list",role:"listbox",children:zn.map(k=>s.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":k.label,children:[s.jsx("header",{className:"create-session-worktree-combobox-group-title",children:k.label}),s.jsx("div",{className:"create-session-worktree-combobox-group-options",children:k.items.map(M=>{const O=Kt.findIndex(Re=>Re.value===M.value),Q=de===M.value,ne=er===O;return s.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":Q,"data-highlighted":ne,onMouseDown:Re=>Re.preventDefault(),onMouseEnter:()=>jt(O),onClick:()=>{Pe(M.value),wt(!1),jt(-1)},children:[s.jsx("span",{className:"create-session-worktree-combobox-option-label",children:M.value}),s.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[M.current?s.jsx("span",{className:"create-session-worktree-combobox-badge",children:l("shell.createWorktreeBaseRefCurrentBadge")}):null,M.recommended?s.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:l("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${k.key}:${M.value}`)})})]},k.key))}):s.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:Ye,onClick:gn,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:Ye,children:Ye?l("shell.createWorktreeSubmitting"):l("shell.createWorktreeSubmit")})]})]})}),s.jsxs(Nt,{open:Wt!==null,title:l("shell.archiveModalTitle"),description:Wt?`${Wt.workspace.name} · ${l("shell.archiveModalDescription")}`:l("shell.archiveModalDescription"),headerActions:xs.length>0?s.jsx("button",{type:"button",className:"secondary-button","aria-pressed":ys,onClick:bi,children:l("shell.archiveSearchAction")}):void 0,onClose:()=>go(null),children:[ys?s.jsxs("div",{className:"workbench-archive-search-panel",children:[s.jsx($s,{label:l("shell.archiveSearchLabel"),htmlFor:Me,children:s.jsx("input",{id:Me,type:"text",value:mi,placeholder:l("shell.archiveSearchPlaceholder"),autoFocus:!0,onChange:k=>gi(k.target.value)})}),Tt?s.jsx("p",{className:"workbench-archive-search-status",children:l("shell.archiveSearchSummaryLoading")}):null,jn?s.jsx("p",{className:"workbench-archive-search-status status-text","data-tone":"warning",children:jn}):null]}):null,Wt&&Pt.length>0?s.jsx(tu,{className:"workbench-archive-list","data-workspace-tone":(Nn==null?void 0:Nn.tone)??"root",style:ir(Nn),children:Pt.map(k=>{var Q;const M=Gu(k.title,l("common.unknown")),O=((Q=ws[k.sessionId])==null?void 0:Q.trim())??"";return s.jsx(ln,{className:"workbench-archive-item","data-workspace-tone":(Nn==null?void 0:Nn.tone)??"root",style:ir(Nn),trailing:s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>fl(k.sessionId),children:l("shell.unarchiveAction")}),children:s.jsxs("div",{className:"workbench-archive-item-main",children:[s.jsx("strong",{title:M.fullTitle,children:M.displayTitle}),s.jsxs("p",{children:[kb(k,Wt.workspace,!1)," ·"," ",Xa(k.provider)]}),ys&&O?s.jsx("p",{className:"workbench-archive-item-summary",children:O}):null]})},k.sessionId)})}):s.jsx(uf,{title:xs.length>0&&mi.trim().length>0?l("shell.archiveSearchEmpty"):l("shell.archiveEmpty"),compact:!0,className:"workbench-section-empty"})]}),s.jsx(Nt,{open:qt!==null,title:l("shell.renameModalTitle"),description:l("shell.renameModalDescription"),onClose:()=>{Hr||(mr(null),gr(""))},children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:Ro,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.renameInputLabel")}),s.jsx("input",{type:"text",value:zr,placeholder:l("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:k=>gr(k.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!Hr,onClick:()=>{mr(null),gr("")},children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!zr.trim()||Hr===(qt==null?void 0:qt.session.sessionId),children:Hr===(qt==null?void 0:qt.session.sessionId)?l("shell.renamingSession"):l("common.save")})]})]})}),rn?s.jsx("div",{ref:yr,className:"session-export-print-root","aria-hidden":"true",children:s.jsxs("div",{className:"session-export-print-shell",style:rn.shellWidthPx?{width:`${rn.shellWidthPx}px`,maxWidth:"100%"}:void 0,children:[s.jsxs("header",{className:"session-export-print-header",children:[s.jsx("h1",{children:rn.session.title||l("conversation.titleFallback")}),s.jsx("p",{children:l("conversation.exportAction")})]}),s.jsx(rI,{sessionId:rn.session.sessionId,messages:rn.messages,provider:rn.session.provider})]})}):null]})}function nf({panelReady:e,activeTab:t,fileRevealRequest:n,onTabChange:r,onToggleCollapse:i,currentSessionId:o,activeWorkspaceId:a,navigationGroups:c,workspaceContext:u,worktreeMeta:d,worktreeMergeState:h,onRefreshWorktreeMergePreview:p,onApplyWorktreeMerge:m,onCleanupWorktree:g}){var Y;const x=a??((Y=c[0])==null?void 0:Y.workspace.id)??null,S=vn(),C=Uf(S),{showToast:y}=Pn(),A=_u(),T=f.useRef(null),G=f.useRef(null),P=S.isDesktop&&S.bridge.supported,E=P&&!!a,V=P&&!!x,U=P&&!!x,L=typeof globalThis<"u"&&"PointerEvent"in globalThis,I=f.useCallback(async(W,q,D)=>{if(W==="files"){const ee=await gy(S,{workspaceId:q,sessionId:D,focusOwner:"file-context-panel"});ee.ok||y({title:ee.detail??l("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(W==="git"){const ee=await by(S,{workspaceId:q,focusOwner:"git-sidebar"});ee.ok||y({title:ee.detail??l("git.openExternalFailed"),tone:"error"});return}const K=await ky(S,{workspaceId:q,focusOwner:"terminal-manager-panel"});K.ok||y({title:K.detail??l("terminalManager.openExternalFailed"),tone:"error"})},[S,y]),H=f.useCallback((W,q)=>{if(W.button!==0||!P)return;const D=q==="files"?a:q==="git"||q==="terminals"?x:null;if(!D)return;const K=q==="files"?o:null;T.current={tab:q,startX:W.clientX,startY:W.clientY,workspaceId:D,sessionId:K,detached:!1,preview:null};const ee=N=>{var oe;const ce=T.current;if(!ce)return;const Ie=Math.abs(N.clientX-ce.startX),fe=Math.abs(N.clientY-ce.startY);!ce.detached&&Math.max(Ie,fe)<Pp||(ce.detached||(ce.detached=!0,G.current=ce.tab,ce.preview=wd({title:ce.tab==="files"?l("shell.filesEntry"):ce.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:N.clientX,y:N.clientY})),(oe=ce.preview)==null||oe.updatePosition(N.clientX,N.clientY))},v=N=>{var Ie;const ce=(Ie=T.current)==null?void 0:Ie.preview;N&&(ce==null||ce.cancel()),window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",Ce),window.removeEventListener("blur",je),T.current=null},Ce=async()=>{var ce;const N=T.current;v(!1),N!=null&&N.detached&&(await((ce=N.preview)==null?void 0:ce.complete()),await I(N.tab,N.workspaceId,N.sessionId))},je=()=>{v(!0)};window.addEventListener("mousemove",ee),window.addEventListener("mouseup",Ce),window.addEventListener("blur",je)},[a,P,o,x,I]),_=f.useCallback((W,q)=>{if(W.button!==0||!P)return;const D=q==="files"?a:q==="git"||q==="terminals"?x:null;if(!D)return;const K=W.currentTarget,ee=W.pointerId;K.setPointerCapture(ee);const v=q==="files"?o:null;T.current={tab:q,startX:W.clientX,startY:W.clientY,workspaceId:D,sessionId:v,detached:!1,preview:null};const Ce=fe=>{var Ke;if(fe.pointerId!==ee)return;const oe=T.current;if(!oe)return;const _e=Math.abs(fe.clientX-oe.startX),Ge=Math.abs(fe.clientY-oe.startY);!oe.detached&&Math.max(_e,Ge)<Pp||(oe.detached||(oe.detached=!0,G.current=oe.tab,oe.preview=wd({title:oe.tab==="files"?l("shell.filesEntry"):oe.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:fe.clientX,y:fe.clientY})),(Ke=oe.preview)==null||Ke.updatePosition(fe.clientX,fe.clientY))},je=fe=>{var _e;const oe=(_e=T.current)==null?void 0:_e.preview;fe&&(oe==null||oe.cancel()),K.removeEventListener("pointermove",Ce),K.removeEventListener("pointerup",N),K.removeEventListener("pointercancel",ce),K.removeEventListener("lostpointercapture",ce),window.removeEventListener("blur",Ie),T.current=null,K.hasPointerCapture(ee)&&K.releasePointerCapture(ee)},N=async fe=>{var _e;if(fe.pointerId!==ee)return;const oe=T.current;je(!1),oe!=null&&oe.detached&&(await((_e=oe.preview)==null?void 0:_e.complete()),await I(oe.tab,oe.workspaceId,oe.sessionId))},ce=fe=>{fe.pointerId===ee&&je(!0)},Ie=()=>{je(!0)};K.addEventListener("pointermove",Ce),K.addEventListener("pointerup",N),K.addEventListener("pointercancel",ce),K.addEventListener("lostpointercapture",ce),window.addEventListener("blur",Ie)},[a,P,o,x,I]),se=f.useCallback(W=>{if(G.current===W){G.current=null;return}r(W)},[r]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(u==null?void 0:u.tone)??"root",style:ir(u),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":C,children:[i?s.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideInfoSidebar"),title:l("shell.hideInfoSidebar"),onClick:i,children:s.jsx(Ob,{})}):null,s.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":l("shell.infoTabsLabel"),"data-tauri-drag-region":C,children:[s.jsx("button",{className:t==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="files",title:E?"拖拽标签到独立窗口":void 0,onPointerDown:W=>_(W,"files"),onMouseDown:L?void 0:W=>H(W,"files"),onClick:()=>se("files"),children:l("shell.filesEntry")}),s.jsx("button",{className:t==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="git",title:V?"拖拽标签到独立窗口":void 0,onPointerDown:W=>_(W,"git"),onMouseDown:L?void 0:W=>H(W,"git"),onClick:()=>se("git"),children:l("shell.gitEntry")}),s.jsx("button",{className:t==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="terminals",title:U?"拖拽标签到独立窗口":void 0,onPointerDown:W=>_(W,"terminals"),onMouseDown:L?void 0:W=>H(W,"terminals"),onClick:()=>se("terminals"),children:l("shell.terminalManagerEntry")})]})]}),s.jsxs("div",{ref:A,className:"workbench-auxiliary-body","data-scrollbar-autohide":"true",children:[e?null:s.jsx(da,{}),e&&t==="git"&&d?s.jsx(hA,{meta:d,state:h,onRefresh:()=>p(d.workspaceId,!0),onApply:()=>m(d.workspaceId),onCleanup:()=>g(d)}):null,e&&t==="files"?a?s.jsx(f.Suspense,{fallback:s.jsx(da,{}),children:s.jsx(rR,{sessionId:o,workspaceId:a,externalRevealRequest:n})}):s.jsx("section",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.filesPanelEmpty")})}):null,e&&t==="git"?x?s.jsx(f.Suspense,{fallback:s.jsx(da,{}),children:s.jsx(sR,{workspaceId:x})}):s.jsx("section",{className:"workbench-empty-state minimal",children:s.jsx("p",{children:l("shell.gitPanelEmpty")})}):null,e&&t==="terminals"?s.jsx(f.Suspense,{fallback:s.jsx(da,{}),children:s.jsx(iR,{currentWorkspaceId:a,navigationGroups:c})}):null]})]})}function hA({meta:e,state:t,onRefresh:n,onApply:r,onCleanup:i}){const[o,a]=f.useState(!1),c=(t==null?void 0:t.preview)??null,u=(t==null?void 0:t.loading)??!1,d=(t==null?void 0:t.applying)??!1,h=(t==null?void 0:t.cleaning)??!1,p=c!==null,m=(c==null?void 0:c.alreadyMerged)===!0,g=new Set((c==null?void 0:c.blockers.map(_=>_.code))??[]),x=g.size>0||!!(t!=null&&t.error),S=m&&!x,C=(c==null?void 0:c.canMerge)===!0&&!u&&!d&&!h&&!S,y=S&&!u&&!d&&!h&&!g.has("SOURCE_DIRTY")&&!g.has("HAS_ACTIVE_CHILDREN"),A=u||d||h?"loading":x?"blocked":S?"merged":c!=null&&c.canMerge?"ready":p?"blocked":"idle",T=(c==null?void 0:c.targetWorkspace.name)??l("common.unknown"),G=(c==null?void 0:c.sourceBranchName)??e.branchName,P=(c==null?void 0:c.targetBranchName)??e.baseRef??l("common.unknown"),E=fA({t:l,hasPreview:p,showMergedState:S,isMerged:m,canMerge:(c==null?void 0:c.canMerge)===!0,ahead:(c==null?void 0:c.ahead)??0,blockerCodeSet:g}),V=u?l("shell.worktreeMergePreviewLoading"):d?l("shell.worktreeMergeApplying"):h?l("shell.worktreeCleanupRunning"):S?l("shell.worktreeMergeAlreadyMerged"):c!=null&&c.canMerge?l("shell.worktreeMergeReady"):p?l("shell.worktreeMergeBlocked"):l("shell.worktreeMergePreviewIdle"),U=[l("shell.worktreeMergeCurrentBranch",{branch:G}),l("shell.worktreeMergeParentBranch",{branch:P}),l("shell.worktreeMergeTargetWorkspace",{name:T}),c?l("shell.worktreeMergeAheadBehind",{ahead:c.ahead,behind:c.behind}):l("shell.worktreeMergeAheadBehindPending"),c!=null&&c.mergeBaseCommit?l("shell.worktreeMergeBaseCommit",{commit:AR(c.mergeBaseCommit)}):null].filter(_=>!!_),L=`worktree-merge-panel-details-${e.workspaceId}`,I=o?l("shell.worktreeMergeCollapseDetails"):l("shell.worktreeMergeExpandDetails"),H=pA({t:l,loading:u,applying:d,cleaning:h,hasPreview:p,canMerge:(c==null?void 0:c.canMerge)===!0,showMergedState:S,blockerCodeSet:g});return f.useEffect(()=>{a(!1)},[e.workspaceId]),s.jsxs("section",{className:"worktree-merge-panel","data-state":A,children:[s.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":I,"aria-expanded":o,"aria-controls":L,onClick:()=>{a(_=>!_)},children:[s.jsx("span",{className:"worktree-merge-panel-summary-label",children:l("shell.worktreeMergePanelLabel")}),s.jsx("span",{className:"worktree-merge-panel-summary-main",children:s.jsx("span",{className:"worktree-merge-panel-summary-tags",children:H.map(_=>s.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":A,children:_},_))})}),s.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:I})]}),o?s.jsxs("div",{id:L,className:"worktree-merge-panel-details",children:[s.jsx("div",{className:"worktree-merge-panel-detail-head",children:s.jsx("span",{className:"worktree-merge-panel-status","data-state":A,children:V})}),s.jsx("div",{className:"worktree-merge-panel-meta",children:U.map(_=>s.jsx("span",{children:_},_))}),p?s.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":l("shell.worktreeMergeChecklistTitle"),children:E.map(_=>s.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":_.state,children:[s.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:_.state==="done"?"✓":_.state==="blocked"?"!":"·"}),s.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[s.jsx("strong",{children:_.label}),_.detail?s.jsx("span",{children:_.detail}):null]})]},_.key))}):null,t!=null&&t.error?s.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:t.error}):null,c!=null&&c.conflictPaths.length?s.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[s.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:l("shell.worktreeMergeConflictLabel")}),s.jsx("div",{className:"worktree-merge-panel-conflict-list",children:c.conflictPaths.map(_=>s.jsx("code",{children:_},_))})]}):null,s.jsxs("div",{className:"worktree-merge-panel-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:u||d||h,onClick:n,children:p?l("shell.worktreeMergePreviewRefresh"):l("shell.worktreeMergePreviewAction")}),s.jsx("button",{type:"button",className:"primary-button",disabled:!C,onClick:r,children:d?l("shell.worktreeMergeApplying"):l("shell.worktreeMergeApplyAction")}),s.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!y,onClick:i,children:h?l("shell.worktreeCleanupRunning"):l("shell.worktreeCleanupAction")})]})]}):null]})}function pA(e){const{t,loading:n,applying:r,cleaning:i,hasPreview:o,canMerge:a,showMergedState:c,blockerCodeSet:u}=e;if(n)return[t("shell.worktreeMergeCompactChecking")];if(r)return[t("shell.worktreeMergeCompactMerging")];if(i)return[t("shell.worktreeMergeCompactCleaning")];const d=[];return u.has("SOURCE_NOT_ACTIVE")&&d.push(t("shell.worktreeMergeCompactInactive")),u.has("SOURCE_DIRTY")&&d.push(t("shell.worktreeMergeCompactDirty")),u.has("TARGET_DIRTY")&&d.push(t("shell.worktreeMergeCompactTargetDirty")),u.has("HAS_CONFLICTS")&&d.push(t("shell.worktreeMergeCompactConflict")),u.has("HAS_ACTIVE_CHILDREN")&&d.push(t("shell.worktreeMergeCompactChildren")),d.length>0?d:a?[t("shell.worktreeMergeCompactReady")]:c?[t("shell.worktreeMergeCompactMerged")]:o?u.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function fA(e){const{t,hasPreview:n,showMergedState:r,isMerged:i,canMerge:o,ahead:a,blockerCodeSet:c}=e,u=c.has("SOURCE_NOT_ACTIVE"),d=c.has("SOURCE_DIRTY"),h=c.has("TARGET_DIRTY"),p=c.has("HAS_ACTIVE_CHILDREN"),m=c.has("HAS_CONFLICTS"),g=n&&!i&&(c.has("NO_COMMITS_TO_MERGE")||a<=0),x=r?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:o?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultReady"),detail:t("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:n?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultBlocked"),detail:t("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:t("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:t("shell.worktreeMergeChecklistSourceState"),detail:n&&u?t("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:n?u?"blocked":"done":"pending"},{key:"clean-source",label:t("shell.worktreeMergeChecklistSourceClean"),detail:n&&d?t("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:n?d?"blocked":"done":"pending"},{key:"clean-target",label:t("shell.worktreeMergeChecklistTargetClean"),detail:n&&h?t("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:n?h?"blocked":"done":"pending"},{key:"children",label:t("shell.worktreeMergeChecklistChildren"),detail:n&&p?t("shell.worktreeMergeChecklistChildrenBlocked"):null,state:n?p?"blocked":"done":"pending"},{key:"commits",label:t("shell.worktreeMergeChecklistCommits"),detail:g?t(i?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:g?i?"done":"blocked":n?"done":"pending"},{key:"conflicts",label:t("shell.worktreeMergeChecklistConflicts"),detail:m?t("shell.worktreeMergeChecklistConflictsBlocked"):null,state:m?"blocked":n?"done":"pending"},x]}function UP({shellMode:e="desktop"}){var qn,Ni,ji,k,M,O,Q,ne,Re,pe,He,gt,ut,Et,kn,xn,Nr;const t=Oa(),n=io(),r=vn(),{showToast:i}=Pn(),o=Lo(b=>b.sessionDisplaySortMode),a=Lo(b=>b.notificationPreferences.notifyOnPermissionRequest),c=Lo(b=>b.notificationPreferences.notifyOnSessionCompleted),u=Lo(b=>b.notificationPreferences.notifyOnSessionFailed),d=f.useRef(BE(tb)),h=f.useRef(0),p=f.useRef((((Ni=(qn=d.current)==null?void 0:qn.items)==null?void 0:Ni.length)??0)>0),m=f.useRef(new Map),g=f.useRef(!1),x=f.useRef(null),S=f.useRef(0),C=f.useRef(null),y=f.useRef(null),A=f.useRef(new Set),T=f.useRef(new Set),G=f.useRef(new Set),P=f.useRef(new Set),E=f.useRef(null),V=f.useRef(null),U=f.useRef(null),L=f.useRef(null),I=f.useRef(null),H=f.useRef(null),_=f.useRef(null),se=f.useRef(null),Y=f.useRef(0),W=f.useRef(0),q=f.useRef(i),D=f.useRef(r.bridge),K=f.useRef(null),ee=f.useRef(0),v=f.useRef(0),Ce=f.useRef(null),je=f.useRef(null),N=f.useRef(null),ce=f.useRef(!1),Ie=f.useRef(!1),fe=f.useRef(!1),oe=f.useRef(new Map),_e=f.useRef(!1),Ge=f.useRef(new Map),Ke=f.useRef(""),ft=f.useRef([]),F=f.useRef(o),te=f.useRef(null),[re,ve]=f.useState(()=>op(d.current,o)),Se=f.useRef(re),[ye,ze]=f.useState(()=>{var b,w;return(((w=(b=d.current)==null?void 0:b.items)==null?void 0:w.length)??0)===0}),[Ve,Je]=f.useState(null),[j,$]=f.useState(()=>ca(zp(vp,TM),Tp,Ep)),[ie,me]=f.useState(()=>ca(zp(Sp,IM),Ip,Mp)),[we,z]=f.useState(()=>Hp(Cp,!1)),[J,he]=f.useState(()=>Hp(Np,!1)),[ke,De]=f.useState(null),[We,mt]=f.useState(null),[Ze,ht]=f.useState(()=>Vp(d.current)),[lt,Ye]=f.useState(()=>Up(rc)),[et,bt]=f.useState(!1),[Ht,B]=f.useState("files"),[ue,de]=f.useState(!1),[Pe,ge]=f.useState(!1),[Ut,kt]=f.useState(null),[wt,er]=f.useState({}),[jt,Ln]=f.useState(!1),[hn,ps]=f.useState("sessions"),[tr,cr]=f.useState(""),[ur,Dn]=f.useState(""),[mo,ui]=f.useState(!1),[di,dr]=f.useState(null),[go,pn]=f.useState([]),[_r,Br]=f.useState(null),[Or,Bt]=f.useState({}),Ot=Hf(r),fn=f.useCallback(b=>{if(Ot)return;const w=K.current;w&&(!mc(r,b.button,b.target)||!qp(b.clientY,w)||oy({platform:r,button:b.button,target:b.target,clientX:b.clientX,clientY:b.clientY}))},[r,Ot]),bo=f.useCallback(b=>{if(Ot)return;const w=K.current;w&&(!mc(r,b.button,b.target)||!qp(b.clientY,w)||r.bridge.setWindowState("toggle-zoom"))},[r,Ot]),[At,mn]=f.useState({}),[ct,Wr]=f.useState(null),[hr,pr]=f.useState(!1),[rn,fs]=f.useState([]),[Fr,$r]=f.useState(()=>new Set),[fr,_n]=f.useState(!1),[hi,ms]=f.useState(!1),[Qa,ko]=f.useState(0),[Bn,pi]=f.useState(()=>Up(jp)),qt=e==="desktop"&&r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar,{theme:mr}=uk();f.useEffect(()=>{q.current=i},[i]),f.useEffect(()=>{if(typeof document>"u")return;const{documentElement:b,body:w}=document,R=document.getElementById("root");if(!qt){b.removeAttribute("data-workbench-macos-vibrancy"),w==null||w.removeAttribute("data-workbench-macos-vibrancy");return}const X=b.style.background,Z=(w==null?void 0:w.style.background)??"",le=(R==null?void 0:R.style.background)??"";return b.setAttribute("data-workbench-macos-vibrancy","true"),w==null||w.setAttribute("data-workbench-macos-vibrancy","true"),b.style.background="transparent",w==null||w.style.setProperty("background","transparent"),R==null||R.style.setProperty("background","transparent"),()=>{b.removeAttribute("data-workbench-macos-vibrancy"),w==null||w.removeAttribute("data-workbench-macos-vibrancy"),b.style.background=X,w&&(w.style.background=Z),R instanceof HTMLElement&&(R.style.background=le)}},[qt]),f.useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current)},[]),f.useEffect(()=>{var Z;if(typeof document>"u")return;const{documentElement:b,body:w}=document;if(!We){b.removeAttribute(Fs),w==null||w.removeAttribute(Fs);return}const R=b.style.cursor,X=(w==null?void 0:w.style.cursor)??"";return b.setAttribute(Fs,We),w==null||w.setAttribute(Fs,We),b.style.cursor="col-resize",w==null||w.style.setProperty("cursor","col-resize"),(Z=window.getSelection())==null||Z.removeAllRanges(),()=>{b.removeAttribute(Fs),w==null||w.removeAttribute(Fs),b.style.cursor=R,w&&(w.style.cursor=X)}},[We]),f.useEffect(()=>{F.current=o,ve(b=>PR(b,o))},[o]),f.useEffect(()=>{Se.current=re},[re]),f.useEffect(()=>{D.current=r.bridge},[r.bridge]),f.useEffect(()=>{ee.current=j},[j]),f.useEffect(()=>{v.current=ie},[ie]),f.useEffect(()=>()=>{Ce.current!==null&&window.cancelAnimationFrame(Ce.current)},[]);const zr=f.useCallback(async()=>{const b=Y.current+1;Y.current=b;try{const w=await qN();if(b!==Y.current)return;if(!w.initialized){fs([]),$r(new Set);return}const[R,X,Z,le]=await Promise.all([GN(),YN(),ag(),QN()]);if(b!==Y.current)return;fs(UM(R.overview,X.items,Z.items)),$r(new Set(le.items.map(Ne=>Ne.notificationId)))}catch{if(b!==Y.current)return;fs([]),$r(new Set)}},[]),gr=f.useCallback(b=>{const w=b.map(R=>R.createdAt).sort((R,X)=>Pr(X)-Pr(R))[0]??null;w&&pi(R=>R&&Pr(R)>=Pr(w)?R:w)},[]);f.useEffect(()=>{Bn&&ts(jp,Bn)},[Bn]),f.useEffect(()=>{zr();const b=window.setInterval(()=>{zr()},MM);return()=>{window.clearInterval(b)}},[zr]),f.useEffect(()=>{Dt("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),f.useEffect(()=>{var b,w;Dt("workbench.cached_snapshot_loaded",{cached:!!d.current,workspaceCount:((b=d.current)==null?void 0:b.items.length)??0,sessionCount:((w=d.current)==null?void 0:w.items.reduce((R,X)=>R+X.sessions.length,0))??0})},[]);function Hr(b){var X;if(!b||!Array.isArray(b.items))return;IR(m.current,b);const w=TR(b,m.current);Dt("workbench.apply_snapshot",{workspaceCount:w.items.length,sessionCount:w.items.reduce((Z,le)=>Z+le.sessions.length,0),currentSessionId:((X=Ki(t.pathname))==null?void 0:X.sessionId)??null});const R=op(w,F.current);d.current=w,ta(w),Se.current=R,ve(R),ht(Vp(w)),Je(null)}const Gt=f.useCallback(async()=>{const b=h.current+1;h.current=b,ze(w=>w||!p.current),Dt("workbench.refresh_navigation.start",{requestId:b,hasNavigationData:p.current});try{const w=await Ik();if(b!==h.current){Dt("workbench.refresh_navigation.stale",{requestId:b});return}Hr(w)}catch(w){if(b!==h.current)return;Je(w instanceof Error?w.message:l("shell.navigationLoadFailed")),q.current({title:w instanceof Error?w.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{Dt("workbench.refresh_navigation.end",{requestId:b,success:b===h.current}),b===h.current&&ze(!1)}},[]),xt=f.useCallback(b=>{ve(w=>{const R=ER(w,b,F.current);return Se.current=R,R})},[]),Vt=f.useCallback(()=>{var b;(b=y.current)==null||b.requestRefresh()},[]),Mt=f.useCallback((b,w)=>{n(Mn(b,w))},[n]),Jt=f.useCallback((b,w,R)=>{var X;E.current={workspaceId:b,paths:w,knownRevisionByPath:R==null?void 0:R.knownRevisionByPath},(X=y.current)==null||X.subscribeFileTree(b,w,R)},[]),br=f.useCallback((b,w,R)=>{var X;V.current={workspaceId:b,paths:w,knownRevisionByPath:R==null?void 0:R.knownRevisionByPath},(X=y.current)==null||X.requestFileTreeRefresh(b,w,R)},[]),fi=f.useCallback(b=>(A.current.add(b),()=>{A.current.delete(b)}),[]),Ur=f.useCallback((b,w)=>{var R;U.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.subscribeGit(b,w)},[]),On=f.useCallback((b,w)=>{var R;L.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.requestGitRefresh(b,w)},[]),gs=f.useCallback(b=>(T.current.add(b),()=>{T.current.delete(b)}),[]),kr=f.useCallback((b,w)=>{var R;I.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.subscribeWorkspaceManagement(b,w)},[]),Wn=f.useCallback((b,w)=>{var R;H.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},Bt(X=>{var Z;return{...X,[b]:{detail:((Z=X[b])==null?void 0:Z.detail)??null,loading:!0,error:null}}}),(R=y.current)==null||R.requestWorkspaceManagementRefresh(b,w)},[]),xr=f.useCallback(b=>(G.current.add(b),()=>{G.current.delete(b)}),[]),yr=f.useCallback(async(b,w=!1)=>{const R=b.trim();if(!R)return;let X=!0;if(mn(Z=>{const le=Z[R];return!w&&(le!=null&&le.loading)?(X=!1,Z):{...Z,[R]:{preview:(le==null?void 0:le.preview)??null,loading:!0,applying:(le==null?void 0:le.applying)??!1,cleaning:(le==null?void 0:le.cleaning)??!1,error:null}}}),!!X)try{const Z=await Ek(R);mn(le=>{var Ne,Ee;return{...le,[R]:{preview:Z,loading:!1,applying:((Ne=le[R])==null?void 0:Ne.applying)??!1,cleaning:((Ee=le[R])==null?void 0:Ee.cleaning)??!1,error:null}}})}catch(Z){mn(le=>{var Ne,Ee,Ae;return{...le,[R]:{preview:((Ne=le[R])==null?void 0:Ne.preview)??null,loading:!1,applying:((Ee=le[R])==null?void 0:Ee.applying)??!1,cleaning:((Ae=le[R])==null?void 0:Ae.cleaning)??!1,error:Z instanceof Error?Z.message:l("shell.worktreeMergePreviewFailed")}}})}},[]),Fn=f.useCallback(async b=>{const w=b.trim();if(w){mn(R=>{var X,Z;return{...R,[w]:{preview:((X=R[w])==null?void 0:X.preview)??null,loading:!1,applying:!0,cleaning:((Z=R[w])==null?void 0:Z.cleaning)??!1,error:null}}});try{const R=await Mk(w);mn(X=>{var Z;return{...X,[w]:{preview:R.preview,loading:!1,applying:!1,cleaning:((Z=X[w])==null?void 0:Z.cleaning)??!1,error:null}}}),Vt(),Gt(),yr(w,!0),On(R.preview.targetWorkspace.id),q.current({title:R.applied?l("shell.worktreeMergeApplySuccess"):l("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(R){mn(X=>{var Z,le;return{...X,[w]:{preview:((Z=X[w])==null?void 0:Z.preview)??null,loading:!1,applying:!1,cleaning:((le=X[w])==null?void 0:le.cleaning)??!1,error:R instanceof Error?R.message:l("shell.worktreeMergeApplyFailed")}}}),q.current({title:R instanceof Error?R.message:l("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[yr,Gt,On,Vt]),bs=f.useCallback(async b=>{var X,Z;const w=b.workspaceId,R=hr&&((Z=(X=At[w])==null?void 0:X.preview)==null?void 0:Z.alreadyMerged)===!0;mn(le=>{var Ne;return{...le,[w]:{preview:((Ne=le[w])==null?void 0:Ne.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const le=await Rk(w,{deleteBranch:R});if(mn(Ne=>{var Ee;return{...Ne,[w]:{preview:((Ee=Ne[w])==null?void 0:Ee.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),pr(!1),Wr(Ne=>(Ne==null?void 0:Ne.workspaceId)===w?null:Ne),Vt(),await Gt(),n(Qn(b.parentWorkspaceId),{replace:!0}),le.branchDeleted){q.current({title:l("shell.worktreeCleanupDeleteBranchSuccess",{branch:le.deletedBranchName||b.branchName}),tone:"success"});return}if(le.branchDeleteRequested){q.current({title:l("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:b.branchName}),description:le.branchDeleteError||void 0,tone:"warning"});return}q.current({title:l("shell.worktreeCleanupSuccess"),tone:"success"})}catch(le){mn(Ne=>{var Ee;return{...Ne,[w]:{preview:((Ee=Ne[w])==null?void 0:Ee.preview)??null,loading:!1,applying:!1,cleaning:!1,error:le instanceof Error?le.message:l("shell.worktreeCleanupFailed")}}}),q.current({title:le instanceof Error?le.message:l("shell.worktreeCleanupFailed"),tone:"error"})}},[hr,n,Gt,Vt,At]),qr=f.useCallback(b=>{pr(!1),Wr(b)},[]),ks=f.useCallback((b,w)=>{var R;_.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.subscribeTerminalManager(b,w)},[]),wr=f.useCallback((b,w)=>{var R;se.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.requestTerminalManagerRefresh(b,w)},[]),xo=f.useCallback(b=>(P.current.add(b),()=>{P.current.delete(b)}),[]),yo=f.useCallback((b,w)=>{ve(R=>MR(R,b,w??new Date().toISOString()))},[]),$n=f.useCallback(async(b,w)=>{m.current.set(b,w),ve(R=>Yp(R,b,w));try{const R=await ff(b,w),X=Xn(R);X===w?m.current.set(b,X):m.current.delete(b),xt(R),Vt(),Gt()}catch(R){throw m.current.delete(b),ve(X=>Yp(X,b,!w)),R}},[Gt,Vt,xt]),Sn=f.useCallback((b,w)=>{Dt("workbench.set_session_workspace",{sessionId:b,workspaceId:w}),er(R=>{if(!w){if(!(b in R))return R;const X={...R};return delete X[b],X}return R[b]===w?R:{...R,[b]:w}})},[]);f.useEffect(()=>{p.current=re.length>0},[re]),f.useEffect(()=>{Dt("workbench.navigation_state",{navigationLoading:ye,workspaceCount:re.length,sessionCount:re.reduce((b,w)=>b+w.sessions.length,0)})},[re,ye]),f.useEffect(()=>{C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{var be;C.current=null,!(g.current||p.current)&&(Dt("workbench.refresh_navigation.ws_fallback_triggered"),(be=y.current)==null||be.requestRefresh())},1200);const b=new ey({onConnectionChange:be=>{be==="connected"&&Ak(),be==="reconnect_failed"&&!p.current&&(Je(l("shell.navigationLoadFailed")),q.current({id:"workbench-navigation-connection",title:l("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:be=>{g.current=!0,Dt("workbench.ws_snapshot_received",{workspaceCount:be.items.length,sessionCount:be.items.reduce((Xe,Zt)=>Xe+Zt.sessions.length,0)}),C.current!==null&&(window.clearTimeout(C.current),C.current=null),Hr(be),ze(!1)},onFileTreeSnapshot:be=>{A.current.forEach(Xe=>Xe(be))},onGitSnapshot:be=>{Hi(Ab(be.workspaceId),{revision:be.revision??null,status:be.status,history:be.history,historyTotalCount:be.historyTotalCount,historyNextCursor:be.historyNextCursor,branches:be.branches}),Bt(Xe=>{var En;const Zt=((En=re.find(Ms=>Ms.workspace.id===be.workspaceId))==null?void 0:En.workspace)??null;if(!Zt)return Xe;const on=Xe[be.workspaceId],St=Db(Lb((on==null?void 0:on.detail)??Pb(Zt),Zt),be);return Hi(Yc(be.workspaceId),St),{...Xe,[be.workspaceId]:{detail:St,loading:!1,error:null}}}),T.current.forEach(Xe=>Xe(be))},onWorkspaceManagementSnapshot:be=>{Hi(Yc(be.workspaceId),be),Bt(Xe=>({...Xe,[be.workspaceId]:{detail:be,loading:!1,error:null}})),G.current.forEach(Xe=>Xe(be))},onTerminalManagerSnapshot:be=>{P.current.forEach(Xe=>Xe(be))},onUnauthorized:()=>{Yi.clear(),n("/login",{replace:!0})}});b.primeWorkbenchSnapshot(d.current),y.current=b;const w=E.current,R=V.current,X=U.current,Z=L.current,le=I.current,Ne=H.current,Ee=_.current,Ae=se.current;return w&&b.subscribeFileTree(w.workspaceId,w.paths,{knownRevisionByPath:w.knownRevisionByPath}),X&&b.subscribeGit(X.workspaceId,{knownRevision:X.knownRevision}),le&&b.subscribeWorkspaceManagement(le.workspaceId,{knownRevision:le.knownRevision}),Ee&&b.subscribeTerminalManager(Ee.workspaceId,{knownRevision:Ee.knownRevision}),R&&b.requestFileTreeRefresh(R.workspaceId,R.paths,{knownRevisionByPath:R.knownRevisionByPath}),Z&&b.requestGitRefresh(Z.workspaceId,{knownRevision:Z.knownRevision}),Ne&&b.requestWorkspaceManagementRefresh(Ne.workspaceId,{knownRevision:Ne.knownRevision}),Ae&&b.requestTerminalManagerRefresh(Ae.workspaceId,{knownRevision:Ae.knownRevision}),b.start(),()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null),y.current===b&&(y.current=null),b.close()}},[n]),f.useEffect(()=>{ts(vp,String(j))},[j]),f.useEffect(()=>{ts(Sp,String(ie))},[ie]),f.useEffect(()=>{ts(Cp,String(we))},[we]),f.useEffect(()=>{ts(Np,String(J))},[J]),f.useEffect(()=>{if(!lt){kR(rc);return}ts(rc,lt)},[lt]),f.useEffect(()=>{if(et||J)return;const b=window.setTimeout(()=>{bt(!0)},EM);return()=>{window.clearTimeout(b)}},[et,J]);const vr=Ki(t.pathname),Fe=(vr==null?void 0:vr.sessionId)??null,st=Fe?$b(Fe):!1,it=f.useMemo(()=>gx(re),[re]),tt=f.useMemo(()=>pb(it,o),[it,o]),nr=f.useMemo(()=>vR(re),[re]),zn=f.useMemo(()=>new Set(Ze),[Ze]),Kt=f.useMemo(()=>it.filter(b=>b.session.isFavorite===!0).map(b=>b.session.sessionId),[it]),Cn=f.useMemo(()=>new Set(Kt),[Kt]),Wt=f.useCallback(b=>{const w=oc(b,Ze);d.current=w,ta(w),Se.current=b,ve(b)},[Ze]),Nn=f.useCallback(b=>{const w=!zn.has(b),R=Jp(Ze,b,w),X=oc(re,R);d.current=X,ta(X),ht(R),mf(b,{collapsed:w}).catch(Z=>{const le=Jp(R,b,!w),Ne=oc(re,le);d.current=Ne,ta(Ne),ht(le),q.current({title:Z instanceof Error?Z.message:l("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[zn,Ze,re]),xs=f.useCallback(()=>{te.current={originalGroups:Se.current}},[]),ys=f.useCallback((b,w,R)=>{const X=Se.current,Z=jR(X,b,w,R);Z!==X&&Wt(Z)},[Wt]),mi=f.useCallback(()=>{const b=te.current;te.current=null;const w=Se.current;b&&(b.originalGroups.length===w.length&&b.originalGroups.every((R,X)=>{var Z;return R.workspace.id===((Z=w[X])==null?void 0:Z.workspace.id)})||Pk({workspaceIds:w.map(R=>R.workspace.id)}).catch(R=>{Wt(b.originalGroups),q.current({title:R instanceof Error?R.message:l("shell.workspaceReorderFailed"),tone:"error"})}))},[Wt]);f.useEffect(()=>{const b=new Map;if(it.forEach(({session:w})=>{b.set(w.sessionId,{activityState:w.activityState,completedAt:w.completedAt??null,runningState:w.runningState??null})}),!fe.current){fe.current=!0,oe.current=b;return}it.forEach(({session:w})=>{var Ne;if(w.sessionId===Fe)return;const R=oe.current.get(w.sessionId);if(!R)return;const X=R.activityState!=="completed_unread"&&w.activityState==="completed_unread",Z=((Ne=w.title)==null?void 0:Ne.trim())||l("common.unknown");if(c&&X){const Ee=l("conversation.backgroundCompletionToastDescription",{title:Z});q.current({id:`workbench-session-completed-${w.sessionId}-${w.completedAt??"unknown"}`,title:l("conversation.backgroundCompletionToastTitle"),description:Ee,tone:"success",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Mt(w.workspaceId,w.sessionId)}}),D.current.showNotification(l("conversation.backgroundCompletionToastTitle"),Ee)}const le=R.runningState!=="failed"&&(w.runningState??null)==="failed";if(u&&le){const Ee=HM(w)??l("conversation.runtimeFailed"),Ae=l("conversation.backgroundFailureToastDescription",{title:Z,detail:Ee});q.current({id:`workbench-session-failed-${w.sessionId}-${w.updatedAt}`,title:l("conversation.backgroundFailureToastTitle"),description:Ae,tone:"error",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Mt(w.workspaceId,w.sessionId)}}),D.current.showNotification(l("conversation.backgroundFailureToastTitle"),Ae)}}),oe.current=b},[Fe,it,c,u,Mt]),f.useEffect(()=>{ft.current=it.map(b=>b.session).filter(b=>b.sessionId!==Fe&&$M(b)).map(b=>{var w;return{sessionId:b.sessionId,workspaceId:b.workspaceId,title:((w=b.title)==null?void 0:w.trim())||l("common.unknown")}})},[Fe,it]),f.useEffect(()=>{let b=!1,w=null;const R=()=>{w=window.setTimeout(()=>{X().finally(()=>{b||R()})},AM)},X=async()=>{var Ae;const Z=ft.current;if(Z.length===0){_e.current||(_e.current=!0),Ke.current="";return}const le=new Set(Z.map(be=>be.sessionId)),Ne=await Promise.all(Z.map(async be=>{try{const Xe=await Dk(be.sessionId);return{session:be,items:Xe.items}}catch{return{session:be,items:null}}}));if(b)return;for(const be of Ne){if(!be.items)continue;const Xe=be.items.filter(St=>St.status==="pending"),Zt=new Set(Xe.map(St=>St.id)),on=Ge.current.get(be.session.sessionId)??new Set;_e.current&&Xe.forEach(St=>{if(on.has(St.id)||!a)return;const En=l("conversation.backgroundPermissionToastDescription",{title:be.session.title,requestTitle:St.title});q.current({id:`workbench-permission-request-${St.id}`,title:l("conversation.permissionRequestToastTitle"),description:En,tone:"warning",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Mt(be.session.workspaceId,be.session.sessionId)}}),D.current.showNotification(l("conversation.permissionRequestToastTitle"),En)}),Ge.current.set(be.session.sessionId,Zt)}for(const[be,Xe]of Ge.current.entries())!le.has(be)&&Xe.size===0&&Ge.current.delete(be);const Ee=zM(Ge.current,le);_e.current&&Ee!==Ke.current&&((Ae=y.current)==null||Ae.requestRefresh()),Ke.current=Ee,_e.current=!0};return X().finally(()=>{b||R()}),()=>{b=!0,w!==null&&window.clearTimeout(w)}},[a,Mt]),f.useEffect(()=>{ye&&re.length===0||(ht(b=>Ib(b,nr)),Ye(b=>b&&nr.has(b)?b:null))},[nr,ye]);const Pt=it.find(b=>b.session.sessionId===Fe)??null,Tt=(Pt==null?void 0:Pt.workspace.id)??(Fe?wt[Fe]??null:null),jn=_p(t.pathname,t.search),ws=jn&&nr.has(jn)?jn:null,gi=lt&&nr.has(lt)?lt:null,bi=Tt??ws??gi??null,Me=bi??((ji=re[0])==null?void 0:ji.workspace.id)??null,Hn=f.useCallback(b=>{if(b){const w=it.find(R=>R.workspace.id===b)??null;if(w)return w}return it[0]??null},[it]),Gr=f.useCallback(b=>{const w=typeof window>"u"?null:window.localStorage.getItem(ia);if(!w)return null;const R=w.split("?")[0]??w,X=Ki(R);if(!X)return window.localStorage.removeItem(ia),null;const Z=X.sessionId,le=it.find(Ee=>Ee.session.sessionId===Z)??null,Ne=X.workspaceId??(le==null?void 0:le.workspace.id)??null;return le&&(!b||Ne===b)?Mn(le.workspace.id,le.session.sessionId):(window.localStorage.removeItem(ia),null)},[it]),Qt=f.useMemo(()=>rn.filter(b=>!Fr.has(b.id)),[Fr,rn]),Sr=f.useMemo(()=>Qt.filter(b=>XM(b,Bn)).length,[Qt,Bn]);f.useEffect(()=>{fr&&gr(Qt)},[Qt,gr,fr]);const Za=f.useCallback(b=>{_n(!1),b.routePath&&n(b.routePath)},[n]),Vr=f.useCallback(async(b,w)=>{const R=W.current+1;W.current=R;try{const X=await ZN(b,w);if(R!==W.current)return;$r(Z=>{const le=new Set(Z);return X.item?le.add(X.item.notificationId):le.delete(b),le})}catch(X){if(R!==W.current)return;q.current({title:l("shell.globalNotificationsArchiveFailed"),description:X instanceof Error?X.message:void 0,tone:"error"})}},[]);f.useEffect(()=>{Tt&&Ye(b=>b===Tt?b:Tt)},[Tt]),f.useEffect(()=>{var le;if(ye)return;const b=((le=re[0])==null?void 0:le.workspace.id)??null,w=ws??b??gi,R=Fe&&!st?Hn(w):null,X=Fe&&!st?Gr(w):null,Z=R?Mn(R.workspace.id,R.session.sessionId):null;if(jn&&!ws){n(X??Z??(b?tR(t.pathname,b):ic(e)),{replace:!0});return}if(Fe&&!st&&!Tt){n(X??Z??(b?ri(b):ic(e)),{replace:!0});return}},[Fe,Hn,st,t.pathname,n,re,ye,Gr,jn,Tt,e,gi,ws]),f.useEffect(()=>{Dt("workbench.current_workspace_resolved",{currentSessionId:Fe,sessionWorkspaceId:Tt,routeWorkspaceId:jn,currentWorkspaceId:Me,source:Tt?Pt?"navigation":"sessionWorkspaceMap":jn?"route":lt?"workspaceSelection":"navigationFallback"})},[Pt,Fe,Me,jn,lt,Tt]);const sn=ba(t.pathname)?"terminals":ka(t.pathname)?"butler":"conversation",vt=e==="mobile",Kr=ic(e),ki=f.useMemo(()=>re.map(b=>{const w=bb(b.sessions),R=new Set(b.sessions.map(X=>X.sessionId));return{workspace:b.workspace,visibleSessions:w,archivedSessions:b.sessions.filter(X=>Xn(X)&&!fo(X)),visibleSessionTree:hb(w,o).filter(X=>!Cn.has(X.item.sessionId)&&!cu(tn(X),Z=>Cn.has(Z.sessionId))),childWorktrees:wb(b.childWorktrees,Cn,o,R),isCollapsed:zn.has(b.workspace.id)}}),[zn,Cn,re,o]),vs=f.useMemo(()=>WE(re),[re]),Yr=f.useMemo(()=>Gp(re,Me),[Me,re]),Tn=(Pt?dx(Pt.session,Pt.session.sessionIsolatedWorkspace):Me)??Me,gn=f.useMemo(()=>Gp(re,Tn),[Tn,re]),xi=f.useMemo(()=>Me?(Yr==null?void 0:Yr.workspace)??re.map(b=>b.workspace).find(b=>b.id===Me)??null:null,[Me,Yr,re]),yi=f.useMemo(()=>Tn?(gn==null?void 0:gn.workspace)??re.map(b=>b.workspace).find(b=>b.id===Tn)??null:null,[Tn,gn,re]),Cr=(gn==null?void 0:gn.meta)??null,tl=(Me?vs[Me]??null:null)??(xi?Da(xi):null),In=(Tn?vs[Tn]??null:null)??(yi?Da(yi):tl),wo=Cr?At[Cr.workspaceId]??null:null,Ss=f.useMemo(()=>{var w,R,X;if(!Fe)return null;const b=((X=(R=(w=Pt==null?void 0:Pt.session)==null?void 0:w.parallelGroup)==null?void 0:R.groupId)==null?void 0:X.trim())||null;return b||dR(tt,Fe)},[(M=(k=Pt==null?void 0:Pt.session)==null?void 0:k.parallelGroup)==null?void 0:M.groupId,Fe,tt]),Lt=sn==="conversation"&&!!Ss;f.useEffect(()=>{if(typeof window>"u"||!Lt||!Ss){De(null);return}const b=px(Ss);if(!b||b.sidebarCollapseDurationMs<=0){De(null);return}De(b);const w=Date.now()-b.createdAt,R=b.totalDurationMs-w;if(R<=0){De(null);return}const X=window.setTimeout(()=>{De(null)},R);return()=>{window.clearTimeout(X)}},[Ss,Lt]),f.useEffect(()=>{Dt("workbench.info_panel_state",{infoPanelReady:et,rightCollapsed:J||Lt,currentWorkspaceId:Me,sessionWorkspaceId:Tt,currentSessionId:Fe})},[Fe,Me,et,Lt,J,Tt]);const rr=f.useMemo(()=>it.filter(b=>Cn.has(b.session.sessionId)&&!Xn(b.session)&&!_a(b.session)),[Cn,it]),wi=t.pathname.startsWith("/settings")?"settings":ka(t.pathname)?"terminals":ba(t.pathname)?"butler":eR(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":ZM(t.pathname)||Bp(t.pathname)?"sessions":"workspaces",nl=vt&&(wi==="sessions"&&Bp(t.pathname)||ka(t.pathname)),rl=Fa({isNativeMobile:r.isNativeMobile,viewportClass:r.viewportClass}),vo=oo({viewportClass:r.viewportClass,activeEntry:wi,hasNavigationPanel:vt,hasAuxiliaryPanel:vt,preferCompactLayout:rl}),sl=vt&&Ff(vo),il=vt&&$f(vo),ol=f.useMemo(()=>re.map(b=>b.workspace),[re]),al=f.useMemo(()=>{const b=tr.trim().toLowerCase();return b?it.filter(w=>{const R=(w.session.title||"").toLowerCase(),X=w.workspace.name.toLowerCase(),Z=Xa(w.session.provider,"full").toLowerCase();return R.includes(b)||X.includes(b)||Z.includes(b)}):[]},[it,tr]);f.useEffect(()=>{var w;const b=Me??((w=re[0])==null?void 0:w.workspace.id)??"";b&&Dn(R=>R&&re.some(Z=>Z.workspace.id===R)?R:b)},[Me,re]),f.useEffect(()=>{Fe&&!st&&Tt&&ts(ia,`${t.pathname}${t.search}`)},[Fe,st,t.pathname,t.search,Tt]),f.useEffect(()=>{if(Fe&&st){x.current=`${t.pathname}${t.search}`;return}Fe&&!st&&(x.current=null)},[Fe,st,t.pathname,t.search]),f.useEffect(()=>{vt||(de(!1),ge(!1))},[vt]),f.useEffect(()=>{!vt||ye||!QM(t.pathname)||bi||(de(!1),ge(!1),n(Kr,{replace:!0}))},[bi,vt,t.pathname,n,ye,Kr]);function ll(){if(vt){de(!0);return}z(!1)}function Cs(){if(!Lt){if(sr(),vt){ge(!0);return}he(!1)}}function cl(){if(vt){de(b=>!b);return}z(b=>!b)}function So(){if(!Lt){if(sr(),vt){ge(b=>!b);return}he(b=>!b)}}function sr(){bt(!0)}function Ns(b){if(Ye(b),sr(),ba(t.pathname)){const w=rs(b);t.pathname!==w&&n(w);return}Fe&&Tt!==b&&n(Kr)}const Xr=f.useCallback(async b=>{var X;const w=((X=it.find(Z=>Z.session.sessionId===b))==null?void 0:X.session)??null,R=(w==null?void 0:w.isFavorite)!==!0;ve(Z=>Xp(Z,b,R));try{const Z=await Lk(b,R);xt(Z),Vt()}catch(Z){throw ve(le=>Xp(le,b,!R)),Z}},[it,Vt,xt]),Co=f.useCallback((b,w)=>{ub(b,w).then(()=>{n(Df(b,w))}).catch(R=>{i({title:R instanceof Error?R.message:l("shell.startSessionFailed"),tone:"error"})})},[n,i]),No=f.useCallback(b=>{var X;const w=((X=b.workspaceId)==null?void 0:X.trim())||Me,R=nR(b.filePath);return!w||!R?!1:(sr(),B("files"),vt?(de(!1),ge(!0)):he(!1),Br({requestId:S.current+1,workspaceId:w,filePath:R,openViewer:b.openViewer===!0}),S.current+=1,!0)},[Me,vt]),vi=f.useCallback(async(b,w)=>{const R=await gf(b,w.trim());return xt(R),R},[xt]);function js(b){Ln(!0)}function Si(){Ln(!1),ps("sessions"),cr(""),dr(null),pn([]),ui(!1)}async function jo(){const b=tr.trim();if(!b||!ur.trim()){pn([]),dr(null);return}ui(!0),dr(null);try{const w=await tx(ur,b);pn(w.items)}catch(w){pn([]),dr(w instanceof Error?w.message:l("shell.searchCodeFailed"))}finally{ui(!1)}}function Jr(b,w){const R=K.current;R&&(R.style.setProperty("--workbench-left-width",`${b}px`),R.style.setProperty("--workbench-left-current-width",we?"0px":`${b}px`),R.style.setProperty("--workbench-right-width",`${w}px`),R.style.setProperty("--workbench-right-current-width",J?"0px":`${w}px`))}function ul(b={}){return{leftWidth:b.leftWidth??(we?0:ee.current),rightWidth:b.rightWidth??(bn&&!J?v.current:0),leftCollapsed:b.leftCollapsed??we,rightCollapsed:b.rightCollapsed??(!bn||J),prefersDarkAppearance:b.prefersDarkAppearance??mr!=="light",isResizing:b.isResizing??We!==null}}function To(b,w){var Ee;w.preventDefault(),w.stopPropagation(),(Ee=window.getSelection())==null||Ee.removeAllRanges();const R=w.clientX,X=b==="left"?j:ie;mt(b);const Z=()=>{const Ae=je.current;if(je.current=null,Ae!==null){if(b==="left"){ee.current=Ae,$(be=>be===Ae?be:Ae),Jr(Ae,v.current);return}v.current=Ae,me(be=>be===Ae?be:Ae),Jr(ee.current,Ae)}};function le(Ae){var on;Ae.preventDefault(),(on=window.getSelection())==null||on.removeAllRanges();const be=Ae.clientX-R,Xe=b==="left"?ca(X+be,Tp,Ep):ca(X-be,Ip,Mp),Zt=b==="left"?ee.current:v.current;Xe===Zt&&je.current===null||(je.current=Xe,Ce.current===null&&(Ce.current=window.requestAnimationFrame(()=>{Ce.current=null,Z()})))}function Ne(){document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",Ne),Ce.current!==null&&(window.cancelAnimationFrame(Ce.current),Ce.current=null),Z(),mt(be=>be===b?null:be);const Ae=ul({isResizing:!1});Ro.current=Ae,r.bridge.syncNativeSidebarLayout(Ae)}document.addEventListener("mousemove",le,{passive:!1}),document.addEventListener("mouseup",Ne)}function Ts(){if(Io())return;if(it.length===0){n(Kr);return}const b=Mn(it[0].workspace.id,it[0].session.sessionId);n(b)}function dl(){if(!Io(Me)){if(Me){n(ri(Me));return}n(Kr)}}function Io(b){if(Fe&&Tt)return b&&Tt&&Tt!==b?!1:(n(`${t.pathname}${t.search}`),!0);if(x.current){if(b){const[R,X=""]=x.current.split("?"),Z=_p(R??x.current,X?`?${X}`:"");if(Z&&Z!==b)return!1}return n(x.current),!0}const w=Gr(b);return w?(n(w),!0):!1}f.useEffect(()=>{if(typeof window>"u")return;function b(w){if(!(w.metaKey||w.ctrlKey)){w.key==="Escape"&&(de(!1),ge(!1));return}if(yR(w.target))return;const X=w.key.toLowerCase();if(!w.shiftKey&&X==="b"){w.preventDefault(),cl();return}if(w.shiftKey&&X==="i"){w.preventDefault(),So();return}if(!w.shiftKey&&X===","){w.preventDefault(),n("/settings");return}if(!w.shiftKey&&X==="1"){w.preventDefault(),Ts();return}if(!w.shiftKey&&X==="2"){w.preventDefault(),n(Me?rs(Me):Yt());return}if(!w.shiftKey&&X==="k"){w.preventDefault(),wR();return}w.shiftKey&&X==="r"&&(w.preventDefault(),Gt())}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[n,Gt,vt,Ts]);const hl=f.useMemo(()=>({shellMode:e,navigationGroups:re,navigationLoading:ye,navigationError:Ve,currentWorkspaceId:Me,currentSessionId:Fe,favoriteSessionIds:Kt,favoriteSessions:rr,globalNotifications:rn,archivedNotificationIds:Array.from(Fr),showArchivedNotifications:hi,unreadNotificationCount:Sr,refreshNavigation:Gt,requestNavigationRefresh:Vt,openNotificationPanel:()=>{_n(!0)},closeNotificationPanel:()=>{_n(!1)},setShowArchivedNotifications:ms,archiveNotification:b=>{Vr(b,!0)},unarchiveNotification:b=>{Vr(b,!1)},setAuxiliaryPanel:kt,subscribeFileTree:Jt,requestFileTreeRefresh:br,addFileTreeSnapshotListener:fi,subscribeGitSnapshot:Ur,requestGitRefresh:On,addGitSnapshotListener:gs,subscribeWorkspaceManagementSnapshot:kr,requestWorkspaceManagementRefresh:Wn,addWorkspaceManagementSnapshotListener:xr,workspaceManagementStateById:Or,subscribeTerminalManagerSnapshot:ks,requestTerminalManagerRefresh:wr,addTerminalManagerSnapshotListener:xo,selectWorkspace:Ns,toggleFavoriteSession:Xr,archiveSession:b=>$n(b,!0),unarchiveSession:b=>$n(b,!1),renameSession:vi,startDraftSession:Co,markNavigationSessionSeen:yo,upsertNavigationSession:xt,setSessionWorkspace:Sn,revealWorkspaceFile:No}),[fi,gs,xr,xo,$n,Fe,Me,rn,Kt,rr,Ns,Fr,yo,Ve,re,ye,Sr,br,On,Wn,Gt,Vt,ms,kt,wr,vi,hi,Or,e,Co,Sn,Jt,Ur,kr,ks,Vr,Xr,xt,No]),pl={"--workbench-left-width":`${j}px`,"--workbench-left-current-width":we?"0px":`${j}px`,"--workbench-right-width":`${ie}px`,"--workbench-right-current-width":J||Lt?"0px":`${ie}px`,"--workbench-right-sidebar-duration":ke&&!J?`${ke.sidebarCollapseDurationMs}ms`:void 0,"--workbench-right-sidebar-content-duration":ke&&!J?`${Math.max(320,ke.sidebarCollapseDurationMs-120)}ms`:void 0},Eo=sn==="butler"?Ut:s.jsx(nf,{panelReady:et,activeTab:Ht,fileRevealRequest:_r,onTabChange:b=>{sr(),B(b)},currentSessionId:st?null:Fe,activeWorkspaceId:Tn,navigationGroups:re,workspaceContext:In,worktreeMeta:Cr,worktreeMergeState:wo,onRefreshWorktreeMergePreview:yr,onApplyWorktreeMerge:Fn,onCleanupWorktree:bs}),bn=Eo!==null,Un=J||Lt,Is=Lt&&ke!==null&&!J,Es=r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar;f.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:b,body:w}=document,R=()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null);const Z=ce.current;ce.current=!1,b.removeAttribute(aa),w==null||w.removeAttribute(aa),Z&&Ie.current&&(Ie.current=!1,ko(le=>le+1))};if(!Es){R();return}const X=()=>{ce.current=!0,b.setAttribute(aa,"true"),w==null||w.setAttribute(aa,"true"),N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{R()},LM)};return window.addEventListener("resize",X),()=>{window.removeEventListener("resize",X),R()}},[Es]);const Qr=f.useMemo(()=>({leftWidth:we?0:j,rightWidth:bn&&!Un?ie:0,leftCollapsed:we,rightCollapsed:!bn||Un,prefersDarkAppearance:mr!=="light",isResizing:We!==null}),[We,Un,we,j,ie,bn,mr]),fl=f.useDeferredValue(Qr),Mo=We===null?fl:Qr,Ro=f.useRef(Qr);f.useEffect(()=>{Ro.current=Qr},[Qr]),f.useEffect(()=>{if(typeof window>"u")return;let b=null;const w=()=>{b=null,r.bridge.syncNativeSidebarLayout(Mo)},R=()=>{b!==null&&window.cancelAnimationFrame(b),b=window.requestAnimationFrame(w)};return qt?(R(),()=>{b!==null&&window.cancelAnimationFrame(b)}):(r.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{b!==null&&window.cancelAnimationFrame(b)})},[Mo,r.bridge,qt]),f.useLayoutEffect(()=>{const b=K.current;if(!b||!Es||typeof window>"u"){Lp(b);return}let w=null,R=null;const X=new Set([b]),Z=()=>{Ie.current=!1;const Ne=window.getComputedStyle(b),Ee=cb(Ne,"--desktop-macos-traffic-light-center-y");if(Ee===null){Lp(b);return}const Ae={navToolbar:Er(b,pt.navToolbar.selector),infoTabs:Er(b,pt.infoTabs.selector),auxiliaryToolbarButton:Er(b,pt.auxiliaryToolbarButton.selector),conversationHeaderMain:Er(b,pt.conversationHeaderMain.selector),conversationHeaderActions:Er(b,pt.conversationHeaderActions.selector),terminalTabbarMain:Er(b,pt.terminalTabbarMain.selector),collapsedLeftControls:Er(b,pt.collapsedLeftControls.selector),collapsedRightControls:Er(b,pt.collapsedRightControls.selector)},be=[Ae.infoTabs,Ae.conversationHeaderMain,Ae.conversationHeaderActions,Ae.terminalTabbarMain].filter(St=>St!==null),Xe=[Ae.collapsedLeftControls,Ae.collapsedRightControls].filter(St=>St!==null),Zt=Xe.length>0?Vn(Ne,"--workbench-collapsed-controls-live-shift-y",Ee,Xe.reduce((St,En)=>St+En,0)/Xe.length):null,on=be.length>0?Vn(Ne,"--workbench-titlebar-live-content-shift-y",Ee,be.reduce((St,En)=>St+En,0)/be.length):null;Gn(b,"--workbench-titlebar-live-content-shift-y",on),Gn(b,"--workbench-collapsed-controls-live-shift-y",Zt),Gn(b,pt.navToolbar.variableName,Vn(Ne,pt.navToolbar.variableName,Ee,Ae.navToolbar)),Gn(b,pt.infoTabs.variableName,Vn(Ne,pt.infoTabs.variableName,Ee,Ae.infoTabs)),Gn(b,pt.auxiliaryToolbarButton.variableName,Vn(Ne,pt.auxiliaryToolbarButton.variableName,Ee,Ae.auxiliaryToolbarButton)),Gn(b,pt.conversationHeaderMain.variableName,Vn(Ne,pt.conversationHeaderMain.variableName,Ee,Ae.conversationHeaderMain)),Gn(b,pt.conversationHeaderActions.variableName,Vn(Ne,pt.conversationHeaderActions.variableName,Ee,Ae.conversationHeaderActions)),Gn(b,pt.terminalTabbarMain.variableName,Vn(Ne,pt.terminalTabbarMain.variableName,Ee,Ae.terminalTabbarMain)),Gn(b,pt.collapsedLeftControls.variableName,Vn(Ne,pt.collapsedLeftControls.variableName,Ee,Ae.collapsedLeftControls)),Gn(b,pt.collapsedRightControls.variableName,Vn(Ne,pt.collapsedRightControls.variableName,Ee,Ae.collapsedRightControls))},le=()=>{if(ce.current){Ie.current=!0;return}w!==null&&window.cancelAnimationFrame(w),w=window.requestAnimationFrame(()=>{w=null,Z()})};if(le(),typeof ResizeObserver<"u"){R=new ResizeObserver(()=>{le()});for(const Ne of Object.values(pt))for(const Ee of b.querySelectorAll(Ne.selector))X.add(Ee);for(const Ne of X)R.observe(Ne)}return window.addEventListener("resize",le),()=>{w!==null&&window.cancelAnimationFrame(w),window.removeEventListener("resize",le),R==null||R.disconnect()}},[sn,et,we,t.pathname,t.search,J,bn,Es,Qa]);const Ci=vt?s.jsx(tf,{workspaceGroups:ki,workspaceVisualContextMap:vs,sessionDisplaySortMode:o,favoriteSessions:rr,favoriteSessionIds:Cn,activeWorkspaceId:Me,isConversationActive:sn==="conversation",isTerminalActive:sn==="terminals",isButlerActive:sn==="butler",isSearchOpen:jt,navigationLoading:ye,navigationError:Ve,activeSessionId:Fe,onRefreshNavigation:Gt,onSessionUpdated:xt,onNavigateConversation:Ts,onNavigateTerminals:()=>{de(!1),n(Me?rs(Me):Yt())},onNavigateButler:()=>{de(!1),n(Me?as(Me):Yt())},onOpenSearch:()=>{de(!1),js()},onOpenSettings:()=>{de(!1),n("/settings")},onSelectWorkspace:Ns,onToggleWorkspaceCollapse:Nn,onStartWorkspaceReorder:xs,onPreviewWorkspaceReorder:ys,onCommitWorkspaceReorder:mi,allowWorkspaceReorder:!1,subscribeGitSnapshot:Ur,requestGitRefresh:On,subscribeWorkspaceManagementSnapshot:kr,requestWorkspaceManagementRefresh:Wn,onToggleFavoriteSession:Xr,onArchiveSession:b=>$n(b,!0),onUnarchiveSession:b=>$n(b,!1),workspaceManagementStateById:Or,setWorkspaceManagementStateById:Bt,unreadNotificationCount:Sr,notificationPanelOpen:fr,onToggleNotificationPanel:()=>{_n(b=>!b)},onClose:()=>de(!1)}):null,Ao=vt&&bn?Eo:null;return s.jsxs(db.Provider,{value:hl,children:[vt?s.jsx(s.Fragment,{children:s.jsx(Ux,{activeEntry:wi,presentation:nl?"conversation-focus":"default",navigationPanel:Ci,auxiliaryPanel:Ao,onOpenNavigation:()=>{ge(!1),de(!0)},onOpenSearch:()=>{de(!1),ge(!1),js()},onOpenAuxiliary:()=>{bn&&(sr(),de(!1),ge(!0))},onNavigateWorkspaces:()=>{de(!1),ge(!1),n(Yt())},onNavigateTerminals:()=>{de(!1),ge(!1),n(Me?rs(Me):Yt())},onNavigateButler:()=>{de(!1),ge(!1),n(Me?as(Me):Yt())},onNavigateSessions:()=>{de(!1),ge(!1),dl()},onNavigateToolFiles:()=>{de(!1),ge(!1),n(Me?Af(Me):Yt())},onNavigateToolGit:()=>{de(!1),ge(!1),n(Me?Pf(Me):Yt())},onNavigateToolProcesses:()=>{de(!1),ge(!1),n(Me?Lf(Me):Yt())},onNavigateSettings:()=>{de(!1),ge(!1),n("/settings")},children:s.jsx(ed,{})})}):s.jsx("div",{className:"workbench-shell",ref:K,style:pl,onMouseDownCapture:fn,onDoubleClickCapture:bo,"data-nav-loading":ye,"data-left-collapsed":we,"data-right-collapsed":Un,"data-info-ready":et,"data-parallel-conversation-active":Lt?"true":void 0,"data-parallel-sidebar-transition":Is?"true":void 0,"data-runtime-platform":r.platform,"data-os-family":r.ui.osFamily,"data-overlay-titlebar":r.ui.prefersOverlayTitlebar,children:s.jsxs("div",{className:"workbench-body-shell",children:[s.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":we,children:s.jsx(tf,{workspaceGroups:ki,workspaceVisualContextMap:vs,sessionDisplaySortMode:o,favoriteSessions:rr,favoriteSessionIds:Cn,activeWorkspaceId:Me,isConversationActive:sn==="conversation",isTerminalActive:sn==="terminals",isButlerActive:sn==="butler",isSearchOpen:jt,navigationLoading:ye,navigationError:Ve,activeSessionId:Fe,onRefreshNavigation:Gt,onSessionUpdated:xt,onNavigateConversation:Ts,onNavigateTerminals:()=>n(Me?rs(Me):Yt()),onNavigateButler:()=>n(Me?as(Me):Yt()),onOpenSearch:()=>js(),onOpenSettings:()=>n("/settings"),onSelectWorkspace:Ns,onToggleWorkspaceCollapse:Nn,onStartWorkspaceReorder:xs,onPreviewWorkspaceReorder:ys,onCommitWorkspaceReorder:mi,allowWorkspaceReorder:!0,subscribeGitSnapshot:Ur,requestGitRefresh:On,subscribeWorkspaceManagementSnapshot:kr,requestWorkspaceManagementRefresh:Wn,onToggleFavoriteSession:Xr,onArchiveSession:b=>$n(b,!0),onUnarchiveSession:b=>$n(b,!1),workspaceManagementStateById:Or,setWorkspaceManagementStateById:Bt,unreadNotificationCount:Sr,notificationPanelOpen:fr,onToggleNotificationPanel:()=>{_n(b=>!b)},onToggleCollapse:()=>z(!0)})}),s.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":we,role:"separator","aria-label":l("shell.leftResizerLabel"),onMouseDown:we?void 0:b=>To("left",b)}),s.jsxs("div",{className:"workbench-main-shell",children:[s.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!we&&!J,children:[s.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":we,children:[s.jsx(Qp,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:ll}),s.jsx(sb,{collapsed:!0}),s.jsx(Bb,{unreadCount:Sr,open:fr,onToggle:()=>{_n(b=>!b)},collapsed:!0})]}),bn&&!Lt?s.jsx("div",{className:"workbench-collapsed-controls right","data-visible":J,children:s.jsx(Qp,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:Cs})}):null]}),s.jsx(ed,{})]}),bn?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Un,"data-auto-hidden":Lt?"true":void 0,role:"separator","aria-label":l("shell.rightResizerLabel"),onMouseDown:Un?void 0:b=>To("right",b)}),s.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(In==null?void 0:In.tone)??"root","data-worktree-depth":(In==null?void 0:In.depth)??0,"data-collapsed":Un,"data-auto-hidden":Lt?"true":void 0,"data-custom-panel":sn==="butler","data-parallel-transition":Is?"true":void 0,"aria-hidden":Un&&!Is,style:ir(In),children:Lt&&!Is?null:sn==="butler"?s.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Ut}):s.jsx(nf,{panelReady:et,activeTab:Ht,fileRevealRequest:_r,onTabChange:b=>{sr(),B(b)},onToggleCollapse:()=>he(!0),currentSessionId:st?null:Fe,activeWorkspaceId:Tn,navigationGroups:re,workspaceContext:In,worktreeMeta:Cr,worktreeMergeState:wo,onRefreshWorktreeMergePreview:yr,onApplyWorktreeMerge:Fn,onCleanupWorktree:qr})})]}):null]})}),s.jsx(WR,{open:fr,notifications:rn,archivedNotificationIds:Fr,showArchivedNotifications:hi,onClose:()=>_n(!1),onToggleShowArchivedNotifications:ms,onArchiveNotification:b=>{Vr(b,!0)},onUnarchiveNotification:b=>{Vr(b,!1)},onSelectNotification:Za,preferredWorkspaceId:Me,preferredSessionId:st?null:Fe}),s.jsx(rA,{open:jt,mode:hn,keyword:tr,codeWorkspaceId:ur,codeResults:go,codeLoading:mo,codeError:di,workspaceOptions:ol,sessionResults:al,onClose:Si,onModeChange:b=>{ps(b),dr(null),pn([])},onKeywordChange:b=>{cr(b),hn==="code"&&!b.trim()&&(pn([]),dr(null))},onCodeWorkspaceChange:b=>Dn(b),onCodeSearch:()=>{jo()},onOpenSession:b=>{Si();const w=it.find(R=>R.session.sessionId===b)??null;n(w?Mn(w.workspace.id,b):Yt())}}),s.jsxs(Nt,{open:ct!==null,title:l("shell.worktreeCleanupModalTitle"),description:l("shell.worktreeCleanupModalDescription"),onClose:()=>{var b;ct&&((b=At[ct.workspaceId])!=null&&b.cleaning)||(pr(!1),Wr(null))},children:[s.jsx("p",{className:"workbench-section-empty",children:ct?l("shell.worktreeCleanupConfirm",{name:ct.displayName||ct.branchName}):""}),ct?s.jsxs("div",{className:"worktree-cleanup-modal-options",children:[s.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[s.jsx("input",{type:"checkbox",checked:hr,disabled:!!((O=At[ct.workspaceId])!=null&&O.cleaning)||((ne=(Q=At[ct.workspaceId])==null?void 0:Q.preview)==null?void 0:ne.alreadyMerged)!==!0,onChange:b=>pr(b.target.checked)}),s.jsx("span",{children:l("shell.worktreeCleanupDeleteBranchLabel",{branch:ct.branchName})})]}),((pe=(Re=At[ct.workspaceId])==null?void 0:Re.preview)==null?void 0:pe.alreadyMerged)!==!0?s.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:l("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!(ct&&((He=At[ct.workspaceId])!=null&&He.cleaning)),onClick:()=>{pr(!1),Wr(null)},children:l("common.cancel")}),s.jsx("button",{type:"button",className:hr&&ct&&((ut=(gt=At[ct.workspaceId])==null?void 0:gt.preview)==null?void 0:ut.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!ct||!!(ct&&((Et=At[ct.workspaceId])!=null&&Et.cleaning)),onClick:()=>{ct&&bs(ct)},children:ct&&((kn=At[ct.workspaceId])!=null&&kn.cleaning)?l("shell.worktreeCleanupRunning"):hr&&ct&&((Nr=(xn=At[ct.workspaceId])==null?void 0:xn.preview)==null?void 0:Nr.alreadyMerged)===!0?l("shell.worktreeCleanupDeleteBranchAction"):l("shell.worktreeCleanupAction")})]})]}),vt?s.jsxs(s.Fragment,{children:[sl?null:s.jsx(rf,{isOpen:ue,side:"left",onClose:()=>de(!1),children:Ci}),il?null:s.jsx(rf,{isOpen:Pe,side:"right",onClose:()=>ge(!1),children:Ao})]}):null]})}function rf({isOpen:e,side:t,onClose:n,children:r,className:i,overlayClassName:o}){if(!e)return null;const a=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:["mobile-nav-overlay","open",o].filter(Boolean).join(" "),onClick:n,role:"button",tabIndex:0,"aria-label":l("common.back"),onKeyDown:c=>{c.key==="Escape"&&n()}}),s.jsx("div",{className:["mobile-nav-drawer",t,"open",i].filter(Boolean).join(" "),children:r})]});return typeof document>"u"?a:or.createPortal(a,document.body)}function Fb(){return f.useContext(db)??{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 $b(e){return e.startsWith("draft-")}export{EP as $,IE as A,tM as B,Gu as C,qj as D,Gj as E,cx as F,VA as G,ax as H,DE as I,Uj as J,WE as K,bx as L,XA as M,ns as N,ai as O,Hs as P,ra as Q,$i as R,dM as S,fM as T,hM as U,ga as V,ey as W,pM as X,mM as Y,uM as Z,jP as _,UP as a,hP as a$,vP as a0,SP as a1,TP as a2,wP as a3,RP as a4,WP as a5,_P as a6,BP as a7,OP as a8,FP as a9,dI as aA,DP as aB,JA as aC,YA as aD,hx as aE,cu as aF,CM as aG,MP as aH,Yt as aI,Zx as aJ,QA as aK,eP as aL,tP as aM,aP as aN,lP as aO,oP as aP,sP as aQ,nP as aR,Hu as aS,xP as aT,rP as aU,fP as aV,XN as aW,CP as aX,NP as aY,kP as aZ,dP as a_,$P as aa,CA as ab,Dt as ac,dc as ad,zP as ae,cs as af,gx as ag,ux as ah,Da as ai,wM as aj,ox as ak,px as al,qA as am,UA as an,KA as ao,dx as ap,ir as aq,ad as ar,GA as as,LP as at,gy as au,by as av,ky as aw,ZA as ax,zu as ay,uI as az,ya as b,pP as b0,mP as b1,gP as b2,bP as b3,HE as b4,iP as b5,cP as b6,uP as b7,yP as b8,IP as b9,$A as bA,FA as bB,EA as bC,NA as bD,T1 as bE,FN as bF,Mf as bG,jj as ba,AP as bb,bp as bc,BE as bd,$E as be,Hc as bf,MA as bg,_u as bh,PA as bi,AA as bj,jA as bk,tx as bl,TA as bm,IA as bn,sx as bo,SA as bp,RA as bq,_A as br,WA as bs,nx as bt,HA as bu,BA as bv,LA as bw,OA as bx,DA as by,zA as bz,Mn as c,lM as d,eM as e,HP as f,cI as g,qN as h,PP as i,GN as j,ag as k,YN as l,op as m,ri as n,rs as o,Rf as p,as as q,Uf as r,Lf as s,Qn as t,Fb as u,EE as v,Hi as w,RE as x,Af as y,Pf as z};