@engenty/wizards-runtime 0.14.1 → 0.15.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 (89) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +50 -3
  2. package/apps/runtime/dist/app.js +9 -2
  3. package/apps/runtime/dist/broker/call.js +2 -0
  4. package/apps/runtime/dist/broker/host.js +1 -0
  5. package/apps/runtime/dist/broker/rwx.js +38 -4
  6. package/apps/runtime/dist/db/client.js +12 -1
  7. package/apps/runtime/dist/db/migrations/tenant/0040_rwx_elements.sql +21 -0
  8. package/apps/runtime/dist/db/migrations/tenant/0041_broker_log_client.sql +1 -0
  9. package/apps/runtime/dist/db/migrations/tenant/meta/0040_snapshot.json +5153 -0
  10. package/apps/runtime/dist/db/migrations/tenant/meta/0041_snapshot.json +5160 -0
  11. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
  12. package/apps/runtime/dist/db/schema.js +2 -0
  13. package/apps/runtime/dist/docs/dev/api.md +24 -2
  14. package/apps/runtime/dist/docs/dev/architecture.md +13 -2
  15. package/apps/runtime/dist/elements/caller.js +45 -0
  16. package/apps/runtime/dist/elements/catalogue.js +14 -0
  17. package/apps/runtime/dist/elements/connections.js +60 -0
  18. package/apps/runtime/dist/elements/gate.js +81 -0
  19. package/apps/runtime/dist/elements/knowledge.js +139 -0
  20. package/apps/runtime/dist/elements/outside.js +103 -0
  21. package/apps/runtime/dist/elements/specs.js +102 -0
  22. package/apps/runtime/dist/elements/wizards.js +59 -0
  23. package/apps/runtime/dist/env.js +5 -2
  24. package/apps/runtime/dist/health.js +50 -1
  25. package/apps/runtime/dist/mcp/elements.js +88 -0
  26. package/apps/runtime/dist/mcp/handler.js +2 -0
  27. package/apps/runtime/dist/mcp/scopes.js +5 -0
  28. package/apps/runtime/dist/prompts/authoring.md +2 -2
  29. package/apps/runtime/dist/prompts/tools.md +3 -0
  30. package/apps/runtime/dist/routes/api.js +2 -2
  31. package/apps/runtime/dist/routes/elements.js +76 -0
  32. package/apps/runtime/dist/services/work-ai.js +27 -19
  33. package/apps/runtime/dist/services/work-connections.js +2 -2
  34. package/apps/runtime/dist/tools/index.js +5 -4
  35. package/apps/runtime/dist/tools/skills.js +80 -54
  36. package/apps/runtime/dist/tools/space.js +8 -152
  37. package/apps/web/dist/assets/{AboutDialog-SpDcn8VZ.js → AboutDialog-DaWEIHFN.js} +1 -1
  38. package/apps/web/dist/assets/{CapabilitiesPage-Bgnm_3dk.js → CapabilitiesPage-Dt91U_sK.js} +2 -2
  39. package/apps/web/dist/assets/{ChangelogDialog-DAnjV6cZ.js → ChangelogDialog-Do7pwmFv.js} +1 -1
  40. package/apps/web/dist/assets/{CodeEditor-nxoOt8ge.js → CodeEditor-Cdox-51M.js} +1 -1
  41. package/apps/web/dist/assets/{EditorPage-B98C-9Nv.js → EditorPage-DS_a5K3s.js} +1 -1
  42. package/apps/web/dist/assets/{FlowPreview-aMfwcPul.js → FlowPreview-BPS86xzA.js} +1 -1
  43. package/apps/web/dist/assets/{LangSwitch-DpD0inR4.js → LangSwitch-BRHbi_Sd.js} +1 -1
  44. package/apps/web/dist/assets/{Marketplace-CpzD9pNQ.js → Marketplace-CS7JTgiv.js} +2 -2
  45. package/apps/web/dist/assets/{NewWizardChannels-D8IYLg_S.js → NewWizardChannels-D-OLsex6.js} +1 -1
  46. package/apps/web/dist/assets/{NewWizardPage-DlBt0Mfq.js → NewWizardPage-BM_pkk41.js} +1 -1
  47. package/apps/web/dist/assets/{OnboardingPage-ztHT01ah.js → OnboardingPage-Cpn5pubC.js} +1 -1
  48. package/apps/web/dist/assets/{PreviewPane-DC1kAi3x.js → PreviewPane-BOk1-yO4.js} +1 -1
  49. package/apps/web/dist/assets/{PublicRunner-D6lKP0j8.js → PublicRunner-CgzMZb0r.js} +1 -1
  50. package/apps/web/dist/assets/{ReadOnly-DFsuKPCw.js → ReadOnly-8DEx-ly3.js} +1 -1
  51. package/apps/web/dist/assets/{SettingsPage-DkHeCO2c.js → SettingsPage-CcrknFcI.js} +2 -2
  52. package/apps/web/dist/assets/{SetupPage-DZ8xRkfS.js → SetupPage-D5nzjgPU.js} +1 -1
  53. package/apps/web/dist/assets/{SharePage-494ZPsjQ.js → SharePage-PKHX8a8a.js} +1 -1
  54. package/apps/web/dist/assets/{SkillEditor-CqQMg2MC.js → SkillEditor-BsXTqNli.js} +1 -1
  55. package/apps/web/dist/assets/{Skills-CnhpgoOA.js → Skills-C_X1ZsKg.js} +1 -1
  56. package/apps/web/dist/assets/{SpacePage-CWlU_BZP.js → SpacePage-wZGqUoSQ.js} +2 -2
  57. package/apps/web/dist/assets/{UpdateCheck-BKNkNJyG.js → UpdateCheck-D6x7MqEl.js} +2 -2
  58. package/apps/web/dist/assets/changelog-M-eOBqgu.js +1 -0
  59. package/apps/web/dist/assets/{circle-alert-C8Ma-bPY.js → circle-alert-DJbCyxcg.js} +1 -1
  60. package/apps/web/dist/assets/{circle-check-Bu9Z3mlJ.js → circle-check-jqtsKi_b.js} +1 -1
  61. package/apps/web/dist/assets/{code-editor-CfTGqOpp.js → code-editor-BpCEnf8H.js} +2 -2
  62. package/apps/web/dist/assets/{code-xml-B4kLFZSj.js → code-xml-q88cSTV8.js} +1 -1
  63. package/apps/web/dist/assets/{connection-sign-in-Cngd_QDO.js → connection-sign-in-UJ6xk-TD.js} +1 -1
  64. package/apps/web/dist/assets/{eye-BpoKpIdt.js → eye-CgkvVlba.js} +1 -1
  65. package/apps/web/dist/assets/{host-C0WQlRKB.js → host-Bd_bon_c.js} +7 -7
  66. package/apps/web/dist/assets/{i18n-BJ7Ld6O6.js → i18n-0fUKyVRE.js} +1 -1
  67. package/apps/web/dist/assets/{index-ClVtdDUZ.js → index-DOgwxnto.js} +3 -3
  68. package/apps/web/dist/assets/{phone-Ctvf-Am-.js → phone-CjPvZ0nk.js} +1 -1
  69. package/apps/web/dist/assets/{read-aloud-Da_RSm2S.js → read-aloud-CLXo_asN.js} +1 -1
  70. package/apps/web/dist/assets/{runners-CyIvJIHr.js → runners-BoPaPsjN.js} +1 -1
  71. package/apps/web/dist/assets/{scroll-text-ChrjRu9Y.js → scroll-text-2BhJO_W7.js} +1 -1
  72. package/apps/web/dist/assets/{session-SXPtTWRK.js → session-CpYa5hwd.js} +1 -1
  73. package/apps/web/dist/assets/{theme-BCau3f6O.js → theme-Bj3wNQR0.js} +1 -1
  74. package/apps/web/dist/assets/{ui-Uqnx1UpK.js → ui-CktezodE.js} +1 -1
  75. package/apps/web/dist/assets/{upload-BchUnQGV.js → upload-CHGCFVZK.js} +1 -1
  76. package/apps/web/dist/assets/{useMutation-DEkZhp5c.js → useMutation-7_FOHoEl.js} +1 -1
  77. package/apps/web/dist/assets/{volume-2-CU_oy81Z.js → volume-2-Bw5KASy8.js} +1 -1
  78. package/apps/web/dist/index.html +13 -13
  79. package/apps/web/dist/mcp/flow.html +1 -1
  80. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  81. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  82. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +1 -1
  83. package/node_modules/@engenty/wizards-shared/dist/rwx.js +3 -0
  84. package/package.json +1 -1
  85. package/plugin/.claude-plugin/plugin.json +1 -1
  86. package/plugin/README.md +3 -0
  87. package/plugin/plugin.json +1 -1
  88. package/plugin/skills/work-in-space/SKILL.md +16 -0
  89. package/apps/web/dist/assets/changelog-BhMZS-rs.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-SpDcn8VZ.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-Uqnx1UpK.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-BJ7Ld6O6.js","assets/logo-BpnjXTRy.js","assets/engenty-CNjaZCVM.js","assets/UpdateCheck-BKNkNJyG.js","assets/useMutation-DEkZhp5c.js","assets/react-dom-hf6EcyAr.js","assets/media-Cej-H610.js","assets/ChangelogDialog-DAnjV6cZ.js","assets/Marketplace-CpzD9pNQ.js","assets/volume-2-CU_oy81Z.js","assets/eye-BpoKpIdt.js","assets/session-SXPtTWRK.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-Uqnx1UpK.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-CpzD9pNQ.js";import{t as ot}from"./useMutation-DEkZhp5c.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-CU_oy81Z.js";import{n as pt,t as mt}from"./scroll-text-ChrjRu9Y.js";import{t as ht}from"./eye-BpoKpIdt.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-Da_RSm2S.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-SXPtTWRK.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-BJ7Ld6O6.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-BKNkNJyG.js";import{n as un,t as dn}from"./with-selector-CoMyWBAX.js";import{r as fn,t as pn}from"./LangSwitch-DpD0inR4.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(`
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
3
  .______background-clip--text {
4
4
  background-clip: text;
5
5
  -webkit-background-clip: text;
@@ -88,10 +88,10 @@ ${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(
88
88
 
89
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
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===`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: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(`
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
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-SpDcn8VZ.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}?
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
95
 
96
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
97
 
@@ -108,11 +108,11 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
108
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
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
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-CpzD9pNQ.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(`
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
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
113
 
114
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
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
116
 
117
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-DAnjV6cZ.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};
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};