@jingyi0605/codingns 0.6.5 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/public/assets/AdaptiveButlerPage-Cd8nPdO0.js +3 -0
  2. package/dist/public/assets/{App-B9HcTkMT.js → App-CyxK-Nos.js} +6 -6
  3. package/dist/public/assets/{BootstrapPage-BgLdZEKQ.js → BootstrapPage-DEwPKWR8.js} +1 -1
  4. package/dist/public/assets/ConversationPage-CxWtRhfz.js +6 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-YCBnyC58.js → DesktopDetachPreviewPage-DDOWolgB.js} +1 -1
  6. package/dist/public/assets/{DesktopWindowPage-CrvndE23.js → DesktopWindowPage-CtS9D8FD.js} +1 -1
  7. package/dist/public/assets/{FileContextPanel-CdC7GGw5.js → FileContextPanel-CNOjhsi5.js} +1 -1
  8. package/dist/public/assets/GitSidebar-DpC4UhFy.js +6 -0
  9. package/dist/public/assets/{MobileCreateSessionSheet-Cb2HM-y3.js → MobileCreateSessionSheet-DE4pTyXj.js} +1 -1
  10. package/dist/public/assets/{MobileTopHeaderFrame-etF2HKlm.js → MobileTopHeaderFrame-D_ZbS0qi.js} +1 -1
  11. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-CuGJ31kb.js → MobileWorkspaceSwitcherHeader-Dc12IAXc.js} +1 -1
  12. package/dist/public/assets/{RelayConnectEntryPage-BB6DbGtP.js → RelayConnectEntryPage-D8kyZfdm.js} +1 -1
  13. package/dist/public/assets/{ServerSettingsModal-Bl1sacZg.js → ServerSettingsModal-8eRu6VXr.js} +1 -1
  14. package/dist/public/assets/SessionIndexPage-DIi0JWKP.js +1 -0
  15. package/dist/public/assets/SettingsPage-OQq3kp32.js +2 -0
  16. package/dist/public/assets/{TerminalManagerPanel-BOm8Hi_v.js → TerminalManagerPanel-BEMzisSy.js} +1 -1
  17. package/dist/public/assets/{TerminalPage-B5JNFU6w.js → TerminalPage-CXLQfwjU.js} +18 -18
  18. package/dist/public/assets/{TerminalRuntimeFallbackModal-CM3LRKOJ.js → TerminalRuntimeFallbackModal-BY_VUAbq.js} +1 -1
  19. package/dist/public/assets/ToolFilesPage-CYx3DgHg.js +1 -0
  20. package/dist/public/assets/ToolGitPage-fgQcvF6v.js +1 -0
  21. package/dist/public/assets/ToolProcessesPage-BL6yDDPV.js +1 -0
  22. package/dist/public/assets/{ToolsHomePage-DsJp0y8A.js → ToolsHomePage-B1n2OeVw.js} +1 -1
  23. package/dist/public/assets/{WorkbenchLandingPage-DyPei0e-.js → WorkbenchLandingPage-Cu9yAWYo.js} +1 -1
  24. package/dist/public/assets/WorkbenchLayout-D6hGXWGE.js +244 -0
  25. package/dist/public/assets/{WorkbenchModal-LNfB69qx.js → WorkbenchModal-Bpb_G1-U.js} +1 -1
  26. package/dist/public/assets/WorkbenchShellRoute-BCjcGWhl.js +1 -0
  27. package/dist/public/assets/{WorkspaceDebugDetailPage-CaXj5zVI.js → WorkspaceDebugDetailPage-CZwT99iQ.js} +1 -1
  28. package/dist/public/assets/{WorkspaceDetailPage-DOexuuaw.js → WorkspaceDetailPage-DCM-olfU.js} +1 -1
  29. package/dist/public/assets/{WorkspaceHomePage-DkCHNjKD.js → WorkspaceHomePage-CsIIqIma.js} +1 -1
  30. package/dist/public/assets/{client-runtime-manager-6OoYHXGd.js → client-runtime-manager-CMK7kLp8.js} +1 -1
  31. package/dist/public/assets/file-tree-icon-Bv-apgA1.js +3 -0
  32. package/dist/public/assets/index-CkkzIvxs.css +1 -0
  33. package/dist/public/assets/index-O3gOb1E0.js +42 -0
  34. package/dist/public/assets/{login-direct-candidate-resolver-CLlYtBRq.js → login-direct-candidate-resolver-Bn4I5JHh.js} +1 -1
  35. package/dist/public/assets/model-switch-api-ZGnyVir7.js +1 -0
  36. package/dist/public/assets/{preferences-service-BCcfYP_d.js → preferences-service-scuqVhuA.js} +1 -1
  37. package/dist/public/assets/realtime-client-TRootbbB.js +1 -0
  38. package/dist/public/assets/{relay-entry-BmLkMKuq.js → relay-entry-eyCjVFMA.js} +1 -1
  39. package/dist/public/assets/styles-DkbkRgWw.css +1 -0
  40. package/dist/public/assets/{terminal-runtime-meta-0h-75uRy.js → terminal-runtime-meta-BGcnzxqn.js} +1 -1
  41. package/dist/public/assets/{useRegisteredDebugTemplates-rBVmAqh3.js → useRegisteredDebugTemplates-BdgPIDVM.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-runtime-boundary.d.ts +4 -0
  116. package/dist/server/modules/channels/wechat-claw-runtime-boundary.js +13 -0
  117. package/dist/server/modules/channels/wechat-claw-runtime-boundary.js.map +1 -0
  118. package/dist/server/modules/channels/wechat-claw-runtime-client.d.ts +14 -0
  119. package/dist/server/modules/channels/wechat-claw-runtime-client.js +95 -0
  120. package/dist/server/modules/channels/wechat-claw-runtime-client.js.map +1 -0
  121. package/dist/server/modules/channels/wechat-claw-runtime-manager.d.ts +16 -0
  122. package/dist/server/modules/channels/wechat-claw-runtime-manager.js +133 -0
  123. package/dist/server/modules/channels/wechat-claw-runtime-manager.js.map +1 -0
  124. package/dist/server/modules/channels/wechat-claw-runtime-types.d.ts +1 -0
  125. package/dist/server/modules/channels/wechat-claw-runtime-types.js +2 -0
  126. package/dist/server/modules/channels/wechat-claw-runtime-types.js.map +1 -0
  127. package/dist/server/modules/git/git-controller.d.ts +3 -1
  128. package/dist/server/modules/git/git-controller.js +9 -2
  129. package/dist/server/modules/git/git-controller.js.map +1 -1
  130. package/dist/server/modules/git/git-read-service.js +2 -1
  131. package/dist/server/modules/git/git-read-service.js.map +1 -1
  132. package/dist/server/modules/git/git-remote-credential-service.d.ts +1 -0
  133. package/dist/server/modules/git/git-remote-credential-service.js +4 -0
  134. package/dist/server/modules/git/git-remote-credential-service.js.map +1 -1
  135. package/dist/server/modules/git/types.d.ts +1 -0
  136. package/dist/server/modules/opencli/opencli-bridge-skill-service.js +2 -1
  137. package/dist/server/modules/opencli/opencli-bridge-skill-service.js.map +1 -1
  138. package/dist/server/modules/provider/codex-model-options.js +14 -15
  139. package/dist/server/modules/provider/codex-model-options.js.map +1 -1
  140. package/dist/server/modules/provider/provider-catalog-service.d.ts +5 -6
  141. package/dist/server/modules/provider/provider-catalog-service.js +12 -57
  142. package/dist/server/modules/provider/provider-catalog-service.js.map +1 -1
  143. package/dist/server/modules/provider/provider-controller.d.ts +1 -0
  144. package/dist/server/modules/provider/provider-controller.js +5 -0
  145. package/dist/server/modules/provider/provider-controller.js.map +1 -1
  146. package/dist/server/modules/provider/provider-discovery-helper-process.js +2 -1
  147. package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
  148. package/dist/server/modules/provider/provider-runtime-state-service.d.ts +24 -0
  149. package/dist/server/modules/provider/provider-runtime-state-service.js +141 -0
  150. package/dist/server/modules/provider/provider-runtime-state-service.js.map +1 -0
  151. package/dist/server/modules/sessions/session-history-service.d.ts +3 -3
  152. package/dist/server/modules/sessions/session-history-service.js +150 -47
  153. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  154. package/dist/server/modules/sessions/session-live-runtime-service.js +9 -11
  155. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  156. package/dist/server/modules/sessions/session-provider-config-service.d.ts +1 -0
  157. package/dist/server/modules/sessions/session-provider-config-service.js +28 -7
  158. package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -1
  159. package/dist/server/modules/sessions/session-provider-error-mapper.js +7 -0
  160. package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
  161. package/dist/server/modules/tasks/task-types.d.ts +2 -0
  162. package/dist/server/modules/tasks/task-types.js +2 -0
  163. package/dist/server/modules/tasks/task-types.js.map +1 -1
  164. package/dist/server/routes/channels.d.ts +3 -0
  165. package/dist/server/routes/channels.js +16 -0
  166. package/dist/server/routes/channels.js.map +1 -0
  167. package/dist/server/routes/providers.js +1 -0
  168. package/dist/server/routes/providers.js.map +1 -1
  169. package/dist/server/routes/public.d.ts +2 -1
  170. package/dist/server/routes/public.js +3 -1
  171. package/dist/server/routes/public.js.map +1 -1
  172. package/dist/server/server/create-server.d.ts +22 -0
  173. package/dist/server/server/create-server.js +63 -4
  174. package/dist/server/server/create-server.js.map +1 -1
  175. package/dist/server/shared/http/error-handler.js +59 -3
  176. package/dist/server/shared/http/error-handler.js.map +1 -1
  177. package/dist/server/storage/repositories/channel-account-repository.d.ts +12 -0
  178. package/dist/server/storage/repositories/channel-account-repository.js +153 -0
  179. package/dist/server/storage/repositories/channel-account-repository.js.map +1 -0
  180. package/dist/server/storage/repositories/channel-delivery-repository.d.ts +13 -0
  181. package/dist/server/storage/repositories/channel-delivery-repository.js +156 -0
  182. package/dist/server/storage/repositories/channel-delivery-repository.js.map +1 -0
  183. package/dist/server/storage/repositories/channel-inbound-event-repository.d.ts +12 -0
  184. package/dist/server/storage/repositories/channel-inbound-event-repository.js +144 -0
  185. package/dist/server/storage/repositories/channel-inbound-event-repository.js.map +1 -0
  186. package/dist/server/storage/repositories/channel-thread-repository.d.ts +12 -0
  187. package/dist/server/storage/repositories/channel-thread-repository.js +152 -0
  188. package/dist/server/storage/repositories/channel-thread-repository.js.map +1 -0
  189. package/dist/server/storage/repositories/provider-runtime-state-repository.d.ts +9 -0
  190. package/dist/server/storage/repositories/provider-runtime-state-repository.js +50 -0
  191. package/dist/server/storage/repositories/provider-runtime-state-repository.js.map +1 -0
  192. package/dist/server/storage/sqlite/schema.sql +114 -0
  193. package/dist/server/types/domain.d.ts +82 -0
  194. package/dist/server/ws/workbench-ws-hub.js +8 -2
  195. package/dist/server/ws/workbench-ws-hub.js.map +1 -1
  196. package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +6 -0
  197. package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +398 -0
  198. package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -1
  199. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +75 -15
  200. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
  201. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +61 -8
  202. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
  203. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +32 -4
  204. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  205. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +3 -0
  206. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +94 -21
  207. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
  208. package/package.json +5 -1
  209. package/dist/public/assets/AdaptiveButlerPage-CfsUVZKl.js +0 -3
  210. package/dist/public/assets/ConversationPage-Cj8go7L0.js +0 -4
  211. package/dist/public/assets/GitSidebar-z2SBinQh.js +0 -6
  212. package/dist/public/assets/SessionIndexPage-NbF9gJnp.js +0 -1
  213. package/dist/public/assets/SettingsPage-DGsmQpLv.js +0 -1
  214. package/dist/public/assets/ToolFilesPage-GSqKQsj_.js +0 -1
  215. package/dist/public/assets/ToolGitPage-BVFWMMQp.js +0 -1
  216. package/dist/public/assets/ToolProcessesPage-DZ456fYz.js +0 -1
  217. package/dist/public/assets/WorkbenchLayout-DlbgBT3n.js +0 -4
  218. package/dist/public/assets/WorkbenchShellRoute-BsxumYx5.js +0 -1
  219. package/dist/public/assets/file-tree-icon-9pt1OStn.js +0 -31
  220. package/dist/public/assets/index-BwlbvwaA.css +0 -1
  221. package/dist/public/assets/index-DSw-TkQL.js +0 -42
  222. package/dist/public/assets/model-switch-api-C-l8-E1S.js +0 -1
  223. package/dist/public/assets/session-runtime-machine-DgtvREca.js +0 -21
  224. package/dist/public/assets/styles-CsEMfdaS.css +0 -1
  225. /package/dist/public/assets/{styles-DRVvx_kv.js → styles-JKFlsYFv.js} +0 -0
@@ -0,0 +1,244 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-CNOjhsi5.js","assets/index-O3gOb1E0.js","assets/index-CkkzIvxs.css","assets/App-CyxK-Nos.js","assets/App-CcDXqFl1.css","assets/model-switch-api-ZGnyVir7.js","assets/WorkbenchModal-Bpb_G1-U.js","assets/file-tree-icon-Bv-apgA1.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-eyCjVFMA.js","assets/GitSidebar-DpC4UhFy.js","assets/TerminalManagerPanel-BEMzisSy.js","assets/terminal-runtime-meta-BGcnzxqn.js","assets/TerminalRuntimeFallbackModal-BY_VUAbq.js"])))=>i.map(i=>d[i]);
2
+ var rk=Object.defineProperty;var sk=(e,t,n)=>t in e?rk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ke=(e,t,n)=>sk(e,typeof t!="symbol"?t+"":t,n);import{C as xe,t as l,b as f,j as s,e as Bn,m as Ji,H as Jc,J as af,F as ik,K as ok,w as Qc,A as Zc,g as lf,D as ak,p as Wa,L as lk,M as ck,N as cf,i as uf,O as dc,f as eu,h as hc,P as uk,l as df,y as dk,n as hk,z as pk,d as fk,_ as tu}from"./index-O3gOb1E0.js";import{m as at,e as bn,h as Fa,u as ao,f as Wn,g as ur,i as mk,j as gk,O as td}from"./App-CyxK-Nos.js";import{e as nu,f as Ys,i as ru,j as pn,k as Lo,V as hf,A as bk,a2 as kk,a3 as xk,H as pf,l as yk,m as wk,a4 as ff,a5 as vk,M as Sk,a6 as Ck,a7 as Nk,n as jk,t as Tk,q as Ik,s as mf,h as Hs,a as pc,v as Ek,o as Mk,p as su,a8 as Rk,a9 as Ak,aa as Pk,u as Do,g as Lk,ab as Dk,ac as _k,ad as Bk,ae as gf,af as Ok,ag as bf,ah as Wk,ai as Fk,aj as kf,K as $k,S as zk,R as nd,r as Hk,ak as Uk}from"./model-switch-api-ZGnyVir7.js";import{t as Xs,P as ya,g as xf}from"./window-BVUB8gMK.js";import{R as qk,_ as rd,a as sd,C as yf,i as Le}from"./event-DvH9tcej.js";import{W as Et,M as Gk,D as iu}from"./WorkbenchModal-Bpb_G1-U.js";import{r as Vk,b as Kk}from"./relay-entry-eyCjVFMA.js";const Js=new Map,wf=48;function ps(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function id(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Yk(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function vf(e){try{const t=JSON.parse(e);return Yk(t)?t:null}catch{return null}}function Xk(){if(!ps())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 Sf(){if(!ps())return[];const e=[];for(const t of Xk()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=vf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function Qi(e){if(ps())try{window.sessionStorage.removeItem(e)}catch{}}function _o(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??wf,r=Sf().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;Qi(a.key)}}function Jk(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function yl(e,t){if(!ps())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return Jk(n)?"quota_exceeded":"failed"}}function Qk(e,t){const n=yl(e,t);if(n==="success"){_o({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(Qi(e),_o({maxCount:Math.max(0,wf-1)}),yl(e,t)==="success"){_o({preserveKeys:[e]});return}for(const r of Sf())if(r.key!==e&&(Qi(r.key),yl(e,t)==="success")){_o({preserveKeys:[e]});return}}}function wa(e,t){const n=Js.get(e);if(n){if(!id(n.savedAt,t))return n.value;Js.delete(e)}if(!ps())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=vf(r);return!i||id(i.savedAt,t)?(Qi(e),Js.delete(e),null):(Js.set(e,i),i.value)}function qi(e,t){const n={savedAt:Date.now(),value:t};if(Js.set(e,n),!!ps())try{Qk(e,JSON.stringify(n))}catch{}}function LA(e){Js.delete(e),ps()&&Qi(e)}const Zk="codingns.debug.perf",ex="codingns.debug.sessionMessageDedup",tx="codingns.debug.opencodeOrder",nx="codingns.debug.timelineScroll";function rx(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Zk)==="1"}catch{return!1}}function Ot(e,t){if(!rx()||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 sx(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ex)==="1"}catch{return!1}}function fc(e,t){if(!sx()||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 ix(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tx)==="1"}catch{return!1}}function DA(e,t){if(!ix()||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 mc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(nx)==="1"}catch{return!1}}function ox(e,t){if(!mc()||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 _A(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 BA(e){return xe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function OA(e){return xe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function WA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/download?${n.toString()}`)}function ax(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 FA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview?${n.toString()}`)}function lx(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview-link?${n.toString()}`)}function $A(e){return xe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function zA(e){return xe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function HA(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return xe.request(`/api/git/diff?${r.toString()}`)}function UA(e,t){return xe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function qA(e,t){return xe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function GA(e,t){return xe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function VA(e,t){return xe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function KA(e,t){return xe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function YA(e){return xe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function XA(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 JA(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return xe.request(`/api/git/commit-detail?${n.toString()}`)}function cx(e){return xe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function ux(e){return xe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function QA(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 eP(e){return xe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var pa,fa;function Cf(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:Cf(n));else if("action"in e&&e.action){const n=new yf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function ai(e,t){const n=new yf;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=Xs(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Xs(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=Xs(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=Xs(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),Cf(i))};t.items=t.items.map(r)}return Le("plugin:menu|new",{kind:e,options:t,handler:n})}class li extends qk{get id(){return rd(this,pa,"f")}get kind(){return rd(this,fa,"f")}constructor(t,n,r){super(t),pa.set(this,void 0),fa.set(this,void 0),sd(this,pa,n),sd(this,fa,r)}}pa=new WeakMap,fa=new WeakMap;class ou extends li{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return ai("MenuItem",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})}}class au extends li{constructor(t,n){super(t,n,"Check")}static async new(t){return ai("Check",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})}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 od;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(od||(od={}));class lu extends li{constructor(t,n){super(t,n,"Icon")}static async new(t){return ai("Icon",t).then(([n,r])=>new lu(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:Xs(t)})}}class cu extends li{constructor(t,n){super(t,n,"Predefined")}static async new(t){return ai("Predefined",t).then(([n,r])=>new cu(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 ti([e,t,n]){switch(n){case"Submenu":return new $a(e,t);case"Predefined":return new cu(e,t);case"Check":return new au(e,t);case"Icon":return new lu(e,t);case"MenuItem":default:return new ou(e,t)}}class $a extends li{constructor(t,n){super(t,n,"Submenu")}static async new(t){return ai("Submenu",t).then(([n,r])=>new $a(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(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(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 ya?t:t?new ya(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:Xs(t)})}}class Qs extends li{constructor(t,n){super(t,n,"Menu")}static async new(t){return ai("Menu",t).then(([n,r])=>new Qs(n,r))}static async default(){return Le("plugin:menu|create_default").then(([t,n])=>new Qs(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(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(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 ya?t:t?new ya(t):null})}async setAsAppMenu(){return Le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Qs(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 Qs(r[0],r[1]):null)}}async function dx(e){if(e.length===0)return;await(await Qs.new({items:await Promise.all(e.map(n=>Nf(n)))})).popup(void 0,xf())}async function Nf(e){return"items"in e?$a.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>Nf(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const ad={"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)"}},hx=2600,jf="workbench.parallel.pane.palette";let Us=null;const ld=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function px(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 Tf(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 fx(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=ad[t]??ad["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function tP(e){const t=va(e.overrideColor)??mx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":cd(t,.08),"--parallel-group-surface":cd(t,.03)}}function nP(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=If();return va(n[t]??null)}function rP(e,t){if(typeof window>"u")return va(t);const n=e.trim();if(!n)return null;const r=If(),i=va(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(jf,JSON.stringify(r)),i}function mx(e,t){const n=ld.length,r=Math.abs(wx(e))%n;return ld[(r+t*5)%n]}function sP(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function gx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function iP(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function oP(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 bx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function kx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function xx(e,t="create"){Us={groupId:e,createdAt:Date.now(),...px(t)}}function yx(e){return!Us||Us.groupId!==e?null:Date.now()-Us.createdAt>hx?(Us=null,null):Us}function If(){if(typeof window>"u")return{};const e=window.localStorage.getItem(jf);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function wx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function va(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function cd(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 uu(e,t){const n=new Map(e.map(o=>[t.getId(o),o])),r=new Map,i=[];for(const o of e){const a=vx(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=>Rf(o,0,r,t,new Set))}function ci(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Ef(e){return e.flatMap(t=>[t.item,...Ef(ci(t))])}function ss(e){return e.flatMap(t=>[t,...ss(ci(t))])}function du(e,t){return e.some(n=>t(n.item)||du(ci(n),t))}function Mf(e,t,n){return e?n(e.item)===t?!0:ci(e).some(r=>Mf(r,t,n)):!1}function qs(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const o=qs(ci(r),t,n);if(Mf(r,t,n)&&o.length>=0)return[i,...o]}return[]}function Rf(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=>Rf(u,t+1,n,r,a));return{item:e,depth:t,children:c}}function vx(e,t,n){const r=ud(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=ud(n.getParentId(a));if(!u||(a=t.get(u),!a))return r}return r}function ud(e){const t=e==null?void 0:e.trim();return t||null}function Zt(){return"/workspaces"}function rr(e){return`/workspaces/${encodeURIComponent(e)}`}function Af(e){return`${rr(e)}/debug`}function ii(e){return`${rr(e)}/sessions`}function _n(e,t){return`${ii(e)}/${encodeURIComponent(t)}`}function Pf(e,t){const n=`${rr(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Lf(e){return`${rr(e)}/tools/files`}function Df(e){return`${rr(e)}/tools/git`}function _f(e){return`${rr(e)}/tools/processes`}function is(e){return`${rr(e)}/terminals`}function cs(e,t){const n=`${rr(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Sx(e){return Wf(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Of(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function aP(e,t){return uu(Wf(e),{getId:n=>n.session.sessionId,getParentId:n=>Cx(n.session,t),compare:jx})}function Cx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:Tf(e)}function Bf(e,t){const n=Nx(),r=new URLSearchParams({provider:t});return`${_n(e,n)}?${r.toString()}`}function Nx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function jx(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Of(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Of(t.children)])}function Wf(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 Tx="mobile.tools.last-primary-tool";function Ff(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Tx)==="git"?"git":"files"}catch{return"files"}}function hu(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=at(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(at(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function Ix(e,t){const n=hu(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":Ff()}function pu(e,t){const n=hu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?is(n.workspaceId):n!=null&&n.workspaceId?Pf(n.workspaceId,Ix(e,t)):n!=null&&n.legacy?Ff()==="git"?"/tools?tab=git":"/tools?tab=files":null}function fu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const o=hu(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 $f=f.createContext({composerPortalTarget:null});function mu({composerPortalTarget:e,children:t}){return s.jsx($f.Provider,{value:{composerPortalTarget:e},children:t})}function lP(){return f.useContext($f)}function gu(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 Ex=3e3,Bo=10,dd=84,hd=.36;function bu({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(){ts(i),i.current=window.setTimeout(()=>{g()},Ex)}function g(){d("hidden"),p(0)}function x(){d("visible"),p(1),m()}f.useEffect(()=>{if(ts(i),!e){ts(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return x(),()=>{ts(i)}},[e,r,n]),f.useEffect(()=>()=>{ts(i)},[]),f.useEffect(()=>{if(!e||n){o.current=null;return}const C=t.current;if(!C)return;function y(q){if(q.touches.length!==1){o.current=null;return}const P=q.touches[0],T=md(q.target);if(!P||!T){o.current=null;return}o.current={surface:T,startX:P.clientX,startY:P.clientY,pointerType:"touch",initialState:a.current==="visible"?"visible":"hidden",touchId:P.identifier,dragging:!1,latestProgress:c.current},a.current==="visible"&&ts(i)}function A(q){const P=o.current;if(!P||P.pointerType!=="touch")return;const T=wl(q.touches,P.touchId);if(!T)return;const H=T.clientX-P.startX,_=T.clientY-P.startY;if(P.surface==="conversation"){if(Math.abs(_)<=Bo||Math.abs(_)<=Math.abs(H))return;o.current=null,P.initialState==="visible"&&g();return}const ie=P.initialState==="hidden"?-_:_;ie<=Bo&&!P.dragging||(bd(q),P.dragging=!0,P.latestProgress=pd(P.initialState,ie),d("dragging"),p(P.latestProgress))}function j(q){const P=o.current;if(!(!P||P.pointerType!=="touch"||!wl(q.changedTouches,P.touchId))){if(o.current=null,!P.dragging){P.initialState==="visible"&&m();return}fd(P.initialState,P.latestProgress,x,d,p)}}function V(q){const P=o.current;if(!(!P||P.pointerType!=="touch"||!wl(q.changedTouches,P.touchId))){if(o.current=null,!P.dragging){P.initialState==="visible"&&m();return}if(P.initialState==="visible"){x();return}d("hidden"),p(0)}}function L(q){if(q.pointerType!=="touch")return;const P=md(q.target);if(!P){o.current=null;return}if(o.current={surface:P,startX:q.clientX,startY:q.clientY,pointerType:"pointer",initialState:a.current==="visible"?"visible":"hidden",pointerId:q.pointerId,captureTarget:q.target instanceof Element?q.target:null,dragging:!1,latestProgress:c.current},q.target instanceof Element)try{q.target.setPointerCapture(q.pointerId)}catch{}a.current==="visible"&&ts(i)}function I(q){const P=o.current;if(!P||P.pointerType!=="pointer")return;const T=q.clientX-P.startX,H=q.clientY-P.startY;if(P.surface==="conversation"){if(Math.abs(H)<=Bo||Math.abs(H)<=Math.abs(T))return;o.current=null,P.initialState==="visible"&&g();return}const _=P.initialState==="hidden"?-H:H;_<=Bo&&!P.dragging||(bd(q),P.dragging=!0,P.latestProgress=pd(P.initialState,_),d("dragging"),p(P.latestProgress))}function G(q){const P=o.current;if(!(!P||P.pointerType!=="pointer"||P.pointerId!==q.pointerId)){if(o.current=null,Mx(P),!P.dragging){P.initialState==="visible"&&m();return}fd(P.initialState,P.latestProgress,x,d,p)}}return C.addEventListener("touchstart",y,{passive:!0}),C.addEventListener("pointerdown",L,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",j),window.addEventListener("touchcancel",V),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),()=>{C.removeEventListener("touchstart",y),C.removeEventListener("pointerdown",L),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",j),window.removeEventListener("touchcancel",V),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function ts(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function pd(e,t){return gd(e==="hidden"?t/dd:1-t/dd,0,1)}function fd(e,t,n,r,i){if(e==="hidden"){if(t>=hd){n();return}r("hidden"),i(0);return}if(t<=1-hd){r("hidden"),i(0);return}n()}function Mx(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 wl(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 md(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 gd(e,t,n){return Math.min(Math.max(e,t),n)}function bd(e){e.cancelable&&e.preventDefault()}function lo({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 za(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function zf(e){return e==="medium-navigation"||e==="expanded"}function Hf(e){return e==="medium-auxiliary"||e==="expanded"}function ku({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:o,navigationPanel:a,auxiliaryPanel:c}){const u=lo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=zf(u)&&a,h=Hf(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 Rx({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=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=t==="conversation-focus",V=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),L=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),I=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V}),G=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.androidMoreAction")}),q=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Lx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Dx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Bx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(_x,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Ox,{}),onClick:h}],P=j?{"--mobile-conversation-tabbar-progress":L.progress.toFixed(4)}:void 0;gu(S,C,j);function T(){const _=pu(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:q.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(mu,{composerPortalTarget:j?y:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":j?L.isOpen:!0,"data-conversation-tabbar-state":j?L.state:"default",style:P,children:[G?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[G.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:T,children:s.jsx(Ax,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:G.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(Px,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V,navigationPanel:r,auxiliaryPanel:i,children:n})}),j?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 Ax(){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 Px(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Lx(){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 Dx(){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 _x(){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 Bx(){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 Ox(){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 Wx=120,Oi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function gc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Fx(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 $x(){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(gc);return e.length>0?Math.max(...e):0}function kd(){if(typeof window>"u")return Oi;const e=window.visualViewport,t=$x(),n=(e==null?void 0:e.height)??t,r=gc(n)?Math.round(n):null,i=gc(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:Fx(typeof document<"u"?document.activeElement:null)&&o>=Wx}}function vl(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 zx(e){const[t,n]=f.useState(()=>e?kd():Oi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Oi),vl(!1,Oi);return}function i(){n(kd())}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),vl(!1,Oi)}},[e]),f.useEffect(()=>{vl(e,t)},[e,t]),t}function Hx({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=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=t==="conversation-focus",V=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),L=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),I=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V}),G=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),q=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Gx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Vx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Yx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Kx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Xx,{}),onClick:h}],P=j?{"--mobile-conversation-tabbar-progress":L.progress.toFixed(4)}:void 0;gu(S,C,j);function T(){const _=pu(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:q.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(mu,{composerPortalTarget:j?y:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":j?L.isOpen:!0,"data-conversation-tabbar-state":j?L.state:"default",style:P,children:[G?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:G.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:T,children:[s.jsx(Ux,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:G.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(qx,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V,navigationPanel:r,auxiliaryPanel:i,children:n})}),j?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 Ux(){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 qx(){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 Gx(){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 Vx(){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 Kx(){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 Yx(){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 Xx(){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 Jx(e){const t=bn();return t.platform==="ios"?s.jsx(Hx,{...e}):t.platform==="android"?s.jsx(Rx,{...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=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=zx(p.platform==="web"),V=p.platform==="web"&&j.keyboardOpen,L=t==="conversation-focus",I=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),G=bu({enabled:L,rootRef:S,suspended:V,resetKey:`${g.pathname}${g.search}`}),q=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),P=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),T=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(ty,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(ny,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(sy,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(ry,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(iy,{}),onClick:h}],H=L?{"--mobile-conversation-tabbar-progress":G.progress.toFixed(4)}:void 0;gu(S,C,L);function _(){const Y=pu(g.pathname,g.search);if(!Y){a();return}x(Y,{replace:!0})}const ie=s.jsx("nav",{ref:C,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:V,children:T.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(mu,{composerPortalTarget:L?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":V,"data-pane-layout":q,"data-tabbar-open":V?!1:L?G.isOpen:!0,"data-conversation-tabbar-state":L?G.state:"default",style:H,children:[P?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[P.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:_,children:s.jsx(Zx,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:P.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:P.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":P.moreButtonLabel,onClick:d,children:s.jsx(ey,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),L?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:ie})]}):ie]})})}function Zx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function ey(){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 ty(){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 ny(){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 ry(){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 sy(){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 iy(){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 oy{constructor(t){Ke(this,"maxAttempts");Ke(this,"baseDelayMs");Ke(this,"reconnectAttempts",0);Ke(this,"reconnectTimer",null);Ke(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(!Bn.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 ay{constructor(t){Ke(this,"socket",null);Ke(this,"disposed",!1);Ke(this,"authRecoveryInFlight",!1);Ke(this,"pendingRefresh",!1);Ke(this,"workbenchKnownRevision");Ke(this,"lastWorkbenchSnapshot",null);Ke(this,"fileTreeSubscription",null);Ke(this,"gitSubscription",null);Ke(this,"terminalManagerSubscription",null);Ke(this,"workspaceManagementSubscription",null);Ke(this,"pendingFileTreeRefresh",null);Ke(this,"pendingGitRefresh",null);Ke(this,"pendingTerminalManagerRefresh",null);Ke(this,"pendingWorkspaceManagementRefresh",null);Ke(this,"fileTreeRevisionByPath",new Map);Ke(this,"gitRevisionByWorkspaceId",new Map);Ke(this,"terminalManagerRevisionByWorkspaceId",new Map);Ke(this,"workspaceManagementRevisionByWorkspaceId",new Map);Ke(this,"fileTreeListeners",new Set);Ke(this,"gitListeners",new Set);Ke(this,"terminalManagerListeners",new Set);Ke(this,"workspaceManagementListeners",new Set);Ke(this,"workbenchSubscribeStartedAtMs",null);Ke(this,"workbenchRefreshStartedAtMs",null);Ke(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new oy({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!xd(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),Ot("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=jn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=jn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:yd(n),knownRevisionByPath:Sl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Cl(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=yd(n),o={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Cl(t,i,Sl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(o)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Sl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:jn(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:jn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:jn(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:jn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:jn(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:jn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:jn(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=Ji.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=Jc(),i=af(r),o=i.baseUrl,a=`${ik("/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})),Ot("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:Cl(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,j,V;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"&&(Ot("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?uy(h.snapshot):0,subscribeDurationMs:Oo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Oo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){Ot("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:Oo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Oo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const L=cy(this.lastWorkbenchSnapshot,h);if(!L){Ot("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=L,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(L);return}if(h.type==="fileTree.snapshot"){const L=h.snapshot;if(L)L.revision=h.revision,this.fileTreeRevisionByPath.set(bc(L.workspaceId,L.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(bc(this.fileTreeSubscription.workspaceId,I),h.revision);if(!L)return;(x=(g=this.options).onFileTreeSnapshot)==null||x.call(g,L),this.fileTreeListeners.forEach(I=>I(L));return}if(h.type==="git.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.gitRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!L)return;(C=(S=this.options).onGitSnapshot)==null||C.call(S,L),this.gitListeners.forEach(I=>I(L));return}if(h.type==="terminalManager.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!L)return;(A=(y=this.options).onTerminalManagerSnapshot)==null||A.call(y,L),this.terminalManagerListeners.forEach(I=>I(L));return}if(h.type==="workspaceManagement.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!L)return;(V=(j=this.options).onWorkspaceManagementSnapshot)==null||V.call(j,L),this.workspaceManagementListeners.forEach(I=>I(L));return}h.type==="workbench.snapshot"&&h.snapshot&&ly(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(),Ji.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 xd(n)?(n.send(JSON.stringify(t)),!0):!1}}function xd(e){return e!==null&&e.readyState===1}function ly(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function yd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function jn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function cy(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 Sl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),jn(n)]).filter(t=>t[1]!==null)):{}}function Cl(e,t,n,r){const i=t.map(o=>{const a=o.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[a,n[a]??r.get(bc(e,a))??null]}).filter(o=>!!o[1]);if(i.length!==0)return Object.fromEntries(i)}function bc(e,t){return`${e}::${t}`}function uy(e){return e.items.reduce((t,n)=>t+n.sessions.length+Uf(n.childWorktrees??[]),0)}function Uf(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)?Uf(r.children):0;return t+i+o},0)}function Oo(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const wd=6,dy=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function hy(e){return e instanceof HTMLElement?!e.closest(dy):!0}function kc(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&hy(n)}function qf(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Gf(e){return qf(e)?"":void 0}function py(e){if(!kc(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)<wd&&Math.abs(u.clientY-n)<wd||(i(),fy())},a=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),window.addEventListener("blur",c)}async function fy(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await xf().startDragging()}const Sa=.78,my=1;function gy(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function Vf(e,t,n,r){const i=Math.hypot(n-e,r-t),o=Math.min(1,i/120);return Sa+(my-Sa)*o}function Lr(e){return Math.round(Number.isFinite(e)?e:0)}function by(e){if(!gy())return null;const t=Lr(e.x),n=Lr(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:Sa}),{updatePosition(c,u){if(r)return;const d=Lr(c),h=Lr(u);o("update_detach_preview_position",{x:d,y:h,scale:Vf(t,n,d,h)})},complete(){return a()},cancel(){return a()}}}function ky(e){if(typeof document>"u")return null;const t=Lr(e.x),n=Lr(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",Sa.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=Lr(d),m=Lr(h),g=Vf(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 vd(e){return by(e)??ky(e)}const xy={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 yy(e){return{...e,bounds:{...e.bounds}}}function wy(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function vy(e){return xy[e]}function Kf(e,t){return`${e}-${t}`}async function Ha(e,t,n){const r=n.workspaceId.trim(),i=vy(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=Kf(t,r),a=e.windows.getDescriptor(o),c=a?yy(a):null,u=e.windows.isWindowOpen(o),d=ok({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?wy(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function cP(e){return Kf("terminals",e)}function Sy(e,t){return Ha(e,"files",t)}function Cy(e,t){return Ha(e,"git",t)}function Ny(e,t){return Ha(e,"processes",t)}function uP(e,t){return Ha(e,"terminals",t)}async function Sd(){return await xe.request("/api/skills/overview")}async function jy(e){await xe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Ty(e){await xe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Iy(e){await xe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}async function Ey(){return await xe.request("/api/opencli/catalog")}async function Cd(){return await xe.request("/api/opencli/check",{method:"POST"})}async function My(e){return await xe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Nl="all",jl="status";function Ry({toolbarMode:e="internal",onToolbarStateChange:t}={}){var We,Ue,Fe,rt;const n=Qc(F=>{var ne;return((ne=F.session)==null?void 0:ne.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),[j,V]=f.useState(Nl),[L,I]=f.useState(null),[G,q]=f.useState(!1),[P,T]=f.useState(""),[H,_]=f.useState(jl);f.useEffect(()=>{let F=!0;if(!n){i(null),m(!1),x([]),A(null),C(null),a(!1),V(Nl),I(null),q(!1),T(""),_(jl);return}return(async()=>{a(!0),A(null),C(null);try{const re=await Cd();if(!F)return;N(re)}catch(re){if(!F)return;const Se=Fo(re);try{const ke=await Ey();if(!F)return;N(ke),A(Se)}catch(ke){if(!F)return;A(Fo(ke))}}finally{F&&a(!1)}})(),()=>{F=!1}},[n]);const ie=f.useMemo(()=>new Set(g),[g]),Y=f.useMemo(()=>Ly((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),W=f.useMemo(()=>Oy(),[]);f.useEffect(()=>{Y.some(F=>F.id===j)||V(Nl)},[j,Y]);const U=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(F=>F.commands.some(ne=>Nd(ne,j,ie))),[j,r==null?void 0:r.siteGroups,ie]),D=f.useMemo(()=>L?U.find(F=>F.site===L)??null:null,[L,U]);f.useEffect(()=>{L&&!D&&I(null)},[L,D]),f.useEffect(()=>{T(""),_(jl)},[L]);const K=f.useMemo(()=>{if(!D)return[];const F=P.trim().toLowerCase();return D.commands.filter(ne=>Nd(ne,j,ie)&&_y(ne,F)).sort((ne,re)=>By(ne,re,{sortId:H,selectedCommandIdSet:ie}))},[j,D,P,H,ie]),ee=!!(r&&(r.provider.enabled!==p||r.entries.some(F=>F.enabled!==ie.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:de,onRefresh:()=>{Ne()},onShowDetails:()=>q(!0),onSave:()=>{ve()}}),[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 Ne(){if(n){u(!0),A(null),C(null);try{const F=await Cd();N(F),C(Gy(F.refreshState,F.runtimeAvailability))}catch(F){A(Fo(F))}finally{u(!1)}}}async function ve(){if(n){h(!0),A(null),C(null);try{const F=await My({enabled:p,enabledCommandIds:g});N(F),C(Vy(F))}catch(F){A(Fo(F))}finally{h(!1)}}}function N(F){i(F),m(F.provider.enabled),x(F.entries.filter(ne=>ne.enabled).map(ne=>ne.commandId).sort((ne,re)=>ne.localeCompare(re))),A(null)}function de(F){m(F)}function Ee(F,ne){const re=F.commands.map(Se=>Se.commandId);x(Se=>{const ke=new Set(Se);for(const pe of re)ne?ke.add(pe):ke.delete(pe);return[...ke].sort((pe,xt)=>pe.localeCompare(xt))})}function me(F,ne){x(re=>{const Se=new Set(re);return ne?Se.add(F):Se.delete(F),[...Se].sort((ke,pe)=>ke.localeCompare(pe))})}const le=(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(Ay,{state:v,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Wo,{label:l("settings.opencliSummaryInstallState"),value:Id(le.installState)}),s.jsx(Wo,{label:l("settings.opencliSummaryCatalogCount"),value:String(le.catalogCount)}),s.jsx(Wo,{label:l("settings.opencliSummaryEnabledCount"),value:String(g.length)}),s.jsx(Wo,{label:l("settings.opencliSummaryBrowserCount"),value:String(le.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 ne=j===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":ne,"data-active":ne?"true":"false",onClick:()=>V(F.id),children:F.label},F.id)})}),U.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:U.map(F=>{const ne=Dy(F,ie),re=Wy(F.commands),Se=Td(F,{maxDescriptions:2}),ke=Td(F),pe=Xf(F.site),xt=L===F.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":xt?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:pe.style,children:s.jsx("span",{children:pe.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:()=>I(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:ne.allSelected,disabled:c||d,ref:Xe=>{Xe&&(Xe.indeterminate=ne.partialSelected)},onChange:Xe=>Ee(F,Xe.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:ke,children:Se})]})]}),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(Xe=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Zf(Xe),children:Jf(Xe)},`${F.site}:${Xe}`))})})})]},F.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:Ky(r)}),s.jsx(Et,{open:G,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>q(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ys,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx(Lo,{children:Id(r.provider.installState)}),s.jsx(Lo,{children:zy(r.provider.healthState)}),s.jsx(Lo,{children:Uy(((We=r.activeRuntimeProfile)==null?void 0:We.status)??null)})]}),children:s.jsxs(ru,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(pn,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(pn,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(le.catalogCount)})}),s.jsx(pn,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(g.length)})}),s.jsx(pn,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(le.browserDependentCount)})}),s.jsx(pn,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(pn,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Hy(r.effectiveCatalogSource??null)})}),s.jsx(pn,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.lastCheckedAt)})}),s.jsx(pn,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.catalogRefreshedAt)})}),s.jsx(pn,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(pn,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(pn,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(Fe=r.activeRuntimeProfile)!=null&&Fe.lastErrorDetail?s.jsx(Ys,{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,(rt=r.activeRuntimeProfile)!=null&&rt.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(Et,{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:()=>I(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Ys,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Yf(D.commands).map(F=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:F},F))})}),s.jsx(Ys,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx(Lo,{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:P,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:F=>T(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 ne=H===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":ne,"data-active":ne?"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(Py,{command:F,checked:ie.has(F.commandId),disabled:c||d,onToggle:me},F.commandId))}):s.jsx(hf,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ay({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 Py({command:e,checked:t,disabled:n,onToggle:r}){const i=Xf(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":Zf(e.strategy),children:qy(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 Wo({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 Ly(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:Jf(n)})}))]}function Nd(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 Dy(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 _y(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
3
+ `).toLowerCase().includes(t):!0}function By(e,t,n){const r=jd(e,n)-jd(t,n);if(r!==0)return r;const i=e.name.localeCompare(t.name);return i!==0?i:e.commandId.localeCompare(t.commandId)}function jd(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 Oy(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function Yf(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function Td(e,t={}){const n=Yf(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function Wy(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 Xf(e){const t=Yy[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=Md[Math.abs($y(e))%Md.length];return{label:Fy(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function Fy(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 $y(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function Fo(e){return e instanceof Zc?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function Id(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function zy(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 Hy(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 Uy(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 qy(e){return l("settings.opencliStrategyLabel",{strategy:Qf(e)})}function Jf(e){return l("settings.opencliStrategyShortLabel",{strategy:Qf(e)})}function Qf(e){switch(em(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 Zf(e){return em(e)}function em(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function Gy(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function Vy(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function Ky(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function Ed(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const Md=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],Yy={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%)"}},Xy=[{id:"skills"},{id:"opencli"}];function Jy({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n}){const r=Qc(E=>{var $;return(($=E.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),[j,V]=f.useState(null),[L,I]=f.useState("file"),[G,q]=f.useState("workspace"),[P,T]=f.useState(""),[H,_]=f.useState(()=>Ri("workspace")),[ie,Y]=f.useState("skills"),[W,U]=f.useState(null),D=f.useId(),ee=bk(S&&!!r).items??[],v=f.useMemo(()=>iw(ee),[ee]);f.useEffect(()=>{let E=!0;if(!S)return;if(!r){a(null),m(null),x(null),u(!1);return}return(async()=>{u(!0);try{const se=await Sd();if(!E)return;a(se),m(null)}catch(se){if(!E)return;m(Ls(se))}finally{E&&u(!1)}})(),()=>{E=!1}},[r,S]);async function Ne(){const E=await Sd();a(E),m(null)}async function ve(){if(r){h("refresh"),m(null),x(null);try{await Ne(),x(l("settings.skillRefreshSuccess"))}catch(E){m(Ls(E))}finally{h(null)}}}async function N(E){if(r){h(Rd(E)),m(null),x(null);try{await Ty({targetCli:E.targetCli,directoryPath:E.directoryPath,expectedContentHash:E.contentHash}),await Ne(),x(l("settings.skillImportSuccess",{name:E.name,target:mn(E.targetCli)}))}catch($){m(Ls($))}finally{h(null)}}}async function de(E){if(!r)return;const $=E.bindings.filter(se=>se.enabled).map(se=>se.targetCli).filter(se=>Gt(se,v));if($.length===0){m(pw(E.bindings));return}h(Ad(E.skill.id)),m(null),x(null);try{await Iy({skillId:E.skill.id,targetCli:$}),await Ne(),x(l("settings.skillSyncSuccess",{name:E.skill.name}))}catch(se){m(Ls(se))}finally{h(null)}}async function Ee(E){var se;const $=((se=E.target.files)==null?void 0:se[0])??null;if(E.target.value="",!!$){m(null),x(null);try{const ue=await yw($),we=rm($.name,ue);V(we),_(Ri(G,v))}catch(ue){m(Ls(ue))}}}async function me(){const E=Pd({sourceMode:L,fileDraft:j,pastedMarkdown:P});if(!r)return;if(!E){m(L==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const $=E.directoryName;if(!$){m(l("settings.skillUploadDirectoryInvalid"));return}const se=Ca(G).filter(ue=>H[ue]).filter(ue=>Gt(ue,v)).map(ue=>ue);if(se.length===0){m(fw(G,v));return}h("upload"),m(null),x(null);try{await jy({markdownContent:E.rawContent,scope:G,fileName:E.fileName,directoryName:$,targetCli:se}),await Ne(),x(l("settings.skillUploadSuccess",{name:$})),F(G),A(!1)}catch(ue){m(Ls(ue))}finally{h(null)}}function le(E){q(E),_(Ri(E,v))}function We(E){I(E),V(null),T(""),_(Ri(G,v)),m(null)}function Ue(E){Gt(E,v)&&_($=>({...$,[E]:!$[E]}))}function Fe(){A(!0),m(null),F(G)}function rt(){A(!1),m(null),F(G)}function F(E){V(null),T(""),I("file"),_(Ri(E,v))}const ne=(o==null?void 0:o.summary)??{managedSkillCount:0,managedEntryCount:0},re=bw((o==null?void 0:o.assistantRuntimeSkills)??[],(o==null?void 0:o.conflictedEntries)??[],(o==null?void 0:o.diagnostics)??[]),Se=((o==null?void 0:o.conflictedEntries)??[]).filter(E=>!nm(E,(o==null?void 0:o.diagnostics)??[])),ke=((o==null?void 0:o.diagnostics)??[]).filter(E=>!co(E)),pe=Pd({sourceMode:L,fileDraft:j,pastedMarkdown:P}),xt=t??l("settings.skillManageAction"),Xe=ie==="skills",st=ie==="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:xt})]}),s.jsxs(Et,{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:Xy.map(E=>{const $=ie===E.id,se=`${D}-${E.id}-tab`,ue=`${D}-${E.id}-panel`;return s.jsx("button",{id:se,type:"button",role:"tab",className:"settings-model-tab","aria-selected":$,"aria-controls":ue,"data-active":$?"true":"false",onClick:()=>Y(E.id),children:Sw(E.id)},E.id)})}),Xe?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:Fe,children:l("settings.skillCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:()=>{ve()},children:d==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,st&&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:E=>W.onEnabledChange(E.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(Gk,{onClick:()=>{Y("skills"),C(!1)}})]}),Xe?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($o,{label:l("settings.skillSummaryManagedSkills"),value:String(ne.managedSkillCount)}),s.jsx($o,{label:l("settings.skillSummaryManagedEntries"),value:String(ne.managedEntryCount)}),s.jsx($o,{label:l("settings.skillSummaryConflictedEntries"),value:String(Se.length)}),s.jsx($o,{label:l("settings.skillSummaryDiagnostics"),value:String(ke.length)})]}),s.jsx("div",{className:"settings-release-meta",children:s.jsxs("span",{children:[l("settings.skillScannedAt"),": ",c?l("common.loading"):gw(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(Mi,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(o==null?void 0:o.managedSkills)??[],renderItem:E=>{const $=Ad(E.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:E.skill.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:uw(E.bindings)}),s.jsx("div",{className:"settings-skill-tags",children:E.bindings.map(se=>s.jsx("span",{className:"settings-skill-tag","data-status":lw(se,v),children:cw(se,v)},`${E.skill.id}-${se.targetCli}`))})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!aw(E.bindings,v),onClick:()=>{de(E)},children:d===$?l("common.loading"):l("settings.skillSyncAction")})})]},E.skill.id)}}),s.jsx(Mi,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(o==null?void 0:o.unmanagedEntries)??[],renderItem:E=>{const $=Rd(E);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:E.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:dw(E,v)}),Gt(E.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||!Gt(E.targetCli,v),onClick:()=>{N(E)},children:d===$?l("common.loading"):l("settings.skillImportAction")})})]},`${E.targetCli}:${E.directoryPath}`)}}),s.jsx(Mi,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:re,renderItem:E=>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:E.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"),": ",tm(E.usedByTargetCli)]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:l("settings.skillTagAssistantOnly")}),E.usedByTargetCli.map($=>s.jsx("span",{className:"settings-skill-tag","data-status":Gt($,v)?"synced":"failed",children:Gt($,v)?mn($):`${mn($)} · ${l("settings.skillTargetDisabledTag")}`},`${E.directoryName}:${$}`))]})]})},`${E.directoryName}:${E.sourcePath}`)}),s.jsx(Mi,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:Se,renderItem:E=>{const $=kw(E,(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:E.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:hw(E,v)}),$.length>0?s.jsx("div",{className:"settings-skill-tags",children:$.map(se=>s.jsx("span",{className:"settings-skill-tag","data-status":se.status,children:se.label},se.key))}):null]})},`${E.targetCli}:${E.directoryPath}`)}}),s.jsx(Mi,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:ke,renderItem:E=>{const $=xw(E),se=mw(E);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:se.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:se.detail}),$.length>0?s.jsx("div",{className:"settings-skill-tags",children:$.map(ue=>s.jsx("span",{className:"settings-skill-tag","data-status":ue.status,children:ue.label},ue.key))}):null]})},`${E.targetCli}:${E.code}:${E.directoryPath??E.rootDir}`)}})]}):s.jsx("div",{id:`${D}-opencli-panel`,role:"tabpanel","aria-labelledby":`${D}-opencli-tab`,className:"settings-skill-panel",children:s.jsx(Ry,{toolbarMode:"external",onToolbarStateChange:U})})]}),s.jsx(Et,{open:y,title:l("settings.skillCreateModalTitle"),description:l("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:rt,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:E=>{Ee(E)}}),s.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:tw.map(E=>{const $=L===E;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":$,"data-active":$?"true":"false",onClick:()=>We(E),children:rw(E)},E)})}),s.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:ew.map(E=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":G===E?"true":"false",children:[s.jsx("input",{type:"radio",name:"skill-upload-scope",checked:G===E,onChange:()=>le(E)}),s.jsx("span",{children:nw(E)})]},E))}),L==="file"?s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null,onClick:()=>{var E;(E=i.current)==null||E.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:P,onChange:E=>T(E.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),pe?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:pe.previewTitle}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",pe.fileName]})]})}):s.jsx("div",{className:"settings-skill-empty",children:L==="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:Ca(G).map(E=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":H[E]?"true":"false",children:[s.jsx("input",{type:"checkbox",checked:H[E],disabled:!Gt(E,v),onChange:()=>Ue(E)}),s.jsx("span",{children:Gt(E,v)?mn(E):`${mn(E)} · ${l("settings.skillTargetDisabledTag")}`})]},E))})]}),pe!=null&&pe.notes.length?s.jsx("div",{className:"settings-skill-tags",children:pe.notes.map((E,$)=>s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:E},`${pe.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:()=>{me()},children:d==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function Mi({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 $o({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 Rd(e){return`import:${e.targetCli}:${e.directoryPath}`}function Ad(e){return`sync:${e}`}const Qy=["codex","claude-code","gemini","opencode"],Zy=["codex","claude-code"],ew=["workspace","assistant"],tw=["file","paste"];function Ls(e){return e instanceof Zc?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function mn(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 nw(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function rw(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function Ri(e,t={}){const r=Ca(e).filter(i=>Gt(i,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function Ca(e){return e==="assistant"?Zy:Qy}function Pd({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?rm(ww(n),n):null}function sw(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 iw(e){const t={};for(const n of e){const r=ow(n.provider);r&&(t[r]=n)}return t}function ow(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 Gt(e,t){var n;return((n=t[e])==null?void 0:n.enabled)!==!1}function aw(e,t){return e.some(n=>n.enabled&&Gt(n.targetCli,t))}function lw(e,t){return Gt(e.targetCli,t)?e.syncStatus:"failed"}function cw(e,t){return Gt(e.targetCli,t)?`${mn(e.targetCli)} · ${sw(e.syncStatus)}`:`${mn(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function tm(e){return e.map(mn).join(" / ")}function uw(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:tm(t.map(n=>n.targetCli))})}function dw(e,t){return Gt(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:mn(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:mn(e.targetCli)})}function hw(e,t){return Gt(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:mn(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:mn(e.targetCli)})}function pw(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function fw(e,t){return Ca(e).some(r=>Gt(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function mw(e){const t=mn(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 gw(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function bw(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)nm(i,n)&&r.set(Ld(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli]});for(const i of n){if(!co(i))continue;const o=i.directoryPath??i.rootDir,a=Ld(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 Ld(e,t){return`${e}:${t}`}function nm(e,t){return t.some(n=>co(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function co(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function kw(e,t){return t.find(r=>co(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 xw(e){return co(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function rm(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=sm(r),o=xc(e)??xc(i)??"";return o||n.push(l("settings.skillUploadDirectoryRequiredNote")),i||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:o,previewTitle:i||vw(o||"skill"),notes:n}}async function yw(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 xc(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 ww(e){const t=xc(sm(e));return t?`${t}.md`:"pasted-skill.md"}function sm(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function vw(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Sw(e){switch(e){case"opencli":return l("settings.skillConfigTabOpenCli");default:return l("settings.skillConfigTabSkills")}}function Cw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Nw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tw={};function Dd(e,t){return(Tw.jsx?jw:Nw).test(e)}const Iw=/[ \t\n\f\r]/g;function Ew(e){return typeof e=="object"?e.type==="text"?_d(e.value):!1:_d(e)}function _d(e){return e.replace(Iw,"")===""}class uo{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}uo.prototype.normal={};uo.prototype.property={};uo.prototype.space=void 0;function im(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new uo(n,r,t)}function yc(e){return e.toLowerCase()}class ln{constructor(t,n){this.attribute=n,this.property=t}}ln.prototype.attribute="";ln.prototype.booleanish=!1;ln.prototype.boolean=!1;ln.prototype.commaOrSpaceSeparated=!1;ln.prototype.commaSeparated=!1;ln.prototype.defined=!1;ln.prototype.mustUseProperty=!1;ln.prototype.number=!1;ln.prototype.overloadedBoolean=!1;ln.prototype.property="";ln.prototype.spaceSeparated=!1;ln.prototype.space=void 0;let Mw=0;const Be=fs(),Rt=fs(),wc=fs(),oe=fs(),bt=fs(),ni=fs(),hn=fs();function fs(){return 2**++Mw}const vc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Be,booleanish:Rt,commaOrSpaceSeparated:hn,commaSeparated:ni,number:oe,overloadedBoolean:wc,spaceSeparated:bt},Symbol.toStringTag,{value:"Module"})),Tl=Object.keys(vc);class xu extends ln{constructor(t,n,r,i){let o=-1;if(super(t,n),Bd(this,"space",i),typeof r=="number")for(;++o<Tl.length;){const a=Tl[o];Bd(this,Tl[o],(r&vc[a])===vc[a])}}}xu.prototype.defined=!0;function Bd(e,t,n){n&&(e[t]=n)}function ui(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new xu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[yc(r)]=r,n[yc(o.attribute)]=r}return new uo(t,n,e.space)}const om=ui({properties:{ariaActiveDescendant:null,ariaAtomic:Rt,ariaAutoComplete:null,ariaBusy:Rt,ariaChecked:Rt,ariaColCount:oe,ariaColIndex:oe,ariaColSpan:oe,ariaControls:bt,ariaCurrent:null,ariaDescribedBy:bt,ariaDetails:null,ariaDisabled:Rt,ariaDropEffect:bt,ariaErrorMessage:null,ariaExpanded:Rt,ariaFlowTo:bt,ariaGrabbed:Rt,ariaHasPopup:null,ariaHidden:Rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:bt,ariaLevel:oe,ariaLive:null,ariaModal:Rt,ariaMultiLine:Rt,ariaMultiSelectable:Rt,ariaOrientation:null,ariaOwns:bt,ariaPlaceholder:null,ariaPosInSet:oe,ariaPressed:Rt,ariaReadOnly:Rt,ariaRelevant:null,ariaRequired:Rt,ariaRoleDescription:bt,ariaRowCount:oe,ariaRowIndex:oe,ariaRowSpan:oe,ariaSelected:Rt,ariaSetSize:oe,ariaSort:null,ariaValueMax:oe,ariaValueMin:oe,ariaValueNow:oe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function am(e,t){return t in e?e[t]:t}function lm(e,t){return am(e,t.toLowerCase())}const Rw=ui({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ni,acceptCharset:bt,accessKey:bt,action:null,allow:null,allowFullScreen:Be,allowPaymentRequest:Be,allowUserMedia:Be,alt:null,as:null,async:Be,autoCapitalize:null,autoComplete:bt,autoFocus:Be,autoPlay:Be,blocking:bt,capture:null,charSet:null,checked:Be,cite:null,className:bt,cols:oe,colSpan:null,content:null,contentEditable:Rt,controls:Be,controlsList:bt,coords:oe|ni,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Be,defer:Be,dir:null,dirName:null,disabled:Be,download:wc,draggable:Rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Be,formTarget:null,headers:bt,height:oe,hidden:wc,high:oe,href:null,hrefLang:null,htmlFor:bt,httpEquiv:bt,id:null,imageSizes:null,imageSrcSet:null,inert:Be,inputMode:null,integrity:null,is:null,isMap:Be,itemId:null,itemProp:bt,itemRef:bt,itemScope:Be,itemType:bt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Be,low:oe,manifest:null,max:null,maxLength:oe,media:null,method:null,min:null,minLength:oe,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:oe,pattern:null,ping:bt,placeholder:null,playsInline:Be,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Be,referrerPolicy:null,rel:bt,required:Be,reversed:Be,rows:oe,rowSpan:oe,sandbox:bt,scope:null,scoped:Be,seamless:Be,selected:Be,shadowRootClonable:Be,shadowRootDelegatesFocus:Be,shadowRootMode:null,shape:null,size:oe,sizes:null,slot:null,span:oe,spellCheck:Rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:oe,step:null,style:null,tabIndex:oe,target:null,title:null,translate:null,type:null,typeMustMatch:Be,useMap:null,value:Rt,width:oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:bt,axis:null,background:null,bgColor:null,border:oe,borderColor:null,bottomMargin:oe,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:oe,leftMargin:oe,link:null,longDesc:null,lowSrc:null,marginHeight:oe,marginWidth:oe,noResize:Be,noHref:Be,noShade:Be,noWrap:Be,object:null,profile:null,prompt:null,rev:null,rightMargin:oe,rules:null,scheme:null,scrolling:Rt,standby:null,summary:null,text:null,topMargin:oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Be,disableRemotePlayback:Be,prefix:null,property:null,results:oe,security:null,unselectable:null},space:"html",transform:lm}),Aw=ui({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:hn,accentHeight:oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:oe,amplitude:oe,arabicForm:null,ascent:oe,attributeName:null,attributeType:null,azimuth:oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:oe,by:null,calcMode:null,capHeight:oe,className:bt,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:oe,diffuseConstant:oe,direction:null,display:null,dur:null,divisor:oe,dominantBaseline:null,download:Be,dx:null,dy:null,edgeMode:null,editable:null,elevation:oe,enableBackground:null,end:null,event:null,exponent:oe,externalResourcesRequired:null,fill:null,fillOpacity:oe,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:ni,g2:ni,glyphName:ni,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:oe,horizOriginX:oe,horizOriginY:oe,id:null,ideographic:oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:oe,k:oe,k1:oe,k2:oe,k3:oe,k4:oe,kernelMatrix:hn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:oe,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:oe,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:oe,overlineThickness:oe,paintOrder:null,panose1:null,path:null,pathLength:oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:bt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:oe,pointsAtY:oe,pointsAtZ:oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:hn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:hn,rev:hn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:hn,requiredFeatures:hn,requiredFonts:hn,requiredFormats:hn,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:oe,specularExponent:oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:oe,strikethroughThickness:oe,string:null,stroke:null,strokeDashArray:hn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:oe,strokeOpacity:oe,strokeWidth:null,style:null,surfaceScale:oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:hn,tabIndex:oe,tableValues:null,target:null,targetX:oe,targetY:oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:hn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:oe,underlineThickness:oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:oe,values:null,vAlphabetic:oe,vMathematical:oe,vectorEffect:null,vHanging:oe,vIdeographic:oe,version:null,vertAdvY:oe,vertOriginX:oe,vertOriginY:oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:am}),cm=ui({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()}}),um=ui({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:lm}),dm=ui({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Pw={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"},Lw=/[A-Z]/g,Od=/-[a-z]/g,Dw=/^data[-\w.:]+$/i;function _w(e,t){const n=yc(t);let r=t,i=ln;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Dw.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Od,Ow);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Od.test(o)){let a=o.replace(Lw,Bw);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=xu}return new i(r,t)}function Bw(e){return"-"+e.toLowerCase()}function Ow(e){return e.charAt(1).toUpperCase()}const Ww=im([om,Rw,cm,um,dm],"html"),yu=im([om,Aw,cm,um,dm],"svg");function Fw(e){return e.join(" ").trim()}var Ds={},Il,Wd;function $w(){if(Wd)return Il;Wd=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,j=1;function V(Y){var W=Y.match(t);W&&(A+=W.length);var U=Y.lastIndexOf(u);j=~U?Y.length-U:j+Y.length}function L(){var Y={line:A,column:j};return function(W){return W.position=new I(Y),P(),W}}function I(Y){this.start=Y,this.end={line:A,column:j},this.source=y.source}I.prototype.content=C;function G(Y){var W=new Error(y.source+":"+A+":"+j+": "+Y);if(W.reason=Y,W.filename=y.source,W.line=A,W.column=j,W.source=C,!y.silent)throw W}function q(Y){var W=Y.exec(C);if(W){var U=W[0];return V(U),C=C.slice(U.length),W}}function P(){q(n)}function T(Y){var W;for(Y=Y||[];W=H();)W!==!1&&Y.push(W);return Y}function H(){var Y=L();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 G("End of comment missing");var U=C.slice(2,W-2);return j+=2,V(U),C=C.slice(W),j+=2,Y({type:m,comment:U})}}function _(){var Y=L(),W=q(r);if(W){if(H(),!q(i))return G("property missing ':'");var U=q(o),D=Y({type:g,property:S(W[0].replace(e,p)),value:U?S(U[0].replace(e,p)):p});return q(a),D}}function ie(){var Y=[];T(Y);for(var W;W=_();)W!==!1&&(Y.push(W),T(Y));return Y}return P(),ie()}function S(C){return C?C.replace(c,p):p}return Il=x,Il}var Fd;function zw(){if(Fd)return Ds;Fd=1;var e=Ds&&Ds.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.default=n;const t=e($w());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 Ds}var Ai={},$d;function Hw(){if($d)return Ai;$d=1,Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.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 Ai.camelCase=u,Ai}var Pi,zd;function Uw(){if(zd)return Pi;zd=1;var e=Pi&&Pi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(zw()),n=Hw();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,Pi=r,Pi}var qw=Uw();const Gw=lf(qw),hm=pm("end"),wu=pm("start");function pm(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 Vw(e){const t=wu(e),n=hm(e);if(t&&n)return{start:t,end:n}}function Gi(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Hd(e.position):"start"in e||"end"in e?Hd(e):"line"in e||"column"in e?Sc(e):""}function Sc(e){return Ud(e&&e.line)+":"+Ud(e&&e.column)}function Hd(e){return Sc(e&&e.start)+"-"+Sc(e&&e.end)}function Ud(e){return e&&typeof e=="number"?e:1}class Kt 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=Gi(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}}Kt.prototype.file="";Kt.prototype.name="";Kt.prototype.reason="";Kt.prototype.message="";Kt.prototype.stack="";Kt.prototype.column=void 0;Kt.prototype.line=void 0;Kt.prototype.ancestors=void 0;Kt.prototype.cause=void 0;Kt.prototype.fatal=void 0;Kt.prototype.place=void 0;Kt.prototype.ruleId=void 0;Kt.prototype.source=void 0;const vu={}.hasOwnProperty,Kw=new Map,Yw=/[A-Z]/g,Xw=new Set(["table","tbody","thead","tfoot","tr"]),Jw=new Set(["td","th"]),fm="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=ov(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=iv(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"?yu:Ww,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=mm(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function mm(e,t,n){if(t.type==="element")return Zw(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ev(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return nv(e,t,n);if(t.type==="mdxjsEsm")return tv(e,t);if(t.type==="root")return rv(e,t,n);if(t.type==="text")return sv(e,t)}function Zw(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=yu,e.schema=i),e.ancestors.push(t);const o=bm(e,t.tagName,!1),a=av(e,t);let c=Cu(e,t);return Xw.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!Ew(u):!0})),gm(e,a,o,t),Su(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function ev(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)}Zi(e,t.position)}function tv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Zi(e,t.position)}function nv(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=yu,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:bm(e,t.name,!0),a=lv(e,t),c=Cu(e,t);return gm(e,a,o,t),Su(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function rv(e,t,n){const r={};return Su(r,Cu(e,t)),e.create(t,e.Fragment,r,n)}function sv(e,t){return t.value}function gm(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Su(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function iv(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 ov(e,t){return n;function n(r,i,o,a){const c=Array.isArray(o.children),u=wu(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 av(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&vu.call(t.properties,i)){const o=cv(e,i,t.properties[i]);if(o){const[a,c]=o;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&Jw.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 lv(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 Zi(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 Zi(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Cu(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Kw;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=mm(e,o,a);c!==void 0&&n.push(c)}return n}function cv(e,t,n){const r=_w(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Cw(n):Fw(n)),r.property==="style"){let i=typeof n=="object"?n:uv(e,String(n));return e.stylePropertyNameCase==="css"&&(i=dv(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Pw[r.property]||r.property:r.attribute,n]}}function uv(e,t){try{return Gw(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Kt("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=fm+"#cannot-parse-style-attribute",i}}function bm(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=Dd(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=Dd(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return vu.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Zi(e)}function Zi(e,t){const n=new Kt("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=fm+"#cannot-handle-mdx-estrees-without-createevaluater",n}function dv(e){const t={};let n;for(n in e)vu.call(e,n)&&(t[hv(n)]=e[n]);return t}function hv(e){let t=e.replace(Yw,pv);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function pv(e){return"-"+e.toLowerCase()}const El={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"]},fv={};function Nu(e,t){const n=fv,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return km(e,r,i)}function km(e,t,n){if(mv(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 qd(e.children,t,n)}return Array.isArray(e)?qd(e,t,n):""}function qd(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=km(e[i],t,n);return r.join("")}function mv(e){return!!(e&&typeof e=="object")}const Gd=document.createElement("i");function ju(e){const t="&"+e+";";Gd.innerHTML=t;const n=Gd.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function gn(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 Tn(e,t){return e.length>0?(gn(e,e.length,0,t),e):t}const Vd={}.hasOwnProperty;function xm(e){const t={};let n=-1;for(;++n<e.length;)gv(t,e[n]);return t}function gv(e,t){let n;for(n in t){const i=(Vd.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Vd.call(i,a)||(i[a]=[]);const c=o[a];bv(i[a],Array.isArray(c)?c:c?[c]:[])}}}function bv(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);gn(e,0,0,r)}function ym(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 On(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const en=Br(/[A-Za-z]/),Vt=Br(/[\dA-Za-z]/),kv=Br(/[#-'*+\--9=?A-Z^-~]/);function Na(e){return e!==null&&(e<32||e===127)}const Cc=Br(/\d/),xv=Br(/[\dA-Fa-f]/),yv=Br(/[!-/:-@[-`{-~]/);function Ie(e){return e!==null&&e<-2}function dt(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const Ua=Br(new RegExp("\\p{P}|\\p{S}","u")),us=Br(/\s/);function Br(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function di(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&Vt(e.charCodeAt(n+1))&&Vt(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 Ye(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return ze(u)?(e.enter(n),c(u)):t(u)}function c(u){return ze(u)&&o++<i?(e.consume(u),c):(e.exit(n),t(u))}}const wv={tokenize:vv};function vv(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"),Ye(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 Ie(c)?(e.consume(c),e.exit("chunkText"),o):(e.consume(c),a)}}const Sv={tokenize:Cv},Kd={tokenize:Nv};function Cv(e){const t=this,n=[];let r=0,i,o,a;return c;function c(j){if(r<n.length){const V=n[r];return t.containerState=V[1],e.attempt(V[0].continuation,u,d)(j)}return d(j)}function u(j){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&A();const V=t.events.length;let L=V,I;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){I=t.events[L][1].end;break}y(r);let G=V;for(;G<t.events.length;)t.events[G][1].end={...I},G++;return gn(t.events,L+1,0,t.events.slice(V)),t.events.length=G,d(j)}return c(j)}function d(j){if(r===n.length){if(!i)return m(j);if(i.currentConstruct&&i.currentConstruct.concrete)return x(j);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Kd,h,p)(j)}function h(j){return i&&A(),y(r),m(j)}function p(j){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,x(j)}function m(j){return t.containerState={},e.attempt(Kd,g,x)(j)}function g(j){return r++,n.push([t.currentConstruct,t.containerState]),m(j)}function x(j){if(j===null){i&&A(),y(0),e.consume(j);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),S(j)}function S(j){if(j===null){C(e.exit("chunkFlow"),!0),y(0),e.consume(j);return}return Ie(j)?(e.consume(j),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(j),S)}function C(j,V){const L=t.sliceStream(j);if(V&&L.push(null),j.previous=o,o&&(o.next=j),o=j,i.defineSkip(j.start),i.write(L),t.parser.lazy[j.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<a&&(!i.events[I][1].end||i.events[I][1].end.offset>a))return;const G=t.events.length;let q=G,P,T;for(;q--;)if(t.events[q][0]==="exit"&&t.events[q][1].type==="chunkFlow"){if(P){T=t.events[q][1].end;break}P=!0}for(y(r),I=G;I<t.events.length;)t.events[I][1].end={...T},I++;gn(t.events,q+1,0,t.events.slice(G)),t.events.length=I}}function y(j){let V=n.length;for(;V-- >j;){const L=n[V];t.containerState=L[1],L[0].exit.call(t,e)}n.length=j}function A(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Nv(e,t,n){return Ye(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function oi(e){if(e===null||dt(e)||us(e))return 1;if(Ua(e))return 2}function qa(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 Nc={name:"attention",resolveAll:jv,tokenize:Tv};function jv(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};Yd(p,-u),Yd(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=Tn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Tn(d,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=Tn(d,qa(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Tn(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=Tn(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,gn(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 Tv(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=oi(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=oi(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 Yd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Iv={name:"autolink",tokenize:Ev};function Ev(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 en(g)?(e.consume(g),a):g===64?n(g):d(g)}function a(g){return g===43||g===45||g===46||Vt(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||Vt(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||Na(g)?n(g):(e.consume(g),u)}function d(g){return g===64?(e.consume(g),h):kv(g)?(e.consume(g),d):n(g)}function h(g){return Vt(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||Vt(g))&&r++<63){const x=g===45?m:p;return e.consume(g),x}return n(g)}}const ho={partial:!0,tokenize:Mv};function Mv(e,t,n){return r;function r(o){return ze(o)?Ye(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||Ie(o)?t(o):n(o)}}const wm={continuation:{tokenize:Av},exit:Pv,name:"blockQuote",tokenize:Rv};function Rv(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 ze(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Av(e,t,n){const r=this;return i;function i(a){return ze(a)?Ye(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(wm,t,n)(a)}}function Pv(e){e.exit("blockQuote")}const vm={name:"characterEscape",tokenize:Lv};function Lv(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 yv(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Sm={name:"characterReference",tokenize:Dv};function Dv(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=Vt,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=xv,h):(e.enter("characterReferenceValue"),o=7,a=Cc,h(p))}function h(p){if(p===59&&i){const m=e.exit("characterReferenceValue");return a===Vt&&!ju(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 Xd={partial:!0,tokenize:Bv},Jd={concrete:!0,name:"codeFenced",tokenize:_v};function _v(e,t,n){const r=this,i={partial:!0,tokenize:L};let o=0,a=0,c;return u;function u(I){return d(I)}function d(I){const G=r.events[r.events.length-1];return o=G&&G[1].type==="linePrefix"?G[2].sliceSerialize(G[1],!0).length:0,c=I,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(I)}function h(I){return I===c?(a++,e.consume(I),h):a<3?n(I):(e.exit("codeFencedFenceSequence"),ze(I)?Ye(e,p,"whitespace")(I):p(I))}function p(I){return I===null||Ie(I)?(e.exit("codeFencedFence"),r.interrupt?t(I):e.check(Xd,S,V)(I)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(I))}function m(I){return I===null||Ie(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(I)):ze(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ye(e,g,"whitespace")(I)):I===96&&I===c?n(I):(e.consume(I),m)}function g(I){return I===null||Ie(I)?p(I):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),x(I))}function x(I){return I===null||Ie(I)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(I)):I===96&&I===c?n(I):(e.consume(I),x)}function S(I){return e.attempt(i,V,C)(I)}function C(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),y}function y(I){return o>0&&ze(I)?Ye(e,A,"linePrefix",o+1)(I):A(I)}function A(I){return I===null||Ie(I)?e.check(Xd,S,V)(I):(e.enter("codeFlowValue"),j(I))}function j(I){return I===null||Ie(I)?(e.exit("codeFlowValue"),A(I)):(e.consume(I),j)}function V(I){return e.exit("codeFenced"),t(I)}function L(I,G,q){let P=0;return T;function T(W){return I.enter("lineEnding"),I.consume(W),I.exit("lineEnding"),H}function H(W){return I.enter("codeFencedFence"),ze(W)?Ye(I,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):_(W)}function _(W){return W===c?(I.enter("codeFencedFenceSequence"),ie(W)):q(W)}function ie(W){return W===c?(P++,I.consume(W),ie):P>=a?(I.exit("codeFencedFenceSequence"),ze(W)?Ye(I,Y,"whitespace")(W):Y(W)):q(W)}function Y(W){return W===null||Ie(W)?(I.exit("codeFencedFence"),G(W)):q(W)}}}function Bv(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 Ml={name:"codeIndented",tokenize:Wv},Ov={partial:!0,tokenize:Fv};function Wv(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),Ye(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):Ie(d)?e.attempt(Ov,a,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Ie(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function Fv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):Ie(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Ye(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):Ie(a)?i(a):n(a)}}const $v={name:"codeText",previous:Hv,resolve:zv,tokenize:Uv};function zv(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 Hv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Uv(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)):Ie(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||Ie(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 qv{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&&Li(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),Li(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Li(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);Li(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Li(this.left,n.reverse())}}}function Li(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 Cm(e){const t={};let n=-1,r,i,o,a,c,u,d;const h=new qv(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,Gv(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 gn(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function Gv(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 Vv={resolve:Yv,tokenize:Xv},Kv={partial:!0,tokenize:Jv};function Yv(e){return Cm(e),e}function Xv(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):Ie(c)?e.check(Kv,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 Jv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ye(e,o,"linePrefix")}function o(a){if(a===null||Ie(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 Nm(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||Na(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||Ie(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||dt(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||Na(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 jm(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):Ie(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||Ie(g)||c++>999?(e.exit("chunkString"),h(g)):(e.consume(g),u||(u=!ze(g)),g===92?m:p)}function m(g){return g===91||g===92||g===93?(e.consume(g),c++,p):p(g)}}function Tm(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):Ie(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Ye(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(m))}function h(m){return m===a||m===null||Ie(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 Vi(e,t){let n;return r;function r(i){return Ie(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ze(i)?Ye(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Qv={name:"definition",tokenize:eS},Zv={partial:!0,tokenize:tS};function eS(e,t,n){const r=this;let i;return o;function o(g){return e.enter("definition"),a(g)}function a(g){return jm.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function c(g){return i=On(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 dt(g)?Vi(e,d)(g):d(g)}function d(g){return Nm(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function h(g){return e.attempt(Zv,p,p)(g)}function p(g){return ze(g)?Ye(e,m,"whitespace")(g):m(g)}function m(g){return g===null||Ie(g)?(e.exit("definition"),r.parser.defined.push(i),t(g)):n(g)}}function tS(e,t,n){return r;function r(c){return dt(c)?Vi(e,i)(c):n(c)}function i(c){return Tm(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return ze(c)?Ye(e,a,"whitespace")(c):a(c)}function a(c){return c===null||Ie(c)?t(c):n(c)}}const nS={name:"hardBreakEscape",tokenize:rS};function rS(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return Ie(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const sS={name:"headingAtx",resolve:iS,tokenize:oS};function iS(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"},gn(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function oS(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||dt(h)?(e.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Ie(h)?(e.exit("atxHeading"),t(h)):ze(h)?Ye(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||dt(h)?(e.exit("atxHeadingText"),c(h)):(e.consume(h),d)}}const aS=["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"],Qd=["pre","script","style","textarea"],lS={concrete:!0,name:"htmlFlow",resolveTo:dS,tokenize:hS},cS={partial:!0,tokenize:fS},uS={partial:!0,tokenize:pS};function dS(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 hS(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):en(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):en(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 de="CDATA[";return N===de.charCodeAt(c++)?(e.consume(N),c===de.length?r.interrupt?t:_:x):n(N)}function S(N){return en(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function C(N){if(N===null||N===47||N===62||dt(N)){const de=N===47,Ee=a.toLowerCase();return!de&&!o&&Qd.includes(Ee)?(i=1,r.interrupt?t(N):_(N)):aS.includes(a.toLowerCase())?(i=6,de?(e.consume(N),y):r.interrupt?t(N):_(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):o?A(N):j(N))}return N===45||Vt(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 ze(N)?(e.consume(N),A):T(N)}function j(N){return N===47?(e.consume(N),T):N===58||N===95||en(N)?(e.consume(N),V):ze(N)?(e.consume(N),j):T(N)}function V(N){return N===45||N===46||N===58||N===95||Vt(N)?(e.consume(N),V):L(N)}function L(N){return N===61?(e.consume(N),I):ze(N)?(e.consume(N),L):j(N)}function I(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,G):ze(N)?(e.consume(N),I):q(N)}function G(N){return N===u?(e.consume(N),u=null,P):N===null||Ie(N)?n(N):(e.consume(N),G)}function q(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||dt(N)?L(N):(e.consume(N),q)}function P(N){return N===47||N===62||ze(N)?j(N):n(N)}function T(N){return N===62?(e.consume(N),H):n(N)}function H(N){return N===null||Ie(N)?_(N):ze(N)?(e.consume(N),H):n(N)}function _(N){return N===45&&i===2?(e.consume(N),U):N===60&&i===1?(e.consume(N),D):N===62&&i===4?(e.consume(N),Ne):N===63&&i===3?(e.consume(N),v):N===93&&i===5?(e.consume(N),ee):Ie(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(cS,ve,ie)(N)):N===null||Ie(N)?(e.exit("htmlFlowData"),ie(N)):(e.consume(N),_)}function ie(N){return e.check(uS,Y,ve)(N)}function Y(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),W}function W(N){return N===null||Ie(N)?ie(N):(e.enter("htmlFlowData"),_(N))}function U(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 de=a.toLowerCase();return Qd.includes(de)?(e.consume(N),Ne):_(N)}return en(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),Ne):N===45&&i===2?(e.consume(N),v):_(N)}function Ne(N){return N===null||Ie(N)?(e.exit("htmlFlowData"),ve(N)):(e.consume(N),Ne)}function ve(N){return e.exit("htmlFlow"),t(N)}}function pS(e,t,n){const r=this;return i;function i(a){return Ie(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 fS(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ho,t,n)}}const mS={name:"htmlText",tokenize:gS};function gS(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),L):v===63?(e.consume(v),j):en(v)?(e.consume(v),q):n(v)}function d(v){return v===45?(e.consume(v),h):v===91?(e.consume(v),o=0,x):en(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):Ie(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?U(v):v===45?m(v):p(v)}function x(v){const Ne="CDATA[";return v===Ne.charCodeAt(o++)?(e.consume(v),o===Ne.length?S:x):n(v)}function S(v){return v===null?n(v):v===93?(e.consume(v),C):Ie(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?U(v):v===93?(e.consume(v),y):S(v)}function A(v){return v===null||v===62?U(v):Ie(v)?(a=A,D(v)):(e.consume(v),A)}function j(v){return v===null?n(v):v===63?(e.consume(v),V):Ie(v)?(a=j,D(v)):(e.consume(v),j)}function V(v){return v===62?U(v):j(v)}function L(v){return en(v)?(e.consume(v),I):n(v)}function I(v){return v===45||Vt(v)?(e.consume(v),I):G(v)}function G(v){return Ie(v)?(a=G,D(v)):ze(v)?(e.consume(v),G):U(v)}function q(v){return v===45||Vt(v)?(e.consume(v),q):v===47||v===62||dt(v)?P(v):n(v)}function P(v){return v===47?(e.consume(v),U):v===58||v===95||en(v)?(e.consume(v),T):Ie(v)?(a=P,D(v)):ze(v)?(e.consume(v),P):U(v)}function T(v){return v===45||v===46||v===58||v===95||Vt(v)?(e.consume(v),T):H(v)}function H(v){return v===61?(e.consume(v),_):Ie(v)?(a=H,D(v)):ze(v)?(e.consume(v),H):P(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,ie):Ie(v)?(a=_,D(v)):ze(v)?(e.consume(v),_):(e.consume(v),Y)}function ie(v){return v===i?(e.consume(v),i=void 0,W):v===null?n(v):Ie(v)?(a=ie,D(v)):(e.consume(v),ie)}function Y(v){return v===null||v===34||v===39||v===60||v===61||v===96?n(v):v===47||v===62||dt(v)?P(v):(e.consume(v),Y)}function W(v){return v===47||v===62||dt(v)?P(v):n(v)}function U(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 ze(v)?Ye(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 Tu={name:"labelEnd",resolveAll:yS,resolveTo:wS,tokenize:vS},bS={tokenize:SS},kS={tokenize:CS},xS={tokenize:NS};function yS(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&&gn(e,0,e.length,n),e}function wS(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=Tn(c,e.slice(o+1,o+r+3)),c=Tn(c,[["enter",h,t]]),c=Tn(c,qa(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),c=Tn(c,[["exit",h,t],e[a-2],e[a-1],["exit",d,t]]),c=Tn(c,e.slice(a+1)),c=Tn(c,[["exit",u,t]]),gn(e,o,e.length,c),e}function vS(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(On(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(bS,h,a?h:p)(m):m===91?e.attempt(kS,h,a?d:p)(m):a?h(m):p(m)}function d(m){return e.attempt(xS,h,p)(m)}function h(m){return t(m)}function p(m){return o._balanced=!0,n(m)}}function SS(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 dt(p)?Vi(e,o)(p):o(p)}function o(p){return p===41?h(p):Nm(e,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return dt(p)?Vi(e,u)(p):h(p)}function c(p){return n(p)}function u(p){return p===34||p===39||p===40?Tm(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return dt(p)?Vi(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 CS(e,t,n){const r=this;return i;function i(c){return jm.call(r,e,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return r.parser.defined.includes(On(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function a(c){return n(c)}}function NS(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 jS={name:"labelStartImage",resolveAll:Tu.resolveAll,tokenize:TS};function TS(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 IS={name:"labelStartLink",resolveAll:Tu.resolveAll,tokenize:ES};function ES(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 Rl={name:"lineEnding",tokenize:MS};function MS(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ye(e,t,"linePrefix")}}const ma={name:"thematicBreak",tokenize:RS};function RS(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||Ie(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),ze(d)?Ye(e,c,"whitespace")(d):c(d))}}const on={continuation:{tokenize:DS},exit:BS,name:"list",tokenize:LS},AS={partial:!0,tokenize:OS},PS={partial:!0,tokenize:_S};function LS(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:Cc(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(ma,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 Cc(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(ho,r.interrupt?n:h,e.attempt(AS,m,p))}function h(g){return r.containerState.initialBlankLine=!0,o++,m(g)}function p(g){return ze(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 DS(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ho,i,o);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ye(e,t,"listItemIndent",r.containerState.size+1)(c)}function o(c){return r.containerState.furtherBlankLines||!ze(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(PS,t,a)(c))}function a(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ye(e,e.attempt(on,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function _S(e,t,n){const r=this;return Ye(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 BS(e){e.exit(this.containerState.type)}function OS(e,t,n){const r=this;return Ye(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!ze(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Zd={name:"setextUnderline",resolveTo:WS,tokenize:FS};function WS(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 FS(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"),ze(d)?Ye(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ie(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const $S={tokenize:zS};function zS(e){const t=this,n=e.attempt(ho,r,e.attempt(this.parser.constructs.flowInitial,i,Ye(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Vv,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 HS={resolveAll:Em()},US=Im("string"),qS=Im("text");function Im(e){return{resolveAll:Em(e==="text"?GS: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 Em(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 GS(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 VS={42:on,43:on,45:on,48:on,49:on,50:on,51:on,52:on,53:on,54:on,55:on,56:on,57:on,62:wm},KS={91:Qv},YS={[-2]:Ml,[-1]:Ml,32:Ml},XS={35:sS,42:ma,45:[Zd,ma],60:lS,61:Zd,95:ma,96:Jd,126:Jd},JS={38:Sm,92:vm},QS={[-5]:Rl,[-4]:Rl,[-3]:Rl,33:jS,38:Sm,42:Nc,60:[Iv,mS],91:IS,92:[nS,vm],93:Tu,95:Nc,96:$v},ZS={null:[Nc,HS]},eC={null:[42,95]},tC={null:[]},nC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eC,contentInitial:KS,disable:tC,document:VS,flow:XS,flowInitial:YS,insideSpan:ZS,string:JS,text:QS},Symbol.toStringTag,{value:"Module"}));function rC(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:G(L),check:G(I),consume:A,enter:j,exit:V,interrupt:G(I,{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=Tn(a,H),C(),a[a.length-1]!==null?[]:(q(t,0),d.events=qa(o,d.events,d),d.events)}function m(H,_){return iC(g(H),_)}function g(H){return sC(a,H)}function x(){const{_bufferIndex:H,_index:_,line:ie,column:Y,offset:W}=r;return{_bufferIndex:H,_index:_,line:ie,column:Y,offset:W}}function S(H){i[H.line]=H.column,T()}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){Ie(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,T()):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 j(H,_){const ie=_||{};return ie.type=H,ie.start=x(),d.events.push(["enter",ie,d]),c.push(ie),ie}function V(H){const _=c.pop();return _.end=x(),d.events.push(["exit",_,d]),_}function L(H,_){q(H,_.from)}function I(H,_){_.restore()}function G(H,_){return ie;function ie(Y,W,U){let D,K,ee,v;return Array.isArray(Y)?ve(Y):"tokenize"in Y?ve([Y]):Ne(Y);function Ne(me){return le;function le(We){const Ue=We!==null&&me[We],Fe=We!==null&&me.null,rt=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(Fe)?Fe:Fe?[Fe]:[]];return ve(rt)(We)}}function ve(me){return D=me,K=0,me.length===0?U:N(me[K])}function N(me){return le;function le(We){return v=P(),ee=me,me.partial||(d.currentConstruct=me),me.name&&d.parser.constructs.disable.null.includes(me.name)?Ee():me.tokenize.call(_?Object.assign(Object.create(d),_):d,u,de,Ee)(We)}}function de(me){return H(ee,v),W}function Ee(me){return v.restore(),++K<D.length?N(D[K]):U}}}function q(H,_){H.resolveAll&&!o.includes(H)&&o.push(H),H.resolve&&gn(d.events,_,d.events.length-_,H.resolve(d.events.slice(_),d)),H.resolveTo&&(d.events=H.resolveTo(d.events,d))}function P(){const H=x(),_=d.previous,ie=d.currentConstruct,Y=d.events.length,W=Array.from(c);return{from:Y,restore:U};function U(){r=H,d.previous=_,d.currentConstruct=ie,d.events.length=Y,c=W,T()}}function T(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sC(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 iC(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 oC(e){const r={constructs:xm([nC,...(e||{}).extensions||[]]),content:i(wv),defined:[],document:i(Sv),flow:i($S),lazy:{},string:i(US),text:i(qS)};return r;function i(o){return a;function a(c){return rC(r,o,c)}}}function aC(e){for(;!Cm(e););return e}const eh=/[\0\t\n\r]/g;function lC(){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(eh.lastIndex=p,d=eh.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 cC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uC(e){return e.replace(cC,dC)}function dC(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return ym(n.slice(o?2:1),o?16:10)}return ju(n)||e}const Mm={}.hasOwnProperty;function hC(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),pC(n)(aC(oC(n).document().write(lC()(e,t,!0))))}function pC(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Xe),autolinkProtocol:P,autolinkEmail:P,atxHeading:o(Se),blockQuote:o(Fe),characterEscape:P,characterReference:P,codeFenced:o(rt),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(rt,a),codeText:o(F,a),codeTextData:P,data:P,codeFlowValue:P,definition:o(ne),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(re),hardBreakEscape:o(ke),hardBreakTrailing:o(ke),htmlFlow:o(pe,a),htmlFlowData:P,htmlText:o(pe,a),htmlTextData:P,image:o(xt),label:a,link:o(Xe),listItem:o(E),listItemValue:m,listOrdered:o(st,p),listUnordered:o(st),paragraph:o($),reference:N,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Se),strong:o(se),thematicBreak:o(we)},exit:{atxHeading:u(),atxHeadingSequence:L,autolink:u(),autolinkEmail:Ue,autolinkProtocol:We,blockQuote:u(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:Ee,characterReferenceMarkerNumeric:Ee,characterReferenceValue:me,characterReference:le,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:g,codeFencedFenceMeta:x,codeFlowValue:T,codeIndented:u(y),codeText:u(W),codeTextData:T,data:T,definition:u(),definitionDestinationString:V,definitionLabelString:A,definitionTitleString:j,emphasis:u(),hardBreakEscape:u(_),hardBreakTrailing:u(_),htmlFlow:u(ie),htmlFlowData:T,htmlText:u(Y),htmlTextData:T,image:u(D),label:ee,labelText:K,lineEnding:H,link:u(U),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:de,resourceDestinationString:v,resourceTitleString:Ne,resource:ve,setextHeading:u(q),setextHeadingLineSequence:G,setextHeadingText:I,strong:u(),thematicBreak:u()}};Rm(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(z){let X={type:"root",children:[]};const ge={stack:[X],tokenStack:[],config:t,enter:c,exit:d,buffer:a,resume:h,data:n},ye=[];let De=-1;for(;++De<z.length;)if(z[De][1].type==="listOrdered"||z[De][1].type==="listUnordered")if(z[De][0]==="enter")ye.push(De);else{const He=ye.pop();De=i(z,He,De)}for(De=-1;++De<z.length;){const He=t[z[De][0]];Mm.call(He,z[De][1].type)&&He[z[De][1].type].call(Object.assign({sliceSerialize:z[De][2].sliceSerialize},ge),z[De][1])}if(ge.tokenStack.length>0){const He=ge.tokenStack[ge.tokenStack.length-1];(He[1]||th).call(ge,void 0,He[0])}for(X.position={start:Ir(z.length>0?z[0][1].start:{line:1,column:1,offset:0}),end:Ir(z.length>0?z[z.length-2][1].end:{line:1,column:1,offset:0})},De=-1;++De<t.transforms.length;)X=t.transforms[De](X)||X;return X}function i(z,X,ge){let ye=X-1,De=-1,He=!1,yt,lt,Ve,tt;for(;++ye<=ge;){const Je=z[ye];switch(Je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Je[0]==="enter"?De++:De--,tt=void 0;break}case"lineEndingBlank":{Je[0]==="enter"&&(yt&&!tt&&!De&&!Ve&&(Ve=ye),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!De&&Je[0]==="enter"&&Je[1].type==="listItemPrefix"||De===-1&&Je[0]==="exit"&&(Je[1].type==="listUnordered"||Je[1].type==="listOrdered")){if(yt){let nt=ye;for(lt=void 0;nt--;){const pt=z[nt];if(pt[1].type==="lineEnding"||pt[1].type==="lineEndingBlank"){if(pt[0]==="exit")continue;lt&&(z[lt][1].type="lineEndingBlank",He=!0),pt[1].type="lineEnding",lt=nt}else if(!(pt[1].type==="linePrefix"||pt[1].type==="blockQuotePrefix"||pt[1].type==="blockQuotePrefixWhitespace"||pt[1].type==="blockQuoteMarker"||pt[1].type==="listItemIndent"))break}Ve&&(!lt||Ve<lt)&&(yt._spread=!0),yt.end=Object.assign({},lt?z[lt][1].start:Je[1].end),z.splice(lt||ye,0,["exit",yt,Je[2]]),ye++,ge++}if(Je[1].type==="listItemPrefix"){const nt={type:"listItem",_spread:!1,start:Object.assign({},Je[1].start),end:void 0};yt=nt,z.splice(ye,0,["enter",nt,Je[2]]),ye++,ge++,Ve=void 0,tt=!0}}}return z[X][1]._spread=He,ge}function o(z,X){return ge;function ge(ye){c.call(this,z(ye),ye),X&&X.call(this,ye)}}function a(){this.stack.push({type:"fragment",children:[]})}function c(z,X,ge){this.stack[this.stack.length-1].children.push(z),this.stack.push(z),this.tokenStack.push([X,ge||void 0]),z.position={start:Ir(X.start),end:void 0}}function u(z){return X;function X(ge){z&&z.call(this,ge),d.call(this,ge)}}function d(z,X){const ge=this.stack.pop(),ye=this.tokenStack.pop();if(ye)ye[0].type!==z.type&&(X?X.call(this,z,ye[0]):(ye[1]||th).call(this,z,ye[0]));else throw new Error("Cannot close `"+z.type+"` ("+Gi({start:z.start,end:z.end})+"): it’s not open");ge.position.end=Ir(z.end)}function h(){return Nu(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(z){if(this.data.expectingFirstListItemValue){const X=this.stack[this.stack.length-2];X.start=Number.parseInt(this.sliceSerialize(z),10),this.data.expectingFirstListItemValue=void 0}}function g(){const z=this.resume(),X=this.stack[this.stack.length-1];X.lang=z}function x(){const z=this.resume(),X=this.stack[this.stack.length-1];X.meta=z}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const z=this.resume(),X=this.stack[this.stack.length-1];X.value=z.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const z=this.resume(),X=this.stack[this.stack.length-1];X.value=z.replace(/(\r?\n|\r)$/g,"")}function A(z){const X=this.resume(),ge=this.stack[this.stack.length-1];ge.label=X,ge.identifier=On(this.sliceSerialize(z)).toLowerCase()}function j(){const z=this.resume(),X=this.stack[this.stack.length-1];X.title=z}function V(){const z=this.resume(),X=this.stack[this.stack.length-1];X.url=z}function L(z){const X=this.stack[this.stack.length-1];if(!X.depth){const ge=this.sliceSerialize(z).length;X.depth=ge}}function I(){this.data.setextHeadingSlurpLineEnding=!0}function G(z){const X=this.stack[this.stack.length-1];X.depth=this.sliceSerialize(z).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function P(z){const ge=this.stack[this.stack.length-1].children;let ye=ge[ge.length-1];(!ye||ye.type!=="text")&&(ye=ue(),ye.position={start:Ir(z.start),end:void 0},ge.push(ye)),this.stack.push(ye)}function T(z){const X=this.stack.pop();X.value+=this.sliceSerialize(z),X.position.end=Ir(z.end)}function H(z){const X=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=X.children[X.children.length-1];ge.position.end=Ir(z.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(X.type)&&(P.call(this,z),T.call(this,z))}function _(){this.data.atHardBreak=!0}function ie(){const z=this.resume(),X=this.stack[this.stack.length-1];X.value=z}function Y(){const z=this.resume(),X=this.stack[this.stack.length-1];X.value=z}function W(){const z=this.resume(),X=this.stack[this.stack.length-1];X.value=z}function U(){const z=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";z.type+="Reference",z.referenceType=X,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 X=this.data.referenceType||"shortcut";z.type+="Reference",z.referenceType=X,delete z.url,delete z.title}else delete z.identifier,delete z.label;this.data.referenceType=void 0}function K(z){const X=this.sliceSerialize(z),ge=this.stack[this.stack.length-2];ge.label=uC(X),ge.identifier=On(X).toLowerCase()}function ee(){const z=this.stack[this.stack.length-1],X=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const ye=z.children;ge.children=ye}else ge.alt=X}function v(){const z=this.resume(),X=this.stack[this.stack.length-1];X.url=z}function Ne(){const z=this.resume(),X=this.stack[this.stack.length-1];X.title=z}function ve(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function de(z){const X=this.resume(),ge=this.stack[this.stack.length-1];ge.label=X,ge.identifier=On(this.sliceSerialize(z)).toLowerCase(),this.data.referenceType="full"}function Ee(z){this.data.characterReferenceType=z.type}function me(z){const X=this.sliceSerialize(z),ge=this.data.characterReferenceType;let ye;ge?(ye=ym(X,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ye=ju(X);const De=this.stack[this.stack.length-1];De.value+=ye}function le(z){const X=this.stack.pop();X.position.end=Ir(z.end)}function We(z){T.call(this,z);const X=this.stack[this.stack.length-1];X.url=this.sliceSerialize(z)}function Ue(z){T.call(this,z);const X=this.stack[this.stack.length-1];X.url="mailto:"+this.sliceSerialize(z)}function Fe(){return{type:"blockquote",children:[]}}function rt(){return{type:"code",lang:null,meta:null,value:""}}function F(){return{type:"inlineCode",value:""}}function ne(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function re(){return{type:"emphasis",children:[]}}function Se(){return{type:"heading",depth:0,children:[]}}function ke(){return{type:"break"}}function pe(){return{type:"html",value:""}}function xt(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function st(z){return{type:"list",ordered:z.type==="listOrdered",start:null,spread:z._spread,children:[]}}function E(z){return{type:"listItem",spread:z._spread,checked:null,children:[]}}function $(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ue(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function Ir(e){return{line:e.line,column:e.column,offset:e.offset}}function Rm(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Rm(e,r):fC(e,r)}}function fC(e,t){let n;for(n in t)if(Mm.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 th(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Gi({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Gi({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Gi({start:t.start,end:t.end})+") is still open")}function mC(e){const t=this;t.parser=n;function n(r){return hC(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gC(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 bC(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
8
+ `}]}function kC(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 xC(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yC(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wC(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=di(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 vC(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 SC(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Am(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 CC(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Am(e,t);const i={src:di(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 NC(e,t){const n={src:di(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 jC(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 TC(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Am(e,t);const i={href:di(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 IC(e,t){const n={href:di(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 EC(e,t,n){const r=e.all(t),i=n?MC(n):Pm(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 MC(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=Pm(n[r])}return t}function Pm(e){const t=e.spread;return t??e.children.length>1}function RC(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 AC(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PC(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function LC(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DC(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=wu(t.children[1]),u=hm(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 _C(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 BC(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const nh=9,rh=32;function OC(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(sh(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(sh(t.slice(i),i>0,!1)),o.join("")}function sh(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===nh||o===rh;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===nh||o===rh;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function WC(e,t){const n={type:"text",value:OC(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function FC(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const $C={blockquote:gC,break:bC,code:kC,delete:xC,emphasis:yC,footnoteReference:wC,heading:vC,html:SC,imageReference:CC,image:NC,inlineCode:jC,linkReference:TC,link:IC,listItem:EC,list:RC,paragraph:AC,root:PC,strong:LC,table:DC,tableCell:BC,tableRow:_C,text:WC,thematicBreak:FC,toml:zo,yaml:zo,definition:zo,footnoteDefinition:zo};function zo(){}const Lm=-1,Ga=0,Ki=1,ja=2,Iu=3,Eu=4,Mu=5,Ru=6,Dm=7,_m=8,ih=typeof self=="object"?self:globalThis,zC=(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 Ga:case Lm:return n(a,i);case Ki:{const c=n([],i);for(const u of a)c.push(r(u));return c}case ja:{const c=n({},i);for(const[u,d]of a)c[r(u)]=r(d);return c}case Iu:return n(new Date(a),i);case Eu:{const{source:c,flags:u}=a;return n(new RegExp(c,u),i)}case Mu:{const c=n(new Map,i);for(const[u,d]of a)c.set(r(u),r(d));return c}case Ru:{const c=n(new Set,i);for(const u of a)c.add(r(u));return c}case Dm:{const{name:c,message:u}=a;return n(new ih[c](u),i)}case _m: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 ih[o](a),i)};return r},oh=e=>zC(new Map,e)(0),_s="",{toString:HC}={},{keys:UC}=Object,Di=e=>{const t=typeof e;if(t!=="object"||!e)return[Ga,t];const n=HC.call(e).slice(8,-1);switch(n){case"Array":return[Ki,_s];case"Object":return[ja,_s];case"Date":return[Iu,_s];case"RegExp":return[Eu,_s];case"Map":return[Mu,_s];case"Set":return[Ru,_s];case"DataView":return[Ki,n]}return n.includes("Array")?[Ki,n]:n.includes("Error")?[Dm,n]:[ja,n]},Ho=([e,t])=>e===Ga&&(t==="function"||t==="symbol"),qC=(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]=Di(a);switch(c){case Ga:{let h=a;switch(u){case"bigint":c=_m,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);h=null;break;case"undefined":return i([Lm],a)}return i([c,h],a)}case Ki:{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 ja:{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 UC(a))(e||!Ho(Di(a[m])))&&h.push([o(m),o(a[m])]);return p}case Iu:return i([c,a.toISOString()],a);case Eu:{const{source:h,flags:p}=a;return i([c,{source:h,flags:p}],a)}case Mu:{const h=[],p=i([c,h],a);for(const[m,g]of a)(e||!(Ho(Di(m))||Ho(Di(g))))&&h.push([o(m),o(g)]);return p}case Ru:{const h=[],p=i([c,h],a);for(const m of a)(e||!Ho(Di(m)))&&h.push(o(m));return p}}const{message:d}=a;return i([c,{name:u,message:d}],a)};return o},ah=(e,{json:t,lossy:n}={})=>{const r=[];return qC(!(t||n),!!t,new Map,r)(e),r},Ta=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?oh(ah(e,t)):structuredClone(e):(e,t)=>oh(ah(e,t));function GC(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 VC(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function KC(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||GC,r=e.options.footnoteBackLabel||VC,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=di(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:{...Ta(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 Va=(function(e){if(e==null)return QC;if(typeof e=="function")return Ka(e);if(typeof e=="object")return Array.isArray(e)?YC(e):XC(e);if(typeof e=="string")return JC(e);throw new Error("Expected function, string, or object as test")});function YC(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Va(e[n]);return Ka(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function XC(e){const t=e;return Ka(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function JC(e){return Ka(t);function t(n){return n&&n.type===e}}function Ka(e){return t;function t(n,r,i){return!!(ZC(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function QC(){return!0}function ZC(e){return e!==null&&typeof e=="object"&&"type"in e}const Bm=[],e1=!0,jc=!1,t1="skip";function Om(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=Va(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=Bm,x,S,C;if((!t||o(u,d,h[h.length-1]||void 0))&&(g=n1(n(u,h)),g[0]===jc))return g;if("children"in u&&u.children){const y=u;if(y.children&&g[0]!==t1)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]===jc)return x;S=typeof x[1]=="number"?x[1]:S+a}}return g}}}function n1(e){return Array.isArray(e)?e:typeof e=="number"?[e1,e]:e==null?Bm:[e]}function Au(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),Om(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 Tc={}.hasOwnProperty,r1={};function s1(e,t){const n=t||r1,r=new Map,i=new Map,o=new Map,a={...$C,...n.handlers},c={all:d,applyData:o1,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:u,options:n,patch:i1,wrap:l1};return Au(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(Tc.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=Ta(C);return y.children=c.all(h),y}return Ta(h)}return(c.options.unknownHandler||a1)(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=lh(x.value)),!Array.isArray(x)&&x.type==="element")){const S=x.children[0];S&&S.type==="text"&&(S.value=lh(S.value))}Array.isArray(x)?p.push(...x):p.push(x)}}}return p}}function i1(e,t){e.position&&(t.position=Vw(e))}function o1(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,Ta(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function a1(e,t){const n=t.data||{},r="value"in t&&!(Tc.call(n,"hProperties")||Tc.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 l1(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 lh(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ch(e,t){const n=s1(e,t),r=n.one(e,void 0),i=KC(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 c1(e,t){return e&&"run"in e?async function(n,r){const i=ch(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ch(n,{file:r,...e||t})}}function uh(e){if(e)throw e}var Al,dh;function u1(){if(dh)return Al;dh=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 Al=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},Al}var d1=u1();const Pl=lf(d1);function Ic(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 h1(){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?p1(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 p1(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 Zn={basename:f1,dirname:m1,extname:g1,join:b1,sep:"/"};function f1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');po(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 m1(e){if(po(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 g1(e){po(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 b1(...e){let t=-1,n;for(;++t<e.length;)po(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":k1(n)}function k1(e){po(e);const t=e.codePointAt(0)===47;let n=x1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function x1(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 po(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const y1={cwd:w1};function w1(){return"/"}function Ec(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function v1(e){if(typeof e=="string")e=new URL(e);else if(!Ec(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 S1(e)}function S1(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 Ll=["history","path","basename","stem","extname","dirname"];class Wm{constructor(t){let n;t?Ec(t)?n={path:t}:typeof t=="string"||C1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":y1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ll.length;){const o=Ll[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)Ll.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Zn.basename(this.path):void 0}set basename(t){_l(t,"basename"),Dl(t,"basename"),this.path=Zn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Zn.dirname(this.path):void 0}set dirname(t){hh(this.basename,"dirname"),this.path=Zn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Zn.extname(this.path):void 0}set extname(t){if(Dl(t,"extname"),hh(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=Zn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ec(t)&&(t=v1(t)),_l(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Zn.basename(this.path,this.extname):void 0}set stem(t){_l(t,"stem"),Dl(t,"stem"),this.path=Zn.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 Kt(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 Dl(e,t){if(e&&e.includes(Zn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Zn.sep+"`")}function _l(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function hh(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function C1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const N1=(function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),j1={}.hasOwnProperty;class Pu extends N1{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=h1()}copy(){const t=new Pu;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Pl(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Wl("data",this.frozen),this.namespace[t]=n,this):j1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Wl("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=Uo(t),r=this.parser||this.Parser;return Bl("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Bl("process",this.parser||this.Parser),Ol("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,a){const c=Uo(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);E1(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(),Bl("processSync",this.parser||this.Parser),Ol("processSync",this.compiler||this.Compiler),this.process(t,i),fh("processSync","process",n),r;function i(o,a){n=!0,uh(o),r=a}}run(t,n,r){ph(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=Uo(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),fh("runSync","run",r),i;function o(a,c){uh(a),i=c,r=!0}}stringify(t,n){this.freeze();const r=Uo(n),i=this.compiler||this.Compiler;return Ol("stringify",i),ph(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Wl("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=Pl(!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];Ic(S)&&Ic(g)&&(g=Pl(!0,S,g)),r[m]=[d,g,...x]}}}}const T1=new Pu().freeze();function Bl(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ol(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Wl(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 ph(e){if(!Ic(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function fh(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Uo(e){return I1(e)?e:new Wm(e)}function I1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function E1(e){return typeof e=="string"||M1(e)}function M1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const R1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",mh=[],gh={allowDangerousHtml:!0},A1=/^(https?|ircs?|mailto|xmpp)$/i,P1=[{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 L1(e){const t=D1(e),n=_1(e);return B1(t.runSync(t.parse(n),n),e)}function D1(e){const t=e.rehypePlugins||mh,n=e.remarkPlugins||mh,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gh}:gh;return T1().use(mC).use(n).use(c1,r).use(t)}function _1(e){const t=e.children||"",n=new Wm;return typeof t=="string"&&(n.value=t),n}function B1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,u=t.urlTransform||O1;for(const h of P1)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+R1+h.id,void 0);return Au(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 El)if(Object.hasOwn(El,g)&&Object.hasOwn(h.properties,g)){const x=h.properties[g],S=El[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 O1(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||A1.test(e.slice(0,t))?e:""}function bh(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 W1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function F1(e,t,n){const i=Va((n||{}).ignore||[]),o=$1(t);let a=-1;for(;++a<o.length;)Om(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 j=m.exec(d.value);for(;j;){const V=j.index,L={index:j.index,input:j.input,stack:[...h,d]};let I=g(...j,L);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?m.lastIndex=V+1:(x!==V&&A.push({type:"text",value:d.value.slice(x,V)}),Array.isArray(I)?A.push(...I):I&&A.push(I),x=V+j[0].length,y=!0),!m.global)break;j=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 $1(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([z1(i[0]),H1(i[1])])}return t}function z1(e){return typeof e=="string"?new RegExp(W1(e),"g"):e}function H1(e){return typeof e=="function"?e:function(){return e}}const Fl="phrasing",$l=["autolink","link","image","label"];function U1(){return{transforms:[J1],enter:{literalAutolink:G1,literalAutolinkEmail:zl,literalAutolinkHttp:zl,literalAutolinkWww:zl},exit:{literalAutolink:X1,literalAutolinkEmail:Y1,literalAutolinkHttp:V1,literalAutolinkWww:K1}}}function q1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Fl,notInConstruct:$l},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Fl,notInConstruct:$l},{character:":",before:"[ps]",after:"\\/",inConstruct:Fl,notInConstruct:$l}]}}function G1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function zl(e){this.config.enter.autolinkProtocol.call(this,e)}function V1(e){this.config.exit.autolinkProtocol.call(this,e)}function K1(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 Y1(e){this.config.exit.autolinkEmail.call(this,e)}function X1(e){this.exit(e)}function J1(e){F1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Q1],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Z1]],{ignore:["link","linkReference"]})}function Q1(e,t,n,r,i){let o="";if(!Fm(i)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!e0(n)))return!1;const a=t0(n+r);if(!a[0])return!1;const c={type:"link",title:null,url:o+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[c,{type:"text",value:a[1]}]:c}function Z1(e,t,n,r){return!Fm(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function e0(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 t0(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=bh(e,"(");let o=bh(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 Fm(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||us(n)||Ua(n))&&(!t||n!==47)}$m.peek=u0;function n0(){this.buffer()}function r0(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function s0(){this.buffer()}function i0(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function o0(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=On(this.sliceSerialize(e)).toLowerCase(),n.label=t}function a0(e){this.exit(e)}function l0(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=On(this.sliceSerialize(e)).toLowerCase(),n.label=t}function c0(e){this.exit(e)}function u0(){return"["}function $m(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 d0(){return{enter:{gfmFootnoteCallString:n0,gfmFootnoteCall:r0,gfmFootnoteDefinitionLabelString:s0,gfmFootnoteDefinition:i0},exit:{gfmFootnoteCallString:o0,gfmFootnoteCall:a0,gfmFootnoteDefinitionLabelString:l0,gfmFootnoteDefinition:c0}}}function h0(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:$m},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?zm:p0))),d(),u}}function p0(e,t,n){return t===0?e:zm(e,t,n)}function zm(e,t,n){return(n?"":" ")+e}const f0=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Hm.peek=x0;function m0(){return{canContainEols:["delete"],enter:{strikethrough:b0},exit:{strikethrough:k0}}}function g0(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:f0}],handlers:{delete:Hm}}}function b0(e){this.enter({type:"delete",children:[]},e)}function k0(e){this.exit(e)}function Hm(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 x0(){return"~"}function y0(e){return e.length}function w0(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||y0,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=v0(e[h][y]);if(n.alignDelimiters!==!1){const j=i(A);C[y]=j,(u[y]===void 0||j>u[y])&&(u[y]=j)}S.push(A)}a[h]=S,c[h]=C}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)o[p]=kh(r[p]);else{const S=kh(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 j=C+"-".repeat(A)+y;n.alignDelimiters!==!1&&(A=C.length+A+y.length,A>u[p]&&(u[p]=A),g[p]=A),m[p]=j}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 j="",V="";if(n.alignDelimiters!==!1){const L=u[p]-(C[p]||0),I=o[p];I===114?j=" ".repeat(L):I===99?L%2?(j=" ".repeat(L/2+.5),V=" ".repeat(L/2-.5)):(j=" ".repeat(L/2),V=j):V=" ".repeat(L)}n.delimiterStart!==!1&&!p&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||p)&&y.push(" "),n.alignDelimiters!==!1&&y.push(j),y.push(A),n.alignDelimiters!==!1&&y.push(V),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 v0(e){return e==null?"":String(e)}function kh(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 S0(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()),C0);return i(),a}function C0(e,t,n){return">"+(n?"":" ")+e}function N0(e,t){return xh(e,t.inConstruct,!0)&&!xh(e,t.notInConstruct,!1)}function xh(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function yh(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
20
+ `&&N0(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
21
+ `}function j0(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 T0(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 I0(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 E0(e,t,n,r){const i=I0(n),o=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(T0(e,n)){const p=n.enter("codeIndented"),m=n.indentLines(o,M0);return p(),m}const c=n.createTracker(r),u=i.repeat(Math.max(j0(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 M0(e,t,n){return(n?"":" ")+e}function Lu(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 R0(e,t,n,r){const i=Lu(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 A0(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 eo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ia(e,t,n){const r=oi(e),i=oi(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}}Um.peek=P0;function Um(e,t,n,r){const i=A0(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=Ia(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=eo(d)+u.slice(1));const p=u.charCodeAt(u.length-1),m=Ia(r.after.charCodeAt(0),p,i);m.inside&&(u=u.slice(0,-1)+eo(p));const g=a.move(i);return o(),n.attentionEncodeSurroundingInfo={after:m.outside,before:h.outside},c+u+g}function P0(e,t,n){return n.options.emphasis||"*"}function L0(e,t){let n=!1;return Au(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,jc}),!!((!e.depth||e.depth<3)&&Nu(e)&&(t.options.setext||n))}function D0(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(L0(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=eo(d.charCodeAt(0))+d.slice(1)),d=d?a+" "+d:a,n.options.closeAtx&&(d+=" "+a),u(),c(),d}qm.peek=_0;function qm(e){return e.value||""}function _0(){return"<"}Gm.peek=B0;function Gm(e,t,n,r){const i=Lu(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 B0(){return"!"}Vm.peek=O0;function Vm(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 O0(){return"!"}Km.peek=W0;function Km(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 W0(){return"`"}function Ym(e,t){const n=Nu(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))}Xm.peek=F0;function Xm(e,t,n,r){const i=Lu(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let c,u;if(Ym(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 F0(e,t,n){return Ym(e,n)?"<":"["}Jm.peek=$0;function Jm(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 $0(){return"["}function Du(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 z0(e){const t=Du(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 H0(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 Qm(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 U0(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?H0(n):Du(n);const c=e.ordered?a==="."?")":".":z0(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),Qm(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 q0(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 G0(e,t,n,r){const i=q0(n);let o=n.bulletCurrent||Du(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 V0(e,t,n,r){const i=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),i(),a}const K0=Va(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Y0(e,t,n,r){return(e.children.some(function(a){return K0(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function X0(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Zm.peek=J0;function Zm(e,t,n,r){const i=X0(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=Ia(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=eo(d)+u.slice(1));const p=u.charCodeAt(u.length-1),m=Ia(r.after.charCodeAt(0),p,i);m.inside&&(u=u.slice(0,-1)+eo(p));const g=a.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:m.outside,before:h.outside},c+u+g}function J0(e,t,n){return n.options.strong||"*"}function Q0(e,t,n,r){return n.safe(e.value,r)}function Z0(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 eN(e,t,n){const r=(Qm(n)+(n.options.ruleSpaces?" ":"")).repeat(Z0(n));return n.options.ruleSpaces?r.slice(0,-1):r}const eg={blockquote:S0,break:yh,code:E0,definition:R0,emphasis:Um,hardBreak:yh,heading:D0,html:qm,image:Gm,imageReference:Vm,inlineCode:Km,link:Xm,linkReference:Jm,list:U0,listItem:G0,paragraph:V0,root:Y0,strong:Zm,text:Q0,thematicBreak:eN};function tN(){return{enter:{table:nN,tableData:wh,tableHeader:wh,tableRow:sN},exit:{codeText:iN,table:rN,tableData:Hl,tableHeader:Hl,tableRow:Hl}}}function nN(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 rN(e){this.exit(e),this.data.inTable=void 0}function sN(e){this.enter({type:"tableRow",children:[]},e)}function Hl(e){this.exit(e)}function wh(e){this.enter({type:"tableCell",children:[]},e)}function iN(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,oN));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function oN(e,t){return t==="|"?t:e}function aN(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"),j=S.containerPhrasing(g,{...C,before:o,after:o});return A(),y(),j}function d(g,x){return w0(g,{align:x,alignDelimiters:r,padding:n,stringLength:i})}function h(g,x,S){const C=g.children;let y=-1;const A=[],j=x.enter("table");for(;++y<C.length;)A[y]=p(C[y],x,S);return j(),A}function p(g,x,S){const C=g.children;let y=-1;const A=[],j=x.enter("tableRow");for(;++y<C.length;)A[y]=u(C[y],g,x,S);return j(),A}function m(g,x,S){let C=eg.inlineCode(g,x,S);return S.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function lN(){return{exit:{taskListCheckValueChecked:vh,taskListCheckValueUnchecked:vh,paragraph:uN}}}function cN(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dN}}}function vh(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function uN(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 dN(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=eg.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 hN(){return[U1(),d0(),m0(),tN(),lN()]}function pN(e){return{extensions:[q1(),h0(e),g0(),aN(e),cN()]}}const fN={tokenize:yN,partial:!0},tg={tokenize:wN,partial:!0},ng={tokenize:vN,partial:!0},rg={tokenize:SN,partial:!0},mN={tokenize:CN,partial:!0},sg={name:"wwwAutolink",tokenize:kN,previous:og},ig={name:"protocolAutolink",tokenize:xN,previous:ag},dr={name:"emailAutolink",tokenize:bN,previous:lg},sr={};function gN(){return{text:sr}}let ns=48;for(;ns<123;)sr[ns]=dr,ns++,ns===58?ns=65:ns===91&&(ns=97);sr[43]=dr;sr[45]=dr;sr[46]=dr;sr[95]=dr;sr[72]=[dr,ig];sr[104]=[dr,ig];sr[87]=[dr,sg];sr[119]=[dr,sg];function bN(e,t,n){const r=this;let i,o;return a;function a(p){return!Mc(p)||!lg.call(r,r.previous)||_u(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(p))}function c(p){return Mc(p)?(e.consume(p),c):p===64?(e.consume(p),u):n(p)}function u(p){return p===46?e.check(mN,h,d)(p):p===45||p===95||Vt(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&&en(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function kN(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!og.call(r,r.previous)||_u(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(fN,e.attempt(tg,e.attempt(ng,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function xN(e,t,n){const r=this;let i="",o=!1;return a;function a(p){return(p===72||p===104)&&ag.call(r,r.previous)&&!_u(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),c):n(p)}function c(p){if(en(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||Na(p)||dt(p)||us(p)||Ua(p)?n(p):e.attempt(tg,e.attempt(ng,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function yN(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 wN(e,t,n){let r,i,o;return a;function a(d){return d===46||d===95?e.check(rg,u,c)(d):d===null||dt(d)||us(d)||d!==45&&Ua(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 vN(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(rg,t,o)(a):a===null||dt(a)||us(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function SN(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||dt(c)||us(c)?t(c):n(c)}function i(c){return c===null||c===40||c===91||dt(c)||us(c)?t(c):r(c)}function o(c){return en(c)?a(c):n(c)}function a(c){return c===59?(e.consume(c),r):en(c)?(e.consume(c),a):n(c)}}function CN(e,t,n){return r;function r(o){return e.consume(o),i}function i(o){return Vt(o)?n(o):t(o)}}function og(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||dt(e)}function ag(e){return!en(e)}function lg(e){return!(e===47||Mc(e))}function Mc(e){return e===43||e===45||e===46||e===95||Vt(e)}function _u(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 NN={tokenize:PN,partial:!0};function jN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:MN,continuation:{tokenize:RN},exit:AN}},text:{91:{name:"gfmFootnoteCall",tokenize:EN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:TN,resolveTo:IN}}}}function TN(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=On(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 IN(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 EN(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||dt(p))return n(p);if(p===93){e.exit("chunkString");const m=e.exit("gfmFootnoteCallString");return i.includes(On(r.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return dt(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 MN(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||dt(x))return n(x);if(x===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return o=On(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return dt(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),Ye(e,g,"gfmFootnoteDefinitionWhitespace")):n(x)}function g(x){return t(x)}}function RN(e,t,n){return e.check(ho,t,e.attempt(NN,t,n))}function AN(e){e.exit("gfmFootnoteDefinition")}function PN(e,t,n){const r=this;return Ye(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 LN(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&&gn(m,m.length,0,qa(g,a.slice(d+1,u),c)),gn(m,m.length,0,[["exit",p,c],["enter",a[u][1],c],["exit",a[u][1],c],["exit",h,c]]),gn(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=oi(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=oi(x);return C._open=!y||y===2&&!!S,C._close=!S||S===2&&!!y,c(x)}}}class DN{constructor(){this.map=[]}add(t,n,r){_N(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 _N(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 BN(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 ON(){return{flow:{null:{name:"table",tokenize:WN,resolveAll:FN}}}}function WN(e,t,n){const r=this;let i=0,o=0,a;return c;function c(T){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,ie=_==="tableHead"||_==="tableRow"?I:u;return ie===I&&r.parser.lazy[r.now().line]?n(T):ie(T)}function u(T){return e.enter("tableHead"),e.enter("tableRow"),d(T)}function d(T){return T===124||(a=!0,o+=1),h(T)}function h(T){return T===null?n(T):Ie(T)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),g):n(T):ze(T)?Ye(e,h,"whitespace")(T):(o+=1,a&&(a=!1,i+=1),T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),p(T)))}function p(T){return T===null||T===124||dt(T)?(e.exit("data"),h(T)):(e.consume(T),T===92?m:p)}function m(T){return T===92||T===124?(e.consume(T),p):p(T)}function g(T){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(T):(e.enter("tableDelimiterRow"),a=!1,ze(T)?Ye(e,x,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):x(T))}function x(T){return T===45||T===58?C(T):T===124?(a=!0,e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),S):L(T)}function S(T){return ze(T)?Ye(e,C,"whitespace")(T):C(T)}function C(T){return T===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),y):T===45?(o+=1,y(T)):T===null||Ie(T)?V(T):L(T)}function y(T){return T===45?(e.enter("tableDelimiterFiller"),A(T)):L(T)}function A(T){return T===45?(e.consume(T),A):T===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(T))}function j(T){return ze(T)?Ye(e,V,"whitespace")(T):V(T)}function V(T){return T===124?x(T):T===null||Ie(T)?!a||i!==o?L(T):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(T)):L(T)}function L(T){return n(T)}function I(T){return e.enter("tableRow"),G(T)}function G(T){return T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),G):T===null||Ie(T)?(e.exit("tableRow"),t(T)):ze(T)?Ye(e,G,"whitespace")(T):(e.enter("data"),q(T))}function q(T){return T===null||T===124||dt(T)?(e.exit("data"),G(T)):(e.consume(T),T===92?P:q)}function P(T){return T===92||T===124?(e.consume(T),q):q(T)}}function FN(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 DN;for(;++n<e.length;){const g=e[n],x=g[1];g[0]==="enter"?x.type==="tableHead"?(c=!1,u!==0&&(Sh(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=qo(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=qo(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=qo(m,t,o,i,n,p)):a[1]!==0&&(p=qo(m,t,a,i,n,p)),i=0):i&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&Sh(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=BN(t.events,n))}return e}function qo(e,t,n,r,i,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},Gs(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const u=Gs(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=Gs(t.events,n[2]),h=Gs(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({},Gs(t.events,i)),e.add(i,0,[["exit",o,t]]),o=void 0),o}function Sh(e,t,n,r,i){const o=[],a=Gs(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 Gs(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const $N={name:"tasklistCheck",tokenize:HN};function zN(){return{text:{91:$N}}}function HN(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 dt(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 Ie(u)?t(u):ze(u)?e.check({tokenize:UN},t,n)(u):n(u)}}function UN(e,t,n){return Ye(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function qN(e){return xm([gN(),jN(),LN(e),ON(),zN()])}const GN={};function VN(e){const t=this,n=e||GN,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(qN(n)),o.push(hN()),a.push(pN(n))}const KN="X-CodingNS-Assistant-Source",YN="butler-ui",Ul=new Map;async function hr(e,t={},n={}){const r=new Headers(t.headers);r.set(KN,YN);const i=XN();if(Ul.get(i)===!1){if(n.unsupportedFallback!==void 0)return Ch(n.unsupportedFallback);throw Nh()}try{const a=await xe.request(e,{...t,headers:r});return Ul.set(i,!0),a}catch(a){if(!JN(a))throw a;if(Ul.set(i,!1),n.unsupportedFallback!==void 0)return Ch(n.unsupportedFallback);throw Nh()}}function XN(){return Jc()}function Ch(e){return typeof e=="function"?e():e}function JN(e){return e instanceof Zc&&(e.status===404||e.status===405||e.status===501)}function Nh(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function QN(){return xe.request("/api/butler/profile")}function dP(e){return xe.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function hP(e){return xe.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function pP(){return xe.request("/api/butler/control-session")}function fP(){return xe.request("/api/butler/control-sessions")}function mP(e){return xe.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function gP(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 bP(){return xe.request("/api/butler/control-session/reset",{method:"POST"})}function kP(e={}){return xe.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function xP(e){return xe.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function yP(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations?${n}`:"/api/assistant/automations";return hr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function wP(e={}){var i;const t=new URLSearchParams;(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations/runs/recent?${n}`:"/api/assistant/automations/runs/recent";return hr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function vP(e){return hr(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function SP(e,t){return hr(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function CP(e){return hr(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function NP(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim());const n=t.toString(),r=n?`/api/assistant/sandboxes?${n}`:"/api/assistant/sandboxes";return hr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function jP(e){return hr(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function TP(e){return hr(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function IP(e){return hr(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function EP(e){return xe.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function MP(){return xe.request("/api/butler/control-session/events")}function ZN(){return xe.request("/api/butler/overview")}function ej(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 RP(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 cg(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 tj(e){return xe.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function nj(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 AP(e){return xe.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function rj(e){return xe.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function PP(e){return xe.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function LP(e,t){return xe.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function jh(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 DP(e){return xe.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function _P(e){return xe.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function sj(e){return xe.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function ij(){return xe.request("/api/butler/notifications/archives")}function oj(e,t){return xe.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function aj(e){const t=new URLSearchParams;return t.set("sessionId",e),xe.request(`/api/butler/session-target?${t.toString()}`)}function BP(e){const t=new URLSearchParams;return t.set("sessionId",e),xe.request(`/api/butler/session-action-context?${t.toString()}`)}function OP(e){return xe.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}const Ea="*** Begin Patch",Ma="*** End Patch";function Th(e){const t=e.replace(/\r\n/g,`
33
+ `);if(!t.includes(Ea)||!t.includes(Ma))return null;const n=t.split(`
34
+ `),r=[];let i=null,o=null;for(const a of n){if(a===Ea||a===Ma)continue;if(a.startsWith("*** Update File: ")){i=ql("update",a.slice(17)),r.push(i),o=null;continue}if(a.startsWith("*** Add File: ")){i=ql("add",a.slice(14)),r.push(i),o={oldLineNumber:0,newLineNumber:1};continue}if(a.startsWith("*** Delete File: ")){i=ql("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=uj(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 lj(e,t=[]){const n=e.replace(/\r\n/g,`
35
+ `).trim();if(!n)return null;if(n.includes(Ea)&&n.includes(Ma))return n;const r=[...new Set(t.map(i=>i.trim()).filter(i=>i.length>0))];return r.length!==1||!dj(n)?null:[Ea,`*** Update File: ${r[0]}`,n,Ma].join(`
36
+ `)}function cj(e){const t=hj(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 Ih(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function ql(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,statsKnown:!1,lines:[]}}function uj(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function dj(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
39
+ @@`)||e.startsWith("+")||e.startsWith("-")}function hj(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 pj=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,fj=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,mj=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,gj=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,bj=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,Eh=/```question\s*([\s\S]*?)```/i;function ds(e){const t=xj(e),n=kj(t);if(n)return n;const r=yj(t);return r||{...dg(t),structuredQuestions:null}}function kj(e){var r;const t=e.match(Eh);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=ug(i);return o?{text:Bu(e.replace(Eh,"").trim()),inlineImages:[],structuredQuestions:o}:null}catch{return null}}function xj(e){return e.replace(bj,"")}function yj(e){const t=e.trim();if(!vj(t))return null;try{const n=JSON.parse(t),r=ug(n),i=Sj(r?wj(n):n);return i.text||i.inlineImages.length>0||r?{...i,structuredQuestions:r}:null}catch{return null}}function wj(e){const t=fo(e);if(!t||!("questions"in t))return e;const{questions:n,...r}=t;return r}function vj(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function Sj(e){const t=[],n=[];return ga(e,t,n),{text:Bu(t.join(`
40
+
41
+ `)),inlineImages:hg(n),structuredQuestions:null}}function ug(e){const t=fo(e);if(!t)return null;const n=Cj(t.questions);return n.length===0?null:{questions:n}}function Cj(e){return Array.isArray(e)?e.map((t,n)=>Nj(t,n)).filter(t=>t!==null):[]}function Nj(e,t){const n=fo(e);if(!n)return null;const r=er(Wt(n.question));if(!r)return null;const i=jj(n.options);return i.length===0?null:{id:er(Wt(n.id))??`structured-question-${t+1}`,header:er(Wt(n.header))??"问题",question:r,allowOther:!!(n.allowOther??n.isOther),secret:!!(n.secret??n.isSecret),options:i}}function jj(e){return Array.isArray(e)?e.map(t=>{const n=fo(t);if(!n)return null;const r=er(Wt(n.label));return r?{label:r,description:er(Wt(n.description))}:null}).filter(t=>t!==null):[]}function ga(e,t,n){if(typeof e=="string"){const a=dg(e);a.text&&t.push(a.text),n.push(...a.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(a=>ga(a,t,n));return}if(typeof e!="object")return;const r=e,i=new Set,o=Tj(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"||!pg(c)||(n.push(as(c,Wt(r.alt))),i.add(a))}for(const a of["text","message","content","output","result","summary","caption"])a in r&&(i.add(a),ga(r[a],t,n));i.size>0||Object.values(r).forEach(a=>{ga(a,t,n)})}function dg(e){const t=[];let n=e;return n=n.replace(gj,(r,i,o)=>{const a=Rj(i,"name"),c=Mj(o);return c!=null&&c.url&&t.push(as(c.url,c.altText||a)),""}),n=n.replace(fj,(r,i,o)=>(t.push(as(o,i)),"")),n=n.replace(mj,(r,i)=>(t.push(as(i,null)),"")),n=n.replace(pj,(r,i,o)=>(t.push(as(r,null,`image/${i}`,Ra(o))),"")),{text:Bu(n),inlineImages:hg(t),structuredQuestions:null}}function as(e,t,n,r){const i=n??Ij(e)??"image/png";return{url:e,mimeType:i,altText:er(t),estimatedBytes:r??Ej(e)}}function Tj(e){const t=fo(e.source);if(t){const i=Wt(t.type).trim().toLowerCase(),o=Rh(t.media_type??t.mime_type??t.mimeType),a=Mh(t.data);if(i==="base64"&&o&&a)return as(`data:${o};base64,${a}`,er(Wt(t.alt)||Wt(t.name)||Wt(e.alt)||Wt(e.name)),o,Ra(a))}const n=Rh(e.media_type??e.mime_type??e.mimeType),r=Mh(e.data);return n&&r?as(`data:${n};base64,${r}`,er(Wt(e.alt)||Wt(e.name)),n,Ra(r)):null}function hg(e){const t=new Map;return e.forEach(n=>{t.has(n.url)||t.set(n.url,n)}),[...t.values()]}function Bu(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 pg(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function Ij(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 Ej(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?Ra(t[1]):null}function Ra(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 er(e){const t=Wt(e).trim();return t.length>0?t:null}function Mh(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function Rh(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function Wt(e){return typeof e=="string"?e:""}function fo(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Mj(e){const t=e.trim();if(t.length===0)return null;try{const n=JSON.parse(t),r=Wt(n.image_url??n.imageUrl).trim(),i=er(Wt(n.name)||Wt(n.alt));return{url:pg(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 Rj(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return er((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 Aj=new Set(["updateplan"]),fg=new Set(["todowrite"]),Rc=new Set(["todoread"]),mg=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function WP(e,t){const n=Dj(e,t);return n||_j(e,t)}function Pj(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function Lj(e,t,n){if(!e)return null;if(Ac(e.name)){const a=ri(e);if(!a||!Xa(a.value))return null;const c=gg(a.value,n);return!c||c.items.length===0?null:{provider:t,source:"plan",explanation:c.explanation,items:c.items,updatedAt:n}}const r=Ya(e.name);if(!fg.has(r)&&!Rc.has(r)&&!mg.has(r))return null;const i=ri(e,(Rc.has(r),"prefer-output"));if(!i)return null;if(r==="taskdelete"||r==="taskremove"){const a=bg(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=Wi(i.value,n);return o.length===0?null:{provider:t,source:Ac(e.name)?"plan":"todo",explanation:null,items:o,updatedAt:n}}function Dj(e,t){let n=null;for(const r of e){const i=r.toolCall;if(!i||Ya(i.name)===""||!Ac(i.name))continue;const o=ri(i);if(!o||typeof o.value!="object"||o.value===null)continue;const a=gg(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 _j(e,t){const n=new Map;let r=null;for(const o of e){const a=o.toolCall;if(!a)continue;const c=Ya(a.name);if(fg.has(c)){const h=ri(a),p=h?Wi(h.value,o.timestamp):[];p.length>0&&(Gl(n,p),r=o.timestamp);continue}if(Rc.has(c)){const h=ri(a,"prefer-output"),p=h?Wi(h.value,o.timestamp):[];p.length>0&&(Gl(n,p),r=o.timestamp);continue}if(!mg.has(c))continue;const u=ri(a,"prefer-output");if(!u)continue;if(c==="tasklist"||c==="taskget"){const h=Wi(u.value,o.timestamp);h.length>0&&(Gl(n,h),r=o.timestamp);continue}if(c==="taskdelete"||c==="taskremove"){const h=bg(u.value);if(h.length>0){for(const p of h)n.delete(p);r=o.timestamp}continue}const d=Wi(u.value,o.timestamp);if(d.length!==0){for(const h of d)Oj(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 Ac(e){return Aj.has(Ya(e))}function gg(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((i,o)=>kg(i,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${o+1}`,fallbackStatus:"pending",updatedAt:t})).filter(i=>i!==null);return r.length===0?null:{items:r,explanation:Ct(e.explanation)}}function ri(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=Bj(r.text);if(i!==null)return{value:i,source:r.source}}return null}function Bj(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=Go(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const u=Go(r[1].trim());if(u!==null)return u}const i=t.indexOf("{"),o=t.lastIndexOf("}");if(i>=0&&o>i){const u=Go(t.slice(i,o+1));if(u!==null)return u}const a=t.indexOf("["),c=t.lastIndexOf("]");return a>=0&&c>a?Go(t.slice(a,c+1)):null}function Go(e){try{return JSON.parse(e)}catch{return null}}function Wi(e,t){return Yi(e).map((r,i)=>kg(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${i+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function Yi(e){if(Array.isArray(e))return e.flatMap(n=>Yi(n));if(!Xa(e))return[];if(zj(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=Yi(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>Yi(n))}function bg(e){const n=Yi(e).map(i=>Pc(i)).filter(i=>i!==null);if(n.length>0)return n;if(!Xa(e))return[];const r=Pc(e);return r?[r]:[]}function kg(e,t){if(!Xa(e))return null;const n=Ct(e.step)??Ct(e.title)??Ct(e.content)??Ct(e.task)??Ct(e.text)??Ct(e.name)??Ct(e.subject)??Ct(e.description)??t.fallbackTitle,r=Pc(e)??$j(t.fallbackIdPrefix,n),i=Fj(e,n);return{id:r,title:n,status:Wj(e.status,t.fallbackStatus),detail:i,updatedAt:t.updatedAt}}function Oj(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 Gl(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function Wj(e,t){var r;const n=(r=Ct(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 Fj(e,t){const n=[Ct(e.detail),Ct(e.details),Ct(e.description),Ct(e.reason),Ct(e.summary),Ct(e.note),Ct(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function Pc(e){return Ct(e.id)??Ct(e.taskId)??Ct(e.task_id)??Ct(e.uuid)??Ct(e.key)}function $j(e,t){return`${e}:${t.trim().toLowerCase()}`}function zj(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>Ct(t)!==null)}function Ya(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function Xa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ct(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Hj({snapshot:e,toolName:t="",expanded:n=!1,exportMode:r=!1,className:i,children:o,onToggleExpanded:a}){const c=Pj(e.items),u=n?l("conversation.taskCardRawCollapse"):l("conversation.taskCardRawExpand"),d=i?`tool-call-item task-tool-item ${i}`:"tool-call-item task-tool-item";return s.jsxs("div",{className:d,children:[s.jsxs("div",{className:"task-tool-header",children:[s.jsxs("div",{className:"task-tool-heading",children:[s.jsx("span",{className:"task-tool-badge",children:e.source==="plan"?l("conversation.taskCardPlanTitle"):l("conversation.taskCardTodoTitle")}),s.jsxs("div",{className:"task-tool-heading-main",children:[s.jsx("strong",{children:Uj(e,t)}),s.jsx("span",{className:"task-tool-summary-text",children:qj(e.items,c)})]})]}),!r&&a?s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:a,children:u}):null]}),s.jsx("ol",{className:"task-tool-list",children:e.items.map(h=>s.jsxs("li",{className:"task-tool-list-item","data-status":h.status,children:[s.jsx("span",{className:"task-tool-item-indicator","data-status":h.status,"aria-hidden":"true"}),s.jsx("strong",{className:"task-tool-item-title",children:h.title}),h.detail?s.jsx("span",{className:"task-tool-item-detail",children:h.detail}):null,s.jsx("span",{className:"task-tool-item-status",children:Gj(h.status)})]},h.id))}),o]})}function Uj(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 qj(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 Gj(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 Vj(){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 Kj(){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 FP(){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 $P(){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 zP(){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 HP(){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 xg="codingns.user-app.conversation-scroll",Bs=1,Yj=200,Xj=1e7;function yg(){return typeof window<"u"&&typeof window.localStorage<"u"}function wg(e){return e.trim()}function vg(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),Xj)}function Sg(e){return!e||typeof e!="object"?null:{scrollTop:vg(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function Cg(){if(!yg())return{schemaVersion:Bs,bySessionId:{}};const e=window.localStorage.getItem(xg);if(!e)return{schemaVersion:Bs,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==Bs||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:Bs,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,i])=>{const o=Sg(i);return o?[r,o]:null}).filter(r=>!!r));return{schemaVersion:Bs,bySessionId:n}}catch{return{schemaVersion:Bs,bySessionId:{}}}}function Jj(e){if(yg())try{window.localStorage.setItem(xg,JSON.stringify(e))}catch{}}function Vo(e){const t=wg(e);if(!t)return null;const n=Cg().bySessionId[t],r=Sg(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function Ah(e,t){const n=wg(e);if(!n)return;const r=Cg();r.bySessionId[n]={scrollTop:vg(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,Yj);r.bySessionId=Object.fromEntries(i),Jj(r)}const Qj=5e3;let Os=null;function Zj(){var t;if(Os!==null)return Os;if(typeof document>"u")return Os=0,Os;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),Os=Math.max(0,e.offsetWidth-e.clientWidth),e.remove(),Os}function eT(e){if(Zj()>0){e.dataset.scrollbarLayout="stable";return}e.removeAttribute("data-scrollbar-layout")}function Ou(e){const t=f.useRef(null),n=e??t;return f.useEffect(()=>{const r=n.current;if(!r||typeof globalThis.window>"u")return;eT(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},Qj)},u=()=>{c()};return r.addEventListener("scroll",u,{passive:!0}),()=>{r.removeEventListener("scroll",u),a()}},[n]),n}function Wu(e){var t,n;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((n=e.lastErrorDetail)!=null&&n.trim())}function tT(e,t,n){return`${e} is-${Ng(t,n)}`}function Ng(e,t){t==null||t.isActive;const n=sT(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 nT(e){return e.runningState==="stale"?l("conversation.runtimeStale"):e.runningState==="unknown"?l("conversation.runtimeUnknown"):null}function rT(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function UP(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function sT(e){return Wu(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?iT(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function iT(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function oT(e){return Wu(e)||e.syncStatus==="error"}function aT(e){if(!oT(e))return null;const t=cT(e.lastErrorCode),n=uT(e.lastErrorDetail),r=lT(t,n,e.syncStatus);return{title:e.syncStatus==="error"&&!Wu(e)?l("conversation.syncStatusError"):l("conversation.runtimeErrorTitle"),summary:r,code:t,detail:n}}function lT(e,t,n){return e&&t&&!t.includes(e)?`${e} · ${t}`:t||e||(n==="error"?l("conversation.syncStatusError"):l("conversation.runtimeErrorFallbackDetail"))}function cT(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}function uT(e){const t=(e==null?void 0:e.replace(/\s+/g," ").trim())??"";return t.length>0?t:null}function jg(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function dT(e){const t=e.trim();if(!t)return[];const n=/\b(?:last status:\s*\d{3}\s+[A-Za-z][A-Za-z ]*|\d{3}\s+(?:Too Many Requests|Bad Gateway|Gateway Timeout|Service Unavailable|Unauthorized|Forbidden|Not Found|Internal Server Error))\b|\brequest id:\s*[A-Za-z0-9-]+\b/gi,r=[];let i=0;for(const o of t.matchAll(n)){const a=o.index??0,c=o[0];a>i&&r.push({type:"text",text:t.slice(i,a)}),r.push({type:/^request id:/i.test(c)?"request_id":"status_code",text:c}),i=a+c.length}return i<t.length&&r.push({type:"text",text:t.slice(i)}),r.filter(o=>o.text.length>0)}function Tg(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 hT(e){return e==="user"?l("conversation.turnAbortedUser"):e==="runtime"?l("conversation.turnAbortedUnexpected"):l("conversation.turnAbortedGeneric")}const pT=480,Ph=80,Lh=240,fT=120,mT=18,gT=50,bT=3500,Lc=f.createContext(!1);function Aa(e){return e.replace(/\\/g,"/")}function Pa(e){return/^[a-zA-Z]:\//.test(e)}function kT(e){return e.startsWith("/")||e.startsWith("//")||Pa(e)}function xT(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Pa(e)}function Dh(e){return e.replace(/\/+$/,"")}function Ig(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 Eg(e){const t=[];for(const n of Aa(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function Fu(e){try{return decodeURIComponent(e)}catch{return e}}function Mg(e,t){const n=Fu(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(xT(r))return null;if(r=Aa(Ig(r.trim())),!r)return null;const i=Dh(Aa(t.trim()));if(!i)return null;if(kT(r)){const o=Dh(r),a=Pa(i)?i.toLowerCase():i,c=Pa(o)?o.toLowerCase():o;if(c===a)return null;const u=`${a}/`;return c.startsWith(u)?o.slice(i.length+1):null}return Eg(r)}function yT(e){if(e.name.trim()!=="view_image")return null;const t=Ja(e.input);return(t?Ag(t,"path").trim():"")||null}function wT(e){return Aa(e).split("/").filter(Boolean).at(-1)??e}function vT(e,t){const n=yT(e);if(!n)return null;const r=t?Mg(n,t):Eg(Ig(n));return{path:r??n,displayPath:r??n,fileName:wT(n)}}function ST(e,t,n){var r;if(e&&!n&&typeof window<"u"&&((r=window.location)!=null&&r.origin))return new URL(e,window.location.origin).toString();if(e&&n)try{const i=af(Jc()).baseUrl;return ak(e,i)}catch{return t}return t}function La(e){return e.kind==="tool_call"||e.kind==="tool_result"}function Rg(e){return e.toolCall?e.toolCall:La(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 CT(e){return e==="shell_command"||e==="tool"?l("conversation.roleTool"):e}function Ja(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 Ag(e,t){const n=e[t];return typeof n=="string"?n:""}function Ws(e,t){for(const n of t){const r=Ag(e,n);if(r)return r}return""}function to(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Lt(e,t){if(!e)return null;const n=e[t];return to(n)?n:null}function Vl(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function ot(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 NT(e){const t=[e.output,e.input];for(const n of t){const r=Pg(n,0);if(r)return r}return null}function Pg(e,t){if(!(e!=null&&e.trim())||t>2)return null;try{return Lg(JSON.parse(e),t)}catch{return null}}function Lg(e,t){if(!to(e))return null;if(jT(e))return{ok:!0,capability:ot(e,"capability")??"",auditId:ot(e,"auditId")??"",timestamp:ot(e,"timestamp")??"",targetRef:{kind:ot(Lt(e,"targetRef"),"kind")??"none",id:ot(Lt(e,"targetRef"),"id")},payload:Lt(e,"payload")??{}};const n=["output","result","data","payload"];for(const r of n){const i=e[r];if(typeof i=="string"){const o=Pg(i,t+1);if(o)return o}if(to(i)){const o=Lg(i,t+1);if(o)return o}}return null}function jT(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&to(e.targetRef)&&to(e.payload)}function TT(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 IT(e,t){const n=NT(e);return n?{..._g(n.capability),rows:OT(n,t)}:null}function ET(e,t){const n=MT(e);if(!n)return null;const r=RT(n);return r?{...LT(r),rows:BT(r,t)}:null}function MT(e){const t=Ja(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 RT(e){const t=AT(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}=PT(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 AT(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 PT(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 LT(e){if(e.mode==="help")return DT(e.group,e.action);const t=_T(e.group,e.action);return t?_g(t):{kind:$u(e.group),badge:Dg(e.group),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCliSummaryCommand")}}function DT(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:$u(e),badge:Dg(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 _T(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 $u(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 Dg(e){switch($u(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 BT(e,t){const n=[],r=Fs(e,"--session-id")??e.positionals[0]??null,i=Fs(e,"--project")??Fs(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"),ls(r,null,t)),e.group==="timers"&&(Oe(n,l("conversation.assistantCapabilityLabelSession"),ls(r,null,t)),Oe(n,l("conversation.assistantCliLabelDelay"),Fs(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"),Pr(e.positionals[0]??null,null,t)),Oe(n,l("conversation.assistantCliLabelProject"),i),Oe(n,l("conversation.assistantCliLabelMessage"),Fs(e,"--message")),Oe(n,l("conversation.assistantCliLabelInput"),Fs(e,"--input")),n.slice(0,4))}function Fs(e,t){const n=e.options[t];return typeof n=="string"?n:null}function _g(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 OT(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const i=Lt(r,"session");Oe(n,l("conversation.assistantCapabilityLabelSession"),ls(ot(i,"sessionId"),ot(i,"title"),t)),Oe(n,l("conversation.assistantCapabilityLabelProvider"),ot(i,"provider"));break}case"sessions.message.send":{const i=Lt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelSession"),ls(e.targetRef.id,null,t)),Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Bg(e.targetRef.id,t)),Oe(n,l("conversation.assistantCapabilityLabelStatus"),l("conversation.assistantCapabilityStatusCompleted")),Oe(n,l("conversation.assistantCapabilityLabelDueAt"),_h(ot(i,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const i=Lt(r,"session");Oe(n,l("conversation.assistantCapabilityLabelSession"),ls(ot(i,"sessionId"),ot(i,"title"),t)),Oe(n,l("conversation.assistantCapabilityLabelProvider"),ot(i,"provider"));break}case"timers.create":case"timers.cancel":{const i=Lt(r,"timer"),o=Lt(i,"controlSession"),a=Lt(o,"session");Oe(n,l("conversation.assistantCapabilityLabelTimer"),ot(i,"title")),Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(a,"workspaceId"),null,t)),Oe(n,l("conversation.assistantCapabilityLabelSession"),ls(ot(i,"targetSessionId"),null,t)),Oe(n,l("conversation.assistantCapabilityLabelDueAt"),_h(ot(i,"dueAt"))),Oe(n,l("conversation.assistantCapabilityLabelStatus"),$T(ot(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=Lt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelPath"),ot(i,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const i=Lt(r,"workspace");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(i,"id")??e.targetRef.id,ot(i,"name"),t)),Oe(n,l("conversation.assistantCapabilityLabelPath"),ot(i,"path"));break}case"workspaces.navigation-state.update":{const i=Lt(r,"state");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(i,"workspaceId")??e.targetRef.id,null,t)),Oe(n,l("conversation.assistantCapabilityLabelStatus"),ot(i,"collapsed")==="true"?l("conversation.assistantCapabilityNavigationCollapsed"):l("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const i=Lt(r,"result"),o=Lt(i,"workspace");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(o,"id")??e.targetRef.id,ot(o,"name"),t)),Oe(n,l("conversation.assistantCapabilityLabelBranch"),ot(i,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const i=Lt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(e.targetRef.id,null,t)),Oe(n,l("conversation.assistantCapabilityLabelStatus"),ot(i,"status"));break}case"debug-targets.run":{const i=Lt(r,"result");Oe(n,l("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),Oe(n,l("conversation.assistantCapabilityLabelRuntime"),ot(i,"runtimeId"));break}}return WT(n,e,t),n.slice(0,4)}function WT(e,t,n){t.targetRef.kind==="session"&&(Oe(e,l("conversation.assistantCapabilityLabelSession"),ls(t.targetRef.id,null,n)),Oe(e,l("conversation.assistantCapabilityLabelWorkspace"),Bg(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&Oe(e,l("conversation.assistantCapabilityLabelWorkspace"),Pr(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=FT(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 ls(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 Pr(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 Bg(e,t){const n=e==null?void 0:e.trim();return n?Pr(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function FT(e){const t=Vl(e,"items");if(t)return t.length;const n=Lt(e,"page"),r=Vl(n,"items");if(r)return r.length;const i=Lt(e,"history"),o=Vl(i,"items");return o?o.length:null}function _h(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 $T(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 zT({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 HT(e){if(e.name==="apply_patch"){const c=Th(e.input);if(c)return c;const u=cj(e.output||e.error||""),d=lj(e.input,u);return d?Th(d):null}const t=e.name.trim().toLowerCase(),n=UT(t);if(!n)return null;const r=Ja(e.input);if(!r)return null;const i=Ws(r,["file_path","filePath","path"]);if(!i)return null;if(n==="write"){const c=Ws(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=Ws(r,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),u=Ws(r,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/);return Bh(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:Ws(u,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),newLines:Ws(u,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/)}}).filter(c=>!!c);return a.length>0?Bh(i,a):null}function UT(e){return e==="write"||e==="overwrite"?"write":e==="edit"?"edit":e==="multiedit"||e==="multi_edit"?"multiedit":null}function Bh(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 qT(e){const t=Ja(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 GT(e){var o;const t=e.map(a=>({message:a,tool:Rg(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 VT(e){const t=new Map;for(const n of e){const r=Rg(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=>GT(n.messages)).filter(n=>!!n)}function Og(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n];if(KT(e,n))continue;if(!La(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(!La(c))break;i.push(c),o+=1}const a=VT(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 KT(e,t){const n=e[t];if(!n||Tg(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const i=e[r];if(!(!i||La(i)))return i.role==="user"}return!1}function YT(e,t){if(!kk(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 XT(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 JT(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 Wg(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 no(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>no(n)).join(""):e&&typeof e=="object"&&"props"in e?no(((t=e.props)==null?void 0:t.children)??""):""}function QT(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:no(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(i==null?void 0:i[1])??null}}function ZT(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 zu(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(!ZT(e))throw new Error(l("conversation.copyContentFailed"))}}function eI({className:e,children:t,onCopy:n,exportMode:r=!1}){const i=f.useContext(Lc),o=no(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 tI({href:e,children:t,className:n,onInteract:r,exportMode:i=!1}){if(i)return s.jsx(Lc.Provider,{value:!0,children:s.jsx("a",{href:e,className:n,children:t})});const o=no(t).trim()||(e?Fu(e).trim():"");return s.jsx(Lc.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 Fg({language:e,codeClassName:t,content:n,exportMode:r=!1}){const{showToast:i}=Wn(),o=bn(),a=(e==null?void 0:e.trim().toLowerCase())??null,c=a==="text",u=a||"code";async function d(){try{await zu(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 Fi({content:e,className:t,exportMode:n=!1}){const{showToast:r}=Wn(),i=bn(),{navigationGroups:o,currentWorkspaceId:a,revealWorkspaceFile:c}=Gb(),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 zu(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)?Mg(p,u.path):null;g&&c({workspaceId:(u==null?void 0:u.id)??a,filePath:g,openViewer:!1})||d(m||(p?Fu(p).trim():""))}return s.jsx("div",{className:t,children:s.jsx(L1,{remarkPlugins:[VN],components:{p:({node:p,...m})=>s.jsx("p",{...m}),a(p){return s.jsx(tI,{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=QT(p.children);return m?s.jsx(Fg,{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(eI,{className:m||void 0,exportMode:n,onCopy:g=>{d(g)},children:p.children})}},children:e})})}function Oh(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function nI(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 Ko({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return s.jsx(rI,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function rI({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=Oh(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)=>!Oh(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 xk(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=nI(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(iu,{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 sI(){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 iI({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:Kl(a.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:Yo(a),children:Ih(a.nextPath??a.path)}),Xl(a)]},Yl(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:Kl(a.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:Yo(a),children:Ih(a.nextPath??a.path)}),Xl(a)]},Yl(a,c)))}),s.jsx(iu,{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:lI(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:Kl(o.action)}),s.jsx("strong",{children:Yo(o)})]}),Xl(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 ${cI(a.kind)}`,children:[s.jsx("span",{className:"apply-patch-line-number",children:Fh(a.oldLineNumber)}),s.jsx("span",{className:"apply-patch-line-number",children:Fh(a.newLineNumber)}),s.jsx("span",{className:"apply-patch-line-content",children:a.text||" "})]},`${Yo(o)}:${c}`))})})]},Yl(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 oI({tool:e,snapshot:t,workspaceId:n,exportMode:r=!1}){const i=bn(),[o,a]=f.useState({status:"idle",url:null});return f.useEffect(()=>{if(r||!n||!t.path){a({status:"idle",url:null});return}let c=!1;return a({status:"loading",url:null}),lx(n,t.path).then(u=>{if(c)return;const d=ST(u.previewPath,u.previewUrl,i.isDesktop);a(d?{status:"ready",url:d}:{status:"error",url:null})}).catch(()=>{c||a({status:"error",url:null})}),()=>{c=!0}},[r,i.isDesktop,t.path,n]),s.jsxs("div",{className:`tool-call-item view-image-tool-item ${e.status==="completed"?"tool-result":""}`,children:[s.jsx("div",{className:"tool-call-header view-image-tool-header",children:s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:l("conversation.toolViewImageActiveLabel")}),s.jsx("span",{className:"tool-call-input-preview",children:t.displayPath})]})}),r?null:s.jsx("div",{className:"view-image-tool-preview",children:o.status==="ready"?s.jsx("img",{src:o.url,alt:t.fileName||l("conversation.attachmentPreviewAlt")}):s.jsx("div",{className:"view-image-tool-placeholder",children:o.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")})})]})}function $g({group:e,workspaceId:t,workspacePath:n,exportMode:r=!1}){const[i,o]=f.useState(!1),{navigationGroups:a}=Gb(),{tool:c,hasRequest:u,hasResult:d}=e,h=CT(c.name),p=f.useMemo(()=>vT(c,n),[c,n]),m=f.useMemo(()=>TT(a),[a]),g=f.useMemo(()=>IT(c,m),[m,c]),x=f.useMemo(()=>ET(c,m),[m,c]),S=f.useMemo(()=>Lj(c,null,e.updatedAt),[e.updatedAt,c]),C=f.useMemo(()=>HT(c),[c.input,c.name]);if(p)return s.jsx(oI,{tool:c,snapshot:p,workspaceId:t,exportMode:r});if(C)return s.jsx(iI,{tool:c,preview:C,exportMode:r});if(g)return s.jsx(Wh,{tool:c,snapshot:g,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(L=>!L)}});if(x)return s.jsx(Wh,{tool:c,snapshot:x,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(L=>!L)}});if(S)return s.jsx(aI,{tool:c,snapshot:S,expanded:i,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(L=>!L)}});const y=qT(c),A=!!(c.input||c.output||c.error),j=A&&!r,V=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:h}),s.jsx("span",{className:"tool-call-input-preview",children:y})]}),s.jsx("div",{className:"tool-call-meta",children:j&&s.jsx("span",{className:`tool-call-toggle ${i?"expanded":""}`,children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]});return s.jsxs("div",{className:`tool-call-item ${d?"tool-result":""}`,children:[r?s.jsx("div",{className:"tool-call-header",children:V}):s.jsx("button",{type:"button",className:"tool-call-header",onClick:()=>A&&o(L=>!L),children:V}),i&&A&&s.jsxs("div",{className:"tool-call-output",children:[u&&c.input&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:c.input})]}),(d||c.error||c.output)&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:c.error?"tool-call-error":void 0,children:c.error||c.output||l("conversation.toolResultEmpty")})]})]})]})}function Wh({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(zT,{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 aI({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:i,onToggleExpanded:o,exportMode:a=!1}){return s.jsx(Hj,{snapshot:t,toolName:e.name,expanded:n,exportMode:a,onToggleExpanded:a?void 0:o,children:!a&&n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,i||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null})}function Kl(e){return e==="add"?l("conversation.applyPatchAddedLabel"):e==="delete"?l("conversation.applyPatchDeletedLabel"):l("conversation.applyPatchEditedLabel")}function Yo(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function Yl(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function Xl(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 lI(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 cI(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function Fh(e){return e===null||e<=0?"":String(e)}function uI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function zg({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:uI(e)}),n]})]})}function os({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:i}){const{showToast:o}=Wn(),a=bn(),[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 zu(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(Vj,{})}):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(Kj,{})}):null]})}function dI({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=JT(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(Fi,{content:e.content,className:"message-text message-content markdown-content",exportMode:c})}),p?s.jsx(zg,{timestamp:e.timestamp,children:s.jsx(os,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(e):null})}):s.jsx(os,{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 Hg({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"?Tg(e.content):null,x=r??(YT(t,e.content)?"rules":XT(t,e.content)?"skill_context":null),S=f.useMemo(()=>ds(e.content),[e.content]),C=S.text,y=S.inlineImages,A=S.structuredQuestions,[j,V]=f.useState(!1),[L,I]=f.useState(!1),[G,q]=f.useState(null),[P,T]=f.useState(null);if(x){const H=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return s.jsx(dI,{message:e,kind:x,tone:H,actionState:i,onRetry:o,onForkMessage:a,forceExpanded:u,exportMode:u})}if(g){const H=hT(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(Jl,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Fi,{content:_,className:"message-text message-content markdown-content",exportMode:u}),s.jsx(os,{text:_,canCopy:i.canCopy,canFork:!1,onFork:null})]})]})}if(h){const H=e.origin==="butler_proxy"||fI(e.clientRequestId),_=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function ie(){if(!_)return;const W=!j;if(V(W),!(!W||P||L)){I(!0),q(null);try{const U=await rj(e.originRef);T(U.task)}catch(U){q(U instanceof Error?U.message:l("conversation.butlerOriginDetailLoadFailed"))}finally{I(!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":j,onClick:()=>{ie()},children:l("conversation.butlerProxyMessageBadge")}),j?s.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[s.jsx("strong",{children:l("conversation.butlerOriginDetailTitle")}),L?s.jsx("p",{children:l("conversation.butlerOriginDetailLoading")}):G?s.jsx("p",{children:G}):P?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:[l("conversation.butlerOriginDetailObjectiveLabel"),":",P.objective]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailStatusLabel"),":",mI(P.status)]}),s.jsxs("p",{children:[l("conversation.butlerOriginDetailSummaryLabel"),":",P.lastAutomationSummary||l("conversation.butlerAnalysisEmpty")]}),P.waitingReason?s.jsxs("p",{children:[l("conversation.butlerOriginDetailWaitingReasonLabel"),":",P.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(Ko,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C?s.jsx(Fi,{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(zg,{timestamp:e.timestamp,leading:Y,children:s.jsx(os,{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(Jl,{})}),s.jsxs("div",{className:"thinking-message-content",children:[s.jsx("div",{className:"thinking-message-label",children:l("conversation.thinkingLabel")}),s.jsx(Ko,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C&&s.jsx(Fi,{content:C,className:"message-text message-content markdown-content thinking-message-text",exportMode:u}),s.jsx(os,{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(Jl,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Ko,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C&&s.jsx(Fi,{content:C,className:"message-text message-content markdown-content",exportMode:u}),A&&d?s.jsx(hI,{messageId:e.id,prompt:A,onSubmit:d}):null,s.jsx(os,{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(Ko,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:y}),C?s.jsx("div",{className:"message-text message-content",children:s.jsx(Fg,{language:"text",content:C,exportMode:u})}):null,s.jsx(os,{text:C,canCopy:i.canCopy,canFork:i.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})})}function hI({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 pI({sessionId:e,workspaceId:t=null,workspacePath:n=null,messages:r,provider:i,interruptedSource:o=null,runtimeThinkingPlaceholder:a=null,assistantAvatar:c}){const u=Og(r),d=f.useMemo(()=>Wg(r,i),[r,i]);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:[u.length===0?s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}):null,u.map(h=>h.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx($g,{group:h.group,workspaceId:t,workspacePath:n,exportMode:!0})},h.key):s.jsx(Hg,{message:h.message,provider:i,foldedPromptKind:d.has(h.message.id)?"system_prompt":null,actionState:{canCopy:!1,canFork:!1},onRetry:()=>{},onForkMessage:null,interruptedSource:o,assistantAvatar:c,exportMode:!0},h.key)),a?s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":a,children:[s.jsx("span",{children:jg(a)||a}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null]})})}function Jl(){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 fI(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function mI(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 qP({sessionId:e="session",workspaceId:t=null,workspacePath:n=null,messages:r,historyState:i,loadingOlderMessages:o=!1,hasOlderMessages:a=!1,onLoadOlderMessages:c=()=>{},onRetryMessage:u,onForkMessage:d,provider:h,interruptedSource:p=null,runtimeThinkingPlaceholder:m=null,assistantAvatar:g,followTailUpdates:x=!1,sessionRunningState:S=null,sessionSyncStatus:C=null,sessionLastErrorCode:y=null,sessionLastErrorDetail:A=null,onSubmitStructuredQuestion:j}){var Fn;const{showToast:V}=Wn(),L=bn(),I=!x,G=f.useRef(null);Ou(G);const q=f.useRef(e),P=f.useRef(0),T=f.useRef(null),H=f.useRef(!0),_=f.useRef(null),ie=f.useRef(null),Y=f.useRef(!1),W=f.useRef(x?null:Vo(e)),U=f.useRef(x?null:((Fn=Vo(e))==null?void 0:Fn.lastMessageSignature)??null),D=f.useRef(x?null:Vo(e)),K=f.useRef(null),ee=f.useRef(null),v=f.useRef(null),Ne=f.useRef(0),ve=f.useRef(!1),N=f.useRef(null),de=f.useRef(null),Ee=f.useRef(null),[me,le]=f.useState(!1),[We,Ue]=f.useState(!1),Fe=f.useRef(!1),rt=Og(r),F=L.isMobile?0:bT,ne=f.useMemo(()=>Wg(r,h),[r,h]),re=f.useMemo(()=>gI(r),[r]),Se=i==="loading"&&r.length===0,ke=f.useMemo(()=>aT({runningState:S,syncStatus:C,lastErrorCode:y,lastErrorDetail:A}),[y,A,S,C]);function pe(B){var ce,Ce,be;if(!B)return null;try{const Te=JSON.parse(B);return{id:typeof Te.id=="string"?Te.id:null,timestamp:typeof Te.timestamp=="string"?Te.timestamp:null,deliveryState:typeof Te.deliveryState=="string"?Te.deliveryState:null,contentLength:typeof Te.content=="string"?Te.content.length:0,attachmentCount:Array.isArray(Te.attachments)?Te.attachments.length:0,toolStatus:typeof((ce=Te.toolCall)==null?void 0:ce.status)=="string"?Te.toolCall.status:null,hasToolOutput:typeof((Ce=Te.toolCall)==null?void 0:Ce.output)=="string"?Te.toolCall.output.length>0:!1,hasToolError:typeof((be=Te.toolCall)==null?void 0:be.error)=="string"?Te.toolCall.error.length>0:!1}}catch{return{parseError:!0,length:B.length}}}function xt(B){var ce;return{id:B.id,rawRef:B.rawRef,role:B.role,kind:B.kind,deliveryState:B.deliveryState,timestamp:B.timestamp,sequence:B.sequence,attachmentCount:((ce=B.attachments)==null?void 0:ce.length)??0,contentPreview:ds(B.content).text.replace(/\r\n/g,`
48
+ `).trimEnd().slice(0,120)}}function Xe(B){return B.type==="message"?{type:B.type,key:B.key,message:xt(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 st(B,ce){const Ce=B.getBoundingClientRect(),be=ce.getBoundingClientRect(),Te=Math.max(be.top,Ce.top),wt=Math.min(be.bottom,Ce.bottom),$t=Math.max(0,wt-Te);return{top:Math.round(be.top),bottom:Math.round(be.bottom),height:Math.round(be.height),relativeTop:Math.round(be.top-Ce.top),relativeBottom:Math.round(be.bottom-Ce.top),bottomGap:Math.round(Ce.bottom-be.bottom),visibleHeight:Math.round($t),fullyVisible:be.top>=Ce.top&&be.bottom<=Ce.bottom}}function E(B,ce){var Te;const Ce=ce.dataset.messageId??null,be=Ce?r.find(wt=>wt.id===Ce)??null:null;return{messageId:Ce,role:(be==null?void 0:be.role)??null,kind:(be==null?void 0:be.kind)??null,className:ce.className,textLength:((Te=ce.textContent)==null?void 0:Te.length)??0,rect:st(B,ce)}}function $(B){var Te;if(!B)return null;const ce=B.getBoundingClientRect(),Ce=Array.from(B.children).filter(wt=>wt instanceof HTMLElement&&wt.classList.contains("message-item")),be=B.querySelector("[data-runtime-thinking-placeholder='true']");return{listRect:{top:Math.round(ce.top),bottom:Math.round(ce.bottom),height:Math.round(ce.height)},messageElementCount:Ce.length,tailDomItems:Ce.slice(-5).map(wt=>E(B,wt)),runtimeThinkingPlaceholderDom:be?{textLength:((Te=be.textContent)==null?void 0:Te.length)??0,rect:st(B,be)}:null}}function se(B,ce={}){const Ce=r[0]??null,be=r.at(-1)??null,Te=rt.at(-1)??null,wt=W.current,$t=D.current,zt=B?B.scrollHeight-B.clientHeight-B.scrollTop:null;return{sessionId:e,historyState:i,followTailUpdates:x,messagesLength:r.length,renderItemsLength:rt.length,firstMessageId:(Ce==null?void 0:Ce.id)??null,firstMessageRole:(Ce==null?void 0:Ce.role)??null,lastMessageId:(be==null?void 0:be.id)??null,lastMessageRole:(be==null?void 0:be.role)??null,lastMessageKind:(be==null?void 0:be.kind)??null,lastMessageTimestamp:(be==null?void 0:be.timestamp)??null,runtimeThinkingPlaceholderVisible:!!m,runtimeThinkingPlaceholderLength:(m==null?void 0:m.length)??0,runtimeThinkingPlaceholderPreview:(m==null?void 0:m.slice(0,80))??null,tailItemType:(Te==null?void 0:Te.type)??null,tailToolCallId:Te&&Te.type==="tool_group"?Te.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:zt,stickToBottomRef:H.current,hasNewMessagesBelow:Fe.current,previousMessageCount:P.current,previousLastMessage:pe(T.current),tailMessages:r.slice(-5).map(xt),tailRenderItems:rt.slice(-5).map(Xe),dom:$(B),pendingRestoreState:wt===null?null:{scrollTop:wt.scrollTop,stickToBottom:wt.stickToBottom,lastMessage:pe(wt.lastMessageSignature)},currentScrollState:$t===null?null:{scrollTop:$t.scrollTop,stickToBottom:$t.stickToBottom,lastMessage:pe($t.lastMessageSignature)},restoredTailMessage:pe(U.current),...ce}}function ue(B,ce,Ce={}){mc()&&ox(B,se(ce,Ce))}function we(B){const Ce=B.scrollHeight-B.clientHeight-B.scrollTop<=Ph;return{scrollTop:B.scrollTop,stickToBottom:Ce,lastMessageSignature:Fe.current&&!Ce?U.current:$s(r.at(-1)??null)}}function z(B){return D.current=we(B),D.current}function X(B){const ce=B.scrollHeight-B.clientHeight-B.scrollTop,Ce=ce<=Ph;H.current=Ce,Ce&&Fe.current&&(Ve(),Fe.current=!1,U.current=$s(r.at(-1)??null),Ue(!1)),le(r.length>0&&(ce>Lh||Fe.current)),z(B),ue("affordance.sync",B,{distanceToBottom:ce,nextStickToBottom:Ce})}function ge(B=G.current){I&&(B&&z(B),D.current&&Ah(e,D.current))}function ye(B){I&&D.current&&Ah(B,D.current)}function De(){K.current!==null&&(window.clearTimeout(K.current),K.current=null)}function He(){I&&(De(),K.current=window.setTimeout(()=>{K.current=null,ge()},fT))}function yt(B,ce,Ce={}){ue("jump_to_bottom.before",B,{reason:ce,...Ce}),B.scrollTop=B.scrollHeight,ue("jump_to_bottom.after",B,{reason:ce,...Ce})}function lt(){ee.current!==null&&(window.clearTimeout(ee.current),ee.current=null)}function Ve(){lt(),ve.current=!1,v.current=null,Ne.current=0,N.current=null}function tt(B,ce){const Ce=Math.max(0,B.scrollHeight-B.clientHeight),be=Math.max(0,Math.min(ce,Ce));N.current=be,B.scrollTop=be,H.current=!1,ue("manual_restore.apply",B,{targetScrollTop:ce,maxScrollableTop:Ce,nextScrollTop:be}),le(r.length>0&&(Ce-be>Lh||Fe.current))}function Je(){lt(),ve.current&&(ee.current=window.setTimeout(()=>{ee.current=null;const B=G.current,ce=v.current;if(!B||ce===null){Ve();return}if(tt(B,ce),Date.now()<Ne.current){Je();return}Ve(),X(B)},gT))}function nt(B,ce){if(F<=0){tt(ce,B),Ve();return}ve.current=!0,v.current=B,Ne.current=Date.now()+F,tt(ce,B),Je()}function pt(){ve.current&&(ue("manual_restore.interrupt",G.current),Ve())}function Ft(B){return Y.current||!a||o||i!=="ready"||B.scrollTop>pT?!1:(Y.current=!0,_.current=B.scrollHeight-B.scrollTop,ie.current=$s(r[0]??null),ue("older_history.prefetch",B,{pendingOlderLoadOffset:_.current,pendingOlderLoadHeadMessage:pe(ie.current)}),c(),!0)}f.useEffect(()=>{i==="error"&&V({title:l("conversation.historyLoadFailed"),tone:"error"})},[i,V]),f.useLayoutEffect(()=>{var B,ce;if(q.current!==e){const Ce=q.current;ye(Ce),q.current=e,P.current=0,T.current=null,W.current=x?null:Vo(e),U.current=((B=W.current)==null?void 0:B.lastMessageSignature)??null,D.current=W.current,H.current=x?!0:((ce=W.current)==null?void 0:ce.stickToBottom)??!0,_.current=null,ie.current=null,Ve(),Fe.current=!1,Ue(!1),le(!1),ue("session.switch",G.current,{previousSessionId:Ce,nextSessionId:e})}},[x,I,e]),f.useLayoutEffect(()=>()=>{De(),Ve(),ye(q.current)},[I,e]),f.useLayoutEffect(()=>{const B=G.current,ce=$s(r.at(-1)??null);if(!B){P.current=r.length,T.current=ce;return}const Ce=P.current,be=T.current,Te=W.current,wt=Ce===0||r.length!==Ce||ce!==be;if(ue("messages.effect.start",B,{previousCount:Ce,previousLastMessage:pe(be),currentLastMessage:pe(ce),hasTailUpdate:wt}),Te&&i==="ready"){const ir=!Te.stickToBottom&&Te.lastMessageSignature!==null&&ce!==null&&Te.lastMessageSignature!==ce;Te.stickToBottom?(Ve(),yt(B,"restore_ready_stick_to_bottom",{hasTailUpdates:ir})):(nt(Te.scrollTop,B),ue("restore_ready.manual",B,{hasTailUpdates:ir,targetScrollTop:Te.scrollTop})),Fe.current=ir,U.current=Te.lastMessageSignature,Ue(ir),W.current=null,X(B),P.current=r.length,T.current=ce,z(B);return}if(Te&&i==="error"){Te.stickToBottom?(Ve(),yt(B,"restore_error_stick_to_bottom")):(nt(Te.scrollTop,B),ue("restore_error.manual",B,{targetScrollTop:Te.scrollTop})),W.current=null,X(B),P.current=r.length,T.current=ce,z(B);return}if(ve.current){tt(B,v.current??B.scrollTop),P.current=r.length,T.current=ce,z(B);return}const $t=$s(r[0]??null),zt=_.current,kn=ie.current,In=zt!==null&&!o&&kn!==null&&kn!==$t&&r.length>=Ce,tn=wt&&(x||H.current);ue("messages.effect.decision",B,{currentHeadMessage:pe($t),pendingOlderLoadOffset:zt,pendingOlderLoadHeadMessage:pe(kn),shouldRestoreOlderLoadOffset:In,shouldFollowTailUpdate:tn,loadingOlderMessages:o}),In?(B.scrollTop=Math.max(0,B.scrollHeight-zt),_.current=null,ie.current=null):_.current!==null&&!o?(_.current=null,ie.current=null,tn&&yt(B,"older_load_offset_cleared_follow_tail",{pendingOlderLoadOffset:zt})):tn&&yt(B,"tail_update_follow"),X(B),P.current=r.length,T.current=ce},[i,o,r,e]),f.useEffect(()=>{if(!a){Y.current=!1;return}!o&&_.current===null&&(Y.current=!1)},[a,o,r.length]),f.useLayoutEffect(()=>{const B=Ee.current;B!==m&&(ue("runtime_thinking.placeholder_change",G.current,{previousVisible:!!B,nextVisible:!!m,previousLength:(B==null?void 0:B.length)??0,nextLength:(m==null?void 0:m.length)??0,note:"Codex 思考中占位符不属于 messages,若这里出现但 messages.effect 没有 tail_update_follow,用户消息会停在可视底部。"}),Ee.current=m)},[m,e]),f.useEffect(()=>{const B=G.current;if(!mc()||!B||typeof ResizeObserver>"u")return;const ce=new ResizeObserver(()=>{ue("list.resize",B)});return ce.observe(B),()=>{ce.disconnect()}},[r.length,e]);function qe(){const B=G.current;if(B){if(ve.current){const ce=N.current;ce!==null&&Math.abs(B.scrollTop-ce)<=1?N.current=null:pt()}X(B),He(),ue("scroll",B),Ft(B)}}function ft(B){if(B.deltaY!==0&&pt(),B.deltaY>=0)return;const ce=G.current;ce&&Ft(ce)}function _e(B){var ce;pt(),de.current=((ce=B.touches[0])==null?void 0:ce.clientY)??null}function Nt(B){var Te;const ce=de.current,Ce=((Te=B.touches[0])==null?void 0:Te.clientY)??null;if(ce===null||Ce===null||Ce-ce<mT)return;pt();const be=G.current;be&&Ft(be)}function Qe(){de.current=null}return s.jsxs("section",{className:"message-timeline",children:[i==="loading"&&s.jsx("div",{className:"timeline-status",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoading")})}),s.jsxs("div",{ref:G,className:"message-list","data-scrollbar-autohide":"true",onScroll:qe,onPointerDown:pt,onWheel:ft,onTouchStart:_e,onTouchMove:Nt,onTouchEnd:Qe,onTouchCancel:Qe,children:[Se?s.jsx(sI,{}):null,o?s.jsx("div",{className:"timeline-status timeline-status-inline",children:s.jsx("span",{className:"status-text",children:l("conversation.historyLoadingOlder")})}):null,rt.length===0&&i==="ready"&&s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}),rt.map(B=>B.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx($g,{group:B.group,workspaceId:t,workspacePath:n})},B.key):s.jsx(Hg,{message:B.message,provider:h,foldedPromptKind:ne.has(B.message.id)?"system_prompt":null,actionState:re.get(B.message.id)??{canCopy:B.message.role==="user",canFork:!1},onRetry:u,onForkMessage:d,interruptedSource:p,assistantAvatar:g,onSubmitStructuredQuestion:j},B.key)),m?s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline","data-runtime-thinking-placeholder":"true",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":m,children:[s.jsx("span",{children:jg(m)||m}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null,ke?s.jsxs("section",{className:"session-runtime-error-panel",role:"status","aria-label":ke.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:ke.title})]}),s.jsx("p",{className:"session-runtime-error-panel__summary",children:dT(ke.summary).map((B,ce)=>B.type==="text"?s.jsx("span",{children:B.text},`text-${ce}`):s.jsx("mark",{className:`session-runtime-error-panel__summary-token session-runtime-error-panel__summary-token--${B.type}`,children:B.text},`${B.type}-${ce}`))}),ke.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",{className:"session-runtime-error-panel__code",children:ke.code})]}):null,ke.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",{className:"session-runtime-error-panel__detail-text",children:ke.detail})]}):null]}):null]}),me?s.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":We?"true":"false","aria-label":l("conversation.scrollToBottomAction"),title:l("conversation.scrollToBottomAction"),onClick:()=>{const B=G.current;B&&(Ve(),yt(B,"scroll_button_click"),Fe.current=!1,U.current=$s(r.at(-1)??null),Ue(!1),X(B),ge(B))},children:[We?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 $s(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 gI(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||!bI(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 bI(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function kI(e){return Hu(e)!==null}function xI(e){return e.isSubagent===!0&&!kI(e)}function Hu(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 yI(e){const t=Hu(e);return t==="reconstructed"?l("shell.sessionForkReconstructed"):t==="message"?l("shell.sessionForkMessage"):t==="session"?l("shell.sessionForkSession"):null}function wI(e){return e.sessionKind==="annotation"?"annotation":null}function GP(e){return wI(e)==="annotation"?l("conversation.actionSessionBadge"):null}const vI=3*1e3,Dc=120*1e3,SI=8,CI=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,NI=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/;function VP(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 Uu(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 KP(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 YP(e,t){return qu([...e,t])}function XP(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=Uu(t,a);o.push(c);const u=sE(r,c,t);if(u&&u!==c.id)continue;const d=rE(r,c,t);d&&d!==c.id&&r.delete(d);const h=iE(r,i,c);if(h&&h!==c.id){const g=r.get(h)??null;if(g){const x=qh(g,c);fc("session.messages.codex_equivalent_replace",{sessionId:t,previous:Ar(g),incoming:Ar(c),merged:Ar(x)}),r.delete(h),r.set(a.messageId,x);continue}}const p=oE(r,c);if(p&&p!==c.id){const g=r.get(p)??null;if(g){const x=zI(g,c);fc("session.messages.opencode_equivalent_replace",{sessionId:t,previous:Ar(g),incoming:Ar(c),merged:Ar(x)}),r.set(p,x);continue}}const m=r.get(a.messageId)??null;r.set(a.messageId,m?qh(m,c):c)}return qu(aE(Array.from(r.values()),o))}function JP(e,t,n,r){const i=r===null?null:e.find(u=>u.clientRequestId===r)??null,o=e.filter(u=>u.clientRequestId!==r),a=Uu(t,n,"sent",r),c=$I(a,i);return qu([...o.filter(u=>u.id!==c.id),c])}function QP(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function jI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!HI(r,n)){t.push(n);continue}t[t.length-1]=VI(r,n)}return t}function TI(e){const t=[];let n=null,r=!1;for(const i of e)if(!UI(n,i,r)){if(t.push(i),so(i)){n=i,r=!1;continue}n&&qI(i)&&(r=!0)}return t}function II(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Gg(r,n)){t.push(n);continue}t[t.length-1]=Vg(r,n)}return t}function EI(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];GI(r,i,o,a)&&t.splice(t.length-3,3,Vg(i,a))}return t}function MI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!KI(r,n)){t.push(n);continue}t[t.length-1]=XI(r,n)}return t}function RI(e){const t=[];for(const n of e){const r=t.findIndex(i=>YI(i,n));if(r===-1){t.push(n);continue}t[r]=JI(t[r],n)}return t}function qu(e){const t=[...e].sort((n,r)=>Ug(n,r));return RI(MI(TI(EI(II(jI(t))))))}function Ug(e,t){const n=AI(e.rawRef,t.rawRef);if(n!==null&&n!==0)return n;if(e.sequence!==t.sequence)return e.sequence-t.sequence;const r=PI(e.rawRef,t.rawRef);if(r!==0)return r;const i=e.timestamp.localeCompare(t.timestamp);if(i!==0)return i;const o=LI(e.rawRef,t.rawRef);if(o!==0)return o;const a=FI(e.role,t.role);if(a!==0)return a;const c=e.rawRef.localeCompare(t.rawRef);return c!==0?c:e.id.localeCompare(t.id)}function AI(e,t){if(!e.startsWith("codex://")||!t.startsWith("codex://"))return null;const n=$h(e),r=$h(t);if(!n||!r||n!==r)return null;const i=ro(e),o=ro(t);if(i===null||o===null)return null;if(i!==o)return i-o;const a=hs(e,"part")??0,c=hs(t,"part")??0;return a-c}function $h(e){const t=e.match(/^codex:\/\/(.+?)(?:#|$)/);return(t==null?void 0:t[1])??null}function PI(e,t){const n=WI(e,t);if(n!==null&&n!==0)return n;const r=DI(e,t);if(r!==null&&r!==0)return r;const i=Hh(e),o=Hh(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 LI(e,t){const n=ro(e),r=ro(t);return n===null&&r===null?0:n===null?1:r===null?-1:n-r}function ro(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 DI(e,t){const n=zh(e),r=zh(t);if(!n||!r||n!==r)return null;const i=hs(e,"part"),o=hs(t,"part");return i===null||o===null?null:i-o}function zh(e){const t=e.match(/^(.+\/message\/[^/?#]+)\/part\/[^/?#]+(?:[?#].*)?$/i);return(t==null?void 0:t[1])??null}function Hh(e){const t=ro(e);if(t!==null){const i=hs(e,"part");return i===null?[t]:[t,i]}const n=_I(e);if(n)return n;const r=BI(e);return r||null}function _I(e){const t=hs(e,"index");if(t===null)return null;const n=hs(e,"part");return n===null?[t]:[t,n]}function hs(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 BI(e){const t=e.match(/\/message\/(user|assistant|tool)-(\d+)\/part\/([a-z_]+)-(\d+)/i);if(!t)return null;const n=OI(t[1]??""),r=Number.parseInt(t[2]??"",10),i=$i(t[3]??""),o=Number.parseInt(t[4]??"",10);return!Number.isFinite(r)||!Number.isFinite(o)?null:[r,n,i,o]}function OI(e){switch(e.toLowerCase()){case"user":return 0;case"assistant":return 1;case"tool":return 2;default:return 3}}function $i(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 WI(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]??"",j=a[2]??"";return C!==y||A!==j?0:$i(o[3]??"")-$i(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:$i(c[4]??"")-$i(u[4]??"")}function FI(e,t){return Uh(e)-Uh(t)}function Uh(e){switch(e){case"user":return 0;case"assistant":return 1;case"tool":return 2;case"system":default:return 3}}function $I(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function qh(e,t){if(e.id!==t.id)return t;if(e.role!==t.role||e.kind!==t.kind)return _r(e,t);const n=Bc(e.toolCall,t.toolCall),r=Oc(e.content,t.content,e.timestamp,t.timestamp),i=Wc(e.attachments,t.attachments),o=Fc(e,t);return{..._r(e,t),content:r,toolCall:n,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence}}function zI(e,t){if(Jg(e,t)){const a=Bc(e.toolCall,t.toolCall),c=Oc(e.content,t.content,e.timestamp,t.timestamp),u=Wc(e.attachments,t.attachments),d=Fc(e,t);return{..._r(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{..._r(e,t),id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId};const n=Bc(e.toolCall,t.toolCall),r=Oc(e.content,t.content,e.timestamp,t.timestamp),i=Wc(e.attachments,t.attachments),o=Fc(e,t);return{..._r(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 HI(e,t){return qg(e,t,vI)}function qg(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=ds(e.content),i=ds(t.content);return ms(e.timestamp,t.timestamp,n)&&ht(r.text)===ht(i.text)&&nE(r.inlineImages,i.inlineImages)}function UI(e,t,n){return!e||n||!so(e)||!so(t)?!1:ms(e.timestamp,t.timestamp,120*1e3)&&ht(e.content)===ht(t.content)}function so(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function _c(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")}function qI(e){return _c(e)&&e.kind==="text"}function Gg(e,t){return _c(e)&&_c(t)&&e.kind===t.kind&&ms(e.timestamp,t.timestamp,120*1e3)&&ht(e.content)===ht(t.content)}function GI(e,t,n,r){return!e||!t||!n||!r||!so(e)||!so(n)?!1:Gg(t,r)&&ms(e.timestamp,n.timestamp,120*1e3)&&ht(e.content)===ht(n.content)}function Vg(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=ht(e.content).length,o=ht(t.content).length;return i!==o?i>o?e:t:_r(e,t)}function VI(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=ds(e.content).inlineImages.length,o=ds(t.content).inlineImages.length;if(i!==o)return i>o?e:t;const a=e.content!==ht(e.content),c=t.content!==ht(t.content);if(a!==c)return a?t:e;const u=io(e.content),d=io(t.content);return u!==d?u?t:e:t}function KI(e,t){return!Gh(e)||!Gh(t)?!1:e.role===t.role&&ms(e.timestamp,t.timestamp,120*1e3)&&ht(e.content)===ht(t.content)}function YI(e,t){return!Vh(e)||!Vh(t)?!1:e.role===t.role&&ms(e.timestamp,t.timestamp,120*1e3)&&ht(e.content)===ht(t.content)}function Gh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Vh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function XI(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=ht(e.content).length,o=ht(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:_r(e,t)}function JI(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=ht(e.content).length,o=ht(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:_r(e,t)}function Bc(e,t){return e?t?{...QI(e,t),input:Kg(e.input,t.input),output:Yh(e.output,t.output),error:Yh(e.error,t.error)}:e:t}function QI(e,t){const n=Kh(e.status),r=Kh(t.status);return r!==n?r>n?t:e:t}function Kh(e){return e==="running"?0:1}function Oc(e,t,n,r){const i=ht(e),o=ht(t);if(i===o){const a=tE(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 Wc(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 Kg(e,t){return t.length>e.length?t:e}function Yh(e,t){return e===null?t:t===null?e:Kg(e,t)}function _r(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function Fc(e,t){return Ug(e,t)<=0?e:t}function ht(e){return eE(e).replace(/\r\n/g,`
49
+ `).trimEnd()}function $c(e){return ht(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:Yg(r)}function eE(e){return Yg(e).replace(/\r\n/g,`
52
+ `).trimEnd()}function io(e){return NI.test(e)}function Yg(e){return io(e)?e.replace(CI,"").replace(/[ \t]+\n/g,`
53
+ `).replace(/\n{3,}/g,`
54
+
55
+ `).trimEnd():e}function tE(e,t){const n=io(e),r=io(t);return n===r?null:n?t:e}function nE(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 rE(e,t,n){return Qg(t)?Xg(e,t,"optimistic",n):null}function sE(e,t,n){return Qa(t)?Xg(e,t,"authoritative",n):null}function iE(e,t,n){if(!Da(n))return null;const r=nr(n.timestamp);let i=null,o=Number.POSITIVE_INFINITY;for(const[a,c]of e.entries()){if(a===n.id||!t.has(a)||!lE(c,n))continue;const u=nr(c.timestamp),d=Math.abs(u-r),p=Math.abs(c.sequence-n.sequence)*Dc+d;p<o&&(i=a,o=p)}return i}function oE(e,t){if(!Xh(t))return null;const n=_a(t.rawRef);if(n===null)return null;const r=nr(t.timestamp);let i=null,o=Number.POSITIVE_INFINITY;for(const[a,c]of e.entries()){if(a===t.id||!Xh(c)||c.role!==t.role)continue;if(Jg(c,t))return a;if(c.kind!==t.kind||_a(c.rawRef)!==n)continue;const d=nr(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 Xg(e,t,n,r){const i=nr(t.timestamp),o=ht(t.content),a=$c(t.content),c=zc(t.attachments);let u=null,d=Number.POSITIVE_INFINITY;const h=[];for(const[p,m]of e.entries()){if(!(n==="optimistic"?Qa(m):Qg(m)))continue;const x=ht(m.content),S=$c(m.content),C=x===o,y=S===a;if(!C&&!y)continue;const A=nr(m.timestamp),j=Math.abs(A-i);if(j>300*1e3)continue;const V=Math.abs(m.sequence-t.sequence),L=zc(m.attachments),I=dE(L,c);if(I==="conflict"&&(C||o.length===0)){h.push(Qh(m,{strictTextMatches:C,relaxedTextMatches:y,attachmentCompatibility:I,distanceMs:j,sequenceDistance:V}));continue}const G=j+V*15e3+(C?0:500)+hE(I);h.push(Qh(m,{strictTextMatches:C,relaxedTextMatches:y,attachmentCompatibility:I,distanceMs:j,sequenceDistance:V})),G<d&&(u=p,d=G)}return h.length>0&&fc("session.messages.user_match",{sessionId:r,target:n,matchedId:u,matchedScore:Number.isFinite(d)?d:null,incoming:pE(t,{relaxedContent:a,attachmentSignature:c}),candidates:h.slice(0,5)}),u}function Da(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.role==="assistant"||e.role==="tool")}function aE(e,t){const n=t.filter(Da);return n.length===0?e:e.map(r=>{if(!uE(r))return r;const i=nr(r.timestamp),o=n.reduce((a,c)=>nr(c.timestamp)<i?a:Math.min(a,c.sequence),Number.POSITIVE_INFINITY);return!Number.isFinite(o)||o>=r.sequence?r:{...r,sequence:o}})}function Xh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&!Qa(e)&&(e.role==="user"||e.role==="assistant"||e.role==="tool")}function Jh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")&&e.toolCall!==null}function Jg(e,t){var i,o;if(!Jh(e)||!Jh(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:_a(e.rawRef)===_a(t.rawRef)}function _a(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 lE(e,t){return!Da(e)||!Da(t)||e.role!==t.role||e.kind!==t.kind||Math.abs(e.sequence-t.sequence)>SI||!ms(e.timestamp,t.timestamp,Dc)?!1:t.kind==="text"||t.kind==="thinking"?qg(e,t,Dc):t.kind==="tool_call"||t.kind==="tool_result"?cE(e,t):!1}function cE(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 Qa(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 uE(e){return e.deliveryState==="sent"&&e.role==="user"&&e.kind==="text"&&e.rawRef.startsWith("synthetic://codex/")}function Qg(e){return e.role==="user"&&e.kind==="text"&&!Qa(e)}function nr(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function Ar(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"?ht(ds(e.content).text).slice(0,160):ht(e.content).slice(0,160)}}function zc(e){return(e??[]).map(t=>[t.kind,t.fileName.trim().toLowerCase(),t.mimeType.trim().toLowerCase(),String(t.fileSize)].join(":")).sort().join("|")}function dE(e,t){return!e&&!t?"same":!e||!t?"one_side_missing":e===t?"same":"conflict"}function hE(e){switch(e){case"same":return 0;case"one_side_missing":return 2500;case"conflict":default:return 12e4}}function Qh(e,t){return{...Ar(e),comparableContent:$c(e.content).slice(0,160),attachmentSignature:zc(e.attachments),strictTextMatches:t.strictTextMatches,relaxedTextMatches:t.relaxedTextMatches,attachmentCompatibility:t.attachmentCompatibility,distanceMs:t.distanceMs,sequenceDistance:t.sequenceDistance}}function pE(e,t){return{...Ar(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 ms(e,t,n){return Math.abs(nr(e)-nr(t))<=n}const fE=200;async function mE(e){const t=[],n=new Set;let r=null;for(;!(r&&n.has(r));){r&&n.add(r);const i=await pf(e,r,fE,"forward"),o=i.messages.map(a=>Uu(e,a));if(t.push(...o),!i.nextCursor||i.nextCursor===r||o.length===0)break;r=i.nextCursor}return{messages:t}}function Ql(e,t,n=new Date){return`${SE(e.title||l("conversation.titleFallback"))}-${vE(n)}.${t}`}function gE(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")}:${si(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${si(n.toISOString())}`,""];return t.forEach((o,a)=>{var c,u,d;i.push(`## ${a+1}. ${Zg(o)}`),i.push(""),i.push(`- ${l("conversation.exportMarkdownTimeLabel")}:${si(o.timestamp)}`),i.push(`- ${l("conversation.exportMarkdownTypeLabel")}:${wE(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}, ${eb(h.fileSize)})`)}),i.push(""))}),`${i.join(`
56
+ `).trimEnd()}
57
+ `}function Zh(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 bE(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 kE(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")}:${si(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${si(n.toISOString())}`],o=new TE;return o.renderDocumentHeader(r,i),t.forEach((a,c)=>{o.renderMessageCard(c,a)}),BE(o.finish())}function xE(e){const t=ep(e.htmlAttributes,e.htmlStyle),n=ep(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>${tb(e.title)}</title>`,`<style>${e.styleText}</style>`,"</head>",`<body${n}>`,e.bodyHtml,"</body>","</html>"].join("")}function Zg(e){return`${yE(e)} · ${si(e.timestamp)}`}function yE(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 wE(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 si(e){const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function vE(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 eb(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 SE(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-")||"session"}function ep(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}="${CE(i)}"`).join(" ")}`}function tb(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function CE(e){return tb(e).replaceAll('"',"&quot;")}const nb=595.28,zi=841.89,tp=40,np=40,Vs=36,rb=nb-Vs*2,NE=14,Hc=12,Xo=12,jE=72,Jo=11,Zs=9,_i=12,rp=20;class TE{constructor(){Ke(this,"pages",[[]]);Ke(this,"cursorTop",tp)}renderDocumentHeader(t,n){this.drawRichText(t,Vs,this.cursorTop,rp,[15,23,42],"sans"),this.cursorTop+=rp+8,n.forEach(r=>{this.drawRichText(r,Vs,this.cursorTop,Zs,[71,85,105],"sans"),this.cursorTop+=Mr(Zs)}),this.cursorTop+=18}renderMessageCard(t,n){const r=IE(t,n);let i=0,o=0;for(;i<r.lines.length||o===0;){this.ensureVerticalSpace(jE);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=Mr(r.lines[i].fontSize));const c=o===0?r.header:`${r.header} · 续`,u=Xo*2+Mr(_i)+8+Math.max(a.height,0);if(this.ensureVerticalSpace(u),this.drawCardSegment(r,c,a.lines,a.height),this.cursorTop+=u+NE,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=Xo*2+Mr(_i)+8+Math.max(i,0),a=this.cursorTop,c=zi-a-o;this.pushCommand(`${Qo(t.backgroundColor)} rg ${Qo(t.borderColor)} RG 1 w ${fn(Vs)} ${fn(c)} ${fn(rb)} ${fn(o)} re B`);let u=a+Xo;this.drawRichText(n,Vs+Hc,u,_i,t.headerColor,"sans"),u+=Mr(_i)+8,r.forEach(d=>{u+=d.gapBefore,this.drawRichText(d.text,Vs+Hc,u,d.fontSize,d.color,d.fontKind),u+=Mr(d.fontSize)})}pickSegmentLines(t,n){const r={lines:[],count:0,height:0},i=zi-this.cursorTop-np-Xo*2-Mr(_i)-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+Mr(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<=zi-np||(this.pages.push([]),this.cursorTop=tp)}drawRichText(t,n,r,i,o,a){const c=zi-r-i;let u=n;AE(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} ${fn(i)} Tf ${Qo(o)} rg 1 0 0 1 ${fn(u)} ${fn(c)} Tm (${_E(h.text)}) Tj ET`),u+=LE(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 ${fn(i)} Tf ${Qo(o)} rg 1 0 0 1 ${fn(a)} ${fn(r)} Tm <${RE(c)}> Tj ET`),a+=Gu(c,i,"F1");return a}pushCommand(t){var n;(n=this.pages[this.pages.length-1])==null||n.push(t)}}function IE(e,t){var a,c;const n=EE(t.role),r=rb-Hc*2,i=[],o=`${e+1}. ${Zg(t)}`;if(t.content.trim()&&Er(i,t.content,r,Jo,[15,23,42],0,"sans"),t.toolCall){const u=`${l("conversation.exportMarkdownToolSectionTitle")} · ${t.toolCall.name} · ${t.toolCall.status}`;Er(i,u,r,Jo,[30,41,59],10,"sans"),t.toolCall.input.trim()&&Er(i,`${l("conversation.exportMarkdownToolInputLabel")}:${t.toolCall.input}`,r,Zs,[71,85,105],6,"mono"),(t.toolCall.output??"").trim()&&Er(i,`${l("conversation.exportMarkdownToolOutputLabel")}:${t.toolCall.output??""}`,r,Zs,[71,85,105],6,"mono"),(t.toolCall.error??"").trim()&&Er(i,`${l("conversation.exportMarkdownToolErrorLabel")}:${t.toolCall.error??""}`,r,Zs,[185,28,28],6,"mono")}return(((a=t.attachments)==null?void 0:a.length)??0)>0&&(Er(i,l("conversation.exportMarkdownAttachmentsSectionTitle"),r,Jo,[30,41,59],10,"sans"),(c=t.attachments)==null||c.forEach(u=>{Er(i,`- ${u.fileName} (${u.kind}, ${u.mimeType}, ${eb(u.fileSize)})`,r,Zs,[71,85,105],4,"sans")})),i.length===0&&Er(i,l("conversation.exportMarkdownTextType"),r,Jo,[100,116,139],0,"sans"),{header:o,headerColor:n.headerColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,lines:i}}function EE(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 Er(e,t,n,r,i,o=0,a="sans"){t.replace(/\r\n/g,`
59
+ `).split(`
60
+ `).forEach((d,h)=>{const p=ME(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 ME(e,t,n,r){if(!e.trim())return[];const i=[];let o="",a=0;const c=sb();for(const u of Array.from(e)){const d=Gu(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 Gu(e,t,n){if(n==="F1")return t*(DE(e)/1e3);const r=n==="F3"?600:ib[e]??556;return t*(r/1e3)}function Mr(e){return e*1.5}function Qo(e){return e.map(t=>fn(t/255)).join(" ")}function fn(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/u,"").replace(/\.$/u,"")}function RE(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 AE(e,t){if(!e)return[];const n=sb();return[{text:e,fontRef:n}]}function sb(e,t){return"F1"}function PE(e){const t=e.codePointAt(0)??0;return t>=32&&t<=126}function LE(e,t,n){return Array.from(e).reduce((r,i)=>r+Gu(i,t,n),0)}function DE(e){return PE(e)?ib[e]??556:e===" "?278:1e3}function _E(e){return e.replace(/\\/gu,"\\\\").replace(/\(/gu,"\\(").replace(/\)/gu,"\\)")}const ib={" ":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 BE(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 ${fn(nb)} ${fn(zi)}]`,"/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 sp=48;function OE(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Vu(e,t){const n=OE(e)||t,r=n.length>sp?n.slice(0,sp).trimEnd():n;return{fullTitle:n,displayTitle:r}}function Zo(e,t){return(t??"").localeCompare(e??"")}function ip(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function ea(e){return(e==null?void 0:e.trim())??""}function oo(e,t,n){if(n==="updatedAt"){const a=Zo(e.updatedAt,t.updatedAt);if(a!==0)return a}if(n==="title"){const a=ip(ea(e.title),ea(t.title));if(a!==0)return a}else{const a=Zo(e.createdAt,t.createdAt);if(a!==0)return a}const r=Zo(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=Zo(e.createdAt,t.createdAt);if(i!==0)return i;const o=ip(ea(e.title),ea(t.title));return o!==0?o:e.sessionId.localeCompare(t.sessionId)}function mo(e,t){return[...e].sort((n,r)=>oo(n,r,t))}function Ku(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:mo(n.sessions,t),children:Ku(n.children,t)})):[]}const Zl=5,ec=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function WE(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function FE(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,Zl).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:ec[u]??ec[0]})),o=e.slice(Zl);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:ec[Zl]}),i}function $E(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} ${op(o)} ${op(a)}`}).join(", ")})`}function zE(e){return{"--workbench-manage-chart-background":$E(e)}}function op(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const HE=8,UE=12,qE=160,ap=96;function GE(e,t,n,r={}){const i=r.gapPx??HE,o=r.viewportMarginPx??UE,a=r.defaultWidthPx??qE,c=r.estimatedHeightPx??ap,u=r.minHeightPx??ap,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=ta(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),j=Math.max(0,e.y-i-o),V=A<x&&j>A,I=ta(Math.max(V?j:A,u),0,p),G=Math.min(x,I),q=y?e.x-g:e.x,P=Math.max(o,d-o-g),T=V?e.y-i-G:e.y+i,H=Math.max(o,h-o-G),_=ta(q,o,P),ie=ta(T,o,H),Y=y||_<e.x?"right":"left";return{top:ie,left:_,width:g,maxHeight:Math.max(0,I),transformOrigin:`${V?"bottom":"top"} ${Y}`}}function ta(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const ob="workbench.navigation.snapshot",ab=1800*1e3,VE="workbench.navigation.snapshot.host.";function lb(e){return`${VE}${e}`}function KE(e=ab,t=Wa(Bn.getState())){if(t){const n=wa(lb(t),e);if(n)return n}return wa(ob,e)}function na(e,t=Wa(Bn.getState())){qi(ob,e),t&&qi(lb(t),e)}function lp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:mo(n.sessions,t),childWorktrees:YE(n.childWorktrees,t)}))}function YE(e,t){return Ku(e,t)}function Ba(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 XE(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Ba(n.workspace)),cb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function cr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function cb(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}),cb(e,a.children,n,a.workspace,c)}}class Uc extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class JE{constructor(){Ke(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=Bn.getState();if(Wa(n)===t)return;const r=lk(n,t);if(!r)throw new Uc("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await ck(r.baseUrl)).reachable)throw new Uc("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const o=cf(r.id);if(o)try{await Ji.loginForHost(r,{username:o.username,password:o.password})}catch{}const a=Bn.getState(),c=new Date().toISOString();if(uf(r)){Bn.updateRuntime({discoveredHosts:a.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}dc.setActiveDiscoveredHost(null),await Bn.update({hosts:a.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const QE=new JE,ZE=1700;function eM({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(),j=Math.max(180,Math.min(u,window.innerWidth-h*2)),V=Math.min(Math.max(h,A.right-j),Math.max(h,window.innerWidth-h-j)),L=A.top>=Math.min(240,window.innerHeight*.42),I=Math.round(L?A.top-d:A.bottom+d);m({top:I,left:Math.round(V),width:j,placeAbove:L})},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 ur.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 tc={status:"idle",latencyMs:null};function ub({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),[j,V]=f.useState(!1),[L,I]=f.useState(!1),[G,q]=f.useState(tc),[P,T]=f.useState(null),H=f.useRef(null),_=f.useRef(null),ie=f.useRef(null),Y=f.useRef(null),W=eu(F=>F),U=Qc(F=>F.session),{showToast:D}=Wn(),K=hc(W),ee=Wa(W),v=yk(),Ne=uk(ee),ve=f.useMemo(()=>cp(W.hosts,ee),[ee,W.hosts]),N=f.useMemo(()=>cp(df(W),ee),[ee,W]),de=f.useCallback(()=>{if(typeof window>"u")return;const F=H.current;if(!F)return;const ne=F.getBoundingClientRect(),re=window.innerWidth,Se=window.innerHeight,ke=16,pe=8,Xe=Math.min(320,Math.max(240,re-ke*2)),st=Math.min(e?Math.max(ke,ne.right+pe):Math.max(ke,ne.left),Math.max(ke,re-Xe-ke)),E=r?440:240,$=e?ne.top:ne.bottom+pe,se=Math.min(Math.max(ke,$),Math.max(ke,Se-E-ke));T({position:"fixed",top:se,left:st,width:Xe,maxWidth:re-ke*2})},[e,r]);f.useEffect(()=>{if(!t){T(null),V(!1),q(tc);return}dc.refresh();function F(re){var Se,ke,pe;re.target instanceof Node&&!((Se=H.current)!=null&&Se.contains(re.target))&&!((ke=_.current)!=null&&ke.contains(re.target))&&!((pe=Y.current)!=null&&pe.contains(re.target))&&(n(!1),i(!1),V(!1),A(null))}function ne(re){re.key==="Escape"&&(n(!1),i(!1),V(!1),A(null))}return window.addEventListener("pointerdown",F),window.addEventListener("keydown",ne),window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),de(),()=>{window.removeEventListener("pointerdown",F),window.removeEventListener("keydown",ne),window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}},[t,de]),f.useEffect(()=>{if(!j||!t||(v==null?void 0:v.kind)!=="relay"){q(tc);return}let F=!1;const ne=performance.now();return q({status:"probing",latencyMs:null}),xe.request("/api/client/runtime-config").then(()=>{F||q({status:"ready",latencyMs:performance.now()-ne})}).catch(()=>{F||q({status:"error",latencyMs:null})}),()=>{F=!0}},[v==null?void 0:v.kind,j,t]);async function Ee(F){if(g||S||F.id===ee){n(!1);return}x(F.id);try{await QE.switchHost(F.id),n(!1),i(!1),V(!1),A(null)}catch(ne){D({title:iM(ne,F.name),tone:"error"})}finally{x(null)}}async function me(F){if(!(F.id===ee||g||S)){if(y!==F.id){A(F.id);return}C(F.id);try{await Bn.update({hosts:W.hosts.filter(ne=>ne.id!==F.id)}),dk(F.id),Ji.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 le(){if(L)return;const F=o.trim(),ne=d.trim();if((ne.length>0||p.length>0)&&(!ne||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Se;try{Se=hk(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const ke=await Vk(Se),pe=Bn.getState(),xt=hc(pe);if(ke?pe.hosts.find(se=>{var ue;return se.baseUrl===Se||!!ke.bindingId&&((ue=se.relayTunnel)==null?void 0:ue.bindingId)===ke.bindingId}):pe.hosts.find(se=>se.baseUrl===Se)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const st=uf(xt)&&xt.baseUrl===Se;st&&dc.setActiveDiscoveredHost(null);let E,$;if(ke){const ue=(await Bn.update(Kk(pe,ke,{activate:st,displayName:F}))).hosts.find(we=>rM(we,Se,ke.bindingId??null));if(!ue)throw new Error("relay entry host missing after save");E=ue.id,$=ue.name}else{const se=new Date().toISOString(),ue={id:sM(),name:F||tM(Se),baseUrl:Se,kind:nM(Se),createdAt:se,updatedAt:se,lastConnectedAt:null,lastUserId:null,lastUsername:null};await Bn.update({hosts:[...pe.hosts,ue],activeHostId:st?ue.id:pe.activeHostId}),E=ue.id,$=ue.name}ne&&p&&pk({hostId:E,username:ne,password:p}),We(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:$})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function We(){a(""),u(""),h(""),m("")}if(!K)return null;const Ue=U!=null&&U.user.username?`${K.baseUrl} · ${U.user.username}`:K.baseUrl,Fe=(v==null?void 0:v.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),rt=v?l(wk(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:Ue,"aria-expanded":t,onClick:()=>{n(F=>!F),i(!1)},children:s.jsx(lM,{})}),t&&P&&typeof document<"u"?ur.createPortal(s.jsxs("div",{ref:_,className:"workbench-host-switcher-menu",style:P,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")}),ve.map(F=>{const ne=F.id===ee,re=ne?(U==null?void 0:U.user.username)??F.lastUsername??F.baseUrl:F.lastUsername??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":ne,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ee(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,ne?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"):ne?s.jsx(dp,{}):s.jsx(up,{})})]}),ne?s.jsx("button",{ref:ie,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{V(Se=>!Se),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:()=>{me(F)},children:S===F.id?l("shell.hostDeleteBusy"):y===F.id?l("shell.hostDeleteConfirmAction"):s.jsx(uM,{})})]},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 ne=F.id===ee,re=cf(F.id),Se=ne?(U==null?void 0:U.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":ne,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ee(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")}),ne?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Se})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):ne?s.jsx(dp,{}):s.jsx(up,{})})]}),ne?s.jsx("button",{ref:ie,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{V(ke=>!ke),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:L,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:L,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:L,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:L,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:L,onClick:()=>{i(!1),We()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:L,onClick:()=>{le()},children:L?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(cM,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(eM,{open:j&&v!==null&&ie.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:ie,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:Fe})]}),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:rt})]}),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:oM(G)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:aM(Ne.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function cp(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 tM(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function nM(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 rM(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function sM(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function iM(e,t){return e instanceof Uc?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function oM(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 aM(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 lM(){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 up(){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 dp(){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 cM(){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 uM(){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 ra={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function dM({open:e,onClose:t,onCloned:n}){const{showToast:r}=Wn(),[i,o]=f.useState(!1),[a,c]=f.useState(ra),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[m,g]=f.useState(null),[x,S]=f.useState(""),[C,y]=f.useState(""),[A,j]=f.useState(null),[V,L]=f.useState([]),[I,G]=f.useState([]),q=i||h;f.useEffect(()=>{!e&&!i&&(c(ra),d(!1),g(null))},[i,e]);const P=f.useCallback(async U=>{p(!0),g(null);try{const D=await ff(U);S(D.currentPath),y(D.currentPath),j(D.parentPath),L(D.roots),G(D.items),c(K=>({...K,parentPath:D.currentPath}))}catch(D){S(""),j(null),G([]),g(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function T(){i||(d(!1),g(null),c(ra),t())}function H(){d(!0),P(a.parentPath||void 0)}function _(){i||(d(!1),g(null))}async function ie(U){U.preventDefault(),await P(C)}function Y(){c(U=>({...U,parentPath:x})),d(!1),g(null)}async function W(U){U.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 vk({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(ra),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(Et,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:T,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:U=>void W(U),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:U=>c(D=>({...D,repositoryUrl:U.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:U=>c(D=>({...D,parentPath:U.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:U=>c(D=>({...D,directoryName:U.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:U=>c(D=>({...D,name:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:a.authMode,onChange:U=>c(D=>({...D,authMode:U.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:U=>c(D=>({...D,username:U.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:U=>c(D=>({...D,password:U.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:U=>c(D=>({...D,username:U.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:U=>c(D=>({...D,token:U.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:T,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(Et,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ie,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:U=>y(U.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:q||!A,onClick:()=>{A&&P(A)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:q,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:V.map(U=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:q,onClick:()=>{P(U.path)},children:U.name},U.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")}):I.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:I.map(U=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:q,onClick:()=>{P(U.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:U.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:U.path})]},U.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:q||!x,onClick:Y,children:l("shell.cloneBrowserSubmit")})]})]})]})}const hM="butler:inbox-updated";function nc(){typeof window>"u"||window.dispatchEvent(new Event(hM))}const hp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function db({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:o=!1,composerOpen:a=!0,onComposerOpenChange:c}){const{showToast:u}=Wn(),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState([]),[y,A]=f.useState(null),[j,V]=f.useState(null),[L,I]=f.useState(hp),[G,q]=f.useState(!1),P=f.useMemo(()=>fp(g,t,j),[j,t,g]),T=f.useMemo(()=>G?S:S.filter(D=>D.status!=="closed"),[S,G]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||y||I(D=>{const K=gp({projects:P,currentProjectId:D.projectId,preferredProjectId:j,preferredWorkspaceId:t});return K===D.projectId?D:{...D,projectId:K}})},[e,y,j,t,P]),f.useEffect(()=>{!e||r<=0||(_(void 0,t,i,j),c==null||c(!0))},[e,r,i,c,j,t]);async function H(){h(!0);try{const[D,K,ee]=await Promise.all([ej(),cg(),n?aj(n).catch(()=>null):Promise.resolve(null)]),v=(ee==null?void 0:ee.target.project.id)??null;V(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=j){var ve,N;const Ne=fp(D,K,v);A(null),I({...hp,projectId:gp({projects:Ne,preferredProjectId:v,preferredWorkspaceId:K}),title:((ve=ee==null?void 0:ee.title)==null?void 0:ve.trim())??"",content:((N=ee==null?void 0:ee.content)==null?void 0:N.trim())??""})}function ie(D){A(D.id),I({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 jh(y,{projectId:L.projectId,itemType:L.itemType,title:L.title,content:L.content,status:L.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await tj({projectId:L.projectId,itemType:L.itemType,title:L.title,content:L.content,status:L.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),nc(),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 sj(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),nc(),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 U(D,K){if(D.status!==K){m(!0);try{await jh(D.id,{status:K}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),nc(),await H(),y===D.id&&I(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(pp,{selectableProjects:P,formState:L,saving:p,editingItemId:y,useMobilePicker:!1,onProjectChange:D=>{I(K=>({...K,projectId:D}))},onItemTypeChange:D=>{I(K=>({...K,itemType:D}))},onStatusChange:D=>{I(K=>({...K,status:D}))},onTitleChange:D=>{I(K=>({...K,title:D}))},onContentChange:D=>{I(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:G,onChange:D=>q(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&T.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&T.length>0?s.jsx("div",{className:"workspace-inbox-list",children:T.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:bp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:bM(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:kM(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:()=>{U(D,K)},children:bp(K)},`${D.id}:${K}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>ie(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(Et,{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(pp,{selectableProjects:P,formState:L,saving:p,editingItemId:y,useMobilePicker:!0,onProjectChange:D=>{I(K=>({...K,projectId:D}))},onItemTypeChange:D=>{I(K=>({...K,itemType:D}))},onStatusChange:D=>{I(K=>({...K,status:D}))},onTitleChange:D=>{I(K=>({...K,title:D}))},onContentChange:D=>{I(K=>({...K,content:D}))},onCancel:()=>{c==null||c(!1),_()},onSubmit:Y})})}):null]})}function pp(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(rc,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(rc,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(rc,{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 rc({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(mM,{expanded:o})})]})]}),s.jsx(pM,{open:o,title:e,options:n,selectedValue:t,onClose:()=>a(!1),onSelect:u=>{i(u),a(!1)}})]})}function pM({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:o}){return e?s.jsx(Sk,{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(ru,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(a=>{const c=a.value===r;return s.jsx(pn,{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(gM,{}):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 eL({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(Et,{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(fM,{})}):void 0,onClose:o,children:s.jsx(db,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:a,composerOpen:d,onComposerOpenChange:h})})}function fp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const o=mp(r,t,n),a=mp(i,t,n);return o!==a?a-o:r.name.localeCompare(i.name,"zh-Hans-CN")})}function mp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function gp({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 fM(){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 mM({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 gM(){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 bM(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 bp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function kM(e){return new Date(e).toLocaleString()}function xM({open:e,onClose:t,onImported:n}){const{showToast:r}=Wn(),[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,j]=f.useState([]),[V,L]=f.useState([]),[I,G]=f.useState(!1),[q,P]=f.useState(""),T=i||a||u,H=f.useCallback(async K=>{o(!0),p(null);try{const ee=await ff(K);g(ee.currentPath),S(ee.currentPath),y(ee.parentPath),j(ee.roots),L(ee.items)}catch(ee){g(""),y(null),L([]),p(ee instanceof Error?ee.message:l("shell.importBrowserBrowseFailed"))}finally{o(!1)}},[]);f.useEffect(()=>{if(!e){G(!1),P(""),p(null);return}H(m||void 0)},[H,e]);function _(){T||(G(!1),P(""),t())}async function ie(K){K.preventDefault(),await H(x)}function Y(){!m||T||(P(""),G(!0))}function W(){a||(G(!1),P(""))}async function U(K){K==null||K.preventDefault();const ee=q.trim();if(!(!m||!ee||T)){c(!0),p(null);try{const v=await Nk({parentPath:m,directoryName:ee});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:v.path,tone:"success"}),G(!1),P(""),await H(v.path)}catch(v){const Ne=v instanceof Error?v.message:l("shell.importBrowserCreateDirectoryFailed");p(Ne),r({title:Ne,tone:"error"})}finally{c(!1)}}}async function D(){const K=m.trim();if(!(!K||T)){d(!0),p(null);try{const ee=await Ck({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(Et,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ie,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:T||!C,onClick:()=>{C&&H(C)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:T,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:T||!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:T,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")}):V.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:V.map(K=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:T,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:T,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:T||!m,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(Et,{open:e&&I,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:W,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:K=>void U(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:q,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:K=>P(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||!q.trim(),children:a?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function yM({onOpenSoftwareUpdate:e}){var r;const t=eu(i=>i.platform),n=mk(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 wM(){const e=fk.getState().profile.defaultPermissionMode;return e==="default"?null:e}const Hi="provider-default",ba="__global_default__";function vM(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function sa(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 SM(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:ba,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 CM(e){return e.usesProviderDefault===!0||e.id===Hi}function NM(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function jM({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),j=f.useRef(null),[V,L]=f.useState(null),I=f.useId(),G=f.useCallback(()=>{const q=A.current;if(!q||typeof window>"u")return;const P=q.getBoundingClientRect(),T=q.closest(".workbench-modal-card"),H=T instanceof HTMLElement?T.getBoundingClientRect():null,_=window.innerWidth,ie=window.innerHeight,Y=12,W=8,U=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(P.width*1.9))),Math.min(320,D)),v=Math.min(Math.max(Y,P.left),Math.max(Y,_-ee-Y)),Ne=H?Math.max(Y,H.top+8):Y,ve=H?Math.min(ie-Y,H.bottom-8):ie-Y,N=Math.max(0,P.top-Ne-W),de=Math.max(0,ve-P.bottom-W),Ee=H?!(de>=U||de>N+40):N>=240||N>=de;L({position:"fixed",left:v,width:ee,maxWidth:D,zIndex:1905,top:Ee?void 0:P.bottom+W,bottom:Ee?ie-P.top+W:void 0})},[]);return f.useEffect(()=>{if(!S)return;function q(T){var _,ie;const H=T.target;!((_=y.current)!=null&&_.contains(H))&&!((ie=j.current)!=null&&ie.contains(H))&&C(!1)}function P(T){T.key==="Escape"&&C(!1)}return window.addEventListener("pointerdown",q),window.addEventListener("keydown",P),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),G(),()=>{window.removeEventListener("pointerdown",q),window.removeEventListener("keydown",P),window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[S,G]),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":I,onClick:()=>C(q=>!q),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&&V&&typeof document<"u"?ur.createPortal(s.jsx("div",{ref:j,className:"composer-mac-select-popover composer-deployment-select-popover",style:V,role:"presentation",children:s.jsxs("div",{id:I,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(q=>{const P=q.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":P,className:`composer-deployment-select-option ${P?"is-selected":""}`,onClick:()=>a(q.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:P?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:q.label}),q.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:q.summary}):null]})]},q.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(q=>{const P=q.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":P,className:`composer-deployment-select-option ${P?"is-selected":""}`,disabled:m,onClick:()=>{d(q.value),C(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:P?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:q.label})})]},q.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:x})})]})]})}),document.body):null]})}const hb=144,TM=196,IM=124,EM=72;let kp=null;function MM(e,t){if(typeof document>"u")return t.length*8;kp??(kp=document.createElement("canvas"));const n=kp.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 RM({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const o=e.reduce((a,c)=>Math.max(a,Math.ceil(i(c)+EM)),0);return Math.min(n,Math.max(t,hb,r,o))}function xp({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(j=>j.value===n)??r[0]??null,y=f.useMemo(()=>r.map(j=>j.label),[r]),A=f.useCallback(()=>{const j=p.current;if(!j||typeof window>"u")return;const V=j.getBoundingClientRect(),L=window.innerWidth,I=window.innerHeight,G=12,q=10,P=Math.max(hb,L-G*2),T=a?IM:TM,H=RM({labels:y,triggerWidth:V.width,maxWidth:P,preferredWidth:T,measureText:U=>MM(j,U)}),_=Math.min(Math.max(G,V.left),Math.max(G,L-H-G)),ie=V.top-G,Y=I-V.bottom-G,W=ie>=180||ie>=Y;x({position:"fixed",left:_,width:H,maxWidth:P,zIndex:1905,top:W?void 0:V.bottom+q,bottom:W?I-V.top+q:void 0})},[a,y]);return f.useEffect(()=>{if(!u)return;function j(L){var G,q;const I=L.target;!((G=h.current)!=null&&G.contains(I))&&!((q=m.current)!=null&&q.contains(I))&&d(!1)}function V(L){L.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",j),window.addEventListener("keydown",V),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",V),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(j=>!j),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"?ur.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(j=>{const V=j.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":V,className:`composer-mac-select-option ${V?"is-selected":""}`,onClick:()=>{i(j.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:V?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:j.label})]},j.value)})})}),document.body):null]}):null}const ia=["codex","claude-code","gemini"];function pb(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function yp(e,t){return Array.from({length:t},()=>pb(e))}function sc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:su(t).modelOptions??[]}function wp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function vp(e,t){return Math.max(0,e-t.length)}function AM({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},(E,$)=>$+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}=jk(Mk,e),[m,g]=f.useState(h),[x,S]=f.useState(d),[C,y]=f.useState(()=>yp(o,d)),[A,j]=f.useState({}),[V,L]=f.useState({}),[I,G]=f.useState({}),[q,P]=f.useState({}),[T,H]=f.useState({}),[_,ie]=f.useState(!1),[Y,W]=f.useState(!1),[U,D]=f.useState(null),[K,ee]=f.useState(null),[v,Ne]=f.useState({}),ve=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const E=(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(yp(E,$)),j({}),L({}),G({}),P({}),H({}),ie(!1),W(!1),D(null),ee(null),Ne({}),ve.current=!1,Object.keys(N.current).forEach(se=>{delete N.current[se]})},[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(E=>{var ue;if(E.length===x)return E;if(E.length>x)return E.slice(0,x);const $=E.slice(),se=((ue=E[0])==null?void 0:ue.provider)??o;for(;$.length<x;)$.push(pb(se));return $})},[o,x]),f.useEffect(()=>{u.length!==0&&S(E=>u.includes(E)?E:u[0]??E)},[u]),f.useEffect(()=>{if(!e||!t)return;let E=!1;return ie(!0),Tk(p,t.workspaceId).then($=>{E||j($)}).finally(()=>{E||ie(!1)}),()=>{E=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(ve.current||(ve.current=!0,G(E=>({...E,...Object.fromEntries(ia.map($=>[$,!0]))})),Ik().then(E=>{const $=Object.fromEntries(E.items.map(se=>[se.app,se]));L(Object.fromEntries(ia.map(se=>[se,$[se]??null])))}).catch(()=>{L(Object.fromEntries(ia.map(E=>[E,null])))}).finally(()=>{G(E=>({...E,...Object.fromEntries(ia.map($=>[$,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const E=Array.from(new Set(C.map($=>{const se=sa($.providerConfigMode,$.providerPresetId);return wp($.provider,se.providerConfigMode,se.providerPresetId)}).filter($=>$!==null))).filter($=>q[$]===void 0&&!N.current[$]);if(E.length!==0)for(const $ of E){const[se,ue]=$.split("::");N.current[$]=!0,H(we=>({...we,[$]:!0})),mf(se,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ue}).then(we=>{P(z=>({...z,[$]:we}))}).catch(()=>{P(we=>({...we,[$]:null}))}).finally(()=>{delete N.current[$],H(we=>({...we,[$]:!1}))})}},[q,C,e,t]);const de=f.useMemo(()=>p.filter(E=>{const $=A[E];return $?$.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!de.length)return;const E=de.includes(o)?o:de[0];y($=>{let se=!1;const ue=$.map(we=>de.includes(we.provider)?we:(se=!0,{...we,provider:E,providerConfigMode:"global-default",providerPresetId:null,model:""}));return se?ue:$})},[de,o]);const Ee=f.useMemo(()=>C.map((E,$)=>{var qe;const se=sa(E.providerConfigMode,E.providerPresetId),ue=vM(E.provider),we=ue?V[ue]??null:null,z=SM(we),X=se.providerConfigMode==="cc-switch-preset"?se.providerPresetId??ba:ba,ge=z.find(ft=>ft.value===X)??z[0]??null,ye=wp(E.provider,se.providerConfigMode,se.providerPresetId),De=A[E.provider]??null,He=ye?q[ye]??null:null,lt=(se.providerConfigMode==="cc-switch-preset"?He?sc(He,E.provider):[{id:Hi,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:sc(De,E.provider)).map(ft=>({value:ft.id,label:CM(ft)?l("conversation.modelUseCliDefault"):ft.name})),Ve=E.model.trim()||Hi,tt=((qe=lt.find(ft=>ft.value===Ve))==null?void 0:qe.label)??l("conversation.modelUseCliDefault"),Je=NM(we),nt=ue!==null,pt=ye?T[ye]===!0:!1,Ft=!!(ye&&pt&&He===null);return{index:$,draft:E,supportsDeploymentPicker:nt,showPresetColumn:Je,deploymentPresetOptions:z,selectedPresetValue:X,selectedPresetOption:ge,triggerLabel:Je?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${tt}`:tt,selectedModelValue:Ve,modelOptions:lt,loadingPresets:ue?I[ue]===!0:!1,loadingModels:pt,modelColumnDisabled:Ft}}),[q,V,I,T,C,A]);if(f.useEffect(()=>{e&&y(E=>{let $=!1;const se=E.map((ue,we)=>{const z=Ee[we];if(!z)return ue;let X=ue;const ge=sa(ue.providerConfigMode,ue.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!z.loadingPresets&&!z.deploymentPresetOptions.some(He=>He.value===ge.providerPresetId)&&(X={...X,providerConfigMode:"global-default",providerPresetId:null,model:""},$=!0);const ye=new Set(z.modelOptions.map(He=>He.value)),De=X.model.trim()||Hi;return ye.has(De)||(X={...X,model:""},$=!0),X});return $?se:E})},[Ee,e]),!e||!t)return null;const me=t,le=K?vp(C.length,K.memberFailures):0,We=new Set(K?C.map((E,$)=>$).filter(E=>!(E in v)):[]),Ue=me.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),Fe=me.kind==="session"?`${me.workspaceName} · ${me.sessionTitle}`:me.workspaceName,rt=me.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),F=me.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),ne=me.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),re=me.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Se=U??(me.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!_&&de.length===0?l("shell.parallelCreateNoAvailableProviders"):null),ke={"--parallel-member-columns":String(Math.max(1,Math.min(x,4)))};function pe(E){D(null),ee(null),Ne($=>{if(!(E in $))return $;const se={...$};return delete se[E],se})}function xt(){D(null),ee(null),Ne({})}function Xe(E,$){pe(E);const se=$?"temporary_worktree":"none";y(ue=>ue.map((we,z)=>z===E?{...we,workspaceIsolationMode:se}:we))}async function st(){const E=m.trim();if(!a&&!E){D(l("shell.parallelCreatePromptRequired"));return}if(me.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!de.length){D(l("shell.parallelCreateNoAvailableProviders"));return}W(!0),D(null),ee(null),Ne({});try{const $=wM(),se=C.map(we=>{const z=sa(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}}),ue=me.kind==="group"?await Rk(me.groupId,{permissionMode:$,members:se}):me.kind==="session"?await Ak(me.sessionId,{sharedPrompt:E,permissionMode:$,members:se}):await Pk(me.workspaceId,{sharedPrompt:E,permissionMode:$,members:se});if(ue.memberFailures.length>0){const we=vp(C.length,ue.memberFailures);ee(ue),Ne(Object.fromEntries(ue.memberFailures.map(z=>[z.ordinal,z]))),D(we>0?l("shell.parallelCreatePartialFailure",{successCount:we,failureCount:ue.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ue.memberFailures.length}));return}await r(ue)}catch($){D($ instanceof Error?$.message:l("shell.parallelGroupLoadFailed"))}finally{W(!1)}}return s.jsx(iu,{open:e,title:Ue,description:Fe,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!Y,onClose:n,footer:s.jsxs(Ek,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Se?s.jsx("span",{className:"parallel-create-modal-error",children:Se}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[K&&le>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||_||de.length===0||me.kind==="group"&&c===0,onClick:()=>{st()},children:Y?re:ne})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Ys,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx(Hs,{className:"parallel-create-target-field",label:rt,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:E=>{a||(xt(),g(E.target.value))}})}),s.jsx(Hs,{className:"parallel-create-count-field",label:F,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":F,children:u.map(E=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":x===E,onClick:()=>{xt(),S(E)},children:E},E))})})]})}),s.jsx(Ys,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:ke,children:Ee.map(({draft:E,index:$,supportsDeploymentPicker:se,showPresetColumn:ue,deploymentPresetOptions:we,selectedPresetValue:z,selectedPresetOption:X,triggerLabel:ge,selectedModelValue:ye,modelOptions:De,loadingPresets:He,loadingModels:yt,modelColumnDisabled:lt})=>{var Ft;const Ve=de,tt=Ve.includes(E.provider)?E.provider:"",Je=Ve.length>0?Ve.map(qe=>({value:qe,label:pc(qe,"full")})):[{value:"",label:_?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],nt=sc(A[E.provider]??null,E.provider),pt=nt.length>0?[{value:"",label:((Ft=nt.find(qe=>qe.usesProviderDefault===!0))==null?void 0:Ft.name)??l("shell.parallelPaneModelFallback")},...nt.filter(qe=>qe.usesProviderDefault!==!0).map(qe=>({value:qe.id,label:qe.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":v[$]?"error":We.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:pc(E.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:E.workspaceIsolationMode==="temporary_worktree",onChange:qe=>{Xe($,qe.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")}):We.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(Hs,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${$}-provider`,children:s.jsx(xp,{triggerId:`${i}-member-${$}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:tt,options:Je,disabled:!Ve.length,onChange:qe=>{pe($);const ft=qe;y(_e=>_e.map((Nt,Qe)=>Qe===$?{...Nt,provider:ft,providerConfigMode:"global-default",providerPresetId:null,model:""}:Nt))}})}),s.jsx(Hs,{label:l("shell.parallelCreateModelLabel"),htmlFor:se?void 0:`${i}-member-${$}-model`,children:se?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(jM,{triggerId:`${i}-member-${$}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:we,selectedPresetValue:z,selectedPresetSummary:(X==null?void 0:X.summary)??null,onSelectPreset:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt!==$?_e:qe===ba?{..._e,providerConfigMode:"global-default",providerPresetId:null,model:""}:{..._e,providerConfigMode:"cc-switch-preset",providerPresetId:qe,model:""}))},modelOptions:De,selectedModelValue:ye,onSelectModel:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt===$?{..._e,model:qe===Hi?"":qe}:_e))},loadingPresets:He,loadingModels:yt,modelColumnDisabled:lt,showPresetColumn:ue,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(xp,{triggerId:`${i}-member-${$}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:E.model,options:pt,disabled:!Ve.length||nt.length===0,onChange:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt===$?{..._e,model:qe}:_e))}})})]}),s.jsx(Hs,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${$}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${$}-prompt`,className:"parallel-create-textarea member",rows:2,value:E.memberPrompt,onChange:qe=>{pe($);const ft=qe.target.value;y(_e=>_e.map((Nt,Qe)=>Qe===$?{...Nt,memberPrompt:ft}:Nt))}})}),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 PM=12,LM=180,Sp=72;function DM(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 j=await pf(A.sessionId,null,PM,"backward");return{sessionId:A.sessionId,summary:_M(j.messages)}})).then(A=>{if(y)return;const j={},V={};let L=0;C.forEach(I=>{j[I.sessionId]=!0});for(const I of A){if(I.status==="fulfilled"){V[I.value.sessionId]=I.value.summary;continue}L+=1}d(I=>({...I,...j})),Object.keys(V).length>0&&c(I=>({...I,...V})),g(L>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{y||p(!1)}),()=>{y=!0}},[u,e,n,t]);const x=f.useMemo(()=>{const C=ic(i);return C?t.filter(y=>ic(y.title).includes(C)?!0:ic(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 _M(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(BM).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return qc(n,LM)}function BM(e){var n,r;const t=fb(e.content);return t.length>0?qc(t,Sp):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?qc(e.toolCall.name.trim(),Sp):""}function ic(e){return fb(e).toLocaleLowerCase()}function fb(e){return e.replace(/\s+/g," ").trim()}function qc(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const Cp="workbench.left.width",Np="workbench.right.width",jp="workbench.left.collapsed",Tp="workbench.right.collapsed",oa="workbench.last.session.path",oc="workbench.workspace.selected.id",Ip="workbench.notifications.seen_at",OM=280,WM=320,Ep=240,Mp=280,Rp=520,Ap=560,FM=200,ac=20,Bi=40,aa=5,$M=3e4,zM=12,Pp=60*1e3,HM=4e3,Lp=220,Dp=18,UM=6,zs="data-workbench-panel-resizing",la="data-workbench-window-resizing",qM=180,GM="workbench:focus-composer",VM=new Set(["starting","running","reconnecting","stale","unknown"]),KM=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],YM=["--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"],kt={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 mb(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function XM(e){return Math.round(e*100)/100}function JM(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 Rr(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(o=>JM(n,o)).filter(o=>o!==null);return i.length===0?null:i.reduce((o,a)=>o+a,0)/i.length}function Jn(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${XM(n)}px`;r!==i&&e.style.setProperty(t,i)}function Qn(e,t,n,r){return r===null?null:(mb(e,t)??0)+(n-r)}function _p(e){if(e)for(const t of YM)e.style.removeProperty(t)}function QM(e){return VM.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 eR(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<=Lp?r:`${r.slice(0,Lp-3)}...`:null}function tR(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:cs(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:cs(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,j=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:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j});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:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j});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:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j})}for(const y of e.verifications){if(y.status!=="failed")continue;const A=y.projectId?r.get(y.projectId)??null:null,j=((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:j}),body:((C=y.summary)==null?void 0:C.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?cs(A):null,workspaceId:A,createdAt:y.finishedAt||y.startedAt||y.createdAt})}return i.sort((y,A)=>{const j=Bp(y.kind)-Bp(A.kind);return j!==0?j:Dr(A.createdAt)-Dr(y.createdAt)}).slice(0,zM)}function Bp(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 nR(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 Dr(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function rR(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function sR(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function iR(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 oR(e){return e.getBoundingClientRect()}function aR(e,t){return t?Dr(e.createdAt)>Dr(t):!0}function lR(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 Op(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=at(u,e),h=(a=d==null?void 0:d.params.workspaceId)==null?void 0:a.trim();if(h)return h}const r=Xi(e),i=(r==null?void 0:r.sessionId)??null;return!i||!Vb(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function cR(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function lc(e){return e==="mobile"?Zt():"/landing"}function Xi(e){var o,a,c;const t=at("/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=at("/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 uR(e){return!!(at("/sessions",e)||at("/workspaces/:workspaceId/sessions",e))}function Wp(e){return!!Xi(e)}function dR(e){return!!(at("/tools",e)||at("/tools/files",e)||at("/tools/git",e)||at("/tools/processes",e)||at("/workspaces/:workspaceId/tools",e)||at("/workspaces/:workspaceId/tools/files",e)||at("/workspaces/:workspaceId/tools/git",e)||at("/workspaces/:workspaceId/tools/processes",e))}function ka(e){return!!(at("/terminals",e)||at("/workspaces/:workspaceId/terminals",e))}function xa(e){return!!at("/workspaces/:workspaceId/butler",e)}function hR(e,t){return at("/workspaces/:workspaceId/debug",e)?Af(t):at("/workspaces/:workspaceId",e)?rr(t):at("/workspaces/:workspaceId/tools/files",e)||at("/tools/files",e)?Lf(t):at("/workspaces/:workspaceId/tools/git",e)||at("/tools/git",e)?Df(t):at("/workspaces/:workspaceId/tools/processes",e)||at("/tools/processes",e)?_f(t):at("/workspaces/:workspaceId/tools",e)||at("/tools",e)?Pf(t):ka(e)?is(t):xa(e)?cs(t):ii(t)}function pR(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const fR=f.lazy(async()=>({default:(await tu(()=>import("./FileContextPanel-CNOjhsi5.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),mR=f.lazy(async()=>({default:(await tu(()=>import("./GitSidebar-DpC4UhFy.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),gR=f.lazy(async()=>({default:(await tu(()=>import("./TerminalManagerPanel-BEMzisSy.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function bR(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function an(e){return ci(e)}function kR(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function Ks(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(bR):[]}async function gb(e,t){const n=await mf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const bb=f.createContext(null);function Oa(e){return xI(e)}function tr(e){return e.isArchived===!0}function go(e){return Tf(e)}function kb(e,t){return uu(e,{getId:n=>n.sessionId,getParentId:go,compare:(n,r)=>oo(n,r,t)})}function xR(e,t){const n=yR(e);return xb(n,t)}function xb(e,t){const n=wR(e);return uu(n,{getId:r=>r.session.sessionId,getParentId:r=>go(r.session),compare:(r,i)=>oo(r.session,i.session,t)}).map(r=>wb(r))}function yR(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...yb(t.childWorktrees)])}function yb(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...yb(t.children)])}function wR(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 wb(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>wb(n,t+1))}}function Gc(e,t){return{...e,depth:e.depth+t,children:an(e).map(n=>Gc(n,t))}}function Fp(e){return`${e}::parallel-anchor-member`}function $p(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function Vc(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=Vc(an(n),t);if(r)return r}return null}function vR(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=vb(r,n,null);if(i)return i}return null}function vb(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 an(e)){const c=vb(a,t,r);if(c)return c}return null}function Sb(e){return e.filter(t=>{if(tr(t))return!1;const n=go(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&tr(r)?!Oa(t):!0})}function SR(e){return e.flatMap(t=>{const n=kR(t);return n?[n,...Ef(an(t))]:[]})}function CR(e,t,n){var m;const r=an(e),i=ss(r).sort((g,x)=>oo(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:Kc(r,g)}}const a=r.slice().sort((g,x)=>oo(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:Kc(r,p)}}function Kc(e,t){return e.flatMap(n=>{const r=Kc(an(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function ca(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 zp(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 NR(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function Za(e,t="compact"){return pc(e,t)}const jR={position:"relative",zIndex:0},TR={zIndex:1};function Cb(e,t,n,r){const i=[],o=(r==null?void 0:r.trim())||t.name;n&&i.push(o);const a=NR(e);return a&&i.push(a),i.join(" · ")||o}function Hp(e,t){return tT("session-state-indicator",e,t)}function IR(e,t){return Ng(e,t)}function Up(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 qp(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Gp(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function rs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ER(e){try{window.localStorage.removeItem(e)}catch{}}function ua(e,t,n){return Math.max(t,Math.min(n,e))}function da(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function MR(e){const t=window.getComputedStyle(e),n=da(t.getPropertyValue("--desktop-macos-titlebar-height")),r=da(t.getPropertyValue("--workbench-header-min-height")),i=da(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),o=da(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+o+8}function Vp(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+MR(t)}function RR(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function AR(){typeof window>"u"||window.dispatchEvent(new CustomEvent(GM))}function Nb(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=Nb(r.children,n);if(i)return i}return null}function Kp(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=Nb(r.childWorktrees,n);if(i)return i}return null}function jb(e){return e.flatMap(t=>[t.workspace.id,...jb(t.children)])}function PR(e){return new Set(e.flatMap(t=>[t.workspace.id,...jb(t.childWorktrees)]))}function Yp(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 cc(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 Tb(e,t,n,r=new Set){return e.map(i=>{const o=i.sessions.filter(c=>!r.has(c.sessionId)),a=Sb(o);return{workspace:i.workspace,meta:i.meta,visibleSessions:a,archivedSessions:o.filter(c=>tr(c)&&!go(c)),visibleSessionTree:kb(a,n).filter(c=>!t.has(c.item.sessionId)&&!du(an(c),u=>t.has(u.sessionId))),children:Tb(i.children,t,n,r)}})}function Yc(e){return e.flatMap(t=>[t.workspace.id,...Yc(t.children)])}function Ui(e){return e.flatMap(t=>[...t.visibleSessionTree,...Ui(t.children)])}function Ib(e){return e.flatMap(t=>[t,...Ib(t.children)])}function LR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:Ks(n)};const r=Eb(n.childWorktrees,t);if(r)return r}return null}function Eb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=Eb(n.children,t);if(r)return r}return null}function DR(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=Mb(n.childWorktrees,t);if(r)return r}return null}function uc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Rb(n.childWorktrees,t);if(r)return r}return null}function Mb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Mb(n.children,t);if(r)return r}return null}function Rb(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Rb(n.children,t);if(r)return r}return null}function Ab(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=Ab(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function Xp(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.childWorktrees)])}function Pb(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.children)])}function _R(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 BR(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 OR(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||tr(u)===d?u:(n=!0,o=!0,{...u,isArchived:d})}),c=Db(i.childWorktrees??[],t,u=>{u&&(n=!0,o=!0)});return o?{...i,sessions:a,childWorktrees:c}:i});return n?{...e,items:r}:e}function WR(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&tr(r)===i&&e.delete(r.sessionId)}_b(e,n.childWorktrees??[])}}function FR(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Bb(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:mo(c,n)}});return r?i:e}function $R(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=el(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 Jp(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=el(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 Qp(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=el(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 zR(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function HR(e){return e?e.slice(0,8):"--"}function Zp(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function Lb(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Db(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||tr(c)===u?c:(i=!0,{...c,isArchived:u})}),a=Db(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:o,children:a}:r})}function _b(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&tr(r)===i&&e.delete(r.sessionId)}_b(e,n.children)}}function Bb(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:mo(u,n)}}const a=Bb(o.children,t,n);return a.changed?(r=!0,{...o,children:a.nodes}):o});return{nodes:r?i:[...e],changed:r}}function UR(e,t){return e.map(n=>({...n,sessions:mo(n.sessions,t),childWorktrees:Ku(n.childWorktrees,t)}))}function el(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=el(i.children,t);return c!==i.children&&(o=!0,n=!0),o?{...i,sessions:a,children:c}:i});return n?r:[...e]}function Xc(e){return`workspace-management.summary.${e}`}function Ob(e){return`git-sidebar.snapshot.${e}`}function Wb(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 Fb(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 $b(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 zb({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 qR(){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(zb,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function ha(){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(zb,{count:3})]},t))})}function GR({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 ef({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(GR,{side:t,collapsed:n})})}function ei({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 VR(){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 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:"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 YR(){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 Hb(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(YR,{}),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 XR(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(Et,{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:nR(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:lR(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(db,{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 JR(){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 QR(){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 eA(){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 tA(){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 nA(){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 Ub(){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 rA(){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 sA(){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 iA(){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 oA(){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 aA({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 qb({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 lA(){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 cA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"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 uA(){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 dA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"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 hA(){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 pA(){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 fA({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(Et,{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=Vu(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," · ",Za(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 mA=`
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 gA({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:j,onRename:V,onOpenContextMenu:L,onExport:I,onToggleFavorite:G,onArchive:q,onDelete:P,onCloseMenu:T}){var Ue,Fe,rt,F;const H=bn(),_=su(t.provider).supportsSessionDelete===!0,ie=!H.isDesktop&&!H.isMobile,Y=Oa(t)?((Ue=t.subagentLabel)==null?void 0:Ue.trim())||l("shell.subagentBadge"):null,W=Vu(t.title,l("common.unknown")),U=nT(t),D=U?rT("session-activity-badge",t):null,K=Hu(t),ee=yI(t),v=x&&((Fe=t.parallelGroup)==null?void 0:Fe.role)==="anchor"?gx(t.parallelGroup):null,Ne=fx(t.parallelGroup),ve=f.useRef(null),[N,de]=f.useState(null),[Ee,me]=f.useState(!1);f.useEffect(()=>{a||me(!1)},[a]),f.useLayoutEffect(()=>{if(H.isDesktop||!a||!c||typeof window>"u"){de(null);return}const ne=()=>{var Se,ke;const re=GE(c,{width:((Se=ve.current)==null?void 0:Se.offsetWidth)??0,height:((ke=ve.current)==null?void 0:ke.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:_&&P?216:168});de({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 ne(),window.addEventListener("resize",ne),window.addEventListener("scroll",ne,!0),()=>{window.removeEventListener("resize",ne),window.removeEventListener("scroll",ne,!0)}},[c,a,H.isDesktop]);async function le(){await dx([{id:`rename:${t.sessionId}`,label:l("shell.renameAction"),onSelect:V},{id:`export:${t.sessionId}`,label:l("conversation.exportAction"),disabled:p,items:[{id:`export-markdown:${t.sessionId}`,label:l("conversation.exportMarkdownAction"),onSelect:()=>I("md")},{id:`export-pdf:${t.sessionId}`,label:l("conversation.exportPdfAction"),onSelect:()=>I("pdf")},{id:`export-html:${t.sessionId}`,label:l("conversation.exportHtmlAction"),onSelect:()=>I("html")}]},{id:`favorite:${t.sessionId}`,label:o?l("shell.unfavoriteAction"):l("shell.favoriteAction"),onSelect:G},{id:`archive:${t.sessionId}`,label:l("shell.archiveAction"),onSelect:q},..._&&P?[{id:`delete:${t.sessionId}`,label:l("shell.deleteSessionAction"),onSelect:P}]:[]])}const We=!H.isDesktop&&a&&typeof document<"u"?ur.createPortal(s.jsxs("div",{ref:ve,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":l("shell.sessionMoreAction"),onClick:ne=>ne.stopPropagation(),style:N??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{V(),T()},children:[s.jsx(cA,{}),s.jsx("span",{children:l("shell.renameAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{G(),T()},children:[s.jsx(qb,{active:o}),s.jsx("span",{children:o?l("shell.unfavoriteAction"):l("shell.favoriteAction")})]}),s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{q(),T()},children:[s.jsx(lA,{}),s.jsx("span",{children:l("shell.archiveAction")})]}),ie?s.jsxs("div",{className:"workbench-session-submenu","data-open":Ee,children:[s.jsxs("button",{type:"button",className:"workbench-session-menu-item","aria-haspopup":"menu","aria-expanded":Ee,onClick:()=>{me(ne=>!ne)},children:[s.jsx(uA,{}),s.jsx("span",{children:l("conversation.exportAction")}),s.jsx("span",{className:"workbench-session-submenu-caret","aria-hidden":"true",children:s.jsx(ei,{expanded:Ee})})]}),Ee?s.jsxs("div",{className:"workbench-session-submenu-panel",role:"menu","aria-label":l("conversation.exportAction"),children:[s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{I("md"),T()},children:s.jsx("span",{children:l("conversation.exportMarkdownAction")})}),s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{I("pdf"),T()},children:s.jsx("span",{children:l("conversation.exportPdfAction")})}),s.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:p,onClick:()=>{I("html"),T()},children:s.jsx("span",{children:l("conversation.exportHtmlAction")})})]}):null]}):null,_&&P?s.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{P(),T()},children:[s.jsx(dA,{}),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":Oa(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":((rt=t.parallelGroup)==null?void 0:rt.role)??void 0,"data-parallel-color-token":((F=t.parallelGroup)==null?void 0:F.colorToken)??void 0,style:{...cr(r)??{},...Ne??{}},onContextMenu:ne=>{if(!(S||!h||!L)){if(ne.preventDefault(),ne.stopPropagation(),H.isDesktop){le();return}L({x:ne.clientX,y:ne.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(aA,{selected:C})}):m?s.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:TR,"data-indicator-variant":IR(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:ne=>{ne.stopPropagation(),A==null||A()},children:[s.jsx("span",{className:Hp(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(ei,{expanded:g})})]}):s.jsx("span",{className:Hp(t,{isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),s.jsx("button",{type:"button",className:"workbench-session-link",style:m?jR:void 0,"data-active":i,"aria-pressed":S?C:void 0,onClick:S?y:j,onKeyDown:ne=>{if(S||!h||!L||ne.key!=="ContextMenu"&&!(ne.shiftKey&&ne.key==="F10"))return;if(ne.preventDefault(),ne.stopPropagation(),H.isDesktop){le();return}const re=ne.currentTarget.getBoundingClientRect();L({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:Cb(t,n,u,r.displayName)}),U&&D?s.jsx("span",{className:D,children:U}):null,s.jsx("span",{className:`session-provider-badge ${t.provider}`,children:Za(t.provider)})]})]})})]}),We]})}async function bA(e,t=document){await nf(),await nf(),await Yu(420),await xA(t,1800),e&&await yA(e,1800)}function kA(){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 tf(e){const t={};for(const n of Array.from(e.attributes))n.name!=="style"&&(t[n.name]=n.value);return t}function nf(){return new Promise(e=>{window.requestAnimationFrame(()=>e())})}function Yu(e){return new Promise(t=>{window.setTimeout(t,e)})}async function xA(e,t){const n=e.fonts;!n||typeof n.ready>"u"||await Promise.race([n.ready.catch(()=>{}),Yu(t)])}async function yA(e,t){const n=Array.from(e.querySelectorAll("img"));n.length!==0&&await Promise.race([Promise.all(n.map(r=>vA(r))),Yu(t)])}function wA(){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 vA(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 rf({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:j,onSelectWorkspace:V,onToggleWorkspaceCollapse:L,onStartWorkspaceReorder:I,onPreviewWorkspaceReorder:G,onCommitWorkspaceReorder:q,allowWorkspaceReorder:P,subscribeGitSnapshot:T,requestGitRefresh:H,subscribeWorkspaceManagementSnapshot:_,requestWorkspaceManagementRefresh:ie,onToggleFavoriteSession:Y,onArchiveSession:W,onUnarchiveSession:U,workspaceManagementStateById:D,setWorkspaceManagementStateById:K,unreadNotificationCount:ee,notificationPanelOpen:v,onToggleNotificationPanel:Ne,onClose:ve,onToggleCollapse:N}){var Ii;const de=ao(),Ee=bn(),me=Gf(Ee),{showToast:le}=Wn(),We=Ou(),Ue=eu(k=>k),Fe=((Ii=hc(Ue))==null?void 0:Ii.name)??"",rt=Ue.hosts.length+df(Ue).length>1&&Fe.length>0,[F,ne]=f.useState(!1),[re,Se]=f.useState(!1),[ke,pe]=f.useState(!1),[xt,Xe]=f.useState([]),[st,E]=f.useState(null),[$,se]=f.useState(null),[ue,we]=f.useState(null),[z,X]=f.useState(null),[ge,ye]=f.useState(null),[De,He]=f.useState(null),[yt,lt]=f.useState(null),[Ve,tt]=f.useState(!1),[Je,nt]=f.useState(!1),[pt,Ft]=f.useState(""),[qe,ft]=f.useState(""),[_e,Nt]=f.useState(""),[Qe,Fn]=f.useState({localBranches:[],remoteBranches:[],tags:[]}),[B,ce]=f.useState(!1),[Ce,be]=f.useState(-1),[Te,wt]=f.useState(!1),[$t,zt]=f.useState(!1),[kn,In]=f.useState(null),[tn,ir]=f.useState(null),[hi,pi]=f.useState(null),[pr,bo]=f.useState(null),[xn,Or]=f.useState(null),[Wr,Fr]=f.useState(null),[Ht,Ut]=f.useState(null),[yn,ko]=f.useState(!1),[Dt,wn]=f.useState(null),[mt,$r]=f.useState(null),[fr,mr]=f.useState(null),[cn,gs]=f.useState(null),[zr,Hr]=f.useState(ac),[gr,$n]=f.useState({}),[fi,bs]=f.useState({}),[tl,xo]=f.useState([]),[zn,mi]=f.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[Yt,br]=f.useState(null),[Ur,kr]=f.useState(""),[qr,Xt]=f.useState(null),[St,Jt]=f.useState(null),[Pt,nn]=f.useState([]),[xr,gi]=f.useState(!1),[Gr,Hn]=f.useState({}),[ks,yr]=f.useState(null),Un=f.useRef(null),wr=f.useRef(null),vr=f.useRef(null),qn=f.useRef(null),xs=f.useRef(new Map),Vr=f.useRef(null),ys=f.useRef(null),Sr=f.useRef(null),yo=f.useMemo(()=>new Set(zn.expandedWorkspaceIds),[zn.expandedWorkspaceIds]),wo=f.useMemo(()=>new Set(zn.collapsedWorkspaceIds),[zn.collapsedWorkspaceIds]),Gn=ks!==null,En=P&&Ee.isDesktop&&Ee.ui.osFamily==="macos",Cr=f.useMemo(()=>xR(e,n),[e,n]),$e=f.useMemo(()=>{const k=new Map;for(const M of e){k.set(M.workspace.id,Ks(M).map(O=>Vc(Cr,O.item.sessionId)??O));for(const O of Ib(M.childWorktrees)){const Q=O.visibleSessionTree.map(te=>Vc(Cr,te.item.sessionId)??te).filter(te=>te.item.workspaceId===O.workspace.id&&te.depth===0);k.set(O.workspace.id,Q)}}return k},[Cr,e]),ct=f.useCallback(()=>{wn(null),$r(null)},[]),ut=f.useCallback((k,M)=>{wn(k),$r(M)},[]),it=uc(e,ge)??((yt==null?void 0:yt.id)===ge?yt:null),or=_e.trim().toLowerCase(),Vn=f.useMemo(()=>[{key:"localBranches",label:l("shell.createWorktreeBaseRefLocalGroup"),items:Qe.localBranches},{key:"remoteBranches",label:l("shell.createWorktreeBaseRefRemoteGroup"),items:Qe.remoteBranches},{key:"tags",label:l("shell.createWorktreeBaseRefTagGroup"),items:Qe.tags}].map(M=>({...M,items:M.items.filter(O=>or?O.value.toLowerCase().includes(or):!0)})).filter(M=>M.items.length>0),[or,Qe]),Qt=f.useMemo(()=>Vn.flatMap(k=>k.items),[Vn]),Mn=it?`create-worktree-base-ref-listbox-${it.id}`:"create-worktree-base-ref-listbox",qt=DR(e,pr),Rn=qt?Xn(qt.workspace):null,ws=(qt==null?void 0:qt.archivedSessions)??[],{searchOpen:vs,searchKeyword:bi,filteredSessions:_t,summaryLoading:Mt,summaryError:An,summaryBySessionId:Ss,setSearchKeyword:ki,toggleSearch:xi}=DM(qt!==null,ws),Re=f.useId(),Kn=f.useMemo(()=>LR(e,St),[St,e]),Kr=f.useMemo(()=>Kn?SR(Kn.visibleSessionTree):[],[Kn]),rn=f.useMemo(()=>Kr.map(k=>k.sessionId),[Kr]),Nr=f.useMemo(()=>new Set(rn),[rn]),nl=f.useMemo(()=>new Set(Pt),[Pt]),Yr=rn.length>0&&Pt.length===rn.length;f.useEffect(()=>{K(k=>{const M=Xp(e),O=new Set(M),Q={};Object.entries(k).forEach(([he,Ge])=>{O.has(he)&&(Q[he]=Ge)}),M.forEach(he=>{const Ge=uc(e,he);if(!Ge)return;const vt=wa(Xc(he),Pp),gt=wa(Ob(he),Pp),At=Q[he];let Cn=Fb((At==null?void 0:At.detail)??vt??Wb(Ge),Ge);(gt!=null&&gt.status||gt!=null&&gt.branches)&&(Cn=$b(Cn,{status:gt.status??null,branches:gt.branches??null})),Q[he]={detail:Cn,loading:!1,error:null}});const te=Object.keys(k),Ae=Object.keys(Q);return te.length===Ae.length&&Ae.every(he=>k[he]===Q[he])?k:Q})},[e]);const un=f.useCallback(async k=>{await g(),await Ee.bridge.showNotification(l("shell.importSuccess"),k.path)},[g,Ee.bridge]),jt=f.useCallback(async k=>{await g(),await Ee.bridge.showNotification(l("shell.cloneSuccess"),k.path)},[g,Ee.bridge]);function Xr(k){if(xt.includes(k)){Xe(O=>O.filter(Q=>Q!==k));return}Xe(O=>[...O,k]),T(k),H(k),_(k),ie(k)}async function yi(k,M){if(Gr[k])return;const O=(M==null?void 0:M.trim().toUpperCase())??null;Hn(Q=>({...Q,[k]:!0}));try{await bf(k,{backgroundColor:O}),await g()}catch(Q){le({title:Q instanceof Error?Q.message:l("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{Hn(Q=>({...Q,[k]:!1}))}}async function Cs(){if(!(!st||$)){se(st.id);try{await Hk(st.id),Xe(k=>k.filter(M=>M!==st.id)),K(k=>{const M={...k};return delete M[st.id],M}),E(null),await g(),le({title:l("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(k){le({title:k instanceof Error?k.message:l("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{se(null)}}}f.useEffect(()=>{if(!Dt)return;function k(M){const O=M.target;O instanceof HTMLElement&&O.closest(".workbench-session-menu")||ct()}return window.addEventListener("pointerdown",k),()=>{window.removeEventListener("pointerdown",k)}},[ct,Dt]),f.useEffect(()=>{if(!St){Pt.length>0&&nn([]),Ht&&Ut(null);return}if(!Kn){Jt(null),nn([]),Ut(null);return}nn(k=>Lb(k,Nr))},[Kn,Ht,Nr,St,Pt.length]),f.useEffect(()=>{St&&rn.length===0&&(Jt(null),nn([]),Ut(null))},[rn.length,St]),f.useEffect(()=>{const k=new Set(Xp(e)),M=new Set(e.flatMap(O=>Yc(O.childWorktrees)));Xe(O=>O.filter(Q=>k.has(Q))),mi(O=>({expandedWorkspaceIds:O.expandedWorkspaceIds.filter(Q=>M.has(Q)),collapsedWorkspaceIds:O.collapsedWorkspaceIds.filter(Q=>M.has(Q))})),E(O=>O&&k.has(O.id)?O:null),Hn(O=>Object.fromEntries(Object.entries(O).filter(([Q,te])=>te&&k.has(Q))))},[e]),f.useEffect(()=>{const k=r.findIndex(M=>M.session.sessionId===m);Hr(M=>{const O=ca(r.length,ac,M,k);return O===M?M:O})},[m,r]),f.useEffect(()=>{$n(k=>{const M={};for(const O of e){const Q=Ks(O),te=Q.findIndex(Ae=>Ae.item.sessionId===m||qs([Ae],m??"",he=>he.sessionId).length>0);M[O.workspace.id]=ca(Q.length,Bi,k[O.workspace.id],te);for(const Ae of Ui(O.childWorktrees)){Ae.item.sessionId===m||qs([Ae],m??"",gt=>gt.sessionId).length>0;const he=Ae.item.workspaceId;if(M[he]!==void 0)continue;const Ge=Ui(O.childWorktrees).filter(gt=>gt.item.workspaceId===he&&gt.depth===0),vt=Ge.findIndex(gt=>gt.item.sessionId===m||qs([gt],m??"",At=>At.sessionId).length>0);M[he]=ca(Ge.length,Bi,k[he],vt)}}return zp(k,M)?k:M})},[m,e]),f.useEffect(()=>{bs(k=>{const M={};for(const O of e)for(const Q of[...Ks(O),...Ui(O.childWorktrees)])for(const te of ss(an(Q))){const Ae=an(te);if(Ae.length===0)continue;const he=ss(Ae),Ge=he.findIndex(vt=>vt.item.sessionId===m);M[te.item.sessionId]=ca(he.length,aa,k[te.item.sessionId],Ge)}return zp(k,M)?k:M})},[m,e]),f.useEffect(()=>{if(!m)return;const k=e.flatMap(M=>[...qs(Ks(M),m,O=>O.sessionId),...Ui(M.childWorktrees).flatMap(O=>qs([O],m,Q=>Q.sessionId))]);k.length!==0&&xo(M=>{const O=new Set(M);let Q=!1;for(const te of k)O.has(te)||(O.add(te),Q=!0);return Q?Array.from(O):M})},[m,e]),f.useEffect(()=>{if(!o)return;const k=[];for(const M of e){const O=Ab(M.childWorktrees,o);O.length!==0&&k.push(...O)}k.length>0&&mi(M=>{const O=new Set(M.expandedWorkspaceIds);let Q=!1;for(const te of k)O.has(te)||(O.add(te),Q=!0);return Q?{expandedWorkspaceIds:Array.from(O),collapsedWorkspaceIds:M.collapsedWorkspaceIds}:M})},[o,e]),f.useEffect(()=>{if(!ge){lt(null),tt(!1),nt(!1),Ft(""),ft(""),Nt(""),ce(!1),be(-1),wt(!1),Fn({localBranches:[],remoteBranches:[],tags:[]}),zt(!1),In(null);return}tt(!1),Ft(""),ft(""),Nt(""),ce(!1),be(-1),wt(!1),Fn({localBranches:[],remoteBranches:[],tags:[]}),zt(!1),In(null)},[ge]),f.useEffect(()=>{const k=it;if(!Ve||!k)return;let M=!1;const O=k.id;return zt(!0),In(null),Promise.all([cx(O),ux(O)]).then(([Q,te])=>{M||Fn(iR(Q,te))}).catch(()=>{M||(Fn({localBranches:[],remoteBranches:[],tags:[]}),In(l("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{M||zt(!1)}),()=>{M=!0}},[it==null?void 0:it.id,Ve]),f.useLayoutEffect(()=>{if(!B||!Un.current){ir(null),pi(null);return}const k=()=>{const O=Un.current;if(!O)return;const Q=oR(O);ir({top:Q.bottom+8,left:Q.left,width:Q.width})};k();const M=O=>{var te,Ae;const Q=O.target;Q instanceof Node&&((te=Un.current)!=null&&te.contains(Q)||(Ae=wr.current)!=null&&Ae.contains(Q)||(ce(!1),be(-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)}},[Qt.length,B]),f.useLayoutEffect(()=>{if(!B||!wr.current){pi(null);return}const k=wr.current,M=()=>{const Q=Math.ceil(k.getBoundingClientRect().height);pi(te=>te===Q?te:Q)};if(M(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(()=>{M()});return O.observe(k),()=>{O.disconnect()}},[B,Vn,$t,kn]);function Jr(){ne(!0)}function rl(){Se(!0)}function Pn(k){vn(),ye(null),He({kind:"workspace",workspaceId:k.id,workspaceName:k.name})}function vn(){tt(!1),Ft(""),ft(""),Nt(""),ce(!1),be(-1),wt(!1)}function wi(k,M){const O=k.getBoundingClientRect();return M<=O.top+O.height/2?"before":"after"}function vi(){qn.current!==null&&(cancelAnimationFrame(qn.current),qn.current=null),yr(null)}function jr(k){const M=(k==null?void 0:k.commit)??!1,O=(k==null?void 0:k.preserveClickSuppression)??!1,Q=Vr.current,te=ys.current;Vr.current=null,ys.current=null,te==null||te(),Q!=null&&Q.dragging&&(vi(),M&&q(),!O&&Sr.current===Q.workspaceId&&(Sr.current=null))}function sl(k){if(Sr.current===k){Sr.current=null;return}L(k)}function Ln(k,M){if(M){xs.current.set(k,M);return}xs.current.delete(k)}function vo(k,M){for(const[O,Q]of xs.current){const te=Q.getBoundingClientRect();if(k>=te.left&&k<=te.right&&M>=te.top&&M<=te.bottom)return{workspaceId:O,element:Q}}return null}function Ns(k,M){var Ge;if(!En||k.button!==0)return;jr();const O=k.currentTarget,Q={pointerId:k.pointerId,workspaceId:M,startX:k.clientX,startY:k.clientY,pointerTarget:O,dragging:!1};Vr.current=Q,(Ge=O.setPointerCapture)==null||Ge.call(O,k.pointerId);const te=vt=>{Bt(vt)},Ae=vt=>{ar(vt.pointerId,{commit:!0,preserveClickSuppression:!0})},he=vt=>{ar(vt.pointerId,{commit:!1,preserveClickSuppression:!1})};ys.current=()=>{O.removeEventListener("pointermove",te),O.removeEventListener("pointerup",Ae),O.removeEventListener("pointercancel",he),window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",Ae),window.removeEventListener("pointercancel",he)},O.addEventListener("pointermove",te),O.addEventListener("pointerup",Ae),O.addEventListener("pointercancel",he),window.addEventListener("pointermove",te,{passive:!1}),window.addEventListener("pointerup",Ae),window.addEventListener("pointercancel",he)}function Bt(k){const M=Vr.current;if(!M||M.pointerId!==k.pointerId)return;if(!M.dragging){if(Math.hypot(k.clientX-M.startX,k.clientY-M.startY)<UM)return;M.dragging=!0,Sr.current=M.workspaceId,I(),yr(M.workspaceId)}k.preventDefault();const O=vo(k.clientX,k.clientY);!O||O.workspaceId===M.workspaceId||G(M.workspaceId,O.workspaceId,wi(O.element,k.clientY))}function ar(k,M){var Q,te;const O=Vr.current;!O||O.pointerId!==k||((te=(Q=O.pointerTarget).releasePointerCapture)==null||te.call(Q,k),jr(M))}function Si(k){Bt(k)}function il(k){ar(k.pointerId,{commit:!0,preserveClickSuppression:!0})}function ol(k){ar(k.pointerId,{commit:!1,preserveClickSuppression:!1})}function So(k,M){k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",M),I(),qn.current!==null&&cancelAnimationFrame(qn.current),qn.current=requestAnimationFrame(()=>{qn.current=null,yr(M)})}function al(k,M){const O=ks||k.dataTransfer.getData("text/plain");!O||O===M||(k.preventDefault(),k.dataTransfer.dropEffect="move",G(O,M,wi(k.currentTarget,k.clientY)))}function ll(k){k.preventDefault()}function cl(){vi(),q()}f.useEffect(()=>()=>{jr()},[]);function ul(k){return fi[k]??aa}function dl(k){return tl.includes(k)}function js(k){return gr[k]??Bi}function hl(){Hr(k=>Math.min(r.length,k+ac))}function Co(k,M){$n(O=>({...O,[k]:Math.min(M,(O[k]??Bi)+Bi)}))}function lr(k){bs(M=>({...M,[k]:(M[k]??aa)+aa}))}function Ts(k){xo(M=>M.includes(k)?M.filter(O=>O!==k):[...M,k])}function Qr(k,M){return wo.has(k)?!1:M||yo.has(k)}function No(k,M){const O=!Qr(k,M);mi(Q=>{const te=Q.expandedWorkspaceIds.filter(he=>he!==k),Ae=Q.collapsedWorkspaceIds.filter(he=>he!==k);return O?{expandedWorkspaceIds:[...te,k],collapsedWorkspaceIds:Ae}:{expandedWorkspaceIds:te,collapsedWorkspaceIds:[...Ae,k]}})}function jo(k){const M=ss(Cr).find(O=>O.item.sessionId===k)??null;return M?an(M):[]}function Ci(k,M){const O=Xn(k);return s.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":O.tone,style:cr(O),onClick:()=>bo(k.id),children:[s.jsxs("span",{className:"workbench-archive-folder-main",children:[s.jsx(hA,{}),s.jsx("span",{children:l("shell.archiveFolderLabel")})]}),s.jsx("span",{className:"workbench-section-counter",children:M.length})]})}function Is(){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:[Pt.length,"/",rn.length]}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:fl,children:Yr?l("shell.clearSelectedSessions"):l("shell.selectAllSessions")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Pt.length===0||xr||yn,onClick:()=>{Rs()},children:xr?l("shell.batchArchiving"):l("shell.batchArchiveAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action danger",disabled:Pt.length===0||xr||yn,onClick:Eo,children:yn?l("shell.batchDeleting"):l("shell.batchDeleteAction")}),s.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Io,children:l("common.cancel")})]})}function Ni(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:()=>{V(k),ve==null||ve()},children:s.jsx(oA,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.batchSelectSessions"),title:l("shell.batchSelectSessions"),onClick:()=>pl(k),children:s.jsx(iA,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":l("shell.createSession"),title:l("shell.createSession"),onClick:()=>ye(k),children:s.jsx(JR,{})})]})}function To(k){const M=$e.get(k.workspace.id)??k.visibleSessionTree,Q=new Set(Yc(k.children)).has(o??""),te=k.workspace.id===o||Q,Ae=Gn||!Qr(k.workspace.id,te),he=Xn(k.workspace);return s.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":St===k.workspace.id,"data-worktree-depth":k.meta.depth,"data-workspace-tone":"worktree",style:cr(he),children:[s.jsxs("div",{className:"workbench-workspace-header minimal",children:[s.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":Ae?l("shell.worktreeExpand"):l("shell.worktreeCollapse"),onClick:()=>No(k.workspace.id,te),children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(ei,{expanded:!Ae})}),s.jsxs("span",{children:[s.jsx("strong",{children:k.meta.displayName||k.workspace.name}),s.jsx("span",{className:"session-meta",children:k.meta.branchName})]})]}),St===k.workspace.id?Is():Ni(k.workspace.id)]}),Ae?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-session-list","data-workspace-tone":he.tone,style:cr(he),children:[M.length===0?s.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,js(k.workspace.id)).map(Ge=>Zr({node:Ge,workspace:k.workspace,workspaceContext:he,menuKeyPrefix:`worktree:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:St===k.workspace.id,favoriteEnabled:!0})),M.length>js(k.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Co(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(Ge=>To(Ge))}):null,Ci(k.workspace,k.archivedSessions)]})]},k.workspace.id)}function Zr(k){var Ju,Qu,Zu,ed;const{node:M,fullNode:O=M,branchKey:Q,subagentStateKey:te,workspace:Ae,workspaceContext:he,menuKeyPrefix:Ge,showWorkspaceName:vt,selectionMode:gt,favoriteEnabled:At,showParallelBadge:Cn=!0,forceInactive:Nn=!1,ancestorExpanded:Tr=!1,allowToggle:b=M.depth===0,ancestorHasNextSiblings:w=[],hasNextSibling:R=!1,isFirstSibling:J=!1}=k,Z=M.item,ae=uc(e,Z.workspaceId)??Ae,je=Xn(ae),Me=an(O),Pe=te??Z.sessionId,fe=dl(Pe),Ze=Tr&&an(M).length>0,sn=fe,dn=Ze||sn,Tt=fe&&b,Dn=Ze?M:Tt?CR(M,ul(Pe),n):O,As=dn?an(Dn):[],Kb=ss(Me).length,Yb=ss(As).length,Xb=Tt&&Yb<Kb,Jb=M.depth>0?[...w,R]:[...w],Ps=((Qu=(Ju=Z.parallelGroup)==null?void 0:Ju.groupId)==null?void 0:Qu.trim())||null,kl=((Zu=Z.parallelGroup)==null?void 0:Zu.role)==="anchor"&&Ps?As.filter(et=>{var It;return((It=et.item.parallelGroup)==null?void 0:It.groupId)===Ps}):[],Qb=As.filter(et=>{var It;return((It=et.item.parallelGroup)==null?void 0:It.groupId)!==Ps}),Zb=((ed=Z.parallelGroup)==null?void 0:ed.role)==="anchor"&&Ps?Me.filter(et=>{var It;return((It=et.item.parallelGroup)==null?void 0:It.groupId)===Ps}):[],ek=Me.filter(et=>{var It;return((It=et.item.parallelGroup)==null?void 0:It.groupId)!==Ps}),tk=kl.length>0?Qb:[],Xu=kl.length>0?[$p({session:Z,depth:M.depth+1,children:tk.map(et=>Gc(et,1))}),...kl].map((et,It)=>{const Ei=It===0,nk=$p({session:Z,depth:M.depth+1,children:ek.map(xl=>Gc(xl,1))});return{node:et,fullNode:Ei?nk:Zb.find(xl=>xl.item.sessionId===et.item.sessionId)??et,branchKey:Ei?Fp(Z.sessionId):void 0,subagentStateKey:Ei?Fp(Z.sessionId):void 0,showParallelBadge:!Ei,forceInactive:Ei}}):As.map(et=>({node:et,fullNode:Me.find(It=>It.item.sessionId===et.item.sessionId)??et}));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((et,It)=>et?s.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":It+1}},`${Z.sessionId}:ancestor:${It}`):null),s.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":R,"data-first":J,style:{"--workbench-session-tree-level":M.depth},children:s.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,s.jsx(gA,{menuKey:`${Ge}:${Q??Z.sessionId}`,session:Z,workspace:ae,workspaceContext:je,isActive:!Nn&&Z.sessionId===m,isFavorite:At&&i.has(Z.sessionId),menuOpen:Dt===`${Ge}:${Q??Z.sessionId}`,showWorkspaceName:vt,depth:M.depth,showActions:At,exportDisabled:fr!==null,hasSubagents:b&&Me.length>0,subagentListExpanded:sn,showParallelBadge:Cn,selectionMode:gt,selected:nl.has(Z.sessionId),onToggleSelect:()=>Es(Z.sessionId),onToggleSubagents:()=>Ts(Pe),onOpen:()=>{de(_n(ae.id,Z.sessionId)),ve==null||ve()},onRename:()=>Ro(Z,ae),menuAnchorPoint:Dt===`${Ge}:${Q??Z.sessionId}`?mt:null,onOpenContextMenu:et=>ut(`${Ge}:${Q??Z.sessionId}`,et),onExport:et=>Yn(Z,et),onToggleFavorite:()=>Mo(Z.sessionId),onArchive:()=>Sn(Z.sessionId),onDelete:su(Z.provider).supportsSessionDelete===!0?()=>{ct(),Or({session:Z,workspace:ae})}:void 0,onCloseMenu:ct})]}),Me.length>0&&dn?s.jsxs("div",{className:"workbench-subsession-list",children:[Xu.map((et,It)=>Zr({node:et.node,fullNode:et.fullNode,branchKey:et.branchKey,subagentStateKey:et.subagentStateKey,workspace:Ae,workspaceContext:he,menuKeyPrefix:Ge,showWorkspaceName:vt,selectionMode:gt,favoriteEnabled:At,showParallelBadge:et.showParallelBadge,forceInactive:et.forceInactive,allowToggle:!0,ancestorHasNextSiblings:Jb,hasNextSibling:It<Xu.length-1,isFirstSibling:It===0})),Xb?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>lr(Pe),children:l("shell.subagentExpandMore")}):null]}):null]},Q??Z.sessionId)}function pl(k){ct(),Jt(k),nn([]),Ut(null)}function Io(){Jt(null),nn([]),Ut(null)}function Es(k){nn(M=>zR(M,k))}function fl(){nn(k=>k.length===rn.length?[]:rn)}function Eo(){if(!Kn||Pt.length===0||xr||yn)return;const k=new Map(Kr.map(O=>[O.sessionId,O])),M=Pt.flatMap(O=>{const Q=k.get(O);return Q?[Q]:[]});M.length!==0&&(ct(),Ut({workspace:Kn.workspace,sessions:M}))}async function ml(k,M){we(k),X(M);try{await gb(k,M),ye(null),de(Bf(k,M)),ve==null||ve()}catch(O){le({title:O instanceof Error?O.message:l("shell.startSessionFailed"),tone:"error"})}finally{we(null),X(null)}}async function gl(k){if(k.preventDefault(),!it||Je)return;const M=pt.trim(),O=qe.trim(),Q=_e.trim();if(!M){le({title:l("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!rR(M)){le({title:l("shell.createWorktreeBranchInvalid"),tone:"error"});return}nt(!0);try{const te=await Uk({sourceWorkspaceId:it.id,branchName:M,displayName:O||void 0,baseRef:Q||void 0});lt(te.workspace),V(te.workspace.id),await g(),ye(te.workspace.id),vn(),le({title:l("shell.createWorktreeSucceeded",{name:te.meta.displayName||te.workspace.name}),tone:"success"})}catch(te){le({title:te instanceof Error?te.message:l("shell.createWorktreeFailed"),tone:"error"})}finally{nt(!1)}}async function Mo(k){const M=i.has(k);ct();try{await Y(k),le({title:M?l("shell.favoriteRemoved"):l("shell.favoriteAdded"),tone:"success"})}catch(O){le({title:O instanceof Error?O.message:l("shell.favoriteToggleFailed"),tone:"error"})}}async function Sn(k){ct();try{await W(k),le({title:l("shell.archiveAdded"),tone:"success"})}catch(M){le({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}async function Yn(k,M){var O,Q;if(!fr){ct(),mr(k.sessionId);try{const te=await mE(k.sessionId),Ae=wA();if(M==="md"){const w=Ql(k,"md"),R=gE(k,te.messages);Zh(w,R,"text/markdown;charset=utf-8"),le({title:l("conversation.exportMarkdownSuccess"),tone:"success"});return}ur.flushSync(()=>{gs({session:k,messages:te.messages,shellWidthPx:Ae.shellWidthPx})}),await bA(vr.current);const he=((O=vr.current)==null?void 0:O.innerHTML.trim())??"";if(!he)throw new Error(l("conversation.exportLoadFailed"));const Ge=tf(document.documentElement),vt=document.body?tf(document.body):{},gt=document.documentElement.getAttribute("style"),At=((Q=document.body)==null?void 0:Q.getAttribute("style"))??null,Cn=`${kA()}
244
+ ${mA}`,Nn=xE({title:k.title||l("conversation.titleFallback"),bodyHtml:`<div class="session-export-document-root">${he}</div>`,styleText:Cn,htmlAttributes:Ge,bodyAttributes:vt,htmlStyle:gt,bodyStyle:At});if(M==="html"){const w=Ql(k,"html");Zh(w,Nn,"text/html;charset=utf-8"),le({title:l("conversation.exportHtmlSuccess"),tone:"success"});return}const Tr=Ql(k,"pdf"),b=kE(k,te.messages);bE(Tr,b,"application/pdf"),le({title:l("conversation.exportPdfPreparing"),tone:"success"})}catch(te){le({title:te instanceof Error?te.message:l("conversation.exportLoadFailed"),tone:"error"})}finally{ur.flushSync(()=>{gs(null)}),mr(null)}}}async function Ms(){if(!xn||Wr)return;const{session:k,workspace:M}=xn;Fr(k.sessionId),ct();try{await nd(k.sessionId),nn(O=>O.filter(Q=>Q!==k.sessionId)),Or(null),m===k.sessionId&&de(M.id?ii(M.id):Zt()),await g(),le({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(O){le({title:O instanceof Error?O.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{Fr(null)}}async function Rs(){if(!(Pt.length===0||xr||yn)){ct(),gi(!0);try{const k=[...Pt],M=await Promise.allSettled(k.map(async te=>({sessionId:te,session:await gf(te,!0)}))),O=[];let Q=0;for(const te of M){if(te.status==="fulfilled"){O.push(te.value.sessionId),x(te.value.session);continue}Q+=1}O.length>0&&(await g(),nn(te=>te.filter(Ae=>!O.includes(Ae)))),Q>0?le({title:O.length>0?l("shell.batchArchivePartialFailed"):l("shell.batchArchiveFailed"),tone:"error"}):le({title:l("shell.batchArchiveSuccess"),tone:"success"})}catch(k){le({title:k instanceof Error?k.message:l("shell.batchArchiveFailed"),tone:"error"})}finally{gi(!1)}}}async function es(){if(!Ht||yn)return;const{workspace:k,sessions:M}=Ht,O=M.map(Q=>Q.sessionId);if(O.length===0){Ut(null);return}ko(!0),ct();try{const Q=await Promise.allSettled(O.map(async he=>(await nd(he),he))),te=[];let Ae=0;for(const he of Q){if(he.status==="fulfilled"){te.push(he.value);continue}Ae+=1}if(te.length>0&&(m&&te.includes(m)&&de(k.id?ii(k.id):Zt()),nn(he=>he.filter(Ge=>!te.includes(Ge))),await g()),Ae>0){Ut(he=>{if(!he)return he;const Ge=he.sessions.filter(vt=>!te.includes(vt.sessionId));return Ge.length>0?{...he,sessions:Ge}:null}),le({title:te.length>0?l("shell.batchDeletePartialFailed"):l("shell.batchDeleteFailed"),tone:"error"});return}Ut(null),le({title:l("shell.batchDeleteSuccess"),tone:"success"})}catch(Q){le({title:Q instanceof Error?Q.message:l("shell.batchDeleteFailed"),tone:"error"})}finally{ko(!1)}}async function bl(k){ct();try{await U(k),le({title:l("shell.archiveRestored"),tone:"success"})}catch(M){le({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}function Ro(k,M){ct(),br({session:k,workspace:M}),kr(k.title)}async function Ao(k){if(k.preventDefault(),!Yt)return;const M=Ur.trim();if(M){Xt(Yt.session.sessionId);try{const O=await kf(Yt.session.sessionId,M);x(O),br(null),kr(""),le({title:l("shell.renameSuccess"),tone:"success"})}catch(O){le({title:O instanceof Error?O.message:l("shell.renameFailed"),tone:"error"})}finally{Xt(null)}}}const ji=r.slice(0,zr),Po=ji.length<r.length;function Xn(k){return t[k.id]??Ba(k)}function Ti(k,M,O,Q,te=[]){var w;const Ae=xt.includes(k.id),he=D[k.id]??{detail:null,loading:!1,error:null},Ge=$===k.id,vt=Gr[k.id]===!0,gt=(w=he.detail)!=null&&w.git.remotes.length?he.detail.git.remotes.map(R=>`${R.name}: ${R.url}`).join(" · "):l("shell.manageWorkspaceNoRemote"),At=he.detail?FE(he.detail.codeComposition.items,l("shell.manageWorkspaceCodeCompositionOther")):[],Cn=At.length>0?zE(At):void 0,Nn=Xn(k),Tr=_R(Nn,te),b=[...te,Nn.displayName];return s.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":Nn.tone,"data-worktree-node":Q,style:cr(Nn),children:[s.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":Ae,onClick:()=>Xr(k.id),children:[s.jsxs("span",{className:"workbench-manage-item-heading",children:[s.jsx(ei,{expanded:Ae}),s.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[s.jsx("strong",{children:Nn.displayName}),s.jsx("span",{className:"workbench-manage-item-tree-path",children:Tr})]})]}),s.jsx("span",{className:"workbench-section-counter",children:M})]}),Ae?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:KM.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:vt,"data-selected":k.backgroundColor===R,style:{backgroundColor:R},onClick:()=>{yi(k.id,R)}},R))}),s.jsx("button",{type:"button",className:"ghost-button",disabled:vt||!k.backgroundColor,onClick:()=>{yi(k.id,null)},children:l("shell.manageWorkspaceColorClearAction")})]})]}),s.jsx("p",{className:"workbench-manage-hint",children:k.backgroundColor??l("shell.manageWorkspaceColorUnset")})]}):null,he.loading&&he.detail===null?s.jsx("p",{className:"workbench-manage-status status-text",children:l("shell.manageWorkspaceLoading")}):null,he.error?s.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:he.error}):null,he.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:he.detail.git.commitCount??"--"})]})}),s.jsxs("div",{className:"workbench-manage-detail-block",children:[s.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitInfoLabel")}),he.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:he.detail.git.repoRoot??"--"})]}),s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceCurrentBranch")}),s.jsx("span",{children:he.detail.git.currentBranch??"--"})]}),s.jsxs("div",{className:"workbench-manage-kv-item",children:[s.jsx("span",{children:l("shell.manageWorkspaceRemoteLabel")}),s.jsx("span",{children:gt})]})]}):s.jsx("p",{className:"workbench-section-empty",children:he.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")}),At.length>0?s.jsxs("div",{className:"workbench-manage-type-chart",children:[s.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Cn,"aria-hidden":"true",children:[s.jsx("strong",{className:"workbench-manage-type-chart-total",children:he.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:At.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," · ",WE(R)]})]},R.key))})]}):s.jsx("p",{className:"workbench-section-empty",children:he.detail.codeComposition.error??l("shell.manageWorkspaceNoCodeComposition")}),he.detail.codeComposition.truncated?s.jsx("p",{className:"workbench-manage-hint",children:l("shell.manageWorkspaceCodeTruncated",{count:he.detail.codeComposition.scannedFileCount})}):null]})]}):null,s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{pe(!1),de(Af(k.id))},children:l("shell.workspaceDetailDebugOpenPageAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!$,onClick:()=>E(k),children:Ge?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveAction")})]})]}):null,O.length>0?s.jsx("div",{className:"workbench-manage-children",children:O.map(R=>Ti(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":me,children:s.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":me,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(Ub,{})}):null,s.jsx(ub,{}),s.jsx(Hb,{unreadCount:ee,open:v,onToggle:Ne})]})}),s.jsxs("div",{ref:We,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(tA,{}),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(eA,{}),s.jsx("span",{children:l("shell.terminalsEntry")})]})]}),s.jsx(Jy,{triggerClassName:"workbench-nav-segment-button",triggerLabel:l("shell.skillsEntry"),triggerLeading:s.jsx(nA,{})}),s.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":d,"aria-haspopup":"dialog","aria-expanded":d,onClick:A,children:[s.jsx(QR,{}),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(qb,{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:[ji.map(k=>{const M=jo(k.session.sessionId);return s.jsx("div",{children:Zr({node:{item:k.session,depth:0,children:M},workspace:k.workspace,workspaceContext:Xn(k.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},k.session.sessionId)}),Po?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:hl,children:l("shell.favoriteExpandMore")}):null]})]}):null,h&&e.length===0?s.jsx(qR,{}):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:()=>pe(!0),children:s.jsx(KR,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.importWorkspaceTitle"),title:l("shell.importWorkspaceTitle"),onClick:Jr,children:s.jsx(VR,{})}),s.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.cloneWorkspaceTitle"),title:l("shell.cloneWorkspaceTitle"),onClick:rl,children:s.jsx(rA,{})})]})]}),e.map(k=>{const M=$e.get(k.workspace.id)??Ks(k),O=ks===k.workspace.id,Q=k.isCollapsed||Gn;return s.jsxs("section",{className:"workbench-workspace-group",ref:te=>Ln(k.workspace.id,te),"data-workspace-group-id":k.workspace.id,"data-batch-active":St===k.workspace.id,"data-dragging":O,onDragOver:te=>al(te,k.workspace.id),onDrop:ll,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:P&&!En,onClick:()=>sl(k.workspace.id),onPointerDown:En?te=>Ns(te,k.workspace.id):void 0,onPointerMove:En?Si:void 0,onPointerUp:En?il:void 0,onPointerCancel:En?ol:void 0,onDragStart:P&&!En?te=>So(te,k.workspace.id):void 0,onDragEnd:P&&!En?cl:void 0,"data-reorder-enabled":P?"true":void 0,children:[s.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:s.jsx(ei,{expanded:!Q})}),s.jsx("strong",{children:k.workspace.name})]}),St===k.workspace.id?Is():Ni(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,js(k.workspace.id)).map(te=>Zr({node:te,workspace:k.workspace,workspaceContext:Xn(k.workspace),menuKeyPrefix:`workspace:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:St===k.workspace.id,favoriteEnabled:!0})),M.length>js(k.workspace.id)?s.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Co(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(te=>To(te))}):null,Ci(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:j,title:rt?`${l("settings.title")} · ${Fe}`:l("settings.title"),children:[s.jsx(sA,{}),s.jsx("span",{className:"settings-entry-label",children:l("settings.title")}),rt?s.jsx("span",{className:"workbench-nav-settings-host-badge",title:Fe,children:Fe}):null]}),s.jsx(yM,{onOpenSoftwareUpdate:()=>de("/settings/software-update")})]})}),s.jsx(Et,{open:ke,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:Jr,children:l("shell.manageWorkspaceImportAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:rl,children:l("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{$||pe(!1)},children:e.length>0?s.jsx("div",{className:"workbench-manage-list",children:e.map(k=>Ti(k.workspace,k.visibleSessions.length+k.archivedSessions.length,k.childWorktrees,!1))}):s.jsx("p",{className:"workbench-section-empty",children:l("shell.manageWorkspaceEmpty")})}),s.jsxs(Et,{open:xn!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),onClose:()=>{Wr||Or(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:xn?xn.session.title:""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!Wr,onClick:()=>Or(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Wr,onClick:()=>{Ms()},children:Wr?l("common.loading"):l("shell.deleteSessionAction")})]})]}),s.jsxs(Et,{open:Ht!==null,title:l("shell.batchDeleteConfirmTitle"),description:l("shell.batchDeleteConfirmDescription",{count:`${(Ht==null?void 0:Ht.sessions.length)??0}`}),onClose:()=>{yn||Ut(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:Ht?l("shell.batchDeleteSelectionSummary",{count:`${Ht.sessions.length}`}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:yn,onClick:()=>Ut(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:yn,onClick:()=>{es()},children:yn?l("shell.batchDeleting"):l("shell.batchDeleteAction")})]})]}),s.jsxs(Et,{open:st!==null,title:l("shell.manageWorkspaceRemoveConfirmTitle"),description:l("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{$||E(null)},children:[s.jsx("p",{className:"workbench-section-empty",children:st?l("shell.manageWorkspaceRemoveConfirmTarget",{name:st.name}):""}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!$,onClick:()=>E(null),children:l("common.cancel")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!$,onClick:()=>{Cs()},children:$?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveConfirmAction")})]})]}),s.jsx(dM,{open:re,onClose:()=>Se(!1),onCloned:jt}),s.jsx(xM,{open:F,onClose:()=>ne(!1),onImported:un}),s.jsx(AM,{open:De!==null,source:De,onClose:()=>He(null),onCreated:async k=>{k.members.forEach(O=>{x(O.session)}),xx(k.group.id),await g();const M=k.members.find(O=>O.session.sessionId===k.group.anchorSessionId)??k.members[0]??null;M&&de(_n(bx(M.session,M.sessionIsolatedWorkspace),M.session.sessionId)),He(null),le({title:l("shell.parallelCreateSucceeded"),tone:"success"})}}),s.jsx(Et,{open:it!==null,title:l("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:it?`${l("shell.createSessionTarget")} · ${it.name}`:l("shell.createSessionModalDescription"),headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"primary-button create-session-parallel-trigger",disabled:Je||!!ue||!it,onClick:()=>{it&&Pn(it)},children:l("shell.parallelCreateAction")}),s.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:Je||!!ue,onClick:()=>tt(!0),children:l("shell.createWorktreeAction")})]}),onClose:()=>ye(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(zk,{disabled:!!ue||Je,workspaceId:(it==null?void 0:it.id)??null,pendingProvider:ue===(it==null?void 0:it.id)?z??null:null,onSelect:k=>{it&&ml(it.id,k)}})]})}),s.jsx(Et,{open:it!==null&&Ve,title:l("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:s.jsx("button",{type:"button",className:Te?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":l("shell.createWorktreeHelpAction"),title:l("shell.createWorktreeHelpAction"),"aria-pressed":Te,onClick:()=>wt(k=>!k),children:s.jsx(pA,{})}),description:it?`${l("shell.createWorktreeSectionDescription")} ${l("shell.createSessionTarget")} · ${it.name}`:l("shell.createWorktreeSectionDescription"),onClose:vn,children:s.jsxs("form",{className:"create-session-worktree-form",onSubmit:gl,children:[Te?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:pt,placeholder:l("shell.createWorktreeBranchPlaceholder"),onChange:k=>{const M=k.target.value;sR(M)&&Ft(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:qe,placeholder:l("shell.createWorktreeDisplayNamePlaceholder"),onChange:k=>ft(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:Un,onBlurCapture:k=>{var O,Q;const M=k.relatedTarget;M instanceof Node&&((O=Un.current)!=null&&O.contains(M)||(Q=wr.current)!=null&&Q.contains(M))||(ce(!1),be(-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":B,"aria-controls":Mn,value:_e,placeholder:l("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{ce(!0),be(Qt.length>0?0:-1)},onChange:k=>{Nt(k.target.value),ce(!0),be(Qt.length>0?0:-1)},onKeyDown:k=>{if(k.key==="ArrowDown"){if(k.preventDefault(),!B){ce(!0);return}Qt.length>0&&be(M=>M>=Qt.length-1?0:M+1);return}if(k.key==="ArrowUp"){if(k.preventDefault(),!B){ce(!0);return}Qt.length>0&&be(M=>M<=0?Qt.length-1:M-1);return}if(k.key==="Enter"&&B&&Ce>=0){k.preventDefault();const M=Qt[Ce];M&&(Nt(M.value),ce(!1),be(-1));return}k.key==="Escape"&&ce(!1)}}),s.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":l("shell.createWorktreeBaseRefToggle"),"aria-expanded":B,onClick:()=>{ce(k=>!k),be(!B&&Qt.length>0?0:-1)},children:s.jsx(ei,{expanded:B})})]})}),s.jsx("span",{className:"create-session-worktree-field-hint",children:$t?l("shell.createWorktreeBaseRefLoading"):kn||l("shell.createWorktreeBaseRefHint",{localCount:Qe.localBranches.length,remoteCount:Qe.remoteBranches.length,tagCount:Qe.tags.length})})]}),B&&tn&&typeof document<"u"?ur.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":`${tn.top}px`,"--create-worktree-combobox-left":`${tn.left}px`,"--create-worktree-combobox-width":`${tn.width}px`,"--create-worktree-combobox-height":`${hi??0}px`}}),s.jsx("div",{ref:wr,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${tn.top}px`,"--create-worktree-combobox-left":`${tn.left}px`,"--create-worktree-combobox-width":`${tn.width}px`},children:$t?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefLoading")}):kn?s.jsx("p",{className:"create-session-worktree-combobox-empty",children:kn}):Vn.length>0?s.jsx("div",{id:Mn,className:"create-session-worktree-combobox-list",role:"listbox",children:Vn.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=Qt.findIndex(Ae=>Ae.value===M.value),Q=_e===M.value,te=Ce===O;return s.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":Q,"data-highlighted":te,onMouseDown:Ae=>Ae.preventDefault(),onMouseEnter:()=>be(O),onClick:()=>{Nt(M.value),ce(!1),be(-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:Je,onClick:vn,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:Je,children:Je?l("shell.createWorktreeSubmitting"):l("shell.createWorktreeSubmit")})]})]})}),s.jsxs(Et,{open:qt!==null,title:l("shell.archiveModalTitle"),description:qt?`${qt.workspace.name} · ${l("shell.archiveModalDescription")}`:l("shell.archiveModalDescription"),headerActions:ws.length>0?s.jsx("button",{type:"button",className:"secondary-button","aria-pressed":vs,onClick:xi,children:l("shell.archiveSearchAction")}):void 0,onClose:()=>bo(null),children:[vs?s.jsxs("div",{className:"workbench-archive-search-panel",children:[s.jsx(Hs,{label:l("shell.archiveSearchLabel"),htmlFor:Re,children:s.jsx("input",{id:Re,type:"text",value:bi,placeholder:l("shell.archiveSearchPlaceholder"),autoFocus:!0,onChange:k=>ki(k.target.value)})}),Mt?s.jsx("p",{className:"workbench-archive-search-status",children:l("shell.archiveSearchSummaryLoading")}):null,An?s.jsx("p",{className:"workbench-archive-search-status status-text","data-tone":"warning",children:An}):null]}):null,qt&&_t.length>0?s.jsx(ru,{className:"workbench-archive-list","data-workspace-tone":(Rn==null?void 0:Rn.tone)??"root",style:cr(Rn),children:_t.map(k=>{var Q;const M=Vu(k.title,l("common.unknown")),O=((Q=Ss[k.sessionId])==null?void 0:Q.trim())??"";return s.jsx(pn,{className:"workbench-archive-item","data-workspace-tone":(Rn==null?void 0:Rn.tone)??"root",style:cr(Rn),trailing:s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>bl(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:[Cb(k,qt.workspace,!1)," ·"," ",Za(k.provider)]}),vs&&O?s.jsx("p",{className:"workbench-archive-item-summary",children:O}):null]})},k.sessionId)})}):s.jsx(hf,{title:ws.length>0&&bi.trim().length>0?l("shell.archiveSearchEmpty"):l("shell.archiveEmpty"),compact:!0,className:"workbench-section-empty"})]}),s.jsx(Et,{open:Yt!==null,title:l("shell.renameModalTitle"),description:l("shell.renameModalDescription"),onClose:()=>{qr||(br(null),kr(""))},children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:Ao,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.renameInputLabel")}),s.jsx("input",{type:"text",value:Ur,placeholder:l("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:k=>kr(k.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:!!qr,onClick:()=>{br(null),kr("")},children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!Ur.trim()||qr===(Yt==null?void 0:Yt.session.sessionId),children:qr===(Yt==null?void 0:Yt.session.sessionId)?l("shell.renamingSession"):l("common.save")})]})]})}),cn?s.jsx("div",{ref:vr,className:"session-export-print-root","aria-hidden":"true",children:s.jsxs("div",{className:"session-export-print-shell",style:cn.shellWidthPx?{width:`${cn.shellWidthPx}px`,maxWidth:"100%"}:void 0,children:[s.jsxs("header",{className:"session-export-print-header",children:[s.jsx("h1",{children:cn.session.title||l("conversation.titleFallback")}),s.jsx("p",{children:l("conversation.exportAction")})]}),s.jsx(pI,{sessionId:cn.session.sessionId,messages:cn.messages,provider:cn.session.provider})]})}):null]})}function sf({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=bn(),C=Gf(S),{showToast:y}=Wn(),A=Ou(),j=f.useRef(null),V=f.useRef(null),L=S.isDesktop&&S.bridge.supported,I=L&&!!a,G=L&&!!x,q=L&&!!x,P=typeof globalThis<"u"&&"PointerEvent"in globalThis,T=f.useCallback(async(W,U,D)=>{if(W==="files"){const ee=await Sy(S,{workspaceId:U,sessionId:D,focusOwner:"file-context-panel"});ee.ok||y({title:ee.detail??l("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(W==="git"){const ee=await Cy(S,{workspaceId:U,focusOwner:"git-sidebar"});ee.ok||y({title:ee.detail??l("git.openExternalFailed"),tone:"error"});return}const K=await Ny(S,{workspaceId:U,focusOwner:"terminal-manager-panel"});K.ok||y({title:K.detail??l("terminalManager.openExternalFailed"),tone:"error"})},[S,y]),H=f.useCallback((W,U)=>{if(W.button!==0||!L)return;const D=U==="files"?a:U==="git"||U==="terminals"?x:null;if(!D)return;const K=U==="files"?o:null;j.current={tab:U,startX:W.clientX,startY:W.clientY,workspaceId:D,sessionId:K,detached:!1,preview:null};const ee=N=>{var le;const de=j.current;if(!de)return;const Ee=Math.abs(N.clientX-de.startX),me=Math.abs(N.clientY-de.startY);!de.detached&&Math.max(Ee,me)<Dp||(de.detached||(de.detached=!0,V.current=de.tab,de.preview=vd({title:de.tab==="files"?l("shell.filesEntry"):de.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:N.clientX,y:N.clientY})),(le=de.preview)==null||le.updatePosition(N.clientX,N.clientY))},v=N=>{var Ee;const de=(Ee=j.current)==null?void 0:Ee.preview;N&&(de==null||de.cancel()),window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",Ne),window.removeEventListener("blur",ve),j.current=null},Ne=async()=>{var de;const N=j.current;v(!1),N!=null&&N.detached&&(await((de=N.preview)==null?void 0:de.complete()),await T(N.tab,N.workspaceId,N.sessionId))},ve=()=>{v(!0)};window.addEventListener("mousemove",ee),window.addEventListener("mouseup",Ne),window.addEventListener("blur",ve)},[a,L,o,x,T]),_=f.useCallback((W,U)=>{if(W.button!==0||!L)return;const D=U==="files"?a:U==="git"||U==="terminals"?x:null;if(!D)return;const K=W.currentTarget,ee=W.pointerId;K.setPointerCapture(ee);const v=U==="files"?o:null;j.current={tab:U,startX:W.clientX,startY:W.clientY,workspaceId:D,sessionId:v,detached:!1,preview:null};const Ne=me=>{var Fe;if(me.pointerId!==ee)return;const le=j.current;if(!le)return;const We=Math.abs(me.clientX-le.startX),Ue=Math.abs(me.clientY-le.startY);!le.detached&&Math.max(We,Ue)<Dp||(le.detached||(le.detached=!0,V.current=le.tab,le.preview=vd({title:le.tab==="files"?l("shell.filesEntry"):le.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:me.clientX,y:me.clientY})),(Fe=le.preview)==null||Fe.updatePosition(me.clientX,me.clientY))},ve=me=>{var We;const le=(We=j.current)==null?void 0:We.preview;me&&(le==null||le.cancel()),K.removeEventListener("pointermove",Ne),K.removeEventListener("pointerup",N),K.removeEventListener("pointercancel",de),K.removeEventListener("lostpointercapture",de),window.removeEventListener("blur",Ee),j.current=null,K.hasPointerCapture(ee)&&K.releasePointerCapture(ee)},N=async me=>{var We;if(me.pointerId!==ee)return;const le=j.current;ve(!1),le!=null&&le.detached&&(await((We=le.preview)==null?void 0:We.complete()),await T(le.tab,le.workspaceId,le.sessionId))},de=me=>{me.pointerId===ee&&ve(!0)},Ee=()=>{ve(!0)};K.addEventListener("pointermove",Ne),K.addEventListener("pointerup",N),K.addEventListener("pointercancel",de),K.addEventListener("lostpointercapture",de),window.addEventListener("blur",Ee)},[a,L,o,x,T]),ie=f.useCallback(W=>{if(V.current===W){V.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:cr(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(Ub,{})}):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:I?"拖拽标签到独立窗口":void 0,onPointerDown:W=>_(W,"files"),onMouseDown:P?void 0:W=>H(W,"files"),onClick:()=>ie("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:G?"拖拽标签到独立窗口":void 0,onPointerDown:W=>_(W,"git"),onMouseDown:P?void 0:W=>H(W,"git"),onClick:()=>ie("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:q?"拖拽标签到独立窗口":void 0,onPointerDown:W=>_(W,"terminals"),onMouseDown:P?void 0:W=>H(W,"terminals"),onClick:()=>ie("terminals"),children:l("shell.terminalManagerEntry")})]})]}),s.jsxs("div",{ref:A,className:"workbench-auxiliary-body","data-scrollbar-autohide":"true",children:[e?null:s.jsx(ha,{}),e&&t==="git"&&d?s.jsx(SA,{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(ha,{}),children:s.jsx(fR,{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(ha,{}),children:s.jsx(mR,{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(ha,{}),children:s.jsx(gR,{currentWorkspaceId:a,navigationGroups:c})}):null]})]})}function SA({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",j=(c==null?void 0:c.targetWorkspace.name)??l("common.unknown"),V=(c==null?void 0:c.sourceBranchName)??e.branchName,L=(c==null?void 0:c.targetBranchName)??e.baseRef??l("common.unknown"),I=NA({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}),G=u?l("shell.worktreeMergePreviewLoading"):d?l("shell.worktreeMergeApplying"):h?l("shell.worktreeCleanupRunning"):S?l("shell.worktreeMergeAlreadyMerged"):c!=null&&c.canMerge?l("shell.worktreeMergeReady"):p?l("shell.worktreeMergeBlocked"):l("shell.worktreeMergePreviewIdle"),q=[l("shell.worktreeMergeCurrentBranch",{branch:V}),l("shell.worktreeMergeParentBranch",{branch:L}),l("shell.worktreeMergeTargetWorkspace",{name:j}),c?l("shell.worktreeMergeAheadBehind",{ahead:c.ahead,behind:c.behind}):l("shell.worktreeMergeAheadBehindPending"),c!=null&&c.mergeBaseCommit?l("shell.worktreeMergeBaseCommit",{commit:HR(c.mergeBaseCommit)}):null].filter(_=>!!_),P=`worktree-merge-panel-details-${e.workspaceId}`,T=o?l("shell.worktreeMergeCollapseDetails"):l("shell.worktreeMergeExpandDetails"),H=CA({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":T,"aria-expanded":o,"aria-controls":P,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:T})]}),o?s.jsxs("div",{id:P,className:"worktree-merge-panel-details",children:[s.jsx("div",{className:"worktree-merge-panel-detail-head",children:s.jsx("span",{className:"worktree-merge-panel-status","data-state":A,children:G})}),s.jsx("div",{className:"worktree-merge-panel-meta",children:q.map(_=>s.jsx("span",{children:_},_))}),p?s.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":l("shell.worktreeMergeChecklistTitle"),children:I.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 CA(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 NA(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 tL({shellMode:e="desktop"}){var Xn,Ti,Ii,k,M,O,Q,te,Ae,he,Ge,vt,gt,At,Cn,Nn,Tr;const t=Fa(),n=ao(),r=bn(),{showToast:i}=Wn(),o=Do(b=>b.sessionDisplaySortMode),a=Do(b=>b.notificationPreferences.notifyOnPermissionRequest),c=Do(b=>b.notificationPreferences.notifyOnSessionCompleted),u=Do(b=>b.notificationPreferences.notifyOnSessionFailed),d=f.useRef(KE(ab)),h=f.useRef(0),p=f.useRef((((Ti=(Xn=d.current)==null?void 0:Xn.items)==null?void 0:Ti.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),j=f.useRef(new Set),V=f.useRef(new Set),L=f.useRef(new Set),I=f.useRef(null),G=f.useRef(null),q=f.useRef(null),P=f.useRef(null),T=f.useRef(null),H=f.useRef(null),_=f.useRef(null),ie=f.useRef(null),Y=f.useRef(0),W=f.useRef(0),U=f.useRef(i),D=f.useRef(r.bridge),K=f.useRef(null),ee=f.useRef(0),v=f.useRef(0),Ne=f.useRef(null),ve=f.useRef(null),N=f.useRef(null),de=f.useRef(!1),Ee=f.useRef(!1),me=f.useRef(!1),le=f.useRef(new Map),We=f.useRef(!1),Ue=f.useRef(new Map),Fe=f.useRef(""),rt=f.useRef([]),F=f.useRef(o),ne=f.useRef(null),[re,Se]=f.useState(()=>lp(d.current,o)),ke=f.useRef(re),[pe,xt]=f.useState(()=>{var b,w;return(((w=(b=d.current)==null?void 0:b.items)==null?void 0:w.length)??0)===0}),[Xe,st]=f.useState(null),[E,$]=f.useState(()=>ua(Up(Cp,OM),Ep,Rp)),[se,ue]=f.useState(()=>ua(Up(Np,WM),Mp,Ap)),[we,z]=f.useState(()=>qp(jp,!1)),[X,ge]=f.useState(()=>qp(Tp,!1)),[ye,De]=f.useState(null),[He,yt]=f.useState(null),[lt,Ve]=f.useState(()=>Yp(d.current)),[tt,Je]=f.useState(()=>Gp(oc)),[nt,pt]=f.useState(!1),[Ft,qe]=f.useState("files"),[ft,_e]=f.useState(!1),[Nt,Qe]=f.useState(!1),[Fn,B]=f.useState(null),[ce,Ce]=f.useState({}),[be,Te]=f.useState(!1),[wt,$t]=f.useState("sessions"),[zt,kn]=f.useState(""),[In,tn]=f.useState(""),[ir,hi]=f.useState(!1),[pi,pr]=f.useState(null),[bo,xn]=f.useState([]),[Or,Wr]=f.useState(null),[Fr,Ht]=f.useState({}),Ut=qf(r),yn=f.useCallback(b=>{if(Ut)return;const w=K.current;w&&(!kc(r,b.button,b.target)||!Vp(b.clientY,w)||py({platform:r,button:b.button,target:b.target,clientX:b.clientX,clientY:b.clientY}))},[r,Ut]),ko=f.useCallback(b=>{if(Ut)return;const w=K.current;w&&(!kc(r,b.button,b.target)||!Vp(b.clientY,w)||r.bridge.setWindowState("toggle-zoom"))},[r,Ut]),[Dt,wn]=f.useState({}),[mt,$r]=f.useState(null),[fr,mr]=f.useState(!1),[cn,gs]=f.useState([]),[zr,Hr]=f.useState(()=>new Set),[gr,$n]=f.useState(!1),[fi,bs]=f.useState(!1),[tl,xo]=f.useState(0),[zn,mi]=f.useState(()=>Gp(Ip)),Yt=e==="desktop"&&r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar,{theme:br}=gk();f.useEffect(()=>{U.current=i},[i]),f.useEffect(()=>{if(typeof document>"u")return;const{documentElement:b,body:w}=document,R=document.getElementById("root");if(!Yt){b.removeAttribute("data-workbench-macos-vibrancy"),w==null||w.removeAttribute("data-workbench-macos-vibrancy");return}const J=b.style.background,Z=(w==null?void 0:w.style.background)??"",ae=(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=J,w&&(w.style.background=Z),R instanceof HTMLElement&&(R.style.background=ae)}},[Yt]),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(!He){b.removeAttribute(zs),w==null||w.removeAttribute(zs);return}const R=b.style.cursor,J=(w==null?void 0:w.style.cursor)??"";return b.setAttribute(zs,He),w==null||w.setAttribute(zs,He),b.style.cursor="col-resize",w==null||w.style.setProperty("cursor","col-resize"),(Z=window.getSelection())==null||Z.removeAllRanges(),()=>{b.removeAttribute(zs),w==null||w.removeAttribute(zs),b.style.cursor=R,w&&(w.style.cursor=J)}},[He]),f.useEffect(()=>{F.current=o,Se(b=>UR(b,o))},[o]),f.useEffect(()=>{ke.current=re},[re]),f.useEffect(()=>{D.current=r.bridge},[r.bridge]),f.useEffect(()=>{ee.current=E},[E]),f.useEffect(()=>{v.current=se},[se]),f.useEffect(()=>()=>{Ne.current!==null&&window.cancelAnimationFrame(Ne.current)},[]);const Ur=f.useCallback(async()=>{const b=Y.current+1;Y.current=b;try{const w=await QN();if(b!==Y.current)return;if(!w.initialized){gs([]),Hr(new Set);return}const[R,J,Z,ae]=await Promise.all([ZN(),nj(),cg(),ij()]);if(b!==Y.current)return;gs(tR(R.overview,J.items,Z.items)),Hr(new Set(ae.items.map(je=>je.notificationId)))}catch{if(b!==Y.current)return;gs([]),Hr(new Set)}},[]),kr=f.useCallback(b=>{const w=b.map(R=>R.createdAt).sort((R,J)=>Dr(J)-Dr(R))[0]??null;w&&mi(R=>R&&Dr(R)>=Dr(w)?R:w)},[]);f.useEffect(()=>{zn&&rs(Ip,zn)},[zn]),f.useEffect(()=>{Ur();const b=window.setInterval(()=>{Ur()},$M);return()=>{window.clearInterval(b)}},[Ur]),f.useEffect(()=>{Ot("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),f.useEffect(()=>{var b,w;Ot("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,J)=>R+J.sessions.length,0))??0})},[]);function qr(b){var J;if(!b||!Array.isArray(b.items))return;WR(m.current,b);const w=OR(b,m.current);Ot("workbench.apply_snapshot",{workspaceCount:w.items.length,sessionCount:w.items.reduce((Z,ae)=>Z+ae.sessions.length,0),currentSessionId:((J=Xi(t.pathname))==null?void 0:J.sessionId)??null});const R=lp(w,F.current);d.current=w,na(w),ke.current=R,Se(R),Ve(Yp(w)),st(null)}const Xt=f.useCallback(async()=>{const b=h.current+1;h.current=b,xt(w=>w||!p.current),Ot("workbench.refresh_navigation.start",{requestId:b,hasNavigationData:p.current});try{const w=await Lk();if(b!==h.current){Ot("workbench.refresh_navigation.stale",{requestId:b});return}qr(w)}catch(w){if(b!==h.current)return;st(w instanceof Error?w.message:l("shell.navigationLoadFailed")),U.current({title:w instanceof Error?w.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{Ot("workbench.refresh_navigation.end",{requestId:b,success:b===h.current}),b===h.current&&xt(!1)}},[]),St=f.useCallback(b=>{Se(w=>{const R=FR(w,b,F.current);return ke.current=R,R})},[]),Jt=f.useCallback(()=>{var b;(b=y.current)==null||b.requestRefresh()},[]),Pt=f.useCallback((b,w)=>{n(_n(b,w))},[n]),nn=f.useCallback((b,w,R)=>{var J;I.current={workspaceId:b,paths:w,knownRevisionByPath:R==null?void 0:R.knownRevisionByPath},(J=y.current)==null||J.subscribeFileTree(b,w,R)},[]),xr=f.useCallback((b,w,R)=>{var J;G.current={workspaceId:b,paths:w,knownRevisionByPath:R==null?void 0:R.knownRevisionByPath},(J=y.current)==null||J.requestFileTreeRefresh(b,w,R)},[]),gi=f.useCallback(b=>(A.current.add(b),()=>{A.current.delete(b)}),[]),Gr=f.useCallback((b,w)=>{var R;q.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.subscribeGit(b,w)},[]),Hn=f.useCallback((b,w)=>{var R;P.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.requestGitRefresh(b,w)},[]),ks=f.useCallback(b=>(j.current.add(b),()=>{j.current.delete(b)}),[]),yr=f.useCallback((b,w)=>{var R;T.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.subscribeWorkspaceManagement(b,w)},[]),Un=f.useCallback((b,w)=>{var R;H.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},Ht(J=>{var Z;return{...J,[b]:{detail:((Z=J[b])==null?void 0:Z.detail)??null,loading:!0,error:null}}}),(R=y.current)==null||R.requestWorkspaceManagementRefresh(b,w)},[]),wr=f.useCallback(b=>(V.current.add(b),()=>{V.current.delete(b)}),[]),vr=f.useCallback(async(b,w=!1)=>{const R=b.trim();if(!R)return;let J=!0;if(wn(Z=>{const ae=Z[R];return!w&&(ae!=null&&ae.loading)?(J=!1,Z):{...Z,[R]:{preview:(ae==null?void 0:ae.preview)??null,loading:!0,applying:(ae==null?void 0:ae.applying)??!1,cleaning:(ae==null?void 0:ae.cleaning)??!1,error:null}}}),!!J)try{const Z=await Dk(R);wn(ae=>{var je,Me;return{...ae,[R]:{preview:Z,loading:!1,applying:((je=ae[R])==null?void 0:je.applying)??!1,cleaning:((Me=ae[R])==null?void 0:Me.cleaning)??!1,error:null}}})}catch(Z){wn(ae=>{var je,Me,Pe;return{...ae,[R]:{preview:((je=ae[R])==null?void 0:je.preview)??null,loading:!1,applying:((Me=ae[R])==null?void 0:Me.applying)??!1,cleaning:((Pe=ae[R])==null?void 0:Pe.cleaning)??!1,error:Z instanceof Error?Z.message:l("shell.worktreeMergePreviewFailed")}}})}},[]),qn=f.useCallback(async b=>{const w=b.trim();if(w){wn(R=>{var J,Z;return{...R,[w]:{preview:((J=R[w])==null?void 0:J.preview)??null,loading:!1,applying:!0,cleaning:((Z=R[w])==null?void 0:Z.cleaning)??!1,error:null}}});try{const R=await _k(w);wn(J=>{var Z;return{...J,[w]:{preview:R.preview,loading:!1,applying:!1,cleaning:((Z=J[w])==null?void 0:Z.cleaning)??!1,error:null}}}),Jt(),Xt(),vr(w,!0),Hn(R.preview.targetWorkspace.id),U.current({title:R.applied?l("shell.worktreeMergeApplySuccess"):l("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(R){wn(J=>{var Z,ae;return{...J,[w]:{preview:((Z=J[w])==null?void 0:Z.preview)??null,loading:!1,applying:!1,cleaning:((ae=J[w])==null?void 0:ae.cleaning)??!1,error:R instanceof Error?R.message:l("shell.worktreeMergeApplyFailed")}}}),U.current({title:R instanceof Error?R.message:l("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[vr,Xt,Hn,Jt]),xs=f.useCallback(async b=>{var J,Z;const w=b.workspaceId,R=fr&&((Z=(J=Dt[w])==null?void 0:J.preview)==null?void 0:Z.alreadyMerged)===!0;wn(ae=>{var je;return{...ae,[w]:{preview:((je=ae[w])==null?void 0:je.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const ae=await Bk(w,{deleteBranch:R});if(wn(je=>{var Me;return{...je,[w]:{preview:((Me=je[w])==null?void 0:Me.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),mr(!1),$r(je=>(je==null?void 0:je.workspaceId)===w?null:je),Jt(),await Xt(),n(rr(b.parentWorkspaceId),{replace:!0}),ae.branchDeleted){U.current({title:l("shell.worktreeCleanupDeleteBranchSuccess",{branch:ae.deletedBranchName||b.branchName}),tone:"success"});return}if(ae.branchDeleteRequested){U.current({title:l("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:b.branchName}),description:ae.branchDeleteError||void 0,tone:"warning"});return}U.current({title:l("shell.worktreeCleanupSuccess"),tone:"success"})}catch(ae){wn(je=>{var Me;return{...je,[w]:{preview:((Me=je[w])==null?void 0:Me.preview)??null,loading:!1,applying:!1,cleaning:!1,error:ae instanceof Error?ae.message:l("shell.worktreeCleanupFailed")}}}),U.current({title:ae instanceof Error?ae.message:l("shell.worktreeCleanupFailed"),tone:"error"})}},[fr,n,Xt,Jt,Dt]),Vr=f.useCallback(b=>{mr(!1),$r(b)},[]),ys=f.useCallback((b,w)=>{var R;_.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.subscribeTerminalManager(b,w)},[]),Sr=f.useCallback((b,w)=>{var R;ie.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=y.current)==null||R.requestTerminalManagerRefresh(b,w)},[]),yo=f.useCallback(b=>(L.current.add(b),()=>{L.current.delete(b)}),[]),wo=f.useCallback((b,w)=>{Se(R=>$R(R,b,w??new Date().toISOString()))},[]),Gn=f.useCallback(async(b,w)=>{m.current.set(b,w),Se(R=>Jp(R,b,w));try{const R=await gf(b,w),J=tr(R);J===w?m.current.set(b,J):m.current.delete(b),St(R),Jt(),Xt()}catch(R){throw m.current.delete(b),Se(J=>Jp(J,b,!w)),R}},[Xt,Jt,St]),En=f.useCallback((b,w)=>{Ot("workbench.set_session_workspace",{sessionId:b,workspaceId:w}),Ce(R=>{if(!w){if(!(b in R))return R;const J={...R};return delete J[b],J}return R[b]===w?R:{...R,[b]:w}})},[]);f.useEffect(()=>{p.current=re.length>0},[re]),f.useEffect(()=>{Ot("workbench.navigation_state",{navigationLoading:pe,workspaceCount:re.length,sessionCount:re.reduce((b,w)=>b+w.sessions.length,0)})},[re,pe]),f.useEffect(()=>{C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{var fe;C.current=null,!(g.current||p.current)&&(Ot("workbench.refresh_navigation.ws_fallback_triggered"),(fe=y.current)==null||fe.requestRefresh())},1200);const b=new ay({onConnectionChange:fe=>{fe==="connected"&&Ok(),fe==="reconnect_failed"&&!p.current&&(st(l("shell.navigationLoadFailed")),U.current({id:"workbench-navigation-connection",title:l("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:fe=>{g.current=!0,Ot("workbench.ws_snapshot_received",{workspaceCount:fe.items.length,sessionCount:fe.items.reduce((Ze,sn)=>Ze+sn.sessions.length,0)}),C.current!==null&&(window.clearTimeout(C.current),C.current=null),qr(fe),xt(!1)},onFileTreeSnapshot:fe=>{A.current.forEach(Ze=>Ze(fe))},onGitSnapshot:fe=>{qi(Ob(fe.workspaceId),{revision:fe.revision??null,status:fe.status,history:fe.history,historyTotalCount:fe.historyTotalCount,historyNextCursor:fe.historyNextCursor,branches:fe.branches}),Ht(Ze=>{var Dn;const sn=((Dn=re.find(As=>As.workspace.id===fe.workspaceId))==null?void 0:Dn.workspace)??null;if(!sn)return Ze;const dn=Ze[fe.workspaceId],Tt=$b(Fb((dn==null?void 0:dn.detail)??Wb(sn),sn),fe);return qi(Xc(fe.workspaceId),Tt),{...Ze,[fe.workspaceId]:{detail:Tt,loading:!1,error:null}}}),j.current.forEach(Ze=>Ze(fe))},onWorkspaceManagementSnapshot:fe=>{qi(Xc(fe.workspaceId),fe),Ht(Ze=>({...Ze,[fe.workspaceId]:{detail:fe,loading:!1,error:null}})),V.current.forEach(Ze=>Ze(fe))},onTerminalManagerSnapshot:fe=>{L.current.forEach(Ze=>Ze(fe))},onUnauthorized:()=>{Ji.clear(),n("/login",{replace:!0})}});b.primeWorkbenchSnapshot(d.current),y.current=b;const w=I.current,R=G.current,J=q.current,Z=P.current,ae=T.current,je=H.current,Me=_.current,Pe=ie.current;return w&&b.subscribeFileTree(w.workspaceId,w.paths,{knownRevisionByPath:w.knownRevisionByPath}),J&&b.subscribeGit(J.workspaceId,{knownRevision:J.knownRevision}),ae&&b.subscribeWorkspaceManagement(ae.workspaceId,{knownRevision:ae.knownRevision}),Me&&b.subscribeTerminalManager(Me.workspaceId,{knownRevision:Me.knownRevision}),R&&b.requestFileTreeRefresh(R.workspaceId,R.paths,{knownRevisionByPath:R.knownRevisionByPath}),Z&&b.requestGitRefresh(Z.workspaceId,{knownRevision:Z.knownRevision}),je&&b.requestWorkspaceManagementRefresh(je.workspaceId,{knownRevision:je.knownRevision}),Pe&&b.requestTerminalManagerRefresh(Pe.workspaceId,{knownRevision:Pe.knownRevision}),b.start(),()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null),y.current===b&&(y.current=null),b.close()}},[n]),f.useEffect(()=>{rs(Cp,String(E))},[E]),f.useEffect(()=>{rs(Np,String(se))},[se]),f.useEffect(()=>{rs(jp,String(we))},[we]),f.useEffect(()=>{rs(Tp,String(X))},[X]),f.useEffect(()=>{if(!tt){ER(oc);return}rs(oc,tt)},[tt]),f.useEffect(()=>{if(nt||X)return;const b=window.setTimeout(()=>{pt(!0)},FM);return()=>{window.clearTimeout(b)}},[nt,X]);const Cr=Xi(t.pathname),$e=(Cr==null?void 0:Cr.sessionId)??null,ct=$e?Vb($e):!1,ut=f.useMemo(()=>Sx(re),[re]),it=f.useMemo(()=>xb(ut,o),[ut,o]),or=f.useMemo(()=>PR(re),[re]),Vn=f.useMemo(()=>new Set(lt),[lt]),Qt=f.useMemo(()=>ut.filter(b=>b.session.isFavorite===!0).map(b=>b.session.sessionId),[ut]),Mn=f.useMemo(()=>new Set(Qt),[Qt]),qt=f.useCallback(b=>{const w=cc(b,lt);d.current=w,na(w),ke.current=b,Se(b)},[lt]),Rn=f.useCallback(b=>{const w=!Vn.has(b),R=Zp(lt,b,w),J=cc(re,R);d.current=J,na(J),Ve(R),bf(b,{collapsed:w}).catch(Z=>{const ae=Zp(R,b,!w),je=cc(re,ae);d.current=je,na(je),Ve(ae),U.current({title:Z instanceof Error?Z.message:l("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[Vn,lt,re]),ws=f.useCallback(()=>{ne.current={originalGroups:ke.current}},[]),vs=f.useCallback((b,w,R)=>{const J=ke.current,Z=BR(J,b,w,R);Z!==J&&qt(Z)},[qt]),bi=f.useCallback(()=>{const b=ne.current;ne.current=null;const w=ke.current;b&&(b.originalGroups.length===w.length&&b.originalGroups.every((R,J)=>{var Z;return R.workspace.id===((Z=w[J])==null?void 0:Z.workspace.id)})||Wk({workspaceIds:w.map(R=>R.workspace.id)}).catch(R=>{qt(b.originalGroups),U.current({title:R instanceof Error?R.message:l("shell.workspaceReorderFailed"),tone:"error"})}))},[qt]);f.useEffect(()=>{const b=new Map;if(ut.forEach(({session:w})=>{b.set(w.sessionId,{activityState:w.activityState,completedAt:w.completedAt??null,runningState:w.runningState??null})}),!me.current){me.current=!0,le.current=b;return}ut.forEach(({session:w})=>{var je;if(w.sessionId===$e)return;const R=le.current.get(w.sessionId);if(!R)return;const J=R.activityState!=="completed_unread"&&w.activityState==="completed_unread",Z=((je=w.title)==null?void 0:je.trim())||l("common.unknown");if(c&&J){const Me=l("conversation.backgroundCompletionToastDescription",{title:Z});U.current({id:`workbench-session-completed-${w.sessionId}-${w.completedAt??"unknown"}`,title:l("conversation.backgroundCompletionToastTitle"),description:Me,tone:"success",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Pt(w.workspaceId,w.sessionId)}}),D.current.showNotification(l("conversation.backgroundCompletionToastTitle"),Me)}const ae=R.runningState!=="failed"&&(w.runningState??null)==="failed";if(u&&ae){const Me=eR(w)??l("conversation.runtimeFailed"),Pe=l("conversation.backgroundFailureToastDescription",{title:Z,detail:Me});U.current({id:`workbench-session-failed-${w.sessionId}-${w.updatedAt}`,title:l("conversation.backgroundFailureToastTitle"),description:Pe,tone:"error",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Pt(w.workspaceId,w.sessionId)}}),D.current.showNotification(l("conversation.backgroundFailureToastTitle"),Pe)}}),le.current=b},[$e,ut,c,u,Pt]),f.useEffect(()=>{rt.current=ut.map(b=>b.session).filter(b=>b.sessionId!==$e&&QM(b)).map(b=>{var w;return{sessionId:b.sessionId,workspaceId:b.workspaceId,title:((w=b.title)==null?void 0:w.trim())||l("common.unknown")}})},[$e,ut]),f.useEffect(()=>{let b=!1,w=null;const R=()=>{w=window.setTimeout(()=>{J().finally(()=>{b||R()})},HM)},J=async()=>{var Pe;const Z=rt.current;if(Z.length===0){We.current||(We.current=!0),Fe.current="";return}const ae=new Set(Z.map(fe=>fe.sessionId)),je=await Promise.all(Z.map(async fe=>{try{const Ze=await $k(fe.sessionId);return{session:fe,items:Ze.items}}catch{return{session:fe,items:null}}}));if(b)return;for(const fe of je){if(!fe.items)continue;const Ze=fe.items.filter(Tt=>Tt.status==="pending"),sn=new Set(Ze.map(Tt=>Tt.id)),dn=Ue.current.get(fe.session.sessionId)??new Set;We.current&&Ze.forEach(Tt=>{if(dn.has(Tt.id)||!a)return;const Dn=l("conversation.backgroundPermissionToastDescription",{title:fe.session.title,requestTitle:Tt.title});U.current({id:`workbench-permission-request-${Tt.id}`,title:l("conversation.permissionRequestToastTitle"),description:Dn,tone:"warning",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Pt(fe.session.workspaceId,fe.session.sessionId)}}),D.current.showNotification(l("conversation.permissionRequestToastTitle"),Dn)}),Ue.current.set(fe.session.sessionId,sn)}for(const[fe,Ze]of Ue.current.entries())!ae.has(fe)&&Ze.size===0&&Ue.current.delete(fe);const Me=ZM(Ue.current,ae);We.current&&Me!==Fe.current&&((Pe=y.current)==null||Pe.requestRefresh()),Fe.current=Me,We.current=!0};return J().finally(()=>{b||R()}),()=>{b=!0,w!==null&&window.clearTimeout(w)}},[a,Pt]),f.useEffect(()=>{pe&&re.length===0||(Ve(b=>Lb(b,or)),Je(b=>b&&or.has(b)?b:null))},[or,pe]);const _t=ut.find(b=>b.session.sessionId===$e)??null,Mt=(_t==null?void 0:_t.workspace.id)??($e?ce[$e]??null:null),An=Op(t.pathname,t.search),Ss=An&&or.has(An)?An:null,ki=tt&&or.has(tt)?tt:null,xi=Mt??Ss??ki??null,Re=xi??((Ii=re[0])==null?void 0:Ii.workspace.id)??null,Kn=f.useCallback(b=>{if(b){const w=ut.find(R=>R.workspace.id===b)??null;if(w)return w}return ut[0]??null},[ut]),Kr=f.useCallback(b=>{const w=typeof window>"u"?null:window.localStorage.getItem(oa);if(!w)return null;const R=w.split("?")[0]??w,J=Xi(R);if(!J)return window.localStorage.removeItem(oa),null;const Z=J.sessionId,ae=ut.find(Me=>Me.session.sessionId===Z)??null,je=J.workspaceId??(ae==null?void 0:ae.workspace.id)??null;return ae&&(!b||je===b)?_n(ae.workspace.id,ae.session.sessionId):(window.localStorage.removeItem(oa),null)},[ut]),rn=f.useMemo(()=>cn.filter(b=>!zr.has(b.id)),[zr,cn]),Nr=f.useMemo(()=>rn.filter(b=>aR(b,zn)).length,[rn,zn]);f.useEffect(()=>{gr&&kr(rn)},[rn,kr,gr]);const nl=f.useCallback(b=>{$n(!1),b.routePath&&n(b.routePath)},[n]),Yr=f.useCallback(async(b,w)=>{const R=W.current+1;W.current=R;try{const J=await oj(b,w);if(R!==W.current)return;Hr(Z=>{const ae=new Set(Z);return J.item?ae.add(J.item.notificationId):ae.delete(b),ae})}catch(J){if(R!==W.current)return;U.current({title:l("shell.globalNotificationsArchiveFailed"),description:J instanceof Error?J.message:void 0,tone:"error"})}},[]);f.useEffect(()=>{Mt&&Je(b=>b===Mt?b:Mt)},[Mt]),f.useEffect(()=>{var ae;if(pe)return;const b=((ae=re[0])==null?void 0:ae.workspace.id)??null,w=Ss??b??ki,R=$e&&!ct?Kn(w):null,J=$e&&!ct?Kr(w):null,Z=R?_n(R.workspace.id,R.session.sessionId):null;if(An&&!Ss){n(J??Z??(b?hR(t.pathname,b):lc(e)),{replace:!0});return}if($e&&!ct&&!Mt){n(J??Z??(b?ii(b):lc(e)),{replace:!0});return}},[$e,Kn,ct,t.pathname,n,re,pe,Kr,An,Mt,e,ki,Ss]),f.useEffect(()=>{Ot("workbench.current_workspace_resolved",{currentSessionId:$e,sessionWorkspaceId:Mt,routeWorkspaceId:An,currentWorkspaceId:Re,source:Mt?_t?"navigation":"sessionWorkspaceMap":An?"route":tt?"workspaceSelection":"navigationFallback"})},[_t,$e,Re,An,tt,Mt]);const un=ka(t.pathname)?"terminals":xa(t.pathname)?"butler":"conversation",jt=e==="mobile",Xr=lc(e),yi=f.useMemo(()=>re.map(b=>{const w=Sb(b.sessions),R=new Set(b.sessions.map(J=>J.sessionId));return{workspace:b.workspace,visibleSessions:w,archivedSessions:b.sessions.filter(J=>tr(J)&&!go(J)),visibleSessionTree:kb(w,o).filter(J=>!Mn.has(J.item.sessionId)&&!du(an(J),Z=>Mn.has(Z.sessionId))),childWorktrees:Tb(b.childWorktrees,Mn,o,R),isCollapsed:Vn.has(b.workspace.id)}}),[Vn,Mn,re,o]),Cs=f.useMemo(()=>XE(re),[re]),Jr=f.useMemo(()=>Kp(re,Re),[Re,re]),Pn=(_t?kx(_t.session,_t.session.sessionIsolatedWorkspace):Re)??Re,vn=f.useMemo(()=>Kp(re,Pn),[Pn,re]),wi=f.useMemo(()=>Re?(Jr==null?void 0:Jr.workspace)??re.map(b=>b.workspace).find(b=>b.id===Re)??null:null,[Re,Jr,re]),vi=f.useMemo(()=>Pn?(vn==null?void 0:vn.workspace)??re.map(b=>b.workspace).find(b=>b.id===Pn)??null:null,[Pn,vn,re]),jr=(vn==null?void 0:vn.meta)??null,sl=(Re?Cs[Re]??null:null)??(wi?Ba(wi):null),Ln=(Pn?Cs[Pn]??null:null)??(vi?Ba(vi):sl),vo=jr?Dt[jr.workspaceId]??null:null,Ns=f.useMemo(()=>{var w,R,J;if(!$e)return null;const b=((J=(R=(w=_t==null?void 0:_t.session)==null?void 0:w.parallelGroup)==null?void 0:R.groupId)==null?void 0:J.trim())||null;return b||vR(it,$e)},[(M=(k=_t==null?void 0:_t.session)==null?void 0:k.parallelGroup)==null?void 0:M.groupId,$e,it]),Bt=un==="conversation"&&!!Ns;f.useEffect(()=>{if(typeof window>"u"||!Bt||!Ns){De(null);return}const b=yx(Ns);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 J=window.setTimeout(()=>{De(null)},R);return()=>{window.clearTimeout(J)}},[Ns,Bt]),f.useEffect(()=>{Ot("workbench.info_panel_state",{infoPanelReady:nt,rightCollapsed:X||Bt,currentWorkspaceId:Re,sessionWorkspaceId:Mt,currentSessionId:$e})},[$e,Re,nt,Bt,X,Mt]);const ar=f.useMemo(()=>ut.filter(b=>Mn.has(b.session.sessionId)&&!tr(b.session)&&!Oa(b.session)),[Mn,ut]),Si=t.pathname.startsWith("/settings")?"settings":xa(t.pathname)?"terminals":ka(t.pathname)?"butler":dR(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":uR(t.pathname)||Wp(t.pathname)?"sessions":"workspaces",il=jt&&(Si==="sessions"&&Wp(t.pathname)||xa(t.pathname)),ol=za({isNativeMobile:r.isNativeMobile,viewportClass:r.viewportClass}),So=lo({viewportClass:r.viewportClass,activeEntry:Si,hasNavigationPanel:jt,hasAuxiliaryPanel:jt,preferCompactLayout:ol}),al=jt&&zf(So),ll=jt&&Hf(So),cl=f.useMemo(()=>re.map(b=>b.workspace),[re]),ul=f.useMemo(()=>{const b=zt.trim().toLowerCase();return b?ut.filter(w=>{const R=(w.session.title||"").toLowerCase(),J=w.workspace.name.toLowerCase(),Z=Za(w.session.provider,"full").toLowerCase();return R.includes(b)||J.includes(b)||Z.includes(b)}):[]},[ut,zt]);f.useEffect(()=>{var w;const b=Re??((w=re[0])==null?void 0:w.workspace.id)??"";b&&tn(R=>R&&re.some(Z=>Z.workspace.id===R)?R:b)},[Re,re]),f.useEffect(()=>{$e&&!ct&&Mt&&rs(oa,`${t.pathname}${t.search}`)},[$e,ct,t.pathname,t.search,Mt]),f.useEffect(()=>{if($e&&ct){x.current=`${t.pathname}${t.search}`;return}$e&&!ct&&(x.current=null)},[$e,ct,t.pathname,t.search]),f.useEffect(()=>{jt||(_e(!1),Qe(!1))},[jt]),f.useEffect(()=>{!jt||pe||!cR(t.pathname)||xi||(_e(!1),Qe(!1),n(Xr,{replace:!0}))},[xi,jt,t.pathname,n,pe,Xr]);function dl(){if(jt){_e(!0);return}z(!1)}function js(){if(!Bt){if(lr(),jt){Qe(!0);return}ge(!1)}}function hl(){if(jt){_e(b=>!b);return}z(b=>!b)}function Co(){if(!Bt){if(lr(),jt){Qe(b=>!b);return}ge(b=>!b)}}function lr(){pt(!0)}function Ts(b){if(Je(b),lr(),ka(t.pathname)){const w=is(b);t.pathname!==w&&n(w);return}$e&&Mt!==b&&n(Xr)}const Qr=f.useCallback(async b=>{var J;const w=((J=ut.find(Z=>Z.session.sessionId===b))==null?void 0:J.session)??null,R=(w==null?void 0:w.isFavorite)!==!0;Se(Z=>Qp(Z,b,R));try{const Z=await Fk(b,R);St(Z),Jt()}catch(Z){throw Se(ae=>Qp(ae,b,!R)),Z}},[ut,Jt,St]),No=f.useCallback((b,w)=>{gb(b,w).then(()=>{n(Bf(b,w))}).catch(R=>{i({title:R instanceof Error?R.message:l("shell.startSessionFailed"),tone:"error"})})},[n,i]),jo=f.useCallback(b=>{var J;const w=((J=b.workspaceId)==null?void 0:J.trim())||Re,R=pR(b.filePath);return!w||!R?!1:(lr(),qe("files"),jt?(_e(!1),Qe(!0)):ge(!1),Wr({requestId:S.current+1,workspaceId:w,filePath:R,openViewer:b.openViewer===!0}),S.current+=1,!0)},[Re,jt]),Ci=f.useCallback(async(b,w)=>{const R=await kf(b,w.trim());return St(R),R},[St]);function Is(b){Te(!0)}function Ni(){Te(!1),$t("sessions"),kn(""),pr(null),xn([]),hi(!1)}async function To(){const b=zt.trim();if(!b||!In.trim()){xn([]),pr(null);return}hi(!0),pr(null);try{const w=await ax(In,b);xn(w.items)}catch(w){xn([]),pr(w instanceof Error?w.message:l("shell.searchCodeFailed"))}finally{hi(!1)}}function Zr(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",X?"0px":`${w}px`))}function pl(b={}){return{leftWidth:b.leftWidth??(we?0:ee.current),rightWidth:b.rightWidth??(Sn&&!X?v.current:0),leftCollapsed:b.leftCollapsed??we,rightCollapsed:b.rightCollapsed??(!Sn||X),prefersDarkAppearance:b.prefersDarkAppearance??br!=="light",isResizing:b.isResizing??He!==null}}function Io(b,w){var Me;w.preventDefault(),w.stopPropagation(),(Me=window.getSelection())==null||Me.removeAllRanges();const R=w.clientX,J=b==="left"?E:se;yt(b);const Z=()=>{const Pe=ve.current;if(ve.current=null,Pe!==null){if(b==="left"){ee.current=Pe,$(fe=>fe===Pe?fe:Pe),Zr(Pe,v.current);return}v.current=Pe,ue(fe=>fe===Pe?fe:Pe),Zr(ee.current,Pe)}};function ae(Pe){var dn;Pe.preventDefault(),(dn=window.getSelection())==null||dn.removeAllRanges();const fe=Pe.clientX-R,Ze=b==="left"?ua(J+fe,Ep,Rp):ua(J-fe,Mp,Ap),sn=b==="left"?ee.current:v.current;Ze===sn&&ve.current===null||(ve.current=Ze,Ne.current===null&&(Ne.current=window.requestAnimationFrame(()=>{Ne.current=null,Z()})))}function je(){document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",je),Ne.current!==null&&(window.cancelAnimationFrame(Ne.current),Ne.current=null),Z(),yt(fe=>fe===b?null:fe);const Pe=pl({isResizing:!1});Ao.current=Pe,r.bridge.syncNativeSidebarLayout(Pe)}document.addEventListener("mousemove",ae,{passive:!1}),document.addEventListener("mouseup",je)}function Es(){if(Eo())return;if(ut.length===0){n(Xr);return}const b=_n(ut[0].workspace.id,ut[0].session.sessionId);n(b)}function fl(){if(!Eo(Re)){if(Re){n(ii(Re));return}n(Xr)}}function Eo(b){if($e&&Mt)return b&&Mt&&Mt!==b?!1:(n(`${t.pathname}${t.search}`),!0);if(x.current){if(b){const[R,J=""]=x.current.split("?"),Z=Op(R??x.current,J?`?${J}`:"");if(Z&&Z!==b)return!1}return n(x.current),!0}const w=Kr(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"&&(_e(!1),Qe(!1));return}if(RR(w.target))return;const J=w.key.toLowerCase();if(!w.shiftKey&&J==="b"){w.preventDefault(),hl();return}if(w.shiftKey&&J==="i"){w.preventDefault(),Co();return}if(!w.shiftKey&&J===","){w.preventDefault(),n("/settings");return}if(!w.shiftKey&&J==="1"){w.preventDefault(),Es();return}if(!w.shiftKey&&J==="2"){w.preventDefault(),n(Re?is(Re):Zt());return}if(!w.shiftKey&&J==="k"){w.preventDefault(),AR();return}w.shiftKey&&J==="r"&&(w.preventDefault(),Xt())}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[n,Xt,jt,Es]);const ml=f.useMemo(()=>({shellMode:e,navigationGroups:re,navigationLoading:pe,navigationError:Xe,currentWorkspaceId:Re,currentSessionId:$e,favoriteSessionIds:Qt,favoriteSessions:ar,globalNotifications:cn,archivedNotificationIds:Array.from(zr),showArchivedNotifications:fi,unreadNotificationCount:Nr,refreshNavigation:Xt,requestNavigationRefresh:Jt,openNotificationPanel:()=>{$n(!0)},closeNotificationPanel:()=>{$n(!1)},setShowArchivedNotifications:bs,archiveNotification:b=>{Yr(b,!0)},unarchiveNotification:b=>{Yr(b,!1)},setAuxiliaryPanel:B,subscribeFileTree:nn,requestFileTreeRefresh:xr,addFileTreeSnapshotListener:gi,subscribeGitSnapshot:Gr,requestGitRefresh:Hn,addGitSnapshotListener:ks,subscribeWorkspaceManagementSnapshot:yr,requestWorkspaceManagementRefresh:Un,addWorkspaceManagementSnapshotListener:wr,workspaceManagementStateById:Fr,subscribeTerminalManagerSnapshot:ys,requestTerminalManagerRefresh:Sr,addTerminalManagerSnapshotListener:yo,selectWorkspace:Ts,toggleFavoriteSession:Qr,archiveSession:b=>Gn(b,!0),unarchiveSession:b=>Gn(b,!1),renameSession:Ci,startDraftSession:No,markNavigationSessionSeen:wo,upsertNavigationSession:St,setSessionWorkspace:En,revealWorkspaceFile:jo}),[gi,ks,wr,yo,Gn,$e,Re,cn,Qt,ar,Ts,zr,wo,Xe,re,pe,Nr,xr,Hn,Un,Xt,Jt,bs,B,Sr,Ci,fi,Fr,e,No,En,nn,Gr,yr,ys,Yr,Qr,St,jo]),gl={"--workbench-left-width":`${E}px`,"--workbench-left-current-width":we?"0px":`${E}px`,"--workbench-right-width":`${se}px`,"--workbench-right-current-width":X||Bt?"0px":`${se}px`,"--workbench-right-sidebar-duration":ye&&!X?`${ye.sidebarCollapseDurationMs}ms`:void 0,"--workbench-right-sidebar-content-duration":ye&&!X?`${Math.max(320,ye.sidebarCollapseDurationMs-120)}ms`:void 0},Mo=un==="butler"?Fn:s.jsx(sf,{panelReady:nt,activeTab:Ft,fileRevealRequest:Or,onTabChange:b=>{lr(),qe(b)},currentSessionId:ct?null:$e,activeWorkspaceId:Pn,navigationGroups:re,workspaceContext:Ln,worktreeMeta:jr,worktreeMergeState:vo,onRefreshWorktreeMergePreview:vr,onApplyWorktreeMerge:qn,onCleanupWorktree:xs}),Sn=Mo!==null,Yn=X||Bt,Ms=Bt&&ye!==null&&!X,Rs=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=de.current;de.current=!1,b.removeAttribute(la),w==null||w.removeAttribute(la),Z&&Ee.current&&(Ee.current=!1,xo(ae=>ae+1))};if(!Rs){R();return}const J=()=>{de.current=!0,b.setAttribute(la,"true"),w==null||w.setAttribute(la,"true"),N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{R()},qM)};return window.addEventListener("resize",J),()=>{window.removeEventListener("resize",J),R()}},[Rs]);const es=f.useMemo(()=>({leftWidth:we?0:E,rightWidth:Sn&&!Yn?se:0,leftCollapsed:we,rightCollapsed:!Sn||Yn,prefersDarkAppearance:br!=="light",isResizing:He!==null}),[He,Yn,we,E,se,Sn,br]),bl=f.useDeferredValue(es),Ro=He===null?bl:es,Ao=f.useRef(es);f.useEffect(()=>{Ao.current=es},[es]),f.useEffect(()=>{if(typeof window>"u")return;let b=null;const w=()=>{b=null,r.bridge.syncNativeSidebarLayout(Ro)},R=()=>{b!==null&&window.cancelAnimationFrame(b),b=window.requestAnimationFrame(w)};return Yt?(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)})},[Ro,r.bridge,Yt]),f.useLayoutEffect(()=>{const b=K.current;if(!b||!Rs||typeof window>"u"){_p(b);return}let w=null,R=null;const J=new Set([b]),Z=()=>{Ee.current=!1;const je=window.getComputedStyle(b),Me=mb(je,"--desktop-macos-traffic-light-center-y");if(Me===null){_p(b);return}const Pe={navToolbar:Rr(b,kt.navToolbar.selector),infoTabs:Rr(b,kt.infoTabs.selector),auxiliaryToolbarButton:Rr(b,kt.auxiliaryToolbarButton.selector),conversationHeaderMain:Rr(b,kt.conversationHeaderMain.selector),conversationHeaderActions:Rr(b,kt.conversationHeaderActions.selector),terminalTabbarMain:Rr(b,kt.terminalTabbarMain.selector),collapsedLeftControls:Rr(b,kt.collapsedLeftControls.selector),collapsedRightControls:Rr(b,kt.collapsedRightControls.selector)},fe=[Pe.infoTabs,Pe.conversationHeaderMain,Pe.conversationHeaderActions,Pe.terminalTabbarMain].filter(Tt=>Tt!==null),Ze=[Pe.collapsedLeftControls,Pe.collapsedRightControls].filter(Tt=>Tt!==null),sn=Ze.length>0?Qn(je,"--workbench-collapsed-controls-live-shift-y",Me,Ze.reduce((Tt,Dn)=>Tt+Dn,0)/Ze.length):null,dn=fe.length>0?Qn(je,"--workbench-titlebar-live-content-shift-y",Me,fe.reduce((Tt,Dn)=>Tt+Dn,0)/fe.length):null;Jn(b,"--workbench-titlebar-live-content-shift-y",dn),Jn(b,"--workbench-collapsed-controls-live-shift-y",sn),Jn(b,kt.navToolbar.variableName,Qn(je,kt.navToolbar.variableName,Me,Pe.navToolbar)),Jn(b,kt.infoTabs.variableName,Qn(je,kt.infoTabs.variableName,Me,Pe.infoTabs)),Jn(b,kt.auxiliaryToolbarButton.variableName,Qn(je,kt.auxiliaryToolbarButton.variableName,Me,Pe.auxiliaryToolbarButton)),Jn(b,kt.conversationHeaderMain.variableName,Qn(je,kt.conversationHeaderMain.variableName,Me,Pe.conversationHeaderMain)),Jn(b,kt.conversationHeaderActions.variableName,Qn(je,kt.conversationHeaderActions.variableName,Me,Pe.conversationHeaderActions)),Jn(b,kt.terminalTabbarMain.variableName,Qn(je,kt.terminalTabbarMain.variableName,Me,Pe.terminalTabbarMain)),Jn(b,kt.collapsedLeftControls.variableName,Qn(je,kt.collapsedLeftControls.variableName,Me,Pe.collapsedLeftControls)),Jn(b,kt.collapsedRightControls.variableName,Qn(je,kt.collapsedRightControls.variableName,Me,Pe.collapsedRightControls))},ae=()=>{if(de.current){Ee.current=!0;return}w!==null&&window.cancelAnimationFrame(w),w=window.requestAnimationFrame(()=>{w=null,Z()})};if(ae(),typeof ResizeObserver<"u"){R=new ResizeObserver(()=>{ae()});for(const je of Object.values(kt))for(const Me of b.querySelectorAll(je.selector))J.add(Me);for(const je of J)R.observe(je)}return window.addEventListener("resize",ae),()=>{w!==null&&window.cancelAnimationFrame(w),window.removeEventListener("resize",ae),R==null||R.disconnect()}},[un,nt,we,t.pathname,t.search,X,Sn,Rs,tl]);const ji=jt?s.jsx(rf,{workspaceGroups:yi,workspaceVisualContextMap:Cs,sessionDisplaySortMode:o,favoriteSessions:ar,favoriteSessionIds:Mn,activeWorkspaceId:Re,isConversationActive:un==="conversation",isTerminalActive:un==="terminals",isButlerActive:un==="butler",isSearchOpen:be,navigationLoading:pe,navigationError:Xe,activeSessionId:$e,onRefreshNavigation:Xt,onSessionUpdated:St,onNavigateConversation:Es,onNavigateTerminals:()=>{_e(!1),n(Re?is(Re):Zt())},onNavigateButler:()=>{_e(!1),n(Re?cs(Re):Zt())},onOpenSearch:()=>{_e(!1),Is()},onOpenSettings:()=>{_e(!1),n("/settings")},onSelectWorkspace:Ts,onToggleWorkspaceCollapse:Rn,onStartWorkspaceReorder:ws,onPreviewWorkspaceReorder:vs,onCommitWorkspaceReorder:bi,allowWorkspaceReorder:!1,subscribeGitSnapshot:Gr,requestGitRefresh:Hn,subscribeWorkspaceManagementSnapshot:yr,requestWorkspaceManagementRefresh:Un,onToggleFavoriteSession:Qr,onArchiveSession:b=>Gn(b,!0),onUnarchiveSession:b=>Gn(b,!1),workspaceManagementStateById:Fr,setWorkspaceManagementStateById:Ht,unreadNotificationCount:Nr,notificationPanelOpen:gr,onToggleNotificationPanel:()=>{$n(b=>!b)},onClose:()=>_e(!1)}):null,Po=jt&&Sn?Mo:null;return s.jsxs(bb.Provider,{value:ml,children:[jt?s.jsx(s.Fragment,{children:s.jsx(Jx,{activeEntry:Si,presentation:il?"conversation-focus":"default",navigationPanel:ji,auxiliaryPanel:Po,onOpenNavigation:()=>{Qe(!1),_e(!0)},onOpenSearch:()=>{_e(!1),Qe(!1),Is()},onOpenAuxiliary:()=>{Sn&&(lr(),_e(!1),Qe(!0))},onNavigateWorkspaces:()=>{_e(!1),Qe(!1),n(Zt())},onNavigateTerminals:()=>{_e(!1),Qe(!1),n(Re?is(Re):Zt())},onNavigateButler:()=>{_e(!1),Qe(!1),n(Re?cs(Re):Zt())},onNavigateSessions:()=>{_e(!1),Qe(!1),fl()},onNavigateToolFiles:()=>{_e(!1),Qe(!1),n(Re?Lf(Re):Zt())},onNavigateToolGit:()=>{_e(!1),Qe(!1),n(Re?Df(Re):Zt())},onNavigateToolProcesses:()=>{_e(!1),Qe(!1),n(Re?_f(Re):Zt())},onNavigateSettings:()=>{_e(!1),Qe(!1),n("/settings")},children:s.jsx(td,{})})}):s.jsx("div",{className:"workbench-shell",ref:K,style:gl,onMouseDownCapture:yn,onDoubleClickCapture:ko,"data-nav-loading":pe,"data-left-collapsed":we,"data-right-collapsed":Yn,"data-info-ready":nt,"data-parallel-conversation-active":Bt?"true":void 0,"data-parallel-sidebar-transition":Ms?"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(rf,{workspaceGroups:yi,workspaceVisualContextMap:Cs,sessionDisplaySortMode:o,favoriteSessions:ar,favoriteSessionIds:Mn,activeWorkspaceId:Re,isConversationActive:un==="conversation",isTerminalActive:un==="terminals",isButlerActive:un==="butler",isSearchOpen:be,navigationLoading:pe,navigationError:Xe,activeSessionId:$e,onRefreshNavigation:Xt,onSessionUpdated:St,onNavigateConversation:Es,onNavigateTerminals:()=>n(Re?is(Re):Zt()),onNavigateButler:()=>n(Re?cs(Re):Zt()),onOpenSearch:()=>Is(),onOpenSettings:()=>n("/settings"),onSelectWorkspace:Ts,onToggleWorkspaceCollapse:Rn,onStartWorkspaceReorder:ws,onPreviewWorkspaceReorder:vs,onCommitWorkspaceReorder:bi,allowWorkspaceReorder:!0,subscribeGitSnapshot:Gr,requestGitRefresh:Hn,subscribeWorkspaceManagementSnapshot:yr,requestWorkspaceManagementRefresh:Un,onToggleFavoriteSession:Qr,onArchiveSession:b=>Gn(b,!0),onUnarchiveSession:b=>Gn(b,!1),workspaceManagementStateById:Fr,setWorkspaceManagementStateById:Ht,unreadNotificationCount:Nr,notificationPanelOpen:gr,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=>Io("left",b)}),s.jsxs("div",{className:"workbench-main-shell",children:[s.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!we&&!X,children:[s.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":we,children:[s.jsx(ef,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:dl}),s.jsx(ub,{collapsed:!0}),s.jsx(Hb,{unreadCount:Nr,open:gr,onToggle:()=>{$n(b=>!b)},collapsed:!0})]}),Sn&&!Bt?s.jsx("div",{className:"workbench-collapsed-controls right","data-visible":X,children:s.jsx(ef,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:js})}):null]}),s.jsx(td,{})]}),Sn?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Yn,"data-auto-hidden":Bt?"true":void 0,role:"separator","aria-label":l("shell.rightResizerLabel"),onMouseDown:Yn?void 0:b=>Io("right",b)}),s.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(Ln==null?void 0:Ln.tone)??"root","data-worktree-depth":(Ln==null?void 0:Ln.depth)??0,"data-collapsed":Yn,"data-auto-hidden":Bt?"true":void 0,"data-custom-panel":un==="butler","data-parallel-transition":Ms?"true":void 0,"aria-hidden":Yn&&!Ms,style:cr(Ln),children:Bt&&!Ms?null:un==="butler"?s.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Fn}):s.jsx(sf,{panelReady:nt,activeTab:Ft,fileRevealRequest:Or,onTabChange:b=>{lr(),qe(b)},onToggleCollapse:()=>ge(!0),currentSessionId:ct?null:$e,activeWorkspaceId:Pn,navigationGroups:re,workspaceContext:Ln,worktreeMeta:jr,worktreeMergeState:vo,onRefreshWorktreeMergePreview:vr,onApplyWorktreeMerge:qn,onCleanupWorktree:Vr})})]}):null]})}),s.jsx(XR,{open:gr,notifications:cn,archivedNotificationIds:zr,showArchivedNotifications:fi,onClose:()=>$n(!1),onToggleShowArchivedNotifications:bs,onArchiveNotification:b=>{Yr(b,!0)},onUnarchiveNotification:b=>{Yr(b,!1)},onSelectNotification:nl,preferredWorkspaceId:Re,preferredSessionId:ct?null:$e}),s.jsx(fA,{open:be,mode:wt,keyword:zt,codeWorkspaceId:In,codeResults:bo,codeLoading:ir,codeError:pi,workspaceOptions:cl,sessionResults:ul,onClose:Ni,onModeChange:b=>{$t(b),pr(null),xn([])},onKeywordChange:b=>{kn(b),wt==="code"&&!b.trim()&&(xn([]),pr(null))},onCodeWorkspaceChange:b=>tn(b),onCodeSearch:()=>{To()},onOpenSession:b=>{Ni();const w=ut.find(R=>R.session.sessionId===b)??null;n(w?_n(w.workspace.id,b):Zt())}}),s.jsxs(Et,{open:mt!==null,title:l("shell.worktreeCleanupModalTitle"),description:l("shell.worktreeCleanupModalDescription"),onClose:()=>{var b;mt&&((b=Dt[mt.workspaceId])!=null&&b.cleaning)||(mr(!1),$r(null))},children:[s.jsx("p",{className:"workbench-section-empty",children:mt?l("shell.worktreeCleanupConfirm",{name:mt.displayName||mt.branchName}):""}),mt?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:fr,disabled:!!((O=Dt[mt.workspaceId])!=null&&O.cleaning)||((te=(Q=Dt[mt.workspaceId])==null?void 0:Q.preview)==null?void 0:te.alreadyMerged)!==!0,onChange:b=>mr(b.target.checked)}),s.jsx("span",{children:l("shell.worktreeCleanupDeleteBranchLabel",{branch:mt.branchName})})]}),((he=(Ae=Dt[mt.workspaceId])==null?void 0:Ae.preview)==null?void 0:he.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:!!(mt&&((Ge=Dt[mt.workspaceId])!=null&&Ge.cleaning)),onClick:()=>{mr(!1),$r(null)},children:l("common.cancel")}),s.jsx("button",{type:"button",className:fr&&mt&&((gt=(vt=Dt[mt.workspaceId])==null?void 0:vt.preview)==null?void 0:gt.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!mt||!!(mt&&((At=Dt[mt.workspaceId])!=null&&At.cleaning)),onClick:()=>{mt&&xs(mt)},children:mt&&((Cn=Dt[mt.workspaceId])!=null&&Cn.cleaning)?l("shell.worktreeCleanupRunning"):fr&&mt&&((Tr=(Nn=Dt[mt.workspaceId])==null?void 0:Nn.preview)==null?void 0:Tr.alreadyMerged)===!0?l("shell.worktreeCleanupDeleteBranchAction"):l("shell.worktreeCleanupAction")})]})]}),jt?s.jsxs(s.Fragment,{children:[al?null:s.jsx(of,{isOpen:ft,side:"left",onClose:()=>_e(!1),children:ji}),ll?null:s.jsx(of,{isOpen:Nt,side:"right",onClose:()=>Qe(!1),children:Po})]}):null]})}function of({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:ur.createPortal(a,document.body)}function Gb(){return f.useContext(bb)??{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 Vb(e){return e.startsWith("draft-")}export{FP as $,WE as A,hM as B,Vu as C,nT as D,rT as E,gx as F,sP as G,fx as H,GE as I,tT as J,XE as K,Cx as L,aP as M,ss as N,ci as O,qs as P,sa as Q,Hi as R,vM as S,NM as T,SM as U,ba as V,ay as W,CM as X,jM as Y,wM as Z,BP as _,tL as a,SP as a$,PP as a0,LP as a1,OP as a2,AP as a3,zP as a4,XP as a5,VP as a6,KP as a7,YP as a8,JP as a9,wI as aA,GP as aB,lP as aC,oP as aD,xx as aE,du as aF,DM as aG,$P as aH,Zt as aI,oy as aJ,cP as aK,dP as aL,hP as aM,kP as aN,xP as aO,bP as aP,mP as aQ,pP as aR,Uu as aS,MP as aT,fP as aU,NP as aV,rj as aW,DP as aX,_P as aY,EP as aZ,vP as a_,QP as aa,DA as ab,Ot as ac,fc as ad,ZP as ae,ds as af,Sx as ag,bx as ah,Ba as ai,AM as aj,px as ak,yx as al,nP as am,tP as an,iP as ao,kx as ap,cr as aq,ld as ar,rP as as,qP as at,Sy as au,Cy as av,Ny as aw,uP as ax,Hu as ay,yI as az,wa as b,CP as b0,jP as b1,TP as b2,IP as b3,eM as b4,gP as b5,yP as b6,wP as b7,RP as b8,WP as b9,eP as bA,QA as bB,JA as bC,FA as bD,_A as bE,L1 as bF,VN as bG,Af as bH,Pj as ba,Hj as bb,HP as bc,xp as bd,KE as be,QE as bf,Uc as bg,$A as bh,Ou as bi,UA as bj,HA as bk,BA as bl,ax as bm,OA as bn,WA as bo,dx as bp,LA as bq,zA as br,VA as bs,XA as bt,cx as bu,KA as bv,qA as bw,YA as bx,GA as by,ZA as bz,_n as c,xM as d,dM as e,eL as f,xI as g,QN as h,UP as i,ZN as j,cg as k,nj as l,lp as m,ii as n,is as o,Pf as p,cs as q,Gf as r,_f as s,rr as t,Gb as u,FE as v,qi as w,zE as x,Lf as y,Df as z};