@engenty/wizards-runtime 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +138 -9
  2. package/apps/runtime/dist/agents/website.js +10 -5
  3. package/apps/runtime/dist/app.js +18 -0
  4. package/apps/runtime/dist/auth/index.js +5 -0
  5. package/apps/runtime/dist/broker/account.js +5 -0
  6. package/apps/runtime/dist/broker/index.js +5 -0
  7. package/apps/runtime/dist/broker/rwx.js +255 -7
  8. package/apps/runtime/dist/cli/main.js +7 -0
  9. package/apps/runtime/dist/cli/move-files.js +68 -0
  10. package/apps/runtime/dist/cli/move-folder-sources.js +120 -0
  11. package/apps/runtime/dist/connectors/plugin-connections.js +74 -4
  12. package/apps/runtime/dist/db/migrations/tenant/0042_client_spaces.sql +16 -0
  13. package/apps/runtime/dist/db/migrations/tenant/0043_space_member_invite.sql +19 -0
  14. package/apps/runtime/dist/db/migrations/tenant/0044_client_portal.sql +8 -0
  15. package/apps/runtime/dist/db/migrations/tenant/0045_client_portal_no_slug.sql +2 -0
  16. package/apps/runtime/dist/db/migrations/tenant/0046_space_file_hash.sql +2 -0
  17. package/apps/runtime/dist/db/migrations/tenant/0047_knowledge_folders.sql +3 -0
  18. package/apps/runtime/dist/db/migrations/tenant/0048_space_chunk_kind.sql +1 -0
  19. package/apps/runtime/dist/db/migrations/tenant/0049_knowledge_sources.sql +57 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0050_dateien.sql +71 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0051_dateien_drafts.sql +23 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0052_dateien_plugin_kinds.sql +5 -0
  23. package/apps/runtime/dist/db/migrations/tenant/0053_dateien_file_title.sql +3 -0
  24. package/apps/runtime/dist/db/migrations/tenant/0054_dateien_ocr.sql +14 -0
  25. package/apps/runtime/dist/db/migrations/tenant/0055_dateien_doc_reread.sql +3 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/0042_snapshot.json +5286 -0
  27. package/apps/runtime/dist/db/migrations/tenant/meta/0043_snapshot.json +5293 -0
  28. package/apps/runtime/dist/db/migrations/tenant/meta/0044_snapshot.json +5344 -0
  29. package/apps/runtime/dist/db/migrations/tenant/meta/0045_snapshot.json +5329 -0
  30. package/apps/runtime/dist/db/migrations/tenant/meta/0046_snapshot.json +5343 -0
  31. package/apps/runtime/dist/db/migrations/tenant/meta/0047_snapshot.json +5391 -0
  32. package/apps/runtime/dist/db/migrations/tenant/meta/0048_snapshot.json +5398 -0
  33. package/apps/runtime/dist/db/migrations/tenant/meta/0049_snapshot.json +5793 -0
  34. package/apps/runtime/dist/db/migrations/tenant/meta/0050_snapshot.json +6288 -0
  35. package/apps/runtime/dist/db/migrations/tenant/meta/0051_snapshot.json +6461 -0
  36. package/apps/runtime/dist/db/migrations/tenant/meta/0052_snapshot.json +6497 -0
  37. package/apps/runtime/dist/db/migrations/tenant/meta/0053_snapshot.json +6504 -0
  38. package/apps/runtime/dist/db/migrations/tenant/meta/0054_snapshot.json +6504 -0
  39. package/apps/runtime/dist/db/migrations/tenant/meta/0055_snapshot.json +6504 -0
  40. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +98 -0
  41. package/apps/runtime/dist/db/schema.js +294 -5
  42. package/apps/runtime/dist/docs/dev/api.md +25 -0
  43. package/apps/runtime/dist/docs/dev/plugins/connections.md +30 -2
  44. package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
  45. package/apps/runtime/dist/docs/dev/plugins/reference.md +7 -4
  46. package/apps/runtime/dist/docs/dev/plugins/server.md +11 -5
  47. package/apps/runtime/dist/docs/dev/plugins/space.md +130 -4
  48. package/apps/runtime/dist/docs/dev/plugins/studio.md +13 -3
  49. package/apps/runtime/dist/docs/user-guide/command-line.md +2 -0
  50. package/apps/runtime/dist/docs/user-guide/plugins.md +1 -1
  51. package/apps/runtime/dist/docs/user-guide/space.md +6 -6
  52. package/apps/runtime/dist/docs/user-guide/steps.md +1 -1
  53. package/apps/runtime/dist/documents/ocr.js +72 -0
  54. package/apps/runtime/dist/documents/parse.js +81 -12
  55. package/apps/runtime/dist/elements/caller.js +5 -3
  56. package/apps/runtime/dist/elements/gate.js +1 -1
  57. package/apps/runtime/dist/elements/knowledge.js +181 -12
  58. package/apps/runtime/dist/elements/specs.js +1 -1
  59. package/apps/runtime/dist/elements/wizards.js +15 -2
  60. package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +3 -0
  61. package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +3 -0
  62. package/apps/runtime/dist/engenty/connections-s3/s3.js +6 -0
  63. package/apps/runtime/dist/engine/runner.js +19 -2
  64. package/apps/runtime/dist/engine/steps.js +1 -1
  65. package/apps/runtime/dist/env.js +6 -0
  66. package/apps/runtime/dist/files/blobs.js +57 -1
  67. package/apps/runtime/dist/files/objects.js +1 -0
  68. package/apps/runtime/dist/files/pictures.js +41 -0
  69. package/apps/runtime/dist/files/storage.js +14 -26
  70. package/apps/runtime/dist/files/thumbs.js +77 -0
  71. package/apps/runtime/dist/files/upload-check.js +2 -2
  72. package/apps/runtime/dist/index.js +22 -0
  73. package/apps/runtime/dist/live/views.js +2 -1
  74. package/apps/runtime/dist/manage.js +4 -1
  75. package/apps/runtime/dist/mcp/tools.js +5 -0
  76. package/apps/runtime/dist/models.js +82 -13
  77. package/apps/runtime/dist/mounts/cache.js +71 -0
  78. package/apps/runtime/dist/mounts/drafts.js +367 -0
  79. package/apps/runtime/dist/mounts/folder.js +148 -0
  80. package/apps/runtime/dist/mounts/mounts.js +1315 -0
  81. package/apps/runtime/dist/mounts/source.js +179 -0
  82. package/apps/runtime/dist/mounts/units.js +97 -0
  83. package/apps/runtime/dist/move-files.js +4 -0
  84. package/apps/runtime/dist/plugins/loader.js +73 -1
  85. package/apps/runtime/dist/plugins/registry.js +2 -0
  86. package/apps/runtime/dist/prompts/goose.md +13 -1
  87. package/apps/runtime/dist/prompts/tools.md +5 -2
  88. package/apps/runtime/dist/render/convert.js +188 -1
  89. package/apps/runtime/dist/routes/api.js +6 -1
  90. package/apps/runtime/dist/routes/client-contract.js +164 -0
  91. package/apps/runtime/dist/routes/client-spaces.js +58 -0
  92. package/apps/runtime/dist/routes/dateien.js +173 -0
  93. package/apps/runtime/dist/routes/elements.js +2 -2
  94. package/apps/runtime/dist/routes/plugins.js +2 -1
  95. package/apps/runtime/dist/routes/runs.js +24 -10
  96. package/apps/runtime/dist/routes/studio.js +168 -8
  97. package/apps/runtime/dist/secrets/signing.js +16 -0
  98. package/apps/runtime/dist/services/client-portal.js +439 -0
  99. package/apps/runtime/dist/services/client-spaces.js +228 -0
  100. package/apps/runtime/dist/services/cloud.js +2 -0
  101. package/apps/runtime/dist/services/knowledge-model.js +24 -8
  102. package/apps/runtime/dist/services/knowledge.js +72 -42
  103. package/apps/runtime/dist/services/links.js +17 -0
  104. package/apps/runtime/dist/services/members-studio.js +5 -1
  105. package/apps/runtime/dist/services/page-pictures.js +162 -0
  106. package/apps/runtime/dist/services/runs.js +22 -6
  107. package/apps/runtime/dist/services/space-categories.js +41 -5
  108. package/apps/runtime/dist/services/space-data.js +165 -8
  109. package/apps/runtime/dist/services/space-files.js +102 -19
  110. package/apps/runtime/dist/services/space-index.js +384 -41
  111. package/apps/runtime/dist/services/space-origin.js +25 -1
  112. package/apps/runtime/dist/services/space-sources.js +937 -0
  113. package/apps/runtime/dist/services/spaces.js +60 -12
  114. package/apps/runtime/dist/services/synced-spaces.js +10 -1
  115. package/apps/runtime/dist/services/work-ai.js +29 -8
  116. package/apps/runtime/dist/services/work-chats.js +3 -2
  117. package/apps/runtime/dist/sharing/index.js +2 -0
  118. package/apps/runtime/dist/store/index.js +29 -8
  119. package/apps/runtime/dist/store/shared-lists.js +30 -17
  120. package/apps/runtime/dist/sync/records.js +22 -27
  121. package/apps/runtime/dist/texts.js +4 -0
  122. package/apps/runtime/dist/tools/pages.js +1 -1
  123. package/apps/runtime/dist/widgets/step.js +2 -1
  124. package/apps/web/dist/assets/AboutDialog-0q4P80yv.js +1 -0
  125. package/apps/web/dist/assets/BlockEditor-CUYFH_CU.js +173 -0
  126. package/apps/web/dist/assets/BlockEditor-CtW6lw0y.css +1 -0
  127. package/apps/web/dist/assets/CapabilitiesPage-BlZP8DYb.js +2 -0
  128. package/apps/web/dist/assets/{ChangelogDialog-Do7pwmFv.js → ChangelogDialog-CDN7kMs1.js} +1 -1
  129. package/apps/web/dist/assets/{CodeEditor-Cdox-51M.js → CodeEditor-D-Y16fdk.js} +1 -1
  130. package/apps/web/dist/assets/EditorPage-CrMVsgUt.js +3 -0
  131. package/apps/web/dist/assets/{FlowPreview-BPS86xzA.js → FlowPreview-DXnk7m9P.js} +1 -1
  132. package/apps/web/dist/assets/{LangSwitch-BRHbi_Sd.js → LangSwitch-Dkd0FBIH.js} +1 -1
  133. package/apps/web/dist/assets/Marketplace-Cty40VwG.js +2 -0
  134. package/apps/web/dist/assets/NewWizardChannels-Czool7s1.js +1 -0
  135. package/apps/web/dist/assets/NewWizardPage-CfVe_4a2.js +7 -0
  136. package/apps/web/dist/assets/OnboardingPage-D3SEpTmt.js +1 -0
  137. package/apps/web/dist/assets/PreviewPane-CQDKQO6z.js +7 -0
  138. package/apps/web/dist/assets/PublicRunner-BDZNnlQw.js +1 -0
  139. package/apps/web/dist/assets/ReadOnly-B7MUySpC.js +1 -0
  140. package/apps/web/dist/assets/SettingsPage-Bgurv3l2.js +2 -0
  141. package/apps/web/dist/assets/SetupPage-C3km8vqv.js +1 -0
  142. package/apps/web/dist/assets/{SharePage-PKHX8a8a.js → SharePage-UwEJBIzq.js} +1 -1
  143. package/apps/web/dist/assets/SkillEditor-BaEiqqXl.js +1 -0
  144. package/apps/web/dist/assets/Skills-Bv6XbKxc.js +9 -0
  145. package/apps/web/dist/assets/SpacePage-D9PXLSU_.js +2 -0
  146. package/apps/web/dist/assets/UpdateCheck-C7I43zFZ.js +2 -0
  147. package/apps/web/dist/assets/changelog-DwgWiSZb.js +1 -0
  148. package/apps/web/dist/assets/circle-check-DDLzlcXP.js +1 -0
  149. package/apps/web/dist/assets/code-DsnwzN1x.js +1 -0
  150. package/apps/web/dist/assets/code-editor-Ca5EAxmd.js +2 -0
  151. package/apps/web/dist/assets/code-xml-S4IFi5Jc.js +1 -0
  152. package/apps/web/dist/assets/connection-sign-in-hI3HXhq4.js +1 -0
  153. package/apps/web/dist/assets/{dist-H1UN89OA.js → dist-B3Ray2U5.js} +1 -1
  154. package/apps/web/dist/assets/dist-CQpLJoQZ.js +10 -0
  155. package/apps/web/dist/assets/{dist-GlRRx9Xl.js → dist-D1uGQ_tB.js} +1 -1
  156. package/apps/web/dist/assets/{dist-BdDd1FxP.js → dist-DFI-tsfx.js} +1 -1
  157. package/apps/web/dist/assets/eye-TJSuiHHO.js +1 -0
  158. package/apps/web/dist/assets/floating-ui.dom-pwdNGv4b.js +1 -0
  159. package/apps/web/dist/assets/host-D5hNHbhF.js +125 -0
  160. package/apps/web/dist/assets/i18n-BBzMbGoo.js +55 -0
  161. package/apps/web/dist/assets/index-CyBrvupM.js +10 -0
  162. package/apps/web/dist/assets/index-w-3J3ZJ9.css +1 -0
  163. package/apps/web/dist/assets/{json-CEsfHdlZ.js → json-Ce3iHrtf.js} +1 -1
  164. package/apps/web/dist/assets/link-CPL8pB1P.js +1 -0
  165. package/apps/web/dist/assets/list-checks-DaxmUPqK.js +1 -0
  166. package/apps/web/dist/assets/{markdown-5-I9_izp.js → markdown-hqKQy2pp.js} +1 -1
  167. package/apps/web/dist/assets/marked.esm-DQ7XA7AC.js +67 -0
  168. package/apps/web/dist/assets/oss-credits-BrwV0a4F.js +1 -0
  169. package/apps/web/dist/assets/pdf-Dg-raaUo.js +54 -0
  170. package/apps/web/dist/assets/pdf.worker.min-68CMzziE.js +1 -0
  171. package/apps/web/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  172. package/apps/web/dist/assets/phone-B4uKDBFq.js +1 -0
  173. package/apps/web/dist/assets/read-aloud-Bfp9_bUY.js +1 -0
  174. package/apps/web/dist/assets/{runners-BoPaPsjN.js → runners-CUpBpSji.js} +1 -1
  175. package/apps/web/dist/assets/scroll-text-BEnPzQEi.js +1 -0
  176. package/apps/web/dist/assets/session-CMQo8P-G.js +2 -0
  177. package/apps/web/dist/assets/table-5B9G3oA6.js +1 -0
  178. package/apps/web/dist/assets/theme-CdX0marK.js +11 -0
  179. package/apps/web/dist/assets/ui-BCfu5sia.js +16 -0
  180. package/apps/web/dist/assets/upload-CAlHC232.js +1 -0
  181. package/apps/web/dist/assets/{useMutation-7_FOHoEl.js → useMutation-1fV4Nnxq.js} +1 -1
  182. package/apps/web/dist/assets/viewers-ChriFcRy.js +2 -0
  183. package/apps/web/dist/assets/volume-2-BqlBtCIJ.js +1 -0
  184. package/apps/web/dist/assets/w3c-keyname-BOAvb0qz.js +1 -0
  185. package/apps/web/dist/assets/xlsx-CuSbHU4R.js +141 -0
  186. package/apps/web/dist/index.html +19 -14
  187. package/apps/web/dist/mcp/flow.html +2 -2
  188. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +223 -4
  189. package/node_modules/@engenty/wizards/dist/plugin/mount.d.ts +123 -0
  190. package/node_modules/@engenty/wizards/dist/plugin/mount.js +7 -0
  191. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +110 -1
  192. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +1 -1
  193. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +24 -0
  194. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +24 -0
  195. package/node_modules/@engenty/wizards-shared/dist/knowledge.d.ts +33 -4
  196. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  197. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  198. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +21 -4
  199. package/node_modules/@engenty/wizards-shared/dist/rwx.js +27 -3
  200. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +11 -1
  201. package/node_modules/@engenty/wizards-shared/dist/spaces.js +9 -2
  202. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +6 -0
  203. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +25 -0
  204. package/package.json +3 -1
  205. package/plugin/.claude-plugin/plugin.json +1 -1
  206. package/plugin/plugin.json +1 -1
  207. package/apps/web/dist/assets/AboutDialog-DaWEIHFN.js +0 -1
  208. package/apps/web/dist/assets/CapabilitiesPage-Dt91U_sK.js +0 -2
  209. package/apps/web/dist/assets/EditorPage-DS_a5K3s.js +0 -3
  210. package/apps/web/dist/assets/Marketplace-CS7JTgiv.js +0 -2
  211. package/apps/web/dist/assets/NewWizardChannels-D-OLsex6.js +0 -1
  212. package/apps/web/dist/assets/NewWizardPage-BM_pkk41.js +0 -7
  213. package/apps/web/dist/assets/OnboardingPage-Cpn5pubC.js +0 -1
  214. package/apps/web/dist/assets/PreviewPane-BOk1-yO4.js +0 -9
  215. package/apps/web/dist/assets/PublicRunner-CgzMZb0r.js +0 -1
  216. package/apps/web/dist/assets/ReadOnly-8DEx-ly3.js +0 -1
  217. package/apps/web/dist/assets/SettingsPage-CcrknFcI.js +0 -2
  218. package/apps/web/dist/assets/SetupPage-D5nzjgPU.js +0 -1
  219. package/apps/web/dist/assets/SkillEditor-BsXTqNli.js +0 -1
  220. package/apps/web/dist/assets/Skills-C_X1ZsKg.js +0 -9
  221. package/apps/web/dist/assets/SpacePage-wZGqUoSQ.js +0 -2
  222. package/apps/web/dist/assets/UpdateCheck-D6x7MqEl.js +0 -2
  223. package/apps/web/dist/assets/changelog-M-eOBqgu.js +0 -1
  224. package/apps/web/dist/assets/circle-alert-DJbCyxcg.js +0 -1
  225. package/apps/web/dist/assets/circle-check-jqtsKi_b.js +0 -1
  226. package/apps/web/dist/assets/code-editor-BpCEnf8H.js +0 -2
  227. package/apps/web/dist/assets/code-xml-q88cSTV8.js +0 -1
  228. package/apps/web/dist/assets/connection-sign-in-UJ6xk-TD.js +0 -1
  229. package/apps/web/dist/assets/dist-EBVTpvRr.js +0 -10
  230. package/apps/web/dist/assets/eye-CgkvVlba.js +0 -1
  231. package/apps/web/dist/assets/host-Bd_bon_c.js +0 -118
  232. package/apps/web/dist/assets/i18n-0fUKyVRE.js +0 -55
  233. package/apps/web/dist/assets/index-D18DvnxX.css +0 -1
  234. package/apps/web/dist/assets/index-DOgwxnto.js +0 -10
  235. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +0 -1
  236. package/apps/web/dist/assets/phone-CjPvZ0nk.js +0 -1
  237. package/apps/web/dist/assets/read-aloud-CLXo_asN.js +0 -1
  238. package/apps/web/dist/assets/scroll-text-2BhJO_W7.js +0 -1
  239. package/apps/web/dist/assets/session-CpYa5hwd.js +0 -2
  240. package/apps/web/dist/assets/theme-Bj3wNQR0.js +0 -11
  241. package/apps/web/dist/assets/ui-CktezodE.js +0 -82
  242. package/apps/web/dist/assets/upload-CHGCFVZK.js +0 -1
  243. package/apps/web/dist/assets/volume-2-Bw5KASy8.js +0 -1
@@ -1,118 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-DaWEIHFN.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-CktezodE.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-0fUKyVRE.js","assets/logo-BpnjXTRy.js","assets/engenty-CNjaZCVM.js","assets/UpdateCheck-D6x7MqEl.js","assets/useMutation-7_FOHoEl.js","assets/react-dom-hf6EcyAr.js","assets/media-Cej-H610.js","assets/ChangelogDialog-Do7pwmFv.js","assets/Marketplace-CS7JTgiv.js","assets/volume-2-Bw5KASy8.js","assets/eye-CgkvVlba.js","assets/session-CpYa5hwd.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{n as r,t as i}from"./jsx-runtime-BNakU3Ej.js";import{$ as a,$n as o,$t as s,B as c,Bn as l,Ct as u,Dn as d,En as f,G as p,Gn as m,Hn as h,J as g,Jn as _,Jt as v,K as y,Kn as b,Kt as x,Ln as S,Mn as C,On as w,Or as T,Pn as E,Q as D,Qn as O,Qt as k,Rn as A,Sn as j,Tn as M,Un as N,V as P,Vn as F,W as I,Wn as L,Wr as R,Xn as ee,Xt as te,Yn as ne,Yt as z,Zt as re,_n as ie,_r as B,a as ae,an as oe,ar as se,at as ce,b as le,bn as ue,c as de,cn as V,ct as fe,dn as pe,dr as me,fr as he,gn as ge,gr as _e,hr as ve,jn as ye,l as be,ln as xe,lr as Se,mn as Ce,nn as we,nr as Te,nt as Ee,o as De,on as Oe,or as ke,ot as Ae,pn as je,q as H,qn as Me,qt as Ne,r as Pe,rn as Fe,rr as Ie,rt as Le,sn as Re,sr as U,t as ze,tr as Be,tt as Ve,un as He,ur as Ue,vn as We,vr as Ge,wn as Ke,xt as qe,yr as Je,zt as Ye}from"./ui-CktezodE.js";import{E as Xe,O as Ze,S as Qe,T as $e,_ as et,b as tt,i as nt,k as rt,w as it,y as at}from"./Marketplace-CS7JTgiv.js";import{t as ot}from"./useMutation-7_FOHoEl.js";import{t as st}from"./react-dom-hf6EcyAr.js";import{t as ct}from"./preload-helper-DpV6A1kQ.js";import{i as lt,n as ut,r as dt,t as ft}from"./volume-2-Bw5KASy8.js";import{n as pt,t as mt}from"./scroll-text-2BhJO_W7.js";import{t as ht}from"./eye-CgkvVlba.js";import{d as gt,i as _t,l as vt,n as yt,r as bt,s as xt,u as St}from"./read-aloud-CLXo_asN.js";import{M as Ct,N as wt,O as Tt,P as Et,S as Dt,b as Ot,d as kt,h as At,j as jt,m as Mt,n as Nt,p as Pt,s as Ft,u as It,w as Lt,x as Rt,y as zt}from"./session-CpYa5hwd.js";import{t as Bt}from"./logo-BpnjXTRy.js";import{A as Vt,Ct as Ht,Dt as Ut,M as Wt,N as Gt,S as Kt,Tt as qt,bt as Jt,j as Yt,n as Xt,s as W,wt as Zt,xt as Qt,y as $t,yt as en}from"./i18n-0fUKyVRE.js";import{t as tn}from"./media-Cej-H610.js";import{d as nn,g as rn,h as an,l as on,n as sn,p as cn,s as ln}from"./UpdateCheck-D6x7MqEl.js";import{n as un,t as dn}from"./with-selector-CoMyWBAX.js";import{r as fn,t as pn}from"./LangSwitch-BRHbi_Sd.js";var mn={name:`a-large-small`,size:24,node:[[`path`,{d:`m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16`,key:`xik6mr`}],[`path`,{d:`M15.697 14h5.606`,key:`1stdlc`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};mn.node;var hn=U(mn),gn={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};gn.node;var _n=U(gn),vn={name:`archive-restore`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]};vn.node;var yn=U(vn),bn={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};bn.node;var xn=U(bn),Sn={name:`arrow-left-right`,size:24,node:[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]};Sn.node;var Cn=U(Sn),wn={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};wn.node;var Tn=U(wn),En={name:`blocks`,size:24,node:[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]};En.node;var Dn=U(En),On={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};On.node;var kn=U(On),An={name:`brain`,size:24,node:[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]};An.node;var jn=U(An),Mn={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};Mn.node;var Nn=U(Mn),Pn={name:`cable`,size:24,node:[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]};Pn.node;var Fn=U(Pn),In={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};In.node;var Ln=U(In),Rn={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Rn.node;var zn=U(Rn),Bn={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Bn.node;var Vn=U(Bn),Hn={name:`cloud-alert`,size:24,node:[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]};Hn.node;var Un=U(Hn),Wn={name:`cloud-cog`,size:24,node:[[`path`,{d:`m10.852 19.772-.383.924`,key:`r7sl7d`}],[`path`,{d:`m13.148 14.228.383-.923`,key:`1d5zpm`}],[`path`,{d:`M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923`,key:`1ydik7`}],[`path`,{d:`m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544`,key:`1m1vsf`}],[`path`,{d:`m14.772 15.852.923-.383`,key:`660p6e`}],[`path`,{d:`m14.772 18.148.923.383`,key:`hrcpis`}],[`path`,{d:`M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2`,key:`j2q98n`}],[`path`,{d:`m9.228 15.852-.923-.383`,key:`1p9ong`}],[`path`,{d:`m9.228 18.148-.923.383`,key:`6558rz`}]]};Wn.node;var Gn=U(Wn),Kn={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};Kn.node;var qn=U(Kn),Jn={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Jn.node;var Yn=U(Jn),Xn={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};Xn.node;var Zn=U(Xn),Qn={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Qn.node;var $n=U(Qn),er={name:`fingerprint-pattern`,size:24,node:[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]],aliases:[`fingerprint`]};er.node;var tr=U(er),nr={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};nr.node;var rr=U(nr),ir={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};ir.node;var ar=U(ir),or={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};or.node;var sr=U(or),cr={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};cr.node;var lr=U(cr),ur={name:`highlighter`,size:24,node:[[`path`,{d:`m9 11-6 6v3h9l3-3`,key:`1a3l36`}],[`path`,{d:`m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4`,key:`14a9rk`}]]};ur.node;var dr=U(ur),fr={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};fr.node;var pr=U(fr),mr={name:`images`,size:24,node:[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]};mr.node;var hr=U(mr),gr={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};gr.node;var _r=U(gr),vr={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};vr.node;var yr=U(vr),br={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};br.node;var xr=U(br),Sr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Sr.node;var Cr=U(Sr),wr={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};wr.node;var Tr=U(wr),Er={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Er.node;var Dr=U(Er),Or={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Or.node;var kr=U(Or),Ar={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Ar.node;var jr=U(Ar),Mr={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Mr.node;var Nr=U(Mr),Pr={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Pr.node;var Fr=U(Pr),Ir={name:`message-circle-more`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]};Ir.node;var Lr=U(Ir),Rr={name:`message-circle`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]};Rr.node;var zr=U(Rr),Br={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};Br.node;var Vr=U(Br),Hr={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Hr.node;var Ur=U(Hr),Wr={name:`message-square-text`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]};Wr.node;var Gr=U(Wr),Kr={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Kr.node;var qr=U(Kr),Jr={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};Jr.node;var Yr=U(Jr),Xr={name:`panel-bottom`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};Xr.node;var Zr=U(Xr),Qr={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};Qr.node;var $r=U(Qr),ei={name:`panel-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]],aliases:[`sidebar`]};ei.node;var ti=U(ei),ni={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};ni.node;var ri=U(ni),ii={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};ii.node;var ai=U(ii),oi={name:`phone-call`,size:24,node:[[`path`,{d:`M13 2a9 9 0 0 1 9 9`,key:`1itnx2`}],[`path`,{d:`M13 6a5 5 0 0 1 5 5`,key:`11nki7`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};oi.node;var si=U(oi),ci={name:`picture-in-picture-2`,size:24,node:[[`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`,key:`daa4of`}],[`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`,key:`1nb8gs`}]]};ci.node;var li=U(ci),ui={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};ui.node;var di=U(ui),fi={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};fi.node;var pi=U(fi),mi={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};mi.node;var hi=U(mi),gi={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};gi.node;var _i=U(gi),vi={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};vi.node;var yi=U(vi),bi={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};bi.node;var xi=U(bi),Si={name:`rows-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]],aliases:[`panels-top-bottom`]};Si.node;var Ci=U(Si),wi={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};wi.node;var Ti=U(wi),Ei={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Ei.node;var Di=U(Ei),Oi={name:`shapes`,size:24,node:[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]};Oi.node;var ki=U(Oi),Ai={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Ai.node;var ji=U(Ai),Mi={name:`shield-question-mark`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`shield-question`]};Mi.node;var Ni=U(Mi),Pi={name:`shield-x`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]],aliases:[`shield-close`]};Pi.node;var Fi=U(Pi),Ii={name:`square-pen`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]],aliases:[`pen-box`,`edit`,`pen-square`]};Ii.node;var Li=U(Ii),Ri={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};Ri.node;var zi=U(Ri),Bi={name:`swatch-book`,size:24,node:[[`path`,{d:`M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z`,key:`1ldrpk`}],[`path`,{d:`M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7`,key:`11i5po`}],[`path`,{d:`M 7 17h.01`,key:`1euzgo`}],[`path`,{d:`m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8`,key:`o2gii7`}]]};Bi.node;var Vi=U(Bi),Hi={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Hi.node;var Ui=U(Hi),Wi={name:`toggle-right`,size:24,node:[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};Wi.node;var Gi=U(Wi),Ki={name:`toolbox`,size:24,node:[[`path`,{d:`M16 12v4`,key:`vf1vip`}],[`path`,{d:`M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2`,key:`llnzfg`}],[`path`,{d:`M17 6a2 2 0 011.414.586l3 3A2 2 0 0122 11v8a2 2 0 01-2 2H4a2 2 0 01-2-2v-8a2 2 0 01.586-1.414l3-3A2 2 0 017 6z`,key:`1hprxj`}],[`path`,{d:`M2 14h20`,key:`myj16y`}],[`path`,{d:`M8 12v4`,key:`1w4uao`}]]};Ki.node;var qi=U(Ki),Ji={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Ji.node;var Yi=U(Ji),Xi={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Xi.node;var Zi=U(Xi),Qi={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};Qi.node;var $i=U(Qi);function ea(){return Je({queryKey:[`config`],queryFn:async()=>{let e=await H.get(`/api/config`);return Ae(e.publicUrl),e},staleTime:6e4})}function ta(){let e=At(),t=ea();return e.data?.features??t.data?.features??zt()}function na(e){return Ot(ta(),e)}var ra=e({defineStudioPlugin:()=>ia});function ia(e){return e}var G=t(r(),1),aa=[`left`,`top`,`right`,`bottom`],oa=`wizards.appbar`,sa={position:`left`,labels:!0},ca=e=>aa.includes(e);function la(){try{let e=JSON.parse(localStorage.getItem(oa)??`null`);return{position:ca(e?.position)?e.position:sa.position,labels:typeof e?.labels==`boolean`?e.labels:sa.labels}}catch{return sa}}var ua=la(),da=new Set;function fa(e){ua={...ua,...e};try{localStorage.setItem(oa,JSON.stringify(ua))}catch{}for(let e of da)e()}function pa(){return tn(`(max-width: 767px)`)}function ma(){let e=(0,G.useSyncExternalStore)(e=>(da.add(e),()=>da.delete(e)),()=>ua),t=pa();return(0,G.useMemo)(()=>t?{...e,position:`bottom`,phone:t}:{...e,phone:t},[e,t])}var ha=e=>e===`top`||e===`bottom`;function ga(e){let{position:t,labels:n}=ma(),r=tn(`(min-width: 1400px)`)&&!ha(t)&&!e;return{shown:n&&r,room:r}}function _a(e,t){switch(e){case`left`:return t===`start`?`top-0 left-full ml-3`:`bottom-0 left-full ml-3`;case`right`:return t===`start`?`top-0 right-full mr-3`:`bottom-0 right-full mr-3`;case`top`:return t===`start`?`top-full left-0 mt-3`:`top-full right-0 mt-3`;case`bottom`:return t===`start`?`bottom-full left-0 mb-3`:`bottom-full right-0 mb-3`}}var va=()=>matchMedia(`(display-mode: standalone)`).matches||matchMedia(`(display-mode: window-controls-overlay)`).matches||navigator.standalone===!0,ya=()=>navigator.userAgent,ba=()=>/iPhone|iPad|iPod/.test(ya())||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,xa=()=>!!navigator.userAgentData?.brands?.length||/Chrome|Chromium|Edg/.test(ya()),Sa=()=>/Safari/.test(ya())&&!/Chrome|Chromium|Edg|Firefox|FxiOS/.test(ya());function Ca(e){return e?`prompt`:/Android/.test(ya())?xa()?`android`:`none`:ba()?`ios`:Sa()?`mac`:xa()?`chromium`:`none`}function wa(){return(0,G.useSyncExternalStore)(e=>(window.addEventListener(`wizard-install`,e),window.addEventListener(`appinstalled`,e),()=>{window.removeEventListener(`wizard-install`,e),window.removeEventListener(`appinstalled`,e)}),()=>window.wizardInstall??null)}async function Ta(e){try{await e.prompt()}finally{window.wizardInstall=null,window.dispatchEvent(new Event(`wizard-install`))}}function Ea(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}var Da=112,Oa=72,ka=89,Aa=115,ja;function Ma(){let e=new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e}function Na(e){let t=-1;ja||=Ma();for(let n=0;n<e.length;n++)t=ja[(t^e[n])&255]^t>>>8;return t^-1}function Pa(e){let t=e.length-1;for(let n=t;n>=4;n--)if(e[n-4]===9&&e[n-3]===Da&&e[n-2]===Oa&&e[n-1]===ka&&e[n]===Aa)return n-3;return 0}function Fa(e,t,n=!1){let r=new Uint8Array(13);t*=39.3701,r[0]=Da,r[1]=Oa,r[2]=ka,r[3]=Aa,r[4]=t>>>24,r[5]=t>>>16,r[6]=t>>>8,r[7]=t&255,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;let i=Na(r),a=new Uint8Array(4);if(a[0]=i>>>24,a[1]=i>>>16,a[2]=i>>>8,a[3]=i&255,n){let t=Pa(e);return e.set(r,t),e.set(a,t+13),e}{let t=new Uint8Array(4);t[0]=0,t[1]=0,t[2]=0,t[3]=9;let n=new Uint8Array(54);return n.set(e,0),n.set(t,33),n.set(r,37),n.set(a,50),n}}var Ia=`AAlwSFlz`,La=`AAAJcEhZ`,Ra=`AAAACXBI`;function za(e){let t=e.indexOf(Ia);return t===-1&&(t=e.indexOf(La)),t===-1&&(t=e.indexOf(Ra)),t}var Ba=`[modern-screenshot]`,Va=typeof window<`u`,Ha=Va&&`Worker`in window,Ua=Va&&`atob`in window,Wa=Va&&`btoa`in window,Ga=Va?window.navigator?.userAgent:``,Ka=Ga.includes(`Chrome`),qa=Ga.includes(`AppleWebKit`)&&!Ka,Ja=Ga.includes(`Firefox`),Ya=e=>e&&`__CONTEXT__`in e,Xa=e=>e.constructor.name===`CSSFontFaceRule`,Za=e=>e.constructor.name===`CSSImportRule`,Qa=e=>e.constructor.name===`CSSLayerBlockRule`,$a=e=>e.nodeType===1,eo=e=>typeof e.className==`object`,to=e=>e.tagName===`image`,no=e=>e.tagName===`use`,ro=e=>$a(e)&&e.style!==void 0&&!eo(e),io=e=>e.nodeType===8,ao=e=>e.nodeType===3,oo=e=>e.tagName===`IMG`,so=e=>e.tagName===`VIDEO`,co=e=>e.tagName===`CANVAS`,lo=e=>e.tagName===`TEXTAREA`,uo=e=>e.tagName===`INPUT`,fo=e=>e.tagName===`STYLE`,po=e=>e.tagName===`SCRIPT`,mo=e=>e.tagName===`SELECT`,ho=e=>e.tagName===`SLOT`,go=e=>e.tagName===`IFRAME`,_o=(...e)=>console.warn(Ba,...e);function vo(e){let t=e?.createElement?.(`canvas`);return t&&(t.height=t.width=1),!!t&&`toDataURL`in t&&!!t.toDataURL(`image/webp`).includes(`image/webp`)}var yo=e=>e.startsWith(`data:`);function bo(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(Va&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!Va)return e;let n=xo().implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}function xo(e){return(e&&$a(e)?e?.ownerDocument:e)??window.document}var So=`http://www.w3.org/2000/svg`;function Co(e,t,n){let r=xo(n).createElementNS(So,`svg`);return r.setAttributeNS(null,`width`,e.toString()),r.setAttributeNS(null,`height`,t.toString()),r.setAttributeNS(null,`viewBox`,`0 0 ${e} ${t}`),r}function wo(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,``)),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function To(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(i.result),i.onerror=()=>r(i.error),i.onabort=()=>r(Error(`Failed read blob to ${t}`)),t===`dataUrl`?i.readAsDataURL(e):t===`arrayBuffer`&&i.readAsArrayBuffer(e)})}var Eo=e=>To(e,`dataUrl`);function Do(e,t){let n=xo(t).createElement(`img`);return n.decoding=`sync`,n.loading=`eager`,n.src=e,n}function Oo(e,t){return new Promise(n=>{let{timeout:r,ownerDocument:i,onError:a,onWarn:o}=t??{},s=typeof e==`string`?Do(e,xo(i)):e,c=null,l=null;function u(){n(s),c&&clearTimeout(c),l?.()}if(r&&(c=setTimeout(u,r)),so(s)){let e=s.currentSrc||s.src;if(!e)return s.poster?Oo(s.poster,t).then(n):u();if(s.readyState>=2)return u();let r=u,i=t=>{o?.(`Failed video load`,e,t),a?.(t),u()};l=()=>{s.removeEventListener(`loadeddata`,r),s.removeEventListener(`error`,i)},s.addEventListener(`loadeddata`,r,{once:!0}),s.addEventListener(`error`,i,{once:!0})}else{let e=to(s)?s.href.baseVal:s.currentSrc||s.src;if(!e)return u();let t=async()=>{if(oo(s)&&`decode`in s)try{await s.decode()}catch(t){o?.(`Failed to decode image, trying to render anyway`,s.dataset.originalSrc||e,t)}u()},n=t=>{o?.(`Failed image load`,s.dataset.originalSrc||e,t),u()};if(oo(s)&&s.complete)return t();l=()=>{s.removeEventListener(`load`,t),s.removeEventListener(`error`,n)},s.addEventListener(`load`,t,{once:!0}),s.addEventListener(`error`,n,{once:!0})}})}async function ko(e,t){ro(e)&&(oo(e)||so(e)?await Oo(e,t):await Promise.all([`img`,`video`].flatMap(n=>Array.from(e.querySelectorAll(n)).map(e=>Oo(e,t)))))}var Ao=function(){let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)}();function jo(e){return e?.split(`,`).map(e=>e.trim().replace(/"|'/g,``).toLowerCase()).filter(Boolean)}var Mo=0;function No(e){let t=`${Ba}[#${Mo}]`;return Mo++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...t)=>e&&_o(...t)}}function Po(e){return{cache:e?`no-cache`:`force-cache`}}async function Fo(e,t){return Ya(e)?e:Io(e,{...t,autoDestruct:!0})}async function Io(e,t){let{scale:n=1,workerUrl:r,workerNumber:i=1}=t||{},a=!!t?.debug,o=t?.features??!0,s=e.ownerDocument??(Va?window.document:void 0),c=e.ownerDocument?.defaultView??(Va?window:void 0),l=new Map,u={width:0,height:0,quality:1,type:`image/png`,scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:a,fetch:{requestInit:Po(t?.fetch?.bypassingCache),placeholderImage:`data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7`,bypassingCache:!1,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:i,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:No(a),node:e,ownerDocument:s,ownerWindow:c,dpi:n===1?null:96*n,svgStyleElement:Lo(s),svgDefsElement:s?.createElementNS(So,`defs`),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:Ha&&r&&i?i:0})].map(()=>{try{let e=new Worker(r);return e.onmessage=async e=>{let{url:t,result:n}=e.data;n?l.get(t)?.resolve?.(n):l.get(t)?.reject?.(Error(`Error receiving message from worker: ${t}`))},e.onmessageerror=e=>{let{url:t}=e.data;l.get(t)?.reject?.(Error(`Error receiving message from worker: ${t}`))},e}catch(e){return u.log.warn(`Failed to new Worker`,e),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[vo(s)&&`image/webp`,`image/svg+xml`,`image/*`,`*/*`].filter(Boolean).join(`,`)};q=0.8`,requests:l,drawImageCount:0,tasks:[],features:o,isEnable:e=>e===`restoreScrollPosition`?typeof o==`boolean`?!1:o[e]??!1:typeof o==`boolean`?o:o[e]??!0,shadowRoots:[]};u.log.time(`wait until load`),await ko(e,{timeout:u.timeout,onWarn:u.log.warn}),u.log.timeEnd(`wait until load`);let{width:d,height:f}=Ro(e,u);return u.width=d,u.height=f,u}function Lo(e){if(!e)return;let t=e.createElement(`style`),n=t.ownerDocument.createTextNode(`
3
- .______background-clip--text {
4
- background-clip: text;
5
- -webkit-background-clip: text;
6
- }
7
- `);return t.appendChild(n),t}function Ro(e,t){let{width:n,height:r}=t;if($a(e)&&(!n||!r)){let t=e.getBoundingClientRect();n=n||t.width||Number(e.getAttribute(`width`))||0,r=r||t.height||Number(e.getAttribute(`height`))||0}return{width:n,height:r}}async function zo(e,t){let{log:n,timeout:r,drawImageCount:i,drawImageInterval:a}=t;n.time(`image to canvas`);let o=await Oo(e,{timeout:r,onWarn:t.log.warn}),{canvas:s,context2d:c}=Bo(e.ownerDocument,t),l=()=>{try{c?.drawImage(o,0,0,s.width,s.height)}catch(e){t.log.warn(`Failed to drawImage`,e)}};if(l(),t.isEnable(`fixSvgXmlDecode`))for(let e=0;e<i;e++)await new Promise(t=>{setTimeout(()=>{c?.clearRect(0,0,s.width,s.height),l(),t()},e+a)});return t.drawImageCount=0,n.timeEnd(`image to canvas`),s}function Bo(e,t){let{width:n,height:r,scale:i,backgroundColor:a,maximumCanvasSize:o}=t,s=e.createElement(`canvas`);s.width=Math.floor(n*i),s.height=Math.floor(r*i),s.style.width=`${n}px`,s.style.height=`${r}px`,o&&(s.width>o||s.height>o)&&(s.width>o&&s.height>o?s.width>s.height?(s.height*=o/s.width,s.width=o):(s.width*=o/s.height,s.height=o):s.width>o?(s.height*=o/s.width,s.width=o):(s.width*=o/s.height,s.height=o));let c=s.getContext(`2d`);return c&&a&&(c.fillStyle=a,c.fillRect(0,0,s.width,s.height)),{canvas:s,context2d:c}}function Vo(e,t){if(e.ownerDocument)try{let t=e.toDataURL();if(t!==`data:,`)return Do(t,e.ownerDocument)}catch(e){t.log.warn(`Failed to clone canvas`,e)}let n=e.cloneNode(!1),r=e.getContext(`2d`),i=n.getContext(`2d`);try{return r&&i&&i.putImageData(r.getImageData(0,0,e.width,e.height),0,0),n}catch(e){t.log.warn(`Failed to clone canvas`,e)}return n}function Ho(e,t){try{if(e?.contentDocument?.documentElement)return cs(e.contentDocument.documentElement,t)}catch(e){t.log.warn(`Failed to clone iframe`,e)}return e.cloneNode(!1)}function Uo(e){let t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=``),t.loading===`lazy`&&(t.loading=`eager`),t}async function Wo(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return Do(e.poster,e.ownerDocument);let n=e.cloneNode(!1);n.crossOrigin=`anonymous`,e.currentSrc&&e.currentSrc!==e.src&&(n.src=e.currentSrc);let r=n.ownerDocument;if(r){let i=!0;if(await Oo(n,{onError:()=>i=!1,onWarn:t.log.warn}),!i)return e.poster?Do(e.poster,e.ownerDocument):n;n.currentTime=e.currentTime,await new Promise(e=>{n.addEventListener(`seeked`,e,{once:!0})});let a=r.createElement(`canvas`);a.width=e.offsetWidth,a.height=e.offsetHeight;try{let e=a.getContext(`2d`);e&&e.drawImage(n,0,0,a.width,a.height)}catch(r){return t.log.warn(`Failed to clone video`,r),e.poster?Do(e.poster,e.ownerDocument):n}return Vo(a,t)}return n}function Go(e,t){return co(e)?Vo(e,t):go(e)?Ho(e,t):oo(e)?Uo(e):so(e)?Wo(e,t):e.cloneNode(!1)}function Ko(e){let t=e.sandbox;if(!t){let{ownerDocument:n}=e;try{n&&(t=n.createElement(`iframe`),t.id=`__SANDBOX__${Ao()}`,t.width=`0`,t.height=`0`,t.style.visibility=`hidden`,t.style.position=`fixed`,n.body.appendChild(t),t.srcdoc=`<!DOCTYPE html><meta charset="UTF-8"><title></title><body>`,e.sandbox=t)}catch(t){e.log.warn(`Failed to getSandBox`,t)}}return t}var qo=[`width`,`height`,`-webkit-text-fill-color`],Jo=[`stroke`,`fill`];function Yo(e,t,n){let{defaultComputedStyles:r}=n,i=e.nodeName.toLowerCase(),a=eo(e)&&i!==`svg`,o=a?Jo.map(t=>[t,e.getAttribute(t)]).filter(([,e])=>e!==null):[],s=[a&&`svg`,i,o.map((e,t)=>`${e}=${t}`).join(`,`),t].filter(Boolean).join(`:`);if(r.has(s))return r.get(s);let c=Ko(n)?.contentWindow;if(!c)return new Map;let l=c?.document,u,d;a?(u=l.createElementNS(So,`svg`),d=u.ownerDocument.createElementNS(u.namespaceURI,i),o.forEach(([e,t])=>{d.setAttributeNS(null,e,t)}),u.appendChild(d)):u=d=l.createElement(i),d.textContent=` `,l.body.appendChild(u);let f=c.getComputedStyle(d,t),p=new Map;for(let e=f.length,t=0;t<e;t++){let e=f.item(t);qo.includes(e)||p.set(e,f.getPropertyValue(e))}return l.body.removeChild(u),r.set(s,p),p}function Xo(e,t,n){let r=new Map,i=[],a=new Map;if(n)for(let e of n)o(e);else for(let t=e.length,n=0;n<t;n++)o(e.item(n));for(let e=i.length,t=0;t<e;t++)a.get(i[t])?.forEach((e,t)=>r.set(t,e));function o(n){let o=e.getPropertyValue(n),s=e.getPropertyPriority(n),c=n.lastIndexOf(`-`),l=c>-1?n.substring(0,c):void 0;if(l){let e=a.get(l);e||(e=new Map,a.set(l,e)),e.set(n,[o,s])}(t.get(n)!==o||s)&&(l?i.push(l):r.set(n,[o,s]))}return r}function Zo(e,t,n,r){let{ownerWindow:i,includeStyleProperties:a,currentParentNodeStyle:o}=r,s=t.style,c=i.getComputedStyle(e),l=Yo(e,null,r);o?.forEach((e,t)=>{l.delete(t)});let u=Xo(c,l,a);u.delete(`transition-property`),u.delete(`all`),u.delete(`d`),u.delete(`content`),n&&(u.delete(`position`),u.delete(`margin-top`),u.delete(`margin-right`),u.delete(`margin-bottom`),u.delete(`margin-left`),u.delete(`margin-block-start`),u.delete(`margin-block-end`),u.delete(`margin-inline-start`),u.delete(`margin-inline-end`),u.set(`box-sizing`,[`border-box`,``])),u.get(`background-clip`)?.[0]===`text`&&t.classList.add(`______background-clip--text`),Ka&&(u.has(`font-kerning`)||u.set(`font-kerning`,[`normal`,``]),(u.get(`overflow-x`)?.[0]===`hidden`||u.get(`overflow-y`)?.[0]===`hidden`)&&u.get(`text-overflow`)?.[0]===`ellipsis`&&e.scrollWidth===e.clientWidth&&u.set(`text-overflow`,[`clip`,``]));for(let e=s.length,t=0;t<e;t++)s.removeProperty(s.item(t));return u.forEach(([e,t],n)=>{s.setProperty(n,e,t)}),u}function Qo(e,t){(lo(e)||uo(e)||mo(e))&&t.setAttribute(`value`,e.value)}var $o=[`::before`,`::after`],es=[`::-webkit-scrollbar`,`::-webkit-scrollbar-button`,`::-webkit-scrollbar-thumb`,`::-webkit-scrollbar-track`,`::-webkit-scrollbar-track-piece`,`::-webkit-scrollbar-corner`,`::-webkit-resizer`];function ts(e,t,n,r,i){let{ownerWindow:a,svgStyleElement:o,svgStyles:s,currentNodeStyle:c}=r;if(!o||!a)return;function l(n){let o=a.getComputedStyle(e,n),l=o.getPropertyValue(`content`);if(!l||l===`none`)return;i?.(l),l=l.replace(/(')|(")|(counter\(.+\))/g,``);let u=[Ao()],d=Yo(e,n,r);c?.forEach((e,t)=>{d.delete(t)});let f=Xo(o,d,r.includeStyleProperties);f.delete(`content`),f.delete(`-webkit-locale`),f.get(`background-clip`)?.[0]===`text`&&t.classList.add(`______background-clip--text`);let p=[`content: '${l}';`];if(f.forEach(([e,t],n)=>{p.push(`${n}: ${e}${t?` !important`:``};`)}),p.length===1)return;try{t.className=[t.className,...u].join(` `)}catch(e){r.log.warn(`Failed to copyPseudoClass`,e);return}let m=p.join(`
8
- `),h=s.get(m);h||(h=[],s.set(m,h)),h.push(`.${u[0]}${n}`)}$o.forEach(l),n&&es.forEach(l)}var ns=new Set([`symbol`]);async function rs(e,t,n,r,i){if($a(n)&&(fo(n)||po(n))||r.filter&&!r.filter(n))return;r.currentParentNodeStyle=ns.has(t.nodeName)||ns.has(n.nodeName)?void 0:r.currentNodeStyle;let a=await cs(n,r,!1,i);r.isEnable(`restoreScrollPosition`)&&as(e,a),t.appendChild(a)}async function is(e,t,n,r){let i=e.firstChild;$a(e)&&e.shadowRoot&&(i=e.shadowRoot?.firstChild,n.shadowRoots.push(e.shadowRoot));for(let a=i;a;a=a.nextSibling)if(!io(a)){if($a(a)&&ho(a)&&typeof a.assignedNodes==`function`){let i=a.assignedNodes();for(let a=0;a<i.length;a++)await rs(e,t,i[a],n,r)}else await rs(e,t,a,n,r)}}function as(e,t){if(!ro(e)||!ro(t))return;let{scrollTop:n,scrollLeft:r}=e;if(!n&&!r)return;let{transform:i}=t.style,a=new DOMMatrix(i),{a:o,b:s,c,d:l}=a;a.a=1,a.b=0,a.c=0,a.d=1,a.translateSelf(-r,-n),a.a=o,a.b=s,a.c=c,a.d=l,t.style.transform=a.toString()}function os(e,t){let{backgroundColor:n,width:r,height:i,style:a}=t,o=e.style;if(n&&o.setProperty(`background-color`,n,`important`),r&&o.setProperty(`width`,`${r}px`,`important`),i&&o.setProperty(`height`,`${i}px`,`important`),a)for(let e in a)o[e]=a[e]}var ss=/^[\w-:]+$/;async function cs(e,t,n=!1,r){let{ownerDocument:i,ownerWindow:a,fontFamilies:o,onCloneEachNode:s}=t;if(i&&ao(e))return r&&/\S/.test(e.data)&&r(e.data),i.createTextNode(e.data);if(i&&a&&$a(e)&&(ro(e)||eo(e))){let r=await Go(e,t);if(t.isEnable(`removeAbnormalAttributes`)){let e=r.getAttributeNames();for(let t=e.length,n=0;n<t;n++){let t=e[n];ss.test(t)||r.removeAttribute(t)}}let i=t.currentNodeStyle=Zo(e,r,n,t);n&&os(r,t);let a=!1;if(t.isEnable(`copyScrollbar`)){let t=[i.get(`overflow-x`)?.[0],i.get(`overflow-y`)?.[0]];a=t.includes(`scroll`)||(t.includes(`auto`)||t.includes(`overlay`))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}let c=i.get(`text-transform`)?.[0],l=jo(i.get(`font-family`)?.[0]),u=l?e=>{c===`uppercase`?e=e.toUpperCase():c===`lowercase`?e=e.toLowerCase():c===`capitalize`&&(e=e[0].toUpperCase()+e.substring(1)),l.forEach(t=>{let n=o.get(t);n||o.set(t,n=new Set),e.split(``).forEach(e=>n.add(e))})}:void 0;return ts(e,r,a,t,u),Qo(e,r),so(e)||await is(e,r,t,u),await s?.(r),r}let c=e.cloneNode(!1);return await is(e,c,t),await s?.(c),c}function ls(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn(`Failed to destroyContext`,t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function us(e){let{url:t,timeout:n,responseType:r,...i}=e,a=new AbortController,o=n?setTimeout(()=>a.abort(),n):void 0;return fetch(t,{signal:a.signal,...i}).then(e=>{if(!e.ok)throw Error(`Failed fetch, not 2xx response`,{cause:e});switch(r){case`arrayBuffer`:return e.arrayBuffer();case`dataUrl`:return e.blob().then(Eo);default:return e.text()}}).finally(()=>clearTimeout(o))}function ds(e,t){let{url:n,requestType:r=`text`,responseType:i=`text`,imageDom:a}=t,o=n,{timeout:s,acceptOfImage:c,requests:l,fetchFn:u,fetch:{requestInit:d,bypassingCache:f,placeholderImage:p},font:m,workers:h,fontFamilies:g}=e;r===`image`&&(qa||Ja)&&e.drawImageCount++;let _=l.get(n);if(!_){f&&f instanceof RegExp&&f.test(o)&&(o+=(/\?/.test(o)?`&`:`?`)+new Date().getTime());let t=r.startsWith(`font`)&&m&&m.minify,v=new Set;t&&r.split(`;`)[1].split(`,`).forEach(e=>{g.has(e)&&g.get(e).forEach(e=>v.add(e))});let y=t&&v.size,b={url:o,timeout:s,responseType:y?`arrayBuffer`:i,headers:r===`image`?{accept:c}:void 0,...d};_={type:r,resolve:void 0,reject:void 0,response:null},_.response=(async()=>{if(u&&r===`image`){let e=await u(n);if(e)return e}return!qa&&n.startsWith(`http`)&&h.length?new Promise((e,t)=>{h[l.size&h.length-1].postMessage({rawUrl:n,...b}),_.resolve=e,_.reject=t}):us(b)})().catch(t=>{if(l.delete(n),r===`image`&&p)return e.log.warn(`Failed to fetch image base64, trying to use placeholder image`,o),typeof p==`string`?p:p(a);throw t}),l.set(n,_)}return _.response}async function fs(e,t,n,r){if(!ps(e))return e;for(let[i,a]of hs(e,t))try{let t=await ds(n,{url:a,requestType:r?`image`:`text`,responseType:`dataUrl`});e=e.replace(gs(i),`$1${t}$3`)}catch(e){n.log.warn(`Failed to fetch css data url`,i,e)}return e}function ps(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}var ms=/url\((['"]?)([^'"]+?)\1\)/g;function hs(e,t){let n=[];return e.replace(ms,(e,r,i)=>(n.push([i,bo(i,t)]),e)),n.filter(([e])=>!yo(e))}function gs(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}var _s=[`background-image`,`border-image-source`,`-webkit-border-image`,`-webkit-mask-image`,`list-style-image`];function vs(e,t){return _s.map(n=>{let r=e.getPropertyValue(n);return!r||r===`none`?null:((qa||Ja)&&t.drawImageCount++,fs(r,null,t,!0).then(t=>{t&&r!==t&&e.setProperty(n,t,e.getPropertyPriority(n))}))}).filter(Boolean)}function ys(e,t){if(oo(e)){let n=e.currentSrc||e.src;if(!yo(n))return[ds(t,{url:n,imageDom:e,requestType:`image`,responseType:`dataUrl`}).then(t=>{t&&(e.srcset=``,e.dataset.originalSrc=n,e.src=t||``)})];(qa||Ja)&&t.drawImageCount++}else if(eo(e)&&!yo(e.href.baseVal)){let n=e.href.baseVal;return[ds(t,{url:n,imageDom:e,requestType:`image`,responseType:`dataUrl`}).then(t=>{t&&(e.dataset.originalSrc=n,e.href.baseVal=t||``)})]}return[]}function bs(e,t){let{ownerDocument:n,svgDefsElement:r}=t,i=e.getAttribute(`href`)??e.getAttribute(`xlink:href`);if(!i)return[];let[a,o]=i.split(`#`);if(o){let i=`#${o}`,s=t.shadowRoots.reduce((e,t)=>e??t.querySelector(`svg ${i}`),n?.querySelector(`svg ${i}`));if(a&&e.setAttribute(`href`,i),r?.querySelector(i))return[];if(s)return r?.appendChild(s.cloneNode(!0)),[];if(a)return[ds(t,{url:a,responseType:`text`}).then(e=>{r?.insertAdjacentHTML(`beforeend`,e)})]}return[]}function xs(e,t){let{tasks:n}=t;$a(e)&&((oo(e)||to(e))&&n.push(...ys(e,t)),no(e)&&n.push(...bs(e,t))),ro(e)&&n.push(...vs(e.style,t)),e.childNodes.forEach(e=>{xs(e,t)})}async function Ss(e,t){let{ownerDocument:n,svgStyleElement:r,fontFamilies:i,fontCssTexts:a,tasks:o,font:s}=t;if(n&&r&&i.size){if(s&&s.cssText){let e=Os(s.cssText,t);r.appendChild(n.createTextNode(`${e}
9
- `))}else{let e=Array.from(n.styleSheets).filter(e=>{try{return`cssRules`in e&&!!e.cssRules.length}catch(n){return t.log.warn(`Error while reading CSS rules from ${e.href}`,n),!1}}),s=n.implementation.createHTMLDocument(``),c=s.createElement(`style`);s.head.appendChild(c);let l=c.sheet;await Promise.all(e.flatMap(e=>Array.from(e.cssRules).map(async e=>{if(Za(e)){let n=e.href,r=``;try{r=await ds(t,{url:n,requestType:`text`,responseType:`text`})}catch(e){t.log.warn(`Error fetch remote css import from ${n}`,e)}let i=r.replace(ms,(e,t,r)=>e.replace(r,bo(r,n)));for(let e of Ts(i))try{l.insertRule(e,l.cssRules.length)}catch(n){t.log.warn(`Error inserting rule from remote css import`,{rule:e,error:n})}}}))),l.cssRules.length&&e.push(l);let u=[];e.forEach(e=>{ks(e.cssRules,u)}),u.filter(e=>Xa(e)&&ps(e.style.getPropertyValue(`src`))&&jo(e.style.getPropertyValue(`font-family`))?.some(e=>i.has(e))).forEach(e=>{let i=e,s=a.get(i.cssText);s?r.appendChild(n.createTextNode(`${s}
10
- `)):o.push(fs(i.cssText,i.parentStyleSheet?i.parentStyleSheet.href:null,t).then(e=>{e=Os(e,t),a.set(i.cssText,e),r.appendChild(n.createTextNode(`${e}
11
- `))}))})}}}var Cs=/(\/\*[\s\S]*?\*\/)/g,ws=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Ts(e){if(e==null)return[];let t=[],n=e.replace(Cs,``);for(;;){let e=ws.exec(n);if(!e)break;t.push(e[0])}n=n.replace(ws,``);let r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=r.exec(n);if(e)i.lastIndex=r.lastIndex;else if(e=i.exec(n),e)r.lastIndex=i.lastIndex;else break;t.push(e[0])}return t}var Es=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ds=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Os(e,t){let{font:n}=t,r=n?n?.preferredFormat:void 0;return r?e.replace(Ds,e=>{for(;;){let[t,,n]=Es.exec(e)||[];if(!n)return``;if(n===r)return`src: ${t};`}}):e}function ks(e,t=[]){for(let n of Array.from(e))Qa(n)?t.push(...ks(n.cssRules)):`cssRules`in n?ks(n.cssRules,t):t.push(n);return t}var As=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function js(e){return As.test(e.innerHTML)}async function Ms(e,t){let n=await Fo(e,t);if($a(n.node)&&eo(n.node)&&!js(n.node))return n.node;let{ownerDocument:r,log:i,tasks:a,svgStyleElement:o,svgDefsElement:s,svgStyles:c,font:l,progress:u,autoDestruct:d,onCloneNode:f,onEmbedNode:p,onCreateForeignObjectSvg:m}=n;i.time(`clone node`);let h=await cs(n.node,n,!0);if(o&&r){let e=``;c.forEach((t,n)=>{e+=`${t.join(`,
12
- `)} {
13
- ${n}
14
- }
15
- `}),o.appendChild(r.createTextNode(e))}i.timeEnd(`clone node`),await f?.(h),l!==!1&&$a(h)&&(i.time(`embed web font`),await Ss(h,n),i.timeEnd(`embed web font`)),i.time(`embed node`),xs(h,n);let g=a.length,_=0,v=async()=>{for(;;){let e=a.pop();if(!e)break;try{await e}catch(e){n.log.warn(`Failed to run task`,e)}u?.(++_,g)}};u?.(_,g),await Promise.all([...Array.from({length:4})].map(v)),i.timeEnd(`embed node`),await p?.(h);let y=Ns(h,n);return s&&y.insertBefore(s,y.children[0]),o&&y.insertBefore(o,y.children[0]),d&&ls(n),await m?.(y),y}function Ns(e,t){let{width:n,height:r}=t,i=Co(n,r,e.ownerDocument),a=i.ownerDocument.createElementNS(i.namespaceURI,`foreignObject`);return a.setAttributeNS(null,`x`,`0%`),a.setAttributeNS(null,`y`,`0%`),a.setAttributeNS(null,`width`,`100%`),a.setAttributeNS(null,`height`,`100%`),a.append(e),i.appendChild(a),i}async function Ps(e,t){let n=await Fo(e,t),r=await Ms(n),i=wo(r,n.isEnable(`removeControlCharacter`));return n.autoDestruct||(n.svgStyleElement=Lo(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(So,`defs`),n.svgStyles.clear()),await zo(Do(i,r.ownerDocument),n)}async function Fs(e,t){let n=await Fo(e,t),{log:r,quality:i,type:a,dpi:o}=n,s=await Ps(n);r.time(`canvas to data url`);let c=s.toDataURL(a,i);if([`image/png`,`image/jpeg`].includes(a)&&o&&Ua&&Wa){let[e,t]=c.split(`,`),n=0,r=!1;if(a===`image/png`){let e=za(t);e>=0?(n=Math.ceil((e+28)/3)*4,r=!0):n=44}else a===`image/jpeg`&&(n=24);let i=t.substring(0,n),s=t.substring(n),l=window.atob(i),u=new Uint8Array(l.length);for(let e=0;e<u.length;e++)u[e]=l.charCodeAt(e);let d=a===`image/png`?Fa(u,o,r):Ea(u,o);c=[e,`,`,window.btoa(String.fromCharCode(...d)),s].join(``)}return r.timeEnd(`canvas to data url`),c}async function Is(e,t){return Fs(await Fo(e,{...t,type:`image/png`}))}var K=t(i(),1),Ls=null,Rs=!1,zs=0,Bs=new Set,Vs=()=>{for(let e of Bs)e()};async function Hs(e){if(Rs)return;Rs=!0,Vs();let t=await Js();Rs=!1,zs+=1,Ls={context:e,shot:t,n:zs},Vs()}var Us=()=>{Ls=null,Vs()},Ws=e=>(Bs.add(e),()=>{Bs.delete(e)}),Gs=()=>(0,G.useSyncExternalStore)(Ws,()=>Ls),Ks=()=>(0,G.useSyncExternalStore)(Ws,()=>Rs);function qs(e){if(e instanceof HTMLInputElement){if(![`button`,`submit`,`checkbox`,`radio`,`range`,`color`,`hidden`].includes(e.type)){let t=e.value?`•`.repeat(Math.min(12,e.value.length)):``;e.setAttribute(`value`,t),e.value=t}}else if(e instanceof HTMLTextAreaElement){let t=e.value?`•`.repeat(Math.min(24,e.value.length)):``;e.textContent=t,e.value=t}else e instanceof HTMLElement&&(e.isContentEditable||e.dataset.private!==void 0)&&(e.style.filter=`blur(6px)`)}async function Js(){try{return await Is(document.body,{scale:Math.min(2,window.devicePixelRatio||1),width:window.innerWidth,height:window.innerHeight,style:{transform:`translateY(-${window.scrollY}px)`},backgroundColor:getComputedStyle(document.body).backgroundColor||`#fff`,onCloneEachNode:qs,filter:e=>!(e instanceof HTMLElement&&e.dataset.reportSkip!==void 0)})}catch(e){return console.warn(`[report] no screenshot:`,e.message),null}}function Ys(e,t,n){if(!e||!t)return;let r=e.getContext(`2d`);if(r){r.drawImage(t,0,0,e.width,e.height);for(let t of n)if(t.tool===`pen`){r.strokeStyle=`#e11d48`,r.lineWidth=Math.max(3,e.width/300),r.lineCap=`round`,r.lineJoin=`round`,r.beginPath();for(let[e,[n,i]]of t.points.entries())e?r.lineTo(n,i):r.moveTo(n,i);r.stroke()}else{r.fillStyle=`#000`;let[e,n]=t.from,[i,a]=t.to;r.fillRect(Math.min(e,i),Math.min(n,a),Math.abs(i-e),Math.abs(a-n))}}}function Xs({src:e,onChange:t}){let n=(0,G.useRef)(null),r=(0,G.useRef)(null),[i,a]=(0,G.useState)(`pen`),[o,s]=(0,G.useState)([]),c=(0,G.useRef)(null),l=e=>Ys(n.current,r.current,e);(0,G.useEffect)(()=>{let t=new Image;t.onload=()=>{r.current=t;let e=n.current;e&&(e.width=t.naturalWidth,e.height=t.naturalHeight,Ys(e,t,[]))},t.src=e},[e]);let u=e=>{let t=n.current,r=t.getBoundingClientRect();return[(e.clientX-r.left)/r.width*t.width,(e.clientY-r.top)/r.height*t.height]},d=e=>{s(e),l(e),t(n.current.toDataURL(`image/png`))};return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:[(0,K.jsxs)(x,{size:`sm`,variant:i===`pen`?`quiet`:`ghost`,onClick:()=>a(`pen`),children:[(0,K.jsx)(dr,{className:`size-4`}),` `,W(`report.pen`)]}),(0,K.jsxs)(x,{size:`sm`,variant:i===`cover`?`quiet`:`ghost`,onClick:()=>a(`cover`),children:[(0,K.jsx)(ge,{className:`size-4 fill-current`}),` `,W(`report.cover`)]}),(0,K.jsxs)(x,{size:`sm`,variant:`ghost`,disabled:!o.length,onClick:()=>d(o.slice(0,-1)),children:[(0,K.jsx)(vt,{className:`size-4`}),` `,W(`report.undo`)]}),o.length?(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>d([]),"aria-label":`Clear`,children:(0,K.jsx)(N,{className:`size-4`})}):null]}),(0,K.jsx)(`canvas`,{ref:n,className:`w-full cursor-crosshair touch-none rounded-lg border border-border`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId);let t=u(e);c.current=i===`pen`?{tool:i,points:[t]}:{tool:i,from:t,to:t}},onPointerMove:e=>{let t=c.current;if(!t)return;let n=u(e);t.tool===`pen`?t.points.push(n):t.to=n,l([...o,t])},onPointerUp:()=>{let e=c.current;c.current=null,e&&d([...o,e])}})]})}function Zs(){let e=Gs();return Ks()?(0,K.jsx)(`div`,{"data-report-skip":!0,className:`pointer-events-none fixed inset-x-0 bottom-6 z-50 flex justify-center`,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2 rounded-full bg-ink px-4 py-2 text-paper text-sm`,children:[(0,K.jsx)(Fe,{className:`size-4`}),` `,W(`report.capturing`)]})}):e?(0,K.jsx)(Qs,{context:e.context,shot:e.shot},e.n):null}function Qs({context:e,shot:t}){let[n,r]=(0,G.useState)(null),[i,o]=(0,G.useState)(!!t),[c,l]=(0,G.useState)(!0),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(`idle`),g=D().map(a),_=a(window.location.href),v=async()=>{h(`sending`);try{let r=await fetch(fe(`/api/bug-reports`),{method:`POST`,headers:{"content-type":`application/json`},credentials:`include`,body:JSON.stringify({where:e.where,url:window.location.href.split(`?`)[0],runId:e.runId??null,comment:u.trim()||null,error:e.error?{message:a(e.error.message),stack:e.error.stack?a(e.error.stack):void 0}:null,logs:c?g:[],screenshot:i?n??t:null,contact:f.trim()||null})});h(r.ok?`sent`:`failed`)}catch{h(`failed`)}};return(0,K.jsx)(z,{open:!0,onClose:Us,title:W(`report.title`),wide:!0,height:`tall`,children:(0,K.jsx)(`div`,{className:`grid gap-5`,"data-report-skip":!0,children:m===`sent`?(0,K.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,K.jsx)(`p`,{className:`font-display font-semibold text-lg`,children:W(`report.sent`)}),(0,K.jsx)(x,{className:`mt-6`,onClick:Us,children:`OK`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-ink-3 text-sm`,children:W(`report.lead`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{hint:W(`report.whatHint`),children:W(`report.what`)}),(0,K.jsx)(Re,{"data-autofocus":!0,value:u,onChange:e=>d(e.target.value),rows:3})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(s,{hint:W(`report.screenshotHint`),children:W(`report.screenshot`)}),(0,K.jsx)(oe,{checked:i,disabled:!t,onChange:o,label:W(`report.screenshot`)})]}),t?i?(0,K.jsx)(Xs,{src:t,onChange:r}):null:(0,K.jsx)(`p`,{className:`text-ink-3 text-sm`,children:W(`report.noShot`)})]}),e.error?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`report.error`)}),(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-paper-2 p-3 text-xs`,children:a(e.error.message)})]}):null,(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(s,{hint:W(`report.logsHint`),children:W(`report.logs`,{count:g.length})}),(0,K.jsx)(oe,{checked:c,disabled:!g.length,onChange:l,label:W(`report.logs`,{count:g.length})})]}),c&&g.length?(0,K.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded-lg bg-paper-2 p-3 text-xs`,children:g.join(`
16
- `)}):null]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`report.page`)}),(0,K.jsxs)(`p`,{className:`break-all font-mono text-ink-3 text-xs`,children:[_,(0,K.jsx)(`br`,{}),navigator.userAgent]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`report.contact`)}),(0,K.jsx)(k,{type:`email`,value:f,onChange:e=>p(e.target.value)})]}),m===`failed`?(0,K.jsx)(`p`,{className:`text-rose text-sm`,children:W(`report.failed`)}):null,(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(x,{variant:`ghost`,onClick:Us,children:W(`report.cancel`)}),(0,K.jsx)(x,{onClick:()=>void v(),busy:m===`sending`,children:W(m===`sending`?`report.sending`:`report.send`)})]})]})})})}var $s={studio:`/`,work:`/work`,client:`/client`},ec=`wizards.mode`;function tc(e){if(!Ot(e.features,`workMode`))return[`studio`];let t=e.limits.create||Ot(e.features,`capabilities`)&&e.limits.build&&nc?[`studio`,`work`,`client`]:[`work`,`client`];return Ot(e.features,`pages`)?t:t.filter(e=>e!==`client`)}var nc=!1;function rc(e){if(e!==nc){nc=e,ac={...ac};for(let e of oc)e()}}function ic(){try{let e=JSON.parse(localStorage.getItem(ec)??`null`);return e&&typeof e==`object`?e:{}}catch{return{}}}var ac=ic(),oc=new Set;function sc(e,t){ac={...ac,[e.user.id]:t};try{localStorage.setItem(ec,JSON.stringify(ac))}catch{}for(let e of oc)e()}function cc(e){let t=(0,G.useSyncExternalStore)(e=>(oc.add(e),()=>oc.delete(e)),()=>ac);if(!e)return`studio`;let n=tc(e),r=t[e.user.id];return r&&n.includes(r)?r:n[0]??`studio`}var lc=`wizards.install-banner`,uc=`wizards.first-day`,dc=()=>window.matchMedia(`(pointer: coarse)`).matches;function fc({open:e,onClose:t}){let n=wa(),r=Ca(n),i=W(r===`prompt`?`install.app.offer`:r===`none`?`install.app.browser`:`install.app.how.${r}`);return(0,K.jsxs)(z,{open:e,onClose:t,title:W(`install.app.action`),children:[(0,K.jsx)(`p`,{className:`text-[0.9375rem] text-ink-2 leading-relaxed`,children:i}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(x,{variant:`ghost`,onClick:t,children:W(`install.app.close`)}),n?(0,K.jsx)(x,{onClick:()=>{Ta(n),t()},children:W(`install.app.action`)}):null]})]})}function pc(){try{return localStorage.getItem(lc)===`1`}catch{return!1}}var mc=()=>new Date().toLocaleDateString(`sv`);function hc(){try{let e=localStorage.getItem(uc);return e?e!==mc():(localStorage.setItem(uc,mc()),!1)}catch{return!1}}function gc({me:e}){let t=wa(),[n,r]=(0,G.useState)(pc),[i]=(0,G.useState)(hc);return!(t&&e.hasWizards&&i)||n||va()||dc()?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-paper-2 px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,K.jsx)(rt,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1`,children:W(`install.app.offer`)}),(0,K.jsx)(x,{size:`sm`,onClick:()=>void Ta(t),children:W(`install.app.action`)}),(0,K.jsx)(re,{label:W(`install.app.close`),onClick:()=>{try{localStorage.setItem(lc,`1`)}catch{}r(!0)},className:`size-8`,children:(0,K.jsx)(xe,{className:`size-4`})})]})}var _c=t(st(),1),vc={studio:d,work:C,client:ht},yc={studio:`dome`,work:`round`,client:`tower`},bc={named:2,stacked:2.75/2.125};function xc({me:e,look:t,stack:n,className:r}){let i=cc(e),a=tc(e),o=B(),s=(0,G.useRef)(null),[c,l]=(0,G.useState)(null),u=c??i,[d,f]=(0,G.useState)(null),p=(0,G.useRef)({look:t,w:0,h:0}),m=t===`stacked`,h=m||!!n,[g,_]=(0,G.useState)(!1),v=!!n&&!g;if((0,G.useEffect)(()=>{if(!(n&&g))return;let e=e=>{s.current?.contains(e.target)||(_(!1),l(null))};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[n,g]),(0,G.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let n=()=>{let n=p.current,r=t!==`row`&&(n.w!==e.clientWidth||n.h!==e.clientHeight),i=n.look!==t||r;p.current={look:t,w:e.clientWidth,h:e.clientHeight};let a=Array.from(e.querySelectorAll(`:scope > button`)),o=a.findIndex(e=>e.hasAttribute(`data-shown`)),s=a[o];if(!s){f(null);return}let c=getComputedStyle(e),l=Number.parseFloat(h?c.paddingTop:c.paddingLeft),u=Number.parseFloat(c.gap)||0,d=t===`row`?a.map(e=>{let t=e.querySelector(`[data-name]`),n=h?e.offsetHeight:e.offsetWidth;if(!t||h!==m)return n;let r=t.firstElementChild,i=e===s?m?r.scrollHeight:r.scrollWidth:0;return n-(m?t.offsetHeight:t.offsetWidth)+i}):(()=>{let n=bc[t],r=(m?e.clientHeight:e.clientWidth)-2*l-u*(a.length-1),i=a.length-1+n;return a.map(e=>r*(e===s?n:1)/i)})(),g=l+d.slice(0,o).reduce((e,t)=>e+t+u,0);f(h?{x:s.offsetLeft,y:g,w:s.offsetWidth,h:d[o],still:i}:{x:g,y:s.offsetTop,w:d[o],h:s.offsetHeight,still:i})};n();let r=new ResizeObserver(n);r.observe(e);for(let t of e.children)r.observe(t);return()=>r.disconnect()},[u,a.length,v,t]),a.length<2)return null;let y=t=>{if(v){_(!0);return}_(!1),l(null),t!==i&&(sc(e,t),o($s[t]))},b=n?[i,...a.filter(e=>e!==i)]:a,x=(0,K.jsxs)(`fieldset`,{ref:s,"aria-label":W(`mode.switch`),onPointerEnter:e=>{e.pointerType===`mouse`&&_(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&(l(null),_(!1))},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(l(null),_(!1))},className:V(`relative isolate flex shrink-0 gap-0.5 rounded-[14px] p-1 ring-1 ring-border-soft`,t===`named`?`w-full`:n?`w-max`:`w-fit`,h&&`flex-col`,n?V(`absolute top-0 right-0 z-40 bg-paper-2 transition-shadow duration-300`,g&&`shadow-overlay`):`bg-ink/5`,n?void 0:r),style:m?{height:`calc(2.75rem + ${a.length-1} * 2.25rem + 0.5rem)`}:void 0,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:V(`absolute top-0 left-0 rounded-[10px] bg-card shadow-soft transition-[transform,width,height,opacity] duration-200 ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none dark:ring-1 dark:ring-border-soft`,d&&!v?`opacity-100`:`opacity-0`),style:d?{transform:`translate(${d.x}px, ${d.y}px)`,width:d.w,height:d.h,transition:d.still?`none`:void 0}:void 0}),b.map((e,r)=>{let a=vc[e],o=W(`mode.${e}`),s=e===u;return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":e===i,"data-shown":s||void 0,onClick:()=>y(e),onMouseEnter:()=>(0,_c.flushSync)(()=>l(e)),onFocus:()=>{l(e),_(!0)},title:t===`row`&&!n?o:void 0,className:V(`relative flex items-center rounded-[10px] transition-[color,margin,opacity,background-color,box-shadow,flex-grow] duration-200 ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none`,s?`text-ink`:`text-ink-3`,m?`w-11 flex-col justify-center`:V(`h-8 coarse:h-9`,t===`row`&&`px-2 coarse:px-2.5`),t!==`row`&&`min-h-0 min-w-0 basis-0 justify-center`,n&&r>0&&(v?`-mt-[34px] opacity-0 coarse:-mt-[38px]`:`mt-0`),v&&r===0&&`bg-card shadow-soft dark:ring-1 dark:ring-border-soft`),style:{flexGrow:t===`row`?void 0:s?bc[t]:1,zIndex:n?b.length-r:void 0},children:[(0,K.jsx)(a,{className:`size-4 shrink-0`,strokeWidth:2}),t===`row`&&!n?(0,K.jsx)(`span`,{className:`sr-only`,children:o}):(0,K.jsx)(`span`,{"data-name":!0,className:V(`grid transition-[grid-template-columns,grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none`,m?s?`grid-rows-[1fr]`:`grid-rows-[0fr] opacity-0`:(n?g:s)?`grid-cols-[1fr]`:`grid-cols-[0fr] opacity-0`),children:(0,K.jsx)(`span`,{className:V(`overflow-hidden whitespace-nowrap font-medium`,m?`pt-0.5 text-center text-[0.625rem]`:V(`pl-1.5 text-[0.8125rem]`,n&&`pr-1.5 coarse:text-[0.875rem]`)),children:o})})]},e)})]});return n?(0,K.jsx)(`div`,{className:V(`relative size-10 shrink-0 coarse:size-11`,r),children:x}):x}function Sc(e){return e.mode===`managed`&&(e.organizations.length>1||e.mayCreateOrganization)}function Cc(e){if(e.slug){window.location.href=`${Ve}/${e.slug}/`;return}let t=new URLSearchParams({organization:e.id,return:`${Ve}/`});window.location.href=fe(`/api/auth/login?${t}`)}function wc(e){return e.organizations.find(t=>t.id===e.tenant.id)??(e.tenant.name?{id:e.tenant.id,name:e.tenant.name,slug:null,role:e.tenant.role,personal:!1,plan:e.tenant.plan}:null)}function Tc({org:e,size:t=`sm`}){return(0,K.jsx)(`span`,{"aria-hidden":`true`,className:V(`grid shrink-0 place-items-center font-semibold tracking-wide`,t===`md`?`size-10 text-[0.8125rem]`:t===`sm`?`size-9 text-[0.75rem]`:`size-7 text-[0.625rem]`,e.personal?`rounded-full bg-ember-tint text-ember-strong ring-1 ring-border-soft`:`rounded-lg bg-card text-ink-2 ring-1 ring-border`),children:Nt(e.name)})}function Ec(e){let t=B();return()=>{Ot(e.features,`teamPlans`)?t(`/settings/organization`):e.manageUrl&&window.open(`${e.manageUrl}/account`,`_blank`,`noreferrer`)}}function Dc({me:e,roomy:t,onDone:n}){let r=Ec(e),[i,a]=(0,G.useState)(null),s=V(`flex w-full items-center gap-3 rounded-lg px-3 text-left text-ink-2 transition hover:bg-accent hover:text-ink`,t?`py-3 text-[0.9375rem]`:`py-2 text-[0.875rem]`);return(0,K.jsxs)(K.Fragment,{children:[e.organizations.map(r=>{let s=r.id===e.tenant.id;return(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:i!==null,"aria-current":s?`true`:void 0,className:V(`flex w-full items-center gap-3 rounded-lg px-2 text-left transition hover:bg-accent disabled:cursor-default`,t?`py-2.5`:`py-1.5`),onClick:()=>{if(s){n();return}a(r.id),Cc(r)},children:[(0,K.jsx)(Tc,{org:r,size:t?`md`:`sm`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,K.jsx)(`span`,{className:V(`truncate`,t?`text-[0.9375rem]`:`text-[0.875rem]`,s?`font-semibold text-ink`:`font-medium text-ink-2`),children:r.name}),(0,K.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:i===r.id?W(`organizations.switching`,{name:r.name}):r.personal?W(`organizations.own`):W(`organization.role.${r.role}`)})]}),r.plan?(0,K.jsx)(`span`,{className:`shrink-0 whitespace-nowrap rounded-full px-2 py-0.5 font-medium text-[0.6875rem] text-ink-3 ring-1 ring-border`,children:r.plan.name}):null,(0,K.jsx)(`span`,{className:`grid w-4 shrink-0 place-items-center`,children:i===r.id?(0,K.jsx)(jr,{className:`size-4 animate-spin text-ink-3`}):s?(0,K.jsx)(o,{className:`size-4 text-ember-strong`}):null})]},r.id)}),(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,onClick:()=>{n(),r()},children:[(0,K.jsx)(Di,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:W(`organizations.manage`)})]}),e.mayCreateOrganization&&e.manageUrl?(0,K.jsxs)(`a`,{role:`menuitem`,className:s,href:`${e.manageUrl}/account`,target:`_blank`,rel:`noreferrer`,onClick:n,children:[(0,K.jsx)(Ke,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:W(`organizations.create`)}),(0,K.jsx)(Tn,{className:`size-3.5 shrink-0 text-ink-4`})]}):null]})}function Oc({me:e,className:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)({top:0,left:0}),o=(0,G.useRef)(null);t0(o,n,()=>r(!1));let s=wc(e);return s?Sc(e)?(0,K.jsxs)(`div`,{ref:o,className:V(`relative min-w-0 shrink`,t),children:[(0,K.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":n,title:W(`organizations.switch`),onClick:e=>{let t=e.currentTarget.getBoundingClientRect();a({top:t.bottom+6,left:t.left}),r(e=>!e)},className:V(`-ml-2 flex max-w-[13rem] items-center gap-1 rounded-md py-0.5 pr-1.5 pl-2 text-[0.9375rem] text-ink-2 transition hover:bg-accent hover:text-ink`,n&&`bg-accent text-ink`),children:[(0,K.jsx)(`span`,{className:`truncate`,children:s.name}),(0,K.jsx)(zn,{className:`size-3.5 shrink-0 text-ink-4`})]}),n?(0,K.jsxs)(`div`,{role:`menu`,style:{position:`fixed`,...i},className:`z-50 w-80 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:W(`organizations.mine`)}),(0,K.jsx)(Dc,{me:e,onDone:()=>r(!1)})]}):null]}):(0,K.jsx)(`span`,{className:V(`max-w-[12rem] truncate text-[0.9375rem] text-ink-3`,t),title:s.name,children:s.name}):null}function kc({me:e,open:t,onClose:n}){let r=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=r.current;t&&e&&!e.open?e.showModal():!t&&e?.open&&e.close()},[t]),(0,K.jsx)(`dialog`,{ref:r,onClose:n,onClick:e=>{e.target===r.current&&n()},"aria-label":W(`organizations.switch`),className:V(`max-h-[85dvh] overflow-y-auto overscroll-contain bg-card p-0 text-ink shadow-overlay backdrop:bg-[oklch(20%_0.01_60/0.28)]`,`max-sm:mx-0 max-sm:mt-auto max-sm:mb-0 max-sm:w-full max-sm:max-w-none max-sm:rounded-t-3xl`,`sm:m-auto sm:w-[calc(100%-32px)] sm:max-w-sm sm:rounded-2xl`),children:t?(0,K.jsxs)(`div`,{className:`px-3 pt-2 pb-[max(1rem,env(safe-area-inset-bottom))] sm:pt-3`,children:[(0,K.jsx)(`div`,{className:`mx-auto mb-2 h-1.5 w-9 rounded-full bg-border sm:hidden`}),(0,K.jsx)(Ac,{onClose:n,children:W(`organizations.switch`)}),(0,K.jsx)(Dc,{me:e,roomy:!0,onDone:n})]}):null})}function Ac({children:e,onClose:t}){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 pt-1 pb-2.5`,children:[(0,K.jsx)(`h2`,{className:`font-semibold text-[1.0625rem]`,children:e}),(0,K.jsx)(`button`,{type:`button`,onClick:t,"aria-label":W(`common.close`),className:`grid size-8 place-items-center rounded-full bg-paper-2 text-ink-3 transition hover:text-ink`,children:(0,K.jsx)(xe,{className:`size-4`})})]})}var jc=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function Mc({me:e,position:t,horizontal:n,labels:r}){let i=B(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),d=e.mode===`managed`?wc(e):null,f=Sc(e),p=Ec(e),m=wa(),h=(0,G.useRef)(null);t0(h,a,()=>o(!1)),(0,G.useEffect)(()=>{a||u(!1)},[a]);let g=e.mode===`local`,{data:_,check:v}=an(g),y=cc(e),b=tc(e).length>1?yc[y]:void 0;(0,G.useEffect)(()=>{let e=e=>{e.key===`,`&&(jc?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.preventDefault(),i(`/settings`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let x=e=>{o(!1),i(e)},S=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`,C=`ml-auto shrink-0 text-[0.75rem] text-ink-4`,w=(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),T=v.isPending?{text:W(`about.update.checking`),tone:C}:_?.newer&&_.latest?{text:_.latest,tone:`ml-auto shrink-0 text-[0.75rem] font-medium text-ember-strong`}:_?{text:W(`about.update.upToDateShort`),tone:`ml-auto shrink-0 text-[0.75rem] text-moss`}:null;return(0,K.jsxs)(`div`,{ref:h,className:V(`relative shrink-0`,r&&`w-full`),children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-haspopup":`menu`,title:W(`about.title`),"aria-label":W(`about.title`),className:V(`shrink-0 rounded-lg transition hover:bg-ink/10`,a&&`bg-ink/10`,r?`flex h-12 w-full items-center gap-2 px-1.5`:V(`grid place-items-center`,n?`size-11`:`h-12 w-11`)),children:[(0,K.jsx)(Bt,{size:32,kind:b}),r?(0,K.jsxs)(`span`,{className:`truncate font-display font-semibold text-[1rem] tracking-tight`,children:[`engenty`,(0,K.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,K.jsx)(`span`,{className:`ml-1 font-normal text-ink-3`,children:`wizards`})]}):null]}),a?(0,K.jsxs)(`div`,{role:`menu`,className:V(`absolute z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,_a(t,`start`)),children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-2 pb-2.5`,children:[(0,K.jsxs)(`span`,{className:`font-display font-semibold text-[1rem] tracking-tight`,children:[`engenty`,(0,K.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,K.jsx)(`span`,{className:`ml-1 font-normal text-ink-3`,children:`wizards`})]}),(0,K.jsx)(`span`,{className:V(C,`tabular-nums`),children:rn})]}),d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":f?`menu`:void 0,"aria-expanded":f?l:void 0,className:V(`flex w-full items-center gap-3 rounded-lg px-2.5 py-1.5 text-left transition hover:bg-accent`,l&&`bg-accent`),onClick:()=>{f?u(e=>!e):(o(!1),p())},children:[(0,K.jsx)(Tc,{org:d,size:`xs`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:d.name}),(0,K.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:d.plan?`${W(`organization.title`)} · ${d.plan.name}`:W(`organization.title`)})]}),f?(0,K.jsx)(ee,{className:`size-4 shrink-0 text-ink-4`}):null]}),l?(0,K.jsxs)(`div`,{role:`menu`,className:V(`absolute top-12 z-50 w-80 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,t===`right`?`right-full mr-1.5`:`left-full ml-1.5`),children:[(0,K.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:W(`organizations.switch`)}),(0,K.jsx)(Dc,{me:e,onDone:()=>o(!1)})]}):null,w]}):null,(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,className:S,onClick:()=>x(`/settings/about`),children:W(`about.title`)}),g?(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:S,onClick:()=>_?.newer?x(`/settings/about`):v.mutate(),children:[W(`about.update.check`),T?(0,K.jsx)(`span`,{className:T.tone,children:T.text}):null]}):null,(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,className:S,onClick:()=>x(`/settings/about?tab=new`),children:W(`about.tab.new`)}),w,(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:S,onClick:()=>x(`/settings`),children:[W(`nav.settings`),` …`,(0,K.jsx)(`span`,{className:C,children:jc?`⌘ ,`:`Ctrl ,`})]}),va()?null:(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,className:S,onClick:()=>{o(!1),m?Ta(m):c(!0)},children:W(`install.app.action`)}),w,(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,className:S,onClick:()=>x(`/settings/about?tab=credits`),children:W(`about.creditsMenu`)})]}):null,(0,K.jsx)(fc,{open:s,onClose:()=>c(!1)})]})}var Nc=[],Pc=0,Fc=new Set;function Ic(){for(let e of Fc)e()}function Lc(e){let t=(0,G.useRef)(e);t.current=e;let n=e!==null,r=e?.icon,i=e?.label;(0,G.useEffect)(()=>{if(!n||!r||i===void 0)return;let e=++Pc;return Nc=[...Nc,{id:e,action:{icon:r,label:i,run:()=>t.current?.run()}}],Ic(),()=>{Nc=Nc.filter(t=>t.id!==e),Ic()}},[n,r,i])}function Rc(){return(0,G.useSyncExternalStore)(e=>(Fc.add(e),()=>Fc.delete(e)),()=>Nc.at(-1)?.action??null,()=>null)}var zc=`vercel.ai.error`,Bc=Symbol.for(zc),Vc,Hc,Uc=class e extends (Hc=Error,Vc=Bc,Hc){constructor({name:e,message:t,cause:n}){super(t),this[Vc]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,zc)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},Wc=`AI_APICallError`,Gc=`vercel.ai.error.${Wc}`,Kc=Symbol.for(Gc),qc,Jc,Yc=class extends (Jc=Uc,qc=Kc,Jc){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:Wc,message:e,cause:o}),this[qc]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return Uc.hasMarker(e,Gc)}},Xc=`AI_EmptyResponseBodyError`,Zc=`vercel.ai.error.${Xc}`,Qc=Symbol.for(Zc),$c,el,tl=class extends (el=Uc,$c=Qc,el){constructor({message:e=`Empty response body`}={}){super({name:Xc,message:e}),this[$c]=!0}static isInstance(e){return Uc.hasMarker(e,Zc)}};function nl(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var rl=`AI_InvalidArgumentError`,il=`vercel.ai.error.${rl}`,al=Symbol.for(il),ol,sl,cl=class extends (sl=Uc,ol=al,sl){constructor({message:e,cause:t,argument:n}){super({name:rl,message:e,cause:t}),this[ol]=!0,this.argument=n}static isInstance(e){return Uc.hasMarker(e,il)}},ll=`AI_JSONParseError`,ul=`vercel.ai.error.${ll}`,dl=Symbol.for(ul),fl,pl,ml=class extends (pl=Uc,fl=dl,pl){constructor({text:e,cause:t}){super({name:ll,message:`JSON parsing failed: Text: ${e}.
17
- Error message: ${nl(t)}`,cause:t}),this[fl]=!0,this.text=e}static isInstance(e){return Uc.hasMarker(e,ul)}},hl=`AI_TypeValidationError`,gl=`vercel.ai.error.${hl}`,_l=Symbol.for(gl),vl,yl,bl=class e extends (yl=Uc,vl=_l,yl){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:hl,message:`${r}: Value: ${JSON.stringify(e)}.
18
- Error message: ${nl(t)}`,cause:t}),this[vl]=!0,this.value=e,this.context=n}static isInstance(e){return Uc.hasMarker(e,gl)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},xl=`AI_UnsupportedFunctionalityError`,Sl=`vercel.ai.error.${xl}`,Cl=Symbol.for(Sl),wl,Tl,El=class extends (Tl=Uc,wl=Cl,Tl){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:xl,message:t}),this[wl]=!0,this.functionality=e}static isInstance(e){return Uc.hasMarker(e,Sl)}};function Dl(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Ol(e,t=`|`){return e.map(e=>nu(e)).join(t)}function kl(e,t){return typeof t==`bigint`?t.toString():t}var Al=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function jl(e){return new Al(e)}function Ml(e){return e==null}function Nl(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Pl(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Fl=Symbol(`evaluating`);function Il(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Fl)return r===void 0&&(r=Fl,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ll(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Rl(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function zl(e){return Rl(e._zod.def)??e._zod.def.shape}function Bl(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ll(this,t,e),e},enumerable:!0,configurable:!0})}function Vl(e,t,n){t in e?Ll(e,t,n):e[t]=n}function Hl(e,t,n,r){let i=zl(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Bl(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Vl(e,a,r?r(n.value,a):n.value))}}function Ul(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Bl(e,n,()=>t[n]):Vl(e,n,r.value))}}function Wl(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Gl(e){return JSON.stringify(e)}function Kl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var ql=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Jl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Yl=jl(()=>{if(Ku.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Xl(e){if(Jl(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Jl(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Zl(e){return Xl(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ql=new Set([`string`,`number`,`symbol`]);function $l(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function eu(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function tu(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function nu(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function ru(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var iu={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},au={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ou(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Hl(i,e,su(e,t)),eu(e,Wl(n,{shape:i,checks:[]}))}function su(e,t){let n=zl(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function cu(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(su(e,t)),a={};return Hl(a,e,Reflect.ownKeys(zl(e)).filter(e=>!i.has(e))),eu(e,Wl(n,{shape:a,checks:[]}))}function lu(e,t){if(!Xl(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=zl(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eu(e,Wl(e._zod.def,{shape:uu(e,t)}))}function uu(e,t){let n={};return Hl(n,e,Reflect.ownKeys(zl(e))),Ul(n,t),n}function du(e,t){if(!Xl(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return eu(e,Wl(e._zod.def,{shape:uu(e,t)}))}function fu(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Hl(n,e,Reflect.ownKeys(zl(e))),Hl(n,t,Reflect.ownKeys(zl(t))),eu(e,Wl(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function pu(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(su(t,n)):void 0,o={};return Hl(o,t,Reflect.ownKeys(zl(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),eu(t,Wl(t._zod.def,{shape:o,checks:[]}))}function mu(e,t,n){let r=n?new Set(su(t,n)):void 0,i={};return Hl(i,t,Reflect.ownKeys(zl(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),eu(t,Wl(t._zod.def,{shape:i}))}function hu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function gu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function _u(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function vu(e){return typeof e==`string`?e:e?.message}function yu(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function bu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function xu(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:vu(e.inst?._zod.def?.error?.(e))??vu(a?.(e))??vu(t?.error?.(e))??vu(n.customError?.(e))??vu(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Su=/[\uD800-\uDBFF]/;function Cu(e){let t=e.length;if(!Su.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function wu(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Tu(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Eu(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Du(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ju(e,n,r.value)}}function Ou(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ku(e,t,n){return Ou(e,t,n,!1)}function Au(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ou(this,n,r(this))},set(e){Ou(this,n,e)}})}return t}function ju(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ou(this,t,n.bind(this))},set(e){Ou(this,t,e)}})}function Mu(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Nu,Pu=!1,Fu={configurable:!0,get(){Pu=!0}};function Iu(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Nu!==e._zod){Nu=void 0;return}Nu=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Fu);let e=Pu;Pu=!1;try{let r=n(this);return Pu?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Pu||=e,r}catch(n){throw delete this[t],Pu||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Lu(e,t,n,r){let i=Mu(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Ru=`~constantCatch`;function zu(e){let t=()=>e;return t[Ru]=!0,t}var Bu,Vu={value:void 0,enumerable:!1},Hu=`captureStackTrace`in Error?Error:null;function Uu(e){let t=Hu;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Hu=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function q(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Vu.value=new a(r);try{Object.defineProperty(n,"_zod",Vu)}finally{Vu.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Du(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Uu(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Wu=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Gu=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Bu=globalThis).__zod_globalConfig??(Bu.__zod_globalConfig={});var Ku=globalThis.__zod_globalConfig;function qu(e){return e&&Object.assign(Ku,e),Ku}function Ju(){let e=this._zod;return e.message??=JSON.stringify(e.def,kl,2),e.message}function Yu(e){this._zod.message=e}var Xu={get:Ju,set:Yu,enumerable:!0,configurable:!0},Zu={value:void 0,enumerable:!1},Qu=new WeakSet([Object.prototype,Error.prototype]),$u=(e,t)=>{e.name=`$ZodError`,Zu.value=t,Object.defineProperty(e,"issues",Zu),Zu.value=void 0,Object.defineProperty(e,"message",Xu);let n=Object.getPrototypeOf(e);Qu.has(n)||(Qu.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},ed=q(`$ZodError`,$u);q(`$ZodError`,$u,void 0,{Parent:Error});function td(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function nd(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?td(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function rd(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function id(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ad=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Wu;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xu(e,o,qu())));throw ql(n,a?.callee??t),n}return s.value};return t},od=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xu(e,o,qu())));throw ql(n,a?.callee??t),n}return s.value};return t},sd=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Wu;return a.issues.length?cd(e,a.issues,i):{success:!0,data:a.value}};function cd(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>xu(e,n,qu()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var ld=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?cd(e,a.issues,i):{success:!0,data:a.value}},ud=Symbol.for(`zod.compile.invalid`),dd=Symbol.for(`zod.compile.fallback`),fd=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ud)return!0;if(r.definite===!0&&n===void 0)return!1}return pd(e,t,n)});function pd(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[dd]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Wu;return a.issues.length===0}var md=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},hd=e=>{let t=ad(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,id(n,a))};return n},gd=e=>{let t=ad(e),n=(e,r,i,a)=>t(e,r,i,id(n,a));return n},_d=e=>{let t=od(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,id(n,a))};return n},vd=e=>{let t=od(e),n=async(e,r,i,a)=>await t(e,r,i,id(n,a));return n},yd=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return sd(e)(t,n,i)},bd=e=>(t,n,r)=>sd(e)(t,n,r),xd=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ld(e)(t,n,i)},Sd=e=>async(t,n,r)=>ld(e)(t,n,r),Cd=/^[cC][0-9a-z]{6,}$/,wd=/^[0-9a-z]+$/,Td=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ed=/^[0-9a-vA-V]{20}$/,Dd=/^[A-Za-z0-9]{27}$/,Od=/^[a-zA-Z0-9_-]{21}$/;function kd(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Ad=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,jd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Md=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Nd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Pd=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Fd(){return new RegExp(Pd,`u`)}var Id=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ld=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Rd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vd=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Hd=/^https?$/,Ud=/^\+[1-9]\d{6,14}$/,Wd=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Gd(e){return RegExp(`^${e}$`)}var Kd=Gd(Wd);function qd(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Jd(e){return RegExp(`^${qd(e)}$`)}function Yd(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${qd({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${qd({precision:e.precision})}`:n;return RegExp(`^${Wd}T(?:${r})$`)}var Xd=/^[\s\S]{0,}$/,Zd=/^-?\d+$/,Qd=/^-?\d+(?:\.\d+)?$/,$d=/^(?:true|false)$/i,ef=/^null$/i,tf=/^[^A-Z]*$/,nf=/^[^a-z]*$/,rf=q(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),af=e=>{let t=e.value;return!Ml(t)&&t.length!==void 0},of={number:`number`,bigint:`bigint`,object:`date`},sf=q(`$ZodCheckLessThan`,(e,t)=>{rf.init(e,t);let n=of[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:of[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),cf=q(`$ZodCheckGreaterThan`,(e,t)=>{rf.init(e,t);let n=of[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:of[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lf=q(`$ZodCheckMultipleOf`,(e,t)=>{rf.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Pl(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),uf=q(`$ZodCheckNumberFormat`,(e,t)=>{rf.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=iu[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),df=q(`$ZodCheckMaxLength`,(e,t)=>{var n;rf.init(e,t),(n=e._zod.def).when??(n.when=af),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Cu(r):i)<=t.maximum)return;let a=wu(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ff=q(`$ZodCheckMinLength`,(e,t)=>{var n;rf.init(e,t),(n=e._zod.def).when??(n.when=af),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Cu(r):i)>=t.minimum)return;let a=wu(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pf=q(`$ZodCheckLengthEquals`,(e,t)=>{var n;rf.init(e,t),(n=e._zod.def).when??(n.when=af),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Cu(r):i;if(a===t.length)return;let o=wu(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),mf=q(`$ZodCheckStringFormat`,(e,t)=>{var n,r;rf.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hf=q(`$ZodCheckRegex`,(e,t)=>{mf.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gf=q(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=tf,mf.init(e,t)}),_f=q(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=nf,mf.init(e,t)}),vf=q(`$ZodCheckIncludes`,(e,t)=>{rf.init(e,t);let n=$l(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),yf=q(`$ZodCheckStartsWith`,(e,t)=>{rf.init(e,t);let n=RegExp(`^${$l(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bf=q(`$ZodCheckEndsWith`,(e,t)=>{rf.init(e,t);let n=RegExp(`.*${$l(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function xf(e,t,n){e.issues.length&&t.issues.push(..._u(n,e.issues))}var Sf=q(`$ZodCheckProperties`,(e,t)=>{rf.init(e,t),ku(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:`object`,code:`invalid_type`,input:r.value,inst:e});return}n??=Reflect.ownKeys(t.shape).map(e=>[e,t.shape[e]]);let i=r.value,a;for(let[e,t]of n){let n=t._zod.run({value:i[e],issues:[]},{});n instanceof Promise?(a??=[],a.push(n.then(t=>xf(t,r,e)))):xf(n,r,e)}if(a)return Promise.all(a).then(()=>void 0)}}),Cf=q(`$ZodCheckOverwrite`,(e,t)=>{rf.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),wf=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
19
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
20
- `)}\n};`)(...Object.values(this.closed))}},Tf={major:4,minor:6,patch:7},Ef=q(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tf;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=hu(t),a;for(let o of n){if(o._zod.def.when){if(gu(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Wu;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(bu(t.issues,n,e),i||=hu(t,n))});else{if(t.issues.length===n)continue;bu(t.issues,n,e),i||=hu(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(hu(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Wu;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Wu;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ku(this,`~standard`,kf(this))},set"~standard"(e){Ou(this,`~standard`,e)}}),Df=(e,t)=>e.issues.length?{issues:e.issues.map(e=>xu(e,t,qu()))}:{value:e.value};async function Of(e,t){let n={async:!0};return Df(await e._zod.run({value:t,issues:[]},n),n)}function kf(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Df(r,n)}catch{}return Of(e,t)},vendor:`zod`,version:1}}var Af=q(`$ZodString`,(e,t)=>{Ef.init(e,t),e._zod.pattern=t.pattern??Xd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),jf=q(`$ZodStringFormat`,(e,t)=>{mf.init(e,t),Af.init(e,t)}),Mf=q(`$ZodGUID`,(e,t)=>{t.pattern??=jd,jf.init(e,t)}),Nf=q(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Md(e)}else t.pattern??=Md();jf.init(e,t)}),Pf=q(`$ZodEmail`,(e,t)=>{t.pattern??=Nd,jf.init(e,t)});function Ff(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function If(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ff(e)||2:Lf(e,t)}function Lf(e,t){if(!t.normalize&&t.protocol?.source===Hd.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Rf=/[\t\n\r]/g;function zf(e){return e.replace(Rf,``)}function Bf(e,t){return t.lastIndex=0,t.test(e.hostname)}function Vf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Hf=q(`$ZodURL`,(e,t)=>{jf.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=If(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=zf(r);return}t.hostname&&!Bf(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Vf(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:zf(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Uf=q(`$ZodEmoji`,(e,t)=>{t.pattern??=Fd(),jf.init(e,t)}),Wf=q(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Od:kd(t.length),jf.init(e,t)}),Gf=q(`$ZodCUID`,(e,t)=>{t.pattern??=Cd,jf.init(e,t)}),Kf=q(`$ZodCUID2`,(e,t)=>{t.pattern??=wd,jf.init(e,t)}),qf=q(`$ZodULID`,(e,t)=>{t.pattern??=Td,jf.init(e,t)}),Jf=q(`$ZodXID`,(e,t)=>{t.pattern??=Ed,jf.init(e,t)}),Yf=q(`$ZodKSUID`,(e,t)=>{t.pattern??=Dd,jf.init(e,t)}),Xf=q(`$ZodISODateTime`,(e,t)=>{t.pattern??=Yd(t),jf.init(e,t)}),Zf=q(`$ZodISODate`,(e,t)=>{t.pattern??=Kd,jf.init(e,t)}),Qf=q(`$ZodISOTime`,(e,t)=>{t.pattern??=Jd(t),jf.init(e,t)}),$f=q(`$ZodISODuration`,(e,t)=>{t.pattern??=Ad,jf.init(e,t)}),ep=q(`$ZodIPv4`,(e,t)=>{t.pattern??=Id,jf.init(e,t)}),tp=/^[0-9a-fA-F:.]+$/;function np(e){return tp.test(e)?Ff(`http://[${e}]`):!1}var rp=q(`$ZodIPv6`,(e,t)=>{t.pattern??=Ld,jf.init(e,t),e._zod.check=n=>{np(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),ip=q(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Rd,jf.init(e,t)});function ap(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:np(n)}var op=q(`$ZodCIDRv6`,(e,t)=>{t.pattern??=zd,jf.init(e,t),e._zod.check=n=>{ap(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function sp(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var cp=/^[0-9a-zA-Z+/]*={0,2}$/,lp=q(`$ZodBase64`,(e,t)=>{t.pattern??=cp,jf.init(e,t),e._zod.check=n=>{sp(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),up=/^[A-Za-z0-9_-]*$/;function dp(e){if(!up.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return sp(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var fp=q(`$ZodBase64URL`,(e,t)=>{t.pattern??=up,jf.init(e,t),e._zod.check=n=>{dp(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),pp=q(`$ZodE164`,(e,t)=>{t.pattern??=Ud,jf.init(e,t)});function mp(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var hp=q(`$ZodJWT`,(e,t)=>{jf.init(e,t),e._zod.check=n=>{mp(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),gp=q(`$ZodNumber`,(e,t)=>{Ef.init(e,t),e._zod.pattern=Qd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),_p=q(`$ZodNumberFormat`,(e,t)=>{uf.init(e,t),gp.init(e,t)}),vp=q(`$ZodBoolean`,(e,t)=>{Ef.init(e,t),e._zod.pattern=$d,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),yp=q(`$ZodNull`,(e,t)=>{Ef.init(e,t),e._zod.pattern=ef,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),bp=q(`$ZodUnknown`,(e,t)=>{Ef.init(e,t),e._zod.parse=e=>e}),xp=q(`$ZodNever`,(e,t)=>{Ef.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Sp(e,t){let n=yu(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of yu(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,bu(n.issues,t,e),n}}return i(n,a)}}var Cp=e=>Array.isArray(e)?e.length:-1;function wp(e,t,n){e.issues.length&&t.issues.push(..._u(n,e.issues)),t.value[n]=e.value}var Tp=q(`$ZodArray`,(e,t)=>{Ef.init(e,t);let n=Ku.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>wp(t,r,e)));else if(wp(c,r,e),s&&c.issues.length!==0&&hu(c))break}return o.length?Promise.all(o).then(()=>r):r},Sp(e,Cp)});function Ep(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(..._u(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Dp=[];function Op(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Dp,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=ru(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function kp(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(hu(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ep(e,n,i,t,d,f))):Ep(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Ap=q(`$ZodObject`,(e,t)=>{Ef.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=jl(()=>Op(t));Iu(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ll(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Jl,o=t.catchall,s,c=Ku.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(hu(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Ep(n,t,e,r,a,o))):Ep(s,t,e,r,a,o)}return o?kp(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),jp=q(`$ZodObjectJIT`,(e,t)=>{Ap.init(e,t);let n=e._zod.parse,r=jl(()=>Op(t)),i=Ku.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new wf([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
21
- let ${e}_ab = false;
22
- for (let i = 0; i < ${e}.issues.length; i++) {
23
- const iss = ${e}.issues[i];
24
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
25
- payload.issues.push(iss);
26
- if (iss.continue !== true) ${e}_ab = true;
27
- }
28
- if (${e}_ab && ctx && ctx.abortEarly) {
29
- payload.value = newResult;
30
- return payload;
31
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Gl(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
32
- const ${n}_present = ${i};
33
- if (!${n}.issues.length || ${n}_present) {
34
- if (${n}.issues.length) {${c(n,r)}
35
- }
36
-
37
- if (${e}) {
38
- newResult[${r}] = ${n}.value;
39
- }
40
- }
41
-
42
- `)}else f?(o.write(`
43
- if (${n}.issues.length) {${c(n,r)}
44
- }
45
- `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
46
- if (${n}.value !== undefined || ${i}) {
47
- newResult[${r}] = ${n}.value;
48
- }
49
- `)):o.write(`
50
- const ${n}_present = ${i};
51
- if (${n}.issues.length) {${c(n,r)}
52
- }
53
- if (!${n}_present && !${n}.issues.length) {
54
- payload.issues.push({
55
- code: "invalid_type",
56
- expected: "nonoptional",
57
- input: undefined,
58
- path: [${r}]
59
- });
60
- if (ctx && ctx.abortEarly) {
61
- payload.value = newResult;
62
- return payload;
63
- }
64
- }
65
-
66
- if (${n}_present) {
67
- newResult[${r}] = ${n}.value;
68
- }
69
-
70
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Jl,c=!Ku.jitless,l=c&&Yl.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?kp([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Mp(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!hu(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>xu(e,r,qu())))}),t)}var Np=q(`$ZodUnion`,(e,t)=>{Ef.init(e,t),Iu(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),Iu(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Iu(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),Iu(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Nl(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Mp(t,r,e,i)):Mp(o,r,e,i)}});function Pp(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Fp=q(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Np.init(e,t);let n=e._zod.parse;Iu(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Ll(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Rl(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=jl(()=>Pp(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Jl(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Ip=q(`$ZodIntersection`,(e,t)=>{Ef.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Rp(e,t,n)):Rp(e,i,a)}});function Lp(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Xl(e)&&Xl(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Lp(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Lp(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Rp(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Lp(t.value,n.value);if(!c.valid){if(hu(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var zp=q(`$ZodRecord`,(e,t)=>{Ef.init(e,t);let n=Ku.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Xl(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>xu(e,i,qu())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(..._u(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(..._u(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Qd.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>xu(e,i,qu())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(..._u(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(..._u(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Bp=q(`$ZodEnum`,(e,t)=>{Ef.init(e,t);let n=Dl(t.entries),r=new Set(n);e._zod.values=r,Iu(e,`pattern`,e=>{let t=Dl(e.def.entries).filter(e=>Ql.has(typeof e));return RegExp(t.length?`^(${t.map(e=>$l(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Vp=q(`$ZodLiteral`,(e,t)=>{Ef.init(e,t);let n=new Set(t.values);e._zod.values=n,Iu(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?$l(e):e?$l(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Hp=q(`$ZodTransform`,(e,t)=>{Ef.init(e,t),e._zod.optin=`optional`,Ku.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gu(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Wu;return n.value=i,n}});function Up(e,t){return e.value=t.issues.length?void 0:t.value,e}var Wp=q(`$ZodOptional`,(e,t)=>{Ef.init(e,t),Iu(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Iu(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Iu(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Nl(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Up(e,t)):Up(e,r)}return t.innerType._zod.run(e,n)}}),Gp=q(`$ZodExactOptional`,(e,t)=>{Wp.init(e,t),Iu(e,`values`,e=>e.def.innerType._zod.values),Iu(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Kp=q(`$ZodNullable`,(e,t)=>{Ef.init(e,t),Iu(e,`optin`,e=>e.def.innerType._zod.optin),Iu(e,`optout`,e=>e.def.innerType._zod.optout),Iu(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Nl(t.source)}|null)$`):void 0}),Iu(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),qp=q(`$ZodDefault`,(e,t)=>{Ef.init(e,t),e._zod.optin=`defaulted`,Iu(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Jp(e,t)):Jp(r,t)}});function Jp(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Yp=q(`$ZodPrefault`,(e,t)=>{Ef.init(e,t),e._zod.optin=`defaulted`,Iu(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Xp=q(`$ZodNonOptional`,(e,t)=>{Ef.init(e,t),Iu(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Zp(t,e)):Zp(i,e)}});function Zp(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Qp(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>xu(e,r,qu()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var $p=q(`$ZodCatch`,(e,t)=>{Ef.init(e,t),Iu(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Iu(e,`optout`,e=>e.def.innerType._zod.optout),Iu(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Qp(e,r,t,n)):Qp(e,r,t,n)}}),em=q(`$ZodPipe`,(e,t)=>{Ef.init(e,t),Iu(e,`values`,e=>e.def.in._zod.values),Iu(e,`optin`,e=>e.def.in._zod.optin),Iu(e,`optout`,e=>e.def.out._zod.optout),Iu(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>tm(e,t.in,n)):tm(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>tm(e,t.out,n)):tm(r,t.out,n)}});function tm(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var nm=q(`$ZodReadonly`,(e,t)=>{Ef.init(e,t),Iu(e,`propValues`,e=>e.def.innerType._zod.propValues),Iu(e,`values`,e=>e.def.innerType._zod.values),Iu(e,`optin`,e=>e.def.innerType?._zod?.optin),Iu(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(rm):rm(r)}});function rm(e){return e.memo||(e.value=Object.freeze(e.value)),e}var im=q(`$ZodLazy`,(e,t)=>{Ef.init(e,t),Il(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),Iu(e,`pattern`,e=>e.innerType?._zod?.pattern),Iu(e,`propValues`,e=>e.innerType?._zod?.propValues),Iu(e,`optin`,e=>e.innerType?._zod?.optin??void 0),Iu(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),am=q(`$ZodCustom`,(e,t)=>{rf.init(e,t),Ef.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>om(t,n,r,e));om(i,n,r,e)}});function om(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Eu(e))}}var sm=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},cm=`~memo`,lm=[];function um(e){return typeof e==`object`&&!!e}function dm(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var fm=new WeakMap,pm=0,mm=1,hm=2;function gm(e,t,n){let r=fm.get(e);if(r!==void 0)return r?hm:pm;if(t.has(e))return hm;t.add(e);let i=pm,a=e=>{if(i!==hm&&e?._zod){let r=gm(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=pm;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?mm:o.value?._zod?gm(o.value,t,n):pm;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Rl(c);s(e?o(e,!0):mm),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?gm(r,t,!1):mm);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),_m(e,i)}function _m(e,t){return t!==mm&&fm.set(e,t===hm),t}function vm(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var ym,bm=[],xm={alloc(e,t,n){let r=ym;if(!r)return n;ym=void 0;let i={value:n,issues:null};return r.set(t.value,i),bm.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Cm(n,e.value))throw new sm;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=gm(e,new Set,!1);if(i===pm)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===hm||r?n=!0:r=!0}let l=s.value;if(!um(l))return t(s,c);let u=c[cm];u||(u={buckets:new WeakMap,backEdges:void 0},c[cm]=u);let d;i===c?d=a:(d=vm(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...dm(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;ym=d;let p=bm.length,m=t(s,c);ym=void 0;let h=bm.length>p?bm.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?dm(e.issues):lm),e)):(h&&(h.issues=m.issues.length?dm(m.issues):lm),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Sm(){return xm}function Cm(e,t){let n=e[cm]?.backEdges;return n!==void 0&&um(t)&&n.has(t)}var wm=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Tu(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${nu(e.values[0])}`:`Invalid option: expected one of ${Ol(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Ol(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Tm(){return{localeError:wm()}}var Em,Dm=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Om(){return new Dm}(Em=globalThis).__zod_globalRegistry??(Em.__zod_globalRegistry=Om());var km=globalThis.__zod_globalRegistry;function Am(e){return e.checks&&=[...e.checks],e}function jm(e,t){return new e(Am({type:`string`,...tu(t)}))}function Mm(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...tu(t)})}function Nm(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...tu(t)})}function Pm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...tu(t)})}function Fm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...tu(t)})}function Im(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...tu(t)})}function Lm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...tu(t)})}function Rm(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...tu(t)})}function zm(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...tu(t)})}function Bm(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...tu(t)})}function Vm(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...tu(t)})}function Hm(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...tu(t)})}function Um(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...tu(t)})}function Wm(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...tu(t)})}function Gm(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...tu(t)})}function Km(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...tu(t)})}function qm(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...tu(t)})}function Jm(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...tu(t)})}function Ym(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...tu(t)})}function Xm(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...tu(t)})}function Zm(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...tu(t)})}function Qm(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...tu(t)})}function $m(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...tu(t)})}function eh(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...tu(t)})}function th(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...tu(t)})}function nh(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...tu(t)})}function rh(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...tu(t)})}function ih(e,t){return new e(Am({type:`number`,checks:[],...tu(t)}))}function ah(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...tu(t)})}function oh(e,t){return new e({type:`boolean`,...tu(t)})}function sh(e,t){return new e({type:`null`,...tu(t)})}function ch(e){return new e({type:`unknown`})}function lh(e,t){return new e({type:`never`,...tu(t)})}function uh(e,t){return new sf({check:`less_than`,...tu(t),value:e,inclusive:!1})}function dh(e,t){return new sf({check:`less_than`,...tu(t),value:e,inclusive:!0})}function fh(e,t){return new cf({check:`greater_than`,...tu(t),value:e,inclusive:!1})}function ph(e,t){return new cf({check:`greater_than`,...tu(t),value:e,inclusive:!0})}function mh(e,t){return new lf({check:`multiple_of`,...tu(t),value:e})}function hh(e,t){return new df({check:`max_length`,...tu(t),maximum:e})}function gh(e,t){return new ff({check:`min_length`,...tu(t),minimum:e})}function _h(e,t){return new pf({check:`length_equals`,...tu(t),length:e})}function vh(e,t){return new hf({check:`string_format`,format:`regex`,...tu(t),pattern:e})}function yh(e){return new gf({check:`string_format`,format:`lowercase`,...tu(e)})}function bh(e){return new _f({check:`string_format`,format:`uppercase`,...tu(e)})}function xh(e,t){return new vf({check:`string_format`,format:`includes`,...tu(t),includes:e})}function Sh(e,t){return new yf({check:`string_format`,format:`starts_with`,...tu(t),prefix:e})}function Ch(e,t){return new bf({check:`string_format`,format:`ends_with`,...tu(t),suffix:e})}function wh(e,t){return new Sf({check:`properties`,shape:e,...tu(t)})}function Th(e){return new Cf({check:`overwrite`,tx:e})}function Eh(e){return Th(t=>t.normalize(e))}function Dh(){return Th(e=>e.trim())}function Oh(){return Th(e=>e.toLowerCase())}function kh(){return Th(e=>e.toUpperCase())}function Ah(){return Th(e=>Kl(e))}function jh(e,t,n){return new e({type:`array`,element:t,...tu(n)})}function Mh(e,t,n){let r=tu(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Nh(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...tu(n)})}function Ph(e,t){let n=Fh(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Eu(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Eu(r))}},e(t.value,t)),t);return n}function Fh(e,t){let n=new rf({check:`custom`,...tu(t)});return n._zod.check=e,n}function Ih(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ll(e,t,n[t]);return e}function Lh(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??km,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Rh(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function zh(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,zh(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ih(o.schema,c),t.io===`input`&&Yh(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Bh(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Vh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Bh(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Bh(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
71
-
72
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Hh(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Hh(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Uh=new Set([`type`,`properties`,`required`,`additionalProperties`]),Wh=[`oneOf`,`anyOf`];function Gh(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Kh(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Uh.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Gh(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ll(n,r,e.length===1?e[0]:Kh(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Gh(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function qh(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Uh)if(t in e)return;let n=t.filter(e=>Wh.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Kh(t);else{let e=n[0],i=Wh.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Kh([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ih(e,r))}function Jh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ih(i,s),Ih(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Hh(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])qh(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ih(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ll(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Zh(t,`input`,e.processors),output:Zh(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Yh(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Yh(r.element,n);if(r.type===`set`)return Yh(r.valueType,n);if(r.type===`lazy`)return Yh(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Yh(r.innerType,n);if(r.type===`intersection`)return Yh(r.left,n)||Yh(r.right,n);if(r.type===`record`||r.type===`map`)return Yh(r.keyType,n)||Yh(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Yh(r.in,n)||Yh(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Yh(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Yh(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Yh(e,n))return!0;return!!(r.rest&&Yh(r.rest,n))}return!1}var Xh=(e,t={})=>n=>{let r=Lh({...n,processors:t});return zh(e,r),Vh(r,e),Jh(r,e)},Zh=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Lh({...i??{},target:a,io:t,processors:n});return zh(e,o),Vh(o,e),Jh(o,e)},Qh=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},$h=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},eg=(e,t)=>{Qh(e,`minimum`,t),$h(e,`maximum`,t)},tg=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},ng=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},rg=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},ig=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},ag=(e,t)=>Qh(e,`minimum`,t.minimum),og=(e,t)=>$h(e,`maximum`,t.maximum),sg=e=>(t,n)=>{ig(t,n.format);let[r,i]=e[n.format];Qh(t,`minimum`,r),$h(t,`maximum`,i)},cg={greater_than:(e,t)=>Qh(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>$h(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>tg(e,t.value),number_format:sg(iu),bigint_format:sg(au),min_length:ag,max_length:og,length_equals:(e,t)=>eg(e,t.length),min_size:ag,max_size:og,size_equals:(e,t)=>eg(e,t.size),string_format:(e,t)=>{ig(e,t.format),t.pattern&&ng(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>rg(e,t.mime)};function lg(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)cg[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Qh(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Qh(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&$h(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&$h(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&tg(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&rg(t,i.mime);for(let e of i.patterns??[])ng(t,e);return t}var ug={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},dg=new Map([[cp,Bd],[up,Vd]]),fg=e=>dg.get(e)??e,pg=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=lg(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ug[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(fg);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},mg=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=lg(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Rh(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},hg=(e,t,n,r)=>{n.type=`boolean`},gg=(e,t,n,r)=>{Rh(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},_g=(e,t,n,r)=>{Rh(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},vg=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},yg=(e,t,n,r)=>{Rh(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},bg=(e,t,n,r)=>{Rh(e,t,n,r,`Void cannot be represented in JSON Schema`)},xg=(e,t,n,r)=>{n.not={}},Sg=(e,t,n,r)=>{},Cg=(e,t,n,r)=>{},wg=(e,t,n,r)=>{Rh(e,t,n,r,`Date cannot be represented in JSON Schema`)},Tg=(e,t,n,r)=>{let i=e._zod.def,a=Dl(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Eg=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Rh(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Rh(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Dg=(e,t,n,r)=>{Rh(e,t,n,r,`NaN cannot be represented in JSON Schema`)},Og=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},kg=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=lg(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},Ag=(e,t,n,r)=>{n.type=`boolean`},jg=(e,t,n,r)=>{Rh(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Mg=(e,t,n,r)=>{Rh(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Ng=(e,t,n,r)=>{Rh(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Pg=(e,t,n,r)=>{Rh(e,t,n,r,`Map cannot be represented in JSON Schema`)},Fg=(e,t,n,r)=>{Rh(e,t,n,r,`Set cannot be represented in JSON Schema`)},Ig=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=lg(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=zh(a.element,t,{...r,path:[...r.path,`items`]})};function Lg(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Lg(t.out):t.type===`catch`?Lg(t.innerType):e._zod.optin}var Rg=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Rh(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ll(i.properties,e,zh(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Lg(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=zh(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},zg=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>zh(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Bg=(e,t,n,r)=>{let i=e._zod.def,a=zh(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=zh(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Vg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>zh(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?zh(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Lg(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=lg(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Hg(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Hg(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Hg(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Qd:Zd).source),p):p}var Ug=new WeakMap;function Wg(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Ug.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Hg(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var Gg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=lg(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=zh(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Ll(i.patternProperties,fg(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=zh(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Ug.get(t);n||(n=[],Ug.set(t,n),t.deferred.push(()=>Wg(t))),n.push(e)}i.additionalProperties=zh(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Lg(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Kg=(e,t,n,r)=>{let i=e._zod.def,a=zh(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},qg=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Jg=Symbol();function Yg(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Rh(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Jg):JSON.parse(o)}var Xg=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Yg(i.defaultValue,e,t,n,r);o!==Jg&&(n.default=o)},Zg=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Yg(i.defaultValue,e,t,n,r);o!==Jg&&(n._prefault=o)},Qg=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Rh(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},$g=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;zh(o,t,r);let s=t.seen.get(e);s.ref=o},e_=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},t_=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},n_=(e,t,n,r)=>{let i=e._zod.def;zh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},r_=(e,t,n,r)=>{let i=e._zod.innerType;zh(i,t,r);let a=t.seen.get(e);a.ref=i},i_={string:pg,number:mg,boolean:hg,bigint:gg,symbol:_g,null:vg,undefined:yg,void:bg,never:xg,any:Sg,unknown:Cg,date:wg,enum:Tg,literal:Eg,nan:Dg,template_literal:Og,file:kg,success:Ag,custom:jg,function:Mg,transform:Ng,map:Pg,set:Fg,array:Ig,object:Rg,union:zg,intersection:Bg,tuple:Vg,record:Gg,nullable:Kg,nonoptional:qg,default:Xg,prefault:Zg,catch:Qg,pipe:$g,readonly:e_,promise:t_,optional:n_,lazy:r_};function a_(e,t){if(`_idmap`in e){let n=e,r=Lh({...t,processors:i_}),i={};for(let e of n._idmap.entries()){let[t,n]=e;zh(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Vh(r,n),Ll(a,t,Jh(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Lh({...t,processors:i_});return zh(e,n),Vh(n,e),Jh(n,e)}var o_=new WeakSet([Object.prototype,Error.prototype]);function s_(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var c_=q(`ZodError`,(e,t)=>{ed.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);o_.has(n)||(o_.add(n),s_(n,`format`,e=>t=>rd(e,t)),s_(n,`flatten`,e=>t=>nd(e,t)),s_(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,kl,2)}),s_(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,kl,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),l_=ad(c_),u_=od(c_),d_=sd(c_),f_=ld(c_),p_=hd(c_),m_=gd(c_),h_=_d(c_),g_=vd(c_),__=yd(c_),v_=bd(c_),y_=xd(c_),b_=Sd(c_);function x_(){Ku.localeError||qu(Tm())}function S_(){Ku.memoizer||qu({memoizer:Sm()})}var C_=q(`ZodType`,(e,t)=>(x_(),Ef.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Wl(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eu(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xv(e,t))},superRefine(e,t){return this.check(Zv(e,t))},overwrite(e){return this.check(Th(e))},optional(){return kv(this)},exactOptional(){return jv(this)},nullable(){return Nv(this)},nullish(){return kv(Nv(this))},nonoptional(e){return zv(this,e)},array(){return uv(this)},or(e){return hv([this,e])},and(e){return yv(this,e)},transform(e){return Uv(this,Dv(e))},default(e){return Fv(this,e)},prefault(e){return Lv(this,e)},catch(e){return Vv(this,e)},pipe(e){return Uv(this,e)},readonly(){return Gv(this)},describe(e){let t=this.clone();return km.add(t,{description:e}),t},meta(...e){if(e.length===0)return km.get(this);let t=this.clone();return km.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ku(this,`~standard`,{...kf(this),jsonSchema:{input:Zh(this,`input`),output:Zh(this,`output`)}})},set"~standard"(e){Ou(this,`~standard`,e)},parse:function e(t,n){return l_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await u_(this,t,n,{callee:e})},safeParse(e,t){return d_(this,e,t)},async safeParseAsync(e,t){return f_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ou(this,`spa`,e)},validate(e,t){return fd(this,e,t)},validateAsync(e,t){return md(this,e,t)},encode:function e(t,n){return p_(this,t,n,{callee:e})},decode:function e(t,n){return m_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await h_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await g_(this,t,n,{callee:e})},safeEncode(e,t){return __(this,e,t)},safeDecode(e,t){return v_(this,e,t)},async safeEncodeAsync(e,t){return y_(this,e,t)},async safeDecodeAsync(e,t){return b_(this,e,t)},toJSONSchema(e){return Xh(this,{})(e)},get description(){return km.get(this)?.description},get _def(){return this._zod.def}}),w_=q(`_ZodString`,(e,t)=>{Af.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pg(e,t,n,r)},Au({format:e=>lg(e).format??null,minLength:e=>lg(e).minimum??null,maxLength:e=>lg(e).maximum??null},{regex(...e){return this.check(vh(...e))},includes(...e){return this.check(xh(...e))},startsWith(...e){return this.check(Sh(...e))},endsWith(...e){return this.check(Ch(...e))},min(...e){return this.check(gh(...e))},max(...e){return this.check(hh(...e))},length(...e){return this.check(_h(...e))},nonempty(...e){return this.check(gh(1,...e))},lowercase(e){return this.check(yh(e))},uppercase(e){return this.check(bh(e))},trim(){return this.check(Dh())},normalize(...e){return this.check(Eh(...e))},toLowerCase(){return this.check(Oh())},toUpperCase(){return this.check(kh())},slugify(){return this.check(Ah())}})),T_=q(`ZodString`,(e,t)=>{Af.init(e,t),w_.init(e,t)},{email(e){return this.check(Mm(M_,e))},url(e){return this.check(Rm(F_,e))},jwt(e){return this.check($m(X_,e))},emoji(e){return this.check(zm(I_,e))},guid(e){return this.check(Nm(N_,e))},uuid(e){return this.check(Pm(P_,e))},uuidv4(e){return this.check(Fm(P_,e))},uuidv6(e){return this.check(Im(P_,e))},uuidv7(e){return this.check(Lm(P_,e))},nanoid(e){return this.check(Bm(L_,e))},cuid(e){return this.check(Vm(R_,e))},cuid2(e){return this.check(Hm(z_,e))},ulid(e){return this.check(Um(B_,e))},base64(e){return this.check(Xm(q_,e))},base64url(e){return this.check(Zm(J_,e))},xid(e){return this.check(Wm(V_,e))},ksuid(e){return this.check(Gm(H_,e))},ipv4(e){return this.check(Km(U_,e))},ipv6(e){return this.check(qm(W_,e))},cidrv4(e){return this.check(Jm(G_,e))},cidrv6(e){return this.check(Ym(K_,e))},e164(e){return this.check(Qm(Y_,e))},datetime(e){return this.check(eh(O_,e))},date(e){return this.check(th(k_,e))},time(e){return this.check(nh(A_,e))},duration(e){return this.check(rh(j_,e))}});function E_(e){return jm(T_,e)}var D_=q(`ZodStringFormat`,(e,t)=>{jf.init(e,t),w_.init(e,t)}),O_=q(`ZodISODateTime`,(e,t)=>{Xf.init(e,t),D_.init(e,t)}),k_=q(`ZodISODate`,(e,t)=>{Zf.init(e,t),D_.init(e,t)}),A_=q(`ZodISOTime`,(e,t)=>{Qf.init(e,t),D_.init(e,t)}),j_=q(`ZodISODuration`,(e,t)=>{$f.init(e,t),D_.init(e,t)}),M_=q(`ZodEmail`,(e,t)=>{Pf.init(e,t),D_.init(e,t)}),N_=q(`ZodGUID`,(e,t)=>{Mf.init(e,t),D_.init(e,t)}),P_=q(`ZodUUID`,(e,t)=>{Nf.init(e,t),D_.init(e,t)}),F_=q(`ZodURL`,(e,t)=>{Hf.init(e,t),D_.init(e,t)}),I_=q(`ZodEmoji`,(e,t)=>{Uf.init(e,t),D_.init(e,t)}),L_=q(`ZodNanoID`,(e,t)=>{Wf.init(e,t),D_.init(e,t)}),R_=q(`ZodCUID`,(e,t)=>{Gf.init(e,t),D_.init(e,t)}),z_=q(`ZodCUID2`,(e,t)=>{Kf.init(e,t),D_.init(e,t)}),B_=q(`ZodULID`,(e,t)=>{qf.init(e,t),D_.init(e,t)}),V_=q(`ZodXID`,(e,t)=>{Jf.init(e,t),D_.init(e,t)}),H_=q(`ZodKSUID`,(e,t)=>{Yf.init(e,t),D_.init(e,t)}),U_=q(`ZodIPv4`,(e,t)=>{ep.init(e,t),D_.init(e,t)}),W_=q(`ZodIPv6`,(e,t)=>{rp.init(e,t),D_.init(e,t)}),G_=q(`ZodCIDRv4`,(e,t)=>{ip.init(e,t),D_.init(e,t)}),K_=q(`ZodCIDRv6`,(e,t)=>{op.init(e,t),D_.init(e,t)}),q_=q(`ZodBase64`,(e,t)=>{lp.init(e,t),D_.init(e,t)}),J_=q(`ZodBase64URL`,(e,t)=>{fp.init(e,t),D_.init(e,t)}),Y_=q(`ZodE164`,(e,t)=>{pp.init(e,t),D_.init(e,t)}),X_=q(`ZodJWT`,(e,t)=>{hp.init(e,t),D_.init(e,t)}),Z_=q(`ZodNumber`,(e,t)=>{gp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mg(e,t,n,r),e.isFinite=!0},Au({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=lg(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=lg(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=lg(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>lg(e).format??null},{gt(e,t){return this.check(fh(e,t))},gte(e,t){return this.check(ph(e,t))},min(e,t){return this.check(ph(e,t))},lt(e,t){return this.check(uh(e,t))},lte(e,t){return this.check(dh(e,t))},max(e,t){return this.check(dh(e,t))},int(e){return this.check(ev(e))},safe(e){return this.check(ev(e))},positive(e){return this.check(fh(0,e))},nonnegative(e){return this.check(ph(0,e))},negative(e){return this.check(uh(0,e))},nonpositive(e){return this.check(dh(0,e))},multipleOf(e,t){return this.check(mh(e,t))},step(e,t){return this.check(mh(e,t))},finite(){return this}}));function Q_(e){return ih(Z_,e)}var $_=q(`ZodNumberFormat`,(e,t)=>{_p.init(e,t),Z_.init(e,t)});function ev(e){return ah($_,e)}var tv=q(`ZodBoolean`,(e,t)=>{vp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hg(e,t,n,r)});function nv(e){return oh(tv,e)}var rv=q(`ZodNull`,(e,t)=>{yp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vg(e,t,n,r)});function iv(e){return sh(rv,e)}var av=q(`ZodUnknown`,(e,t)=>{bp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ov(){return ch(av)}var sv=q(`ZodNever`,(e,t)=>{xp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xg(e,t,n,r)});function cv(e){return lh(sv,e)}var lv=q(`ZodArray`,(e,t)=>{S_(),Tp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ig(e,t,n,r),e.element=t.element},{min(e,t){return this.check(gh(e,t))},nonempty(e){return this.check(gh(1,e))},max(e,t){return this.check(hh(e,t))},length(e,t){return this.check(_h(e,t))},unwrap(){return this.element}});function uv(e,t){return jh(lv,e,t)}var dv=q(`ZodObject`,(e,t)=>{S_(),jp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rg(e,t,n,r),Lu(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Cv(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Wl(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Wl(this._zod.def,{catchall:ov()}))},loose(){return this.clone(Wl(this._zod.def,{catchall:ov()}))},strict(){return this.clone(Wl(this._zod.def,{catchall:cv()}))},strip(){return this.clone(Wl(this._zod.def,{catchall:void 0}))},extend(e){return lu(this,e)},safeExtend(e){return du(this,e)},merge(e){return fu(this,e)},pick(e){return ou(this,e)},omit(e){return cu(this,e)},partial(...e){return pu(Ov,this,e[0])},exactPartial(...e){return pu(Av,this,e[0],`exactPartial`)},required(...e){return mu(Rv,this,e[0])}});function fv(e,t){return new dv({type:`object`,shape:e??{},...tu(t)})}function pv(e,t){return new dv({type:`object`,shape:e,catchall:ov(),...tu(t)})}var mv=q(`ZodUnion`,(e,t)=>{Np.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zg(e,t,n,r),e.options=t.options});function hv(e,t){return new mv({type:`union`,options:e,...tu(t)})}var gv=q(`ZodDiscriminatedUnion`,(e,t)=>{mv.init(e,t),Fp.init(e,t)});function _v(e,t,n){return new gv({type:`union`,options:t,discriminator:e,...tu(n)})}var vv=q(`ZodIntersection`,(e,t)=>{Ip.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bg(e,t,n,r)});function yv(e,t){return new vv({type:`intersection`,left:e,right:t})}var bv=q(`ZodRecord`,(e,t)=>{S_(),zp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function xv(e,t,n){return!t||!t._zod?new bv({type:`record`,keyType:E_(),valueType:e,...tu(t)}):new bv({type:`record`,keyType:e,valueType:t,...tu(n)})}var Sv=q(`ZodEnum`,(e,t)=>{Bp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tg(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Sv({...t,checks:[],...tu(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Sv({...t,checks:[],...tu(r),entries:i})}});function Cv(e,t){return new Sv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...tu(t)})}var wv=q(`ZodLiteral`,(e,t)=>{Vp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eg(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Tv(e,t){return new wv({type:`literal`,values:Array.isArray(e)?e:[e],...tu(t)})}var Ev=q(`ZodTransform`,(e,t)=>{S_(),Hp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ng(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gu(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Eu(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Eu(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Dv(e){return new Ev({type:`transform`,transform:e})}var Ov=q(`ZodOptional`,(e,t)=>{Wp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>n_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kv(e){return new Ov({type:`optional`,innerType:e})}var Av=q(`ZodExactOptional`,(e,t)=>{Gp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>n_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jv(e){return new Av({type:`optional`,innerType:e})}var Mv=q(`ZodNullable`,(e,t)=>{Kp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nv(e){return new Mv({type:`nullable`,innerType:e})}var Pv=q(`ZodDefault`,(e,t)=>{qp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Fv(e,t){return new Pv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zl(t)}})}var Iv=q(`ZodPrefault`,(e,t)=>{Yp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lv(e,t){return new Iv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zl(t)}})}var Rv=q(`ZodNonOptional`,(e,t)=>{Xp.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zv(e,t){return new Rv({type:`nonoptional`,innerType:e,...tu(t)})}var Bv=q(`ZodCatch`,(e,t)=>{$p.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vv(e,t){return new Bv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:zu(t)})}var Hv=q(`ZodPipe`,(e,t)=>{em.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$g(e,t,n,r),e.in=t.in,e.out=t.out});function Uv(e,t){return new Hv({type:`pipe`,in:e,out:t})}var Wv=q(`ZodReadonly`,(e,t)=>{nm.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gv(e){return new Wv({type:`readonly`,innerType:e})}var Kv=q(`ZodLazy`,(e,t)=>{im.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>r_(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function qv(e){return new Kv({type:`lazy`,getter:e})}var Jv=q(`ZodCustom`,(e,t)=>{am.init(e,t),C_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jg(e,t,n,r)});function Yv(e,t){return Mh(Jv,e??(()=>!0),t)}function Xv(e,t={}){return Nh(Jv,e,t)}function Zv(e,t){return Ph(e,t)}var Qv=q(`ZodInstanceOf`,(e,t)=>{Jv.init(e,t)},{properties(e,t){return this.check(wh(e,t))}});function $v(e,t={}){let n=new Qv({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...tu(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}var ey=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},ty=10,ny=13,ry=32;function iy(e){}function ay(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=iy,onError:n=iy,onRetry:r=iy,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
73
- `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new ey(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
74
- `,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
75
- `,n);continue}let i=e.charCodeAt(n);if(oy(e,n,i)){let i=e.charCodeAt(n+5)===ry?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===ty){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
76
- `,n);continue}u=d===0?a:`${u}
77
- ${a}`,d++}else sy(e,n,i)?f=e.slice(e.charCodeAt(n+6)===ry?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
78
- `,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
79
- `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===ny&&e.charCodeAt(n)===ty&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(oy(e,t,r)){let r=e.charCodeAt(t+5)===ry?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
80
- ${i}`,d++;return}if(sy(e,t,r)){f=e.slice(e.charCodeAt(t+6)===ry?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===ry?t+4:t+3,n);r.includes(`\0`)||(l=r);return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===ry?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===ry?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
81
- ${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new ey(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new ey(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function oy(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function sy(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var cy=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=ay({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}};new TextDecoder;var{btoa:ly,atob:uy}=globalThis;function dy(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var fy=globalThis.fetch;py(fy);function py(e){if(typeof e!=`function`)return!1;let t=Function.prototype.toString.call(e);return t.includes(`internal/deps/undici`)||t.includes(`lazy loading of undici`)}var my=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new cl({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},hy=my();function gy(e){return globalThis.Buffer?.isBuffer(e)??!1}var _y=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,vy=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function yy(e){let t=JSON.parse(e);return typeof t!=`object`||!t||_y.test(e)===!1&&vy.test(e)===!1?t:by(t)}function by(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function xy(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return yy(e)}try{return yy(e)}finally{Error.stackTraceLimit=t}}function Sy(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&Cy(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=Cy(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Cy):Cy(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Cy)),e.allOf!=null&&(e.allOf=e.allOf.map(Cy)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Cy));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Cy(t[e]);return e}function Cy(e){return typeof e==`boolean`?e:Sy(e)}var wy=Symbol(`Let zodToJsonSchema decide on which parser to use`),Ty={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},Ey=e=>typeof e==`string`?{...Ty,name:e}:{...Ty,...e};function Dy(){return{}}function Oy(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=yb(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function ky(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Ay(){return{type:`boolean`}}function jy(e,t){return yb(e.type._def,t)}var My=(e,t)=>yb(e.innerType._def,t);function Ny(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>Ny(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Py(e)}}var Py=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function Fy(e,t){return{...yb(e.innerType._def,t),default:e.defaultValue()}}function Iy(e,t){return t.effectStrategy===`input`?yb(e.schema._def,t):Dy()}function Ly(e){return{type:`string`,enum:Array.from(e.values)}}var Ry=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function zy(e,t){let n=[yb(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),yb(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(Ry(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function By(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var Vy=void 0,Hy={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Vy===void 0&&(Vy=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Vy),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Uy(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:qy(n,`email`,r.message,t);break;case`format:idn-email`:qy(n,`idn-email`,r.message,t);break;case`pattern:zod`:Jy(n,Hy.email,r.message,t)}break;case`url`:qy(n,`uri`,r.message,t);break;case`uuid`:qy(n,`uuid`,r.message,t);break;case`regex`:Jy(n,r.regex,r.message,t);break;case`cuid`:Jy(n,Hy.cuid,r.message,t);break;case`cuid2`:Jy(n,Hy.cuid2,r.message,t);break;case`startsWith`:Jy(n,RegExp(`^${Wy(r.value,t)}`),r.message,t);break;case`endsWith`:Jy(n,RegExp(`${Wy(r.value,t)}$`),r.message,t);break;case`datetime`:qy(n,`date-time`,r.message,t);break;case`date`:qy(n,`date`,r.message,t);break;case`time`:qy(n,`time`,r.message,t);break;case`duration`:qy(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:Jy(n,RegExp(Wy(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&qy(n,`ipv4`,r.message,t),r.version!==`v4`&&qy(n,`ipv6`,r.message,t);break;case`base64url`:Jy(n,Hy.base64url,r.message,t);break;case`jwt`:Jy(n,Hy.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&Jy(n,Hy.ipv4Cidr,r.message,t),r.version!==`v4`&&Jy(n,Hy.ipv6Cidr,r.message,t);break;case`emoji`:Jy(n,Hy.emoji(),r.message,t);break;case`ulid`:Jy(n,Hy.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:qy(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:Jy(n,Hy.base64,r.message,t)}break;case`nanoid`:Jy(n,Hy.nanoid,r.message,t)}return n}function Wy(e,t){return t.patternStrategy===`escape`?Ky(e):e}var Gy=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function Ky(e){let t=``;for(let n=0;n<e.length;n++)Gy.has(e[n])||(t+=`\\`),t+=e[n];return t}function qy(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Jy(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Yy(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Yy(t,r)}function Yy(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
82
- ]))`;continue}if(r[e]===`$`){i+=`($|(?=[\r
83
- ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r
84
- `:`[${r[e]}\r
85
- ]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Xy(e,t){let n={type:`object`,additionalProperties:yb(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=Uy(e.keyType._def,t);return{...n,propertyNames:i}}if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=jy(e.keyType._def,t);return{...n,propertyNames:i}}return n}function Zy(e,t){return t.mapStrategy===`record`?Xy(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[yb(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Dy(),yb(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Dy()],minItems:2,maxItems:2}}}function Qy(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function $y(){return{not:Dy()}}function eb(){return{type:`null`}}var tb={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function nb(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in tb&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=tb[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return rb(e,t)}var rb=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>yb(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function ib(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[tb[e.innerType._def.typeName],`null`]};let n=yb(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function ab(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function ob(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=cb(a),s=yb(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=sb(e,t);return a!==void 0&&(n.additionalProperties=a),n}function sb(e,t){if(e.catchall._def.typeName!==`ZodNever`)return yb(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function cb(e){try{return e.isOptional()}catch{return!0}}var lb=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return yb(e.innerType._def,t);let n=yb(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Dy()},n]}:Dy()},ub=(e,t)=>{if(t.pipeStrategy===`input`)return yb(e.in._def,t);if(t.pipeStrategy===`output`)return yb(e.out._def,t);let n=yb(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,yb(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function db(e,t){return yb(e.type._def,t)}function fb(e,t){let n={type:`array`,uniqueItems:!0,items:yb(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function pb(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>yb(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:yb(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>yb(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function mb(){return{not:Dy()}}function hb(){return Dy()}var gb=(e,t)=>yb(e.innerType._def,t),_b=(e,t,n)=>{switch(t){case`ZodString`:return Uy(e,n);case`ZodNumber`:return ab(e);case`ZodObject`:return ob(e,n);case`ZodBigInt`:return ky(e);case`ZodBoolean`:return Ay();case`ZodDate`:return Ny(e,n);case`ZodUndefined`:return mb();case`ZodNull`:return eb();case`ZodArray`:return Oy(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return nb(e,n);case`ZodIntersection`:return zy(e,n);case`ZodTuple`:return pb(e,n);case`ZodRecord`:return Xy(e,n);case`ZodLiteral`:return By(e);case`ZodEnum`:return Ly(e);case`ZodNativeEnum`:return Qy(e);case`ZodNullable`:return ib(e,n);case`ZodOptional`:return lb(e,n);case`ZodMap`:return Zy(e,n);case`ZodSet`:return fb(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return db(e,n);case`ZodNaN`:case`ZodNever`:return $y();case`ZodEffects`:return Iy(e,n);case`ZodAny`:return Dy();case`ZodUnknown`:return hb();case`ZodDefault`:return Fy(e,n);case`ZodBranded`:return jy(e,n);case`ZodReadonly`:return gb(e,n);case`ZodCatch`:return My(e,n);case`ZodPipeline`:return ub(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},vb=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function yb(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==wy)return i}if(r&&!n){let e=bb(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=_b(e,e.typeName,t),o=typeof a==`function`?yb(a(),t):a;if(o&&xb(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var bb=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:vb(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Dy()):t.$refStrategy===`seen`?Dy():void 0}},xb=(e,t,n)=>(e.description&&(n.description=e.description),n),Sb=e=>{let t=Ey(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Cb=(e,t)=>{let n=Sb(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:yb(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Dy()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=yb(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Dy(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},wb=Symbol.for(`vercel.ai.schema`);function Tb(e){let t;return()=>(t??=e(),t)}function Eb(e,{validate:t}={}){return{[wb]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Db(e){return typeof e==`object`&&!!e&&wb in e&&e[wb]===!0&&`jsonSchema`in e&&`validate`in e}function Ob(e){return e==null?Eb({type:`object`,properties:{},additionalProperties:!1}):Db(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?Pb(e):kb(e):e()}function kb(e){return Eb(()=>{if(!Ab(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return Sy(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new bl({value:t,cause:n.issues})}}})}function Ab(e){return e[`~standard`].jsonSchema!=null}function jb(e,t){let n=t?.useReferences??!1;return Eb(()=>Cb(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Mb(e,t){let n=t?.useReferences??!1;return Eb(()=>Sy(a_(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await f_(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Nb(e){return`_zod`in e}function Pb(e,t){return Nb(e)?Mb(e,t):jb(e,t)}async function Fb({value:e,schema:t,context:n}){let r=await Ib({value:e,schema:t,context:n});if(!r.success)throw bl.wrap({value:e,cause:r.error,context:n});return r.value}async function Ib({value:e,schema:t,context:n}){let r=Ob(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:bl.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:bl.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function Lb({text:e,schema:t}){try{let n=xy(e);return t==null?{success:!0,value:n,rawValue:n}:await Ib({value:n,schema:t})}catch(t){return{success:!1,error:ml.isInstance(t)?t:new ml({text:e,cause:t}),rawValue:void 0}}}function Rb({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new cy).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await Lb({text:e,schema:t}))}}))}async function zb(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}new TextDecoder;var Bb=Object.defineProperty,Vb=(e,t)=>{for(var n in t)Bb(e,n,{get:t[n],enumerable:!0})},Hb=`AI_InvalidArgumentError`,Ub=`vercel.ai.error.${Hb}`,Wb=Symbol.for(Ub),Gb,Kb,qb=class extends (Kb=Uc,Gb=Wb,Kb){constructor({parameter:e,value:t,message:n}){super({name:Hb,message:`Invalid argument for parameter ${e}: ${n}`}),this[Gb]=!0,this.parameter=e,this.value=t}static isInstance(e){return Uc.hasMarker(e,Ub)}},Jb=`AI_NoObjectGeneratedError`,Yb=`vercel.ai.error.${Jb}`,Xb=Symbol.for(Yb),Zb,Qb,$b=class extends (Qb=Uc,Zb=Xb,Qb){constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:Jb,message:e,cause:t}),this[Zb]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return Uc.hasMarker(e,Yb)}},ex=`AI_UIMessageStreamError`,tx=`vercel.ai.error.${ex}`,nx=Symbol.for(tx),rx,ix,ax=class extends (ix=Uc,rx=nx,ix){constructor({chunkType:e,chunkId:t,message:n}){super({name:ex,message:n}),this[rx]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Uc.hasMarker(e,tx)}};function ox(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(r!==`__proto__`&&r!==`constructor`&&r!==`prototype`&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);n[r]=o&&s?ox(a,i):i}return n}var J={array:uv,boolean:nv,custom:Yv,discriminatedUnion:_v,enum:Cv,instanceof:$v,lazy:qv,literal:Tv,looseObject:pv,never:cv,null:iv,number:Q_,object:fv,record:xv,string:E_,union:hv,unknown:ov},sx=J.lazy(()=>J.union([J.null(),J.string(),J.number(),J.boolean(),J.record(J.string(),sx.optional()),J.array(sx)])),cx=J.record(J.string(),J.record(J.string(),sx.optional())),lx=J.union([J.string(),J.instanceof(Uint8Array),J.instanceof(ArrayBuffer),J.custom(gy,{message:`Must be a Buffer`})]),ux=J.record(J.string(),J.string()),dx=J.object({type:J.literal(`text`),text:J.string(),providerOptions:cx.optional()}),fx=J.object({type:J.literal(`image`),image:J.union([lx,J.instanceof(URL),ux]),mediaType:J.string().optional(),providerOptions:cx.optional()}),px=J.discriminatedUnion(`type`,[J.object({type:J.literal(`data`),data:lx}),J.object({type:J.literal(`url`),url:J.instanceof(URL)}),J.object({type:J.literal(`reference`),reference:ux}),J.object({type:J.literal(`text`),text:J.string()})]),mx=J.discriminatedUnion(`type`,[J.object({type:J.literal(`data`),data:lx}),J.object({type:J.literal(`url`),url:J.instanceof(URL)})]),hx=J.object({type:J.literal(`file`),data:J.union([px,lx,J.instanceof(URL),ux]),filename:J.string().optional(),mediaType:J.string(),providerOptions:cx.optional()}),gx=J.object({type:J.literal(`reasoning`),text:J.string(),providerOptions:cx.optional()}),_x=J.object({type:J.literal(`custom`),kind:J.string().transform(e=>e),providerOptions:cx.optional()}),vx=J.object({type:J.literal(`reasoning-file`),data:J.union([mx,lx,J.instanceof(URL)]),mediaType:J.string(),providerOptions:cx.optional()}),yx=J.object({type:J.literal(`tool-call`),toolCallId:J.string(),toolName:J.string(),input:J.unknown(),providerOptions:cx.optional(),providerExecuted:J.boolean().optional()}),bx=J.discriminatedUnion(`type`,[J.object({type:J.literal(`text`),value:J.string(),providerOptions:cx.optional()}),J.object({type:J.literal(`json`),value:sx,providerOptions:cx.optional()}),J.object({type:J.literal(`execution-denied`),reason:J.string().optional(),providerOptions:cx.optional()}),J.object({type:J.literal(`error-text`),value:J.string(),providerOptions:cx.optional()}),J.object({type:J.literal(`error-json`),value:sx,providerOptions:cx.optional()}),J.object({type:J.literal(`content`),value:J.array(J.union([J.object({type:J.literal(`text`),text:J.string(),providerOptions:cx.optional()}),J.object({type:J.literal(`file`),data:px,mediaType:J.string(),filename:J.string().optional(),providerOptions:cx.optional()}),J.object({type:J.literal(`file-data`),data:J.string(),mediaType:J.string(),filename:J.string().optional(),providerOptions:cx.optional()}),J.object({type:J.literal(`file-url`),url:J.string(),mediaType:J.string().optional(),providerOptions:cx.optional()}),J.object({type:J.literal(`file-id`),fileId:J.union([J.string(),J.record(J.string(),J.string())]),providerOptions:cx.optional()}),J.object({type:J.literal(`file-reference`),providerReference:J.record(J.string(),J.string()),providerOptions:cx.optional()}),J.object({type:J.literal(`image-data`),data:J.string(),mediaType:J.string(),providerOptions:cx.optional()}),J.object({type:J.literal(`image-url`),url:J.string(),providerOptions:cx.optional()}),J.object({type:J.literal(`image-file-id`),fileId:J.union([J.string(),J.record(J.string(),J.string())]),providerOptions:cx.optional()}),J.object({type:J.literal(`image-file-reference`),providerReference:J.record(J.string(),J.string()),providerOptions:cx.optional()}),J.object({type:J.literal(`custom`),providerOptions:cx.optional()})]))})]),xx=J.object({type:J.literal(`tool-result`),toolCallId:J.string(),toolName:J.string(),output:bx,providerOptions:cx.optional()}),Sx=J.object({type:J.literal(`tool-approval-request`),approvalId:J.string(),toolCallId:J.string(),reason:J.string().optional()}),Cx=J.object({type:J.literal(`tool-approval-response`),approvalId:J.string(),approved:J.boolean(),reason:J.string().optional()}),wx=J.object({role:J.literal(`system`),content:J.string(),providerOptions:cx.optional()}),Tx=J.object({role:J.literal(`user`),content:J.union([J.string(),J.array(J.union([dx,fx,hx]))]),providerOptions:cx.optional()}),Ex=J.object({role:J.literal(`assistant`),content:J.union([J.string(),J.array(J.union([dx,_x,hx,gx,vx,yx,xx,Sx]))]),providerOptions:cx.optional()}),Dx=J.object({role:J.literal(`tool`),content:J.array(J.union([xx,Cx])),providerOptions:cx.optional()});J.union([wx,Tx,Ex,Dx]),Vb({},{array:()=>Mx,choice:()=>Fx,json:()=>Ix,object:()=>jx,text:()=>Ax});function Ox(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`));break;case`INSIDE_OBJECT_KEY`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`));break;case`INSIDE_OBJECT_AFTER_KEY`:u===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:n=l,o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function kx(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await Lb({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await Lb({text:Ox(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}var Ax=()=>({name:`text`,responseFormat:Promise.resolve({type:`text`}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),jx=({schema:e,name:t,description:n})=>{let r=Ob(e);return{name:`object`,responseFormat:zb(r.jsonSchema).then(e=>({type:`json`,schema:e,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:e},t){let n=await Lb({text:e});if(!n.success)throw new $b({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=await Ib({value:n.value,schema:r});if(!i.success)throw new $b({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return i.value},async parsePartialOutput({text:e}){let t=await kx(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value}}},createElementStreamTransform(){}}},Mx=({element:e,minItems:t,maxItems:n,name:r,description:i})=>{if(Nx({name:`minItems`,value:t}),Nx({name:`maxItems`,value:n}),t!=null&&n!=null&&t>n)throw new qb({parameter:`minItems`,value:t,message:`minItems must be less than or equal to maxItems`});let a=Ob(e);return{name:`array`,responseFormat:zb(a.jsonSchema).then(e=>{let{$schema:a,definitions:o,$defs:s,...c}=e;return{type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,...o!=null&&{definitions:o},...s!=null&&{$defs:s},type:`object`,properties:{elements:{type:`array`,items:c,...t!=null&&{minItems:t},...n!=null&&{maxItems:n}}},required:[`elements`],additionalProperties:!1},...r!=null&&{name:r},...i!=null&&{description:i}}}),async parseCompleteOutput({text:e},r){let i=await Lb({text:e});if(!i.success)throw new $b({message:`No object generated: could not parse the response.`,cause:i.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});let o=i.value;if(typeof o!=`object`||!o||!(`elements`in o)||!Array.isArray(o.elements))throw new $b({message:`No object generated: response did not match schema.`,cause:new bl({value:o,cause:`response must be an object with an elements array`}),text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});let s=Px({value:o.elements,minItems:t,maxItems:n});if(s!=null)throw new $b({message:`No object generated: response did not match schema.`,cause:s,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});let c=[];for(let t of o.elements){let n=await Ib({value:t,schema:a});if(!n.success)throw new $b({message:`No object generated: response did not match schema.`,cause:n.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});c.push(n.value)}return c},async parsePartialOutput({text:e}){let t=await kx(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let e=t.value;if(typeof e!=`object`||!e||!(`elements`in e)||!Array.isArray(e.elements))return;let n=t.state===`repaired-parse`&&e.elements.length>0?e.elements.slice(0,-1):e.elements,r=[];for(let e of n){let t=await Ib({value:e,schema:a});t.success&&r.push(t.value)}return{partial:r}}}},createElementStreamTransform(){let e=0;return new TransformStream({transform({partialOutput:t},r){if(t!=null)for(;e<t.length;e++){if(n!=null&&e>=n){r.error(Px({value:t,maxItems:n}));return}r.enqueue(t[e])}}})}}};function Nx({name:e,value:t}){if(t!=null){if(!Number.isInteger(t))throw new qb({parameter:e,value:t,message:`${e} must be an integer`});if(t<0)throw new qb({parameter:e,value:t,message:`${e} must be greater than or equal to 0`})}}function Px({value:e,minItems:t,maxItems:n}){if(t!=null&&e.length<t)return new bl({value:e,cause:`elements array must contain at least ${t} items`});if(n!=null&&e.length>n)return new bl({value:e,cause:`elements array must contain at most ${n} items`})}var Fx=({options:e,name:t,description:n})=>({name:`choice`,responseFormat:Promise.resolve({type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{result:{type:`string`,enum:e}},required:[`result`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:t},n){let r=await Lb({text:t});if(!r.success)throw new $b({message:`No object generated: could not parse the response.`,cause:r.error,text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=r.value;if(typeof i!=`object`||!i||!(`result`in i)||typeof i.result!=`string`||!e.includes(i.result))throw new $b({message:`No object generated: response did not match schema.`,cause:new bl({value:i,cause:`response must be an object that contains a choice value.`}),text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.result},async parsePartialOutput({text:t}){let n=await kx(t);switch(n.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let t=n.value;if(typeof t!=`object`||!t||!(`result`in t)||typeof t.result!=`string`)return;let r=e.filter(e=>e.startsWith(t.result));return n.state===`successful-parse`?r.includes(t.result)?{partial:t.result}:void 0:r.length===1?{partial:r[0]}:void 0}}},createElementStreamTransform(){}}),Ix=({name:e,description:t}={})=>({name:`json`,responseFormat:Promise.resolve({type:`json`,...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:e},t){let n=await Lb({text:e});if(!n.success)throw new $b({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return n.value},async parsePartialOutput({text:e}){let t=await kx(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return t.value===void 0?void 0:{partial:t.value}}},createElementStreamTransform(){}});new TextEncoder,new TextEncoder,my({prefix:`aitxt`,size:24}),my({prefix:`call`,size:24});function Lx(e,t){let n=new Headers(e??{});for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r);return n}var Rx=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
86
-
87
- `)},flush(e){e.enqueue(`data: [DONE]
88
-
89
- `)}})}},zx={"content-type":`text/event-stream`,"cache-control":`no-cache`,connection:`keep-alive`,"x-vercel-ai-ui-message-stream":`v1`,"x-accel-buffering":`no`};function Bx({status:e,statusText:t,headers:n,stream:r,consumeSseStream:i}){let a=r.pipeThrough(new Rx);if(i){let[e,t]=a.tee();a=e,i({stream:t})}return new Response(a.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Lx(n,zx)})}var Vx=J.record(J.string(),sx.optional()),Hx=Tb(()=>Pb(J.union([J.looseObject({type:J.literal(`text-start`),id:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`text-delta`),id:J.string(),delta:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`text-end`),id:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`error`),errorText:J.string()}),J.looseObject({type:J.literal(`tool-input-start`),toolCallId:J.string(),toolName:J.string(),providerExecuted:J.boolean().optional(),providerMetadata:cx.optional(),toolMetadata:Vx.optional(),dynamic:J.boolean().optional(),title:J.string().optional()}),J.looseObject({type:J.literal(`tool-input-delta`),toolCallId:J.string(),inputTextDelta:J.string()}),J.looseObject({type:J.literal(`tool-input-available`),toolCallId:J.string(),toolName:J.string(),input:J.unknown(),providerExecuted:J.boolean().optional(),providerMetadata:cx.optional(),toolMetadata:Vx.optional(),dynamic:J.boolean().optional(),title:J.string().optional()}),J.looseObject({type:J.literal(`tool-input-error`),toolCallId:J.string(),toolName:J.string(),input:J.unknown(),providerExecuted:J.boolean().optional(),providerMetadata:cx.optional(),toolMetadata:Vx.optional(),dynamic:J.boolean().optional(),errorText:J.string(),title:J.string().optional()}),J.looseObject({type:J.literal(`tool-approval-request`),approvalId:J.string(),toolCallId:J.string(),approvalDescriptor:J.unknown().optional(),reason:J.string().optional(),isAutomatic:J.boolean().optional(),signature:J.string().optional()}),J.looseObject({type:J.literal(`tool-approval-response`),approvalId:J.string(),approved:J.boolean(),reason:J.string().optional(),providerExecuted:J.boolean().optional(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`tool-output-available`),toolCallId:J.string(),output:J.unknown(),providerExecuted:J.boolean().optional(),providerMetadata:cx.optional(),toolMetadata:Vx.optional(),dynamic:J.boolean().optional(),preliminary:J.boolean().optional()}),J.looseObject({type:J.literal(`tool-output-error`),toolCallId:J.string(),errorText:J.string(),providerExecuted:J.boolean().optional(),providerMetadata:cx.optional(),toolMetadata:Vx.optional(),dynamic:J.boolean().optional()}),J.looseObject({type:J.literal(`tool-output-denied`),toolCallId:J.string()}),J.looseObject({type:J.literal(`reasoning-start`),id:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`reasoning-delta`),id:J.string(),delta:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`reasoning-end`),id:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`custom`),kind:J.string().transform(e=>e),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`source-url`),sourceId:J.string(),url:J.string(),title:J.string().optional(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`source-document`),sourceId:J.string(),mediaType:J.string(),title:J.string(),filename:J.string().optional(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`file`),url:J.string(),mediaType:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.literal(`reasoning-file`),url:J.string(),mediaType:J.string(),providerMetadata:cx.optional()}),J.looseObject({type:J.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:J.string().optional(),data:J.unknown(),transient:J.boolean().optional()}),J.looseObject({type:J.literal(`start-step`)}),J.looseObject({type:J.literal(`finish-step`)}),J.looseObject({type:J.literal(`reset-step`)}),J.looseObject({type:J.literal(`start`),messageId:J.string().optional(),messageMetadata:J.unknown().optional()}),J.looseObject({type:J.literal(`finish`),finishReason:J.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`]).optional(),messageMetadata:J.unknown().optional()}),J.looseObject({type:J.literal(`abort`),reason:J.string().optional()}),J.looseObject({type:J.literal(`message-metadata`),messageMetadata:J.unknown()})])));function Ux(e){return e.type.startsWith(`data-`)}function Wx(){return Object.create(null)}function Gx(e){return e.type.startsWith(`tool-`)}function Kx(e){return e.type===`dynamic-tool`}function qx(e){return Gx(e)||Kx(e)}function Jx(e){return e.type.split(`-`).slice(1).join(`-`)}function Yx({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:Wx(),activeReasoningParts:Wx(),partialToolCalls:Wx()}}function Xx({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{function l(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function u(){return l().filter(qx)}function d(e){let t=u().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(qx(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new ax({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function f(e){let t=r.message.parts.filter(qx).find(t=>t.approval?.id===e);if(t==null)throw new ax({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function p(e,t){let n=t??l().find(t=>Gx(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null){if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&e.state!==`output-available`&&e.state!==`output-error`?{callProviderMetadata:i.providerMetadata}:{}})}function m(e,t){let n=t??l().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput??a.rawInput,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null){if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&e.state!==`output-available`&&e.state!==`output-error`?{callProviderMetadata:i.providerMetadata}:{}})}async function h(e){if(e!=null){let n=r.message.metadata==null?e:ox(r.message.metadata,e);t!=null&&await Fb({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new ax({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new ax({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),c();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new ax({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new ax({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=l().filter(Gx);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new ax({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let{value:n}=await kx(t.text);t.dynamic?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}):p({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-input-available`:e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=l().filter(qx).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),c();break}case`tool-approval-request`:{let t=d(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},c();break}case`tool-approval-response`:{let t=f(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),c();break}case`tool-output-denied`:{let t=d(e.toolCallId);t.state=`output-denied`,c();break}case`tool-output-available`:{let t=d(e.toolCallId);t.type===`dynamic-tool`?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t):p({toolCallId:e.toolCallId,toolName:Jx(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t),c();break}case`tool-output-error`:{let t=d(e.toolCallId);t.type===`dynamic-tool`?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t):p({toolCallId:e.toolCallId,toolName:Jx(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t),c();break}case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=l();r.activeTextParts=Wx(),r.activeReasoningParts=Wx(),r.partialToolCalls=Wx(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),c());break}case`start`:e.messageId!=null&&(r.message.id=e.messageId),await h(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c({updateStatus:!1});break;case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await h(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await h(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(Ux(e)){if(n?.[e.type]!=null){let t=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=t>=0?t:r.message.parts.length;await Fb({value:e.data,schema:n[e.type],context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}async function Zx({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}my({prefix:`aitxt`,size:24}),my({prefix:`call`,size:24}),my({prefix:`aitxt`,size:24}),my({prefix:`call`,size:24}),J.record(J.string(),sx.optional()),J.record(J.string(),J.string()),my({prefix:`call`,size:24}),my({prefix:`call`,size:24}),new TextEncoder,my({prefix:`aiobj`,size:24});var{atob:Qx}=globalThis,$x=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}};my({prefix:`aiobj`,size:24}),J.object({token:J.string().refine(e=>e.trim().length>0),url:J.string().refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}}),expiresAt:J.number().positive().max(2**53-1).optional(),tools:J.array(J.object({type:J.literal(`function`),name:J.string().min(1),description:J.string().optional(),parameters:J.record(J.string(),J.unknown())})).optional()}),my({prefix:`call`,size:24});async function eS({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new Yc({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function tS(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new El({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}var nS=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await zb(this.body),r=await zb(this.headers),i=await zb(this.credentials),a={...dy(r),...dy(t.headers)},o=await this.prepareSendMessagesRequest?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:dy(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"Content-Type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await eS({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new tl({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await zb(this.body),n=await zb(this.headers),r=await zb(this.credentials),i={...dy(n),...dy(e.headers)},a=await this.prepareReconnectToStreamRequest?.call(this,{api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api??`${this.api}/${e.chatId}/stream`,s=a?.headers===void 0?i:dy(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await eS({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new tl({message:`The response body is empty.`});return this.processResponseStream(l.body)}},rS=class extends nS{constructor(e={}){super(e)}processResponseStream(e){return Rb({stream:e,schema:Hx}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},iS=class{constructor({generateId:e=hy,id:t=e(),transport:n=new rS,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.pendingMessagePreparations=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.jobExecutor=new $x,this.sendMessage=async(e,t)=>{if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await tS(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new qb({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new qb({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new qb({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.state.messages,a=i[i.length-1],o=r=>qx(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r;this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(o)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...r})})}),this.addToolOutput=async({state:e=`output-available`,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.state.messages,o=a[a.length-1],s=i=>qx(i)&&i.toolCallId===t?{...i,state:e,output:n,errorText:r}:i;this.state.replaceMessage(a.length-1,{...o,parts:o.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...i})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var e,t;for(let e of this.pendingMessagePreparations)e.abort();(e=this.activeResumeRequest)==null||e.abortController.abort(),(t=this.activeResponse)==null||t.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e==`object`&&`then`in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a,o;let s=new AbortController,c=e===`resume-stream`?{abortController:s}:void 0;c&&((a=this.activeResumeRequest)==null||a.abortController.abort(),this.activeResumeRequest=c);let l=()=>c==null||this.activeResumeRequest===c,u=()=>{this.activeResumeRequest===c&&(this.activeResumeRequest=void 0)},d;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:s.signal,metadata:t,headers:n,body:r});if(s.signal.aborted||!l()){await e?.cancel().catch(()=>{}),l()&&this.setStatus({status:`ready`}),u();return}if(e==null){this.setStatus({status:`ready`}),u();return}d=e}catch(e){if(s.signal.aborted||e.name===`AbortError`){l()&&this.setStatus({status:`ready`}),u();return}if(!l())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),u();return}this.setStatus({status:`submitted`,error:void 0});let f=this.lastMessage,p=!1,m=!1,h=!1,g;try{let a={state:Yx({lastMessage:e===`resume-stream`||e===`regenerate-message`?void 0:this.state.snapshot(f),messageId:this.generateId()}),abortController:s};g=a,a.abortController.signal.addEventListener(`abort`,()=>{p=!0}),this.activeResponse=a;let o;if(o=e===`resume-stream`?d:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Zx({stream:Xx({stream:o,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>a.abortController.signal.aborted?Promise.resolve():e({state:a.state,write:({updateStatus:e=!0}={})=>{a.abortController.signal.aborted||(e&&this.setStatus({status:`streaming`}),a.state.message.id===this.lastMessage?.id?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message))}})),onError:e=>{throw e}}),abortSignal:a.abortController.signal,onError:e=>{throw e}}),p)return l()&&this.setStatus({status:`ready`}),null;l()&&this.setStatus({status:`ready`})}catch(e){if(p||e.name===`AbortError`)return p=!0,l()&&this.setStatus({status:`ready`}),null;if(!l())return null;h=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(m=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{g&&((o=this.onFinish)==null||o.call(this,{message:g.state.message,messages:this.state.messages,isAbort:p,isDisconnect:m,isError:h,finishReason:g.state.finishReason}))}finally{this.activeResponse===g&&(this.activeResponse=void 0),u()}}!h&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r})}},aS=t(n(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1),oS=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},sS=(e,t,n)=>(oS(e,t,`read from private field`),n?n.call(e):t.get(e)),cS=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},lS=(e,t,n,r)=>(oS(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function uS(e,t){return t==null?e:(0,aS.default)(e,t)}function dS(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var fS,pS,mS,hS,gS,_S,vS,yS,bS,xS=class{constructor(e=[]){cS(this,fS,void 0),cS(this,pS,`ready`),cS(this,mS,void 0),cS(this,hS,new Set),cS(this,gS,new Set),cS(this,_S,new Set),this.pushMessage=e=>{lS(this,fS,sS(this,fS).concat(e)),sS(this,vS).call(this)},this.popMessage=()=>{lS(this,fS,sS(this,fS).slice(0,-1)),sS(this,vS).call(this)},this.replaceMessage=(e,t)=>{lS(this,fS,[...sS(this,fS).slice(0,e),this.snapshot(t),...sS(this,fS).slice(e+1)]),sS(this,vS).call(this)},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=dS(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?uS(e,t):e;return sS(this,hS).add(n),()=>{sS(this,hS).delete(n)}},this[`~registerStatusCallback`]=e=>(sS(this,gS).add(e),()=>{sS(this,gS).delete(e)}),this[`~registerErrorCallback`]=e=>(sS(this,_S).add(e),()=>{sS(this,_S).delete(e)}),cS(this,vS,()=>{sS(this,hS).forEach(e=>e())}),cS(this,yS,()=>{sS(this,gS).forEach(e=>e())}),cS(this,bS,()=>{sS(this,_S).forEach(e=>e())}),lS(this,fS,e)}get status(){return sS(this,pS)}set status(e){lS(this,pS,e),sS(this,yS).call(this)}get error(){return sS(this,mS)}set error(e){lS(this,mS,e),sS(this,bS).call(this)}get messages(){return sS(this,fS)}set messages(e){lS(this,fS,[...e]),sS(this,vS).call(this)}};fS=new WeakMap,pS=new WeakMap,mS=new WeakMap,hS=new WeakMap,gS=new WeakMap,_S=new WeakMap,vS=new WeakMap,yS=new WeakMap,bS=new WeakMap;var SS,CS=class extends iS{constructor({messages:e,...t}){let n=new xS(e);super({...t,state:n}),cS(this,SS,void 0),this[`~registerMessagesCallback`]=(e,t)=>sS(this,SS)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>sS(this,SS)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>sS(this,SS)[`~registerErrorCallback`](e),lS(this,SS,n)}};SS=new WeakMap;function wS({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,G.useRef)({});`chat`in r||(a.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let o,s=()=>a.current.transport??(o??=new rS),c={...r,transport:{sendMessages:e=>s().sendMessages(e),reconnectToStream:e=>s().reconnectToStream(e)},onToolCall:e=>{var t;return(t=a.current).onToolCall?.call(t,e)},onData:e=>{var t;return(t=a.current).onData?.call(t,e)},onFinish:e=>{var t;return(t=a.current).onFinish?.call(t,e)},onError:e=>{var t;return(t=a.current).onError?.call(t,e)},sendAutomaticallyWhen:e=>{var t;return(t=a.current).sendAutomaticallyWhen?.call(t,e)??!1}},l=`chat`in r?r.chat:r.id,{chat:u,isExternallyManaged:d}=(0,G.useMemo)(()=>({chat:`chat`in r?r.chat:new CS(c),isExternallyManaged:`chat`in r}),[l]);(0,G.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let f=(0,G.useMemo)(()=>({messages:u.messages}),[u]),p=(0,G.useCallback)(e=>{let t=!0,n=u[`~registerMessagesCallback`](()=>{t&&(f.messages=u.messages,e())},i);return f.messages=u.messages,()=>{t=!1,n()}},[u,f,i]),m=(0,G.useCallback)(()=>f.messages,[f]),h=(0,G.useSyncExternalStore)(p,m,m),g=(0,G.useCallback)(e=>u[`~registerStatusCallback`](()=>{(u.status===`ready`||u.status===`error`)&&(f.messages=u.messages),e()}),[u,f]),_=(0,G.useCallback)(()=>u.status,[u]),v=(0,G.useSyncExternalStore)(g,_,_),y=(0,G.useSyncExternalStore)(u[`~registerErrorCallback`],()=>u.error,()=>u.error),b=(0,G.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,G.useEffect)(()=>{n&&u.resumeStream()},[n,u]),{id:u.id,messages:h,setMessages:b,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:y,resumeStream:u.resumeStream,status:v,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse}}var TS=`/api/studio/work`,ES=e=>`${TS}/chats/${e}`,DS=4e3,OS=()=>!na(`liveChanges`)&&DS,kS=[`work-chats`];function AS(e,t){let n=OS();return Je({queryKey:[...kS,e,t],queryFn:()=>H.get(`${TS}/chats?space=${encodeURIComponent(e??``)}${t?`&q=${encodeURIComponent(t)}`:``}`),enabled:!!e,refetchInterval:n,placeholderData:e=>e})}function jS(e,t=!1){let n=OS();return Je({queryKey:[`work-chat`,e],queryFn:()=>H.get(`${TS}/chats/${e}`),enabled:!!e,refetchInterval:!t&&n})}var MS=()=>Bx({stream:new ReadableStream({start(e){e.enqueue({type:`start`}),e.enqueue({type:`finish`}),e.close()}})});async function NS(e,t,n){let r=``;try{r=String(JSON.parse(String(t?.body??`{}`)).text??``)}catch{}n.start(r);let i=e.getReader(),a=new TextDecoder,o=``;try{for(;;){let{done:e,value:t}=await i.read();if(e)break;let r=(o+a.decode(t,{stream:!0})).split(`
90
- `);o=r.pop()??``;for(let e of r){let t=e.startsWith(`data:`)?e.slice(5).trim():``;if(t&&t!==`[DONE]`)try{n.chunk(JSON.parse(t))}catch{}}}}finally{n.end()}}function PS(e,t){let n=R(),r=(0,G.useMemo)(()=>new rS({api:fe(`${TS}/chats/${e}/messages`),credentials:`include`,headers:{...y,"accept-language":Xt},prepareSendMessagesRequest:({messages:e,body:t})=>({body:{text:(e.at(-1)?.parts??[]).map(e=>e.type===`text`?e.text:``).join(``),ask:!0,...t}}),prepareReconnectToStreamRequest:()=>({api:fe(`${TS}/chats/${e}/follow`),credentials:`include`,headers:{...y,"accept-language":Xt}}),fetch:async(e,n)=>{let r=await fetch(e,n);if(r.ok&&r.headers.get(`content-type`)?.includes(`application/json`))return MS();let i=t?.current;if(!(i&&r.status===200&&r.body))return r;let[a,o]=r.body.tee();return NS(o,n,i),new Response(a,{status:r.status,statusText:r.statusText,headers:r.headers})}}),[e,t]),i=wS({id:`work-${e}`,transport:r,onFinish:async()=>{await n.invalidateQueries({queryKey:[`work-chat`,e]}),await n.invalidateQueries({queryKey:kS}),i.setMessages([])}});return i}function FS(){let e=At().data,t=e?e.chatModels.ways[e.chatEngine]:void 0;if(!(e&&t))return{};let n=e.chatModels.chosen[e.chatEngine]??{},r=e=>t.models.find(t=>t.id===e)?.label??e.replace(/^[a-z]+:/,``);return{normal:r(n.normal??t.normal),extra:r(n.extra??t.extra)}}var IS=e=>H.post(`${TS}/chats/${e}/stop`);function LS(e){let t=R();return ot({mutationFn:e,onSettled:()=>{t.invalidateQueries({queryKey:kS}),t.invalidateQueries({queryKey:[`work-chat`]})}})}var RS=()=>LS(e=>H.post(`${TS}/chats`,e)),zS=()=>LS(({id:e,...t})=>H.patch(`${TS}/chats/${e}`,t)),BS=()=>LS(({id:e,...t})=>H.put(`${TS}/chats/${e}/state`,t)),VS=()=>LS(e=>H.del(`${TS}/chats/${e}`)),HS=()=>LS(({id:e,text:t,later:n,files:r,choice:i,form:a})=>H.post(`${TS}/chats/${e}/messages`,{text:t,...r?.length?{files:r}:{},...a?{form:a}:{},...n?{ask:!0,later:n,...i}:{}}));async function US(e,t){let n=[];for(let r of t){let t=await H.upload(`${TS}/chats/${e}/files`,r);n.push({id:t.id,name:t.name,mime:t.mime})}return n}var WS=()=>LS(e=>H.post(`${TS}/sections`,e)),GS=()=>LS(({id:e,name:t})=>H.patch(`${TS}/sections/${e}`,{name:t})),KS=()=>LS(({id:e,direction:t})=>H.post(`${TS}/sections/${e}/move`,{direction:t})),qS=()=>LS(e=>H.del(`${TS}/sections/${e}`));function JS(){let e=OS();return Je({queryKey:[`work-approvals`],queryFn:()=>H.get(`${TS}/approvals`),refetchInterval:e})}function YS(){let e=R();return ot({mutationFn:()=>H.post(`${TS}/approvals/seen`),onSuccess:()=>e.invalidateQueries({queryKey:[`work-approvals`]})})}function XS(e){let t=R();return ot({mutationFn:async({id:n,approve:r})=>{let i=await fetch(fe(`${TS}/chats/${e}/approvals/${n}`),{method:`POST`,credentials:`include`,headers:{...y,"content-type":`application/json`,"accept-language":Xt},body:JSON.stringify({approve:r})});if(!i.ok)throw Error((await i.json().catch(()=>null))?.error??i.statusText);t.invalidateQueries({queryKey:[`work-chat`,e]}),t.invalidateQueries({queryKey:[`work-approvals`]}),await i.text()},onSettled:()=>{t.invalidateQueries({queryKey:[`work-chat`,e]}),t.invalidateQueries({queryKey:[`work-approvals`]}),t.invalidateQueries({queryKey:kS})}})}var ZS={...G};function QS(){let[,e]=G.useState({});return G.useCallback(()=>{e({})},[])}var $S=0;function eC(e,t=`mui`){let n=G.useRef(void 0),r=QS(),i=e??n.current;return G.useEffect(()=>{n.current??($S+=1,n.current=`${t}-${$S}`,e??r())},[e,t,r]),i}var tC=ZS.useId;function nC(e,t){if(tC!==void 0){let n=tC();return e??(t?`${t}-${n}`:n)}return eC(e,t)}function rC(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var iC=rC(`https://base-ui.com/production-error`,`Base UI`),aC=G.createContext(void 0);function oC(e=!0){let t=G.useContext(aC);if(t===void 0&&!e)throw Error(iC(25));return t}var sC=un(),cC=G.createContext(void 0);function lC(e){let t=G.useContext(cC);if(t===void 0&&!e)throw Error(iC(33));return t}var uC=G.createContext(void 0);function dC(e){let t=G.useContext(uC);if(t===void 0&&!e)throw Error(iC(36));return t}var fC={};function pC(e,t){let n=G.useRef(fC);return n.current===fC&&(n.current=e(t)),n}function mC(e,t,n,r){let i=pC(gC).current;return _C(i,e,t,n,r)&&yC(i,[e,t,n,r]),i.callback}function hC(e){let t=pC(gC).current;return vC(t,e)&&yC(t,e),t.callback}function gC(){return{callback:null,cleanup:null,refs:[]}}function _C(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function vC(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function yC(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var bC=19;function xC(e){return bC>=e}function SC(e){if(!G.isValidElement(e))return null;let t=e,n=t.props;return(xC(19)?n?.ref:t.ref)??null}function CC(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function wC(){}var TC=Object.freeze([]),EC=Object.freeze({});function DC(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function OC(e,t){return typeof e==`function`?e(t):e}function kC(e,t){return typeof e==`function`?e(t):e}var AC={};function jC(e,t,n,r,i){if(!n&&!r&&!i&&!e)return NC(t);let a=NC(e);return t&&(a=PC(a,t)),n&&(a=PC(a,n)),r&&(a=PC(a,r)),i&&(a=PC(a,i)),a}function MC(e){if(e.length===0)return AC;if(e.length===1)return NC(e[0]);let t=NC(e[0]);for(let n=1;n<e.length;n+=1)t=PC(t,e[n]);return t}function NC(e){return RC(e)?{...e(AC)}:FC(e)}function PC(e,t){return RC(t)?t(e):IC(e,t)}function FC(e){let t={...e};for(let e in t){let n=t[e];LC(e,n)&&(t[e]=BC(n))}return t}function IC(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=CC(e.style,r);break;case`className`:e[n]=HC(e.className,r);break;default:e[n]=LC(n,r)?zC(e[n],r):r}}return e}function LC(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function RC(e){return typeof e==`function`}function zC(e,t){return t?e?(...n)=>{let r=n[0];if(UC(r)){let i=r;VC(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:BC(t):e}function BC(e){return e&&((...t)=>{let n=t[0];return UC(n)&&VC(n),e(...t)})}function VC(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function HC(e,t){return t?e?t+` `+e:t:e}function UC(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function WC(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=JC(r));let i=GC(t,n,r);if(n.enabled===!1)return null;let a=n.state??EC;return YC(e,r,i,a)}function GC(e,t,n){let{className:r,style:i}=e,{state:a=EC,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?OC(r,a):void 0,d=l?kC(i,a):void 0,f=l?DC(a,c):EC,p=l&&s?KC(s):void 0,m=l?CC(f,p)??{}:EC;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?hC([m.ref,SC(n),...o]):mC(m.ref,SC(n),o):mC(null,null)),l?(u!==void 0&&(m.className=HC(m.className,u)),d!==void 0&&(m.style=CC(m.style,d)),m):EC}function KC(e){return Array.isArray(e)?MC(e):jC(void 0,e)}var qC=Symbol.for(`react.lazy`);function JC(e){if(e?.$$typeof!==qC)return e;let t=G.Children.toArray(e)[0];return G.isValidElement(t)?t:e}function YC(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=jC(n,t.props);return e.ref=n.ref,G.cloneElement(t,e)}return XC(e,n)}function XC(e,t){return e===`button`?(0,G.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,G.createElement)(`img`,{alt:``,...t,key:t.key}):G.createElement(e,t)}var ZC=`data-starting-style`,QC=`data-ending-style`,$C={[ZC]:``},ew={[QC]:``},tw={transitionStatus(e){return e===`starting`?$C:e===`ending`?ew:null}},nw=`data-open`,rw=`data-closed`,iw=`data-anchor-hidden`,aw=`data-popup-open`,ow=`data-pressed`,sw={[aw]:``},cw={[aw]:``,[ow]:``},lw={[nw]:``},uw={[rw]:``},dw={[iw]:``},fw={open(e){return e?sw:null}},pw={open(e){return e?cw:null}},mw={open(e){return e?lw:uw},anchorHidden(e){return e?dw:null}},hw={...mw,...tw},gw=`none`,_w=`trigger-press`,vw=`trigger-hover`,yw=`trigger-focus`,bw=`outside-press`,xw=`item-press`,Sw=`focus-out`,Cw=`escape-key`,ww=`list-navigation`,Tw=`keyboard`,Ew=`pointer`,Dw=`cancel-open`,Ow=`sibling-open`,kw=`disabled`,Aw=`imperative-action`;function jw({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=G.useRef(e!==void 0),[a,o]=G.useState(()=>t);return[i&&e!==void 0?e:a,G.useCallback(e=>{i||o(e)},[])]}var Mw=G.createContext(null);function Nw(e=`root`){let t=G.useContext(Mw),n=G.useContext(uC);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var Pw={visible:!0,ref:null};function Fw(){return Pw}function Iw(e,t,n=`root`){let r=Nw(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Fw)({label:e.label,children:e.children,render:e.render}),a=mC(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var Lw=G.createContext(void 0);function Rw(){let e=G.useContext(Lw);if(e===void 0)throw Error(iC(30));return e}function zw(){return typeof window<`u`}function Bw(e){return Uw(e)?(e.nodeName||``).toLowerCase():`#document`}function Vw(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Hw(e){return((Uw(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Uw(e){return zw()?e instanceof Node||e instanceof Vw(e).Node:!1}function Ww(e){return zw()?e instanceof Element||e instanceof Vw(e).Element:!1}function Gw(e){return zw()?e instanceof HTMLElement||e instanceof Vw(e).HTMLElement:!1}function Kw(e){return!zw()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Vw(e).ShadowRoot}function qw(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=iT(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Jw(e){return/^(table|td|th)$/.test(Bw(e))}function Yw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Xw=/transform|translate|scale|rotate|perspective|filter/,Zw=/paint|layout|strict|content/,Qw=e=>!!e&&e!==`none`,$w;function eT(e){let t=Ww(e)?iT(e):e;return Qw(t.transform)||Qw(t.translate)||Qw(t.scale)||Qw(t.rotate)||Qw(t.perspective)||!nT()&&(Qw(t.backdropFilter)||Qw(t.filter))||Xw.test(t.willChange||``)||Zw.test(t.contain||``)}function tT(e){let t=oT(e);for(;Gw(t)&&!rT(t);){if(eT(t))return t;if(Yw(t))return null;t=oT(t)}return null}function nT(){return $w??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),$w}function rT(e){return/^(html|body|#document)$/.test(Bw(e))}function iT(e){return Vw(e).getComputedStyle(e)}function aT(e){return Ww(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function oT(e){if(Bw(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Kw(e)&&e.host||Hw(e);return Kw(t)?t.host:t}function sT(e){let t=oT(e);return rT(t)?(e.ownerDocument||e).body:Gw(t)&&qw(t)?t:sT(t)}function cT(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=sT(e),i=r===e.ownerDocument?.body,a=Vw(r);if(i){let e=lT(a);return t.concat(a,a.visualViewport||[],qw(r)?r:[],e&&n?cT(e):[])}return t.concat(r,cT(r,[],n))}function lT(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var uT=ZS.useInsertionEffect,dT=uT&&uT!==ZS.useLayoutEffect?uT:e=>e();function Y(e){let t=pC(fT).current;return t.next=e,dT(t.effect),t.trampoline}function fT(){let e={next:void 0,callback:pT,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function pT(){}var X=typeof document<`u`?G.useLayoutEffect:()=>{},mT=G.createContext(void 0);function hT(e=!1){let t=G.useContext(mT);if(t===void 0&&!e)throw Error(iC(16));return t}function gT(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:G.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function _T(e){return e?.ownerDocument||document}function vT(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(Vw(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function yT(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=G.useRef(null),s=hT(!0),c=a??s!==void 0,{props:l}=gT({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=G.useCallback(()=>{let e=o.current;bT(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:G.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return jC({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(VC(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=bT(r),s=!i&&xT(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),vT(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),vT(r,e)))},onKeyUp(e){if(!t){if(VC(e),a?.(e),e.target===e.currentTarget&&i&&c&&bT(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),vT(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Y(e=>{o.current=e,u()})}}function bT(e){return Gw(e)&&e.tagName===`BUTTON`}function xT(e){return Gw(e)&&e.tagName===`A`&&!!e.href}function ST(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:CT,platform:wT,maxTouchPoints:TT}=ST(),ET=CT.toLowerCase(),DT=wT.toLowerCase(),OT=/^i(os$|p)/.test(DT)||DT===`macintel`&&TT>1,kT=`android`,AT=DT===kT||ET.includes(kT),jT=!OT&&DT.startsWith(`mac`);DT.startsWith(`win`),!AT&&/^(linux|chrome os)/.test(DT);var MT=jT||OT,NT=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!NT&&ET.includes(`firefox`),!NT&&ET.includes(`chrom`);var PT=MT,FT=/jsdom|happydom/.test(ET);function IT(e){e.preventDefault()}function LT(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=dC(),u=oC(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return G.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?IT:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:xw})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!jT&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&vT(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var RT={type:`regular-item`};function zT(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=G.useRef(null),{getButtonProps:d,buttonRef:f}=yT({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=LT({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=G.useCallback(e=>jC(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=mC(u,f);return G.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var BT=G.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function VT(){return G.useContext(BT)}function HT(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=VT(),u=G.useRef(-1),[d,f]=G.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=G.useRef(null),h=G.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function UT(e){return nC(e,`base-ui`)}var WT=`data-checked`,GT=`data-unchecked`,KT={checked(e){return e?{[WT]:``}:{[GT]:``}},...tw};function qT(e,t,n,r){let i=!1,a=!1,o=r??EC;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function JT(e,t,n){let r=n??EC;return{reason:e,event:t??new Event(`base-ui`),...r}}var YT=G.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=dC(),m=HT({guess:!0,label:a}),h=UT(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=zT({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:RT}),C=G.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=qT(xw,e.nativeEvent,void 0,{preventUnmountOnClose:wC});u?.(!l,t)}let T=WC(`div`,e,{state:C,stateAttributesMapping:KT,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,K.jsx)(Lw.Provider,{value:C,children:T})}),XT=G.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=jw({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=Iw(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,K.jsx)(YT,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null});function ZT(e){G.useEffect(e,TC)}var QT=null;globalThis.requestAnimationFrame;var $T=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},eE=class e{static create(){return new e}static request(e){return $T.request(e)}static cancel(e){return $T.cancel(e)}currentId=QT;request(e){this.cancel(),this.currentId=$T.request(()=>{this.currentId=QT,e()})}cancel=()=>{this.currentId!==QT&&($T.cancel(this.currentId),this.currentId=QT)};disposeEffect=()=>this.cancel};function tE(){let e=pC(eE.create).current;return ZT(e.disposeEffect),e}function nE(e,t=!1,n=!1,r=!1){let[i,a]=G.useState(e&&t?`idle`:void 0),[o,s]=G.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),X(()=>{if(!e&&o&&i!==`ending`&&n){let e=eE.request(()=>{a(`ending`)});return()=>{eE.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t||i===void 0)return;let n=eE.request(()=>{a(void 0)});return()=>{eE.cancel(n)}},[t,e,i]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=eE.request(()=>{a(`idle`)});return()=>{eE.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function rE(e){return e==null?e:`current`in e?e.current:e}function iE(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var aE=null;function oE(e){if(!aE){let e=[];aE=e,queueMicrotask(()=>{aE=null,_c.flushSync(()=>{for(let t of e)t()})})}aE.push(e)}function sE(e,t=!1,n=!1){let r=tE();return Y((i,a=null)=>{r.cancel();let o=rE(e);if(o==null)return;let s=o,c=()=>{if(!n){_c.flushSync(i);return}oE(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(iE(s).map(e=>e.finished.then(wC))).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(iE(s).some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=ZC;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function cE(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=Y(a),s=sE(r,n,i);G.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var lE=G.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Rw(),c=G.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=nE(s.checked);return cE({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),WC(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:KT,props:{"aria-hidden":!0,...o},enabled:a||u})}),uE=G.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=dC(),f=HT({guess:!0,label:a}),p=UT(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=zT({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:RT});return WC(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),dE=G.forwardRef(function(e,t){let n=Iw(e,t);return n.visible?(0,K.jsx)(uE,{...e,ref:n.ref}):null}),fE=0,pE=class e{static create(){return new e}currentId=fE;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=fE,t()},e)}isStarted(){return this.currentId!==fE}clear=()=>{this.currentId!==fE&&(clearTimeout(this.currentId),this.currentId=fE)};disposeEffect=()=>this.clear};function mE(){let e=pC(pE.create).current;return ZT(e.disposeEffect),e}function hE(e){e.preventDefault(),e.stopPropagation()}function gE(e){return`nativeEvent`in e}function _E(e){return e.pointerType===``&&e.isTrusted?!0:AT&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function vE(e){return FT?!1:!AT&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(AT||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function yE(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function bE(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function xE(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function SE(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Kw(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function CE(e,t){let n=e;for(;n;){if(Ww(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(Kw(n)?n.host:null)}return null}function wE(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var TE=`data-base-ui-focusable`,EE=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,DE=`ArrowLeft`,OE=`ArrowRight`,kE=`ArrowUp`,AE=`ArrowDown`,jE=`data-trigger-disabled`;function ME(e,t){if(!Ww(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(jE);for(let[,e]of t.entries())if(SE(e,n))return!e.hasAttribute(jE);return!1}function NE(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function PE(e){return e.matches(`html,body`)}function FE(e){return Gw(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function IE(e){return CE(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${EE}`)!=null}function LE(e){return e?e.getAttribute(`role`)===`combobox`&&FE(e):!1}function RE(e){if(!e||FT)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function zE(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function BE(e,t){return t!=null&&!yE(t)?0:typeof e==`function`?e():e}function VE(e,t,n){let r=BE(e,n);return typeof r==`number`?r:r?.[t]}function HE(e){return typeof e==`function`?e():e}function UE(e,t){return t||e===`click`||e===`mousedown`}function WE(e){return e?.includes(`mouse`)&&e!==`mousedown`}var GE=G.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new pE,currentIdRef:{current:null},currentContextRef:{current:null}});function KE(e,t){e.current=t.current}function qE(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=G.useRef(n),a=G.useRef(n),o=G.useRef(null),s=G.useRef(null),c=mE();return X(()=>{if(a.current=n,!o.current){i.current=n;return}i.current={open:VE(i.current,`open`),close:VE(n,`close`)}},[n,o,i,a]),(0,K.jsx)(GE.Provider,{value:G.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function JE(e,t={open:!1}){let{open:n}=t,r=e.useState(`floatingId`),{currentIdRef:i,delayRef:a,timeoutMs:o,initialDelayRef:s,currentContextRef:c,hasProvider:l,timeout:u}=G.useContext(GE),[d,f]=G.useState(!1),p=G.useRef(n);return X(()=>{p.current=n},[n]),X(()=>{function t(){c.current?.setIsInstantPhase(!1),i.current=null,c.current=null,a.current=s.current,u.clear()}if(i.current&&!n&&i.current===r){if(f(!1),o){let n=r;return u.start(o,()=>{e.select(`open`)||i.current&&i.current!==n||t()}),()=>{(p.current||i.current!==n)&&u.clear()}}t()}},[n,r,i,a,o,s,c,u,e]),X(()=>{if(!n)return;let t=c.current,o=i.current;u.clear(),c.current={onOpenChange:e.setOpen,setIsInstantPhase:f},i.current=r,a.current={open:0,close:VE(s.current,`close`)},o!==null&&o!==r?(f(!0),t?.setIsInstantPhase(!0),t?.onOpenChange(!1,qT(gw))):(f(!1),t?.setIsInstantPhase(!1))},[n,r,e,i,a,s,c,u]),X(()=>()=>{if(i.current===r){if(c.current=null,!p.current)return;i.current=null,KE(a,s),u.clear()}},[c,i,a,r,s,u]),G.useMemo(()=>({activeIdRef:i,hasProvider:l,delayRef:a,isInstantPhase:d}),[i,l,a,d])}function YE(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function XE(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function ZE(e){let t=pC(QE,e).current;return t.next=e,X(t.effect),t}function QE(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var $E={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},eD={...$E,position:`fixed`,margin:0,top:0,left:0};({...$E});var tD=G.forwardRef(function(e,t){let[n,r]=G.useState();X(()=>{PT&&NT&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,K.jsx)(`span`,{...e,ref:t,style:eD,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),nD=Math.min,rD=Math.max,iD=Math.round,aD=Math.floor,oD=e=>({x:e,y:e}),sD={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function cD(e,t,n){return rD(e,nD(t,n))}function lD(e,t){return typeof e==`function`?e(t):e}function uD(e){return e.split(`-`)[0]}function dD(e){return e.split(`-`)[1]}function fD(e){return e===`x`?`y`:`x`}function pD(e){return e===`y`?`height`:`width`}function mD(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function hD(e){return fD(mD(e))}function gD(e,t,n){n===void 0&&(n=!1);let r=dD(e),i=hD(e),a=pD(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=TD(o)),[o,TD(o)]}function _D(e){let t=TD(e);return[vD(e),t,vD(t)]}function vD(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var yD=[`left`,`right`],bD=[`right`,`left`],xD=[`top`,`bottom`],SD=[`bottom`,`top`];function CD(e,t,n){switch(e){case`top`:case`bottom`:return n?t?bD:yD:t?yD:bD;case`left`:case`right`:return t?xD:SD;default:return[]}}function wD(e,t,n,r){let i=dD(e),a=CD(uD(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(vD)))),a}function TD(e){let t=uD(e);return sD[t]+e.slice(t.length)}function ED(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function DD(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ED(e)}function OD(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function kD(e,t){return t<0||t>=e.length}function AD(e,t){return ND(e.current,{disabledIndices:t})}function jD(e,t){return ND(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function MD(e,t,n){let{decrement:r,loopFocus:i,allowEscape:a,disabledIndices:o,minIndex:s,maxIndex:c}=n,l=()=>ND(e,{startingIndex:t,decrement:r,disabledIndices:o}),u,d=!1;if(!i)u=r?Math.max(s,l()):Math.min(c,l());else if(r?t<=s:t>=c){let n=r?-1:e.length;a&&t!==n?u=-1:(u=r?c:s,d=!0)}else u=l();return{index:kD(e,u)?-1:u,wrapped:d}}function ND(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&PD(e,a,r));return a}function PD(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!ID(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function FD(e){return e.visibility===`hidden`||e.visibility===`collapse`}function ID(e,t=e?iT(e):null){return!e||!e.isConnected||!t||FD(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var LD=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function RD(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return Kw(n)?n.host:null}function zD(e){for(let t of Array.from(e.children))if(Bw(t)===`summary`)return t;return null}function BD(e,t){let n=zD(t);return!!n&&(e===n||SE(n,e))}function VD(e){let t=e?Bw(e):``;return e!=null&&e.matches(LD)&&(t!==`summary`||e.parentElement!=null&&Bw(e.parentElement)===`details`&&zD(e.parentElement)===e)&&(t!==`details`||zD(e)==null)&&(t!==`input`||e.type!==`hidden`)}function HD(e){if(!VD(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=RD(t)){let n=t!==e,r=Bw(t)===`slot`;if(t.hasAttribute(`inert`)||n&&Bw(t)===`details`&&!t.open&&!BD(e,t)||t.hasAttribute(`hidden`)||!r&&!UD(t,n))return!1}return!0}function UD(e,t){let n=iT(e);return t?n.display!==`none`:ID(e,n)}function WD(e){let t=e.tabIndex;if(t<0){let t=Bw(e);if(t===`details`||t===`audio`||t===`video`||Gw(e)&&e.isContentEditable)return 0}return t}function GD(e){if(Bw(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function KD(e,t){let n=GD(e);if(!n)return!0;let r=t.find(e=>{let t=GD(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=GD(e);return t?.name===n.name&&t.form===n.form})===n}function qD(e){if(Gw(e)&&Bw(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return Gw(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function JD(e,t){qD(e).forEach(e=>{VD(e)&&t.push(e),JD(e,t)})}function YD(e,t,n){qD(e).forEach(e=>{Gw(e)&&e.matches(t)&&n.push(e),YD(e,t,n)})}function XD(e){return HD(e)&&WD(e)>=0}function ZD(e){let t=[];return JD(e,t),t.filter(HD)}function QD(e){let t=ZD(e);return t.filter(e=>WD(e)>=0&&KD(e,t))}function $D(e,t){let n=QD(e),r=n.length;if(r===0)return;let i=xE(_T(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function eO(e){return $D(_T(e).body,1)||e}function tO(e){return $D(_T(e).body,-1)||e}function nO(e,t,n){if(!e)return null;let r=[];JD(_T(e).body,r);let i=r.indexOf(e);if(i===-1)return null;let a=r.filter(HD);for(let e=1;e<r.length;e+=1){let o=r[(i+t*e+r.length)%r.length];if(!SE(n,o)&&XD(o)&&KD(o,a))return o}return r[i]}function rO(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!SE(n,r)}function iO(e){QD(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function aO(e){let t=[];YD(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function oO(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...oO(e,t.id,n)])}function sO(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function cO(e){return`data-base-ui-${e}`}var lO=0;function uO(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(lO);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),wC;let o=requestAnimationFrame(a);return lO=o,()=>{lO===o&&(cancelAnimationFrame(o),lO=0)}}var dO=`data-base-ui-inert`,fO=new WeakMap,pO=new WeakSet,mO=new WeakMap,hO=0;function gO(e){return e?Kw(e)?e.host:gO(e.parentNode):null}var _O=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=gO(t);return e.contains(n)?n:null}).filter(e=>e!=null),vO=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},yO=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Bw(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function bO(e,t,n,{mark:r=!0}){let i=_O(t,e),a=r?yO(t,vO(i),new Set(i)):[],o=[],s=[];if(n){let e=_O(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);yO(t,vO(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(fO.get(e)||0)+1;fO.set(e,r),o.push(e),r===1&&n&&pO.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(mO.get(e)||0)+1;mO.set(e,t),s.push(e),t===1&&e.setAttribute(dO,``)}),hO+=1,()=>{o.forEach(e=>{let t=(fO.get(e)||0)-1;fO.set(e,t),t||(pO.has(e)||e.removeAttribute(`aria-hidden`),pO.delete(e))}),r&&s.forEach(e=>{let t=(mO.get(e)||0)-1;mO.set(e,t),t||e.removeAttribute(dO)}),--hO,hO||(fO=new WeakMap,pO=new WeakSet,mO=new WeakMap)}}function xO(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=_T(e[0]).body;return bO(e,i,n,{mark:r})}var SO={style:{transition:`none`}},CO={fallbackAxisSide:`none`},wO={fallbackAxisSide:`end`},TO={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},EO=G.createContext(null),DO=()=>G.useContext(EO),OO=cO(`portal`);function kO(e={}){let{ref:t,container:n,componentProps:r=EC,elementProps:i}=e,a=nC(),o=DO()?.portalNode,[s,c]=G.useState(null),[l,u]=G.useState(null),d=Y(e=>{e!==null&&u(e)}),f=G.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(Uw(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=WC(`div`,r,{ref:[t,d],props:[{id:a,[OO]:``},i]}),m=s&&p?_c.createPortal(p,s):null;return{node:l,nodeId:G.isValidElement(p)?p.props.id:void 0,subtree:m}}var AO=G.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=kO({container:o,ref:t,componentProps:e,elementProps:c}),f=G.useRef(null),p=G.useRef(null),m=G.useRef(null),h=G.useRef(null),[g,_]=G.useState(null),v=G.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;G.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&rO(e)&&(e.type===`focusin`?v.current&&=(aO(l),!1):(iO(l),v.current=!0))}return XE(YE(l,`focusin`,e,!0),YE(l,`focusout`,e,!0))},[l,y]),X(()=>{l&&b===!0&&v.current&&(aO(l),v.current=!1)},[b,l]);let S=G.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,K.jsxs)(G.Fragment,{children:[d,(0,K.jsxs)(EO.Provider,{value:S,children:[x&&l&&(0,K.jsx)(tD,{"data-type":`outside`,ref:f,onFocus:e=>{rO(e,l)?m.current?.focus():tO(g?g.domReference:null)?.focus()}}),x&&l&&(0,K.jsx)(`span`,{role:s,"aria-owns":u,style:TO}),l&&_c.createPortal(a,l),x&&l&&(0,K.jsx)(tD,{"data-type":`outside`,ref:p,onFocus:e=>{rO(e,l)?h.current?.focus():(eO(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,qT(`focus-out`,e.nativeEvent)))}})]})]})});function jO(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var MO=class{nodesRef={current:[]};events=jO();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},NO=G.createContext(null),PO=G.createContext(null),FO=()=>G.useContext(NO)?.id||null,IO=e=>{let t=G.useContext(PO);return e??t};function LO(e){let t=nC(),n=IO(e),r=FO();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function RO(e){let{children:t,id:n}=e,r=FO();return(0,K.jsx)(NO.Provider,{value:G.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function zO(e){let{children:t,externalTree:n}=e,r=pC(()=>n??new MO).current;return(0,K.jsx)(PO.Provider,{value:r,children:t})}function BO(e,t){let n=Vw(wE(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(_E(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var VO=20,HO=[];function UO(){HO=HO.filter(e=>e.deref()?.isConnected)}function WO(e){UO(),e&&Bw(e)!==`body`&&(HO.push(new WeakRef(e)),HO.length>VO&&(HO=HO.slice(-20)))}function GO(){return UO(),HO[HO.length-1]?.deref()}function KO(e){return e?XD(e)?e:QD(e)[0]||e:null}function qO(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=ZD(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return XD(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function JO(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=Y(()=>b.current.floatingContext?.nodeId),S=i===!1,C=LE(_)&&S,w=ZE(i),T=ZE(a),E=ZE(o),D=ZE(u),O=ZE(g),k=IO(m),A=DO(),j=G.useRef(!1),M=G.useRef(!1),N=G.useRef(!1),P=G.useRef(null),F=G.useRef(``),I=G.useRef(``),L=G.useRef(null),R=G.useRef(null),ee=mC(L,p,A?.beforeInsideRef),te=mC(R,A?.afterInsideRef),ne=mE(),z=mE(),re=tE(),ie=A!=null,B=zE(v),ae=Y((e=B)=>e?QD(e):[]),oe=Y(()=>h?.().filter(e=>e!=null)??[]);G.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&SE(B,xE(_T(B)))&&ae().length===0&&!C&&hE(e)}return YE(_T(B),`keydown`,e)},[r,B,c,C,ae]),G.useEffect(()=>{if(r||!g)return;let e=_T(B);function t(){N.current=!1}function n(e){let t=wE(e),n=oe(),r=SE(v,t)||SE(_,t)||SE(A?.portalNode,t)||n.some(e=>e===t||SE(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,CE(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,z.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return XE(YE(e,`pointerdown`,n,!0),YE(e,`pointerup`,t,!0),YE(e,`pointercancel`,t,!0),YE(e,`keydown`,i,!0),t)},[r,v,_,B,g,A,z,oe]),G.useEffect(()=>{if(r||!l)return;let e=_T(B);function n(){M.current=!0,z.start(0,()=>{M.current=!1})}function i(e){let t=wE(e);XD(t)&&(P.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=wE(n);c&&r==null&&a!=null&&SE(v,a)&&WO(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=oe(),p=r?.hasAttribute(cO(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,rE(f),rE(d)].includes(r),m=!(SE(_,r)||SE(v,r)||SE(r,v)||SE(A?.portalNode,r)||u.some(e=>e===r||SE(e,r))||l.hasMatchingElement(e=>SE(e,r))||p||k&&(oO(k.nodesRef.current,o).find(e=>SE(e.context?.elements.floating,r)||SE(e.context?.elements.domReference,r))||sO(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,zE(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&B&&qO(B),s&&i!==_&&!ID(a)&&xE(e)===e.body){if(Gw(B)&&(B.focus(),s===`popup`)){re.request(()=>{B.focus()});return}let e=ae(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||B;Gw(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!c)&&r&&m&&!M.current&&(C||r!==GO())&&(j.current=!0,t.setOpen(!1,qT(Sw,n)))})}function o(){N.current||(b.current.insideReactTree=!0,ne.start(0,()=>{b.current.insideReactTree=!1}))}let u=Gw(_)?_:null;if(v||u)return XE(u&&YE(u,`focusout`,a),u&&YE(u,`pointerdown`,n),v&&YE(v,`focusin`,i),v&&YE(v,`focusout`,a),v&&A&&YE(v,`focusout`,o,!0))},[r,_,v,B,c,k,A,t,l,s,ae,C,x,b,ne,z,re,d,f,oe]),G.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${cO(`portal`)}]`)||[]),t=(k?sO(k.nodesRef.current,x()):[]).find(e=>LE(e.context?.elements.domReference||null))?.context?.elements.domReference,n=xO([v,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...oe(),t,rE(f),rE(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=xO([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,oe]),X(()=>{if(!g||r||!Gw(B))return;F.current=``,I.current=``;let e=_T(B),t=xE(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||SE(B,t))return;let i=null,a=()=>(i??=ae(B),i[0]||B),o;o=r===!0||r===null?a():rE(r),o||=a();let s=SE(B,xE(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&_E(c);uO(o,{sync:l,preventScroll:o===B,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=xE(e);return!(t!==o&&SE(B,t))}})})},[r,g,B,ae,w,D,O,b]);let se=G.useRef(null);X(()=>{if(r||!B){se.current=null;return}se.current&&=(se.current.cancelled=!0,null);let e=_T(B),t=xE(e),n=D.current==null;WO(t);function i(e){if(e.open||(F.current=BO(e.nativeEvent,I.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(cO(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(_E(e.nativeEvent)||vE(e.nativeEvent))j.current=!1;else{let e=!1;_T(B).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&Bw(t)!==`body`?t:null,s=n?o||a:a||o;return s||=GO()||null,typeof i==`boolean`?s:rE(i)||s||null}return()=>{y.off(`openchange`,i);let t=xE(e),n=oe(),r=SE(v,t)||n.some(e=>e===t||SE(e,t))||k&&oO(k.nodesRef.current,x(),!1).some(e=>SE(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s),l={cancelled:!1};se.current=l,queueMicrotask(()=>{se.current===l&&(se.current=null);let n=KO(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&Gw(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,B,T,E,D,y,k,_,x,oe]),X(()=>{if(!NT||g||!v)return;let e=xE(_T(v));Gw(e)&&FE(e)&&SE(v,e)&&e.blur()},[g,v]),X(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),X(()=>{if(!r&&B)return qO(B),()=>{queueMicrotask(UO)}},[r,B]);let ce=!r&&(!c||!C)&&(ie||c);return(0,K.jsxs)(G.Fragment,{children:[ce&&(0,K.jsx)(tD,{"data-type":`inside`,ref:ee,onFocus:e=>{if(c){let e=ae();uO(e[e.length-1])}else A?.portalNode&&(j.current=!1,rO(e,A.portalNode)?eO(_)?.focus():rE(f??A.beforeOutsideRef)?.focus())}}),n,ce&&(0,K.jsx)(tD,{"data-type":`inside`,ref:te,onFocus:e=>{c?uO(ae()[0]):A?.portalNode&&(l&&(j.current=!0),rO(e,A.portalNode)?tO(_)?.focus():rE(d??A.afterOutsideRef)?.focus())}})]})}function YO(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=_w}=t,l=e.context.dataRef,u=G.useRef(void 0),d=tE(),f=mE(),p=G.useMemo(()=>{function t(t,n,r,i){let a=qT(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=yE(e.pointerType,!0)&&vE(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||yE(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=wE(s),p=FE(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;if(r===`mousedown`&&o){u.current=void 0;return}yE(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return G.useMemo(()=>n?{reference:p}:EC,[n,p])}function XO(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,(!i||c)&&(d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function ZO(e){return e!=null&&e.clientX!=null}function QO(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=e.useState(`open`),a=e.useState(`floatingElement`),o=e.useState(`domReferenceElement`),s=e.context.dataRef,c=G.useRef(!1),l=G.useRef(null),[u,d]=G.useState(),[f,p]=G.useState([]),m=Y(t=>{e.set(`positionReference`,t)}),h=Y((t,n,i)=>{c.current||(!s.current.openEvent||ZO(s.current.openEvent))&&e.set(`positionReference`,XO(i??o,{x:t,y:n,axis:r,dataRef:s,pointerType:u}))}),g=Y(e=>{i?l.current||(h(e.clientX,e.clientY,e.currentTarget),p([])):h(e.clientX,e.clientY,e.currentTarget)}),_=yE(u)?a:i;G.useEffect(()=>{if(!n){m(o);return}if(!_)return;function e(){l.current?.(),l.current=null}let t=Vw(a);function r(t){let n=wE(t);SE(a,n)?e():h(t.clientX,t.clientY)}return!s.current.openEvent||ZO(s.current.openEvent)?l.current=YE(t,`mousemove`,r):m(o),e},[_,n,a,s,o,e,h,m,f]),G.useEffect(()=>()=>{e.set(`positionReference`,null)},[e]),G.useEffect(()=>{n&&!a&&(c.current=!1)},[n,a]),G.useEffect(()=>{!n&&i&&(c.current=!0)},[n,i]);let v=G.useMemo(()=>{function e(e){d(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:g,onMouseEnter:g}},[g]);return G.useMemo(()=>n?{reference:v,trigger:v}:{},[n,v])}function $O(){return!1}function ek(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function tk(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=$O,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=IO(c),m=Y(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=Y(()=>a),{escapeKey:v,outsidePress:y}=ek(s),b=G.useRef(!1),x=G.useRef(!1),S=G.useRef(!1),C=G.useRef(!1),w=G.useRef(!1),T=G.useRef(``),E=G.useRef(null),D=mE(),O=mE(),k=mE(),A=Y(()=>{O.clear(),d.current.insideReactTree=!1}),j=Y(e=>{let t=d.current.floatingContext?.nodeId;return(p?oO(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=Y(t=>NE(t,e.select(`floatingElement`))||NE(t,e.select(`domReferenceElement`))),N=Y(t=>{o()&&e.setOpen(!1,qT(_w,t.nativeEvent))}),P=Y(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=gE(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=qT(Cw,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),F=Y(()=>{d.current.insideReactTree=!0,O.start(0,A)}),I=Y(t=>{if(!l||!n||t.button!==0)return;let r=wE(t.nativeEvent);SE(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),L=Y(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});G.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),G.useEffect(()=>A,[A]),G.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new pE,i=_T(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(NT?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&oO(p.nodesRef.current,t).some(t=>NE(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=wE(n),i=`[${cO(`inert`)}]`,a=Ww(r)?r.getRootNode():null,o=Array.from((Kw(a)?a:_T(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>SE(e,r))))return;let c=Ww(r)?r:null;for(;c&&!rT(c);){let e=oT(c);if(rT(e)||!Ww(e))break;c=e}if(!(o.length&&Ww(r)&&!PE(r)&&!SE(r,e.select(`floatingElement`))&&o.every(e=>!SE(c,e)))){if(Gw(r)&&!(`touches`in n)){let e=rT(r),t=iT(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!_E(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}(typeof h!=`function`||h(n))&&(j(`__outsidePressBubbles`)||(e.setOpen(!1,qT(bw,n)),A()))}}}function F(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&N(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=wE(e);if(!n)return;let r=YE(n,e.type,()=>{t(e),r()})}function R(e){T.current=`touch`,L(e,I)}function ee(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function te(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;if(c(),f()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!O(e)){if(n){s();return}(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())}}}function ne(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function z(e){L(e,ne)}function re(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function ie(e){L(e,re)}let B=XE(r&&XE(YE(i,`keydown`,P),YE(i,`compositionstart`,a),YE(i,`compositionend`,o)),g&&XE(YE(i,`click`,ee,!0),YE(i,`pointerdown`,ee,!0),YE(i,`pointerup`,te,!0),YE(i,`pointercancel`,te,!0),YE(i,`mousedown`,ee,!0),YE(i,`mouseup`,te,!0),YE(i,`touchstart`,R,{capture:!0,passive:!0}),YE(i,`touchmove`,z,{capture:!0,passive:!0}),YE(i,`touchend`,ie,{capture:!0,passive:!0})));return()=>{B(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,P,A,_,j,M,p,e,D,k]);let R=G.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),ee=G.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return G.useMemo(()=>n?{reference:R,floating:ee,trigger:R}:{},[n,R,ee])}function nk(e,t,n,r){return{left:e,top:t,right:n,bottom:r,x:e,y:t,width:n-e,height:r-t}}function rk(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function ik(e){let t=[],n,r=1/0,i=1/0,a=-1/0,o=-1/0;for(let s of Array.from(e).sort((e,t)=>e.top-t.top)){if(r=Math.min(r,s.left),i=Math.min(i,s.top),a=Math.max(a,s.right),o=Math.max(o,s.bottom),!n||s.top-n.top>n.height/2)t.push(rk(s));else{let e=t[t.length-1];e.left=Math.min(e.left,s.left),e.right=Math.max(e.right,s.right),e.bottom=Math.max(e.bottom,s.bottom),e.width=e.right-e.left,e.height=e.bottom-e.top}n=s}return{lines:t,fallback:nk(r,i,a,o)}}function ak(e,t,n){return e.findIndex(e=>t>e.left-2&&t<e.right+2&&n>e.top-2&&n<e.bottom+2)}function ok(e){return nk(e.left,e.top,e.right,e.bottom)}function sk(e,t,n){let{lines:r}=ik(e.getClientRects());if(r.length<2)return;let i=ak(r,t,n);return{x:t,y:n,lineIndex:i===-1?void 0:i,element:e}}function ck(e,t,n){let{lines:r,fallback:i}=ik(e.getClientRects());if(r.length<2)return null;let a=n?.x,o=n?.y,s=t[0];if(n?.lineIndex!=null&&r[n.lineIndex])return ok(r[n.lineIndex]);if(a!=null&&o!=null){let e=ak(r,a,o);if(e!==-1)return ok(r[e])}if(r.length===2&&r[0].left>r[1].right&&a!=null&&o!=null)return i;if(s===`t`||s===`b`){let e=r[0],t=r[r.length-1],n=s===`t`?e:t;return nk(n.left,e.top,n.right,t.bottom)}let c=s===`l`,l=r[0].left,u=r[0].right,d=c?1/0:-1/0,f=r[0],p=r[0];for(let e of r){l=Math.min(l,e.left),u=Math.max(u,e.right);let t=c?e.left:e.right;c&&t<d||!c&&t>d?(d=t,f=e,p=e):t===d&&(p=e)}return nk(l,f.top,u,p.bottom)}function lk(e){return`contextElement`in e&&e.contextElement?e.contextElement:Ww(e)?e:void 0}function uk(e,t){function n(t){dk(e,t.currentTarget,t.clientX,t.clientY)}function r(e){t||n(e)}return{onFocus(){e.current=void 0},onMouseEnter:r,onMouseMove:r}}function dk(e,t,n,r){let i=sk(t,n,r);return e.current=i,i}function fk(e){return{name:`inline`,async fn(t){let n=t.elements.reference;if(typeof n?.getClientRects!=`function`)return{};let r=lk(n),i=e.current,a=i?.element===n||i?.element===r?i:void 0,o=ck(n,t.placement,a);if(!o||typeof t.platform.getElementRects!=`function`)return{};let s=await t.platform.getElementRects({reference:{contextElement:r,getBoundingClientRect(){return o}},floating:t.elements.floating,strategy:t.strategy});return t.rects.reference.x===s.reference.x&&t.rects.reference.y===s.reference.y&&t.rects.reference.width===s.reference.width&&t.rects.reference.height===s.reference.height?{}:{reset:{rects:s}}}}}function pk(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Ww(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function mk(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=Y(i),{mounted:c,setMounted:l,transitionStatus:u}=nE(t,!1,!1,o),d=!t&&r;X(()=>{t&&s(!1)},[t,s]);let f=G.useRef(c),p=G.useRef(!1),m=QS(),h=()=>{f.current=!1,l(!1),a()};X(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=Y(()=>{if(f.current){if(t){p.current=!0,m();return}h()}});return cE({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var hk={tabIndex:-1,[TE]:``};function gk(e,t=!1){let n=nC(),r=FO()!=null,i=pC(()=>e(n,r)).current;return pk({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function _k({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function vk(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function yk(e,t){let n=G.useRef(null);return Y(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),vk(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),vk(t))})}function bk(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function xk(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Sk(e,t,n,r={}){let i=n.reason,a=i===vw,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=xk(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=bk(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?_c.flushSync(l):l()}function Ck(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=yk(e,n),o=Y(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Y(e=>{a(e),e&&o(e)});return X(()=>(s(t.current),()=>s(null)),[s,t,n,e]),X(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function wk(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=G.useRef(null),i=e.useState(`open`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=qT(gw);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Tk(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=mk({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return pC(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Ek(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:EC,inactiveTriggerProps:EC,popupProps:EC})},[e])}var Dk=class{idMap=new Map;add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},Ok=t(dn(),1),kk=[],Ak=void 0;function jk(){return Ak}function Mk(e){kk.push(e)}function Nk(e){let t=(t,n)=>{let r=pC(Fk).current,i;try{Ak=r;for(let e of kk)e.before(r);i=e(t,n);for(let e of kk)e.after(r);r.didInitialize=!0}finally{Ak=void 0}return i};return t.displayName=e.displayName||e.name,t}function Pk(e){return G.forwardRef(Nk(e))}function Fk(){return{didInitialize:!1}}var Ik=xC(19)?zk:Bk;function Lk(e,t,n,r,i){return Ik(e,t,n,r,i)}function Rk(e,t,n,r,i){let a=G.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,sC.useSyncExternalStore)(e.subscribe,a,a)}Mk({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,sC.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function zk(e,t,n,r,i){let a=jk();if(!a)return Rk(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function Bk(e,t,n,r,i){return(0,Ok.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Vk=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return Lk(this,e,t,n,r)}},Hk=class extends Vk{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){G.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;X(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){G.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return G.useDebugValue(e),Lk(this,this.selectors[e],t,n,r)}useContextCallback(e,t){G.useDebugValue(e);let n=Y(t??wC);this.context[e]=n}useStateSetter(e){let t=G.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},Uk={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},Wk=class extends Hk{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:jO(),nested:n,triggerElements:i},Uk),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&bE(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Gk(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new Wk({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:EC,inactiveTriggerProps:EC,popupProps:EC}}var Kk=e=>e.triggerIdProp??e.activeTriggerId,qk=e=>e.openProp??e.open,Jk=e=>(e.popupElement?.id??e.floatingId)||void 0;function Yk(e,t){return t!==void 0&&qk(e)&&Kk(e)===t}function Xk(e,t){return Yk(e,t)?!0:t!==void 0&&qk(e)&&Kk(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var Zk={open:qk,mounted:e=>e.mounted,transitionStatus:e=>qk(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Kk,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Jk,isTriggerActive:(e,t)=>t!==void 0&&Kk(e)===t,isOpenedByTrigger:(e,t)=>Yk(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Kk(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Xk(e,t)?Jk(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Qk(e){let t=G.useCallback(t=>e===void 0?wC:e.subscribeStore(t),[e]),n=G.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,sC.useSyncExternalStore)(t,n,()=>e?.serverStore)}var $k=jT&&NT;function eA(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=G.useRef(!1),s=G.useRef(null),c=G.useRef(!0),l=mE();G.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=Vw(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Gw(t)&&t===xE(_T(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return XE(YE(r,`blur`,i),$k&&YE(r,`keydown`,a,!0),$k&&YE(r,`pointerdown`,l,!0))},[e,n]),G.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);Ww(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=G.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=wE(n.nativeEvent);if(Ww(a)){if($k&&!n.relatedTarget){if(!c.current&&!FE(a))return}else if(!RE(a))return}let u=ME(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,qT(yw,d,f));return}l.start(r,()=>{o.current||e.setOpen(!0,qT(yw,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Ww(r)&&r.hasAttribute(cO(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=xE(_T(t));(r||n!==t)&&(SE(a.current.floatingContext?.refs.floating.current,n)||SE(t,n)||o||ME(r??n,e.context.triggerElements)||e.setOpen(!1,qT(yw,i)))})}}},[a,r,e,l]);return G.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var tA=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new pE;restTimeout=new pE;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},nA=new WeakMap;function rA(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&nA.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),nA.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function iA(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=nA.get(n);a&&a!==e&&rA(a),rA(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,nA.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function aA(e){let t=e.context.dataRef.current,n=pC(()=>t.hoverInteractionState??tA.create()).current;return t.hoverInteractionState||=n,ZT(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function oA(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=IO(),u=FO(),d=aA(e),f=mE(),p=Y(()=>UE(c.current.openEvent?.type,d.interactedInside)),m=Y(()=>WE(c.current.openEvent?.type)),h=Y(()=>{rA(d)});X(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),G.useEffect(()=>h,[h]),X(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&Ww(s)&&o){let e=s,t=o,n=_T(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??CE(e,`[data-rootownerid]`)??n.body;return iA(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),G.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&oO(l.nodesRef.current,u).length>0)}function a(t){let n=VE(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,qT(vw,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=wE(e);if(!IE(t)){d.interactedInside=!1;return}d.interactedInside=CE(t,`[aria-haspopup]`)!=null}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(ME(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(l&&r&&Ww(o)&&oO(l.nodesRef.current,r,!1).some(e=>SE(e.context?.elements.floating,o)))){if(d.handler){d.handler(n);return}h(),m()&&!p()&&a(n)}}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,qT(vw,n)),l.events.emit(`floating.closed`,n)})}let y=o;return XE(y&&YE(y,`mouseenter`,g),y&&YE(y,`mouseleave`,_),y&&YE(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var sA={current:null};function cA(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=sA,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=IO(l),v=aA(e),y=G.useRef(!1),b=ZE(i),x=ZE(r),S=ZE(o),C=ZE(n),w=ZE(p),T=ZE(f),E=Y(()=>UE(h.current.openEvent?.type,v.interactedInside)),D=Y(()=>w.current?.()!==!1),O=Y((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!SE(t,n);if(!Ww(r))return!1;let a=r;return i.hasMatchingElement(e=>SE(e,a))&&(!t||!SE(t,a))}),k=Y(()=>{v.handler&&=(_T(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=Y(()=>{rA(v)});return u&&(v.handleCloseOptions=i?.__options),G.useEffect(()=>k,[k]),G.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===vw,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),G.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=VE(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,qT(vw,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,qT(vw,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Ww(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!yE(v.pointerType))return;let n=HE(S.current),r=VE(x.current,`open`,v.pointerType),i=wE(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Ww(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(SE(t,i)){c=t;break}}Ww(o)&&Ww(s)&&!e.context.triggerElements.hasElement(o)&&SE(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&Ww(c)&&Ww(s)&&SE(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;if(h){D()&&e.setOpen(!0,qT(vw,t,c));return}m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,qT(vw,t,c))}):g&&D()&&e.setOpen(!0,qT(vw,t,c)))}function o(n){if(E()){A();return}k();let r=_T(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!ME(n.relatedTarget,e.context.triggerElements)){if(b.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=b.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n);return}(v.pointerType!==`touch`||!SE(e.select(`floatingElement`),n.relatedTarget))&&t(n)}}function l(e){SE(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?YE(r,`mouseout`,l):void 0;return s?XE(YE(r,`mousemove`,i,{once:!0}),YE(r,`mouseenter`,i),YE(r,`mouseleave`,o),f):XE(YE(r,`mouseenter`,i),YE(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),G.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!yE(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;iA(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=HE(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,qT(vw,n,r))}v.pointerType===`touch`?_c.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function lA(e){return NT&&e.movementX===0&&e.movementY===0}function uA(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function dA(e,t){return uA(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function fA(e,t,n){return uA(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function pA(e,t,n){return uA(t,n?e===DE:e===OE,e===AE)}function mA(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:uA(t,n?e===OE:e===DE,e===kE)}function hA(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=zE(E),A=LE(D),j=ZE(k),M=FO(),N=IO(x),P=G.useRef(f),F=G.useRef(o??-1),I=G.useRef(null),L=G.useRef(!0),R=Y(e=>{i(F.current===-1?null:F.current,e)}),ee=G.useRef(!!E),te=G.useRef(T),ne=G.useRef(!1),z=G.useRef(!1),re=G.useRef(null),ie=ZE(h),B=ZE(T),ae=ZE(o),oe=ZE(b),se=tE(),ce=tE(),le=Y(()=>{se.cancel();function e(e){d||(re.current=uO(e,{sync:ne.current,preventScroll:!0}))}let t=n.current[F.current],r=z.current;t&&e(t),(ne.current?e=>e():e=>se.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),me&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{O.current.orientation=g},[O,g]),X(()=>{T||(I.current=null),(!T||f!==`auto`)&&(P.current=f)},[T,f]),X(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(z.current=!0,R())):ee.current&&(F.current=-1,R()))},[a,T,E,o,R]),X(()=>{if(a){if(!T){ne.current=!1;return}if(E){if(r==null){if(ne.current=!1,ae.current!=null)return;if(ee.current&&(F.current=-1,le()),(!te.current||!ee.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ce.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||fA(I.current,_,u)||l?AD(n):jD(n),I.current=null,R())};t()}}else kD(n.current,r)||(F.current=r,le(),z.current=!1)}}},[a,T,E,r,ae,l,n,_,u,R,le,ce]),X(()=>{if(!a||E||!N||d||!ee.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=xE(_T(D??t??null)),r=e.some(e=>e.context&&SE(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),X(()=>{te.current=T,ee.current=!!E});let ue=r!=null,de=Y(e=>{if(!B.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),V=Y(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),fe=Y(()=>AD(n,ie.current)),pe=Y(t=>{if(L.current=!1,ne.current=!0,t.which===229||!B.current&&t.currentTarget===j.current)return;if(l&&mA(t.key,g,u,w)){dA(t.key,V())||hE(t),e.setOpen(!1,qT(ww,t.nativeEvent));let n=S?.current??D;Gw(n)&&n.focus();return}r!=null&&r!==F.current&&!kD(n.current,r)&&(F.current=r);let i=F.current,a=AD(n,h),o=jD(n,h);if(A||(t.key===`Home`&&(hE(t),F.current=a,R(t)),t.key===`End`&&(hE(t),F.current=o,R(t))),C!=null){let e=C(t,F.current,n,g,c,u,h,a,o);if(e!=null&&e!==F.current&&(F.current=e,R(t)),g===`both`)return}if(dA(t.key,g)){hE(t);let e=xE(t.currentTarget.ownerDocument);if(T&&!d&&SE(t.currentTarget,e)&&!n.current.some(t=>t!=null&&SE(t,e))){F.current=fA(t.key,g,u)?a:o,R(t),r===F.current&&le();return}let{index:l,wrapped:f}=MD(n.current,i,{decrement:!fA(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(ne.current=!1),F.current=l,R(t)}}),me=G.useMemo(()=>({onFocus(e){ne.current=!0,de(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){lA(e)||(ne.current=!0,z.current=!1,p&&de(e))},onPointerLeave(e){if(!B.current||!L.current||e.pointerType===`touch`)return;ne.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&oe.current&&(re.current?.(),re.current=null,F.current=-1,R(e),!d)){let e=j.current,t=xE(_T(e));e&&SE(e,t)&&e.focus({preventScroll:!0})}}}),[de,B,j,p,n,R,oe,d]),he=G.useMemo(()=>d&&T&&ue&&{"aria-activedescendant":`${y}-${r}`},[d,T,ue,y,r]),ge=G.useMemo(()=>({...A?{}:he,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=wE(t.nativeEvent);if(n&&!SE(j.current,n))return;hE(t);let r=qT(Sw,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&Gw(i)&&i.focus();return}pe(t)},onPointerMove(e){lA(e)||(L.current=!0)}}),[he,pe,j,A,e,T,d,D,S]),_e=G.useMemo(()=>{function t(t){e.setOpen(!0,qT(ww,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&_E(e.nativeEvent)&&(P.current=!d)}function r(e){P.current=f,f===`auto`&&vE(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(n){let r=e.select(`open`);L.current=!1;let i=n.key.startsWith(`Arrow`),a=pA(n.key,V(),u),o=dA(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||FE(n.currentTarget)))return pe(n);if(r||m||!i){if(s){let e=dA(n.key,V());I.current=l&&e?null:n.key}if(l){a&&(hE(n),r?(F.current=fe(),R(n),d&&j.current?.focus()):t(n));return}o&&(ae.current!=null&&(F.current=ae.current),hE(n),!r&&m?t(n):pe(n),r&&R(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(F.current=-1,R(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[pe,f,fe,l,R,e,m,g,_,V,u,ae,d,j]),ve=G.useMemo(()=>({...he,..._e}),[he,_e]);return G.useMemo(()=>a?{reference:ve,floating:ge,item:me,trigger:_e}:{},[a,ve,ge,_e,me])}function gA(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=Y(s),f=e.useState(`open`),p=mE(),m=G.useRef(``),h=G.useRef(u??i??-1),g=G.useRef(null),_=Y(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!ID(n)||n?.matches(`:disabled`)?!1:o==null||!PD(TC,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(hE(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(hE(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=Y(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);SE(r,n)||SE(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=G.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return G.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var _A=.1,vA=_A*_A,yA=.5;function bA(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function xA(e,t,n,r,i,a,o,s,c,l){let u=!1;return bA(e,t,n,r,i,a)&&(u=!u),bA(e,t,i,a,o,s)&&(u=!u),bA(e,t,o,s,c,l)&&(u=!u),bA(e,t,c,l,n,r)&&(u=!u),u}function SA(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function CA(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function wA(e={}){let{blockPointerEvents:t=!1}=e,n=new pE,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*vA;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=wE(r),g=r.type===`mouseleave`,_=SE(u,h),v=SE(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Ww(r.relatedTarget)&&SE(u,r.relatedTarget))return;function y(){return!!(s&&oO(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=CA(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=CA(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=CA(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=CA(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!SA(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?yA/2:yA*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+yA+1,o=C||T?S.bottom-yA:S.top,s=C?T?S.bottom-yA:S.top:S.bottom-yA;M=xA(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?yA/2:yA*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-yA,o=C||T?S.top+yA:S.bottom,s=C?T?S.top+yA:S.bottom:S.top+yA;M=xA(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?yA/2:yA*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+yA+1,o=w||E?S.right-yA:S.left,s=w?E?S.right-yA:S.left:S.right-yA;M=xA(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?yA/2:yA*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-yA,o=w||E?S.left+yA:S.right,s=w?E?S.left+yA:S.right:S.left+yA;M=xA(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function TA(e,t,n){let{reference:r,floating:i}=e,a=mD(t),o=hD(t),s=pD(o),c=uD(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=dD(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function EA(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=lD(t,e),p=DD(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=OD(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=OD(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var DA=50,OA=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:EA},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=TA(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<DA&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=TA(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},kA=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=lD(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=uD(r),_=mD(o),v=uD(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[TD(o)]:_D(o)),x=p!==`none`;!d&&x&&b.push(...wD(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=gD(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===mD(t)||T.every(e=>mD(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=mD(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},AA=new Set([`left`,`top`]);async function jA(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=uD(n),s=dD(n),c=mD(n)===`y`,l=AA.has(o)?-1:1,u=a&&c?-1:1,d=lD(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var MA=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await jA(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},NA=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=lD(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=mD(i),p=fD(f),m=u[p],h=u[f],g=(e,t)=>cD(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},PA=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=lD(e,t),u={x:n,y:r},d=mD(i),f=fD(d),p=u[f],m=u[d],h=lD(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=AA.has(uD(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},FA=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=lD(e,t),c=await i.detectOverflow(t,s),l=uD(n),u=dD(n),d=mD(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=nD(p-c[m],g),y=nD(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*rD(c.left,c.right):S=p-2*rD(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function IA(e){let t=iT(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Gw(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=iD(n)!==a||iD(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function LA(e){return Ww(e)?e:e.contextElement}function RA(e){let t=LA(e);if(!Gw(t))return oD(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=IA(t),o=(a?iD(n.width):n.width)/r,s=(a?iD(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var zA=oD(0);function BA(e){let t=Vw(e);return!nT()||!t.visualViewport?zA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function VA(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Vw(e)}function HA(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=LA(e),o=oD(1);t&&(r?Ww(r)&&(o=RA(r)):o=RA(e));let s=VA(a,n,r)?BA(a):oD(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Vw(a),t=Ww(r)?Vw(r):r,n=e,i=lT(n);for(;i&&t!==n;){let e=RA(i),t=i.getBoundingClientRect(),r=iT(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Vw(i),i=lT(n)}}return OD({width:u,height:d,x:c,y:l})}function UA(e,t){let n=aT(e).scrollLeft;return t?t.left+n:HA(Hw(e)).left+n}function WA(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-UA(e,n),y:n.top+t.scrollTop}}function GA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Hw(r),s=t?Yw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=oD(1),u=oD(0),d=Gw(r);if((d||!a)&&((Bw(r)!==`body`||qw(o))&&(c=aT(r)),d)){let e=HA(r);l=RA(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?WA(o,c):oD(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function KA(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function qA(e){let t=aT(e),n=e.ownerDocument.body,r=rD(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=rD(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+UA(e),o=-t.scrollTop;return iT(n).direction===`rtl`&&(a+=rD(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var JA=25;function YA(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Vw(e),a=Hw(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!nT()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(UA(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=JA&&(s-=o)}return{width:s,height:c,x:l,y:u}}function XA(e,t){let n=HA(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=RA(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ZA(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=YA(e,n,t);else if(t===`document`)r=qA(Hw(e));else if(Ww(t))r=XA(t,n);else{let n=BA(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return OD(r)}function QA(e,t){let n=t.get(e);if(n)return n;let r=cT(e,[],!1).filter(e=>Ww(e)&&Bw(e)!==`body`),i=null,a=iT(e).position===`fixed`,o=a?oT(e):e;for(;Ww(o)&&!rT(o);){let e=iT(o),t=eT(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=oT(o)}return t.set(e,r),r}function $A(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Yw(t)?[]:QA(t,this._c):[].concat(n),r],o=ZA(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=ZA(t,a[e],i);s=rD(n.top,s),c=nD(n.right,c),l=nD(n.bottom,l),u=rD(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function ej(e){let{width:t,height:n}=IA(e);return{width:t,height:n}}function tj(e,t,n){let r=Gw(t),i=Hw(t),a=n===`fixed`,o=HA(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=oD(0);if((r||!a)&&((Bw(t)!==`body`||qw(i))&&(s=aT(t)),r)){let e=HA(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=UA(i));let l=i&&!r&&!a?WA(i,s):oD(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function nj(e){return iT(e).position===`static`}function rj(e,t){if(!Gw(e)||iT(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Hw(e)===n&&(n=n.ownerDocument.body),n}function ij(e,t){let n=Vw(e);if(Yw(e))return n;if(!Gw(e)){let t=oT(e);for(;t&&!rT(t);){if(Ww(t)&&!nj(t))return t;t=oT(t)}return n}let r=rj(e,t);for(;r&&Jw(r)&&nj(r);)r=rj(r,t);return r&&rT(r)&&nj(r)&&!eT(r)?n:r||tT(e)||n}var aj=async function(e){let t=this.getOffsetParent||ij,n=this.getDimensions,r=await n(e.floating);return{reference:tj(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function oj(e){return iT(e).direction===`rtl`}var sj={convertOffsetParentRelativeRectToViewportRelativeRect:GA,getDocumentElement:Hw,getClippingRect:$A,getOffsetParent:ij,getElementRects:aj,getClientRects:KA,getDimensions:ej,getScale:RA,isElement:Ww,isRTL:oj};function cj(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lj(e,t,n){let r=null,i,a=Hw(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=aD(d),h=aD(a.clientWidth-(u+f)),g=aD(a.clientHeight-(d+p)),_=aD(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:rD(0,nD(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!cj(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Vw(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function uj(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=LA(e),u=i||a?[...l?cT(l):[],...t?cT(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?lj(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?HA(e):null;c&&g();function g(){let t=HA(e);h&&!cj(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var dj=MA,fj=NA,pj=kA,mj=FA,hj=PA,gj=(e,t,n)=>{let r=new Map,i=n??{},a={...sj,...i.platform,_c:r};return OA(e,t,{...i,platform:a})},_j=typeof document<`u`?G.useLayoutEffect:function(){};function vj(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!vj(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!vj(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function yj(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bj(e,t){let n=yj(e);return Math.round(t*n)/n}function xj(e){let t=G.useRef(e);return _j(()=>{t.current=e}),t}function Sj(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=G.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=G.useState(r);vj(f,r)||p(r);let[m,h]=G.useState(null),[g,_]=G.useState(null),v=G.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=G.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=G.useRef(null),C=G.useRef(null),w=G.useRef(u),T=c!=null,E=xj(c),D=xj(i),O=xj(l),k=G.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),gj(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!vj(w.current,t)&&(w.current=t,_c.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);_j(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=G.useRef(!1);_j(()=>(A.current=!0,()=>{A.current=!1}),[]),_j(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=G.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=G.useMemo(()=>({reference:b,floating:x}),[b,x]),N=G.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=bj(M.floating,u.x),r=bj(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...yj(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return G.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Cj=(e,t)=>{let n=dj(e);return{name:n.name,fn:n.fn,options:[e,t]}},wj=(e,t)=>{let n=fj(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tj=(e,t)=>({fn:hj(e).fn,options:[e,t]}),Ej=(e,t)=>{let n=pj(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dj=(e,t)=>{let n=mj(e);return{name:n.name,fn:n.fn,options:[e,t]}},Oj=G.createContext(void 0);function kj(e){let t=G.useContext(Oj);if(t===void 0&&!e)throw Error(iC(69));return t}var Aj=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]);function jj(e){return e===`starting`?SO:EC}var Mj=G.createContext(void 0);function Nj(){return G.useContext(Mj)}function Pj(e,t){let n=JC(e.render);if(G.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function Fj(e,t,n){let r=Pj(e,t),i=r===t?void 0:r;return[r,G.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Ij(e,t,n){let r=JC(e.render),i=G.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var Lj=G.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=dC(),m=Nj(),{side:h,align:g}=lC(),_=kj(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=Fj(e,u,d),L=Ij(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,te=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(te=()=>l.state.activeIndex===null&&P),cE({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),G.useEffect(()=>{function e(e){l.setOpen(!1,qT(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),oA(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let ne=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:z,handleFocus:re}=(G.useContext(Mw)?.useParentHandoff??zj)(l,w,v,f),ie=WC(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,ne,I],stateAttributesMapping:hw,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&Aj.has(e.key)&&e.stopPropagation()},onFocus:re},jj(y),c,{"data-rootownerid":E}]}),B=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(B=!0);let ae=R?.getReturnElement??z;return(0,K.jsx)(JO,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??ae??B,explicitReturnFocus:a===void 0&&ae?!1:void 0,initialFocus:te,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ie})}),Rj={parentVirtualFocusRef:void 0,handleFocus:void 0};function zj(){return Rj}var Bj=G.forwardRef(function(e,t){let n=Nw()?.Popup??Lj;return(0,K.jsx)(n,{...e,ref:t})}),Vj=G.createContext(void 0);function Hj(){let e=G.useContext(Vj);if(e===void 0)throw Error(iC(32));return e}var Uj=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=dC();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,K.jsx)(Vj.Provider,{value:n,children:(0,K.jsx)(AO,{ref:t,...r,portalOwnerRole:o})})});function Wj(e){return xC(19)?e:e?`true`:void 0}function Gj(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=G.useState(null),d=G.useRef(null),f=IO(n),p=G.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Sj({...e,elements:{...p,...l&&{reference:l}}}),h=G.useCallback(e=>{let t=Ww(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=G.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=G.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=G.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return X(()=>{o&&(d.current=o)},[o]),X(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),G.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var Kj=G.createContext(void 0);function qj(){return G.useContext(Kj)?.direction??`ltr`}var Jj=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=lD(e,t)||{};if(l==null)return{};let d=DD(u),f={x:n,y:r},p=hD(i),m=pD(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=cD(D,k,O),j=!c.arrow&&dD(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Yj=(e,t)=>{let{name:n,fn:r}=Jj(e);return{name:n,fn:r,options:[e,t]}},Xj={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Zj={sideX:`left`,sideY:`top`},Qj=`--available-width`,$j=`--available-height`,eM=`--anchor-width`,tM=`--anchor-height`,nM=`--transform-origin`,rM=Qj,iM=$j;function aM(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function oM(e,t,n){let{rects:r,placement:i}=e;return{side:aM(t,uD(i),n),align:dD(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sM(e){return cM(e,Gj)}function cM(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=Y(O),A=O?k:n,j=ZE(n),M=ZE(g),N=qj()===`rtl`,[P,F]=G.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?uD(P):null,R=P&&I?dD(P)||`center`:null,ee=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],te=R||o,ne=te===`center`?ee:`${ee}-${te}`,z=l;typeof z==`number`?z={top:z,right:z,bottom:z,left:z}:z&&={top:z.top||0,right:z.right||0,bottom:z.bottom||0,left:z.left||0};let re=+(i===`bottom`),ie=+(i===`top`),B=+(i===`right`),ae=+(i===`left`),oe={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:z},se=G.useRef(null),ce=ZE(a),le=ZE(s),ue=typeof a==`function`?0:a,de=typeof s==`function`?0:s,V=[];p&&V.push(p),V.push(Cj(e=>{let t=oM(e,i,N),n=typeof ce.current==`function`?ce.current(t):ce.current,r=typeof le.current==`function`?le.current(t):le.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ue,de,N,i]));let fe=w===`none`&&C!==`shift`,pe=!fe&&(u||E||C===`shift`),me=C===`none`?null:Ej({...oe,padding:{top:z.top+1+re,right:z.right+1+ae,bottom:z.bottom+1+ie,left:z.left+1+B},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),he=fe?null:wj({...oe,rootBoundary:D,mainAxis:w!==`none`,crossAxis:pe,limiter:u||E?void 0:Tj(e=>{if(!se.current)return{};let{width:t,height:n}=se.current.getBoundingClientRect(),r=mD(uD(e.placement)),i=r===`y`?t:n,a=r===`y`?z.left+z.right:z.top+z.bottom;return{offset:i/2+a/2}})},[oe,u,E,D,z,w]);C===`shift`||w===`shift`||te===`center`?V.push(he,me):V.push(me,he),V.push(Dj({...oe,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(rM,`${t}px`),i.setProperty(iM,`${n}px`);let a=Vw(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(eM,`${u}px`),i.setProperty(tM,`${d}px`)}}),Yj(e=>({element:se.current||_T(e.elements.floating).createElement(`div`),padding:se.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=uD(r),u=dD(r),d=mD(l)===`y`,f=se.current,p=typeof a==`function`?a(oM(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return pe&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(nM,d?`${m} ${h}`:`${h} ${m}`),{}}},Xj,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ge=G.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:_e,elements:ve,x:ye,y:be,middlewareData:xe,update:Se,placement:Ce,context:we,isPositioned:Te,floatingStyles:Ee}=t({rootContext:h,open:m?g:void 0,placement:ne,middleware:V,strategy:r,whileElementsMounted:m?void 0:(...e)=>uj(...e,ge),nodeId:y,externalTree:S}),{sideX:De,sideY:Oe}=xe.adaptiveOrigin||Zj,ke=Te?r:`fixed`,Ae=G.useMemo(()=>{let e;return e=Te?b?{position:ke,[De]:ye,[Oe]:be}:{...Ee,position:ke}:{position:ke,top:0,left:0},e[rM]=`100vw`,e[iM]=`100vh`,Te||(e.opacity=0),e},[b,ke,De,ye,Oe,be,Ee,Te]),je=G.useRef(null);X(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(lM(t)?t.current:t)||null;n!==je.current&&(_e.setPositionReference(n),je.current=n)},[g,_e,A,j]),G.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&lM(e)&&e.current!==je.current&&(_e.setPositionReference(e.current),je.current=e.current)},[g,_e,A,j]),G.useEffect(()=>{if(m&&g&&ve.reference&&ve.floating)return uj(ve.reference,ve.floating,Se,ge)},[m,g,ve,Se,ge]);let H=uD(Ce),Me=aM(i,H,N),Ne=dD(Ce)||`center`,Pe=!!xe.hide?.referenceHidden;X(()=>{x&&g&&Te&&(H!==ee||I&&Ne!==te)&&F(Ce)},[x,I,g,Te,Ce,H,Ne,ee,te]);let Fe=G.useMemo(()=>({position:`absolute`,top:xe.arrow?.y,left:xe.arrow?.x}),[xe.arrow]),Ie=xe.arrow?.centerOffset!==0;return G.useMemo(()=>({positionerStyles:Ae,arrowStyles:Fe,arrowRef:se,arrowUncentered:Ie,side:Me,align:Ne,physicalSide:H,anchorHidden:Pe,refs:_e,context:we,isPositioned:Te,update:Se}),[Ae,Fe,se,Ie,Me,Ne,H,Pe,_e,we,Te,Se])}function lM(e){return e!=null&&`current`in e}function uM(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Y(i),[,o]=G.useState(0),s=pC(fM).current,c=pC(dM).current,l=G.useRef(0),u=G.useRef(!0),d=G.useRef(null),f=G.useRef(null),p=Y(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Y((e,t)=>{c.set(e,t),p()}),h=Y(e=>{c.delete(e),p()}),g=Y(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!hM(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&gM(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=mM(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Y(()=>{let[e,t]=pM(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Y(e=>(s.add(e),()=>{s.delete(e)})),b=G.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,K.jsx)(BT.Provider,{value:b,children:t})}function dM(){return new Map}function fM(){return new Set}function pM(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>gM(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function mM(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function hM(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function gM(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var _M=G.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,K.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function vM(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=G.useRef(null),o=G.useRef(null),s=sE(r);X(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),X(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function yM(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),WC(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},jj(r),i],stateAttributesMapping:mw})}var bM={},xM={},SM=``;function CM(e,t){return qw(e)?e:t}function wM(e,t,n){return/hidden|clip/.test(e.getComputedStyle(CM(t,n)).overflowY)}function TM(e){if(typeof document>`u`)return!1;let t=_T(e);return Vw(t).innerWidth-t.documentElement.clientWidth>0}function EM(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=_T(e),n=t.documentElement,r=t.body,i=CM(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function DM(e){let t=_T(e),n=t.documentElement,r=t.body,i=CM(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function OM(e){let t=_T(e),n=t.documentElement,r=t.body,i=Vw(n),a=0,o=0,s=!1,c=eE.create();if(NT&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,bM={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},SM=n.style.scrollBehavior,xM={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=CM(n,r);if(s=EM(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,bM),Object.assign(r.style,xM),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=SM)}function d(){u(),c.request(l)}l();let f=YE(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var kM=new class{lockCount=0;restore=null;timeoutLock=pE.create();timeoutUnlock=pE.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=_T(e),n=t.documentElement,r=t.body,i=Vw(n);if(wM(i,n,r)){let t=new i.MutationObserver(()=>{wM(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=OT||!TM(e);this.restore=a?DM(e):OM(e)}};function AM(e=!0,t=null){X(()=>{if(e)return kM.acquire(t)},[e,t])}var jM=20;function MM(e,t,n,r){let[i,a]=G.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=_T(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-jM)},[e,t,n]),AM(e&&(!t||i),r)}var NM=G.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=CO,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=dC(),x=Hj(),S=oC(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=n,te=c,ne=l,z=s,re=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,z??=`start`,!o&&z!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ie=o,B=z;C.type===`menu`?(ie??=`inline-end`,B??=`start`,re=e.collisionAvoidance??wO):C.type===`menubar`&&(ie??=C.context.orientation===`vertical`?`inline-end`:`bottom`,B??=`start`);let ae=C.type===`context-menu`,oe=sM({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ie,sideOffset:te,align:B,alignOffset:ne,arrowPadding:ae?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:re,shift:ae?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});G.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,qT(Ow)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),G.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,qT(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let se=mE();G.useEffect(()=>{D||se.clear()},[D,se]),G.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?se.isStarted()||se.start(e,()=>{v.setOpen(!1,qT(Ow))}):v.setOpen(!1,qT(Ow))}else se.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,se]),G.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),vM({store:v,domReference:R,positionerElement:M,open:D});let ce={open:D,side:oe.side,align:oe.align,anchorHidden:oe.anchorHidden,nested:C.type===`menu`,instant:N},le=C.type===`menubar`&&C.context.modal;MM(D&&(le||O&&F!==`trigger-hover`),k===`touch`,M,A);let ue=yM(e,ce,{styles:oe.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),de=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),V=null;return C.type===`menubar`?V=C.context.contentElement:C.type===void 0&&(V=A),(0,K.jsxs)(cC.Provider,{value:oe,children:[de&&(0,K.jsx)(_M,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Wj(!D),cutout:V}),(0,K.jsx)(RO,{id:I,children:(0,K.jsx)(uM,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:ue})})]})}),PM=G.createContext(null);function FM(e){let t=G.useContext(PM);if(t===null&&!e)throw Error(iC(5));return t}function IM(e){let t=G.useRef(``),n=G.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:G.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function LM(e,t){let n=G.useRef(e),r=Y(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function RM(e,t){let{onClick:n,onPointerDown:r}=IM(Y((n,r)=>{(typeof e==`function`?e():e)||t(r||(OT?`touch`:``))}));return G.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function zM(e){let[t,n]=G.useState(null),r=RM(e,n);return LM(e,t=>{t&&!e&&n(null)}),G.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function BM(e){return e==null?gw:e.type.startsWith(`key`)?Tw:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Ew:gw}var VM={...Zk,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Zk.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>NT&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Zk.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},HM=class extends Hk{constructor(e,t,n=!1){let r=new Dk,i=WM(r,t,n,e);super(i,UM(r),VM),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function UM(e){return{positionerRef:G.createRef(),popupRef:G.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:G.createRef(),beforeTriggerFocusGuardRef:G.createRef(),beforeContentFocusGuardRef:G.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function WM(e,t,n=!1,r){return{...Gk(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:EC,inputProps:EC,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new MO,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:EC,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var GM=G.createContext(null);function KM(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function qM(e,t){return e===`list-navigation`||KM(e,t)}var JM=Nk(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=oC(!0),C=dC(!0),w=FM(!0),T=C?.store,E=C?.virtualFocus??!1,D=G.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=UT(),k=UT(),[A,j]=G.useState(void 0),M=(A??k)||void 0,N=FO(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=pC(()=>F?P?.state.instantType:void 0).current,L=pC(()=>{let e=new HM({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),ee=LO(R),te=L.useState(`open`),ne=L.useState(`activeTriggerElement`),z=L.useState(`positionerElement`),re=L.useState(`hoverEnabled`),ie=L.useState(`disabled`),B=L.useState(`lastOpenChangeReason`),ae=L.useState(`parent`),oe=L.useState(`activeIndex`),se=L.useState(`keyboardOpen`),ce=L.useState(`payload`),le=L.useState(`floatingParentNodeId`),ue=G.useRef(null),de=G.useRef(ae.type!==`context-menu`),V=mE(),fe=G.useRef(!0),pe=mE(),me=le!=null,{openMethod:he,triggerProps:ge}=zM(te);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:ae.type===void 0?c:void 0,openMethod:he,rootId:O}),wk(L);let{forceUnmount:_e,transitionStatus:ve}=Tk(te,L,()=>{L.set(`allowMouseEnter`,!1)},F),ye=sE(L.context.popupRef);G.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!te){e();return}if(ve!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return ye(e,t.signal),()=>{t.abort()}},[I,te,ve,ye,L]),X(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ee,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ee,floatingParentNodeId:N})},[S,C,ee,N,ne,L]),G.useEffect(()=>{if(te||(ue.current=null),ae.type===`context-menu`){if(!te){V.clear(),de.current=!1;return}V.start(500,()=>{de.current=!0})}},[V,te,ae.type]),X(()=>{!te&&!re&&L.set(`hoverEnabled`,!0)},[te,re,L]);let be=Y((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||te===e&&t.trigger===ne&&B===n)return;let i=xk(t);if(!e&&t.trigger==null&&(t.trigger=ne??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!fe.current)return;e&&n===`trigger-focus`?(fe.current=!1,pe.start(300,()=>{fe.current=!0})):(fe.current=!0,pe.clear());let o=!e&&(n===`escape-key`||n==null);ue.current=t.event;let s=bk(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&qM(n,a),s.instantType=ae.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:KM(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),xe=pk({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:be}),Se=xe.context.events;X(()=>{let e=({open:e,eventDetails:t})=>be(e,t);return Se.on(`setOpen`,e),()=>{Se?.off(`setOpen`,e)}},[Se,be]),X(()=>L.subscribeToParentMenu(),[L]);let Ce=G.useCallback(()=>{L.setOpen(!1,qT(Aw))},[L]);G.useImperativeHandle(d,()=>({unmount:_e,close:Ce}),[_e,Ce]);let we;ae.type===`context-menu`&&(we=ae.context),G.useImperativeHandle(we?.positionerRef,()=>z,[z]),G.useImperativeHandle(we?.actionsRef,()=>({setOpen:be}),[be]);let Te=tk(xe,{enabled:!ie,bubbles:{escapeKey:f&&ae.type===`menu`},outsidePress(){return ae.type!==`context-menu`||ue.current?.type===`contextmenu`||de.current},externalTree:me?R:void 0}),Ee=qj(),De=hA(xe,{enabled:!ie,listRef:L.context.itemDomElements,activeIndex:oe,virtual:v,nested:ae.type===`menubar`||!v&&ae.type!==void 0,parentOrientation:ae.type===`menubar`?ae.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?se:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Ee===`rtl`,disabledIndices:TC,onNavigate(e,t){L.setActiveIndex(e,BM(t),t?.nativeEvent)},openOnArrowKeyDown:ae.type!==`context-menu`&&!(v&&_),externalTree:!v&&me?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Oe=G.useCallback(e=>{L.context.typingRef.current=e},[L]),ke=gA(xe,{enabled:!ie&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:oe,resetMs:500,onMatch:(e,t)=>{te&&e!==oe&&L.setActiveIndex(e,Tw,t.nativeEvent)},onTyping:Oe}),Ae=Y(a),je=G.useRef(-1),H=Y(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(je.current===n&&L.context.reportedItem===t)return;je.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=gw,L.context.highlightEvent=void 0,a&&Ae(t,JT(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});X(()=>{H()},[oe,H]);let Me=G.useMemo(()=>{if(!v)return De.reference;if(!De.trigger)return EC;let{onFocus:e,...t}=De.trigger;return t},[v,De.reference,De.trigger]);L.useSyncedValue(`inputProps`,v?De.reference??EC:EC);let Ne=G.useMemo(()=>{let e=jC(ke.reference,Me,Te.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=te,e},[L,ke.reference,Me,Te.reference,ge,te]),Pe=G.useMemo(()=>{let e=jC(De.trigger,Te.trigger,ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[De.trigger,Te.trigger,ge]);pC(()=>(L.update({inactiveTriggerProps:Pe}),null)),Ek(L,{floatingRootContext:xe,activeTriggerProps:Ne,inactiveTriggerProps:Pe,popupProps:G.useMemo(()=>jC(hk,{onMouseMove(){L.set(`allowMouseEnter`,!0),ae.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},ke.floating,De.floating,Te.floating),[ae.type,L,ke.floating,De.floating,Te.floating]),itemProps:De.item??EC});let Fe=G.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:H}),[L,D,u,l,b,k,v,E,H]),Ie=typeof t==`function`?t({payload:ce}):t,Le=(0,K.jsxs)(uC.Provider,{value:Fe,children:[p&&(0,K.jsx)(_k,{handle:p,store:L}),Ie]});return(ae.type===void 0||ae.type===`context-menu`)&&(Le=(0,K.jsx)(zO,{externalTree:R,children:Le})),Le});function YM(e){let t=G.useContext(GM);if(t===null)return(0,K.jsx)(JM,{...e});let n=t.Root;return(0,K.jsx)(GM.Provider,{value:null,children:(0,K.jsx)(n,{...t.options,...e})})}var XM={};function ZM(e){dC();let t=G.useContext(GM);if(t!==null){let n=t.SubmenuRoot;return(0,K.jsx)(GM.Provider,{value:null,children:(0,K.jsx)(n,{...t.options,...e})})}return(0,K.jsx)(Mj.Provider,{value:XM,children:(0,K.jsx)(JM,{...e,isSubmenu:!0})})}var QM=5;function $M(e,t){let n=eN(t);return e.clientX>=n.left-QM&&e.clientX<=n.right+QM&&e.clientY>=n.top-QM&&e.clientY<=n.bottom+QM}function eN(e){let t=e.getBoundingClientRect(),n=Vw(e);if(FT)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function tN(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=hT(),{ref:i,index:a}=HT(e),o=n===a,s=G.useRef(null),c=mC(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function nN(e){let{render:t,className:n,style:r,state:i=EC,props:a=TC,refs:o=TC,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=tN({metadata:s});return WC(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function rN(e){if(Gw(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!rT(e))return rN(oT(e))}function iN(e,t){function n(n,r,i){let a=n.currentTarget;_c.flushSync(()=>{e.setOpen(!1,qT(Sw,n.nativeEvent,a))}),nO(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&rO(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function aN(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=G.useRef(!1);return G.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,_T(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:EC,[t,n,r])}var oN=Pk(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=dC(!0),h=Qk(d)??m?.store;if(!h)throw Error(iC(85));let g=UT(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=G.useRef(null),S=cN(),C=hT(!0),w=IO(),T=G.useMemo(()=>w??new MO,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Ck(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:LO(T),floatingParentNodeId:FO(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=yT({disabled:A,native:o});G.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=G.useRef(null),P=mE(),F=Y(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;SE(N.current,t)||SE(h.select(`positionerElement`),t)||t===N.current||(t==null||rN(t)!==h.select(`rootId`))&&($M(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Dw}))});G.useEffect(()=>{let e=_T(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=cA(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:wA({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=sN(y,h.select(`lastOpenChangeReason`)),ee=YO(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),te=eA(v,{enabled:!A&&I}),ne=aN({open:y,enabled:O,mouseDownAction:`open`}),z=G.useMemo(()=>jC(te.reference,ee.reference),[te.reference,ee.reference]),re=h.useState(`triggerProps`,D),ie=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:B,handleFocusTargetFocus:ae}=iN(h,x),oe={disabled:A,open:y},se=[N,t,M,E,x],ce=[z,L??EC,re,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),_T(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ie,O?{role:`menuitem`}:{},ne,p,j],le=WC(`button`,e,{enabled:!O,stateAttributesMapping:pw,state:oe,ref:se,props:ce});return O?(0,K.jsx)(nN,{tag:`button`,render:n,className:r,style:i,state:oe,refs:se,props:ce,stateAttributesMapping:pw}):y?(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(tD,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:B},`${g}-pre-focus-guard`),(0,K.jsx)(G.Fragment,{children:le},g),(0,K.jsx)(tD,{ref:h.context.triggerFocusTargetRef,onFocus:ae},`${g}-post-focus-guard`)]}):(0,K.jsx)(G.Fragment,{children:le},g)});function sN(e,t){let n=mE(),[r,i]=G.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function cN(){let e=FM(!0);return G.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var lN=G.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return WC(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),uN={"aria-expanded":void 0},dN=G.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=dC(!0);if(p?.parent.type!==`menu`)throw Error(iC(37));let m=lC(),h=Nj(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,y=HT({guess:!0,label:a}),b=UT(o),x=g.useState(`open`),S=G.useRef(!1),C=g.useState(`positionerElement`),w=g.useState(`floatingRootContext`),T=g.useState(`floatingTreeRoot`),E=g.useState(`triggerPopupId`,b),D=yk(b,g),O=Y(e=>{D(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:b??null,activeTriggerElement:e,closeDelay:u})}),k=G.useRef(null),A=G.useCallback(e=>{k.current=e,g.set(`activeTriggerElement`,e)},[g]);X(()=>(O(k.current),()=>O(null)),[O,b,g]),X(()=>{if(!x||!C)return;function e(e){wE(e)===g.context.beforeContentFocusGuardRef.current&&(S.current=e.relatedTarget===k.current)}return C.addEventListener(`focusout`,e,!0),()=>{S.current=!1,C.removeEventListener(`focusout`,e,!0)}},[x,C,g]),g.useSyncedValue(`closeDelay`,u);let j=g.useState(`disabled`),M=v.useState(`disabled`),N=d||j||M,P=v.useState(`itemProps`),F=v.useState(`isActive`,y.index),I=G.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(y.index,Ew,e)}}),[v,y.index]),{getItemProps:L,itemRef:R}=zT({closeOnClick:!1,disabled:N,highlighted:F,id:b,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:I,nodeId:m?.context.nodeId}),ee=cA(w,{enabled:g.useState(`hoverEnabled`)&&c&&!N,handleClose:wA({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:k,externalTree:T,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),te=YO(w,{enabled:!N,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??EC,ne=g.useState(`triggerProps`,!0);delete ne.id;let z={disabled:N,highlighted:F,open:x},re=g.useState(`openMethod`),ie=g.useState(`lastOpenChangeReason`)===`list-navigation`||re===`keyboard`,B=x&&ie&&PT;return WC(`div`,e,{state:z,stateAttributesMapping:fw,props:[te,ee,ne,h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0,P,B?uN:void 0,{"aria-controls":E,tabIndex:_||!(x||F)?-1:0,onFocus(e){g.select(`open`)&&S.current&&(S.current=!1,g.setOpen(!1,qT(Sw,e.nativeEvent)))},onBlur(){F&&v.setActiveIndex(null,gw)}},f,L],ref:[t,y.ref,R,O,A]})}),fN=G.forwardRef(function(e,t){let n=Iw(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?jC(n.props,e):e;return(0,K.jsx)(dN,{...r,ref:n.ref})});function pN(e){let[t,n]=G.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=G.useRef(null),i=G.useRef(null),a=G.useRef(null),o=G.useRef(null),s=G.useRef(!0),c=G.useRef(null),l=nC(),u=G.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,K.jsx)(aC.Provider,{value:u,children:(0,K.jsx)(uC.Provider,{value:void 0,children:(0,K.jsx)(YM,{...e})})})}var mN=500,hN=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=oC(!1),{store:m}=dC(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=G.useRef(null),v=G.useRef(null),y=mE(),b=mE(),x=G.useRef(!1),S=G.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,qT(_w,n)),b.start(mN,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,hE(e),C(e.clientX,e.clientY,e.nativeEvent);let t=_T(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=wE(e);SE(u.current,t)||p&&t&&rN(t)===p||s.current?.setOpen(!1,qT(Dw,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(mN,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return G.useEffect(()=>()=>{S.current?.abort()},[]),G.useEffect(()=>{function e(e){if(g)return;let t=wE(e);(SE(_.current,t)||SE(c.current,t)||SE(l.current,t))&&e.preventDefault()}return YE(_T(_.current),`contextmenu`,e)},[l,g,c]),WC(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:pw})}),gN=NM,_N=48,vN=(e,t=0)=>{let n=new Int32Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r)-_N-t;return n},yN=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t},bN=e=>{let t=new Int32Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r)-_N;n+=i>>>1^-(i&1),t[r]=n}return t},xN=384,SN=[],CN=yN(vN(`E0500002005282000000002000150000020021820000011200000003022202000300004200120000200420001200021200301200010400162000010000220021010:2192001200220012000220012000200200200400010200040000000000400200108200110100000022010313000162002000020020012020080213000228200000000082000000000120002000120020020040101020300130001001010`)),wN=yN(vN(`:11111111211111119311546544411119731869:671397415686432441111111111161114151214313433415:78311132233313187211117221449443411141111151152226611131111112212518142224214215421421542142424242516171151615616347111111111197911327451111111111111111111113134714133513411111311111111111111111111112444411111342312715245411117:3`)),TN=`@containerabcdefghinlmoprstunderlineviawzccentlignnimatespectuto-colsrowsaglorightnessckdrop-sisbcontrastfiltergrayscalehue-rotateinvertopacityslurrightnessaturateepia-coniclinearpositionradialsizeockurrderttom-belrstxyespacing-xyaretoursorlnt-umnsendspantartainentrasteividerop-shadowurationcorationlay-xyasendillexontromlter-featuresstretchapr-xyayscaleidow-colsrowsue-rotatedentlinesetvert-beringsxyeshadoweiadingftnest-clamp-imageabein-lrstxyskx--b-coniclpositionrsizet-x-y-fromto-fromto-inearfromto-fromto-adialfromto-fromtofromtofromtofromtoblockhinlinew-screenesblockhinlinewbjectpacityrutlinederigin-offsetbelrstxyesrspective-originaceholderioghtng-offsettateundedw-xyz-belrstlreseslr-endspantartaturatecepiahizekewpace-taleroll-xyz-barmpbelrstxyesbelrstxyes-thumbrackadowrink-xyxyartrokeabextora-shadowpckingnsformitionlate-xyz-offsetill-changeoom`,EN=(()=>{let e=CN.length-1,t=new Int32Array(e);for(let n=e-1;n>=0;n--){let e=1,r=n+1;for(let i=CN[n];i<CN[n+1];i++)e+=t[r],r+=t[r];t[n]=e}let n=new Int32Array(CN[e]),r=0;for(let i=0;i<e;i++){let e=i+1;for(let a=CN[i];a<CN[i+1];a++)n[r++]=e,e+=t[e]}return n})(),DN=vN(`02000000000000900<=0?000B000F00F00ŏI0J0LNPRTVX0000]_a00000000000000000000000rst0000000zŏ00000000000…ŏ000ˆ0000ŏ0000000000—0000000000000000000000000000000000000000000000000000Ë000000000000000000000Þ000000000000000000ð0000000ø0ùúûüýþÿĀāĂ㥹Ć000000000000000000000000000000000000000000ħ0ĨĪ00000000000000000000ļĽ00000Ŭ000000`,1),ON=yN(vN(`123333359346463635126536711576`)),kN=vN(`93203242332583253248325D>E?F@03263243255B:032523853:0325B:8GA032542H<C=12727B:0328432553;D>E?3257D>032585:0325B:;0328B:032`),AN=vN(`012113445661666666789111:5;;;;;;;;444;;;:62999<1161=62>>?61:21@ABCD4446996:64E:::;:?::64:F114GHHIHHHHIHH1HH1HH1HHHHHH::EEJ4444::EE4444441691;644444114244444:;K6666555555555555555999666664444444444444444444444226?6:66644L9M?D:111::::6DE199`),jN=bN(`020200202020020020020020020020200200200200200200200002020202001003040106000200200200200200200200200200200200200200200200200200200200200200200200200200200200020020020020020020002020200202002002002002002002002002002020002002020020200220200200200200200200200200200200020020020000200020002000200200200020020020002000200200200020020202002020202000200200020022000200200020020002002000200220002002000200W0Z00020020002002020002002000200g0j0002002000200200020020002002000200200020020002000200002000002002002002002000200020000200002002002002002002002020020020200200200200200200200200202020020020020020020020020002002002020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020002002002002002002000200200200200200200200200200020202020002000200020002002002002000020200200`),MN=(()=>{let e=new Int32Array(319).fill(-1),t=bN(`02422242:222222242224222242442222222422222244442242226224222426222422442462222422622222222626222462242622422622422424242422222222422222222242422222222222222222622442224222222222222224424442262222222222222222222226224222424242422224422422422222`),n=bN(`02222222222222222222202222222222222222222222221422222222222222222222222222222222222Y\\222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221422222222222222222222222222222222222222Ŀł222222222222222222`);for(let r=0;r<t.length;r++)e[t[r]]=n[r];return e})(),NN=`container |break-after- all auto avoid avoid-page column left page right|break-before- all auto avoid avoid-page column left page right|break-inside-a uto void void-column void-page|box-decoration- clone slice|box- border content| contents flow-root hidden table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group| not-sr-only sr-only|float- end left none right start|clear- both end left none right start|isolat e ion-auto|overflow- auto clip hidden scroll visible|overflow-x- auto clip hidden scroll visible|overflow-y- auto clip hidden scroll visible|overscroll- auto contain none|overscroll-x- auto contain none|overscroll-y- auto contain none| absolute fixed relative static sticky| collapse invisible visible|justify- around baseline between center center-safe end end-safe evenly normal start stretch|justify-items- center center-safe end end-safe normal start stretch|justify-self- auto center center-safe end end-safe start stretch|items- baseline baseline-last center center-safe end end-safe start stretch|self- auto baseline baseline-last center center-safe end end-safe start stretch|place-content- around baseline between center center-safe end end-safe evenly start stretch|place-items- baseline center center-safe end end-safe start stretch|place-self- auto center center-safe end end-safe start stretch| antialiased subpixel-antialiased| italic not-italic|normal-nums |ordinal |slashed-zero | lining-nums oldstyle-nums| proportional-nums tabular-nums| diagonal-fractions stacked-fractions| no-underline overline| capitalize lowercase normal-case uppercase|truncate |whitespace- break-spaces normal nowrap pre pre-line pre-wrap|break- all keep normal words|wrap- anywhere break-word normal|hyphens- auto manual none|mix-blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay plus-darker plus-lighter saturation screen soft-light|table- auto fixed|caption- bottom top|backface- hidden visible|appearance- auto none|scheme- dark light light-dark normal only-dark only-light|field-sizing- content fixed|pointer-events- auto none|resize -none -x -y|snap- align-none center end start|snap- always normal|snap- both none x y|snap- mandatory proximity|touch- auto manipulation none|touch-pan- left right x|touch-pan- down up y|touch-pinch-zoom |select- all auto none text|forced-color-adjust- auto none| normal size| baseline bottom middle sub super text-bottom text-top top| bounce none ping pulse spin| auto square video| auto fr max min px|none | auto full px| fixed local scroll|clip- border content padding text|origin- border content padding| bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| no-repeat repeat repeat-round repeat-space repeat-x repeat-y| auto contain cover| gradient-to-b gradient-to-bl gradient-to-br gradient-to-l gradient-to-r gradient-to-t gradient-to-tl gradient-to-tr none|blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay saturation screen soft-light|to- b bl br l r t tl tr| auto dvh fit full lh lvh max min px screen svh| dashed dotted double hidden none solid| collapse separate|px |auto |full | content none strict| inline-size size|layout |paint |style | around baseline between center center-safe end end-safe evenly normal start stretch| alias all-scroll auto cell col-resize context-menu copy crosshair default e-resize ew-resize grab grabbing help move n-resize ne-resize nesw-resize no-drop none not-allowed ns-resize nw-resize nwse-resize pointer progress row-resize s-resize se-resize sw-resize text vertical-text w-resize wait zoom-in zoom-out| dashed dotted double solid wavy| auto from-font|reverse |initial | in in-out initial linear out| col col-reverse row row-reverse| nowrap wrap wrap-reverse| auto initial none| black bold extrabold extralight light medium normal semibold thin| condensed expanded extra-condensed extra-expanded normal semi-condensed semi-expanded ultra-condensed ultra-expanded|flow- col col-dense dense row row-dense| none subgrid| auto dvh dvw fit full lh lvh lvw max min px screen svh svw| block flex grid table| auto dvw fit full lvw max min px screen svw| loose none normal px relaxed snug tight|through |item | inside outside| decimal disc none| auto px| clip-border clip-content clip-fill clip-padding clip-stroke clip-view no-clip| add exclude intersect subtract| alpha luminance match|origin- border content fill padding stroke view|type- alpha luminance| circle ellipse| closest-corner closest-side farthest-corner farthest-side|at- bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| dvh fit full lh lvh max min none px screen svh| auto dvh dvw fit full lh lvh lvw max min none px screen svh svw| dvw fit full lvw max min none px screen svw| auto dvh dvw fit full lvh lvw max min none prose px svh svw| auto dvh dvw fit full lvh lvw max min none px screen svh svw| contain cover fill none scale-down| first last none| distant dramatic midrange near none normal|inset | full none|3d | auto smooth|gutter- auto both stable| auto none thin| inner none| auto dvh dvw fit full lvh lvw max min px svh svw|base | center end justify left right start| clip ellipsis| balance nowrap pretty wrap| normal tight tighter wide wider widest| cpu gpu none| 3d flat| all colors none opacity shadow transform| discrete normal| full px| auto dvh dvw fit full lvh lvw max min px screen svh svw| auto contents scroll transform`.split(`|`).map(e=>{let t=e.split(` `),n=t.shift();for(let e=0;e<t.length;e++)t[e]=n+t[e];return t}),PN=bN(`0000000000000000000000000000000000000000000000000000000000000262242:6@200000006:240B428:4422400002046044222426220026642642462026224222824220022400000000\\00N222422242222222224062242222222422226264222422222222222222442804222422222222222222222222220<4<0204260002444020204224422`),FN=bN(`ɠ222222222222222222222222222222222222222222222222222222222222˕4222226>ʶ22ʷʺʷ2ʸʷ42ʴ2ʓ22>621422ɶ222ɹɼɷɺɷɺ22ɱ42222ɨ2ɧ26622ɘɓ244ƸƵ222]d24242ǖǓƚÄȫ2263ȨȥȨ2222222ǣ222222222222222222ǂƽ2ƾƵ2222222422222ƜƑ22222222222222222222144Ŧţ22Ţş222222222222222222222ĸ2ı68ĦģĦɡŰ4Ġ«®ĝ822ĔđĔ2ē2222622`),IN=bN(`02222222222222222222222222222222222222222222222222222222222222222202022222222222EH2200IL021042222Y\\222IL0cf2e10j2222U00X202[^2y0000120|{~‚22…ˆ‡:22|22222222222G000q†OVI00000}š2›>40000ŒB00000I¨©000¬00000000000000021M®­00°“000000000000000000000–222›HGHa1º222¿2À2222ÉÌ000­°2±`),LN=new Int32Array(995),RN=new Int32Array(995),zN=new Int32Array(995),BN=``,VN=new Int32Array(1038);{let e=new Map,t=0,n=0;for(let r=0;r<PN.length;r++)for(let i of NN[IN[r]]){let a=e.get(i);a===void 0&&(a=t++,e.set(i,a),VN[a*2]=BN.length,VN[a*2+1]=i.length,BN+=i),LN[n]=PN[r],RN[n]=FN[r],zN[n]=a,n++}}var HN=bN(`0b2N:222@R>F@286¦2@H2D266226FB22B2>BD\\6N22222Z222D222p`),UN=yN(vN(`1::24444432:442:44:44>222222:44:4421322511111311111114`)),WN=bN(`2Š4A;33N=C@H4A;33N=C@<27;83:;8393NQ:3NQʰ222ˉºŴŽ2R2=18cƴÅҜ=cĞÛC1ƈǝȈ:ħ25=11D3A@4=<1;1DEr25;11B3?<6;:371BCn9@7=<8192>2E121@9@EHE@9>2T25511<398454131<=V25511<398454131<=„ƧNž2Đå242L222290000f22500ɛ000ǘ222`),GN=vN(`ij`),KN=vN(`—`),qN=vN(`1`),JN={GROUP_COUNT:xN,customValidatorNames:SN,edgeStart:CN,labelStart:wN,labelText:TN,edgeTarget:EN,nodeGroup:DN,nodeVlist:MN,vlistPat:ON,vlistOps:kN,vlistRef:AN,vlistGroup:jN,litAnchor:LN,litGroup:RN,litPool:zN,poolOffsets:VN,poolText:BN,adjGid:HN,adjStart:UN,adjTgt:WN,patGid:GN,patTgt:KN,postfixLookupGroups:qN,orderSensitiveModifiers:`* ** after backdrop before details-content file first-letter first-line marker placeholder selection`},YN=`line`in Error(),XN=-1,ZN=-1,QN=(e,t,n)=>{let r=2166136261;for(let i=t;i<n;i++)r=Math.imul(r^e.charCodeAt(i),16777619);return r},$N=(e,t,n)=>{let r=n-t,i=Math.imul(r,2654435761)^e.charCodeAt(t);if(r>3){let a=r>>2,o=r>>1;i=Math.imul(i^e.charCodeAt(t+1)<<8^e.charCodeAt(t+2)<<16^e.charCodeAt(t+a),2246822507),i=Math.imul(i^e.charCodeAt(t+o)<<8^e.charCodeAt(t+o+a)<<16^e.charCodeAt(n-3),3266489909),i^=e.charCodeAt(n-2)<<8^e.charCodeAt(n-1)<<16;for(let r=t+3,a=n-4;r<t+8&&r<a;r++,a--)i=Math.imul(i^e.charCodeAt(r)^e.charCodeAt(a)<<8,16777619)}return i^i>>>15|0},eP=(e,t,n={})=>{let{GROUP_COUNT:r,edgeStart:i,labelStart:a,labelText:o,edgeTarget:s,nodeGroup:c,nodeVlist:l,vlistPat:u,vlistOps:d,vlistRef:f,vlistGroup:p,litAnchor:m,litGroup:h,litPool:g,poolOffsets:_,poolText:v,adjGid:y,adjStart:b,adjTgt:x,patGid:S,patTgt:C,postfixLookupGroups:w,customValidatorNames:T,orderSensitiveModifiers:E}=e,D=new Int32Array(r).fill(-1);for(let e=0;e<y.length;e++)D[y[e]]=e;let O=0;for(let e=0;e+1<b.length;e++){let t=b[e+1]-b[e];t>O&&(O=t)}let k=32;for(;k<2*(1+O+S.length);)k<<=1;let A=new Int32Array(f.length+1);for(let e=0;e<f.length;e++)A[e+1]=A[e]+u[f[e]+1]-u[f[e]];let j=new Uint8Array(r);for(let e=0;e<w.length;e++)j[w[e]]=1;let M=i.length-1,N=new Uint8Array(M),P=0,F=!0;for(let e=0;e<m.length;e++){N[m[e]]=1;let t=_[g[e]*2+1];t>P&&(P=t);let n=v.charCodeAt(_[g[e]*2]);(n===91||n===40)&&(F=!1)}let I=1;for(;I<m.length*2;)I<<=1;let L=new Int32Array(I).fill(-1);for(let e=0;e<m.length;e++){let t=_[g[e]*2],n=(QN(v,t,t+_[g[e]*2+1])^Math.imul(m[e],2654435761)|0)&I-1;for(;L[n]!==-1;)n=n+1&I-1;L[n]=e}let R=(e,t,n,r)=>{let i=(QN(t,n,r)^Math.imul(e,2654435761)|0)&I-1,a=r-n;for(;;){let r=L[i];if(r===-1)return-1;if(m[r]===e&&_[g[r]*2+1]===a){let e=_[g[r]*2],i=!0;for(let r=0;r<a;r++)if(v.charCodeAt(e+r)!==t.charCodeAt(n+r)){i=!1;break}if(i)return h[r]}i=i+1&I-1}},ee=n.cacheSize??8192,te=n.prefix??e.prefix??``,ne=te===``?``:te+`:`,z=ne.length,re=(T??[]).map(e=>{let n=t&&t[e];if(!n)throw Error(`cn: missing validator `+e);return n}),ie=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,B=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ae=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,oe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,se=0,ce=-1,le=-1,ue=-1,de=-1,V=e=>e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95,fe=e=>/\s/.test(String.fromCharCode(e)),pe=(e,t,n)=>{if(se=0,ce=-1,n-t<3)return;let r=e.charCodeAt(t),i=e.charCodeAt(n-1);if(r===91&&i===93)se=1;else if(r===40&&i===41)se=2;else return;ue=t+1,de=n-1;let a=t+1;if(V(e.charCodeAt(a))){for(a++;a<n-1;){let t=e.charCodeAt(a);if(!V(t)&&t!==45)break;a++}a<n-2&&e.charCodeAt(a)===58&&(ce=t+1,le=a,ue=a+1)}},me=(e,t,n,r)=>{if(n-t!==r.length)return!1;for(let n=0;n<r.length;n++)if(e.charCodeAt(t+n)!==r.charCodeAt(n))return!1;return!0},he=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ge=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_e=e=>!!e&&!Number.isNaN(Number(e)),ve=(e,t,n)=>{if(n-t<11||!me(e,t,t+10,`@container`))return!1;if(e.charCodeAt(t+10)===47)return n-t>=12;let r=e.charCodeAt(t+11);return r===115&&n-t>=17&&me(e,t+10,t+16,`-size/`)||r===110&&n-t>=19&&me(e,t+10,t+18,`-normal/`)},ye=[1,1,1,1,1,1,1,1,2,2,2,2,2,2,2],be=`length|number|number weight|family-name|position percentage|length size bg-size|image url|shadow|length|family-name|position percentage|length size bg-size|image url|shadow|number weight`.split(`|`).map(e=>e.split(` `)),xe=[2,3,1,0,0,0,4,5,0,0,0,0,0,1,1],Se=(e,t,n,r)=>{if(e>=10){if(e>=25)return re[e-25](t.slice(n,r));let i=e-10;if(se!==ye[i])return!1;if(ce>=0){for(let e of be[i])if(me(t,ce,le,e))return!0;return!1}switch(xe[i]){case 0:return!1;case 1:return!0;case 2:{let e=t.slice(ue,de);return ie.test(e)&&!B.test(e)}case 3:return _e(t.slice(ue,de));case 4:return oe.test(t.slice(ue,de));default:return ae.test(t.slice(ue,de))}}switch(e){case 0:return!0;case 1:return se===0;case 2:return se===1;case 3:return se===2;case 4:return he.test(t.slice(n,r));case 5:return _e(t.slice(n,r));case 6:{let e=t.slice(n,r);return!!e&&Number.isInteger(Number(e))}case 7:return r>n&&t.charCodeAt(r-1)===37&&_e(t.slice(n,r-1));case 8:return ge.test(t.slice(n,r));default:return ve(t,n,r)}},Ce=new Set(typeof E==`string`?E.split(` `):E),we=(e,t,n,r,i,a)=>{let o=QN(t,n,r)^(i?2654435769:0)|0,s=e.get(o);if(s!==void 0)outer:for(let e=0;e<s.length;e++){let a=s[e];if(a.imp===i&&a.k.length===r-n){for(let e=0;e<a.k.length;e++)if(a.k.charCodeAt(e)!==t.charCodeAt(n+e))continue outer;return a.id}}else e.set(o,s=[]);let c=t.slice(n,r),l=a(c);return s.push({k:c,imp:i,id:l}),l},Te=new Map,Ee=new Map,De=2,Oe=4096,ke=(e,t)=>{let n=[],r=0,i=0,a=0;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);r===0&&i===0&&o===58?(n.push(e.slice(a,t)),a=t+1):o===91?r++:o===93?r--:o===40?i++:o===41&&i--}n.push(e.slice(a));let o=n[0];if(n.length>1){let e=[],t=[];for(let r of n)r.charCodeAt(0)===91||Ce.has(r)?(t.length&&(e.push(...t.sort()),t=[]),e.push(r)):t.push(r);t.length&&e.push(...t.sort()),o=e.join(`:`)}let s=t?o+` !`:o,c=Ee.get(s);return c===void 0&&Ee.set(s,c=De++),c},Ae=new Map,je=r,H=r+4096,Me=()=>je++,Ne=2097152,Pe=8192,Fe=new Int32Array(Pe),Ie=Array(Pe).fill(null),Le=new Int32Array(Pe),Re=new Int32Array(Pe),U=new Uint8Array(Pe),ze=0,Be=(e,t,n,r,i,a,o,s)=>{let c=e;if(Ie[e]!==null){if(Ie[e|1]===null)c=e|1;else if(!(ze++&3))c=e|ze>>2&1;else return}Ie[c]=t.slice(n,r),Fe[c]=i,Le[c]=a,Re[c]=o,U[c]=s},Ve=()=>Ie.fill(null),He=256,Ue=[new Int32Array(He),new Int32Array(He),new Int32Array(He),new Int32Array(He)],[We,Ge,Ke,qe]=Ue,Je=new Uint8Array(He),Ye=new Uint8Array(He),Xe=()=>{He*=2,Ue=Ue.map(e=>{let t=new Int32Array(He);return t.set(e),t}),[We,Ge,Ke,qe]=Ue;let e=new Uint8Array(He);e.set(Je),Je=e,Ye=new Uint8Array(He)},Ze=64,Qe=new Int32Array(Ze),$e=new Int32Array(Ze),et=new Int32Array(r),tt=2048,nt=21,rt=new Float64Array(tt),it=new Int32Array(tt),at=0,ot=(e,t)=>{if(e===0&&t<r)return et[t]===at?1:(et[t]=at,0);let n=e*2097152+t+1,i=Math.imul(n,2654435761)>>>nt;for(;it[i]===at;){if(rt[i]===n)return 1;i=i+1&tt-1}return rt[i]=n,it[i]=at,0},st=(e,t,n,r,i)=>{if(n-t>=2&&e.charCodeAt(t)===91&&e.charCodeAt(n-1)===93){let r=-1;for(let i=t+1;i<n-1;i++)if(e.charCodeAt(i)===58){r=i;break}return r===-1||r===t+1?XN:we(Ae,e,t+1,r,0,Me)}if(r>=0&&c[r]>=0)return c[r];for(let t=i-1;t>=0;t--){let r=$e[t];if(r>n)continue;let i=Qe[t],a=n-r;if(N[i]===1&&a>0&&a<=P){let t=e.charCodeAt(r);if(F===!1||t!==91&&t!==40){let t=R(i,e,r,n);if(t>=0)return t}}let o=l[i];if(o<0)continue;let s=f[o],c=u[s],m=u[s+1];if(c===m)continue;pe(e,r,n);let h=A[o]-c;for(let t=c;t<m;t++)if(Se(d[t],e,r,n))return p[h+t]}return XN},ct=e=>{let t=e.length,n=0,c=0,u=!1;(De>Oe||Te.size>Oe)&&(Te=new Map,Ee=new Map,De=2,Ve()),je>H&&(Ae=new Map,je=r,Ve());let d=0;for(;d<t;){let f=e.charCodeAt(d);if(f===32||f>=9&&f<=13||f>=160&&fe(f)){f!==32&&(u=!0),d++;continue}let p=d,m=0;for(;d<t;){if(f=e.charCodeAt(d),f<=32){if(f===32)break;if(f>=9&&f<=13){u=!0;break}}else if(f>=160&&fe(f)){u=!0;break}m=Math.imul(m^f,16777619),d++}let h=d,g=h-p;n===He&&Xe();let _=n++;We[_]=p,Ge[_]=h,c+=g,m^=Math.imul(g,2654435761);let v=m^m>>>15|0,y=v&8190;{let t=-1;if(Fe[y]===v&&Ie[y]!==null&&Ie[y].length===g?t=y:Fe[y|1]===v&&Ie[y|1]!==null&&Ie[y|1].length===g&&(t=y|1),t>=0){let n=Ie[t],r=!0;for(let t=0;t<g;t++)if(n.charCodeAt(t)!==e.charCodeAt(p+t)){r=!1;break}if(r){Ke[_]=Le[t],qe[_]=Re[t],Je[_]=U[t];continue}}}let b=p;if(z!==0){if(h-p<=z||!e.startsWith(ne,p)){Ke[_]=XN,Be(y,e,p,h,v,XN,0,0);continue}b=p+z}let x=0,S=0,C=-1,w=-1;for(let t=b;t<h;t++){let n=e.charCodeAt(t);if(x===0&&S===0){if(n===58){C=t;continue}if(n===47){w=t;continue}}n===91?x++:n===93?x--:n===40?S++:n===41&&S--}let T=C>=b?C+1:b,E=T,D=h,O=!1,k=0;D>E&&e.charCodeAt(D-1)===33?(O=!0,D--):D>E&&e.charCodeAt(E)===33&&(O=!0,E++,k=1);let A=-1;w>T&&(A=w+k,A>=D&&(A=-1));let M=E;D-E>1&&e.charCodeAt(E)===45&&(M=E+1);let P=0,F=0,I=0,L=-1,R=0;(l[0]>=0||N[0]===1)&&(Qe[0]=0,$e[0]=M,R=1);let ee=ZN,te=0;for(let t=M;t<D;t++)if(t===A&&(ee=F<I?ZN:P,te=R),P!==ZN){let n=e.charCodeAt(t),r=-1;if(F<I)o.charCodeAt(F)===n?(F++,F===I&&(r=P=L)):P=ZN;else{let e=i[P],t=i[P+1],c=ZN;for(let i=e;i<t;i++){let e=a[i];if(o.charCodeAt(e)===n){a[i+1]-e===1?r=c=s[i]:(F=e+1,I=a[i+1],L=s[i],c=P);break}}P=c}if(r>=0&&(l[r]>=0||N[r]===1)&&t+1<D&&e.charCodeAt(t+1)===45){if(R===Ze){Ze*=2;let e=new Int32Array(Ze);e.set(Qe),Qe=e;let t=new Int32Array(Ze);t.set($e),$e=t}Qe[R]=r,$e[R]=t+2,R++}}A===D&&(ee=F<I?ZN:P,te=R);let re=F<I?ZN:P,ie,B=!1;if(A>=0){if(B=!0,ie=st(e,E,A,ee,te),ie!==XN&&ie<r&&j[ie]){let t=st(e,E,D,re,R);t!==XN&&t!==ie&&(ie=t,B=!1)}else ie===XN&&(ie=st(e,E,D,re,R),B=!1)}else ie=st(e,E,D,re,R);let ae=0,oe=0;ie===XN?Ke[_]=XN:(oe=+!!B,ae=b>=C?+!!O:we(Te,e,b,C,+!!O,e=>ke(e,O)),Ke[_]=ie,Je[_]=oe,qe[_]=ae),Be(y,e,p,h,v,ie,ae,oe)}if(n===0)return``;if(n===1)return We[0]===0&&Ge[0]===t?e:e.slice(We[0],Ge[0]);if(n*k>tt){for(;n*k>tt;)tt<<=1,nt--;rt=new Float64Array(tt),it=new Int32Array(tt)}if(De>=Ne||je>=Ne)throw Error(`cn: too many distinct classes in one merge`);at=at+1|0,at===0&&(et.fill(0),it.fill(0),at=1);let f=!1;for(let e=n-1;e>=0;e--){let t=Ke[e];if(t===XN){Ye[e]=1;continue}let n=qe[e];if(ot(n,t)===1){Ye[e]=0,f=!0;continue}if(Ye[e]=1,t<r){let r=D[t];if(r>=0)for(let e=b[r];e<b[r+1];e++)ot(n,x[e]);if(Je[e]&1)for(let e=0;e<S.length;e++)S[e]===t&&ot(n,C[e])}}if(!f&&!u&&t===c+n-1)return e;let p=``,m=0;for(;m<n;){if(!Ye[m]){m++;continue}let t=We[m],r=Ge[m],i=m+1;for(;i<n&&Ye[i]&&We[i]===r+1&&e.charCodeAt(r)===32;)r=Ge[i],i++;p.length>0&&(p+=` `),p+=e.slice(t,r),m=i}return p},lt=16384,ut=new Int32Array(lt*2),dt=0,ft=1,pt=Object.create(null),mt=Object.create(null),ht=new Map,gt=new Map,_t=0,vt=0,yt=()=>{dt^=lt,ft=ft+1|0,vt=0},bt=e=>{let t=pt[e];if(t!==void 0)return t;let n=$N(e,0,e.length),r=(n&16383)+dt,i=ut[r]===(n^ft)||ut[r^lt]===(n^ft-1);return i&&(t=mt[e],t!==void 0)?(pt[e]=t,t):(t=ct(e),i?(pt[e]=t,++_t>ee&&(_t=0,mt=pt,pt=Object.create(null),yt())):(ut[r]=n^ft,++vt>lt&&yt()),t)},xt=e=>{let t=ht.get(e);if(t!==void 0)return t;let n=$N(e,0,e.length),r=(n&16383)+dt,i=ut[r]===(n^ft)||ut[r^lt]===(n^ft-1);return i&&(t=gt.get(e),t!==void 0)?(ht.set(e,t),t):(t=ct(e),i?(ht.set(e,t),++_t>ee&&(_t=0,gt=ht,ht=new Map,yt())):(ut[r]=n^ft,++vt>lt&&yt()),t)},St=e=>{let t=$N(e,0,e.length),n=(t&16383)+dt;return ut[n]===(t^ft)||ut[n^lt]===(t^ft-1)||(ut[n]=t^ft,++vt>lt&&yt(),!1)},Ct=ee===0?ct:YN?e=>{let t=ht.get(e);return t===void 0?xt(e):t}:bt;return{merge:function(){return arguments.length===1&&typeof arguments[0]==`string`?Ct(arguments[0]):Ct(rP.apply(null,arguments))},mergeString:Ct,seenBefore:ee===0?()=>!1:St,mergeUncached:ct}},tP=(e,t)=>{if(!e)return``;if(typeof e==`string`)return e;let n=``;if(typeof e.length==`number`&&(!t||Array.isArray(e))){let r=e;for(let e=0;e<r.length;e++){let i=r[e];if(!i)continue;let a=typeof i==`string`?i:tP(i,t);a&&(n&&(n+=` `),n+=a)}return n}if(t){if(typeof e==`number`)return``+e;if(typeof e==`object`)for(let t in e)e[t]&&(n&&(n+=` `),n+=t)}return n},nP=(e,t)=>{let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(!i)continue;let a=typeof i==`string`?i:tP(i,t);a&&(n&&(n+=` `),n+=a)}return n},rP=function(){return nP(arguments,!1)},iP=256,aP=16,oP=1024,sP=4096,cP=(e,t)=>{let n=t===void 0?()=>!0:t.seenBefore,r=t===void 0?e:t.mergeUncached,i=new Map,a=new Map,o=0,s=null,c=null,l=[],u=[],d=0,f=(t,n,r)=>{c===null&&(c=Array(sP).fill(``),l=Array(sP).fill(``),u=Array(sP).fill(``));let i=$N(t,0,t.length)&4094;if(c[i]===t&&l[i]===n)return u[i];if(c[i|1]===t&&l[i|1]===n)return u[i|1];let a=e(r?n+` `+t:t),o=c[i]===``?i:i|(c[i|1]===``?1:d++&1);return c[o]=t,l[o]=n,u[o]=a,a},p=(e,t,n,r)=>{let i=0;if(t){if(t!==e.a0)return!1;i=1}if(n){if(n!==(i===0?e.a0:e.a1))return!1;i++}if(r){if(r!==(i===0?e.a0:i===1?e.a1:e.a2))return!1;i++}return i===e.t},m=(e,t)=>{let n=e.a,r=0;for(let e=0;e<t.length;e++){let i=t[e];if(i){if(i!==n[r])return!1;r++}}return r===e.t},h=(t,c)=>{let l=t.length,u=s===null?null:s.n;if(!c){if(u!==null&&m(u,t))return s=u,u.r;if(s!==null&&s!==u&&m(s,t))return s.r}let d=``,p=-1,h=0,g=!1;for(let e=0;e<l;e++){let n=t[e];if(n){if(typeof n!=`string`){if(n=t[e]=tP(n,!0),!n)continue;g=!0}p<0&&(d=n,p=e),h++}}if(h===0)return``;if(h===1)return e(d);if(g){if(u!==null&&m(u,t))return s=u,u.r;if(s!==null&&s!==u&&m(s,t))return s.r}let _=i.get(d);_===void 0&&(_=a.get(d),_!==void 0&&i.set(d,_));let v=null;if(_!==void 0){if(_.skip>0){_.skip--,s=null;let e=d;for(let n=p+1;n<l;n++){let r=t[n];r&&(e+=` `+r)}return f(e,``,!1)}let e=_.e;outer:for(let n=0;n<e.length;n++){let r=e[n];if(r.t!==h)continue;let i=r.a,a=1;for(let e=p+1;e<l;e++){let n=t[e];if(n&&n!==i[a++])continue outer}v=r;break}v!==null&&(_.miss=0)}if(v===null){let s=d,c=[d];for(let e=p+1;e<l;e++){let n=t[e];n&&(s+=` `+n,c.push(n))}if(!n(s))return r(s);v={r:e(s),t:c.length,a0:c[0],a1:c[1],a2:c[2]??``,a:c,n:null},_===void 0?i.set(d,_={e:[],miss:0,skip:0,at:0}):++_.miss>aP&&(_.miss=aP,_.skip=oP,_.e.length=0,_.at=0);let u=_.e;u.length<iP?u.push(v):(u[_.at]=v,_.at=_.at+1&255),++o>1e3&&(o=0,a=i,i=new Map)}return s!==null&&s!==v&&(s.n=v),s=v,v.r},g=t=>Array.isArray(t)?h(t.slice(),!1):e(tP(t,!0));return function(t,n,r){let a=arguments.length;if((a|1)==3){let e=s;if(e!==null){let i=e.n;if(i!==null&&p(i,t,n,r))return s=i,i.r;if(e!==i&&p(e,t,n,r))return e.r}if(a===2&&typeof n==`string`&&n!==``){let e=i.get(t);if(e!==void 0&&e.skip>0)return e.skip--,s=null,f(n,t,!0)}return h([t,n,r],!0)}if(a===1)return typeof t==`string`?e(t):g(t);let o=s;if(o!==null){let e=o.n;if(e!==null){let t=e.a,n=0,r=!0;for(let e=0;e<a;e++){let i=arguments[e];if(i){if(i!==t[n]){r=!1;break}n++}}if(r&&n===e.t)return s=e,e.r}if(o!==e){let e=o.a,t=0,n=!0;for(let r=0;r<a;r++){let i=arguments[r];if(i){if(i!==e[t]){n=!1;break}t++}}if(n&&t===o.t)return o.r}}let c=[];for(let e=0;e<a;e++)c.push(arguments[e]);return h(c,!0)}},lP=eP(JN),uP=cP(lP.mergeString,lP);lP.merge;function dP({...e}){return(0,K.jsx)(pN,{"data-slot":`context-menu`,...e})}function fP({className:e,...t}){return(0,K.jsx)(hN,{"data-slot":`context-menu-trigger`,className:uP(`select-none`,e),...t})}function pP({className:e,align:t=`start`,alignOffset:n=4,side:r=`right`,sideOffset:i=0,...a}){return(0,K.jsx)(Uj,{children:(0,K.jsx)(gN,{className:`isolate z-50 outline-none`,align:t,alignOffset:n,side:r,sideOffset:i,children:(0,K.jsx)(Bj,{"data-slot":`context-menu-content`,className:uP(`z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md backdrop-blur-xl ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function mP({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(dE,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:uP(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function hP({...e}){return(0,K.jsx)(ZM,{"data-slot":`context-menu-sub`,...e})}function gP({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(fN,{"data-slot":`context-menu-sub-trigger`,"data-inset":t,className:uP(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,K.jsx)(ee,{className:`ml-auto`})]})}function _P({...e}){return(0,K.jsx)(pP,{"data-slot":`context-menu-sub-content`,className:`shadow-lg`,side:`right`,...e})}function vP({className:e,children:t,checked:n,inset:r,...i}){return(0,K.jsxs)(XT,{"data-slot":`context-menu-checkbox-item`,"data-inset":r,className:uP(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,K.jsx)(lE,{children:(0,K.jsx)(o,{})})}),t]})}function yP({className:e,...t}){return(0,K.jsx)(lN,{"data-slot":`context-menu-separator`,className:uP(`-mx-1 my-1 h-px bg-border`,e),...t})}function bP({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`context-menu-shortcut`,className:uP(`ml-auto text-xs tracking-widest text-muted-foreground group-focus/context-menu-item:text-accent-foreground`,e),...t})}function xP({...e}){return(0,K.jsx)(YM,{"data-slot":`dropdown-menu`,...e})}function SP({...e}){return(0,K.jsx)(oN,{"data-slot":`dropdown-menu-trigger`,...e})}function CP({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,K.jsx)(Uj,{children:(0,K.jsx)(NM,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,K.jsx)(Bj,{"data-slot":`dropdown-menu-content`,className:uP(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md backdrop-blur-xl ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function wP({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(dE,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:uP(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function TP({...e}){return(0,K.jsx)(ZM,{"data-slot":`dropdown-menu-sub`,...e})}function EP({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(fN,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:uP(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,K.jsx)(ee,{className:`ml-auto`})]})}function DP({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,K.jsx)(CP,{"data-slot":`dropdown-menu-sub-content`,className:uP(`w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg backdrop-blur-xl ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function OP({className:e,children:t,checked:n,inset:r,...i}){return(0,K.jsxs)(XT,{"data-slot":`dropdown-menu-checkbox-item`,"data-inset":r,className:uP(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-checkbox-item-indicator`,children:(0,K.jsx)(lE,{children:(0,K.jsx)(o,{})})}),t]})}function kP({className:e,...t}){return(0,K.jsx)(lN,{"data-slot":`dropdown-menu-separator`,className:uP(`-mx-1 my-1 h-px bg-border`,e),...t})}function AP({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:uP(`ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground`,e),...t})}var jP=G.createContext(void 0);function MP(e){let t=G.useContext(jP);if(t===void 0&&!e)throw Error(iC(50));return t}var NP={...Zk,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay},PP=class extends Hk{constructor(e,t,n){let r=new Dk;super(FP(e,r,t,n),IP(r),NP)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;Sk(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&dk(n,t.trigger,r.clientX,r.clientY)}})}};function FP(e,t,n,r=!1){return{...Gk(t,n,r),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e}}function IP(e){return{popupRef:G.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function LP(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=gk((e,r)=>new PP({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);wk(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=Tk(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});X(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),G.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,qT(Aw))}),[h,u]);let g=d||p||o!=null;return(0,K.jsxs)(jP.Provider,{value:u,children:[o&&(0,K.jsx)(_k,{handle:o,store:u}),g&&(0,K.jsx)(RP,{store:u}),typeof l==`function`?l({payload:m}):l]})}function RP({store:e}){let t=tk(e.useState(`floatingRootContext`));return Ek(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}var zP=Nk(function(e){return MP(!0)?(0,K.jsx)(LP,{...e}):(0,K.jsx)(zO,{children:(0,K.jsx)(LP,{...e})})}),BP=G.createContext(void 0);function VP(){let e=G.useContext(BP);if(e===void 0)throw Error(iC(48));return e}var HP=G.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=kO({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,K.jsxs)(G.Fragment,{children:[l,c&&_c.createPortal(n,c)]})}),UP=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return MP().useState(`mounted`)||n?(0,K.jsx)(BP.Provider,{value:n,children:(0,K.jsx)(HP,{ref:t,...r})}):null}),WP=Pk(function(e,t){let{render:n,className:r,delay:i,closeDelay:a,id:o,payload:s,handle:c,style:l,...u}=e,d=MP(!0),f=Qk(c)??d;if(!f)throw Error(iC(89));let p=UT(o),m=f.useState(`isTriggerActive`,p),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`floatingRootContext`),_=f.context.inlineRectCoordsRef,v=G.useRef(null),y=i??600,b=a??300,{registerTrigger:x,isMountedByThisTrigger:S}=Ck(p,v,f,{payload:s,closeDelay:b}),C=cA(g,{mouseOnly:!0,move:!1,handleClose:wA(),delay:()=>({open:y,close:b}),triggerElementRef:v,isActiveTrigger:m,isClosing:()=>f.select(`transitionStatus`)===`ending`}),w=eA(g,{delay:y}),T={open:h},E=f.useState(`triggerProps`,S),D=uk(_,h);return WC(`a`,e,{state:T,ref:[t,x,v],props:[C,w.reference,E,D,{id:p},u],stateAttributesMapping:fw})}),GP=G.createContext(void 0);function KP(){let e=G.useContext(GP);if(e===void 0)throw Error(iC(49));return e}var qP=G.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=wO,style:g,..._}=e,v=MP(),y=VP(),b=LO(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=sM({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:fk(D)}),k=O.update;X(()=>{x&&S&&k()},[x,S,k]);let A=yM(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return(0,K.jsx)(GP.Provider,{value:O,children:(0,K.jsx)(RO,{id:b,children:A})})}),JP=G.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=MP(),{side:s,align:c}=KP(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return cE({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),oA(p,{closeDelay:m}),WC(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[hk,f,jj(d),a],stateAttributesMapping:hw})});function YP({...e}){return(0,K.jsx)(zP,{"data-slot":`hover-card`,...e})}function XP({...e}){return(0,K.jsx)(WP,{"data-slot":`hover-card-trigger`,...e})}function ZP({className:e,side:t=`bottom`,sideOffset:n=4,align:r=`center`,alignOffset:i=4,anchor:a,...o}){return(0,K.jsx)(UP,{"data-slot":`hover-card-portal`,children:(0,K.jsx)(qP,{anchor:a,align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,K.jsx)(JP,{"data-slot":`hover-card-content`,className:uP(`z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md backdrop-blur-xl ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o})})})}var QP=G.createContext(void 0);function $P(e){let t=G.useContext(QP);if(t===void 0&&!e)throw Error(iC(72));return t}var eF={...Zk,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},tF=class extends Hk{constructor(e,t,n){let r=new Dk;super(nF(e,r,t,n),rF(r),eF)}setOpen=(e,t)=>{Sk(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,qT(_w,e))}};function nF(e,t,n,r=!1){return{...Gk(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function rF(e){return{popupRef:G.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var iF=Nk(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=gk((e,t)=>new tF({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),wk(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=Tk(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=G.useRef(null);X(()=>{m&&t&&p.setOpen(!1,qT(kw))},[m,t,p]),X(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),X(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),G.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,qT(Aw))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,K.jsxs)(QP.Provider,{value:p,children:[l&&(0,K.jsx)(_k,{handle:l,store:p}),T&&(0,K.jsx)(aF,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function aF({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=tk(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=QO(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=G.useMemo(()=>jC(a.reference,i.reference),[a.reference,i.reference]);return Ek(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??EC}),null}var oF=G.createContext(void 0);function sF(){return G.useContext(oF)}var cF=`data-base-ui-tooltip-trigger`;function lF(e){let t=wE(e);return Ww(t)?t:null}var uF=Pk(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=$P(!0),m=Qk(a)??p;if(!m)throw Error(iC(82));let h=UT(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=G.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=Ck(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=sF(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=JE(v,{open:_}),O=aA(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=ZE(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=G.useRef(!1),F=mE(),I=G.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=CE(e,`[${cF}]`);return n!==null&&n!==t&&SE(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let te=cA(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?wA():null,restMs:L,delay(){return u==null&&D?{close:VE(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),ne=eA(v,{enabled:!A}).reference,z=e=>{let t=P.current,n=lF(e),r=ee(n),i=y.current,a=i&&n&&SE(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`){m.setOpen(!1,qT(vw,e));return}if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&yE(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,qT(vw,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},re=m.useState(`appliedTriggerProps`,S||M!==`none`);return WC(`button`,e,{state:{open:_},ref:[t,x,y],props:[te,ne,re,{onMouseOver(e){z(e.nativeEvent)},onFocus(e){R(lF(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[jE]:A?``:void 0,[cF]:A?void 0:``},f],stateAttributesMapping:fw})}),dF=G.createContext(void 0);function fF(){let e=G.useContext(dF);if(e===void 0)throw Error(iC(70));return e}var pF=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return $P().useState(`mounted`)||n?(0,K.jsx)(dF.Provider,{value:n,children:(0,K.jsx)(HP,{ref:t,...r})}):null}),mF=G.createContext(void 0);function hF(){let e=G.useContext(mF);if(e===void 0)throw Error(iC(71));return e}var gF=G.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=wO,style:g,..._}=e,v=$P(),y=fF(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=sM({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=yM(e,G.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,K.jsx)(mF.Provider,{value:D,children:O})}),_F=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=$P(),{side:s,align:c}=hF(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);cE({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),oA(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return WC(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[hk,f,jj(d),a],stateAttributesMapping:hw})}),vF=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=$P(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=hF();return WC(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:mw})}),yF=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=G.useMemo(()=>({open:t,close:n}),[t,n]);return(0,K.jsx)(oF.Provider,{value:t,children:(0,K.jsx)(qE,{delay:i,timeoutMs:r,children:e.children})})};function bF({delay:e=0,...t}){return(0,K.jsx)(yF,{"data-slot":`tooltip-provider`,delay:e,...t})}function xF({...e}){return(0,K.jsx)(iF,{"data-slot":`tooltip`,...e})}function SF({...e}){return(0,K.jsx)(uF,{"data-slot":`tooltip-trigger`,...e})}function CF({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,K.jsx)(pF,{children:(0,K.jsx)(gF,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,K.jsxs)(_F,{"data-slot":`tooltip-content`,className:uP(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,K.jsx)(vF,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var wF=`application/x-wizards-chat`;function TF(e){let[t,n]=(0,G.useState)(()=>{try{return new Set(JSON.parse(localStorage.getItem(e)??`[]`))}catch{return new Set}});return[t,t=>n(n=>{let r=new Set(n);r.delete(t)||r.add(t);try{localStorage.setItem(e,JSON.stringify([...r]))}catch{}return r})]}function EF(){let[e,t]=(0,G.useState)(``),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),{space:o}=It(),{data:s}=AS(o?.id,e),[c,l]=TF(`wizards.work.folded-sections`),[u,d]=TF(`wizards.work.folded-threads`),[f,p]=(0,G.useState)(!1),m=RS(),h=WS(),g=B(),_=s?.sections??[],v=(s?.chats??[]).filter(e=>(n||!e.archived)&&(!i||e.unread)),y=new Set(v.map(e=>e.id)),b=v.filter(e=>!e.parentId||!y.has(e.parentId)),x=e=>v.filter(t=>t.parentId===e),S=new Set(_.map(e=>e.id)),C=b.filter(e=>!e.archived),w=C.filter(e=>e.pinned),T=e=>C.filter(t=>!t.pinned&&t.sectionId===e),E=C.filter(e=>!e.pinned&&(!e.sectionId||!S.has(e.sectionId))),D=b.filter(e=>e.archived),O=async(e=null,t=null)=>{let n=await m.mutateAsync({spaceId:o?.id,sectionId:e,parentId:t});g(`/work/c/${n.id}`)},k=e=>(0,K.jsx)(LF,{chat:e,sections:_,threads:x(e.id),threadsFolded:u.has(e.id),onToggleThreads:()=>d(e.id),onNewThread:()=>O(e.sectionId,e.id),onNewSection:()=>p(!0)},e.id);return(0,K.jsx)(bF,{delay:500,children:(0,K.jsxs)(`aside`,{"aria-label":W(`work.chats`),className:`flex w-72 shrink-0 flex-col gap-0.5 overflow-y-auto border-border-soft border-r p-2 text-[0.875rem]`,children:[(0,K.jsxs)(Ue,{to:`/work`,end:!0,className:({isActive:e})=>V(`mb-1 flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 font-semibold text-ink hover:bg-ink/5`,e&&`bg-ink/10 hover:bg-ink/10`),children:[(0,K.jsx)(pr,{className:`size-4 shrink-0`}),W(`work.start`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>O(),className:`flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-ink hover:bg-ink/5`,children:[(0,K.jsx)(Ke,{className:`size-4 shrink-0`}),W(`work.newChat`)]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-ink-3 focus-within:bg-ink/5 hover:bg-ink/5`,children:[(0,K.jsx)(ue,{className:`size-4 shrink-0`}),(0,K.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:W(`work.search`),"aria-label":W(`work.search`),className:`min-w-0 flex-1 bg-transparent text-ink outline-none placeholder:text-ink-3`})]}),w.length?(0,K.jsx)(AF,{title:W(`work.pinned`),children:w.map(k)}):null,_.map((e,t)=>(0,K.jsx)(jF,{section:e,first:t===0,last:t===_.length-1,folded:c.has(e.id),onToggle:()=>l(e.id),onNewChat:()=>O(e.id),children:T(e.id).map(k)},e.id)),f?(0,K.jsx)(MF,{placeholder:W(`work.sectionName`),onDone:async e=>{p(!1),e&&o&&await h.mutateAsync({spaceId:o.id,name:e})}}):null,(0,K.jsx)(AF,{title:W(`work.chats`),dropTo:null,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(xP,{children:[(0,K.jsx)(OF,{label:W(`work.filter`),children:(0,K.jsx)(SP,{className:DF,"aria-label":W(`work.filter`),children:(0,K.jsx)(kr,{className:`size-3.5`})})}),(0,K.jsxs)(CP,{align:`end`,className:`w-52`,children:[(0,K.jsx)(OP,{checked:i,onCheckedChange:e=>a(!!e),children:W(`work.unreadOnly`)}),(0,K.jsx)(OP,{checked:n,onCheckedChange:e=>r(!!e),children:W(`work.showArchived`)})]})]}),(0,K.jsx)(OF,{label:W(`work.newSection`),children:(0,K.jsx)(`button`,{type:`button`,className:DF,"aria-label":W(`work.newSection`),onClick:()=>p(!0),children:(0,K.jsx)(Ke,{className:`size-3.5`})})})]}),children:E.length?E.map(k):(0,K.jsx)(`p`,{className:`px-2.5 py-1 text-[0.8125rem] text-ink-4`,children:W(e||i?`work.noMatches`:`work.noChats`)})}),n&&D.length?(0,K.jsx)(AF,{title:W(`work.archived`),children:D.map(k)}):null]})})}var DF=`grid size-6 place-items-center rounded-md text-ink-3 hover:bg-ink/10 hover:text-ink data-popup-open:bg-ink/10`;function OF({label:e,children:t}){return(0,K.jsxs)(xF,{children:[(0,K.jsx)(SF,{render:(0,K.jsx)(`span`,{className:`inline-flex`}),children:t}),(0,K.jsx)(CF,{children:e})]})}function kF(e){let[t,n]=(0,G.useState)(!1),r=zS();return e===void 0?{over:!1,props:{}}:{over:t,props:{onDragOver:e=>{e.dataTransfer.types.includes(wF)&&(e.preventDefault(),n(!0))},onDragLeave:()=>n(!1),onDrop:t=>{n(!1);let i=t.dataTransfer.getData(wF);i&&(t.preventDefault(),r.mutate({id:i,sectionId:e}))}}}}function AF({title:e,actions:t,dropTo:n,children:r}){let i=kF(n);return(0,K.jsxs)(`section`,{...i.props,className:V(`mt-3 flex min-w-0 flex-col gap-0.5 rounded-lg`,i.over&&`bg-ink/5 ring-1 ring-ember/40`),children:[(0,K.jsxs)(`div`,{className:`group/heading flex h-7 items-center gap-1 px-2.5`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-medium text-[0.8125rem] text-ink-3`,children:e}),t?(0,K.jsx)(`div`,{className:`flex items-center gap-0.5`,children:t}):null]}),r]})}function jF({section:e,first:t,last:n,folded:r,onToggle:i,onNewChat:a,children:o}){let s=kF(e.id),[c,l]=(0,G.useState)(!1),u=GS(),d=KS(),f=qS(),p=Array.isArray(o)?o.length:0;return(0,K.jsxs)(`section`,{...s.props,className:V(`mt-3 flex min-w-0 flex-col gap-0.5 rounded-lg`,s.over&&`bg-ink/5 ring-1 ring-ember/40`),children:[(0,K.jsxs)(`div`,{className:`group/heading flex h-7 items-center gap-1 rounded-lg px-1.5 hover:bg-ink/5`,children:[c?(0,K.jsx)(MF,{initial:e.name,placeholder:W(`work.sectionName`),onDone:async t=>{l(!1),t&&t!==e.name&&await u.mutateAsync({id:e.id,name:t})}}):(0,K.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":!r,className:`flex min-w-0 flex-1 items-center gap-1 px-1 text-left font-medium text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.name}),(0,K.jsx)(O,{className:V(`size-3.5 shrink-0 transition-transform`,r&&`-rotate-90`)}),r&&p?(0,K.jsx)(`span`,{className:`text-ink-4 tabular-nums`,children:p}):null]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 focus-within:opacity-100 group-hover/heading:opacity-100 has-data-popup-open:opacity-100`,children:[(0,K.jsxs)(xP,{children:[(0,K.jsx)(SP,{className:DF,"aria-label":W(`work.more`),children:(0,K.jsx)(pt,{className:`size-3.5`})}),(0,K.jsxs)(CP,{align:`end`,className:`w-52`,children:[(0,K.jsxs)(wP,{onClick:()=>l(!0),children:[(0,K.jsx)(M,{}),W(`work.rename`)]}),(0,K.jsxs)(wP,{disabled:t,onClick:()=>d.mutate({id:e.id,direction:`up`}),children:[(0,K.jsx)(Ie,{}),W(`work.moveUp`)]}),(0,K.jsxs)(wP,{disabled:n,onClick:()=>d.mutate({id:e.id,direction:`down`}),children:[(0,K.jsx)(ke,{}),W(`work.moveDown`)]}),(0,K.jsx)(kP,{}),(0,K.jsxs)(wP,{variant:`destructive`,onClick:()=>{confirm(W(`work.deleteSectionConfirm`,{name:e.name}))&&f.mutate(e.id)},children:[(0,K.jsx)(je,{}),W(`work.deleteSection`)]})]})]}),(0,K.jsx)(OF,{label:W(`work.newChatIn`,{name:e.name}),children:(0,K.jsx)(`button`,{type:`button`,className:DF,"aria-label":W(`work.newChatIn`,{name:e.name}),onClick:a,children:(0,K.jsx)(Ke,{className:`size-3.5`})})})]})]}),r?null:p?o:(0,K.jsx)(`p`,{className:`px-2.5 py-1 text-[0.8125rem] text-ink-4`,children:W(`work.noChats`)})]})}function MF({initial:e=``,placeholder:t,onDone:n}){let[r,i]=(0,G.useState)(e),a=(0,G.useRef)(!1),o=e=>{a.current||(a.current=!0,n(e))};return(0,K.jsx)(`input`,{autoFocus:!0,value:r,placeholder:t,"aria-label":t,onChange:e=>i(e.target.value),onFocus:e=>e.target.select(),onKeyDown:e=>{e.key===`Enter`?o(r.trim()||null):e.key===`Escape`&&o(null)},onBlur:()=>o(r.trim()||null),className:`h-7 min-w-0 flex-1 rounded-md bg-card px-2 text-[0.8125rem] text-ink outline-none ring-1 ring-ember/50`})}var NF={Item:wP,CheckboxItem:OP,Sub:TP,SubTrigger:EP,SubContent:DP,Separator:kP,Shortcut:AP},PF={Item:mP,CheckboxItem:vP,Sub:hP,SubTrigger:gP,SubContent:_P,Separator:yP,Shortcut:bP},FF={rename:`R`,pin:`P`,read:`U`,thread:`T`,archive:`A`,remove:`D`};function IF({kit:e,chat:t,sections:n,act:r}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(e.Item,{onClick:r.rename,children:[(0,K.jsx)(M,{}),W(`work.rename`),(0,K.jsx)(e.Shortcut,{children:FF.rename})]}),(0,K.jsxs)(e.Item,{onClick:r.pin,children:[t.pinned?(0,K.jsx)(di,{}):(0,K.jsx)(pi,{}),t.pinned?W(`work.unpin`):W(`work.pin`),(0,K.jsx)(e.Shortcut,{children:FF.pin})]}),(0,K.jsxs)(e.Item,{onClick:r.read,children:[t.unread?(0,K.jsx)($n,{}):(0,K.jsx)(ht,{}),t.unread?W(`work.markRead`):W(`work.markUnread`),(0,K.jsx)(e.Shortcut,{children:FF.read})]}),t.parentId?null:(0,K.jsxs)(e.Sub,{children:[(0,K.jsxs)(e.SubTrigger,{children:[(0,K.jsx)(A,{}),W(`work.moveTo`)]}),(0,K.jsxs)(e.SubContent,{className:`w-52`,children:[n.map(n=>(0,K.jsx)(e.CheckboxItem,{checked:t.sectionId===n.id,onCheckedChange:()=>r.move(n.id),children:n.name},n.id)),(0,K.jsx)(e.CheckboxItem,{checked:!t.sectionId,onCheckedChange:()=>r.move(null),children:W(`work.noSection`)}),(0,K.jsx)(e.Separator,{}),(0,K.jsxs)(e.Item,{onClick:r.newSection,children:[(0,K.jsx)(Ke,{}),W(`work.newSection`)]})]})]}),(0,K.jsxs)(e.Item,{onClick:r.newThread,children:[(0,K.jsx)(Vr,{}),W(`work.newThread`),(0,K.jsx)(e.Shortcut,{children:FF.thread})]}),(0,K.jsx)(e.Separator,{}),(0,K.jsx)(e.CheckboxItem,{checked:t.private,onCheckedChange:r.setPrivate,children:W(`work.private`)}),(0,K.jsxs)(e.Item,{onClick:r.copyLink,children:[(0,K.jsx)(E,{}),W(`work.copyLink`)]}),(0,K.jsx)(e.Separator,{}),(0,K.jsxs)(e.Item,{onClick:r.archive,children:[t.archived?(0,K.jsx)(yn,{}):(0,K.jsx)(xn,{}),t.archived?W(`work.unarchive`):W(`work.archive`),(0,K.jsx)(e.Shortcut,{children:FF.archive})]}),(0,K.jsxs)(e.Item,{variant:`destructive`,onClick:r.remove,children:[(0,K.jsx)(je,{}),W(`work.delete`),(0,K.jsx)(e.Shortcut,{children:FF.remove})]})]})}function LF({chat:e,sections:t,threads:n,threadsFolded:r,onToggleThreads:i,onNewThread:a,onNewSection:o,depth:s=0,last:c=!1}){let{chatId:l}=Ge(),u=B(),[d,f]=(0,G.useState)(!1),p=(0,G.useRef)(null),m=BS(),h=zS(),g=VS(),_=e.title||W(`work.untitled`),v=l===e.id,y={rename:()=>f(!0),pin:()=>m.mutate({id:e.id,pinned:!e.pinned}),read:()=>m.mutate({id:e.id,read:e.unread}),archive:()=>m.mutate({id:e.id,archived:!e.archived}),remove:()=>{confirm(W(`work.deleteConfirm`,{title:_}))&&g.mutate(e.id,{onSuccess:()=>{v&&u(`/work`)}})},move:t=>h.mutate({id:e.id,sectionId:t}),newSection:o,newThread:a,setPrivate:t=>h.mutate({id:e.id,private:t}),copyLink:()=>{navigator.clipboard?.writeText(new URL(`work/c/${e.id}`,document.baseURI).href)}},b=e=>{if(e.metaKey||e.ctrlKey||e.altKey||d)return;let t=e.key.toUpperCase(),n={[FF.rename]:y.rename,[FF.pin]:y.pin,[FF.read]:y.read,[FF.thread]:y.newThread,[FF.archive]:y.archive,[FF.remove]:y.remove}[t];n&&(e.preventDefault(),n())},x=n.length>0;return(0,K.jsxs)(`div`,{className:V(s>0&&`relative ml-4 pl-3`),children:[s>0?(0,K.jsx)(`span`,{"aria-hidden":`true`,className:V(`pointer-events-none absolute top-0 left-0 border-border border-l`,c?`h-4 w-2 rounded-bl-md border-b`:`bottom-0`)}):null,(0,K.jsxs)(dP,{children:[(0,K.jsxs)(fP,{render:(0,K.jsx)(`div`,{ref:p,draggable:!d,onDragStart:t=>{t.dataTransfer.setData(wF,e.id),t.dataTransfer.effectAllowed=`move`},className:V(`group/row relative flex h-8 items-center gap-1 rounded-lg pr-1 hover:bg-ink/5 has-data-popup-open:bg-ink/5`,v&&`bg-ink/10 hover:bg-ink/10`)}),children:[d?(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 px-1`,children:(0,K.jsx)(MF,{initial:e.title,placeholder:W(`work.untitled`),onDone:t=>{f(!1),t&&t!==e.title&&h.mutate({id:e.id,title:t})}})}):(0,K.jsxs)(YP,{children:[(0,K.jsxs)(XP,{delay:700,render:(0,K.jsx)(Ue,{to:`/work/c/${e.id}`,onKeyDown:b,className:`flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-lg pl-2.5 outline-none focus-visible:ring-2 focus-visible:ring-ring`}),children:[(0,K.jsx)(`span`,{className:V(`truncate`,e.unread?`font-medium text-ink`:`text-ink-2`,!e.title&&`text-ink-3`),children:_}),e.private?(0,K.jsx)(Nr,{className:`size-3 shrink-0 text-ink-4`,"aria-label":W(`work.private`)}):null]}),(0,K.jsx)(ZP,{anchor:p,side:`right`,align:`start`,sideOffset:10,className:`w-80 p-3`,children:(0,K.jsx)(RF,{chat:e})})]}),x?(0,K.jsx)(OF,{label:W(r?`work.showThreads`:`work.hideThreads`),children:(0,K.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":!r,"aria-label":W(r?`work.showThreads`:`work.hideThreads`),className:`flex h-6 shrink-0 items-center gap-0.5 rounded-md px-1 text-ink-4 hover:bg-ink/10 hover:text-ink`,children:[(0,K.jsx)(O,{className:V(`size-3.5 transition-transform`,r&&`-rotate-90`)}),r?(0,K.jsx)(`span`,{className:`text-xs tabular-nums`,children:n.length}):null]})}):null,(0,K.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover/row:flex has-data-popup-open:flex`,children:[(0,K.jsx)(OF,{label:e.pinned?W(`work.unpinChat`):W(`work.pinChat`),children:(0,K.jsx)(`button`,{type:`button`,className:DF,"aria-label":e.pinned?W(`work.unpinChat`):W(`work.pinChat`),onClick:y.pin,children:e.pinned?(0,K.jsx)(di,{className:`size-3.5`}):(0,K.jsx)(pi,{className:`size-3.5`})})}),(0,K.jsx)(OF,{label:e.archived?W(`work.unarchive`):W(`work.archiveChat`),children:(0,K.jsx)(`button`,{type:`button`,className:DF,"aria-label":e.archived?W(`work.unarchive`):W(`work.archiveChat`),onClick:y.archive,children:e.archived?(0,K.jsx)(yn,{className:`size-3.5`}):(0,K.jsx)(xn,{className:`size-3.5`})})}),(0,K.jsxs)(xP,{children:[(0,K.jsx)(SP,{className:DF,"aria-label":W(`work.more`),children:(0,K.jsx)(pt,{className:`size-3.5`})}),(0,K.jsx)(CP,{align:`start`,className:`w-60`,children:(0,K.jsx)(IF,{kit:NF,chat:e,sections:t,act:y})})]})]}),e.unread?(0,K.jsx)(`span`,{role:`img`,"aria-label":W(`work.unread`),className:`mr-1.5 size-2 shrink-0 rounded-full bg-ember group-hover/row:hidden`}):null]}),(0,K.jsx)(pP,{className:`w-60`,children:(0,K.jsx)(IF,{kit:PF,chat:e,sections:t,act:y})})]}),x&&!r?n.map((e,r)=>(0,K.jsx)(LF,{chat:e,sections:t,threads:[],threadsFolded:!0,onToggleThreads:()=>{},onNewThread:a,onNewSection:o,depth:s+1,last:r===n.length-1},e.id)):null]})}function RF({chat:e}){let[t,n]=(0,G.useState)(``),r=HS(),i=()=>{let i=t.trim();i&&(r.mutate({id:e.id,text:i}),n(``))};return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold text-ink`,children:e.title||W(`work.untitled`)}),e.last?(0,K.jsxs)(`p`,{className:`line-clamp-3 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(`span`,{className:`text-ink-2`,children:e.last.author}),` · `,e.last.text]}):(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-4`,children:W(`work.emptyChat`)}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg bg-ink/5 px-2.5 py-1.5`,children:[(0,K.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())},placeholder:W(`work.reply`),"aria-label":W(`work.reply`),className:`min-w-0 flex-1 bg-transparent text-[0.8125rem] text-ink outline-none placeholder:text-ink-4`}),(0,K.jsx)(Me,{className:`size-3.5 shrink-0 text-ink-4`})]})]})}function zF(e){return WC(e.defaultTagName??`div`,e,e)}function BF(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=BF(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function VF(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=BF(e))&&(r&&(r+=` `),r+=t);return r}var HF=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,UF=VF,WF=(e,t)=>n=>{if(t?.variants==null)return UF(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=HF(t)||HF(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return UF(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},GF=WF(`group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full`,{variants:{variant:{default:`*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80`,secondary:`*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]`,muted:`*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]`,tinted:`*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]`,outline:`*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30`,ghost:`border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50`,destructive:`*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30`}},defaultVariants:{variant:`default`}});function KF({variant:e=`default`,align:t=`start`,className:n,...r}){return(0,K.jsx)(`div`,{"data-slot":`bubble`,"data-variant":e,"data-align":t,className:uP(GF({variant:e}),n),...r})}function qF({className:e,render:t,...n}){return zF({defaultTagName:`div`,props:jC({className:uP(`w-fit max-w-full min-w-0 overflow-hidden rounded-xl border border-transparent px-3 py-2 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/50`,e)},n),render:t,state:{slot:`bubble-content`}})}var JF=WF(`group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground`,{variants:{variant:{default:``,separator:`before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border`,border:`border-b border-border pb-2`}}});function YF({className:e,variant:t=`default`,render:n,...r}){return zF({defaultTagName:`div`,props:jC({className:uP(JF({variant:t,className:e}))},r),render:n,state:{slot:`marker`,variant:t}})}function XF({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`marker-content`,className:uP(`min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function ZF({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`message-group`,className:uP(`flex min-w-0 flex-col gap-2`,e),...t})}function QF({className:e,align:t=`start`,...n}){return(0,K.jsx)(`div`,{"data-slot":`message`,"data-align":t,className:uP(`group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse`,e),...n})}function $F({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`message-avatar`,className:uP(`flex w-fit min-w-8 shrink-0 items-center justify-center self-end overflow-hidden rounded-full bg-muted group-has-data-[slot=message-footer]/message:-translate-y-8`,e),...t})}function eI({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`message-content`,className:uP(`flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end`,e),...t})}function tI({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`message-header`,className:uP(`flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0`,e),...t})}function nI({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:i}){let a=rI(iI(r,i),t);if(!n)return G.createElement(e,a);if(typeof n==`function`)return n(a,r);if(!G.isValidElement(n))return null;let o=n.props,s={...rI(a,o),ref:sI(a.ref,o.ref)};return G.cloneElement(n,s)}function rI(...e){let t={};for(let n of e){if(!n)continue;let e=n;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=t[n];t[n]=n===`className`?[i,r].filter(Boolean).join(` `):n===`style`?{...i,...r}:n===`ref`?sI(i,r):oI(n)&&typeof i==`function`&&typeof r==`function`?aI(r,i):r}}return t}function iI(e,t){let n={};for(let r of Object.keys(e)){let i=e[r],a=t?.[r]?.(i);if(a){Object.assign(n,a);continue}if(r===`slot`){n[`data-slot`]=i;continue}let o=`data-${String(r).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`;typeof i==`boolean`?n[o]=i?``:void 0:i!=null&&(n[o]=String(i))}return n}function aI(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function oI(e){return/^on[A-Z]/.test(e)}function sI(...e){let t=e.filter(Boolean);if(t.length!==0)return e=>{for(let n of t)typeof n==`function`?n(e):n&&(n.current=e)}}var cI=8,lI=64,uI=0,dI=.5,fI=180,pI=new Set([`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`,` `]),mI={start:!1,end:!1},hI={currentAnchorId:null,visibleMessageIds:[]};function gI({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return mI;let i=OI({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:i-r.scrollTop-r.clientHeight>t}}function _I({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:i,visibleMessageIds:a}){if(!e||!i)return hI;let o=i.getBoundingClientRect(),s=o.top+t+n,c=typeof IntersectionObserver>`u`,l=[],u=null;for(let t of vI(e,r)){let e=t.dataset.messageId;if(!e)continue;let n=t.dataset.scrollAnchor===`true`,r=n||c?t.getBoundingClientRect():null;(c&&r?r.bottom>s&&r.top<o.bottom:a.has(e))&&l.push(e),n&&r&&r.top<=s+dI&&(u=e)}return l.length===0&&u===null?hI:{currentAnchorId:u,visibleMessageIds:l}}function vI(e,t){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e!==t)}function yI(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t?.dataset.scrollAnchor===`true`)return t}return null}function bI(e,t){for(let n of e)if(n.dataset.scrollAnchor===`true`&&!t.has(n))return n;return null}function xI(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor===`true`&&(n+=1,n>1))return!0;return!1}function SI(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor===`true`)return n}return null}function CI({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let n of vI(e,t)){if(!n.dataset.messageId)continue;let e=n.getBoundingClientRect();if(e.bottom>r.top&&e.top<r.bottom)return n}return null}function wI({align:e,element:t,scrollMargin:n,spacer:r,viewport:i}){let a=TI(t,i),o=t.getBoundingClientRect().height,s=jI(r);if(e===`center`){let e=Math.max(0,i.clientHeight-s.start-s.end);return a-s.start-(e-o)/2-n}if(e===`end`)return a-i.clientHeight+o+s.end+n;if(e===`nearest`){let e=a+o,t=i.scrollTop+s.start,r=i.scrollTop+i.clientHeight-s.end;return a>=t&&e<=r?i.scrollTop:a<t?a-s.start-n:e-i.clientHeight+s.end+n}return a-s.start-n}function TI(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function EI(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function DI({content:e,scrollTop:t,spacer:n,viewport:r}){let i=OI({content:e,spacer:n,viewport:r});return t+r.clientHeight-i}function OI({content:e,spacer:t,viewport:n}){let r=vI(e,t),i=AI(e),a=n.getBoundingClientRect(),o=n.scrollTop,s=i.start+i.end;for(let e of r){let t=e.getBoundingClientRect();s=Math.max(s,t.bottom-a.top+o+i.end)}return s}function kI(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function AI(e){let t=window.getComputedStyle(e);return{end:NI(t.paddingBlockEnd||t.paddingBottom),start:NI(t.paddingBlockStart||t.paddingTop)}}function jI(e){let t=e?.parentElement;return t?AI(t):{end:0,start:0}}function MI(e){if(!e)return 0;let t=window.getComputedStyle(e);return NI(t.rowGap===`normal`?t.gap:t.rowGap)}function NI(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function PI(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:e=>{t(n,e)||(n=e,r.forEach(e=>e()))},subscribe:(e,t,n)=>{let i=r.size===0;return r.add(e),i&&t?.(),()=>{r.delete(e),r.size===0&&n?.()}}}}function FI(e,t){return PI(e,t)}function II(){return PI(hI,RI)}function LI(e,t){return e.start===t.start&&e.end===t.end}function RI(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((e,n)=>e===t.visibleMessageIds[n])}function zI({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:r,scrollPreviousItemPeek:i}){let a=G.useRef(e),o=G.useRef(!1),s=G.useRef(null),c=G.useRef(!1),l=G.useRef(n),u=G.useRef(0),d=G.useRef(null),f=G.useRef(0),p=G.useRef(e?`following-bottom`:`free-scrolling`),m=G.useRef(new Map),h=G.useRef(null),g=G.useRef(null),_=G.useRef(null),v=G.useRef(i),y=G.useRef(!0),b=G.useRef(null),x=G.useRef(r),S=G.useRef(null),C=G.useRef(0),w=G.useRef(0),T=G.useRef(null),E=G.useRef(null),D=G.useRef(null),O=G.useRef(null),k=G.useRef(null),A=G.useRef(null),j=G.useRef(null),M=G.useRef(null),N=G.useRef(null),P=G.useRef(new Set),F=G.useRef(new WeakSet);return D.current===null&&(D.current=FI(t===`end`||t===`last-anchor`,(e,t)=>e===t)),O.current===null&&(O.current=FI(mI,LI)),N.current===null&&(N.current=II()),a.current=e,l.current=n,x.current=r,v.current=i,{autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:k,streamingTurnRef:_,contentRef:s,defaultScrollPositionAppliedRef:c,firstItemRef:d,itemCountRef:u,lastScrollTopRef:f,messageElementsRef:m,modeRef:p,pendingScrollFrameRef:S,pendingScrollToMessageRef:h,prependRestoreRef:g,preserveScrollOnPrependRef:y,pendingDefaultScrollStore:D.current,rootRef:b,scrollEdgeThresholdRef:l,scrollMarginRef:x,scrollPreviousItemPeekRef:v,spacerGapRef:C,spacerHeightRef:w,spacerRef:T,stateFrameRef:E,stateStore:O.current,viewportRef:A,visibilityFrameRef:j,visibilityObserverRef:M,visibilityStore:N.current,visibleMessageIdsRef:P,handledScrollAnchorsRef:F}}function BI(e){e.pendingDefaultScrollStore.setSnapshot(!1)}function VI(e){e.defaultScrollPositionAppliedRef.current=!0,BI(e)}function HI({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:i,autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:s,contentRef:c,itemCountRef:l,messageElementsRef:u,modeRef:d,pendingScrollToMessageRef:f,prependRestoreRef:p,scrollMarginRef:m,scrollPreviousItemPeekRef:h,spacerGapRef:g,spacerHeightRef:_,spacerRef:v,viewportRef:y}=e,b=G.useCallback(e=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),o.current!==e&&(o.current=e,t()),e&&(s.current=window.setTimeout(()=>{s.current=null,o.current=!1,t()},fI))},[t]),x=G.useCallback(e=>{let t=v.current;if(!t)return;let n=Math.max(0,Math.ceil(e));_.current!==n&&(_.current=n,t.hidden=n===0,t.style.height=`${n}px`,t.style.marginTop=n>0?`${-g.current}px`:``)},[]),S=G.useCallback((e,{behavior:r=`auto`,autoscrolling:i=!1}={})=>{let a=y.current;if(!a)return;let o=Math.max(0,e);if(Math.abs(a.scrollTop-o)<=dI){a.scrollTop=o,t();return}i&&b(!0),a.scrollTo({top:o,behavior:r}),n()},[t,n,b]),C=G.useCallback(({behavior:e=`auto`}={})=>y.current?(x(0),i.current=null,d.current=`free-scrolling`,S(0,{behavior:e}),r(),!0):!1,[r,S,x]),w=G.useCallback(({behavior:e=`auto`}={})=>{let t=y.current;return t?(x(0),i.current=null,d.current=a.current?`following-bottom`:`free-scrolling`,S(kI(t),{autoscrolling:!0,behavior:e}),r(),!0):!1},[r,S,x]),T=G.useCallback((e,{align:t=`start`,behavior:n=`auto`,scrollMargin:a=m.current}={},{keepPreviousPeek:o=!1}={})=>{let s=c.current,l=y.current;if(!s||!l||!s.contains(e))return!1;let u=wI({align:t,element:e,scrollMargin:o?a+h.current:a,spacer:v.current,viewport:l}),f=DI({content:s,scrollTop:u,spacer:v.current,viewport:l});return x(f),p.current={element:e,viewportTop:EI(e,l)},d.current=o?`anchored-to-message`:`settling-jump`,i.current=o?e:null,S(u,{behavior:n}),r(),!0},[r,S,x]),E=G.useCallback(()=>{let e=i.current;return!e||!e.isConnected||d.current!==`anchored-to-message`?!1:T(e,{align:`start`},{keepPreviousPeek:!0})},[T]),D=G.useCallback((t,n)=>{let r=u.current.get(t);return r?(VI(e),T(r,n)?(f.current=null,!0):(f.current={messageId:t,options:n},!0)):l.current===0&&(f.current={messageId:t,options:n},VI(e),!0)},[T]);return{flushPendingScrollToMessage:G.useCallback(()=>{let t=f.current;if(!t)return!1;let n=u.current.get(t.messageId);return!n||!T(n,t.options)?!1:(f.current=null,VI(e),!0)},[T]),reanchorToAnchoredMessage:E,scrollToElement:T,scrollToEnd:w,scrollToMessage:D,scrollToStart:C}}function UI(e,t){return G.useCallback(n=>{e.current=n,n&&t()},[e,t])}function WI({autoScroll:e=!1,defaultScrollPosition:t=`end`,scrollEdgeThreshold:n=cI,scrollPreviousItemPeek:r=lI,scrollMargin:i=uI}){let a=zI({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:i,scrollPreviousItemPeek:r}),{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:c,autoscrollingTimeoutRef:l,contentRef:u,defaultScrollPositionAppliedRef:d,firstItemRef:f,itemCountRef:p,lastScrollTopRef:m,messageElementsRef:h,modeRef:g,pendingScrollFrameRef:_,pendingScrollToMessageRef:v,prependRestoreRef:y,preserveScrollOnPrependRef:b,pendingDefaultScrollStore:x,rootRef:S,scrollEdgeThresholdRef:C,scrollMarginRef:w,scrollPreviousItemPeekRef:T,spacerGapRef:E,spacerHeightRef:D,spacerRef:O,stateFrameRef:k,stateStore:A,viewportRef:j,visibilityFrameRef:M,visibilityObserverRef:N,visibilityStore:P,visibleMessageIdsRef:F,handledScrollAnchorsRef:I}=a,L=G.useRef(t);L.current!==t&&(L.current=t,d.current=!1);let R=G.useCallback(e=>{let t=S.current,n=j.current,r=[e.start&&`start`,e.end&&`end`].filter(Boolean).join(` `),i=c.current;for(let e of[t,n])e&&(r?e.setAttribute(`data-scrollable`,r):e.removeAttribute(`data-scrollable`),e.toggleAttribute(`data-autoscrolling`,i))},[]),ee=G.useCallback(e=>{let t=j.current?.scrollTop??0,n=t<m.current-dI;m.current=t,s.current&&!e.end&&g.current!==`settling-jump`&&g.current!==`anchored-to-message`?g.current=`following-bottom`:g.current===`following-bottom`&&e.end&&n&&!c.current&&(g.current=`free-scrolling`)},[]),te=G.useCallback(()=>{let e=gI({content:u.current,scrollEdgeThreshold:C.current,spacer:O.current,viewport:j.current});ee(e);let t=g.current===`following-bottom`?{...e,end:!1}:e;R(t),A.setSnapshot(t)},[ee,A,R]),ne=G.useCallback(()=>{k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,te()}))},[te]),z=G.useCallback(()=>{P.hasListeners()&&M.current===null&&(M.current=window.requestAnimationFrame(()=>{M.current=null,P.hasListeners()&&P.setSnapshot(_I({content:u.current,scrollMargin:w.current,scrollPreviousItemPeek:T.current,spacer:O.current,viewport:j.current,visibleMessageIds:F.current}))}))},[P]),{flushPendingScrollToMessage:re,reanchorToAnchoredMessage:ie,scrollToElement:B,scrollToEnd:ae,scrollToMessage:oe,scrollToStart:se}=HI({refs:a,commitScrollState:te,scheduleStateCommit:ne,scheduleVisibilitySync:z}),ce=G.useCallback(()=>{let e=y.current,t=j.current;if(!e||!t||!e.element.isConnected)return!1;let n=EI(e.element,t)-e.viewportTop;return Math.abs(n)<=dI?!1:(t.scrollTop+=n,e.viewportTop=EI(e.element,t),ne(),z(),!0)},[ne,z]),le=G.useCallback(()=>{let e=u.current,t=j.current;if(!e||!t){y.current=null;return}let n=CI({content:e,spacer:O.current,viewport:t});y.current=n?{element:n,viewportTop:EI(n,t)}:null},[]),ue=G.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,re()&&le()}))},[le,re]),de=G.useCallback(()=>{if(!t||d.current||p.current===0)return!1;let e=!1;if(t===`last-anchor`){let t=u.current,n=j.current,r=t&&n?SI(vI(t,O.current)):null;if(!t||!n||!r)e=ae({behavior:`auto`});else{let i=TI(r,n);e=OI({content:t,spacer:O.current,viewport:n})-i<=n.clientHeight?ae({behavior:`auto`}):B(r,{align:`start`},{keepPreviousPeek:!0})}}else e=t===`end`?ae({behavior:`auto`}):se({behavior:`auto`});return e?(VI(a),!0):!1},[t,B,ae,se]),V=G.useCallback(()=>{let e=u.current;if(!e)return;let t=vI(e,O.current),n=p.current,r=f.current;p.current=t.length,f.current=t[0]??null,(()=>{if(re())return;if(n===0){if(de()||t.length>0&&s.current&&ae({behavior:`auto`}))return;te(),z();return}let e=r?t.indexOf(r):-1;if(b.current&&e>0){ce();return}if(t.length>n){let e=yI(t,n);if(e){if(s.current&&g.current===`following-bottom`&&xI(t,n)){ae({behavior:`auto`});return}B(e,{align:`start`},{keepPreviousPeek:!0}),I.current.add(e);return}}if(t.length===n){let e=bI(t,I.current);if(e){B(e,{align:`start`},{keepPreviousPeek:!0}),I.current.add(e);return}}g.current===`following-bottom`&&s.current?ae({behavior:`auto`}):(te(),z())})(),le()},[de,le,te,re,ce,z,B,ae]),fe=G.useCallback(()=>{if(g.current===`following-bottom`&&s.current){ae({behavior:`auto`});return}let e=D.current;if(ie()){s.current&&e>0&&D.current===0&&ae({behavior:`auto`});return}ne(),z()},[ie,ne,z,ae]),pe=G.useCallback(()=>{let e=j.current;if(e&&P.hasListeners()){if(typeof IntersectionObserver>`u`){z();return}N.current||=new IntersectionObserver(e=>{for(let t of e){let e=t.target.dataset.messageId;e&&(t.isIntersecting?F.current.add(e):F.current.delete(e))}z()},{root:e,rootMargin:`${-(w.current+T.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]}),h.current.forEach(e=>{N.current?.observe(e)}),z()}},[z,P]),me=G.useCallback(()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),N.current?.disconnect(),N.current=null,F.current.clear(),P.setSnapshot(hI)},[P]),he=G.useCallback((e,t,n)=>{if(t){h.current.set(e,t),N.current?.observe(t),z(),v.current?.messageId===e&&ue();return}n&&h.current.get(e)===n&&(h.current.delete(e),F.current.delete(e),N.current?.unobserve(n),z())},[ue,z]),ge=G.useCallback(()=>{(g.current===`following-bottom`||g.current===`anchored-to-message`||g.current===`settling-jump`)&&(o.current=null,g.current=`free-scrolling`)},[]),_e=G.useCallback(()=>R(A.getSnapshot()),[A,R]),ve=UI(S,_e),ye=UI(j,_e),be=G.useCallback(e=>{u.current=e},[]),xe=G.useCallback(e=>{O.current=e,E.current=MI(e?.parentElement??null)},[]),Se=G.useCallback(()=>{te(),z(),le()},[le,te,z]),Ce=G.useMemo(()=>({handleContentChange:V,handleResize:fe,observeVisibility:pe,pendingDefaultScrollStore:x,preserveScrollOnPrependRef:b,scrollToEnd:ae,scrollToMessage:oe,scrollToStart:se,setContentElement:be,setRootElement:ve,setSpacerElement:xe,setViewportElement:ye,stateStore:A,syncAfterScroll:Se,unobserveVisibility:me,userScrollIntent:ge,viewportRef:j,visibilityStore:P}),[V,fe,pe,x,ae,oe,se,be,ve,xe,ye,A,Se,me,ge,P]);return G.useLayoutEffect(()=>{de()||p.current===0&&BI(a)},[de]),G.useEffect(()=>()=>{k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),N.current?.disconnect(),N.current=null},[]),G.useLayoutEffect(()=>{if(e&&g.current===`following-bottom`&&p.current>0){ae({behavior:`auto`});return}te()},[e,te,ae]),{context:Ce,registerMessage:he}}function GI(e){let t=G.useRef(e);return t.current=e,t}var KI=G.createContext(null),qI=G.createContext(null);function JI(){let e=G.useContext(KI);if(!e)throw Error(`useMessageScroller must be used within a MessageScroller.`);return e}function YI(){let e=G.useContext(qI);if(!e)throw Error(`MessageScrollerItem must be used within a MessageScroller.`);return e}function XI(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=JI();return G.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function ZI({autoScroll:e=!1,children:t,defaultScrollPosition:n=`end`,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a}){let{context:o,registerMessage:s}=WI({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a});return(0,K.jsx)(KI.Provider,{value:o,children:(0,K.jsx)(qI.Provider,{value:s,children:t})})}function QI(){let{pendingDefaultScrollStore:e}=JI();return G.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function $I({children:e,...t}){let{setRootElement:n}=JI(),r=QI();return(0,K.jsx)(`div`,{ref:n,...t,...r?{"data-pending-scroll":``}:null,children:e})}function eL({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:i,onWheel:a,preserveScrollOnPrepend:o=!0,ref:s,role:c,tabIndex:l,...u}){let{handleResize:d,preserveScrollOnPrependRef:f,setViewportElement:p,syncAfterScroll:m,userScrollIntent:h,viewportRef:g}=JI(),_=QI();f.current=o;let v=G.useCallback(e=>{p(e),sI(s)?.(e)},[s,p]);function y(e){m(),r?.(e)}function b(e){h(),a?.(e)}function x(e){h(),i?.(e)}function S(e){pI.has(e.key)&&h(),n?.(e)}return G.useEffect(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(d)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[d,g]),(0,K.jsx)(`div`,{ref:v,role:c??`region`,"aria-label":e??`Messages`,tabIndex:l??0,onKeyDown:S,onScroll:y,onTouchMove:x,onWheel:b,...u,..._?{"data-pending-scroll":``}:null,children:t})}function tL({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:i,...a}){let{handleContentChange:o,handleResize:s,setContentElement:c,setSpacerElement:l}=JI(),u=G.useRef(null),d=G.useCallback(e=>{u.current=e,c(e),sI(n)?.(e)},[n,c]);return G.useLayoutEffect(()=>{let e=u.current;if(!e||(o(),typeof MutationObserver>`u`))return;let t=new MutationObserver(()=>{o()});return t.observe(e,{childList:!0}),()=>t.disconnect()},[o]),G.useEffect(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(s)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[s]),(0,K.jsxs)(`div`,{ref:d,role:r??`log`,"aria-relevant":e??`additions`,...a,children:[t,(0,K.jsx)(`div`,{ref:l,"aria-hidden":`true`,"data-message-scroller-spacer":``,hidden:!0,className:i})]})}function nL({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let i=YI(),a=G.useRef(null),o=G.useCallback(n=>{let r=a.current;a.current=n,e&&i(e,n,r),sI(t)?.(n)},[e,t,i]);return(0,K.jsx)(`div`,{ref:o,"data-message-id":e,"data-scroll-anchor":n?`true`:`false`,...r})}function rL({behavior:e=`smooth`,children:t,direction:n=`end`,onClick:r,render:i,tabIndex:a,type:o=`button`,...s}){let{scrollToEnd:c,scrollToStart:l,stateStore:u}=JI(),d=GI(r),f=G.useCallback(e=>u.subscribe(e),[u]),p=G.useCallback(()=>{let e=u.getSnapshot();return n===`start`?e.start:e.end},[n,u]),m=G.useSyncExternalStore(f,p,p),h=G.useCallback(t=>{m&&(d.current?.(t),t.defaultPrevented||(t.currentTarget.blur(),n===`start`?l({behavior:e}):c({behavior:e})))},[e,n,m,d,c,l]);return nI({defaultTagName:`button`,props:rI({type:o,inert:!m,tabIndex:m?a:-1,children:t??(0,K.jsxs)(`span`,{children:[`Scroll to `,n]}),onClick:h},s),render:i,state:{active:m,direction:n},stateAttributesMapping:{active:e=>({"data-active":e?`true`:`false`})}})}var iL={Provider:ZI,Root:$I,Viewport:eL,Content:tL,Item:nL,Button:rL},aL=G.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=yT({disabled:i,focusableWhenDisabled:a,native:o});return WC(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),oL=WF(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function sL({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,K.jsx)(aL,{"data-slot":`button`,className:uP(oL({variant:t,size:n,className:e})),...r})}function cL(e){return(0,K.jsx)(iL.Provider,{...e})}function lL({className:e,...t}){return(0,K.jsx)(iL.Root,{"data-slot":`message-scroller`,className:uP(`group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden`,e),...t})}function uL({className:e,...t}){return(0,K.jsx)(iL.Viewport,{"data-slot":`message-scroller-viewport`,className:uP(`size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent data-pending-scroll:invisible`,e),...t})}function dL({className:e,...t}){return(0,K.jsx)(iL.Content,{"data-slot":`message-scroller-content`,className:uP(`flex h-max min-h-full flex-col gap-6`,e),...t})}function fL({className:e,scrollAnchor:t=!1,...n}){return(0,K.jsx)(iL.Item,{"data-slot":`message-scroller-item`,scrollAnchor:t,className:uP(`min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]`,e),...n})}function pL({direction:e=`end`,className:t,children:n,render:r,variant:i=`secondary`,size:a=`icon-sm`,...o}){return(0,K.jsx)(iL.Button,{"data-slot":`message-scroller-button`,"data-direction":e,"data-variant":i,"data-size":a,direction:e,className:uP(`absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180`,t),render:r??(0,K.jsx)(sL,{variant:i,size:a}),...o,children:n??(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ke,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:e===`end`?`Scroll to end`:`Scroll to start`})]})})}var mL=new Map,hL={},gL=new Set;function _L(){hL=Object.assign({},...mL.values());for(let e of gL)e()}function vL(){return(0,G.useSyncExternalStore)(e=>(gL.add(e),()=>gL.delete(e)),()=>hL)}function yL(){for(let e of mL.values())e.onChanged?.()}function bL(e){let t=(0,G.useId)(),n=(0,G.useRef)(e);n.current=e;let{onChanged:r,...i}=e,a=JSON.stringify(i);(0,G.useEffect)(()=>{mL.set(t,{...JSON.parse(a),onChanged:()=>n.current.onChanged?.()}),_L()},[t,a]),(0,G.useEffect)(()=>()=>{mL.delete(t),_L()},[t])}function xL(){let e=document.getElementById(f0);if(!e)return;let t=e.getBoundingClientRect().top;for(let n of e.querySelectorAll(`[data-assist-section]`)){let e=n.getBoundingClientRect();if(e.bottom>t+40&&e.top<window.innerHeight*.6)return n.dataset.assistSection||void 0}}function SL(){let{title:e,hello:t,about:n,placeholder:r,suggestions:i,compact:a,ownInput:o,onChanged:s,...c}=hL,l=Y1().map(e=>e.label),u=window.location.pathname,d=u.startsWith(Le)?u.slice(Le.length)||`/`:u,f=xL(),p=(e,t)=>e&&e.length>t?`${e.slice(0,t-1)}…`:e;return{route:`${d}${window.location.search}`.slice(0,400),...l.length?{title:p(l.join(` / `),200)}:{},...f?{view:p(f,200)}:{},...c.open?{open:{kind:c.open.kind.slice(0,60),...c.open.id?{id:c.open.id.slice(0,120)}:{},label:p(c.open.label,200)??``}}:{},...c.selection?{selection:c.selection.slice(0,100).map(e=>e.slice(0,120))}:{},...c.summary?{summary:p(c.summary,2e3)}:{},...c.fields?{fields:c.fields.slice(0,60).map(e=>({id:e.id.slice(0,120),label:p(e.label,200)??``,value:e.value}))}:{},...c.plugin?{plugin:c.plugin}:{}}}var CL=[`text`,`image`,`video`,`speech`,`listening`],wL={text:[`classifier`,`low`,`standard`,`high`],image:[`image`],video:[`video`],speech:[`speech`],listening:[`audio`]},TL={classifier:{needs:[`json`],context:32e3,blocks:[]},low:{needs:[`tools`,`json`,`vision`],context:64e3,blocks:[]},standard:{needs:[`tools`,`json`,`vision`],context:128e3,blocks:[`tools`]},high:{needs:[`tools`,`json`,`vision`,`reasoning`],context:2e5,blocks:[`tools`]}},EL=`credits`,DL=`${EL}:`;function OL(e){return e===`credits`||!!e?.startsWith(DL)}function kL(e){return e?.startsWith(DL)&&e.slice(DL.length)||null}function AL(e){return e?`${DL}${e}`:EL}function jL(e){return e===`transcription`?`listening`:e}var ML=[`openai`,`anthropic`,`google`,`fal`,`elevenlabs`,`replicate`,`gateway`],NL={en:{"about.openai":`GPT models, GPT Image and voices.`,fast:`fast`,thorough:`thorough`,versatile:`versatile`,lowCost:`low cost`,fastLowCost:`fast, low cost`,"about.anthropic":`The Claude models.`,strongest:`strongest`,"about.google":`Gemini, Veo for video and voices – one key from AI Studio.`,fastEditsPhotos:`fast, edits photos`,bestQuality:`best quality`,withSound:`with sound`,"about.fal":`Hundreds of image, video and audio models with one key: FLUX, Recraft, Veo, Luma, MiniMax.`,highQuality:`high quality`,graphicsLogosTextIn:`graphics, logos, text in images`,photorealistic:`photorealistic`,"about.elevenlabs":`Natural voices in many languages and accurate transcripts.`,naturalManyLanguages:`natural, many languages`,expressive:`expressive`,veryAccurate:`very accurate`,"about.replicate":`Open image and video models, billed per run.`,"about.gateway":`One key for many providers’ models, billed by Vercel.`},de:{"about.openai":`GPT-Modelle, GPT Image und Stimmen.`,fast:`schnell`,thorough:`gründlich`,versatile:`vielseitig`,lowCost:`günstig`,fastLowCost:`schnell, günstig`,"about.anthropic":`Die Claude-Modelle.`,strongest:`am stärksten`,"about.google":`Gemini, Veo für Videos und Stimmen – ein Key aus dem AI Studio.`,fastEditsPhotos:`schnell, bearbeitet Fotos`,bestQuality:`beste Qualität`,withSound:`mit Ton`,"about.fal":`Hunderte Bild-, Video- und Audio-Modelle mit einem Key: FLUX, Recraft, Veo, Luma, MiniMax.`,highQuality:`hohe Qualität`,graphicsLogosTextIn:`Grafiken, Logos, Text im Bild`,photorealistic:`fotorealistisch`,"about.elevenlabs":`Natürliche Stimmen in vielen Sprachen und genaue Transkripte.`,naturalManyLanguages:`natürlich, viele Sprachen`,expressive:`ausdrucksstark`,veryAccurate:`sehr genau`,"about.replicate":`Offene Bild- und Video-Modelle, abgerechnet pro Lauf.`,"about.gateway":`Ein Key für die Modelle vieler Anbieter, abgerechnet bei Vercel.`}},PL=(e,t)=>$t(NL,e,t),FL=[{id:`openai`,name:`OpenAI`,about:`about.openai`,keyUrl:`https://platform.openai.com/api-keys`,keyPlaceholder:`sk-…`,text:{classifier:`openai:gpt-5.4-mini`,low:`openai:gpt-5.4-mini`,standard:`openai:gpt-5.5`,high:`openai:gpt-5.5`},models:{text:[{ref:`openai:gpt-5.4-mini`,label:`GPT-5.4 mini`,note:`fast`},{ref:`openai:gpt-5.5`,label:`GPT-5.5`,note:`thorough`}],image:[{ref:`openai:gpt-image-2`,label:`GPT Image 2`,note:`versatile`},{ref:`openai:gpt-image-1-mini`,label:`GPT Image 1 mini`,note:`lowCost`}],speech:[{ref:`openai:gpt-4o-mini-tts`,label:`GPT-4o mini TTS`,note:`lowCost`}],listening:[{ref:`openai:gpt-4o-mini-transcribe`,label:`GPT-4o mini Transcribe`,note:`fastLowCost`},{ref:`openai:whisper-1`,label:`Whisper`}]}},{id:`anthropic`,name:`Anthropic`,about:`about.anthropic`,keyUrl:`https://console.anthropic.com/settings/keys`,keyPlaceholder:`sk-ant-…`,text:{classifier:`anthropic:claude-haiku-4-5`,low:`anthropic:claude-haiku-4-5`,standard:`anthropic:claude-sonnet-5-5`,high:`anthropic:claude-opus-5-5`},models:{text:[{ref:`anthropic:claude-haiku-4-5`,label:`Claude Haiku 4.5`,note:`fast`},{ref:`anthropic:claude-sonnet-5-5`,label:`Claude Sonnet 5.5`},{ref:`anthropic:claude-opus-5-5`,label:`Claude Opus 5.5`,note:`strongest`}]}},{id:`google`,name:`Google Gemini`,about:`about.google`,keyUrl:`https://aistudio.google.com/apikey`,keyPlaceholder:`AIza…`,text:{classifier:`google:gemini-flash-lite-latest`,low:`google:gemini-flash-latest`,standard:`google:gemini-pro-latest`,high:`google:gemini-pro-latest`},models:{text:[{ref:`google:gemini-flash-lite-latest`,label:`Gemini Flash-Lite`,note:`lowCost`},{ref:`google:gemini-flash-latest`,label:`Gemini Flash`},{ref:`google:gemini-pro-latest`,label:`Gemini Pro`,note:`thorough`}],image:[{ref:`google:gemini-3.1-flash-image-preview`,label:`Gemini 3.1 Flash Image`,note:`fastEditsPhotos`},{ref:`google:gemini-3-pro-image-preview`,label:`Gemini 3 Pro Image`,note:`bestQuality`}],video:[{ref:`google:veo-3.1-fast-generate-preview`,label:`Veo 3.1 Fast`,note:`withSound`},{ref:`google:veo-3.1-generate-preview`,label:`Veo 3.1`,note:`bestQuality`}],speech:[{ref:`google:gemini-3.8-flash-tts`,label:`Gemini Flash TTS`}],listening:[{ref:`google:gemini-flash-lite-latest`,label:`Gemini Flash-Lite`}]}},{id:`fal`,name:`fal.ai`,about:`about.fal`,keyUrl:`https://fal.ai/dashboard/keys`,keyPlaceholder:`xxxxxxxx-…:…`,models:{image:[{ref:`fal:fal-ai/flux/schnell`,label:`FLUX.1 schnell`,note:`fastLowCost`},{ref:`fal:fal-ai/flux-pro/v1.1`,label:`FLUX 1.1 pro`,note:`highQuality`},{ref:`fal:fal-ai/recraft/v3/text-to-image`,label:`Recraft V3`,note:`graphicsLogosTextIn`},{ref:`fal:fal-ai/imagen4/preview`,label:`Imagen 4`,note:`photorealistic`}],video:[{ref:`fal:veo3/fast`,label:`Veo 3 Fast`,note:`withSound`},{ref:`fal:luma-ray-2-flash`,label:`Luma Ray 2 Flash`,note:`fast`},{ref:`fal:minimax-video`,label:`MiniMax Hailuo`}],speech:[{ref:`fal:fal-ai/minimax/speech-02-turbo`,label:`MiniMax Speech-02 Turbo`,note:`fast`},{ref:`fal:fal-ai/minimax/speech-02-hd`,label:`MiniMax Speech-02 HD`}],listening:[{ref:`fal:wizper`,label:`Wizper`,note:`fast`},{ref:`fal:whisper`,label:`Whisper`}]}},{id:`elevenlabs`,name:`ElevenLabs`,about:`about.elevenlabs`,keyUrl:`https://elevenlabs.io/app/settings/api-keys`,keyPlaceholder:`sk_…`,models:{speech:[{ref:`elevenlabs:eleven_multilingual_v2`,label:`Multilingual v2`,note:`naturalManyLanguages`},{ref:`elevenlabs:eleven_flash_v2_5`,label:`Flash v2.5`,note:`fastLowCost`},{ref:`elevenlabs:eleven_v3`,label:`Eleven v3`,note:`expressive`}],listening:[{ref:`elevenlabs:scribe_v2`,label:`Scribe v2`,note:`veryAccurate`}]}},{id:`replicate`,name:`Replicate`,about:`about.replicate`,keyUrl:`https://replicate.com/account/api-tokens`,keyPlaceholder:`r8_…`,models:{image:[{ref:`replicate:black-forest-labs/flux-schnell`,label:`FLUX.1 schnell`,note:`fastLowCost`},{ref:`replicate:black-forest-labs/flux-1.1-pro`,label:`FLUX 1.1 pro`},{ref:`replicate:recraft-ai/recraft-v3`,label:`Recraft V3`}],video:[{ref:`replicate:minimax/video-01`,label:`MiniMax Video-01`}]}},{id:`gateway`,name:`Vercel AI Gateway`,about:`about.gateway`,keyUrl:`https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Fapi-keys`,keyPlaceholder:`vck_…`,text:{classifier:`deepseek/deepseek-v4.1-flash`,low:`deepseek/deepseek-v4.1-flash`,standard:`deepseek/deepseek-v4.1-flash`,high:`moonshotai/kimi-k3`},models:{text:[{ref:`deepseek/deepseek-v4.1-flash`,label:`DeepSeek V4.1 Flash`,note:`fastLowCost`},{ref:`moonshotai/kimi-k3`,label:`Kimi K3`},{ref:`zai/glm-5.3`,label:`GLM 5.3`},{ref:`anthropic/claude-haiku-4.5`,label:`Claude Haiku 4.5`,note:`fast`},{ref:`anthropic/claude-sonnet-5.5`,label:`Claude Sonnet 5.5`},{ref:`openai/gpt-5.5`,label:`GPT-5.5`},{ref:`google/gemini-3.5-flash`,label:`Gemini 3.5 Flash`}],image:[{ref:`google/gemini-3.1-flash-image`,label:`Gemini 3.1 Flash Image`}],video:[{ref:`google/veo-3.1-fast-generate-001`,label:`Veo 3.1 Fast`,note:`withSound`}],speech:[{ref:`google/gemini-3.8-flash-tts`,label:`Gemini Flash TTS`}],listening:[{ref:`google/gemini-3.5-flash-lite`,label:`Gemini 3.5 Flash-Lite`}]}}];function IL(e){return FL.find(t=>t.id===e)??null}function LL(e){if(OL(e))return null;let t=/^([a-z]+):/.exec(e)?.[1];return t?ML.includes(t)?t:null:e?.includes(`/`)?`gateway`:null}function RL(e){for(let t of FL)for(let n of Object.values(t.models)){let t=n?.find(t=>t.ref===e);if(t)return t.label}return e.replace(/^[a-z]+:/,``)}function zL(e){let t=window.engentyDesktop;t?t.open(e):window.open(e,`_blank`,`noopener`)}var BL=FL.filter(e=>e.text);function VL({models:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`local.keys`)}),(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:W(`local.keysHint`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[BL.map(t=>(0,K.jsx)(UL,{provider:t,stored:!!e.keys[t.id]},t.id)),(0,K.jsx)(WL,{url:e.ollamaUrl})]}),(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:W(`local.modelsLater`)})]})}function HL(e){let t=R();return ot({mutationFn:t=>H.post(e,t),onSuccess:()=>t.invalidateQueries({queryKey:[`me`]})})}function UL({provider:e,stored:t}){let n=R(),[r,i]=(0,G.useState)(``),a=HL(`/api/studio/local/keys/${e.id}`),o=()=>a.mutate(r.trim()?{key:r.trim()}:{},{onSuccess:e=>e.ok?i(``):void 0}),s=ot({mutationFn:()=>H.put(`/api/studio/local/models`,{keys:{[e.id]:``}}),onSuccess:async()=>{a.reset(),await n.invalidateQueries({queryKey:[`me`]})}});return(0,K.jsx)(KL,{label:e.name,sub:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>zL(e.keyUrl),className:`inline-flex items-center gap-1 text-left hover:text-ink-2 hover:underline`,children:[W(`local.keyGet`),` `,(0,K.jsx)(h,{className:`size-3`})]}),input:(0,K.jsx)(k,{type:`password`,autoComplete:`off`,className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,placeholder:t?W(`local.keySet`):e.keyPlaceholder,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r.trim()&&o()}}),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{variant:`secondary`,busy:a.isPending,disabled:!t&&!r.trim(),onClick:o,children:W(`local.test`)}),t?(0,K.jsx)(x,{variant:`ghost`,size:`sm`,busy:s.isPending,onClick:()=>s.mutate(),children:W(`local.keyRemove`)}):null]}),said:GL(a,t=>LL(t)===e.id)})}function WL({url:e}){let[t,n]=(0,G.useState)(e),r=HL(`/api/studio/local/ollama`);return(0,K.jsx)(KL,{label:`Ollama`,sub:W(`local.ollamaWhere`),input:(0,K.jsx)(k,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:t,onChange:e=>n(e.target.value)}),actions:(0,K.jsx)(x,{variant:`secondary`,busy:r.isPending,disabled:!t.trim(),onClick:()=>r.mutate({url:t.trim()}),children:W(`local.test`)}),said:GL(r,e=>e.startsWith(`ollama:`))})}function GL(e,t){if(e.isError)return{ok:!1,text:e.error.message};let n=e.data;if(!n)return null;if(!n.ok)return{ok:!1,text:n.message??W(`models.keyBad`)};if(!n.text)return{ok:!0,text:W(`local.keyWorksPlain`)};let r=RL(n.text);return{ok:!0,text:W(t(n.text)?`local.keyWorks`:`local.keyWorksOther`,{model:r})}}function KL({label:e,sub:t,input:n,actions:r,said:i}){return(0,K.jsxs)(`div`,{className:`grid gap-x-3 gap-y-1.5 border-border-soft border-t py-3 sm:grid-cols-[10rem_minmax(0,1fr)]`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[0.875rem] text-ink-2`,children:e}),(0,K.jsx)(`div`,{className:`text-[0.75rem] text-ink-4`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n,r]}),i?(0,K.jsxs)(`p`,{className:V(`flex items-start gap-1.5 text-[0.8125rem]`,i.ok?`text-moss`:`text-rose`),children:[i.ok?(0,K.jsx)(o,{className:`mt-0.5 size-3.5 shrink-0`,strokeWidth:3}):null,i.text]}):null]})]})}function qL(e){try{return new URL(e).host}catch{return e}}var JL=e=>`${ce()}/w/${e.shareToken}`;function YL(e,t,n){if(!e.published)return{kind:`draft`};if(t.mode===`managed`)return{kind:`live`,url:JL(e),runs:e.publishedVersion??0,notes:0,cloud:!1};if(!t.account||n===null)return{kind:`here`};if(n===void 0)return{kind:`unknown`};let{copy:r,error:i}=n,a=r?.publishedVersion??null,o=r&&a!==null?r.shareUrl:null;return i?.again?{kind:`sending`,url:o,runs:a,again:i.again}:i?{kind:`missing`,url:o,runs:a,why:i.message}:!r||r.version<(e.publishedVersion??0)?{kind:`missing`,url:o,runs:a,why:W(`cloud.notSent`)}:!r.runnable||!o||a===null?{kind:`missing`,url:o,runs:a,why:`${W(`cloud.notRunnable`,{v:r.version})} ${a===null?W(`cloud.nothingRuns`):W(`cloud.keepsRunning`,{v:a})}`}:{kind:`live`,url:o,runs:a,notes:r.problems.filter(e=>!e.blocking).length,cloud:!0}}function XL(e){return e.kind===`live`||e.kind===`sending`||e.kind===`missing`?e.url:null}function ZL({where:e,me:t,version:n}){let r=qL(t.account?.cloudUrl??``),i=`size-3.5`;switch(e.kind){case`draft`:return null;case`unknown`:return(0,K.jsx)(v,{tone:`live`,children:W(`home.live`)});case`here`:return(0,K.jsx)(v,{icon:(0,K.jsx)(Cr,{className:i}),title:W(`where.hereHint`),children:n?W(`where.hereVersion`,{v:n}):W(`where.here`)});case`live`:{let t=n?W(`editor.published`,{v:e.runs}):W(`home.live`),a=e.notes===1?W(`where.note`):e.notes>1?W(`where.notes`,{n:e.notes}):null;return(0,K.jsx)(v,{tone:`live`,icon:e.cloud?(0,K.jsx)(qn,{className:i}):void 0,title:e.cloud?W(`where.liveHint`,{host:r}):void 0,children:a?`${t} · ${a}`:t})}case`sending`:return(0,K.jsx)(v,{tone:`warn`,icon:(0,K.jsx)(ne,{className:i}),title:W(`cloud.again`,{when:new Intl.DateTimeFormat(Xt,{timeStyle:`short`}).format(new Date(e.again))}),children:W(`where.sending`)});case`missing`:return(0,K.jsx)(v,{tone:`warn`,icon:(0,K.jsx)(Xe,{className:i}),title:e.why,children:e.runs===null?W(`where.missing`):W(`editor.published`,{v:e.runs})})}}var QL={extra:!1,web:!0,pluginsOff:[]};function $L(e){return{...e.extra?{extra:!0}:{},...e.web?{}:{web:!1},...e.pluginsOff.length?{pluginsOff:e.pluginsOff}:{}}}function eR(e,t){return`${XL(YL(e,t,e.cloud))??JL(e)}/chat`}function tR(e){let t=At().data;return(Je({queryKey:[`wizards`,e,!!t?.account],queryFn:()=>H.get(`/api/studio/spaces/${e}/wizards`),enabled:!!e}).data??[]).filter(e=>e.published).sort((e,t)=>t.updatedAt>e.updatedAt?1:-1)}function nR(e,t,n=QL){let r=At().data,[i,a]=(0,G.useState)(n),o=FS(),s=Je({queryKey:[`work-composer`],queryFn:()=>H.get(`/api/studio/work/composer`)}).data,c=tR(e),l=s?.plugins??[],u=e=>a(t=>({...t,...e})),d=[[{icon:(0,K.jsx)(rr,{}),label:W(`work.files.fromSpace`),onSelect:t}],[...l.length?[{kind:`menu`,icon:(0,K.jsx)(at,{}),label:W(`work.composer.plugins`),choices:l.map(e=>({id:e.id,label:e.name,on:!i.pluginsOff.includes(e.id),onSelect:()=>u({pluginsOff:i.pluginsOff.includes(e.id)?i.pluginsOff.filter(t=>t!==e.id):[...i.pluginsOff,e.id]})}))}]:[],...c.length&&r?[{kind:`menu`,icon:(0,K.jsx)(He,{}),label:W(`work.home.wizards`),choices:c.map(e=>({id:e.id,label:e.title,hint:W(`work.home.wizardOpen`),onSelect:()=>zL(eR(e,r))}))}]:[]],s?.web?[{kind:`toggle`,icon:(0,K.jsx)(dt,{}),label:W(`work.composer.web`),on:i.web,onChange:e=>u({web:e})}]:[]];return{body:$L({...i,web:i.web||!s?.web}),choice:i,chooser:{on:i.extra,onChange:e=>u({extra:e}),...o},plus:d}}var rR=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),iR=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,aR=e=>e?`$${e<.01?e.toFixed(4):e.toFixed(3)}`:`$0`,oR=e=>Math.round(e/4),sR=(e,t)=>W(`assistant.tokens`,{input:rR(e),output:rR(t),total:rR(e+t)});function cR({steps:e}){return e?.length?(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.map(e=>(0,K.jsxs)(`details`,{className:`group text-[0.75rem] text-ink-4`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer list-none truncate hover:text-ink-3`,children:[W(`assistant.step`,{n:e.step}),e.model,sR(e.inputTokens,e.outputTokens),iR(e.ms),e.costUsd?aR(e.costUsd):null].filter(Boolean).join(` · `)}),(0,K.jsxs)(`div`,{className:`mt-1 rounded-lg bg-paper-2 px-3 py-2 font-mono text-[0.6875rem] text-ink-3`,children:[W(`assistant.stepTools`),`: `,e.tools.length?e.tools.join(`, `):`–`,e.cachedInputTokens?` · cache ${rR(e.cachedInputTokens)}`:``]})]},e.step))}):null}function lR(e){if(typeof e!=`string`)return JSON.stringify(e,null,2)??``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function uR({calls:e}){return e?.length?(0,K.jsx)(`div`,{className:`mb-1.5 flex flex-col gap-1`,children:e.map(e=>(0,K.jsxs)(`details`,{className:`rounded-lg bg-paper-2 text-[0.75rem]`,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer px-2.5 py-1 font-mono text-ink-3 hover:text-ink`,children:[e.toolCallName,e.result===void 0?` …`:``]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 pb-2`,children:[(0,K.jsx)(`span`,{className:`text-ink-4`,children:W(`assistant.args`)}),(0,K.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-[0.6875rem] text-ink-2`,children:lR(e.args)}),e.result===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-ink-4`,children:W(`assistant.result`)}),(0,K.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-[0.6875rem] text-ink-2`,children:lR(e.result)})]})]})]},e.toolCallId))}):null}function dR(e){let t=[];for(let n of e)n.role===`user`&&!n.signal?t.push([]):n.steps?.length&&(t.length||t.push([]),t[t.length-1].push(...n.steps));let n=e=>({input:e.reduce((e,t)=>e+t.inputTokens,0),output:e.reduce((e,t)=>e+t.outputTokens,0),ms:e.reduce((e,t)=>e+t.ms,0),cost:e.reduce((e,t)=>e+t.costUsd,0),steps:e.length}),r=t.flat(),i=r.at(-1);return{last:n([...t].reverse().find(e=>e.length)??[]),thread:n(r),lastStep:i,context:i?.inputTokens??0,window:i?.window??null}}function fR({ratio:e}){let t=2*Math.PI*7;return(0,K.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:`size-[18px] -rotate-90`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`9`,cy:`9`,r:7,fill:`none`,strokeWidth:`2.5`,className:`stroke-paper-3`}),(0,K.jsx)(`circle`,{cx:`9`,cy:`9`,r:7,fill:`none`,strokeWidth:`2.5`,strokeDasharray:`${Math.min(1,e)*t} ${t}`,strokeLinecap:`round`,className:e>.8?`stroke-rose`:`stroke-ember`})]})}function pR({messages:e,narrow:t}){let[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null);t0(i,n,()=>r(!1));let a=dR(e);if(!a.lastStep)return null;let o=a.window?a.context/a.window:0,s=(e,t)=>(0,K.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,K.jsx)(`span`,{className:`font-mono tabular-nums`,children:t})]});return(0,K.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":n,title:W(`assistant.usage`),onClick:()=>r(e=>!e),className:`flex h-8 items-center gap-1.5 rounded-lg px-1.5 font-mono text-[0.75rem] text-ink-3 tabular-nums transition hover:bg-accent hover:text-ink`,children:[t?null:(0,K.jsxs)(`span`,{className:`whitespace-nowrap max-sm:hidden`,children:[rR(a.last.input+a.last.output),` / `,rR(a.thread.input+a.thread.output)]}),(0,K.jsx)(fR,{ratio:o})]}),n?(0,K.jsxs)(`div`,{role:`dialog`,"aria-label":W(`assistant.window`),className:`absolute top-9 right-0 z-50 flex w-72 animate-rise flex-col gap-1.5 rounded-xl bg-card p-3 text-[0.8125rem] shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:W(`assistant.window`)}),(0,K.jsxs)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:[rR(a.context),` /`,` `,a.window?`${rR(a.window)} (${Math.round(o*100)}%)`:`?`]})]}),(0,K.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-paper-2`,children:(0,K.jsx)(`span`,{className:V(`block h-full rounded-full`,o>.8?`bg-rose`:`bg-ember`),style:{width:`${Math.min(100,o*100)}%`}})}),(0,K.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:a.lastStep.model}),(0,K.jsx)(`span`,{className:`mt-1 font-medium text-[0.75rem] text-ink-3`,children:W(`assistant.lastTurn`)}),s(W(`assistant.promptTokens`),rR(a.last.input)),s(W(`assistant.answerTokens`),rR(a.last.output)),s(W(`assistant.duration`),iR(a.last.ms)),s(W(`assistant.cost`),aR(a.last.cost)),(0,K.jsx)(`span`,{className:`mt-1 font-medium text-[0.75rem] text-ink-3`,children:W(`assistant.wholeChat`)}),s(W(`assistant.promptTokens`),rR(a.thread.input)),s(W(`assistant.answerTokens`),rR(a.thread.output)),s(W(`assistant.steps`),String(a.thread.steps)),s(W(`assistant.cost`),aR(a.thread.cost))]}):null]})}function mR(e,t){return JSON.stringify({messages:e.map(({previews:e,...t})=>t),turns:t},null,2)}function hR({messages:e,turns:t}){let[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(!1),1500);return()=>clearTimeout(e)},[n]),(0,K.jsx)(re,{label:W(n?`assistant.copied`:`assistant.copyThread`),onClick:()=>void navigator.clipboard.writeText(mR(e,t)).then(()=>r(!0)),className:`size-8`,children:n?(0,K.jsx)(o,{className:`size-4`}):(0,K.jsx)(_,{className:`size-4`})})}function gR({prompt:e}){let t=e.history.reduce((e,t)=>e+t.chars,0),n=e.tools.reduce((e,t)=>e+t.chars,0),r=[{label:W(`assistant.system`),chars:e.system.length},{label:W(`assistant.context`),chars:e.context.length},{label:W(`assistant.history`,{n:e.history.length}),chars:t},{label:W(`assistant.tools`,{n:e.tools.length}),chars:n}],i=r.reduce((e,t)=>e+t.chars,0)||1,a=(e,t)=>(0,K.jsxs)(`details`,{className:`rounded-lg bg-paper-2`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer px-3 py-2 font-medium text-[0.8125rem]`,children:e}),(0,K.jsx)(`div`,{className:`px-3 pb-3`,children:t})]});return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 text-[0.8125rem]`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-ink-3`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e.model}),(0,K.jsx)(`span`,{children:W(`assistant.estimate`,{tokens:rR(oR(i))})})]}),(0,K.jsx)(`div`,{className:`flex h-2 overflow-hidden rounded-full bg-paper-2`,children:r.map((e,t)=>(0,K.jsx)(`span`,{title:e.label,className:[`bg-ember`,`bg-ink-3`,`bg-ember-strong`,`bg-ink-4`][t],style:{width:`${e.chars/i*100}%`}},e.label))}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:r.map(e=>(0,K.jsxs)(`li`,{className:`flex justify-between gap-4`,children:[(0,K.jsx)(`span`,{children:e.label}),(0,K.jsxs)(`span`,{className:`font-mono text-ink-3 tabular-nums`,children:[rR(oR(e.chars)),` · `,Math.round(e.chars/i*100),`%`]})]},e.label))}),a(W(`assistant.system`),(0,K.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap font-mono text-[0.6875rem] text-ink-2`,children:e.system})),a(W(`assistant.context`),(0,K.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap font-mono text-[0.6875rem] text-ink-2`,children:e.context})),a(W(`assistant.tools`,{n:e.tools.length}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5 font-mono text-[0.6875rem]`,children:e.tools.map(e=>(0,K.jsxs)(`li`,{className:`flex justify-between gap-4`,children:[(0,K.jsx)(`span`,{children:e.name}),(0,K.jsx)(`span`,{className:`text-ink-3`,children:rR(oR(e.chars))})]},e.name))}))]})}function _R({turn:e}){let t=e.endedAt??e.events.at(-1)?.at??e.startedAt,n=Math.max(1,t-e.startedAt),r=[],i=new Map;for(let t of e.events){let e=t.data;if(t.event===`tool_call`)i.set(e.toolCallId,{name:e.toolCallName,at:t.at});else if(t.event===`tool_result`&&i.has(e.toolCallId)){let n=i.get(e.toolCallId);r.push({label:n.name,from:n.at,to:t.at,kind:`tool`})}else t.event===`step`&&r.push({label:`${W(`assistant.step`,{n:e.step})} · ${sR(e.inputTokens,e.outputTokens)}`,from:t.at-e.ms,to:t.at,kind:`step`})}return r.sort((e,t)=>e.from-t.from),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between gap-3 text-[0.8125rem]`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.message}),(0,K.jsx)(`span`,{className:`shrink-0 text-ink-3 tabular-nums`,children:iR(n)})]}),r.map((t,r)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[0.75rem]`,children:[(0,K.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-ink-3`,children:t.label}),(0,K.jsx)(`span`,{className:`relative h-3 flex-1 rounded bg-paper-2`,children:(0,K.jsx)(`span`,{className:V(`absolute inset-y-0 rounded`,t.kind===`step`?`bg-ember`:`bg-ink-4`),style:{left:`${Math.max(0,t.from-e.startedAt)/n*100}%`,width:`${Math.max(1,(t.to-t.from)/n*100)}%`}})}),(0,K.jsx)(`span`,{className:`w-14 shrink-0 text-right text-ink-4 tabular-nums`,children:iR(t.to-t.from)})]},`${t.label}-${r}`))]})}function vR({open:e,onClose:t,turns:n,messages:r,file:i=`goose`}){let[a,o]=(0,G.useState)(`timeline`),s=n.at(-1);return(0,K.jsx)(z,{open:e,onClose:t,title:W(`assistant.turns`),wide:!0,height:`tall`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(Oe,{value:a,onChange:o,options:[{id:`timeline`,label:W(`assistant.turnsTimeline`)},{id:`prompt`,label:W(`assistant.turnsPrompt`)},{id:`events`,label:W(`assistant.turnsEvents`)}]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(hR,{messages:r,turns:n}),(0,K.jsx)(re,{label:W(`assistant.download`),onClick:()=>{let e=n.flatMap(e=>e.events.map(t=>JSON.stringify({turn:e.id,...t}))),t=new Blob([`${e.join(`
91
- `)}\n`],{type:`application/x-ndjson`}),r=document.createElement(`a`);r.href=URL.createObjectURL(t),r.download=`${i}-${new Date().toISOString().slice(0,19)}.jsonl`,r.click(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)},disabled:!n.length,className:`size-8`,children:(0,K.jsx)(m,{className:`size-4`})})]})]}),n.length?a===`timeline`?(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:n.map(e=>(0,K.jsx)(_R,{turn:e},e.id))}):a===`prompt`?s?.prompt?(0,K.jsx)(gR,{prompt:s.prompt}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`assistant.noTurns`)}):(0,K.jsx)(`div`,{className:`flex flex-col gap-1 font-mono text-[0.6875rem]`,children:n.flatMap(e=>e.events.map((t,n)=>(0,K.jsxs)(`details`,{className:`rounded bg-paper-2`,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer px-2 py-1 text-ink-3`,children:[(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[`+`,iR(t.at-e.startedAt)]}),` `,(0,K.jsx)(`span`,{className:`text-ink`,children:t.event})]}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all px-2 pb-2 text-ink-2`,children:JSON.stringify(t.data,null,2)})]},`${e.id}-${n}`)))}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`assistant.noTurns`)})]})})}var yR=`wizards.assistant`,bR={place:`center`,height:null,dev:!1};function xR(){try{let e=JSON.parse(localStorage.getItem(yR)??`null`);return{place:e?.place===`right`?`right`:`center`,height:typeof e?.height==`number`?e.height:null,dev:e?.dev===!0}}catch{return bR}}var SR=xR(),CR=new Set,wR=()=>{for(let e of CR)e()},TR=e=>(CR.add(e),()=>CR.delete(e));function ER(e){SR={...SR,...e};try{localStorage.setItem(yR,JSON.stringify(SR))}catch{}wR()}function DR(){return(0,G.useSyncExternalStore)(TR,()=>SR)}var OR=64,kR=12,AR=null,jR=new Set;function MR(e){AR=e;for(let e of jR)e()}function NR(){return(0,G.useSyncExternalStore)(e=>(jR.add(e),()=>jR.delete(e)),()=>AR)}var PR=e=>Math.min(600,e-24);function FR(e,t,n){let r=PR(e.width),i=e.height-kR-t;return{center:{left:(e.width-r)/2,top:i,width:r,height:t},right:e.width>=r+24+240?{left:e.width-kR-r,top:i,width:r,height:t}:null,sidebar:n?{left:e.width-400+8,top:8,width:384,height:e.height-16}:null}}var IR=e=>e>=PR(e)+24+240;function LR(e,t){if(e.button!==0)return;e.preventDefault();let n={x:e.clientX,y:e.clientY},r=t.frame()?.getBoundingClientRect(),i=r?{x:n.x-r.left,y:n.y-r.top}:{x:28,y:24},a=!1,o=null,s=r=>{if(r.pointerId!==e.pointerId||!a&&Math.hypot(r.clientX-n.x,r.clientY-n.y)<5)return;a||(a=!0,document.body.style.userSelect=`none`,t.onLeave?.());let s=t.column()?.getBoundingClientRect();if(!s)return;let c=t.frame()?.getBoundingClientRect(),l=PR(s.width),u=c?.height??160,d=Math.min(Math.max(r.clientX-s.left-i.x,8),Math.max(8,s.width-120)),f=Math.min(Math.max(r.clientY-s.top-i.y,8),Math.max(8,s.height-u-8)),p=FR(s,u,t.sidebar),m=s.height-(f+u)<OR,h=s.width-(d+l)<OR||window.innerWidth-r.clientX<OR,g;if(p.sidebar&&h&&(!m||window.innerWidth-r.clientX<OR))g=`sidebar`;else{let e=d+l/2;g=p.right&&Math.abs(e-(p.right.left+l/2))<Math.abs(e-(p.center.left+l/2))?`right`:`center`}o={left:d,top:f,width:l,zone:g,spot:p[g]??o?.spot??null},MR(o)},c=n=>{if(n.pointerId!==e.pointerId)return;window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),document.body.style.userSelect=``;let r=o;if(MR(null),!a){t.onClick?.();return}r?.zone&&t.onDrop(r.zone)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)}var RR=null,zR=new Set;function BR(e){RR=e;for(let e of zR)e()}function VR(){return(0,G.useSyncExternalStore)(e=>(zR.add(e),()=>zR.delete(e)),()=>RR)}var HR=null,UR=new Set;function WR(e){HR=e;for(let e of UR)e()}function GR(){return(0,G.useSyncExternalStore)(e=>(UR.add(e),()=>UR.delete(e)),()=>HR)}function KR(e){switch(e.type){case`tool-input-available`:return{event:`tool_call`,data:{toolCallId:e.toolCallId,toolCallName:e.toolName,input:e.input}};case`tool-output-available`:case`tool-output-error`:return{event:`tool_result`,data:e};case`data-dev-step`:return{event:`step`,data:e.data};case`data-dev-prompt`:return{event:`prompt`,data:e.data};default:return{event:e.type,data:e}}}function qR(e){let t=!!At().data?.assistantDev,n=DR(),r=t&&n.dev,[i,a]=(0,G.useState)({chat:``,turns:[]}),o=(0,G.useRef)({chat:``,turns:[]}),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=()=>a({chat:o.current.chat,turns:[...o.current.turns]});return s.current=r?{start:t=>{c.current={id:crypto.randomUUID(),message:t,startedAt:Date.now(),endedAt:null,prompt:null,events:[]},o.current={chat:e,turns:[...o.current.chat===e?o.current.turns:[],c.current]},l()},chunk:e=>{let t=c.current;if(!t)return;let{event:n,data:r}=KR(e);t.events.push({at:Date.now(),event:n,data:r}),n===`prompt`&&(t.prompt=r),e.type.endsWith(`-delta`)||l()},end:()=>{c.current&&(c.current.endedAt=Date.now(),c.current=null,l())}}:null,{on:r,turns:i.chat===e?i.turns:[],tap:s}}function JR({dev:e,messages:t}){let[n,r]=(0,G.useState)(!1);return e.on?(0,K.jsxs)(`span`,{className:`flex h-9 shrink-0 items-center gap-0.5 px-1 coarse:h-11`,children:[(0,K.jsx)(re,{label:W(`assistant.inspect`),onClick:()=>r(!0),className:`size-8`,children:(0,K.jsx)(_n,{className:`size-4`})}),t.length?(0,K.jsx)(hR,{messages:t,turns:e.turns}):null,(0,K.jsx)(vR,{open:n,onClose:()=>r(!1),turns:e.turns,messages:t,file:`work`})]}):null}function YR({spaceId:e,open:t,onClose:n,onPick:r}){let i=(I(e).data?.files??[]).filter(e=>(e.kind===`document`||e.kind===`asset`)&&e.status!==`failed`),[a,s]=(0,G.useState)(``),[l,u]=(0,G.useState)([]),d=a.trim().toLowerCase(),f=i.filter(e=>!d||e.name.toLowerCase().includes(d)).reverse(),p=()=>{s(``),u([]),n()},m=e=>u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,K.jsx)(z,{open:t,onClose:p,title:W(`work.files.title`),height:`tall`,children:(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[(0,K.jsx)(k,{"data-autofocus":!0,value:a,onChange:e=>s(e.target.value),placeholder:W(`work.files.search`)}),(0,K.jsx)(`ul`,{className:`-mx-2`,children:f.map(t=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":l.includes(t.id),onClick:()=>m(t.id),className:`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left hover:bg-paper-2`,children:[(0,K.jsx)(XR,{spaceId:e,file:t}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`truncate text-[0.875rem] text-ink`,children:t.name}),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:ZR(t.size)})]}),(0,K.jsx)(`span`,{className:V(`flex size-4 shrink-0 items-center justify-center rounded border`,l.includes(t.id)?`border-primary bg-primary text-primary-foreground`:`border-input`),children:l.includes(t.id)?(0,K.jsx)(o,{className:`size-3`,strokeWidth:3}):null})]})},t.id))}),f.length?null:(0,K.jsx)(`p`,{className:`py-6 text-center text-[0.875rem] text-ink-3`,children:i.length?W(`work.files.noMatch`):W(`work.files.none`)}),(0,K.jsxs)(`div`,{className:`sticky bottom-0 flex justify-end gap-2 bg-card py-3`,children:[(0,K.jsx)(x,{variant:`secondary`,onClick:p,children:W(`work.files.cancel`)}),(0,K.jsx)(x,{disabled:!l.length,onClick:()=>{r(l.flatMap(t=>{let n=i.find(e=>e.id===t);return n?[{id:n.id,name:n.name,mime:n.mime,url:c(e,n.id)}]:[]})),p()},children:W(`work.files.add`)})]})]})})}function XR({spaceId:e,file:t}){return t.mime.startsWith(`image/`)?(0,K.jsx)(`img`,{src:c(e,t.id),alt:``,className:`size-9 shrink-0 rounded-md bg-paper-2 object-cover ring-1 ring-border`}):(0,K.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-paper-2 text-ink-3`,children:(0,K.jsx)(F,{className:`size-4`})})}var ZR=e=>e<1e6?`${Math.max(1,Math.round(e/1e3))} KB`:`${(e/1e6).toFixed(1)} MB`;function QR(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=jw({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=nE(a,!0,!0),u=UT(),[d,f]=G.useState(),p=d===null?void 0:d??u,m=Y(e=>{let t=!a,n=qT(_w,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return G.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var $R=G.createContext(void 0);function ez(){let e=G.useContext($R);if(e===void 0)throw Error(iC(15));return e}var tz=`data-open`,nz=`data-closed`,rz=ZC,iz=`data-panel-open`,az={[tz]:``},oz={[nz]:``},sz={open(e){return e?{[iz]:``}:null}},cz={open(e){return e?az:oz},...tw},lz=G.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=Y(o),d=QR({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=G.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=G.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=WC(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:cz});return(0,K.jsx)($R.Provider,{value:p,children:m})}),uz={...sz,...tw},dz=G.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=ez(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=yT({disabled:c,native:u});return WC(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:uz})}),fz={height:void 0,width:void 0};function pz(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=G.useRef(null),f=G.useRef(null),[p,m]=G.useState(fz),h=G.useRef(fz),g=G.useRef(!1),_=G.useRef(s),v=G.useRef(!1),[y,b]=G.useState(!1),x=G.useRef(null),S=mC(t,d),C=ZE(s),w=sE(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),O=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,k=n&&T&&f.current!==`css-animation`,A=Y((e,t=!0)=>{t&&(h.current=e),m(e)}),j=Y(()=>{x.current?.(),x.current=null}),M=Y(e=>{j(),x.current=()=>{x.current=null,e()}}),N=Y(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});X(()=>{y&&u!==`starting`&&b(!1)},[y,u]),G.useEffect(()=>()=>{N(),j()},[N,j]),X(()=>{s||(_.current=!1,v.current=!1);let e=d.current;if(!e)return;!s&&x.current&&j();let t=hz(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=mz(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){A(mz(e)),b(!0);return}if(t===`css-transition`){let t=vz(e);if(A(mz(e)),!n)return t;let r=_z(e,`transition-duration`,`0s`);return M(r),b(!0),t}A(mz(e));let r=_z(e,`animation-name`,`none`);if(!n){r();return}let i=_z(e,`animation-duration`,`0s`);r(),M(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){A(fz,!1),c(!1);return}A(mz(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=mz(e);if(!(n.height>0||n.width>0)){c(!1);return}A(n),t===`css-animation`&&_z(e,`animation-name`,`none`)()},[a,s,j,A,c,M,D,u]),cE({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&A(fz,!1)}}),G.useEffect(()=>{if(s||!a||E!==`ending`)return;if(!d.current){c(!1),A(fz,!1);return}let e=new AbortController,t=-1;function n(){C.current||(c(!1),A(fz,!1))}return t=eE.request(()=>{w(n,e.signal)}),()=>{eE.cancel(t),e.abort()}},[C,a,s,E,w,A,c]),X(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),G.useEffect(function(){let e=d.current;if(!e)return;let t=pE.create(),n=-1,r=(r,i)=>{t.start(0,()=>{C.current||(n=eE.request(()=>{C.current||(r&&(g.current=!1),i&&e.setAttribute(rz,``),e.setAttribute(`hidden`,`until-found`))}))})},i=YE(e,`beforematch`,t=>{let n=qT(gw,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}g.current=!0;let i=e.hasAttribute(rz);e.removeAttribute(rz),l(!0),r(!0,i)});return()=>{t.clear(),eE.cancel(n),i()}},[C,o,l]);let P=i||n||a||s;return{height:O.height,props:{...k?{[rz]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:P,transitionStatus:E,width:O.width}}function mz(e){return{height:e.scrollHeight,width:e.scrollWidth}}function hz(e,t){let n=Vw(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&gz(n.animationDuration),i=gz(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function gz(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function _z(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function vz(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=eE.request(n);return()=>{eE.cancel(r),n()}}var yz=`--collapsible-panel-height`,bz=`--collapsible-panel-width`,xz=G.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=ez(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;X(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=pz({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=kC(s,k),j=WC(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[yz]:S===void 0?`auto`:`${S}px`,[bz]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:cz});return E?j:null});function Sz({...e}){return(0,K.jsx)(lz,{"data-slot":`collapsible`,...e})}function Cz({...e}){return(0,K.jsx)(dz,{"data-slot":`collapsible-trigger`,...e})}function wz({...e}){return(0,K.jsx)(xz,{"data-slot":`collapsible-content`,...e})}function Tz({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`trace`,className:uP(`flex w-full min-w-0 flex-col gap-2 *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:rounded-md *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/50`,e),...t})}function Ez({className:e,status:t,...n}){return(0,K.jsx)(`span`,{"data-slot":`trace-line`,"data-status":t,className:uP(`flex w-fit max-w-full min-w-0 items-center gap-2 text-sm text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=pending]:opacity-60 data-[status=running]:*:data-[slot=trace-title]:shimmer`,e),...n})}function Dz({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`trace-icon`,"aria-hidden":`true`,className:uP(`flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1`,e),...t})}function Oz({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`trace-title`,className:uP(`min-w-0 truncate motion-reduce:shimmer-none`,e),...t})}function kz({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`trace-description`,className:uP(`shrink-0 text-muted-foreground/70 tabular-nums`,e),...t})}function Az({className:e,...t}){return(0,K.jsx)(Sz,{"data-slot":`trace-collapsible`,className:uP(`flex w-full min-w-0 flex-col`,e),...t})}function jz({className:e,children:t,...n}){return(0,K.jsxs)(Cz,{"data-slot":`trace-collapsible-trigger`,className:uP(`group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-md text-left text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 has-[[data-status=error]]:text-destructive`,e),...n,children:[t,(0,K.jsx)(Dz,{className:`transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90`,children:(0,K.jsx)(ee,{})})]})}function Mz({className:e,children:t,...n}){return(0,K.jsx)(wz,{"data-slot":`trace-collapsible-content`,className:`h-(--collapsible-panel-height) min-w-0 overflow-hidden transition-[height] duration-200 data-ending-style:h-0 data-starting-style:h-0`,...n,children:(0,K.jsx)(`div`,{"data-slot":`trace-collapsible-content-inner`,className:uP(`mt-2 mb-1 ml-[calc(--spacing(2)-1px)] min-w-0 border-l pr-1 pl-4 leading-relaxed wrap-break-word text-muted-foreground`,e),children:t})})}var Nz=(0,G.createContext)(null),Pz=e=>(e??[]).filter(e=>!!e&&typeof e.id==`string`&&typeof e.component==`string`);function Fz(e){let[t,...n]=e.split(`:`),r=n.join(`:`);return r?[`p`,`t`,`f`,`v`].includes(t)?`/space/knowledge?show=${encodeURIComponent(e)}`:t===`chat`?`/work/c/${encodeURIComponent(r)}`:t===`wizard`?`/edit/${encodeURIComponent(r)}`:null:null}function Iz({part:e,live:t}){let n=(0,G.useContext)(Nz),r=B(),i=ve(`/`).replace(/\/$/,``),a=e.input??{},o=e.output,s=Pz(a.components),c=e.state===`input-streaming`||e.state===`input-available`;if(!n||e.state===`output-error`||e.state===`output-available`&&o?.ok!==!0)return null;if(!s.some(e=>e.id===`root`))return c&&t?(0,K.jsxs)(Ez,{status:`running`,children:[(0,K.jsx)(Dz,{children:(0,K.jsx)(Qe,{})}),(0,K.jsx)(Oz,{children:W(`work.view.building`)})]}):null;let l=n.answered.get(e.toolCallId)??null,d={href:e=>{let t=Fz(e);return t?`${i}${t}`:null},follow:e=>r(e.slice(i.length)||`/`),fieldBase:ES(n.chatId),submit:t=>n.submit(e.toolCallId,{...t,text:a.title&&!t.text.startsWith(a.title)?`${a.title}\n${t.text}`:t.text}),answered:l};return(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[a.title?(0,K.jsx)(`div`,{className:`font-display font-semibold text-[1rem] leading-snug`,children:a.title}):null,(0,K.jsx)(u,{surface:{components:s,data:a.data??{}},assetUrl:e=>n.assetUrl?.(e)??fe(`/api/studio/spaces/${n.spaceId}/files/${encodeURIComponent(e.replace(/^f:/,``))}/content`),onAction:e=>{e.action===`ask`&&typeof e.target==`string`&&e.target&&n.ask(e.target)},chat:d})]})}var Lz=e=>e.type.startsWith(`tool-`)&&`toolCallId`in e,Rz=e=>e.type===`reasoning`,zz=(0,G.createContext)({approvals:new Map,may:()=>!1,decide:()=>{},busy:!1,tools:{}}),Bz=e=>{let t=e.output;return t&&typeof t.approval==`string`&&t.status===`waiting`?t.approval:null};function Vz(e,t){let n=t[e];return n?n.label?.[Xt]??`${n.plugin}: ${Hz(n.tool)}`:Hz(e)}var Hz=e=>e.replaceAll(`_`,` `).replace(/([a-z])([A-Z])/g,`$1 $2`);function Uz(e){let t=[];for(let n of e){let e=t.at(-1);if(n.type===`text`){let r=String(n.text??``);e?.kind===`text`?e.text+=r:r&&t.push({kind:`text`,text:r})}else n.type===`tool-show_view`&&`toolCallId`in n?t.push({kind:`view`,part:n}):(Rz(n)||Lz(n))&&(e?.kind===`steps`?e.parts.push(n):t.push({kind:`steps`,parts:[n]}))}return t}function Wz({parts:e,live:t,id:n}){let r=Uz(e),i=oB(e),a=t&&r.at(-1)?.kind!==`text`;return(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[r.map((e,i)=>e.kind===`text`?(0,K.jsx)(qe,{text:e.text,className:`text-[0.9375rem]`},`text-${i}`):e.kind===`view`?(0,K.jsx)(Iz,{part:e.part,live:t},e.part.toolCallId):(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(Xz,{parts:e.parts,running:t&&i===r.length-1,live:t,id:`${n.replace(/^pending-/,``)}:${i}`}),e.parts.filter(Lz).map(Bz).filter(e=>!!e).map(e=>(0,K.jsx)(gB,{id:e},e))]},`steps-${i}`)),i.length&&!a?(0,K.jsx)(uB,{list:i}):null]})}var Gz={failed:`work.step.failed`,denied:`work.step.denied`,waiting:`work.step.waiting`,stopped:`work.step.stopped`};function Kz(e,t,n,r){if(n)return!r||r.state===`pending`?`waiting`:r.state===`approved`?`done`:r.state;switch(e.state){case`output-available`:return pB(e.output)!==null&&Object.keys(e.output).length===1?`failed`:`done`;case`output-error`:return`failed`;case`output-denied`:return`denied`;case`approval-requested`:return`waiting`;default:return t?`running`:`stopped`}}function qz(e,t,n,r){let i=e.type.slice(5),a=e.state===`output-available`?Bz(e):null,o=a?n.get(a):void 0,s=Kz(e,t,a,o),c=a?o?.output:e.output,l=e.input??{},u=Gz[s]?W(Gz[s]):null,d=s===`failed`?e.errorText??pB(c):null,f=d?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:d}):null,p={key:e.toolCallId,phase:s};if(i===`space_search`||i===`search_space`){let t=typeof l.query==`string`?l.query:``,n=nB(c);return{...p,icon:ue,title:W(s===`running`?`work.step.searchingSpace`:`work.step.searchedSpace`,{query:t}),detail:u??(s===`done`&&n?n.length?W(`work.step.hits`,{count:n.length}):W(`work.step.noHits`):null),body:n?.length?(0,K.jsx)(iB,{hits:n}):f,raw:n?.length||d?{input:e.input,output:c??d}:null}}if(i===`web_search`){let t=l.query??l.queries,n=Array.isArray(t)?t.join(`, `):typeof t==`string`?t:``,r=aB(c);return{...p,icon:dt,title:n?W(s===`running`?`work.step.searchingWeb`:`work.step.searchedWeb`,{query:n}):W(s===`running`?`work.step.searchingWebBare`:`work.step.webSearch`),detail:u??(s===`done`&&r.length?W(`work.step.sources`,{count:r.length}):null),body:r.length?(0,K.jsx)(lB,{list:r}):f,raw:r.length||d?{input:e.input,output:c??d}:null}}if(i===`skill_load`||i===`skill_read`){let t=typeof l.name==`string`?l.name:``,n=i===`skill_read`&&typeof l.path==`string`?l.path:``;return{...p,icon:mt,title:W(s===`running`?`work.step.readingSkill`:`work.step.readSkill`,{name:n?`${t}/${n}`:t}),detail:u,body:f,raw:{input:e.input,output:c??d??void 0}}}if(i===`run_command`){let t=typeof l.command==`string`?l.command:``,n=c??{},r=[n.stdout,n.stderr].filter(Boolean).join(`
92
- `).trim();return{...p,icon:zi,title:W(s===`running`?`work.step.runningCommand`:`work.step.ranCommand`),detail:u??(s===`done`&&typeof n.exitCode==`number`&&n.exitCode!==0?W(`work.step.exitCode`,{code:n.exitCode}):null),body:(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap rounded-lg bg-ink/5 px-2.5 py-1.5 font-mono text-[0.75rem]`,children:t}),r?(0,K.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap px-2.5 font-mono text-[0.75rem] text-ink-3`,children:r}):null,f]}),raw:{input:e.input,output:c??d??void 0}}}return{...p,icon:r[i]?at:$i,title:Vz(i,r),detail:u??(s===`done`?dB(c):null),body:f,raw:{input:e.input,output:c??d??void 0}}}function Jz(e,t,n){let r=e.text.trim();return{key:t,icon:jn,title:W(n?`work.step.thinking`:`work.step.thought`),detail:null,phase:n?`running`:`done`,body:r?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.8125rem] leading-relaxed`,children:r}):null,raw:null}}function Yz({view:e,seconds:t}){let n=(0,K.jsxs)(Ez,{status:e.phase===`running`?`running`:e.phase===`failed`?`error`:void 0,children:[(0,K.jsx)(Dz,{children:(0,K.jsx)(e.icon,{})}),(0,K.jsx)(Oz,{children:e.title}),e.detail?(0,K.jsxs)(kz,{className:e.phase===`waiting`?`text-ember`:void 0,children:[`· `,e.detail]}):null,t===null?null:(0,K.jsxs)(kz,{children:[`· `,eB(t)]})]});return e.body||e.raw?(0,K.jsxs)(Az,{children:[(0,K.jsx)(jz,{children:n}),(0,K.jsxs)(Mz,{className:`grid gap-2`,children:[e.body,e.raw?(0,K.jsx)(mB,{raw:e.raw}):null]})]}):n}function Xz({parts:e,running:t,live:n,id:r}){let{approvals:i,tools:a}=(0,G.useContext)(zz),[o,s]=(0,G.useState)(null);tB(t);let c=e.map((o,s)=>Lz(o)?qz(o,n,i,a):Jz(o,`${r}:r${s}`,t&&(s===e.length-1||o.state===`streaming`))),l=c.map(e=>Qz(e.key,e.phase===`running`));if(c.length===1)return(0,K.jsx)(Tz,{children:(0,K.jsx)(Yz,{view:c[0],seconds:$z(l,c[0].phase===`running`)})});let u=c.filter(e=>e.phase===`failed`).length,d=$z(l,t);return(0,K.jsx)(Tz,{children:(0,K.jsxs)(Az,{open:o??t,onOpenChange:e=>s(e),children:[(0,K.jsx)(jz,{children:(0,K.jsxs)(Ez,{status:t?`running`:void 0,children:[(0,K.jsx)(Dz,{children:(0,K.jsx)(tt,{})}),(0,K.jsx)(Oz,{children:W(`work.step.steps`,{count:c.length})}),d===null?null:(0,K.jsxs)(kz,{children:[`· `,eB(d)]}),u?(0,K.jsxs)(kz,{className:`text-danger`,children:[`· `,W(`work.step.failedCount`,{count:u})]}):null]})}),(0,K.jsx)(Mz,{children:(0,K.jsx)(Tz,{children:c.map((e,t)=>(0,K.jsx)(Yz,{view:e,seconds:e.phase===`running`?null:$z([l[t]],!1)},e.key))})})]})})}var Zz=new Map;function Qz(e,t){let n=Zz.get(e);return!n&&t&&(n={from:Date.now(),to:null},Zz.set(e,n)),n&&!t&&n.to===null&&(n.to=Date.now()),n??null}function $z(e,t){let n=e.filter(e=>e!==null);if(!n.length)return null;let r=Math.min(...n.map(e=>e.from));return((t?Date.now():Math.max(...n.map(e=>e.to??e.from)))-r)/1e3}function eB(e){let t=Math.max(1,Math.round(e));return t<60?W(`work.step.seconds`,{n:t}):W(`work.step.minutes`,{m:Math.floor(t/60),s:t%60})}function tB(e){let[,t]=(0,G.useState)(0);(0,G.useEffect)(()=>{if(!e)return;let n=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(n)},[e])}function nB(e){let t=e?.hits;return Array.isArray(t)?t.map(e=>{let t=t=>typeof e[t]==`string`?e[t]:null;return{key:t(`key`)??t(`open`)??t(`path`)??``,title:t(`title`)??``,heading:t(`heading`)??t(`section`),text:t(`text`)??``,open:t(`open`),link:t(`link`)}}):null}var rB={p:F,d:F,t:Ce,f:l,v:Ui,x:at};function iB({hits:e}){return(0,K.jsx)(`ul`,{className:`-mx-2 grid`,children:e.map((e,t)=>{let n=rB[e.key.split(`:`)[0]]??F,r=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{className:`mt-0.5 size-3.5 shrink-0 text-ink-4`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`block truncate text-[0.8125rem] text-ink-2`,children:[e.title,e.heading&&e.heading!==e.title?(0,K.jsxs)(`span`,{className:`text-ink-4`,children:[` › `,e.heading]}):null]}),(0,K.jsx)(`span`,{className:`line-clamp-2 text-[0.75rem] text-ink-4`,children:e.text})]})]}),i=`flex items-start gap-2 rounded-md px-2 py-1.5`;return(0,K.jsx)(`li`,{children:e.open?(0,K.jsx)(Ue,{to:`/space/knowledge?show=${encodeURIComponent(e.open)}`,className:V(i,`hover:bg-ink/5`),children:r}):e.link?(0,K.jsx)(`a`,{href:e.link,className:V(i,`hover:bg-ink/5`),children:r}):(0,K.jsx)(`div`,{className:i,children:r})},`${e.key}:${t}`)})})}function aB(e){let t=Array.isArray(e)?e:e?.results??e?.sources;return Array.isArray(t)?t.flatMap(e=>e&&typeof e.url==`string`?[{url:e.url,title:typeof e.title==`string`?e.title:``}]:[]):[]}function oB(e){let t=new Map;for(let n of e){let e=n.type===`source-url`?[n]:Lz(n)&&n.type===`tool-web_search`?aB(n.output):[];for(let n of e)typeof n.url==`string`&&!t.has(n.url)&&t.set(n.url,{url:n.url,title:n.title??``})}return[...t.values()]}var sB=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return``}};function cB({url:e,className:t}){let[n,r]=(0,G.useState)(!1),i=sB(e);return n||!i?(0,K.jsx)(dt,{className:V(`size-3.5 shrink-0 text-ink-4`,t)}):(0,K.jsx)(`img`,{src:`https://${new URL(e).hostname}/favicon.ico`,alt:``,loading:`lazy`,onError:()=>r(!0),className:V(`size-3.5 shrink-0 rounded-sm`,t)})}function lB({list:e}){return(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:e.title||e.url,className:`flex max-w-80 items-center gap-1.5 rounded-full bg-ink/5 py-1 pr-2.5 pl-2 text-[0.75rem] text-ink-2 transition hover:bg-ink/10 hover:text-ink`,children:[(0,K.jsx)(cB,{url:e.url}),(0,K.jsx)(`span`,{className:`truncate`,children:e.title||sB(e.url)}),e.title?(0,K.jsx)(`span`,{className:`shrink-0 text-ink-4`,children:sB(e.url)}):null]},e.url))})}function uB({list:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`flex items-center gap-2 rounded-full border border-border-soft py-1 pr-3 pl-1.5 text-[0.8125rem] text-ink-3 transition hover:bg-ink/5 hover:text-ink`,children:[(0,K.jsx)(`span`,{className:`-space-x-1 flex`,children:e.slice(0,4).map(e=>(0,K.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-canvas ring-1 ring-border-soft`,children:(0,K.jsx)(cB,{url:e.url,className:`size-3`})},e.url))}),W(`work.step.sources`,{count:e.length})]}),t?(0,K.jsx)(lB,{list:e}):null]})}function dB(e){if(typeof e==`string`&&e.trim())return fB(e.trim().split(`
93
- `)[0]);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=Object.entries(e).filter(([,e])=>[`string`,`number`,`boolean`].includes(typeof e)).slice(0,2).map(([e,t])=>`${Hz(e)}: ${fB(String(t))}`);if(t.length)return t.join(` · `)}return W(`work.step.done`)}var fB=e=>e.length>80?`${e.slice(0,79)}…`:e,pB=e=>{let t=e?.error;return typeof t==`string`?t:null};function mB({raw:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-1.5`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`flex items-center gap-1 text-[0.75rem] text-ink-4 transition hover:text-ink`,children:[(0,K.jsx)(ee,{className:V(`size-3 transition-transform`,t&&`rotate-90`)}),W(`work.step.details`)]}),t?(0,K.jsxs)(`div`,{className:`grid w-full gap-1.5`,children:[e.input===void 0?null:(0,K.jsx)(hB,{label:W(`work.step.input`),value:e.input}),e.output===void 0?null:(0,K.jsx)(hB,{label:W(`work.step.output`),value:e.output})]}):null]})}function hB({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4 uppercase tracking-wide`,children:e}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-ink/5 p-2 font-mono text-[0.75rem]`,children:typeof t==`string`?t:JSON.stringify(t,null,2)})]})}function gB({id:e}){let{approvals:t,may:n,decide:r,busy:i,tools:a}=(0,G.useContext)(zz),o=t.get(e);if(!o)return null;let s=o.input&&typeof o.input==`object`&&!Array.isArray(o.input)?Object.entries(o.input):[],c=o.state===`approved`?Bz({output:o.output}):null,l=o.state===`approved`?W(c?`work.approval.toAdmins`:`work.approval.approved`):o.state===`denied`?W(`work.approval.denied`):o.state===`failed`?W(`work.approval.failed`):null;return(0,K.jsxs)(`div`,{className:`grid gap-3 rounded-xl border border-border bg-card/40 p-3.5 text-[0.875rem]`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-ink`,children:[o.state===`pending`?(0,K.jsx)(Ni,{className:`size-4 shrink-0 text-ember`}):o.state===`approved`?(0,K.jsx)(We,{className:`size-4 shrink-0 text-moss`}):(0,K.jsx)(Fi,{className:`size-4 shrink-0 text-ink-3`}),o.state===`pending`?W(o.heldFor===`admins`?`work.approval.waitingAdmins`:`work.approval.waiting`,{name:Vz(o.toolName,a)}):Vz(o.toolName,a)]}),s.length?(0,K.jsx)(`dl`,{className:`grid max-h-56 grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 overflow-auto rounded-lg bg-ink/5 px-3 py-2.5 text-[0.8125rem]`,children:s.map(([e,t])=>(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:Hz(e)}),(0,K.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words text-ink`,children:typeof t==`string`?t:JSON.stringify(t)})]},e))}):null,l?(0,K.jsx)(`p`,{className:o.state===`failed`?`text-danger`:`text-ink-3`,children:l}):n(o)?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(x,{size:`sm`,disabled:i,onClick:()=>r(o.id,!0),children:W(`work.approval.approve`)}),(0,K.jsx)(x,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>r(o.id,!1),children:W(`work.approval.deny`)})]}):(0,K.jsx)(`p`,{className:`text-ink-3`,children:W(o.heldFor===`admins`?`work.approval.notYoursAdmins`:`work.approval.notYours`)}),c?(0,K.jsx)(gB,{id:c}):null]})}function _B({id:e}){bL({ownInput:!0});let t=qR(e),n=PS(e,t.tap),r=n.status===`submitted`||n.status===`streaming`,{data:i,isError:a}=jS(e,r),o=At().data,s=o?.user.id,c=o?.tenant.role??`member`,l=XS(e),u=HS(),[d,f]=(0,G.useState)(null),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(!1),b=_e(),x=b.state,S=i?.chat.answeringSince??null,C=(0,G.useRef)(null);(0,G.useEffect)(()=>{S&&!r&&C.current!==S&&(C.current=S,n.resumeStream())},[S,r,n]);let w=B(),T=!!i,E=i?.chat.spaceId??``,D=nR(i?.chat.spaceId,()=>h(!0),x?.choice),O=(0,G.useRef)(null);(0,G.useEffect)(()=>{x?.ask!==void 0&&T&&O.current!==b.key&&(O.current=b.key,w(b.pathname,{replace:!0,state:null}),vB(n,E,x.ask,x.files??[],D.body))},[x,T,E,w,b.key,b.pathname,n,D.body]);let k=(0,G.useRef)(new Map),{space:A}=It(),j=R(),M=i?.chat.id;if((0,G.useEffect)(()=>{M&&j.invalidateQueries({queryKey:[`work-chats`]})},[M,j]),J1([{label:W(`work.chats`),to:`/work`},{label:xB(i)}]),a)return(0,K.jsx)(`p`,{className:`m-auto text-ink-3`,children:W(`work.chatGone`)});if(!i)return(0,K.jsx)(`div`,{className:`flex-1`});let N=new Map(i.members.map(e=>[`${e.kind}:${e.id}`,e])),P=i.members.filter(e=>e.kind===`person`).length,F=d??P<=1,I=[...i.messages,...yB(n.messages,s??``,i.messages,k.current)],L={approvals:new Map(i.approvals.map(e=>[e.id,e])),may:e=>c!==`member`||e.heldFor===`asker`&&e.askedBy===s,decide:(e,t)=>l.mutate({id:e,approve:t}),busy:l.isPending,tools:i.tools??{}},ee={chatId:e,spaceId:E,ask:t=>{r?u.mutateAsync({id:e,text:t,later:!0,choice:D.body}):vB(n,E,t,[],D.body)},submit:async(t,i)=>{let a={call:t,values:i.values};r?await u.mutateAsync({id:e,text:i.text,later:!0,files:i.files,form:a,choice:D.body}):await vB(n,E,i.text,[],D.body,{files:i.files,form:a})},answered:new Map(i.messages.filter(e=>e.form).map(e=>[e.form?.call??``,{by:N.get(`person:${e.author.id}`)?.name??e.author.name,values:e.form?.values??{}}]))},te=I.at(-1),ne=r&&te?.author.kind===`ai`&&te.id.startsWith(`pending-`)?te.id:null,z=e=>e.author.kind===`ai`?null:N.get(`person:${e.author.id}`)??{kind:`person`,id:e.author.id,name:e.author.name,image:null};return(0,K.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),y(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||y(!1)},onDrop:e=>{y(!1),e.dataTransfer.files.length&&(e.preventDefault(),p.current?.add(Array.from(e.dataTransfer.files).map(De)),p.current?.focus())},children:[v?(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-3 z-20 grid place-items-center rounded-2xl border-2 border-focus border-dashed bg-card/95 font-medium text-[0.9375rem] text-ink`,children:W(`new.dropHint`)}):null,(0,K.jsx)(SB,{chat:i}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1`,children:I.length?(0,K.jsx)(zz.Provider,{value:L,children:(0,K.jsx)(Nz.Provider,{value:ee,children:(0,K.jsxs)(cL,{autoScroll:!0,children:[(0,K.jsx)(bB,{sent:I.filter(e=>e.author.kind===`person`&&e.author.id===s).length}),(0,K.jsxs)(lL,{children:[(0,K.jsx)(uL,{children:(0,K.jsx)(dL,{className:`mx-auto w-full max-w-3xl gap-4 px-6 py-6`,children:wB(I).map((e,t,n)=>{let r=e[0],i=r.author.kind===`person`&&r.author.id===s,a=z(r),o=TB(r.createdAt),c=t===0||TB(n[t-1][0].createdAt)!==o;return(0,K.jsxs)(G.Fragment,{children:[c?(0,K.jsx)(YF,{variant:`separator`,children:(0,K.jsx)(XF,{children:EB(r.createdAt)})}):null,(0,K.jsx)(fL,{messageId:r.id,children:(0,K.jsx)(OB,{group:e,mine:i,author:a,spaceName:A?.name??``,liveId:ne})})]},r.id)})})}),(0,K.jsx)(pL,{})]})]},e)})}):(0,K.jsx)(`p`,{className:`grid h-full place-items-center text-[0.9375rem] text-ink-3`,children:W(`work.emptyChat`)})}),(0,K.jsxs)(`div`,{className:`mx-auto grid w-full max-w-3xl gap-2 px-6 pb-5`,children:[n.error?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:W(`work.turnFailed`,{message:n.error.message})}):null,g?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:W(`work.files.uploadFailed`,{message:g})}):null,(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":F,onClick:()=>f(!F),className:V(`flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[0.8125rem] transition`,F?`bg-ember/15 text-ink`:`text-ink-3 hover:bg-ink/5 hover:text-ink`),children:[(0,K.jsx)(ie,{className:`size-3.5`}),W(`work.askAi`,{name:A?.name??``})]})}),(0,K.jsx)(Pe,{ref:p,autoFocus:!0,tall:!0,lines:2,busy:r,chooser:D.chooser,buttons:(0,K.jsx)(JR,{dev:t,messages:I}),plus:D.plus,onStop:()=>{n.stop(),IS(e)},placeholder:W(F?`work.writeAsk`:`work.write`),onSend:async(t,i,a,o=[])=>{let s=t.trim();if(!s&&!i.length&&!o.length)return!1;_(null);let c;try{c=[...o,...await US(e,i)]}catch(e){return _(e.message),!1}let l=c.map(e=>e.id);return a&&r?await u.mutateAsync({id:e,text:s,later:!0,files:l,choice:D.body}):F||s.startsWith(`@`)?vB(n,E,s,c,D.body):await u.mutateAsync({id:e,text:s,files:l}),!0}},e),(0,K.jsx)(YR,{spaceId:i.chat.spaceId,open:m,onClose:()=>h(!1),onPick:e=>p.current?.pick(e)})]})]})}function vB(e,t,n,r,i,a){if(a)return e.sendMessage({text:n},{body:{...i,form:a.form,...a.files.length?{files:a.files}:{}}});if(!r.length)return e.sendMessage({text:n},{body:i});let o=r.map(e=>({type:`file`,mediaType:e.mime,filename:e.name,url:`/api/studio/spaces/${t}/files/${e.id}/content`}));return e.sendMessage(n?{text:n,files:o}:{files:o},{body:{files:r.map(e=>e.id),...i}})}function yB(e,t,n,r){let i=e=>n.filter(n=>n.author.kind===`person`&&n.author.id===t&&AB(n.parts)===e).length;return e.flatMap(e=>{if(e.role===`user`){let t=AB(e.parts);if(r.has(e.id)||r.set(e.id,i(t)),i(t)>(r.get(e.id)??0))return[]}return[{id:`pending-${e.id}`,author:e.role===`user`?{kind:`person`,id:t,name:``}:{kind:`ai`,id:`ai`,name:``},parts:e.parts,createdAt:new Date().toISOString()}]})}function bB({sent:e}){let{scrollToEnd:t}=XI(),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{e>n.current&&t({behavior:`smooth`}),n.current=e},[e,t]),null}var xB=e=>e?e.chat.title||W(`work.untitled`):W(`work.chats`);function SB({chat:e}){let t=RS(),n=B();return(0,K.jsxs)(`header`,{className:`flex min-h-12 flex-wrap items-center gap-x-3 gap-y-1 border-border-soft border-b px-6 py-2`,children:[e.chat.private?(0,K.jsx)(Nr,{className:`size-3.5 shrink-0 text-ink-4`,"aria-label":W(`work.private`)}):null,(0,K.jsx)(`div`,{className:`-space-x-1.5 flex`,title:e.members.map(e=>e.name).join(`, `),children:e.members.slice(0,5).map(e=>(0,K.jsx)(CB,{member:e,className:`ring-2 ring-canvas`},`${e.kind}:${e.id}`))}),(0,K.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[e.threads.map(e=>(0,K.jsx)(Ue,{to:`/work/c/${e.id}`,className:`max-w-48 truncate rounded-full bg-ink/5 px-2.5 py-1 text-[0.8125rem] text-ink-2 hover:bg-ink/10`,children:e.title||W(`work.untitled`)},e.id)),(0,K.jsxs)(`button`,{type:`button`,onClick:async()=>{let r=await t.mutateAsync({parentId:e.chat.id});n(`/work/c/${r.id}`)},className:`flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[0.8125rem] text-ink-3 hover:bg-ink/5 hover:text-ink`,children:[(0,K.jsx)(Vr,{className:`size-3.5`}),W(`work.newThread`)]}),e.chat.parentId?(0,K.jsx)(Ue,{to:`/work/c/${e.chat.parentId}`,className:`rounded-full px-2.5 py-1 text-[0.8125rem] text-ink-3 hover:bg-ink/5 hover:text-ink`,children:W(`work.toParent`)}):null]})]})}function CB({member:e,className:t}){let n=(e?.name??`?`).split(/\s+/).map(e=>e[0]).join(``).slice(0,2).toUpperCase();return e?.image?(0,K.jsx)(`img`,{src:e.image,alt:``,className:`size-7 shrink-0 rounded-full object-cover ${t??``}`}):(0,K.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-full bg-ink/10 font-semibold text-[0.6875rem] text-ink-2 ${t??``}`,children:n})}function wB(e){let t=[];for(let n of e){let e=t.at(-1)?.at(-1);e&&e.author.kind===n.author.kind&&e.author.id===n.author.id&&Date.parse(n.createdAt)-Date.parse(e.createdAt)<3e5?t.at(-1)?.push(n):t.push([n])}return t}var TB=e=>new Date(e).toDateString();function EB(e){let t=new Date(e),n=new Date,r=new Date(n.getTime()-864e5);return t.toDateString()===n.toDateString()?W(`work.today`):t.toDateString()===r.toDateString()?W(`work.yesterday`):t.toLocaleDateString(Xt,{weekday:`long`,day:`numeric`,month:`long`})}var DB=e=>new Date(e).toLocaleTimeString(Xt,{hour:`2-digit`,minute:`2-digit`});function OB({group:e,mine:t,author:n,spaceName:r,liveId:i}){let a=e[0].author.kind===`ai`;return(0,K.jsxs)(QF,{align:t?`end`:`start`,children:[t?null:(0,K.jsx)($F,{className:`min-w-0 self-start bg-transparent`,children:a?(0,K.jsx)(Bt,{size:28}):(0,K.jsx)(CB,{member:n??void 0})}),(0,K.jsxs)(eI,{children:[(0,K.jsxs)(tI,{className:t?`justify-end`:void 0,children:[t?W(`work.you`):a?r:n?.name??``,(0,K.jsx)(`span`,{className:`ml-2 font-normal text-ink-4`,children:DB(e[0].createdAt)})]}),(0,K.jsx)(ZF,{children:e.map(e=>a?(0,K.jsx)(Wz,{id:e.id,parts:e.parts,live:e.id===i},e.id):(0,K.jsxs)(G.Fragment,{children:[AB(e.parts)?(0,K.jsx)(KF,{align:t?`end`:`start`,variant:t?`muted`:`outline`,children:(0,K.jsx)(qF,{className:`whitespace-pre-wrap text-[0.9375rem]`,children:AB(e.parts)})}):null,(0,K.jsx)(kB,{parts:e.parts,mine:t})]},e.id))})]})]})}function kB({parts:e,mine:t}){let[n,r]=(0,G.useState)(null),i=e.filter(e=>e.type===`file`).map(e=>({name:e.filename??W(`work.files.file`),mime:e.mediaType,url:fe(e.url)}));if(!i.length)return null;let a=i.map((e,t)=>({f:e,i:t})),o=a.filter(({f:e})=>e.mime.startsWith(`image/`)),s=a.filter(({f:e})=>!e.mime.startsWith(`image/`)),c=({f:e,i:t},n)=>(0,K.jsx)(be,{file:e,large:!0,imageClassName:n,onOpen:()=>r(t)},`${e.url}-${t}`);return(0,K.jsxs)(K.Fragment,{children:[o.length===1?(0,K.jsx)(`ul`,{className:V(`flex w-full`,t&&`justify-end`),children:o.map(e=>c(e))}):o.length?(0,K.jsx)(`ul`,{className:V(`grid w-full max-w-3xl grid-cols-2 items-start gap-2`,t&&`ml-auto justify-items-end`),children:o.map(e=>c(e,`max-h-[55dvh]`))}):null,s.length?(0,K.jsx)(`ul`,{className:V(`flex flex-wrap gap-2`,t&&`justify-end`),children:s.map(e=>c(e))}):null,(0,K.jsx)(de,{files:i,at:n,onAt:r})]})}var AB=e=>e.filter(e=>e.type===`text`).map(e=>e.text).join(`
94
- `),jB=6,MB=4;function NB(){J1([{label:W(`work.chats`)}]),bL({ownInput:!0});let{space:e}=It(),t=At().data,n=e?.name??``,r=(AS(e?.id,``).data?.chats??[]).filter(e=>!e.archived),i=JS().data?.approvals??[],a=RS(),o=B(),s=(0,G.useRef)(null),[c,l]=(0,G.useState)(!1),u=nR(e?.id,()=>l(!0)),[d,f]=(0,G.useState)(null),p=tR(e?.id).slice(0,MB),m=new Map(r.map(e=>[e.id,e.title||W(`work.untitled`)])),h=r.filter(e=>e.unread&&e.last),g=r.filter(e=>e.answeringSince),_=new Set([...h,...g].map(e=>e.id)),v=[...r].filter(e=>!_.has(e.id)).sort((e,t)=>PB(t)>PB(e)?1:-1).slice(0,jB),y=i.length+h.length,b=t?.user.name.split(` `)[0]??``;return(0,K.jsx)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`mx-auto grid w-full max-w-3xl gap-10 px-6 pt-14 pb-16`,children:[(0,K.jsxs)(`header`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:new Date().toLocaleDateString(Xt,{weekday:`long`,day:`numeric`,month:`long`})}),(0,K.jsx)(`h1`,{className:`font-display font-semibold text-[2rem] text-ink leading-tight`,children:FB(b)}),(0,K.jsx)(`p`,{className:`text-[0.9375rem] text-ink-2`,children:y?W(`work.home.needs`,{count:y}):W(`work.waitingEmpty`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(Pe,{ref:s,tall:!0,autoFocus:!0,placeholder:W(`work.home.ask`,{name:n}),chooser:u.chooser,plus:u.plus,onSend:async(t,n,r,i=[])=>{let s=t.trim();if(!s&&!n.length&&!i.length||!e)return!1;f(null);try{let t=await a.mutateAsync({spaceId:e.id}),r=await US(t.id,n);return o(`/work/c/${t.id}`,{state:{ask:s,files:[...i,...r],choice:u.choice}}),!0}catch(e){return f(e.message),!1}}}),(0,K.jsx)(`p`,{className:V(`px-3 text-[0.75rem]`,d?`text-danger`:`text-ink-4`),children:d?W(`work.files.uploadFailed`,{message:d}):W(`work.home.askHint`)}),e?(0,K.jsx)(YR,{spaceId:e.id,open:c,onClose:()=>l(!1),onPick:e=>s.current?.pick(e)}):null]}),y?(0,K.jsx)(LB,{label:W(`work.home.needsYou`),children:(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i.map(e=>(0,K.jsx)(zB,{approval:e,chat:m.get(e.chatId)??W(`work.untitled`),may:t?.tenant.role!==`member`||e.heldFor===`asker`&&e.askedBy===t?.user.id},e.id)),h.map(e=>(0,K.jsx)(VB,{chat:e},e.id))]})}):null,g.length?(0,K.jsx)(LB,{label:W(`work.home.running`),children:(0,K.jsx)(`ul`,{className:`grid`,children:g.map(e=>(0,K.jsx)(UB,{chat:e,note:(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-ember`,children:[(0,K.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-ember`}),W(`work.home.answering`,{name:n})]})},e.id))})}):null,p.length&&t?(0,K.jsx)(LB,{label:W(`work.home.wizards`),children:(0,K.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>(0,K.jsx)(BB,{wizard:e,me:t},e.id))})}):null,v.length?(0,K.jsx)(LB,{label:W(`work.home.recent`),children:(0,K.jsx)(`ul`,{className:`grid`,children:v.map(e=>(0,K.jsx)(UB,{chat:e},e.id))})}):null]})})}var PB=e=>e.last?.at??e.updatedAt;function FB(e){let t=new Date().getHours();return W(t<11?`work.home.morning`:t<18?`work.home.day`:`work.home.evening`,{name:e})}function IB(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString(Xt,{hour:`2-digit`,minute:`2-digit`}):t.toDateString()===new Date(n.getTime()-864e5).toDateString()?W(`work.yesterday`):t.toLocaleDateString(Xt,{day:`numeric`,month:`short`})}function LB({label:e,children:t}){return(0,K.jsxs)(`section`,{className:`grid gap-3`,children:[(0,K.jsx)(`h2`,{className:`font-semibold text-[0.75rem] text-ink-3 uppercase tracking-wide`,children:e}),t]})}var RB=`grid content-start gap-3 rounded-2xl border border-border bg-card p-4`;function zB({approval:e,chat:t,may:n}){let r=XS(e.chatId);return(0,K.jsxs)(`div`,{className:V(RB,`border-ember/40`),children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(Ni,{className:`mt-0.5 size-4 shrink-0 text-ember`}),(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsx)(`p`,{className:`truncate text-[0.75rem] text-ink-3`,children:t}),(0,K.jsx)(`p`,{className:`font-medium text-[0.9375rem] text-ink`,children:W(e.heldFor===`admins`?`work.approval.waitingAdmins`:`work.approval.waiting`,{name:e.toolName})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{size:`sm`,disabled:r.isPending,onClick:()=>r.mutate({id:e.id,approve:!0}),children:W(`work.approval.approve`)}),(0,K.jsx)(x,{size:`sm`,variant:`secondary`,disabled:r.isPending,onClick:()=>r.mutate({id:e.id,approve:!1}),children:W(`work.approval.deny`)})]}):null,(0,K.jsx)(Ue,{to:`/work/c/${e.chatId}`,className:`ml-auto text-[0.8125rem] text-ink-3 hover:text-ink`,children:W(`work.home.open`)})]})]})}function BB({wizard:e,me:t}){return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>zL(eR(e,t)),title:W(`work.home.wizardOpen`),className:V(RB,`grid-cols-[auto_1fr] items-start text-left hover:bg-ink/5`),children:[(0,K.jsx)(Dt,{kind:e.avatar,costume:e.costume,size:40}),(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsx)(`p`,{className:`truncate font-medium text-[0.9375rem] text-ink`,children:e.title}),(0,K.jsx)(`p`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.description})]})]})}function VB({chat:e}){let t=HB(e);return(0,K.jsx)(Ue,{to:`/work/c/${e.id}`,className:V(RB,`hover:bg-ink/5`),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsxs)(`p`,{className:`truncate text-[0.75rem] text-ink-3`,children:[e.title||W(`work.untitled`),` · `,IB(PB(e))]}),(0,K.jsxs)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-ink`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:t}),e.last?.text]})]})]})})}function HB(e){let t=At().data?.user.name,n=e.last?.author;return n?`${n===t?W(`work.you`):n}: `:``}function UB({chat:e,note:t}){let n=HB(e);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(Ue,{to:`/work/c/${e.id}`,className:`-mx-3 flex items-baseline gap-3 rounded-xl px-3 py-2.5 hover:bg-ink/5`,children:[(0,K.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`p`,{className:`truncate font-medium text-[0.9375rem] text-ink`,children:e.title||W(`work.untitled`)}),(0,K.jsx)(`div`,{className:`truncate text-[0.8125rem] text-ink-3`,children:t??(e.last?(0,K.jsxs)(K.Fragment,{children:[n,e.last.text]}):W(`work.emptyChat`))})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-4`,children:IB(PB(e))})]})})}var WB=[{place:`chats`,to:`/work`,label:`work.chats`},{place:`engenties`,to:`/work/engenties`,label:`work.engenties`},{place:`files`,to:`/work/files`,label:`work.files`},{place:`data`,to:`/work/data`,label:`work.data`},{place:`results`,to:`/work/results`,label:`work.results`},{place:`waiting`,to:`/work/waiting`,label:`work.waiting`}],GB={engenties:`work.engentiesEmpty`,files:`work.filesEmpty`,data:`work.dataEmpty`,results:`work.resultsEmpty`,waiting:`work.waitingEmpty`};function KB(e){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...e,children:[(0,K.jsx)(`path`,{d:`M12 3.2Q19 7.6 19 14q0 6.5-7 6.9Q5 20.5 5 14q0-6.4 7-10.8z`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12.6`,r:`2.2`})]})}function qB({mode:e,children:t}){let n=cc(At().data);return n===e?t:(0,K.jsx)(he,{to:$s[n],replace:!0})}function JB(){let{place:e,chatId:t}=Ge(),n=na(`workWip`);if(t)return(0,K.jsx)(YB,{});let r=n?WB.find(t=>t.place===e&&t.place!==`chats`):void 0;return e&&!r?(0,K.jsx)(he,{to:`/work`,replace:!0}):r?.place===`waiting`?(0,K.jsx)(QB,{}):r?(0,K.jsx)(XB,{place:r.place}):(0,K.jsx)(YB,{})}function YB(){let{chatId:e}=Ge(),t=At().data;return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t?(0,K.jsx)(d0,{me:t}):null,(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,K.jsx)(EF,{}),e?(0,K.jsx)(_B,{id:e}):(0,K.jsx)(NB,{})]})]})}function XB({place:e}){let t=WB.find(t=>t.place===e)?.label??`work.chats`;return J1([{label:W(t)}]),(0,K.jsx)(nV,{children:W(GB[e])})}var ZB=`flex items-center gap-2 rounded-xl border border-border px-4 py-3 text-[0.9375rem] text-ink hover:bg-ink/5`;function QB(){J1([{label:W(`work.waiting`)}]);let e=JS().data,t=YS().mutate;(0,G.useEffect)(()=>{t()},[t]);let n=e?.approvals??[],r=e?.critical??[];return n.length||r.length?(0,K.jsxs)(`div`,{className:`mx-auto grid w-full max-w-2xl gap-8 py-8`,children:[n.length?(0,K.jsxs)(`section`,{className:`grid gap-2`,children:[(0,K.jsx)(`h2`,{className:`font-semibold text-[0.75rem] text-ink-3 uppercase tracking-wide`,children:W(`work.waiting.calls`)}),(0,K.jsx)(`ul`,{className:`grid gap-2`,children:n.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(Ue,{to:`/work/c/${e.chatId}`,className:ZB,children:[(0,K.jsx)(Ni,{className:`size-4 shrink-0 text-ember`}),W(e.heldFor===`admins`?`work.approval.waitingAdmins`:`work.approval.waiting`,{name:e.toolName})]})},e.id))})]}):null,r.length?(0,K.jsxs)(`section`,{className:`grid gap-2`,children:[(0,K.jsx)(`h2`,{className:`font-semibold text-[0.75rem] text-ink-3 uppercase tracking-wide`,children:W(`work.waiting.critical`)}),(0,K.jsx)(`ul`,{className:`grid gap-2`,children:r.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(eV,{line:e})},e.id))})]}):null]}):(0,K.jsx)(nV,{children:W(`work.waitingEmpty`)})}function $B(e){return e.chatId?`/work/c/${e.chatId}`:e.wizardId?`/wizards/${e.wizardId}${e.runId?`?run=${e.runId}`:``}`:null}function eV({line:e}){let t=$B(e),n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ji,{className:`size-4 shrink-0 text-ember`}),(0,K.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsxs)(`span`,{className:`truncate`,children:[W(`work.critical.${e.kind}`),` · `,e.connectionId,` · `,e.actionId]}),(0,K.jsxs)(`span`,{className:`truncate text-[0.8125rem] text-ink-3`,children:[new Date(e.at).toLocaleString(Xt,{dateStyle:`short`,timeStyle:`short`}),` · `,e.who.kind,e.reason?` · ${e.reason}`:``]})]})]});return t?(0,K.jsx)(Ue,{to:t,className:ZB,children:n}):(0,K.jsx)(`div`,{className:ZB,children:n})}function tV(){return J1([{label:W(`mode.client`)}]),(0,K.jsx)(nV,{children:W(`client.placeholder`)})}function nV({children:e}){return(0,K.jsx)(`p`,{className:`py-24 text-center text-[0.9375rem] text-ink-3`,children:e})}var rV=(0,G.lazy)(()=>ct(()=>import(`./AboutDialog-DaWEIHFN.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])));function iV(e,t=!1){return V(`shrink-0 rounded-lg transition`,t?`flex h-10 w-full items-center gap-3 px-2.5 font-medium text-[0.875rem]`:`grid size-10 place-items-center`,e?`bg-paper text-ink shadow-soft dark:ring-1 dark:ring-border-soft`:`text-ink-3 hover:bg-ink/10 hover:text-ink`)}function aV(e,t){let[n,r]=(0,G.useState)(null);return{over:n=>{if(!e)return;let i=n.target.closest(`a[aria-label], button[aria-label]`),a=i?.getAttribute(`aria-label`);if(!(i&&a)){r(null);return}let o=i.getBoundingClientRect();r(t===`left`?{label:a,x:o.right+8,y:o.top+o.height/2}:t===`right`?{label:a,x:o.left-8,y:o.top+o.height/2}:t===`top`?{label:a,x:o.left+o.width/2,y:o.bottom+8}:{label:a,x:o.left+o.width/2,y:o.top-8})},out:()=>r(null),element:n?(0,_c.createPortal)((0,K.jsx)(`span`,{role:`tooltip`,className:V(`pointer-events-none fixed z-[60] animate-in whitespace-nowrap rounded-md bg-ink px-2.5 py-1 font-medium text-[0.8125rem] text-paper shadow-soft fade-in-0`,t===`left`&&`-translate-y-1/2`,t===`right`&&`-translate-x-full -translate-y-1/2`,t===`top`&&`-translate-x-1/2`,t===`bottom`&&`-translate-x-1/2 -translate-y-full`),style:{left:n.x,top:n.y},children:n.label}),document.body):null}}function oV({children:e}){return(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})}function sV({me:e,labels:t}){let{space:n}=It(),r=a0(e),i=r?e.tenant.name??void 0:void 0;return(0,K.jsxs)(o0,{me:e,placement:`bar-start`,label:n?.name??W(`nav.space`),className:e=>t?V(`flex w-full items-center gap-3 rounded-lg p-0.5 pr-2 text-left transition hover:bg-ink/10`,e&&`bg-ink/10`):V(`block rounded-lg transition`,e?`ring-2 ring-ink/80 ring-offset-2 ring-offset-sidebar`:`hover:shadow-soft`),children:[(0,K.jsx)(i0,{space:n,name:i}),t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.875rem] text-ink`,children:i??n?.name??W(`nav.space`)}),r?null:(0,K.jsx)(zn,{className:`size-4 shrink-0 text-ink-4`})]}):null]})}var cV={left:ti,top:ai,right:ri,bottom:Zr},lV=[{pick:`light`,icon:wt,label:`appbar.light`},{pick:`branded`,icon:Yr,label:`appbar.branded`},{pick:`dark`,icon:Et,label:`appbar.dark`},{pick:null,icon:qr,label:`appbar.system`}];function uV({at:e,room:t,onClose:n}){let{position:r,labels:i}=ma(),a=Ct(),s=aa,c=(0,G.useRef)(null);t0(c,!0,n);let[l,u]=(0,G.useState)({x:0,y:0});(0,G.useLayoutEffect)(()=>{let e=c.current?.getBoundingClientRect();e&&u({x:Math.min(0,window.innerWidth-8-e.right),y:Math.min(0,window.innerHeight-8-e.bottom)})},[]);let d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink disabled:pointer-events-none disabled:opacity-50`,f=`px-3 pt-2 pb-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.07em]`;return(0,K.jsxs)(`div`,{ref:c,role:`menu`,className:`fixed z-[60] w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,style:{left:Math.max(8,e.x+l.x),top:Math.max(8,e.y+l.y)},onContextMenu:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:f,children:W(`appbar.position`)}),s.map(e=>{let t=cV[e];return(0,K.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===r,className:V(d,e===r&&`text-ink`),onClick:()=>{fa({position:e}),n()},children:[(0,K.jsx)(t,{className:`size-4`}),(0,K.jsx)(`span`,{className:`flex-1`,children:W(`appbar.${e}`)}),e===r?(0,K.jsx)(o,{className:`size-4 text-ember-strong`}):null]},e)}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":i,disabled:!(i||t),className:V(d,i&&`text-ink`),onClick:()=>{fa({labels:!i}),n()},children:[(0,K.jsx)($r,{className:`size-4`}),(0,K.jsx)(`span`,{className:`flex-1`,children:W(`appbar.labels`)}),i?(0,K.jsx)(o,{className:`size-4 text-ember-strong`}):null]}),(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsx)(`div`,{className:f,children:W(`appbar.theme`)}),lV.map(({pick:e,icon:t,label:r})=>(0,K.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===a,className:V(d,e===a&&`text-ink`),onClick:()=>{Lt(e),n()},children:[(0,K.jsx)(t,{className:`size-4`}),(0,K.jsx)(`span`,{className:`flex-1`,children:W(r)}),e===a?(0,K.jsx)(o,{className:`size-4 text-ember-strong`}):null]},r))]})}function dV(){let{pathname:e}=_e();return e===`/new`?`new`:e===`/`||e.startsWith(`/edit/`)?`home`:e===`/skills`?`skills`:e===`/capabilities`||e.startsWith(`/capabilities/`)?`capabilities`:e===`/space/results`||e.startsWith(`/space/results/`)?`results`:e===`/settings`||e.startsWith(`/settings/`)?`settings`:e===`/space`||e.startsWith(`/space/`)?`space`:null}var fV={chats:C,engenties:KB,files:ar,data:b,results:_r,waiting:Be};function pV({labels:e,horizontal:t}){let n=JS().data,r=(n?.approvals.length??0)+(n?.unseen??0),i=na(`workWip`)?WB:WB.filter(e=>e.place===`chats`);return(0,K.jsx)(`nav`,{className:V(`flex min-h-0 min-w-0 flex-1`,e?`items-stretch`:`items-center`,t?`ml-1.5 flex-row gap-1.5 overflow-x-auto`:`mt-2 flex-col gap-2`),children:i.map(({place:t,to:n,label:i})=>{let a=fV[t];return(0,K.jsxs)(Ue,{to:n,end:!0,"aria-label":W(i),className:({isActive:t})=>V(iV(t,e),`relative`),children:[(0,K.jsx)(a,{className:`size-5 shrink-0`}),e?(0,K.jsx)(oV,{children:W(i)}):null,t===`waiting`&&r>0?(0,K.jsx)(`span`,{className:`absolute top-0.5 left-6 grid h-4 min-w-4 place-items-center rounded-full bg-ember px-1 font-bold text-[0.625rem] text-white`,children:r}):null]},t)})})}function mV({me:e,labels:t,room:n}){let r=O0(),i=na(`skills`),a=na(`capabilities`),{position:o}=ma(),s=ha(o),c=aV(!t,o),l=dV(),u=cc(e),[d,f]=(0,G.useState)(null),p=e=>{e.preventDefault(),f({x:e.clientX,y:e.clientY})},m=(0,G.useRef)(null),h=(0,G.useRef)(!1),g=()=>{m.current&&=(window.clearTimeout(m.current.timer),null)};return(0,K.jsxs)(`aside`,{"aria-label":Rt.name,onContextMenu:p,onPointerDown:e=>{if(e.pointerType===`mouse`)return;g();let{clientX:t,clientY:n}=e;m.current={x:t,y:n,timer:window.setTimeout(()=>{m.current=null,h.current=!0,window.setTimeout(()=>{h.current=!1},700),f({x:t,y:n})},500)}},onPointerMove:e=>{m.current&&Math.hypot(e.clientX-m.current.x,e.clientY-m.current.y)>10&&g()},onPointerUp:g,onPointerCancel:g,onPointerLeave:g,onClickCapture:e=>{h.current&&(h.current=!1,e.preventDefault(),e.stopPropagation())},onMouseOver:c.over,onFocus:c.over,onMouseLeave:c.out,onBlur:c.out,onClick:c.out,className:V(`flex shrink-0 select-none bg-sidebar [-webkit-touch-callout:none]`,s?`w-full flex-row items-center gap-1.5 px-2`:V(`h-full flex-col pt-2 pb-3 transition-[width] duration-200 ease-out`,t?`w-56 items-stretch px-2.5`:`w-16 items-center`),o===`bottom`&&`pt-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))]`,o===`top`&&`pt-[calc(0.375rem+env(safe-area-inset-top))] pb-1.5`),children:[(0,K.jsx)(Mc,{me:e,position:o,horizontal:s,labels:t}),(0,K.jsx)(`div`,{className:s?`ml-1`:`mt-1`,children:(0,K.jsx)(sV,{me:e,labels:t})}),(0,K.jsx)(xc,{me:e,look:s?`row`:t?`named`:`stacked`,className:s?`ml-1`:`mt-2`}),u===`work`?(0,K.jsx)(pV,{labels:t,horizontal:s}):u===`client`?(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Se,{to:`/`,"aria-label":W(`nav.home`),"aria-current":l===`home`||l===`new`?`page`:void 0,className:V(iV(l===`home`||l===`new`,t),s?`ml-1.5`:`mt-2`),children:[(0,K.jsx)(pr,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:W(`nav.home`)}):null]}),(0,K.jsxs)(Se,{to:`/space`,"aria-label":W(`nav.sources`),"aria-current":l===`space`?`page`:void 0,className:V(iV(l===`space`,t),s?`ml-1.5`:`mt-2`),children:[(0,K.jsx)(Tr,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:W(`nav.sources`)}):null]}),a?(0,K.jsxs)(Se,{to:`/capabilities`,"aria-label":W(`nav.capabilities`),"aria-current":l===`capabilities`?`page`:void 0,className:V(iV(l===`capabilities`,t),s?`ml-1.5`:`mt-2`),children:[(0,K.jsx)(qi,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:W(`nav.capabilities`)}):null]}):i?(0,K.jsxs)(Se,{to:`/skills`,"aria-label":W(`space.skills`),"aria-current":l===`skills`?`page`:void 0,className:V(iV(l===`skills`,t),s?`ml-1.5`:`mt-2`),children:[(0,K.jsx)(mt,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:W(`space.skills`)}):null]}):null,(0,K.jsxs)(Se,{to:`/space/results`,"aria-label":W(`space.results`),"aria-current":l===`results`?`page`:void 0,className:V(iV(l===`results`,t),s?`ml-1.5`:`mt-2`),children:[(0,K.jsx)(_r,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:W(`space.results`)}):null]}),r.nav.length?(0,K.jsx)(`div`,{className:V(`shrink-0 bg-border`,s?`mx-2 h-7 w-px`:V(`my-3 h-px`,t?`mx-2.5`:`w-7`))}):null,(0,K.jsx)(`nav`,{className:V(`flex min-h-0 min-w-0 flex-1 gap-1.5`,t?`items-stretch`:`items-center`,s?`flex-row overflow-x-auto`:`flex-col overflow-y-auto`),children:r.nav.map(e=>(0,K.jsx)(Q0,{of:e,children:(0,K.jsxs)(Ue,{to:e.to,"aria-label":e.label(),className:({isActive:e})=>iV(e,t),children:[(0,K.jsx)(e.icon,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:e.label()}):null]})},e.serial))})]}),(0,K.jsxs)(`div`,{className:V(`flex shrink-0 gap-2`,s?`flex-row pl-3`:`flex-col pt-3`,t?`items-stretch`:`items-center`),children:[(0,K.jsxs)(Ue,{to:`/settings`,"aria-label":W(`nav.settings`),className:({isActive:e})=>iV(e,t),children:[(0,K.jsx)(Di,{className:`size-5 shrink-0`}),t?(0,K.jsx)(oV,{children:W(`nav.settings`)}):null]}),(0,K.jsx)(u0,{me:e,placement:`bar-end`,named:t})]}),d?(0,K.jsx)(uV,{at:d,room:n,onClose:()=>f(null)}):null,c.element]})}function hV(e){return V(`glass-press relative grid h-12 w-16 place-items-center rounded-full transition-colors`,e?`text-ink`:`text-ink-3`)}var gV=68;function _V({index:e}){let t=(0,G.useRef)(null),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{let r=n.current;n.current=e;let i=t.current;if(!i||r===null||e===null||r===e||matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let a=r*gV,o=e*gV;i.animate([{transform:`translateX(${a}px)`},{transform:`translateX(${(a+o)/2}px) scaleX(1.35) scaleY(0.92)`,offset:.45},{transform:`translateX(${o}px)`}],{duration:420,easing:`cubic-bezier(0.34, 1.3, 0.64, 1)`})},[e]),(0,K.jsx)(`span`,{ref:t,"aria-hidden":`true`,className:`pointer-events-none absolute top-1 left-1 h-12 w-16 rounded-full bg-ink/12 transition-opacity`,style:{transform:`translateX(${(e??0)*gV}px)`,opacity:e===null?0:1}})}function vV({me:e}){let t=O0(),n=na(`skills`),r=na(`capabilities`),i=dV(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),l=B(),u=(0,G.useRef)(null),d=Rc(),f=Mt(),{space:p}=It(),m=d??(f&&!p?.readOnly&&i!==`new`?{icon:Ke,label:W(`home.new`),run:()=>l(`/new`)}:null);t0(u,a,()=>o(!1));let{pathname:h}=_e();(0,G.useEffect)(()=>o(!1),[h]);let g=e=>!a&&i===e,_=a?2:i===`home`||i===`new`?0:i===`space`?1:i===`skills`||i===`capabilities`||i===`results`||i===`settings`?2:null,v=e=>{o(!1),l(e)},y=e=>V(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-[0.9375rem] transition`,e?`bg-accent text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`);return(0,K.jsxs)(`div`,{className:`fixed inset-x-0 bottom-[calc(0.5rem+env(safe-area-inset-bottom))] z-40 flex select-none justify-center gap-2.5 [-webkit-touch-callout:none]`,children:[(0,K.jsxs)(`nav`,{ref:u,"aria-label":Rt.name,className:`liquid-glass relative flex gap-1 rounded-full p-1`,children:[(0,K.jsx)(_V,{index:_}),(0,K.jsx)(Se,{to:`/`,"aria-label":W(`nav.home`),"aria-current":i===`home`?`page`:void 0,onClick:()=>o(!1),className:hV(g(`home`)),children:(0,K.jsx)(pr,{className:`size-[1.375rem]`})}),(0,K.jsx)(Se,{to:`/space`,"aria-label":W(`nav.sources`),"aria-current":i===`space`?`page`:void 0,onClick:()=>o(!1),className:hV(g(`space`)),children:(0,K.jsx)(Tr,{className:`size-[1.375rem]`})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":W(`nav.more`),"aria-expanded":a,"aria-haspopup":`menu`,onClick:()=>o(e=>!e),className:hV(a||i===`skills`||i===`capabilities`||i===`results`||i===`settings`),children:(0,K.jsx)(pt,{className:`size-[1.375rem]`})}),a?(0,K.jsxs)(`div`,{role:`menu`,className:`absolute right-0 bottom-full mb-3 flex w-60 animate-rise flex-col rounded-2xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[r?(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:y(i===`capabilities`),onClick:()=>v(`/capabilities`),children:[(0,K.jsx)(qi,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:W(`nav.capabilities`)})]}):n?(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:y(i===`skills`),onClick:()=>v(`/skills`),children:[(0,K.jsx)(mt,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:W(`space.skills`)})]}):null,(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:y(i===`results`),onClick:()=>v(`/space/results`),children:[(0,K.jsx)(_r,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:W(`space.results`)})]}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:y(i===`settings`),onClick:()=>v(`/settings`),children:[(0,K.jsx)(Di,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:W(`nav.settings`)})]}),t.nav.map(e=>(0,K.jsx)(Q0,{of:e,children:(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:y(!1),onClick:()=>v(e.to),children:[(0,K.jsx)(e.icon,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label()})]})},e.serial)),(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:y(!1),onClick:()=>{o(!1),c(!0)},children:[(0,K.jsx)(yr,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:W(`about.nav`)})]})]}):null,s?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(rV,{open:!0,me:e,onClose:()=>c(!1)})}):null]}),m?(0,K.jsx)(`button`,{type:`button`,"aria-label":m.label,title:m.label,onClick:m.run,className:`liquid-glass glass-press relative grid size-14 shrink-0 place-items-center rounded-full text-ink`,children:(0,K.jsx)(m.icon,{className:`size-6`})}):null]})}var yV=Ht({route:qt().max(400),title:qt().max(200).optional(),view:qt().max(200).optional(),open:Ht({kind:qt().max(60),id:qt().max(120).optional(),label:qt().max(200)}).optional(),selection:Jt(qt().max(120)).max(100).optional(),summary:qt().max(2e3).optional(),fields:Jt(Ht({id:qt().max(120),label:qt().max(200),value:Ut()})).max(60).optional(),plugin:qt().max(60).optional()}),bV=Ht({name:qt().regex(/^[a-z][a-z0-9_]{1,62}$/),description:qt().max(2e3),parameters:Zt(qt(),Ut())}),xV=`confirm_action`;Ht({message:qt().min(1).max(8e3),spaceId:qt().max(80).optional(),page:yV.optional(),tools:Jt(bV).max(40).default([]),debug:Qt().optional(),extra:Qt().optional(),model:qt().max(80).optional()}),Ht({ref:qt().min(1).max(40),message:qt().min(1).max(8e3)});var SV={initial:400,min:320,max:720},CV=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function wV(e){let t=e.filter(e=>e.type.startsWith(`image/`));return t.length?Object.fromEntries(t.map(e=>[e.name,URL.createObjectURL(e)])):void 0}function TV(e){let t=e.match(/(?:^|\n\n)(?:Angehängt|Attached): ([^\n]+)$/);return t?{text:e.slice(0,t.index).trim(),names:t[1].split(`, `).filter(Boolean)}:{text:e,names:[]}}function EV({names:e,previews:t,fileUrl:n}){let r=e.filter(e=>t?.[e]||n&&CV.test(e)),i=e.filter(e=>!r.includes(e));return(0,K.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5`,children:[r.map(e=>{let r=t?.[e]??n?.(e)??``;return(0,K.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,title:e,children:(0,K.jsx)(`img`,{src:r,alt:e,className:`max-h-60 w-auto max-w-full rounded-xl bg-paper-2 object-contain ring-1 ring-border`})},e)}),i.length?(0,K.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:i.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 px-2.5 py-1 text-[0.75rem] text-ink-2`,children:[(0,K.jsx)(w,{className:`size-3 shrink-0 text-ink-4`}),(0,K.jsx)(`span`,{className:`truncate`,children:e})]},e))}):null]})}function DV(e,t){let n=R(),[r,i]=(0,G.useState)([]),[a,o]=(0,G.useState)(`idle`),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[_,v]=(0,G.useState)(!0),y=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(e){if(y.current!==e.id){y.current=e.id,i(e.messages);return}a===`idle`&&i(t=>e.messages.length>=t.length?e.messages:t)}},[e,a]),{messages:r,phase:a,activity:l,thought:d,startedAt:m,error:s,send:async(r,s=[])=>{if(!e||!(r.trim()||s.length)||a!==`idle`)return!1;if(c(null),h(Date.now()),f(null),s.length){o(`thinking`);try{for(let t of s){let n=await fetch(fe(`/api/studio/wizards/${e.id}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":Xt},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}}catch(t){return c(t.message),o(`idle`),h(null),await n.invalidateQueries({queryKey:p.wizard(e.id)}),!1}let t=`${W(`editor.attached`)}: ${s.map(e=>e.name).join(`, `)}`;r=r.trim()?`${r}\n\n${t}`:t}let l=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:r,previews:wV(s)},{id:l,role:`assistant`,content:``,pending:!0}]),o(`thinking`),u(null);let d=!1;try{await g(`/api/studio/wizards/${e.id}/chat`,{message:r,extra:_},(e,n)=>{if(e===`text`){let e=JSON.parse(n);i(t=>t.map(t=>t.id===l?{...t,content:t.content+e}:t))}else if(e===`activity`)u(JSON.parse(n));else if(e===`thought`)f(JSON.parse(n));else if(e===`building`)o(`building`);else if(e===`done`){d=!0;let e=JSON.parse(n);i(t=>t.map(t=>t.id===l?{...t,content:e.reply,changed:e.changed,pending:!1}:t)),e.changed&&t(e.draft,e.revision)}else e===`error`&&(d=!0,c(JSON.parse(n).message))}),d||c(W(`editor.chatBroken`))}catch(e){c(e.message)}finally{u(null),f(null),h(null),i(e=>e.filter(e=>!(e.id===l&&!e.content)).map(e=>({...e,pending:!1}))),o(`idle`),await n.invalidateQueries({queryKey:p.wizard(e.id)}),await n.invalidateQueries({queryKey:[`me`]})}return!0},fileUrl:t=>fe(`/api/studio/wizards/${e?.id}/files/${encodeURIComponent(t)}`),extra:_,setExtra:v}}function OV(e){let[t,n]=(0,G.useState)(()=>Date.now());return(0,G.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?null:Math.max(0,Math.floor((t-e)/1e3))}function kV(e){return e<60?`${e} s`:`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} min`}function AV({chat:e,thought:t,className:n,spinner:r=`size-3.5`}){let i=OV(e.startedAt);return(0,K.jsxs)(`div`,{className:V(`min-w-0`,n),children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(Fe,{className:V(`shrink-0`,r)}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.activity??(e.phase===`building`?W(`editor.building`):W(`editor.thinking`))}),i===null?null:(0,K.jsx)(`span`,{className:`shrink-0 text-ink-4 tabular-nums`,children:kV(i)})]}),t&&e.thought?(0,K.jsx)(`p`,{className:`mt-0.5 truncate pl-5.5 text-[0.75rem] text-ink-4`,children:e.thought}):null]})}function jV({message:e,fileUrl:t}){let{text:n,names:r}=TV(e.content);return(0,K.jsxs)(`div`,{className:`ml-8 flex flex-col items-end gap-1.5 self-end`,children:[e.signal?(0,K.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:W(`assistant.signalled`)}):null,r.length?(0,K.jsx)(EV,{names:r,previews:e.previews,fileUrl:t}):null,n?(0,K.jsx)(`div`,{className:`rounded-xl rounded-br-md bg-paper-2 px-4 py-2.5 text-[0.875rem] leading-relaxed`,children:(0,K.jsx)(`span`,{className:`whitespace-pre-wrap`,children:n})}):null]})}function MV({chat:e,avatar:t,costume:n,changedLabel:r,card:i,calls:a,foot:o}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.messages.map(s=>s.role===`user`?(0,K.jsx)(jV,{message:s,fileUrl:e.fileUrl},s.id):(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`shrink-0`,children:(0,K.jsx)(Dt,{kind:t,costume:n,size:28,interactive:!1})}),(0,K.jsxs)(`div`,{className:`min-w-0 pt-0.5 text-[0.875rem]`,children:[s.source===`mcp`?(0,K.jsxs)(`div`,{className:`mb-1 inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(ut,{className:`size-3`}),` `,W(`editor.viaClient`,{client:s.client??`MCP`})]}):null,a?a(s):null,s.content?(0,K.jsx)(qe,{text:s.content,className:`text-[0.875rem]`}):null,i&&s.cards?.length?(0,K.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:s.cards.map(e=>(0,K.jsx)(G.Fragment,{children:i(e)},e.id))}):null,s.pending?(0,K.jsx)(AV,{chat:e,thought:!0,className:`mt-1 text-[0.8125rem] text-ink-3`}):null,s.changed?(0,K.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-full bg-ember-tint px-2.5 py-0.5 text-[0.75rem] text-ember-strong`,children:[(0,K.jsx)(ie,{className:`size-3`}),` `,r]}):null,o?o(s):null]})]},s.id))})}var NV=`wizards.editorThread.height`,PV=320,FV=120,IV=()=>Math.max(FV,window.innerHeight-260);function LV(){let[e,t]=(0,G.useState)(()=>{try{let e=Number(localStorage.getItem(NV));return e?Math.min(Math.max(e,FV),IV()):PV}catch{return PV}});return{height:e,set:e=>{let n=Math.round(Math.min(Math.max(e,FV),IV()));t(n);try{localStorage.setItem(NV,String(n))}catch{}}}}function RV({open:e,height:t,onHeight:n,onToggle:r}){let i=(0,G.useRef)(null);return(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,"aria-valuenow":t,"aria-valuemin":FV,"aria-label":W(`editor.threadGrip`),title:W(`editor.threadGrip`),onPointerDown:n=>{n.button===0&&(n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),i.current={y:n.clientY,height:e?t:0,moved:!1})},onPointerMove:t=>{let a=i.current;!a||!a.moved&&Math.abs(t.clientY-a.y)<4||!(e||a.moved)&&t.clientY>a.y||(e||a.moved||r(!0),a.moved=!0,n(a.height+(a.y-t.clientY)))},onPointerUp:()=>{let t=i.current&&!i.current.moved;i.current=null,t&&r(!e)},onPointerCancel:()=>{i.current=null},onKeyDown:i=>{if(i.key===`ArrowUp`||i.key===`ArrowDown`){if(i.preventDefault(),!e){i.key===`ArrowUp`&&r(!0);return}n(t+(i.key===`ArrowUp`?32:-32))}else(i.key===`Enter`||i.key===` `)&&(i.preventDefault(),r(!e))},className:`group flex h-3.5 shrink-0 cursor-row-resize touch-none items-center justify-center outline-none`,children:(0,K.jsx)(`span`,{className:`h-1 w-10 rounded-full bg-ink-4/40 transition group-hover:bg-ink-4 group-focus-visible:bg-ember`})})}function zV({chat:e,avatar:t,costume:n,hello:r=W(`editor.chatHello`),placeholder:i=W(`editor.composer`),changedLabel:a=W(`editor.flowChanged`),compact:o,intro:s,closed:c,card:l,foldOn:u}){let[d,f]=(0,G.useState)(!1);(0,G.useEffect)(()=>{u&&f(!1)},[u]);let p=LV(),m=(0,G.useRef)(null),h=(0,G.useRef)(null);(0,G.useEffect)(()=>{m.current?.scrollTo({top:m.current.scrollHeight,behavior:`smooth`})},[e.messages,e.phase]);let g=!o||d,_=e.messages.at(-1),[v,y]=(0,G.useState)(!1),b=(0,G.useRef)(0),x=e=>!c&&e.dataTransfer.types.includes(`Files`);return(0,K.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,onDragEnter:e=>{x(e)&&(e.preventDefault(),b.current+=1,y(!0))},onDragOver:e=>{x(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:()=>{b.current=Math.max(0,b.current-1),b.current===0&&y(!1)},onDrop:e=>{x(e)&&(e.preventDefault(),b.current=0,y(!1),h.current?.add(Array.from(e.dataTransfer.files).map(De)),h.current?.focus())},children:[v?(0,K.jsxs)(`div`,{className:`pointer-events-none absolute inset-3 z-20 flex flex-col items-center justify-center gap-2 rounded-2xl border-2 border-ember border-dashed bg-ember-veil text-[0.875rem] text-ember-strong`,children:[(0,K.jsx)(w,{className:`size-6`}),W(`editor.dropToAttach`)]}):null,(0,K.jsxs)(`div`,{className:o?V(`mb-2 flex min-h-0 flex-col overflow-hidden rounded-2xl bg-card shadow-overlay ring-1 ring-border`,!(_||e.error)&&`hidden`):`contents`,children:[o&&(_||e.error)?(0,K.jsx)(RV,{open:d,height:p.height,onHeight:p.set,onToggle:f}):null,o&&(_||e.error)?(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":d,"aria-label":W(`editor.thread`),onClick:()=>f(e=>!e),className:`flex items-center gap-2 px-4 pb-0.5 text-left text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[!(e.error||d)&&_?.pending?(0,K.jsx)(AV,{chat:e,className:`flex-1`}):(0,K.jsx)(`span`,{className:V(`min-w-0 flex-1 truncate`,e.error&&`text-rose`),children:e.error??(d?W(`editor.thread`):_?.content)}),d?(0,K.jsx)(O,{className:`size-4 shrink-0`}):(0,K.jsx)(Ln,{className:`size-4 shrink-0`})]}):null,(0,K.jsxs)(`div`,{ref:m,className:V(`min-h-0 flex-1 overflow-y-auto px-5 py-5`,!g&&`hidden`),style:o?{height:p.height,flex:`none`}:void 0,children:[e.messages.length===0&&!c?s??(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Dt,{kind:t,costume:n,size:32,interactive:!1}),(0,K.jsx)(`p`,{className:`pt-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:r})]}):null,(0,K.jsx)(MV,{chat:e,avatar:t,costume:n,changedLabel:a,card:l}),e.error?(0,K.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-3 py-2 text-[0.8125rem] text-rose`,children:e.error}):null]})]}),c?(0,K.jsx)(`p`,{className:`m-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.8125rem] text-ink-2 leading-relaxed`,children:c}):(0,K.jsx)(Pe,{ref:h,floating:o,className:o?void 0:`p-3`,placeholder:i,disabled:e.phase!==`idle`,onSend:(t,n)=>e.send(t,n),effort:e.setExtra?{on:!!e.extra,onChange:e.setExtra}:void 0})]})}var BV=1e3;function VV(e){let[t,n]=e.split(`/`);return n&&Vt.includes(t)?{maker:t,cls:n}:{maker:null,cls:e}}var HV=[`low`,`standard`,`high`,`highest`];function UV(e){let t=e.filter(e=>HV.includes(VV(e).cls));return t.find(e=>VV(e).maker)??t[0]??null}function WV(e,t){let n=e.models.find(e=>e.id===t),r=n?UV(n.classes):t;if(!r)return null;let{maker:i,cls:a}=VV(r);return HV.includes(a)&&(i?Yt[i].includes(a):a!==`highest`)?{maker:i,cls:a}:null}function GV(e,t,n,r){let i=t?.way===`C`?t.purposes[n].models:null,a=e.classes[r]?.model;return i&&!i.includes(r)&&a&&i.includes(a)?a:r}var KV=Ht({models:Jt(qt().min(1).max(200)).max(100).nullable(),default:qt().min(1).max(200).nullable(),effortCap:en(Kt).nullable(),efforts:Zt(qt(),Jt(en(Kt)).min(1)).nullable()});Ht({way:en([`A`,`B`,`C`]),purposes:Ht({wizard:KV,assistant:KV,work:KV}),credits:Qt(),ownKeys:Qt(),subscriptions:Qt(),localModels:Qt(),apps:Ht({local:Qt(),subscriptions:Qt()}),masking:Qt(),maskInstructions:qt().max(BV).optional(),maskLabels:Jt(qt().trim().min(1).max(60)).max(20).optional()});var qV={general:`tier.name.general`,"eu-private":`tier.name.eu-private`,"eu-sovereign":`tier.name.eu-sovereign`};function JV(e,t){let n=qV[e];return n?W(n):t}function YV(e){let{tier:t}=e;return t?{...e,tier:{...t,name:JV(t.id,t.name),choices:t.choices.map(e=>({...e,name:JV(e.id,e.name)}))}}:e}function XV(){let e=na(`modelTiers`),{data:t}=Je({queryKey:[`models`],queryFn:()=>H.get(`/api/studio/models`),select:YV,enabled:e});return e?{tier:t?.tier??null,modelPolicy:t?.modelPolicy??null}:{tier:null,modelPolicy:null}}var ZV=e=>!!(e&&(e.rules.regions||e.rules.zdr||e.rules.noTraining)),QV=e=>!!e?.model;function $V(e){let t=e?.name??W(`tier.theModel`);return e&&!QV(e)?W(`tier.reason.${e.reason}`,{model:t}):W(`tier.reason.unbound`)}function eH(e){let t=[e.route,e.region].filter(Boolean).join(`, `);return t?`${e.name} · ${t}`:e.name}function tH(e){let{maker:t,cls:n}=VV(e),r=W(`class.${n}`);return t?`${W(`maker.family.${t}`)} · ${r}`:r}function nH(e){return[...Gt.filter(e=>e!==`classifier`),...Vt.flatMap(t=>Yt[t].map(e=>`${t}/${e}`).filter(t=>t in e.classes))]}function rH(e,t){return t.models??nH(e).filter(t=>QV(e.classes[t]))}function iH(e){return W(`chooser.hint.${VV(e).cls}`)}function aH(e){return e.models.filter(e=>e.kind===`text`)}var oH=(e,t)=>({id:t,model:e.id,name:e.name,hint:iH(t),efforts:e.efforts});function sH(e){return aH(e).flatMap(e=>{let t=e.chooser?UV(e.classes):null;return t?[oH(e,t)]:[]})}function cH(e){return aH(e).flatMap(e=>{let t=e.chooser?null:UV(e.classes);return t?[oH(e,t)]:[]})}function lH(e){return[...sH(e),...cH(e)]}function uH(e,t){let n=e.classes[t],r=QV(n)?n.model:n?null:t,i=r?aH(e).find(e=>e.id===r):void 0,a=i?n?t:UV(i.classes):null;return i&&a?oH(i,a):null}function dH(e){let t=new Set;return e.filter(e=>!e||t.has(e.model)?!1:(t.add(e.model),!0))}function fH(e,t,n){let r=t?.purposes[n]??null,i=t?.way===`C`&&r?rH(e,r):null,a=t?.way===`B`?r?.effortCap??null:null,o=r=>GV(e,t,n,r);return{way:t?.way??`A`,allowed:t=>QV(e.classes[t])&&(!i||i.includes(o(t))),notApproved:t=>QV(e.classes[t])&&!!i&&!i?.includes(o(t)),efforts:e=>i?r?.efforts?.[o(e)]??[...Kt]:a?Kt.slice(0,Kt.indexOf(a)+1):[...Kt],items:i?dH(i.map(t=>uH(e,t))):sH(e),auto:!i,itemFor(t,n){let r=uH(e,t)?.model;return n.find(e=>e.id===t)??n.find(e=>e.model===r)??null},default:r?.default??null,cap:a}}var pH=p.cloudSync();function mH(e){return e?.mode===`local`&&!!e.account&&Ot(e.features,`twoWaySync`)}function hH(){let e=At(),t=mH(e.data),n=Ot(e.data?.features??{},`liveChanges`);return Je({queryKey:pH,queryFn:()=>H.get(`/api/studio/sync`),enabled:t,refetchInterval:t?n?12e4:2e4:!1})}function gH(e){let t=R(),n=Ot(At().data?.features??{},`liveChanges`);return ot({mutationFn:e,onSuccess:e=>{e&&typeof e==`object`&&`spaces`in e?t.setQueryData(pH,e):t.invalidateQueries({queryKey:pH}),!n&&(t.invalidateQueries({queryKey:[`wizard`]}),t.invalidateQueries({queryKey:[`space-page`]}),t.invalidateQueries({queryKey:[`space-table`]}))}})}var _H=e=>new Date(e).toLocaleString(Xt===`de`?`de-AT`:`en-GB`,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}),vH={update_here:`cloudSync.error.updateHere`,update_cloud:`cloudSync.error.updateCloud`,unreachable:`cloudSync.error.unreachable`,signed_out:`cloudSync.error.signedOut`,refused:`cloudSync.error.refused`};function yH(e){let t=e.reason?vH[e.reason]:void 0;return t?W(t):e.message}var bH={space:`cloudSync.kind.space`,wizard:`cloudSync.kind.wizard`,translation:`cloudSync.kind.translation`,message:`cloudSync.kind.message`,page:`cloudSync.kind.page`,table:`cloudSync.kind.table`,row:`cloudSync.kind.row`,category:`cloudSync.kind.category`,file:`cloudSync.kind.file`,connector:`cloudSync.kind.connector`,skill:`cloudSync.kind.skill`},xH={title:`cloudSync.word.title`,markdown:`cloudSync.word.text`,description:`cloudSync.word.description`,steps:`cloudSync.word.steps`,fields:`cloudSync.word.fields`,instructions:`cloudSync.word.instructions`,prompt:`cloudSync.word.prompt`,label:`cloudSync.word.label`,cells:`cloudSync.word.cells`,columns:`cloudSync.word.columns`,name:`cloudSync.word.name`,brand:`cloudSync.word.brand`,facts:`cloudSync.word.facts`,themes:`cloudSync.word.themes`,files:`cloudSync.word.files`,options:`cloudSync.word.options`,categories:`cloudSync.word.categories`,values:`cloudSync.word.values`,texts:`cloudSync.word.texts`,page:`cloudSync.word.page`};function SH(e){return e.split(` › `).map(e=>e.startsWith(`“`)||!xH[e]?e:W(xH[e])).join(` › `)}var CH=new Map,wH=new Set;function TH(e){(0,G.useEffect)(()=>{if(e){CH.set(e,(CH.get(e)??0)+1);for(let e of wH)e();return()=>{CH.set(e,(CH.get(e)??1)-1),CH.get(e)||CH.delete(e);for(let e of wH)e()}}},[e])}function EH(){let[,e]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let t=()=>e(e=>e+1);return wH.add(t),()=>{wH.delete(t)}},[]),[...CH.keys()]}function DH(){let e=hH(),t=gH(()=>H.post(`/api/studio/sync/now`,{})),n=gH(e=>H.put(`/api/studio/sync/spaces/${e.id}`,{on:e.on})),r=e.data;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,K.jsx)(le,{title:W(`cloudSync.title`),hint:W(`cloudSync.hint`),action:(0,K.jsxs)(x,{variant:`secondary`,size:`sm`,busy:t.isPending,onClick:()=>t.mutate(void 0),children:[(0,K.jsx)(j,{className:`size-3.5`}),` `,W(`cloudSync.now`)]}),children:(0,K.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:r.spaces.map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-4 py-3 first:pt-0 last:pb-0`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:e.name}),(0,K.jsx)(OH,{space:e,refusals:r.refusals[e.spaceId]})]}),e.organization?null:(0,K.jsx)(oe,{checked:e.on,label:W(`cloudSync.spaceOn`),disabled:n.isPending,onChange:t=>n.mutate({id:e.spaceId,on:t})})]},e.spaceId))})}),r.conflicts.length?(0,K.jsx)(kH,{view:r}):null,r.merges.length?(0,K.jsx)(MH,{merges:r.merges}):null]}):e.isLoading?(0,K.jsx)(Fe,{className:`size-5`}):null}function OH({space:e,refusals:t}){let n=`mt-0.5 text-[0.8125rem] text-ink-3`;return e.organization?(0,K.jsx)(`p`,{className:n,children:W(`cloudSync.state.otherOrganization`,{name:e.organization})}):e.on?(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[e.error?(0,K.jsxs)(`p`,{className:`text-[0.8125rem] text-rose`,children:[yH(e.error),e.error.reason===`refused`&&t?.length?` ${t.join(` · `)}`:``]}):e.waiting?(0,K.jsx)(v,{tone:`warn`,children:W(`cloudSync.state.waiting`,{count:e.waiting})}):e.conflicts?null:(0,K.jsx)(v,{tone:`live`,children:W(`cloudSync.state.ok`)}),e.conflicts?(0,K.jsx)(v,{tone:`ember`,children:W(`cloudSync.state.conflicts`,{count:e.conflicts})}):null,e.syncedAt?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:W(`cloudSync.state.at`,{when:_H(e.syncedAt)})}):null]}):(0,K.jsx)(`p`,{className:n,children:W(e.here?`cloudSync.state.hereOnly`:`cloudSync.state.cloudOnly`)})}function kH({view:e}){let t=gH(e=>H.post(`/api/studio/sync/spaces/${e}/keep-cloud`,{})),n=[...new Set(e.conflicts.map(e=>e.spaceId))];return(0,K.jsx)(le,{title:W(`cloudSync.conflicts`),hint:W(`cloudSync.conflictsHint`),action:e.conflicts.length>1&&n.length===1?(0,K.jsx)(x,{variant:`secondary`,size:`sm`,busy:t.isPending,onClick:()=>t.mutate(n[0]),children:W(`cloudSync.keepCloudAll`)}):null,children:(0,K.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.conflicts.map(e=>(0,K.jsx)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:(0,K.jsx)(jH,{conflict:e})},e.id))})})}var AH=e=>e===void 0?W(`cloudSync.removed`):typeof e==`string`?e:JSON.stringify(e,null,1);function jH({conflict:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(()=>e.conflicts.map(()=>`local`)),[a,o]=(0,G.useState)(null),s=gH(t=>H.post(`/api/studio/sync/conflicts/${e.id}/resolve`,t)),c=ot({mutationFn:()=>H.post(`/api/studio/sync/conflicts/${e.id}/propose`,{}),onSuccess:e=>o(e.record)}),l=e.deleted===`remote`?W(`cloudSync.conflict.deletedRemote`):e.deleted===`local`?W(`cloudSync.conflict.deletedLocal`):W(`cloudSync.conflict.both`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`font-medium text-[0.9375rem]`,children:[(0,K.jsxs)(`span`,{className:`text-ink-3`,children:[W(bH[e.kind]),` · `]}),e.title]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:l})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(x,{size:`sm`,variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate({take:`remote`}),children:W(`cloudSync.keepCloud`)}),(0,K.jsx)(x,{size:`sm`,variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate({take:`local`}),children:W(`cloudSync.keepLocal`)}),e.conflicts.length?(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>n(e=>!e),children:W(`cloudSync.pick`)}):null,e.deleted?null:(0,K.jsx)(x,{size:`sm`,variant:`ghost`,busy:c.isPending,onClick:()=>c.mutate(),children:W(`cloudSync.ai`)})]}),t?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-paper-2 p-3`,children:[e.conflicts.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`p`,{className:`font-medium text-[0.8125rem]`,children:SH(e.label)}),[`local`,`remote`].map(n=>(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[0.8125rem]`,children:[(0,K.jsx)(`input`,{type:`radio`,className:`mt-1`,checked:r[t]===n,onChange:()=>i(e=>e.map((e,r)=>r===t?n:e))}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`text-ink-3`,children:[W(n===`local`?`cloudSync.here`:`cloudSync.cloud`),`:`,` `]}),(0,K.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:AH(e[n])})]})]},n))]},e.label)),(0,K.jsx)(`div`,{children:(0,K.jsx)(x,{size:`sm`,busy:s.isPending,onClick:()=>s.mutate({choices:r.map(e=>({take:e}))}),children:W(`cloudSync.apply`)})})]}):null,c.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:W(`cloudSync.aiFailed`,{error:c.error.message})}):null,a?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-paper-2 p-3`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:W(`cloudSync.aiProposal`)}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-[0.75rem] text-ink-2`,children:JSON.stringify(a,null,2)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(x,{size:`sm`,busy:s.isPending,onClick:()=>s.mutate({record:a}),children:W(`cloudSync.aiTake`)})})]}):null,s.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:s.error.message}):null]})}function MH({merges:e}){return(0,K.jsx)(le,{title:W(`cloudSync.merges`),hint:W(`cloudSync.mergesHint`),children:(0,K.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.map(e=>(0,K.jsx)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:(0,K.jsx)(NH,{merge:e})},e.id))})})}function NH({merge:e,compact:t}){let n=gH(()=>H.post(`/api/studio/sync/merges/seen`,{ids:[e.id]})),r=gH(t=>H.post(`/api/studio/sync/merges/${e.id}/undo`,{take:t}));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`text-[0.8125rem]`,children:[(0,K.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:t?W(`cloudSync.merged`):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`text-ink-3`,children:[W(bH[e.kind]),` · `]}),e.title]})}),e.local.length?(0,K.jsx)(`p`,{className:`mt-0.5 text-ink-3`,children:W(`cloudSync.mergedHere`,{places:e.local.map(SH).join(`, `)})}):null,e.remote.length?(0,K.jsx)(`p`,{className:`mt-0.5 text-ink-3`,children:W(`cloudSync.mergedThere`,{places:e.remote.map(SH).join(`, `)})}):null]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(x,{size:`sm`,variant:`secondary`,busy:n.isPending,onClick:()=>n.mutate(void 0),children:W(`cloudSync.ok`)}),(0,K.jsx)(x,{size:`sm`,variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(`local`),children:W(`cloudSync.undoLocal`)}),(0,K.jsx)(x,{size:`sm`,variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(`remote`),children:W(`cloudSync.undoRemote`)})]})]})}function PH({kind:e,item:t}){let n=hH(),r=n.data?.conflicts.find(n=>n.kind===e&&n.item===t),i=n.data?.merges.find(n=>n.kind===e&&n.item===t);return TH(r?r.id:null),r?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-border-soft border-b bg-amber-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,K.jsx)(Un,{className:`size-4 shrink-0 text-amber`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1`,children:W(`cloudSync.conflict.both`)}),(0,K.jsx)(Se,{to:`/settings/cloud`,className:`shrink-0 underline transition hover:text-ink`,children:W(`cloudSync.settle`)})]}):i?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-border-soft border-b bg-moss-tint px-4 py-2 sm:px-6`,children:[(0,K.jsx)(sr,{className:`mt-1 size-4 shrink-0 text-moss`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(NH,{merge:i,compact:!0})})]}):null}function FH({me:e}){let t=hH(),n=EH(),r=(t.data?.conflicts??[]).filter(e=>!n.includes(e.id)).length;return!mH(e)||!r?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-amber-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,K.jsx)(Un,{className:`size-4 shrink-0 text-amber`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1`,children:W(`cloudSync.bar`,{count:r})}),(0,K.jsx)(Se,{to:`/settings/cloud`,className:`shrink-0 underline transition hover:text-ink`,children:W(`cloudSync.settle`)})]})}var IH=2,LH=1,RH=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(IH,Math.floor(u/e.css.cell.width)),rows:Math.max(LH,Math.floor(l/e.css.cell.height))}}},zH=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=VH.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function BH(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var VH=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!BH(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},HH=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function UH(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var WH=class{constructor(e=UH,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||HH;this._linkProvider=this._terminal.registerLinkProvider(new zH(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},GH=Object.defineProperty,KH=Object.getOwnPropertyDescriptor,qH=(e,t)=>{for(var n in t)GH(e,n,{get:t[n],enumerable:!0})},JH=(e,t,n,r)=>{for(var i=r>1?void 0:r?KH(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&GH(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),YH=`Terminal input`,XH={get:()=>YH,set:e=>YH=e},ZH=`Too much output to announce, navigate to rows manually to read`,QH={get:()=>ZH,set:e=>ZH=e};function $H(e){return e.replace(/\r?\n/g,`\r`)}function eU(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function tU(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function nU(e,t,n,r){e.stopPropagation(),e.clipboardData&&rU(e.clipboardData.getData(`text/plain`),t,n,r)}function rU(e,t,n,r){e=$H(e),e=eU(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function iU(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function aU(e,t,n,r,i){iU(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function oU(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function sU(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var cU=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},lU=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},uU=``,dU=` `,fU=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pU}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pU=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mU=class e extends fU{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pU,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?oU(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hU=`di$target`,gU=`di$dependencies`,_U=new Map;function vU(e){return e[gU]||[]}function yU(e){if(_U.has(e))return _U.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);bU(t,e,r)};return t._id=e,_U.set(e,t),t}function bU(e,t,n){t[hU]===t?t[gU].push({id:e,index:n}):(t[gU]=[{id:e,index:n}],t[hU]=t)}var xU=yU(`BufferService`),SU=yU(`CoreMouseService`),CU=yU(`CoreService`),wU=yU(`CharsetService`),TU=yU(`InstantiationService`),EU=yU(`LogService`),DU=yU(`OptionsService`),OU=yU(`OscLinkService`),kU=yU(`UnicodeService`),AU=yU(`DecorationService`),jU=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new mU,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):MU(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};jU=JH([Z(0,xU),Z(1,DU),Z(2,OU)],jU);function MU(e,t){if(confirm(`Do you want to navigate to ${t}?
95
-
96
- WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var NU=yU(`CharSizeService`),PU=yU(`CoreBrowserService`),FU=yU(`MouseService`),IU=yU(`RenderService`),LU=yU(`SelectionService`),RU=yU(`CharacterJoinerService`),zU=yU(`ThemeService`),BU=yU(`LinkProviderService`),VU=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?qU.isErrorNoTelemetry(e)?new qU(e.message+`
97
-
98
- `+e.stack):Error(e.message+`
99
-
100
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function HU(e){WU(e)||VU.onUnexpectedError(e)}var UU=`Canceled`;function WU(e){return e instanceof GU||e instanceof Error&&e.name===UU&&e.message===UU}var GU=class extends Error{constructor(){super(UU),this.name=this.message}};function KU(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var qU=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},JU=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function YU(e,t=0){return e[e.length-(1+t)]}var XU;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(XU||={});var ZU=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||XU.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};ZU.empty=new ZU(e=>{});function QU(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var $U;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})($U||={});var eW=null;function tW(e){return eW?.trackDisposable(e),e}function nW(e){eW?.markAsDisposed(e)}function rW(e,t){eW?.setParent(e,t)}function iW(e){return eW?.markAsSingleton(e),e}function aW(e){if($U.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function oW(...e){return sW(()=>aW(e))}function sW(e){let t=tW({dispose:QU(()=>{nW(t),e()})});return t}var cW=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,tW(this)}dispose(){this._isDisposed||(nW(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{aW(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return rW(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),rW(e,null))}};cW.DISABLE_DISPOSED_WARNING=!1;var lW=cW,uW=class{constructor(){this._store=new lW,tW(this),rW(this._store,this)}dispose(){nW(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};uW.None=Object.freeze({dispose(){}});var dW=class{constructor(){this._isDisposed=!1,tW(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&rW(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,nW(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&rW(e,null),e}},fW=typeof window==`object`?window:globalThis,pW=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};pW.Undefined=new pW(void 0);var mW=pW,hW=class{constructor(){this._first=mW.Undefined,this._last=mW.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mW.Undefined}clear(){let e=this._first;for(;e!==mW.Undefined;){let t=e.next;e.prev=mW.Undefined,e.next=mW.Undefined,e=t}this._first=mW.Undefined,this._last=mW.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new mW(e);if(this._first===mW.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==mW.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mW.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mW.Undefined&&e.next!==mW.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mW.Undefined&&e.next===mW.Undefined?(this._first=mW.Undefined,this._last=mW.Undefined):e.next===mW.Undefined?(this._last=this._last.prev,this._last.next=mW.Undefined):e.prev===mW.Undefined&&(this._first=this._first.next,this._first.prev=mW.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==mW.Undefined;)yield e.element,e=e.next}},gW=globalThis.performance&&typeof globalThis.performance.now==`function`,_W=class e{static create(t){return new e(t)}constructor(e){this._now=gW&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},vW;(e=>{e.None=()=>uW.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(oW(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof lW?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(vW||={});var yW=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new _W,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};yW.all=new Set,yW._idPool=0;var bW=yW,xW=-1,SW=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new TW(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};SW._idPool=1;var CW=SW,wW=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
101
- `).slice(2).join(`
102
- `))}},TW=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},EW=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},DW=0,OW=class{constructor(e){this.value=e,this.id=DW++}},kW=2,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=xW>0||this._options?.leakWarningThreshold?new CW(e?.onListenerError??HU,this._options?.leakWarningThreshold??xW):void 0,this._perfMon=this._options?._profName?new bW(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new EW(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||HU)(n),uW.None}if(this._disposed)return uW.None;t&&(e=e.bind(t));let r=new OW(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=wW.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof OW?(this._deliveryQueue??=new AW,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=sW(()=>{i?.(),this._removeListener(r)});return n instanceof lW?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*kW<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||HU;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof OW)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},AW=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},jW=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};jW.INSTANCE=new jW;var MW=jW;function NW(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}MW.INSTANCE.onDidChangeZoomLevel;function PW(e){return MW.INSTANCE.getZoomFactor(e)}MW.INSTANCE.onDidChangeFullscreen;var FW=typeof navigator==`object`?navigator.userAgent:``,IW=FW.indexOf(`Firefox`)>=0,LW=FW.indexOf(`AppleWebKit`)>=0,RW=FW.indexOf(`Chrome`)>=0,zW=!RW&&FW.indexOf(`Safari`)>=0;FW.indexOf(`Electron/`),FW.indexOf(`Android`);var BW=!1;if(typeof fW.matchMedia==`function`){let e=fW.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=fW.matchMedia(`(display-mode: fullscreen)`);BW=e.matches,NW(fW,e,({matches:e})=>{BW&&t.matches||(BW=e)})}function VW(){return BW}var HW=`en`,UW=!1,WW=!1,GW=!1,KW=!1,qW=!1,JW=HW,YW,XW=globalThis,ZW;typeof XW.vscode<`u`&&typeof XW.vscode.process<`u`?ZW=XW.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(ZW=process);var QW=typeof ZW?.versions?.electron==`string`&&ZW?.type===`renderer`;if(typeof ZW==`object`){UW=ZW.platform===`win32`,WW=ZW.platform===`darwin`,GW=ZW.platform===`linux`,GW&&ZW.env.SNAP&&ZW.env.SNAP_REVISION,ZW.env.CI||ZW.env.BUILD_ARTIFACTSTAGINGDIRECTORY,JW=HW;let e=ZW.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,JW=t.resolvedLanguage||HW,t.languagePack?.translationsConfigFile}catch{}KW=!0}else typeof navigator==`object`&&!QW?(YW=navigator.userAgent,UW=YW.indexOf(`Windows`)>=0,WW=YW.indexOf(`Macintosh`)>=0,(YW.indexOf(`Macintosh`)>=0||YW.indexOf(`iPad`)>=0||YW.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,GW=YW.indexOf(`Linux`)>=0,YW?.indexOf(`Mobi`),qW=!0,JW=globalThis._VSCODE_NLS_LANGUAGE||HW,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var $W=UW,eG=WW,tG=GW,nG=KW;qW&&typeof XW.importScripts==`function`&&XW.origin;var rG=YW,iG=JW,aG;(e=>{function t(){return iG}e.value=t;function n(){return iG.length===2?iG===`en`:iG.length>=3&&iG[0]===`e`&&iG[1]===`n`&&iG[2]===`-`}e.isDefaultVariant=n;function r(){return iG===`en`}e.isDefault=r})(aG||={});var oG=typeof XW.postMessage==`function`&&!XW.importScripts;(()=>{if(oG){let e=[];XW.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),XW.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var sG=!!(rG&&rG.indexOf(`Chrome`)>=0);rG&&rG.indexOf(`Firefox`),!sG&&rG&&rG.indexOf(`Safari`),rG&&rG.indexOf(`Edg/`),rG&&rG.indexOf(`Android`);var cG=typeof navigator==`object`?navigator:{};nG||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||cG&&cG.clipboard&&cG.clipboard.writeText,nG||cG&&cG.clipboard&&cG.clipboard.readText,nG||VW()||cG.keyboard,`ontouchstart`in fW||cG.maxTouchPoints,fW.PointerEvent&&(`ontouchstart`in fW||navigator.maxTouchPoints);var lG=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},uG=new lG,dG=new lG,fG=new lG,pG=Array(230),mG;(e=>{function t(e){return uG.keyCodeToStr(e)}e.toString=t;function n(e){return uG.strToKeyCode(e)}e.fromString=n;function r(e){return dG.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return fG.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return dG.strToKeyCode(e)||fG.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return uG.keyCodeToStr(e)}e.toElectronAccelerator=o})(mG||={});var hG=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new gG([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},gG=class{constructor(e){if(e.length===0)throw KU(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function _G(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return mG.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(IW)switch(t){case 59:return 85;case 60:if(tG)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(eG)return 57}else if(LW&&(eG&&t===93||!eG&&t===92))return 57;return pG[t]||0}var vG=eG?256:2048,yG=512,bG=1024,xG=eG?2048:256,SG=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=_G(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=vG),this.altKey&&(t|=yG),this.shiftKey&&(t|=bG),this.metaKey&&(t|=xG),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new hG(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},CG=new WeakMap;function wG(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var TG=class{static getSameOriginWindowChain(e){let t=CG.get(e);if(!t){t=[],CG.set(e,t);let n=e,r;do r=wG(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},EG=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=TG.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},DG=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(RW){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?IW&&!eG?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=zW&&$W?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?IW&&!eG?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},OG=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),kG;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof AG?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:vW.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:OG})})(kG||={});var AG=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?OG:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},jG=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new JU(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new JU(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},MG=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new JU(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=sW(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var NG;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(NG||={});var PG=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await vW.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};PG.EMPTY=PG.fromArray([]);function FG(e){return IG(e,0)}function IG(e,t){switch(typeof e){case`object`:return e===null?LG(349,t):Array.isArray(e)?BG(e,t):VG(e,t);case`string`:return zG(e,t);case`boolean`:return RG(e,t);case`number`:return LG(e,t);case`undefined`:return LG(937,t);default:return LG(617,t)}}function LG(e,t){return(t<<5)-t+e|0}function RG(e,t){return LG(e?433:863,t)}function zG(e,t){t=LG(149417,t);for(let n=0,r=e.length;n<r;n++)t=LG(e.charCodeAt(n),t);return t}function BG(e,t){return t=LG(104579,t),e.reduce((e,t)=>IG(t,e),t)}function VG(e,t){return t=LG(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=zG(n,t),IG(e[n],t)),t)}var{registerWindow:HG,getWindow:UG,getDocument:WG,getWindows:GG,getWindowsCount:KG,getWindowId:qG,getWindowById:JG,hasWindow:YG,onDidRegisterWindow:XG,onWillUnregisterWindow:ZG,onDidUnregisterWindow:QG}=function(){let e=new Map,t={window:fW,disposables:new lW};e.set(fW.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return uW.None;let a=new lW,o={window:t,disposables:a.add(new lW)};return e.set(t.vscodeWindowId,o),a.add(sW(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(eK(t,lK.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:fW},getDocument(e){return UG(e).document}}}(),$G=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function eK(e,t,n,r){return new $G(e,t,n,r)}function tK(e,t){return function(n){return t(new EG(e,n))}}function nK(e){return function(t){return e(new SG(t))}}var rK=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=tK(UG(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=nK(n)),eK(e,t,i,r)},iK,aK=class extends MG{constructor(e){super(),this.defaultTarget=e&&UG(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},oK=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){HU(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(oK.sort),a.shift().execute();r.set(i,!1)};iK=(t,r,a=0)=>{let o=qG(t),s=new oK(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var sK=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};sK.None=new sK(0,0);function cK(e){let t=e.getBoundingClientRect(),n=UG(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=FG(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(sW(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var lK={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:LW?`webkitAnimationStart`:`animationstart`,ANIMATION_END:LW?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:LW?`webkitAnimationIteration`:`animationiteration`},uK=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=dK(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=dK(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=dK(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=dK(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=dK(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=dK(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=dK(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=dK(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=dK(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=dK(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=dK(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=dK(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=dK(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=dK(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function dK(e){return typeof e==`number`?`${e}px`:e}function fK(e){return new uK(e)}var pK=class{constructor(){this._hooks=new lW,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(sW(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=UG(e)}this._hooks.add(eK(a,lK.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(eK(a,lK.POINTER_UP,e=>this.stopMonitoring(!0)))}};function mK(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var hK;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(hK||={});var gK=class e extends uW{constructor(){super(),this.dispatched=!1,this.targets=new hW,this.ignoreTargets=new hW,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(vW.runAndSubscribe(XG,({window:e,disposables:t})=>{t.add(eK(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(eK(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(eK(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:fW,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=iW(new e),sW(e.INSTANCE.targets.push(t))):uW.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=iW(new e),sW(e.INSTANCE.ignoreTargets.push(t))):uW.None}static isTouchDevice(){return`ontouchstart`in fW||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(hK.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-YU(s.rollingPageX))<30&&Math.abs(s.initialPageY-YU(s.rollingPageY))<30){let e=this.newGestureEvent(hK.Tap,s.initialTarget);e.pageX=YU(s.rollingPageX),e.pageY=YU(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-YU(s.rollingPageX))<30&&Math.abs(s.initialPageY-YU(s.rollingPageY))<30){let e=this.newGestureEvent(hK.Contextmenu,s.initialTarget);e.pageX=YU(s.rollingPageX),e.pageY=YU(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=YU(s.rollingPageX),n=YU(s.rollingPageY),i=YU(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(hK.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===hK.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===hK.Change||t.type===hK.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=iK(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(hK.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(hK.Change,i.initialTarget);a.translationX=r.pageX-YU(i.rollingPageX),a.translationY=r.pageY-YU(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};gK.SCROLL_FRICTION=-.005,gK.HOLD_DELAY=700,gK.CLEAR_TAP_COUNT_TIME=400,JH([mK],gK,`isTouchDevice`,1);var _K=gK,vK=class extends uW{onclick(e,t){this._register(eK(e,lK.CLICK,n=>t(new EG(UG(e),n))))}onmousedown(e,t){this._register(eK(e,lK.MOUSE_DOWN,n=>t(new EG(UG(e),n))))}onmouseover(e,t){this._register(eK(e,lK.MOUSE_OVER,n=>t(new EG(UG(e),n))))}onmouseleave(e,t){this._register(eK(e,lK.MOUSE_LEAVE,n=>t(new EG(UG(e),n))))}onkeydown(e,t){this._register(eK(e,lK.KEY_DOWN,e=>t(new SG(e))))}onkeyup(e,t){this._register(eK(e,lK.KEY_UP,e=>t(new SG(e))))}oninput(e,t){this._register(eK(e,lK.INPUT,t))}onblur(e,t){this._register(eK(e,lK.BLUR,t))}onfocus(e,t){this._register(eK(e,lK.FOCUS,t))}onchange(e,t){this._register(eK(e,lK.CHANGE,t))}ignoreGesture(e){return _K.ignoreTarget(e)}},yK=11,bK=class extends vK{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=yK+`px`,this.domNode.style.height=yK+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new pK),this._register(rK(this.bgDomNode,lK.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(rK(this.domNode,lK.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new aK),this._pointerdownScheduleRepeatTimer=this._register(new jG)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,UG(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},xK=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},SK=class extends uW{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new xK(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new EK(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=EK.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},CK=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function wK(e,t){let n=t-e;return function(t){return e+n*OK(t)}}function TK(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var EK=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),TK(wK(e,r),wK(i,t),.33)}return wK(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new CK(this.scrollLeft(t),this.scrollTop(t),!1):new CK(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function DK(e){return e**3}function OK(e){return 1-DK(1-e)}var kK=class extends uW{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new jG)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},AK=140,jK=class extends vK{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new kK(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pK),this._shouldRender=!0,this.domNode=fK(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(eK(this.domNode.domNode,lK.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new bK(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=fK(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(eK(this.slider.domNode,lK.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=cK(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if($W&&a>AK){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},MK=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},NK=class extends jK{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new MK(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},PK=class extends jK{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new MK(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},FK=500,IK=50,LK=!0,RK=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},zK=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(1);return t<=.5}acceptStandardWheelEvent(e){if(RW){let t=PW(UG(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new RK(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};zK.INSTANCE=new zK;var BK=zK,VK=class extends vK{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=UK(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new PK(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new NK(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=fK(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=fK(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=fK(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new jG),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=aW(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,eG&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new DG(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=aW(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(eK(this._listenOnDomNode,lK.MOUSE_WHEEL,e=>{this._onMouseWheel(new DG(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=BK.INSTANCE;LK&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!eG&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=IK*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=IK*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(LK&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),FK)}},HK=class extends VK{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function UK(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,eG&&(t.className+=` mac`),t}var WK=class extends uW{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new SK({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>iK(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new HK(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(vW.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(sW(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(sW(()=>this._styleElement.remove())),this._register(vW.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
103
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};WK=JH([Z(2,xU),Z(3,PU),Z(4,SU),Z(5,zU),Z(6,DU),Z(7,IU)],WK);var GK=class extends uW{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(sW(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};GK=JH([Z(1,xU),Z(2,PU),Z(3,AU),Z(4,IU)],GK);var KK=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},qK={full:0,left:0,center:0,right:0},JK={full:0,left:0,center:0,right:0},YK={full:0,left:0,center:0,right:0},XK=class extends uW{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new KK,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(sW(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);JK.full=this._canvas.width,JK.left=e,JK.center=t,JK.right=e,this._refreshDrawHeightConstants(),YK.full=1,YK.left=1,YK.center=1+JK.left,YK.right=1+JK.left+JK.center}_refreshDrawHeightConstants(){qK.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);qK.left=t,qK.center=t,qK.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qK.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qK.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qK.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qK.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(YK[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-qK[e.position||`full`]/2),JK[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+qK[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};XK=JH([Z(2,xU),Z(3,AU),Z(4,IU),Z(5,DU),Z(6,zU),Z(7,PU)],XK);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
104
- `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var ZK;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(ZK||={});var QK;(e=>e.ST=`${$.ESC}\\`)(QK||={});var $K=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};$K=JH([Z(2,xU),Z(3,DU),Z(4,CU),Z(5,IU)],$K);var eq=0,tq=0,nq=0,rq=0,iq={css:`#00000000`,rgba:0},aq;(e=>{function t(e,t,n,r){return r===void 0?`#${uq(e)}${uq(t)}${uq(n)}`:`#${uq(e)}${uq(t)}${uq(n)}${uq(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(aq||={});var oq;(e=>{function t(e,t){if(rq=(t.rgba&255)/255,rq===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return eq=a+Math.round((n-a)*rq),tq=o+Math.round((r-o)*rq),nq=s+Math.round((i-s)*rq),{css:aq.toCss(eq,tq,nq),rgba:aq.toRgba(eq,tq,nq)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=lq.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return aq.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[eq,tq,nq]=lq.toChannels(t),{css:aq.toCss(eq,tq,nq),rgba:t}}e.opaque=i;function a(e,t){return rq=Math.round(t*255),[eq,tq,nq]=lq.toChannels(e.rgba),{css:aq.toCss(eq,tq,nq,rq),rgba:aq.toRgba(eq,tq,nq,rq)}}e.opacity=a;function o(e,t){return rq=e.rgba&255,a(e,rq*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(oq||={});var sq;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return eq=parseInt(e.slice(1,2).repeat(2),16),tq=parseInt(e.slice(2,3).repeat(2),16),nq=parseInt(e.slice(3,4).repeat(2),16),aq.toColor(eq,tq,nq);case 5:return eq=parseInt(e.slice(1,2).repeat(2),16),tq=parseInt(e.slice(2,3).repeat(2),16),nq=parseInt(e.slice(3,4).repeat(2),16),rq=parseInt(e.slice(4,5).repeat(2),16),aq.toColor(eq,tq,nq,rq);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return eq=parseInt(r[1]),tq=parseInt(r[2]),nq=parseInt(r[3]),rq=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),aq.toColor(eq,tq,nq,rq);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[eq,tq,nq,rq]=t.getImageData(0,0,1,1).data,rq!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:aq.toRgba(eq,tq,nq,rq),css:e}}e.toColor=r})(sq||={});var cq;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(cq||={});var lq;(e=>{function t(e,t){if(rq=(t&255)/255,rq===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return eq=a+Math.round((n-a)*rq),tq=o+Math.round((r-o)*rq),nq=s+Math.round((i-s)*rq),aq.toRgba(eq,tq,nq)}e.blend=t;function n(e,t,n){let a=cq.relativeLuminance(e>>8),o=cq.relativeLuminance(t>>8);if(dq(a,o)<n){if(o<a){let o=r(e,t,n),s=dq(a,cq.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>dq(a,cq.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=dq(a,cq.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>dq(a,cq.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=dq(cq.relativeLuminance2(o,s,c),cq.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=dq(cq.relativeLuminance2(o,s,c),cq.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=dq(cq.relativeLuminance2(o,s,c),cq.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=dq(cq.relativeLuminance2(o,s,c),cq.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(lq||={});function uq(e){let t=e.toString(16);return t.length<2?`0`+t:t}function dq(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var fq=class extends fU{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pq=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new mU}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||dU.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)pq._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||dU.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};pq=JH([Z(0,xU)],pq);function mq(e){return 57508<=e&&e<=57558}function hq(e){return 9472<=e&&e<=9631}function gq(e){return mq(e)||hq(e)}function _q(){return{css:{canvas:vq(),cell:vq()},device:{canvas:vq(),cell:vq(),char:{width:0,height:0,left:0,top:0}}}}function vq(){return{width:0,height:0}}var yq=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new mU,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new fq(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let R=N.getChars()||dU;if(R===` `&&(N.isUnderline()||N.isOverline())&&(R=`\xA0`),T=m*s-c.get(R,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!L&&j){N.isInvisible()?_+=dU:_+=R,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?dU:N.getChars()||dU,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${fU.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let ee=N.getFgColor(),te=N.getFgColorMode(),ne=N.getBgColor(),z=N.getBgColorMode(),re=!!N.isInverse();if(re){let e=ee;ee=ne,ne=e;let t=te;te=z,z=t}let ie,B,ae=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&ae||(e.backgroundColorRGB&&(z=50331648,ne=e.backgroundColorRGB.rgba>>8&16777215,ie=e.backgroundColorRGB),e.foregroundColorRGB&&(te=50331648,ee=e.foregroundColorRGB.rgba>>8&16777215,B=e.foregroundColorRGB),ae=e.options.layer===`top`)}),!ae&&P&&(ie=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ne=ie.rgba>>8&16777215,z=50331648,ae=!0,p.selectionForeground&&(te=50331648,ee=p.selectionForeground.rgba>>8&16777215,B=p.selectionForeground)),ae&&D.push(`xterm-decoration-top`);let oe;switch(z){case 16777216:case 33554432:oe=p.ansi[ne],D.push(`xterm-bg-${ne}`);break;case 50331648:oe=aq.toColor(ne>>16,ne>>8&255,ne&255),this._addStyle(h,`background-color:#${bq((ne>>>0).toString(16),`0`,6)}`);break;default:re?(oe=p.foreground,D.push(`xterm-bg-257`)):oe=p.background}switch(ie||N.isDim()&&(ie=oq.multiplyOpacity(oe,.5)),te){case 16777216:case 33554432:N.isBold()&&ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ee+=8),this._applyMinimumContrast(h,oe,p.ansi[ee],N,ie,void 0)||D.push(`xterm-fg-${ee}`);break;case 50331648:let e=aq.toColor(ee>>16&255,ee>>8&255,ee&255);this._applyMinimumContrast(h,oe,e,N,ie,B)||this._addStyle(h,`color:#${bq(ee.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,oe,p.foreground,N,ie,B)||re&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||gq(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=oq.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};yq=JH([Z(1,RU),Z(2,DU),Z(3,PU),Z(4,CU),Z(5,AU),Z(6,zU)],yq);function bq(e,t,n){for(;e.length<n;)e=t+e;return e}var xq=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Sq=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Cq(){return new Sq}var wq=`xterm-dom-renderer-owner-`,Tq=`xterm-rows`,Eq=`xterm-fg-`,Dq=`xterm-bg-`,Oq=`xterm-focus`,kq=`xterm-selection`,Aq=1,jq=class extends uW{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=Aq++,this._rowElements=[],this._selectionRenderModel=Cq(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Tq),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(kq),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=_q(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(yq,document),this._element.classList.add(wq+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(sW(()=>{this._element.classList.remove(wq+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new xq(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Tq} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Tq} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Tq} .xterm-dim { color: ${oq.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Tq}.${Oq} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Tq}.${Oq} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Tq}.${Oq} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Tq} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Tq} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Tq} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Tq} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Tq} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${kq} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${kq} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${kq} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Eq}${n} { color: ${r.css}; }${this._terminalSelector} .${Eq}${n}.xterm-dim { color: ${oq.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Dq}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Eq}257 { color: ${oq.opaque(e.background).css}; }${this._terminalSelector} .${Eq}257.xterm-dim { color: ${oq.multiplyOpacity(oq.opaque(e.background),.5).css}; }${this._terminalSelector} .${Dq}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Oq),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Oq),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${wq}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};jq=JH([Z(7,TU),Z(8,NU),Z(9,DU),Z(10,xU),Z(11,CU),Z(12,PU),Z(13,zU)],jq);var Mq=class extends uW{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Fq(this._optionsService))}catch{this._measureStrategy=this._register(new Pq(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Mq=JH([Z(2,DU)],Mq);var Nq=class extends uW{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Pq=class extends Nq{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Fq=class extends Nq{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Iq=class extends uW{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Lq(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(vW.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(eK(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(eK(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Lq=class extends uW{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new dW),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(sW(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=eK(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Rq=class extends uW{constructor(){super(),this.linkProviders=[],this._register(sW(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function zq(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function Bq(e,t,n,r,i,a,o,s,c){if(!a)return;let l=zq(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var Vq=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Bq(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=zq(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Vq=JH([Z(0,IU),Z(1,NU)],Vq);var Hq=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Uq={};qH(Uq,{getSafariVersion:()=>Xq,isChromeOS:()=>nJ,isFirefox:()=>qq,isIpad:()=>Qq,isIphone:()=>$q,isLegacyEdge:()=>Jq,isLinux:()=>tJ,isMac:()=>Zq,isNode:()=>Wq,isSafari:()=>Yq,isWindows:()=>eJ});var Wq=typeof process<`u`&&`title`in process,Gq=Wq?`node`:navigator.userAgent,Kq=Wq?`node`:navigator.platform,qq=Gq.includes(`Firefox`),Jq=Gq.includes(`Edge`),Yq=/^((?!chrome|android).)*safari/i.test(Gq);function Xq(){if(!Yq)return 0;let e=Gq.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Zq=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Kq),Qq=Kq===`iPad`,$q=Kq===`iPhone`,eJ=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Kq),tJ=Kq.indexOf(`Linux`)>=0,nJ=/\bCrOS\b/.test(Gq),rJ=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},iJ=class extends rJ{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},aJ=class extends rJ{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},oJ=!Wq&&`requestIdleCallback`in window?aJ:iJ,sJ=class{constructor(){this._queue=new oJ}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},cJ=class extends uW{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new dW),this._pausedResizeTask=new sJ,this._observerDisposable=this._register(new dW),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Hq((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new lJ(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(sW(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=sW(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};cJ=JH([Z(2,DU),Z(3,NU),Z(4,CU),Z(5,AU),Z(6,xU),Z(7,PU),Z(8,zU)],cJ);var lJ=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function uJ(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return pJ(i,a,e,t,n,r)+mJ(a,t,n,r)+hJ(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,SJ(Math.abs(i-e),xJ(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return SJ(fJ(a>t?e:i,n)+(s-1)*n.cols+1+dJ(a>t?i:e,n),xJ(o,r))}function dJ(e,t){return e-1}function fJ(e,t){return t.cols-e}function pJ(e,t,n,r,i,a){return mJ(t,r,i,a).length===0?``:SJ(bJ(e,t,e,t-_J(t,i),!1,i).length,xJ(`D`,a))}function mJ(e,t,n,r){let i=e-_J(e,n),a=t-_J(t,n);return SJ(Math.abs(i-a)-gJ(e,t,n),xJ(yJ(e,t),r))}function hJ(e,t,n,r,i,a){let o;o=mJ(t,r,i,a).length>0?r-_J(r,i):t;let s=r,c=vJ(e,t,n,r,i,a);return SJ(bJ(e,o,n,s,c===`C`,i).length,xJ(c,a))}function gJ(e,t,n){let r=0,i=e-_J(e,n),a=t-_J(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=yJ(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function _J(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function vJ(e,t,n,r,i,a){let o;return o=mJ(n,r,i,a).length>0?r-_J(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function yJ(e,t){return e>t?`A`:`B`}function bJ(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function xJ(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function SJ(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var CJ=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function wJ(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var TJ=50,EJ=15,DJ=50,OJ=500,kJ=RegExp(`\xA0`,`g`),AJ=class extends uW{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mU,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new CJ(this._bufferService),this._activeSelectionMode=0,this._register(sW(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(kJ,` `)).join(eJ?`\r
105
- `:`
106
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),tJ&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=wJ(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=zq(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-TJ),TJ),t/=TJ,t/Math.abs(t)+Math.round(t*(EJ-1)))}shouldForceSelection(e){return Zq?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),DJ)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Zq&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<OJ&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=uJ(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=wJ(n,this._bufferService.cols)}};AJ=JH([Z(3,xU),Z(4,CU),Z(5,FU),Z(6,DU),Z(7,IU),Z(8,PU)],AJ);var jJ=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},MJ=class{constructor(){this._color=new jJ,this._css=new jJ}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},NJ=Object.freeze((()=>{let e=[sq.toColor(`#2e3436`),sq.toColor(`#cc0000`),sq.toColor(`#4e9a06`),sq.toColor(`#c4a000`),sq.toColor(`#3465a4`),sq.toColor(`#75507b`),sq.toColor(`#06989a`),sq.toColor(`#d3d7cf`),sq.toColor(`#555753`),sq.toColor(`#ef2929`),sq.toColor(`#8ae234`),sq.toColor(`#fce94f`),sq.toColor(`#729fcf`),sq.toColor(`#ad7fa8`),sq.toColor(`#34e2e2`),sq.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:aq.toCss(r,i,a),rgba:aq.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:aq.toCss(n,n,n),rgba:aq.toRgba(n,n,n)})}return e})()),PJ=sq.toColor(`#ffffff`),FJ=sq.toColor(`#000000`),IJ=sq.toColor(`#ffffff`),LJ=FJ,RJ={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},zJ=PJ,BJ=class extends uW{constructor(e){super(),this._optionsService=e,this._contrastCache=new MJ,this._halfContrastCache=new MJ,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:PJ,background:FJ,cursor:IJ,cursorAccent:LJ,selectionForeground:void 0,selectionBackgroundTransparent:RJ,selectionBackgroundOpaque:oq.blend(FJ,RJ),selectionInactiveBackgroundTransparent:RJ,selectionInactiveBackgroundOpaque:oq.blend(FJ,RJ),scrollbarSliderBackground:oq.opacity(PJ,.2),scrollbarSliderHoverBackground:oq.opacity(PJ,.4),scrollbarSliderActiveBackground:oq.opacity(PJ,.5),overviewRulerBorder:PJ,ansi:NJ.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=VJ(e.foreground,PJ),t.background=VJ(e.background,FJ),t.cursor=oq.blend(t.background,VJ(e.cursor,IJ)),t.cursorAccent=oq.blend(t.background,VJ(e.cursorAccent,LJ)),t.selectionBackgroundTransparent=VJ(e.selectionBackground,RJ),t.selectionBackgroundOpaque=oq.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=VJ(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=oq.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?VJ(e.selectionForeground,iq):void 0,t.selectionForeground===iq&&(t.selectionForeground=void 0),oq.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=oq.opacity(t.selectionBackgroundTransparent,.3)),oq.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=oq.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=VJ(e.scrollbarSliderBackground,oq.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=VJ(e.scrollbarSliderHoverBackground,oq.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=VJ(e.scrollbarSliderActiveBackground,oq.opacity(t.foreground,.5)),t.overviewRulerBorder=VJ(e.overviewRulerBorder,zJ),t.ansi=NJ.slice(),t.ansi[0]=VJ(e.black,NJ[0]),t.ansi[1]=VJ(e.red,NJ[1]),t.ansi[2]=VJ(e.green,NJ[2]),t.ansi[3]=VJ(e.yellow,NJ[3]),t.ansi[4]=VJ(e.blue,NJ[4]),t.ansi[5]=VJ(e.magenta,NJ[5]),t.ansi[6]=VJ(e.cyan,NJ[6]),t.ansi[7]=VJ(e.white,NJ[7]),t.ansi[8]=VJ(e.brightBlack,NJ[8]),t.ansi[9]=VJ(e.brightRed,NJ[9]),t.ansi[10]=VJ(e.brightGreen,NJ[10]),t.ansi[11]=VJ(e.brightYellow,NJ[11]),t.ansi[12]=VJ(e.brightBlue,NJ[12]),t.ansi[13]=VJ(e.brightMagenta,NJ[13]),t.ansi[14]=VJ(e.brightCyan,NJ[14]),t.ansi[15]=VJ(e.brightWhite,NJ[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=VJ(e.extendedAnsi[r],NJ[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};BJ=JH([Z(0,DU)],BJ);function VJ(e,t){if(e!==void 0)try{return sq.toColor(e)}catch{}return t}var HJ=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},UJ=class{constructor(){this._services=new HJ,this._services.set(TU,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=vU(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},WJ={trace:0,debug:1,info:2,warn:3,error:4,off:5},GJ=`xterm.js: `,KJ=class extends uW{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),qJ=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=WJ[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:GJ)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};KJ=JH([Z(0,DU)],KJ);var qJ,JJ=class extends uW{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},YJ=3,XJ=Object.freeze(new fU),ZJ=0,QJ=2,$J=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*YJ);let r=t||mU.fromCharData([0,uU,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*YJ+0],n=t&2097151;return[this._data[e*YJ+1],t&2097152?this._combined[e]:n?oU(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*YJ+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*YJ+0]=e|2097152|t[2]<<22):this._data[e*YJ+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*YJ+0]>>22}hasWidth(e){return this._data[e*YJ+0]&12582912}getFg(e){return this._data[e*YJ+1]}getBg(e){return this._data[e*YJ+2]}hasContent(e){return this._data[e*YJ+0]&4194303}getCodePoint(e){let t=this._data[e*YJ+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*YJ+0]&2097152}getString(e){let t=this._data[e*YJ+0];return t&2097152?this._combined[e]:t&2097151?oU(t&2097151):``}isProtected(e){return this._data[e*YJ+2]&536870912}loadCell(e,t){return ZJ=e*YJ,t.content=this._data[ZJ+0],t.fg=this._data[ZJ+1],t.bg=this._data[ZJ+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*YJ+0]=t.content,this._data[e*YJ+1]=t.fg,this._data[e*YJ+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*YJ+0]=t|n<<22,this._data[e*YJ+1]=r.fg,this._data[e*YJ+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*YJ+0];r&2097152?this._combined[e]+=oU(t):r&2097151?(this._combined[e]=oU(r&2097151)+oU(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*YJ+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new mU;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new mU;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*QJ<this._data.buffer.byteLength;let n=e*YJ;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*QJ<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*QJ<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*YJ+0]&4194303)return e+(this._data[e*YJ+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*YJ+0]&4194303||this._data[e*YJ+2]&50331648)return e+(this._data[e*YJ+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<YJ;e++)this._data[(n+i)*YJ+e]=a[(t+i)*YJ+e];a[(t+i)*YJ+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<YJ;e++)this._data[(n+i)*YJ+e]=a[(t+i)*YJ+e];a[(t+i)*YJ+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*YJ+0],n=e&2097151,a=e&2097152?this._combined[t]:n?oU(n):dU;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function eY(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=iY(u,d,t),p=1,m=0;for(;p<u.length;){let e=iY(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function tY(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function nY(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function rY(e,t,n){let r=[],i=e.map((n,r)=>iY(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=iY(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function iY(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var aY=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),aW(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};aY._nextId=1;var oY=aY,sY={},cY=sY.B;sY[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},sY.A={"#":`£`},sY.B=void 0,sY[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},sY.C=sY[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},sY.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},sY.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},sY.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},sY.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},sY.E=sY[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},sY.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},sY.H=sY[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},sY[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var lY=4294967295,uY=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=XJ.clone(),this.savedCharset=cY,this.markers=[],this._nullCell=mU.fromCharData([0,uU,1,0]),this._whitespaceCell=mU.fromCharData([0,dU,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new oJ,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new JJ(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new pU),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new pU),this._whitespaceCell}getBlankLine(e,t){return new $J(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>lY?lY:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=XJ);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new JJ(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(XJ),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new $J(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new $J(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=eY(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(XJ),n);if(r.length>0){let n=tY(this.lines,r);nY(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(XJ),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new $J(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(XJ),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=rY(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(XJ,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=iY(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new oY(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},dY=class extends uW{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new uY(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new uY(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},fY=2,pY=1,mY=class extends uW{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,fY),this.rows=Math.max(e.rawOptions.rows||0,pY),this.buffers=this._register(new dY(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};mY=JH([Z(0,DU)],mY);var hY={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Zq,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},gY=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],_Y=class extends uW{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...hY};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(sW(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in hY))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in hY))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=hY[e],!vY(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=hY[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=gY.includes(t)?t:hY[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function vY(e){return e===`block`||e===`underline`||e===`bar`}function yY(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&yY(e[r],t-1);return n}var bY=Object.freeze({insertMode:!1}),xY=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),SY=class extends uW{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=yY(bY),this.decPrivateModes=yY(xY)}reset(){this.modes=yY(bY),this.decPrivateModes=yY(xY)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};SY=JH([Z(0,xU),Z(1,EU),Z(2,DU)],SY);var CY={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function wY(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var TY=String.fromCharCode,EY={DEFAULT:e=>{let t=[wY(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${TY(t[0])}${TY(t[1])}${TY(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${wY(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${wY(e,!0)};${e.x};${e.y}${t}`}},DY=class extends uW{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(CY))this.addProtocol(e,CY[e]);for(let e of Object.keys(EY))this.addEncoding(e,EY[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};DY=JH([Z(0,xU),Z(1,CU),Z(2,DU)],DY);var OY=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],kY=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],AY;function jY(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var MY=class{constructor(){if(this.version=`6`,!AY){AY=new Uint8Array(65536),AY.fill(1),AY[0]=0,AY.fill(0,1,32),AY.fill(0,127,160),AY.fill(2,4352,4448),AY[9001]=2,AY[9002]=2,AY.fill(2,11904,42192),AY[12351]=1,AY.fill(2,44032,55204),AY.fill(2,63744,64256),AY.fill(2,65040,65050),AY.fill(2,65072,65136),AY.fill(2,65280,65377),AY.fill(2,65504,65511);for(let e=0;e<OY.length;++e)AY.fill(0,OY[e][0],OY[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?AY[e]:jY(e,kY)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=NY.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return NY.createPropertyValue(0,n,r)}},NY=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new MY;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},PY=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function FY(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var IY=2147483647,LY=256,RY=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>LY)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>IY?IY:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>IY?IY:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,IY):e}},zY=[],BY=class{constructor(){this._state=0,this._active=zY,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=zY}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=zY,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||zY,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,sU(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=zY,this._id=-1,this._state=0}}},VY=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=sU(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},HY=[],UY=class{constructor(){this._handlers=Object.create(null),this._active=HY,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=HY}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=HY,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||HY,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,sU(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=HY,this._ident=0}},WY=new RY;WY.addParam(0);var GY=class{constructor(e){this._handler=e,this._data=``,this._params=WY,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():WY,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=sU(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=WY,this._data=``,this._hitLimit=!1,e));return this._params=WY,this._data=``,this._hitLimit=!1,t}},KY=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},qY=160,JY=function(){let e=new KY(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(qY,0,2,0),e.add(qY,8,5,8),e.add(qY,6,0,6),e.add(qY,11,0,11),e.add(qY,13,13,13),e}(),YY=class extends uW{constructor(e=JY){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new RY,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(sW(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new BY),this._dcsParser=this._register(new UY),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:qY)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<qY){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<qY){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<qY){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<qY){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<qY){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<qY){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},XY=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,ZY=/^[\da-f]+$/;function QY(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=XY.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),ZY.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function $Y(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function eX(e,t=16){let[n,r,i]=e;return`rgb:${$Y(n,t)}/${$Y(r,t)}/${$Y(i,t)}`}var tX={"(":0,")":1,"*":2,"+":3,"-":1,".":2},nX=131072,rX=10;function iX(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var aX=5e3,oX=0,sX=class extends uW{constructor(e,t,n,r,i,a,o,s,c=new YY){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new cU,this._utf8Decoder=new lU,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=XJ.clone(),this._eraseAttrDataInternal=XJ.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new cX(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ZK.IND,()=>this.index()),this._parser.setExecuteHandler(ZK.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ZK.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new VY(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new VY(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new VY(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new VY(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new VY(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new VY(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new VY(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new VY(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new VY(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new VY(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new VY(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new VY(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in sY)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new GY((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),aX))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${aX} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>nX&&(a=this._parseStack.position+nX)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<nX&&(this._parseBuffer=new Uint32Array(Math.min(e.length,nX))),o||this._dirtyRowTracker.clearRange(),e.length>nX)for(let t=a;t<e.length;t+=nX){let a=t+nX<e.length?t+nX:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=NY.extractWidth(t);let n=NY.extractShouldJoin(t),m=n?NY.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(oU(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof $J&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!iX(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new GY(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new VY(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(XJ));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=NY.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,cY),this._charsetService.setgCharset(1,cY),this._charsetService.setgCharset(2,cY),this._charsetService.setgCharset(3,cY);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=fU.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=XJ.fg,e.bg=XJ.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=XJ.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=XJ.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=XJ.fg&16777215,r.bg&=-67108864,r.bg|=XJ.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=XJ.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!iX(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>rX&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>rX&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(lX(n)){if(r===`?`)t.push({type:0,index:n});else{let e=QY(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=QY(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);lX(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,cY),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(tX[e[0]],sY[e[1]]||cY),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=XJ.clone(),this._eraseAttrDataInternal=XJ.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new mU;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},cX=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(oX=e,e=t,t=oX),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};cX=JH([Z(0,xU)],cX);function lX(e){return 0<=e&&e<256}var uX=5e7,dX=12,fX=50,pX=class extends uW{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>uX)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=dX?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=dX)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>fX&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},mX=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};mX=JH([Z(0,xU)],mX);var hX=!1,gX=class extends uW{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new dW),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new UJ,this.optionsService=this._register(new _Y(e)),this._instantiationService.setService(DU,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(mY)),this._instantiationService.setService(xU,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(KJ)),this._instantiationService.setService(EU,this._logService),this.coreService=this._register(this._instantiationService.createInstance(SY)),this._instantiationService.setService(CU,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(DY)),this._instantiationService.setService(SU,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(NY)),this._instantiationService.setService(kU,this.unicodeService),this._charsetService=this._instantiationService.createInstance(PY),this._instantiationService.setService(wU,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(mX),this._instantiationService.setService(OU,this._oscLinkService),this._inputHandler=this._register(new sX(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(vW.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(vW.forward(this._bufferService.onResize,this._onResize)),this._register(vW.forward(this.coreService.onData,this._onData)),this._register(vW.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new pX((e,t)=>this._inputHandler.parse(e,t))),this._register(vW.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!hX&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),hX=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,fY),t=Math.max(t,pY),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(FY.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(FY(this._bufferService),!1))),this._windowsWrappingHeuristics.value=sW(()=>{for(let t of e)t.dispose()})}}},_X={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function vX(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=_X[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var yX=0,bX=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new oJ,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new oJ,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(yX=this._search(t),yX===-1)||this._getKey(this._array[yX])!==t)return!1;do if(this._array[yX]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(yX),!0;while(++yX<this._array.length&&this._getKey(this._array[yX])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(yX=this._search(e),!(yX<0||yX>=this._array.length)&&this._getKey(this._array[yX])===e))do yield this._array[yX];while(++yX<this._array.length&&this._getKey(this._array[yX])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(yX=this._search(e),!(yX<0||yX>=this._array.length)&&this._getKey(this._array[yX])===e))do t(this._array[yX]);while(++yX<this._array.length&&this._getKey(this._array[yX])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},xX=0,SX=0,CX=class extends uW{constructor(){super(),this._decorations=new bX(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(sW(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new wX(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{xX=t.options.x??0,SX=xX+(t.options.width??1),e>=xX&&e<SX&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},wX=class extends lW{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?sq.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?sq.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},TX=1e3,EX=class{constructor(e,t=TX){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},DX=20,OX=class extends uW{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new EX(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
107
- `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(eK(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(sW(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<DX+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
108
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===DX+1&&(this._liveRegion.textContent+=QH.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};OX=JH([Z(1,TU),Z(2,PU),Z(3,IU)],OX);var kX=class extends uW{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(sW(()=>{aW(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(eK(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(eK(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(eK(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(eK(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&AX(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,aW(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};kX=JH([Z(1,FU),Z(2,IU),Z(3,xU),Z(4,BU)],kX);function AX(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var jX=class extends gX{constructor(e={}){super(e),this._linkifier=this._register(new dW),this.browser=Uq,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new dW),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(CX),this._instantiationService.setService(AU,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Rq),this._instantiationService.setService(BU,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(jU)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(vW.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(vW.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(vW.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(vW.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(sW(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=oq.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${eX(r)}${QK.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=aq.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=aq.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(OX,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(eK(this.element,`copy`,e=>{this.hasSelection()&&tU(e,this._selectionService)}));let e=e=>nU(e,this.textarea,this.coreService,this.optionsService);this._register(eK(this.textarea,`paste`,e)),this._register(eK(this.element,`paste`,e)),qq?this._register(eK(this.element,`mousedown`,e=>{e.button===2&&aU(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(eK(this.element,`contextmenu`,e=>{aU(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),tJ&&this._register(eK(this.element,`auxclick`,e=>{e.button===1&&iU(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(eK(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(eK(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(eK(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(eK(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(eK(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(eK(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(eK(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(eK(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,XH.get()),nJ||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Iq,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(PU,this._coreBrowserService),this._register(eK(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(eK(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Mq,this._document,this._helperContainer),this._instantiationService.setService(NU,this._charSizeService),this._themeService=this._instantiationService.createInstance(BJ),this._instantiationService.setService(zU,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(pq),this._instantiationService.setService(RU,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(cJ,this.rows,this.screenElement)),this._instantiationService.setService(IU,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance($K,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Vq),this._instantiationService.setService(FU,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(kX,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(WK,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(AJ,this.element,this.screenElement,r)),this._instantiationService.setService(LU,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(vW.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(GK,this.screenElement)),this._register(eK(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(OX,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(XK,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(XK,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(jq,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(eK(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(eK(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){rU(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=vX(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(MX(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(XJ));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function MX(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var NX=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},PX=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mU)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},FX=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new PX(t)}getNullCell(){return new mU}},IX=class extends uW{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new FX(this._core.buffers.normal,`normal`),this._alternate=new FX(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},LX=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},RX=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},zX=[`cols`,`rows`],BX=0,VX=class extends uW{constructor(e){super(),this._core=this._register(new jX(e)),this._addonManager=this._register(new NX),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(zX.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new LX(this._core),this._parser}get unicode(){return this._checkProposedApi(),new RX(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new IX(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
109
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return XH.get()},set promptLabel(e){XH.set(e)},get tooMuchOutput(){return QH.get()},set tooMuchOutput(e){QH.set(e)}}}_verifyIntegers(...e){for(BX of e)if(BX===1/0||isNaN(BX)||BX%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(BX of e)if(BX&&(BX===1/0||isNaN(BX)||BX%1!=0||BX<0))throw Error(`This API only accepts positive integers`)}};function HX({id:e,onExit:t,onDone:n,className:r}){let i=(0,G.useRef)(null),a=(0,G.useRef)(t);a.current=t;let o=(0,G.useRef)(n);return o.current=n,(0,G.useEffect)(()=>{let t=i.current;if(!t)return;let n=new VX({fontSize:13,lineHeight:1.2,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,cursorBlink:!0,scrollback:3e3,theme:{background:`#0f1424`,foreground:`#e6e9f2`,cursor:`#f0b35b`,selectionBackground:`#2f3a5f`}}),r=new RH;n.loadAddon(r),n.loadAddon(new WH((e,t)=>zL(t))),n.open(t);let s=`/api/studio/local/terminal/${e}`,c=()=>void 0,l=()=>{try{r.fit()}catch{}H.post(`${s}/resize`,{cols:n.cols,rows:n.rows}).catch(c)};l();let u=new ResizeObserver(l);u.observe(t);let d=n.onData(e=>void H.post(`${s}/input`,{data:e}).catch(c)),f=new EventSource(fe(`${s}/stream`),{withCredentials:!0});return f.addEventListener(`data`,e=>{n.write(JSON.parse(e.data).data)}),f.addEventListener(`done`,()=>o.current?.()),f.addEventListener(`exit`,e=>{f.close(),a.current?.(JSON.parse(e.data).code)}),n.focus(),()=>{f.close(),u.disconnect(),d.dispose(),n.dispose()}},[e]),(0,K.jsx)(`div`,{ref:i,className:V(`h-[28rem] max-h-[60dvh] w-full overflow-hidden rounded-lg bg-[#0f1424] p-2`,r)})}function UX({auto:e=!1}){let t=R(),n=ot({mutationFn:()=>H.post(`/api/studio/local/models/test`,{cls:`classifier`}),onSuccess:e=>e.ok?t.invalidateQueries({queryKey:[`me`]}):void 0}),{mutate:r}=n,i=(0,G.useRef)(!1);(0,G.useEffect)(()=>{e&&!i.current&&(i.current=!0,r())},[e,r]);let a=n.data;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:W(`local.testHint`)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(x,{variant:`secondary`,busy:n.isPending,onClick:()=>n.mutate(),children:W(`local.test`)})}),a?.ok?(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-[0.875rem] text-ink-2`,children:[(0,K.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-moss`}),(0,K.jsx)(`span`,{children:W(`local.testOk`,{s:(a.ms/1e3).toFixed(1),ref:a.ref??``,reply:a.reply??``})})]}):null,a&&!a.ok?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:W(`local.testFailed`,{error:a.error??``})}):null,n.isError?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:W(`local.testFailed`,{error:n.error.message})}):null]})}function WX({me:e,id:t,autoTest:n=!1}){let r=R(),i=e.harnesses.find(e=>e.id===t),[a,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=ot({mutationFn:()=>H.post(`/api/studio/local/harness/${t}/detect`),onSuccess:()=>r.invalidateQueries({queryKey:[`me`]})}),d=e=>({mutationFn:()=>H.post(`/api/studio/local/harness/${t}/${e}`,{cols:100,rows:24}),onSuccess:({terminal:t})=>{s({id:t,job:e}),l(null)}}),f=ot(d(`install`)),p=ot(d(`login`)),m=i?.auth===`subscription`,h=i?i.version!==null:!1;if((0,G.useEffect)(()=>{c!==null&&(a?.job===`install`?h:m)&&s(null)},[m,h,c,a?.job]),!i)return null;let g=W(`harness.sub.${t}`),_=(0,K.jsxs)(x,{variant:`ghost`,size:`sm`,busy:u.isPending,onClick:()=>u.mutate(),children:[(0,K.jsx)(j,{className:`size-3.5`}),` `,W(`local.recheck`)]});return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:W(i.images?`harness.hintImages`:`harness.hint`,{name:i.name,sub:g})}),h?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.875rem] text-ink-2`,children:[(0,K.jsx)(o,{className:`size-4 text-moss`}),W(`harness.found`,{name:i.name,version:i.version??``})]}),(0,K.jsx)(`p`,{className:V(`text-[0.8125rem]`,m?`text-ink-3`:`text-rose`),children:m?W(`harness.authSubscription`,{sub:g}):i.auth===`api_key`?W(`harness.authKey`,{sub:g}):W(`harness.authNone`)}),m||a?null:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(x,{busy:p.isPending,onClick:()=>p.mutate(),children:W(`harness.signIn`)}),_]}),p.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:p.error.message}):null]}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:W(`harness.missing`,{name:i.name})}),i.app?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:W(`harness.appHere`,{app:i.app,name:i.name,sub:g})}):null,a?null:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(x,{busy:f.isPending,onClick:()=>f.mutate(),children:W(`harness.installButton`,{name:i.name})}),_]}),f.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,K.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[W(`harness.install`),` `,(0,K.jsx)(`code`,{className:`rounded bg-paper px-1.5 py-0.5 font-mono text-[0.75rem] text-ink-2`,children:i.install})]})]}),a?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:a.job===`install`?W(`harness.installing`,{name:i.name}):i.interactiveLogin?W(`harness.signInInteractive`,{name:i.name,sub:g}):W(`harness.signingIn`)}),(0,K.jsx)(HX,{id:a.id,onDone:()=>u.mutate(),onExit:e=>{l(e),u.mutate()}},a.id),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:c===null?(0,K.jsx)(x,{variant:`ghost`,size:`sm`,onClick:()=>{H.del(`/api/studio/local/terminal/${a.id}`).catch(()=>void 0),s(null)},children:W(`common.cancel`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{variant:`ghost`,size:`sm`,onClick:()=>s(null),children:W(`common.close`)}),a.job===`install`?h?null:(0,K.jsx)(`span`,{className:`text-[0.8125rem] text-rose`,children:W(`harness.installEnded`,{name:i.name})}):m?null:(0,K.jsx)(`span`,{className:`text-[0.8125rem] text-rose`,children:W(`harness.loginEnded`,{name:i.name})})]})})]}):null,h?(0,K.jsx)(UX,{auto:n&&i.auth!==`none`},`${t}:${i.auth}`):null]})}var GX=e=>e?.runtimeSettings===!0;function KX(){return Je({queryKey:[`runtime`],queryFn:()=>H.get(`/api/studio/runtime`)})}function qX({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`grid gap-x-6 gap-y-0.5 py-2 sm:grid-cols-[11rem_minmax(0,1fr)]`,children:[(0,K.jsx)(`dt`,{className:`text-[0.875rem] text-ink-3`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 break-words text-[0.875rem] text-ink`,children:t})]})}var JX=({children:e})=>(0,K.jsx)(`span`,{className:`font-mono text-[0.8125rem]`,children:e}),YX={script:`about.kind.script`,checkout:`about.kind.checkout`,npm:`about.kind.npm`,cloud:`about.kind.cloud`};function XX(e,t){return e===`account`?W(`models.creditsName`):e===`own`?W(`local.sourceOwn`):t.harnesses.find(t=>t.id===e)?.name??e}function ZX(){let[e,t]=(0,G.useState)(`idle`);return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,K.jsxs)(x,{variant:`secondary`,busy:e===`restarting`,onClick:async()=>{t(`restarting`);let{restarting:e}=await H.post(`/api/studio/runtime/restart`,{}).catch(()=>({restarting:!1}));if(!e){t(`failed`);return}await new Promise(e=>setTimeout(e,2e3));for(let e=0;e<60;e++){if(await fetch(`/api/config`,{cache:`no-store`}).then(e=>e.ok).catch(()=>!1)){window.location.reload();return}await new Promise(e=>setTimeout(e,1e3))}t(`failed`)},children:[(0,K.jsx)(xi,{className:`size-4`}),` `,W(`runtime.restart`)]}),e===`restarting`?(0,K.jsx)(`span`,{className:`text-[0.875rem] text-ink-3`,children:W(`runtime.restarting`)}):null,e===`failed`?(0,K.jsx)(`span`,{className:`text-[0.875rem] text-rose`,children:W(`runtime.restartFailed`)}):null]})}function QX({me:e}){let[t,n]=me(),{narrow:r}=cn(),i=t.get(`show`)===`features`?`features`:`general`;nn(t.get(`show`)||!r?W($X[i]):null);let a=e=>n({show:e},{replace:!r});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(on,{children:(0,K.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(ln,{icon:Ti,label:W($X.general),selected:i===`general`&&!(!t.get(`show`)&&r),onPick:()=>a(`general`)}),(0,K.jsx)(ln,{icon:Gi,label:W($X.features),selected:i===`features`,onPick:()=>a(`features`)})]})}),i===`features`?(0,K.jsx)(nZ,{me:e}):(0,K.jsx)(eZ,{me:e})]})}var $X={general:`runtime.general`,features:`runtime.featuresNav`};function eZ({me:e}){let t=B(),n=KX(),r=n.data;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[r.models?(0,K.jsxs)(le,{title:W(`runtime.models`),hint:W(`runtime.modelsHint`),children:[(0,K.jsxs)(`dl`,{className:`-my-2 divide-y divide-border-soft`,children:[(0,K.jsx)(qX,{label:W(`runtime.source`),children:XX(r.models.source,e)}),(0,K.jsx)(qX,{label:W(`runtime.keys`),children:r.models.keys.length?r.models.keys.map(e=>IL(e)?.name??e).join(`, `):W(`runtime.noKeys`)})]}),(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,K.jsx)(UX,{}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,K.jsx)(x,{variant:`secondary`,onClick:()=>t(`/settings/models`),children:W(`runtime.openModels`)}),(0,K.jsx)(x,{variant:`ghost`,onClick:()=>t(`/setup`),children:W(`runtime.openSetup`)})]})]})]}):null,(0,K.jsx)(le,{title:W(`runtime.server`),hint:W(`runtime.serverHint`),children:(0,K.jsxs)(`dl`,{className:`-my-2 divide-y divide-border-soft`,children:[(0,K.jsxs)(qX,{label:W(`runtime.version`),children:[r.version,` · `,W(YX[r.kind])]}),(0,K.jsx)(qX,{label:W(`runtime.role`),children:(0,K.jsx)(JX,{children:r.role})}),(0,K.jsx)(qX,{label:W(`runtime.address`),children:(0,K.jsx)(JX,{children:r.publicUrl})}),(0,K.jsx)(qX,{label:W(`runtime.dataDir`),children:(0,K.jsx)(JX,{children:r.dataDir})}),(0,K.jsx)(qX,{label:W(`runtime.database`),children:r.database===`server`?W(`runtime.databaseServer`):W(`runtime.databaseFile`)}),(0,K.jsx)(qX,{label:W(`runtime.files`),children:r.files===`bucket`?W(`runtime.filesBucket`):W(`runtime.filesFolder`)}),(0,K.jsx)(qX,{label:W(`runtime.plugins`),children:r.plugins.length?r.plugins.join(`, `):W(`runtime.noPlugins`)}),(0,K.jsx)(qX,{label:W(`runtime.featuresFile`),children:(0,K.jsx)(JX,{children:r.featuresFile})})]})}),r.restarts?(0,K.jsx)(le,{title:W(`runtime.restartTitle`),hint:W(`runtime.restartHint`),children:(0,K.jsx)(ZX,{})}):null]}):n.isLoading?(0,K.jsx)(Fe,{className:`size-5 text-ink-3`}):null}var tZ={default:`runtime.fromDefault`,env:`runtime.fromEnv`,remote:`runtime.fromRemote`,file:`runtime.fromFile`};function nZ({me:e}){let t=R(),n=Je({queryKey:[`runtime`,`features`],queryFn:()=>H.get(`/api/studio/runtime/features`)}),r=ot({mutationFn:({name:e,on:t})=>H.put(`/api/studio/runtime/features/${encodeURIComponent(e)}`,{on:t}),onSettled:()=>Promise.all([t.invalidateQueries({queryKey:[`runtime`,`features`]}),t.invalidateQueries({queryKey:[`me`]}),t.invalidateQueries({queryKey:[`config`]})])}),i=n.data;if(!i)return n.isLoading?(0,K.jsx)(Fe,{className:`size-5 text-ink-3`}):null;let a=e.mode===`managed`?W(`runtime.fromOrganization`):W(tZ.remote);return(0,K.jsx)(`div`,{className:`flex flex-col gap-9`,children:(0,K.jsxs)(le,{title:W(`runtime.featuresTitle`),hint:W(e.mode===`managed`?`runtime.featuresHintCloud`:`runtime.featuresHint`,{file:i.file}),children:[i.features.length?(0,K.jsx)(`ul`,{className:`-my-2 divide-y divide-border-soft`,children:i.features.map(e=>{let t=r.isPending&&r.variables?.name===e.name;return(0,K.jsxs)(`li`,{className:`flex items-start gap-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.9375rem] text-ink`,children:e.label??e.name}),(0,K.jsx)(v,{children:e.source===`remote`?a:W(tZ[e.source])}),e.kind===`plan`?(0,K.jsx)(v,{children:W(`runtime.kindPlan`)}):null]}),(0,K.jsx)(`p`,{className:`mt-0.5 font-mono text-[0.75rem] text-ink-4`,children:e.name}),e.hint?(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:e.hint}):null,e.source===`file`?(0,K.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r.mutate({name:e.name,on:null}),className:`mt-1 text-[0.8125rem] text-ink-3 underline-offset-2 hover:text-ink hover:underline`,children:W(`runtime.followDefault`,{state:e.without?W(`runtime.on`):W(`runtime.off`)})}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[t?(0,K.jsx)(Fe,{className:`size-4 text-ink-3`}):null,(0,K.jsx)(oe,{checked:e.on,label:e.label??e.name,disabled:t,onChange:t=>r.mutate({name:e.name,on:t})})]})]},e.name)})}):(0,K.jsx)(te,{children:W(`runtime.noFeatures`)}),r.error?(0,K.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:W(`runtime.featureFailed`)}):null,(0,K.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 border-border-soft border-t pt-4`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:W(i.restarts?`runtime.featuresRestart`:`runtime.featuresRestartBySelf`)}),i.restarts?(0,K.jsx)(ZX,{}):null]})]})})}function rZ(e,t){let n=e?.mode===`managed`&&Ot(e.features,`organizationSettings`),r=!(e?.mode===`managed`&&e.tenant.role===`member`&&Ot(e.features,`capabilities`)),i=W(`settings.groupOrganization`),a=n?W(`settings.groupStudio`):void 0,o=e=>a?{...e,group:a}:e;return[...n?[]:[{id:`account`,label:W(`account.title`),icon:Yi,menu:!0}],...n&&r?[{id:`general`,label:W(`orgSettings.general`),icon:Nn,menu:!1,group:i},{id:`members`,label:W(`orgSettings.members`),icon:Zi,menu:!0,group:i},{id:`credits`,label:W(`credits.title`),icon:$e,menu:!1,group:i},{id:`usage`,label:W(`credits.usage`),icon:Ze,menu:!1,group:i},{id:`invoices`,label:W(`credits.invoices`),icon:_i,menu:!1,group:i},{id:`keys`,label:W(`orgSettings.keys`),icon:xr,menu:!1,group:i}]:e?.mode===`managed`&&Ot(e.features,`teamPlans`)&&r?[{id:`organization`,label:W(`organization.title`),icon:Zi,menu:!0}]:[],...mH(e)?[o({id:`cloud`,label:W(`cloudSync.title`),icon:Gn,menu:!1})]:[],...Ot(e?.features,`capabilities`)?[]:[o({id:`connectors`,label:W(`connectors.title`),icon:ut,menu:!0})],...Ot(e?.features,`capabilities`)&&(e?.mode!==`managed`||e.tenant.role!==`member`)?[o({id:`notifications`,label:W(`protocol.notify.title`),icon:Be,menu:!1})]:[],o({id:`models`,label:W(`local.title`),icon:Yn,menu:!0}),o({id:`integrate`,label:W(`integrate.nav`),icon:Fn,menu:!0}),...Ot(e?.features,`plugins`)||t.plugins.length||t.problems.length||t.canReload&&e?.account?[o({id:`plugins`,label:W(`plugins.title`),icon:Dn,menu:!1})]:[],...GX(e)?[o({id:`setup`,label:W(`runtime.setupNav`),icon:$i,menu:!1})]:[],{id:`about`,label:W(`about.nav`),icon:yr,menu:!1}]}function iZ(e){return[{id:`profile`,label:W(`konto.profile`),icon:Yi,menu:!0},...Ot(e,`capabilities`)?[{id:`connections`,label:W(`konto.connections`),icon:E,menu:!0}]:[],{id:`orgs`,label:W(`konto.organizations`),icon:Nn,menu:!1},{id:`apps`,label:W(`konto.apps`),icon:ut,menu:!1}]}var aZ=1300,oZ=3e3;function sZ(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}var cZ=typeof window<`u`&&(!!sZ()||!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`);function lZ(e){return e.toLowerCase().split(/[\s\-–—/]+/).map(e=>e.replace(/[^\p{L}\p{N}]/gu,``)).filter(Boolean)}function uZ(e,t){let n=new Set(lZ(t)),r=lZ(e);return r.length<2||r.filter(e=>n.has(e)).length/r.length>=.75}function dZ(e){let[t,n]=(0,G.useState)(`off`),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(null),h=(0,G.useRef)(`off`),g=(0,G.useRef)(!1),_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(``),x=(0,G.useRef)({text:``,until:0}),S=(0,G.useRef)(``),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(e);T.current=e;let E=(0,G.useRef)(p);E.current=p;let D=(0,G.useCallback)(e=>{h.current=e,n(e)},[]),O=(0,G.useCallback)(()=>{yt(),y.current&&=(y.current.pause(),null),b.current=``},[]),k=(0,G.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null);let e=S.current.trim();S.current=``,f(``),e&&h.current!==`off`&&(D(`thinking`),w.current=T.current.messages.at(-1)?.id??null,T.current.send(e).then(e=>{!e&&h.current===`thinking`&&D(`listening`)}))},[D]),A=(0,G.useCallback)((e,t)=>{if(!(g.current||h.current===`off`||h.current===`thinking`)){if(h.current===`speaking`){if(uZ(e,b.current))return;O(),D(`listening`)}else if(Date.now()<x.current.until&&uZ(e,x.current.text))return;f(e),t&&(S.current=`${S.current} ${e}`.trim(),f(S.current)),C.current&&clearTimeout(C.current),C.current=setTimeout(k,aZ)}},[k,O,D]),j=(0,G.useCallback)(()=>{let e=sZ();if(!e||_.current)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=Wt[Xt],t.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n];r.isFinal?A(r[0].transcript,!0):t+=r[0].transcript}t.trim()&&A(`${S.current} ${t}`.trim(),!1)},t.onerror=e=>{(e.error===`not-allowed`||e.error===`service-not-allowed`)&&c(`denied`)},t.onend=()=>{_.current=null,h.current!==`off`&&!g.current&&setTimeout(j,200)},_.current=t;try{t.start()}catch{_.current=null}},[A]),M=(0,G.useCallback)((e,t)=>{let n=null,r=[],i=0,a=new Uint8Array(t.fftSize),o=()=>{if(h.current===`off`){n?.stop();return}t.getByteTimeDomainData(a);let s=0;for(let e of a)s=Math.max(s,Math.abs(e-128)/128);if(s>.08&&!g.current&&h.current===`listening`){if(i=Date.now(),!n){let t=Date.now()<x.current.until?x.current.text:``;r=[],n=new MediaRecorder(e),n.ondataavailable=e=>e.data.size&&r.push(e.data),n.onstop=async()=>{let e=new File(r,`live`,{type:(n?.mimeType||`audio/webm`).split(`;`)[0]});if(n=null,e.size&&h.current!==`off`){D(`thinking`);try{let{text:n}=await H.upload(`/api/studio/transcribe`,e);if(t&&uZ(n,t)){D(`listening`);return}S.current=n,k()}catch(e){c(e.message),D(`listening`)}}},n.start()}}else n&&Date.now()-i>aZ&&n.stop();setTimeout(o,100)};o()},[k,D]),N=(0,G.useCallback)(async()=>{if(h.current!==`off`)return;c(null);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch{c(`denied`);return}v.current=e,w.current=T.current.messages.at(-1)?.id??null,D(`listening`),o(Date.now());let t=new AudioContext,n=t.createAnalyser();n.fftSize=512,t.createMediaStreamSource(e).connect(n);let r=new Uint8Array(n.fftSize),i=()=>{if(h.current===`off`){t.close();return}n.getByteTimeDomainData(r);let e=0;for(let t of r)e=Math.max(e,Math.abs(t-128)/128);u(g.current?0:Math.min(1,e*3)),setTimeout(i,90)};i(),sZ()?j():M(e,n),E.current||H.get(`/api/studio/assistant/voice`).then(({way:e})=>m({way:e,natural:e===`key`||e===`local`})).catch(()=>m({way:`none`,natural:!1}))},[j,M,D]),P=(0,G.useCallback)(()=>{D(`off`),o(null),f(``),u(0),S.current=``,C.current&&clearTimeout(C.current),_.current?.abort(),_.current=null,O();for(let e of v.current?.getTracks()??[])e.stop();v.current=null},[O,D]),F=(0,G.useCallback)(()=>{let e=!g.current;g.current=e,i(e);for(let t of v.current?.getAudioTracks()??[])t.enabled=!e;e?(_.current?.abort(),_.current=null):h.current!==`off`&&j()},[j]),I=(0,G.useCallback)(async e=>{let t=_t(e);if(!t){D(`listening`);return}D(`speaking`),b.current=t;let n=E.current?.natural&&E.current.way!==`none`,r=!1;if(n)try{let e=await fetch(fe(`/api/studio/assistant/speak`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.slice(0,4e3)})});if(e.ok&&h.current===`speaking`){let t=URL.createObjectURL(await e.blob()),n=new Audio(t);y.current=n,await new Promise(e=>{n.onended=()=>e(),n.onerror=()=>e(),n.onpause=()=>e(),n.play().catch(()=>e())}),URL.revokeObjectURL(t),r=!0}}catch{}!r&&h.current===`speaking`&&await bt(t,Xt),y.current=null,b.current=``,h.current===`speaking`&&(x.current={text:t,until:Date.now()+oZ},S.current=``,f(``),_.current?.abort(),D(`listening`))},[D]);return(0,G.useEffect)(()=>{if(t!==`thinking`||e.phase!==`idle`)return;let n=e.messages.at(-1);n?.role===`assistant`&&n.id!==w.current&&!n.pending?(w.current=n.id,I(n.content)):e.error&&D(`listening`)},[t,e.phase,e.messages,e.error,I,D]),(0,G.useEffect)(()=>()=>P(),[P]),{state:t,muted:r,since:a,error:s,level:l,heard:d,voice:p,setNatural:e=>m(t=>t&&{...t,natural:e}),start:N,end:P,toggleMute:F}}var fZ=()=>document.getElementById(`studio-scroll`)??document.body,pZ=`[data-assist],h1,h2,h3,h4,button,a[href],input,textarea,select,[role=switch],[role=checkbox],[role=tab],[contenteditable=true]`,mZ=150,hZ=0;function gZ(e){return e.dataset.assist?e.dataset.assist:(e.dataset.assistRef||(hZ+=1,e.dataset.assistRef=`e${hZ}`),e.dataset.assistRef)}var _Z=(e,t=120)=>(e??``).replace(/\s+/g,` `).trim().slice(0,t);function vZ(e){if(e.dataset.assistLabel)return _Z(e.dataset.assistLabel);let t=e.getAttribute(`aria-label`);if(t)return _Z(t);if(e.dataset.assist&&!e.matches(`input,textarea,select,button,a`)){let t=e.querySelector(`h1,h2,h3,h4,[data-assist-section]`);if(t)return _Z(t.getAttribute(`data-assist-section`)||t.textContent)}if(e.id){let t=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(t)return _Z(t.textContent)}let n=e.closest(`label`);if(n&&n!==e)return _Z(n.textContent);let r=e.parentElement?.querySelector(`label`);return r&&(e.matches(`input,textarea,select`)||e.getAttribute(`role`)===`switch`)?_Z(r.textContent):_Z(e.textContent||e.placeholder||e.getAttribute(`title`)||``)}function yZ(e){if(e instanceof HTMLInputElement)return e.type===`password`?e.value?`••••`:``:e.type===`checkbox`||e.type===`radio`?e.checked:e.value.slice(0,300);if(e instanceof HTMLTextAreaElement)return e.value.slice(0,600);if(e instanceof HTMLSelectElement)return _Z(e.selectedOptions[0]?.textContent??e.value);let t=e.getAttribute(`role`);if(t===`switch`||t===`checkbox`)return e.getAttribute(`aria-checked`)===`true`;if(e.isContentEditable)return _Z(e.textContent,600)}function bZ(e){return e.dataset.assist&&!e.matches(`input,textarea,select,button,a`)?`area`:/^H[1-4]$/.test(e.tagName)?`heading`:e.matches(`input,textarea,select,[role=switch],[role=checkbox],[contenteditable=true]`)?`field`:e.getAttribute(`role`)===`tab`?`tab`:e.tagName===`A`?`link`:`button`}function xZ(e){if(e.closest(`[data-assistant-ui],[aria-hidden=true]`))return!1;let t=getComputedStyle(e);if(t.display===`none`||t.visibility===`hidden`)return!1;let n=e.getBoundingClientRect();return n.width>0||n.height>0}function SZ(e){let t=e.getBoundingClientRect();return t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth}function CZ(e,t){let n=[];for(let r of e.querySelectorAll(pZ)){if(n.length>=mZ)break;if(!xZ(r)||t&&!SZ(r))continue;let e=bZ(r),i=vZ(r);if(!i&&e!==`field`)continue;let a=e===`field`?yZ(r):void 0,o=r.disabled||r.getAttribute(`aria-disabled`)===`true`;n.push({ref:gZ(r),kind:e,label:i,...a===void 0?{}:{value:a},...o?{disabled:!0}:{},...r.getAttribute(`aria-current`)||r.getAttribute(`aria-selected`)===`true`?{current:!0}:{}})}return n}function wZ(e){let t=fZ(),n=e.trim(),r=document.querySelector(`[data-assist="${CSS.escape(n)}"]`)??document.querySelector(`[data-assist-ref="${CSS.escape(n)}"]`)??(/^[A-Za-z][\w-]*$/.test(n)?document.getElementById(n):null);if(r)return r;let i=n.toLowerCase(),a=null;for(let e of t.querySelectorAll(pZ)){if(!xZ(e))continue;let t=vZ(e).toLowerCase();if(t===i)return e;!a&&t.includes(i)&&(a=e)}return a}var TZ=e=>({error:`Nothing on the page is "${e}". look_at_page lists what is there.`}),EZ=null,DZ=0,OZ=new Set;function kZ(e){EZ=e;for(let e of OZ)e()}function AZ(){return(0,G.useSyncExternalStore)(e=>(OZ.add(e),()=>OZ.delete(e)),()=>EZ)}var jZ=null,MZ=0,NZ=new Set;function PZ(e){jZ=e;for(let e of NZ)e()}function FZ(){return(0,G.useSyncExternalStore)(e=>(NZ.add(e),()=>NZ.delete(e)),()=>jZ)}function IZ(){jZ?.answer(!1)}var LZ=null,RZ=()=>[];function zZ(e,t){LZ=e,RZ=t}function BZ(e){let t=e.split(/[?#]/)[0]||`/`;return RZ().some(e=>RegExp(`^${e.split(`/`).map(e=>e.startsWith(`:`)?e.endsWith(`?`)?`(?:[^/]+)?`:`[^/]+`:e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`/`)}/?$`).test(t))}var VZ=()=>new Promise(e=>setTimeout(e,450));function HZ(e){return!e.startsWith(`/`)||e.startsWith(`//`)||/^\/(api|w|s)\//.test(e)||!(LZ&&BZ(e))?!1:(LZ(e),!0)}var UZ={type:`string`,description:`A ref or area from look_at_page, or the label`},WZ=new Map;function GZ(){return[...WZ.values()].map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:n}))}var KZ=[{name:`navigate`,description:`Open a page of the studio by its address (/settings/models, /space/knowledge, /space/data, a plugin's page). The chat stays open.`,parameters:{type:`object`,properties:{to:{type:`string`,description:`The studio address, starting with /`}},required:[`to`]},run:async({to:e})=>{let t=String(e??``);return t.startsWith(`/`)&&BZ(t)?(LZ?.(t),await VZ(),{opened:t,pageTools:GZ()}):{error:`The studio has no page "${t}".`,pages:RZ()}}},{name:`highlight`,description:"Point at one element: `spotlight` dims the page except it, `ring` only rings it. A small card beside it shows a title, a text and buttons; a button the person presses comes back as their next message. Scrolls it into view.",parameters:{type:`object`,properties:{target:UZ,mode:{type:`string`,enum:[`spotlight`,`ring`]},title:{type:`string`,maxLength:80},text:{type:`string`,maxLength:400},buttons:{type:`array`,items:{type:`string`,maxLength:40},maxItems:3,description:`Answers the person can give with one click`}},required:[`target`]},run:async({target:e,mode:t,title:n,text:r,buttons:i})=>{let a=wZ(String(e??``));return a?(a.scrollIntoView({behavior:`smooth`,block:`center`}),await VZ(),DZ+=1,kZ({id:DZ,el:a,mode:t===`ring`?`ring`:`spotlight`,title:n?String(n):void 0,text:r?String(r):void 0,buttons:Array.isArray(i)?i.map(String).slice(0,3):[]}),{shown:vZ(a)}):TZ(String(e))}},{name:xV,description:`Shows the person a change about to be made through one of their connections and waits for their yes.`,parameters:{type:`object`,properties:{service:{type:`string`},action:{type:`string`},destructive:{type:`boolean`},input:{type:`string`}},required:[`service`,`action`,`input`]},run:({service:e,action:t,destructive:n,input:r})=>new Promise(i=>{jZ?.answer(!1),MZ+=1,PZ({id:MZ,service:String(e??``),action:String(t??``),destructive:n===!0,input:String(r??``),answer:e=>{PZ(null),i({confirmed:e})}})})},{name:`look_at_page`,description:`What is on the screen now, as a list: headings, areas, buttons, links, tabs and fields with their values, each with a ref to point at (at most 150). Not a picture.`,parameters:{type:`object`,properties:{}},run:()=>({route:window.location.pathname,scrolled:Math.round(fZ().scrollTop),items:CZ(fZ(),!0),pageTools:GZ()})},{name:`read_section`,description:`Everything in one area of the page, also what is scrolled away: its elements with values, and its text.`,parameters:{type:`object`,properties:{target:UZ},required:[`target`]},run:({target:e})=>{let t=wZ(String(e??``));return t?{area:vZ(t),items:CZ(t,!1),text:_Z(t.innerText,4e3)}:TZ(String(e))}},{name:`fill_field`,description:`Put a value into a field of the page, as if typed: text, a choice by its label, yes/no for a switch. Not saved by you: the person checks and saves.`,parameters:{type:`object`,properties:{target:UZ,value:{type:[`string`,`number`,`boolean`]}},required:[`target`,`value`]},run:async({target:e,value:t})=>{let n=wZ(String(e??``));if(!n)return TZ(String(e));if(n.scrollIntoView({behavior:`smooth`,block:`center`}),n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`))n.checked!==!!t&&n.click();else if(n.getAttribute(`role`)===`switch`||n.getAttribute(`role`)===`checkbox`)n.getAttribute(`aria-checked`)===`true`!=!!t&&n.click();else if(n instanceof HTMLSelectElement){let e=[...n.options].find(e=>e.value===String(t)||_Z(e.textContent).toLowerCase()===String(t).toLowerCase());if(!e)return{error:`No such choice.`,choices:[...n.options].map(e=>_Z(e.textContent))};n.value=e.value,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}else if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){if(n.disabled||n.readOnly)return{error:`The field takes nothing here.`};let e=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(e,`value`)?.set?.call(n,String(t)),n.dispatchEvent(new Event(`input`,{bubbles:!0})),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}else return{error:`That is not a field.`};return n.focus({preventScroll:!0}),{filled:vZ(n),value:yZ(n)}}},{name:`page_tool`,description:`Runs a tool the page shown now offers, by its name, with its arguments: a page opened during this answer brings tools that are not among yours (navigate and look_at_page list them with their parameters).`,parameters:{type:`object`,properties:{name:{type:`string`},args:{type:`object`,description:`The tool's arguments, as its parameters say`}},required:[`name`]},run:async({name:e,args:t})=>{let n=WZ.get(String(e??``));return n?n.run(t??{}):{error:`The page offers no tool "${String(e)}".`,pageTools:GZ()}}},{name:`scroll_to`,description:`Scroll an element of the page into view.`,parameters:{type:`object`,properties:{target:UZ},required:[`target`]},run:async({target:e})=>{let t=wZ(String(e??``));return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),await VZ(),{at:vZ(t)}):TZ(String(e))}}];function qZ(e,t,n){let r=(0,G.useRef)(n);r.current=n;let i=JSON.stringify(t);(0,G.useEffect)(()=>{if(KZ.some(t=>t.name===e))throw Error(`"${e}" is a tool of the assistant itself.`);if(!/^[a-z][a-z0-9_]{1,62}$/.test(e))throw Error(`"${e}": a tool's name is lower case letters, digits and _.`);let{description:t,parameters:n}=JSON.parse(i);return WZ.set(e,{name:e,description:t,parameters:n??{type:`object`,properties:{}},run:e=>r.current(e)}),()=>{WZ.delete(e)}},[e,i])}function JZ(){return[...KZ,...WZ.values()].map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:n}))}async function YZ(e,t){let n=KZ.find(t=>t.name===e)??WZ.get(e);if(!n)return null;try{return{result:await n.run(t??{})}}catch(e){return{result:{error:e.message}}}}var XZ=e=>({id:e.id,role:e.role,content:e.content,cards:e.cards.map((t,n)=>({...t,id:`${e.id}-${n}`})),toolCalls:e.toolCalls,changed:e.changed});function ZZ(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}var QZ=0,$Z=e=>`${e}-${Date.now()}-${++QZ}`,eQ=(0,G.createContext)(null);function tQ(){return(0,G.useContext)(eQ)}function nQ(){let e=O0(),t=At(),n=na(`capabilities`),r=(0,G.useRef)([]);return r.current=[`/`,`/new`,`/edit/:id`,`/space`,`/space/:group`,`/skills`,...n?[`/capabilities`,`/capabilities/:section`]:[],`/settings`,...rZ(t.data,e).map(e=>`/settings/${e.id}`),...e.pages.map(e=>e.path)],(0,G.useCallback)(()=>r.current,[])}function rQ({children:e}){let t=R(),n=At(),r=!!n.data,{space:i}=It(),a=B(),o=nQ();(0,G.useEffect)(()=>{zZ(e=>a(e),o)},[a,o]);let s=Je({queryKey:[`assistant-chat`],queryFn:()=>H.get(`/api/studio/assistant/chat`),enabled:r,staleTime:1/0}),c=Je({queryKey:[`assistant-layout`],queryFn:()=>H.get(`/api/studio/assistant/layout`),enabled:r,staleTime:1/0}),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)(`idle`),[m,h]=(0,G.useState)(null),[_,v]=(0,G.useState)(null),[y,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)({kind:`chat`}),D=oQ(_e().pathname),[O,k]=(0,G.useState)({}),[A,j]=(0,G.useState)(void 0),[M,N]=(0,G.useState)([]),[P,F]=(0,G.useState)([]),I=(0,G.useRef)(null),L=DR(),ee=!!n.data?.assistantDev&&L.dev,te=(0,G.useRef)(ee);te.current=ee;let[ne,z]=(0,G.useState)(!1),re=(0,G.useRef)(ne);re.current=ne;let[ie,ae]=(0,G.useState)(null),oe=(0,G.useRef)(ie);oe.current=ie,(0,G.useEffect)(()=>{s.data&&I.current!==s.data.id&&(I.current=s.data.id,u(s.data.messages.map(XZ)))},[s.data]);let se=(0,G.useCallback)(e=>{k(t=>({...t,[D]:e})),t.setQueryData([`assistant-layout`],t=>({...t,layouts:{...t?.layouts,[D]:e}})),H.put(`/api/studio/assistant/layout`,{layout:e,area:D}).catch(()=>null)},[t,D]),ce=O[D]??c.data?.layouts?.[D]??c.data?.layout??`bottom`,le=(0,G.useCallback)((e,n=!0)=>{j(e),n&&(t.setQueryData([`assistant-layout`],t=>({...t,width:e})),H.put(`/api/studio/assistant/layout`,{width:e}).catch(()=>null))},[t]),ue=(0,G.useRef)(null),de=(0,G.useCallback)(()=>(ue.current??=(async()=>{await Promise.all([t.invalidateQueries({queryKey:p.spaces()}),i?t.invalidateQueries({queryKey:p.files(i.id)}):null,i?t.invalidateQueries({queryKey:p.knowledge(i.id)}):null]),yL(),ue.current=null})(),ue.current),[t,i]),V=(0,G.useRef)([]),fe=(0,G.useCallback)(e=>{V.current=e(V.current),N(V.current)},[]),pe=(0,G.useRef)(!1),me=(0,G.useRef)(null),he=(0,G.useRef)(null),ge=(0,G.useRef)(()=>void 0),ve=(0,G.useRef)(new Set),ye=(0,G.useCallback)(()=>{let e=me.current?.runId;if(e)for(let t of V.current)t.way!==`signal`||ve.current.has(t.id)||(ve.current.add(t.id),H.post(`/api/studio/assistant/run/${e}/signal`,{ref:t.id,message:t.text}).catch(()=>{}))},[]),be=(0,G.useCallback)(async(e,t)=>{if(!t.length)return e;if(!i||i.readOnly)return h(W(`assistant.filesNeedSpace`)),null;try{for(let e of t)await H.upload(`/api/studio/spaces/${i.id}/files?kind=${ZZ(e)}`,e)}catch(e){return h(e.message),await de(),null}await de();let n=`${W(`editor.attached`)}: ${t.map(e=>e.name).join(`, `)}`;return e.trim()?`${e}\n\n${n}`:n},[i,de]),xe=(0,G.useCallback)(async(e,n)=>{pe.current=!0,h(null),f(`thinking`),b(Date.now()),kZ(null),E({kind:`chat`});let r=$Z(`p`),a=$Z(`u`);u(t=>[...t,{id:a,role:`user`,content:e,previews:n},{id:r,role:`assistant`,content:``,pending:!0}]),v(null);let o=e=>{let t=r;u(n=>n.map(n=>n.id===t?e(n):n))},s=te.current?{id:$Z(`t`),message:e,startedAt:Date.now(),endedAt:null,prompt:null,events:[]}:null;s&&F(e=>[...e,s]);let c=(e,t)=>{s&&(s.events.push({at:Date.now(),event:e,data:t}),e===`prompt`&&(s.prompt=t),F(e=>e.map(e=>e.id===s.id?{...s}:e)))},l=new AbortController,d={runId:null,abort:l,stopped:!1};me.current=d;let p=!1;try{await g(`/api/studio/assistant/turn`,{message:e,spaceId:i?.id,page:SL(),tools:JZ(),lang:Xt,...te.current?{debug:!0}:{},...re.current?{extra:!0}:{},...oe.current?{model:oe.current}:{}},(e,t)=>{let n=JSON.parse(t);switch(c(e,n),e){case`run_started`:{let e=n;d.runId=e.runId,u(t=>t.map(t=>t.id===a?{...t,id:e.messageId}:t)),ye();break}case`text`:o(e=>({...e,content:e.content+n.delta}));break;case`activity`:v(n.label);break;case`tool_call`:{let e=n;o(t=>({...t,toolCalls:[...t.toolCalls??[],e]})),YZ(e.toolCallName,e.args).then(t=>{t&&H.post(`/api/studio/assistant/tool/${e.toolCallId}`,{result:t.result??null}).catch(()=>null)});break}case`tool_result`:{let e=n;o(t=>({...t,toolCalls:t.toolCalls?.map(t=>t.toolCallId===e.toolCallId?{...t,result:e.content}:t)}));break}case`card`:{let e=n;o(t=>({...t,cards:[...t.cards??[],{...e,id:`${t.id}-${t.cards?.length??0}`}]}));break}case`changed`:de();break;case`step`:o(e=>({...e,steps:[...e.steps??[],n]}));break;case`signal`:{let e=n,t=r;r=$Z(`p`),fe(t=>t.filter(t=>t.id!==e.ref)),u(n=>[...n.flatMap(n=>n.id===t?n.content||n.toolCalls?.length||n.cards?.length||n.steps?.length?[{...n,id:e.answerId??n.id,pending:!1}]:[]:[n]),{id:e.messageId,role:`user`,content:e.content,signal:!0},{id:r,role:`assistant`,content:``,pending:!0}]);break}case`done`:{p=!0;let e=n;o(t=>({...t,id:e.messageId,content:e.reply,changed:e.changed,pending:!1}));break}case`error`:p=!0,h(n.message)}},l.signal),p||h(W(`editor.chatBroken`))}catch(e){d.stopped||h(e.message)}finally{s&&(s.endedAt=Date.now(),F(e=>e.map(e=>e.id===s.id?{...s}:e))),me.current=null,v(null),b(null),u(e=>e.filter(e=>!(e.pending&&!e.content&&!e.cards?.length&&!e.toolCalls?.length&&!e.steps?.length)).map(e=>({...e,pending:!1}))),f(`idle`),pe.current=!1,await ue.current,t.invalidateQueries({queryKey:[`me`]})}let m=he.current;if(he.current=null,!(m||d.stopped)){let e=V.current.filter(e=>e.way===`signal`),t=e.length?e:V.current.filter(e=>e.way===`queue`).slice(0,1);t.length&&(fe(e=>e.filter(e=>!t.includes(e))),m=t.map(e=>e.text).join(`
110
-
111
- `))}m&&ge.current(m)},[i,de,t,ye,fe]);ge.current=e=>void xe(e);let Se=(0,G.useCallback)(async(e,t=[],n=`signal`)=>{if(!(e.trim()||t.length))return!1;if(w(!0),!pe.current){pe.current=!0,f(`thinking`);let n=await be(e,t);return n===null?(pe.current=!1,f(`idle`),!1):(xe(n,wV(t)),!0)}let r=await be(e,t);return r!==null&&(fe(e=>[...e,{id:$Z(`s`),text:r,way:n}]),ye(),!0)},[be,xe,ye,fe]),Ce=(0,G.useCallback)(()=>{let e=me.current;e&&(e.stopped=!0,e.abort.abort())},[]),we=(0,G.useCallback)(e=>{let t=V.current.find(t=>t.id===e);t&&(fe(e=>e.filter(e=>e!==t)),me.current?(he.current=t.text,Ce()):pe.current||xe(t.text))},[xe,Ce,fe]),Te=(0,G.useCallback)(e=>{let t=V.current.find(t=>t.id===e);return fe(e=>e.filter(e=>e!==t)),t},[fe]),Ee=(0,G.useCallback)(async()=>{Ce(),fe(()=>[]),u([]),F([]),h(null),E({kind:`chat`}),S(!0);try{let e=await H.post(`/api/studio/assistant/chat/new`);I.current=e.id,t.setQueryData([`assistant-chat`],e),await t.invalidateQueries({queryKey:[`assistant-chats`]})}catch(e){h(e.message)}finally{S(!1)}},[t,Ce,fe]),De=(0,G.useCallback)((e,t)=>Se(e,t),[Se]),Oe=(0,G.useMemo)(()=>({messages:l,phase:d,activity:_,startedAt:y,error:m,send:De}),[l,d,_,y,m,De]),ke=dZ(Oe),Ae=(0,G.useMemo)(()=>({chat:Oe,ready:!!s.data,renewing:x,newChat:Ee,send:Se,pending:M,sendNow:we,takeBack:Te,stop:Ce,extra:ne,setExtra:z,model:ie,setModel:ae,layout:ce,setLayout:se,width:A===void 0?c.data?.width??null:A,setWidth:le,open:C,setOpen:w,view:T,setView:E,live:ke,dev:{on:ee,turns:P}}),[Oe,s.data,x,Ee,Se,M,we,Te,Ce,ne,ie,ce,c.data,se,A,le,C,T,ke,ee,P]);return(0,K.jsx)(eQ.Provider,{value:Ae,children:e})}function iQ(e){return Je({queryKey:[`assistant-chats`],queryFn:()=>H.get(`/api/studio/assistant/chats`),enabled:e,refetchInterval:e=>e.state.data?.chats.some(e=>e.summarising)?2e3:!1})}function aQ(e){return Je({queryKey:[`assistant-chat`,e],queryFn:async()=>{let t=await H.get(`/api/studio/assistant/chats/${e}`);return{...t,messages:t.messages.map(XZ)}},enabled:!!e})}function oQ(e){return e.split(`/`).find(Boolean)?.toLowerCase().replace(/[^a-z0-9-]/g,``)||`home`}var sQ=(0,G.lazy)(()=>ct(()=>import(`./Marketplace-CS7JTgiv.js`).then(e=>e.a).then(e=>({default:e.MarketplaceCards})),__vite__mapDeps([13,1,2,3,4,5,9,14,15,16,7,6]))),cQ=1520,lQ=768,uQ={min:120,max:900};function dQ(){return(0,G.useSyncExternalStore)(e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),()=>window.innerWidth)}function fQ(e){let t=dQ(),n=vL(),r=t>=cQ,i=t<lQ,a=e.layout;a===`sidebar`&&(!r||i)&&(a=`bottom`);let o=a===`bottom`&&!!n.compact;return o&&(a=`avatar`),{where:a,wide:r&&!i,phone:i,compact:o}}var pQ=new Set([`scroll_to`]);function mQ(e){let t=e.args??{},n={};try{n=e.result?JSON.parse(e.result):{}}catch{}let r=/^e\d+$/.test(String(t.target??``))?``:String(t.target??``),i=String(n.shown||n.filled||n.area||r);switch(e.toolCallName){case`navigate`:return W(`assistant.tool.navigate`,{where:String(t.to??``)});case`highlight`:return W(`assistant.tool.highlight`,{what:i});case`look_at_page`:return W(`assistant.tool.look`);case`read_section`:return W(`assistant.tool.read`,{what:i});case`fill_field`:return W(`assistant.tool.fill`,{what:i});case`docs_search`:case`docs_read`:case`authoring_guide`:return W(`assistant.tool.docs`);case`gallery_search`:case`gallery_detail`:case`show_templates`:return W(`assistant.tool.gallery`);case`plans`:case`account`:case`usage`:return W(`assistant.tool.account`);case`chats_search`:case`chat_read`:return W(`assistant.tool.chats`);case`wizards`:case`runs`:return W(`assistant.tool.space`);case`models`:return W(`assistant.tool.models`);default:return null}}function hQ({calls:e}){let t=[...new Set((e??[]).filter(e=>!pQ.has(e.toolCallName)).map(mQ).filter(e=>!!e))];return t.length?(0,K.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:t.map(e=>(0,K.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded-full bg-paper-2 px-2.5 py-0.5 text-[0.75rem] text-ink-3`,children:(0,K.jsx)(`span`,{className:`truncate`,children:e})},e))}):null}function gQ({card:e,send:t}){if(!e.plugin&&e.tool===`extraEffort`)return(0,K.jsx)(_Q,{reason:String(e.data.reason??``)});if(!e.plugin&&e.tool===`templates`){let{entries:t}=e.data;return(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Fe,{className:`m-2 size-4`}),children:(0,K.jsx)(sQ,{entries:t})})}return(0,K.jsx)(vQ,{card:e,send:t})}function _Q({reason:e}){let t=tQ(),[n,r]=(0,G.useState)(!1);return!t||n?null:(0,K.jsxs)(`div`,{className:`my-2 flex flex-col gap-2 rounded-xl bg-amber/10 p-3 text-[0.8125rem] ring-1 ring-amber/30`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`b`,{className:`font-medium`,children:W(`assistant.extraTitle`)}),` `,(0,K.jsx)(`span`,{className:`text-ink-2`,children:e})]}),t.extra?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-ink-2`,children:[(0,K.jsx)(o,{className:`size-3.5 text-moss`,strokeWidth:3}),` `,W(`assistant.extraOn`)]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>t.setExtra(!0),className:`inline-flex h-8 items-center rounded-full bg-primary px-3 font-medium text-primary-foreground text-[0.8125rem]`,children:W(`assistant.extraOnButton`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`inline-flex h-8 items-center rounded-full px-3 text-ink-2 ring-1 ring-border hover:bg-paper-2`,children:W(`assistant.extraNo`)})]})]})}function vQ({card:e,send:t}){let n=O0().cards.find(t=>t.plugin===e.plugin&&t.tool===e.tool);return n?(0,K.jsx)(Q0,{of:n,children:(0,K.jsx)(n.component,{data:e.data,send:t})}):null}function yQ(){return[{label:W(`assistant.suggest.what`)},{label:W(`assistant.suggest.models`)},{label:W(`assistant.suggest.credits`)}]}function bQ({state:e,composer:t}){let n=vL(),r=(n.suggestions?.length?n.suggestions:yQ()).slice(0,3);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`shrink-0`,children:(0,K.jsx)(Dt,{kind:`round`,size:44,helmet:!0,interactive:!1})}),(0,K.jsxs)(`div`,{className:`min-w-0 pt-0.5`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-[1.0625rem] leading-tight tracking-tight`,children:n.title??W(`assistant.helloTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:n.hello??W(`assistant.hello`)})]})]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(n=>(0,K.jsxs)(`button`,{type:`button`,disabled:e.chat.phase!==`idle`,onClick:()=>{let r=n.message??n.label;n.fill?t.current?.fill(r):e.chat.send(r)},className:`flex items-center gap-2 rounded-xl bg-paper-2 px-3.5 py-2.5 text-left text-[0.875rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:opacity-60`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:n.label}),n.fill?(0,K.jsx)(Li,{className:`size-3.5 shrink-0 text-ink-4`}):null]},n.label))})]})}function xQ({state:e}){let t=iQ(!0);if(t.isLoading)return(0,K.jsx)(Fe,{className:`m-4 size-4`});let n=t.data?.chats??[];return n.length?(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(t=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>e.setView({kind:`read`,id:t.id}),className:`flex w-full flex-col gap-0.5 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:t.title||W(`assistant.untitled`)}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-4 tabular-nums`,children:new Date(t.closedAt).toLocaleDateString(Xt)})]}),(0,K.jsx)(`span`,{className:`line-clamp-1 text-[0.8125rem] text-ink-3`,children:t.summarising?W(`assistant.summarising`):t.summary.split(`
112
- `)[0]})]})},t.id))}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`assistant.noEarlier`)})}function SQ({id:e}){let t=aQ(e);return t.data?(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl bg-paper-2 px-4 py-3 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,K.jsx)(`div`,{className:`font-medium text-ink`,children:t.data.title||W(`assistant.untitled`)}),(0,K.jsx)(`p`,{className:`mt-1 whitespace-pre-line`,children:t.data.summary})]}),(0,K.jsx)(MV,{chat:{messages:t.data.messages,phase:`idle`,activity:null,startedAt:null,error:null,send:async()=>!1},avatar:`round`,changedLabel:W(`space.assistantChanged`),card:e=>(0,K.jsx)(gQ,{card:e,send:()=>void 0}),calls:e=>(0,K.jsx)(hQ,{calls:e.toolCalls})})]}):(0,K.jsx)(Fe,{className:`m-4 size-4`})}function CQ({state:e,composer:t}){let n=(0,G.useRef)(null),{chat:r,view:i}=e;return(0,G.useEffect)(()=>{let e=n.current,t=e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);!t||e.metaKey||e.ctrlKey||e.shiftKey||(HZ(t)?e.preventDefault():/^https?:\/\//.test(t)&&(e.preventDefault(),window.open(t,`_blank`,`noopener,noreferrer`)))};return e?.addEventListener(`click`,t),()=>e?.removeEventListener(`click`,t)},[]),(0,G.useEffect)(()=>{n.current?.scrollTo({top:n.current.scrollHeight,behavior:`smooth`})},[r.messages,r.phase,i]),(0,K.jsxs)(`div`,{ref:n,"data-assistant-thread":!0,className:`min-h-0 flex-1 overflow-y-auto px-4 py-4 sm:px-5`,children:[i.kind===`earlier`?(0,K.jsx)(xQ,{state:e}):i.kind===`read`?(0,K.jsx)(SQ,{id:i.id}):r.messages.length?(0,K.jsx)(MV,{chat:r,avatar:`round`,changedLabel:W(`space.assistantChanged`),card:e=>(0,K.jsx)(gQ,{card:e,send:e=>void r.send(e)}),calls:t=>e.dev.on?(0,K.jsx)(uR,{calls:t.toolCalls}):(0,K.jsx)(hQ,{calls:t.toolCalls}),foot:t=>e.dev.on?(0,K.jsx)(cR,{steps:t.steps}):null}):(0,K.jsx)(bQ,{state:e,composer:t}),r.error&&i.kind===`chat`?(0,K.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-3 py-2 text-[0.8125rem] text-rose`,children:r.error}):null]})}function wQ({state:e}){let[t,n]=(0,G.useState)(!1),r=!!iQ(!0).data?.chats.length,i=(0,G.useRef)(null);t0(i,t,()=>n(!1));let a=`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink disabled:opacity-50`;return(0,K.jsxs)(`div`,{className:`relative shrink-0`,ref:i,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":t,"aria-label":W(`assistant.menu`),onClick:()=>n(e=>!e),className:`-ml-1 flex items-center gap-1 rounded-lg px-1.5 py-0.5 font-display font-semibold text-[0.9375rem] transition hover:bg-accent`,children:[W(`assistant.name`),(0,K.jsx)(O,{className:`size-3.5 text-ink-4`})]}),t?(0,K.jsxs)(`div`,{role:`menu`,className:`absolute top-8 left-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,disabled:e.renewing,onClick:()=>{n(!1),e.newChat()},children:[(0,K.jsx)(Li,{className:`size-4`}),` `,W(`assistant.newChat`)]}),r?(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,onClick:()=>{n(!1),e.setView({kind:`earlier`})},children:[(0,K.jsx)(yi,{className:`size-4`}),` `,W(`assistant.earlier`)]}):null]}):null]})}function TQ({state:e,where:t,wide:n,phone:r,compact:i,grip:a,floating:o}){let s=e.live,[c,l]=(0,G.useState)(!1),u=X1().map(e=>e.label).join(` · `),d=e.dev.on&&e.view.kind===`chat`,f=t===`sidebar`,p=e.chat.messages;return(0,K.jsxs)(`div`,{className:V(`flex items-center border-border-soft border-b py-1`,f?`px-3`:`px-3 sm:px-4`),children:[a,e.view.kind===`chat`?t===`sidebar`?(0,K.jsx)(Dt,{kind:`round`,size:26,helmet:!0,interactive:!1}):null:(0,K.jsx)(re,{label:W(`assistant.back`),onClick:()=>e.setView({kind:e.view.kind===`read`?`earlier`:`chat`}),className:`size-8`,children:(0,K.jsx)(se,{className:`size-4`})}),(0,K.jsx)(`div`,{className:`mr-1 ml-1.5 min-w-[8.5rem] flex-1`,children:(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.view.kind===`chat`?(0,K.jsx)(wQ,{state:e}):(0,K.jsx)(`span`,{className:`font-display font-semibold text-[0.9375rem]`,children:W(`assistant.earlier`)}),s.state===`off`?u?(0,K.jsx)(`span`,{className:`min-w-0 truncate text-[0.75rem] text-ink-4`,children:W(`assistant.sees`,{page:u})}):null:(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ember-strong`,children:[(0,K.jsx)(`span`,{className:`size-1.5 animate-pulse-dot rounded-full bg-ember`}),W(`assistant.live`),` · `,(0,K.jsx)(EQ,{since:s.since})]})]})}),d?(0,K.jsx)(pR,{messages:p,narrow:f}):null,d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(re,{label:W(`assistant.inspect`),onClick:()=>l(!0),className:`size-8 max-sm:hidden`,children:(0,K.jsx)(_n,{className:`size-4`})}),p.length&&!f?(0,K.jsx)(`span`,{className:`max-sm:hidden`,children:(0,K.jsx)(hR,{messages:p,turns:e.dev.turns})}):null,(0,K.jsx)(vR,{open:c,onClose:()=>l(!1),turns:e.dev.turns,messages:p})]}):null,e.view.kind===`chat`&&p.length?(0,K.jsx)(re,{label:W(`assistant.newChat`),disabled:e.renewing,onClick:()=>void e.newChat(),className:`size-8`,children:(0,K.jsx)(Li,{className:`size-4`})}):null,(t===`bottom`||t===`avatar`&&!i)&&o?.can?(0,K.jsx)(re,{label:o.on&&t===`bottom`?W(`assistant.layoutCenter`):W(`assistant.layoutFloat`),onClick:()=>{t===`avatar`?(ER({place:`right`}),e.setLayout(`bottom`),e.setOpen(!0)):ER({place:o.on?`center`:`right`})},className:`size-8`,children:o.on&&t===`bottom`?(0,K.jsx)(Zr,{className:`size-4`}):(0,K.jsx)(li,{className:`size-4`})}):null,t!==`sidebar`&&n?(0,K.jsx)(re,{label:W(`assistant.layoutSidebar`),onClick:()=>e.setLayout(`sidebar`),className:`size-8`,children:(0,K.jsx)(ri,{className:`size-4`})}):null,t===`sidebar`||t===`avatar`&&!r&&!i?(0,K.jsx)(re,{label:W(`assistant.layoutBottom`),onClick:()=>{e.setLayout(`bottom`),e.setOpen(!0)},className:`size-8`,children:(0,K.jsx)(Zr,{className:`size-4`})}):null,(0,K.jsx)(re,{label:W(`assistant.close`),onClick:()=>{e.layout!==`avatar`&&e.setLayout(`avatar`),e.setOpen(!1),GQ.dispatchEvent(new Event(`close`))},className:`size-8`,children:(0,K.jsx)(xe,{className:`size-4`})})]})}function EQ({since:e}){let[t,n]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=e?Math.max(0,Math.floor((t-e)/1e3)):0;return(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[String(Math.floor(r/60)).padStart(2,`0`),`:`,String(r%60).padStart(2,`0`)]})}function DQ({state:e}){let t=e.live,n=t.state===`thinking`?W(`assistant.liveThinking`):t.state===`speaking`?W(`assistant.liveSpeaking`):t.muted?W(`assistant.liveMuted`):W(`assistant.liveListening`);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full bg-card p-1 pl-4 shadow-overlay ring-1 ring-ember-veil`,children:[(0,K.jsx)(`span`,{className:`size-2 shrink-0 animate-pulse-dot rounded-full bg-ember`}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-5 shrink-0 items-center gap-0.5`,children:[.5,.8,1,.75,.45].map((e,n)=>(0,K.jsx)(`span`,{className:`w-1 rounded-full bg-ember transition-[height] duration-100`,style:{height:`${Math.max(3,Math.round(t.level*e*20))}px`}},n))}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-2`,children:t.heard?(0,K.jsx)(`span`,{className:`text-ink`,children:t.heard}):t.state===`thinking`?(0,K.jsx)(AV,{chat:e.chat,className:`text-ink-3`}):(0,K.jsxs)(K.Fragment,{children:[n,` · `,(0,K.jsx)(EQ,{since:t.since})]})}),t.voice&&t.voice.way!==`none`?(0,K.jsx)(re,{label:W(`assistant.naturalVoice`),"aria-pressed":t.voice.natural,onClick:()=>t.setNatural(!t.voice?.natural),className:V(t.voice.natural&&`bg-ember-tint text-ember-strong`),children:(0,K.jsx)(ft,{className:`size-4`})}):null,(0,K.jsx)(re,{label:t.muted?W(`assistant.unmute`):W(`assistant.mute`),"aria-pressed":t.muted,onClick:t.toggleMute,children:t.muted?(0,K.jsx)(gt,{className:`size-4`}):(0,K.jsx)(ye,{className:`size-4`})}),(0,K.jsxs)(`button`,{type:`button`,onClick:t.end,className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-rose px-3.5 font-medium text-[0.8125rem] text-white coarse:h-11`,children:[(0,K.jsx)(St,{className:`size-4`}),` `,W(`assistant.end`)]})]})}function OQ({state:e}){let t=FZ(),n=e.chat.phase===`idle`;return(0,G.useEffect)(()=>{n&&IZ()},[n]),t?(0,K.jsxs)(`div`,{className:`mb-2 grid gap-2.5 rounded-xl border border-ember/40 bg-card p-3 text-[0.8125rem]`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-ink`,children:[(0,K.jsx)(Ni,{className:`size-4 shrink-0 text-ember`}),W(t.destructive?`assistant.confirm.delete`:`assistant.confirm.change`,{service:t.service})]}),(0,K.jsx)(`p`,{className:`text-ink-2`,children:t.action}),t.input&&t.input!==`{}`?(0,K.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-ink/5 px-3 py-2 text-[0.75rem] text-ink`,children:t.input}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>t.answer(!0),className:`inline-flex h-8 items-center rounded-full bg-primary px-3 font-medium text-[0.8125rem] text-primary-foreground`,children:W(`assistant.confirm.yes`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>t.answer(!1),className:`inline-flex h-8 items-center rounded-full px-3 text-ink-2 ring-1 ring-border hover:bg-paper-2`,children:W(`assistant.confirm.no`)})]})]}):null}function kQ({state:e,composer:t}){return e.pending.length?(0,K.jsx)(`ul`,{"aria-label":W(`assistant.pending`),className:`mb-2 flex flex-col gap-1`,children:e.pending.map(n=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 rounded-xl bg-card py-1 pr-1 pl-3 text-[0.8125rem] shadow-soft ring-1 ring-border`,children:[(0,K.jsx)(`span`,{title:n.way===`queue`?W(`assistant.pendingQueueHint`):W(`assistant.pendingSignalHint`),className:V(`shrink-0 rounded-full px-2 py-0.5 text-[0.6875rem]`,n.way===`queue`?`bg-paper-2 text-ink-3`:`bg-ember-tint text-ember-strong`),children:n.way===`queue`?W(`assistant.pendingQueue`):W(`assistant.pendingSignal`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.text}),(0,K.jsx)(`button`,{type:`button`,title:W(`assistant.sendNowHint`),onClick:()=>e.sendNow(n.id),className:`shrink-0 rounded-full px-2 py-1 font-medium text-[0.75rem] text-ember-strong transition hover:bg-ember-tint`,children:W(`assistant.sendNow`)}),(0,K.jsx)(re,{label:W(`assistant.edit`),onClick:()=>{let r=e.takeBack(n.id);r&&t.current?.fill(r.text)},className:`size-7`,children:(0,K.jsx)(M,{className:`size-3.5`})}),(0,K.jsx)(re,{label:W(`assistant.remove`),onClick:()=>e.takeBack(n.id),className:`size-7`,children:(0,K.jsx)(xe,{className:`size-3.5`})})]},n.id))}):null}var AQ=`auto`;function jQ(e,t){let{tier:n,modelPolicy:r}=XV(),i=n?fH(n,r,`assistant`):null,a=i?e&&i.allowed(e)?e:i.way===`A`?null:i.default??(i.auto?null:i.items[0]?.id??null):null,o=i!==null;if((0,G.useEffect)(()=>{o&&a!==e&&t(a)},[o,a,e,t]),!n||!i)return{model:void 0,effort:{}};let s=a?i.itemFor(a,i.items):null,c={items:[...i.auto?[{id:AQ,label:W(`chooser.auto`),note:W(`chooser.auto.hint`)}]:[],...i.items.map(e=>({id:e.id,label:e.name,note:e.hint}))],value:s?.id??a??AQ,onChange:e=>t(e===AQ?null:e)},l=i.efforts(a??`standard`).filter(e=>!s||s.efforts.includes(e));return{model:c,effort:l.includes(`high`)?{}:{disabled:!0,hint:s&&!s.efforts.length?W(`chooser.noEffort`,{model:s.name}):W(`composer.extraCap`,{effort:W(`class.effort.${l.at(-1)??`low`}`)})}}}function MQ({state:e,composer:t,floating:n,bare:r}){let i=vL(),a=e.live,o=jQ(e.model,e.setModel);if(e.view.kind===`earlier`)return null;if(e.view.kind===`read`)return(0,K.jsx)(`p`,{className:`m-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.8125rem] text-ink-2 leading-relaxed`,children:W(`assistant.readOnly`)});let s=e.chat.phase!==`idle`;return(0,K.jsxs)(`div`,{className:n?void 0:`p-3`,children:[a.state===`off`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(OQ,{state:e}),(0,K.jsx)(kQ,{state:e,composer:t}),(0,K.jsx)(Pe,{ref:t,floating:n,bare:r,placeholder:s?W(`assistant.busyComposer`,{keys:ae}):i.placeholder??W(`assistant.composer`),busy:s,onStop:e.stop,effort:{on:e.extra,onChange:e.setExtra,...o.effort},model:o.model,onSend:(t,n,r)=>e.send(t,n,r?`queue`:`signal`),onTalk:cZ?()=>{e.setOpen(!0),a.start()}:void 0})]}):(0,K.jsx)(DQ,{state:e}),a.error?(0,K.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:a.error===`denied`?W(`editor.micDenied`):a.error}):null]})}function NQ({composer:e,children:t,className:n,style:r}){return(0,K.jsx)(`div`,{"data-assistant-ui":!0,className:n,style:r,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:t=>{t.dataTransfer.files.length&&(t.preventDefault(),e.current?.add(Array.from(t.dataTransfer.files)),e.current?.focus())},children:t})}function PQ(e){let[t,n]=(0,G.useState)({width:0,height:0});return(0,G.useLayoutEffect)(()=>{let t=null,r=0,i=()=>{let a=e.current;if(!a){r=requestAnimationFrame(i);return}let o=()=>n({width:a.clientWidth,height:a.clientHeight});o(),t=new ResizeObserver(o),t.observe(a)};return i(),()=>{cancelAnimationFrame(r),t?.disconnect()}},[e]),t}function FQ(e){return t=>{if(t===`sidebar`){e.setLayout(`sidebar`);return}ER({place:t})}}function IQ({state:e,column:t,frame:n,wide:r,from:i}){let a=DR(),o=FQ(e);return(0,K.jsx)(`button`,{type:`button`,title:W(`assistant.move`),"aria-label":W(`assistant.move`),onPointerDown:a=>LR(a,{column:()=>t.current,frame:n,sidebar:r,onLeave:i===`sidebar`?()=>{e.setLayout(`bottom`),e.setOpen(!0)}:void 0,onDrop:o}),onKeyDown:e=>{let n=null;i===`sidebar`?n=e.key===`ArrowLeft`||e.key===`ArrowDown`?`right`:null:e.key===`ArrowLeft`?n=`center`:e.key===`ArrowRight`&&(n=IR(t.current?.clientWidth??0)&&a.place!==`right`?`right`:r?`sidebar`:null),n&&(e.preventDefault(),o(n))},className:`-ml-1.5 inline-flex h-8 w-5 shrink-0 cursor-grab touch-none items-center justify-center rounded-md text-ink-4 transition hover:bg-accent hover:text-ink active:cursor-grabbing`,children:(0,K.jsx)(S,{className:`size-4`})})}function LQ(){let e=NR();return e?.spot?(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute rounded-2xl border-2 border-ember border-dashed bg-ember-veil transition-all duration-200`,style:e.spot}):null}function RQ({place:e,width:t,column:n,frame:r,children:i}){let a=NR(),o;return o=a?{left:a.left,top:a.top,width:t}:{left:e===`right`?n.width-t-12:(n.width-t)/2,bottom:0,width:t},(0,K.jsx)(`div`,{ref:r,className:V(`pointer-events-none absolute flex flex-col`,a?`opacity-90`:`transition-[left,bottom] duration-300 ease-out`),style:o,children:i})}function zQ({thread:e,max:t,folded:n,onFold:r,onOpen:i}){let a=DR(),o=(0,G.useRef)(null),s=e=>Math.round(Math.min(Math.max(e,uQ.min),t)),c=a.height??e.current?.offsetHeight??uQ.min;return(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,"aria-valuenow":c,"aria-valuemin":uQ.min,"aria-valuemax":t,"aria-label":W(n?`assistant.open`:`assistant.flap`),title:W(n?`assistant.open`:`assistant.flap`),onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),o.current={y:t.clientY,height:e.current?.offsetHeight??0,moved:!1})},onPointerMove:e=>{let t=o.current;!t||!t.moved&&Math.abs(e.clientY-t.y)<4||n&&e.clientY>t.y||(n&&!t.moved&&i(),t.moved=!0,ER({height:s(t.height+(t.y-e.clientY))}))},onPointerUp:()=>{let e=o.current&&!o.current.moved;o.current=null,e&&(n?i:r)()},onPointerCancel:()=>{o.current=null},onKeyDown:e=>{if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(e.preventDefault(),n){e.key===`ArrowUp`&&i();return}ER({height:s(c+(e.key===`ArrowUp`?32:-32))})}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),(n?i:r)())},className:`group absolute top-0 left-1/2 z-10 flex h-3 w-16 -translate-x-1/2 cursor-row-resize touch-none items-center justify-center outline-none`,children:(0,K.jsx)(`span`,{className:`h-1 w-10 rounded-full bg-ink-4/40 transition group-hover:bg-ink-4 group-focus-visible:bg-ember`})})}var BQ=48,VQ=32,HQ=240;function UQ(){return(0,K.jsx)(`div`,{ref:BR,className:`hidden`})}var WQ=6e5,GQ=new EventTarget;function KQ(e){let t=e?.chat.phase??`idle`,[n,r]=(0,G.useState)(0),[,i]=(0,G.useState)(0),a=(0,G.useRef)(t);return(0,G.useEffect)(()=>{a.current!==`idle`&&t===`idle`&&r(Date.now()+WQ),a.current=t},[t]),(0,G.useEffect)(()=>{let e=()=>r(0);return GQ.addEventListener(`close`,e),()=>GQ.removeEventListener(`close`,e)},[]),(0,G.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>i(e=>e+1),Math.max(0,n-Date.now()));return()=>clearTimeout(e)},[n]),n>Date.now()}function qQ(e){let[t,n]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{try{n(localStorage.getItem(e)===`1`)}catch{n(!1)}},[e]),[t,(t=!0)=>{n(t);try{t?localStorage.setItem(e,`1`):localStorage.removeItem(e)}catch{}}]}function JQ({closed:e,children:t}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)(null);return(0,G.useLayoutEffect)(()=>{let e=n.current;if(!e)return;let t=()=>i(e.offsetHeight);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e]),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(`section`,{className:V(`overflow-hidden bg-card shadow-soft ring-1 transition-[width,height,border-radius,box-shadow] duration-300 ease-out [interpolate-size:allow-keywords] motion-reduce:transition-none`,e?`w-fit rounded-[1.25rem] ring-border`:`w-full rounded-xl bg-linear-to-br from-ember-tint via-card to-card ring-ember-veil`),style:r===null?void 0:{height:r},children:(0,K.jsx)(`div`,{ref:n,className:`fade-in-0 animate-in duration-300`,children:t},e?`hint`:`intro`)})})}function YQ({onOpen:e}){return(0,K.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-2 whitespace-nowrap py-1 pr-3 pl-1 text-[0.875rem] text-ink-2 transition hover:text-ink`,children:[(0,K.jsx)(Dt,{kind:`round`,size:28,helmet:!0,interactive:!1}),W(`assistant.help`),(0,K.jsx)(Vn,{className:`size-4 text-ink-3`})]})}function XQ({state:e,onClose:t}){let n=vL(),r=_e().pathname,[i,a]=qQ(`goose.intro.hello:${r}`),[o,s]=(0,G.useState)(``),c=e.chat.phase===`idle`,l=(n.suggestions?.length?n.suggestions:yQ()).slice(0,3),u=t=>{t.trim()&&c&&(e.setOpen(!0),e.chat.send(t.trim()),s(``))};return(0,K.jsxs)(`div`,{className:`relative p-4 sm:p-5`,children:[(0,K.jsx)(re,{label:W(`assistant.intro.close`),onClick:t,className:`absolute top-2 right-2 size-8`,children:(0,K.jsx)(xe,{className:`size-4`})}),i?null:(0,K.jsxs)(`div`,{className:`mb-4 flex items-start gap-4 pr-8`,children:[(0,K.jsx)(`div`,{className:`shrink-0`,children:(0,K.jsx)(Dt,{kind:`round`,size:48,helmet:!0,interactive:!1})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-[1.125rem] leading-tight tracking-tight`,children:n.title??W(`assistant.helloTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:n.hello??W(`assistant.hello`)}),n.about?(0,K.jsx)(`p`,{className:`mt-1.5 max-w-2xl text-[0.8125rem] text-ink-3 leading-relaxed`,children:n.about}):null,(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(),className:`mt-2 text-[0.75rem] text-ink-3 underline-offset-2 hover:text-ink hover:underline`,children:W(`assistant.intro.hideHello`)})]})]}),(0,K.jsxs)(`form`,{className:V(`flex h-11 items-center gap-2 rounded-full border border-input bg-paper pr-1.5 pl-2 focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,i&&`mr-8`),onSubmit:e=>{e.preventDefault(),u(o)},children:[(0,K.jsx)(Dt,{kind:`round`,size:28,helmet:!0,interactive:!1}),(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":W(`assistant.ask`),placeholder:n.placeholder??W(`assistant.composer`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,K.jsx)(re,{type:`submit`,label:W(`assistant.ask`),disabled:!(o.trim()&&c),className:`size-8 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground disabled:opacity-40`,children:(0,K.jsx)(Ie,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:l.map(e=>(0,K.jsxs)(`button`,{type:`button`,disabled:!c,onClick:()=>e.fill?s(e.message??e.label):u(e.message??e.label),className:`flex items-center gap-1.5 rounded-full bg-paper-2 px-3 py-1.5 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:opacity-60`,children:[e.label,e.fill?(0,K.jsx)(Li,{className:`size-3.5 shrink-0 text-ink-4`}):null]},e.label))})]})}function ZQ(e,t){let[n,r]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>{if(!e){r(!1);return}let n=0,i=()=>{n=0;let i=p0().getBoundingClientRect(),a=e.getBoundingClientRect();if(!e.offsetParent){r(!0);return}let o=a.top+Math.max(a.height,t.current||HQ);r(o<i.top+BQ||a.top>i.bottom)},a=()=>{n||=requestAnimationFrame(i)};i();let o=new ResizeObserver(a);return o.observe(e),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),o.disconnect(),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[e,t]),n}function QQ({column:e}){let t=tQ(),n=!!AZ(),r=(0,G.useRef)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=e$(t),l=DR(),u=PQ(e),d=t&&c,f=GR(),p=PR(u.width),m=c?.phone||!IR(u.width)?`center`:l.place,h=!!t?.open,[g,_]=(0,G.useState)(!1),v=KQ(t),y=t?.chat.phase!==`idle`||(t?.live.state??`off`)!==`off`||v,b=g||h||y,x=c?.where===`sidebar`,S=!!vL().ownInput,C=!x&&(c?.where===`avatar`||S)&&!y,w=VR(),T=_e().pathname,[E,D]=qQ(`goose.intro.closed:${T}`),O=w&&d&&C&&!h?w:null,k=(0,G.useRef)(0);(0,G.useLayoutEffect)(()=>{w&&(w.style.display=O?`block`:``)},[w,O]);let A=ZQ(O,k),j=!!O&&!A||S&&!y&&!h&&!x,M=!(j||x),N=!!c?.phone,P=!!d&&!j&&!(C&&!h),[F]=(0,G.useState)(()=>{let e=document.createElement(`div`);return e.className=`flex min-h-0 flex-col`,e}),[I,L]=(0,G.useState)(null),[R,ee]=(0,G.useState)(!1);if((0,G.useLayoutEffect)(()=>{let e=x?f:I;if(F.className=V(`flex min-h-0 flex-col`,x&&`flex-1`),!e||F.parentElement===e)return;let t=F.contains(document.activeElement)?document.activeElement:null;e.appendChild(F),t instanceof HTMLElement&&t.focus({preventScroll:!0});for(let e of F.querySelectorAll(`[data-assistant-thread]`))e.scrollTop=e.scrollHeight;ee(!0)},[x,f,I,F]),(0,G.useEffect)(()=>()=>{F.remove()},[F]),(0,G.useLayoutEffect)(()=>{let t=C&&!h?i.current:o.current,n=e.current;if(!(t&&n&&d&&M)){n?.style.setProperty(`--assistant-dock`,`0px`);return}let r=new ResizeObserver(()=>{let e=t===o.current&&!N?VQ:0,r=n.getBoundingClientRect().bottom-t.getBoundingClientRect().top;n.style.setProperty(`--assistant-dock`,`${Math.max(0,Math.ceil(r))+e+8}px`)});return r.observe(t),r.observe(n),()=>{r.disconnect(),n.style.setProperty(`--assistant-dock`,`0px`)}},[e,d,M,C,h,R,N]),(0,G.useEffect)(()=>{if(!t?.open)return;let e=e=>{e.key===`Escape`&&!document.querySelector(`[role=dialog], dialog[open]`)&&t.setOpen(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),!(t&&c&&d))return null;let te=O?(0,_c.createPortal)((0,K.jsx)(JQ,{closed:E,children:E?(0,K.jsx)(YQ,{onOpen:()=>D(!1)}):(0,K.jsx)(XQ,{state:t,onClose:()=>D()})}),O):null,ne=Math.max(uQ.min,Math.min(uQ.max,u.height-220)),z=l.height===null?null:Math.min(l.height,ne),ie=c.phone?void 0:(0,K.jsx)(IQ,{state:t,column:e,frame:()=>x?null:o.current,wide:c.wide,from:x?`sidebar`:`bottom`}),B=h||x,ae=P&&R?(0,_c.createPortal)((0,K.jsx)(NQ,{composer:r,className:V(`flex min-h-0 flex-col`,x&&`flex-1`),children:(0,K.jsxs)(`div`,{className:V(`pointer-events-auto relative flex min-h-0 flex-col overflow-hidden`,x?`flex-1`:`rounded-[1.375rem] bg-card shadow-overlay ring-1 ring-border focus-within:ring-focus`),children:[x?null:(0,K.jsx)(zQ,{thread:s,max:ne,folded:!h,onFold:()=>t.setOpen(!1),onOpen:()=>t.setOpen(!0)}),(0,K.jsx)(`div`,{className:V(`relative flex min-h-0 flex-col`,x&&`flex-1`),children:(0,K.jsxs)(`div`,{className:V(`flex min-h-0 flex-col`,x&&`flex-1`),style:B&&!x?{maxHeight:ne+60}:void 0,children:[(0,K.jsx)(TQ,{state:t,where:x?`sidebar`:C?`avatar`:`bottom`,wide:c.wide,phone:c.phone,compact:c.compact,grip:ie,floating:{on:m===`right`,can:IR(u.width)&&!c.phone}}),B?(0,K.jsx)(`div`,{ref:s,className:V(`flex min-h-0 flex-col border-border-soft border-b`,x?`flex-1`:`animate-rise`),style:x?void 0:z===null?{maxHeight:Math.min(ne,Math.round(u.height*.45))}:{height:z},children:(0,K.jsx)(CQ,{state:t,composer:r})}):t.chat.messages.length||t.chat.error?(0,K.jsx)($Q,{state:t}):null]})}),(0,K.jsx)(`div`,{ref:i,onFocusCapture:()=>_(!0),onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},className:`relative w-full`,children:(0,K.jsx)(MQ,{state:t,composer:r,floating:!0,bare:!0})})]})}),F):null,oe=(0,K.jsx)(`button`,{type:`button`,"aria-label":W(`assistant.open`),title:`${W(`assistant.open`)} · ${W(`assistant.move`)}`,tabIndex:-1,onPointerDown:n=>LR(n,{column:()=>e.current,frame:()=>o.current,sidebar:c.wide,onClick:()=>t.setOpen(!0),onDrop:FQ(t)}),onClick:e=>{e.detail===0&&t.setOpen(!0)},className:V(`pointer-events-auto absolute bottom-full left-6 -mb-3 origin-bottom cursor-grab touch-none transition duration-300 ease-out active:cursor-grabbing max-sm:hidden`,b?`translate-y-0 scale-100 opacity-100`:`pointer-events-none translate-y-3 scale-75 opacity-0`),children:(0,K.jsx)(Dt,{kind:`round`,size:44,helmet:!0,interactive:b})}),se=(0,K.jsx)(NQ,{composer:r,className:V(`pointer-events-none absolute inset-0`,n?`z-[61]`:`z-30`),children:(0,K.jsx)(`div`,{ref:i,className:V(`pointer-events-auto absolute right-3 sm:right-4`,N?`bottom-[calc(4.75rem+env(safe-area-inset-bottom))]`:`bottom-3 sm:bottom-4`),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full bg-card p-1 pr-1.5 shadow-overlay ring-1 ring-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t.setOpen(!0),className:`flex items-center gap-2 rounded-full py-0.5 pr-2 pl-0.5 text-[0.875rem] text-ink-2 transition hover:text-ink`,children:[(0,K.jsxs)(`span`,{className:`relative`,children:[(0,K.jsx)(Dt,{kind:`round`,size:36,helmet:!0,interactive:!1}),t.chat.phase!==`idle`||t.live.state!==`off`?(0,K.jsx)(`span`,{className:`absolute top-0 right-0 size-2.5 animate-pulse-dot rounded-full bg-ember ring-2 ring-card`}):null]}),(0,K.jsx)(`span`,{className:`max-sm:hidden`,children:W(`assistant.ask`)})]}),cZ?(0,K.jsx)(re,{label:W(`assistant.talk`),onClick:()=>{t.setOpen(!0),t.live.start()},className:`size-8 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground`,children:(0,K.jsx)(Te,{className:`size-4`})}):null]})})});return(0,K.jsxs)(K.Fragment,{children:[te,ae,j||x?null:C&&!h?se:(0,K.jsxs)(NQ,{composer:r,className:V(`pointer-events-none absolute inset-0`,n?`z-[61]`:`z-30`),children:[(0,K.jsx)(LQ,{}),(0,K.jsxs)(RQ,{place:m,width:p,column:u,frame:o,children:[oe,(0,K.jsx)(`div`,{ref:L,className:`flex min-h-0 flex-col`}),(0,K.jsx)(`div`,{ref:a,className:V(`shrink-0`,N?`h-[calc(4.75rem+env(safe-area-inset-bottom))]`:`h-[max(0.75rem,env(safe-area-inset-bottom))]`)})]})]})]})}function $Q({state:e}){let t=e.chat.messages.at(-1);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>e.setOpen(!0),className:`flex w-full items-center gap-2 border-border-soft border-b px-4 py-2.5 text-left text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:t?.pending?(0,K.jsx)(AV,{chat:e.chat,className:`flex-1`}):(0,K.jsx)(`span`,{className:V(`min-w-0 flex-1 truncate`,e.chat.error&&`text-rose`),children:e.chat.error??_t(t?.content??``)})})}function e$(e){let t=fQ(e??t$);return e?t:null}var t$={layout:`bottom`,open:!1,chat:{messages:[]}},n$=e=>Math.max(SV.min,Math.min(SV.max,e-1120));function r$({state:e,width:t,max:n}){let r=e=>Math.round(Math.min(Math.max(e,SV.min),n));return(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":W(`editor.resize`),"aria-valuenow":t,"aria-valuemin":SV.min,"aria-valuemax":n,tabIndex:0,title:W(`editor.resize`),onPointerDown:n=>{if(n.button!==0)return;n.preventDefault();let i=n.clientX,a=t,o=n=>{a=r(t-(n.clientX-i)),e.setWidth(a,!1)},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),e.setWidth(a===SV.initial?null:a)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},onKeyDown:n=>{if(n.key===`ArrowLeft`||n.key===`ArrowRight`){n.preventDefault();let i=n.shiftKey?64:16;e.setWidth(r(t+(n.key===`ArrowLeft`?i:-i)))}},onDoubleClick:()=>e.setWidth(null),className:`group -left-2 absolute inset-y-0 z-10 w-2 cursor-col-resize outline-none`,children:(0,K.jsx)(`span`,{className:`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 h-8 w-1 rounded-full bg-ink-4/20 transition group-hover:bg-ember/60 group-focus-visible:bg-ember group-active:h-12 group-active:bg-ember`})})}function i$(){return e$(tQ())?.where===`sidebar`}function a$(){let e=tQ(),t=!!AZ(),n=e$(e),r=n$(dQ());if(!(e&&n&&n.where===`sidebar`))return null;let i=Math.min(Math.max(e.width??SV.initial,SV.min),r);return(0,K.jsxs)(`div`,{className:V(`relative flex shrink-0`,t&&`z-[61]`),style:{width:i},children:[(0,K.jsx)(r$,{state:e,width:i,max:r}),(0,K.jsx)(`aside`,{"aria-label":W(`assistant.name`),className:`flex min-w-0 flex-1 flex-col overflow-hidden rounded-xl bg-background shadow-elevated dark:ring-1 dark:ring-border-soft`,children:(0,K.jsx)(`div`,{ref:WR,className:`flex min-h-0 flex-1 flex-col`})})]})}function o$(){let e=AZ(),t=tQ(),[n,r]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!e){r(null);return}let t=0,n=()=>{if(!e.el.isConnected){kZ(null);return}r(e.el.getBoundingClientRect()),t=requestAnimationFrame(n)};n();let i=e=>{e.key===`Escape`&&kZ(null)};return document.addEventListener(`keydown`,i),()=>{cancelAnimationFrame(t),document.removeEventListener(`keydown`,i)}},[e]),!(e&&n))return null;let i={left:n.left-6,top:n.top-6,width:n.width+12,height:n.height+12},a=i.top+i.height+220<window.innerHeight,o=a?i.top+i.height+10:Math.max(10,i.top-10),s=Math.min(Math.max(10,i.left),window.innerWidth-330),c=e=>{kZ(null),t?.chat.send(e)};return(0,_c.createPortal)((0,K.jsxs)(`div`,{"data-assistant-ui":!0,className:`pointer-events-none fixed inset-0 z-[60]`,children:[e.mode===`spotlight`?(0,K.jsx)(`div`,{className:`pointer-events-auto absolute rounded-xl transition-all duration-200`,style:{...i,boxShadow:`0 0 0 100vmax oklch(0.2 0.01 60 / 0.45)`},onClick:()=>kZ(null),onKeyDown:void 0,role:`presentation`}):null,(0,K.jsx)(`div`,{className:`absolute rounded-xl ring-2 ring-ember ring-offset-2 ring-offset-transparent transition-all duration-200`,style:i}),e.title||e.text||e.buttons.length?(0,K.jsxs)(`div`,{className:`pointer-events-auto absolute w-80 max-w-[calc(100vw-20px)] animate-rise rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border`,style:{left:s,...a?{top:o}:{bottom:window.innerHeight-o}},children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(Dt,{kind:`round`,size:28,helmet:!0,interactive:!1}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e.title?(0,K.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:e.title}):null,e.text?(0,K.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:e.text}):null]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-1.5`,children:[e.buttons.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:`rounded-full bg-paper-2 px-3 py-1.5 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e)),(0,K.jsx)(`button`,{type:`button`,onClick:()=>kZ(null),className:`rounded-full bg-primary px-3 py-1.5 font-medium text-[0.8125rem] text-primary-foreground`,children:W(`assistant.gotIt`)})]})]}):null]}),document.body)}var s$=[{theme:`light`,icon:wt,label:`theme.light`},{theme:`branded`,icon:Yr,label:`theme.branded`},{theme:`dark`,icon:Et,label:`theme.dark`}],c$=`cubic-bezier(0.3, 0.7, 0.2, 1)`;function l$({tone:e=`surface`}){let t=jt(),n=Tt(),r=e===`ground`,i=r?n:t,a=s$.findIndex(e=>e.theme===i);return(0,K.jsxs)(`fieldset`,{className:V(`relative inline-flex items-center rounded-full border-0 p-0.5 ring-1`,r?`bg-white/10 ring-white/15`:`bg-paper-2 ring-border-soft`),children:[(0,K.jsx)(`legend`,{className:`sr-only`,children:W(`nav.theme`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:V(`absolute top-0.5 bottom-0.5 left-0.5 w-9 rounded-full shadow-sm motion-reduce:transition-none`,r?`bg-white`:`bg-card`),style:{transform:`translateX(${a*100}%)`,transition:`transform 300ms ${c$}`}}),s$.map(({theme:e,icon:t,label:n})=>(0,K.jsx)(`button`,{"aria-label":W(n),"aria-pressed":e===i,className:V(`relative grid h-7 w-9 cursor-pointer place-items-center rounded-full transition-colors motion-reduce:transition-none`,r?e===i?`text-[oklch(32%_0.15_262)]`:`text-white/70 hover:text-white`:e===i?`text-ink`:`text-ink-3 hover:text-ink-2`),onClick:()=>Lt(e),title:W(n),type:`button`,children:(0,K.jsx)(t,{className:`size-3.5`})},e))]})}var u$=`mt-1.5 text-[0.8125rem] text-ink-3`;function d$(e){let t=R(),[n,r]=(0,G.useState)(!1),i=ot({mutationFn:e=>H.post(`/api/studio/account/link`,e),onSuccess:({url:e})=>{zL(e),r(!0)}});return(0,G.useEffect)(()=>{if(!n)return;let e=setInterval(()=>void t.invalidateQueries({queryKey:[`me`]}),2e3),i=setTimeout(()=>r(!1),3e5);return()=>{clearInterval(e),clearTimeout(i)}},[n,t]),(0,G.useEffect)(()=>{e&&r(!1)},[e]),{link:i,waiting:n}}function f$({link:e,waiting:t}){return e.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:W(`local.accountFailed`)}):t?(0,K.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(Fe,{className:`size-3.5`}),` `,W(`local.accountWaiting`)]}):null}function p$({me:e}){let t=na(`account`),n=d$(!1),{link:r}=n,[i,a]=(0,G.useState)(``);return(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 py-5 first:pt-0 last:pb-0`,children:[(0,K.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2`,children:(0,K.jsx)(lr,{className:`size-5`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:W(`account.local`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:W(`account.localText`)}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(sn,{me:e})})]})]}),t?(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 py-5 last:pb-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:W(`account.with`)}),(0,K.jsxs)(`ul`,{className:`mt-2 flex flex-col gap-2 text-[0.875rem] text-ink-2 leading-snug`,children:[(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)($e,{className:`mt-0.5 size-4 shrink-0 text-amber`}),W(`account.withCredits`)]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(qn,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),W(`account.withCloud`)]})]})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(x,{busy:r.isPending&&!r.variables?.signup,onClick:()=>r.mutate({}),children:W(`account.signIn`)})})]}):null,t?(0,K.jsxs)(`form`,{className:`flex flex-col gap-3 py-5 last:pb-0`,onSubmit:e=>{e.preventDefault(),r.mutate({signup:!0,code:i.trim()||void 0})},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:W(`account.new`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:W(`account.newHint`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(k,{value:i,maxLength:64,autoComplete:`off`,spellCheck:!1,placeholder:W(`account.code`),"aria-label":W(`account.code`),onChange:e=>a(e.target.value),className:`w-56 font-mono text-[0.875rem]`}),(0,K.jsx)(x,{type:`submit`,variant:`secondary`,className:`h-11`,busy:r.isPending&&!!r.variables?.signup,children:W(`account.create`)})]}),(0,K.jsx)(f$,{...n})]}):null]})}var m$=e=>({...e,slug:null,personal:!1,plan:null});function h$({account:e}){let t=R(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),o=e.organizations.filter(t=>t.id!==e.organizationId),s=e.organizations.find(t=>t.id===e.organizationId),c=e.organization??s?.name??null,l=ot({mutationFn:()=>H.post(`/api/studio/account/refresh`,{}),onSettled:()=>t.invalidateQueries()}),u=ot({mutationFn:e=>H.post(`/api/studio/account/switch`,e),onSuccess:({url:e})=>{zL(e),a(!0)}});return(0,G.useEffect)(()=>{if(!i)return;let e=setInterval(()=>void t.invalidateQueries({queryKey:[`me`]}),2e3),n=setTimeout(()=>a(!1),3e5);return()=>{clearInterval(e),clearTimeout(n)}},[i,t]),(0,G.useEffect)(()=>{a(!1),r(!1)},[e.organizationId]),c?(0,K.jsxs)(`div`,{className:`py-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,K.jsx)(Tc,{org:m$({id:e.organizationId,name:c,role:s?.role??`member`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:W(`account.organization`)}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:c}),e.plan?(0,K.jsx)(v,{children:e.plan.name}):null,(0,K.jsx)(re,{label:W(`account.refresh`),className:`size-7 coarse:size-9`,disabled:l.isPending,onClick:()=>l.mutate(),children:(0,K.jsx)(j,{className:V(`size-3.5`,l.isPending&&`animate-spin`)})})]})]})]}),o.length?(0,K.jsxs)(x,{variant:`secondary`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,K.jsx)(Cn,{className:`size-4`}),` `,W(`organizations.switch`)]}):null]}),n&&o.length?(0,K.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:W(`account.switchHint`,{name:c})}),(0,K.jsx)(`div`,{className:`flex flex-col rounded-xl ring-1 ring-border-soft`,children:o.map(e=>(0,K.jsxs)(`button`,{type:`button`,disabled:u.isPending||i,className:`flex w-full items-center gap-3 px-3 py-2.5 text-left transition first:rounded-t-xl last:rounded-b-xl hover:bg-accent disabled:cursor-default disabled:opacity-70`,onClick:()=>u.mutate({organization:e.id}),children:[(0,K.jsx)(Tc,{org:m$(e)}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink-2`,children:e.name}),(0,K.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:u.isPending&&u.variables?.organization===e.id?W(`organizations.switching`,{name:e.name}):W(`organization.role.${e.role}`)})]}),u.isPending&&u.variables?.organization===e.id?(0,K.jsx)(Fe,{className:`size-4`}):null]},e.id))}),u.isError?(0,K.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:u.error instanceof Ye?u.error.message:W(`local.accountFailed`)}),u.error instanceof Ye&&u.error.body?.reason===`changes_waiting`&&u.variables?(0,K.jsx)(x,{variant:`secondary`,size:`sm`,onClick:()=>u.mutate({...u.variables,anyway:!0}),children:W(`account.switchAnyway`)}):null]}):i?(0,K.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(Fe,{className:`size-3.5`}),` `,W(`local.accountWaiting`)]}):null]}):null]}):null}var g$={start:`account.kind.start`,monthly:`account.kind.monthly`,gift:`account.kind.gift`};function _$({account:e,me:t}){let n=R(),r=d$(e.signedIn),i=ot({mutationFn:()=>H.del(`/api/studio/account`),onSuccess:()=>n.invalidateQueries({queryKey:[`me`]})}),a=new Intl.DateTimeFormat(Xt,{dateStyle:`medium`});return(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 py-5 first:pt-0`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.name||e.email}),e.signedIn?(0,K.jsx)(v,{tone:`live`,children:W(`account.linked`)}):null]}),(0,K.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.email}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(sn,{me:t})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(x,{variant:`secondary`,onClick:()=>zL(e.url),children:[W(`setup.openAccount`),` `,(0,K.jsx)(h,{className:`size-4`})]}),(0,K.jsxs)(x,{variant:`ghost`,busy:i.isPending,onClick:()=>i.mutate(),children:[(0,K.jsx)(Fr,{className:`size-4`}),` `,W(`nav.logout`)]})]})]}),e.signedIn?(0,K.jsx)(h$,{account:e}):null,e.signedIn?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 py-5`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:W(`local.accountExpired`)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(x,{busy:r.link.isPending,onClick:()=>r.link.mutate({}),children:W(`account.signInAgain`)})}),(0,K.jsx)(f$,{...r})]}),e.credits===null?null:(0,K.jsxs)(`div`,{className:`py-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:W(`account.credits`)}),(0,K.jsx)(`div`,{className:`font-display font-semibold text-[1.375rem] tabular-nums leading-tight`,children:W(`nav.credits`,{n:Math.floor(e.credits).toLocaleString(Xt)})})]}),(0,K.jsxs)(x,{variant:`secondary`,onClick:()=>zL(`${e.url}/billing`),children:[W(`account.topUp`),` `,(0,K.jsx)(h,{className:`size-4`})]})]}),e.expiring.length?(0,K.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.expiring.map(e=>(0,K.jsxs)(`li`,{children:[W(`account.expires`,{n:Math.floor(e.credits).toLocaleString(Xt),date:a.format(new Date(e.expiresAt))}),g$[e.kind]?(0,K.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,W(g$[e.kind])]}):null]},`${e.kind}:${e.expiresAt}`))}):null]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5 py-5 text-[0.875rem] text-ink-2 leading-snug last:pb-0`,children:[(0,K.jsx)(qn,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),(0,K.jsx)(`p`,{children:W(`account.cloud`,{host:qL(e.cloudUrl)})})]})]})}function v$({me:e,fromAccount:t}){let n=R(),[r,i]=(0,G.useState)(e.profile),a=e=>i(t=>({...t,...e})),o=P(r,async e=>{await H.put(`/api/studio/profile`,e),await n.invalidateQueries({queryKey:[`me`]})});return(0,K.jsx)(le,{title:W(`account.profile`),hint:W(`account.hint`),save:o,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row sm:gap-8`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-2 sm:w-32`,children:[(0,K.jsx)(`div`,{className:`flex size-20 items-center justify-center overflow-hidden rounded-full bg-ember-tint font-semibold text-[1.75rem] text-ember-strong ring-1 ring-border-soft`,children:e.user.image?(0,K.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full object-cover`}):Nt(r.name)||`?`}),(0,K.jsx)(`p`,{className:`text-center text-[0.75rem] text-ink-3 leading-snug`,children:W(`account.initials`)})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`account.name`)}),(0,K.jsx)(k,{value:r.name,maxLength:80,disabled:t,onChange:e=>a({name:e.target.value})}),(0,K.jsx)(`p`,{className:u$,children:W(t?`account.fromAccount`:`account.nameHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`account.about`)}),(0,K.jsx)(Re,{minRows:3,maxLength:2e3,value:r.about,onChange:e=>a({about:e.target.value})}),(0,K.jsx)(`p`,{className:u$,children:W(`account.aboutHint`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`account.email`)}),(0,K.jsx)(k,{type:`email`,value:r.email,maxLength:200,disabled:t,onChange:e=>a({email:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(s,{children:W(`account.phone`)}),(0,K.jsx)(k,{type:`tel`,value:r.phone,maxLength:40,onChange:e=>a({phone:e.target.value})})]})]})]})]})})}function y$({me:e}){let t=e.mode===`managed`,n=t||!!e.account;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,K.jsx)(le,{title:W(`account.connection`),hint:W(`account.connectionHint`),children:t?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.user.name}),(0,K.jsx)(v,{tone:`live`,children:W(`account.linked`)})]}),(0,K.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.user.email}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(sn,{me:e})})]}),e.manageUrl?(0,K.jsxs)(x,{variant:`secondary`,onClick:()=>zL(`${e.manageUrl}/account`),children:[W(`setup.openAccount`),` `,(0,K.jsx)(h,{className:`size-4`})]}):null]}):e.account?(0,K.jsx)(_$,{account:e.account,me:e}):(0,K.jsx)(p$,{me:e})}),(0,K.jsx)(v$,{me:e,fromAccount:n},n?`account`:`own`),(0,K.jsx)(le,{title:W(`account.look`),hint:W(`account.lookHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pb-4`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:W(`nav.language`)}),(0,K.jsx)(pn,{})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-4`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:W(`nav.theme`)}),(0,K.jsx)(l$,{})]})]})})]})}var b$={steps:Ci,chat:zr,talk:ye,whatsapp:Lr,sms:Gr,call:si,video:pe},x$=e=>b$[e]??at,S$=[`steps`,`chat`];function C$(){return Je({queryKey:[`runners`],queryFn:()=>H.get(`/api/studio/runners`),staleTime:6e4})}function w$(e,t){let n=new Set(t.map(e=>e.id)),r=(e.runners?.enabled??S$).filter(e=>n.has(e)),i=e.runners?.default??`steps`;return[...r].sort((e,t)=>e===i?-1:+(t===i))}function T$({w:e,runners:t}){let n=w$(e,t),r=e.runners?.default??`steps`;return(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:n.map(e=>{let n=x$(e),i=t.find(t=>t.id===e)?.label[Xt]??e;return(0,K.jsx)(n,{"aria-label":i,className:V(`size-3.5`,e===r?`text-ink-2`:`text-ink-4`),children:(0,K.jsx)(`title`,{children:i})},e)})})}async function E$(e,t){let n=e.isFetching({queryKey:t.queryKey,exact:!0})>0;await e.cancelQueries({queryKey:t.queryKey,exact:!0});let r=e.getQueryData(t.queryKey),i=t.update(r);i!==r&&e.setQueryData(t.queryKey,i);let a=e.getQueryData(t.queryKey),o=()=>e.invalidateQueries({queryKey:t.queryKey,exact:!0});return{invalidate:o,wasFetching:n,rollback:()=>{if(e.getQueryData(t.queryKey)!==a)return o(),`invalidated`;if(r===void 0){if(a===void 0)return`unchanged`;e.removeQueries({queryKey:t.queryKey,exact:!0})}else e.setQueryData(t.queryKey,r);return`restored`}}}function D$(e,t=150){let n=new Map;return r=>{let i=JSON.stringify(r),a=n.get(i);a&&clearTimeout(a),n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:r,refetchType:`active`})},t))}}var O$=[];function k$(e){for(let t of e)O$.some(e=>e.id===t.id)||O$.push(t)}var A$=new Map;function j$(e,t,n){let r=`${e}|${t}`;return A$.set(r,n),()=>{A$.get(r)===n&&A$.delete(r)}}var M$=(e,t)=>A$.get(`${e}|${t}`);function N$(e,t){return e?typeof t.revision==`number`&&typeof e.revision==`number`?t.revision>e.revision:t.updatedAt&&e.updatedAt?Date.parse(t.updatedAt)>Date.parse(e.updatedAt):!0:!0}async function P$(e,t,n){if(!e.getQueryCache().find({queryKey:t,exact:!0}))return!1;let r=!1,i=await E$(e,{queryKey:t,update:e=>{let t=n(e);return t===void 0||t===e?e:(r=!0,t)}});return i.wasFetching&&i.invalidate(),r}function F$(e,t,n){e.setQueriesData({queryKey:t},e=>Array.isArray(e)?n(e)??e:e)}function I$(e,t,n){let r=e.findIndex(e=>e.id===t.id);if(r<0)return n===`none`?void 0:n===`first`?[t,...e]:[...e,t];if(!N$(e[r],t))return;let i=e.slice();return i[r]=t,i}var L$=(e,t)=>e.some(e=>e.id===t)?e.filter(e=>e.id!==t):void 0,R$=1500,z$=new Map,B$=new Map,V$=e=>{for(let t of B$.get(e)??[])t()};function H$(e){z$.set(e,{at:Date.now(),n:(z$.get(e)?.n??0)+1}),V$(e),setTimeout(()=>{let t=z$.get(e);t&&Date.now()-t.at>=R$&&(z$.delete(e),V$(e))},1550)}function U$(e){let t=z$.get(e);return!t||Date.now()-t.at>=R$?``:t.n%2?`live-flash-a`:`live-flash-b`}function W$(e,t){let n=B$.get(e)??new Set;return n.add(t),B$.set(e,n),()=>{n.delete(t),n.size||B$.delete(e)}}function G$(e){let t=D$(e,150),n={qc:e,invalidate:t,flash:H$};return async function(e){let r=[];T.batch(()=>{for(let i of e)for(let e of O$){if(!e.kinds.includes(i.kind))continue;let a=()=>{for(let n of e.fallback(i))t(n)};if(i.op===`put`&&i.view===void 0){a();continue}try{let t=e.patch(i,n);t&&r.push(t.catch(t=>{console.warn(`[live] ${e.id} could not patch ${i.kind}:`,t),a()}))}catch(t){console.warn(`[live] ${e.id} could not patch ${i.kind}:`,t),a()}}}),await Promise.all(r)}}function K$(e){e.invalidateQueries({refetchType:`active`})}var q$=(e,t)=>(e.getQueryCache().find({queryKey:t,exact:!0})?.getObserversCount()??0)>0,J$=[{id:`wizards`,kinds:[`wizard`],patch:async(e,{qc:t,flash:n})=>{let r=[p.wizards(e.spaceId??void 0),p.spaceWizards(e.spaceId??``)];if(e.op===`del`){for(let n of r)F$(t,n,t=>L$(t,e.item));return}let i=e.view;for(let n of r)F$(t,n,t=>I$(t,{...t.find(t=>t.id===e.item),...i.summary},`first`));n(e.item);let a=M$(`wizard`,e.item);a?a(e):q$(t,p.wizard(e.item))||await P$(t,p.wizard(e.item),e=>N$(e,i.detail)?i.detail:e)},fallback:e=>[p.wizards(e.spaceId??void 0),p.spaceWizards(e.spaceId??``)]},{id:`translations`,kinds:[`translation`],patch:(e,{qc:t})=>{e.parent&&e.view&&t.setQueryData(p.translations(e.parent),e.view)},fallback:e=>e.parent?[p.translations(e.parent)]:[]},{id:`messages`,kinds:[`message`],patch:()=>void 0,fallback:()=>[]}],Y$=[{id:`pages`,kinds:[`page`],patch:async(e,{qc:t,invalidate:n,flash:r})=>{let i=p.page(e.item),a=t.getQueryData(i);if(e.op===`del`)t.removeQueries({queryKey:i,exact:!0});else{let n=e.view,r=M$(`page`,e.item);if(r?r(e):await P$(t,i,e=>N$(e,n)?n:e),a&&a.title===n.title)return}r(e.item),n(p.knowledge(e.spaceId??void 0)),n(p.spaceData(e.spaceId??void 0))},fallback:e=>[p.page(e.item),p.knowledge(e.spaceId??void 0),p.spaceData(e.spaceId??void 0)]},{id:`tables`,kinds:[`table`],patch:async(e,{qc:t,invalidate:n})=>{let r=p.table(e.item),i=t.getQueryData(r);if(e.op===`del`)t.removeQueries({queryKey:r,exact:!0});else{let n=e.view;if(await P$(t,r,e=>e&&{...n,rows:e.rows}),i&&i.title===n.title)return}n(p.knowledge(e.spaceId??void 0)),n(p.spaceData(e.spaceId??void 0))},fallback:e=>[p.table(e.item),p.knowledge(e.spaceId??void 0),p.spaceData(e.spaceId??void 0)]},{id:`rows`,kinds:[`row`],patch:async(e,{qc:t,invalidate:n,flash:r})=>{if(!e.parent)return;let i=p.table(e.parent),a=e.view;await P$(t,i,t=>{if(!t)return t;if(e.op===`del`||!a){let n=L$(t.rows,e.item);return n?{...t,rows:n}:t}let{tableId:n,...r}=a,i=I$(t.rows,r,`last`);return i?{...t,rows:i}:t}),e.op===`put`&&r(e.item),n(p.spaceData(e.spaceId??void 0))},fallback:e=>[...e.parent?[p.table(e.parent)]:[],p.spaceData(e.spaceId??void 0)]},{id:`categories`,kinds:[`category`],patch:(e,{invalidate:t})=>{t(p.knowledge(e.spaceId??void 0)),t(p.knowledgeValues())},fallback:e=>[p.knowledge(e.spaceId??void 0),p.knowledgeValues()]},{id:`files`,kinds:[`file`],patch:(e,{qc:t,invalidate:n,flash:r})=>{if(!e.spaceId)return;let i=p.files(e.spaceId),a=t.getQueryData(i);if(a){let n=e.op===`del`?L$(a.files,e.item):I$(a.files,e.view,`first`);n&&t.setQueryData(i,{...a,files:n})}e.op===`put`&&r(e.item),n(p.fileText(e.item)),n(p.knowledge(e.spaceId))},fallback:e=>[...e.spaceId?[p.files(e.spaceId),p.knowledge(e.spaceId)]:[],p.fileText(e.item)]}],X$=[{id:`skills`,kinds:[`skill`],patch:(e,{invalidate:t,flash:n})=>{n(e.item),t(p.skills(e.spaceId??void 0)),t(p.skill(e.item))},fallback:e=>[p.skills(e.spaceId??void 0),p.skill(e.item)]}],Z$=e=>[[`work-chats`],...e.parent===`section`?[]:[[`work-chat`,e.item]],[`work-approvals`]],Q$=[{id:`work-chats`,kinds:[`chat`],patch:(e,{invalidate:t})=>{for(let n of Z$(e))t(n)},fallback:Z$}],$$=Math.random().toString(36).slice(2,10),e1=[{id:`presence`,kinds:[`presence`],patch:(e,{qc:t})=>{if(!e.parent)return;let n=e.item.slice(e.parent.length+1),r=e.view??[];t.setQueryData(p.presence(e.parent,n),r),t.setQueryData(p.presentItems(e.parent),e=>{if(!e)return e;let t={...e};return r.length?t[n]=r:delete t[n],t})},fallback:e=>e.parent?[p.presence(e.parent,e.item.slice(e.parent.length+1)),p.presentItems(e.parent)]:[]}];function t1(e,t,n){let r=na(`liveChanges`);return(Je({queryKey:p.presence(e,t??``),queryFn:()=>H.get(`/api/studio/presence/${e}/${t}`),enabled:r&&!!t,refetchInterval:6e4}).data??[]).filter(e=>e.who!==n)}function n1(e){let t=na(`liveChanges`);return Je({queryKey:p.presentItems(e),queryFn:()=>H.get(`/api/studio/presence/${e}`),enabled:t,refetchInterval:6e4}).data}var r1=2e4;function i1(e,t,n){let r=na(`liveChanges`),i=(0,G.useRef)(n);i.current=n;let a=`${n.state}|${n.place??``}`;(0,G.useEffect)(()=>{if(!r||!t)return;let n=()=>H.put(`/api/studio/presence`,{kind:e,item:t,tab:$$,...i.current}).catch(()=>void 0);n();let a=setInterval(()=>void n(),r1),o=()=>navigator.sendBeacon?.(fe(`/api/studio/presence/leave`),new Blob([JSON.stringify({kind:e,item:t,tab:$$})],{type:`text/plain`}));return window.addEventListener(`pagehide`,o),()=>{clearInterval(a),window.removeEventListener(`pagehide`,o),H.post(`/api/studio/presence/leave`,{kind:e,item:t,tab:$$}).catch(()=>void 0)}},[r,e,t]),(0,G.useEffect)(()=>{if(!r||!t)return;let n=setTimeout(()=>void H.put(`/api/studio/presence`,{kind:e,item:t,tab:$$,...i.current}).catch(()=>void 0),1e3);return()=>clearTimeout(n)},[r,e,t,a])}var a1=[{id:`spaces`,kinds:[`space`],patch:(e,{qc:t,invalidate:n})=>{let r=t.getQueryData(p.spaces());if(r){let n=e.op===`del`?L$(r,e.item):I$(r,e.view,`last`);n&&t.setQueryData(p.spaces(),n)}n(p.themes(e.item))},fallback:e=>[p.spaces(),p.themes(e.item)]},{id:`connectors`,kinds:[`connector`],patch:(e,{qc:t})=>{if(!e.spaceId)return;let n=p.connectors(e.spaceId),r=t.getQueryData(n);if(!r)return;let i=e.item.slice(e.spaceId.length+1),a=e.op===`del`?L$(r,i):I$(r,e.view,`last`);a&&t.setQueryData(n,a)},fallback:e=>e.spaceId?[p.connectors(e.spaceId)]:[]}],o1=100,s1=45e3,c1=3e4;function l1(e){let t=na(`liveChanges`),n=R();(0,G.useEffect)(()=>{if(!t){console.info(`[live] off: the liveChanges switch is off`);return}return u1(n,e)},[t,n,e])}function u1(e,t){let n=`wz-live:${t}`,r=new AbortController,i=typeof BroadcastChannel==`function`?new BroadcastChannel(n):null,a=G$(e),o=null,s=new Map,c=null,l=()=>{c=null;let e=[...s.values()];s=new Map,a(e)},u=t=>{if(`seq`in t&&(o=t.seq),t.event===`changes`){for(let e of t.items){let t=`${e.kind}|${e.item}`;s.delete(t),s.set(t,e)}c??=setTimeout(l,o1)}else t.event===`reset`?(s.clear(),K$(e)):t.event===`sync`&&e.invalidateQueries({queryKey:p.cloudSync()})};i&&(i.onmessage=e=>u(e.data));let d=async()=>{await d1(()=>o,e=>{u(e),i?.postMessage(e)},r.signal)};return typeof navigator<`u`&&navigator.locks?navigator.locks.request(n,{signal:r.signal},d).catch(e=>{r.signal.aborted||console.warn(`[live]`,e)}):d(),()=>{r.abort(),i?.close(),c&&clearTimeout(c)}}async function d1(e,t,n){let r=1e3;for(;!n.aborted;){let i=new AbortController,a=()=>i.abort();n.addEventListener(`abort`,a,{once:!0});let o=null,s=()=>{o&&clearTimeout(o),o=setTimeout(()=>i.abort(),s1)};try{let a=e(),o=await fetch(fe(`/api/studio/live`),{credentials:`include`,headers:{accept:`text/event-stream`,"x-wizards-client":`web`,...a===null?{}:{"last-event-id":String(a)}},signal:i.signal});if(o.status===404){console.info(`[live] off: this runtime has no live stream`);return}if(o.status===429){console.info(`[live] waiting: too many studio windows are open`),await f1(c1,n);continue}if(!o.ok||!o.body)throw Error(`live stream answered ${o.status}`);r=1e3,s(),await p1(o.body,e=>{s(),t(e)})}catch(e){if(n.aborted)return;i.signal.aborted||console.info(`[live] dropped, reconnecting:`,e.message)}finally{o&&clearTimeout(o),n.removeEventListener(`abort`,a)}await f1(r,n),r=Math.min(r*2,3e4)}}function f1(e,t){return new Promise(n=>{let r=()=>{clearTimeout(a),document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`online`,r),t.removeEventListener(`abort`,r),n()},i=()=>{document.visibilityState===`visible`&&r()},a=setTimeout(r,e);document.addEventListener(`visibilitychange`,i),window.addEventListener(`online`,r),t.addEventListener(`abort`,r)})}async function p1(e,t){let n=e.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:a}=await n.read();if(e)return;i+=r.decode(a,{stream:!0});let o=i.indexOf(`
113
-
114
- `);for(;o>=0;){let e=i.slice(0,o);i=i.slice(o+2);let n=`message`,r=``;for(let t of e.split(`
115
- `))t.startsWith(`event:`)?n=t.slice(6).trim():t.startsWith(`data:`)&&(r+=t.slice(5).replace(/^ /,``));t({event:n,...r?JSON.parse(r):{}}),o=i.indexOf(`
116
-
117
- `)}}}k$([...a1,...J$,...Y$,...X$,...e1,...Q$]);function m1(e){let[,t]=(0,G.useReducer)(e=>e+1,0);return(0,G.useEffect)(()=>W$(e,t),[e]),U$(e)}function h1(e){let t=0;for(let n of e)t=(t*31+n.charCodeAt(0))%360;return`oklch(72% 0.13 ${t})`}var g1=e=>e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`?`;function _1(e){let t=Math.max(0,Math.round((Date.parse(e)-Date.now())/1e3));return new Intl.RelativeTimeFormat(Xt,{numeric:`auto`}).format(Math.abs(t)<60?-Math.abs(t):-Math.round(Math.abs(t)/60),Math.abs(t)<60?`second`:`minute`)}function v1(e){let t=e.whoKind===`assistant`?W(`presence.assistant`,{person:e.client??W(`presence.someone`)}):e.whoKind===`agent`?e.client?W(`presence.agentFor`,{name:e.name,person:e.client,ago:_1(e.seenAt)}):W(`presence.agent`,{name:e.name,ago:_1(e.seenAt)}):W(e.state===`editing`?`presence.editing`:`presence.viewing`,{name:e.name});return e.placeLabel?W(`presence.at`,{who:t,place:e.placeLabel}):t}function y1({kind:e,item:t,me:n,className:r}){let i=t1(e,t,n),a=new Map;for(let e of i){let t=a.get(e.who);(!t||e.state===`editing`&&t.state!==`editing`)&&a.set(e.who,e)}let o=[...a.values()];return o.length?(0,K.jsxs)(`ul`,{"aria-label":W(`presence.here`),className:V(`flex shrink-0 items-center -space-x-1.5`,r),children:[o.slice(0,4).map(e=>(0,K.jsx)(`li`,{title:v1(e),"aria-label":v1(e),className:V(`relative grid size-7 place-items-center rounded-full font-semibold text-[0.6875rem] ring-2 ring-background`,e.state===`editing`&&`outline-2 outline-offset-1`),style:{background:h1(e.who),outlineColor:h1(e.who),color:`oklch(24% 0.03 260)`},children:e.whoKind===`person`?g1(e.name):(0,K.jsx)(lt,{className:`size-3.5`})},e.who)),o.length>4?(0,K.jsxs)(`li`,{className:`grid size-7 place-items-center rounded-full bg-paper-2 text-[0.6875rem] text-ink-3 ring-2 ring-background`,children:[`+`,o.length-4]}):null]}):null}function b1(e,t,n,r){let i=t1(e,t,n);return r?i.find(e=>e.place===r&&e.state===`editing`&&e.whoKind===`person`)??null:null}function x1(e,t,n){return t1(e,t,n).filter(e=>e.state===`editing`)}function S1({wizard:e,className:t,onDeleted:n}){let r=R(),i=B(),a=kt(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(null);t0(u,o,()=>s(!1));let d=ot({mutationFn:()=>H.post(`/api/studio/wizards/${e.id}/duplicate`),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`wizards`]}),i(`/edit/${e}`)}}),f=ot({mutationFn:()=>H.del(`/api/studio/wizards/${e.id}`),onSuccess:async()=>{l(!1),await r.invalidateQueries({queryKey:[`wizards`]}),await r.invalidateQueries({queryKey:p.spaces()}),n?.()}}),h=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`;return(0,K.jsxs)(`div`,{ref:u,className:V(`relative`,t),onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":W(`wizardMenu.label`),title:W(`wizardMenu.label`),"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>s(e=>!e),className:V(`grid size-8 place-items-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,o&&`bg-accent text-ink`),children:(0,K.jsx)(L,{className:`size-4`})}),o?(0,K.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-60 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:h,disabled:d.isPending,onClick:()=>{s(!1),d.mutate()},children:[(0,K.jsx)(_,{className:`size-4 shrink-0`}),` `,W(`wizardMenu.duplicate`)]}),(0,K.jsxs)(`a`,{role:`menuitem`,href:fe(`/api/studio/wizards/${e.id}/export`),download:!0,className:h,onClick:()=>s(!1),children:[(0,K.jsx)(m,{className:`size-4 shrink-0`}),` `,W(`editor.export`)]}),a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:V(h,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:()=>{s(!1),l(!0)},children:[(0,K.jsx)(je,{className:`size-4 shrink-0`}),` `,W(`wizardMenu.delete`)]})]}):null]}):null,(0,K.jsxs)(z,{open:c,onClose:()=>l(!1),title:W(`wizardMenu.deleteTitle`,{title:e.title}),children:[(0,K.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:e.published?W(`wizardMenu.deletePublished`):W(`wizardMenu.deleteDraft`)}),f.error?(0,K.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(x,{variant:`ghost`,onClick:()=>l(!1),children:W(`common.cancel`)}),(0,K.jsxs)(x,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:[(0,K.jsx)(je,{className:`size-4`}),` `,W(`wizardMenu.delete`)]})]})]})]})}var C1=e({HomePage:()=>B1,NewSpaceDialog:()=>T1,SpaceSwitcher:()=>E1}),w1=[{icon:He,name:()=>W(`nav.wizards`),what:`space.holds.wizards`},{icon:tr,name:()=>W(`space.info`),what:`space.holds.info`},{icon:kn,name:()=>`${W(`space.knowledge`)} & ${W(`space.data`)}`,what:`space.holds.knowledge`},{icon:ut,name:()=>W(`connectors.title`),what:`space.holds.connectors`},{icon:_r,name:()=>W(`space.results`),what:`space.holds.results`}];function T1({open:e,onClose:t}){let{select:n}=It(),r=R(),[i,a]=(0,G.useState)(``),o=ot({mutationFn:()=>H.post(`/api/studio/spaces`,{name:i}),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:p.spaces()}),n(e),a(``),t()}});return(0,K.jsxs)(z,{open:e,onClose:t,title:W(`home.newSpace`),children:[(0,K.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:W(`space.holds.intro`)}),(0,K.jsx)(`dl`,{className:`mt-4 flex flex-col gap-2.5 text-[0.8125rem]`,children:w1.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`dt`,{className:`w-28 shrink-0 font-medium text-ink`,children:e.name()}),(0,K.jsx)(`dd`,{className:`min-w-0 text-ink-3`,children:W(e.what)})]},e.what))}),(0,K.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-4`,children:W(`space.holds.shared`)}),(0,K.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,K.jsx)(k,{autoFocus:!0,placeholder:W(`home.spaceName`),value:i,onChange:e=>a(e.target.value)}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(x,{variant:`ghost`,onClick:t,children:W(`common.cancel`)}),(0,K.jsx)(x,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:W(`home.newSpace`)})]})]})]})}function E1(){let{space:e,spaces:t,select:n}=It(),r=At().data?.limits.spaces??1,i=Mt(),[a,o]=(0,G.useState)(!1);return!e||r!==null&&r<=1?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(we,{className:`w-56`,value:e.id,onChange:e=>e===`__new`?o(!0):n(e),options:[...t.map(e=>({value:e.id,label:e.name})),...i?[r===null||t.length<r?{value:`__new`,label:`+ ${W(`home.newSpace`)}`}:{value:`__new`,label:W(`home.spaceLimit`,{n:r}),disabled:!0}]:[]]}),(0,K.jsx)(T1,{open:a,onClose:()=>o(!1)})]})}function D1({url:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[t?(0,K.jsx)(o,{className:`size-3.5`}):(0,K.jsx)(_,{className:`size-3.5`}),W(t?`share.copied`:`share.link`)]})}function O1(){let e=B(),t=d$(!1),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,K.jsxs)(`div`,{className:`relative`,ref:i,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[(0,K.jsx)(_,{className:`size-3.5`}),` `,W(`share.link`)]}),n?(0,K.jsxs)(`div`,{className:`absolute right-0 bottom-10 z-20 flex w-72 animate-rise flex-col gap-3 rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-relaxed`,children:W(`teaser.link`)}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(x,{size:`sm`,busy:t.link.isPending,onClick:()=>t.link.mutate({}),children:W(`account.signIn`)}),(0,K.jsx)(x,{size:`sm`,variant:`secondary`,onClick:()=>e(`/settings/account`),children:W(`account.create`)})]}),(0,K.jsx)(f$,{...t})]}):null]})}function k1({w:e,me:t,runners:n,present:r}){let i=na(`account`),a=B(),o=YL(e,t,e.cloud),s=XL(o),c=s??(e.published?JL(e):null),l=m1(e.id);return(0,K.jsxs)(`div`,{className:`group/card relative pt-6`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-4 z-10`,children:(0,K.jsx)(Dt,{kind:e.avatar,costume:e.costume,size:52})}),(0,K.jsxs)(Ne,{className:V(`relative flex h-full cursor-pointer flex-col px-5 pt-10 pb-3 transition hover:shadow-elevated`,l),onClick:()=>a(`/edit/${e.id}`),children:[(0,K.jsx)(`div`,{className:`absolute top-3 right-3`,children:e.published?(0,K.jsx)(ZL,{where:o,me:t}):(0,K.jsx)(v,{children:W(`home.draft`)})}),(0,K.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem] leading-snug`,children:e.title}),(0,K.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.description}),(0,K.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between pt-3`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2.5 text-[0.75rem] text-ink-4`,children:[W(`home.steps`,{n:e.stepCount}),(0,K.jsx)(T$,{w:e,runners:n}),r?.length?(0,K.jsx)(`span`,{role:`img`,className:`inline-flex items-center gap-1`,title:r.map(v1).join(`
118
- `),"aria-label":r.map(v1).join(`, `),children:r.slice(0,3).map(e=>(0,K.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:h1(e.who)}},`${e.who}|${e.tab}`))}):null]}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(S1,{wizard:e,className:`opacity-0 transition group-hover/card:opacity-100 has-[[aria-expanded=true]]:opacity-100 focus-within:opacity-100 coarse:opacity-100`}),s?(0,K.jsx)(D1,{url:s}):o.kind===`here`&&i?(0,K.jsx)(O1,{}):null,c?(0,K.jsx)(re,{label:W(s?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),zL(c)},children:(0,K.jsx)(Tn,{className:`size-4`})}):null]})]})]})]})}var A1=[`draft`,`here`,`live`,`missing`],j1={draft:f,here:Cr,live:hi,missing:Xe},M1=e=>W(e===`draft`?`home.draft`:e===`here`?`where.here`:e===`live`?`home.live`:`where.missing`);function N1(e,t){let{kind:n}=YL(e,t,e.cloud);return n===`draft`||n===`here`?n:n===`live`||n===`unknown`?`live`:`missing`}function P1({wizards:e,me:t,value:n,onChange:r}){let i=new Map;for(let n of e){let e=N1(n,t);i.set(e,(i.get(e)??0)+1)}if(i.size<2)return null;let a=e=>V(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] transition`,e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`);return(0,K.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,className:a(n===null),onClick:()=>r(null),children:[W(`home.all`),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e.length})]}),A1.filter(e=>i.has(e)).map(e=>{let t=j1[e];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":n===e,className:a(n===e),onClick:()=>r(n===e?null:e),children:[(0,K.jsx)(t,{className:`size-3.5`}),M1(e),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:i.get(e)})]},e)})]})}var F1=12,I1=3;function L1({value:e,onChange:t}){return(0,K.jsxs)(`label`,{className:`relative flex h-10 w-full max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[(0,K.jsx)(ue,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:W(`home.search`),"aria-label":W(`home.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),e?(0,K.jsx)(`button`,{type:`button`,"aria-label":W(`market.reset`),onClick:()=>t(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(xe,{className:`size-4`})}):null]})}var R1=`curl -fsSL https://engenty.ai/install.sh | bash`;function z1(){let[e,t]=(0,G.useState)(!1),n=[W(`home.local.install`),W(`home.local.signIn`),W(`home.local.publish`)];return(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,K.jsx)(Dt,{kind:`round`,size:120}),(0,K.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:W(`home.local.title`)}),(0,K.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:W(`home.local.text`)}),(0,K.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,K.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,K.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,K.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:R1}),(0,K.jsxs)(x,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(R1),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,K.jsx)(o,{className:`size-3.5`}):(0,K.jsx)(_,{className:`size-3.5`}),W(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function B1(){let e=B(),t=R(),{space:n,spaces:r,loading:i}=It(),a=At().data,o=Pt(),s=Mt(),c=Je({queryKey:[`wizards`,n?.id,!!a?.account],queryFn:()=>H.get(`/api/studio/spaces/${n.id}/wizards`),enabled:!!n}),l=C$().data??[],u=n1(`wizard`),[d,f]=(0,G.useState)(null),[m,h]=(0,G.useState)(``),g=(c.data?.length??0)>F1,_=g?m.trim().toLowerCase():``,v=(c.data??[]).filter(e=>(!d||!a||N1(e,a)===d)&&(!_||`${e.title} ${e.description}`.toLowerCase().includes(_))),y=!!_&&v.length<I1,b=ot({mutationFn:e=>H.post(`/api/studio/wizards`,{spaceId:n.id,starterId:e,lang:Xt}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:p.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),S=r.reduce((e,t)=>e+t.wizardCount,0),C=s&&!n?.readOnly;return!i&&C&&r.length&&S===0?(0,K.jsx)(he,{to:`/new`,replace:!0}):!i&&!o&&r.length===0?(0,K.jsx)(z1,{}):(0,K.jsxs)(`div`,{className:`animate-rise`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[g?(0,K.jsx)(L1,{value:m,onChange:h}):(0,K.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] tracking-tight`,children:W(`home.title`,{space:n?.name??``})}),C?(0,K.jsxs)(x,{onClick:()=>e(`/new`),children:[(0,K.jsx)(Ke,{className:`size-4`}),` `,W(`home.new`)]}):null]}),n?.origin===`local`?(0,K.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[W(`home.fromLocal`),` `,n.syncedAt?W(`home.syncedAt`,{when:new Intl.DateTimeFormat(Xt,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n.syncedAt))}):null]}):null,c.data&&c.data.length===0?(0,K.jsxs)(te,{children:[(0,K.jsx)(`p`,{children:W(`home.empty`)}),C?(0,K.jsxs)(x,{className:`mt-5`,onClick:()=>e(`/new`),children:[(0,K.jsx)(Ke,{className:`size-4`}),` `,W(`home.new`)]}):null]}):null,c.data?.length&&a?(0,K.jsx)(P1,{wizards:c.data,me:a,value:d,onChange:f}):null,_&&v.length===0?(0,K.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:W(`home.noMatch`)}):null,(0,K.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:a?v.map(e=>(0,K.jsx)(k1,{w:e,me:a,runners:l,present:u?.[e.id]?.filter(e=>e.who!==a.user.id)},e.id)):null}),y?(0,K.jsxs)(K.Fragment,{children:[C?(0,K.jsx)(nt,{query:m,busy:b.isPending,onUse:e=>n&&!b.isPending&&b.mutate(e.id)}):(0,K.jsx)(nt,{query:m}),C?(0,K.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,K.jsxs)(x,{variant:`secondary`,onClick:()=>e(`/new?wish=${encodeURIComponent(m.trim())}`),children:[(0,K.jsx)(ie,{className:`size-4`}),` `,W(`home.newFromSearch`,{q:m.trim()})]})}):null]}):null]})}var V1=(0,G.lazy)(()=>ct(()=>import(`./ChangelogDialog-Do7pwmFv.js`).then(e=>({default:e.ChangelogDialog})),__vite__mapDeps([12,1,2,3,4,5]))),H1=`wizards.update-banner`;function U1(){try{return localStorage.getItem(H1)}catch{return null}}function W1(){let[e,t]=(0,G.useState)(U1),[n,r]=(0,G.useState)(!1),{data:i,latest:a,apply:o,busy:s,progress:c}=an(),l=i&&!i.newer?i.updated?.to??null:null,u=l??(i?.newer?a:null);if(!(i&&u)||e===u&&i.applying===`idle`)return null;let d=()=>{try{localStorage.setItem(H1,u)}catch{}t(u)},f=c??(l?W(`about.update.updated`,{v:u}):i.pending?.version===u?W(`about.update.ready`,{v:u}):W(`about.update.available`,{v:u}));return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-ember-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[s?(0,K.jsx)(Fe,{className:`size-4 shrink-0 text-ember-strong`}):(0,K.jsx)(m,{className:`size-4 shrink-0 text-ember-strong`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1`,children:f}),s?null:(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`shrink-0 underline transition hover:text-ink`,children:W(`about.update.notes`)}),n?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(V1,{open:!0,version:u,onClose:()=>r(!1)})}):null,i.canApply&&!l&&(i.applying===`idle`||i.applying===`failed`)?(0,K.jsx)(x,{size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(),children:W(`about.update.install`)}):null,s?null:(0,K.jsx)(re,{label:W(`install.app.close`),onClick:d,className:`size-8`,children:(0,K.jsx)(xe,{className:`size-4`})})]})}var G1=[],K1=new Set;function q1(e){G1=e;for(let e of K1)e()}function J1(e){let t=JSON.stringify(e);(0,G.useEffect)(()=>(q1(JSON.parse(t)),()=>q1([])),[t])}function Y1(){return G1}function X1(){return(0,G.useSyncExternalStore)(e=>(K1.add(e),()=>K1.delete(e)),()=>G1)}function Z1({alone:e=!1}){let t=X1();return t.length?(0,K.jsx)(`nav`,{"aria-label":W(`nav.breadcrumb`),className:`flex min-w-0 items-center text-[0.9375rem] max-sm:hidden`,children:t.map((n,r)=>(0,K.jsxs)(G.Fragment,{children:[e&&r===0?null:(0,K.jsx)(`span`,{className:V(`mr-2 text-ink-4`,r===0?`-ml-1 sm:-ml-2`:`ml-2`),children:`/`}),n.to&&r<t.length-1?(0,K.jsx)(Se,{to:n.to,className:`truncate text-ink-3 transition hover:text-ink`,children:n.label}):(0,K.jsx)(`span`,{"aria-current":`page`,className:`truncate font-medium text-ink`,children:n.label})]},`${r}:${n.label}`))}):null}var Q1=e=>e.manageUrl??e.account?.url??null;function $1(e){let t=Q1(e);return t?`${t}/billing`:null}function e0(e,t){return e.mode===`local`?e.account?e.account.signedIn?`linked`:`expired`:t?`alone`:null:null}function t0(e,t,n){let r=(0,G.useRef)(n);r.current=n,(0,G.useEffect)(()=>{if(!t)return;let n=t=>{e.current?.contains(t.target)||r.current()},i=e=>{e.key===`Escape`&&r.current()};return document.addEventListener(`pointerdown`,n),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,n),document.removeEventListener(`keydown`,i)}},[e,t])}function n0(e,t,n){return e===`below`?n:_a(t,e===`bar-start`?`start`:`end`)}var r0=e=>`oklch(from ${e} calc(0.16 + 0.83 * clamp(0, (0.65 - l) * 1000, 1)) 0.01 h)`;function i0({space:e,name:t,size:n=`md`}){let r=e?.brand.colors?.[0]?.value,i=Nt(t??e?.name??``),a=(0,K.jsx)(`span`,{className:V(`grid shrink-0 place-items-center font-semibold tracking-wide`,n===`md`?`size-10 rounded-lg text-[0.8125rem]`:n===`sm`?`size-9 rounded-lg text-[0.75rem]`:`size-6 rounded-md text-[0.5625rem]`,r?null:`bg-paper-3 text-ink ring-1 ring-border`),style:r?{background:r,color:r0(r)}:void 0,children:i||(0,K.jsx)(ar,{className:`size-4`})});return e?.origin===`local`?(0,K.jsxs)(`span`,{className:`relative shrink-0`,title:W(`readonly.space`),children:[a,(0,K.jsx)(`span`,{className:`-right-1 -bottom-1 absolute grid size-4 place-items-center rounded-full bg-amber ring-2 ring-paper`,children:(0,K.jsx)(Cr,{className:`size-2.5 text-paper`})})]}):a}function a0(e){let{spaces:t}=It();return e.mode===`managed`&&!!e.tenant.name&&e.limits.spaces===1&&t.length<=1}function o0({me:e,placement:t,label:n,className:r,children:i}){let a=B(),{position:s,phone:c}=ma(),{space:l,spaces:u,select:d}=It(),f=a0(e),p=Ec(e),m=Mt(),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(!1),C=wc(e),[w,T]=(0,G.useState)({top:0,left:0}),E=(0,G.useRef)(null);t0(E,h,()=>g(!1));let D=e.limits.spaces,O=D!==null&&u.length>=D,k=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`;return(0,K.jsx)(`div`,{className:`shrink-0`,ref:E,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();T({top:t.bottom+6,left:t.left}),g(e=>!e)},"aria-expanded":h,"aria-haspopup":`menu`,"aria-label":n,title:f?void 0:W(`nav.switchSpace`),className:typeof r==`function`?r(h):r,children:i}),h?(0,K.jsxs)(`div`,{role:`menu`,style:t===`below`?{position:`fixed`,...w}:void 0,className:V(`z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,t===`below`?null:V(`absolute`,n0(t,s,`top-10 left-0`))),children:[f&&Sc(e)&&!c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:W(`organizations.mine`)}),(0,K.jsx)(Dc,{me:e,onDone:()=>g(!1)}),(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`})]}):null,f&&!(Sc(e)&&c)?null:C&&Sc(e)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition hover:bg-accent`,onClick:()=>{g(!1),S(!0)},children:[(0,K.jsx)(Tc,{org:C,size:`xs`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-semibold text-[0.875rem] text-ink`,children:C.name}),C.plan?(0,K.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:C.plan.name}):null]}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-3`,children:W(`organizations.switchShort`)}),(0,K.jsx)(ee,{className:`size-4 shrink-0 text-ink-4`})]}),(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`})]}):e.tenant.name?(0,K.jsx)(`div`,{className:`truncate px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:e.tenant.name}):null,(f?[]:u).map(e=>{let t=e.id===l?.id;return(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition hover:bg-accent`,onClick:()=>{g(!1),t?a(`/`):d(e.id)},children:[(0,K.jsx)(i0,{space:e,size:`sm`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,K.jsx)(`span`,{className:V(`truncate text-[0.875rem]`,t?`font-semibold text-ink`:`font-medium text-ink-2`),children:e.name}),(0,K.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:W(`nav.wizardCount`,{n:e.wizardCount})})]}),t?(0,K.jsx)(o,{className:`size-4 shrink-0 text-ember-strong`}):null]},e.id)}),f?null:(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),[{to:`/`,icon:He,label:W(f?`nav.allWizards`:`nav.wizardsInSpace`),show:!0},{to:`/new`,icon:Ke,label:W(`nav.addWizard`),show:m}].filter(e=>e.show).map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:k,onClick:()=>{g(!1),a(e.to)},children:[(0,K.jsx)(e.icon,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.label})]},e.to)),f&&!Sc(e)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:k,onClick:()=>{g(!1),p()},children:[(0,K.jsx)(Di,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:W(`organizations.manage`)})]})]}):null,l&&!l.readOnly&&!f?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:k,onClick:()=>{g(!1),b(!0)},children:[(0,K.jsx)(M,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:W(`nav.renameSpace`)})]})]}):null,m&&!O?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:k,onClick:()=>{g(!1),v(!0)},children:[(0,K.jsx)(Ke,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:(0,K.jsx)(`span`,{className:`truncate`,children:W(`nav.addSpace`)})})]})]}):null]}):null,(0,K.jsx)(T1,{open:_,onClose:()=>v(!1)}),Sc(e)?(0,K.jsx)(kc,{me:e,open:x,onClose:()=>S(!1)}):null,l?(0,K.jsx)(s0,{space:l,open:y,onClose:()=>b(!1)}):null]})})}function s0({space:e,open:t,onClose:n}){let r=R(),[i,a]=(0,G.useState)(e.name);(0,G.useEffect)(()=>{t&&a(e.name)},[t,e.name]);let o=ot({mutationFn:()=>H.patch(`/api/studio/spaces/${e.id}`,{name:i.trim()}),onSuccess:async()=>{await r.invalidateQueries({queryKey:p.spaces()}),n()}});return(0,K.jsx)(z,{open:t,onClose:n,title:W(`nav.renameSpace`),children:(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,K.jsx)(k,{autoFocus:!0,maxLength:80,"aria-label":W(`nav.renameSpace`),value:i,onChange:e=>a(e.target.value)}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(x,{variant:`ghost`,onClick:n,children:W(`common.cancel`)}),(0,K.jsx)(x,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:W(`settings.save`)})]})]})})}function c0({me:e,space:t}){let n=e.mode===`local`||t.origin===`local`,r=n?Cr:qn,i=W(n?`nav.spaceLocal`:`nav.spaceCloud`);return(0,K.jsx)(`span`,{title:i,className:`grid size-6 shrink-0 place-items-center text-ink-4`,children:(0,K.jsx)(r,{className:`size-3.5`,"aria-label":i})})}function l0({me:e}){let{space:t}=It(),{phone:n}=ma(),r=a0(e);return t?r&&e.tenant.name?(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,K.jsxs)(o0,{me:e,placement:`below`,label:e.tenant.name,className:e=>V(n?`-ml-1 flex max-w-[16rem] items-center gap-2.5 rounded-xl py-1 pr-2 pl-1`:`-mx-1 flex max-w-[16rem] items-center gap-1 rounded-md px-2 py-0.5`,`text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`,e&&`bg-accent`),children:[n?(0,K.jsx)(i0,{space:t,name:e.tenant.name,size:`sm`}):null,(0,K.jsx)(`span`,{className:`truncate`,children:e.tenant.name}),(0,K.jsx)(zn,{className:`size-3.5 shrink-0 text-ink-4`})]}),(0,K.jsx)(c0,{me:e,space:t})]}):(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[e.tenant.name&&!n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oc,{me:e,className:`max-lg:hidden`}),(0,K.jsx)(`span`,{className:`text-ink-4 max-lg:hidden`,"aria-hidden":`true`,children:`/`})]}):null,(0,K.jsx)(o0,{me:e,placement:`below`,label:t.name,className:e=>V(n?`-ml-1 flex max-w-[16rem] items-center gap-2.5 rounded-xl py-1 pr-2 pl-1 text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`:`-mx-1 max-w-[16rem] translate-y-[0.5px] truncate rounded-md px-2 py-0.5 text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`,e&&`bg-accent`),children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i0,{space:t,size:`sm`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col leading-tight`,children:[e.tenant.name?(0,K.jsx)(`span`,{className:`truncate font-normal text-[0.75rem] text-ink-3`,children:e.tenant.name}):null,(0,K.jsx)(`span`,{className:`truncate`,children:t.name})]})]}):t.name}),(0,K.jsx)(c0,{me:e,space:t})]}):null}function u0({me:e,placement:t=`below`,named:n}){let[r,i]=(0,G.useState)(!1),a=(0,G.useRef)(null),o=B(),{position:s,phone:c}=ma();t0(a,r,()=>i(!1));let l=wa(),[u,d]=(0,G.useState)(!1),f=Nt(e.user.name),p=DR().dev,m=e0(e,na(`account`)),h=na(`capabilities`),g=e.mode===`managed`&&Ot(e.features,`organizationSettings`),_=`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`;return(0,K.jsxs)(`div`,{className:V(`relative`,n&&`w-full`),ref:a,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:n?V(`flex w-full items-center gap-3 rounded-lg p-0.5 pr-2 text-left transition hover:bg-ink/10`,r&&`bg-ink/10`):`block shrink-0 rounded-full`,"aria-label":e.user.name||`Menu`,children:[(0,K.jsxs)(`span`,{className:V(`relative flex shrink-0 items-center justify-center rounded-full bg-ember-tint font-semibold text-[0.8125rem] text-ember-strong ring-1 ring-border-soft`,t===`below`?`size-9`:`size-10`),children:[e.user.image?(0,K.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full rounded-full object-cover`}):f,m===`linked`||m===`expired`?(0,K.jsx)(`span`,{title:m===`linked`?W(`nav.connected`,{host:qL(e.account?.cloudUrl??``)}):W(`nav.expired`),className:`-right-1 -bottom-1 absolute flex size-4 items-center justify-center rounded-full bg-card ring-1 ring-border-soft`,children:m===`linked`?(0,K.jsx)(qn,{className:`size-2.5 text-moss`}):(0,K.jsx)(Xe,{className:`size-2.5 text-amber`})}):null]}),n?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem] text-ink-2`,children:e.user.name}):null]}),r?(0,K.jsxs)(`div`,{className:V(`absolute z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,n0(t,s,`top-11 right-0`)),children:[(0,K.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5`,children:[(0,K.jsxs)(`div`,{className:`truncate font-medium text-[0.875rem]`,children:[e.user.name,m===`alone`?(0,K.jsxs)(`span`,{className:`font-normal text-ink-4`,children:[` (`,W(`nav.local`),`)`]}):null]}),(0,K.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.user.email}),e.tenant.name?(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 text-[0.75rem] text-ink-2`,children:[(0,K.jsx)(Nn,{className:`size-3.5 shrink-0 text-ink-4`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.tenant.name})]}):null]}),m?(0,K.jsxs)(`button`,{type:`button`,className:`mx-1.5 mb-1.5 flex w-[calc(100%-0.75rem)] items-start gap-2.5 rounded-lg bg-paper-2 px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 hover:text-ink`,onClick:()=>{i(!1),o(`/settings/account`)},children:[m===`linked`?(0,K.jsx)(qn,{className:`mt-0.5 size-4 shrink-0 text-moss`}):m===`expired`?(0,K.jsx)(Xe,{className:`mt-0.5 size-4 shrink-0 text-amber`}):(0,K.jsx)(Cr,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-snug`,children:[(0,K.jsx)(`span`,{className:`break-words`,children:m===`linked`?W(`nav.connected`,{host:qL(e.account?.cloudUrl??``)}):W(m===`expired`?`nav.expired`:`nav.onlyHere`)}),(0,K.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:m===`linked`?e.account?.credits!==null&&e.account?.credits!==void 0?W(`nav.credits`,{n:Math.floor(e.account.credits).toLocaleString(Xt)}):null:W(m===`expired`?`account.signInAgain`:`account.signIn`)})]})]}):null,(0,K.jsxs)(`button`,{type:`button`,className:_,onClick:()=>{i(!1),o(g?`/account`:`/settings/account`)},children:[(0,K.jsx)(Yi,{className:`size-4`}),` `,W(`konto.title`)]}),h?(0,K.jsxs)(`button`,{type:`button`,className:_,onClick:()=>{i(!1),o(`/account/connections`)},children:[(0,K.jsx)(E,{className:`size-4`}),` `,W(`konto.connections`)]}):null,!g&&e.manageUrl?(0,K.jsxs)(`a`,{className:_,href:`${e.manageUrl}/account`,target:`_blank`,rel:`noreferrer`,children:[(0,K.jsx)(Zn,{className:`size-4`}),` `,W(`nav.account`)]}):null,c&&!va()?(0,K.jsxs)(`button`,{type:`button`,className:_,onClick:()=>{i(!1),l?Ta(l):d(!0)},children:[(0,K.jsx)(rt,{className:`size-4`}),` `,W(`install.app.action`)]}):null,(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[W(`nav.theme`),(0,K.jsx)(l$,{})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[W(`nav.language`),(0,K.jsx)(fn,{tone:`surface`})]}),e.assistantDev?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[W(`assistant.dev`),(0,K.jsx)(oe,{checked:p,onChange:e=>ER({dev:e}),label:W(`assistant.dev`)})]}):null,e.mode===`managed`?(0,K.jsxs)(`button`,{type:`button`,className:_,onClick:()=>{i(!1),Hs({where:`studio`})},children:[(0,K.jsx)(it,{className:`size-4`}),` `,W(`report.open`)]}):null,e.mode===`managed`?(0,K.jsxs)(`button`,{type:`button`,className:_,onClick:()=>void Ft(),children:[(0,K.jsx)(Fr,{className:`size-4`}),` `,W(`nav.logout`)]}):null]}):null,(0,K.jsx)(fc,{open:u,onClose:()=>d(!1)})]})}function d0({me:e,children:t}){let{phone:n}=ma(),r=_e().pathname.startsWith(`/account`);return(0,K.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 px-3 coarse:h-14 sm:gap-3 sm:px-4 md:px-5`,children:[r?null:(0,K.jsx)(l0,{me:e}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,K.jsx)(Z1,{alone:r}),t]}),r||!n?null:(0,K.jsx)(xc,{me:e,look:`row`,stack:!0}),n?(0,K.jsx)(u0,{me:e}):null]})}var f0=`studio-scroll`;function p0(){return document.getElementById(`studio-scroll`)??document.documentElement}var m0={left:`md:py-2 md:pr-2`,right:`md:py-2 md:pl-2`,top:`md:px-2 md:pb-2`,bottom:`md:px-2 md:pt-2`},h0={left:`flex-row`,right:`flex-row-reverse`,top:`flex-col`,bottom:`flex-col-reverse`};function g0({me:e,wide:t,full:n,children:r}){let{position:i,phone:a}=ma(),o=(0,G.useRef)(null),s=a&&!n?`calc(4.75rem + env(safe-area-inset-bottom))`:`0px`,c=na(`goose`),l=i$()&&c&&!n,u=ga(!!n||l);return l1(e.tenant.id),(0,K.jsxs)(`div`,{className:V(`flex h-dvh overflow-hidden bg-sidebar`,h0[i]),children:[a?n?null:(0,K.jsx)(vV,{me:e}):(0,K.jsx)(mV,{me:e,labels:u.shown,room:u.room}),(0,K.jsxs)(`div`,{className:V(`flex min-h-0 min-w-0 flex-1 md:gap-2`,m0[i]),children:[(0,K.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background md:rounded-xl md:shadow-elevated md:dark:ring-1 md:dark:ring-border-soft`,children:[e.impersonation?(0,K.jsx)(xt,{name:e.user.name||e.user.email,until:e.impersonation.until}):null,(0,K.jsx)(W1,{}),(0,K.jsx)(gc,{me:e}),(0,K.jsx)(FH,{me:e}),n?(0,K.jsx)(`main`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:r}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(d0,{me:e}),(0,K.jsxs)(`div`,{ref:o,className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(`main`,{id:f0,className:`relative min-h-0 flex-1 overflow-y-auto`,style:{paddingBottom:`max(var(--assistant-dock, 0px), ${s})`},children:(0,K.jsx)(`div`,{className:V(`mx-auto w-full px-3 pt-4 pb-12 sm:px-6 sm:pt-6`,t?`max-w-[88rem]`:`max-w-5xl`),children:r})}),c&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(QQ,{column:o}),(0,K.jsx)(o$,{})]})]})]})]}),c&&!n?(0,K.jsx)(a$,{}):null]})]})}function _0(){return[{id:`info`,label:W(`space.info`),icon:tr},{id:`brand`,label:W(`space.brand`),icon:Vi},{id:`knowledge`,label:W(`space.knowledge`),icon:kn},{id:`data`,label:W(`space.data`),icon:b},{id:`page`,label:W(`space.page`),icon:dt}]}function v0(e,t){let n=[...e];for(let e of t.spaceParts){let r=n.findIndex(t=>t.id===(e.after??`data`))+1;for(;r<n.length&&t.spaceParts.some(e=>e.id===n[r].id);)r++;n.splice(r,0,{id:e.id,label:e.label(),icon:e.icon})}return n}function y0(e){return e===`info`||e===`brand`||e===`knowledge`||e===`data`||e===`page`||e===`results`||e===`skills`}var b0=[{id:`base`,group:`info`,label:`space.base`,icon:et},{id:`facts`,group:`info`,label:`space.facts`,icon:tt},{id:`links`,group:`info`,label:`space.links`,icon:E},{id:`identity`,group:`brand`,label:`space.identity`,icon:et},{id:`logos`,group:`brand`,label:`space.logos`,icon:ki},{id:`colors`,group:`brand`,label:`space.colors`,icon:Yr},{id:`typography`,group:`brand`,label:`space.typography`,icon:hn},{id:`assets`,group:`brand`,label:`space.assets`,icon:hr},{id:`voice`,group:`brand`,label:`space.voice`,icon:Ur},{id:`documents`,group:`knowledge`,label:`space.documents`,icon:F},{id:`page`,group:`page`,label:`page.sectionPage`,icon:dt},{id:`page-words`,group:`page`,label:`page.sectionWords`,icon:et},{id:`page-wizards`,group:`page`,label:`page.sectionWizards`,icon:Dr}],x0=b0.map(e=>e.id);function S0(e,t){let n=t.spaceSections.find(t=>t.id===e);return b0.find(t=>t.id===e)?.group??(n?n.group??`knowledge`:null)}function C0(e,t,n=[]){let r=b0.filter(t=>t.group===e&&!n.includes(t.id)).map(e=>({id:e.id,label:W(e.label),icon:e.icon})),i=new Map;for(let n of t.spaceSections){if((n.group??`knowledge`)!==e)continue;let t=i.get(n.plugin)??[];t.push({id:n.id,label:n.label()}),i.set(n.plugin,t)}return[...r.length?[{plugin:null,label:null,sections:r}]:[],...[...i].map(([e,n])=>({plugin:e,label:t.plugins.find(t=>t.id===e)?.name??e,sections:n}))]}globalThis.__WIZARDS_STUDIO__={react:G,jsx:K,reactDom:{createPortal:_c.createPortal,flushSync:_c.flushSync},router:{Link:Se,Navigate:he,NavLink:Ue,useLocation:_e,useNavigate:B,useParams:Ge,useSearchParams:me},query:{useMutation:ot,useQuery:Je,useQueryClient:R},ui:ze,sdk:ra};var w0=0,T0={status:`idle`,plugins:[],canReload:!1,problems:[],failed:{},pages:[],nav:[],sections:[],spaceSections:[],spaceParts:[],spaceMenus:{},shareSections:[],shareSetups:[],cards:[]},E0=new Set;function D0(e){T0={...T0,...e};for(let e of E0)e()}function O0(){return(0,G.useSyncExternalStore)(e=>(E0.add(e),()=>E0.delete(e)),()=>T0)}var k0=new Set([`account`,`space`,`connectors`,`models`,`build`,`plugins`]),A0=new Set([`info`,`brand`,`knowledge`,`data`,`page`,`results`]),j0=new Map,M0=null,N0=e=>`${e.script}|${e.styles}`,P0=e=>`__wizardsPlugin_${e.replaceAll(`-`,`_`)}`;function F0(){let{space:e}=It(),t=e?.id,n=e?.name??``,r=e?.readOnly??!1,i=JSON.stringify({name:e?.brand.name??``,colors:(e?.brand.colors??[]).map(({name:e,value:t})=>({name:e,value:t})),fonts:(e?.brand.fonts??[]).map(({family:e,role:t,weights:n})=>({family:e,role:t,weights:n}))});return(0,G.useMemo)(()=>t?{id:t,name:n,readOnly:r,brand:JSON.parse(i)}:null,[t,n,r,i])}var I0=(0,G.createContext)(null);function L0({part:e,children:t}){return(0,K.jsx)(I0.Provider,{value:e,children:t})}function R0(e){let t=(0,G.useContext)(I0),n=JSON.stringify(e.map(e=>[e.id,e.label]));(0,G.useEffect)(()=>{if(t)return D0({spaceMenus:{...T0.spaceMenus,[t]:e}}),()=>{let{[t]:e,...n}=T0.spaceMenus;D0({spaceMenus:n})}},[t,n])}function z0({plugin:e,...t}){return bL({...t,plugin:e}),null}function B0(e,t){let{id:n}=e,r=e=>`/api/studio/plugins/${n}${e.startsWith(`/`)?e:`/${e}`}`,i=e=>e.filter(e=>e.plugin!==n);return{plugin:{id:n,name:e.name,version:e.version},registerPage(e){let r=e.path.split(`/`)[1]??``;if(!e.path.startsWith(`/`)||Ee.has(r))throw Error(`"${e.path}" is an address of the studio itself.`);if([...i(T0.pages),...t.pages].some(t=>t.path===e.path))throw Error(`"${e.path}" is registered already.`);t.pages.push({...e,plugin:n,serial:++w0})},registerNav(e){t.nav.push({...e,plugin:n,serial:++w0})},registerSettingsSection(e){let r=[...i(T0.sections),...t.sections].some(t=>t.id===e.id);if(k0.has(e.id)||r)throw Error(`The settings have a section "${e.id}" already.`);t.sections.push({...e,plugin:n,serial:++w0})},registerSpaceSection(e){let r=[...i(T0.spaceSections),...t.spaceSections].some(t=>t.id===e.id);if(x0.includes(e.id)||r)throw Error(`The space page has a section "${e.id}" already.`);t.spaceSections.push({...e,plugin:n,serial:++w0})},registerSpacePart(e){let r=[...i(T0.spaceParts),...t.spaceParts].some(t=>t.id===e.id);if(!/^[a-z][a-z0-9-]{0,39}$/.test(e.id)||A0.has(e.id)||r)throw Error(`The space page has a part "${e.id}" already.`);t.spaceParts.push({...e,plugin:n,serial:++w0})},registerShareSection(e){if([...i(T0.shareSections),...t.shareSections].some(t=>t.runner===e.runner))throw Error(`The runner "${e.runner}" has a share section already.`);t.shareSections.push({...e,plugin:n,serial:++w0})},registerShareSetup(e){if([...i(T0.shareSetups),...t.shareSetups].some(t=>t.runner===e.runner))throw Error(`The runner "${e.runner}" has a share setup already.`);t.shareSetups.push({...e,plugin:n,serial:++w0})},registerAssistantCard(e){if(t.cards.some(t=>t.tool===e.tool))throw Error(`The tool "${e.tool}" has a card already.`);t.cards.push({...e,plugin:n,serial:++w0})},useSpace:F0,useSpaceMenu:R0,useCrumbs:J1,Assistant:e=>(0,K.jsx)(z0,{plugin:n,...e}),useAssistantPage:e=>bL({...e,plugin:n}),useAssistantTool:(e,t,r)=>qZ(`${n.replaceAll(`-`,`_`)}_${e}`,t,r),i18n:{register:e=>(t,n)=>{let r=e[Xt]?.[t]??e.de[t]??t;for(let[e,t]of Object.entries(n??{}))r=r.replace(`{${e}}`,String(t));return r},lang:()=>Xt},api:{get:e=>H.get(r(e)),post:(e,t)=>H.post(r(e),t),put:(e,t)=>H.put(r(e),t),patch:(e,t)=>H.patch(r(e),t),del:e=>H.del(r(e))},me:()=>({user:{id:M0.user.id,name:M0.user.name,email:M0.user.email},tenant:M0.tenant,mode:M0.mode}),onUnload(e){t.disposers.push(e)}}}function V0(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.src=e,r.onload=()=>{r.remove(),t()},r.onerror=()=>{r.remove(),n(Error(`The plugin's script did not load.`))},document.head.append(r)})}function H0(e,t){return new Promise(n=>{let r=document.createElement(`link`);r.rel=`stylesheet`,r.href=t,r.dataset.plugin=e,r.onload=()=>n(r),r.onerror=()=>n(r),document.head.append(r)})}function U0(e,t,n){for(let n of t)try{n()}catch(t){console.error(`[plugin ${e}]`,t)}n?.remove()}function W0(e){let t=j0.get(e);j0.delete(e),U0(e,t?.disposers??[],t?.link??null);let{[e]:n,...r}=T0.failed;D0({failed:r,pages:T0.pages.filter(t=>t.plugin!==e),nav:T0.nav.filter(t=>t.plugin!==e),sections:T0.sections.filter(t=>t.plugin!==e),spaceSections:T0.spaceSections.filter(t=>t.plugin!==e),spaceParts:T0.spaceParts.filter(t=>t.plugin!==e),shareSections:T0.shareSections.filter(t=>t.plugin!==e),shareSetups:T0.shareSetups.filter(t=>t.plugin!==e),cards:T0.cards.filter(t=>t.plugin!==e)})}async function G0(e){let{id:t}=e,n={pages:[],nav:[],sections:[],spaceSections:[],spaceParts:[],shareSections:[],shareSetups:[],cards:[],disposers:[]},r=null;try{e.styles&&(r=await H0(t,fe(e.styles))),await V0(fe(e.script));let i=globalThis,a=P0(t),o=i[a];i[a]=void 0;let s=typeof o==`function`?o:o?.default;if(typeof s!=`function`)throw Error(`The plugin's script has no default export.`);s(B0(e,n))}catch(i){console.error(`[plugin ${t}]`,i),U0(t,n.disposers,r),W0(t),j0.set(t,{key:N0(e),disposers:[],link:null}),D0({failed:{...T0.failed,[t]:i.message}});return}let i=j0.get(t);j0.set(t,{key:N0(e),disposers:n.disposers,link:r});let{[t]:a,...o}=T0.failed;D0({failed:o,pages:[...T0.pages.filter(e=>e.plugin!==t),...n.pages],nav:[...T0.nav.filter(e=>e.plugin!==t),...n.nav],sections:[...T0.sections.filter(e=>e.plugin!==t),...n.sections],spaceSections:[...T0.spaceSections.filter(e=>e.plugin!==t),...n.spaceSections],spaceParts:[...T0.spaceParts.filter(e=>e.plugin!==t),...n.spaceParts],shareSections:[...T0.shareSections.filter(e=>e.plugin!==t),...n.shareSections],shareSetups:[...T0.shareSetups.filter(e=>e.plugin!==t),...n.shareSetups],cards:[...T0.cards.filter(e=>e.plugin!==t),...n.cards]}),U0(t,i?.disposers??[],i?.link??null)}var K0=Promise.resolve();function q0(){return K0=K0.catch(()=>void 0).then(async()=>{let e=await H.get(`/api/studio/plugins`);for(let t of[...j0.keys()])e.plugins.some(e=>e.id===t&&e.script)||W0(t);D0(e);for(let t of e.plugins)t.script&&j0.get(t.id)?.key!==N0(t)&&await G0(t)}).catch(e=>console.error(`[plugins]`,e)).finally(()=>D0({status:`ready`})),K0}var J0=null;function Y0(e){M0=e,T0.status===`idle`&&(D0({status:`loading`}),q0().then(()=>{T0.canReload&&!J0&&(J0=new EventSource(fe(`/api/studio/plugins/-/events`),{withCredentials:!0}),J0.addEventListener(`change`,()=>void q0()))}))}async function X0(e){await H.post(e?`/api/studio/plugins/-/reload/${e}`:`/api/studio/plugins/-/reload`),await q0()}var Z0=class extends G.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[plugin]`,e)}render(){return this.state.failed?(0,K.jsx)(te,{children:W(`plugins.crashed`)}):this.props.children}};function Q0({of:e,children:t}){return(0,K.jsx)(`div`,{"data-plugin":e.plugin,className:`contents`,children:(0,K.jsx)(Z0,{children:t},e.serial)})}export{BV as $,Tr as $t,l$ as A,Zs as At,lH as B,Ni as Bt,m1 as C,IL as Ct,y$ as D,Lc as Dt,j$ as E,bL as Et,QX as F,$i as Ft,nH as G,yi as Gt,uH as H,Di as Ht,WX as I,Zi as It,$V as J,Gr as Jt,sH as K,Yr as Kt,UX as L,Yi as Lt,rQ as M,ea as Mt,iZ as N,na as Nt,f$ as O,Cc as Ot,rZ as P,ta as Pt,YV as Q,Dr as Qt,DH as R,qi as Rt,x1 as S,RL as St,i1 as T,PL as Tt,ZV as U,Ci as Ut,rH as V,ji as Vt,QV as W,xi as Wt,tH as X,Fr as Xt,eH as Y,zr as Yt,XV as Z,Nr as Zt,S1 as _,FL as _t,O0 as a,sr as an,tV as at,v1 as b,AL as bt,_0 as c,qn as cn,ZL as ct,g0 as d,Dn as dn,VL as dt,Cr as en,WV as et,$1 as f,Tn as fn,zL as ft,E1 as g,CL as gt,C1 as h,EL as ht,Y0 as i,lr as in,DV as it,UQ as j,Hs as jt,d$ as k,rc as kt,C0 as l,Ln as ln,XL as lt,J1 as m,TL as mt,L0 as n,yr as nn,zV as nt,S0 as o,$n as on,qB as ot,p0 as p,wL as pt,fH as q,qr as qt,X0 as r,_r as rn,AV as rt,y0 as s,Zn as sn,JB as st,Q0 as t,xr as tn,VV as tt,v0 as u,Nn as un,YL as ut,y1 as v,jL as vt,t1 as w,LL as wt,b1 as x,OL as xt,h1 as y,kL as yt,PH as z,zi as zt};